Ignore:
Timestamp:
2012-08-25T00:18:10+02:00 (12 years ago)
Author:
donvip
Message:

[josm_junctionchecking] fix bug

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/junctionchecking/src/org/openstreetmap/josm/plugins/JunctionChecker/JunctionCheckerPlugin.java

    r28610 r28626  
    2828public class JunctionCheckerPlugin extends Plugin implements LayerChangeListener{
    2929
    30         private static final String COLORSCHEMEFILTERFILE = "/resources/xml/colorscheme.xml";
    31         private JunctionCheckDialog junctionCheckDialog;
    32         private File pathDir;
    33         private final RelationProducer relationproducer;
    34         //Die benötigten Layer für JOSM
    35         private OsmDataLayer osmlayer; //IN diesem Layer sind die Originaldaten gespiechert, aus denen der Channel-Digraph erzeugt wird
    36         private ChannelDiGraphLayer channelDigraphLayer;
    37         private final ColorSchemeXMLReader cXMLReaderMK;
    38         private ChannelDiGraph channelDigraph;
    39         private final JunctionCheckerMapMode jcMapMode;
    40         private MapMode normalMapMode;
     30    private static final String COLORSCHEMEFILTERFILE = "/resources/xml/colorscheme.xml";
     31    private JunctionCheckDialog junctionCheckDialog;
     32    private File pathDir;
     33    private final RelationProducer relationproducer;
     34    //Die benötigten Layer für JOSM
     35    private OsmDataLayer osmlayer; //IN diesem Layer sind die Originaldaten gespiechert, aus denen der Channel-Digraph erzeugt wird
     36    private ChannelDiGraphLayer channelDigraphLayer;
     37    private final ColorSchemeXMLReader cXMLReaderMK;
     38    private ChannelDiGraph channelDigraph;
     39    private final JunctionCheckerMapMode jcMapMode;
     40    private MapMode normalMapMode;
    4141
    42         public JunctionCheckerPlugin(PluginInformation info) {
    43                 super(info);
    44                 jcMapMode = new JunctionCheckerMapMode(Main.map, "junctionchecking", tr("construct channel digraph and search for junctions"));
    45                 relationproducer = new RelationProducer(this);
    46                 cXMLReaderMK = new ColorSchemeXMLReader(COLORSCHEMEFILTERFILE);
    47         }
     42    public JunctionCheckerPlugin(PluginInformation info) {
     43        super(info);
     44        jcMapMode = new JunctionCheckerMapMode(Main.map, "junctionchecking", tr("construct channel digraph and search for junctions"));
     45        relationproducer = new RelationProducer(this);
     46        cXMLReaderMK = new ColorSchemeXMLReader(COLORSCHEMEFILTERFILE);
     47    }
    4848
    49         @Override
    50         public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
    51                 jcMapMode.setFrame(newFrame);
    52                 if (newFrame != null) {
    53                         junctionCheckDialog = new JunctionCheckDialog(this);
    54                         newFrame.addToggleDialog(junctionCheckDialog);
    55                         MapView.addLayerChangeListener(this);
    56                 } else
    57                         MapView.removeLayerChangeListener(this);
    58         }
     49    @Override
     50    public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
     51        jcMapMode.setFrame(newFrame);
     52        if (newFrame != null) {
     53            junctionCheckDialog = new JunctionCheckDialog(this);
     54            newFrame.addToggleDialog(junctionCheckDialog);
     55            MapView.addLayerChangeListener(this);
     56        } else
     57            MapView.removeLayerChangeListener(this);
     58    }
    5959
    60         public void activeLayerChange(Layer oldLayer, Layer newLayer) {
    61                 if (newLayer instanceof OsmDataLayer) {
    62                         this.getJunctionCheckDialog().setActivateCreateDigraph(true);
    63                         this.getJunctionCheckDialog().setActivateJunctionCheckOrSearch(false);
    64                         if (normalMapMode != null) {
    65                                 Main.map.selectMapMode(normalMapMode);
    66                         }
    67                 }
    68                 if (newLayer == channelDigraphLayer) {
    69                         this.getJunctionCheckDialog().setActivateCreateDigraph(false);
    70                         this.getJunctionCheckDialog().setActivateJunctionCheckOrSearch(true);
    71                         Main.map.selectMapMode(jcMapMode);
    72                 }
    73         }
     60    public void activeLayerChange(Layer oldLayer, Layer newLayer) {
     61        if (newLayer instanceof OsmDataLayer) {
     62            this.getJunctionCheckDialog().setActivateCreateDigraph(true);
     63            this.getJunctionCheckDialog().setActivateJunctionCheckOrSearch(false);
     64            if (normalMapMode != null) {
     65                Main.map.selectMapMode(normalMapMode);
     66            }
     67        } else if (newLayer instanceof ChannelDiGraphLayer) {
     68            this.getJunctionCheckDialog().setActivateCreateDigraph(false);
     69            this.getJunctionCheckDialog().setActivateJunctionCheckOrSearch(true);
     70            Main.map.selectMapMode(jcMapMode);
     71        }
     72    }
    7473
    75         public void layerAdded(Layer newLayer) {
    76         }
     74    public void layerAdded(Layer newLayer) {
     75    }
    7776
    78         public void layerRemoved(Layer oldLayer) {
    79                 if (oldLayer == channelDigraphLayer) {
    80                         channelDigraphLayer = null;
    81                         this.getJunctionCheckDialog().setActivateJunctionCheckOrSearch(false);
    82                         return;
    83                 }
    84                 else {
    85                         this.getJunctionCheckDialog().setActivateCreateDigraph(false);
    86                 }
    87         }
     77    public void layerRemoved(Layer oldLayer) {
     78        if (oldLayer == channelDigraphLayer) {
     79            channelDigraphLayer = null;
     80            this.getJunctionCheckDialog().setActivateJunctionCheckOrSearch(false);
     81            return;
     82        }
     83        else {
     84            this.getJunctionCheckDialog().setActivateCreateDigraph(false);
     85        }
     86    }
    8887
    89         public ChannelDiGraphLayer getChannelDigraphLayer() {
    90                 if (channelDigraphLayer == null) {
    91                         channelDigraphLayer = new ChannelDiGraphLayer(cXMLReaderMK);
    92                 }
    93                 return channelDigraphLayer;
    94         }
     88    public ChannelDiGraphLayer getChannelDigraphLayer() {
     89        if (channelDigraphLayer == null) {
     90            channelDigraphLayer = new ChannelDiGraphLayer(cXMLReaderMK);
     91        }
     92        return channelDigraphLayer;
     93    }
    9594
    96         public JunctionCheckDialog getJunctionCheckDialog() {
    97                 return junctionCheckDialog;
    98         }
     95    public JunctionCheckDialog getJunctionCheckDialog() {
     96        return junctionCheckDialog;
     97    }
    9998
    100         public File getPathDir() {
    101                 return pathDir;
    102         }
     99    public File getPathDir() {
     100        return pathDir;
     101    }
    103102
    104         public OsmDataLayer getOsmlayer() {
    105                 return osmlayer;
    106         }
     103    public OsmDataLayer getOsmlayer() {
     104        return osmlayer;
     105    }
    107106
    108         public void setOsmlayer(OsmDataLayer osmlayer) {
    109                 this.osmlayer = osmlayer;
    110         }
     107    public void setOsmlayer(OsmDataLayer osmlayer) {
     108        this.osmlayer = osmlayer;
     109    }
    111110
    112         public RelationProducer getRelationProducer() {
    113                 return relationproducer;
    114         }
     111    public RelationProducer getRelationProducer() {
     112        return relationproducer;
     113    }
    115114
    116         public ChannelDiGraph getChannelDigraph() {
    117                 return channelDigraph;
    118         }
     115    public ChannelDiGraph getChannelDigraph() {
     116        return channelDigraph;
     117    }
    119118
    120         public void setChannelDigraph(ChannelDiGraph channelDigraph) {
    121                 this.channelDigraph = channelDigraph;
    122         }
     119    public void setChannelDigraph(ChannelDiGraph channelDigraph) {
     120        this.channelDigraph = channelDigraph;
     121    }
    123122
    124         public JunctionCheckerMapMode getJcMapMode() {
    125                 return jcMapMode;
    126         }
     123    public JunctionCheckerMapMode getJcMapMode() {
     124        return jcMapMode;
     125    }
    127126
    128         public void setNormalMapMode(MapMode mm) {
    129                 normalMapMode = mm;
    130         }
     127    public void setNormalMapMode(MapMode mm) {
     128        normalMapMode = mm;
     129    }
    131130}
Note: See TracChangeset for help on using the changeset viewer.