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 context sensitive SLD content editor.

This class is intended to be used by a StyleConfigurator providing SLD style content.

An SLD 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.

Concepts:

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

This class also provides the ability to look up symbolizers by class against the "default rule". This allows configurators interested in a particular symbolizer to 'track' the instance of it as the default rule is changed.

Instructions for Subclassing

This base implementation works against the "first" rule in the Style. When providing a SLDConfigurator specific subclass (say for themeing) you may wish to connect the "defaultRule" up to the current rule.

You may also supply context sensitive overrrides for color, simply override the methods such as color( LineSymbolizer line ) to return the correct default when a line is null.

Since:
0.9
Author:
Justin Deoliveira

Constructor Summary
SLDContentManager()
          Creates the SLD content manager.
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 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()
           
<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(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 the SLD content manager.


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(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 SLD style.

getStyleBuilder

public StyleBuilder getStyleBuilder()
Returns:
Returns the styleBuilder.

getDefaultFeatureTypeStyle

public FeatureTypeStyle getDefaultFeatureTypeStyle()
Returns the the first feature type style for the SLD style. The feature type style is created if it does not exist.

Returns:
The default (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.

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)