Ignore:
Timestamp:
2013-03-21T21:30:58+01:00 (11 years ago)
Author:
zverik
Message:

iodb updates

File:
1 edited

Legend:

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

    r29380 r29382  
    1111import javax.swing.border.EmptyBorder;
    1212import org.openstreetmap.josm.Main;
     13import org.openstreetmap.josm.data.Bounds;
    1314import org.openstreetmap.josm.gui.JosmUserIdentityManager;
     15import org.openstreetmap.josm.gui.MapView;
    1416import org.openstreetmap.josm.gui.NavigatableComponent;
    1517import org.openstreetmap.josm.gui.layer.ImageryLayer;
     18import org.openstreetmap.josm.gui.layer.MapViewPaintable;
    1619import static org.openstreetmap.josm.tools.I18n.tr;
    1720import org.openstreetmap.josm.tools.ImageProvider;
     
    2326 * @author zverik
    2427 */
    25 public class OffsetDialog extends JDialog implements ActionListener, NavigatableComponent.ZoomChangeListener {
     28public class OffsetDialog extends JDialog implements ActionListener, NavigatableComponent.ZoomChangeListener, MapViewPaintable {
    2629    protected static final String PREF_CALIBRATION = "iodb.show.calibration";
    2730    protected static final String PREF_DEPRECATED = "iodb.show.deprecated";
     
    106109        }
    107110        pack();
     111        Main.map.mapView.repaint();
    108112    }
    109113
     
    131135        }
    132136    }
     137
     138    public void paint( Graphics2D g, MapView mv, Bounds bbox ) {
     139        if( offsets == null )
     140            return;
     141
     142        Graphics2D g2 = (Graphics2D)g.create();
     143        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
     144        g2.setStroke(new BasicStroke(2));
     145        for( ImageryOffsetBase offset : filterOffsets() ) {
     146            Point p = mv.getPoint(offset.getPosition());
     147            g2.setColor(Color.BLACK);
     148            g2.fillOval(p.x - 2, p.y - 2, 5, 5);
     149            g2.setColor(Color.WHITE);
     150            g2.drawOval(p.x - 3, p.y - 3, 7, 7);
     151        }
     152    }
    133153   
    134154    public ImageryOffsetBase showDialog() {
     155        // todo: add a temporary layer showing all offsets
    135156        selectedOffset = null;
    136157        prepareDialog();
     158        if( !MODAL ) {
     159            Main.map.mapView.addTemporaryLayer(this);
     160            Main.map.mapView.repaint();
     161        }
    137162        setVisible(true);
    138163        return selectedOffset;
     
    173198        NavigatableComponent.removeZoomChangeListener(this);
    174199        setVisible(false);
    175         if( !MODAL && selectedOffset != null )
    176             applyOffset();
     200        if( !MODAL ) {
     201            Main.map.mapView.removeTemporaryLayer(this);
     202            Main.map.mapView.repaint();
     203            if( selectedOffset != null )
     204                applyOffset();
     205        }
    177206    }
    178207
Note: See TracChangeset for help on using the changeset viewer.