JHotDraw 6.0b1

org.jhotdraw.contrib
Class TriangleFigure

java.lang.Object
  extended by org.jhotdraw.standard.AbstractFigure
      extended by org.jhotdraw.figures.AttributeFigure
          extended by org.jhotdraw.figures.RectangleFigure
              extended by org.jhotdraw.contrib.TriangleFigure
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Figure, Storable
Direct Known Subclasses:
TriangleFigureGeometricAdapter

public class TriangleFigure
extends RectangleFigure

A triangle with same dimensions as its enclosing rectangle, and apex at any of 8 places

See Also:
Serialized Form

Constructor Summary
TriangleFigure()
           
TriangleFigure(java.awt.Point origin, java.awt.Point corner)
           
 
Method Summary
 java.awt.Point center()
          Gets the center of a figure.
 java.awt.Point chop(java.awt.Point p)
           
 java.lang.Object clone()
          Clones a figure.
 java.awt.Insets connectionInsets()
          Returns the connection inset.
 boolean containsPoint(int x, int y)
          Checks if a point is inside the figure.
 void draw(java.awt.Graphics g)
          Draws the figure in the given graphics.
 java.awt.Polygon getPolygon()
          Return the polygon describing the triangle
 double getRotationAngle()
           
 HandleEnumeration handles()
          Returns the handles of a Figure that can be used to manipulate some of its attributes.
 void read(StorableInput dr)
          Reads the Figure from a StorableInput.
 void rotate(double angle)
           
 void write(StorableOutput dw)
          Stores the Figure to a StorableOutput.
 
Methods inherited from class org.jhotdraw.figures.RectangleFigure
basicDisplayBox, basicMoveBy, displayBox, drawBackground, drawFrame
 
Methods inherited from class org.jhotdraw.figures.AttributeFigure
getAttribute, getAttribute, getDefaultAttribute, getDefaultAttribute, getFillColor, getFrameColor, initDefaultAttribute, setAttribute, setAttribute, setDefaultAttribute
 
Methods inherited from class org.jhotdraw.standard.AbstractFigure
addDependendFigure, addFigureChangeListener, addToContainer, canConnect, changed, connectedTextLocator, connectorAt, connectorVisibility, decompose, displayBox, displayBox, figures, findFigureInside, getDecoratedFigure, getDependendFigures, getTextHolder, getZValue, includes, invalidate, invalidateRectangle, isEmpty, listener, moveBy, release, removeDependendFigure, removeFigureChangeListener, removeFromContainer, setZValue, size, visit, willChange
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TriangleFigure

public TriangleFigure()

TriangleFigure

public TriangleFigure(java.awt.Point origin,
                      java.awt.Point corner)
Method Detail

handles

public HandleEnumeration handles()
Description copied from class: AbstractFigure
Returns the handles of a Figure that can be used to manipulate some of its attributes.

Specified by:
handles in interface Figure
Overrides:
handles in class RectangleFigure
Returns:
a type-safe iterator of handles
See Also:
Handle

rotate

public void rotate(double angle)

getPolygon

public java.awt.Polygon getPolygon()
Return the polygon describing the triangle


draw

public void draw(java.awt.Graphics g)
Description copied from class: AttributeFigure
Draws the figure in the given graphics. Draw is a template method calling drawBackground followed by drawFrame.

Specified by:
draw in interface Figure
Overrides:
draw in class AttributeFigure
Parameters:
g - the Graphics to draw into

connectionInsets

public java.awt.Insets connectionInsets()
Description copied from class: AbstractFigure
Returns the connection inset. The connection inset defines the area where the display box of a figure can't be connected. By default the entire display box can be connected.

Specified by:
connectionInsets in interface Figure
Overrides:
connectionInsets in class AbstractFigure

containsPoint

public boolean containsPoint(int x,
                             int y)
Description copied from class: AbstractFigure
Checks if a point is inside the figure.

Specified by:
containsPoint in interface Figure
Overrides:
containsPoint in class AbstractFigure

center

public java.awt.Point center()
Description copied from class: AbstractFigure
Gets the center of a figure. A convenice method that is rarely overridden.

Specified by:
center in interface Figure
Overrides:
center in class AbstractFigure

chop

public java.awt.Point chop(java.awt.Point p)

clone

public java.lang.Object clone()
Description copied from class: AbstractFigure
Clones a figure. Creates a clone by using the storable mechanism to flatten the Figure to stream followed by resurrecting it from the same stream.

Specified by:
clone in interface Figure
Overrides:
clone in class AbstractFigure
See Also:
Figure.clone()

getRotationAngle

public double getRotationAngle()

write

public void write(StorableOutput dw)
Description copied from class: AttributeFigure
Stores the Figure to a StorableOutput.

Specified by:
write in interface Storable
Overrides:
write in class RectangleFigure

read

public void read(StorableInput dr)
          throws java.io.IOException
Description copied from class: AttributeFigure
Reads the Figure from a StorableInput.

Specified by:
read in interface Storable
Overrides:
read in class RectangleFigure
Throws:
java.io.IOException

JHotDraw 6.0b1