source: josm/src/org/openstreetmap/josm/gui/layer/Layer.java@ 71

Last change on this file since 71 was 71, checked in by imi, 18 years ago
  • refactored GpsPoint to be immutable and added LatLon and NorthEast
  • refactored Bounding Box calculations
  • various other renames
File size: 2.5 KB
Line 
1package org.openstreetmap.josm.gui.layer;
2
3import java.awt.Graphics;
4
5import javax.swing.Icon;
6
7import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
8import org.openstreetmap.josm.data.projection.Projection;
9import org.openstreetmap.josm.gui.MapView;
10
11/**
12 * A layer encapsulates the gui componente of one dataset and its representation.
13 *
14 * Some layers may display data directly importet from OSM server. Other only
15 * display background images. Some can be edited, some not. Some are static and
16 * other changes dynamically (auto-updated).
17 *
18 * Layers can be visible or not. Most actions the user can do applies only on
19 * selected layers. The available actions depend on the selected layers too.
20 *
21 * All layers are managed by the MapView. They are displayed in a list to the
22 * right of the screen.
23 *
24 * @author imi
25 */
26abstract public class Layer {
27
28 /**
29 * The visibility state of the layer.
30 */
31 public boolean visible = true;
32 /**
33 * The name of this layer.
34 */
35 public final String name;
36
37 /**
38 * Create the layer and fill in the necessary components.
39 */
40 public Layer(String name) {
41 this.name = name;
42 }
43
44 /**
45 * Paint the dataset using the engine set.
46 * @param mv The object that can translate GeoPoints to screen coordinates.
47 */
48 abstract public void paint(Graphics g, MapView mv);
49 /**
50 * Return a representative small image for this layer. The image must not
51 * be larger than 64 pixel in any dimension.
52 */
53 abstract public Icon getIcon();
54
55 /**
56 * @return A small tooltip hint about some statistics for this layer.
57 */
58 abstract public String getToolTipText();
59
60 /**
61 * Merges the given layer into this layer. Throws if the layer types are
62 * incompatible.
63 * @param from The layer that get merged into this one. After the merge,
64 * the other layer is not usable anymore and passing to one others
65 * mergeFrom should be one of the last things to do with a layer.
66 */
67 abstract public void mergeFrom(Layer from);
68
69 /**
70 * @param other The other layer that is tested to be mergable with this.
71 * @return Whether the other layer can be merged into this layer.
72 */
73 abstract public boolean isMergable(Layer other);
74
75 /**
76 * @return The bounding rectangle this layer occupies on screen when looking
77 * at x/y values or <code>null</code>, if infinite area or unknown
78 * area is occupied.
79 */
80 abstract public void visitBoundingBox(BoundingXYVisitor v);
81
82 /**
83 * Initialize the internal dataset with the given projection.
84 */
85 abstract public void init(Projection projection);
86}
Note: See TracBrowser for help on using the repository browser.