X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fgui%2Fcolour%2FDiscretePointColourer.java;fp=tim%2Fprune%2Fgui%2Fcolour%2FDiscretePointColourer.java;h=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hp=9549a934f48aa4c4f6f8e2fdbaa64fe38733fbcf;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465;p=GpsPrune.git diff --git a/tim/prune/gui/colour/DiscretePointColourer.java b/tim/prune/gui/colour/DiscretePointColourer.java deleted file mode 100644 index 9549a93..0000000 --- a/tim/prune/gui/colour/DiscretePointColourer.java +++ /dev/null @@ -1,124 +0,0 @@ -package tim.prune.gui.colour; - -import java.awt.Color; - -/** - * Abstract class to do the discrete colouring of points, - * using start and end colours and a wrapping index - */ -public abstract class DiscretePointColourer extends PointColourer -{ - /** array of discrete colours to use */ - private Color[] _discreteColours = null; - /** array of colour indexes */ - private int[] _colourIndexes = null; - - - /** - * Constructor - * @param inStartColour start colour of scale - * @param inEndColour end colour of scale - * @param inMaxColours number of unique colours before wrap - */ - public DiscretePointColourer(Color inStartColour, Color inEndColour, int inMaxColours) - { - super(inStartColour, inEndColour, inMaxColours); - } - - /** max number of colours is required here */ - public static boolean isMaxColoursRequired() { - return true; - } - - /** - * Initialise the array to the right size - * @param inNumPoints number of points in the track - */ - protected void init(int inNumPoints) - { - if (_colourIndexes == null || _colourIndexes.length != inNumPoints) - { - // Array needs to be created or resized - if (inNumPoints > 0) { - _colourIndexes = new int[inNumPoints]; - } - else { - _colourIndexes = null; - } - } - } - - /** - * Set the colour at the given index - * @param inPointIndex point index - * @param inColourIndex index of colour to use - */ - protected void setColour(int inPointIndex, int inColourIndex) - { - if (_colourIndexes != null && _colourIndexes.length > inPointIndex && inPointIndex >= 0) - { - _colourIndexes[inPointIndex] = inColourIndex; - } - } - - /** - * Get the colour for the given point index - * @param inPointIndex index of point in track - * @return colour object - */ - public Color getColour(int inPointIndex) - { - if (_colourIndexes != null && _colourIndexes.length > inPointIndex && inPointIndex >= 0 && getMaxColours() > 0) - { - int colourIndex = _colourIndexes[inPointIndex] % getMaxColours(); - if (colourIndex >= 0 && _discreteColours != null && colourIndex < _discreteColours.length) { - return _discreteColours[colourIndex]; - } - } - // not found, use default - return super.getDefaultColour(); - } - - /** - * Generate the set of discrete colours to use - * @param inNumCategories number of different categories found in the data - */ - protected void generateDiscreteColours(int inNumCategories) - { - int maxColours = getMaxColours(); - if (maxColours <= 1) {maxColours = 2;} - if (inNumCategories < 1) {inNumCategories = 1;} - else if (inNumCategories > maxColours) {inNumCategories = maxColours;} - - // Use this number of categories to generate the colours - _discreteColours = new Color[inNumCategories]; - for (int i=0; i