javalib.worldimages
Class RectangleImage

java.lang.Object
  extended by javalib.worldimages.AImage
      extended by javalib.worldimages.ColoredImage
          extended by javalib.worldimages.RectangularImage
              extended by javalib.worldimages.RectangleImage
All Implemented Interfaces:
Drawable, WorldImage, tester.ISame<WorldImage>

 class RectangleImage
extends RectangularImage

A filled or outlined rectangle

Version:
Dec. 5, 2012
Author:
Stephen Bloch

Field Summary
 
Fields inherited from class javalib.worldimages.ColoredImage
defaultColor
 
Fields inherited from interface javalib.worldimages.WorldImage
LOOKS_SAME
 
Constructor Summary
protected RectangleImage(int width, int height, Color color, Mode mode)
          The full constructor for a RectangleImage.
 
Method Summary
 void draw(Graphics2D g)
          Draw this image in the provided Graphics2D context.
(package private) static RectangleImage make(int width, int height)
          Pseudo-constructor with a default color and mode.
(package private) static RectangleImage make(int width, int height, Color color)
          Pseudo-constructor with a Color and a default mode.
(package private) static RectangleImage make(int width, int height, Color color, Mode mode)
          The full pseudo-constructor
(package private) static RectangleImage make(int width, int height, IColor color)
          Pseudo-constructor with an IColor and a default mode.
(package private) static RectangleImage make(int width, int height, IColor color, Mode mode)
          Pseudo-constructor with an IColor
(package private) static RectangleImage make(int width, int height, Mode mode)
          Pseudo-constructor with a default color
(package private)  ColoredImage replaceColor(Color newColor)
          Functional setter for the color field Define this in all concrete subclasses.
(package private)  RectangularImage replaceDimensions(int width, int height)
          Functional setter for width and height.
(package private)  ColoredImage replaceMode(Mode newMode)
          Functional setter for the mode field Define this in all concrete subclasses.
 String toIndentedString(String indent)
          Produce a String that represents this image, indented by the given indent.
 
Methods inherited from class javalib.worldimages.RectangularImage
equals, getBottom, getRight, hashCode, replaceHeight, replaceWidth
 
Methods inherited from class javalib.worldimages.ColoredImage
getColor, getMode, replaceColor
 
Methods inherited from class javalib.worldimages.AImage
above, aboveCentered, beside, besideCentered, build, build, centerMoved, centerMoved, cornerString, cropped, frozen, getCenter, getHeight, getLeft, getPixelColor, getTop, getWidth, isApplet, makeCenteredCircle, makeCenteredCircle, makeCenteredCircle, makeCenteredCircle, makeCenteredCircle, makeCenteredCircle, makeCircle, makeCircle, makeCircle, makeCircle, makeCircle, makeCircle, makeEllipse, makeEllipse, makeEllipse, makeEllipse, makeEllipse, makeEllipse, makeFromFile, makeFromURL, makeImage, makeLine, makeLine, makeLine, makePolygon, makePolygon, makePolygon, makePolygon, makePolygon, makePolygon, makeRectangle, makeRectangle, makeRectangle, makeRectangle, makeRectangle, makeRectangle, makeText, makeText, makeText, makeText, makeText, makeText, makeText, makeText, makeText, makeText, makeText, makeText, makeTriangle, makeTriangle, makeTriangle, makeTriangle, makeTriangle, makeTriangle, makeTriangle, makeTriangle, makeTriangle, makeTriangle, makeTriangle, makeTriangle, map, map, moved, moved, normalized, overlay, overlayCentered, overlayImages, overlayXY, place, rotate, rotated, rotated, rotatedAround, rotatedAround, rotatedInPlace, rotatedInPlace, same, sameClass, save, scaled, scaled, show, toString, xReflected, yReflected
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RectangleImage

protected RectangleImage(int width,
                         int height,
                         Color color,
                         Mode mode)
The full constructor for a RectangleImage.

Parameters:
width -
height -
color -
Method Detail

draw

public void draw(Graphics2D g)
Draw this image in the provided Graphics2D context.

Parameters:
g - the provided Graphics2D context

make

static RectangleImage make(int width,
                           int height)
Pseudo-constructor with a default color and mode.

Parameters:
width -
height -

make

static RectangleImage make(int width,
                           int height,
                           Color color)
Pseudo-constructor with a Color and a default mode.

Parameters:
width -
height -
color -

make

static RectangleImage make(int width,
                           int height,
                           Color color,
                           Mode mode)
The full pseudo-constructor

Parameters:
width -
height -
color -
mode -

make

static RectangleImage make(int width,
                           int height,
                           IColor color)
Pseudo-constructor with an IColor and a default mode.

Parameters:
width -
height -
color -

make

static RectangleImage make(int width,
                           int height,
                           IColor color,
                           Mode mode)
Pseudo-constructor with an IColor

Parameters:
width -
height -
color -
mode -

make

static RectangleImage make(int width,
                           int height,
                           Mode mode)
Pseudo-constructor with a default color

Parameters:
width -
height -
mode -

replaceColor

ColoredImage replaceColor(Color newColor)
Description copied from class: ColoredImage
Functional setter for the color field Define this in all concrete subclasses. (I HATE this! Every one of these definitions will consist of calling the constructor with exactly the same fields but newColor plugged in as the color. Why do I have to write that over and over in every concrete subclass?)

Specified by:
replaceColor in class ColoredImage
Returns:
a new image just like this one but with a different color

replaceDimensions

RectangularImage replaceDimensions(int width,
                                   int height)
Description copied from class: RectangularImage
Functional setter for width and height.

Specified by:
replaceDimensions in class RectangularImage
Returns:
a new image just like this one but with different dimensions.

replaceMode

ColoredImage replaceMode(Mode newMode)
Description copied from class: ColoredImage
Functional setter for the mode field Define this in all concrete subclasses.

Specified by:
replaceMode in class ColoredImage
Returns:
a new image just like this one but with a different mode

toIndentedString

public String toIndentedString(String indent)
Description copied from interface: WorldImage
Produce a String that represents this image, indented by the given indent.

Define this in all concrete subclasses.

Convention: The result of toIndentedString() will neither begin nor end with a newline; the specified indent will immediately follow each internal newline.

Parameters:
indent - the given prefix representing the desired indentation
Returns:
the String representation of this image