Changeset 21 in josm for src/org/openstreetmap/josm/gui/layer/Layer.java
- Timestamp:
- 2005-10-20T13:00:33+02:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/gui/layer/Layer.java
r17 r21 5 5 import javax.swing.Icon; 6 6 7 import org.openstreetmap.josm.data.osm.DataSet; 7 import org.openstreetmap.josm.command.DataSet; 8 import org.openstreetmap.josm.data.osm.LineSegment; 9 import org.openstreetmap.josm.data.osm.Node; 10 import org.openstreetmap.josm.data.osm.Track; 8 11 import org.openstreetmap.josm.gui.MapView; 12 import org.openstreetmap.josm.gui.engine.Engine; 9 13 10 14 /** … … 23 27 * @author imi 24 28 */ 25 public interfaceLayer {29 abstract public class Layer { 26 30 27 31 /** 28 * Draw the layer on the given Graphics. The state of the graphics object 29 * can be changed (drawing color..) 30 * 31 * @param g The graphics to draw the layer on. 32 * @param mv The MapView with information about the screen layout. 32 * The visibility state of the layer. 33 33 */ 34 void paint(Graphics g, MapView mv); 34 public boolean visible = true; 35 /** 36 * The dataSet this layer operates on, if any. Not all layer may have a 37 * dataset associated. 38 */ 39 public final DataSet dataSet; 40 /** 41 * The name of this layer. 42 */ 43 public final String name; 44 /** 45 * The engine used to draw the data. 46 */ 47 private final Engine engine; 48 49 /** 50 * Create the layer and fill in the necessary components. 51 * @param dataSet The DataSet, this layer operates on. Can be <code>null</code>. 52 */ 53 public Layer(DataSet dataSet, Engine engine, String name) { 54 if (engine == null || name == null) 55 throw new NullPointerException(); 56 this.dataSet = dataSet; 57 this.name = name; 58 this.engine = engine; 59 } 60 61 /** 62 * Paint the dataset using the engine set. 63 * @param mv The object that can translate GeoPoints to screen coordinates. 64 */ 65 public final void paint(Graphics g, MapView mv) { 66 engine.init(g, mv); 67 68 for (Track t : dataSet.tracks()) 69 engine.drawTrack(t); 70 for (LineSegment ls : dataSet.pendingLineSegments()) 71 engine.drawPendingLineSegment(ls); 72 for (Node n : dataSet.nodes) 73 engine.drawNode(n); 74 } 35 75 36 76 /** … … 38 78 * be larger than 64 pixel in any dimension. 39 79 */ 40 Icon getIcon();80 abstract public Icon getIcon(); 41 81 42 /**43 * Provide a human readable name (may be in html format).44 */45 String getName();46 47 /**48 * If the layer has a dataset it can provide, return it here.49 * @return The dataset for this layer or <code>null</code> if no dataset50 * is available.51 */52 DataSet getDataSet();53 54 82 /** 55 83 * @return <code>true</code>, if the map data can be edited. 56 84 */ 57 boolean isEditable(); 58 59 /** 60 * @return <code>true</code>, if the layer is visible 61 */ 62 boolean isVisible(); 63 64 /** 65 * Set the visibility state of the layer. 66 */ 67 void setVisible(boolean visible); 85 public boolean isEditable() { 86 return false; 87 } 68 88 }
Note:
See TracChangeset
for help on using the changeset viewer.