Class Picture

java.lang.Object
  extended by SimplePicture
      extended by Picture
All Implemented Interfaces:
DigitalPicture

public class Picture
extends SimplePicture

A class that represents a picture. This class inherits from SimplePicture and allows the student to add functionality to the Picture class. In JES, many "extra" features are already present, available through OO-notation for the advanced media computation students. Copyright Georgia Institute of Technology 2004-2005


Field Summary
 
Fields inherited from class SimplePicture
_PictureIndexOffset
 
Constructor Summary
Picture()
          Constructor that takes no arguments
Picture(java.awt.image.BufferedImage image)
          Constructor that takes a buffered image
Picture(int width, int height)
          Constructor that takes the width and height
Picture(int width, int height, java.awt.Color color)
          Constructor that takes the width and height, and a color
Picture(Picture copyPicture)
          Constructor that takes a picture and creates a copy of that picture.
Picture(java.lang.String fileName)
          Constructor that takes a file name and creates the picture
 
Method Summary
 void addArc(java.awt.Color acolor, int x, int y, int w, int h, int start, int angle)
          Method to draw the outline of an arc on a picture
 void addArcFilled(java.awt.Color acolor, int x, int y, int w, int h, int start, int angle)
          Method to draw a solid arc on a picture
 void addLine(java.awt.Color acolor, int x1, int y1, int x2, int y2)
          Method to draw a line between two points on a picture
 void addOval(java.awt.Color acolor, int x, int y, int w, int h)
          Method to draw the outline of an oval on a picture.
 void addOvalFilled(java.awt.Color acolor, int x, int y, int w, int h)
          Method to draw a solid oval on a picture.
 void addRect(java.awt.Color acolor, int x, int y, int w, int h)
          Method to draw the outline of a rectangle on a picture.
 void addRectFilled(java.awt.Color acolor, int x, int y, int w, int h)
          Method to draw a solid rectangle on a picture.
 void addText(java.awt.Color acolor, int x, int y, java.lang.String string)
          Method to add a line of text to a picture
 void addTextWithStyle(java.awt.Color acolor, int x, int y, java.lang.String string, java.awt.Font style)
          Method to add text to a picture withe a particular font style
 void copyInto(Picture dest, int upperLeftX, int upperLeftY)
          Copies all the pixels from this picture to the destination picture, starting with the specified upper-left corner.
 Picture crop(int upperLeftX, int upperLeftY, int width, int height)
          Returns a cropped version of this picture: copies the pixels in it starting at the specified upper-left corner and taking as many pixels as specified by width and height.
 java.lang.String toString()
          Method to return a string with information about this picture.
 
Methods inherited from class SimplePicture
addMessage, copyPicture, createGraphics, drawString, explore, getBasicPixel, getBufferedImage, getExtension, getFileName, getGraphics, getHeight, getImage, getMediaPath, getPictureFrame, getPictureWithHeight, getPictureWithWidth, getPixel, getPixels, getTitle, getTransformEnclosingRect, getWidth, hide, load, load, loadImage, loadOrFail, loadPictureAndShowIt, repaint, scale, setAllPixelsToAColor, setBasicPixel, setFileName, setMediaPath, setPictureFrame, setTitle, setVisible, show, write, writeOrFail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Picture

public Picture()
Constructor that takes no arguments


Picture

public Picture(java.lang.String fileName)
Constructor that takes a file name and creates the picture

Parameters:
fileName - the name of the file to create the picture from

Picture

public Picture(int width,
               int height)
Constructor that takes the width and height

Parameters:
width - the width of the desired picture
height - the height of the desired picture

Picture

public Picture(int width,
               int height,
               java.awt.Color color)
Constructor that takes the width and height, and a color

Parameters:
width - the width of the desired picture
height - the height of the desired picture
color - the color of the desired picture

Picture

public Picture(Picture copyPicture)
Constructor that takes a picture and creates a copy of that picture.

Parameters:
copyPicture - the picture to be copied

Picture

public Picture(java.awt.image.BufferedImage image)
Constructor that takes a buffered image

Parameters:
image - the buffered image to use
Method Detail

toString

public java.lang.String toString()
Method to return a string with information about this picture.

Overrides:
toString in class SimplePicture
Returns:
a string with information about the picture such as fileName, height and width.

addLine

public void addLine(java.awt.Color acolor,
                    int x1,
                    int y1,
                    int x2,
                    int y2)
Method to draw a line between two points on a picture

