Changeset 17327 in osm for applications


Ignore:
Timestamp:
2009-08-28T22:06:42+02:00 (15 years ago)
Author:
tstelmach
Message:

Saving / loading image calibration

Location:
applications/editors/josm/plugins/piclayer
Files:
3 added
9 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/piclayer/README

    r17323 r17327  
    22========
    33
    4 This plugin is meant for showing images as a background of the data being edited.It offers two ways of loading the data - from a file and from the clipboard.This is an early version and is not end-user-proof, so please follow the steps exactly in case you want to use it.Actually... it's barely working at the moment but I already find it very useful :).
     4A plugin for JOSM editor. Use it wisely - do not copy from copyrighted maps. Use "help" option to get a short tutorial.
    55
    6 NOTE: Make sure the image is suitable, copyright-wise, if in doubt, don't use.
    7 Step 1) Load some data from the server so that map is visible.
    8 Step 2) Go to PicLayer menu and either choose to add a layer from a file or from the clipboard.
    9 Step 2a) If you chose a file, a file selector will pop-up. Choose the image you want. Of course the format you are using might not be supported yet :)
    10 Step 2b) If you chose a clipboard, please wait. For some reason it takes time. To be fixed later.
    11 NOTE) If something failed, you should get a message box. If not - check the console for messages (Linux only?)
    12 Step 3) Once the image is visible you may start positioning it. For that - select the PicLayer in the layers list and activate it (!).
    13 Step 4) Start aligning the image.
    14 Step 4a) Move the image by choosing 'Move' from the toolbar and draggin the mouse around with left button pressed.
    15 Step 4b) Rotate the image by choosing 'Rotate' from the toolbar and draggin the mouse up/down with left button pressed.
    16 Step 4c) Scale the image by choosing 'Scale' from the toolbar and draggin the mouse up/down with left button pressed.
    17 NOTE) If it does not work - make sure the right layer is selected.
    18 Step 5) If you need to reset your changes - you can use the popup menu available under the PicLayer entry in the layer list.
    19 
    20 This plugin is meant to help with mapping from photos (for me it's mostly buildings) for people who simply don't like MetaCarta Rectifier (like me).
    21 
    22 Although I wrote it only to help myself and currently have no intention of extending it beyond what I need, you may still contact me with any suggestions that you think are important: tomasz.stelmach@poczta.onet.pl
    23 
    24 I used wmsplugin and routing plugin code very much during coding. Thank you and I hope you don't mind :)
     6Author: Tomasz Stelmach
     7Email: tomasz.stelmach@poczta.onet.pl
     8WWW: http://www.stelmach-online.net/
    259
    2610HISTORY:
     
    29132009.08.28:
    3014- added support for scaling in one axis only
     15- added support for saving / loading image calibration
    3116- added new icons
     17
     182009.04.27:
     19- initial version
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/HelpAction.java

    r17321 r17327  
    7676            + "Step 4d) You can also choose to scale in just one axis by selecting the proper button."
    7777            + "\n"
    78             + "NOTE) If it does not work - make sure the right layer is selected."
     78            + "NOTE) If it does not work - make sure the right layer is selected AND ACTIVATED."
    7979            + "\n"
    8080            + "Step 5) If you need to reset your changes - you can use the popup menu available under the PicLayer entry in the layer list."
     81            + "\n"
     82            + "Step 6) If you want to save the calibraton of the picture you have made, you can also do this using the popup menu."
    8183            + "\n\n"
    8284            + "This plugin is meant to help with mapping from photos (for me it's mostly buildings) for people who simply don't like MetaCarta Rectifier (like me)."
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerAbstract.java

    r17321 r17327  
    2929import java.awt.image.BufferedImage;
    3030import java.io.IOException;
     31import java.util.Properties;
     32
    3133import javax.swing.Icon;
    3234import javax.swing.ImageIcon;
     
    6870    // Layer icon
    6971    private Icon m_layericon = null;
     72   
     73    // Keys for saving in Properties
     74    private final String INITIAL_POS_X = "INITIAL_POS_X";
     75    private final String INITIAL_POS_Y = "INITIAL_POS_y";
     76    private final String POSITION_X = "POSITION_X";
     77    private final String POSITION_Y = "POSITION_Y";
     78    private final String ANGLE = "ANGLE";
     79    private final String INITIAL_SCALE = "INITIAL_SCALE";
     80    private final String SCALEX = "SCALEX";
     81    private final String SCALEY = "SCALEY";
    7082
    7183    /**
     
    89101        m_popupmenu = new Component[]{
    90102                reset_submenu,
     103                new JSeparator(),
     104                new JMenuItem( new SavePictureCalibrationAction(this)),
     105                new JMenuItem( new LoadPictureCalibrationAction(this)),
    91106                new JSeparator(),
    92107                new JMenuItem( new HelpAction() )
     
    263278
    264279    }
     280
     281    /**
     282     * Saves the calibration data into properties structure
     283     * @param props Properties to save to
     284     */
     285    public void saveCalibration( Properties props ) {
     286        // Save
     287        props.put(INITIAL_POS_X, "" + m_initial_position.getX());
     288        props.put(INITIAL_POS_Y, "" + m_initial_position.getY());
     289        props.put(POSITION_X, "" + m_position.getX());
     290        props.put(POSITION_Y, "" + m_position.getY());
     291        props.put(INITIAL_SCALE, "" + m_initial_scale);
     292        props.put(SCALEX, "" + m_scalex);
     293        props.put(SCALEY, "" + m_scaley);
     294        props.put(ANGLE, "" + m_angle);
     295    }
     296   
     297    /**
     298     * Loads calibration data from properties structure
     299     * @param props Properties to load from
     300     * @return
     301     */
     302    public void loadCalibration( Properties props ) {
     303        // Load
     304                double pos_x = Double.valueOf( props.getProperty(POSITION_X));
     305                double pos_y = Double.valueOf( props.getProperty(POSITION_Y));
     306                double in_pos_x = Double.valueOf( props.getProperty(INITIAL_POS_X));
     307                double in_pos_y = Double.valueOf( props.getProperty(INITIAL_POS_Y));
     308                double angle = Double.valueOf( props.getProperty(ANGLE));
     309                double in_scale = Double.valueOf( props.getProperty(INITIAL_SCALE));
     310                double scale_x = Double.valueOf( props.getProperty(SCALEX));
     311                double scale_y = Double.valueOf( props.getProperty(SCALEY));
     312                        m_position.setLocation(pos_x, pos_y);
     313                m_initial_position.setLocation(pos_x, pos_y);
     314                m_angle = angle;
     315                m_scalex = scale_x;
     316                m_scaley = scale_y;
     317                m_initial_scale = in_scale;
     318                // Refresh
     319            Main.map.mapView.repaint();
     320    }
    265321}
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerFromClipboard.java

    r14779 r17327  
    6161        @Override
    6262        protected String getPicLayerName() {
    63                 return super.name + " <Clipboard>";
     63                return "Clipboard";
    6464        }
    6565
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerFromFile.java

    r14779 r17327  
    4040        m_file = file;
    4141        // Generate tooltip text
    42         m_tooltiptext = super.name + " <" + m_file.getAbsolutePath() + ">";
     42        m_tooltiptext = m_file.getAbsolutePath();
    4343    }   
    4444   
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureAllAction.java

    r14779 r17327  
    3939         */
    4040        public ResetPictureAllAction( PicLayerAbstract owner ) {
    41                 super("All", null, null, null, false);
     41                super("All", null, "Resets picture calibration", null, false);
    4242                // Remember the owner...
    4343                m_owner = owner;
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureAngleAction.java

    r14779 r17327  
    3939         */
    4040        public ResetPictureAngleAction( PicLayerAbstract owner ) {
    41                 super("Angle", null, null, null, false);
     41                super("Angle", null, "Resets picture rotation", null, false);
    4242                // Remember the owner...
    4343                m_owner = owner;
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPicturePositionAction.java

    r14779 r17327  
    3939         */
    4040        public ResetPicturePositionAction( PicLayerAbstract owner ) {
    41                 super("Position", null, null, null, false);
     41                super("Position", null, "Resets picture position", null, false);
    4242                // Remember the owner...
    4343                m_owner = owner;
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/ResetPictureScaleAction.java

    r14779 r17327  
    3939         */
    4040        public ResetPictureScaleAction( PicLayerAbstract owner ) {
    41                 super("Scale", null, null, null, false);
     41                super("Scale", null, "Resets picture scale", null, false);
    4242                // Remember the owner...
    4343                m_owner = owner;
Note: See TracChangeset for help on using the changeset viewer.