org.geotools.styling
Interface Graphic

All Superinterfaces:
GTComponent
All Known Implementing Classes:
GraphicImpl

public interface Graphic
extends GTComponent

A Graphic is a "graphical symbol" with an inherent shape, color(s), and possibly size.

A "graphic" can very informally be defined as "a little picture" and can be of either a raster or vector graphic source type. The term graphic is used since the term "symbol" is similar to "symbolizer" which is used in a difference context in SLD. The graphical symbol to display can be provided either as an external graphical resource or as a Mark.
Multiple external URLs and marks can be referenced with the proviso that they all provide equivalent graphics in different formats. The 'hot spot' to use for positioning the rendering at a point must either be inherent from the external format or be defined to be the "central point" of the graphic.

The details of this object are taken from the OGC Styled-Layer Descriptor Report (OGC 02-070) version 1.0.0.:


 <xsd:element name="Graphic">
   <xsd:annotation>
     <xsd:documentation>
       A "Graphic" specifies or refers to a "graphic symbol" with inherent
       shape, size, and coloring.
     </xsd:documentation>
   </xsd:annotation>
   <xsd:complexType>
     <xsd:sequence>
       <xsd:choice minOccurs="0" maxOccurs="unbounded">
         <xsd:element ref="sld:ExternalGraphic"/>
         <xsd:element ref="sld:Mark"/>
       </xsd:choice>
       <xsd:sequence>
         <xsd:element ref="sld:Opacity" minOccurs="0"/>
         <xsd:element ref="sld:Size" minOccurs="0"/>
         <xsd:element ref="sld:Rotation" minOccurs="0"/>
       </xsd:sequence>
     </xsd:sequence>
   </xsd:complexType>
 </xsd:element> 
 

Renderers can ue this information when displaying styled features, though it must be remembered that not all renderers will be able to fully represent strokes as set out by this interface. For example, opacity may not be supported.

Notes:

Task:
REVISIT: There are no setter methods in this interface, is this a problem?

Field Summary
static Graphic DEFAULT
          A default Graphic instance.
static Graphic NULL
          Indicates an absense of graphic.
 
Method Summary
 void accept(StyleVisitor visitor)
          accepts a StyleVisitor - used by xmlencoder and other packages which need to walk the style tree
 void addExternalGraphic(ExternalGraphic externalGraphic)
           
 void addMark(Mark mark)
           
 void addSymbol(Symbol symbol)
           
 Displacement getDisplacement()
           
 ExternalGraphic[] getExternalGraphics()
          Provides a list of external graphics which can be used to represent this graphic.
 java.lang.String getGeometryPropertyName()
          Getter for property geometryPropertyName.
 Mark[] getMarks()
          Provides a list of suitable marks which can be used to represent this graphic.
 Expression getOpacity()
          This specifies the level of translucency to use when rendering the graphic.
 Expression getRotation()
          This parameter defines the rotation of a graphic in the clockwise direction about its centre point in decimal degrees.
 Expression getSize()
          This paramteter gives the absolute size of the graphic in pixels encoded as a floating point number.
 Symbol[] getSymbols()
          Provides a list of all the symbols which can be used to represent this graphic.
 void setDisplacement(Displacement offset)
           
 void setExternalGraphics(ExternalGraphic[] externalGraphics)
           
 void setGeometryPropertyName(java.lang.String geometryPropertyName)
          Setter for property geometryPropertyName.
 void setMarks(Mark[] marks)
           
 void setOpacity(Expression opacity)
           
 void setRotation(Expression rotation)
           
 void setSize(Expression size)
           
 void setSymbols(Symbol[] symbols)
           
 
Methods inherited from interface org.geotools.event.GTComponent
changed, getNote, getParent, removed, setNote
 

Field Detail

DEFAULT

public static final Graphic DEFAULT
A default Graphic instance.

For some attributes the standard does not define a default, so a reasonable value is supplied.


NULL

public static final Graphic NULL
Indicates an absense of graphic.

This value is used to indicate that the Graphics based opperation should be skipped. Aka this is used by Stroke.Stroke as place holders for GRAPHIC_FILL and GRAPHIC_STROKE.

Method Detail

getExternalGraphics

public ExternalGraphic[] getExternalGraphics()
Provides a list of external graphics which can be used to represent this graphic. Each one should be an equivalent representation but in a different format. If none are provided, or if none of the formats are supported, then the list of Marks should be used instead.

Returns:
An array of ExternalGraphics objects which should be equivalents but in different formats. If null is returned, use getMarks instead.
Task:
REVISIT: The following may be a handy extra to have in this interface. public ExternalGraphic getExternalGraphic(String formats); return the first external graphic to match one of the given formats

setExternalGraphics

public void setExternalGraphics(ExternalGraphic[] externalGraphics)

addExternalGraphic

public void addExternalGraphic(ExternalGraphic externalGraphic)

getMarks

public Mark[] getMarks()
Provides a list of suitable marks which can be used to represent this graphic. These should only be used if no ExternalGraphic is provided, or if none of the external graphics formats are supported.

Returns:
An array of marks to use when displaying this Graphic. By default, a "square" with 50% gray fill and black outline with a size of 6 pixels (unless a size is specified) is provided.

setMarks

public void setMarks(Mark[] marks)

addMark

public void addMark(Mark mark)

getSymbols

public Symbol[] getSymbols()
Provides a list of all the symbols which can be used to represent this graphic. A symbol is an ExternalGraphic, Mark or any other object which implements the Symbol interface. These are returned in the order they were set.

Returns:
An array of symbols to use when displaying this Graphic. By default, a "square" with 50% gray fill and black outline with a size of 6 pixels (unless a size is specified) is provided.

setSymbols

public void setSymbols(Symbol[] symbols)

addSymbol

public void addSymbol(Symbol symbol)

getOpacity

public Expression getOpacity()
This specifies the level of translucency to use when rendering the graphic.
The value is encoded as a floating-point value between 0.0 and 1.0 with 0.0 representing totally transparent and 1.0 representing totally opaque, with a linear scale of translucency for intermediate values.
For example, "0.65" would represent 65% opacity. The default value is 1.0 (opaque).

Returns:
The opacity of the Graphic, where 0.0 is completely transparent and 1.0 is completely opaque.

setOpacity

public void setOpacity(Expression opacity)

getSize

public Expression getSize()
This paramteter gives the absolute size of the graphic in pixels encoded as a floating point number.

The default size of an image format (such as GIFD) is the inherent size of the image. The default size of a format without an inherent size (such as SVG) is defined to be 16 pixels in height and the corresponding aspect in width. If a size is specified, the height of the graphic will be scaled to that size and the corresponding aspect will be used for the width.

Returns:
The size of the graphic. The default is context specific. Negative values are not possible.

setSize

public void setSize(Expression size)

getDisplacement

public Displacement getDisplacement()

setDisplacement

public void setDisplacement(Displacement offset)

getRotation

public Expression getRotation()
This parameter defines the rotation of a graphic in the clockwise direction about its centre point in decimal degrees. The value encoded as a floating point number.

Returns:
The angle of rotation in decimal degrees. Negative values represent counter-clockwise rotation. The default is 0.0 (no rotation).

setRotation

public void setRotation(Expression rotation)

getGeometryPropertyName

public java.lang.String getGeometryPropertyName()
Getter for property geometryPropertyName.

Returns:
Value of property geometryPropertyName.

setGeometryPropertyName

public void setGeometryPropertyName(java.lang.String geometryPropertyName)
Setter for property geometryPropertyName.

Parameters:
geometryPropertyName - New value of property geometryPropertyName.

accept

public void accept(StyleVisitor visitor)
accepts a StyleVisitor - used by xmlencoder and other packages which need to walk the style tree

Parameters:
visitor - - the visitor object


Copyright © GeoTools. All Rights Reserved.