Ticket #9995: hidpi_patch_2_images_leftovers.patch

File hidpi_patch_2_images_leftovers.patch, 38.4 KB (added by strump, 8 years ago)
  • src/org/openstreetmap/josm/actions/AboutAction.java

     
    104104        // Intermediate panel to allow proper optionPane resizing
    105105        JPanel panel = new JPanel(new GridBagLayout());
    106106        panel.setPreferredSize(new Dimension(890, 300));
    107         panel.add(new JLabel("", new ImageIcon(ImageProvider.get("logo.svg").getImage().getScaledInstance(256, 258, Image.SCALE_SMOOTH)),
     107        panel.add(new JLabel("", new ImageProvider("logo.svg").setSize(ImageProvider.ImageSizes.ABOUT_LOGO).get(),
    108108                JLabel.CENTER), GBC.std().insets(0, 5, 0, 0));
    109109        panel.add(about, GBC.std().fill());
    110110
  • src/org/openstreetmap/josm/actions/AbstractSelectAction.java

     
    1919    public AbstractSelectAction() {
    2020        putValue(NAME, tr("Select"));
    2121        putValue(SHORT_DESCRIPTION,  tr("Set the selected elements on the map to the selected items in the list above."));
    22         new ImageProvider("dialogs", "select").getResource().getImageIcon(this, true);
     22        new ImageProvider("dialogs", "select").getResource().attachImageIcon(this, true);
    2323    }
    2424}
  • src/org/openstreetmap/josm/actions/AddImageryLayerAction.java

     
    6262                                GuiHelper.runInEDT(new Runnable() {
    6363                                    @Override
    6464                                    public void run() {
    65                                         result.getImageIcon(AddImageryLayerAction.this);
     65                                        result.attachImageIcon(AddImageryLayerAction.this);
    6666                                    }
    6767                                });
    6868                            }
  • src/org/openstreetmap/josm/actions/JosmAction.java

     
    7272            String toolbarId, boolean installAdapters) {
    7373        super(name);
    7474        if (icon != null)
    75             icon.getResource().getImageIcon(this);
     75            icon.getResource().attachImageIcon(this);
    7676        setHelpId();
    7777        sc = shortcut;
    7878        if (sc != null) {
  • src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolverDialog.java

     
    366366        CancelAction() {
    367367            putValue(Action.SHORT_DESCRIPTION, tr("Cancel conflict resolution"));
    368368            putValue(Action.NAME, tr("Cancel"));
    369             new ImageProvider("cancel").getResource().getImageIcon(this);
     369            new ImageProvider("cancel").getResource().attachImageIcon(this);
    370370            setEnabled(true);
    371371        }
    372372
     
    381381        public ApplyAction() {
    382382            putValue(Action.SHORT_DESCRIPTION, tr("Apply resolved conflicts"));
    383383            putValue(Action.NAME, tr("Apply"));
    384             new ImageProvider("ok").getResource().getImageIcon(this);
     384            new ImageProvider("ok").getResource().attachImageIcon(this);
    385385            updateEnabledState();
    386386        }
    387387
  • src/org/openstreetmap/josm/gui/conflict/tags/PasteTagsConflictResolverDialog.java

     
    264264        private CancelAction() {
    265265            putValue(Action.SHORT_DESCRIPTION, tr("Cancel conflict resolution"));
    266266            putValue(Action.NAME, tr("Cancel"));
    267             new ImageProvider("cancel").getResource().getImageIcon(this);
     267            new ImageProvider("cancel").getResource().attachImageIcon(this);
    268268            setEnabled(true);
    269269        }
    270270
     
    280280        private ApplyAction() {
    281281            putValue(Action.SHORT_DESCRIPTION, tr("Apply resolved conflicts"));
    282282            putValue(Action.NAME, tr("Apply"));
    283             new ImageProvider("ok").getResource().getImageIcon(this);
     283            new ImageProvider("ok").getResource().attachImageIcon(this);
    284284            updateEnabledState();
    285285        }
    286286
  • src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolver.java

     
    154154    class ApplyRoleAction extends AbstractAction {
    155155        ApplyRoleAction() {
    156156            putValue(NAME, tr("Apply"));
    157             new ImageProvider("ok").getResource().getImageIcon(this);
     157            new ImageProvider("ok").getResource().attachImageIcon(this);
    158158            putValue(SHORT_DESCRIPTION, tr("Apply this role to all members"));
    159159        }
    160160
  • src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java

     
    375375        public SelectAction() {
    376376            putValue(NAME, tr("Select"));
    377377            putValue(SHORT_DESCRIPTION, tr("Selects the objects that take part in this command (unless currently deleted)"));
    378             new ImageProvider("dialogs", "select").getResource().getImageIcon(this, true);
     378            new ImageProvider("dialogs", "select").getResource().attachImageIcon(this, true);
    379379        }
    380380
    381381        @Override
     
    410410            putValue(NAME, tr("Select and zoom"));
    411411            putValue(SHORT_DESCRIPTION,
    412412                    tr("Selects the objects that take part in this command (unless currently deleted), then and zooms to it"));
    413             new ImageProvider("dialogs/autoscale", "selection").getResource().getImageIcon(this, true);
     413            new ImageProvider("dialogs/autoscale", "selection").getResource().attachImageIcon(this, true);
    414414        }
    415415
    416416        @Override
     
    446446                tree = undoTree;
    447447                putValue(NAME, tr("Undo"));
    448448                putValue(SHORT_DESCRIPTION, tr("Undo the selected and all later commands"));
    449                 new ImageProvider("undo").getResource().getImageIcon(this, true);
     449                new ImageProvider("undo").getResource().attachImageIcon(this, true);
    450450            } else {
    451451                tree = redoTree;
    452452                putValue(NAME, tr("Redo"));
    453453                putValue(SHORT_DESCRIPTION, tr("Redo the selected and all earlier commands"));
    454                 new ImageProvider("redo").getResource().getImageIcon(this, true);
     454                new ImageProvider("redo").getResource().attachImageIcon(this, true);
    455455            }
    456456        }
    457457
  • src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java

     
    433433        ResolveAction() {
    434434            putValue(NAME, tr("Resolve"));
    435435            putValue(SHORT_DESCRIPTION,  tr("Open a merge dialog of all selected items in the list above."));
    436             new ImageProvider("dialogs", "conflict").getResource().getImageIcon(this, true);
     436            new ImageProvider("dialogs", "conflict").getResource().attachImageIcon(this, true);
    437437            putValue("help", ht("/Dialog/ConflictList#ResolveAction"));
    438438        }
    439439
  • src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java

     
    157157        CancelAction() {
    158158            putValue(Action.SHORT_DESCRIPTION, tr("Cancel conflict resolution and close the dialog"));
    159159            putValue(Action.NAME, tr("Cancel"));
    160             new ImageProvider("cancel").getResource().getImageIcon(this);
     160            new ImageProvider("cancel").getResource().attachImageIcon(this);
    161161            setEnabled(true);
    162162        }
    163163
     
    174174        HelpAction() {
    175175            putValue(Action.SHORT_DESCRIPTION, tr("Show help information"));
    176176            putValue(Action.NAME, tr("Help"));
    177             new ImageProvider("help").getResource().getImageIcon(this);
     177            new ImageProvider("help").getResource().attachImageIcon(this);
    178178            setEnabled(true);
    179179        }
    180180
     
    192192        ApplyResolutionAction() {
    193193            putValue(Action.SHORT_DESCRIPTION, tr("Apply resolved conflicts and close the dialog"));
    194194            putValue(Action.NAME, tr("Apply Resolution"));
    195             new ImageProvider("dialogs", "conflict").getResource().getImageIcon(this);
     195            new ImageProvider("dialogs", "conflict").getResource().attachImageIcon(this);
    196196            updateEnabledState();
    197197        }
    198198
  • src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java

     
    140140            {
    141141                putValue(NAME, tr("Add"));
    142142                putValue(SHORT_DESCRIPTION,  tr("Add filter."));
    143                 new ImageProvider("dialogs", "add").getResource().getImageIcon(this, true);
     143                new ImageProvider("dialogs", "add").getResource().attachImageIcon(this, true);
    144144            }
    145145
    146146            @Override
     
    155155            {
    156156                putValue(NAME, tr("Edit"));
    157157                putValue(SHORT_DESCRIPTION, tr("Edit filter."));
    158                 new ImageProvider("dialogs", "edit").getResource().getImageIcon(this, true);
     158                new ImageProvider("dialogs", "edit").getResource().attachImageIcon(this, true);
    159159            }
    160160
    161161            @Override
     
    173173            {
    174174                putValue(NAME, tr("Delete"));
    175175                putValue(SHORT_DESCRIPTION, tr("Delete filter."));
    176                 new ImageProvider("dialogs", "delete").getResource().getImageIcon(this, true);
     176                new ImageProvider("dialogs", "delete").getResource().attachImageIcon(this, true);
    177177            }
    178178
    179179            @Override
     
    188188            {
    189189                putValue(NAME, tr("Up"));
    190190                putValue(SHORT_DESCRIPTION, tr("Move filter up."));
    191                 new ImageProvider("dialogs", "up").getResource().getImageIcon(this, true);
     191                new ImageProvider("dialogs", "up").getResource().attachImageIcon(this, true);
    192192            }
    193193
    194194            @Override
     
    204204            {
    205205                putValue(NAME, tr("Down"));
    206206                putValue(SHORT_DESCRIPTION, tr("Move filter down."));
    207                 new ImageProvider("dialogs", "down").getResource().getImageIcon(this, true);
     207                new ImageProvider("dialogs", "down").getResource().attachImageIcon(this, true);
    208208            }
    209209
    210210            @Override
  • src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java

     
    5656 */
    5757public class NotesDialog extends ToggleDialog implements LayerChangeListener {
    5858
     59    private static ImageProvider iconOpenImageProvider = new ImageProvider("dialogs/notes", "note_open");
     60    private static ImageProvider iconCloseImageProvider = new ImageProvider("dialogs/notes", "note_closed");
     61    private static ImageProvider iconNewImageProvider = new ImageProvider("dialogs/notes", "note_closed");
     62
    5963    /** Small icon size for use in graphics calculations */
    6064    public static final int ICON_SMALL_SIZE = 16;
    6165    /** 24x24 icon for unresolved notes */
    62     public static final ImageIcon ICON_OPEN = ImageProvider.get("dialogs/notes", "note_open");
     66    public static final ImageIcon ICON_OPEN = iconOpenImageProvider.get();
    6367    /** 16x16 icon for unresolved notes */
    6468    public static final ImageIcon ICON_OPEN_SMALL =
    65             new ImageIcon(ICON_OPEN.getImage().getScaledInstance(ICON_SMALL_SIZE, ICON_SMALL_SIZE, Image.SCALE_SMOOTH));
     69            iconOpenImageProvider.setSize(ImageProvider.ImageSizes.SMALLICON).get();
    6670    /** 24x24 icon for resolved notes */
    67     public static final ImageIcon ICON_CLOSED = ImageProvider.get("dialogs/notes", "note_closed");
     71    public static final ImageIcon ICON_CLOSED = iconCloseImageProvider.get();
    6872    /** 16x16 icon for resolved notes */
    6973    public static final ImageIcon ICON_CLOSED_SMALL =
    70             new ImageIcon(ICON_CLOSED.getImage().getScaledInstance(ICON_SMALL_SIZE, ICON_SMALL_SIZE, Image.SCALE_SMOOTH));
     74            iconCloseImageProvider.setSize(ImageProvider.ImageSizes.SMALLICON).get();
    7175    /** 24x24 icon for new notes */
    72     public static final ImageIcon ICON_NEW = ImageProvider.get("dialogs/notes", "note_new");
     76    public static final ImageIcon ICON_NEW = iconNewImageProvider.get();
    7377    /** 16x16 icon for new notes */
    7478    public static final ImageIcon ICON_NEW_SMALL =
    75             new ImageIcon(ICON_NEW.getImage().getScaledInstance(ICON_SMALL_SIZE, ICON_SMALL_SIZE, Image.SCALE_SMOOTH));
     79            iconNewImageProvider.setSize(ImageProvider.ImageSizes.SMALLICON).get();
    7680    /** Icon for note comments */
    7781    public static final ImageIcon ICON_COMMENT = ImageProvider.get("dialogs/notes", "note_comment");
    7882
     
    8892
    8993    private transient NoteData noteData;
    9094
     95    static {
     96        //Free unused fields
     97        iconOpenImageProvider = null;
     98        iconCloseImageProvider = null;
     99        iconNewImageProvider = null;
     100    }
     101
    91102    /** Creates a new toggle dialog for notes */
    92103    public NotesDialog() {
    93104        super(tr("Notes"), "notes/note_open", tr("List of notes"), null, 150);
  • src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java

     
    298298        SearchAction() {
    299299            putValue(NAME, tr("Search"));
    300300            putValue(SHORT_DESCRIPTION,   tr("Search for objects"));
    301             new ImageProvider("dialogs", "search").getResource().getImageIcon(this, true);
     301            new ImageProvider("dialogs", "search").getResource().attachImageIcon(this, true);
    302302            updateEnabledState();
    303303        }
    304304
     
    360360        ShowHistoryAction() {
    361361            putValue(NAME, tr("History"));
    362362            putValue(SHORT_DESCRIPTION, tr("Display the history of the selected objects."));
    363             new ImageProvider("dialogs", "history").getResource().getImageIcon(this, true);
     363            new ImageProvider("dialogs", "history").getResource().attachImageIcon(this, true);
    364364            updateEnabledState(model.getSize());
    365365        }
    366366
     
    400400        ZoomToJOSMSelectionAction() {
    401401            putValue(NAME, tr("Zoom to selection"));
    402402            putValue(SHORT_DESCRIPTION, tr("Zoom to selection"));
    403             new ImageProvider("dialogs/autoscale", "selection").getResource().getImageIcon(this, true);
     403            new ImageProvider("dialogs/autoscale", "selection").getResource().attachImageIcon(this, true);
    404404            updateEnabledState();
    405405        }
    406406
     
    441441        ZoomToListSelection() {
    442442            putValue(NAME, tr("Zoom to selected element(s)"));
    443443            putValue(SHORT_DESCRIPTION, tr("Zoom to selected element(s)"));
    444             new ImageProvider("dialogs/autoscale", "selection").getResource().getImageIcon(this, true);
     444            new ImageProvider("dialogs/autoscale", "selection").getResource().attachImageIcon(this, true);
    445445            updateEnabledState();
    446446        }
    447447
  • src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java

     
    157157        SelectUsersPrimitivesAction() {
    158158            putValue(NAME, tr("Select"));
    159159            putValue(SHORT_DESCRIPTION, tr("Select objects submitted by this user"));
    160             new ImageProvider("dialogs", "select").getResource().getImageIcon(this, true);
     160            new ImageProvider("dialogs", "select").getResource().attachImageIcon(this, true);
    161161            updateEnabledState();
    162162        }
    163163
     
    192192            super(false);
    193193            putValue(NAME, tr("Show info"));
    194194            putValue(SHORT_DESCRIPTION, tr("Launches a browser with information about the user"));
    195             new ImageProvider("help/internet").getResource().getImageIcon(this, true);
     195            new ImageProvider("help/internet").getResource().attachImageIcon(this, true);
    196196            updateEnabledState();
    197197        }
    198198
  • src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java

     
    119119            {
    120120                putValue(NAME, tr("Lookup"));
    121121                putValue(SHORT_DESCRIPTION, tr("Looks up the selected primitives in the error list."));
    122                 new ImageProvider("dialogs", "search").getResource().getImageIcon(this, true);
     122                new ImageProvider("dialogs", "search").getResource().attachImageIcon(this, true);
    123123            }
    124124
    125125            @Override
     
    140140            {
    141141                putValue(NAME, tr("Fix"));
    142142                putValue(SHORT_DESCRIPTION,  tr("Fix the selected issue."));
    143                 new ImageProvider("dialogs", "fix").getResource().getImageIcon(this, true);
     143                new ImageProvider("dialogs", "fix").getResource().attachImageIcon(this, true);
    144144            }
    145145            @Override
    146146            public void actionPerformed(ActionEvent e) {
     
    155155                {
    156156                    putValue(NAME, tr("Ignore"));
    157157                    putValue(SHORT_DESCRIPTION,  tr("Ignore the selected issue next time."));
    158                     new ImageProvider("dialogs", "fix").getResource().getImageIcon(this, true);
     158                    new ImageProvider("dialogs", "fix").getResource().attachImageIcon(this, true);
    159159                }
    160160                @Override
    161161                public void actionPerformed(ActionEvent e) {
  • src/org/openstreetmap/josm/gui/help/ContextSensitiveHelpAction.java

     
    4646    public ContextSensitiveHelpAction(String helpTopic) {
    4747        putValue(SHORT_DESCRIPTION, tr("Show help information"));
    4848        putValue(NAME, tr("Help"));
    49         new ImageProvider("help").getResource().getImageIcon(this);
     49        new ImageProvider("help").getResource().attachImageIcon(this);
    5050        this.helpTopic = helpTopic;
    5151        setEnabled(!Main.isOffline(OnlineResource.JOSM_WEBSITE));
    5252    }
  • src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java

     
    381381    }
    382382
    383383    final class SaveAndProceedAction extends AbstractAction implements PropertyChangeListener {
    384         private static final int ICON_SIZE = 24;
    385384        private static final String BASE_ICON = "BASE_ICON";
    386385        private final transient Image save = ImageProvider.get("save").getImage();
    387386        private final transient Image upld = ImageProvider.get("upload").getImage();
    388         private final transient Image saveDis = new BufferedImage(ICON_SIZE, ICON_SIZE, BufferedImage.TYPE_4BYTE_ABGR);
    389         private final transient Image upldDis = new BufferedImage(ICON_SIZE, ICON_SIZE, BufferedImage.TYPE_4BYTE_ABGR);
     387        private final transient Image saveDis = new ImageProvider("save").getDisabledImage();
     388        private final transient Image upldDis = new ImageProvider("upload").getDisabledImage();
    390389
    391390        SaveAndProceedAction() {
    392             // get disabled versions of icons
    393             new JLabel(ImageProvider.get("save")).getDisabledIcon().paintIcon(new JPanel(), saveDis.getGraphics(), 0, 0);
    394             new JLabel(ImageProvider.get("upload")).getDisabledIcon().paintIcon(new JPanel(), upldDis.getGraphics(), 0, 0);
    395391            initForSaveAndExit();
    396392        }
    397393
     
    411407
    412408        public void redrawIcon() {
    413409            Image base = ((ImageIcon) getValue(BASE_ICON)).getImage();
    414             BufferedImage newIco = new BufferedImage(ICON_SIZE*3, ICON_SIZE, BufferedImage.TYPE_4BYTE_ABGR);
    415             Graphics2D g = newIco.createGraphics();
    416             g.drawImage(model.getLayersToUpload().isEmpty() ? upldDis : upld, ICON_SIZE*0, 0, ICON_SIZE, ICON_SIZE, null);
    417             g.drawImage(model.getLayersToSave().isEmpty()   ? saveDis : save, ICON_SIZE*1, 0, ICON_SIZE, ICON_SIZE, null);
    418             g.drawImage(base,                                                 ICON_SIZE*2, 0, ICON_SIZE, ICON_SIZE, null);
    419             putValue(SMALL_ICON, new ImageIcon(newIco));
     410            //Prepare images
     411            Image iconsInRow[] = {
     412                    model.getLayersToUpload().isEmpty() ? upldDis : upld,
     413                    model.getLayersToSave().isEmpty()   ? saveDis : save,
     414                    base};
     415
     416            //Join them in one image
     417            Image newIcon = ImageProvider.joinImages(iconsInRow);
     418            putValue(SMALL_ICON, new ImageIcon(newIcon));
    420419        }
    421420
    422421        @Override
  • src/org/openstreetmap/josm/gui/io/UploadSelectionDialog.java

     
    258258        CancelAction() {
    259259            putValue(Action.SHORT_DESCRIPTION, tr("Cancel uploading"));
    260260            putValue(Action.NAME, tr("Cancel"));
    261             new ImageProvider("cancel").getResource().getImageIcon(this);
     261            new ImageProvider("cancel").getResource().attachImageIcon(this);
    262262            getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
    263263            .put(KeyStroke.getKeyStroke("ESCAPE"), "ESCAPE");
    264264            getRootPane().getActionMap().put("ESCAPE", this);
     
    276276        ContinueAction() {
    277277            putValue(Action.SHORT_DESCRIPTION, tr("Continue uploading"));
    278278            putValue(Action.NAME, tr("Continue"));
    279             new ImageProvider("upload").getResource().getImageIcon(this);
     279            new ImageProvider("upload").getResource().attachImageIcon(this);
    280280            updateEnabledState();
    281281        }
    282282
  • src/org/openstreetmap/josm/gui/oauth/FullyAutomaticAuthorizationUI.java

     
    324324    class RunAuthorisationAction extends AbstractAction implements DocumentListener {
    325325        RunAuthorisationAction() {
    326326            putValue(NAME, tr("Authorize now"));
    327             new ImageProvider("oauth", "oauth-small").getResource().getImageIcon(this);
     327            new ImageProvider("oauth", "oauth-small").getResource().attachImageIcon(this);
    328328            putValue(SHORT_DESCRIPTION, tr("Click to redirect you to the authorization form on the JOSM web site"));
    329329            updateEnabledState();
    330330        }
     
    361361        BackAction() {
    362362            putValue(NAME, tr("Back"));
    363363            putValue(SHORT_DESCRIPTION, tr("Run the automatic authorization steps again"));
    364             new ImageProvider("dialogs", "previous").getResource().getImageIcon(this);
     364            new ImageProvider("dialogs", "previous").getResource().attachImageIcon(this);
    365365        }
    366366
    367367        @Override
     
    376376    class TestAccessTokenAction extends AbstractAction {
    377377        TestAccessTokenAction() {
    378378            putValue(NAME, tr("Test Access Token"));
    379             new ImageProvider("logo").getResource().getImageIcon(this);
     379            new ImageProvider("logo").getResource().attachImageIcon(this);
    380380        }
    381381
    382382        @Override
  • src/org/openstreetmap/josm/gui/oauth/ManualAuthorizationUI.java

     
    222222    class TestAccessTokenAction extends AbstractAction implements PropertyChangeListener {
    223223        TestAccessTokenAction() {
    224224            putValue(NAME, tr("Test Access Token"));
    225             new ImageProvider("oauth", "oauth-small").getResource().getImageIcon(this);
     225            new ImageProvider("oauth", "oauth-small").getResource().attachImageIcon(this);
    226226            putValue(SHORT_DESCRIPTION, tr("Click to test the Access Token"));
    227227            updateEnabledState();
    228228        }
  • src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java

     
    350350         */
    351351        CancelAction() {
    352352            putValue(NAME, tr("Cancel"));
    353             new ImageProvider("cancel").getResource().getImageIcon(this);
     353            new ImageProvider("cancel").getResource().attachImageIcon(this);
    354354            putValue(SHORT_DESCRIPTION, tr("Close the dialog and cancel authorization"));
    355355        }
    356356
     
    372372         */
    373373        AcceptAccessTokenAction() {
    374374            putValue(NAME, tr("Accept Access Token"));
    375             new ImageProvider("ok").getResource().getImageIcon(this);
     375            new ImageProvider("ok").getResource().attachImageIcon(this);
    376376            putValue(SHORT_DESCRIPTION, tr("Close the dialog and accept the Access Token"));
    377377            updateEnabledState(null);
    378378        }
  • src/org/openstreetmap/josm/gui/oauth/SemiAutomaticAuthorizationUI.java

     
    291291            BackAction() {
    292292                putValue(NAME, tr("Back"));
    293293                putValue(SHORT_DESCRIPTION, tr("Go back to step 1/3"));
    294                 new ImageProvider("dialogs", "previous").getResource().getImageIcon(this);
     294                new ImageProvider("dialogs", "previous").getResource().attachImageIcon(this);
    295295            }
    296296
    297297            @Override
     
    367367            RestartAction() {
    368368                putValue(NAME, tr("Restart"));
    369369                putValue(SHORT_DESCRIPTION, tr("Go back to step 1/3"));
    370                 new ImageProvider("dialogs", "previous").getResource().getImageIcon(this);
     370                new ImageProvider("dialogs", "previous").getResource().attachImageIcon(this);
    371371            }
    372372
    373373            @Override
     
    388388
    389389        RetrieveRequestTokenAction() {
    390390            putValue(NAME, tr("Retrieve Request Token"));
    391             new ImageProvider("oauth", "oauth-small").getResource().getImageIcon(this);
     391            new ImageProvider("oauth", "oauth-small").getResource().attachImageIcon(this);
    392392            putValue(SHORT_DESCRIPTION, tr("Click to retrieve a Request Token"));
    393393        }
    394394
     
    424424
    425425        RetrieveAccessTokenAction() {
    426426            putValue(NAME, tr("Retrieve Access Token"));
    427             new ImageProvider("oauth", "oauth-small").getResource().getImageIcon(this);
     427            new ImageProvider("oauth", "oauth-small").getResource().attachImageIcon(this);
    428428            putValue(SHORT_DESCRIPTION, tr("Click to retrieve an Access Token"));
    429429        }
    430430
     
    461461
    462462        TestAccessTokenAction() {
    463463            putValue(NAME, tr("Test Access Token"));
    464             new ImageProvider("oauth", "oauth-small").getResource().getImageIcon(this);
     464            new ImageProvider("oauth", "oauth-small").getResource().attachImageIcon(this);
    465465            putValue(SHORT_DESCRIPTION, tr("Click to test the Access Token"));
    466466        }
    467467
  • src/org/openstreetmap/josm/gui/preferences/PreferenceDialog.java

     
    156156    class CancelAction extends AbstractAction {
    157157        CancelAction() {
    158158            putValue(NAME, tr("Cancel"));
    159             new ImageProvider("cancel").getResource().getImageIcon(this);
     159            new ImageProvider("cancel").getResource().attachImageIcon(this);
    160160            putValue(SHORT_DESCRIPTION, tr("Close the preferences dialog and discard preference updates"));
    161161        }
    162162
     
    175175    class OKAction extends AbstractAction {
    176176        OKAction() {
    177177            putValue(NAME, tr("OK"));
    178             new ImageProvider("ok").getResource().getImageIcon(this);
     178            new ImageProvider("ok").getResource().attachImageIcon(this);
    179179            putValue(SHORT_DESCRIPTION, tr("Save the preferences and close the dialog"));
    180180        }
    181181
  • src/org/openstreetmap/josm/gui/tagging/TagTable.java

     
    163163    class DeleteAction extends AbstractAction implements ListSelectionListener {
    164164
    165165        DeleteAction() {
    166             new ImageProvider("dialogs", "delete").getResource().getImageIcon(this);
     166            new ImageProvider("dialogs", "delete").getResource().attachImageIcon(this);
    167167            putValue(SHORT_DESCRIPTION, tr("Delete the selection in the tag table"));
    168168            getSelectionModel().addListSelectionListener(this);
    169169            getColumnModel().getSelectionModel().addListSelectionListener(this);
     
    252252     */
    253253    class AddAction extends AbstractAction implements PropertyChangeListener {
    254254        AddAction() {
    255             new ImageProvider("dialogs", "add").getResource().getImageIcon(this);
     255            new ImageProvider("dialogs", "add").getResource().attachImageIcon(this);
    256256            putValue(SHORT_DESCRIPTION, tr("Add a new tag"));
    257257            TagTable.this.addPropertyChangeListener(this);
    258258            updateEnabledState();
     
    286286     */
    287287    class PasteAction extends AbstractAction implements PropertyChangeListener {
    288288        PasteAction() {
    289             new ImageProvider("pastetags").getResource().getImageIcon(this);
     289            new ImageProvider("pastetags").getResource().attachImageIcon(this);
    290290            putValue(SHORT_DESCRIPTION, tr("Paste tags from buffer"));
    291291            TagTable.this.addPropertyChangeListener(this);
    292292            updateEnabledState();
  • src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java

     
    191191                    GuiHelper.runInEDT(new Runnable() {
    192192                        @Override
    193193                        public void run() {
    194                             result.getImageIcon(TaggingPreset.this);
     194                            result.attachImageIcon(TaggingPreset.this);
    195195                        }
    196196                    });
    197197                } else {
  • src/org/openstreetmap/josm/io/session/GenericSessionExporter.java

     
    7373         * Constructs a new {@code LayerSaveAction}.
    7474         */
    7575        LayerSaveAction() {
    76             putValue(SMALL_ICON, new ImageProvider("save").setWidth(16).get());
     76            putValue(SMALL_ICON, new ImageProvider("save").setSize(ImageProvider.ImageSizes.SMALLICON).get());
    7777            putValue(SHORT_DESCRIPTION, ((AbstractModifiableLayer) layer).requiresSaveToFile() ?
    7878                    tr("Layer contains unsaved data - save to file.") :
    7979                    tr("Layer does not contain unsaved data."));
  • src/org/openstreetmap/josm/tools/ImageProvider.java

     
    5353import javax.imageio.ImageReader;
    5454import javax.imageio.metadata.IIOMetadata;
    5555import javax.imageio.stream.ImageInputStream;
     56import javax.swing.Icon;
    5657import javax.swing.ImageIcon;
     58import javax.swing.JPanel;
     59import javax.swing.UIManager;
    5760import javax.xml.bind.DatatypeConverter;
    5861
    5962import org.openstreetmap.josm.Main;
     
    692695    }
    693696
    694697    /**
     698     * Get disabled (grayed out) icon.
     699     *
     700     * This method gets standard icon and uses default Swing functionality
     701     * to make it look disabled by applying grayscaling filter.
     702     *
     703     * @return Icon in disabled state
     704     * @since ???
     705     */
     706    public Icon getDisabledIcon() {
     707        return UIManager.getLookAndFeel().getDisabledIcon(null, get());
     708    }
     709
     710    /**
     711     * Get disabled (grayed out) image.
     712     *
     713     * This method does the same as #getDisabledIcon()
     714     * but returns instance of Image instead of Icon.
     715     *
     716     * @return Image in disabled state
     717     * @since ???
     718     */
     719    public Image getDisabledImage() {
     720        Icon disabledIcon = getDisabledIcon();
     721        //Convert Icon to Image
     722        if (disabledIcon instanceof ImageIcon) {
     723            return ((ImageIcon) disabledIcon).getImage();
     724        } else {
     725            Image disabledImage = new BufferedImage(disabledIcon.getIconWidth(), disabledIcon.getIconHeight(), BufferedImage.TYPE_4BYTE_ABGR);
     726            disabledIcon.paintIcon(new JPanel(), disabledImage.getGraphics(), 0, 0);
     727            return disabledImage;
     728        }
     729    }
     730
     731
     732    /**
    695733     * Load an image with a given file name.
    696734     *
    697735     * @param subdir subdirectory the image lies in
     
    18731911            IMAGE_FETCHER.shutdown();
    18741912        }
    18751913    }
     1914
     1915    /**
     1916     * Join multiple images in one row.
     1917     *
     1918     * Generates new image where all "images" are layouted side by side.
     1919     *
     1920     * @param images array of images to be joined
     1921     * @return new Image with all images in a row
     1922     * @see SaveAndProceedAction.redrawIcon()
     1923     */
     1924    public static Image joinImages(Image[] images) {
     1925        int targetWidth = 0;
     1926        int targetHeight = 0;
     1927
     1928        //Calculate cumulative width and max height
     1929        for (Image img : images) {
     1930            targetWidth += img.getWidth(null);
     1931            targetHeight = Math.max(targetHeight, img.getHeight(null));
     1932        }
     1933
     1934        BufferedImage newIco = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_4BYTE_ABGR);
     1935        Graphics2D g = newIco.createGraphics();
     1936
     1937        //Draw all images in row
     1938        int x = 0;
     1939        for (Image img : images) {
     1940            int curWidth = img.getWidth(null);
     1941            int curHeight = img.getHeight(null);
     1942            g.drawImage(img, x, 0, curWidth, curHeight, null);
     1943            x += curWidth;
     1944        }
     1945
     1946        return newIco;
     1947    }
    18761948}
  • src/org/openstreetmap/josm/tools/ImageResource.java

     
    109109     * @param a The action for the icons
    110110     * @since 7693
    111111     */
    112     public void getImageIcon(AbstractAction a) {
     112    public void attachImageIcon(AbstractAction a) {
    113113        Dimension iconDimension = ImageProvider.ImageSizes.SMALLICON.getImageDimension();
    114114        ImageIcon icon = getImageIconBounded(iconDimension);
    115115        a.putValue(Action.SMALL_ICON, icon);
     
    126126     * @param addresource Adds an resource named "ImageResource" if <code>true</code>
    127127     * @since 10356
    128128     */
    129     public void getImageIcon(AbstractAction a, boolean addresource) {
    130         getImageIcon(a);
     129    public void attachImageIcon(AbstractAction a, boolean addresource) {
     130        attachImageIcon(a);
    131131        if (addresource) {
    132132            a.putValue("ImageResource", this);
    133133        }