|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Paintable describes an object that can paint onto a
graphics context.
As of 2.4.0, the former interface MutatablePaintable has
been merged into Paintable. Furthermore, the interface
MutatablePaintable has been removed from the Java Power
Tools as has the class AbstractMutatablePaintable.
Much programming experience proved that splitting the design into two interfaces and two abstract classes was more hassle than it was worth. Although splittling the design into two classes was conceptually simple, it made programming much more difficult since the necessary facilities were not all available everywhere.
The new Paintable interface also includes methods that
have proven to be useful but which required explicit coding in earlier
versions of JPT. These methods are now available automatically in the
base class AbstractPaintable.
In fact, all but three of the methods specified in this interface have
default definitions in AbstractPaintable. The three abstract
methods in that class are:
public void originalPaint(Graphics g)public XRect getActualBounds2D()public boolean originalContains(double x, double y)Therefore, it is relatively easy to create a Paintable in
a direct manner by extending AbstractPaintable. However, it
is even easier to use the existing JPT Paintable classes to
handle shapes, images, and text directly, and to create composites of
simpler paintables via PaintableSequence.
As of 2.4.0, the interface Paintable extends the interface
SupportsPropertyChange. This makes explicit a relationship
that was true de facto in earlier releases of JPT since the class
AbstractPaintable has always implemented
SupportsPropertyChange.
In 2.6.0, the notion of a background paint was refactored from
Tile into required “set” and “get”
methods in this interface and corresponding implementation in the base
class AbstractPaintable.
Also, in 2.6.0, support was added to use a paintable as a tile for a rectangle. Once this facility was in place, we added the option for one paintable to use another paintable as a background tile that will paint the bounding box of the primary paintable before that paintable itself paints.
The order of painting should now be:
Of course, no painting takes place if the paintable is set to be invisible.
Finally, in 2.6.0, as a convenience, Paintable also extends
the interface of constants JPTConstants.
In 2.6.0c, added the method makeSnapshot.
AbstractPaintable,
SupportsPropertyChange,
JPTConstants| Field Summary | |
static String |
REMOVE_PAINTABLE
Bound property name to remove paintables. |
static String |
SET_CLIPPING_SHAPE
Bound property name for set clipping shape. |
static String |
SET_DEFAULT_BOUNDS2D
Bound property name for set default bounds2D. |
static String |
SET_DEFAULT_CENTER
Bound property name for set default center. |
static String |
SET_DEFAULT_ORIGINAL_BOUNDS2D
Bound property name for set default original bounds2D. |
static String |
SET_DEFAULT_ORIGINAL_CENTER
Bound property name for set default originalcenter. |
static String |
SET_MUTATOR
Bound property name for set mutator. |
static String |
SET_OPACITY
Bound property name for set opacity. |
static String |
SET_PAINTABLE
Bound property name for set paintables. |
static String |
SET_VISIBLE
Bound property name for set visible. |
static String |
SHIFT_PAINTABLE
Bound property name to shift paintables within a sequence. |
| Fields inherited from interface edu.neu.ccs.util.JPTConstants |
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE |
| Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Method Summary | |
void |
addPostMutation(AffineTransform M)
Composes the current mutator on the left with the given transform provided that the given transform is invertible. |
void |
addPostMutation(Mutator.Strategy strategy)
Applies a Mutator.Strategy object to the paintable
by constructing an affine transform using the mutated center
of the paintable
and then calling addPostMutation with this transform as the
argument. |
void |
addPreMutation(AffineTransform M)
Composes the current mutator on the right with the given transform provided that the given transform is invertible and the paintable object supports this operation. |
void |
addPreMutation(Mutator.Strategy strategy)
Applies a Mutator.Strategy object to the paintable
by constructing an affine transform using the original center
of the paintable
and then calling addPreMutation with this transform as the
argument. |
void |
affinetransform(double m00,
double m10,
double m01,
double m11,
double m02,
double m12)
Apply the affine transform given by the matrix coefficients m00, m10, m01, m11, m02, m12 as if the transform were centered at the center of the paintable. |
void |
applyOpacity(Graphics2D h)
Apply the current opacity to calculate and set a net opacity for the given graphics context. |
void |
clearBackgroundPaint()
Clear the background paint. |
void |
clearBackgroundTile()
Clear the background tile. |
void |
clearBothBackgrounds()
Clear the background paint and the background tile. |
boolean |
contains(double x,
double y)
Tests if a point specified by coordinates is inside the paintable. |
boolean |
contains(Point2D p)
Tests if a specified point is inside the paintable. |
XRect |
getActualBounds2D()
Returns the actual bounds of the original paintable or null if the paintable is effectively empty. |
Paint |
getBackgroundPaint()
Returns the background paint. |
Paintable |
getBackgroundTile()
Returns the background tile. |
XRect |
getBounds2D()
Returns a copy of the 2-dimensional bounds of the paintable. |
XPoint2D |
getCenter()
Returns a copy of the center of the paintable. |
XPoint2D |
getCorner()
Returns a copy of the corner of the paintable. |
XRect |
getDefaultBounds2D()
Returns a copy of the default Bounds2D rectangle, that is, the default for computation of getBounds2D. |
XPoint2D |
getDefaultCenter()
Returns a copy of the default center, that is, the default for computation of getCenter. |
XRect |
getDefaultOriginalBounds2D()
Returns a copy of the default original Bounds2D rectangle, that is, the default for computation of getOriginalBounds2D. |
XPoint2D |
getDefaultOriginalCenter()
Returns a copy of the default original center, that is, the default for computation of getOriginalCenter. |
AffineTransform |
getMutator()
Returns a copy of the existing mutator transform. |
AffineTransform |
getMutatorInverse()
Returns a copy of the existing mutator inverse transform. |
float |
getOpacity()
Returns the opacity value of this paintable between 0 and 1. |
XRect |
getOriginalBounds2D()
Returns a copy of the 2-dimensional bounds of the original paintable prior to any mutation. |
XPoint2D |
getOriginalCenter()
Returns a copy of the original center of the paint region. |
Graphics2D |
getPreparedGraphics2D(Graphics g)
Returns a copy of the given graphics context after modifying the copy to clip to within the bounds region, to set anti-aliasing on, and to apply the opacity of this paintable if needed. |
void |
glide(double degrees,
double distance)
Glides (translates) the paintable along a glide line at the given angle in degrees and the given glide distance. |
void |
glidereflect(double degrees,
double distance)
Glide-reflects the paintable along the line through its center at the given angle in degrees and the given glide distance. |
void |
hreflect()
Reflects the paintable along a horizontal axis through its center. |
boolean |
isVisible()
Returns the current visibility property of this paintable. |
void |
lineartransform(double m00,
double m10,
double m01,
double m11)
Apply the linear transform given by the matrix coefficients m00, m10, m01, m11 as if the transform were centered at the center of the paintable. |
BufferedImage |
makeSnapshot()
Constructs a BufferedImage object that is
the same size as the bounding box of this paintable and
then paints this paintable onto the buffered image with a
suitable translation back to the origin. |
void |
move(double dx,
double dy)
Moves the paintable by a translation using the data in the point specified by coordinates. |
void |
move(Point2D p)
Moves the paintable by a translation using the data in the point. |
void |
moveCenterTo(double x,
double y)
Moves the paintable by a translation in such a way that the paintable center specified by getCenter
will move to the given point specified in coordinates. |
void |
moveCenterTo(Point2D p)
Moves the paintable by a translation in such a way that the paintable center specified by getCenter
will move to the given point. |
void |
moveCornerTo(double x,
double y)
Moves the paintable by a translation in such a way that the paintable corner specified by getCorner
will move to the given point specified in coordinates. |
void |
moveCornerTo(Point2D p)
Moves the paintable by a translation in such a way that the paintable corner specified by getCorner
will move to the given point. |
void |
mutate(AffineTransform M)
This method should always be implemented to do exactly the same operation as the corresponding method addPostMutation. |
void |
mutate(Mutator.Strategy strategy)
This method should always be implemented to do exactly the same operation as the corresponding method addPostMutation. |
boolean |
originalContains(double x,
double y)
Tests if a point specified by coordinates is inside the original paintable without mutation. |
boolean |
originalContains(Point2D p)
Tests if a specified point is inside the original paintable without mutation. |
void |
originalPaint(Graphics g)
Paints onto a Graphics context using information
from this object but without the use of the mutator transform. |
void |
paint(Graphics g)
Paints onto a Graphics context using information
from this object. |
void |
paintAsTiles(Graphics g,
double w,
double h)
Repeatedly paints this object as a tile that covers the rectangle (0,0,w,h) in the graphics context
g. |
void |
paintAsTiles(Graphics g,
double x,
double y,
double w,
double h)
Repeatedly paints this object as a tile that covers the rectangle (x,y,w,h) in the graphics context
g. |
void |
paintAsTiles(Graphics g,
Rectangle2D rect)
Repeatedly paints this object as a tile that covers the given rectangle in the graphics context g. |
void |
paintAt(Graphics g,
AffineTransform T,
double x,
double y)
Without changing the paintable or the graphics context, paint the paintable in a translated position specified by the point in coordinates and the affine transform T; before painting the transform T should be applied to the point. |
void |
paintAt(Graphics g,
AffineTransform T,
Point2D p)
Without changing the paintable or the graphics context, paint the paintable in a translated position specified by the point in coordinates and the affine transform T; before painting the transform T should be applied to the point. |
void |
paintAt(Graphics g,
double x,
double y)
Without changing the paintable or the graphics context, paint the paintable in a translated position specified by the point in coordinates. |
void |
paintAt(Graphics g,
Point2D p)
Without changing the paintable or the graphics context, paint the paintable in a translated position specified by the point. |
void |
reflect(double degrees)
Reflects the paintable along the line through its center at the given angle in degrees. |
void |
rotate(double degrees)
Rotates the paintable about its center by the given angle in degrees. |
void |
scale(double s)
Scales the paintable about its center by the given factor s uniformly in all directions. |
void |
scale(double degrees,
double s,
double t)
Scales the paintable about its center by the given factor s along the main axis at the given angle in degrees and the given factor t along the perpendicular axis. |
void |
setBackgroundPaint(Paint background)
Sets the background paint. |
void |
setBackgroundTile(Object object)
Sets the background tile paintable. |
void |
setDefaultBounds2D(Rectangle2D rectangle)
Sets the default Bounds2D rectangle, that is, the default for computation of getBounds2D. |
void |
setDefaultCenter(Point2D center)
Sets the default center, that is, the default for computation of getCenter. |
void |
setDefaultOriginalBounds2D(Rectangle2D rectangle)
Sets the default original Bounds2D rectangle, that is, the default for computation of getOriginalBounds2D. |
void |
setDefaultOriginalCenter(Point2D center)
Sets the default original center, that is, the default for computation of getOriginalCenter. |
void |
setMutator(AffineTransform M)
Sets the mutator transform to the given transform provided that the given transform is invertible and the paintable object supports this operation. |
void |
setMutator(Mutator.Strategy strategy)
Applies a Mutator.Strategy object to the paintable
by constructing an affine transform using the original center
of the paintable
and then calling setMutation with this transform as the
argument. |
void |
setOpacity(float opacity)
Sets the opacity of this paintable to a value between 0 and 1. |
void |
setVisible(boolean visible)
Sets the visibility property of this paintable. |
void |
shear(double degrees,
double s)
Shears the paintable about its center and with shear factor s along the line at the given angle in degrees. |
void |
vreflect()
Reflects the paintable along a vertical axis through its center. |
| Field Detail |
public static final String SET_DEFAULT_BOUNDS2D
public static final String SET_DEFAULT_CENTER
public static final String SET_DEFAULT_ORIGINAL_BOUNDS2D
public static final String SET_DEFAULT_ORIGINAL_CENTER
public static final String SET_VISIBLE
public static final String SET_OPACITY
public static final String SET_MUTATOR
public static final String SET_PAINTABLE
public static final String REMOVE_PAINTABLE
public static final String SHIFT_PAINTABLE
public static final String SET_CLIPPING_SHAPE
| Method Detail |
public void paint(Graphics g)
Paints onto a Graphics context using information
from this object.
A recommended implementation should adopt the following policy:
null
or the paintable is set to be invisible.getBounds2D.originalPaint to
complete the actual paint operations.Whatever the implementation, when this method call is complete, the internal state of g should be unchanged.
g - the graphics context on which to paint
public void paintAt(Graphics g,
double x,
double y)
Without changing the paintable or the graphics context, paint the paintable in a translated position specified by the point in coordinates.
In particular, paintAt(g,0,0) should be equivalent
to paint(g).
Recommendation: The paintAt methods are
intended to be used if a designer wants to define a paintable at
or near the origin of coordinates and then independently compute
or retrieve the position at which the paintable will be painted.
If the paintAt methods are used, it is recommended
that the programmer avoid mutating the paintable directly since
that will almost certainly lead to confusion and bugs. Either
use mutation or use paintAt but not both.
g - the graphics context on which to paintx - the x-translationy - the y-translation
public void paintAt(Graphics g,
Point2D p)
Without changing the paintable or the graphics context, paint the paintable in a translated position specified by the point.
Recommendation: The paintAt methods are
intended to be used if a designer wants to define a paintable at
or near the origin of coordinates and then independently compute
or retrieve the position at which the paintable will be painted.
If the paintAt methods are used, it is recommended
that the programmer avoid mutating the paintable directly since
that will almost certainly lead to confusion and bugs. Either
use mutation or use paintAt but not both.
g - the graphics context on which to paintp - the translation vector
public void paintAt(Graphics g,
AffineTransform T,
double x,
double y)
Without changing the paintable or the graphics context, paint the paintable in a translated position specified by the point in coordinates and the affine transform T; before painting the transform T should be applied to the point.
The application of this facility is to apply a transform to the position of painting that should be applied to the position alone and NOT to the paintable or to the graphics context.
For example, if T is a reflection through a horizontal axis that places the origin (0,0) at the lower left of a panel, then it would probably be a very bad idea to apply the reflection to the graphics context (which turns every object upside down) or to the paintable (which turns the paintable upside down). The transform should be applied to the position alone.
Recommendation: The paintAt methods are
intended to be used if a designer wants to define a paintable at
or near the origin of coordinates and then independently compute
or retrieve the position at which the paintable will be painted.
If the paintAt methods are used, it is recommended
that the programmer avoid mutating the paintable directly since
that will almost certainly lead to confusion and bugs. Either
use mutation or use paintAt but not both.
g - the graphics context on which to paintT - the affine transform to apply to the translation pointx - the original x-translation before transformationy - the original y-translation before transformation
public void paintAt(Graphics g,
AffineTransform T,
Point2D p)
Without changing the paintable or the graphics context, paint the paintable in a translated position specified by the point in coordinates and the affine transform T; before painting the transform T should be applied to the point.
The application of this facility is to apply a transform to the position of painting that should be applied to the position alone and NOT to the paintable or to the graphics context.
For example, if T is a reflection through a horizontal axis that places the origin (0,0) at the lower left of a panel, then it would probably be a very bad idea to apply the reflection to the graphics context (which turns every object upside down) or to the paintable (which turns the paintable upside down). The transform should be applied to the position alone.
Recommendation: The paintAt methods are
intended to be used if a designer wants to define a paintable at
or near the origin of coordinates and then independently compute
or retrieve the position at which the paintable will be painted.
If the paintAt methods are used, it is recommended
that the programmer avoid mutating the paintable directly since
that will almost certainly lead to confusion and bugs. Either
use mutation or use paintAt but not both.
g - the graphics context on which to paintT - the affine transform to apply to the translation pointp - the original translation point before transformation
public void paintAsTiles(Graphics g,
double x,
double y,
double w,
double h)
Repeatedly paints this object as a tile that covers the
rectangle (x,y,w,h) in the graphics context
g. The painting is clipped to this rectangle.
The graphics context is unchanged when this method is done.
This method should work appropriately if the width or height is negative.
The method should do nothing if:
null.
g - the graphics contextx - the x-corner of the rectangle to tiley - the y-corner of the rectangle to tilew - the width of the rectangle to tileh - the height of the rectangle to tile
public void paintAsTiles(Graphics g,
double w,
double h)
Repeatedly paints this object as a tile that covers the
rectangle (0,0,w,h) in the graphics context
g. The painting is clipped to this rectangle.
The graphics context is unchanged when this method is done.
This method should work appropriately if the width or height is negative.
The method should do nothing if:
null.
g - the graphics contextw - the width of the rectangle to tileh - the height of the rectangle to tile
public void paintAsTiles(Graphics g,
Rectangle2D rect)
Repeatedly paints this object as a tile that covers the
given rectangle in the graphics context g.
The painting is clipped to this rectangle.
The graphics context is unchanged when this method is done.
The method should do nothing if:
null.null.
g - the graphics contextrect - the rectangle to tilepublic Graphics2D getPreparedGraphics2D(Graphics g)
Returns a copy of the given graphics context after modifying the copy to clip to within the bounds region, to set anti-aliasing on, and to apply the opacity of this paintable if needed.
For convenience, the graphics context should be returned as a
Graphics2D object.
It is recommended that this method be used in the implementation of
the paint method.
g - the given graphics context to copy
public BufferedImage makeSnapshot()
Constructs a BufferedImage object that is
the same size as the bounding box of this paintable and
then paints this paintable onto the buffered image with a
suitable translation back to the origin.
This method creates a snapshot of the current visual state of this paintable.
The BufferedImage returned will have size at
least 1-by-1 even if this paintable has 0 width or height.
public XRect getBounds2D()
Returns a copy of the 2-dimensional bounds of the paintable.
A recommended implementation should adopt the following policy:
If the value of getDefaultBounds2D is
non-null, then return this value.
Otherwise, return a reasonable estimate of the bounds within computational constraints.
This method must not return null.
public XPoint2D getCenter()
Returns a copy of the center of the paintable.
A recommended implementation should adopt the following policy:
If the value of getDefaultCenter is
non-null, then return this value.
Otherwise, return a computed value of the center.
This method must not return null.
public XPoint2D getCorner()
Returns a copy of the corner of the paintable.
The corner should be the top-left corner of the bounds
rectangle returned by getBounds2D.
public boolean contains(double x,
double y)
Tests if a point specified by coordinates is inside the paintable.
x - the x-coordinate of the pointy - the y-coordinate of the point
public boolean contains(Point2D p)
Tests if a specified point is inside the paintable.
p - a specified point
public void setVisible(boolean visible)
Sets the visibility property of this paintable.
The default for the visibility property should be true
Fires property change: SET_VISIBLE.
visible - the visibility settingpublic boolean isVisible()
public void setOpacity(float opacity)
Sets the opacity of this paintable to a value between 0 and 1.
Note that an opacity of 0 will make the paintable invisible. This
is not recommended. Instead use setVisible(false).
Fires property change: SET_OPACITY.
opacity - the opacity of this paintablepublic float getOpacity()
public void setBackgroundPaint(Paint background)
Sets the background paint.
The paint may be set to null to
eliminate background painting.
background - the background paintpublic Paint getBackgroundPaint()
public void clearBackgroundPaint()
public void setBackgroundTile(Object object)
Sets the background tile paintable. The object passed
should be a paintable or be convertible to a paintable
via the method ComponentFactory.makePaintable.
The object may be set to null to
eliminate background tiling.
object - the background tile objectpublic Paintable getBackgroundTile()
public void clearBackgroundTile()
public void clearBothBackgrounds()
public void setMutator(AffineTransform M)
Sets the mutator transform to the given transform provided that the given transform is invertible and the paintable object supports this operation.
If the given transform is not invertible, the method does nothing.
Fires property change: SET_MUTATOR.
Remarks:
If the paintable object maintains a mutator object that transforms
the paintable, then this method should set that mutator. Moreover,
in this case, the method getMutator should return a copy
of that mutator.
If the paintable object distributes mutation to internal data then
this method may or may not make sense. The documentation of the
implementation should state what, if anything, is done by this method.
In particular, it is valid for the method getMutator to
return an identity transform if no mutator is maintained explicitly.
M - the invertible affine transform to set as the mutatorpublic void addPreMutation(AffineTransform M)
Composes the current mutator on the right with the given transform provided that the given transform is invertible and the paintable object supports this operation.
If the given transform is not invertible, the method does nothing.
Fires property change: SET_MUTATOR.
Remarks:
Normally, the action of the new mutator will be to apply the given transform and then to apply the old mutator.
If the paintable object distributes mutation to internal data then this method may or may not make sense. The documentation of the implementation should state what, if anything, is done by this method.
M - the invertible affine transform to composepublic void addPostMutation(AffineTransform M)
Composes the current mutator on the left with the given transform provided that the given transform is invertible.
If the given transform is not invertible, the method does nothing.
Fires property change: SET_MUTATOR.
Remarks:
Normally, the action of the new mutator will be to apply the old mutator and then to apply the given transform.
This method should always have a meaningful interpretation for a paintable, that is, it should always be possible to apply a mutation that follows earlier mutations. If this method is implemented in a non-standard fashion, the documentation should state what is done.
M - the invertible affine transform to composepublic void setMutator(Mutator.Strategy strategy)
Applies a Mutator.Strategy object to the paintable
by constructing an affine transform using the original center
of the paintable
and then calling setMutation with this transform as the
argument.
Fires property change: SET_MUTATOR.
This method may be implemented in a more sophisticated fashion if that is appropriate for a particular paintable.
strategy - the mutator strategy to applypublic void addPreMutation(Mutator.Strategy strategy)
Applies a Mutator.Strategy object to the paintable
by constructing an affine transform using the original center
of the paintable
and then calling addPreMutation with this transform as the
argument.
Fires property change: SET_MUTATOR.
This method may be implemented in a more sophisticated fashion if that is appropriate for a particular paintable.
strategy - the mutator strategy to applypublic void addPostMutation(Mutator.Strategy strategy)
Applies a Mutator.Strategy object to the paintable
by constructing an affine transform using the mutated center
of the paintable
and then calling addPostMutation with this transform as the
argument.
Fires property change: SET_MUTATOR.
This method may be implemented in a more sophisticated fashion if that is appropriate for a particular paintable.
strategy - the mutator strategy to applypublic AffineTransform getMutator()
Returns a copy of the existing mutator transform.
If the implementation chooses to distribute transforms to sub-objects, then this method may validly always return the identity transform.
public AffineTransform getMutatorInverse()
Returns a copy of the existing mutator inverse transform.
If the implementation chooses to distribute transforms to sub-objects, then this method may validly always return the identity transform.
public void mutate(AffineTransform M)
This method should always be implemented to do exactly the same
operation as the corresponding method addPostMutation.
In other words, this should simply be a convenience method with a
short name.
M - the invertible affine transform to composeaddPostMutation(AffineTransform)public void mutate(Mutator.Strategy strategy)
This method should always be implemented to do exactly the same
operation as the corresponding method addPostMutation.
In other words, this should simply be a convenience method with a
short name.
strategy - the mutator strategy to applyaddPostMutation(Mutator.Strategy)
public void move(double dx,
double dy)
Moves the paintable by a translation using the data in the point specified by coordinates.
dx - the x-coordinate of the translationdy - the y-coordinate of the translationpublic void move(Point2D p)
Moves the paintable by a translation using the data in the point.
p - the translation vector
public void moveCenterTo(double x,
double y)
Moves the paintable by a translation in such a way that the
paintable center specified by getCenter
will move to the given point specified in coordinates.
x - the x-coordinate of the desired centery - the y-coordinate of the desired centerpublic void moveCenterTo(Point2D p)
Moves the paintable by a translation in such a way that the
paintable center specified by getCenter
will move to the given point.
p - the desired center
public void moveCornerTo(double x,
double y)
Moves the paintable by a translation in such a way that the
paintable corner specified by getCorner
will move to the given point specified in coordinates.
x - the x-coordinate of the desired cornery - the y-coordinate of the desired cornerpublic void moveCornerTo(Point2D p)
Moves the paintable by a translation in such a way that the
paintable corner specified by getCorner
will move to the given point.
p - the desired cornerpublic void rotate(double degrees)
Rotates the paintable about its center by the given angle in degrees.
degrees - the rotation angle in degreespublic void reflect(double degrees)
degrees - the angle in degrees of the line of reflectionpublic void hreflect()
public void vreflect()
public void scale(double s)
Scales the paintable about its center by the given factor s uniformly in all directions.
s - the scale in all directions
public void scale(double degrees,
double s,
double t)
Scales the paintable about its center by the given factor s along the main axis at the given angle in degrees and the given factor t along the perpendicular axis.
degrees - the angle in degrees of the main scaling axiss - the scale factor along the axis at angle degreest - the scale factor along the axis at angle degrees+90
public void shear(double degrees,
double s)
Shears the paintable about its center and with shear factor s along the line at the given angle in degrees.
In the special case when the center is at (0,0) and the angle in degrees is 0, this corresponds to the transform: (u,v) maps to (u+s*v,v), which fixes the x-axis and shears parallel to that axis.
In the general case, the fixed axis for the shear is the line at the given angle degrees through the center.
degrees - the angle in degrees of the fixed axis for shears - determines the amount of shear along lines parallel to
the fixed axis for shear
public void glide(double degrees,
double distance)
Glides (translates) the paintable along a glide line at the given angle in degrees and the given glide distance.
Equivalent to specifing a translation via polar coordinates with the angle in degrees specified first and the distance specified second. The reason for specifying degrees first here is to be consistent with the usage of all other methods that have degrees as a parameter.
degrees - the angle in degrees of the line of glidedistance - the translation distance along the line of glide
public void glidereflect(double degrees,
double distance)
degrees - the angle in degrees of the line of glide reflectiondistance - the translation distance along the line of glide reflection
public void lineartransform(double m00,
double m10,
double m01,
double m11)
Apply the linear transform given by the matrix coefficients m00, m10, m01, m11 as if the transform were centered at the center of the paintable. In other words, before applying the given transform, adjust it so that the center of the paintable remains fixed.
Note that the two coefficients of column 0 are given first and the two coefficients of column 1 are given next.
m00 - the matrix coefficient in row 0 column 0m10 - the matrix coefficient in row 1 column 0m01 - the matrix coefficient in row 0 column 1m11 - the matrix coefficient in row 1 column 1
public void affinetransform(double m00,
double m10,
double m01,
double m11,
double m02,
double m12)
Apply the affine transform given by the matrix coefficients m00, m10, m01, m11, m02, m12 as if the transform were centered at the center of the paintable.
Note that the two coefficients of column 0 are given first, the two coefficients of column 1 are given next, and the two coefficients of column 2 are given last.
m00 - the matrix coefficient in row 0 column 0m10 - the matrix coefficient in row 1 column 0m01 - the matrix coefficient in row 0 column 1m11 - the matrix coefficient in row 1 column 1m02 - the matrix coefficient in row 0 column 2m12 - the matrix coefficient in row 1 column 2public void originalPaint(Graphics g)
Paints onto a Graphics context using information
from this object but without the use of the mutator transform.
This method should be the foundation for the paint
methods that use the mutator.
The designer of this method should assume that issues such as
visibility, opacity, clipping, antialiasing, and mutation will
be taken care of by the paint methods. Therefore,
this method need only paint what must be painted with no
adjustments.
Whatever the implementation, when this method call is complete, the internal state of g should be unchanged.
g - the graphics context on which to paintpublic XRect getOriginalBounds2D()
Returns a copy of the 2-dimensional bounds of the original paintable prior to any mutation.
A recommended implementation should adopt the following policy:
If the value of getDefaultOriginalBounds2D
is non-null, then return this value.
If the value of getActualBounds2D
is non-null, then return this value.
Otherwise, return new XRect().
This method must not return null.
public XRect getActualBounds2D()
Returns the actual bounds of the original paintable or
null if the paintable is effectively empty.
public XPoint2D getOriginalCenter()
Returns a copy of the original center of the paint region.
A recommended implementation should adopt the following policy:
If the value of getDefaultOriginalCenter
is non-null, then return this value.
Otherwise, return a computed value of the center.
This method must not return null.
public boolean originalContains(double x,
double y)
Tests if a point specified by coordinates is inside the original paintable without mutation.
x - the x-coordinate of the pointy - the y-coordinate of the point
public boolean originalContains(Point2D p)
Tests if a specified point is inside the original paintable without mutation.
p - a specified Point2D
public void applyOpacity(Graphics2D h)
Apply the current opacity to calculate and set a net opacity for the given graphics context.
The following conditions must hold:
Composite set
or has a Composite of type AlphaComposite
whose rule is SRC_OVER.
In the case that the graphics context has a Composite set
of type AlphaComposite with rule SRC_OVER, then
the net opacity is the product of the current opacity of this object and
the alpha value of the context's AlphaComposite.
Otherwise the net opacity equals the current opacity of this object.
It is recommended that this method be used in the implementation of
the getPreparedGraphics2D method.
h - the graphics context whose opacity will be changedpublic void setDefaultBounds2D(Rectangle2D rectangle)
Sets the default Bounds2D rectangle, that is,
the default for computation of getBounds2D.
It is valid to set the default Bounds2D rectangle to
null to force a computation of the bounds.
Setting the default Bounds2D rectangle to a rectangle
with zero width or height should be equivalent to
setting it to null.
Fires property change: SET_DEFAULT_BOUNDS2D.
rectangle - the default Bounds2D rectanglepublic XRect getDefaultBounds2D()
Returns a copy of the default Bounds2D rectangle, that is,
the default for computation of getBounds2D.
Returns null to signal no setting.
public void setDefaultCenter(Point2D center)
Sets the default center, that is,
the default for computation of getCenter.
It is valid to set the default center to
null to force a computation of the center.
Fires property change: SET_DEFAULT_CENTER.
center - the default centerpublic XPoint2D getDefaultCenter()
Returns a copy of the default center, that is,
the default for computation of getCenter.
Returns null to signal no setting.
public void setDefaultOriginalBounds2D(Rectangle2D rectangle)
Sets the default original Bounds2D rectangle, that is,
the default for computation of getOriginalBounds2D.
It is valid to set the default original Bounds2D rectangle
to null to force a computation of the bounds.
Setting the default original Bounds2D rectangle to a rectangle
with zero width or height should be equivalent to setting it
to null.
Fires property change: SET_DEFAULT_ORIGINAL_BOUNDS2D.
rectangle - the default original Bounds2D rectanglepublic XRect getDefaultOriginalBounds2D()
Returns a copy of the default original Bounds2D rectangle, that is,
the default for computation of getOriginalBounds2D.
Returns null to signal no setting.
public void setDefaultOriginalCenter(Point2D center)
Sets the default original center, that is,
the default for computation of getOriginalCenter.
It is valid to set the default original center to
null to force a computation of the center.
Fires property change: SET_DEFAULT_ORIGINAL_CENTER.
center - the default original centerpublic XPoint2D getDefaultOriginalCenter()
Returns a copy of the default original center, that is,
the default for computation of getOriginalCenter.
Returns null to signal no setting.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||