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

java.lang.Object
  extended by CH.ifa.draw.standard.AbstractFigure
      extended by org.openbp.cockpit.modeler.figures.generic.BasicFigure
          extended by org.openbp.cockpit.modeler.figures.generic.XFigure
All Implemented Interfaces:
CH.ifa.draw.framework.Figure, CH.ifa.draw.util.Storable, java.io.Serializable, java.lang.Cloneable, ChildFigure, Colorizable
Direct Known Subclasses:
XRectangleFigure

public abstract class XFigure
extends BasicFigure

Extended figure.

Author:
Heiko Erhardt
See Also:
Serialized Form

Field Summary
static java.lang.String DECO_FILLCOLOR2
          Decoration key for the second fill color (used with Color objects)
static java.lang.String DECO_FRAMECOLOR
          Decoration key for the frame color (used with Color objects)
static java.lang.String DECO_FRAMESTROKE
          Decoration key for the frame stroke (used with Stroke objects)
protected  XFigureDescriptor descriptor
          Figure descriptor
protected  boolean needUpdatePaint
          Flag if the paint should be updated
protected  java.awt.Paint paint
          Paint used to fill the figure
 
Fields inherited from class org.openbp.cockpit.modeler.figures.generic.BasicFigure
DECO_FILLCOLOR, DECO_OVERLAY
 
Fields inherited from interface CH.ifa.draw.framework.Figure
POPUP_MENU
 
Constructor Summary
XFigure()
          Default constructor.
 
Method Summary
 void changed()
           
 java.lang.Object clone()
          Creates a clone of this object.
 java.awt.geom.RectangularShape createRectangularShape()
          Creates a rectangular shape object that defines the outline of the figure.
 java.awt.Shape createShape()
          Creates a shape object that defines the outline of the figure.
 void draw(java.awt.Graphics g)
          Draws the figure in the given graphics.
protected  void drawAppliances(java.awt.Graphics g)
          Draws additional frame parts.
protected  void drawFrame(java.awt.Graphics g)
          Draws the frame of the figure.
protected  void drawImage(java.awt.Graphics g)
          Draws the image of the figure.
 java.awt.Color getDefaultFillColor()
          Gets the default fill color.
 java.awt.Color getDefaultFillColor2()
          Gets the default second (optional) fill color for gradients.
 java.awt.Color getDefaultFrameColor()
          Gets the default frame color.
 XFigureDescriptor getDescriptor()
          Gets the figure descriptor.
 java.awt.Color getFillColor2()
          Gets the second (optional) fill color for gradients.
 java.awt.Color getFrameColor()
          Gets the frame color.
 java.awt.Stroke getFrameStroke()
          Gets the frame stroke.
 javax.swing.ImageIcon getImageIcon()
          Gets the optional image.
 Orientation getOrientation()
          Gets the orientation of the figure.
 void initialize()
          Initializes the figure after all information from the figure descriptor has been set (template method).
abstract  java.awt.Rectangle placeAdjacent(java.awt.Rectangle rect, double angle)
          Places the given rectangle so that its center is in the given direction and it exactly touches the figure, without crossing any lines.
 void requestPaintUpdate()
          Requests an update of the figure's paint.
 void setDescriptor(XFigureDescriptor descriptor)
          Sets the figure descriptor.
 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 setFrameColor(java.awt.Color frameColor)
          Sets the frame color.
 void setFrameStroke(java.awt.Stroke frameStroke)
          Sets the frame stroke.
 void setImageIcon(javax.swing.ImageIcon imageIcon)
          Sets the optional image.
 void setOrientation(Orientation orientation)
          Sets the orientation of the figure.
 void updatePaint()
          Updates the paint object used for filling the figure.
 
Methods inherited from class org.openbp.cockpit.modeler.figures.generic.BasicFigure
decorateValue, drawFigure, getDecorationOwner, getFillColor, getParent, setParent
 
Methods inherited from class CH.ifa.draw.standard.AbstractFigure
addFigureChangeListener, addToContainer, basicDisplayBox, basicMoveBy, canConnect, center, connectedTextLocator, connectionInsets, connectorAt, connectorVisibility, containsPoint, decompose, displayBox, displayBox, displayBox, figures, findFigureInside, getAttribute, getZValue, handles, includes, invalidate, isEmpty, listener, moveBy, read, release, removeFigureChangeListener, removeFromContainer, setAttribute, setZValue, size, willChange, write
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface CH.ifa.draw.framework.Figure
addFigureChangeListener, addToContainer, basicDisplayBox, canConnect, center, connectedTextLocator, connectionInsets, connectorAt, connectorVisibility, containsPoint, decompose, displayBox, displayBox, displayBox, figures, findFigureInside, getAttribute, getZValue, handles, includes, invalidate, isEmpty, listener, moveBy, release, removeFigureChangeListener, removeFromContainer, setAttribute, setZValue, size, willChange
 
