Changeset 17605 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2021-03-20T15:53:51+01:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Check.java
r16276 r17605 10 10 import java.util.List; 11 11 12 import javax.swing.ImageIcon;13 12 import javax.swing.JLabel; 14 13 import javax.swing.JPanel; 15 import javax.swing.SwingConstants;16 14 17 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 18 16 import org.openstreetmap.josm.data.osm.OsmUtils; 19 17 import org.openstreetmap.josm.data.osm.Tag; 20 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader;21 18 import org.openstreetmap.josm.gui.widgets.QuadStateCheckBox; 22 19 import org.openstreetmap.josm.tools.GBC; … … 96 93 JPanel checkPanel = new JPanel(new GridBagLayout()); 97 94 checkPanel.add(check, GBC.std()); 98 JLabel label = new JLabel(locale_text, getIcon(), SwingConstants.LEFT); 95 JLabel label = new JLabel(locale_text); 96 addIcon(label); 99 97 label.addMouseListener(new MouseAdapter() { 100 98 @Override … … 129 127 } 130 128 131 /**132 * Returns the entry icon, if any.133 * @return the entry icon, or {@code null}134 * @since 15437135 */136 public ImageIcon getIcon() {137 return icon == null ? null : loadImageIcon(icon, TaggingPresetReader.getZipIcons(), (int) icon_size);138 }139 140 129 @Override 141 130 public Collection<String> getValues() { -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java
r17077 r17605 216 216 217 217 final JLabel label = new JLabel(tr("{0}:", locale_text)); 218 addIcon(label); 218 219 label.setToolTipText(getKeyTooltipText()); 219 220 label.setComponentPopupMenu(getPopupMenu()); -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Label.java
r16042 r17605 4 4 import java.util.Collection; 5 5 6 import javax.swing.Icon;7 import javax.swing.ImageIcon;8 6 import javax.swing.JLabel; 9 7 import javax.swing.JPanel; 10 8 11 9 import org.openstreetmap.josm.data.osm.OsmPrimitive; 12 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader;13 10 import org.openstreetmap.josm.tools.GBC; 14 11 … … 18 15 public class Label extends TextItem { 19 16 20 /** The location of icon file to display (optional) */21 public String icon; // NOSONAR22 /** The size of displayed icon. If not set, default is 16px */23 public short icon_size = 16; // NOSONAR24 25 17 @Override 26 18 public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) { 27 19 initializeLocaleText(null); 28 addLabel(p, getIcon(), locale_text); 20 JLabel label = new JLabel(locale_text); 21 addIcon(label); 22 p.add(label, GBC.eol().fill(GBC.HORIZONTAL)); 29 23 return true; 30 24 } 31 25 32 /**33 * Adds a new {@code JLabel} to the given panel.34 * @param p The panel35 * @param icon the icon (optional, can be null)36 * @param label The text label37 */38 public static void addLabel(JPanel p, Icon icon, String label) {39 p.add(new JLabel(label, icon, JLabel.LEADING), GBC.eol().fill(GBC.HORIZONTAL));40 }41 42 /**43 * Returns the label icon, if any.44 * @return the label icon, or {@code null}45 */46 public ImageIcon getIcon() {47 return icon == null ? null : loadImageIcon(icon, TaggingPresetReader.getZipIcons(), (int) icon_size);48 }49 26 } -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Link.java
r15423 r17605 44 44 final String url = getUrl(); 45 45 if (wiki != null) { 46 returnnew UrlLabel(url, locale_text, 2) {46 UrlLabel urlLabel = new UrlLabel(url, locale_text, 2) { 47 47 @Override 48 48 public void mouseClicked(MouseEvent e) { … … 57 57 } 58 58 }; 59 addIcon(urlLabel); 60 return urlLabel; 59 61 } else if (href != null || locale_href != null) { 60 return new UrlLabel(url, locale_text, 2); 62 UrlLabel urlLabel = new UrlLabel(url, locale_text, 2); 63 addIcon(urlLabel); 64 return urlLabel; 61 65 } 62 66 return null; -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Text.java
r16643 r17605 164 164 value = pnl; 165 165 } 166 final JLabel label = new JLabel(locale_text + ':'); 166 final JLabel label = new JLabel(tr("{0}:", locale_text)); 167 addIcon(label); 167 168 label.setToolTipText(getKeyTooltipText()); 168 169 label.setComponentPopupMenu(getPopupMenu()); -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/TextItem.java
r9665 r17605 6 6 import org.openstreetmap.josm.data.osm.Tag; 7 7 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem; 8 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader; 9 10 import javax.swing.ImageIcon; 11 import javax.swing.JLabel; 12 import javax.swing.SwingConstants; 8 13 9 14 /** … … 21 26 /** The localized version of {@link #text} */ 22 27 public String locale_text; // NOSONAR 28 29 /** The location of icon file to display */ 30 public String icon; // NOSONAR 31 /** The size of displayed icon. If not set, default is 16px */ 32 public short icon_size = 16; // NOSONAR 33 23 34 24 35 protected final void initializeLocaleText(String defaultText) { … … 39 50 } 40 51 52 /** 53 * Defines the label icon from this entry's icon 54 * @param label the component 55 * @since 17605 56 */ 57 protected void addIcon(JLabel label) { 58 label.setIcon(getIcon()); 59 label.setHorizontalAlignment(SwingConstants.LEADING); 60 } 61 62 /** 63 * Returns the entry icon, if any. 64 * @return the entry icon, or {@code null} 65 * @since 17605 66 */ 67 public ImageIcon getIcon() { 68 return icon == null ? null : loadImageIcon(icon, TaggingPresetReader.getZipIcons(), (int) icon_size); 69 } 70 41 71 @Override 42 72 public String toString() { -
trunk/src/org/openstreetmap/josm/gui/widgets/UrlLabel.java
r17299 r17605 60 60 61 61 /** 62 * Constructs a new {@code UrlLabel} for the given URL, description and font increase.62 * Constructs a new {@code UrlLabel} for the given URL, description and image. 63 63 * @param url The URL to use 64 64 * @param description The description to display
Note:
See TracChangeset
for help on using the changeset viewer.