Package org.openstreetmap.josm.gui.layer
Class AbstractMapViewPaintable
- java.lang.Object
-
- org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable
-
- All Implemented Interfaces:
MapViewPaintable
- Direct Known Subclasses:
Layer,ParallelWayAction.ParallelWayLayer,SelectionManager.SelectionHintLayer
public abstract class AbstractMapViewPaintable extends java.lang.Object implements MapViewPaintable
This class implements the invalidation listener mechanism suggested byMapViewPaintableand a default #atta- Since:
- 10031
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classAbstractMapViewPaintable.CompatibilityModeLayerPainterThis is the default implementation of the layer painter.-
Nested classes/interfaces inherited from interface org.openstreetmap.josm.gui.layer.MapViewPaintable
MapViewPaintable.LayerPainter, MapViewPaintable.MapViewEvent, MapViewPaintable.PaintableInvalidationEvent, MapViewPaintable.PaintableInvalidationListener
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.CopyOnWriteArrayList<MapViewPaintable.PaintableInvalidationListener>invalidationListenersA list of invalidation listeners to call when this layer is invalidated.
-
Constructor Summary
Constructors Constructor Description AbstractMapViewPaintable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInvalidationListener(MapViewPaintable.PaintableInvalidationListener l)Adds a new paintable invalidation listener.MapViewPaintable.LayerPainterattachToMapView(MapViewPaintable.MapViewEvent event)This method is called whenever this layer is added to a map view.protected MapViewPaintable.LayerPaintercreateMapViewPainter(MapViewPaintable.MapViewEvent event)Creates a new LayerPainter.voidinvalidate()This needs to be called whenever the content of this view was invalidated.voidremoveInvalidationListener(MapViewPaintable.PaintableInvalidationListener l)Removes an added paintable invalidation listener.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.gui.layer.MapViewPaintable
paint
-
-
-
-
Field Detail
-
invalidationListeners
private final java.util.concurrent.CopyOnWriteArrayList<MapViewPaintable.PaintableInvalidationListener> invalidationListeners
A list of invalidation listeners to call when this layer is invalidated.
-
-
Constructor Detail
-
AbstractMapViewPaintable
public AbstractMapViewPaintable()
-
-
Method Detail
-
attachToMapView
public MapViewPaintable.LayerPainter attachToMapView(MapViewPaintable.MapViewEvent event)
This method is called whenever this layer is added to a map view.You need to return a painter here. The
MapViewPaintable.LayerPainter.detachFromMapView(org.openstreetmap.josm.gui.layer.MapViewPaintable.MapViewEvent)method is called when the layer is removed from that map view. You are free to reuse painters.You should always call the super method. See
createMapViewPainter(org.openstreetmap.josm.gui.layer.MapViewPaintable.MapViewEvent)if you want to influence painter creation.This replaces
Layer.hookUpMapView()in the long run.- Parameters:
event- the event.- Returns:
- A layer painter.
- Since:
- 10458
-
createMapViewPainter
protected MapViewPaintable.LayerPainter createMapViewPainter(MapViewPaintable.MapViewEvent event)
Creates a new LayerPainter.- Parameters:
event- The event that triggered the creation.- Returns:
- The painter.
- Since:
- 10458
-
addInvalidationListener
public void addInvalidationListener(MapViewPaintable.PaintableInvalidationListener l)
Description copied from interface:MapViewPaintableAdds a new paintable invalidation listener.- Specified by:
addInvalidationListenerin interfaceMapViewPaintable- Parameters:
l- The listener to add.
-
removeInvalidationListener
public void removeInvalidationListener(MapViewPaintable.PaintableInvalidationListener l)
Description copied from interface:MapViewPaintableRemoves an added paintable invalidation listener. May throw an exception if the listener is added twice.- Specified by:
removeInvalidationListenerin interfaceMapViewPaintable- Parameters:
l- The listener to remove.
-
invalidate
public void invalidate()
This needs to be called whenever the content of this view was invalidated. It triggers a repaint of the components that display this layer.
-
-