Ignore:
Timestamp:
2013-03-21T07:42:54+01:00 (12 years ago)
Author:
zverik
Message:

small refactoring of iodb

Location:
applications/editors/josm/plugins/imagery_offset_db/src/iodb
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/DeprecateOffsetAction.java

    r29380 r29381  
    11package iodb;
    22
    3 import iodb.QuerySuccessListener;
    43import java.awt.event.ActionEvent;
    54import java.io.UnsupportedEncodingException;
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/GetImageryOffsetAction.java

    r29380 r29381  
    1010import org.openstreetmap.josm.Main;
    1111import org.openstreetmap.josm.actions.JosmAction;
     12import org.openstreetmap.josm.data.coor.CoordinateFormat;
    1213import org.openstreetmap.josm.data.coor.LatLon;
    1314import org.openstreetmap.josm.data.projection.Projection;
     
    7374            super(null, tr("Loading imagery offsets..."));
    7475            try {
    75                 String query = "get?lat=" + center.lat() + "&lon=" + center.lon()
     76                String query = "get?lat=" + center.latToString(CoordinateFormat.DECIMAL_DEGREES)
     77                        + "&lon=" + center.lonToString(CoordinateFormat.DECIMAL_DEGREES)
    7678                        + "&imagery=" + URLEncoder.encode(imagery, "UTF8");
    7779                int radius = Main.pref.getInteger("iodb.radius", -1);
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetInfoAction.java

    r29380 r29381  
    66import javax.swing.JOptionPane;
    77import org.openstreetmap.josm.Main;
    8 import org.openstreetmap.josm.data.coor.LatLon;
    98import static org.openstreetmap.josm.tools.I18n.tr;
    109import org.openstreetmap.josm.tools.ImageProvider;
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/QuerySuccessListener.java

    r29380 r29381  
    66 * @author zverik
    77 */
    8 interface QuerySuccessListener {
     8public interface QuerySuccessListener {
    99
    1010    /**
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/StoreImageryOffsetAction.java

    r29380 r29381  
    2828
    2929    public void actionPerformed(ActionEvent e) {
    30         if( Main.map == null || Main.map.mapView == null || getCurrentDataSet() == null )
     30        if( Main.map == null || Main.map.mapView == null )
    3131            return;
    3232
     
    4343        // check if an object suitable for calibration is selected
    4444        OsmPrimitive calibration = null;
    45         Collection<OsmPrimitive> selectedObjects = getCurrentDataSet().getSelected();
    46         if( selectedObjects.size() == 1 ) {
    47             OsmPrimitive selection = selectedObjects.iterator().next();
    48             if( (selection instanceof Node || selection instanceof Way) && !selection.isIncomplete() && !selection.isReferredByWays(1) ) {
    49                 String[] options = new String[] {tr("Store calibration geometry"), tr("Store imagery offset")};
    50                 int result = JOptionPane.showOptionDialog(Main.parent,
    51                         tr("The selected object can be used as a calibration geometry. What do you intend to do?"),
    52                         ImageryOffsetTools.DIALOG_TITLE, JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE,
    53                         null, options, options[0]);
    54                 if( result == 2 || result == JOptionPane.CLOSED_OPTION )
    55                     return;
    56                 if( result == 0 )
    57                     calibration = selection;
     45        if( getCurrentDataSet() != null ) {
     46            Collection<OsmPrimitive> selectedObjects = getCurrentDataSet().getSelected();
     47            if( selectedObjects.size() == 1 ) {
     48                OsmPrimitive selection = selectedObjects.iterator().next();
     49                if( (selection instanceof Node || selection instanceof Way) && !selection.isIncomplete() && !selection.isReferredByWays(1) ) {
     50                    String[] options = new String[] {tr("Store calibration geometry"), tr("Store imagery offset")};
     51                    int result = JOptionPane.showOptionDialog(Main.parent,
     52                            tr("The selected object can be used as a calibration geometry. What do you intend to do?"),
     53                            ImageryOffsetTools.DIALOG_TITLE, JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE,
     54                            null, options, options[0]);
     55                    if( result == 2 || result == JOptionPane.CLOSED_OPTION )
     56                        return;
     57                    if( result == 0 )
     58                        calibration = selection;
     59                }
    5860            }
    5961        }
     
    132134        if( ImageryOffsetTools.getTopImageryLayer() == null )
    133135            state = false;
    134         if( getCurrentDataSet() == null )
    135             state = false;
    136136        setEnabled(state);
    137137    }
Note: See TracChangeset for help on using the changeset viewer.