Changeset 10191 in josm
- Timestamp:
- 2016-05-11T18:28:35+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r10179 r10191 21 21 import java.awt.event.AWTEventListener; 22 22 import java.awt.event.ActionEvent; 23 import java.awt.event.ComponentAdapter; 24 import java.awt.event.ComponentEvent; 23 25 import java.awt.event.InputEvent; 24 26 import java.awt.event.KeyAdapter; … … 197 199 tr("The length of the new way segment being drawn."), 10, PROP_BACKGROUND_COLOR.get()); 198 200 private final ImageLabel nameText = new ImageLabel("name", 199 tr("The name of the object at the mouse pointer."), 20, PROP_BACKGROUND_COLOR.get());201 tr("The name of the object at the mouse pointer."), getNameLabelCharacterCount(Main.parent), PROP_BACKGROUND_COLOR.get()); 200 202 private final JosmTextField helpText = new JosmTextField(); 201 203 private final JProgressBar progressBar = new JProgressBar(); 204 private final transient ComponentAdapter mvComponentAdapter; 202 205 public final transient BackgroundProgressMonitor progressMonitor = new BackgroundProgressMonitor(); 203 206 … … 948 951 Main.pref.addPreferenceChangeListener(this); 949 952 953 mvComponentAdapter = new ComponentAdapter() { 954 @Override 955 public void componentResized(ComponentEvent e) { 956 nameText.setCharCount(getNameLabelCharacterCount(Main.parent)); 957 revalidate(); 958 } 959 }; 960 mv.addComponentListener(mvComponentAdapter); 961 950 962 // The background thread 951 963 thread = new Thread(collector, "Map Status Collector"); … … 1078 1090 SystemOfMeasurement.removeSoMChangeListener(this); 1079 1091 Main.pref.removePreferenceChangeListener(this); 1092 mv.removeComponentListener(mvComponentAdapter); 1080 1093 1081 1094 // MapFrame gets destroyed when the last layer is removed, but the status line background … … 1117 1130 PROP_ACTIVE_FOREGROUND_COLOR.get(); 1118 1131 } 1132 1133 private static int getNameLabelCharacterCount(Component parent) { 1134 int w = parent != null ? parent.getWidth() : 800; 1135 return Math.min(80, 20 + Math.max(0, w-1280) * 60 / (1920-1280)); 1136 } 1119 1137 } -
trunk/src/org/openstreetmap/josm/gui/widgets/ImageLabel.java
r10179 r10191 20 20 private final JLabel imgLabel = new JLabel(); 21 21 private final JLabel tf = new JLabel(); 22 private finalint charCount;22 private int charCount; 23 23 24 24 /** … … 36 36 add(tf, GBC.std().fill(GBC.BOTH).anchor(GBC.WEST).insets(2, 1, 1, 0)); 37 37 setToolTipText(tooltip); 38 this.charCount = charCount;38 setCharCount(charCount); 39 39 } 40 40 … … 64 64 return new Dimension(25 + charCount*tf.getFontMetrics(tf.getFont()).charWidth('0'), super.getMinimumSize().height); 65 65 } 66 67 /** 68 * Returns the preferred char count. 69 * @return the preferred char count 70 * @since 10191 71 */ 72 public final int getCharCount() { 73 return charCount; 74 } 75 76 /** 77 * Sets the preferred char count. 78 * @param charCount the preferred char count 79 * @since 10191 80 */ 81 public final void setCharCount(int charCount) { 82 this.charCount = charCount; 83 } 66 84 }
Note:
See TracChangeset
for help on using the changeset viewer.