Package diva.canvas.toolbox
Class IconFigure
- java.lang.Object
-
- diva.canvas.AbstractFigure
-
- diva.canvas.toolbox.IconFigure
-
- All Implemented Interfaces:
CanvasComponent
,Figure
,VisibleComponent
,UserObjectContainer
public class IconFigure extends AbstractFigure
An IconFigure is a figure that contains a main background figure, a PaintedObject to decorate that figure, a label, and an arbitrary number of attached Terminal objects.- Version:
- $Id$
- Author:
- John Reekie
-
-
Constructor Summary
Constructors Constructor Description IconFigure(Figure f)
Create a new icon figure using the given figure as the "background" figure.IconFigure(Figure f, PaintedObject g)
Create a new icon figure using the given figure as the "background" figure and the given Painted object as its "graphic."IconFigure(Figure f, PaintedObject g, java.lang.String label)
Create a new icon figure using the given figure as the "background" figure, the given Painted object as its "graphic," and the given string as a displayed label.IconFigure(Figure f, java.lang.String label)
Create a new icon figure using the given figure as the "background" figure and with the given label.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTerminal(Terminal t, int side, double offset)
Add the given terminal, on the given side and with the given offset, to the icon.Figure
getBackground()
Get the background figure of the icon.java.awt.geom.Rectangle2D
getBounds()
Get the bounding box of this icon, including the terminals.java.awt.Composite
getComposite()
Get the composite of this icon, or null if it doesn't have one.PaintedObject
getGraphic()
Get the painted object that is drawn over the top of the icon as its "graphic."java.awt.Shape
getShape()
Get the shape of this figure.Terminal
getTerminal(int index)
Get the terminal at the given indexboolean
intersects(java.awt.geom.Rectangle2D r)
Test if this figure intersects the given rectangle.void
paint(java.awt.Graphics2D g)
Paint the icon.void
setComposite(java.awt.Composite c)
Set the color composition operator of this figure.void
setLabel(java.lang.String s)
Set the label of this figure.java.util.Iterator
terminals()
Get an iterator over the terminals of this figure.void
transform(java.awt.geom.AffineTransform at)
Transform the figure with the supplied transform.void
translate(double x, double y)
Translate the figure the given distance.-
Methods inherited from class diva.canvas.AbstractFigure
contains, getInteractor, getLayer, getOrigin, getParent, getToolTipText, getTransformContext, getUserObject, hit, isVisible, paint, repaint, repaint, setInteractor, setParent, setToolTipText, setUserObject, setVisible
-
-
-
-
Constructor Detail
-
IconFigure
public IconFigure(Figure f)
Create a new icon figure using the given figure as the "background" figure.
-
IconFigure
public IconFigure(Figure f, PaintedObject g)
Create a new icon figure using the given figure as the "background" figure and the given Painted object as its "graphic."
-
IconFigure
public IconFigure(Figure f, java.lang.String label)
Create a new icon figure using the given figure as the "background" figure and with the given label.
-
IconFigure
public IconFigure(Figure f, PaintedObject g, java.lang.String label)
Create a new icon figure using the given figure as the "background" figure, the given Painted object as its "graphic," and the given string as a displayed label.
-
-
Method Detail
-
addTerminal
public void addTerminal(Terminal t, int side, double offset)
Add the given terminal, on the given side and with the given offset, to the icon. A BoundsSite will be created and the terminal attached to it. See the BoundsSite class for a description if the side and offset arguments.
-
getBackground
public Figure getBackground()
Get the background figure of the icon.
-
getBounds
public java.awt.geom.Rectangle2D getBounds()
Get the bounding box of this icon, including the terminals. The bounds of the painted objects on top of the icon is not included in the calculation, as its expensive to compute and whoever created the icon is assumed to check that the painted objects are within bounds at creation time.- Specified by:
getBounds
in interfaceFigure
- Overrides:
getBounds
in classAbstractFigure
- Returns:
- the bounding box of this figure.
-
getGraphic
public PaintedObject getGraphic()
Get the painted object that is drawn over the top of the icon as its "graphic."
-
getComposite
public java.awt.Composite getComposite()
Get the composite of this icon, or null if it doesn't have one.
-
getShape
public java.awt.Shape getShape()
Get the shape of this figure. This is the shape of the background figure.- Specified by:
getShape
in interfaceFigure
- Specified by:
getShape
in classAbstractFigure
- Returns:
- the outline shape of this figure
-
getTerminal
public Terminal getTerminal(int index)
Get the terminal at the given index
-
intersects
public boolean intersects(java.awt.geom.Rectangle2D r)
Test if this figure intersects the given rectangle.- Specified by:
intersects
in interfaceFigure
- Overrides:
intersects
in classAbstractFigure
- Parameters:
r
- The rectangle to be checked.- Returns:
- truen if the figure intersects the given rectangle.
-
paint
public void paint(java.awt.Graphics2D g)
Paint the icon.- Specified by:
paint
in interfaceVisibleComponent
- Specified by:
paint
in classAbstractFigure
- Parameters:
g
- The 2D graphics object that this object it to be painted upon.
-
setComposite
public void setComposite(java.awt.Composite c)
Set the color composition operator of this figure. If the composite is set to null, then the composite will not be changed when the figure is painted -- provided that all other objects in the system are well-behaved, this means that icons will be opaque. The default composite value is null.
-
setLabel
public void setLabel(java.lang.String s)
Set the label of this figure.
-
terminals
public java.util.Iterator terminals()
Get an iterator over the terminals of this figure.
-
transform
public void transform(java.awt.geom.AffineTransform at)
Transform the figure with the supplied transform. This method transforms the background figure and the graphic, but not the label or the terminals.- Specified by:
transform
in interfaceFigure
- Specified by:
transform
in classAbstractFigure
- Parameters:
at
- The transform to be used.
-
translate
public void translate(double x, double y)
Translate the figure the given distance.- Specified by:
translate
in interfaceFigure
- Overrides:
translate
in classAbstractFigure
- Parameters:
x
- The x value to be moved.y
- The y value to be moved.
-
-