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