|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.tigris.gef.presentation.Fig
org.tigris.gef.presentation.FigPoly
public class FigPoly
Primitive Fig to paint Polygons on a LayerDiagram. FigPolys contain a set of points that define the polygon, a boolean to determine if the polygon should be constrained to rectilinear (strict horizontal and vertical) segments, and a number of handles that cannot be moved by user dragging. A FigPoly is not closed unless the last point equals the first point. Thus, FigPolys can be used to represent polylines such as FigEdgeRectilinear.
FigEdgeRectiline
,
Serialized FormField Summary | |
---|---|
protected int |
_fixedHandles
The number of handles at each end of the polygon that cannot be dragged by the user. |
boolean |
_isComplete
Flag to indicate when the polygon is completed |
protected boolean |
_isSelfLoop
Flag to indicate when the polygon is used as a self-loop for a node |
protected int |
_npoints
The total number of points. |
protected boolean |
_rectilinear
Flag to control how the polygon is drawn |
protected int[] |
_xpoints
The array of x coordinates. |
protected int[] |
_ypoints
The array of y coordinates. |
protected static double |
FUDGEFACTOR
The radian angle at which a point can be deleted. |
Fields inherited from class org.tigris.gef.presentation.Fig |
---|
_allowsSaving, _context, _dashes, _dashPeriod, _dashStyle, _filled, _h, _w, _x, _y, an, annotationOwner, annotationStatus, BORDER, MIN_SIZE |
Constructor Summary | |
---|---|
FigPoly()
Construct a new FigPoly. |
|
FigPoly(java.awt.Color lineColor)
Construct a new FigPoly w/ the given line color. |
|
FigPoly(java.awt.Color lineColor,
java.awt.Color fillColor)
Construct a new FigPoly w/ the given line color and fill color. |
|
FigPoly(int x,
int y)
Construct a new FigPoly w/ the given point. |
Method Summary | |
---|---|
void |
addPoint(int x,
int y)
Add a point to this polygon. |
void |
addPoint(java.awt.Point p)
Add a point to this polygon. |
protected void |
appendTwoPoints()
Add two points at the end of the polygon. |
void |
calcBounds()
Update the bounding box. |
protected boolean |
canMoveVertex(int i,
boolean ov)
Reply true if the point at the given index can be moved. |
void |
cleanUp()
|
java.lang.Object |
clone()
|
boolean |
contains(int x,
int y)
Reply true iff the given point is inside this FigPoly. |
protected int |
countCornersContained(int x,
int y,
int w,
int h)
Return the number of corners of the given rectangle that are contained within this polygon. |
protected void |
drawDashedPerimeter(java.awt.Graphics g)
A faster implementation of drawDashedPerimeter for polygons. |
protected int |
findHandle(int x,
int y)
Reply the index of the vertex that the given mouse point is near. |
java.awt.Point |
getClosestPoint(java.awt.Point anotherPt)
Returns the point that other connected Figs should attach to. |
java.awt.Point |
getFirstPoint()
USED BY PGML.tee |
int |
getFixedHandles()
Reply the number of fixed handles. |
java.util.List |
getGravityPoints()
|
java.awt.Point |
getLastPoint()
|
int |
getNumPoints()
Return the number of points in this polygon |
int |
getPerimeterLength()
Returns the length of the perimeter of the polygon, which is the sum of all the lengths of its segments. |
java.awt.Point |
getPoint(int i)
Find the required line break and return it's corordinates as a Point. |
java.awt.Point[] |
getPoints()
USED BY PGML.tee |
java.util.List |
getPointsList()
USED BY PGML.tee |
java.awt.Polygon |
getPolygon()
Get the current vector of points as a java.awt.Polygon. |
boolean |
getRectilinear()
Return true if the polygon should be constrained to rectilinear segments. |
int[] |
getXs()
Returns the array of X coordinates of points |
int[] |
getYs()
Returns the array of Y coordinates of points |
protected void |
growIfNeeded()
Increase the memory used to store polygon points, if needed. |
boolean |
hit(java.awt.Rectangle rect)
Tests, if the given rectangle hits this polygon. |
void |
insertPoint(int i,
int x,
int y)
Inserts a point at index i. |
boolean |
intersectsPerimeter(java.awt.Rectangle rect)
Tests, if the given rectangle intersects with the perimeter of this polygon. |
boolean |
isPerimeterClosed()
Tests, if the perimeter of the polygon is closed, i.e. |
boolean |
isReshapable()
Returns true if this Fig can be reshaped by the user. |
boolean |
isResizable()
FigPolys are resizeable and reshapable, but not rotatable (yet). |
boolean |
isRotatable()
Returns true if this Fig can be rotated by the user. |
boolean |
isSelfLoop()
|
void |
moveVertex(Handle h,
int x,
int y,
boolean ov)
Move the point indicated by the given Handle object to the given location. |
boolean |
OK()
Class invarient to make sure this object is in a valid state. |
void |
paint(java.awt.Graphics g)
Paint the FigPoly on the given Graphics |
protected void |
prependTwoPoints()
Add two points to the front of the list of points. |
void |
removePoint(int i)
Removes the point at index i. |
void |
setBounds(int x,
int y,
int w,
int h)
Sets the FigPoly's bounding box to the given coordinates. |
void |
setEndPoints(java.awt.Point start,
java.awt.Point end)
Set the end points of this polygon, regardless of the number of fixed handles. |
void |
setFixedHandles(int n)
Set the number of points near each end of the polygon that cannot be dragged by the user. |
void |
setPoints(Handle h,
int mX,
int mY)
When the user drags the handles, move individual points |
void |
setPolygon(java.awt.Polygon p)
Set the current vector of points. |
void |
setRectilinear(boolean r)
Set the rectilinear flag. |
void |
setSelfLoop(boolean self)
|
void |
stuffPointAlongPerimeter(int dist,
java.awt.Point res)
Returns a point along the perimeter at distance dist from the start of the polygon. |
void |
translate(int dx,
int dy)
Change the position of the object from were it is to were it is plus dx or dy. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final double FUDGEFACTOR
protected int _npoints
protected int[] _xpoints
protected int[] _ypoints
protected boolean _rectilinear
public boolean _isComplete
protected boolean _isSelfLoop
protected int _fixedHandles
Constructor Detail |
---|
public FigPoly(java.awt.Color lineColor)
public FigPoly(java.awt.Color lineColor, java.awt.Color fillColor)
public FigPoly()
public FigPoly(int x, int y)
Method Detail |
---|
public java.lang.Object clone()
clone
in class Fig
public boolean OK()
OK
in class Fig
public java.awt.Polygon getPolygon()
public void setPolygon(java.awt.Polygon p)
public void setSelfLoop(boolean self)
public int getNumPoints()
getNumPoints
in class Fig
public boolean getRectilinear()
public void setRectilinear(boolean r)
public int getFixedHandles()
public void setFixedHandles(int n)
public boolean isSelfLoop()
public void setEndPoints(java.awt.Point start, java.awt.Point end)
public void translate(int dx, int dy)
translate
in class Fig
public void addPoint(int x, int y)
addPoint
in class Fig
public final void addPoint(java.awt.Point p)
protected boolean canMoveVertex(int i, boolean ov)
public void moveVertex(Handle h, int x, int y, boolean ov)
protected void prependTwoPoints()
protected void appendTwoPoints()
public void removePoint(int i)
removePoint
in class Fig
public void insertPoint(int i, int x, int y)
insertPoint
in class Fig
protected void growIfNeeded()
public java.awt.Point getPoint(int i)
getPoint
in class Fig
i
- the position of the point to return
public java.util.List getPointsList()
public java.awt.Point[] getPoints()
getPoints
in class Fig
public java.awt.Point getFirstPoint()
getFirstPoint
in class Fig
public java.awt.Point getLastPoint()
getLastPoint
in class Fig
public void setPoints(Handle h, int mX, int mY)
public void cleanUp()
cleanUp
in class Fig
public java.awt.Point getClosestPoint(java.awt.Point anotherPt)
getClosestPoint
in class Fig
public java.util.List getGravityPoints()
getGravityPoints
in class Fig
public void paint(java.awt.Graphics g)
paint
in class Fig
protected void drawDashedPerimeter(java.awt.Graphics g)
drawDashedPerimeter
in class Fig
protected int findHandle(int x, int y)
public boolean contains(int x, int y)
contains
in class Fig
FigCircle
,
FigEdge
public int[] getXs()
getXs
in class Fig
public int[] getYs()
getYs
in class Fig
public void setBounds(int x, int y, int w, int h)
setBounds
in class Fig
public int getPerimeterLength()
getPerimeterLength
in class Fig
public void stuffPointAlongPerimeter(int dist, java.awt.Point res)
stuffPointAlongPerimeter
in class Fig
public boolean isResizable()
isResizable
in class Fig
public boolean isReshapable()
Fig
isReshapable
in class Fig
public boolean isRotatable()
Fig
isRotatable
in class Fig
public boolean isPerimeterClosed()
protected int countCornersContained(int x, int y, int w, int h)
countCornersContained
in class Fig
Fig.hit(java.awt.Rectangle)
public boolean hit(java.awt.Rectangle rect)
hit
in class Fig
rect
- The rectangle to be tested.
public boolean intersectsPerimeter(java.awt.Rectangle rect)
intersectsPerimeter
in class Fig
rect
- The rectangle to be tested.
public void calcBounds()
calcBounds
in class Fig
FigText.calcBounds()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |