Java Reference
In-Depth Information
Figure 7-26.
Press the mouse pointer over the round rectangle to begin dragging this
shape.
Constructive Area Geometry
Constructive Area Geometry (CAG)
is the creation of a new shape by performing a
Booleanoperationontwoexistingshapes.TheoperationsareBooleanOR(createanew
shapethatcombinestheexistingshapes'pixels),BooleanNOT(createanewshapethat
containsonlythepixelsinoneshapethatarenotalsointheothershape),BooleanAND
(create a new shape that contains only overlapping pixels), and Boolean XOR (create
a new shape that contains only nonoverlapping pixels). Boolean OR is also known as
union,BooleanNOTisalsoknownassubtraction,andBooleanANDisalsoknownas
intersection.
Java2Dprovidesthe
java.awt.geom.Area
classforperformingBooleanoper-
ations via its
void add(Area rhs)
[union],
void subtract(Area rhs)
,
void intersect(Area rhs)
,and
void exclusiveOr(Area rhs)
meth-
ods.EachmethodperformsthespecifiedBooleanoperationonthecurrent
Area
object
and its
Area
object argument, and stores the result in the current
Area
object.