org.deegree_impl.graphics.sld
Class Graphic_Impl

java.lang.Object
  extended byorg.deegree_impl.graphics.sld.Graphic_Impl
All Implemented Interfaces:
Graphic, Marshallable

public class Graphic_Impl
extends java.lang.Object
implements Graphic, Marshallable

A Graphic is a "graphic symbol" with an inherent shape, color, and size. Graphics can either be referenced from an external URL in a common format (such as GIF or SVG) or may be derived from a Mark. Multiple external URLs may be referenced with the semantic that they all provide the same graphic in different formats. The "hot spot" to use for rendering at a point or the start and finish handle points to use for rendering a graphic along a line must either be inherent in the external format or are system- dependent. The default size of an image format (such as GIF) is the inherent size of the image. The default size of a format without an inherent size is 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. The default if neither an ExternalURL nor a Mark is specified is to use the default Mark with a size of 6 pixels. The size is in pixels and the rotation is in degrees clockwise, with 0 (default) meaning no rotation. In the case that a Graphic is derived from a font-glyph Mark, the Size specified here will be used for the final rendering. Allowed CssParameters are "opacity", "size", and "rotation".

Version:
$Revision: 1.13 $ $Date: 2004/05/26 08:12:33 $
Author:
Katharina Lupp, Markus Schneider

Field Summary
private  java.awt.image.BufferedImage image
           
private  java.util.ArrayList marksAndExtGraphics
           
private  ParameterValueType opacity
           
private  ParameterValueType rotation
           
private  ParameterValueType size
           
 
Fields inherited from interface org.deegree.graphics.sld.Graphic
OPACITY_DEFAULT, ROTATION_DEFAULT, SIZE_DEFAULT
 
Constructor Summary
protected Graphic_Impl()
          Creates a new Graphic_Impl instance based on the default Mark: a square.
protected Graphic_Impl(java.lang.Object[] marksAndExtGraphics, ParameterValueType opacity, ParameterValueType size, ParameterValueType rotation)
          Creates a new Graphic_Impl instance.
protected Graphic_Impl(ParameterValueType opacity, ParameterValueType size, ParameterValueType rotation)
          Creates a new Graphic_Impl instance based on the default Mark: a square.
 
Method Summary
 void addMarksAndExtGraphic(java.lang.Object object)
          Adds an Object to an object-array that enables the access to the stored ExternalGraphic and Mark-instances.
 java.lang.String exportAsXML()
          exports the content of the Graphic as XML formated String
 java.awt.image.BufferedImage getAsImage(Feature feature)
          Returns a BufferedImage representing this object.
 java.lang.Object[] getMarksAndExtGraphics()
          Returns an object-array that enables the access to the stored ExternalGraphic and Mark-instances.
 double getOpacity(Feature feature)
          The Opacity element gives the opacity to use for rendering the graphic.
 double getRotation(Feature feature)
          The Rotation element gives the rotation of a graphic in the clockwise direction about its center point in radian, encoded as a floating- point number.
 double getSize(Feature feature)
          The Size element gives the absolute size of the graphic in pixels encoded as a floating-point number.
 void removeMarksAndExtGraphic(java.lang.Object object)
          Removes an Object from an object-array that enables the access to the stored ExternalGraphic and Mark-instances.
 void setAsImage(java.awt.image.BufferedImage bufferedImage)
          Sets a BufferedImage representing this object.
 void setMarksAndExtGraphics(java.lang.Object[] object)
          Sets the ExternalGraphic/Mark-instances that the image will be based on.
 void setOpacity(double opacity)
          The Opacity element gives the opacity of to use for rendering the graphic.
 void setRotation(double rotation)
           
 void setSize(double size)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

marksAndExtGraphics

private java.util.ArrayList marksAndExtGraphics

image

private java.awt.image.BufferedImage image

opacity

private ParameterValueType opacity

rotation

private ParameterValueType rotation

size

private ParameterValueType size
Constructor Detail

Graphic_Impl

protected Graphic_Impl(java.lang.Object[] marksAndExtGraphics,
                       ParameterValueType opacity,
                       ParameterValueType size,
                       ParameterValueType rotation)
Creates a new Graphic_Impl instance.

Parameters:
marksAndExtGraphics - the image will be based upon these
opacity - opacity that the resulting image will have
size - image height will be scaled to this value, respecting the proportions
rotation - image will be rotated clockwise for positive values, negative values result in anti-clockwise rotation

Graphic_Impl

protected Graphic_Impl(ParameterValueType opacity,
                       ParameterValueType size,
                       ParameterValueType rotation)
Creates a new Graphic_Impl instance based on the default Mark: a square.

