Changeset 9346 in josm
- Timestamp:
- 2016-01-09T11:52:36+01:00 (9 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r9317 r9346 34 34 import java.util.ConcurrentModificationException; 35 35 import java.util.List; 36 import java.util.Objects; 36 37 import java.util.TreeSet; 37 38 import java.util.concurrent.BlockingQueue; … … 182 183 } 183 184 185 /** The {@link CoordinateFormat} set in the previous update */ 186 private transient CoordinateFormat previousCoordinateFormat = null; 184 187 private final ImageLabel latText = new ImageLabel("lat", 185 tr("The geographic latitude at the mouse pointer."), 11, PROP_BACKGROUND_COLOR.get());188 null, 11, PROP_BACKGROUND_COLOR.get()); 186 189 private final ImageLabel lonText = new ImageLabel("lon", 187 tr("The geographic longitude at the mouse pointer."), 11, PROP_BACKGROUND_COLOR.get());190 null, 11, PROP_BACKGROUND_COLOR.get()); 188 191 private final ImageLabel headingText = new ImageLabel("heading", 189 192 tr("The (compass) heading of the line segment being drawn."), … … 871 874 latText.setText(p.latToString(mCord)); 872 875 lonText.setText(p.lonToString(mCord)); 876 if (Objects.equals(previousCoordinateFormat, mCord)) { 877 // do nothing 878 } else if (CoordinateFormat.EAST_NORTH.equals(mCord)) { 879 latText.setIcon("northing"); 880 lonText.setIcon("easting"); 881 latText.setToolTipText(tr("The northing at the mouse pointer.")); 882 lonText.setToolTipText(tr("The easting at the mouse pointer.")); 883 previousCoordinateFormat = mCord; 884 } else { 885 latText.setIcon("lat"); 886 lonText.setIcon("lon"); 887 latText.setToolTipText(tr("The geographic latitude at the mouse pointer.")); 888 lonText.setToolTipText(tr("The geographic longitude at the mouse pointer.")); 889 previousCoordinateFormat = mCord; 890 } 873 891 } 874 892 } -
trunk/src/org/openstreetmap/josm/gui/widgets/ImageLabel.java
r9078 r9346 6 6 import java.awt.GridBagLayout; 7 7 8 import javax.swing.Icon; 8 9 import javax.swing.JLabel; 9 10 import javax.swing.JPanel; … … 18 19 */ 19 20 public class ImageLabel extends JPanel { 21 private final JLabel imgLabel; 20 22 private final JLabel tf; 21 23 private final int charCount; … … 23 25 /** 24 26 * Constructs a new {@code ImageLabel}. 25 * @param img Image name (without .pngextension) to find in {@code statusline} directory27 * @param img Image name (without extension) to find in {@code statusline} directory 26 28 * @param tooltip Tooltip text to display 27 29 * @param charCount Character count used to compute min/preferred size … … 31 33 setLayout(new GridBagLayout()); 32 34 setBackground(background); 33 add(new JLabel(ImageProvider.get("statusline/"+img+".png")), GBC.std().anchor(GBC.WEST).insets(0, 1, 1, 0)); 35 add(imgLabel = new JLabel(), GBC.std().anchor(GBC.WEST).insets(0, 1, 1, 0)); 36 setIcon(img); 34 37 add(tf = new JLabel(), GBC.std().fill(GBC.BOTH).anchor(GBC.WEST).insets(2, 1, 1, 0)); 35 38 setToolTipText(tooltip); … … 45 48 } 46 49 50 /** 51 * Sets the image to display. 52 * @param img Image name (without extension) to find in {@code statusline} directory 53 */ 54 public void setIcon(String img) { 55 imgLabel.setIcon(ImageProvider.get("statusline/" + img)); 56 } 57 47 58 @Override 48 59 public Dimension getPreferredSize() {
Note:
See TracChangeset
for help on using the changeset viewer.