Package diva.canvas.toolbox
Class VectorFigure
- java.lang.Object
-
- diva.canvas.AbstractFigure
-
- diva.canvas.toolbox.VectorFigure
-
- All Implemented Interfaces:
CanvasComponent
,Figure
,VisibleComponent
,UserObjectContainer
public class VectorFigure extends AbstractFigure
A VectorFigure is a figure containing a list of objects that are drawn to produce the figure. The list of objects that are drawn includes both geometric objects and drawing control objects. Specifically:- Shape: any Shape is drawn as determine by the current fill and line styles.
- Stroke, Paint, Composite: any subsequent shapes are drawn using this object set appropriately in the graphics object
- Figure: Any other Figure can be drawn as well, thus allowing hierarchical drawing. Note, however, that figures drawn inside are NOT able to detect events. After the figure is drawn, the style, stroke, etc, will revert to the default
- Version:
- $Id$
- Author:
- John Reekie
-
-
Constructor Summary
Constructors Constructor Description VectorFigure()
Create a new blank figure.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Figure f)
Add a new figure to the list of drawn objectsvoid
add(java.awt.Composite c)
Add a new compositioning operator to the list of drawn objects.void
add(java.awt.Paint p)
Add a new paint to the list of drawn objects.void
add(java.awt.Shape s)
Add a new painted shape to the list of drawn objects.void
add(java.awt.Stroke s)
Add a new stroke to the list of drawn objects.void
fillMode()
Add an object to the list that puts drawing into fill modejava.awt.geom.Rectangle2D
getBounds()
Get the bounding box of this figure.java.awt.Shape
getShape()
Get the shape of this figure.void
lineMode()
Add an object to the list that puts drawing into line modevoid
paint(java.awt.Graphics2D g)
Paint the figure.void
setShape(java.awt.Shape s)
Set the shape of this Figure.void
transform(java.awt.geom.AffineTransform at)
Transform the figure with the supplied transform.-
Methods inherited from class diva.canvas.AbstractFigure
contains, getInteractor, getLayer, getOrigin, getParent, getToolTipText, getTransformContext, getUserObject, hit, intersects, isVisible, paint, repaint, repaint, setInteractor, setParent, setToolTipText, setUserObject, setVisible, translate
-
-
-
-
Method Detail
-
add
public void add(java.awt.Shape s)
Add a new painted shape to the list of drawn objects.
-
add
public void add(Figure f)
Add a new figure to the list of drawn objects
-
add
public void add(java.awt.Composite c)
Add a new compositioning operator to the list of drawn objects.
-
add
public void add(java.awt.Paint p)
Add a new paint to the list of drawn objects.
-
add
public void add(java.awt.Stroke s)
Add a new stroke to the list of drawn objects.
-
fillMode
public void fillMode()
Add an object to the list that puts drawing into fill mode
-
getBounds
public java.awt.geom.Rectangle2D getBounds()
Get the bounding box of this figure. If a bounding box has not yet been set (by calling the constructor that takes a Figure, or by calling _setBounds()), then a new bounding box will be computed by traversing the list of objects.- Specified by:
getBounds
in interfaceFigure
- Overrides:
getBounds
in classAbstractFigure
- Returns:
- the bounding box of this figure.
-
getShape
public java.awt.Shape getShape()
Get the shape of this figure. If a shape has not yet been set by calling setShape(), then the shape will be set to the bounding box.- Specified by:
getShape
in interfaceFigure
- Specified by:
getShape
in classAbstractFigure
- Returns:
- the outline shape of this figure
-
lineMode
public void lineMode()
Add an object to the list that puts drawing into line mode
-
paint
public void paint(java.awt.Graphics2D g)
Paint the figure.- Specified by:
paint
in interfaceVisibleComponent
- Specified by:
paint
in classAbstractFigure
- Parameters:
g
- The 2D graphics object that this object it to be painted upon.
-
setShape
public void setShape(java.awt.Shape s)
Set the shape of this Figure. This is useful when the default of the bounding box is not the right thing -- such as when a circular shape is required, for instance.
-
transform
public void transform(java.awt.geom.AffineTransform at)
Transform the figure with the supplied transform. This can be used to perform arbitrary translation, scaling, shearing, and rotation operations.- Specified by:
transform
in interfaceFigure
- Specified by:
transform
in classAbstractFigure
- Parameters:
at
- The transform to be used.
-
-