|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectschmitzm.geotools.styling.StylingUtil
public class StylingUtil
Diese Klasse enthaelt Hilfsfunktionen zum GeoTools-Styling
Field Summary | |
---|---|
static StyleBuilder |
builder
Deprecated. wurde ersetzt durch STYLE_BUILDER |
static SLDTransformer |
SLDTRANSFORMER
Standard-Instanz eines SLDTransformer . |
static StyleBuilder |
STYLE_BUILDER
Standard-Instanz eines StyleBuilder . |
static StyleFactory |
STYLE_FACTORY
Standard-Instanz einer StyleFactory |
static StyleFactory |
styleFactory
Deprecated. wurde ersetzt durch STYLE_FACTORY |
static Color |
TRANSPARENT_COLOR
Transparente Farbe |
Constructor Summary | |
---|---|
StylingUtil()
|
Method Summary | |
---|---|
static ColorMap |
clearColorMapLabels(ColorMap colorMap)
Removes all label information from the ColorMapEntry s of the
given ColorMap |
static Graphic |
clone(Graphic graphic)
Clons a Graphic element |
static Style |
clone(Style style)
Clones a Style by converting it to XML and reading it back in. |
static Symbolizer |
clone(Symbolizer sym)
|
static ColorMap |
cloneColorMap(ColorMap colorMap)
Kopiert eine ColorMap . |
static ColorMapEntry |
cloneColorMapEntry(ColorMapEntry colorMapEntry)
Kopiert einen ColorMapEntry . |
static boolean |
colorMapEntriesEqual(ColorMapEntry cme1,
ColorMapEntry cme2)
Prueft, ob zwei ColorMapEntry -Instanzen gleich sind. |
static boolean |
colorMapsEqual(ColorMap cm1,
ColorMap cm2)
Prueft, ob zwei ColorMap -Instanzen gleich sind. |
static void |
copyAllValues(TextSymbolizer from,
TextSymbolizer to)
Copies all Values from one TextSymbolizer to another
TextSymbolizer |
static BrewerPalette |
createBrewerPalette(String name,
Color[] colors)
Creates a new BrewerPalette with only one scheme (which includes
all colors). |
static ColorMapEntry |
createColorMapEntry(String label,
Double quantity,
Color color,
double opacity)
Erzeugt einen ColorMapEntry . |
static Style |
createDefaultStyle(Object object)
Erstellt einen Default-Style fuer ein Geo-Objekt. |
static GridSampleDimension |
createDiscreteGridSampleDimension(String name,
ColorMap colorMap,
double[] noDataValues,
Unit unit)
Erzeugt eine GridSampleDimension aus einer ColorMap . |
static Box |
createLegendPanel(FeatureTypeStyle[] featureTypeStyles,
FeatureType featureType)
Creates a Box that shows a legend for a list of
FeatureTypeStyle s and a targeted featureType |
static Category |
createNoDataCategory(double geoValue)
Erzeugt eine Category fuer die NoData-Werte transparent
dargestellt werden. |
static Category |
createNoDataCategory(int value,
double geoValue)
Erzeugt eine Category fuer die NoData-Werte transparent
dargestellt werden. |
static Style |
createSelectionStyle(Object geoObject)
|
static Style |
createStyleFromColorMap(ColorMap colorMap,
String name)
Creates a Style for a Grid layer from a ColorMap
Title will be set to GridUtil.UNTITLED_RASTER_STYLE_TITLE |
static Style |
createStyleFromColorMap(ColorMap colorMap,
String name,
String title)
Creates a Style for a Grid layer from a ColorMap |
static Style |
createStyleFromSLD(Element element)
Erzeugt einen Style aus einem JDOM-Element,
des eine SLD-Definition enthaelt |
static Style |
createStyleSimple(Object geoObject,
Color color,
Color color2)
|
static MemoryFeatureCollection |
filterSLDVisibleOnly(FeatureCollection fc,
Style style,
Double scaleDenominator)
SLD Rules können die Paramter MinScaleDenominator und MaxScaleDenominator enthalten. |
static ColorMapEntry |
findColorMapEntry(ColorMap colorMap,
double value)
Ermittelt fuer einen Wert den ColorMapEntry aus einer
ColorMap . |
static Color |
getColorFromColorMapEntry(ColorMapEntry entry)
Liefert die Farbe eines Farbpaletten-Eintrag. |
static Color |
getColorFromExpression(Expression expression)
Liefert die Farbe eines Farbpaletten-Eintrag. |
static ColorMap |
getColorMapFromStyle(Style style)
Liefert die Farbpalette zu einem Style, wenn der Style aus einem RasterSymbolizer erzeugt wurde. |
static Color |
getFillColor(Fill fill)
|
static Color |
getGraphicColor(Graphic graphic)
|
static Color |
getLineSymbolizerColor(LineSymbolizer ps)
|
static Double |
getOpacityFromColorMapEntry(ColorMapEntry entry)
Liefert die Transparenz eines Farbpaletten-Eintrag. |
static Double |
getOpacityFromExpression(Expression expression)
Liefert die Transparenz eines Farbpaletten-Eintrag. |
static Color |
getPointSymbolizerColor(PointSymbolizer ps)
|
static Color |
getPolygonSymbolizerColor(PolygonSymbolizer ps)
|
static Double |
getQuantityFromColorMapEntry(ColorMapEntry entry)
Liefert den Wert eines Farbpaletten-Eintrag. |
static Double |
getQuantityFromExpression(Expression expression)
Liefert den Wert eines Farbpaletten-Eintrag. |
static Color |
getStrokeColor(Stroke stroke)
|
static Color |
getSymbolizerColor(Symbolizer symb)
|
static TextSymbolizer |
getTextSymbolizer(Style style,
Feature f)
|
static List<TextSymbolizer> |
getTextSymbolizers(Style style)
|
static List<TextSymbolizer> |
getTextSymbolizers(Symbolizer[] symbolizers)
|
static Style[] |
loadSLD(File sldFile)
Loads Style s from a SLD File |
static Style[] |
loadSLD(InputStream inputStream)
Loads Style s from a SLD InputStream |
static Style[] |
loadSLD(URL url)
Loads Style s from a SLD InputStream |
static void |
replaceFillColor(Fill fill,
Color oldColor,
Color newColor)
Replaces the "main" color in a given Fill element |
static void |
replaceGraphicColor(Graphic graphic,
Color oldColor,
Color newColor)
Replaces the "main" color in a given Graphic element |
static void |
replaceLineSymbolizerColor(LineSymbolizer ps,
Color oldColor,
Color newColor)
Replaces the "main" color in a given LineSymbolizer element |
static void |
replacePointSymbolizerColor(PointSymbolizer ps,
Color oldColor,
Color newColor)
Replaces the "main" color in a given PointSymbolizer element |
static void |
replacePolygonSymbolizerColor(PolygonSymbolizer ps,
Color oldColor,
Color newColor)
Replaces the "main" color in a given PolygonSymbolizer element |
static void |
replaceStrokeColor(Stroke stroke,
Color oldColor,
Color newColor)
Replaces the "main" color in a given Stroke element |
static void |
replaceSymbolizerColor(Symbolizer symb,
Color oldColor,
Color newColor)
Replaces the "main" color in a given Symbolizer element |
static void |
saveStyleToSLD(Style style,
File exportFile)
Saves the Style to OGC SLD using ISO-8859-1 as charset. |
static void |
saveStyleToSLD(Style style,
File exportFile,
Charset charset)
Saves the Style to OGC SLD. |
static void |
setColorForColorMapEntry(ColorMapEntry entry,
Color color)
Setzt die Farbe eines Farbpaletten-Eintrag. |
static void |
setOpacityForColorMapEntry(ColorMapEntry entry,
double opacity)
Setzt die Transparenz eines Farbpaletten-Eintrag. |
static void |
setQuantityForColorMapEntry(ColorMapEntry entry,
double quantity)
Setzt den Wert eines Farbpaletten-Eintrag. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Color TRANSPARENT_COLOR
public static final StyleBuilder STYLE_BUILDER
StyleBuilder
.
public static final SLDTransformer SLDTRANSFORMER
SLDTransformer
.
public static final StyleBuilder builder
STYLE_BUILDER
StyleBuilder
.
public static final StyleFactory STYLE_FACTORY
StyleFactory
public static final StyleFactory styleFactory
STYLE_FACTORY
StyleFactory
Constructor Detail |
---|
public StylingUtil()
Method Detail |
---|
public static Style createDefaultStyle(Object object)
object
- GridCoverage2D
,
org.geotools.coverage.grid.io.AbstractGridCoverage2DReader
oder FeatureCollection
null
falls kein Style generiert werden kannpublic static Category createNoDataCategory(double geoValue)
Category
fuer die NoData-Werte transparent
dargestellt werden.
geoValue
- Geo-Wert, der NoData repraesentiertpublic static Category createNoDataCategory(int value, double geoValue)
Category
fuer die NoData-Werte transparent
dargestellt werden.
value
- Sample-Wert der CategorygeoValue
- Geo-Wert, der NoData repraesentiertpublic static GridSampleDimension createDiscreteGridSampleDimension(String name, ColorMap colorMap, double[] noDataValues, Unit unit)
GridSampleDimension
aus einer ColorMap
.
name
- Name fuer die GridSampleDimension
colorMap
- fuer jeden Eintrag der ColorMap
wird eine
Category
erzeugtnoDataValues
- Werte fuer die zusaetzliche Categorys
erstellt werden, welche die transparent dargestellt werden
(wenn null
wird keine zusaetzliche Category
erstellt)unit
- Einheit der Werte in der GridSampleDimension
(kann
null
sein)public static ColorMap getColorMapFromStyle(Style style)
RasterSymbolizer
erzeugt wurde.
style
- Style Wenn null
, dann wird style auf
GridUtil
.createDefaultStyle() gesetzt
null
wenn der Style nicht auf einem
RasterSymbolizer
basiert.public static ColorMapEntry findColorMapEntry(ColorMap colorMap, double value)
ColorMapEntry
aus einer
ColorMap
.
value
- Wert
null
, wenn in der ColorMap
kein expliziter
Eintrag fuer den Wert hinterlegt istpublic static ColorMap cloneColorMap(ColorMap colorMap)
ColorMap
.
null
wenn die uebergebene ColorMap null
istpublic static boolean colorMapsEqual(ColorMap cm1, ColorMap cm2)
ColorMap
-Instanzen gleich sind.
cm1
- eine Farbpalettecm2
- eine andere Farbpalettepublic static boolean colorMapEntriesEqual(ColorMapEntry cme1, ColorMapEntry cme2)
ColorMapEntry
-Instanzen gleich sind. Dies ist der
Fall, wenn ihnen der gleiche Wert, die gleiche Farbe, die gleiche
Transparenz und das gleiche Label zugeordnet ist.
cme1
- ein Farbpaletten-Eintragcme2
- ein anderer Farbpaletten-Eintragpublic static ColorMapEntry createColorMapEntry(String label, Double quantity, Color color, double opacity)
ColorMapEntry
.
label
- Label fuer den Farbpaletten-Eintragquantity
- Wert fuer den Farbpaletten-Eintragcolor
- Farbe fuer den Farbpaletten-Eintragopacity
- Transparenz fuer die Farbe des Farbpaletten-Eintragpublic static ColorMapEntry cloneColorMapEntry(ColorMapEntry colorMapEntry)
ColorMapEntry
.
null
wenn der uebergebene ColorMapEntry
null
istpublic static Double getQuantityFromExpression(Expression expression)
expression
- Expression, die einen String oder einen Double liefert
null
, wenn null
uebergeben wirdpublic static Double getQuantityFromColorMapEntry(ColorMapEntry entry)
entry
- Farbpaletten-Eintrag
null
, wenn null
uebergeben wirdpublic static void setQuantityForColorMapEntry(ColorMapEntry entry, double quantity)
entry
- Farbpaletten-Eintragquantity
- neuer Wertpublic static Double getOpacityFromExpression(Expression expression)
expression
- Expression, die einen String oder einen Double liefert
null
uebergeben wirdpublic static Double getOpacityFromColorMapEntry(ColorMapEntry entry)
entry
- Farbpaletten-Eintrag
null
uebergeben wirdpublic static void setOpacityForColorMapEntry(ColorMapEntry entry, double opacity)
entry
- Farbpaletten-Eintragopacity
- Transparenzwertpublic static Color getColorFromExpression(Expression expression)
expression
- Expression, die einen String liefertpublic static Color getColorFromColorMapEntry(ColorMapEntry entry)
entry
- Farbpaletten-Eintragpublic static void setColorForColorMapEntry(ColorMapEntry entry, Color color)
entry
- Farbpaletten-Eintragcolor
- eine Farbepublic static Style createStyleFromSLD(Element element)
Style
aus einem JDOM-Element,
des eine SLD-Definition enthaelt
element
- Element mit SLD-Definitionpublic static Style createStyleFromColorMap(ColorMap colorMap, String name, String title)
Style
for a Grid
layer from a ColorMap
colorMap
- If null, then defaultStyle for Grid will be usedname
- The name to give to the Style. null will result in name=
GridUtil.UNNAMED_RASTER_STYLE_NAME
or
GridUtil#DEFAULT_RASTER_STYLE_NAME} (if no colorMap is given).title
- The Title to give to the Style. null will result in title=
GridUtil.UNTITLED_RASTER_STYLE_TITLE
or
GridUtil.DEFAULT_RASTER_STYLE_TITLE
(if no colorMap is
given)
Style
that you can be applyed to a
GridCoverage
.public static ColorMap clearColorMapLabels(ColorMap colorMap)
ColorMapEntry
s of the
given ColorMap
public static Style createStyleFromColorMap(ColorMap colorMap, String name)
Style
for a Grid
layer from a ColorMap
Title will be set to GridUtil.UNTITLED_RASTER_STYLE_TITLE
colorMap
- If null, then defaultStyle for Grid will be usedname
- The name to give to the Style. null will result in name
GridUtil.UNTITLED_RASTER_STYLE_TITLE
GridCoverage
.
Style has name GridUtil.DEFAULT_RASTER_STYLE_NAME
if no
colormap was provided.public static Style[] loadSLD(URL url)
Style
s from a SLD InputStream
url
- URL
to read the SLD from
Array
of Style
s, can be length==0 if no
UserStyles in SLD file. null if file not existspublic static Style[] loadSLD(InputStream inputStream)
Style
s from a SLD InputStream
inputStream
- InputStream
to read the SLD from
Array
of Style
s, can be length==0. null if
file not existspublic static Style[] loadSLD(File sldFile) throws FileNotFoundException
Style
s from a SLD File
sldFile
- File
to read the SLD from
Array
of Style
s, can be length==0
FileNotFoundException
public static final void saveStyleToSLD(Style style, File exportFile, Charset charset) throws TransformerException, IOException
Style
to OGC SLD. Overwrites any existing file.
style
- Style
to savecharset
- The charset to use for the XML, e.g. . If null, ISO-8859-1 is used.
TransformerException
IOException
public static final void saveStyleToSLD(Style style, File exportFile) throws TransformerException, IOException
Style
to OGC SLD using ISO-8859-1 as charset.
Overwrites any existing file.
style
- Style
to save
TransformerException
IOException
public static MemoryFeatureCollection filterSLDVisibleOnly(FeatureCollection fc, Style style, Double scaleDenominator)
PolygonSymbolizer
zählt nicht der Rand,
sondern nur ob eine Füllung vorhanden ist! Man kann dann zwar leider
nicht auf ein Rand eines Polygons ohne Fill klicken, aber dafür kann man
durch die ungefüllte Fläche klicken.
fc
- Die zu filternde FeatureCollection. Diese wird nicht
verändert.style
- Der Style, mit dem die Features gerendert werden (z.b.
layer.getStyle() )scaleDenominator
- Der aktuelle ScaleDenomitor für den die Sichtbarkeit ermittelt
wird.
RendererUtilities.calculateOGCScale
public static TextSymbolizer getTextSymbolizer(Style style, Feature f)
style
- A Style
to search for the first TextSymbolizer
that will be used for the given Feature
.
null
or the first TextSymbolizer
found in
the style that applies to the Feature
.public static List<TextSymbolizer> getTextSymbolizers(Style style)
style
- A Style
to search for all TextSymbolizer
s . No
guarantee, that any one of them will ever be used for any
feature (think about filters).
List
or all TextSymbolizer
s found in the
Style
.public static List<TextSymbolizer> getTextSymbolizers(Symbolizer[] symbolizers)
symbolizers
- List of Symbolizers to search for all TextSymbolizer
s
. No guarantee, that any one of them will ever be used for any
feature (think about filters).
List
or all TextSymbolizer
s found in the given
symbolizers.public static Style clone(Style style)
style
- the Style
to be copied.public static Symbolizer clone(Symbolizer sym)
public static Graphic clone(Graphic graphic)
Graphic
element
graphicFill
-
public static BrewerPalette createBrewerPalette(String name, Color[] colors) throws IOException
BrewerPalette
with only one scheme (which includes
all colors). The suitablity of the palette is set to "unknown" for all
viewer types.
name
- name for the palette (also the description is set to this
value)colors
- colors for the palette
IOException
public static Style createSelectionStyle(Object geoObject)
geoObject
- GridCoverage2D
, AbstractGridCoverage2DReader
,
FeatureCollection
, GeometryAttributeType
or
FeatureSource
Style
that is suitable to identify features of the
given type as selected items.public static Style createStyleSimple(Object geoObject, Color color, Color color2)
public static Box createLegendPanel(FeatureTypeStyle[] featureTypeStyles, FeatureType featureType)
Box
that shows a legend for a list of
FeatureTypeStyle
s and a targeted featureType
featureType
- If this a legend for Point, Polygon or Line?featureTypeStyles
- The Styles to presen in this legendpublic static void replaceSymbolizerColor(Symbolizer symb, Color oldColor, Color newColor)
Symbolizer
element
public static void replaceLineSymbolizerColor(LineSymbolizer ps, Color oldColor, Color newColor)
LineSymbolizer
element
public static void replacePointSymbolizerColor(PointSymbolizer ps, Color oldColor, Color newColor)
PointSymbolizer
element
public static void replacePolygonSymbolizerColor(PolygonSymbolizer ps, Color oldColor, Color newColor)
PolygonSymbolizer
element
oldColor
- newColor
- ps
- public static void replaceStrokeColor(Stroke stroke, Color oldColor, Color newColor)
Stroke
element
stroke
- oldColor
- newColor
- public static void replaceFillColor(Fill fill, Color oldColor, Color newColor)
Fill
element
fill
- oldColor
- newColor
- public static void replaceGraphicColor(Graphic graphic, Color oldColor, Color newColor)
Graphic
element
public static Color getGraphicColor(Graphic graphic)
graphic
- If null
returns null
Color
used in the Graphic
or null, if an
ExternalGraphic
is used.public static Color getStrokeColor(Stroke stroke)
Color
used in a Stroke
.public static Color getFillColor(Fill fill)
Color
used in a Fill
.public static Color getSymbolizerColor(Symbolizer symb)
Color
used in a Symbolizer
.public static Color getLineSymbolizerColor(LineSymbolizer ps)
Color
used in a LineSymbolizer
.public static Color getPolygonSymbolizerColor(PolygonSymbolizer ps)
Color
used in a PolygonSymbolizer
.public static Color getPointSymbolizerColor(PointSymbolizer ps)
Color
used in a PointSymbolizer
.public static void copyAllValues(TextSymbolizer from, TextSymbolizer to)
TextSymbolizer
to another
TextSymbolizer
from
- TextSymbolizer
sourceto
- TextSymbolizer
target. May not be null
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |