Package diva.canvas.toolbox
Class ImageFigure
- java.lang.Object
-
- diva.canvas.AbstractFigure
-
- diva.canvas.toolbox.ImageFigure
-
- All Implemented Interfaces:
CanvasComponent,Figure,VisibleComponent,UserObjectContainer,java.awt.image.ImageObserver
public class ImageFigure extends AbstractFigure implements java.awt.image.ImageObserver
A figure which draws a user-specified image.- Version:
- $Id$
- Author:
- Michael Shilman
-
-
Constructor Summary
Constructors Constructor Description ImageFigure()Create an empty image figure.ImageFigure(java.awt.Image i)Create an image figure displaying the given image.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.ImagegetImage()Return the figure's image.java.awt.geom.Point2DgetOrigin()Return the origin of the figure in the enclosing transform context.java.awt.ShapegetShape()Return the rectangular shape of the image, or a small rectangle if the image is null.booleanimageUpdate(java.awt.Image image, int infoflags, int x, int y, int width, int height)This method, which is required by the ImageObserver interface, is called if something has changed in a background loading of the image.booleanisCentered()Return whether the figure should be centered on its origin.voidpaint(java.awt.Graphics2D g)Paint the figure's image.voidsetCentered(boolean centered)Specify whether the figure should be centered on its origin.voidsetImage(java.awt.Image i)Set the figure's image.voidtransform(java.awt.geom.AffineTransform t)Perform an affine transform on this image.-
Methods inherited from class diva.canvas.AbstractFigure
contains, getBounds, getInteractor, getLayer, getParent, getToolTipText, getTransformContext, getUserObject, hit, intersects, isVisible, paint, repaint, repaint, setInteractor, setParent, setToolTipText, setUserObject, setVisible, translate
-
-
-
-
Method Detail
-
getImage
public java.awt.Image getImage()
Return the figure's image.
-
getOrigin
public java.awt.geom.Point2D getOrigin()
Return the origin of the figure in the enclosing transform context. This overrides the base class to return the center of the shape, if the figure is centered, or the origin of the shape if the figure is not centered.- Specified by:
getOriginin interfaceFigure- Overrides:
getOriginin classAbstractFigure- Returns:
- The origin of the figure.
- See Also:
AbstractFigure.getBounds()
-
getShape
public java.awt.Shape getShape()
Return the rectangular shape of the image, or a small rectangle if the image is null. NOTE: You cannot rely on the return value unless the image has been fully rendered.- Specified by:
getShapein interfaceFigure- Specified by:
getShapein classAbstractFigure- Returns:
- the outline shape of this figure
-
imageUpdate
public boolean imageUpdate(java.awt.Image image, int infoflags, int x, int y, int width, int height)This method, which is required by the ImageObserver interface, is called if something has changed in a background loading of the image. It simply calls repaint().- Specified by:
imageUpdatein interfacejava.awt.image.ImageObserver- Parameters:
image- The image being observed.infoflags- The bitwise inclusive OR of the following flags: WIDTH, HEIGHT, PROPERTIES, SOMEBITS, FRAMEBITS, ALLBITS, ERROR, ABORT.x- The x coordinate of the image.y- The y coordinate of the image.width- The width of the image.height- The height of the image.- Returns:
- False if the infoflags indicate that the image is completely loaded; true otherwise.
-
isCentered
public boolean isCentered()
Return whether the figure should be centered on its origin.- Returns:
- False If the origin of the figure, as returned by getOrigin(), is the upper left corner.
- See Also:
getOrigin(),setCentered(boolean)
-
paint
public void paint(java.awt.Graphics2D g)
Paint the figure's image.- Specified by:
paintin interfaceVisibleComponent- Specified by:
paintin classAbstractFigure- Parameters:
g- The 2D graphics object that this object it to be painted upon.
-
setCentered
public void setCentered(boolean centered)
Specify whether the figure should be centered on its origin. By default, it is.- Parameters:
centered- False to make the origin of the figure, as returned by getOrigin(), be the upper left corner.- See Also:
getOrigin()
-
setImage
public void setImage(java.awt.Image i)
Set the figure's image. This should be called only from the Swing thread.- Parameters:
i- The image.
-
transform
public void transform(java.awt.geom.AffineTransform t)
Perform an affine transform on this image.- Specified by:
transformin interfaceFigure- Specified by:
transformin classAbstractFigure- Parameters:
t- The transform to be used.
-
-