Parameters:
acolor - the color of the line
x1 - the x-coordinate of the first point
y1 - the y-coordinate of the first point
x2 - the x-coordinate of the second point
y2 - the y-coordinate of the second point

addText

public void addText(java.awt.Color acolor,
                    int x,
                    int y,
                    java.lang.String string)
Method to add a line of text to a picture

Parameters:
acolor - the color of the text
x - the x-coordinate of the bottom left corner of the text
y - the y-coordinate of the bottom left corner of the text
string - the text to be added to the picture

addTextWithStyle

public void addTextWithStyle(java.awt.Color acolor,
                             int x,
                             int y,
                             java.lang.String string,
                             java.awt.Font style)
Method to add text to a picture withe a particular font style

Parameters:
acolor - the color of the text
x - the x-coordinate of the bottom left corner of the text
y - the y-coordinate of the bottom left corner of the text
string - the text to be added to the picture
style - the font style to be used

addRect

public void addRect(java.awt.Color acolor,
                    int x,
                    int y,
                    int w,
                    int h)
Method to draw the outline of a rectangle on a picture.

Parameters:
acolor - the color of the rectangle
x - the x-coordinate of the upper-left corner of the rectangle
y - the y-coordinate of the upper-left corner of the rectangle
w - the width of the rectangle
h - the height of the rectangle

addRectFilled

public void addRectFilled(java.awt.Color acolor,
                          int x,
                          int y,
                          int w,
                          int h)
Method to draw a solid rectangle on a picture.

Parameters:
acolor - the color of the rectangle
x - the x-coordinate of the upper-left corner of the rectangle
y - the y-coordinate of the upper-left corner of the rectangle
w - the width of the rectangle
h - the height of the rectangle

addOvalFilled

public void addOvalFilled(java.awt.Color acolor,
                          int x,
                          int y,
                          int w,
                          int h)
Method to draw a solid oval on a picture.

Parameters:
acolor - the color of the oval
x - the x-coordinate of the upper-left corner of the bounding rectangle for the oval
y - the y-coordinate of the upper-left corner of the bounding rectangle for the oval
w - the width of the oval
h - the height of the oval

addOval

public void addOval(java.awt.Color acolor,
                    int x,
                    int y,
                    int w,
                    int h)
Method to draw the outline of an oval on a picture.

Parameters:
acolor - the color of the oval
x - the x-coordinate of the upper-left corner of the bounding rectangle for the oval
y - the y-coordinate of the upper-left corner of the bounding rectangle for the oval
w - the width of the oval
h - the height of the oval

addArcFilled

public void addArcFilled(java.awt.Color acolor,
                         int x,
                         int y,
                         int w,
                         int h,
                         int start,
                         int angle)
Method to draw a solid arc on a picture

Parameters:
acolor - the color of the arc
x - the x-coordinate of the center of the arc
y - the y-coordinate of the center of the arc
w - the width of the arc
h - the height of the arc
start - the starting angle at which to draw the arc
angle - the angle of the arc, relative to the start angle

addArc

public void addArc(java.awt.Color acolor,
                   int x,
                   int y,
                   int w,
                   int h,
                   int start,
                   int angle)
Method to draw the outline of an arc on a picture

Parameters:
acolor - the color of the arc
x - the x-coordinate of the center of the arc
y - the y-coordinate of the center of the arc
w - the width of the arc
h - the height of the arc
start - the starting angle at which to draw the arc
angle - the angle of the arc, relative to the start angle

copyInto

public void copyInto(Picture dest,
                     int upperLeftX,
                     int upperLeftY)
Copies all the pixels from this picture to the destination picture, starting with the specified upper-left corner. If this picture will not fit in the destination starting at the upper-left corner, then only the pixels that will fit are copied. If the specified upper-left corner is not in the bounds of the destination picture, no pixels are copied.

Parameters:
dest - the picture which to copy into
upperLeftX - the x-coord for the upper-left corner
upperLeftY - the y-coord for the upper-left corner

crop

public Picture crop(int upperLeftX,
                    int upperLeftY,
                    int width,
                    int height)
Returns a cropped version of this picture: copies the pixels in it starting at the specified upper-left corner and taking as many pixels as specified by width and height. The final cropped picture may be smaller than indicated by the parameters if the cropping area as specified would go beyond the bounds of this picture. The cropping area will be 0 x 0 if the specified upper-left corner is not in the bounds of the destination picture.

Parameters:
upperLeftX - the x-coord of the upper-left corner
upperLeftY - the y-coord of the upper-left corner
width - the desired width of the cropped area
height - the desired height of the cropped area
Returns:
the new cropped picture