javalib.worldimages
Class Crop

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

public class Crop
extends AImage

A rectangular window on an existing image.

Version:
Dec. 12, 2012
Author:
Stephen Bloch

Field Summary
 
Fields inherited from interface javalib.worldimages.WorldImage
LOOKS_SAME
 
Constructor Summary
Crop(WorldImage base, int left, int right, int top, int bottom)
          Constructor for objects of class Crop
 
Method Summary
 void draw(Graphics2D g)
          Draw this image in the provided Graphics2D context.
 boolean equals(Object other)
          Is this the same as another WorldImage, as expression trees? Define this at every level that has instance variables.
 int getBottom()
          Produce the bottom of the bounding box.
 int getLeft()
          Getter for the left edge of the bounding box.
 int getRight()
          Produce the bottom of the bounding box.
 int getTop()
          Getter for the top of the bounding box.
(package private) static WorldImage make(WorldImage base, int left, int right, int top, int bottom)
          Pseudo-constructor for objects of class Crop
 String toIndentedString(String indent)
          Produce a String that represents this image, indented by the given indent.
 
Methods inherited from class javalib.worldimages.AImage
above, aboveCentered, beside, besideCentered, build, build, centerMoved, centerMoved, cornerString, cropped, frozen, getCenter, getHeight, getPixelColor, 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, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javalib.worldimages.WorldImage
hashCode
 

Constructor Detail

Crop

Crop(WorldImage base,
     int left,
     int right,
     int top,
     int bottom)
Constructor for objects of class Crop

Parameters:
base - the image to crop
left, - right, top, bottom the borders to crop to
Method Detail

draw

public void draw(Graphics2D g)
Description copied from interface: WorldImage
Draw this image in the provided Graphics2D context.

Parameters:
g - the provided Graphics2D context

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.

getBottom

public int getBottom()
Description copied from interface: WorldImage
Produce the bottom of the bounding box.

Returns:
the y coordinate of the bottom of the bounding box

getLeft

public int getLeft()
Description copied from class: AImage
Getter for the left edge of the bounding box.

Specified by:
getLeft in interface WorldImage
Overrides:
getLeft in class AImage
Returns:
the minimum x coordinate of the image

getRight

public int getRight()
Description copied from interface: WorldImage
Produce the bottom of the bounding box.

Returns:
the x coordinate of the right edge of the bounding box

getTop

public int getTop()
Description copied from class: AImage
Getter for the top of the bounding box.

Specified by:
getTop in interface WorldImage
Overrides:
getTop in class AImage
Returns:
the minimum y coordinate of the image

make

static WorldImage make(WorldImage base,
                       int left,
                       int right,
                       int top,
                       int bottom)
Pseudo-constructor for objects of class Crop

Parameters:
base - the image to crop
left, - right, top, bottom the borders to crop to

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