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
Implementation of the
ContourPlot.ColorMap interface.- Author:
- hageldave
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSimpleColorMap(int... colors) Creates a newContourPlot.SimpleColorMapwith the specified colors and uniform spacing.SimpleColorMap(int[] colors, double[] locations) Creates aContourPlot.SimpleColorMapwith the specified colors and corresponding locations in the unit interval. -
Method Summary
Modifier and TypeMethodDescriptionintgetColor(int index) Returns the ith colorint[]doublegetLocation(int index) Returns the location of the ith color within the unit interval.double[]intMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface gov.nih.mipav.model.algorithms.ContourPlot.ColorMap
copy, interpolate, resample
-
Field Details
-
colors
protected int[] colors -
locations
protected double[] locations
-
-
Constructor Details
-
SimpleColorMap
public SimpleColorMap(int[] colors, double[] locations) Creates aContourPlot.SimpleColorMapwith the specified colors and corresponding locations in the unit interval. As required by theContourPlot.ColorMapinterface 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:
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.SimpleColorMapwith the specified colors and uniform spacing.- Parameters:
colors- integer packed ARGB values (e.g. 0xff00ff00 is opaque green)- Throws:
IllegalArgumentException- when less than 2 colors are specified.
-
-
Method Details
-
numColors
public int numColors()- Specified by:
numColorsin interfaceContourPlot.ColorMap- Returns:
- the number of discrete colors in this
ContourPlot.ColorMap
-
getColor
public int getColor(int index) Description copied from interface:ContourPlot.ColorMapReturns the ith color- Specified by:
getColorin 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:
getColorsin interfaceContourPlot.ColorMap- Returns:
- all discrete colors in this
ContourPlot.ColorMapin integer packed ARGB format (0xff00ff00 is opaque green)
-
getLocation
public double getLocation(int index) Description copied from interface:ContourPlot.ColorMapReturns the location of the ith color within the unit interval.- Specified by:
getLocationin interfaceContourPlot.ColorMap- Parameters:
index- index of the location/color- Returns:
- location within [0,1]
-
getLocations
public double[] getLocations()- Specified by:
getLocationsin interfaceContourPlot.ColorMap- Returns:
- all locations of the discrete colors in this
ContourPlot.ColorMap
-