Ticket #18389: 18389-2.patch
| File 18389-2.patch, 3.2 KB (added by , 6 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
3 3 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; 12 16 import java.awt.event.KeyEvent; … … 16 20 import java.util.ArrayList; 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 22 25 import javax.swing.AbstractAction; … … 455 458 private final ImageIcon iconEye; 456 459 private final ImageIcon iconEyeTranslucent; 457 460 private boolean isTranslucent; 461 private Layer layer; 458 462 459 463 /** 460 464 * Constructs a new {@code LayerVisibleCheckBox}. … … 466 470 setPressedIcon(ImageProvider.get("dialogs/layerlist", "eye-pressed")); 467 471 setSelectedIcon(iconEye); 468 472 isTranslucent = false; 473 setBackground(new Color(0, 0, 0, 0)); 469 474 } 470 475 471 476 public void setTranslucent(boolean isTranslucent) { … … 479 484 } 480 485 481 486 public void updateStatus(Layer layer) { 487 this.layer = layer; 482 488 boolean visible = layer.isVisible(); 483 489 setSelected(visible); 484 490 if (displayLayerNumbers()) { … … 493 499 tr("layer is currently visible (click to hide layer)") : 494 500 tr("layer is currently hidden (click to show layer)")); 495 501 } 502 503 @Override 504 protected void paintComponent(Graphics g) { 505 if (Config.getPref().getBoolean("dialog.layer.colorname", true) 506 && layer != null && layer.getColor() != null) { 507 if (g instanceof Graphics2D) { 508 Graphics2D g2d = (Graphics2D) g; 509 g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 510 RenderingHints.VALUE_ANTIALIAS_ON); 511 } 512 g.setColor(layer.getColor()); 513 g.fillRoundRect(0, 0, getHeight() + 7, getHeight(), 20, 20); 514 } 515 super.paintComponent(g); 516 } 496 517 } 497 518 498 519 private static class NativeScaleLayerCheckBox extends JCheckBox { … … 649 670 if (isActiveLayer(layer)) { 650 671 label.setFont(label.getFont().deriveFont(Font.BOLD)); 651 672 } 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 }657 673 label.setIcon(layer.getIcon()); 658 674 label.setToolTipText(layer.getToolTipText()); 659 675 return label;
