img
Class Picture

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

public class Picture
extends SimplePicture

Picture class from Guzdial and Ericson with explanatory comments enhanced by sdc@cs.albany.edu A class that represents a picture. This class inherits from SimplePicture and allows the student to add functionality to the Picture class. Copyright Georgia Institute of Technology 2004-2005

Author:
Barbara Ericson ericson@cc.gatech.edu

Constructor Summary
Picture()
          Constructor that takes no arguments
Picture(int width, int height)
          Wow, a third form of constructor! Constructor that takes the width and height
Picture(Picture copyPicture)
          Whoops, yet another! Constructor that takes a picture and creates a copy of that picture
Picture(java.lang.String fileName)
          In Java, constructors (and other methods) can be "Polymorphic".
 
Method Summary
 void blacken(int row)
          Cause the pixels in the specified row to change to black.
 void modifyRowColour(int row, java.awt.Color theNewColor)
          Cause the pixels in the specified row to change to the specifed colour.
 java.lang.String toString()
          This method DOES NOT (yes, NOT) PRINT anything! What code could a program using the Picture class have to use this method to print a string form of a Picture? Method to return a string with information about this picture.
 
Methods inherited from class img.SimplePicture
addMessage, copyPicture, createGraphics, explore, getBasicPixel, getBufferedImage, getExtension, getFileName, getGraphics, getHeight, getImage, getPictureFrame, getPictureWithHeight, getPixel, getPixels, getTitle, getTranslationEnclosingRectangle, getWidth, load, load, loadPictureAndShowIt, repaint, setAllPixelsToAColor, setBasicPixel, setPictureFrame, setTitle, show, write
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Picture

public Picture()
Constructor that takes no arguments


Picture

public Picture(java.lang.String fileName)
In Java, constructors (and other methods) can be "Polymorphic". Polymorphic methods have the SAME NAME but MULTIPLE FORMS. Each form has a really different body. Which body is called depends on the types of arguments coded in the call. Here is a second polymorphic form for Picture's constructor. 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)
Wow, a third form of constructor! 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(Picture copyPicture)
Whoops, yet another! Constructor that takes a picture and creates a copy of that picture

Method Detail

toString

public java.lang.String toString()
This method DOES NOT (yes, NOT) PRINT anything! What code could a program using the Picture class have to use this method to print a string form of a Picture? 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.

blacken

public void blacken(int row)
Cause the pixels in the specified row to change to black. The row indexing is the same as the pixel indexing (e.g., the topmost row has index position 0)

Parameters:
row - the index of the row to be changed

modifyRowColour

public void modifyRowColour(int row,
                            java.awt.Color theNewColor)
Cause the pixels in the specified row to change to the specifed colour. The row indexing is the same as the pixel indexing (e.g., the topmost row has index position 0)

Parameters:
row - the index of the row to be changed
theNewColor - the new colour of the row