Changeset 12419 in josm for trunk/src/org
- Timestamp:
- 2017-06-21T12:37:36+02:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/layer/LayerVisibilityAction.java
r12402 r12419 17 17 import java.util.HashMap; 18 18 import java.util.List; 19 import java.util.function.Supplier; 19 20 import java.util.stream.Collectors; 20 21 … … 93 94 addContentEntry(new GammaFilterSlider()); 94 95 addContentEntry(new SharpnessSlider()); 95 addContentEntry(new ColorSelector( ));96 addContentEntry(new ColorSelector(model::getSelectedLayers)); 96 97 } 97 98 … … 527 528 * @author Michael Zangl 528 529 */ 529 private class ColorSelector extends JPanel implements LayerVisibilityMenuEntry {530 531 private final Border NORMAL_BORDER = BorderFactory.createEmptyBorder(2, 2, 2, 2);532 private final Border SELECTED_BORDER = BorderFactory.createLineBorder(Color.BLACK, 2);530 private static class ColorSelector extends JPanel implements LayerVisibilityMenuEntry { 531 532 private static final Border NORMAL_BORDER = BorderFactory.createEmptyBorder(2, 2, 2, 2); 533 private static final Border SELECTED_BORDER = BorderFactory.createLineBorder(Color.BLACK, 2); 533 534 534 535 // TODO: Nicer color palette 535 private final Color[] COLORS = new Color[] {536 private static final Color[] COLORS = new Color[] { 536 537 Color.RED, 537 538 Color.ORANGE, … … 542 543 Color.GRAY, 543 544 }; 545 private final Supplier<List<Layer>> layerSupplier; 544 546 private final HashMap<Color, JPanel> panels = new HashMap<>(); 545 547 546 ColorSelector( ) {548 ColorSelector(Supplier<List<Layer>> layerSupplier) { 547 549 super(new GridBagLayout()); 550 this.layerSupplier = layerSupplier; 548 551 add(new JLabel(tr("Color")), GBC.eol().insets(24 + 10, 0, 0, 0)); 549 552 for (Color color : COLORS) { … … 563 566 @Override 564 567 public void mouseClicked(MouseEvent e) { 565 List<Layer> layers = model.getSelectedLayers();568 List<Layer> layers = layerSupplier.get(); 566 569 for (Layer l : layers) { 567 570 if (l instanceof GpxLayer) { … … 574 577 add(colorPanel, GBC.std().weight(1, 1).fill().insets(5)); 575 578 panels.put(color, colorPanel); 579 580 List<Color> colors = layerSupplier.get().stream().map(l -> l.getColorProperty().get()).distinct().collect(Collectors.toList()); 581 if (colors.size() == 1) { 582 highlightColor(colors.get(0)); 583 } 576 584 } 577 585 … … 585 593 setVisible(true); 586 594 highlightColor(colors.get(0)); 587 } else if (colors.size() > 0) {595 } else if (colors.size() > 1) { 588 596 setVisible(true); 589 597 highlightColor(null);
Note:
See TracChangeset
for help on using the changeset viewer.