public class Picture extends java.util.Observable implements java.lang.Iterable<Pixel>
Constructor and Description |
---|
Picture()
Create a picture from a file provided by a dialog.
|
Picture(int width,
int height)
This constructor creates a new blank (white) picture of sepcified width & height.
|
Picture(java.lang.String fileName)
Create a picture with the specified filename
|
Modifier and Type | Method and Description |
---|---|
java.io.File |
getFile()
This method returns the file of the picture or null if there is no associated file.
|
int |
getHeight()
This method returns the height of the Picture
|
Pixel |
getPixel(int x,
int y)
This method returns a single Pixel object
|
int |
getWidth()
This method returns the width of the Picture
|
boolean |
hasNext()
This method returns true if there is at least one more pixel that hasn't
been accessed via the default iterator.
|
java.util.Iterator<Pixel> |
iterator()
Creates and returns a new Iterator to iterate through the pixels.
|
Pixel |
next()
This method returns the next Pixel in the picture.
|
void |
save()
This method saves the image with the filename provided by the dialog.
|
void |
save(java.lang.String filename)
Saves the picture to the specified file
|
void |
setCanvas(BasicIO.GeneralCanvas gc)
Used by BasicForm.
|
void |
setJFrame(javax.swing.JFrame frame)
Used by BasicForm.
|
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
public Picture()
public Picture(java.lang.String fileName)
fileName
- the name and directory of the picture filepublic Picture(int width, int height)
width
- width of blank pictureheight
- height of blank picturepublic void setJFrame(javax.swing.JFrame frame)
frame
- the JFrame which the picture is onpublic void setCanvas(BasicIO.GeneralCanvas gc)
gc
- the canvas the picture is being drawn topublic java.io.File getFile()
public int getWidth()
public int getHeight()
public Pixel getPixel(int x, int y)
x
- (the x-coordinate of the desired Pixel)y
- (the y-coordinate of the desired Pixel)public void save()
public void save(java.lang.String filename)
filename
- the file name and directory of where to save the image.public java.util.Iterator<Pixel> iterator()
iterator
in interface java.lang.Iterable<Pixel>
public boolean hasNext()
public Pixel next()