CH.ifa.draw.figures
Class PolyLineFigure
- java.lang.Object
-
- CH.ifa.draw.standard.AbstractFigure
-
- CH.ifa.draw.figures.PolyLineFigure
-
- Direct Known Subclasses:
- LineConnection, LineFigure
public class PolyLineFigure extends AbstractFigure
A poly line figure consists of a list of points. It has an optional line decoration at the start and end.- See Also:
LineDecoration, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static intARROW_TIP_BOTHstatic intARROW_TIP_ENDstatic intARROW_TIP_NONEstatic intARROW_TIP_START-
Fields inherited from interface CH.ifa.draw.framework.Figure
POPUP_MENU
-
-
Constructor Summary
Constructors Constructor and Description PolyLineFigure()PolyLineFigure(int size)PolyLineFigure(int x, int y)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddPoint(int x, int y)Adds a node to the list of points.voidbasicDisplayBox(java.awt.Point origin, java.awt.Point corner)Sets the display box of a figure.ConnectorconnectorAt(int x, int y)Returns the Figures connector for the specified location.booleancontainsPoint(int x, int y)Checks if a point is inside the figure.java.awt.RectangledisplayBox()Gets the display box of a figure.voiddraw(java.awt.Graphics g)Draws the figure.intfindSegment(int x, int y)Gets the segment of the polyline that is hit by the given point.java.lang.ObjectgetAttribute(java.lang.String name)Gets the attribute with the given name.LineDecorationgetEndDecoration()Returns the end decoration.LineDecorationgetStartDecoration()Returns the start decoration.java.util.Vectorhandles()Returns the handles of a Figure that can be used to manipulate some of its attributes.voidinsertPointAt(java.awt.Point p, int i)Insert a node at the given point.booleanisEmpty()Checks if the figure is empty.booleanjoinSegments(int x, int y)Joins to segments into one if the given point hits a node of the polyline.static Locatorlocator(int pointIndex)Creates a locator for the point with the given index.java.awt.PointpointAt(int i)intpointCount()java.util.Enumerationpoints()voidread(StorableInput dr)Reads the Figure from a StorableInput.voidremovePointAt(int i)voidsetAttribute(java.lang.String name, java.lang.Object value)Sets the attribute with the given name.voidsetEndDecoration(LineDecoration l)Sets the end decoration.voidsetPointAt(java.awt.Point p, int i)Changes the position of a node.voidsetStartDecoration(LineDecoration l)Sets the start decoration.intsplitSegment(int x, int y)Splits the segment at the given point if a segment was hit.voidwrite(StorableOutput dw)Stores the Figure to a StorableOutput.-
Methods inherited from class CH.ifa.draw.standard.AbstractFigure
addFigureChangeListener, addToContainer, canConnect, center, changed, clone, connectedTextLocator, connectionInsets, connectorVisibility, decompose, displayBox, displayBox, figures, findFigureInside, includes, invalidate, listener, moveBy, release, removeFigureChangeListener, removeFromContainer, size, willChange
-
-
-
-
Field Detail
-
ARROW_TIP_NONE
public static final int ARROW_TIP_NONE
- See Also:
- Constant Field Values
-
ARROW_TIP_START
public static final int ARROW_TIP_START
- See Also:
- Constant Field Values
-
ARROW_TIP_END
public static final int ARROW_TIP_END
- See Also:
- Constant Field Values
-
ARROW_TIP_BOTH
public static final int ARROW_TIP_BOTH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PolyLineFigure
public PolyLineFigure()
-
PolyLineFigure
public PolyLineFigure(int size)
-
PolyLineFigure
public PolyLineFigure(int x, int y)
-
-
Method Detail
-
displayBox
public java.awt.Rectangle displayBox()
Description copied from class:AbstractFigureGets the display box of a figure.- Specified by:
displayBoxin interfaceFigure- Specified by:
displayBoxin classAbstractFigure- See Also:
Figure.basicDisplayBox(java.awt.Point, java.awt.Point)
-
isEmpty
public boolean isEmpty()
Description copied from class:AbstractFigureChecks if the figure is empty. The default implementation returns true if the width or height of its display box is < 3- Specified by:
isEmptyin interfaceFigure- Overrides:
isEmptyin classAbstractFigure- See Also:
Figure.isEmpty()
-
handles
public java.util.Vector handles()
Description copied from class:AbstractFigureReturns the handles of a Figure that can be used to manipulate some of its attributes.- Specified by:
handlesin interfaceFigure- Specified by:
handlesin classAbstractFigure- Returns:
- a Vector of handles
- See Also:
Handle
-
basicDisplayBox
public void basicDisplayBox(java.awt.Point origin, java.awt.Point corner)Description copied from class:AbstractFigureSets the display box of a figure. This is the method that subclassers override. Clients usually call displayBox.- Specified by:
basicDisplayBoxin interfaceFigure- Specified by:
basicDisplayBoxin classAbstractFigure- Parameters:
origin- the new origincorner- the new corner- See Also:
AbstractFigure.displayBox(java.awt.Point, java.awt.Point)
-
addPoint
public void addPoint(int x, int y)Adds a node to the list of points.
-
points
public java.util.Enumeration points()
-
pointCount
public int pointCount()
-
setPointAt
public void setPointAt(java.awt.Point p, int i)Changes the position of a node.
-
insertPointAt
public void insertPointAt(java.awt.Point p, int i)Insert a node at the given point.
-
removePointAt
public void removePointAt(int i)
-
splitSegment
public int splitSegment(int x, int y)Splits the segment at the given point if a segment was hit.- Returns:
- the index of the segment or -1 if no segment was hit.
-
pointAt
public java.awt.Point pointAt(int i)
-
joinSegments
public boolean joinSegments(int x, int y)Joins to segments into one if the given point hits a node of the polyline.- Returns:
- true if the two segments were joined.
-
connectorAt
public Connector connectorAt(int x, int y)
Description copied from class:AbstractFigureReturns the Figures connector for the specified location. By default a ChopBoxConnector is returned.- Specified by:
connectorAtin interfaceFigure- Overrides:
connectorAtin classAbstractFigure- See Also:
ChopBoxConnector
-
setStartDecoration
public void setStartDecoration(LineDecoration l)
Sets the start decoration.
-
getStartDecoration
public LineDecoration getStartDecoration()
Returns the start decoration.
-
setEndDecoration
public void setEndDecoration(LineDecoration l)
Sets the end decoration.
-
getEndDecoration
public LineDecoration getEndDecoration()
Returns the end decoration.
-
draw
public void draw(java.awt.Graphics g)
Description copied from interface:FigureDraws the figure.- Parameters:
g- the Graphics to draw into
-
containsPoint
public boolean containsPoint(int x, int y)Description copied from class:AbstractFigureChecks if a point is inside the figure.- Specified by:
containsPointin interfaceFigure- Overrides:
containsPointin classAbstractFigure
-
findSegment
public int findSegment(int x, int y)Gets the segment of the polyline that is hit by the given point.- Returns:
- the index of the segment or -1 if no segment was hit.
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
Gets the attribute with the given name. PolyLineFigure maps "ArrowMode"to a line decoration.- Specified by:
getAttributein interfaceFigure- Overrides:
getAttributein classAbstractFigure
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)Sets the attribute with the given name. PolyLineFigure interprets "ArrowMode"to set the line decoration.- Specified by:
setAttributein interfaceFigure- Overrides:
setAttributein classAbstractFigure
-
write
public void write(StorableOutput dw)
Description copied from class:AbstractFigureStores the Figure to a StorableOutput.- Specified by:
writein interfaceStorable- Overrides:
writein classAbstractFigure
-
read
public void read(StorableInput dr) throws java.io.IOException
Description copied from class:AbstractFigureReads the Figure from a StorableInput.- Specified by:
readin interfaceStorable- Overrides:
readin classAbstractFigure- Throws:
java.io.IOException
-
locator
public static Locator locator(int pointIndex)
Creates a locator for the point with the given index.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG