javalib.worldimages
Class ColoredImage

java.lang.Object
  extended by javalib.worldimages.AImage
      extended by javalib.worldimages.ColoredImage
All Implemented Interfaces:
Drawable, WorldImage, tester.ISame<WorldImage>
Direct Known Subclasses:
PolygonImage, RectangularImage, TextImage

abstract class ColoredImage
extends AImage

Any image that explicitly stores a color and a mode.

Version:
Dec. 24, 2012
Author:
Stephen Bloch

Field Summary
static Color defaultColor
           
 
Fields inherited from interface javalib.worldimages.WorldImage
LOOKS_SAME
 
Constructor Summary
ColoredImage(Color color, Mode mode)
          The full constructor
ColoredImage(IColor color, Mode mode)
          Another constructor that takes in an IColorIColor.
ColoredImage(Mode mode)
          Another constructor that takes no color.
 
Method Summary
 boolean equals(Object other)
          Is this the same as another WorldImage, as expression trees? Define this at every level that has instance variables.
 Color getColor()
          get the color of an image
 Mode getMode()
           
 int hashCode()
          Get a hash code for the WorldImage.
(package private) abstract  ColoredImage replaceColor(Color newColor)
          Functional setter for the color field Define this in all concrete subclasses.
(package private)  ColoredImage replaceColor(IColor newColor)
           
(package private) abstract  ColoredImage replaceMode(Mode newMode)
          Functional setter for the mode field Define this in all concrete subclasses.
 
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
 
Methods inherited from interface javalib.worldimages.WorldImage
draw, getBottom, getRight, toIndentedString
 

Field Detail

defaultColor

public static final Color defaultColor
Constructor Detail

ColoredImage

ColoredImage(Color color,
             Mode mode)
The full constructor

Parameters:
color -

ColoredImage

ColoredImage(IColor color,
             Mode mode)
Another constructor that takes in an IColorIColor.

Parameters:
color -

ColoredImage

ColoredImage(Mode mode)
Another constructor that takes no color.

Method Detail

equals

public boolean equals(Object other)
Description copied from interface: WorldImage
Is this the same as another WorldImage, as expression trees? Define this at every level that has instance variables.

Specified by:
equals in interface WorldImage
Overrides:
equals in class AImage
Parameters:
other - the object to compare with this
Returns:
true iff the images are isomorphic expression trees, with equal fields.

getColor

public Color getColor()
get the color of an image

Returns:
an Color

getMode

public Mode getMode()

hashCode

public int hashCode()
Description copied from interface: WorldImage
Get a hash code for the WorldImage. Needs to agree with equals(). In our case, "equals" means they're the same as expression trees.

Specified by:
hashCode in interface WorldImage
Overrides:
hashCode in class Object

replaceColor

abstract ColoredImage replaceColor(Color newColor)
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?)

Parameters:
newColor -
Returns:
a new image just like this one but with a different color

replaceColor

ColoredImage replaceColor(IColor newColor)

replaceMode

abstract ColoredImage replaceMode(Mode newMode)
Functional setter for the mode field Define this in all concrete subclasses.

Parameters:
newMode -
Returns:
a new image just like this one but with a different mode