Ignore:
Timestamp:
2016-06-19T16:08:56+02:00 (9 years ago)
Author:
donvip
Message:

fix #josm12953 - Replace most uses of MapView.getActiveLayer and similar methods (patch by michael2402, modified) - gsoc-core

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

Legend:

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

    r32078 r32329  
    111111      MapView.addEditLayerChangeListener(this, false);
    112112      MapView.addLayerChangeListener(this);
    113       if (Main.map.mapView.getEditLayer() != null)
    114         Main.map.mapView.getEditLayer().data.addDataSetListener(this);
     113      if (Main.getLayerManager().getEditLayer() != null)
     114        Main.getLayerManager().getEditLayer().data.addDataSetListener(this);
    115115      if (MapillaryDownloader.getMode() == MapillaryDownloader.MODES.Automatic)
    116116        MapillaryDownloader.automaticDownload();
     
    223223    Main.map.mapView.removeMouseMotionListener(this.mode);
    224224    MapView.removeEditLayerChangeListener(this);
    225     if (Main.map.mapView.getEditLayer() != null)
    226       Main.map.mapView.getEditLayer().data.removeDataSetListener(this);
     225    if (Main.getLayerManager().getEditLayer() != null)
     226      Main.getLayerManager().getEditLayer().data.removeDataSetListener(this);
    227227    clearInstance();
    228228    super.destroy();
     
    286286  public synchronized void paint(final Graphics2D g, final MapView mv, final Bounds box) {
    287287    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    288     if (Main.map.mapView.getActiveLayer() == this) {
     288    if (Main.getLayerManager().getActiveLayer() == this) {
    289289      // paint remainder
    290290      g.setPaint(this.hatched);
     
    323323      selectedImageKey = selectedImage.getSequence().getKey();
    324324    }
    325     g.setStroke(new BasicStroke(this == Main.map.mapView.getActiveLayer() ? 3 : 2));
     325    g.setStroke(new BasicStroke(this == Main.getLayerManager().getActiveLayer() ? 3 : 2));
    326326    for (MapillarySequence seq : getData().getSequences()) {
    327327      if (selectedImageKey != null && selectedImageKey.equals(seq.getKey())) {
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryDownloadAction.java

    r31973 r32329  
    4848    }
    4949    // Successive calls to this action toggle the active layer between the OSM data layer and the mapillary layer
    50     Main.map.mapView.setActiveLayer(
    51         Main.map.mapView.getActiveLayer() == MapillaryLayer.getInstance()
    52           ? Main.map.mapView.getEditLayer()
     50    Main.getLayerManager().setActiveLayer(
     51        Main.getLayerManager().getActiveLayer() == MapillaryLayer.getInstance()
     52          ? Main.getLayerManager().getEditLayer()
    5353          : MapillaryLayer.getInstance()
    5454    );
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java

    r32064 r32329  
    152152  public static void automaticDownload() {
    153153    MapillaryLayer layer = MapillaryLayer.getInstance();
    154     if (Main.map.mapView.getEditLayer() == null)
     154    if (Main.getLayerManager().getEditLayer() == null)
    155155      return;
    156156    if (isAreaTooBig()) {
     
    160160    if (getMode() != MODES.Automatic)
    161161      throw new IllegalStateException("Must be in automatic mode.");
    162     for (Bounds bounds : Main.map.mapView.getEditLayer().data
     162    for (Bounds bounds : Main.getLayerManager().getEditLayer().data
    163163        .getDataSourceBounds()) {
    164164      if (!layer.getData().getBounds().contains(bounds)) {
     
    177177  private static boolean isAreaTooBig() {
    178178    double area = 0;
    179     for (Bounds bounds : Main.map.mapView.getEditLayer().data.getDataSourceBounds()) {
     179    for (Bounds bounds : Main.getLayerManager().getEditLayer().data.getDataSourceBounds()) {
    180180      area += bounds.getArea();
    181181    }
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java

    r31974 r32329  
    7171  public void mouseMoved(MouseEvent e) {
    7272    this.lastPos = e;
    73     if (!(Main.map.mapView.getActiveLayer() instanceof MapillaryLayer))
     73    if (!(Main.getLayerManager().getActiveLayer() instanceof MapillaryLayer))
    7474      return;
    7575    MapillaryAbstractImage closestTemp = getClosest(e.getPoint());
  • applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java

    r32199 r32329  
    5252      return;
    5353    MapillaryAbstractImage closest = getClosest(e.getPoint());
    54     if (!(Main.map.mapView.getActiveLayer() instanceof MapillaryLayer)
     54    if (!(Main.getLayerManager().getActiveLayer() instanceof MapillaryLayer)
    5555            && closest != null && Main.map.mapMode == Main.map.mapModeSelect) {
    5656      this.lastClicked = this.closest;
    5757      this.data.setSelectedImage(closest);
    5858      return;
    59     } else if (Main.map.mapView.getActiveLayer() != MapillaryLayer
     59    } else if (Main.getLayerManager().getActiveLayer() != MapillaryLayer
    6060            .getInstance())
    6161      return;
     
    9898  @Override
    9999  public void mouseDragged(MouseEvent e) {
    100     if (Main.map.mapView.getActiveLayer() != MapillaryLayer.getInstance()) {
     100    if (Main.getLayerManager().getActiveLayer() != MapillaryLayer.getInstance()) {
    101101      return;
    102102    }
     
    156156  @Override
    157157  public void mouseMoved(MouseEvent e) {
    158     if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
     158    if (Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer
    159159            && Main.map.mapMode != Main.map.mapModeSelect) {
    160160      return;
     
    167167
    168168    if (closestTemp != null
    169             && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
     169            && Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer
    170170            && !this.imageHighlighted) {
    171171      Main.map.mapMode.putValue("active", Boolean.FALSE);
     
    173173
    174174    } else if (closestTemp == null
    175             && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
     175            && Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer
    176176            && this.imageHighlighted && this.nothingHighlighted) {
    177177      this.nothingHighlighted = false;
     
    179179
    180180    } else if (this.imageHighlighted && !this.nothingHighlighted
    181             && Main.map.mapView.getEditLayer().data != null
    182             && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer) {
    183 
    184       for (OsmPrimitive primivitive : Main.map.mapView.getEditLayer().data
     181            && Main.getLayerManager().getEditLayer().data != null
     182            && Main.getLayerManager().getActiveLayer() instanceof OsmDataLayer) {
     183
     184      for (OsmPrimitive primivitive : Main.getLayerManager().getEditLayer().data
    185185              .allPrimitives()) {
    186186        primivitive.setHighlighted(false);
Note: See TracChangeset for help on using the changeset viewer.