Changeset 32344 in osm for applications/editors/josm/plugins/graphview/src/org/openstreetmap
- Timestamp:
- 2016-06-20T23:39:51+02:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/GraphViewPlugin.java
r32343 r32344 18 18 import org.openstreetmap.josm.Main; 19 19 import org.openstreetmap.josm.gui.MapFrame; 20 import org.openstreetmap.josm.gui.MapView; 21 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 22 import org.openstreetmap.josm.gui.layer.Layer; 20 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 21 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; 22 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 23 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 23 24 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 24 25 import org.openstreetmap.josm.plugins.Plugin; … … 81 82 preferences = GraphViewPreferences.getInstance(); 82 83 this.preferences.addObserver(this); 83 84 84 } 85 85 … … 122 122 graphViewLayer.setNodePositioner(new DefaultNodePositioner()); 123 123 124 Main.main.addLayer(graphViewLayer); 125 124 Main.getLayerManager().addLayer(graphViewLayer); 126 125 } 127 128 } 129 126 } 130 127 } catch (AccessRulesetSyntaxException e) { 131 128 JOptionPane.showMessageDialog(Main.parent, tr("Syntax exception in access ruleset:\n{0}", e)); 132 e.printStackTrace();129 Main.error(e); 133 130 } catch (FileNotFoundException e) { 134 131 JOptionPane.showMessageDialog(Main.parent, tr("File not found:\n{0}", e)); 135 e.printStackTrace();132 Main.error(e); 136 133 } catch (IOException e) { 137 134 JOptionPane.showMessageDialog(Main.parent, tr("Problem when accessing a file:\n{0}", e)); 138 e.printStackTrace(); 139 } 140 135 Main.error(e); 136 } 141 137 } 142 138 143 139 /** allows update of GraphViewLayer */ 144 140 public void updateGraphViewLayer() { 145 146 141 try { 147 148 142 if (graphViewLayer != null) { 149 143 … … 158 152 transitionStructure.forceUpdate(); 159 153 } 160 161 } 162 154 } 163 155 } catch (AccessRulesetSyntaxException e) { 164 156 JOptionPane.showMessageDialog(Main.parent, tr("Syntax exception in access ruleset:\n{0}", e)); 165 e.printStackTrace();157 Main.error(e); 166 158 } catch (FileNotFoundException e) { 167 159 JOptionPane.showMessageDialog(Main.parent, tr("File not found:\n", e)); 168 e.printStackTrace();160 Main.error(e); 169 161 } catch (IOException e) { 170 162 JOptionPane.showMessageDialog(Main.parent, tr("Problem when accessing a file:\n{0}", e)); 171 e.printStackTrace(); 172 } 173 163 Main.error(e); 164 } 174 165 } 175 166 176 167 /** repaints the GraphViewLayer without recalculating the graph (visual update) */ 177 168 public void repaintGraphViewLayer() { 178 179 169 if (graphViewLayer != null) { 180 170 graphViewLayer.invalidate(); 181 171 } 182 183 172 } 184 173 … … 211 200 throw new FileNotFoundException(tr("Couldn''t find built-in ruleset {0}", ruleset)); 212 201 } 213 214 202 } else { 215 203 … … 221 209 222 210 rulesetInputStream = new FileInputStream(rulesetFile); 223 224 211 } 225 212 226 213 return AccessRulesetReader.readAccessRuleset(rulesetInputStream); 227 228 214 } 229 215 … … 241 227 newFrame.addToggleDialog(laneDialog); 242 228 } 243 Ma pView.addLayerChangeListener(this);229 Main.getLayerManager().addLayerChangeListener(this); 244 230 } else { 245 MapView.removeLayerChangeListener(this); 246 } 247 } 248 249 public void layerRemoved(Layer oldLayer) { 250 if (oldLayer == graphViewLayer) { 231 Main.getLayerManager().removeLayerChangeListener(this); 232 } 233 } 234 235 @Override 236 public void layerRemoving(LayerRemoveEvent e) { 237 if (e.getRemovedLayer() == graphViewLayer) { 251 238 graphViewLayer = null; 252 } else if ( oldLayer== Main.main.getEditLayer()) { //data layer removed239 } else if (e.getRemovedLayer() == Main.getLayerManager().getEditLayer()) { //data layer removed 253 240 if (graphViewLayer != null) { 254 Main. main.removeLayer(graphViewLayer);241 Main.getLayerManager().removeLayer(graphViewLayer); 255 242 graphViewLayer = null; 256 243 } … … 258 245 } 259 246 260 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 247 @Override 248 public void layerOrderChanged(LayerOrderChangeEvent e) { 261 249 //do nothing 262 250 } 263 251 264 public void layerAdded(Layer newLayer) { 252 @Override 253 public void layerAdded(LayerAddEvent e) { 265 254 //do nothing 266 255 } 267 256 257 @Override 268 258 public void update(Observable arg0, Object arg1) { 269 if (arg0 == preferences) { 270 if (graphViewLayer != null) { 271 graphViewLayer.setColorScheme(preferences.getCurrentColorScheme()); 272 graphViewLayer.setArrowheadPlacement(preferences.getArrowheadPlacement()); 273 } 274 } 275 } 276 259 if (arg0 == preferences && graphViewLayer != null) { 260 graphViewLayer.setColorScheme(preferences.getCurrentColorScheme()); 261 graphViewLayer.setArrowheadPlacement(preferences.getArrowheadPlacement()); 262 } 263 } 277 264 } -
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/data/JOSMDataSource.java
r30737 r32344 43 43 44 44 public Iterable<Node> getNodes() { 45 return new FilteredOsmPrimitiveIterable<>(Main. main.getCurrentDataSet().getNodes());45 return new FilteredOsmPrimitiveIterable<>(Main.getLayerManager().getEditDataSet().getNodes()); 46 46 } 47 47 48 48 public Iterable<Relation> getRelations() { 49 return new FilteredRelationIterable(Main. main.getCurrentDataSet().getRelations());49 return new FilteredRelationIterable(Main.getLayerManager().getEditDataSet().getRelations()); 50 50 } 51 51 52 52 public Iterable<Way> getWays() { 53 return new FilteredOsmPrimitiveIterable<>(Main. main.getCurrentDataSet().getWays());53 return new FilteredOsmPrimitiveIterable<>(Main.getLayerManager().getEditDataSet().getWays()); 54 54 } 55 55
Note:
See TracChangeset
for help on using the changeset viewer.