1 package tim.prune.gui.colour;
4 import java.util.ArrayList;
6 import tim.prune.data.DataPoint;
7 import tim.prune.data.FileInfo;
8 import tim.prune.data.SourceInfo;
9 import tim.prune.data.TrackInfo;
12 * Colours points according to which file (or source) they came from
14 public class FileColourer extends DiscretePointColourer
18 * @param inStartColour start colour of scale
19 * @param inEndColour end colour of scale
20 * @param inWrapLength number of unique colours before wrap
22 public FileColourer(Color inStartColour, Color inEndColour, int inWrapLength)
24 super(inStartColour, inEndColour, inWrapLength);
28 * Calculate the colours for each of the points in the given track
29 * @param inTrackInfo track info object
32 public void calculateColours(TrackInfo inTrackInfo)
34 // initialise the array to the right size
35 final int numPoints = inTrackInfo.getTrack().getNumPoints();
38 // loop over track points
39 FileInfo fInfo = inTrackInfo.getFileInfo();
40 ArrayList<SourceInfo> sourceList = new ArrayList<SourceInfo>();
41 for (int i=0; i<numPoints; i++)
43 DataPoint p = inTrackInfo.getTrack().getPoint(i);
44 if (p != null && !p.isWaypoint())
46 SourceInfo sInfo = fInfo.getSourceForPoint(p);
47 // Is this info object already in the list?
50 for (SourceInfo si : sourceList) {
57 // Add source info to list
60 sourceList.add(sInfo);
61 foundIndex = sourceList.size()-1;
63 // use this foundIndex to find the colour
64 setColour(i, foundIndex);
67 // generate the colours needed
68 generateDiscreteColours(sourceList.size());