Changeset 29394 in osm for applications/editors/josm


Ignore:
Timestamp:
2013-03-24T20:08:00+01:00 (11 years ago)
Author:
zverik
Message:

iodb: small refactoring, also offset watcher

Location:
applications/editors/josm/plugins/imagery_offset_db
Files:
2 added
3 edited

Legend:

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

    r29384 r29394  
    77import java.net.*;
    88import java.util.*;
     9import javax.swing.Action;
     10import javax.swing.Icon;
    911import javax.swing.JOptionPane;
    1012import org.openstreetmap.josm.Main;
     
    1517import org.openstreetmap.josm.gui.layer.ImageryLayer;
    1618import static org.openstreetmap.josm.tools.I18n.tr;
     19import org.openstreetmap.josm.tools.ImageProvider;
    1720import org.openstreetmap.josm.tools.Shortcut;
    1821
     
    2427 */
    2528public class GetImageryOffsetAction extends JosmAction {
     29    private Icon iconOffsetOk;
     30    private Icon iconOffsetBad;
    2631   
    2732    /**
    2833     * Initialize the action. Sets "Ctrl+Alt+I" shortcut: the only shortcut in this plugin.
     34     * Also registers itself with {@link ImageryOffsetWatcher}.
    2935     */
    3036    public GetImageryOffsetAction() {
     
    3238                Shortcut.registerShortcut("imageryoffset:get", tr("Imagery: {0}", tr("Get Imagery Offset...")),
    3339                KeyEvent.VK_I, Shortcut.ALT_CTRL), true);
     40        iconOffsetOk = ImageProvider.get("getoffset");
     41        iconOffsetBad = ImageProvider.get("getoffsetnow"); // todo: create icon
     42        ImageryOffsetWatcher.getInstance().register(this);
    3443    }
    3544
     
    8493
    8594    /**
     95     * Update action icon based on an offset state.
     96     */
     97    public void offsetStateChanged( boolean isOffsetGood ) {
     98        putValue(Action.SMALL_ICON, isOffsetGood ? iconOffsetOk : iconOffsetBad);
     99    }
     100
     101    /**
     102     * Remove offset listener.
     103     */
     104    @Override
     105    public void destroy() {
     106        ImageryOffsetWatcher.getInstance().unregister(this);
     107        super.destroy();
     108    }
     109
     110    /**
    86111     * A task that downloads offsets for a given position and imagery layer,
    87112     * then parses resulting XML and calls
    88113     * {@link #showOffsetDialog(java.util.List)} on success.
    89114     */
    90     class DownloadOffsetsTask extends SimpleOffsetQueryTask {
     115    private class DownloadOffsetsTask extends SimpleOffsetQueryTask {
    91116        private ImageryLayer layer;
    92117        private List<ImageryOffsetBase> offsets;
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetDialog.java

    r29388 r29394  
    1717import org.openstreetmap.josm.gui.JosmUserIdentityManager;
    1818import org.openstreetmap.josm.gui.MapView;
    19 import org.openstreetmap.josm.gui.NavigatableComponent;
    2019import org.openstreetmap.josm.gui.layer.ImageryLayer;
    2120import org.openstreetmap.josm.gui.layer.MapViewPaintable;
     
    2928 * @license WTFPL
    3029 */
    31 public class OffsetDialog extends JDialog implements ActionListener, NavigatableComponent.ZoomChangeListener, MapViewPaintable {
     30public class OffsetDialog extends JDialog implements ActionListener, MapView.ZoomChangeListener, MapViewPaintable {
    3231    protected static final String PREF_CALIBRATION = "iodb.show.calibration";
    3332    protected static final String PREF_DEPRECATED = "iodb.show.deprecated";
     
    5554        setResizable(false);
    5655        this.offsets = offsets;
    57         NavigatableComponent.addZoomChangeListener(this);
    5856
    5957        // make this dialog close on "escape"
     
    194192        selectedOffset = null;
    195193        prepareDialog();
     194        MapView.addZoomChangeListener(this);
    196195        if( !MODAL ) {
    197196            Main.map.mapView.addTemporaryLayer(this);
     
    218217                || Main.pref.getBoolean("iodb.close.on.select", true);
    219218        if( closeDialog ) {
    220             NavigatableComponent.removeZoomChangeListener(this);
     219            MapView.removeZoomChangeListener(this);
    221220            setVisible(false);
    222221        }
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetDialogButton.java

    r29390 r29394  
    7474        description = description.replace("<", "&lt;").replace(">", "&gt;");
    7575        JLabel descriptionLabel = new JLabel("<html><div style=\"width: 300px;\">"+description+"</div></html>");
    76         Font descriptionFont = new Font(descriptionLabel.getFont().getName(), Font.BOLD, descriptionLabel.getFont().getSize() - 2);
     76        Font descriptionFont = new Font(descriptionLabel.getFont().getName(), Font.BOLD, descriptionLabel.getFont().getSize());
    7777        descriptionLabel.setFont(descriptionFont);
    7878
Note: See TracChangeset for help on using the changeset viewer.