Class GradientMapper
java.lang.Object
org.biojava.nbio.structure.gui.util.color.GradientMapper
- All Implemented Interfaces:
Map<Double,,Color> ContinuousColorMapper
Maps a set of real values onto a gradient.
The real line is partitioned into segments [a,b). The endpoint of each segment is labeled with a color.
Colors are linearly interpolated between finite endpoints. Endpoints implicitly exist for
Double.NEGATIVE_INFINITY and Double.POSITIVE_INFINITY, representing default colors. Thus any point
in the segment [-Inf,a) is labeled with the negInf color, and any point in [b,Inf] is labeled with the posInf
color. If no endpoints are present, the posInf color is used as default.
Common gradients are predefined an may be instantiated through
GradientMapper.getGradientMapper().
- Author:
- Spencer Bliven
-
Nested Class Summary
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionGradientMapper(Color negInf, Color posInf) GradientMapper(Color negInf, Color posInf, ColorSpace cspace) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all finite endpointsbooleancontainsKey(Object position) booleancontainsValue(Object color) entrySet()getColor(double value) static GradientMappergetGradientMapper(int gradientType, double min, double max) Constructs a gradientMapper to draw one of the pre-defined gradients For example, GradientMapper.getGradientMapper(GradientMapper.RAINBOW_GRADIENT, 0, 10)booleanisEmpty()keySet()static voidAdds a gradient endpoint at the specified position.voidvoidsetInterpolator(ColorInterpolator interpolator) intsize()values()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
BLACK_WHITE_GRADIENT
public static final int BLACK_WHITE_GRADIENT- See Also:
-
WHITE_BLACK_GRADIENT
public static final int WHITE_BLACK_GRADIENT- See Also:
-
RED_BLUE_GRADIENT
public static final int RED_BLUE_GRADIENT- See Also:
-
RAINBOW_GRADIENT
public static final int RAINBOW_GRADIENT- See Also:
-
RAINBOW_INTENSITY_GRADIENT
public static final int RAINBOW_INTENSITY_GRADIENT- See Also:
-
-
Constructor Details
-
GradientMapper
public GradientMapper() -
GradientMapper
-
GradientMapper
-
-
Method Details
-
getGradientMapper
Constructs a gradientMapper to draw one of the pre-defined gradients For example, GradientMapper.getGradientMapper(GradientMapper.RAINBOW_GRADIENT, 0, 10)- Parameters:
gradientType- One of the gradient types, eg GradientMapper.BLACK_WHITE_GRADIENTmin- Start of the gradientmax- End of the gradient- Returns:
-
getColor
- Specified by:
getColorin interfaceContinuousColorMapper- Parameters:
value-- Returns:
- See Also:
-
clear
public void clear()Clears all finite endpoints -
containsKey
- Specified by:
containsKeyin interfaceMap<Double,Color> - Parameters:
position-- Returns:
- See Also:
-
containsValue
- Specified by:
containsValuein interfaceMap<Double,Color> - Parameters:
color-- Returns:
- See Also:
-
entrySet
-
get
-
isEmpty
public boolean isEmpty() -
keySet
-
put
Adds a gradient endpoint at the specified position. -
putAll
-
remove
-
size
public int size() -
values
-
getInterpolator
- Returns:
- the interpolator
-
setInterpolator
- Parameters:
interpolator- the interpolator to set
-
main
- Parameters:
args-
-