Changeset 33258 in osm for applications/editors


Ignore:
Timestamp:
2017-04-17T02:17:09+02:00 (7 years ago)
Author:
donvip
Message:

fix #josm13345 - IAE: Listener was not registered before: LayerChangeAdapter (GPSBlamMode)

Location:
applications/editors/josm/plugins/gpsblam/src/org/openstreetmap/josm/plugins/gpsblam
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/gpsblam/src/org/openstreetmap/josm/plugins/gpsblam/GPSBlamMode.java

    r33257 r33258  
    2424import org.openstreetmap.josm.Main;
    2525import org.openstreetmap.josm.actions.mapmode.MapMode;
    26 import org.openstreetmap.josm.gui.MapFrame;
    2726import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
    2827import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
     
    3332
    3433    Point pointPressed;
    35     MapFrame frame;
    3634    private Point oldP2;
    3735    int radius;
     
    146144
    147145    private void xorDrawBox(Point p1, Point p2, int radius){
    148         if (frame != null) {
    149             Graphics2D g = (Graphics2D)Main.map.mapView.getGraphics();
     146        if (Main.map != null) {
     147            Graphics2D g = (Graphics2D) Main.map.mapView.getGraphics();
    150148            g.setXORMode(Color.BLACK);
    151149            g.setColor(Color.WHITE);
     
    188186
    189187    private void paintBox(Point p2, int newRadius) {
    190         if (frame != null) {
     188        if (Main.map != null) {
    191189            if (oldP2 != null) {
    192190                xorDrawBox(pointPressed, oldP2, radius); // clear old box
     
    195193            oldP2 = p2;
    196194        }
    197     }
    198 
    199     public void setFrame(MapFrame mapFrame) {
    200         frame = mapFrame;
    201195    }
    202196
     
    215209        if (e.getRemovedLayer() instanceof GPSBlamLayer) {
    216210            currentBlamLayer = null;
    217             if(Main.map.mapMode instanceof GPSBlamMode)
     211            if (Main.map.mapMode instanceof GPSBlamMode)
    218212                Main.map.selectSelectTool(false);
    219213        }
  • applications/editors/josm/plugins/gpsblam/src/org/openstreetmap/josm/plugins/gpsblam/GPSBlamPlugin.java

    r33257 r33258  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import org.openstreetmap.josm.Main;
    76import org.openstreetmap.josm.gui.IconToggleButton;
    87import org.openstreetmap.josm.gui.MapFrame;
     
    1716public class GPSBlamPlugin extends Plugin {
    1817
    19     private final IconToggleButton btn;
    20     private final GPSBlamMode mode;
    21 
    2218    /**
    2319     * Constructs a new {@code GPSBlamPlugin}.
     
    2622    public GPSBlamPlugin(PluginInformation info) {
    2723        super(info);
    28         mode = new GPSBlamMode("gpsblam", tr("select gpx points and \"blam!\", find centre and direction of spread"));
    29 
    30         btn = new IconToggleButton(mode);
    31         btn.setVisible(true);
    3224    }
    3325
    3426    @Override
    3527    public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
    36         mode.setFrame(newFrame);
    37         if (oldFrame == null && newFrame != null && Main.map != null) {
    38             Main.map.addMapMode(btn);
     28        if (oldFrame == null && newFrame != null) {
     29            GPSBlamMode mode = new GPSBlamMode("gpsblam", tr("select gpx points and \"blam!\", find centre and direction of spread"));
     30            IconToggleButton btn = new IconToggleButton(mode);
     31            btn.setVisible(true);
     32            newFrame.addMapMode(btn);
    3933        }
    4034    }
Note: See TracChangeset for help on using the changeset viewer.