Methods inherited from interface CH.ifa.draw.util.Storable
read, write
 

Field Detail

DECO_FRAMESTROKE

public static final java.lang.String DECO_FRAMESTROKE
Decoration key for the frame stroke (used with Stroke objects)

See Also:
Constant Field Values

DECO_FRAMECOLOR

public static final java.lang.String DECO_FRAMECOLOR
Decoration key for the frame color (used with Color objects)

See Also:
Constant Field Values

DECO_FILLCOLOR2

public static final java.lang.String DECO_FILLCOLOR2
Decoration key for the second fill color (used with Color objects)

See Also:
Constant Field Values

descriptor

protected transient XFigureDescriptor descriptor
Figure descriptor


paint

protected transient java.awt.Paint paint
Paint used to fill the figure


needUpdatePaint

protected transient boolean needUpdatePaint
Flag if the paint should be updated

Constructor Detail

XFigure

public XFigure()
Default constructor.

Method Detail

clone

public java.lang.Object clone()
Creates a clone of this object.

Specified by:
clone in interface CH.ifa.draw.framework.Figure
Overrides:
clone in class BasicFigure

getDescriptor

public XFigureDescriptor getDescriptor()
Gets the figure descriptor.


setDescriptor

public void setDescriptor(XFigureDescriptor descriptor)
Sets the figure descriptor.


initialize

public void initialize()
Initializes the figure after all information from the figure descriptor has been set (template method). Can be used to parse tagged values of the figure descriptor. The default implementation does nothing.


draw

public void draw(java.awt.Graphics g)
Draws the figure in the given graphics. Template method calling BasicFigure.drawFigure(java.awt.Graphics) followed by drawFrame(java.awt.Graphics) and drawImage(java.awt.Graphics).

Specified by:
draw in interface CH.ifa.draw.framework.Figure
Overrides:
draw in class BasicFigure
Parameters:
g - Graphics to draw to
See Also:
BasicFigure.draw(Graphics g)

changed

public void changed()
Specified by:
changed in interface CH.ifa.draw.framework.Figure
Overrides:
changed in class CH.ifa.draw.standard.AbstractFigure
See Also:
()

drawFrame

protected void drawFrame(java.awt.Graphics g)
Draws the frame of the figure.

Parameters:
g - Graphics to draw to

drawAppliances

protected void drawAppliances(java.awt.Graphics g)
Draws additional frame parts.

Parameters:
g - Graphics to draw to

drawImage

protected void drawImage(java.awt.Graphics g)
Draws the image of the figure. By default, the image will be drawn according to the orientation of the figure.

Parameters:
g - Graphics to draw to

requestPaintUpdate

public void requestPaintUpdate()
Requests an update of the figure's paint.


updatePaint

public void updatePaint()
Updates the paint object used for filling the figure. Should be called when the fill colors change (done by the setFillColor(java.awt.Color) or setFillColor2(java.awt.Color) methods) or when the size or orientation of the figure changes.


placeAdjacent

public abstract java.awt.Rectangle placeAdjacent(java.awt.Rectangle rect,
                                                 double angle)
Places the given rectangle so that its center is in the given direction and it exactly touches the figure, without crossing any lines.

Parameters:
rect - Rectangle to adjust
angle - Direction in which the rectangle should be placed
Returns:
The translated rectangle

createShape

public java.awt.Shape createShape()
Creates a shape object that defines the outline of the figure. The shape returned by this method is supposed to be more acurate than the one returned by createRectangularShape(). However, for most figure types it will be the same.

Returns:
The shape or null if the figure does not support shape creation

createRectangularShape

public java.awt.geom.RectangularShape createRectangularShape()
Creates a rectangular shape object that defines the outline of the figure. The shape returned by this method might be more inacurate than the one returned by createShape(), but it is supposed to be faster and it returns an easily translatable and scalable object.

Returns:
The shape or null if the figure does not support shape creation

setFillColor

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

Specified by:
setFillColor in interface Colorizable
Overrides:
setFillColor in class BasicFigure
Parameters:
fillColor - Fill color or null for no fill color

getDefaultFillColor

public java.awt.Color getDefaultFillColor()
Gets the default fill color.

Specified by:
getDefaultFillColor in interface Colorizable
Overrides:
getDefaultFillColor in class BasicFigure
Returns:
Default 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

getDefaultFillColor2

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

Returns:
Default gradient color or null for solid fill

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

getDefaultFrameColor

public java.awt.Color getDefaultFrameColor()
Gets the default frame color.

Returns:
Default frame color or null for no frame color

getImageIcon

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


setImageIcon

public void setImageIcon(javax.swing.ImageIcon imageIcon)
Sets the optional image.


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

getFrameStroke

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


setFrameStroke

public void setFrameStroke(java.awt.Stroke frameStroke)
Sets the frame stroke.



Copyright © 2011. All Rights Reserved.