T
- the doodle typepublic abstract class DoodleDecorator<T extends Doodle> extends ChildDoodle implements ParentDoodle
Details:
A DoodleDecorator
wraps a Doodle
and forwards calls and return values between the sender and the receiver.
By itself, this class is worthless.
It is intended to be subclassed so that individual methods can be overridden with decorating behavior.
All calls except Doodle.setParent(ParentDoodle)
are forwarded.
(Forwarding Doodle.setParent(ParentDoodle)
would result in unintentional communication between the "decoratee" and this decorator's parent, bypassing this decorator.)
When this decorator is constructed, it sets itself as the decoratee's parent.
Only Doodle
methods are forwarded in this decorator.
Object methods, such as Object.equals(Object)
, Object.hashCode()
, etc. are the subclass' responsibility.
Modifier and Type | Field and Description |
---|---|
protected T |
mDoodle |
mParent
Constructor and Description |
---|
DoodleDecorator(T iDoodle) |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(AffineTransform iTransform,
Point2D iPoint)
Tests point for contact with doodle.
|
boolean |
draw(FigGraphics iG)
Renders doodle.
|
Rectangle2D |
getBounds(AffineTransform iTransform,
Rectangle2D oBounds)
Returns rectangular extent.
|
T |
getDoodle() |
float |
getZOrder()
Determines rendering priority for overlapping shapes.
|
boolean |
hasDescendant(Doodle iDoodle) |
void |
sendDoodleChanged(Doodle iShape)
Advises container to react to changes in contained doodle.
|
getDefaultOrigin, getParent, redraw, setParent
public DoodleDecorator(T iDoodle)
public T getDoodle()
public boolean contains(AffineTransform iTransform, Point2D iPoint)
Doodle
Details:
Doodle.contains(AffineTransform, Point2D)
returns true
if the given point lies on this doodle, false
otherwise.
A provided AffineTransform
reveals the characteristics of the view where containment is being tested.
This is useful only for Doodle
s that alter their logical form in order to accommodate the view.
Most implementations will simply ignore this transform, and in some cases, this transform may be null
, indicating that the transform is not to be considered.
In any case, the point being tested is already in figure coordinates.
public boolean draw(FigGraphics iG)
Doodle
Details:
Doodle.draw(FigGraphics)
renders this doodle using the supplied graphics environment.
When the host FigureView
is repainting itself, it will probably call this method, albeit indirectly, to redraw its figure's components.
This method returns true
if drawing was successful, false
otherwise.
public Rectangle2D getBounds(AffineTransform iTransform, Rectangle2D oBounds)
Doodle
Details:
This method returns the rectangular extent of this Doodle
.
The rectangle returned is in logical (i.e. figure) units, not display units.
A provided AffineTransform
reveals the characteristics of the viewing context in which the bounds will be considered.
This information is meaningful only in Doodle
s that alter their logical form to accommodate the view, such as ViewDoodle
.
Most implementations will simply ignore this transform, and in some cases, this transform may be null
, indicating that the transform is a "don't-
Optionally, the caller may pass in a pre-null
, a new rectangle will be instantiated, initialized with the result, and returned.
In either case, the rectangle containing the result is returned.
public float getZOrder()
Doodle
Details:
When two doodles in a figure overlap, one doodle must be displayed above the other.
Doodle.getZOrder()
is called to determine which doodle is "higher."
Greater values win.
public void sendDoodleChanged(Doodle iShape)
ParentDoodle
Details:
ParentDoodle.sendDoodleChanged(Doodle)
notifies this container that a doodle contained by this container has changed.
This message propagates up the containment hierarchy, and generally causes all of the views to refresh themselves.
sendDoodleChanged
in interface ParentDoodle
iShape
- doodle that changedpublic boolean hasDescendant(Doodle iDoodle)
hasDescendant
in interface ParentDoodle
Copyright © 2013. All Rights Reserved.