source: josm/trunk/src/org/openstreetmap/josm/gui/layer/MapViewPaintable.java@ 10461

Last change on this file since 10461 was 10461, checked in by Don-vip, 8 years ago

see #13029 - fix javadoc warnings

  • Property svn:eol-style set to native
File size: 4.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.layer;
3
4import java.awt.Graphics2D;
5
6import org.openstreetmap.josm.data.Bounds;
7import org.openstreetmap.josm.gui.MapView;
8
9/**
10 * This is a component that can be painted on the map view.
11 * <p>
12 * You might want to extend {@link AbstractMapViewPaintable} to ease implementation of this.
13 * <p>
14 * That class allows you to listen to paintable change events. Those methods may be moved here some time in the future.
15 */
16public interface MapViewPaintable {
17
18 /**
19 * This event is fired whenever the paintable got invalidated and needs repainting some time in the future.
20 * <p>
21 * Note: We might add an area in the future.
22 *
23 * @author Michael Zangl
24 */
25 class PaintableInvalidationEvent {
26 private final MapViewPaintable paintable;
27
28 /**
29 * Creates a new {@link PaintableInvalidationEvent}
30 * @param paintable The paintable that is invalidated.
31 */
32 public PaintableInvalidationEvent(MapViewPaintable paintable) {
33 this.paintable = paintable;
34 }
35
36 /**
37 * Gets the layer that was invalidated.
38 * @return The layer.
39 */
40 public MapViewPaintable getLayer() {
41 return paintable;
42 }
43
44 @Override
45 public String toString() {
46 return "LayerInvalidationEvent [layer=" + paintable + ']';
47 }
48 }
49
50 /**
51 * This is a listener that listens to {@link PaintableInvalidationEvent}s
52 * @author Michael Zangl
53 */
54 interface PaintableInvalidationListener {
55 /**
56 * Called whenever a {@link PaintableInvalidationEvent} is fired. This might be called from any thread.
57 * @param event The event
58 */
59 void paintablInvalidated(PaintableInvalidationEvent event);
60 }
61
62 /**
63 * Gets a new LayerPainter that paints this {@link MapViewPaintable} to the given map view.
64 *
65 * @author Michael Zangl
66 * @since 10458
67 */
68 public interface LayerPainter {
69
70 /**
71 * Paints the given layer.
72 * <p>
73 * This can be called in any thread at any time. You will not receive parallel calls for the same map view but you can receive parallel
74 * calls if you use the same {@link LayerPainter} for different map views.
75 * @param graphics The graphics object of the map view you should use.
76 * It provides you with a content pane, the bounds and the view state.
77 */
78 void paint(MapViewGraphics graphics);
79
80 /**
81 * Called when the layer is removed from the map view and this painter is not used any more.
82 * <p>
83 * This method is called once on the painter returned by {@link Layer#attachToMapView}
84 * @param event The event.
85 */
86 void detachFromMapView(MapViewEvent event);
87 }
88
89 /**
90 * A event that is fired whenever the map view is attached or detached from any layer.
91 * @author Michael Zangl
92 * @see Layer#attachToMapView
93 * @since 10458
94 */
95 class MapViewEvent {
96 private final MapView mapView;
97 private final boolean temporaryLayer;
98
99 /**
100 * Create a new {@link MapViewEvent}
101 * @param mapView The map view
102 * @param temporaryLayer <code>true</code> if this layer is in the temporary layer list of the view.
103 */
104 public MapViewEvent(MapView mapView, boolean temporaryLayer) {
105 super();
106 this.mapView = mapView;
107 this.temporaryLayer = temporaryLayer;
108 }
109
110 /**
111 * Gets the map view.
112 * @return The map view.
113 */
114 public MapView getMapView() {
115 return mapView;
116 }
117
118 /**
119 * @return true if this {@link MapViewPaintable} is used as a temporary layer.
120 */
121 public boolean isTemporaryLayer() {
122 return temporaryLayer;
123 }
124
125 @Override
126 public String toString() {
127 return "AttachToMapViewEvent [mapView=" + mapView + ", temporaryLayer=" + temporaryLayer + "]";
128 }
129 }
130
131 /**
132 * Paint the dataset using the engine set.
133 * @param g Graphics
134 * @param mv The object that can translate GeoPoints to screen coordinates.
135 * @param bbox Bounding box
136 */
137 void paint(Graphics2D g, MapView mv, Bounds bbox);
138}
Note: See TracBrowser for help on using the repository browser.