edu.neu.ccs.gui
Class PaintMode

java.lang.Object
  extended byedu.neu.ccs.gui.PaintMode

public abstract class PaintMode
extends Object

Abstract class PaintMode defines the requirements for an object that can control the painting of a ShapePaintable.

Class PaintMode provides some examples of its own objects.

Class PaintMode also provides some static convenience methods.

In 2.3.5, the class was refactored to be consistent with the new Paintable interface and the new AbstractPaintable class.

In 2.4.0, this class was updated to be consistent with refinements to the Paintable interface.

Since:
2.3
Version:
2.4.0

Field Summary
static PaintMode DRAW
          The paint mode corresponding to drawing the shape of the shape paintable using its draw paint and draw stroke.
static PaintMode FILL
          The paint mode corresponding to filling the shape of the shape paintable using its fill paint.
static PaintMode FILL_DRAW
          The paint mode corresponding to filling the shape of the shape paintable using its fill paint and then drawing the shape using its draw paint and draw stroke.
 
Constructor Summary
PaintMode()
           
 
Method Summary
static void draw(Graphics g, Shape shape, Paint drawpaint)
          Draws the given shape using the given drawpaint in the given graphics context.
static void draw(Graphics g, Shape shape, Paint drawpaint, Stroke drawstroke)
          Draws the given shape using the given drawpaint and the given drawstroke in the given graphics context.
static void fill(Graphics g, Shape shape, Paint fillpaint)
          Fills the given shape using the given fillpaint in the given graphics context.
static void filldraw(Graphics g, Shape shape, Paint fillpaint, Paint drawpaint)
          Fills and draws the given shape using the given fillpaint and the given drawpaint in the given graphics context.
static void filldraw(Graphics g, Shape shape, Paint fillpaint, Paint drawpaint, Stroke drawstroke)
          Fills and draws the given shape using the given fillpaint, the given drawpaint, and the given drawstroke in the given graphics context.
abstract  XRect getActualBounds2D(ShapePaintable paintable)
          Returns the original 2-dimensional bounds of the paint region that will be changed when the originalPaint method is called on the given shape paintable.
abstract  Shape getOutline(ShapePaintable paintable)
          Returns the Shape representing the paint region that will be changed when the originalPaint method is called on the given shape paintable.
abstract  boolean originalContains(ShapePaintable paintable, double x, double y)
          Tests if a point specified by coordinates is inside the orignal outline of the given shape paintable.
 boolean originalContains(ShapePaintable paintable, Point2D p)
          Tests if a point specified by coordinates is inside the orignal outline of the given shape paintable.
abstract  void originalPaint(ShapePaintable paintable, Graphics g)
          Paints the given shape paintable without mutation using the given graphics context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILL

public static final PaintMode FILL
The paint mode corresponding to filling the shape of the shape paintable using its fill paint.


DRAW

public static final PaintMode DRAW
The paint mode corresponding to drawing the shape of the shape paintable using its draw paint and draw stroke.


FILL_DRAW

public static final PaintMode FILL_DRAW
The paint mode corresponding to filling the shape of the shape paintable using its fill paint and then drawing the shape using its draw paint and draw stroke.

Constructor Detail

PaintMode

public PaintMode()
Method Detail

originalPaint

public abstract void originalPaint(ShapePaintable paintable,
                                   Graphics g)

Paints the given shape paintable without mutation using the given graphics context.

It is assumed that the graphics context has been prepared and mutation has been applied by the caller of this method.

If the given shape paintable or given graphics context is null, then this method should do nothing.

When this method call is complete, the internal state of the given graphics context should be unchanged.

Parameters:
paintable - the shape paintable
g - the graphics context on which to paint

getActualBounds2D

public abstract XRect getActualBounds2D(ShapePaintable paintable)

Returns the original 2-dimensional bounds of the paint region that will be changed when the originalPaint method is called on the given shape paintable.

If the given shape paintable is null or if the bounds may not otherwise be computed then this method should return new Rectangle2D.Double().

This method should not return null.

Parameters:
paintable - the shape paintable
Returns:
the orignal bounds of the paint region that will be changed

getOutline

public abstract Shape getOutline(ShapePaintable paintable)

Returns the Shape representing the paint region that will be changed when the originalPaint method is called on the given shape paintable.

If the given shape paintable is null, then this method should return null.

Parameters:
paintable - the shape paintable
Returns:
the shape of the paint region that will be changed

originalContains

public abstract boolean originalContains(ShapePaintable paintable,
                                         double x,
                                         double y)

Tests if a point specified by coordinates is inside the orignal outline of the given shape paintable.

If the given shape paintable is null, then this method should return false.

Parameters:
paintable - the shape paintable
x - the x-coordinate of the point
y - the y-coordinate of the point
Returns:
whether or not a specified point is inside the paintable

originalContains

public final boolean originalContains(ShapePaintable paintable,
                                      Point2D p)

Tests if a point specified by coordinates is inside the orignal outline of the given shape paintable.

If the given shape paintable is null, then this method should return false.

Parameters:
paintable - the shape paintable
p - a specified point
Returns:
whether or not a specified point is inside the paintable

fill

public static void fill(Graphics g,
                        Shape shape,
                        Paint fillpaint)

Fills the given shape using the given fillpaint in the given graphics context.

Parameters:
g - the graphics context
shape - the shape to paint
fillpaint - the paint to use for fill
See Also:
FILL

draw

public static void draw(Graphics g,
                        Shape shape,
                        Paint drawpaint)

Draws the given shape using the given drawpaint in the given graphics context.

Parameters:
g - the graphics context
shape - the shape to paint
drawpaint - the paint to use for draw
See Also:
DRAW

draw

public static void draw(Graphics g,
                        Shape shape,
                        Paint drawpaint,
                        Stroke drawstroke)

Draws the given shape using the given drawpaint and the given drawstroke in the given graphics context.

Parameters:
g - the graphics context
shape - the shape to paint
drawpaint - the paint to use for draw
drawstroke - the stroke to use for draw
See Also:
DRAW

filldraw

public static void filldraw(Graphics g,
                            Shape shape,
                            Paint fillpaint,
                            Paint drawpaint)

Fills and draws the given shape using the given fillpaint and the given drawpaint in the given graphics context.

Parameters:
g - the graphics context
shape - the shape to paint
fillpaint - the paint to use for fill
drawpaint - the paint to use for draw
See Also:
FILL_DRAW

filldraw

public static void filldraw(Graphics g,
                            Shape shape,
                            Paint fillpaint,
                            Paint drawpaint,
                            Stroke drawstroke)

Fills and draws the given shape using the given fillpaint, the given drawpaint, and the given drawstroke in the given graphics context.

Parameters:
g - the graphics context
shape - the shape to paint
fillpaint - the paint to use for fill
drawpaint - the paint to use for draw
drawstroke - the stroke to use for draw
See Also:
FILL_DRAW