Parameters:
opacity - opacity that the resulting image will have
size - image height will be scaled to this value, respecting the proportions
rotation - image will be rotated clockwise for positive values, negative values result in anti-clockwise rotation

Graphic_Impl

protected Graphic_Impl()
Creates a new Graphic_Impl instance based on the default Mark: a square.

Method Detail

getMarksAndExtGraphics

public java.lang.Object[] getMarksAndExtGraphics()
Returns an object-array that enables the access to the stored ExternalGraphic and Mark-instances.

Specified by:
getMarksAndExtGraphics in interface Graphic
Returns:
contains ExternalGraphic and Mark-objects

setMarksAndExtGraphics

public void setMarksAndExtGraphics(java.lang.Object[] object)
Sets the ExternalGraphic/Mark-instances that the image will be based on.

Specified by:
setMarksAndExtGraphics in interface Graphic
Parameters:
object - to be used as basis for the resulting image

addMarksAndExtGraphic

public void addMarksAndExtGraphic(java.lang.Object object)
Adds an Object to an object-array that enables the access to the stored ExternalGraphic and Mark-instances.

Specified by:
addMarksAndExtGraphic in interface Graphic
Parameters:
object - to be used as basis for the resulting image

removeMarksAndExtGraphic

public void removeMarksAndExtGraphic(java.lang.Object object)
Removes an Object from an object-array that enables the access to the stored ExternalGraphic and Mark-instances.

Specified by:
removeMarksAndExtGraphic in interface Graphic
Parameters:
object - to be used as basis for the resulting image

getOpacity

public double getOpacity(Feature feature)
                  throws FilterEvaluationException
The Opacity element gives the opacity to use for rendering the graphic.

Specified by:
getOpacity in interface Graphic
Parameters:
feature - specifies the Feature to be used for evaluation of the underlying 'sld:ParameterValueType'
Returns:
the (evaluated) value of the parameter
Throws:
FilterEvaluationException - if the evaluation fails or the value is invalid

setOpacity

public void setOpacity(double opacity)
The Opacity element gives the opacity of to use for rendering the graphic.

Specified by:
setOpacity in interface Graphic
Parameters:
opacity - Opacity to be set for the graphic

getSize

public double getSize(Feature feature)
               throws FilterEvaluationException
The Size element gives the absolute size of the graphic in pixels encoded as a floating-point number. This element is also used in other contexts than graphic size and pixel units are still used even for font size. The default size for an object is context-dependent. Negative values are not allowed.

Specified by:
getSize in interface Graphic
Parameters:
feature - specifies the Feature to be used for evaluation of the underlying 'sld:ParameterValueType'
Returns:
the (evaluated) value of the parameter
Throws:
FilterEvaluationException - if the evaluation fails or the value is invalid

setSize

public void setSize(double size)
Specified by:
setSize in interface Graphic
Parameters:
size - size to be set for the graphic
See Also:


getRotation

public double getRotation(Feature feature)
                   throws FilterEvaluationException
The Rotation element gives the rotation of a graphic in the clockwise direction about its center point in radian, encoded as a floating- point number. Negative values mean counter-clockwise rotation. The default value is 0.0 (no rotation).

Specified by:
getRotation in interface Graphic
Parameters:
feature - specifies the Feature to be used for evaluation of the underlying 'sld:ParameterValueType'
Returns:
the (evaluated) value of the parameter
Throws:
FilterEvaluationException - if the evaluation fails or the value is invalid

setRotation

public void setRotation(double rotation)
Specified by:
setRotation in interface Graphic
Parameters:
rotation - rotation to be set for the graphic
See Also:


getAsImage

public java.awt.image.BufferedImage getAsImage(Feature feature)
                                        throws FilterEvaluationException
Returns a BufferedImage representing this object. The image respects the 'Opacity', 'Size' and 'Rotation' parameters. If the 'Size'-parameter is omitted, the height of the first ExternalGraphic is used. If there is none, the default value of 6 pixels is used.

Specified by:
getAsImage in interface Graphic
Returns:
the BufferedImage ready to be painted
Throws:
FilterEvaluationException - if the evaluation fails

setAsImage

public void setAsImage(java.awt.image.BufferedImage bufferedImage)
Sets a BufferedImage representing this object. The image respects the 'Opacity', 'Size' and 'Rotation' parameters.

Specified by:
setAsImage in interface Graphic
Parameters:
bufferedImage - BufferedImage to be set

exportAsXML

public java.lang.String exportAsXML()
exports the content of the Graphic as XML formated String

Specified by:
exportAsXML in interface Marshallable
Returns:
xml representation of the Graphic