Ignore:
Timestamp:
2015-08-05T11:45:39+02:00 (9 years ago)
Author:
nokutu
Message:

Remove getInstance method in MapillaryData class.

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

Legend:

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

    r31445 r31450  
    1818public class MapillaryData {
    1919
    20   /** Unique instance of the class */
    21   public volatile static MapillaryData INSTANCE;
    22 
    2320  private final List<MapillaryAbstractImage> images;
    2421  private MapillaryAbstractImage selectedImage;
     
    3229   * Main constructor.
    3330   */
    34   private MapillaryData() {
     31  protected MapillaryData() {
    3532    this.images = new CopyOnWriteArrayList<>();
    3633    this.multiSelectedImages = new ArrayList<>();
     
    3835
    3936    addListener(MapillaryPlugin.walkAction);
    40   }
    41 
    42   /**
    43    * Returns the unique instance of the class.
    44    *
    45    * @return The unique instance of the class.
    46    */
    47   public static MapillaryData getInstance() {
    48     if (INSTANCE == null) {
    49       INSTANCE = new MapillaryData();
    50     }
    51     return INSTANCE;
    52   }
    53 
    54   /**
    55    * Destroys the unique instance.
    56    */
    57   public static void clearInstance() {
    58     INSTANCE = null;
    5937  }
    6038
     
    317295    }
    318296    if (zoom)
    319       Main.map.mapView.zoomTo(MapillaryData.getInstance().getSelectedImage()
    320           .getLatLon());
     297      Main.map.mapView.zoomTo(getSelectedImage().getLatLon());
    321298    if (Main.main != null)
    322299      Main.map.mapView.repaint();
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java

    r31449 r31450  
    9999  private MapillaryLayer() {
    100100    super(tr("Mapillary Images"));
    101     this.data = MapillaryData.getInstance();
     101    this.data = new MapillaryData();
    102102    this.bounds = new CopyOnWriteArrayList<>();
    103103    init();
     
    190190    if (Main.map.mapView.getEditLayer() != null)
    191191      Main.map.mapView.getEditLayer().data.removeDataSetListener(this);
    192     MapillaryData.clearInstance();
    193192    clearInstance();
    194193    super.destroy();
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryExportAction.java

    r31445 r31450  
    1818import org.openstreetmap.josm.actions.JosmAction;
    1919import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
    20 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
    2120import org.openstreetmap.josm.plugins.mapillary.MapillaryImage;
    2221import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
     22import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
    2323import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
    2424import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryExportManager;
     
    7171        && this.dialog.chooser != null) {
    7272      if (this.dialog.group.isSelected(this.dialog.all.getModel())) {
    73         export(MapillaryData.getInstance().getImages());
     73        export(MapillaryLayer.getInstance().data.getImages());
    7474      } else if (this.dialog.group.isSelected(this.dialog.sequence.getModel())) {
    7575        ArrayList<MapillaryAbstractImage> images = new ArrayList<>();
    76         for (MapillaryAbstractImage image : MapillaryData.getInstance()
     76        for (MapillaryAbstractImage image : MapillaryLayer.getInstance().data
    7777            .getMultiSelectedImages())
    7878          if (image instanceof MapillaryImage) {
     
    8383        export(images);
    8484      } else if (this.dialog.group.isSelected(this.dialog.selected.getModel())) {
    85         export(MapillaryData.getInstance().getMultiSelectedImages());
     85        export(MapillaryLayer.getInstance().data.getMultiSelectedImages());
    8686      }
    8787      // This option ignores the selected directory.
    8888    } else if (this.dialog.group.isSelected(this.dialog.rewrite.getModel())) {
    8989      ArrayList<MapillaryImportedImage> images = new ArrayList<>();
    90       for (MapillaryAbstractImage image : MapillaryData.getInstance()
     90      for (MapillaryAbstractImage image : MapillaryLayer.getInstance().data
    9191          .getImages())
    9292        if (image instanceof MapillaryImportedImage) {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java

    r31445 r31450  
    2222import org.openstreetmap.josm.actions.JosmAction;
    2323import org.openstreetmap.josm.data.coor.LatLon;
    24 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
    2524import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
    2625import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
     
    8584            try {
    8685              if (extension.equals("jpg") || extension.equals("jpeg"))
    87                 MapillaryData.getInstance().add(readJPG(file.listFiles()[j]));
     86                MapillaryLayer.getInstance().data.add(readJPG(file.listFiles()[j]));
    8887
    8988              else if (extension.equals("png"))
    90                 MapillaryData.getInstance().add(readPNG(file.listFiles()[j]));
     89                MapillaryLayer.getInstance().data.add(readPNG(file.listFiles()[j]));
    9190            } catch (ImageReadException | IOException | NullPointerException e1) {
    9291              Main.error(e1);
     
    9998                  .equals(".jpeg")) {
    10099            try {
    101               MapillaryData.getInstance().add(readJPG(file));
     100              MapillaryLayer.getInstance().data.add(readJPG(file));
    102101            } catch (ImageReadException ex) {
    103102              Main.error(ex);
     
    107106          } else if (file.getPath().substring(file.getPath().length() - 4)
    108107              .equals(".png")) {
    109             MapillaryData.getInstance().add(readPNG(file));
     108            MapillaryLayer.getInstance().data.add(readPNG(file));
    110109          }
    111110        }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportIntoSequenceAction.java

    r31445 r31450  
    2525import org.openstreetmap.josm.actions.JosmAction;
    2626import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
    27 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
    2827import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
    2928import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
     
    162161      MapillaryImportedImage image = new MapillaryImportedImage(latValue,
    163162          lonValue, caValue, file, datetimeOriginal.getStringValue());
    164       MapillaryData.getInstance().add(image);
     163      MapillaryLayer.getInstance().data.add(image);
    165164      image.getCapturedAt();
    166165
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryUploadAction.java

    r31449 r31450  
    1313import org.openstreetmap.josm.actions.JosmAction;
    1414import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
    15 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
    1615import org.openstreetmap.josm.plugins.mapillary.MapillaryDataListener;
     16import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
    1717import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
    1818import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryUploadDialog;
     
    3838            Shortcut.NONE), false, "mapillaryUpload", false);
    3939    this.setEnabled(false);
    40     MapillaryData.getInstance().addListener(this);
     40    MapillaryLayer.getInstance().data.addListener(this);
    4141  }
    4242
     
    5353        && (int) pane.getValue() == JOptionPane.OK_OPTION) {
    5454      if (dialog.sequence.isSelected()) {
    55         OAuthUtils.uploadSequence(MapillaryData.getInstance()
     55        OAuthUtils.uploadSequence(MapillaryLayer.getInstance().data
    5656            .getSelectedImage().getSequence());
    5757      }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryZoomAction.java

    r31425 r31450  
    99import org.openstreetmap.josm.actions.JosmAction;
    1010import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
    11 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
    1211import org.openstreetmap.josm.plugins.mapillary.MapillaryDataListener;
     12import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
    1313import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
    1414import org.openstreetmap.josm.tools.Shortcut;
     
    2929   */
    3030  public MapillaryZoomAction() {
    31     super(tr("Zoom to selected image"), MapillaryPlugin.getProvider("icon24.png"),
    32         tr("Zoom to selected image"), Shortcut.registerShortcut(
    33             "Zoom Mapillary",
     31    super(tr("Zoom to selected image"), MapillaryPlugin
     32        .getProvider("icon24.png"), tr("Zoom to selected image"), Shortcut
     33        .registerShortcut("Zoom Mapillary",
    3434            tr("Zoom to the currently selected Mapillary image"),
    3535            KeyEvent.CHAR_UNDEFINED, Shortcut.NONE), false, "mapillaryZoom",
    3636        false);
    37     MapillaryData.getInstance().addListener(this);
     37    MapillaryLayer.getInstance().data.addListener(this);
    3838    this.setEnabled(false);
    3939  }
     
    4141  @Override
    4242  public void actionPerformed(ActionEvent arg0) {
    43     if (MapillaryData.getInstance().getSelectedImage() == null)
     43    if (MapillaryLayer.getInstance().data.getSelectedImage() == null)
    4444      throw new IllegalStateException();
    45     Main.map.mapView.zoomTo(MapillaryData.getInstance().getSelectedImage()
    46         .getLatLon());
     45    Main.map.mapView.zoomTo(MapillaryLayer.getInstance().data
     46        .getSelectedImage().getLatLon());
    4747  }
    4848
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryExportDialog.java

    r31445 r31450  
    1818
    1919import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
    20 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
    2120import org.openstreetmap.josm.plugins.mapillary.MapillaryImage;
    2221import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
     22import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
    2323
    2424/**
     
    8181    this.group.add(this.rewrite);
    8282    // Some options are disabled depending on the circumstances
    83     if (MapillaryData.getInstance().getSelectedImage() == null
    84         || !(MapillaryData.getInstance().getSelectedImage() instanceof MapillaryImage && ((MapillaryImage) MapillaryData
    85             .getInstance().getSelectedImage()).getSequence() != null)) {
     83    if (MapillaryLayer.getInstance().data.getSelectedImage() == null
     84        || !(MapillaryLayer.getInstance().data.getSelectedImage() instanceof MapillaryImage && ((MapillaryImage) MapillaryLayer
     85            .getInstance().data.getSelectedImage()).getSequence() != null)) {
    8686      this.sequence.setEnabled(false);
    8787    }
    88     if (MapillaryData.getInstance().getMultiSelectedImages().isEmpty()) {
     88    if (MapillaryLayer.getInstance().data.getMultiSelectedImages().isEmpty()) {
    8989      this.selected.setEnabled(false);
    9090    }
    9191    this.rewrite.setEnabled(false);
    92     for (MapillaryAbstractImage img : MapillaryData.getInstance().getImages())
     92    for (MapillaryAbstractImage img : MapillaryLayer.getInstance().data
     93        .getImages())
    9394      if (img instanceof MapillaryImportedImage)
    9495        this.rewrite.setEnabled(true);
     
    158159    @Override
    159160    public void actionPerformed(ActionEvent arg0) {
    160       MapillaryExportDialog.this.choose.setEnabled(!MapillaryExportDialog.this.rewrite.isSelected());
     161      MapillaryExportDialog.this.choose
     162          .setEnabled(!MapillaryExportDialog.this.rewrite.isSelected());
    161163      if (MapillaryExportDialog.this.rewrite.isSelected()) {
    162164        this.lastPath = this.dlg.path.getText();
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterDialog.java

    r31445 r31450  
    2626import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
    2727import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
    28 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
    2928import org.openstreetmap.josm.plugins.mapillary.MapillaryDataListener;
    3029import org.openstreetmap.josm.plugins.mapillary.MapillaryImage;
    3130import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
     31import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
    3232import org.openstreetmap.josm.tools.Shortcut;
    3333
     
    7979  /** The the {@link JCheckBox} where the respective tag should be searched */
    8080  private final JCheckBox[] SIGN_CHECKBOXES = { this.signFilter.maxSpeed,
    81       this.signFilter.stop, this.signFilter.giveWay, this.signFilter.roundabout,
    82       this.signFilter.access, this.signFilter.access, this.signFilter.intersection,
    83       this.signFilter.direction, this.signFilter.direction, this.signFilter.intersection,
    84       this.signFilter.uneven, this.signFilter.noParking, this.signFilter.noOvertaking,
     81      this.signFilter.stop, this.signFilter.giveWay,
     82      this.signFilter.roundabout, this.signFilter.access,
     83      this.signFilter.access, this.signFilter.intersection,
     84      this.signFilter.direction, this.signFilter.direction,
     85      this.signFilter.intersection, this.signFilter.uneven,
     86      this.signFilter.noParking, this.signFilter.noOvertaking,
    8587      this.signFilter.crossing, this.signFilter.noTurn, this.signFilter.noTurn };
    8688
     
    174176    boolean onlySigns = this.onlySigns.isSelected();
    175177
    176     for (MapillaryAbstractImage img : MapillaryData.getInstance().getImages()) {
     178    for (MapillaryAbstractImage img : MapillaryLayer.getInstance().data
     179        .getImages()) {
    177180      img.setVisible(true);
    178181      if (img instanceof MapillaryImportedImage) {
     
    205208      if (this.time.getSelectedItem().equals(TIME_LIST[1])) {
    206209        if (img.getCapturedAt() < currentTime
    207             - ((Integer) this.spinner.getValue()).longValue() * 365 * 24 * 60 * 60
    208             * 1000) {
     210            - ((Integer) this.spinner.getValue()).longValue() * 365 * 24 * 60
     211            * 60 * 1000) {
    209212          img.setVisible(false);
    210213          continue;
     
    213216      if (this.time.getSelectedItem().equals(TIME_LIST[2])) {
    214217        if (img.getCapturedAt() < currentTime
    215             - ((Integer) this.spinner.getValue()).longValue() * 30 * 24 * 60 * 60
    216             * 1000) {
     218            - ((Integer) this.spinner.getValue()).longValue() * 30 * 24 * 60
     219            * 60 * 1000) {
    217220          img.setVisible(false);
    218221          continue;
     
    274277    @Override
    275278    public void actionPerformed(ActionEvent arg0) {
    276       MapillaryFilterDialog.this.onlySigns.setEnabled(MapillaryFilterDialog.this.downloaded.isSelected());
     279      MapillaryFilterDialog.this.onlySigns
     280          .setEnabled(MapillaryFilterDialog.this.downloaded.isSelected());
    277281    }
    278282  }
     
    318322    @Override
    319323    public void actionPerformed(ActionEvent arg0) {
    320       MapillaryFilterDialog.this.signChooser.setEnabled(MapillaryFilterDialog.this.onlySigns.isSelected());
     324      MapillaryFilterDialog.this.signChooser
     325          .setEnabled(MapillaryFilterDialog.this.onlySigns.isSelected());
    321326    }
    322327  }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java

    r31445 r31450  
    2323import org.openstreetmap.josm.gui.SideButton;
    2424import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
    25 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
    2625import org.openstreetmap.josm.plugins.mapillary.MapillaryDataListener;
    2726import org.openstreetmap.josm.plugins.mapillary.MapillaryImage;
     
    9796            tr("Open Mapillary main dialog"), KeyEvent.VK_M, Shortcut.NONE),
    9897        200, false, MapillaryPreferenceSetting.class);
    99     MapillaryData.getInstance().addListener(this);
     98    MapillaryLayer.getInstance().data.addListener(this);
    10099    addShortcuts();
    101100    this.mapillaryImageDisplay = new MapillaryImageDisplay();
     
    345344    @Override
    346345    public void actionPerformed(ActionEvent e) {
    347       MapillaryData.getInstance().selectNext();
     346      MapillaryLayer.getInstance().data.selectNext();
    348347    }
    349348  }
     
    367366    @Override
    368367    public void actionPerformed(ActionEvent e) {
    369       MapillaryData.getInstance().selectPrevious();
     368      MapillaryLayer.getInstance().data.selectPrevious();
    370369    }
    371370  }
     
    390389    public void actionPerformed(ActionEvent e) {
    391390      if (MapillaryMainDialog.getInstance().getImage() != null) {
    392         MapillaryData.getInstance().setSelectedImage(MapillaryLayer.RED, true);
     391        MapillaryLayer.getInstance().data.setSelectedImage(MapillaryLayer.RED,
     392            true);
    393393      }
    394394    }
     
    414414    public void actionPerformed(ActionEvent e) {
    415415      if (MapillaryMainDialog.getInstance().getImage() != null) {
    416         MapillaryData.getInstance().setSelectedImage(MapillaryLayer.BLUE, true);
     416        MapillaryLayer.getInstance().data.setSelectedImage(MapillaryLayer.BLUE,
     417            true);
    417418      }
    418419    }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryUploadDialog.java

    r31445 r31450  
    55import javax.swing.JRadioButton;
    66
    7 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
    87import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
     8import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
    99
    1010/**
     
    2828
    2929    this.sequence = new JRadioButton("Upload selected sequence.");
    30     if (MapillaryData.getInstance().getSelectedImage() == null
    31         || !(MapillaryData.getInstance().getSelectedImage() instanceof MapillaryImportedImage))
     30    if (MapillaryLayer.getInstance().data.getSelectedImage() == null
     31        || !(MapillaryLayer.getInstance().data.getSelectedImage() instanceof MapillaryImportedImage))
    3232      this.sequence.setEnabled(false);
    3333    this.group.add(this.sequence);
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/AbstractMode.java

    r31445 r31450  
    2828  private final static int DOWNLOAD_COOLDOWN = 2000;
    2929
    30   protected MapillaryData data = MapillaryData.getInstance();
     30  protected MapillaryData data = MapillaryLayer.getInstance().data;
    3131  private static SemiautomaticThread semiautomaticThread = new SemiautomaticThread();
    3232
Note: See TracChangeset for help on using the changeset viewer.