Ignore:
Timestamp:
2017-04-28T14:36:21+02:00 (3 years ago)
Author:
michael2402
Message:

See #14120: Use a listener to get notified of way segment / virtual node highlight changes.

Location:
trunk/src/org/openstreetmap/josm/gui/layer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractMapViewPaintable.java

    r10600 r12014  
    8888    /**
    8989     * This needs to be called whenever the content of this view was invalidated.
     90     * It triggers a repaint of the components that display this layer.
    9091     */
    9192    public void invalidate() {
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r11893 r12014  
    6666import org.openstreetmap.josm.data.osm.DataSetMerger;
    6767import org.openstreetmap.josm.data.osm.DatasetConsistencyTest;
     68import org.openstreetmap.josm.data.osm.HighlightUpdateListener;
    6869import org.openstreetmap.josm.data.osm.IPrimitive;
    6970import org.openstreetmap.josm.data.osm.Node;
     
    117118 * @since 17
    118119 */
    119 public class OsmDataLayer extends AbstractModifiableLayer implements Listener, SelectionChangedListener {
     120public class OsmDataLayer extends AbstractModifiableLayer implements Listener, SelectionChangedListener, HighlightUpdateListener {
    120121    private static final int HATCHED_SIZE = 15;
    121122    /** Property used to know if this layer has to be saved on disk */
     
    126127    private boolean requiresSaveToFile;
    127128    private boolean requiresUploadToServer;
    128     private int highlightUpdateCount;
    129129
    130130    /**
     
    364364        data.addDataSetListener(new DataSetListenerAdapter(this));
    365365        data.addDataSetListener(MultipolygonCache.getInstance());
     366        data.addHighlightUpdateListener(this);
    366367        DataSet.addSelectionListener(this);
    367368        if (name != null && name.startsWith(createLayerName("")) && Character.isDigit(
     
    400401     */
    401402    @Override public void paint(final Graphics2D g, final MapView mv, Bounds box) {
    402         highlightUpdateCount = data.getHighlightUpdateCount();
    403 
    404403        boolean active = mv.getLayerManager().getActiveLayer() == this;
    405404        boolean inactive = !active && Main.pref.getBoolean("draw.data.inactive_color", true);
     
    908907
    909908    @Override
    910     public boolean isChanged() {
    911         return highlightUpdateCount != data.getHighlightUpdateCount();
    912     }
    913 
    914     @Override
    915909    public void onPostSaveToFile() {
    916910        setRequiresSaveToFile(false);
     
    952946        super.destroy();
    953947        DataSet.removeSelectionListener(this);
     948        data.removeHighlightUpdateListener(this);
    954949    }
    955950
     
    11021097        return v.getBounds();
    11031098    }
     1099
     1100    @Override
     1101    public void highlightUpdated(HighlightUpdateEvent e) {
     1102        invalidate();
     1103    }
    11041104}
Note: See TracChangeset for help on using the changeset viewer.