|
||||||||||
| 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.
| Method Summary | |
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. |
Rectangle2D |
getBounds2D()
Returns a copy of the 2-dimensional bounds of the paint region affected by the paint method. |
Point2D |
getCenter()
Returns a copy of the center of the paint region affected by the paint method. |
float |
getOpacity()
Returns the opacity value of this paintable between 0 and 1. |
Graphics2D |
getPreparedGraphics2D(Graphics g)
Returns a copy of the given graphics context after modifying the copy to set anti-aliasing on, to clip to within the bounds region, and to apply the opacity of the paintable if needed. |
boolean |
isVisible()
Returns the current visibility property of this paintable. |
void |
paint(Graphics g)
Paints onto a Graphics context g using information
from this object provided that the visibility property of the
object is set to true. |
void |
setOpacity(float opacity)
Sets the opacity value of this paintable between 0 and 1. |
void |
setVisible(boolean visible)
Sets the visibility property of this paintable. |
| Method Detail |
public void paint(Graphics g)
Paints onto a Graphics context g using information
from this object provided that the visibility property of the
object is set to true.
After this method call is complete, the internal state of g
should be unchanged. In addition, this method should not paint
outside of the region returned by getBounds2D.
Implementation recommendation:
To achieve the above goals, it is recommended that the graphics
context g be copied to a new graphics context h and that the clip
region of h be intersected with the Bounds2D rectangle. This may
be done directly or may be achieved in one step by using the
method getPreparedGraphics2D which also takes care of
other issues.
g - the graphics context on which to paintpublic Rectangle2D getBounds2D()
paint method.
public Point2D getCenter()
Returns a copy of the center of the paint region affected
by the paint method.
By default, this method may be implemented to return the center of the rectangle returned by getBounds2D(). However, a different result is permitted if the object geometry so dictates.
public boolean contains(double x,
double y)
Tests if a point specified by coordinates is inside the paintable.
This method must return false if one or more of the
following conditions occurs:
getBounds2D.isVisible returns false.
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.
This method must return false if one or more of the
following conditions occurs:
null.getBounds2D.isVisible returns false.
p - a specified Point2D
public void setVisible(boolean visible)
Sets the visibility property of this paintable.
The default for the visibility property should be true
visible - the visibility settingisVisible()public boolean isVisible()
setVisible(boolean)public void setOpacity(float opacity)
opacity - the opacity value of this paintable between 0 and 1getOpacity()public float getOpacity()
setOpacity(float)public Graphics2D getPreparedGraphics2D(Graphics g)
Returns a copy of the given graphics context after modifying the copy to set anti-aliasing on, to clip to within the bounds region, and to apply the opacity of the paintable if needed.
For convenience, return the graphics context as a
Graphics2D object.
g - the given graphics context to copy
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||