Changeset 19387 in osm for applications
- Timestamp:
- 2010-01-10T20:41:49+01:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/GeorefImage.java
r19371 r19387 30 30 // bbox of the georeferenced original image (raster only) (inclined if rotated and before cropping) 31 31 // P[0] is bottom,left then next are clockwise. 32 p rivateEastNorth[] orgRaster = new EastNorth[4];32 public EastNorth[] orgRaster = new EastNorth[4]; 33 33 // bbox of the georeferenced original image (raster only) after cropping 34 p rivateEastNorth[] orgCroppedRaster = new EastNorth[4];34 public EastNorth[] orgCroppedRaster = new EastNorth[4]; 35 35 // angle with georeferenced original image after rotation (raster images only)(in radian) 36 p rivatedouble angle = 0;36 public double angle = 0; 37 37 38 38 public BufferedImage image; -
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; -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java
r19371 r19387 81 81 82 82 private JMenuItem saveAsPng; 83 84 public boolean adjustModeEnabled; 83 85 84 86 public WMSLayer() { … … 237 239 paintCrosspieces(g, mv); 238 240 } 241 if (this.adjustModeEnabled) { 242 WMSAdjustAction.paintAdjustFrames(g, mv); 243 } 239 244 } 240 245
Note:
See TracChangeset
for help on using the changeset viewer.