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/src/org/openstreetmap/josm/plugins/piclayer
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • 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.