Changeset 19387 in osm for applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSAdjustAction.java
- Timestamp:
- 2010-01-10T20:41:49+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSAdjustAction.java
r19371 r19387 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Color; 6 7 import java.awt.Cursor; 8 import java.awt.Graphics2D; 7 9 import java.awt.Toolkit; 8 10 import java.awt.event.ActionEvent; … … 16 18 import org.openstreetmap.josm.Main; 17 19 import org.openstreetmap.josm.gui.MapFrame; 20 import org.openstreetmap.josm.gui.MapView; 18 21 import org.openstreetmap.josm.actions.mapmode.MapMode; 19 22 import org.openstreetmap.josm.data.coor.EastNorth; … … 30 33 private EastNorth prevEastNorth; 31 34 enum Mode { moveXY, moveZ, rotate} 32 private Mode mode = null; 35 private static Mode mode = null; 36 private static EastNorth[] croppedRaster = new EastNorth[5];; 33 37 34 38 public WMSAdjustAction(MapFrame mapFrame) { … … 60 64 Main.map.mapView.addMouseMotionListener(this); 61 65 rasterMoved = false; 66 selectedLayer.adjustModeEnabled = true; 62 67 } else { 63 68 JOptionPane.showMessageDialog(Main.parent,tr("This mode works only if active layer is\n" … … 81 86 } 82 87 modifiedLayers.clear(); 88 selectedLayer.adjustModeEnabled = false; 83 89 selectedLayer = null; 84 90 } … … 104 110 @Override public void mouseDragged(MouseEvent e) { 105 111 EastNorth newEastNorth = Main.map.mapView.getEastNorth(e.getX(),e.getY()); 106 if (mode == Mode.moveXY) { 107 displace(prevEastNorth, newEastNorth); 108 } else if (mode == Mode.moveZ) { 109 resize(newEastNorth); 110 } else if (mode == Mode.rotate) { 111 rotate(prevEastNorth, newEastNorth); 112 if (mode == Mode.rotate) { 113 rotateFrameOnly(prevEastNorth, newEastNorth); 114 } else { 115 if (mode == Mode.moveXY) { 116 displace(prevEastNorth, newEastNorth); 117 } else if (mode == Mode.moveZ) { 118 resize(newEastNorth); 119 } 120 prevEastNorth = newEastNorth; 112 121 } 113 122 if (!modifiedLayers.contains(selectedLayer)) 114 123 modifiedLayers.add(selectedLayer); 115 124 Main.map.mapView.repaint(); 116 prevEastNorth = newEastNorth; 125 } 126 127 public static void paintAdjustFrames(Graphics2D g, final MapView mv) { 128 if (mode == Mode.rotate && croppedRaster != null) { 129 g.setColor(Color.red); 130 for (int i=0; i<4; i++) 131 g.drawLine(mv.getPoint(croppedRaster[i]).x, 132 mv.getPoint(croppedRaster[i]).y, 133 mv.getPoint(croppedRaster[i+1]).x, 134 mv.getPoint(croppedRaster[i+1]).y); 135 } 117 136 } 118 137 … … 136 155 } 137 156 157 private void rotateFrameOnly(EastNorth start, EastNorth end) { 158 if (start != null && end != null) { 159 EastNorth pivot = selectedLayer.getRasterCenter(); 160 double startAngle = Math.atan2(start.east()-pivot.east(), start.north()-pivot.north()); 161 double endAngle = Math.atan2(end.east()-pivot.east(), end.north()-pivot.north()); 162 double rotationAngle = endAngle - startAngle; 163 if (selectedLayer.images.get(0).orgCroppedRaster != null) { 164 for (int i=0; i<4; i++) { 165 croppedRaster[i] = selectedLayer.images.get(0).orgCroppedRaster[i].rotate(pivot, rotationAngle); 166 } 167 croppedRaster[4] = croppedRaster[0]; 168 } 169 } 170 } 171 138 172 @Override public void mouseReleased(MouseEvent e) { 139 173 //Main.map.mapView.repaint(); 174 if (mode == Mode.rotate) { 175 EastNorth newEastNorth = Main.map.mapView.getEastNorth(e.getX(),e.getY()); 176 rotate(prevEastNorth, newEastNorth); 177 Main.map.mapView.repaint(); 178 } 140 179 Main.map.mapView.setCursor(Cursor.getDefaultCursor()); 141 180 prevEastNorth = null;
Note:
See TracChangeset
for help on using the changeset viewer.