Changeset 35005 in osm for applications/editors
- Timestamp:
- 2019-05-22T18:19:28+02:00 (5 years ago)
- Location:
- applications/editors/josm/plugins/piclayer
- Files:
-
- 18 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/piclayer
- Property svn:ignore
-
old new 3 3 findbugs-josm-PicLayer.xml 4 4 javadoc 5 .git
-
- Property svn:ignore
-
applications/editors/josm/plugins/piclayer/.classpath
r35003 r35005 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <classpath> 3 <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 3 4 <classpathentry kind="src" path="src"/> 4 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>5 5 <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/> 6 <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> 6 7 <classpathentry kind="output" path="build"/> 7 8 </classpath> -
applications/editors/josm/plugins/piclayer/.project
r35003 r35005 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <projectDescription> 3 <name> JOSM-piclayer</name>3 <name>piclayer</name> 4 4 <comment></comment> 5 5 <projects> 6 <project>JOSM</project> 7 <project>JOSM-indoorhelper</project> 6 8 </projects> 7 9 <buildSpec> … … 11 13 </arguments> 12 14 </buildCommand> 13 <buildCommand>14 <name>org.sonarlint.eclipse.core.sonarlintBuilder</name>15 <arguments>16 </arguments>17 </buildCommand>18 <buildCommand>19 <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>20 <arguments>21 </arguments>22 </buildCommand>23 15 </buildSpec> 24 16 <natures> 25 17 <nature>org.eclipse.jdt.core.javanature</nature> 26 <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>27 18 </natures> 28 19 </projectDescription> -
applications/editors/josm/plugins/piclayer/.settings/org.eclipse.jdt.core.prefs
r35003 r35005 10 10 org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled 11 11 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 12 org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate 12 13 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 14 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 13 15 org.eclipse.jdt.core.compiler.compliance=1.8 16 org.eclipse.jdt.core.compiler.debug.lineNumber=generate 17 org.eclipse.jdt.core.compiler.debug.localVariable=generate 18 org.eclipse.jdt.core.compiler.debug.sourceFile=generate 14 19 org.eclipse.jdt.core.compiler.doc.comment.support=enabled 15 20 org.eclipse.jdt.core.compiler.problem.APILeak=warning … … 118 123 org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning 119 124 org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning 125 org.eclipse.jdt.core.compiler.release=disabled 120 126 org.eclipse.jdt.core.compiler.source=1.8 -
applications/editors/josm/plugins/piclayer/build.xml
r35003 r35005 1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 3 <project name="PicLayer" default="dist" basedir="."> 4 3 5 <property name="commit.message" value="[josm/PicLayer] - #12045 add ability to localize dialog titles"/> 6 4 7 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 5 <property name="plugin.main.version" value="14153"/> 6 8 9 <property name="plugin.main.version" value="11713"/> 10 11 12 7 13 <!-- Configure these properties (replace "..." accordingly). 14 8 15 See https://josm.openstreetmap.de/wiki/DevelopersGuide/DevelopingPlugins 16 9 17 --> 10 <property name="plugin.author" value="Tomasz Stelmach"/> 18 19 <property name="plugin.author" value="Tomasz Stelmach, Rebecca Schmidt"/> 20 11 21 <property name="plugin.class" value="org.openstreetmap.josm.plugins.piclayer.PicLayerPlugin"/> 22 12 23 <property name="plugin.description" value="This plugin allows to display any picture as a background in the editor and align it with the map."/> 24 13 25 <property name="plugin.icon" value="images/layericon.png"/> 26 14 27 <property name="plugin.link" value="https://josm.openstreetmap.de/wiki/Help/Plugin/PicLayer"/> 28 15 29 <property name="plugin.canloadatruntime" value="true"/> 16 30 31 32 17 33 <!-- ** include targets that all plugins have in common ** --> 34 18 35 <import file="../build-common.xml"/> 19 36 37 38 20 39 </project> -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java
r35003 r35005 36 36 import org.openstreetmap.josm.plugins.piclayer.actions.transform.affine.RemovePointAction; 37 37 import org.openstreetmap.josm.plugins.piclayer.actions.transform.affine.TransformPointAction; 38 import org.openstreetmap.josm.plugins.piclayer.actions.transform.autocalibrate.AutoCalibratePictureAction; 38 39 import org.openstreetmap.josm.plugins.piclayer.layer.PicLayerAbstract; 39 40 … … 84 85 ScaleYPictureAction scaleYPictureAction = new ScaleYPictureAction(); 85 86 ShearPictureAction shearPictureAction = new ShearPictureAction(); 87 AutoCalibratePictureAction autoCalibratePictureAction = new AutoCalibratePictureAction(); 88 86 89 // Create plugin buttons and add them to the toolbar 87 90 … … 96 99 buttonList.add(picLayerActionButtonFactory(scaleYPictureAction)); 97 100 buttonList.add(picLayerActionButtonFactory(shearPictureAction)); 101 buttonList.add(picLayerActionButtonFactory(autoCalibratePictureAction)); 98 102 99 103 for (IconToggleButton btn : buttonList) { … … 120 124 121 125 if (oldPic) { 122 ((PicLayerAbstract) oldLayer).setDraw Points(false);126 ((PicLayerAbstract) oldLayer).setDrawOriginPoints(false); 123 127 } 124 128 125 129 if (newPic) { 126 ((PicLayerAbstract) newLayer).setDraw Points(true);130 ((PicLayerAbstract) newLayer).setDrawOriginPoints(true); 127 131 } 128 132 } -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/GenericPicTransformAction.java
r35003 r35005 103 103 Layer active = MainApplication.getLayerManager().getActiveLayer(); 104 104 if (active instanceof PicLayerAbstract) { 105 ((PicLayerAbstract) active).setDraw Points(value);105 ((PicLayerAbstract) active).setDrawOriginPoints(value); 106 106 active.invalidate(); 107 107 } -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/affine/MovePointAction.java
r35003 r35005 8 8 import java.awt.geom.Point2D; 9 9 10 import org.openstreetmap.josm.data.coor.LatLon; 11 import org.openstreetmap.josm.data.coor.conversion.CoordinateFormatManager; 12 import org.openstreetmap.josm.data.coor.conversion.ICoordinateFormat; 13 import org.openstreetmap.josm.gui.MainApplication; 10 14 import org.openstreetmap.josm.plugins.piclayer.actions.GenericPicTransformAction; 11 15 import org.openstreetmap.josm.tools.ImageProvider; 12 16 import org.openstreetmap.josm.tools.Logging; 17 13 18 14 19 /** … … 41 46 42 47 try { 48 setLatLonOriginPoints(e.getPoint()); // collect lat/lon data points for auto calibration 49 43 50 Point2D pressed = currentLayer.transformPoint(e.getPoint()); 44 51 if (selectedPoint == null) … … 62 69 updateDrawPoints(false); 63 70 } 71 72 /** 73 * Method to collect raw data points for additional auto calibration and transforms them into LatLon. 74 * Transformed points will be stored into {@code PictureTransform } attribute to make them accessible for actions. 75 * @param point to collect 76 */ 77 private void setLatLonOriginPoints(Point2D point) { 78 LatLon latLonPoint = MainApplication.getMap().mapView.getLatLon(point.getX(), point.getY()); 79 ICoordinateFormat mCoord = CoordinateFormatManager.getDefaultFormat(); 80 double latY = Double.parseDouble(mCoord.latToString(latLonPoint)); 81 double lonX = Double.parseDouble(mCoord.lonToString(latLonPoint)); 82 currentLayer.getTransformer().addLatLonOriginPoint(new Point2D.Double(lonX, latY)); 83 } 84 64 85 } -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/affine/RemovePointAction.java
r35003 r35005 25 25 26 26 if (selectedPoint != null) { 27 currentLayer.getTransformer().removeLatLonOriginPoint(selectedPoint); 27 28 currentLayer.getTransformer().removeOriginPoint(selectedPoint); 28 29 selectedPoint = null; -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/PicLayerAbstract.java
r35003 r35005 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 7 import java.awt.BasicStroke; 6 8 import java.awt.Color; 7 9 import java.awt.Graphics2D; … … 19 21 import java.io.Reader; 20 22 import java.nio.charset.StandardCharsets; 23 import java.util.ArrayList; 24 import java.util.List; 21 25 import java.util.Properties; 22 26 … … 58 62 // Tiles of pin images 59 63 private static Image pinTiledImage; 64 private static Image pinTiledImageOrange; 60 65 61 66 // Initial position of the image in the real world … … 68 73 protected double initialImageScale = 1.0; 69 74 70 // Layer icon 75 // Layer icon / lines 71 76 private Icon layerIcon = null; 72 77 73 private boolean drawMarkers = true; 74 75 public void setDrawPoints(boolean value) { 76 drawMarkers = value; 78 private boolean drawOriginMarkers = true; 79 80 private boolean drawRefMarkers = false; 81 82 private boolean drawFirstLine = false; 83 84 private boolean drawSecLine = false; 85 86 public void setDrawOriginPoints(boolean value) { 87 drawOriginMarkers = value; 88 } 89 90 private List<Point2D> refPointsBuffer = new ArrayList<>(3); // only for buffering 91 92 public void setDrawReferencePoints(boolean value, Point2D pointToDraw) { 93 drawRefMarkers = value; 94 if(this.refPointsBuffer == null) refPointsBuffer = new ArrayList<>(3); 95 if(pointToDraw != null) this.refPointsBuffer.add(pointToDraw); 96 } 97 98 public void clearDrawReferencePoints() { 99 drawRefMarkers = false; 100 this.refPointsBuffer = null; 101 } 102 103 public void setDrawFirstLine(boolean value) { 104 drawFirstLine = value; 105 } 106 107 public void setDrawSecLine(boolean value) { 108 drawSecLine = value; 77 109 } 78 110 … … 126 158 // allow system to load the image and use it in future 127 159 pinTiledImage = new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource("/images/v6_64.png"))).getImage(); 160 pinTiledImageOrange = new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource("/images/v6_64o.png"))).getImage(); 128 161 } 129 162 … … 139 172 // First, we initialize the calibration, so that createImage() can rely on it 140 173 141 174 if(transformer == null) transformer = new PictureTransform(); 142 175 143 176 // If the map does not exist - we're screwed. We should not get into this situation in the first place! … … 181 214 */ 182 215 public abstract String getPicLayerName(); 216 217 public Image getImage() { 218 return this.image; 219 } 183 220 184 221 @Override … … 270 307 ); 271 308 } 272 if (draw Markers) {309 if (drawOriginMarkers) { 273 310 // draw markers for selection 274 311 Graphics2D gPoints = (Graphics2D) g2.create(); … … 290 327 pinTileOffsetX[i], pinTileOffsetY[i], pinTileOffsetX[i]+pinWidth, pinTileOffsetY[i]+pinHeight, null); 291 328 } 329 } 330 if (drawRefMarkers) { 331 // draw markers for selection 332 Graphics2D gPoints = (Graphics2D) g2.create(); 333 334 gPoints.translate(pic_offset_x, pic_offset_y); 335 336 gPoints.setColor(Color.RED); // red color for points output 337 338 AffineTransform tr = AffineTransform.getScaleInstance(scalex, scaley); 339 tr.concatenate(transformer.getTransform()); 340 341 for (int i = 0; i < refPointsBuffer.size(); i++) { 342 Point2D trP = tr.transform(refPointsBuffer.get(i), null); 343 int x = (int) trP.getX(), y = (int) trP.getY(); 344 345 int dstx = x-pinAnchorX; 346 int dsty = y-pinAnchorY; 347 gPoints.drawImage(pinTiledImageOrange, dstx, dsty, dstx+pinWidth, dsty+pinHeight, 348 pinTileOffsetX[i], pinTileOffsetY[i], pinTileOffsetX[i]+pinWidth, pinTileOffsetY[i]+pinHeight, null); 349 } 350 } 351 if (drawFirstLine) { 352 // set line from point1 to point2 353 List<Point2D> points = this.getTransformer().getOriginPoints(); 354 Point2D p1 = points.get(0); 355 Point2D p2 = points.get(1); 356 g.setColor(Color.green); 357 g.setStroke(new BasicStroke(5)); 358 g.drawLine((int)p1.getX(), (int)p1.getY(), (int)p2.getX(), (int)p2.getY()); 359 } 360 if (drawSecLine) { 361 // set line from point2 to point3 362 List<Point2D> points = this.getTransformer().getOriginPoints(); 363 Point2D p2 = points.get(1); 364 Point2D p3 = points.get(2); 365 g.setColor(Color.green); 366 g.setStroke(new BasicStroke(5)); 367 g.drawLine((int)p2.getX(), (int)p2.getY(), (int)p3.getX(), (int)p3.getY()); 292 368 } 293 369 } else { … … 523 599 } 524 600 525 public Point2D transformPoint(Point p) throws NoninvertibleTransformException {601 public Point2D transformPoint(Point2D p) throws NoninvertibleTransformException { 526 602 // Position image at the right graphical place 527 603 -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/transform/PictureTransform.java
r35003 r35005 8 8 9 9 import org.openstreetmap.josm.data.coor.EastNorth; 10 import org.openstreetmap.josm.plugins.piclayer.actions.transform.autocalibrate.helper.ObservableArrayList; 10 11 11 12 public class PictureTransform { … … 29 30 cachedTransform = new AffineTransform(); 30 31 originPoints = new ArrayList<>(3); 32 latLonOriginPoints = new ObservableArrayList<>(3); 31 33 } 32 34 … … 186 188 187 189 public void setOriginPoints(List<Point2D> list) { 188 this.originPoints = new ArrayList<>(list); 190 if(originPoints == null) originPoints = new ArrayList<>(list); 191 else { 192 originPoints.clear(); 193 originPoints.addAll(list); 194 } 189 195 } 190 196 … … 192 198 originPoints.remove(selectedPoint); 193 199 } 200 201 public void clearOriginPoints() { 202 originPoints.clear(); 203 } 204 205 // similar to originPointList - points scaled in LatLon, list observable 206 private ObservableArrayList<Point2D> latLonOriginPoints = new ObservableArrayList<>(3); 207 208 public ObservableArrayList<Point2D> getLatLonOriginPoints() { 209 return this.latLonOriginPoints; 210 } 211 212 public void addLatLonOriginPoint(Point2D p) { 213 latLonOriginPoints.add(p); 214 } 215 216 public void removeLatLonOriginPoint(Point2D selectedPoint) { 217 int index = originPoints.indexOf(selectedPoint); 218 Point2D toDelete = this.latLonOriginPoints.get(index); 219 this.latLonOriginPoints.remove(toDelete); 220 } 221 222 public void setLatLonOriginPoint(List<Point2D> list) { 223 if(latLonOriginPoints == null) latLonOriginPoints = new ObservableArrayList<>(list); 224 else { 225 latLonOriginPoints.clear(); 226 latLonOriginPoints.addAll(list); 227 } 228 } 229 230 public void clearLatLonOriginPoints() { 231 latLonOriginPoints.clear(); 232 } 194 233 }
Note:
See TracChangeset
for help on using the changeset viewer.