org.openbp.cockpit.modeler.figures.generic
Class XFigureDescriptor

java.lang.Object
  extended by org.openbp.cockpit.modeler.figures.generic.XFigureDescriptor
Direct Known Subclasses:
SymbolDescriptor

public class XFigureDescriptor
extends java.lang.Object

Delegation object that implements some functionality of the XFigure interface.

Author:
Heiko Erhardt

Field Summary
static int DEFAULT_FRAME_STROKE_WIDTH
          Default frame stroke width
static int DEFAULT_GRADIENT_POS
          Default gradient position
static Orientation DEFAULT_ORIENTATION
          Default orientation
static int DEFAULT_SIZE
          Default x/y size
static int FLAG_CYCLIC_GRADIENT
          Flag: We have a cyclic gradient
static int GRADIENTPOS_CENTER
          Center
static int GRADIENTPOS_E
          E (right)
static int GRADIENTPOS_N
          N (top)
static int GRADIENTPOS_NE
          NE (top left)
static int GRADIENTPOS_NW
          NW (top left)
static int GRADIENTPOS_S
          S (bottom)
static int GRADIENTPOS_SE
          SE (bottom right)
static int GRADIENTPOS_SW
          SW (bottom left)
static int GRADIENTPOS_W
          W (left)
static int MAX_SIZE
          Maximum size
static int MIN_SIZE
          Minimum size
 
Constructor Summary
XFigureDescriptor()
          Default constructor.
 
Method Summary
protected  void addErrorMsg(java.util.List errorMsgs, java.lang.String errorMsg)
          Adds an error msg, prepending it by the node type name.
 void addTaggedValue(TaggedValue taggedValue)
          Adds a tagged value.
 void clearTaggedValues()
          Clears the tagged value list.
 XFigure createFigure()
          Creates a new figure according to the figure type of this descriptor.
protected  java.lang.String determineFigureClassName()
          Determines the figure class name from the figure type.
 int getCustomIntAttributeValue(java.lang.String name, int dflt)
          Gets the value of a tagged value as integer.
 java.lang.String getFigureClassName()
          Gets the figure class.
 java.lang.String getFigureType()
          Gets the figure type.
 java.awt.Color getFillColor()
          Gets the fill color.
 java.awt.Color getFillColor2()
          Gets the second (optional) fill color for gradients.
 java.lang.String getFillColor2Str()
          Gets the second (optional) fill color for gradients (colon-separated RGBA value).
 java.lang.String getFillColorStr()
          Gets the fill color (colon-separated RGBA value).
 java.awt.Color getFrameColor()
          Gets the frame color.
 java.lang.String getFrameColorStr()
          Gets the frame color (colon-separated RGBA value).
 java.awt.Stroke getFrameStroke()
          Gets the frame stroke.
 int getFrameStrokeWidth()
          Gets the stroke width.
 int getGradientPos1()
          Gets the position of the gradient (position 1) in a top-down figure orientation.
 java.lang.String getGradientPos1Str()
          Gets the position of the gradient (position 1) in a top-down figure orientation (string access).
 int getGradientPos2()
          Gets the position of the gradient (position 2) in a top-down figure orientation.
 java.lang.String getGradientPos2Str()
          Gets the position of the gradient (position 2) in a top-down figure orientation (string access).
 java.lang.String getImageFileName()
          Gets the image file name.
 javax.swing.ImageIcon getImageIcon()
          Gets the image.
 int getMaxSizeX()
          Gets the maximum horizontal size.
 int getMaxSizeY()
          Gets the maximum vertical size.
 int getMinSizeX()
          Gets the minimum horizontal size.
 int getMinSizeY()
          Gets the minimum vertical size.
 Orientation getOrientation()
          Gets the orientation of the figure.
 java.lang.String getOrientationStr()
          Gets the orientation of the figure (string access).
 int getSizeX()
          Gets the horizontal size.
 int getSizeY()
          Gets the vertical size.
 TaggedValue getTaggedValue(int index)
          Gets a tagged value by its collection index.
 java.lang.String getTaggedValue(java.lang.String name)
          Gets the value of a tagged value.
 java.util.List getTaggedValueList()
          Gets the tagged value list.
 java.util.Iterator getTaggedValues()
          Gets the tagged value list.
 boolean hasFrameStrokeWidth()
          Determines if the stroke width should be persisted.
 boolean hasOrientation()
          Determines if the orientation of the figure should be persisted.
 boolean hasSizeX()
          Determines if the horizontal size should be persisted.
 boolean hasSizeY()
          Determines if the vertical size should be persisted.
 boolean initialize(java.lang.String descriptorResourcePath)
          Initializes the descriptor.
 boolean isCyclicGradient()
          Gets the cyclic gradient.
 void setCyclicGradient(boolean cyclicGradient)
          Sets the cyclic gradient.
 void setFigureClassName(java.lang.String figureClassName)
          Sets the figure class.
 void setFigureType(java.lang.String figureType)
          Sets the figure type.
 void setFillColor(java.awt.Color fillColor)
          Sets the fill color.
 void setFillColor2(java.awt.Color fillColor2)
          Sets the second (optional) fill color for gradients.
 void setFillColor2Str(java.lang.String s)
          Sets the second (optional) fill color for gradients (colon-separated RGBA value).
 void setFillColorStr(java.lang.String s)
          Sets the fill color (colon-separated RGBA value).
 void setFrameColor(java.awt.Color frameColor)
          Sets the frame color.
 void setFrameColorStr(java.lang.String s)
          Sets the frame color (colon-separated RGBA value).
 void setFrameStrokeWidth(int frameStrokeWidth)
          Sets the stroke width.
 void setGradientPos1(int gradientPos1)
          Sets the position of the gradient (position 1) in a top-down figure orientation.
 void setGradientPos1Str(java.lang.String s)
          Sets the position of the gradient (position 1) in a top-down figure orientation (string access).
 void setGradientPos2(int gradientPos2)
          Sets the position of the gradient (position 2) in a top-down figure orientation.
 void setGradientPos2Str(java.lang.String s)
          Sets the position of the gradient (position 2) in a top-down figure orientation (string access).
 void setImageFileName(java.lang.String imageFileName)
          Sets the image file name.
 void setMaxSizeX(int maxSizeX)
          Sets the maximum horizontal size.
 void setMaxSizeY(int maxSizeY)
          Sets the maximum vertical size.
 void setMinSizeX(int minSizeX)
          Sets the minimum horizontal size.
 void setMinSizeY(int minSizeY)
          Sets the minimum vertical size.
 void setOrientation(Orientation orientation)
          Sets the orientation of the figure.
 void setOrientationStr(java.lang.String s)
          Sets the orientation of the figure (string access).
 void setSizeX(int sizeX)
          Sets the horizontal size.
 void setSizeY(int sizeY)
          Sets the vertical size.
 void setTaggedValueList(java.util.List taggedValueList)
          Sets the tagged value list.
 boolean validate(java.lang.String descriptorResourcePath, java.util.List errorMsgs)
          Validates the descriptor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GRADIENTPOS_CENTER

public static final int GRADIENTPOS_CENTER
Center

See Also:
Constant Field Values

GRADIENTPOS_E

public static final int GRADIENTPOS_E
E (right)

See Also:
Constant Field Values

GRADIENTPOS_SE

public static final int GRADIENTPOS_SE
SE (bottom right)

See Also:
Constant Field Values

GRADIENTPOS_S

public static final int GRADIENTPOS_S
S (bottom)

See Also:
Constant Field Values

GRADIENTPOS_SW

public static final int GRADIENTPOS_SW
SW (bottom left)

See Also:
Constant Field Values

GRADIENTPOS_W

public static final int GRADIENTPOS_W
W (left)

See Also:
Constant Field Values

GRADIENTPOS_NW

public static final int GRADIENTPOS_NW
NW (top left)

See Also:
Constant Field Values

GRADIENTPOS_N

public static final int GRADIENTPOS_N
N (top)

See Also:
Constant Field Values

GRADIENTPOS_NE

public static final int GRADIENTPOS_NE
NE (top left)

See Also:
Constant Field Values

DEFAULT_SIZE

public static final int DEFAULT_SIZE
Default x/y size

See Also:
Constant Field Values

DEFAULT_FRAME_STROKE_WIDTH

public static final int DEFAULT_FRAME_STROKE_WIDTH
Default frame stroke width

See Also:
Constant Field Values

DEFAULT_ORIENTATION

public static final Orientation DEFAULT_ORIENTATION
Default orientation


DEFAULT_GRADIENT_POS

public static final int DEFAULT_GRADIENT_POS
Default gradient position

See Also:
Constant Field Values

MIN_SIZE

public static final int MIN_SIZE
Minimum size

See Also:
Constant Field Values

MAX_SIZE

public static final int MAX_SIZE
Maximum size

See Also:
Constant Field Values

FLAG_CYCLIC_GRADIENT

public static final int FLAG_CYCLIC_GRADIENT
Flag: We have a cyclic gradient

See Also:
Constant Field Values
Constructor Detail

XFigureDescriptor

public XFigureDescriptor()
Default constructor.

Method Detail

validate

public boolean validate(java.lang.String descriptorResourcePath,
                        java.util.List errorMsgs)
Validates the descriptor. Any error messages should be added to the supplied error message list and will be displayed by the caller.

Parameters:
descriptorResourcePath - Resource path to the descriptor resources
errorMsgs - List of strings that holds error messages
Returns:
true: The descriptor was successfully validated.
false: There was an error validating the descriptor.

addErrorMsg

protected void addErrorMsg(java.util.List errorMsgs,
                           java.lang.String errorMsg)
Adds an error msg, prepending it by the node type name.

Parameters:
errorMsgs - List of strings that holds error messages
errorMsg - Error msg to add

initialize

public boolean initialize(java.lang.String descriptorResourcePath)
Initializes the descriptor. Loads the figure image (if an image file has been defined).

Parameters:
descriptorResourcePath - Resource path to the resource folder containing the descriptor
Returns:
true: The descriptor was successfully initialized.
false: There was an error initializing the descriptor. The descriptor should not be added to the descriptor list.

createFigure

public XFigure createFigure()
Creates a new figure according to the figure type of this descriptor.

Returns:
The new figure or null on error

determineFigureClassName

protected java.lang.String determineFigureClassName()
Determines the figure class name from the figure type.

Returns:
The class name

getTaggedValues

public java.util.Iterator getTaggedValues()
Gets the tagged value list.

Returns:
An iterator of TaggedValue objects

getTaggedValue

public TaggedValue getTaggedValue(int index)
Gets a tagged value by its collection index.

Parameters:
index - Collection index
Returns:
The tagged value

addTaggedValue

public void addTaggedValue(TaggedValue taggedValue)
Adds a tagged value.

Parameters:
taggedValue - The tagged value to add

clearTaggedValues

public void clearTaggedValues()
Clears the tagged value list.


getTaggedValueList

public java.util.List getTaggedValueList()
Gets the tagged value list.

Returns:
A list of TaggedValue objects

setTaggedValueList

public void setTaggedValueList(java.util.List taggedValueList)
Sets the tagged value list.

Parameters:
taggedValueList - A list of TaggedValue objects

getTaggedValue

public java.lang.String getTaggedValue(java.lang.String name)
Gets the value of a tagged value.

Parameters:
name - Name of the attribute
Returns:
The value or null if no such attribute exists

getCustomIntAttributeValue

public int getCustomIntAttributeValue(java.lang.String name,
                                      int dflt)
Gets the value of a tagged value as integer.

Parameters:
name - Name of the attribute
dflt - The default value
Returns:
The attribute value or the default if no such attribute exists

getFigureType

public java.lang.String getFigureType()
Gets the figure type.


setFigureType

public void setFigureType(java.lang.String figureType)
Sets the figure type.


getFigureClassName

public java.lang.String getFigureClassName()
Gets the figure class.


setFigureClassName

public void setFigureClassName(java.lang.String figureClassName)
Sets the figure class.


hasOrientation

public boolean hasOrientation()
Determines if the orientation of the figure should be persisted.


getOrientation

public Orientation getOrientation()
Gets the orientation of the figure.

Returns:
Orientation.RIGHT/Orientation.BOTTOM/Orientation.LEFT/Orientation.TOP

setOrientation

public void setOrientation(Orientation orientation)
Sets the orientation of the figure.

Parameters:
orientation - Orientation.RIGHT/Orientation.BOTTOM/Orientation.LEFT/Orientation.TOP

getOrientationStr

public java.lang.String getOrientationStr()
Gets the orientation of the figure (string access).

Returns:
Orientation.RIGHT/Orientation.BOTTOM/Orientation.LEFT/Orientation.TOP

setOrientationStr

public void setOrientationStr(java.lang.String s)
Sets the orientation of the figure (string access).

Parameters:
s - Orientation.RIGHT/Orientation.BOTTOM/Orientation.LEFT/Orientation.TOP

hasSizeX

public boolean hasSizeX()
Determines if the horizontal size should be persisted.


getSizeX

public int getSizeX()
Gets the horizontal size.


setSizeX

public void setSizeX(int sizeX)
Sets the horizontal size.


hasSizeY

public boolean hasSizeY()
Determines if the vertical size should be persisted.


getSizeY

public int getSizeY()
Gets the vertical size.


setSizeY

public void setSizeY(int sizeY)
Sets the vertical size.


getMinSizeX

public int getMinSizeX()
Gets the minimum horizontal size.


setMinSizeX

public void setMinSizeX(int minSizeX)
Sets the minimum horizontal size.


getMinSizeY

public int getMinSizeY()
Gets the minimum vertical size.


setMinSizeY

public void setMinSizeY(int minSizeY)
Sets the minimum vertical size.


getMaxSizeX

public int getMaxSizeX()
Gets the maximum horizontal size.


