| 1 | ### Eclipse Workspace Patch 1.0
|
|---|
| 2 | #P JMapViewer
|
|---|
| 3 | Index: src/org/openstreetmap/gui/jmapviewer/checkBoxTree/CheckBoxNodeRenderer.java
|
|---|
| 4 | ===================================================================
|
|---|
| 5 | --- src/org/openstreetmap/gui/jmapviewer/checkBoxTree/CheckBoxNodeRenderer.java (revision 36494)
|
|---|
| 6 | +++ src/org/openstreetmap/gui/jmapviewer/checkBoxTree/CheckBoxNodeRenderer.java (working copy)
|
|---|
| 7 | @@ -33,9 +33,14 @@
|
|---|
| 8 | final Font fontValue = UIManager.getFont("Tree.font");
|
|---|
| 9 | if (fontValue != null) panel.getLabel().setFont(fontValue);
|
|---|
| 10 |
|
|---|
| 11 | +
|
|---|
| 12 | + /*
|
|---|
| 13 | final Boolean focusPainted =
|
|---|
| 14 | (Boolean) UIManager.get("Tree.drawsFocusBorderAroundIcon");
|
|---|
| 15 | panel.check.setFocusPainted(focusPainted != null && focusPainted);
|
|---|
| 16 | + */
|
|---|
| 17 | + // Compact check for Focus Border
|
|---|
| 18 | + panel.check.setFocusPainted(Boolean.TRUE.equals(UIManager.get("Tree.drawsFocusBorderAroundIcon")));
|
|---|
| 19 |
|
|---|
| 20 | selectionForeground = UIManager.getColor("Tree.selectionForeground");
|
|---|
| 21 | selectionBackground = UIManager.getColor("Tree.selectionBackground");
|
|---|
| 22 | @@ -69,11 +74,20 @@
|
|---|
| 23 | //final String stringValue =
|
|---|
| 24 | // tree.convertValueToText(value, selected, expanded, leaf, row, false);
|
|---|
| 25 | //panel.label.setText(stringValue);
|
|---|
| 26 | +
|
|---|
| 27 | + // Order adjusted: Fallback to DefaultRenderer inserted further up the list if no CheckBox data is available.
|
|---|
| 28 | + if (data == null) {
|
|---|
| 29 | + // not a check box node; return default cell renderer
|
|---|
| 30 | + return defaultRenderer.getTreeCellRendererComponent(tree, value,
|
|---|
| 31 | + selected, expanded, leaf, row, hasFocus);
|
|---|
| 32 | + }
|
|---|
| 33 |
|
|---|
| 34 | + //
|
|---|
| 35 | panel.setSelected(Boolean.FALSE);
|
|---|
| 36 |
|
|---|
| 37 | panel.setEnabled(tree.isEnabled());
|
|---|
| 38 |
|
|---|
| 39 | + /*
|
|---|
| 40 | if (selected) {
|
|---|
| 41 | panel.setForeground(selectionForeground);
|
|---|
| 42 | panel.setBackground(selectionBackground);
|
|---|
| 43 | @@ -85,12 +99,17 @@
|
|---|
| 44 | panel.getLabel().setForeground(textForeground);
|
|---|
| 45 | panel.getLabel().setBackground(textBackground);
|
|---|
| 46 | }
|
|---|
| 47 | + */
|
|---|
| 48 | + // Centralized color management for improved readability.
|
|---|
| 49 | + updateColors(selected);
|
|---|
| 50 |
|
|---|
| 51 | + /*
|
|---|
| 52 | if (data == null) {
|
|---|
| 53 | // not a check box node; return default cell renderer
|
|---|
| 54 | return defaultRenderer.getTreeCellRendererComponent(tree, value,
|
|---|
| 55 | selected, expanded, leaf, row, hasFocus);
|
|---|
| 56 | }
|
|---|
| 57 | + */
|
|---|
| 58 |
|
|---|
| 59 | //panel.label.setText(data.getText());
|
|---|
| 60 | panel.setData(data);
|
|---|
| 61 | @@ -98,6 +117,17 @@
|
|---|
| 62 |
|
|---|
| 63 | return panel;
|
|---|
| 64 | }
|
|---|
| 65 | +
|
|---|
| 66 | + private void updateColors(boolean selected) {
|
|---|
| 67 | + Color fg = selected ? selectionForeground : textForeground;
|
|---|
| 68 | + Color bg = selected ? selectionBackground : textBackground;
|
|---|
| 69 | +
|
|---|
| 70 | + panel.setForeground(fg);
|
|---|
| 71 | + panel.setBackground(bg);
|
|---|
| 72 | + panel.getLabel().setForeground(fg);
|
|---|
| 73 | + panel.getLabel().setBackground(bg);
|
|---|
| 74 | + }
|
|---|
| 75 | +
|
|---|
| 76 | /*
|
|---|
| 77 | private JPopupMenu createPopupMenu(final AbstractLayer layer) {
|
|---|
| 78 | JMenuItem menuItem;
|
|---|