Ignore:
Timestamp:
2019-05-18T02:05:52+02:00 (6 years ago)
Author:
donvip
Message:

fix #josm17728 - revert last commit

Location:
applications/editors/josm/plugins/piclayer
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/piclayer/.classpath

    r35001 r35003  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<classpath>
    3         <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    43        <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"/>
    55        <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/>
    6         <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
    76        <classpathentry kind="output" path="build"/>
    87</classpath>
  • applications/editors/josm/plugins/piclayer/.project

    r35001 r35003  
    11<?xml version="1.0" encoding="UTF-8"?>
    22<projectDescription>
    3         <name>piclayer</name>
     3        <name>JOSM-piclayer</name>
    44        <comment></comment>
    55        <projects>
    6                 <project>JOSM</project>
    7                 <project>JOSM-indoorhelper</project>
    86        </projects>
    97        <buildSpec>
     
    1311                        </arguments>
    1412                </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>
    1523        </buildSpec>
    1624        <natures>
    1725                <nature>org.eclipse.jdt.core.javanature</nature>
     26                <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
    1827        </natures>
    1928</projectDescription>
  • applications/editors/josm/plugins/piclayer/.settings/org.eclipse.jdt.core.prefs

    r35001 r35003  
    1010org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
    1111org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
    12 org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
    1312org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
    14 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
    1513org.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
    1914org.eclipse.jdt.core.compiler.doc.comment.support=enabled
    2015org.eclipse.jdt.core.compiler.problem.APILeak=warning
     
    123118org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
    124119org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
    125 org.eclipse.jdt.core.compiler.release=disabled
    126120org.eclipse.jdt.core.compiler.source=1.8
  • applications/editors/josm/plugins/piclayer/build.xml

    r35001 r35003  
    11<?xml version="1.0" encoding="utf-8"?>
    2 
    32<project name="PicLayer" default="dist" basedir=".">
    4 
    53    <property name="commit.message" value="[josm/PicLayer] - #12045 add ability to localize dialog titles"/>
    6 
    74    <!-- 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       
    137    <!-- Configure these properties (replace "..." accordingly).
    14 
    158         See https://josm.openstreetmap.de/wiki/DevelopersGuide/DevelopingPlugins
    16 
    179    -->
    18 
    19     <property name="plugin.author" value="Tomasz Stelmach, Rebecca Schmidt"/>
    20 
     10    <property name="plugin.author" value="Tomasz Stelmach"/>
    2111    <property name="plugin.class" value="org.openstreetmap.josm.plugins.piclayer.PicLayerPlugin"/>
    22 
    2312    <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 
    2513    <property name="plugin.icon" value="images/layericon.png"/>
    26 
    2714    <property name="plugin.link" value="https://josm.openstreetmap.de/wiki/Help/Plugin/PicLayer"/>
    28 
    2915    <property name="plugin.canloadatruntime" value="true"/>
    3016
    31 
    32 
    3317    <!-- ** include targets that all plugins have in common ** -->
    34 
    3518    <import file="../build-common.xml"/>
    3619
    37 
    38 
    3920</project>
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java

    r35001 r35003  
    3636import org.openstreetmap.josm.plugins.piclayer.actions.transform.affine.RemovePointAction;
    3737import org.openstreetmap.josm.plugins.piclayer.actions.transform.affine.TransformPointAction;
    38 import org.openstreetmap.josm.plugins.piclayer.actions.transform.autocalibrate.AutoCalibratePictureAction;
    3938import org.openstreetmap.josm.plugins.piclayer.layer.PicLayerAbstract;
    4039
     
    8584            ScaleYPictureAction scaleYPictureAction = new ScaleYPictureAction();
    8685            ShearPictureAction shearPictureAction = new ShearPictureAction();
    87             AutoCalibratePictureAction autoCalibratePictureAction = new AutoCalibratePictureAction();
    88 
    8986            // Create plugin buttons and add them to the toolbar
    9087
     
    9996            buttonList.add(picLayerActionButtonFactory(scaleYPictureAction));
    10097            buttonList.add(picLayerActionButtonFactory(shearPictureAction));
    101             buttonList.add(picLayerActionButtonFactory(autoCalibratePictureAction));
    10298
    10399            for (IconToggleButton btn : buttonList) {
     
    124120
    125121        if (oldPic) {
    126             ((PicLayerAbstract) oldLayer).setDrawOriginPoints(false);
     122            ((PicLayerAbstract) oldLayer).setDrawPoints(false);
    127123        }
    128124
    129125        if (newPic) {
    130             ((PicLayerAbstract) newLayer).setDrawOriginPoints(true);
     126            ((PicLayerAbstract) newLayer).setDrawPoints(true);
    131127        }
    132128    }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/GenericPicTransformAction.java

    r35001 r35003  
    103103        Layer active = MainApplication.getLayerManager().getActiveLayer();
    104104        if (active instanceof PicLayerAbstract) {
    105             ((PicLayerAbstract) active).setDrawOriginPoints(value);
     105            ((PicLayerAbstract) active).setDrawPoints(value);
    106106            active.invalidate();
    107107        }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/affine/MovePointAction.java

    r35001 r35003  
    88import java.awt.geom.Point2D;
    99
    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;
    1410import org.openstreetmap.josm.plugins.piclayer.actions.GenericPicTransformAction;
    1511import org.openstreetmap.josm.tools.ImageProvider;
    1612import org.openstreetmap.josm.tools.Logging;
    17 
    1813
    1914/**
     
    4641
    4742        try {
    48                 setLatLonOriginPoints(e.getPoint());    // collect lat/lon data points for auto calibration
    49 
    5043            Point2D pressed = currentLayer.transformPoint(e.getPoint());
    5144            if (selectedPoint == null)
     
    6962        updateDrawPoints(false);
    7063    }
    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 
    8564}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/affine/RemovePointAction.java

    r35001 r35003  
    2525
    2626        if (selectedPoint != null) {
    27                 currentLayer.getTransformer().removeLatLonOriginPoint(selectedPoint);
    2827            currentLayer.getTransformer().removeOriginPoint(selectedPoint);
    2928            selectedPoint = null;
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/PicLayerAbstract.java

    r35001 r35003  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 
    7 import java.awt.BasicStroke;
    86import java.awt.Color;
    97import java.awt.Graphics2D;
     
    2119import java.io.Reader;
    2220import java.nio.charset.StandardCharsets;
    23 import java.util.ArrayList;
    24 import java.util.List;
    2521import java.util.Properties;
    2622
     
    6258    // Tiles of pin images
    6359    private static Image pinTiledImage;
    64     private static Image pinTiledImageOrange;
    6560
    6661    // Initial position of the image in the real world
     
    7368    protected double initialImageScale = 1.0;
    7469
    75     // Layer icon / lines
     70    // Layer icon
    7671    private Icon layerIcon = null;
    7772
    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;
    10977    }
    11078
     
    158126            // allow system to load the image and use it in future
    159127            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();
    161128        }
    162129
     
    172139        // First, we initialize the calibration, so that createImage() can rely on it
    173140
    174           if(transformer == null)               transformer = new PictureTransform();
     141        transformer = new PictureTransform();
    175142
    176143        // If the map does not exist - we're screwed. We should not get into this situation in the first place!
     
    214181     */
    215182    public abstract String getPicLayerName();
    216 
    217     public Image getImage() {
    218         return this.image;
    219     }
    220183
    221184    @Override
     
    307270                );
    308271            }
    309             if (drawOriginMarkers) {
     272            if (drawMarkers) {
    310273                // draw markers for selection
    311274                Graphics2D gPoints = (Graphics2D) g2.create();
     
    327290                           pinTileOffsetX[i], pinTileOffsetY[i], pinTileOffsetX[i]+pinWidth, pinTileOffsetY[i]+pinHeight, null);
    328291                }
    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());
    368292            }
    369293        } else {
     
    599523    }
    600524
    601     public Point2D transformPoint(Point2D p) throws NoninvertibleTransformException {
     525    public Point2D transformPoint(Point p) throws NoninvertibleTransformException {
    602526        // Position image at the right graphical place
    603527
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/transform/PictureTransform.java

    r35001 r35003  
    88
    99import org.openstreetmap.josm.data.coor.EastNorth;
    10 import org.openstreetmap.josm.plugins.piclayer.actions.transform.autocalibrate.helper.ObservableArrayList;
    1110
    1211public class PictureTransform {
     
    3029        cachedTransform = new AffineTransform();
    3130        originPoints = new ArrayList<>(3);
    32         latLonOriginPoints = new ObservableArrayList<>(3);
    3331    }
    3432
     
    188186
    189187    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);
    195189    }
    196190
     
    198192        originPoints.remove(selectedPoint);
    199193    }
    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     }
    233194}
Note: See TracChangeset for help on using the changeset viewer.