Changeset 35003 in osm
- Timestamp:
- 2019-05-18T02:05:52+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/piclayer
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/piclayer/.classpath
r35001 r35003 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"/>4 3 <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"/>7 6 <classpathentry kind="output" path="build"/> 8 7 </classpath> -
applications/editors/josm/plugins/piclayer/.project
r35001 r35003 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <projectDescription> 3 <name> piclayer</name>3 <name>JOSM-piclayer</name> 4 4 <comment></comment> 5 5 <projects> 6 <project>JOSM</project>7 <project>JOSM-indoorhelper</project>8 6 </projects> 9 7 <buildSpec> … … 13 11 </arguments> 14 12 </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> 15 23 </buildSpec> 16 24 <natures> 17 25 <nature>org.eclipse.jdt.core.javanature</nature> 26 <nature>net.sf.eclipsecs.core.CheckstyleNature</nature> 18 27 </natures> 19 28 </projectDescription> -
applications/editors/josm/plugins/piclayer/.settings/org.eclipse.jdt.core.prefs
r35001 r35003 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 generate13 12 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 14 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve15 13 org.eclipse.jdt.core.compiler.compliance=1.8 16 org.eclipse.jdt.core.compiler.debug.lineNumber=generate17 org.eclipse.jdt.core.compiler.debug.localVariable=generate18 org.eclipse.jdt.core.compiler.debug.sourceFile=generate19 14 org.eclipse.jdt.core.compiler.doc.comment.support=enabled 20 15 org.eclipse.jdt.core.compiler.problem.APILeak=warning … … 123 118 org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning 124 119 org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning 125 org.eclipse.jdt.core.compiler.release=disabled126 120 org.eclipse.jdt.core.compiler.source=1.8 -
applications/editors/josm/plugins/piclayer/build.xml
r35001 r35003 1 1 <?xml version="1.0" encoding="utf-8"?> 2 3 2 <project name="PicLayer" default="dist" basedir="."> 4 5 3 <property name="commit.message" value="[josm/PicLayer] - #12045 add ability to localize dialog titles"/> 6 7 4 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 8 9 <property name="plugin.main.version" value="11713"/> 10 11 12 5 <property name="plugin.main.version" value="14153"/> 6 13 7 <!-- Configure these properties (replace "..." accordingly). 14 15 8 See https://josm.openstreetmap.de/wiki/DevelopersGuide/DevelopingPlugins 16 17 9 --> 18 19 <property name="plugin.author" value="Tomasz Stelmach, Rebecca Schmidt"/> 20 10 <property name="plugin.author" value="Tomasz Stelmach"/> 21 11 <property name="plugin.class" value="org.openstreetmap.josm.plugins.piclayer.PicLayerPlugin"/> 22 23 12 <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 25 13 <property name="plugin.icon" value="images/layericon.png"/> 26 27 14 <property name="plugin.link" value="https://josm.openstreetmap.de/wiki/Help/Plugin/PicLayer"/> 28 29 15 <property name="plugin.canloadatruntime" value="true"/> 30 16 31 32 33 17 <!-- ** include targets that all plugins have in common ** --> 34 35 18 <import file="../build-common.xml"/> 36 19 37 38 39 20 </project> -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java
r35001 r35003 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;39 38 import org.openstreetmap.josm.plugins.piclayer.layer.PicLayerAbstract; 40 39 … … 85 84 ScaleYPictureAction scaleYPictureAction = new ScaleYPictureAction(); 86 85 ShearPictureAction shearPictureAction = new ShearPictureAction(); 87 AutoCalibratePictureAction autoCalibratePictureAction = new AutoCalibratePictureAction();88 89 86 // Create plugin buttons and add them to the toolbar 90 87 … … 99 96 buttonList.add(picLayerActionButtonFactory(scaleYPictureAction)); 100 97 buttonList.add(picLayerActionButtonFactory(shearPictureAction)); 101 buttonList.add(picLayerActionButtonFactory(autoCalibratePictureAction));102 98 103 99 for (IconToggleButton btn : buttonList) { … … 124 120 125 121 if (oldPic) { 126 ((PicLayerAbstract) oldLayer).setDraw OriginPoints(false);122 ((PicLayerAbstract) oldLayer).setDrawPoints(false); 127 123 } 128 124 129 125 if (newPic) { 130 ((PicLayerAbstract) newLayer).setDraw OriginPoints(true);126 ((PicLayerAbstract) newLayer).setDrawPoints(true); 131 127 } 132 128 } -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/GenericPicTransformAction.java
r35001 r35003 103 103 Layer active = MainApplication.getLayerManager().getActiveLayer(); 104 104 if (active instanceof PicLayerAbstract) { 105 ((PicLayerAbstract) active).setDraw OriginPoints(value);105 ((PicLayerAbstract) active).setDrawPoints(value); 106 106 active.invalidate(); 107 107 } -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/affine/MovePointAction.java
r35001 r35003 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;14 10 import org.openstreetmap.josm.plugins.piclayer.actions.GenericPicTransformAction; 15 11 import org.openstreetmap.josm.tools.ImageProvider; 16 12 import org.openstreetmap.josm.tools.Logging; 17 18 13 19 14 /** … … 46 41 47 42 try { 48 setLatLonOriginPoints(e.getPoint()); // collect lat/lon data points for auto calibration49 50 43 Point2D pressed = currentLayer.transformPoint(e.getPoint()); 51 44 if (selectedPoint == null) … … 69 62 updateDrawPoints(false); 70 63 } 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 collect76 */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 85 64 } -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/affine/RemovePointAction.java
r35001 r35003 25 25 26 26 if (selectedPoint != null) { 27 currentLayer.getTransformer().removeLatLonOriginPoint(selectedPoint);28 27 currentLayer.getTransformer().removeOriginPoint(selectedPoint); 29 28 selectedPoint = null; -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/PicLayerAbstract.java
r35001 r35003 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 7 import java.awt.BasicStroke;8 6 import java.awt.Color; 9 7 import java.awt.Graphics2D; … … 21 19 import java.io.Reader; 22 20 import java.nio.charset.StandardCharsets; 23 import java.util.ArrayList;24 import java.util.List;25 21 import java.util.Properties; 26 22 … … 62 58 // Tiles of pin images 63 59 private static Image pinTiledImage; 64 private static Image pinTiledImageOrange;65 60 66 61 // Initial position of the image in the real world … … 73 68 protected double initialImageScale = 1.0; 74 69 75 // Layer icon / lines70 // Layer icon 76 71 private Icon layerIcon = null; 77 72 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; 73 private boolean drawMarkers = true; 74 75 public void setDrawPoints(boolean value) { 76 drawMarkers = value; 109 77 } 110 78 … … 158 126 // allow system to load the image and use it in future 159 127 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();161 128 } 162 129 … … 172 139 // First, we initialize the calibration, so that createImage() can rely on it 173 140 174 if(transformer == null)transformer = new PictureTransform();141 transformer = new PictureTransform(); 175 142 176 143 // If the map does not exist - we're screwed. We should not get into this situation in the first place! … … 214 181 */ 215 182 public abstract String getPicLayerName(); 216 217 public Image getImage() {218 return this.image;219 }220 183 221 184 @Override … … 307 270 ); 308 271 } 309 if (draw OriginMarkers) {272 if (drawMarkers) { 310 273 // draw markers for selection 311 274 Graphics2D gPoints = (Graphics2D) g2.create(); … … 327 290 pinTileOffsetX[i], pinTileOffsetY[i], pinTileOffsetX[i]+pinWidth, pinTileOffsetY[i]+pinHeight, null); 328 291 } 329 }330 if (drawRefMarkers) {331 // draw markers for selection332 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 output337 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 point2353 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 point3362 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());368 292 } 369 293 } else { … … 599 523 } 600 524 601 public Point2D transformPoint(Point 2Dp) throws NoninvertibleTransformException {525 public Point2D transformPoint(Point p) throws NoninvertibleTransformException { 602 526 // Position image at the right graphical place 603 527 -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/transform/PictureTransform.java
r35001 r35003 8 8 9 9 import org.openstreetmap.josm.data.coor.EastNorth; 10 import org.openstreetmap.josm.plugins.piclayer.actions.transform.autocalibrate.helper.ObservableArrayList;11 10 12 11 public class PictureTransform { … … 30 29 cachedTransform = new AffineTransform(); 31 30 originPoints = new ArrayList<>(3); 32 latLonOriginPoints = new ObservableArrayList<>(3);33 31 } 34 32 … … 188 186 189 187 public void setOriginPoints(List<Point2D> list) { 190 if(originPoints == null) originPoints = new ArrayList<>(list); 191 else { 192 originPoints.clear(); 193 originPoints.addAll(list); 194 } 188 this.originPoints = new ArrayList<>(list); 195 189 } 196 190 … … 198 192 originPoints.remove(selectedPoint); 199 193 } 200 201 public void clearOriginPoints() {202 originPoints.clear();203 }204 205 // similar to originPointList - points scaled in LatLon, list observable206 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 }233 194 }
Note:
See TracChangeset
for help on using the changeset viewer.