org.geotools.styling
Class Styles

java.lang.Object
  extended byorg.geotools.styling.Styles

public class Styles
extends java.lang.Object

Utility class for Styles.

Warning: these methods are subject to change in the near future.

Author:
Cory Horner, Refractions Research

Constructor Summary
Styles()
           
 
Method Summary
static AttributeType[] getAttributeTypes(Filter[] filter, AttributeType[] availableAttributeTypes)
          Deprecated.  
static java.lang.String[] getColors(Rule rule)
           
static java.lang.String[] getColors(Style style)
           
static Filter[] getFilters(Rule[] rule)
           
static Filter[] getFilters(Style style)
           
static Rule[] getRules(Style style)
           
static StyledLayerDescriptor getStyledLayerDescriptor(java.lang.Object gtComponent)
          Climbs the style hierarchy until null or an SLD is found.
static void modifyFTS(FeatureTypeStyle fts, int ruleIndex, java.lang.String styleExpression)
           
static java.awt.Color toColor(java.lang.String htmlColor)
           
static Filter toExplicitFilter(java.lang.String styleExpression, Expression attribExpr)
           Creates a filter with each value explicitly defined.
static Filter toExplicitFilter(java.lang.String styleExpression, FeatureType featureType, java.lang.String attributeTypeName)
           Creates a filter with each value explicitly defined.
static Filter[] toFilter(java.lang.String[] styleExpression, FeatureType[] featureType, java.lang.String[] attributeTypeName)
           Converts an array of styleExpressions and attributes into Filters styleExpression[0] = "1..5";
styleExpression[1] = "5..10";
styleExpression[2] = "11, -13";
--->
filter[0] = [[1 <= attr] AND [attr < 5]]
filter[1] = [[6 <= attr] AND [attr <= 10]]
filter[2] = [[attr = 11] OR [attr = -13]]
static java.lang.String toHTMLColor(java.awt.Color color)
          Converts a java.awt.Color into an HTML Colour
static Filter toRangedFilter(java.lang.String styleExpression, FeatureType featureType, java.lang.String attributeTypeName, boolean upperBoundClosed)
           Creates a filter for a range of values.
static java.lang.String toStyleExpression(Filter filter)
           
static java.lang.String[] toStyleExpression(Filter[] filter)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Styles

public Styles()
Method Detail

getAttributeTypes

public static AttributeType[] getAttributeTypes(Filter[] filter,
                                                AttributeType[] availableAttributeTypes)
                                         throws IllegalFilterException
Deprecated.  

Throws:
IllegalFilterException

getColors

public static java.lang.String[] getColors(Rule rule)

getColors

public static java.lang.String[] getColors(Style style)

toColor

public static java.awt.Color toColor(java.lang.String htmlColor)

getFilters

public static Filter[] getFilters(Rule[] rule)

getFilters

public static Filter[] getFilters(Style style)

getRules

public static Rule[] getRules(Style style)

getStyledLayerDescriptor

public static StyledLayerDescriptor getStyledLayerDescriptor(java.lang.Object gtComponent)
Climbs the style hierarchy until null or an SLD is found.

Returns:
SLD

toExplicitFilter

public static Filter toExplicitFilter(java.lang.String styleExpression,
                                      FeatureType featureType,
                                      java.lang.String attributeTypeName)
                               throws IllegalFilterException

Creates a filter with each value explicitly defined.

Examples:
"LIB" --> [PARTY = LIB]
"LIB, NDP" --> [[PARTY = LIB] OR [PARTY = NDP]]

Parameters:
styleExpression - the list of attribute values, separated by commas (and optional spaces)
Returns:
a filter
Throws:
IllegalFilterException

toExplicitFilter

public static Filter toExplicitFilter(java.lang.String styleExpression,
                                      Expression attribExpr)
                               throws IllegalFilterException

Creates a filter with each value explicitly defined.

Examples:
"LIB" --> [PARTY = LIB]
"LIB, NDP" --> [[PARTY = LIB] OR [PARTY = NDP]]

Parameters:
styleExpression - the list of attribute values, separated by commas (and optional spaces)
attribExpr - an Expression to compare each value with (simple case = attributeExpression)
Returns:
a filter
Throws:
IllegalFilterException

toFilter

public static Filter[] toFilter(java.lang.String[] styleExpression,
                                FeatureType[] featureType,
                                java.lang.String[] attributeTypeName)
                         throws IllegalFilterException

Converts an array of styleExpressions and attributes into Filters

styleExpression[0] = "1..5";
styleExpression[1] = "5..10";
styleExpression[2] = "11, -13";
--->
filter[0] = [[1 <= attr] AND [attr < 5]]
filter[1] = [[6 <= attr] AND [attr <= 10]]
filter[2] = [[attr = 11] OR [attr = -13]]

Parameters:
styleExpression - strings of ranged expressions "lowValue..highValue" or explicit values "value1, value2"
Returns:
all the filters
Throws:
IllegalFilterException

toHTMLColor

public static java.lang.String toHTMLColor(java.awt.Color color)
Converts a java.awt.Color into an HTML Colour

Parameters:
color -
Returns:
HTML Color (fill) in hex #RRGGBB

toRangedFilter

public static Filter toRangedFilter(java.lang.String styleExpression,
                                    FeatureType featureType,
                                    java.lang.String attributeTypeName,
                                    boolean upperBoundClosed)
                             throws IllegalFilterException

Creates a filter for a range of values.

Examples:
"1..5", closed=true --> [[1 <= attr] AND [attr <= 5]]
"1..10", closed=false --> [[1 <= attr] AND [attr < 10]]

Parameters:
styleExpression - the ranged style expression (minValue..maxValue)
upperBoundClosed - is the upper bound include the max value? (true: <=, false: <)
Returns:
a filter
Throws:
IllegalFilterException

toStyleExpression

public static java.lang.String toStyleExpression(Filter filter)

toStyleExpression

public static java.lang.String[] toStyleExpression(Filter[] filter)

modifyFTS

public static void modifyFTS(FeatureTypeStyle fts,
                             int ruleIndex,
                             java.lang.String styleExpression)
                      throws IllegalFilterException
Throws:
IllegalFilterException


Copyright © GeoTools. All Rights Reserved.