Changeset 10428 in josm for trunk/src/org
- Timestamp:
- 2016-06-19T18:28:26+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AboutAction.java
r10375 r10428 103 103 JPanel panel = new JPanel(new GridBagLayout()); 104 104 panel.setPreferredSize(new Dimension(890, 300)); 105 panel.add(new JLabel("", new ImageProvider("logo.svg").setSize(ImageProvider.ImageSizes.ABOUT_LOGO).get(),105 panel.add(new JLabel("", ImageProvider.get("logo.svg", ImageProvider.ImageSizes.ABOUT_LOGO), 106 106 JLabel.CENTER), GBC.std().insets(0, 5, 0, 0)); 107 107 panel.add(about, GBC.std().fill()); -
trunk/src/org/openstreetmap/josm/actions/JosmAction.java
r10409 r10428 73 73 super(name); 74 74 if (icon != null) 75 icon.getResource().attachImageIcon(this );75 icon.getResource().attachImageIcon(this, true); 76 76 setHelpId(); 77 77 sc = shortcut; -
trunk/src/org/openstreetmap/josm/actions/UploadNotesAction.java
r10318 r10428 26 26 putValue(SHORT_DESCRIPTION, tr("Upload note changes to server")); 27 27 putValue(NAME, tr("Upload notes")); 28 putValue(SMALL_ICON, ImageProvider.get("upload"));28 new ImageProvider("upload").getResource().attachImageIcon(this, true); 29 29 } 30 30 -
trunk/src/org/openstreetmap/josm/actions/mapmode/AddNoteAction.java
r9989 r10428 70 70 71 71 NoteInputDialog dialog = new NoteInputDialog(Main.parent, tr("Create new note"), tr("Create note")); 72 dialog.showNoteDialog(tr("Enter a detailed comment to create a note"), NotesDialog.ICON_NEW);72 dialog.showNoteDialog(tr("Enter a detailed comment to create a note"), ImageProvider.get("dialogs/notes", "note_new")); 73 73 74 74 if (dialog.getValue() != 1) { -
trunk/src/org/openstreetmap/josm/actions/relation/DeleteRelationsAction.java
r10413 r10428 24 24 putValue(SHORT_DESCRIPTION, tr("Delete the selected relation")); 25 25 putValue(NAME, tr("Delete")); 26 putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete"));26 new ImageProvider("dialogs", "delete").getResource().attachImageIcon(this, true); 27 27 } 28 28 -
trunk/src/org/openstreetmap/josm/actions/relation/DuplicateRelationAction.java
r10413 r10428 22 22 public DuplicateRelationAction() { 23 23 putValue(SHORT_DESCRIPTION, tr("Create a copy of this relation and open it in another editor window")); 24 putValue(SMALL_ICON, ImageProvider.get("duplicate"));24 new ImageProvider("duplicate").getResource().attachImageIcon(this, true); 25 25 putValue(NAME, tr("Duplicate")); 26 26 } -
trunk/src/org/openstreetmap/josm/actions/relation/EditRelationAction.java
r10413 r10428 32 32 putValue(NAME, tr("Edit")); 33 33 putValue(SHORT_DESCRIPTION, tr("Call relation editor for selected relation")); 34 putValue(SMALL_ICON, ImageProvider.get("dialogs", "edit"));34 new ImageProvider("dialogs", "edit").getResource().attachImageIcon(this, true); 35 35 } 36 36 -
trunk/src/org/openstreetmap/josm/actions/relation/SelectRelationAction.java
r10413 r10428 26 26 putValue(SHORT_DESCRIPTION, add ? tr("Add the selected relations to the current selection") : 27 27 tr("Set the current selection to the list of selected relations")); 28 putValue(SMALL_ICON, ImageProvider.get("dialogs", "select"));28 new ImageProvider("dialogs", "select").getResource().attachImageIcon(this, true); 29 29 putValue(NAME, add ? tr("Select relation (add)") : tr("Select relation")); 30 30 this.add = add; -
trunk/src/org/openstreetmap/josm/gui/SideButton.java
r10378 r10428 56 56 */ 57 57 public SideButton(Action action, boolean usename) { 58 super(action);58 this(action); 59 59 if (!usename) { 60 60 setText(null); 61 fixIcon(action);62 doStyle();63 61 } 64 62 } … … 72 70 public SideButton(Action action, String imagename) { 73 71 super(action); 74 ImageProvider prov = new ImageProvider("dialogs", imagename); 75 setIcon(prov.setSize(ImageProvider.ImageSizes.SIDEBUTTON).get()); 72 setIcon(ImageProvider.get("dialogs", imagename, ImageProvider.ImageSizes.SIDEBUTTON)); 76 73 doStyle(); 77 74 } -
trunk/src/org/openstreetmap/josm/gui/SplashScreen.java
r10358 r10428 68 68 69 69 // Add the logo 70 JLabel logo = new JLabel( new ImageProvider("logo.svg").setSize(ImageProvider.ImageSizes.SPLASH_LOGO).get());70 JLabel logo = new JLabel(ImageProvider.get("logo.svg", ImageProvider.ImageSizes.SPLASH_LOGO)); 71 71 GridBagConstraints gbc = new GridBagConstraints(); 72 72 gbc.gridheight = 2; -
trunk/src/org/openstreetmap/josm/gui/dialogs/ChangesetDialog.java
r10413 r10428 298 298 putValue(NAME, tr("Select")); 299 299 putValue(SHORT_DESCRIPTION, tr("Select all objects assigned to the currently selected changesets")); 300 putValue(SMALL_ICON, ImageProvider.get("dialogs", "select"));300 new ImageProvider("dialogs", "select").getResource().attachImageIcon(this, true); 301 301 updateEnabledState(); 302 302 } … … 351 351 putValue(NAME, tr("Download")); 352 352 putValue(SHORT_DESCRIPTION, tr("Download information about the selected changesets from the OSM server")); 353 putValue(SMALL_ICON, ImageProvider.get("download"));353 new ImageProvider("download").getResource().attachImageIcon(this, true); 354 354 updateEnabledState(); 355 355 } … … 388 388 putValue(NAME, tr("Close open changesets")); 389 389 putValue(SHORT_DESCRIPTION, tr("Closes the selected open changesets")); 390 putValue(SMALL_ICON, ImageProvider.get("closechangeset"));390 new ImageProvider("closechangeset").getResource().attachImageIcon(this, true); 391 391 updateEnabledState(); 392 392 } … … 423 423 putValue(NAME, tr("Show info")); 424 424 putValue(SHORT_DESCRIPTION, tr("Open a web page for each selected changeset")); 425 putValue(SMALL_ICON, ImageProvider.get("help/internet"));425 new ImageProvider("help/internet").getResource().attachImageIcon(this, true); 426 426 updateEnabledState(); 427 427 } … … 463 463 putValue(NAME, tr("Details")); 464 464 putValue(SHORT_DESCRIPTION, tr("Opens the Changeset Manager window for the selected changesets")); 465 putValue(SMALL_ICON, ImageProvider.get("dialogs/changeset", "changesetmanager"));465 new ImageProvider("dialogs/changeset", "changesetmanager").getResource().attachImageIcon(this, true); 466 466 } 467 467 -
trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java
r10300 r10428 342 342 putValue(NAME, tr("On/Off")); 343 343 putValue(SHORT_DESCRIPTION, tr("Turn selected styles on or off")); 344 putValue(SMALL_ICON, ImageProvider.get("apply"));344 new ImageProvider("apply").getResource().attachImageIcon(this); 345 345 updateEnabledState(); 346 346 } … … 380 380 increment = isDown ? 1 : -1; 381 381 putValue(NAME, isDown ? tr("Down") : tr("Up")); 382 putValue(SMALL_ICON, isDown ? ImageProvider.get("dialogs", "down") : ImageProvider.get("dialogs", "up"));382 new ImageProvider("dialogs", isDown ? "down" : "up").getResource().attachImageIcon(this, true); 383 383 putValue(SHORT_DESCRIPTION, isDown ? tr("Move the selected entry one row down.") : tr("Move the selected entry one row up.")); 384 384 updateEnabledState(); … … 415 415 putValue(NAME, tr("Reload from file")); 416 416 putValue(SHORT_DESCRIPTION, tr("reload selected styles from file")); 417 putValue(SMALL_ICON, ImageProvider.get("dialogs", "refresh"));417 new ImageProvider("dialogs", "refresh").getResource().attachImageIcon(this); 418 418 setEnabled(getEnabledState()); 419 419 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java
r10395 r10428 6 6 import java.awt.BorderLayout; 7 7 import java.awt.Component; 8 import java.awt.Image;9 8 import java.awt.event.ActionEvent; 10 9 import java.awt.event.MouseAdapter; … … 56 55 */ 57 56 public class NotesDialog extends ToggleDialog implements LayerChangeListener { 58 59 /** Small icon size for use in graphics calculations */60 public static final int ICON_SMALL_SIZE = 16;61 /** 24x24 icon for unresolved notes */62 public static final ImageIcon ICON_OPEN = ImageProvider.get("dialogs/notes", "note_open");63 /** 16x16 icon for unresolved notes */64 public static final ImageIcon ICON_OPEN_SMALL =65 new ImageIcon(ICON_OPEN.getImage().getScaledInstance(ICON_SMALL_SIZE, ICON_SMALL_SIZE, Image.SCALE_SMOOTH));66 /** 24x24 icon for resolved notes */67 public static final ImageIcon ICON_CLOSED = ImageProvider.get("dialogs/notes", "note_closed");68 /** 16x16 icon for resolved notes */69 public static final ImageIcon ICON_CLOSED_SMALL =70 new ImageIcon(ICON_CLOSED.getImage().getScaledInstance(ICON_SMALL_SIZE, ICON_SMALL_SIZE, Image.SCALE_SMOOTH));71 /** 24x24 icon for new notes */72 public static final ImageIcon ICON_NEW = ImageProvider.get("dialogs/notes", "note_new");73 /** 16x16 icon for new notes */74 public static final ImageIcon ICON_NEW_SMALL =75 new ImageIcon(ICON_NEW.getImage().getScaledInstance(ICON_SMALL_SIZE, ICON_SMALL_SIZE, Image.SCALE_SMOOTH));76 /** Icon for note comments */77 public static final ImageIcon ICON_COMMENT = ImageProvider.get("dialogs/notes", "note_comment");78 57 79 58 private NoteTableModel model; … … 257 236 ImageIcon icon; 258 237 if (note.getId() < 0) { 259 icon = I CON_NEW_SMALL;238 icon = ImageProvider.get("dialogs/notes", "note_new", ImageProvider.ImageSizes.SMALLICON); 260 239 } else if (note.getState() == State.CLOSED) { 261 icon = I CON_CLOSED_SMALL;240 icon = ImageProvider.get("dialogs/notes", "note_closed", ImageProvider.ImageSizes.SMALLICON); 262 241 } else { 263 icon = I CON_OPEN_SMALL;242 icon = ImageProvider.get("dialogs/notes", "note_open", ImageProvider.ImageSizes.SMALLICON); 264 243 } 265 244 jlabel.setIcon(icon); … … 313 292 putValue(SHORT_DESCRIPTION, tr("Add comment")); 314 293 putValue(NAME, tr("Comment")); 315 putValue(SMALL_ICON, ICON_COMMENT);294 new ImageProvider("dialogs/notes", "note_comment").getResource().attachImageIcon(this, true); 316 295 } 317 296 … … 327 306 } 328 307 NoteInputDialog dialog = new NoteInputDialog(Main.parent, tr("Comment on note"), tr("Add comment")); 329 dialog.showNoteDialog(tr("Add comment to note:"), NotesDialog.ICON_COMMENT);308 dialog.showNoteDialog(tr("Add comment to note:"), ImageProvider.get("dialogs/notes", "note_comment")); 330 309 if (dialog.getValue() != 1) { 331 310 return; … … 345 324 putValue(SHORT_DESCRIPTION, tr("Close note")); 346 325 putValue(NAME, tr("Close")); 347 putValue(SMALL_ICON, ICON_CLOSED);326 new ImageProvider("dialogs/notes", "note_closed").getResource().attachImageIcon(this, true); 348 327 } 349 328 … … 351 330 public void actionPerformed(ActionEvent e) { 352 331 NoteInputDialog dialog = new NoteInputDialog(Main.parent, tr("Close note"), tr("Close note")); 353 dialog.showNoteDialog(tr("Close note with message:"), NotesDialog.ICON_CLOSED);332 dialog.showNoteDialog(tr("Close note with message:"), ImageProvider.get("dialogs/notes", "note_closed")); 354 333 if (dialog.getValue() != 1) { 355 334 return; … … 370 349 putValue(SHORT_DESCRIPTION, tr("Create a new note")); 371 350 putValue(NAME, tr("Create")); 372 putValue(SMALL_ICON, ICON_NEW);351 new ImageProvider("dialogs/notes", "note_new").getResource().attachImageIcon(this, true); 373 352 } 374 353 … … 390 369 putValue(SHORT_DESCRIPTION, tr("Reopen note")); 391 370 putValue(NAME, tr("Reopen")); 392 putValue(SMALL_ICON, ICON_OPEN);371 new ImageProvider("dialogs/notes", "note_open").getResource().attachImageIcon(this, true); 393 372 } 394 373 … … 396 375 public void actionPerformed(ActionEvent e) { 397 376 NoteInputDialog dialog = new NoteInputDialog(Main.parent, tr("Reopen note"), tr("Reopen note")); 398 dialog.showNoteDialog(tr("Reopen note with message:"), NotesDialog.ICON_OPEN);377 dialog.showNoteDialog(tr("Reopen note with message:"), ImageProvider.get("dialogs/notes", "note_open")); 399 378 if (dialog.getValue() != 1) { 400 379 return; … … 416 395 putValue(SHORT_DESCRIPTION, tr("Sort notes")); 417 396 putValue(NAME, tr("Sort")); 418 putValue(SMALL_ICON, ImageProvider.get("dialogs", "sort"));397 new ImageProvider("dialogs", "sort").getResource().attachImageIcon(this, true); 419 398 } 420 399 -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r10413 r10428 357 357 putValue(SHORT_DESCRIPTION, tr("Create a new relation")); 358 358 putValue(NAME, tr("New")); 359 putValue(SMALL_ICON, ImageProvider.get("dialogs", "addrelation"));359 new ImageProvider("dialogs", "addrelation").getResource().attachImageIcon(this, true); 360 360 updateEnabledState(); 361 361 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r10384 r10428 507 507 508 508 // scale down the dialog icon 509 ImageIcon icon = new ImageProvider("dialogs", iconName).setSize(ImageProvider.ImageSizes.SMALLICON).get();509 ImageIcon icon = ImageProvider.get("dialogs", iconName, ImageProvider.ImageSizes.SMALLICON); 510 510 lblTitle = new JLabel("", icon, JLabel.TRAILING); 511 511 lblTitle.setIconTextGap(8); … … 545 545 // show the pref button if applicable 546 546 if (preferenceClass != null) { 547 JButton pref = new JButton( new ImageProvider("preference").setSize(ImageProvider.ImageSizes.SMALLICON).get());547 JButton pref = new JButton(ImageProvider.get("preference", ImageProvider.ImageSizes.SMALLICON)); 548 548 pref.setToolTipText(tr("Open preferences for this panel")); 549 549 pref.setBorder(BorderFactory.createEmptyBorder()); -
trunk/src/org/openstreetmap/josm/gui/dialogs/layer/ActivateLayerAction.java
r10345 r10428 51 51 this.model = model; 52 52 putValue(NAME, tr("Activate")); 53 putValue(SMALL_ICON, ImageProvider.get("dialogs", "activate"));53 new ImageProvider("dialogs", "activate").getResource().attachImageIcon(this, true); 54 54 putValue(SHORT_DESCRIPTION, tr("Activate the selected layer")); 55 55 multikeyShortcut = Shortcut.registerShortcut("core_multikey:activateLayer", tr("Multikey: {0}", -
trunk/src/org/openstreetmap/josm/gui/dialogs/layer/DeleteLayerAction.java
r10144 r10428 31 31 public DeleteLayerAction(LayerListModel model) { 32 32 this.model = model; 33 putValue(SMALL_ICON, ImageProvider.get("dialogs", "delete"));33 new ImageProvider("dialogs", "delete").getResource().attachImageIcon(this, true); 34 34 putValue(SHORT_DESCRIPTION, tr("Delete the selected layers.")); 35 35 putValue(NAME, tr("Delete")); -
trunk/src/org/openstreetmap/josm/gui/dialogs/layer/LayerVisibilityAction.java
r10306 r10428 63 63 content.setLayout(new GridBagLayout()); 64 64 65 putValue(SMALL_ICON, ImageProvider.get("dialogs/layerlist", "visibility"));65 new ImageProvider("dialogs/layerlist", "visibility").getResource().attachImageIcon(this, true); 66 66 putValue(SHORT_DESCRIPTION, tr("Change visibility of the selected layer.")); 67 67 -
trunk/src/org/openstreetmap/josm/gui/dialogs/layer/MergeAction.java
r10378 r10428 60 60 this.model = model; 61 61 putValue(NAME, tr("Merge")); 62 putValue(SMALL_ICON, ImageProvider.get("dialogs", "mergedown"));62 new ImageProvider("dialogs", "mergedown").getResource().attachImageIcon(this, true); 63 63 putValue(SHORT_DESCRIPTION, tr("Merge this layer into another layer")); 64 64 putValue("help", HelpUtil.ht("/Dialog/LayerList#MergeLayer")); -
trunk/src/org/openstreetmap/josm/gui/dialogs/layer/MoveDownAction.java
r10144 r10428 24 24 this.model = model; 25 25 putValue(NAME, tr("Move down")); 26 putValue(SMALL_ICON, ImageProvider.get("dialogs", "down"));26 new ImageProvider("dialogs", "down").getResource().attachImageIcon(this, true); 27 27 putValue(SHORT_DESCRIPTION, tr("Move the selected layer one row down.")); 28 28 updateEnabledState(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/layer/MoveUpAction.java
r10378 r10428 24 24 this.model = model; 25 25 putValue(NAME, tr("Move up")); 26 putValue(SMALL_ICON, ImageProvider.get("dialogs", "up"));26 new ImageProvider("dialogs", "up").getResource().attachImageIcon(this, true); 27 27 putValue(SHORT_DESCRIPTION, tr("Move the selected layer one row up.")); 28 28 updateEnabledState(); -
trunk/src/org/openstreetmap/josm/gui/io/RecentlyOpenedFilesMenu.java
r10173 r10428 33 33 super(tr("Open Recent")); 34 34 setToolTipText(tr("List of recently opened files")); 35 setIcon( new ImageProvider("openrecent").setSize(ImageProvider.ImageSizes.MENU).get());35 setIcon(ImageProvider.get("openrecent", ImageProvider.ImageSizes.MENU)); 36 36 putClientProperty("help", ht("/Action/OpenRecent")); 37 37 -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java
r10420 r10428 384 384 private final transient Image save = ImageProvider.get("save").getImage(); 385 385 private final transient Image upld = ImageProvider.get("upload").getImage(); 386 private final transient Image saveDis = new BufferedImage(ICON_SIZE, ICON_SIZE, BufferedImage.TYPE_4BYTE_ABGR);387 private final transient Image upldDis = new BufferedImage(ICON_SIZE, ICON_SIZE, BufferedImage.TYPE_4BYTE_ABGR);386 private final transient Image saveDis = new ImageProvider("save").setDisabled(true).get().getImage(); 387 private final transient Image upldDis = new ImageProvider("upload").setDisabled(true).get().getImage(); 388 388 389 389 SaveAndProceedAction() { 390 // get disabled versions of icons391 new JLabel(ImageProvider.get("save")).getDisabledIcon().paintIcon(new JPanel(), saveDis.getGraphics(), 0, 0);392 new JLabel(ImageProvider.get("upload")).getDisabledIcon().paintIcon(new JPanel(), upldDis.getGraphics(), 0, 0);393 390 initForSaveAndExit(); 394 391 } -
trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java
r10308 r10428 37 37 import org.openstreetmap.josm.gui.io.UploadNoteLayerTask; 38 38 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 39 import org.openstreetmap.josm.gui.util.GuiSizesHelper; 39 40 import org.openstreetmap.josm.io.NoteExporter; 40 41 import org.openstreetmap.josm.io.OsmApi; 41 42 import org.openstreetmap.josm.io.XmlWriter; 42 43 import org.openstreetmap.josm.tools.ColorHelper; 44 import org.openstreetmap.josm.tools.ImageProvider; 43 45 import org.openstreetmap.josm.tools.Utils; 44 46 import org.openstreetmap.josm.tools.date.DateUtils; … … 107 109 @Override 108 110 public void paint(Graphics2D g, MapView mv, Bounds box) { 111 final int iconHeight = GuiSizesHelper.getSizeDpiAdjusted( ImageProvider.ImageSizes.SMALLICON.getVirtualHeight() ); 112 final int iconWidth = GuiSizesHelper.getSizeDpiAdjusted( ImageProvider.ImageSizes.SMALLICON.getVirtualWidth() ); 113 109 114 for (Note note : noteData.getNotes()) { 110 115 Point p = mv.getPoint(note.getLatLon()); … … 112 117 ImageIcon icon; 113 118 if (note.getId() < 0) { 114 icon = NotesDialog.ICON_NEW_SMALL;119 icon = ImageProvider.get("dialogs/notes", "note_new", ImageProvider.ImageSizes.SMALLICON); 115 120 } else if (note.getState() == State.CLOSED) { 116 icon = NotesDialog.ICON_CLOSED_SMALL;121 icon = ImageProvider.get("dialogs/notes", "note_closed", ImageProvider.ImageSizes.SMALLICON); 117 122 } else { 118 icon = NotesDialog.ICON_OPEN_SMALL;123 icon = ImageProvider.get("dialogs/notes", "note_open", ImageProvider.ImageSizes.SMALLICON); 119 124 } 120 125 int width = icon.getIconWidth(); … … 151 156 152 157 g.setColor(ColorHelper.html2color(Main.pref.get("color.selected"))); 153 g.drawRect(p.x - ( NotesDialog.ICON_SMALL_SIZE / 2), p.y - NotesDialog.ICON_SMALL_SIZE,154 NotesDialog.ICON_SMALL_SIZE - 1, NotesDialog.ICON_SMALL_SIZE- 1);155 156 int tx = p.x + ( NotesDialog.ICON_SMALL_SIZE/ 2) + 5;157 int ty = p.y - NotesDialog.ICON_SMALL_SIZE- 1;158 g.drawRect(p.x - (iconWidth / 2), p.y - iconHeight, 159 iconWidth - 1, iconHeight - 1); 160 161 int tx = p.x + (iconWidth / 2) + 5; 162 int ty = p.y - iconHeight - 1; 158 163 g.translate(tx, ty); 159 164 … … 180 185 @Override 181 186 public Icon getIcon() { 182 return NotesDialog.ICON_OPEN_SMALL;187 return ImageProvider.get("dialogs/notes", "note_open", ImageProvider.ImageSizes.SMALLICON); 183 188 } 184 189 … … 243 248 double snapDistance = 10; 244 249 double minDistance = Double.MAX_VALUE; 250 final int iconHeight = GuiSizesHelper.getSizeDpiAdjusted( ImageProvider.ImageSizes.SMALLICON.getVirtualHeight() ); 245 251 Note closestNote = null; 246 252 for (Note note : noteData.getNotes()) { 247 253 Point notePoint = Main.map.mapView.getPoint(note.getLatLon()); 248 254 //move the note point to the center of the icon where users are most likely to click when selecting 249 notePoint.setLocation(notePoint.getX(), notePoint.getY() - NotesDialog.ICON_SMALL_SIZE/ 2);255 notePoint.setLocation(notePoint.getX(), notePoint.getY() - iconHeight / 2); 250 256 double dist = clickPoint.distanceSq(notePoint); 251 257 if (minDistance > dist && clickPoint.distance(notePoint) < snapDistance) { -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintMenu.java
r10364 r10428 86 86 public MapPaintMenu() { 87 87 super(tr("Map Paint Styles")); 88 setIcon( new ImageProvider("dialogs", "mapstyle").setSize(ImageProvider.ImageSizes.MENU).get());88 setIcon(ImageProvider.get("dialogs", "mapstyle", ImageProvider.ImageSizes.MENU)); 89 89 MapPaintStyles.addMapPaintSylesUpdateListener(this); 90 90 putClientProperty("help", ht("/Dialog/MapPaint")); -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
r10378 r10428 512 512 513 513 if (iconName != null && !iconName.isEmpty()) { 514 icon = new ImageProvider("preferences", iconName).setSize(ImageProvider.ImageSizes.SETTINGS_TAB).get();514 icon = ImageProvider.get("preferences", iconName, ImageProvider.ImageSizes.SETTINGS_TAB); 515 515 } 516 516 if (settingsInitialized.contains(tps)) { -
trunk/src/org/openstreetmap/josm/gui/widgets/TextContextualPopupMenu.java
r10378 r10428 180 180 mi.setText(label); 181 181 if (iconName != null && Main.pref.getBoolean("text.popupmenu.useicons", true)) { 182 ImageIcon icon = new ImageProvider(iconName).setSize(ImageProvider.ImageSizes.SMALLICON).get();182 ImageIcon icon = ImageProvider.get(iconName, ImageProvider.ImageSizes.SMALLICON); 183 183 if (icon != null) { 184 184 mi.setIcon(icon); -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r10410 r10428 272 272 /** ordered list of overlay images */ 273 273 protected List<ImageOverlay> overlayInfo; 274 /** <code>true</code> if icon must be grayed out */ 275 protected boolean isDisabled = false; 274 276 275 277 private static SVGUniverse svgUniverse; … … 351 353 this.additionalClassLoaders = image.additionalClassLoaders; 352 354 this.overlayInfo = image.overlayInfo; 355 this.isDisabled = image.isDisabled; 353 356 } 354 357 … … 601 604 602 605 /** 606 * Set, if image must be filtered to grayscale so it will look like disabled icon. 607 * 608 * @param disabled true, if image must be grayed out for disabled state 609 * @return the current object, for convenience 610 * @since 10428 611 */ 612 public ImageProvider setDisabled(boolean disabled) { 613 this.isDisabled = disabled; 614 return this; 615 } 616 617 /** 603 618 * Execute the image request and scale result. 604 619 * @return the requested image or null if the request failed … … 606 621 public ImageIcon get() { 607 622 ImageResource ir = getResource(); 608 if (ir == null) 623 624 if (ir == null) { 609 625 return null; 626 } 610 627 if (virtualMaxWidth != -1 || virtualMaxHeight != -1) 611 628 return ir.getImageIconBounded(new Dimension(virtualMaxWidth, virtualMaxHeight)); … … 638 655 ir = new ImageResource(ir, overlayInfo); 639 656 } 657 if (isDisabled) { 658 ir.setDisabled(true); 659 } 640 660 return ir; 641 661 } … … 718 738 719 739 /** 740 * Load an image from directory with a given file name and size. 741 * 742 * @param subdir subdirectory the image lies in 743 * @param name The icon name (base name with or without '.png' or '.svg' extension) 744 * @param size Target icon size 745 * @return The requested Image. 746 * @throws RuntimeException if the image cannot be located 747 * @since 10428 748 */ 749 public static ImageIcon get(String subdir, String name, ImageSizes size) { 750 return new ImageProvider(subdir, name).setSize(size).get(); 751 } 752 753 /** 720 754 * Load an empty image with a given size. 721 755 * … … 741 775 public static ImageIcon getIfAvailable(String subdir, String name) { 742 776 return new ImageProvider(subdir, name).setOptional(true).get(); 777 } 778 779 /** 780 * Load an image with a given file name and size. 781 * 782 * @param name The icon name (base name with or without '.png' or '.svg' extension) 783 * @param size Target icon size 784 * @return the requested image or null if the request failed 785 * @see #get(String, String) 786 * @since 10428 787 */ 788 public static ImageIcon get(String name, ImageSizes size) { 789 return new ImageProvider(name).setSize(size).get(); 743 790 } 744 791 … … 776 823 return null; 777 824 825 String prefix = ""; 826 if(isDisabled) 827 prefix = "dis:"+prefix; 778 828 if (name.startsWith("data:")) { 779 829 String url = name; 780 ImageResource ir = cache.get( url);830 ImageResource ir = cache.get(prefix+url); 781 831 if (ir != null) return ir; 782 832 ir = getIfAvailableDataUrl(url); 783 833 if (ir != null) { 784 cache.put( url, ir);834 cache.put(prefix+url, ir); 785 835 } 786 836 return ir; … … 791 841 if (name.startsWith(HTTP_PROTOCOL) || name.startsWith(HTTPS_PROTOCOL)) { 792 842 String url = name; 793 ImageResource ir = cache.get( url);843 ImageResource ir = cache.get(prefix+url); 794 844 if (ir != null) return ir; 795 845 ir = getIfAvailableHttp(url, type); 796 846 if (ir != null) { 797 cache.put( url, ir);847 cache.put(prefix+url, ir); 798 848 } 799 849 return ir; 800 850 } else if (name.startsWith(WIKI_PROTOCOL)) { 801 ImageResource ir = cache.get( name);851 ImageResource ir = cache.get(prefix+name); 802 852 if (ir != null) return ir; 803 853 ir = getIfAvailableWiki(name, type); 804 854 if (ir != null) { 805 cache.put( name, ir);855 cache.put(prefix+name, ir); 806 856 } 807 857 return ir; … … 831 881 832 882 String fullName = subdir + name + ext; 833 String cacheName = fullName;883 String cacheName = prefix + fullName; 834 884 /* cache separately */ 835 885 if (dirs != null && !dirs.isEmpty()) { -
trunk/src/org/openstreetmap/josm/tools/ImageResource.java
r10409 r10428 11 11 import javax.swing.AbstractAction; 12 12 import javax.swing.Action; 13 import javax.swing.Icon; 13 14 import javax.swing.ImageIcon; 15 import javax.swing.JPanel; 16 import javax.swing.UIManager; 14 17 15 18 import org.openstreetmap.josm.gui.util.GuiSizesHelper; … … 43 46 */ 44 47 protected List<ImageOverlay> overlayInfo; 48 /** 49 * <code>true</code> if icon must be grayed out 50 */ 51 protected boolean isDisabled = false; 52 /** 53 * The base raster image for the final output 54 */ 45 55 private Image baseImage; 46 56 … … 51 61 public ImageResource(Image img) { 52 62 CheckParameterUtil.ensureParameterNotNull(img); 53 baseImage = img; 54 imgCache.put(DEFAULT_DIMENSION, scaleBaseImageIfNeeded(img)); 63 baseImage = scaleBaseImageIfNeeded(img); 55 64 } 56 65 … … 96 105 97 106 /** 107 * Set, if image must be filtered to grayscale so it will look like disabled icon. 108 * 109 * @param disabled true, if image must be grayed out for disabled state 110 * @return the current object, for convenience 111 * @since 10428 112 */ 113 public ImageResource setDisabled(boolean disabled) { 114 this.isDisabled = disabled; 115 return this; 116 } 117 118 /** 98 119 * Set both icons of an Action 99 120 * @param a The action for the icons … … 145 166 return new ImageIcon(img); 146 167 } 168 BufferedImage bimg; 147 169 if (svg != null) { 148 170 Dimension realDim = GuiSizesHelper.getDimensionDpiAdjusted(dim); 149 BufferedImagebimg = ImageProvider.createImageFromSvg(svg, realDim);171 bimg = ImageProvider.createImageFromSvg(svg, realDim); 150 172 if (bimg == null) { 151 173 return null; 152 174 } 153 if (overlayInfo != null) {154 for (ImageOverlay o : overlayInfo) {155 o.process(bimg);156 }157 }158 imgCache.put(dim, bimg);159 return new ImageIcon(bimg);160 175 } else { 161 176 if (baseImage == null) throw new AssertionError(); … … 173 188 } 174 189 Image i = icon.getImage().getScaledInstance(realWidth, realHeight, Image.SCALE_SMOOTH); 175 BufferedImagebimg = new BufferedImage(realWidth, realHeight, BufferedImage.TYPE_INT_ARGB);190 bimg = new BufferedImage(realWidth, realHeight, BufferedImage.TYPE_INT_ARGB); 176 191 bimg.getGraphics().drawImage(i, 0, 0, null); 177 if (overlayInfo != null) { 178 for (ImageOverlay o : overlayInfo) { 179 o.process(bimg); 180 } 181 } 182 imgCache.put(dim, bimg); 183 return new ImageIcon(bimg); 184 } 192 } 193 if (overlayInfo != null) { 194 for (ImageOverlay o : overlayInfo) { 195 o.process(bimg); 196 } 197 } 198 if (isDisabled) { 199 //Use default Swing functionality to make icon look disabled by applying grayscaling filter. 200 Icon disabledIcon = UIManager.getLookAndFeel().getDisabledIcon(null, new ImageIcon(bimg)); 201 202 //Convert Icon to ImageIcon with BufferedImage inside 203 bimg = new BufferedImage(bimg.getWidth(), bimg.getHeight(), BufferedImage.TYPE_4BYTE_ABGR); 204 disabledIcon.paintIcon(new JPanel(), bimg.getGraphics(), 0, 0); 205 } 206 imgCache.put(dim, bimg); 207 return new ImageIcon(bimg); 185 208 } 186 209
Note:
See TracChangeset
for help on using the changeset viewer.