|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Polygon | +--gishur.gui2.PolygonShape
A PolygonShape represents a polygon. PolygonShape extends
Polygon
and implements the Shape
interface.
Fields inherited from class java.awt.Polygon |
bounds, npoints, xpoints, ypoints |
Constructor Summary | |
PolygonShape()
Creates an empty PolygonShape . |
|
PolygonShape(int[] xpoints,
int[] ypoints,
int length)
Constructs and initializes a PolygonShape from the specified parameters. |
|
PolygonShape(java.awt.Point[] points)
Constructs and initializes a PolygonShape from the specified point list. |
|
PolygonShape(java.awt.Point[] points,
int start,
int len)
Constructs and initializes a PolygonShape from the specified point list. |
|
PolygonShape(java.awt.Polygon pol)
Creates a PolygonShape from the specified polygon. |
Method Summary | |
void |
clear()
|
java.lang.Object |
clone()
Creates a new object of the same class as this object. |
boolean |
contains(int x,
int y)
Tests if a given coordinate is inside the boundary of the Shape . |
boolean |
contains(int x,
int y,
int w,
int h)
Tests if the interior of the Shape entirely contains
the specified rectangular area. |
boolean |
contains(java.awt.Point p)
Tests if a specified Point is inside the boundary
of the Shape . |
void |
draw(java.awt.Graphics g)
Strokes the outline of the Shape using the settings of the
Graphics context (if visible). |
void |
fill(java.awt.Graphics g)
Fills the interior of the Shape using the settings of the
Graphics context (if visible). |
java.awt.Rectangle |
getBounds()
Returns the bounding box of this EllipseShape. |
RectangleShape |
getBoundShape()
Return the bounding box of the Shape . |
java.awt.Point |
getCenter()
Returns the center point of the framing rectangle of the Shape . |
int |
getCenterX()
Returns the X coordinate of the center of the framing rectangle of the Shape . |
int |
getCenterY()
Returns the Y coordinate of the center of the framing rectangle of the Shape . |
boolean |
intersects(int x,
int y,
int w,
int h)
Tests if the interior of the Shape intersects the
interior of a specified rectangular area.
|
void |
set(int[] xpoints,
int[] ypoints)
Sets the polygon shape to the given points array. |
void |
set(java.awt.Point[] points,
int idx,
int len)
Sets the polygon shape to the given points array. |
static void |
setArrow(boolean right,
int x1,
int y1,
int x2,
int y2,
int width,
int height,
int[] xp,
int[] yp,
int idx)
Stores the arrow point for a right/left arrow at the given position in the coordinate array. |
static void |
setCurve(int x1,
int y1,
int x2,
int y2,
int x3,
int y3,
int width,
int steps,
int[] xp,
int[] yp,
int idx1,
int idx2)
Stores a bezier curve in the given coordinate arrays. |
static void |
setLine(int x1,
int y1,
int x2,
int y2,
int width,
int[] xp,
int[] yp,
int idx1,
int idx2)
Stores a line segment (x1,y1)-(x2,y2) with the line width
width in the given coordinate arrays. |
void |
setLocation(int x,
int y)
Moves the this Shape to the specified location. |
java.lang.String |
toString()
Returns a string representation of the object. |
Methods inherited from class java.awt.Polygon |
addPoint, contains, contains, contains, contains, getBoundingBox, getBounds2D, getPathIterator, getPathIterator, inside, intersects, intersects, translate |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface gishur.gui2.Shape |
translate |
Methods inherited from interface java.awt.Shape |
contains, contains, contains, contains, getBounds2D, getPathIterator, getPathIterator, intersects, intersects |
Constructor Detail |
public PolygonShape()
PolygonShape
.public PolygonShape(int[] xpoints, int[] ypoints, int length)
xpoints
- an array of x coordinates.ypoints
- an array of y coordinates.length
- the total number of points in the polygon.public PolygonShape(java.awt.Polygon pol)
pol
- the polygon.public PolygonShape(java.awt.Point[] points)
points
- array with polygon pointspublic PolygonShape(java.awt.Point[] points, int start, int len)
points
- array with polygon pointsstart
- the start index in the point arraylen
- the length of the subarrayMethod Detail |
public java.lang.Object clone()
clone
in interface Cloneable
clone
in class java.lang.Object
OutOfMemoryError
- if there is not enough memory.Cloneable
public java.lang.String toString()
toString
in class java.lang.Object
public static final void setLine(int x1, int y1, int x2, int y2, int width, int[] xp, int[] yp, int idx1, int idx2)
(x1,y1)-(x2,y2)
with the line width
width
in the given coordinate arrays.x1,y1
- first segment endpointx2,y2
- second segment endpointwidth
- linewidthxp
- array with the x-coordinatesyp
- array with the y-coordinatesidx1
- start index for lower line partidx2
- start index for upper line partpublic static final void setCurve(int x1, int y1, int x2, int y2, int x3, int y3, int width, int steps, int[] xp, int[] yp, int idx1, int idx2)
step
points, that means it needs 2*step
points to
store that curve. The first part (lower part) will be stored beginning at index
idx1
, the second part (upper part) will be stored beginning at index
idx2
.x1,y1
- first bezier pointx2,y2
- second bezier pointx3,y3
- third bezier pointwidth
- line widthstep
- approximation stepsxp
- array of x-coordinatesyp
- array of y-coordinatesidx1
- start index for lower part of the curveidx2
- start index for upper part of the curvepublic static final void setArrow(boolean right, int x1, int y1, int x2, int y2, int width, int height, int[] xp, int[] yp, int idx)
right
- if true
arrow will point to the rightx1,y1
- source point (if left arrow, this point will be the peek)x2,y2
- target point (if rigth arrow, this point will be the peek)width
- the arrow widthheight
- the arrow heightxp
- array with the x-coordinatesyp
- array with the y-coordinatesidx
- start index, where to store arrowpublic void clear()
public void set(java.awt.Point[] points, int idx, int len)
null
and the specified subarray must be valid.points
- the array with pointsidx
- start index of the subarraylen
- the length of the subarraypublic void set(int[] xpoints, int[] ypoints)
null
and the specified subarray must be valid.xpoints
- the array with x-coordinates of the pointsypoints
- the array with y-coordinates of the pointspublic java.awt.Rectangle getBounds()
this
EllipseShape.getBounds
in interface java.awt.Shape
getBounds
in class java.awt.Polygon
Rectangle
that is the bounding box
of this
EllipseShape.public boolean contains(int x, int y)
Shape
.contains
in interface Shape
contains
in class java.awt.Polygon
x
- x-coordinate of the pointy
- y-coordinate of the pointtrue
if the specified point is
inside the boundary of the Shape
;
false
otherwise.public boolean contains(java.awt.Point p)
Point
is inside the boundary
of the Shape
.contains
in interface Shape
contains
in class java.awt.Polygon
p
- a specified pointtrue
if the specified point is
inside the boundary of the Shape
;
false
otherwise.public boolean intersects(int x, int y, int w, int h)
Shape
intersects the
interior of a specified rectangular area.
The rectangular area is considered to intersect the Shape
if any point is contained in both the interior of the
Shape
and the specified rectangular area.intersects
in interface Shape
x, y
- the coordinates of the specified rectangular areaw
- the width of the specified rectangular areah
- the height of the specified rectangular areatrue
if the interior of the Shape
and
the interior of the rectangular area intersect;
false
otherwise.public boolean contains(int x, int y, int w, int h)
Shape
entirely contains
the specified rectangular area. All coordinates that lie inside
the rectangular area must lie within the Shape
for the
entire rectanglar area to be considered contained within the
Shape
.contains
in interface Shape
x, y
- the coordinates of the specified rectangular areaw
- the width of the specified rectangular areah
- the height of the specified rectangular areatrue
if the interior of the Shape
entirely contains the specified rectangular area;
false
otherwise.intersects(int, int, int, int)
public RectangleShape getBoundShape()
Shape
.getBoundShape
in interface Shape
public int getCenterX()
Shape
.getCenterX
in interface Shape
Shape
public int getCenterY()
Shape
.getCenterY
in interface Shape
Shape
public java.awt.Point getCenter()
Shape
.getCenter
in interface Shape
public void setLocation(int x, int y)
this
Shape to the specified location. The location
of a polygon is the upper left corner of its bounding box.setLocation
in interface Shape
dx
- x coordinate of point to move tody
- y coordinate of point to move topublic void draw(java.awt.Graphics g)
Shape
using the settings of the
Graphics
context (if visible).draw
in interface Shape
g
- Graphics contextpublic void fill(java.awt.Graphics g)
Shape
using the settings of the
Graphics
context (if visible).fill
in interface Shape
g
- Graphics context
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |