|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gishur.gui2.ShapeContainer
The ShapeContainer
class defines a shape which consists of
a set of other
. Because Shape
s
should be static, Shape
sShapeContainer
caches the bounding box once
calculated. The calculation will be automatically updated, if new
are added to the Shape
sShapeContainer
.
The ShapeContainer
class contains also some static methods to
extract parts of element names or tokenize element names
(see #removeContainerName
, #getLocalName
,
#getContainerName
, #getParentName
, #tokenizeName
).
Inner Class Summary | |
class |
ShapeContainer.ShapeEnumeration
An Enumeration for ShapeContainers. |
Constructor Summary | |
ShapeContainer(int length)
Constructs a new ShapeContainer, which can store length
Shape s. |
Method Summary | |
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. |
boolean |
empty()
Returns true , if the container contains no Shape . |
ShapeContainer.ShapeEnumeration |
enumeration()
Returns a new ShapeContainer.ShapeEnumeration object which enumerates all
Shape s contained in the shape hierachy of this
ShapeContainer. |
void |
fill(java.awt.Graphics g)
Fills the interior of the Shape using the settings of the
Graphics context. |
java.awt.Rectangle |
getBounds()
Returns the bounding box of this ShapeContainer. |
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 |
invalidateBounds()
Invalidates the bounds of the ShapeContainer . |
boolean |
isEmpty()
Determines whether or not the bounding box of this
ShapeContainer is empty. |
int |
length()
Returns the capacity of this container. |
void |
setLocation(int x,
int y)
Moves the this Shape to the specified location. |
void |
setShape(int idx,
Shape shape)
Stores the Shape shape at the index
idx in the ShapeContainer . |
Shape |
shape(int idx)
Returns the stored Shape at the specified index. |
java.lang.String |
toString()
Returns a string representation of the object. |
void |
translate(int dx,
int dy)
Translates this Shape by the vector (x,y) . |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.awt.Shape |
contains, contains, contains, contains, getBounds2D, getPathIterator, getPathIterator, intersects, intersects |
Constructor Detail |
public ShapeContainer(int length)
length
Shape
s.name
- the name of the shape (must not be null).length
- capacity of the ShapeContainerMethod Detail |
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.Object clone()
clone
in interface Cloneable
clone
in class java.lang.Object
OutOfMemoryError
- if there is not enough memory.Cloneable
public int length()
public boolean empty()
true
, if the container contains no Shape
.true
, if empty.public void setShape(int idx, Shape shape)
Shape
shape
at the index
idx
in the ShapeContainer
.idx
- store indexid
- Shape
IDshape
- the Shape
to storejava.lang.IndexOutOfBoundsException
- if index was out of boundspublic Shape shape(int idx)
Shape
at the specified index.idx
- the indexShape
at the index idx
.java.lang.IndexOutOfBoundsException
- if index was out of boundspublic void invalidateBounds()
ShapeContainer
.public ShapeContainer.ShapeEnumeration enumeration()
ShapeContainer.ShapeEnumeration
object which enumerates all
Shape
s contained in the shape hierachy of this
ShapeContainer.ShapeContainer.ShapeEnumeration
that enumerates all Shape
s in the
shape hierachypublic boolean isEmpty()
this
ShapeContainer is empty.true
if the bounding rectangle of
this
ShapeContainer is empty; false
otherwise.public boolean contains(int x, int y)
Shape
.contains
in interface Shape
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
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 java.awt.Rectangle getBounds()
this
ShapeContainer.getBounds
in interface java.awt.Shape
Rectangle
that is the bounding box
of this
ShapeContainer.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 translate(int dx, int dy)
this
Shape
by the vector (x,y)
.translate
in interface Shape
dx
- x coordinate of the translation vectordy
- y coordinate of the translation vectorpublic 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.draw
in interface Shape
g
- Graphics contextpublic void fill(java.awt.Graphics g)
Shape
using the settings of the
Graphics
context.fill
in interface Shape
g
- Graphics context
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |