Class ImageFigure
- java.lang.Object
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, DecoratedFigure, Figure, ImageHolderFigure, DOMStorable
public class ImageFigure extends AbstractAttributedDecoratedFigure implements ImageHolderFigure
A default implementation ofImageHolderFigurewhich can hold a buffered image.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.jhotdraw.draw.Figure
CONNECTABLE_PROPERTY, REMOVABLE_PROPERTY, SELECTABLE_PROPERTY, TRANSFORMABLE_PROPERTY
-
-
Constructor Summary
Constructors Constructor and Description ImageFigure()Creates a new instance.ImageFigure(double x, double y, double width, double height)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description ImageFigureclone()Returns a clone of the figure, with clones of all aggregated figures, such as children and decorators.booleanfigureContains(java.awt.geom.Point2D.Double p)Checks if a Point2D.Double is inside the figure.ConnectorfindCompatibleConnector(Connector c, boolean isStartConnector)Gets a compatible connector.ConnectorfindConnector(java.awt.geom.Point2D.Double p, ConnectionFigure prototype)Returns the Figures connector for the specified location.java.util.Collection<javax.swing.Action>getActions(java.awt.geom.Point2D.Double p)Returns a collection of actions which are presented to the user in a popup menu.java.awt.geom.Rectangle2D.DoublegetBounds()Returns the untransformed logical bounds of the figure as a Rectangle.java.awt.image.BufferedImagegetBufferedImage()Gets the buffered image.java.awt.geom.Rectangle2D.DoublegetFigureDrawingArea()byte[]getImageData()Gets the image data.java.lang.ObjectgetTransformRestoreData()Gets data which can be used to restore the transformation of the figure without loss of precision, after a transform has been applied to it.voidloadImage(java.io.File file)Loads an image from a File.voidloadImage(java.io.InputStream in)Loads an image from an Input Stream.voidread(DOMInput in)voidrestoreTransformTo(java.lang.Object geometry)Restores the transform of the figure to a previously stored state.voidsetBounds(java.awt.geom.Point2D.Double anchor, java.awt.geom.Point2D.Double lead)Sets the logical and untransformed bounds of the figure.voidsetBufferedImage(java.awt.image.BufferedImage image)Sets the buffered image.voidsetImage(byte[] imageData, java.awt.image.BufferedImage bufferedImage)Sets the image.voidsetImageData(byte[] imageData)Sets the image data.voidtransform(java.awt.geom.AffineTransform tx)Transforms the figure.voidwrite(DOMOutput out)-
Methods inherited from class org.jhotdraw.draw.AbstractAttributedDecoratedFigure
contains, draw, getDecorator, getDrawingArea, setDecorator
-
Methods inherited from class org.jhotdraw.draw.AbstractAttributedFigure
get, getAttributes, getAttributesRestoreData, getStroke, getStrokeMiterLimitFactor, hasAttribute, isAttributeEnabled, removeAttribute, restoreAttributesTo, set, setAttributeEnabled, setAttributes
-
Methods inherited from class org.jhotdraw.draw.AbstractFigure
addFigureListener, addNotify, changed, createHandles, findFigureInside, fireAreaInvalidated, fireFigureChanged, getConnectors, getCursor, getDecomposition, getEndPoint, getLayer, getPreferredSize, getStartPoint, getTool, getToolTipText, handleDrop, handleMouseClick, includes, isConnectable, isRemovable, isSelectable, isTransformable, isVisible, remap, removeFigureListener, removeNotify, requestRemove, setBounds, setConnectable, setRemovable, setSelectable, setTransformable, setVisible, toString, willChange
-
Methods inherited from class org.jhotdraw.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jhotdraw.draw.Figure
addFigureListener, addNotify, addPropertyChangeListener, changed, contains, createHandles, draw, findFigureInside, get, getAttributes, getAttributesRestoreData, getConnectors, getCursor, getDecomposition, getDrawingArea, getEndPoint, getLayer, getPreferredSize, getStartPoint, getTool, getToolTipText, handleDrop, handleMouseClick, includes, isConnectable, isRemovable, isSelectable, isTransformable, isVisible, remap, removeFigureListener, removeNotify, removePropertyChangeListener, requestRemove, restoreAttributesTo, set, willChange
-
-
-
-
Constructor Detail
-
ImageFigure
public ImageFigure()
Creates a new instance.
-
ImageFigure
public ImageFigure(double x, double y, double width, double height)
-
-
Method Detail
-
getBounds
public java.awt.geom.Rectangle2D.Double getBounds()
Description copied from interface:FigureReturns the untransformed logical bounds of the figure as a Rectangle.The bounds are used by Handle objects for adjusting the figure and for aligning the figure on a grid.
-
getFigureDrawingArea
public java.awt.geom.Rectangle2D.Double getFigureDrawingArea()
-
figureContains
public boolean figureContains(java.awt.geom.Point2D.Double p)
Checks if a Point2D.Double is inside the figure.
-
setBounds
public void setBounds(java.awt.geom.Point2D.Double anchor, java.awt.geom.Point2D.Double lead)Description copied from interface:FigureSets the logical and untransformed bounds of the figure.This is used by Tool's which create a new Figure and by Tool's which connect a Figure to another Figure.
This is a basic operation which does not fire events. Use the following code sequence, if you need event firing:
figure.willChange(); figure.setBounds(...); figure.changed();
- Specified by:
setBoundsin interfaceFigure- Overrides:
setBoundsin classAbstractFigure- Parameters:
anchor- the start point of the boundslead- the end point of the bounds- See Also:
Figure.getBounds()
-
transform
public void transform(java.awt.geom.AffineTransform tx)
Transforms the figure.- Specified by:
transformin interfaceFigure- Parameters:
tx- The transformation.- See Also:
Figure.getTransformRestoreData(),Figure.restoreTransformTo(java.lang.Object)
-
restoreTransformTo
public void restoreTransformTo(java.lang.Object geometry)
Description copied from interface:FigureRestores the transform of the figure to a previously stored state.- Specified by:
restoreTransformToin interfaceFigure
-
getTransformRestoreData
public java.lang.Object getTransformRestoreData()
Description copied from interface:FigureGets data which can be used to restore the transformation of the figure without loss of precision, after a transform has been applied to it.- Specified by:
getTransformRestoreDatain interfaceFigure- See Also:
Figure.transform(AffineTransform)
-
getActions
public java.util.Collection<javax.swing.Action> getActions(java.awt.geom.Point2D.Double p)
Description copied from class:AbstractFigureReturns a collection of actions which are presented to the user in a popup menu.The collection may contain null entries. These entries are used interpreted as separators in the popup menu.
- Specified by:
getActionsin interfaceFigure- Overrides:
getActionsin classAbstractFigure
-
findConnector
public Connector findConnector(java.awt.geom.Point2D.Double p, ConnectionFigure prototype)
Description copied from class:AbstractFigureReturns the Figures connector for the specified location. By default a ChopBoxConnector is returned.- Specified by:
findConnectorin interfaceFigure- Overrides:
findConnectorin classAbstractFigure- Parameters:
p- the location of the connector.prototype- The prototype used to create a connection or null if unknown. This allows for specific connectors for different connection figures.- See Also:
ChopRectangleConnector
-
findCompatibleConnector
public Connector findCompatibleConnector(Connector c, boolean isStartConnector)
Description copied from interface:FigureGets a compatible connector. If the provided connector is part of this figure, return the connector. If the provided connector is part of another figure, return a connector with the same semantics for this figure. Returns null, if no compatible connector is available.- Specified by:
findCompatibleConnectorin interfaceFigure- Overrides:
findCompatibleConnectorin classAbstractFigure
-
clone
public ImageFigure clone()
Description copied from interface:FigureReturns a clone of the figure, with clones of all aggregated figures, such as children and decorators. The cloned figure does not clone the list of FigureListeners from its original.- Specified by:
clonein interfaceFigure- Overrides:
clonein classAbstractAttributedDecoratedFigure
-
read
public void read(DOMInput in) throws java.io.IOException
- Specified by:
readin interfaceDOMStorable- Overrides:
readin classAbstractAttributedDecoratedFigure- Throws:
java.io.IOException
-
write
public void write(DOMOutput out) throws java.io.IOException
- Specified by:
writein interfaceDOMStorable- Overrides:
writein classAbstractAttributedDecoratedFigure- Throws:
java.io.IOException
-
setImage
public void setImage(byte[] imageData, java.awt.image.BufferedImage bufferedImage)Sets the image.- Specified by:
setImagein interfaceImageHolderFigure- Parameters:
imageData- The image data. If this is null, a buffered image must be provided.bufferedImage- An image constructed from the imageData. If this is null, imageData must be provided.
-
setImageData
public void setImageData(byte[] imageData)
Sets the image data. This clears the buffered image.Note: For performance reasons this method stores a reference to the imageData array instead of cloning it. Do not modify the image data array after invoking this method.
-
setBufferedImage
public void setBufferedImage(java.awt.image.BufferedImage image)
Sets the buffered image. This clears the image data.- Specified by:
setBufferedImagein interfaceImageHolderFigure
-
getBufferedImage
@Nullable public java.awt.image.BufferedImage getBufferedImage()
Gets the buffered image. If necessary, this method creates the buffered image from the image data.- Specified by:
getBufferedImagein interfaceImageHolderFigure
-
getImageData
@Nullable public byte[] getImageData()
Gets the image data. If necessary, this method creates the image data from the buffered image.Note: For performance reasons this method returns a reference to the internally used image data array instead of cloning it. Do not modify this array.
- Specified by:
getImageDatain interfaceImageHolderFigure- Returns:
- imageData The image data, or null, if the ImageHolderFigure does not have an image.
-
loadImage
public void loadImage(java.io.File file) throws java.io.IOExceptionDescription copied from interface:ImageHolderFigureLoads an image from a File. By convention this method is never invoked on the AWT Event Dispatcher Thread.- Specified by:
loadImagein interfaceImageHolderFigure- Throws:
java.io.IOException
-
loadImage
public void loadImage(java.io.InputStream in) throws java.io.IOExceptionDescription copied from interface:ImageHolderFigureLoads an image from an Input Stream. By convention this method is never invoked on the AWT Event Dispatcher Thread.- Specified by:
loadImagein interfaceImageHolderFigure- Throws:
java.io.IOException
-
-
DataMelt 3.0 © DataMelt by jWork.ORG