Ignore:
Timestamp:
2005-10-20T13:00:33+02:00 (19 years ago)
Author:
imi
Message:
  • started command implementation
  • cleaned up Layer
  • gpsbabel style for importing qpegps tracks
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/gui/layer/Layer.java

    r17 r21  
    55import javax.swing.Icon;
    66
    7 import org.openstreetmap.josm.data.osm.DataSet;
     7import org.openstreetmap.josm.command.DataSet;
     8import org.openstreetmap.josm.data.osm.LineSegment;
     9import org.openstreetmap.josm.data.osm.Node;
     10import org.openstreetmap.josm.data.osm.Track;
    811import org.openstreetmap.josm.gui.MapView;
     12import org.openstreetmap.josm.gui.engine.Engine;
    913
    1014/**
     
    2327 * @author imi
    2428 */
    25 public interface Layer {
     29abstract public class Layer {
    2630
    2731        /**
    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.
    3333         */
    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        }
    3575
    3676        /**
     
    3878         * be larger than 64 pixel in any dimension.
    3979         */
    40         Icon getIcon();
     80        abstract public Icon getIcon();
    4181
    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 dataset
    50          *              is available.
    51          */
    52         DataSet getDataSet();
    53        
    5482        /**
    5583         * @return <code>true</code>, if the map data can be edited.
    5684         */
    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        }
    6888}
Note: See TracChangeset for help on using the changeset viewer.