uDig can provide maps symbolized by implementing styles.
Basically, a style describes how to paint points, lines, polygons and raster data sets by providing a set of painting rules.

The style api has two major players.

  • StyleContent: this is the style object, in the case of SLD it is a org.geotools.styling.Style object. However it can be any object.
  • StyleConfigurator: This the the ui part of the style. It is responsible for creating the ui used to edit the style.

The udig will use this information as metadata when choosing which
Renderer to use for the layer. The Renderer itself will use this information when drawing to the screen.

Style Object and StyleBlackboard

Style objects are stored a StyleBlackboard. Configurators use the blackboard to collaborate. Objects are stored on the blackboard by id. When a configurator queries the blackboard for an object and it does not exist, a default object should be created and placed on the blackboard. The following is an example:

Since different renders can use completely different style objects, the coupling between the render and the style needs to kept low. In order to achieve this, we decided to create the notion of a style blackboard which is associated with a layer. This way the render and configurator can collaborate without talking to each other.

The Renderer and the StyleConfigurator look for particular style objects on the blackboard in order to do their part. The style content is responsible for creating, and persiting the style object.

Each Layer has a StyleBlackboard. Configurators should not write to this blackboard directly. Each configurator is supplied with a copy of the actual layer blackboard.
Each time a style object is changed, it must be replaced onto the blackboard for persistance reasons.

The StyleConfigurator should store no state. All state should be stored in the style objects on the style blackboard. When a ui widget changes state, the style object should be written to immediately to reflect the change.
When the configurator becomes active, the ui widgets should be initialized from the values of style objects on the blackboard. This should be performed every time refresh() is called.

Whenever style objects are read from the blackboard,

void apply() {
      StyleBlackboard styleBlackboard = getStyleBlackboard();
      Point style = styleBlackboard.lookup("point.style");      
      if (style == null) {
          style = new Point();    
          styleBlackboard.put("point.style", style);
      }
      
      style.setX(...) //set to some value from ui
      style.setY(...) //set to some value from ui
  }
  
  void init() {
      StyleBlackboard styleBlackboard = getStyleBlackboard();
      Point style = styleBlackboard.lookup("point.style");
      if (style != null) {
          //set some ui widget to value of style.getX();
          //set some ui widget to value of style.getY();
      }
  }

StyleBuilder

Since a Style is composed of a complex set of objects, a StyleBuilder object is provided for you to conveniently build simple styles without the need to build all of the style elements by hand. For example, you can create a PolygonSymbolizer and then create a Style out of it with a single method call: the builder will generate a default FeatureTypeStyle and the Rule for you.

FeatureTypeStyle

A FeatureTypeStyle declares a part of a style that is specifically geared toward a FeatureType, that is, features will be rendered according to this FeatureTypeStyle only if their FeatureType is the same as the FeatureType declared in the FeatureTypeStyle or a descendent. A FeatureTypeStyle contains one or more rules;

Rule

A Rule contains filters that will decide whether features will be displayed or not, specifically:
a minimum and maximum map scale, if set and the current scale is outside the specified range, the rule won't apply and thus its symbolizers won't be used;
a Filter that is applied to the features, only the features matching the filter will be painted according to the Rule symbolizers;
as an alternative, the rule can have an "else filter". This special kind of filter catches all of the features that still haven't been symbolized by previous rules with a regular filter.

Symbolizers

A Symbolizer describes how to represent a feature on the screen based on the feature contents (geometry and attributes). Each rule can have one or more Symbolizer attached to it.

  • Text Symbolizer
  • Line Symbolizer
  • Polygon Symbolizer
  • Point Symbolizer
  • Raster Symbolizer
[view] [edit]
(c) Copyright (c) 2004,2005 Refractions Research Inc. and others.