]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - tim/prune/gui/colour/AltitudeColourer.java
Moved source into separate src directory due to popular request
[GpsPrune.git] / tim / prune / gui / colour / AltitudeColourer.java
diff --git a/tim/prune/gui/colour/AltitudeColourer.java b/tim/prune/gui/colour/AltitudeColourer.java
deleted file mode 100644 (file)
index 5ab79db..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-package tim.prune.gui.colour;
-
-import java.awt.Color;
-
-import tim.prune.data.DataPoint;
-import tim.prune.data.Track;
-import tim.prune.data.TrackInfo;
-
-/**
- * Colourer based on altitude values
- */
-public class AltitudeColourer extends ContinuousPointColourer
-{
-       /**
-        * Constructor
-        * @param inStartColour start colour
-        * @param inEndColour end colour
-        */
-       public AltitudeColourer(Color inStartColour, Color inEndColour)
-       {
-               super(inStartColour, inEndColour);
-       }
-
-       @Override
-       public void calculateColours(TrackInfo inTrackInfo)
-       {
-               Track track = inTrackInfo == null ? null : inTrackInfo.getTrack();
-               final int numPoints = track == null ? 0 : track.getNumPoints();
-               DataPoint point = null;
-
-               // Figure out altitude range
-               double minAltitude = 0.0;
-               double maxAltitude = 0.0;
-               boolean altFound = false;
-               for (int i=0; i<numPoints; i++)
-               {
-                       point = track.getPoint(i);
-                       if (point != null && point.hasAltitude())
-                       {
-                               double altValue = point.getAltitude().getMetricValue();
-                               if (altValue < minAltitude || !altFound) {minAltitude = altValue;}
-                               if (altValue > maxAltitude || !altFound) {maxAltitude = altValue;}
-                               altFound = true;
-                       }
-               }
-
-               if ((maxAltitude - minAltitude) < 1.0)
-               {
-                       // not enough altitude range, set all to null
-                       init(0);
-               }
-               else
-               {
-                       // initialise the array to the right size
-                       init(numPoints);
-                       // loop over track points to calculate colours
-                       for (int i=0; i<numPoints; i++)
-                       {
-                               point = track.getPoint(i);
-                               if (point != null && point.hasAltitude() && !point.isWaypoint())
-                               {
-                                       double altValue = point.getAltitude().getMetricValue();
-                                       double fraction = (altValue - minAltitude) / (maxAltitude - minAltitude);
-                                       setColour(i, mixColour((float) fraction));
-                               }
-                               else setColour(i, null);
-                       }
-               }
-       }
-}