Update to Worldwind release 20070920
[worldwind-tracker.git] / gov / nasa / worldwind / layers / TrackLayer.java
blob71223bf48f8ffd840663a9bc516eeb82d1e251fa
1 /*
2 Copyright (C) 2001, 2006 United States Government
3 as represented by the Administrator of the
4 National Aeronautics and Space Administration.
5 All Rights Reserved.
6 */
7 package gov.nasa.worldwind.layers;
9 import gov.nasa.worldwind.tracks.*;
10 import gov.nasa.worldwind.geom.Sector;
11 import gov.nasa.worldwind.util.Logging;
12 import gov.nasa.worldwind.render.DrawContext;
13 import gov.nasa.worldwind.globes.SectorGeometryList;
15 import java.util.List;
17 /**
18 * @author tag
19 * @version $Id: TrackLayer.java 2817 2007-09-12 19:28:14Z tgaskins $
21 public abstract class TrackLayer extends AbstractLayer
23 private java.util.List<Track> tracks = new java.util.ArrayList<Track>();
24 private Sector boundingSector;
25 private int lowerLimit;
26 private int upperLimit;
27 private boolean overrideElevation = false;
28 private double elevation = 10d;
30 public TrackLayer(List<Track> tracks)
32 if (tracks == null)
34 String msg = Logging.getMessage("nullValue.TracksIsNull");
35 Logging.logger().severe(msg);
36 throw new IllegalArgumentException(msg);
39 this.tracks = tracks;
40 this.boundingSector = Sector.boundingSector(this.iterator());
43 public TrackPointIteratorImpl iterator()
45 return new TrackPointIteratorImpl(this.tracks);
48 public int getNumPoints()
50 return this.iterator().getNumPoints();
53 public List<Track> getTracks()
55 return tracks;
58 public void setTracks(List<Track> tracks)
60 this.tracks = tracks;
63 public Sector getBoundingSector()
65 return boundingSector;
68 public void setBoundingSector(Sector boundingSector)
70 this.boundingSector = boundingSector;
73 public int getLowerLimit()
75 return lowerLimit;
78 public void setLowerLimit(int lowerLimit)
80 this.lowerLimit = lowerLimit;
83 public int getUpperLimit()
85 return upperLimit;
88 public void setUpperLimit(int upperLimit)
90 this.upperLimit = upperLimit;
93 public double getElevation()
95 return this.elevation;
98 public void setElevation(double markerElevation)
100 this.elevation = markerElevation;
103 public boolean isOverrideElevation()
105 return this.overrideElevation;
108 public void setOverrideElevation(boolean overrideElevation)
110 this.overrideElevation = overrideElevation;
113 @Override
114 public String toString()
116 return Logging.getMessage("layers.TrackLayer.Name");
119 @Override
120 protected void doPick(DrawContext dc, java.awt.Point pickPoint)
122 this.draw(dc, pickPoint);
125 protected void doRender(DrawContext dc)
127 this.draw(dc, null);
130 private void draw(DrawContext dc, java.awt.Point pickPoint)
132 TrackPointIterator trackPoints = this.iterator();
133 if (!trackPoints.hasNext())
134 return;
136 if (dc.getVisibleSector() == null)
137 return;
139 SectorGeometryList geos = dc.getSurfaceGeometry();
140 if (geos == null)
141 return;
143 if (!dc.getVisibleSector().intersects(this.getBoundingSector()))
144 return;
146 this.doDraw(dc, trackPoints, pickPoint);
149 protected abstract void doDraw(DrawContext dc, TrackPointIterator trackPoints, java.awt.Point pickPoint);