Changeset 10356 in josm
- Timestamp:
- 2016-06-12T00:00:29+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AbstractSelectAction.java
r8624 r10356 20 20 putValue(NAME, tr("Select")); 21 21 putValue(SHORT_DESCRIPTION, tr("Set the selected elements on the map to the selected items in the list above.")); 22 putValue(SMALL_ICON, ImageProvider.get("dialogs", "select"));22 new ImageProvider("dialogs", "select").getResource().getImageIcon(this, true); 23 23 } 24 24 } -
trunk/src/org/openstreetmap/josm/gui/SideButton.java
r10179 r10356 18 18 import javax.swing.plaf.basic.BasicArrowButton; 19 19 20 import org.openstreetmap.josm.Main; 20 21 import org.openstreetmap.josm.tools.Destroyable; 21 22 import org.openstreetmap.josm.tools.ImageProvider; 23 import org.openstreetmap.josm.tools.ImageResource; 22 24 23 25 /** … … 26 28 */ 27 29 public class SideButton extends JButton implements Destroyable { 28 private static final int iconHeight = ImageProvider.ImageSizes.SIDEBUTTON.getImageSize();29 30 30 31 private transient PropertyChangeListener propertyChangeListener; … … 33 34 * Constructs a new {@code SideButton}. 34 35 * @param action action used to specify the new button 36 * @since 744 35 37 */ 36 38 public SideButton(Action action) { 37 39 super(action); 38 fixIcon(action); 40 ImageResource icon = (ImageResource) action.getValue("ImageResource"); 41 if (icon != null) { 42 setIcon(icon.getImageIconBounded( 43 ImageProvider.ImageSizes.SIDEBUTTON.getImageDimension())); 44 } else { /* TODO: remove when calling code is fixed */ 45 Main.warn("Old style SideButton usage for action " + action); 46 fixIcon(action); 47 } 39 48 doStyle(); 40 49 } … … 44 53 * @param action action used to specify the new button 45 54 * @param usename use action name 55 * @since 2710 46 56 */ 47 57 public SideButton(Action action, boolean usename) { … … 58 68 * @param action action used to specify the new button 59 69 * @param imagename image name in "dialogs" directory 70 * @since 2747 60 71 */ 61 72 public SideButton(Action action, String imagename) { 62 73 super(action); 63 setIcon(getScaledImage(ImageProvider.get("dialogs", imagename).getImage())); 74 ImageProvider prov = new ImageProvider("dialogs", imagename); 75 setIcon(prov.setSize(ImageProvider.ImageSizes.SIDEBUTTON).get()); 64 76 doStyle(); 65 77 } 66 78 79 @Deprecated 67 80 private void fixIcon(Action action) { 68 81 // need to listen for changes, so that putValue() that are called after the … … 79 92 action.addPropertyChangeListener(propertyChangeListener); 80 93 } 94 int iconHeight = ImageProvider.ImageSizes.SIDEBUTTON.getImageSize(); 81 95 Icon i = getIcon(); 82 96 if (i instanceof ImageIcon && i.getIconHeight() != iconHeight) { 83 setIcon(getScaledImage(((ImageIcon) i).getImage())); 97 Image im = ((ImageIcon) i).getImage(); 98 int newWidth = im.getWidth(null) * iconHeight / im.getHeight(null); 99 ImageIcon icon = new ImageIcon(im.getScaledInstance(newWidth, iconHeight, Image.SCALE_SMOOTH)); 100 setIcon(icon); 84 101 } 85 102 } 86 103 87 104 /** 88 * Scales the given image proportionally so that the height is "iconHeight" 89 * @param im original image 90 * @return scaled image 105 * Do the style settings for the side button layout 91 106 */ 92 private static ImageIcon getScaledImage(Image im) {93 int newWidth = im.getWidth(null) * iconHeight / im.getHeight(null);94 return new ImageIcon(im.getScaledInstance(newWidth, iconHeight, Image.SCALE_SMOOTH));95 }96 97 107 private void doStyle() { 98 108 setLayout(new BorderLayout()); … … 101 111 } 102 112 113 /** 114 * Create the arrow for opening a drop-down menu 115 * @param listener listener to use for button actions (e.g. pressing) 116 * @return the created button 117 * @since 9668 118 */ 103 119 public BasicArrowButton createArrow(ActionListener listener) { 104 120 setMargin(new Insets(0, 0, 0, 0)); -
trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java
r9246 r10356 376 376 putValue(NAME, tr("Select")); 377 377 putValue(SHORT_DESCRIPTION, tr("Selects the objects that take part in this command (unless currently deleted)")); 378 putValue(SMALL_ICON, ImageProvider.get("dialogs", "select"));378 new ImageProvider("dialogs", "select").getResource().getImageIcon(this, true); 379 379 } 380 380 … … 411 411 putValue(SHORT_DESCRIPTION, 412 412 tr("Selects the objects that take part in this command (unless currently deleted), then and zooms to it")); 413 putValue(SMALL_ICON, ImageProvider.get("dialogs/autoscale", "selection"));413 new ImageProvider("dialogs/autoscale", "selection").getResource().getImageIcon(this, true); 414 414 } 415 415 … … 447 447 putValue(NAME, tr("Undo")); 448 448 putValue(SHORT_DESCRIPTION, tr("Undo the selected and all later commands")); 449 putValue(SMALL_ICON, ImageProvider.get("undo"));449 new ImageProvider("undo").getResource().getImageIcon(this, true); 450 450 } else { 451 451 tree = redoTree; 452 452 putValue(NAME, tr("Redo")); 453 453 putValue(SHORT_DESCRIPTION, tr("Redo the selected and all earlier commands")); 454 putValue(SMALL_ICON, ImageProvider.get("redo"));454 new ImageProvider("redo").getResource().getImageIcon(this, true); 455 455 } 456 456 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r10332 r10356 434 434 putValue(NAME, tr("Resolve")); 435 435 putValue(SHORT_DESCRIPTION, tr("Open a merge dialog of all selected items in the list above.")); 436 putValue(SMALL_ICON, ImageProvider.get("dialogs", "conflict"));436 new ImageProvider("dialogs", "conflict").getResource().getImageIcon(this, true); 437 437 putValue("help", ht("/Dialog/ConflictList#ResolveAction")); 438 438 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java
r10250 r10356 141 141 putValue(NAME, tr("Add")); 142 142 putValue(SHORT_DESCRIPTION, tr("Add filter.")); 143 putValue(SMALL_ICON, ImageProvider.get("dialogs", "add"));143 new ImageProvider("dialogs", "add").getResource().getImageIcon(this, true); 144 144 } 145 145 … … 156 156 putValue(NAME, tr("Edit")); 157 157 putValue(SHORT_DESCRIPTION, tr("Edit filter.")); 158 putValue(SMALL_ICON, ImageProvider.get("dialogs", "edit"));158 new ImageProvider("dialogs", "edit").getResource().getImageIcon(this, true); 159 159 } 160 160 … … 174 174 putValue(NAME, tr("Delete")); 175 175 putValue(SHORT_DESCRIPTION, tr("Delete filter.")); 176 putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete"));176 new ImageProvider("dialogs", "delete").getResource().getImageIcon(this, true); 177 177 } 178 178 … … 189 189 putValue(NAME, tr("Up")); 190 190 putValue(SHORT_DESCRIPTION, tr("Move filter up.")); 191 putValue(SMALL_ICON, ImageProvider.get("dialogs", "up"));191 new ImageProvider("dialogs", "up").getResource().getImageIcon(this, true); 192 192 } 193 193 … … 205 205 putValue(NAME, tr("Down")); 206 206 putValue(SHORT_DESCRIPTION, tr("Move filter down.")); 207 putValue(SMALL_ICON, ImageProvider.get("dialogs", "down"));207 new ImageProvider("dialogs", "down").getResource().getImageIcon(this, true); 208 208 } 209 209 -
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r10332 r10356 299 299 putValue(NAME, tr("Search")); 300 300 putValue(SHORT_DESCRIPTION, tr("Search for objects")); 301 putValue(SMALL_ICON, ImageProvider.get("dialogs", "search"));301 new ImageProvider("dialogs", "search").getResource().getImageIcon(this, true); 302 302 updateEnabledState(); 303 303 } … … 361 361 putValue(NAME, tr("History")); 362 362 putValue(SHORT_DESCRIPTION, tr("Display the history of the selected objects.")); 363 putValue(SMALL_ICON, ImageProvider.get("dialogs", "history"));363 new ImageProvider("dialogs", "history").getResource().getImageIcon(this, true); 364 364 updateEnabledState(model.getSize()); 365 365 } … … 401 401 putValue(NAME, tr("Zoom to selection")); 402 402 putValue(SHORT_DESCRIPTION, tr("Zoom to selection")); 403 putValue(SMALL_ICON, ImageProvider.get("dialogs/autoscale", "selection"));403 new ImageProvider("dialogs/autoscale", "selection").getResource().getImageIcon(this, true); 404 404 updateEnabledState(); 405 405 } … … 442 442 putValue(NAME, tr("Zoom to selected element(s)")); 443 443 putValue(SHORT_DESCRIPTION, tr("Zoom to selected element(s)")); 444 putValue(SMALL_ICON, ImageProvider.get("dialogs/autoscale", "selection"));444 new ImageProvider("dialogs/autoscale", "selection").getResource().getImageIcon(this, true); 445 445 updateEnabledState(); 446 446 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
r10345 r10356 158 158 putValue(NAME, tr("Select")); 159 159 putValue(SHORT_DESCRIPTION, tr("Select objects submitted by this user")); 160 putValue(SMALL_ICON, ImageProvider.get("dialogs", "select"));160 new ImageProvider("dialogs", "select").getResource().getImageIcon(this, true); 161 161 updateEnabledState(); 162 162 } … … 193 193 putValue(NAME, tr("Show info")); 194 194 putValue(SHORT_DESCRIPTION, tr("Launches a browser with information about the user")); 195 putValue(SMALL_ICON, ImageProvider.get("help/internet"));195 new ImageProvider("help/internet").getResource().getImageIcon(this, true); 196 196 updateEnabledState(); 197 197 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java
r10345 r10356 120 120 putValue(NAME, tr("Lookup")); 121 121 putValue(SHORT_DESCRIPTION, tr("Looks up the selected primitives in the error list.")); 122 putValue(SMALL_ICON, ImageProvider.get("dialogs", "search"));122 new ImageProvider("dialogs", "search").getResource().getImageIcon(this, true); 123 123 } 124 124 … … 141 141 putValue(NAME, tr("Fix")); 142 142 putValue(SHORT_DESCRIPTION, tr("Fix the selected issue.")); 143 putValue(SMALL_ICON, ImageProvider.get("dialogs", "fix"));143 new ImageProvider("dialogs", "fix").getResource().getImageIcon(this, true); 144 144 } 145 145 @Override … … 156 156 putValue(NAME, tr("Ignore")); 157 157 putValue(SHORT_DESCRIPTION, tr("Ignore the selected issue next time.")); 158 putValue(SMALL_ICON, ImageProvider.get("dialogs", "fix"));158 new ImageProvider("dialogs", "fix").getResource().getImageIcon(this, true); 159 159 } 160 160 @Override -
trunk/src/org/openstreetmap/josm/gui/help/ContextSensitiveHelpAction.java
r7434 r10356 47 47 putValue(SHORT_DESCRIPTION, tr("Show help information")); 48 48 putValue(NAME, tr("Help")); 49 putValue(SMALL_ICON, ImageProvider.get("help"));49 new ImageProvider("help").getResource().getImageIcon(this); 50 50 this.helpTopic = helpTopic; 51 51 setEnabled(!Main.isOffline(OnlineResource.JOSM_WEBSITE)); -
trunk/src/org/openstreetmap/josm/tools/ImageResource.java
r9705 r10356 92 92 icon = getImageIconBounded(ImageProvider.ImageSizes.LARGEICON.getImageDimension()); 93 93 a.putValue(Action.LARGE_ICON_KEY, icon); 94 a.putValue("ImageResource", this); 95 } 96 97 /** 98 * Set both icons of an Action 99 * @param a The action for the icons 100 * @param addresource Adds an resource named "ImageResource" if <code>true</code> 101 * @since 10356 102 */ 103 public void getImageIcon(AbstractAction a, boolean addresource) { 104 getImageIcon(a); 105 if (addresource) { 106 a.putValue("ImageResource", this); 107 } 94 108 } 95 109
Note:
See TracChangeset
for help on using the changeset viewer.