Class SLDColorMapBuilder
- Object
-
- SLDColorMapBuilder
-
public class SLDColorMapBuilder extends Object
Builder facility for creating aLinearColorMapusing elements fromRasterSymbolizerColorMapTransformelement.This class is not intended to be thread safe.
- Author:
- Simone Giannecchini, GeoSolutions
-
-
Field Summary
Fields Modifier and Type Field Description static ColordefaultColorForValuesToPreservestatic ColordefaultGapsColorDefault color to fill gaps
-
Constructor Summary
Constructors Constructor Description SLDColorMapBuilder()Default constructor for theSLDColorMapBuilderclass.SLDColorMapBuilder(String name)Constructor for theSLDColorMapBuilderclass.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SLDColorMapBuilderaddColorMapEntry(ColorMapEntry colorMapEntry)SLDColorMapBuilderaddValueToPreserve(double value)Add a value that we should try to preserve while applying the color map.LinearColorMapbuildLinearColorMap()ColorgetColorForValuesToPreserve()booleangetExtendedColors()Getter of the property extendedColorsintgetLinearColorMapType()Retrieves theLinearColorMap.LinearColorMapTypefor thisSLDColorMapBuilder.intgetNumberColorMapEntries()Getter of the property numberColorMapEntriesintgetNumberOfColorMapElements()Getter of the property numberOfColorMapElementsdouble[]getValuesToPreserve()Retrieves the values to preserve.SLDColorMapBuildersetColorForValuesToPreserve(Color color)Set the color to use for the values we want to preserve.SLDColorMapBuildersetExtendedColors(boolean extendedColors)Setter of the property extendedColorsvoidsetGapsColor(Color defaultColor)Sets the defaultColorto use when a value falls outside the range of values for provided color map elements.SLDColorMapBuildersetLinearColorMapType(int colorMapType)Sets theLinearColorMap.LinearColorMapTypefor thisSLDColorMapBuilder.SLDColorMapBuildersetNumberColorMapEntries(int numberColorMapEntries)Setter of the property numberColorMapEntries
-
-
-
Constructor Detail
-
SLDColorMapBuilder
public SLDColorMapBuilder()
Default constructor for theSLDColorMapBuilderclass.
-
SLDColorMapBuilder
public SLDColorMapBuilder(String name)
Constructor for theSLDColorMapBuilderclass.- Parameters:
name- name for theLinearColorMapwe will create at the end of this process.
-
-
Method Detail
-
setGapsColor
public void setGapsColor(Color defaultColor)
Sets the defaultColorto use when a value falls outside the range of values for provided color map elements.Note that once the underlying colormap has been built this method will throw an
IllegalStateExceptionif invoked.In case one would want to unset the default color, he should simply call this method with a
nullvalue.- Parameters:
defaultColor- The defaultColorto use when a value falls outside the provided color map elements.- UML property:
- name="gapsColor"
-
setLinearColorMapType
public SLDColorMapBuilder setLinearColorMapType(int colorMapType)
Sets theLinearColorMap.LinearColorMapTypefor thisSLDColorMapBuilder.- Returns:
- this
SLDColorMapBuilder. - See Also:
LinearColorMap.LinearColorMapType- UML property:
- name="linearColorMapType"
-
getLinearColorMapType
public int getLinearColorMapType()
Retrieves theLinearColorMap.LinearColorMapTypefor thisSLDColorMapBuilder.-1is returned in case theLinearColorMap.LinearColorMapTypeis still unspecified.- Returns:
- the
LinearColorMap.LinearColorMapTypefor thisSLDColorMapBuilderor-1case theLinearColorMap.LinearColorMapTypeis still unspecified. - UML property:
- name="linearColorMapType"
-
addColorMapEntry
public SLDColorMapBuilder addColorMapEntry(ColorMapEntry colorMapEntry)
-
getValuesToPreserve
public double[] getValuesToPreserve()
Retrieves the values to preserve.- Returns:
- an array of double which represents the values that need to be preserved by the
ColorMapTransformwe will create.
-
addValueToPreserve
public SLDColorMapBuilder addValueToPreserve(double value)
Add a value that we should try to preserve while applying the color map.This means that all the values we add using this method will be mapped to the same color which can be set using
setColorForValuesToPreserve(Color).- Returns:
- this
SLDColorMapBuilder.
-
setColorForValuesToPreserve
public SLDColorMapBuilder setColorForValuesToPreserve(Color color)
Set the color to use for the values we want to preserve.- Returns:
- this
SLDColorMapBuilder.
-
getColorForValuesToPreserve
public Color getColorForValuesToPreserve()
- Returns:
-
getExtendedColors
public boolean getExtendedColors()
Getter of the property extendedColors- Returns:
- Returns the extendedColors.
- UML property:
- name="extendedColors"
-
setExtendedColors
public SLDColorMapBuilder setExtendedColors(boolean extendedColors)
Setter of the property extendedColorsUnless this property is set prior to start working with this
SLDColorMapBuilderwe will make use of only 256 colors. If we use extended colors, then we'll be able to use up to 65536 colors.Note that this imposes a limitation on the maximum number of
ColorMapEntrywe can use.- Parameters:
extendedColors- The extendedColors to set.- UML property:
- name="extendedColors"
-
getNumberColorMapEntries
public int getNumberColorMapEntries()
Getter of the property numberColorMapEntries- Returns:
- Returns the numberColorMapEntries.
- UML property:
- name="numberColorMapEntries"
-
setNumberColorMapEntries
public SLDColorMapBuilder setNumberColorMapEntries(int numberColorMapEntries)
Setter of the property numberColorMapEntries- Parameters:
numberColorMapEntries- The numberColorMapEntries to set.- UML property:
- name="numberColorMapEntries"
-
getNumberOfColorMapElements
public int getNumberOfColorMapElements()
Getter of the property numberOfColorMapElements- Returns:
- Returns the numberOfColorMapElements.
- UML property:
- name="numberOfColorMapElements"
-
buildLinearColorMap
public LinearColorMap buildLinearColorMap()
-
-