public class TransformedDoodle<DoodleType extends Doodle> extends DoodleDecorator<DoodleType> implements LocationDoodle
Details:
TransformedDoodle
allows you to place a Doodle
at any location and draw it at any scale or rotation.
Four properties govern the transformation of the original Doodle
:
Rotation is the amount that the original Doodle
is rotated.
ScaleX and ScaleY are the amounts that the original Doodle
is scaled in the X and Y direction, respectively.
Origin
is the point in the original Doodle
about which the Doodle
is scaled and rotated, and it is also the point in the original Doodle
that appears at the TransformedDoodle
's location.
In other words, when the transformed Doodle
's Location is set to a new value, it is the original Doodle
's origin that is translated to this point.
Modifier and Type | Field and Description |
---|---|
protected Point2D |
mLocation |
protected Point2D |
mOrigin |
protected double |
mRotationRadians |
protected double |
mScaleX |
protected double |
mScaleY |
mDoodle
mParent
Constructor and Description |
---|
TransformedDoodle(DoodleType iDoodle) |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(AffineTransform iTransform,
Point2D iPoint)
Tests point for contact with doodle.
|
static <DoodleType extends Doodle> |
createCentered(DoodleType iDoodle)
Centers origin in new instance.
|
boolean |
draw(FigGraphics iG)
Renders doodle.
|
Rectangle2D |
getBounds(AffineTransform iTransform,
Rectangle2D oBounds)
Returns rectangular extent.
|
Point2D |
getLocation() |
Point2D |
getOrigin() |
double |
getRotationDegrees() |
double |
getRotationRadians() |
double |
getScaleX() |
double |
getScaleY() |
protected AffineTransform |
getTransform() |
void |
setLocation(Point2D iLocation) |
void |
setOrigin(Point2D iOrigin) |
void |
setRotationDegrees(double iRotationDegrees) |
void |
setRotationRadians(double iRotationRadians) |
void |
setScale(double iScale) |
void |
setScaleX(double iScaleX) |
void |
setScaleY(double iScaleY) |
getDoodle, getZOrder, hasDescendant, sendDoodleChanged
getDefaultOrigin, getParent, redraw, setParent
protected Point2D mOrigin
protected Point2D mLocation
protected double mRotationRadians
protected double mScaleX
protected double mScaleY
public TransformedDoodle(DoodleType iDoodle)
public Point2D getOrigin()
getOrigin
in interface LocationDoodle
public void setOrigin(Point2D iOrigin)
setOrigin
in interface LocationDoodle
public Point2D getLocation()
getLocation
in interface LocationDoodle
public void setLocation(Point2D iLocation)
setLocation
in interface LocationDoodle
public double getRotationRadians()
public void setRotationRadians(double iRotationRadians)
public double getRotationDegrees()
public void setRotationDegrees(double iRotationDegrees)
public double getScaleX()
public void setScaleX(double iScaleX)
public double getScaleY()
public void setScaleY(double iScaleY)
public void setScale(double iScale)
protected AffineTransform getTransform()
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.
draw
in interface Doodle
draw
in class DoodleDecorator<DoodleType extends Doodle>
iG
- the graphics contextpublic 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.
getBounds
in interface Doodle
getBounds
in class DoodleDecorator<DoodleType extends Doodle>
iTransform
- the current viewing transformoBounds
- destination for resultpublic static <DoodleType extends Doodle> TransformedDoodle<DoodleType> createCentered(DoodleType iDoodle)
Details:
createCentered
instantiates a new TransformedDoodle
with the origin set to the original Doodle
's center.
iDoodle
- the Doodle to decoratepublic 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.
contains
in interface Doodle
contains
in class DoodleDecorator<DoodleType extends Doodle>
iTransform
- current viewing transformiPoint
- point to testCopyright © 2013. All Rights Reserved.