Changeset 33760 in osm for applications
- Timestamp:
- 2017-11-02T20:03:28+01:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/measurement
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/measurement/build.xml
r32680 r33760 4 4 <property name="commit.message" value="recompile dure to core change"/> 5 5 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 6 <property name="plugin.main.version" value="1 0580"/>6 <property name="plugin.main.version" value="12636"/> 7 7 <property name="plugin.canloadatruntime" value="true"/> 8 8 -
applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementDialog.java
r32936 r33760 16 16 import javax.swing.JPanel; 17 17 18 import org.openstreetmap.josm.Main;19 18 import org.openstreetmap.josm.data.SelectionChangedListener; 20 19 import org.openstreetmap.josm.data.SystemOfMeasurement; … … 33 32 import org.openstreetmap.josm.data.osm.event.TagsChangedEvent; 34 33 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent; 34 import org.openstreetmap.josm.gui.MainApplication; 35 35 import org.openstreetmap.josm.gui.SideButton; 36 36 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; … … 171 171 @Override 172 172 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 173 refresh(newSelection); 174 } 175 176 private void refresh(Collection<? extends OsmPrimitive> selection) { 173 177 double length = 0.0; 174 178 double segAngle = 0.0; … … 177 181 Node lastNode = null; 178 182 // Don't mix up way and nodes computation (fix #6872). Priority given to ways 179 ways = new SubclassFilteredCollection<>( newSelection, Way.class::isInstance);183 ways = new SubclassFilteredCollection<>(selection, Way.class::isInstance); 180 184 if (ways.isEmpty()) { 181 nodes = new SubclassFilteredCollection<>( newSelection, Node.class::isInstance);185 nodes = new SubclassFilteredCollection<>(selection, Node.class::isInstance); 182 186 for (Node n : nodes) { 183 187 if (n.getCoor() != null) { … … 241 245 }); 242 246 243 DataSet currentDs = Main .getLayerManager().getEditDataSet();247 DataSet currentDs = MainApplication.getLayerManager().getEditDataSet(); 244 248 245 249 if (ds != currentDs) { … … 280 284 // Refresh selection if a node belonging to a selected member has moved (example: scale action) 281 285 if ((nodes != null && nodes.contains(n)) || waysContain(n)) { 282 selectionChanged(Main.getLayerManager().getEditDataSet().getSelected()); 286 refresh(event.getDataset().getSelected()); 287 } 288 } 289 290 @Override public void wayNodesChanged(WayNodesChangedEvent event) { 291 if (ways.contains(event.getChangedWay())) { 292 refresh(event.getDataset().getSelected()); 283 293 } 284 294 } … … 287 297 @Override public void primitivesRemoved(PrimitivesRemovedEvent event) {} 288 298 @Override public void tagsChanged(TagsChangedEvent event) {} 289 @Override public void wayNodesChanged(WayNodesChangedEvent event) { }290 299 @Override public void relationMembersChanged(RelationMembersChangedEvent event) {} 291 300 @Override public void otherDatasetChange(AbstractDatasetChangedEvent event) {} … … 295 304 public void systemOfMeasurementChanged(String oldSoM, String newSoM) { 296 305 // Refresh selection to take into account new system of measurement 297 DataSet currentDs = Main .getLayerManager().getEditDataSet();306 DataSet currentDs = MainApplication.getLayerManager().getEditDataSet(); 298 307 if (currentDs != null) { 299 selectionChanged(currentDs.getSelected());308 refresh(currentDs.getSelected()); 300 309 } 301 310 } -
applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementLayer.java
r32324 r33760 34 34 import org.openstreetmap.josm.data.gpx.WayPoint; 35 35 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 36 import org.openstreetmap.josm.gui.MainApplication; 36 37 import org.openstreetmap.josm.gui.MapView; 37 38 import org.openstreetmap.josm.gui.NavigatableComponent; … … 115 116 if(l != null) points.remove(l); 116 117 recalculate(); 117 Main.map.repaint();118 118 } 119 119 … … 121 121 if (e.getButton() != MouseEvent.BUTTON1) return; 122 122 123 LatLon coor = Main .map.mapView.getLatLon(e.getX(), e.getY());123 LatLon coor = MainApplication.getMap().mapView.getLatLon(e.getX(), e.getY()); 124 124 points.add(new WayPoint(coor)); 125 125 126 Main.map.repaint();127 126 recalculate(); 128 127 } … … 131 130 points.clear(); 132 131 recalculate(); 133 Main.map.repaint();134 132 } 135 133 … … 149 147 MeasurementPlugin.measurementDialog.pathLengthLabel.setText(NavigatableComponent.getDistText(pathLength)); 150 148 } 151 if (Main.map.mapMode instanceof MeasurementMode) { 152 Main.map.statusLine.setDist(pathLength); 153 } 149 if (MainApplication.getMap().mapMode instanceof MeasurementMode) { 150 MainApplication.getMap().statusLine.setDist(pathLength); 151 } 152 invalidate(); 154 153 } 155 154 … … 234 233 Box panel = Box.createVerticalBox(); 235 234 final JList<GpxLayer> layerList = new JList<>(model); 236 Collection<Layer> data = Main .getLayerManager().getLayers();235 Collection<Layer> data = MainApplication.getLayerManager().getLayers(); 237 236 Layer lastLayer = null; 238 237 int layerCnt = 0; … … 295 294 } 296 295 recalculate(); 297 Main.parent.repaint();298 296 } else{ 299 297 // TODO: register a listener and show menu entry only if gps layers are available -
applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementMode.java
r30641 r33760 12 12 import org.openstreetmap.josm.actions.mapmode.MapMode; 13 13 import org.openstreetmap.josm.data.coor.LatLon; 14 import org.openstreetmap.josm.gui.Ma pFrame;14 import org.openstreetmap.josm.gui.MainApplication; 15 15 16 16 public class MeasurementMode extends MapMode { 17 17 18 18 private static final long serialVersionUID = 3853830673475744263L; 19 20 public MeasurementMode( MapFrame mapFrame,String name, String desc) {21 super(name, "measurement.png", desc, mapFrame,Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));19 20 public MeasurementMode(String name, String desc) { 21 super(name, "measurement.png", desc, Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); 22 22 } 23 23 … … 25 25 public void enterMode() { 26 26 super.enterMode(); 27 Main .map.mapView.addMouseListener(this);27 MainApplication.getMap().mapView.addMouseListener(this); 28 28 } 29 29 … … 31 31 public void exitMode() { 32 32 super.exitMode(); 33 Main .map.mapView.removeMouseListener(this);33 MainApplication.getMap().mapView.removeMouseListener(this); 34 34 } 35 35 … … 47 47 MeasurementPlugin.getCurrentLayer().removeLastPoint(); 48 48 } else if (e.getButton() == MouseEvent.BUTTON1){ 49 LatLon coor = Main .map.mapView.getLatLon(e.getX(), e.getY());49 LatLon coor = MainApplication.getMap().mapView.getLatLon(e.getX(), e.getY()); 50 50 if (coor.isOutSideWorld()) { 51 51 JOptionPane.showMessageDialog(Main.parent,tr("Can not draw outside of the world.")); -
applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementPlugin.java
r32454 r33760 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import org.openstreetmap.josm.Main;7 6 import org.openstreetmap.josm.gui.IconToggleButton; 7 import org.openstreetmap.josm.gui.MainApplication; 8 8 import org.openstreetmap.josm.gui.MapFrame; 9 9 import org.openstreetmap.josm.gui.layer.Layer; … … 32 32 if (newFrame != null) { 33 33 newFrame.addToggleDialog(measurementDialog = new MeasurementDialog()); 34 mode = new MeasurementMode( newFrame,"measurement", tr("measurement mode"));34 mode = new MeasurementMode("measurement", tr("measurement mode")); 35 35 btn = new IconToggleButton(mode); 36 36 btn.setVisible(true); … … 46 46 if (currentLayer == null) { 47 47 currentLayer = new MeasurementLayer(tr("Measurements")); 48 Main .getLayerManager().addLayer(currentLayer);48 MainApplication.getLayerManager().addLayer(currentLayer); 49 49 final ActiveLayerChangeListener activeListener = new ActiveLayerChangeListener() { 50 50 @Override 51 51 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 52 Layer newLayer = Main .getLayerManager().getActiveLayer();52 Layer newLayer = MainApplication.getLayerManager().getActiveLayer(); 53 53 if (newLayer instanceof MeasurementLayer) 54 54 MeasurementPlugin.currentLayer = (MeasurementLayer)newLayer; 55 55 } 56 56 }; 57 Main .getLayerManager().addActiveLayerChangeListener(activeListener);58 Main .getLayerManager().addLayerChangeListener(new LayerChangeListener(){57 MainApplication.getLayerManager().addActiveLayerChangeListener(activeListener); 58 MainApplication.getLayerManager().addLayerChangeListener(new LayerChangeListener(){ 59 59 @Override 60 60 public void layerAdded(LayerAddEvent e) { … … 66 66 Layer oldLayer = e.getRemovedLayer(); 67 67 if (oldLayer != null && oldLayer == currentLayer) { 68 Main .getLayerManager().removeActiveLayerChangeListener(activeListener);69 Main .getLayerManager().removeLayerChangeListener(this);68 MainApplication.getLayerManager().removeActiveLayerChangeListener(activeListener); 69 MainApplication.getLayerManager().removeLayerChangeListener(this); 70 70 } 71 71 }
Note:
See TracChangeset
for help on using the changeset viewer.