- Timestamp:
- 2020-01-04T20:16:33+01:00 (5 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r15592 r15632 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Color; 6 7 import java.awt.Component; 7 8 import java.awt.Dimension; 8 9 import java.awt.Font; 10 import java.awt.Graphics; 11 import java.awt.Graphics2D; 9 12 import java.awt.GraphicsEnvironment; 13 import java.awt.RenderingHints; 10 14 import java.awt.event.ActionEvent; 11 15 import java.awt.event.InputEvent; … … 17 21 import java.util.Arrays; 18 22 import java.util.List; 19 import java.util.Optional;20 23 import java.util.concurrent.CopyOnWriteArrayList; 21 24 … … 456 459 private final ImageIcon iconEyeTranslucent; 457 460 private boolean isTranslucent; 461 private Layer layer; 458 462 459 463 /** … … 461 465 */ 462 466 LayerVisibleCheckBox() { 463 iconEye = ImageProvider.get("dialogs/layerlist","eye");464 iconEyeTranslucent = ImageProvider.get("dialogs/layerlist", "eye-translucent");467 iconEye = new EyeIcon("eye"); 468 iconEyeTranslucent = new EyeIcon("eye-translucent", true); 465 469 setIcon(ImageProvider.get("dialogs/layerlist", "eye-off")); 466 setPressedIcon( ImageProvider.get("dialogs/layerlist","eye-pressed"));470 setPressedIcon(new EyeIcon("eye-pressed")); 467 471 setSelectedIcon(iconEye); 468 472 isTranslucent = false; … … 480 484 481 485 public void updateStatus(Layer layer) { 486 this.layer = layer; 482 487 boolean visible = layer.isVisible(); 483 488 setSelected(visible); … … 493 498 tr("layer is currently visible (click to hide layer)") : 494 499 tr("layer is currently hidden (click to show layer)")); 500 } 501 502 private class EyeIcon extends ImageIcon { 503 private final boolean translucent; 504 505 EyeIcon(String name) { 506 this(name, false); 507 } 508 509 EyeIcon(String name, boolean translucent) { 510 super(ImageProvider.get("dialogs/layerlist", name).getImage()); 511 this.translucent = translucent; 512 } 513 514 @Override 515 public synchronized void paintIcon(Component comp, Graphics g, int x, int y) { 516 Color c; 517 if (Config.getPref().getBoolean("dialog.layer.colorname", true) 518 && layer != null && (c = layer.getColor()) != null) { 519 if (g instanceof Graphics2D) { 520 ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 521 } 522 if (translucent) { 523 g.setColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), 125)); 524 } else { 525 g.setColor(c); 526 } 527 g.fillOval(x, y + 1, getIconWidth(), getIconHeight() - 2); 528 } 529 super.paintIcon(comp, g, x, y); 530 } 495 531 } 496 532 } … … 649 685 if (isActiveLayer(layer)) { 650 686 label.setFont(label.getFont().deriveFont(Font.BOLD)); 651 }652 if (Config.getPref().getBoolean("dialog.layer.colorname", true)) {653 label.setForeground(Optional654 .ofNullable(layer.getColor())655 .orElse(UIManager.getColor(isSelected ? "Table.selectionForeground" : "Table.foreground")));656 687 } 657 688 label.setIcon(layer.getIcon());
Note:
See TracChangeset
for help on using the changeset viewer.