edu.neu.ccs.gui
Class PaintMode

java.lang.Object
  |
  +--edu.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.

Since:
2.3

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
abstract  boolean contains(ShapePaintable paintable, double x, double y)
          Tests if a point specified by coordinates is inside the outline of the given shape paintable.
abstract  boolean contains(ShapePaintable paintable, Point2D p)
          Tests if a specified Point2D is inside the outline of the given shape paintable.
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  Rectangle2D getBounds2D(ShapePaintable paintable)
          Returns the 2-dimensional bounds of the paint region that will be changed when the paint 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 paint method is called on the given shape paintable.
abstract  void paint(ShapePaintable paintable, Graphics g)
          Paints the given shape paintable 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

paint

public abstract void paint(ShapePaintable paintable,
                           Graphics g)

Paints the given shape paintable using the given graphics context.

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

getBounds2D

public abstract Rectangle2D getBounds2D(ShapePaintable paintable)

Returns the 2-dimensional bounds of the paint region that will be changed when the paint 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 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 paint 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

contains

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

Tests if a point specified by coordinates is inside the 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

contains

public abstract boolean contains(ShapePaintable paintable,
                                 Point2D p)

Tests if a specified Point2D is inside the 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