setMaxSizeX

public void setMaxSizeX(int maxSizeX)
Sets the maximum horizontal size.


getMaxSizeY

public int getMaxSizeY()
Gets the maximum vertical size.


setMaxSizeY

public void setMaxSizeY(int maxSizeY)
Sets the maximum vertical size.


hasFrameStrokeWidth

public boolean hasFrameStrokeWidth()
Determines if the stroke width should be persisted.


getFrameStrokeWidth

public int getFrameStrokeWidth()
Gets the stroke width.

Returns:
The stroke width in pixel/10 or 0 for no stroke

setFrameStrokeWidth

public void setFrameStrokeWidth(int frameStrokeWidth)
Sets the stroke width.

Parameters:
frameStrokeWidth - The stroke width in pixel/10 or 0 for no stroke

getFrameColor

public java.awt.Color getFrameColor()
Gets the frame color.

Returns:
The frame color or null for no frame

setFrameColor

public void setFrameColor(java.awt.Color frameColor)
Sets the frame color.

Parameters:
frameColor - The frame color or null for no frame

getFillColor

public java.awt.Color getFillColor()
Gets the fill color.

Returns:
Fill color or null for no fill color

setFillColor

public void setFillColor(java.awt.Color fillColor)
Sets the fill color.

Parameters:
fillColor - Fill color or null for no fill color

getFillColor2

public java.awt.Color getFillColor2()
Gets the second (optional) fill color for gradients.

Returns:
Gradient color or null for solid fill

setFillColor2

public void setFillColor2(java.awt.Color fillColor2)
Sets the second (optional) fill color for gradients.

Parameters:
fillColor2 - Gradient color or null for solid fill

getGradientPos1

public int getGradientPos1()
Gets the position of the gradient (position 1) in a top-down figure orientation.

Returns:
See the NUM_* constants of the CircleConstants class

setGradientPos1

public void setGradientPos1(int gradientPos1)
Sets the position of the gradient (position 1) in a top-down figure orientation.

Parameters:
gradientPos1 - See the NUM_* constants of the CircleConstants class

getGradientPos2

public int getGradientPos2()
Gets the position of the gradient (position 2) in a top-down figure orientation.

Returns:
See the NUM_* constants of the CircleConstants class

setGradientPos2

public void setGradientPos2(int gradientPos2)
Sets the position of the gradient (position 2) in a top-down figure orientation.

Parameters:
gradientPos2 - See the NUM_* constants of the CircleConstants class

getGradientPos1Str

public java.lang.String getGradientPos1Str()
Gets the position of the gradient (position 1) in a top-down figure orientation (string access).

Returns:
See the NUM_* constants of the CircleConstants class

setGradientPos1Str

public void setGradientPos1Str(java.lang.String s)
Sets the position of the gradient (position 1) in a top-down figure orientation (string access).

Parameters:
s - See the NUM_* constants of the CircleConstants class

getGradientPos2Str

public java.lang.String getGradientPos2Str()
Gets the position of the gradient (position 2) in a top-down figure orientation (string access).

Returns:
See the NUM_* constants of the CircleConstants class

setGradientPos2Str

public void setGradientPos2Str(java.lang.String s)
Sets the position of the gradient (position 2) in a top-down figure orientation (string access).

Parameters:
s - See the NUM_* constants of the CircleConstants class

isCyclicGradient

public boolean isCyclicGradient()
Gets the cyclic gradient.


setCyclicGradient

public void setCyclicGradient(boolean cyclicGradient)
Sets the cyclic gradient.


getFrameColorStr

public java.lang.String getFrameColorStr()
Gets the frame color (colon-separated RGBA value).


setFrameColorStr

public void setFrameColorStr(java.lang.String s)
Sets the frame color (colon-separated RGBA value).


getFillColorStr

public java.lang.String getFillColorStr()
Gets the fill color (colon-separated RGBA value).


setFillColorStr

public void setFillColorStr(java.lang.String s)
Sets the fill color (colon-separated RGBA value).


getFillColor2Str

public java.lang.String getFillColor2Str()
Gets the second (optional) fill color for gradients (colon-separated RGBA value).


setFillColor2Str

public void setFillColor2Str(java.lang.String s)
Sets the second (optional) fill color for gradients (colon-separated RGBA value).


getImageFileName

public java.lang.String getImageFileName()
Gets the image file name.


setImageFileName

public void setImageFileName(java.lang.String imageFileName)
Sets the image file name.


getFrameStroke

public java.awt.Stroke getFrameStroke()
Gets the frame stroke.


getImageIcon

public javax.swing.ImageIcon getImageIcon()
Gets the image.



Copyright © 2011. All Rights Reserved.