|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--edu.neu.ccs.gui.AbstractPaintable
|
+--edu.neu.ccs.gui.ClippingWrapper
The class ClippingWrapper will wrap a Paintable
and a clipping Shape to obtain a Paintable that
clips the original Paintable to the Shape.
In 2.3.2, the method getBounds2D was modified to use the
default Bounds2D rectangle if that rectangle is non-null
before making any other tests or computations.
| Field Summary | |
static String |
SET_CLIPPING_SHAPE
Bound property name for set paintable. |
static String |
SET_PAINTABLE
Bound property name for set paintable. |
| Fields inherited from class edu.neu.ccs.gui.AbstractPaintable |
SET_DEFAULT_BOUNDS2D, SET_DEFAULT_CENTER, SET_OPACITY, SET_VISIBLE |
| Constructor Summary | |
ClippingWrapper()
The constructor that leaves the paintable and clipping shape as null. |
|
ClippingWrapper(Paintable paintable)
The constructor to specify the paintable to be wrapped. |
|
ClippingWrapper(Paintable paintable,
Shape clippingshape)
The constructor to specify the paintable to be wrapped and the clipping shape. |
|
| Method Summary | |
boolean |
contains(double x,
double y)
Tests if a point specified by coordinates is inside the this object. |
Rectangle2D |
getBounds2D()
Returns the bounds of the paintable based on the default settings or on more detailed computations. |
Point2D |
getCenter()
If the wrapped paintable is null, this method returns
new Point2D.Double(). |
Shape |
getClippingShape()
Returns the clipping shape. |
Paintable |
getPaintable()
Returns the wrapped paintable. |
void |
paint(Graphics g)
Paints onto a Graphics context by clipping the
painting of the wrapped paintable to the clipping shape. |
void |
setClippingShape(Shape clippingshape)
Sets the clipping shape. |
void |
setPaintable(Paintable paintable)
Sets the paintable to be wrapped. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String SET_PAINTABLE
public static final String SET_CLIPPING_SHAPE
| Constructor Detail |
public ClippingWrapper()
null.
ClippingWrapper(Paintable),
ClippingWrapper(Paintable, Shape)public ClippingWrapper(Paintable paintable)
paintable - the paintable to be wrappedClippingWrapper(),
ClippingWrapper(Paintable, Shape)
public ClippingWrapper(Paintable paintable,
Shape clippingshape)
paintable - the paintable to be wrappedclippingshape - the clipping shapeClippingWrapper(),
ClippingWrapper(Paintable)| Method Detail |
public final void paint(Graphics g)
Paints onto a Graphics context by clipping the
painting of the wrapped paintable to the clipping shape.
If the wrapped paintable is null, this method will
not paint.
If the clipping shape is null, no clipping will be
done.
paint in interface Paintablepaint in class AbstractPaintableg - the graphics context on which to paintAbstractPaintable.getPreparedGraphics2D(Graphics)public final void setPaintable(Paintable paintable)
Sets the paintable to be wrapped.
The paintable may be set to null to eliminate the
paintable. This object will then paint nothing.
Fires property change: SET_PAINTABLE.
paintable - the paintable to be wrappedgetPaintable()public final Paintable getPaintable()
setPaintable(Paintable)public final void setClippingShape(Shape clippingshape)
Sets the clipping shape.
The clipping shape may be set to null to eliminate
special clipping of the wrapped paintable.
Fires property change: SET_CLIPPING_SHAPE.
clippingshape - the clipping shapegetClippingShape()public final Shape getClippingShape()
setClippingShape(Shape)public final Rectangle2D getBounds2D()
Returns the bounds of the paintable based on the default settings or on more detailed computations.
If the value of getDefaultBounds2D is non-null,
then this value is returned.
Otherwise, if the wrapped paintable is null, this method
returns new Rectangle2D.Double().
Otherwise, the bounds of the wrapped paintable are used before clipping.
If the clipping shape is non-null, then the paintable bounds are
clipped to the bounds of the clipping shape. The resulting bounds are then
returned.
getBounds2D in interface PaintablegetBounds2D in class AbstractPaintableAbstractPaintable.setDefaultBounds2D(Rectangle2D),
AbstractPaintable.getDefaultBounds2D()public final Point2D getCenter()
If the wrapped paintable is null, this method returns
new Point2D.Double().
If the value of getDefaultCenter is non-null,
then this value is returned.
Otherwise, this method returns the center of the wrapped paintable.
getCenter in interface PaintablegetCenter in class AbstractPaintableAbstractPaintable.setDefaultCenter(Point2D),
AbstractPaintable.getDefaultCenter()
public final boolean contains(double x,
double y)
Tests if a point specified by coordinates is inside the this object.
This method returns false if one or more of the following
conditions occurs:
null.getBounds2D.isVisible returns false.
x - the x-coordinate of the pointy - the y-coordinate of the point
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||