net.refractions.udig.style.sld
Class SLDContentManager

java.lang.Object
  extended by net.refractions.udig.style.sld.SLDContentManager

public class SLDContentManager
extends java.lang.Object

A helpful class for sifting through an SLD Style object while implementing an editor. Consider it a wrapper that allows you to easily edit (it will completely write any and all changes directly to the wrapped style).

Used by a StyleConfigurator or IStyledEditorPage working with SLD style content on the blackboard.

A Style object can contain any number of FeatureTypeStyle objects, which can in turn contain any number of Rule objects, which can in turn contain any number of Symbolizer objects.

The SLDContentManager provides support for the following concepts:

This allows IStyleConfigurator implementation who simply want to add a new symbolizer to the style to forgo the creation and setup of the style hierarchy.

To help keep everything straight here are a couple of naming conventions:

This class also provides the ability to look up symbolizers by class against the "default" rule (ie the rule with the name "default"). This allows an SLDConfigurator interested in a particular symbolizer to 'track' the instance of it as the default rule is changed.

Since:
0.9
Author:
Justin Deoliveira

Constructor Summary
SLDContentManager()
          Creates an empty SLDContentManager that is set up around a default style.
SLDContentManager(StyleBuilder styleBuilder)
          Creates an empty SLDContentManager that is setup around a default style
SLDContentManager(StyleBuilder styleBuilder, Style style)
          Creates the SLD content manager.
 
Method Summary
 void addSymbolizer(Rule rule, Symbolizer symbolizer)
          Adds a symbolizer to a rule.
 void addSymbolizer(Symbolizer symbolizer)
          Adds a symbolizer to the default rule.
 java.awt.Color color(LineSymbolizer line)
           
 FeatureTypeStyle createFeatureTypeStyle(java.lang.String name)
          Creates a new feature type style for the object, and adds it to the style.
 Rule createRule()
          Creates an empty rule.
 Rule createRule(FeatureTypeStyle ftStyle)
          Creates a new rule for a specific feature type style.
 FeatureTypeStyle featureTypeStyle(java.lang.String name)
           
 FeatureTypeStyle getDefaultFeatureTypeStyle()
          Returns the the first feature type style for the SLD style.
 Rule getDefaultRule()
           
 FeatureTypeStyle getFeatureTypeStyle(java.lang.String name)
          Returns a feature type style with specific name, or null if no such feature type style exists.
 Style getStyle()
           
 StyleBuilder getStyleBuilder()
           
 StyleFactory getStyleFactory()
           
<T extends Symbolizer>
T
getSymbolizer(java.lang.Class<T> theClass)
          Returns the first symbolizer of a particular class from the default rule or none if no such symbolizer exists.
<T> T
getSymbolizer(Rule rule, java.lang.Class<T> theClass)
          Returns the first symbolizer of a particular class for a rule or none if no such symbolizer exists.
 void init(Style style)
           
 void init(StyleBuilder styleBuilder, Style style)
          Initializes the content manager with a new style.
 double opacity(LineSymbolizer line)
           
 void removeSymbolizer(Symbolizer symbolizer)
           
 double width(LineSymbolizer line)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SLDContentManager

public SLDContentManager()
Creates an empty SLDContentManager that is set up around a default style.


SLDContentManager

public SLDContentManager(StyleBuilder styleBuilder)
Creates an empty SLDContentManager that is setup around a default style

Parameters:
styleBuilder - StyleBuilder used to create the default style

SLDContentManager

public SLDContentManager(StyleBuilder styleBuilder,
                         Style style)
Creates the SLD content manager.

Parameters:
styleBuilder - The builder object used to create style content.
style - The SLD style itself.
Method Detail

init

public void init(Style style)

init

public void init(StyleBuilder styleBuilder,
                 Style style)
Initializes the content manager with a new style.

Parameters:
styleBuilder - The builder object used to create style content.
style - The SLD style itself.

getStyle

public Style getStyle()
Returns:
Returns the wrapped Style object

getStyleBuilder

public StyleBuilder getStyleBuilder()
Returns:
Returns the styleBuilder.

getStyleFactory

public StyleFactory getStyleFactory()

getDefaultFeatureTypeStyle

public FeatureTypeStyle getDefaultFeatureTypeStyle()
Returns the the first feature type style for the SLD style.

Please note a feature type style is created if it does not exist.

Returns:
The default (ie first) feature type style.

getFeatureTypeStyle

public FeatureTypeStyle getFeatureTypeStyle(java.lang.String name)
Returns a feature type style with specific name, or null if no such feature type style exists.

Parameters:
name - The name of the feature type style.
Returns:
the feature type style identified by name, or null.

featureTypeStyle

public FeatureTypeStyle featureTypeStyle(java.lang.String name)

getDefaultRule

public Rule getDefaultRule()
Returns:
the first rule in the default feature type style.

createFeatureTypeStyle

public FeatureTypeStyle createFeatureTypeStyle(java.lang.String name)
Creates a new feature type style for the object, and adds it to the style.

Parameters:
name - The name of feature type style.
Returns:
The newly created feature type style.

createRule

public Rule createRule()
Creates an empty rule. This method does not associate the rule with the SLD style. The rule is created with an empty symbolizer list.

Returns:
The newly created rule.

createRule

public Rule createRule(FeatureTypeStyle ftStyle)
Creates a new rule for a specific feature type style. The rule is created with an empty symbolizer list.

Parameters:
ftStyle - The feature type style for the rule.
Returns:
The newly created rule.

getSymbolizer

public <T> T getSymbolizer(Rule rule,
                           java.lang.Class<T> theClass)
Returns the first symbolizer of a particular class for a rule or none if no such symbolizer exists.

Parameters:
rule - The rule containing the symbolizer to be returned.
theClass - The typed class of the symbolizer.
Returns:
The symbolizer of type T, or null if none exists.

getSymbolizer

public <T extends Symbolizer> T getSymbolizer(java.lang.Class<T> theClass)
Returns the first symbolizer of a particular class from the default rule or none if no such symbolizer exists.

Parameters:
theClass - The typed class of the symbolizer.
Returns:
The symbolizer of type T, or null if none exists.

addSymbolizer

public void addSymbolizer(Symbolizer symbolizer)
Adds a symbolizer to the default rule.

Parameters:
symbolizer - The symbolizer to add.

addSymbolizer

public void addSymbolizer(Rule rule,
                          Symbolizer symbolizer)
Adds a symbolizer to a rule.

Parameters:
rule - The rule.
symbolizer - The symbolizer

removeSymbolizer

public void removeSymbolizer(Symbolizer symbolizer)

color

public java.awt.Color color(LineSymbolizer line)

width

public double width(LineSymbolizer line)

opacity

public double opacity(LineSymbolizer line)