DigitalPicturePicturepublic class SimplePicture extends java.lang.Object implements DigitalPicture
| Constructor | Description |
|---|---|
SimplePicture() |
A Constructor that takes no arguments.
|
SimplePicture(int width,
int height) |
A constructor that takes the width and height desired for a picture and
creates a buffered image of that size.
|
SimplePicture(int width,
int height,
java.awt.Color theColor) |
A constructor that takes the width and height desired for a picture and
creates a buffered image of that size.
|
SimplePicture(java.awt.image.BufferedImage image) |
A constructor that takes a buffered image
|
SimplePicture(java.lang.String fileName) |
A Constructor that takes a file name and uses the file to create
a picture
|
SimplePicture(SimplePicture copyPicture) |
A Constructor that takes a picture to copy information from
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
addMessage(java.lang.String message,
int xPos,
int yPos) |
Method to draw a message as a string on the buffered image
|
void |
copyPicture(SimplePicture sourcePicture) |
Method that will copy all of the passed source picture into
the current picture object
|
java.awt.Graphics2D |
createGraphics() |
Method to get a Graphics2D object for this picture which can
be used to do 2D drawing on the picture
|
void |
drawString(java.lang.String text,
int xPos,
int yPos) |
Method to draw a string at the given location on the picture
|
void |
explore() |
Method to open a picture explorer on a copy (in memory) of this
simple picture
|
int |
getBasicPixel(int x,
int y) |
Method to return the pixel value as an int for the given x and y location
|
java.awt.image.BufferedImage |
getBufferedImage() |
Method to get the buffered image
|
java.lang.String |
getExtension() |
Method to get the extension for this picture
|
java.lang.String |
getFileName() |
Method to get the file name associated with the picture
|
java.awt.Graphics |
getGraphics() |
Method to get a graphics object for this picture to use to draw on
|
int |
getHeight() |
Method to get the height of the picture in pixels
|
java.awt.Image |
getImage() |
Method to get an image from the picture
|
static java.lang.String |
getMediaPath(java.lang.String fileName) |
Method to get the directory for the media
|
PictureFrame |
getPictureFrame() |
Method to get the picture frame for the picture
|
Picture |
getPictureWithHeight(int height) |
Method to create a new picture of the passed height.
|
Picture |
getPictureWithWidth(int width) |
Method to create a new picture of the passed width.
|
Pixel |
getPixel(int x,
int y) |
Method to get a pixel object for the given x and y location
|
Pixel[] |
getPixels() |
Method to get a one-dimensional array of Pixels for this simple picture
|
Pixel[][] |
getPixels2D() |
Method to get a two-dimensional array of Pixels for this simple picture
|
java.lang.String |
getTitle() |
Method to get the title of the picture
|
java.awt.geom.Rectangle2D |
getTransformEnclosingRect(java.awt.geom.AffineTransform trans) |
Method to get the coordinates of the enclosing rectangle after this
transformation is applied to the current picture
|
java.awt.geom.Rectangle2D |
getTranslationEnclosingRect(java.awt.geom.AffineTransform trans) |
Method to get the coordinates of the enclosing rectangle after this
transformation is applied to the current picture
|
int |
getWidth() |
Method to get the width of the picture in pixels
|
void |
hide() |
Method to hide the picture display
|
void |
load(java.awt.Image image) |
Method to load the buffered image with the passed image
|
boolean |
load(java.lang.String fileName) |
Method to read the contents of the picture from a filename
without throwing errors
|
boolean |
loadImage(java.lang.String fileName) |
Method to load the picture from the passed file name
this just calls load(fileName) and is for name compatibility
|
void |
loadOrFail(java.lang.String fileName) |
Method to load the picture from the passed file name
|
boolean |
loadPictureAndShowIt(java.lang.String fileName) |
Method to load a picture from a file name and show it in a picture frame
|
void |
repaint() |
Method to force the picture to repaint itself.
|
Picture |
scale(double xFactor,
double yFactor) |
Method to create a new picture by scaling the current
picture by the given x and y factors
|
void |
setAllPixelsToAColor(java.awt.Color color) |
Method to set the color in the picture to the passed color
|
void |
setBasicPixel(int x,
int y,
int rgb) |
Method to set the value of a pixel in the picture from an int
|
void |
setFileName(java.lang.String name) |
Method to set the file name
|
void |
setPictureFrame(PictureFrame pictureFrame) |
Method to set the picture frame for this picture
|
void |
setTitle(java.lang.String title) |
Method to set the title for the picture
|
void |
setVisible(boolean flag) |
Method to make this picture visible or not
|
void |
show() |
Method to show the picture in a picture frame
|
java.lang.String |
toString() |
Method to return a string with information about this picture
|
boolean |
write(java.lang.String fileName) |
Method to write the contents of the picture to a file with
the passed name without throwing errors
|
void |
writeOrFail(java.lang.String fileName) |
Method to write the contents of the picture to a file with
the passed name
|
public SimplePicture()
public SimplePicture(java.lang.String fileName)
fileName - the file name to use in creating the picturepublic SimplePicture(int width,
int height)
width - the desired widthheight - the desired heightpublic SimplePicture(int width,
int height,
java.awt.Color theColor)
width - the desired widthheight - the desired heighttheColor - the background color for the picturepublic SimplePicture(SimplePicture copyPicture)
copyPicture - the picture to copy frompublic SimplePicture(java.awt.image.BufferedImage image)
image - the buffered imagepublic java.lang.String getExtension()
public void copyPicture(SimplePicture sourcePicture)
sourcePicture - the picture object to copypublic void setAllPixelsToAColor(java.awt.Color color)
color - the color to set topublic java.awt.image.BufferedImage getBufferedImage()
getBufferedImage in interface DigitalPicturepublic java.awt.Graphics getGraphics()
public java.awt.Graphics2D createGraphics()
public java.lang.String getFileName()
getFileName in interface DigitalPicturepublic void setFileName(java.lang.String name)
name - the full pathname of the filepublic java.lang.String getTitle()
getTitle in interface DigitalPicturepublic void setTitle(java.lang.String title)
setTitle in interface DigitalPicturetitle - the title to use for the picturepublic int getWidth()
getWidth in interface DigitalPicturepublic int getHeight()
getHeight in interface DigitalPicturepublic PictureFrame getPictureFrame()
public void setPictureFrame(PictureFrame pictureFrame)
pictureFrame - the picture frame to usepublic java.awt.Image getImage()
getImage in interface DigitalPicturepublic int getBasicPixel(int x,
int y)
getBasicPixel in interface DigitalPicturex - the x coordinate of the pixely - the y coordinate of the pixelpublic void setBasicPixel(int x,
int y,
int rgb)
setBasicPixel in interface DigitalPicturex - the x coordinate of the pixely - the y coordinate of the pixelrgb - the new rgb value of the pixel (alpha, red, green, blue)public Pixel getPixel(int x, int y)
getPixel in interface DigitalPicturex - the x location of the pixel in the picturey - the y location of the pixel in the picturepublic Pixel[] getPixels()
getPixels in interface DigitalPicturepublic Pixel[][] getPixels2D()
getPixels2D in interface DigitalPicturepublic void load(java.awt.Image image)
load in interface DigitalPictureimage - the image to usepublic void show()
show in interface DigitalPicturepublic void hide()
public void setVisible(boolean flag)
flag - true if you want it visible else falsepublic void explore()
explore in interface DigitalPicturepublic void repaint()
public void loadOrFail(java.lang.String fileName)
throws java.io.IOException
fileName - the file name to use to load the picture fromjava.io.IOException - if the picture isn't foundpublic boolean load(java.lang.String fileName)
load in interface DigitalPicturefileName - the name of the file to write the picture topublic boolean loadImage(java.lang.String fileName)
fileName - the file name to use to load the picture frompublic void addMessage(java.lang.String message,
int xPos,
int yPos)
message - the message to draw on the buffered imagexPos - the x coordinate of the leftmost point of the stringyPos - the y coordinate of the bottom of the stringpublic void drawString(java.lang.String text,
int xPos,
int yPos)
text - the text to drawxPos - the left x for the textyPos - the top y for the textpublic Picture scale(double xFactor, double yFactor)
xFactor - the amount to scale in xyFactor - the amount to scale in ypublic Picture getPictureWithWidth(int width)
width - the desired widthpublic Picture getPictureWithHeight(int height)
height - the desired heightpublic boolean loadPictureAndShowIt(java.lang.String fileName)
fileName - the file name to load the picture frompublic void writeOrFail(java.lang.String fileName)
throws java.io.IOException
fileName - the name of the file to write the picture tojava.io.IOExceptionpublic boolean write(java.lang.String fileName)
write in interface DigitalPicturefileName - the name of the file to write the picture topublic static java.lang.String getMediaPath(java.lang.String fileName)
fileName - the base file name to usepublic java.awt.geom.Rectangle2D getTransformEnclosingRect(java.awt.geom.AffineTransform trans)
public java.awt.geom.Rectangle2D getTranslationEnclosingRect(java.awt.geom.AffineTransform trans)
public java.lang.String toString()
toString in class java.lang.Object