org.jhotdraw.samples.mini
Class StraightLineFigure
- java.lang.Object
-
- org.jhotdraw.beans.AbstractBean
-
- org.jhotdraw.draw.AbstractFigure
-
- org.jhotdraw.draw.AbstractAttributedFigure
-
- org.jhotdraw.samples.mini.StraightLineFigure
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, Figure, DOMStorable
public class StraightLineFigure extends AbstractAttributedFigure
Example showing the minimal amount of code needed to implement aFigureby extendingAbstractAttributedFigure.- 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 StraightLineFigure()Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description StraightLineFigureclone()Returns a clone of the figure, with clones of all aggregated figures, such as children and decorators.booleancontains(java.awt.geom.Point2D.Double p)Checks if a point is contained by the figure.java.awt.geom.Rectangle2D.DoublegetBounds()Returns the untransformed logical bounds of the figure as a Rectangle.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.voidrestoreTransformTo(java.lang.Object restoreData)Restores the transform of the figure to a previously stored state.voidsetBounds(java.awt.geom.Point2D.Double start, java.awt.geom.Point2D.Double end)Sets the logical and untransformed bounds of the figure.voidtransform(java.awt.geom.AffineTransform ty)Transforms the shape of the Figure.-
Methods inherited from class org.jhotdraw.draw.AbstractAttributedFigure
draw, get, getAttributes, getAttributesRestoreData, getDrawingArea, getStroke, getStrokeMiterLimitFactor, hasAttribute, isAttributeEnabled, read, removeAttribute, restoreAttributesTo, set, setAttributeEnabled, setAttributes, write
-
Methods inherited from class org.jhotdraw.draw.AbstractFigure
addFigureListener, addNotify, changed, createHandles, findCompatibleConnector, findConnector, findFigureInside, fireAreaInvalidated, fireFigureChanged, getActions, 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
addPropertyChangeListener, removePropertyChangeListener
-
-
-
-
Method Detail
-
transform
public void transform(java.awt.geom.AffineTransform ty)
Description copied from interface:FigureTransforms the shape of the Figure. Transformations using double precision arithmethics are inherently lossy operations. Therefore it is recommended to use getTransformRestoreData() restoreTransformTo() to provide lossless undo/redo functionality.This is a basic operation which does not fire events. Use the following code sequence, if you need event firing:
figure.willChange(); figure.transform(...); figure.changed();
- Parameters:
ty- The transformation.- See Also:
Figure.getTransformRestoreData(),Figure.restoreTransformTo(java.lang.Object)
-
setBounds
public void setBounds(java.awt.geom.Point2D.Double start, java.awt.geom.Point2D.Double end)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:
start- the start point of the boundsend- the end point of the bounds- See Also:
Figure.getBounds()
-
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.
-
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.- See Also:
Figure.transform(AffineTransform)
-
restoreTransformTo
public void restoreTransformTo(java.lang.Object restoreData)
Description copied from interface:FigureRestores the transform of the figure to a previously stored state.
-
contains
public boolean contains(java.awt.geom.Point2D.Double p)
Description copied from interface:FigureChecks if a point is contained by the figure.This is used for hit testing by Tool's.
-
clone
public StraightLineFigure 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 classAbstractAttributedFigure
-
-
DataMelt 3.0 © DataMelt by jWork.ORG