Ignore:
Timestamp:
2015-07-31T18:23:44+02:00 (10 years ago)
Author:
nokutu
Message:

Fixed problem with ImageProvider and tests

Location:
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java

    r31424 r31425  
    11package org.openstreetmap.josm.plugins.mapillary;
    22
    3 import java.io.File;
    43import java.io.IOException;
    54
     
    3231public class MapillaryPlugin extends Plugin {
    3332
    34   /** Plugin's directory */
    35   public static String directory;
    3633  /** OS route separator */
    3734  public static final String SEPARATOR = System.getProperty("file.separator");
     
    8885    super(info);
    8986
    90 
    91     directory = new File("").getAbsolutePath() + SEPARATOR;
    92     ICON24 = new ImageProvider(directory + "images" + SEPARATOR + "icon24.png").get();
    93     ICON16 = new ImageProvider(directory + "images" + SEPARATOR + "icon16.png").get();
    94     MAP_ICON = new ImageProvider(directory + "images" + SEPARATOR + "mapicon.png").get();
    95     MAP_ICON_SELECTED = new ImageProvider(directory
    96         + "images" + SEPARATOR + "mapiconselected.png").get();
    97     MAP_ICON_IMPORTED = new ImageProvider(directory
    98         + "images/mapiconimported.png").get();
    99     MAP_SIGN = new ImageProvider(directory + "images" + SEPARATOR + "sign.png").get();
     87    ICON24 = new ImageProvider("icon24.png").get();
     88    ICON16 = new ImageProvider("icon16.png").get();
     89    MAP_ICON = new ImageProvider("mapicon.png").get();
     90    MAP_ICON_SELECTED = new ImageProvider("mapiconselected.png").get();
     91    MAP_ICON_IMPORTED = new ImageProvider("mapiconimported.png").get();
     92    MAP_SIGN = new ImageProvider("sign.png").get();
    10093
    10194    downloadAction = new MapillaryDownloadAction();
     
    184177    return new MapillaryPreferenceSetting();
    185178  }
     179
     180  /**
     181   * Returns a ImageProvider for the given string or null if in headless mode.
     182   *
     183   * @param s
     184   * @return A ImageProvider object for the given string or null if in headless mode.
     185   */
     186  public static ImageProvider getProvider(String s) {
     187    if (Main.map == null)
     188      return null;
     189    else
     190      return new ImageProvider(s);
     191  }
    186192}
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryDownloadAction.java

    r31424 r31425  
    1313import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
    1414import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
    15 import org.openstreetmap.josm.tools.ImageProvider;
    1615import org.openstreetmap.josm.tools.Shortcut;
    1716
     
    3130   */
    3231  public MapillaryDownloadAction() {
    33     super(tr("Mapillary"), new ImageProvider(MapillaryPlugin.directory
    34         + "images" + MapillaryPlugin.SEPARATOR + "icon24.png"),
     32    super(tr("Mapillary"), MapillaryPlugin.getProvider("icon24.png"),
    3533        tr("Create Mapillary layer"), Shortcut.registerShortcut("Mapillary",
    3634            tr("Start Mapillary layer"), KeyEvent.VK_COMMA, Shortcut.SHIFT),
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryDownloadViewAction.java

    r31424 r31425  
    77
    88import org.openstreetmap.josm.actions.JosmAction;
    9 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
    109import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader;
    1110import org.openstreetmap.josm.tools.ImageProvider;
     
    2726  public MapillaryDownloadViewAction() {
    2827    super(tr("Download Mapillary images in current view"), new ImageProvider(
    29         MapillaryPlugin.directory + "images" + MapillaryPlugin.SEPARATOR + "icon24.png"), tr("Download Mapillary images in current view"),
     28        "icon24.png"), tr("Download Mapillary images in current view"),
    3029        Shortcut.registerShortcut("Mapillary area",
    3130            tr("Download Mapillary images in current view"),
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryExportAction.java

    r31424 r31425  
    2424import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryExportManager;
    2525import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryExportDialog;
    26 import org.openstreetmap.josm.tools.ImageProvider;
    2726import org.openstreetmap.josm.tools.Shortcut;
    2827
     
    4342   */
    4443  public MapillaryExportAction() {
    45     super(tr("Export pictures"), new ImageProvider(MapillaryPlugin.directory
    46         + "images" + MapillaryPlugin.SEPARATOR + "icon24.png"),
     44    super(tr("Export pictures"), MapillaryPlugin.getProvider("icon24.png"),
    4745        tr("Export pictures"), Shortcut.registerShortcut("Export Mapillary",
    4846            tr("Export Mapillary pictures"), KeyEvent.CHAR_UNDEFINED,
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java

    r31424 r31425  
    2626import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
    2727import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
    28 import org.openstreetmap.josm.tools.ImageProvider;
    2928import org.openstreetmap.josm.tools.Shortcut;
    3029
     
    5049   */
    5150  public MapillaryImportAction() {
    52     super(tr("Import pictures"), new ImageProvider(MapillaryPlugin.directory
    53         + "images" + MapillaryPlugin.SEPARATOR + "icon24.png"),
     51    super(tr("Import pictures"), MapillaryPlugin.getProvider("icon24.png"),
    5452        tr("Import local pictures"), Shortcut.registerShortcut(
    5553            "Import Mapillary", tr("Import pictures into Mapillary layer"),
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportIntoSequenceAction.java

    r31424 r31425  
    3030import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
    3131import org.openstreetmap.josm.plugins.mapillary.MapillarySequence;
    32 import org.openstreetmap.josm.tools.ImageProvider;
    3332import org.openstreetmap.josm.tools.Shortcut;
    3433
     
    5150   */
    5251  public MapillaryImportIntoSequenceAction() {
    53     super(tr("Import pictures into sequence"), new ImageProvider(
    54         MapillaryPlugin.directory
    55             + "images" + MapillaryPlugin.SEPARATOR + "icon24.png"),
     52    super(tr("Import pictures into sequence"), MapillaryPlugin.getProvider("icon24.png"),
    5653        tr("Import local pictures"), Shortcut.registerShortcut(
    5754            "Import Mapillary Sequence",
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryJoinAction.java

    r31424 r31425  
    1111import org.openstreetmap.josm.plugins.mapillary.mode.JoinMode;
    1212import org.openstreetmap.josm.plugins.mapillary.mode.SelectMode;
    13 import org.openstreetmap.josm.tools.ImageProvider;
    1413import org.openstreetmap.josm.tools.Shortcut;
    1514
     
    2827   */
    2928  public MapillaryJoinAction() {
    30     super(tr("Join mode"), new ImageProvider(MapillaryPlugin.directory
    31         + "images" + MapillaryPlugin.SEPARATOR + "icon24.png"),
     29    super(tr("Join mode"), MapillaryPlugin.getProvider("icon24.png"),
    3230        tr("Join/unjoin pictures"), Shortcut.registerShortcut("Mapillary join",
    3331            tr("Join Mapillary pictures"), KeyEvent.CHAR_UNDEFINED,
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryWalkAction.java

    r31424 r31425  
    1818import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog;
    1919import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryWalkDialog;
    20 import org.openstreetmap.josm.tools.ImageProvider;
    2120import org.openstreetmap.josm.tools.Shortcut;
    2221
     
    3938   */
    4039  public MapillaryWalkAction() {
    41     super(tr("Walk mode"), new ImageProvider(MapillaryPlugin.directory
    42         + "images" + MapillaryPlugin.SEPARATOR + "icon24.png"), tr("Walk mode"),
     40    super(tr("Walk mode"), MapillaryPlugin.getProvider("icon24.png"), tr("Walk mode"),
    4341        Shortcut.registerShortcut("Mapillary walk", tr("Start walk mode"),
    4442            KeyEvent.CHAR_UNDEFINED, Shortcut.NONE), false, "mapillaryWalk",
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryZoomAction.java

    r31424 r31425  
    1212import org.openstreetmap.josm.plugins.mapillary.MapillaryDataListener;
    1313import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
    14 import org.openstreetmap.josm.tools.ImageProvider;
    1514import org.openstreetmap.josm.tools.Shortcut;
    1615
     
    3029   */
    3130  public MapillaryZoomAction() {
    32     super(tr("Zoom to selected image"), new ImageProvider(
    33         MapillaryPlugin.directory
    34             + "images" + MapillaryPlugin.SEPARATOR + "icon24.png"),
     31    super(tr("Zoom to selected image"), MapillaryPlugin.getProvider("icon24.png"),
    3532        tr("Zoom to selected image"), Shortcut.registerShortcut(
    3633            "Zoom Mapillary",
Note: See TracChangeset for help on using the changeset viewer.