Package gov.nih.mipav.model.algorithms
Class ContourPlot.SimpleColorMap
- java.lang.Object
-
- gov.nih.mipav.model.algorithms.ContourPlot.SimpleColorMap
-
- All Implemented Interfaces:
ContourPlot.ColorMap
- Enclosing class:
- ContourPlot
public class ContourPlot.SimpleColorMap extends java.lang.Object implements ContourPlot.ColorMap
Implementation of theContourPlot.ColorMap
interface.- Author:
- hageldave
-
-
Constructor Summary
Constructors Constructor Description SimpleColorMap(int... colors)
Creates a newContourPlot.SimpleColorMap
with the specified colors and uniform spacing.SimpleColorMap(int[] colors, double[] locations)
Creates aContourPlot.SimpleColorMap
with the specified colors and corresponding locations in the unit interval.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getColor(int index)
Returns the ith colorint[]
getColors()
double
getLocation(int index)
Returns the location of the ith color within the unit interval.double[]
getLocations()
int
numColors()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.nih.mipav.model.algorithms.ContourPlot.ColorMap
copy, interpolate, resample
-
-
-
-
Constructor Detail
-
SimpleColorMap
public SimpleColorMap(int[] colors, double[] locations)
Creates aContourPlot.SimpleColorMap
with the specified colors and corresponding locations in the unit interval. As required by theContourPlot.ColorMap
interface the first location has to be 0, the last location has to 1 and the locations in between have to monotonically increase within ]0,1[.- Parameters:
colors
- integer packed ARGB values (e.g. 0xff00ff00 is opaque green)locations
- corresponding to colors. Within [0,1].- Throws:
java.lang.IllegalArgumentException
- if colors and locations are of different lengths, if less than 2 colors are specified, if locations does not start with 0 or does not end with 1, if locations is not sorted in ascending order.
-
SimpleColorMap
public SimpleColorMap(int... colors)
Creates a newContourPlot.SimpleColorMap
with the specified colors and uniform spacing.- Parameters:
colors
- integer packed ARGB values (e.g. 0xff00ff00 is opaque green)- Throws:
java.lang.IllegalArgumentException
- when less than 2 colors are specified.
-
-
Method Detail
-
numColors
public int numColors()
- Specified by:
numColors
in interfaceContourPlot.ColorMap
- Returns:
- the number of discrete colors in this
ContourPlot.ColorMap
-
getColor
public int getColor(int index)
Description copied from interface:ContourPlot.ColorMap
Returns the ith color- Specified by:
getColor
in interfaceContourPlot.ColorMap
- Parameters:
index
- index of the color- Returns:
- ith color in integer packed ARGB format (0xff00ff00 is opaque green)
-
getColors
public int[] getColors()
- Specified by:
getColors
in interfaceContourPlot.ColorMap
- Returns:
- all discrete colors in this
ContourPlot.ColorMap
in integer packed ARGB format (0xff00ff00 is opaque green)
-
getLocation
public double getLocation(int index)
Description copied from interface:ContourPlot.ColorMap
Returns the location of the ith color within the unit interval.- Specified by:
getLocation
in interfaceContourPlot.ColorMap
- Parameters:
index
- index of the location/color- Returns:
- location within [0,1]
-
getLocations
public double[] getLocations()
- Specified by:
getLocations
in interfaceContourPlot.ColorMap
- Returns:
- all locations of the discrete colors in this
ContourPlot.ColorMap
-
-