|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectimg.SimplePicture
img.Picture
public class Picture
This class encapsulates a basic Picture component. The pixels of the picture can be modified by the client. The initial state and dimensions of the pixels depends on the constructor that is invoked (e.g., all pixels initialized to a particular colour or taken from an image file). This class a further detailed version of the SimplePicture (inheritance is used). It is designed so as to allow the student/learner to add functionality to the Picture class. This implementation is taken from Guzdial and Ericson codebase resource (accompanies the textbook). Further explanatory comments were added by sdc@cs.albany.edu. Further modifications have been added by mb@cse.yorku.ca Copyright Georgia Institute of Technology 2004-2005
Constructor Summary | |
---|---|
Picture()
Creates an instance of a default Picture, which is 200 pixels wide and 100 pixels high. |
|
Picture(int width,
int height)
A third form of constructor, which takes a 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)
Creates an instance of a Picture that takes its pixel values and dimensions from the image that is passed as a parameter. |
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, getGraphics2D, 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 |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Picture()
public Picture(java.lang.String fileName)
fileName
- the name of the file to create the picture from or the URL
that corresponds to a picture [MB: modified to accept URL]public Picture(int width, int height)
width
- the width of the desired pictureheight
- the height of the desired picturepublic Picture(Picture copyPicture)
Method Detail |
---|
public java.lang.String toString()
toString
in class SimplePicture
public void blacken(int row)
row
- the index of the row to be changedpublic void modifyRowColour(int row, java.awt.Color theNewColor)
row
- the index of the row to be changedtheNewColor
- the new colour of the row
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |