|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSimplePicture
Picture
public class Picture
A class that represents a picture. This class inherits from SimplePicture and allows the student to add functionality to the Picture class. Pictures are immutable (don't change). Each method that changes a picture creates a copy of the original picture and changes that. Copyright Georgia Institute of Technology 2004
Constructor Summary | |
---|---|
Picture()
Constructor that takes no arguments |
|
Picture(int width,
int height)
Constructor that takes the width and height |
|
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 | |
---|---|
static Picture |
addBoxToBeach()
Method to add a solid red rectangle to the beach picture |
static Picture |
blendPictures()
Method to blend pictures of Katie and Jenny |
Picture |
blendPictures(Picture sourcePict,
double sourceAlpha)
Method to blend two pictures, the current picture object and the passed sourcePict object. |
void |
blueChange()
Method to set all blue values to 100 in the picture |
void |
blueOneHundred()
Method to set the blue values to 100 in a rectangle of 100 pixels with x and y starting at 0 and ending at 99 |
void |
blur(int numPixels)
Method to blur the pixels |
Picture |
changeColors(double redAmount,
double greenAmount,
double blueAmount)
Method to change the color of each pixel in a copy of the current picture object by the passed amounts. |
void |
changePixelsWithinDistance(java.awt.Color compareColor,
double distance,
double redFactor,
double greenFactor,
double blueFactor,
int startX,
int startY,
int endX,
int endY)
Method to change all the pixels within a passed distance of a passed color in a range specified by a startX, startY, endX, and endY by passed red, green, and blue factors. |
Picture |
changeRed(double amount)
Method to change the red by an amount |
void |
chromakey(Picture newBg)
Method to do chromakey using a blue background |
void |
chromakeyBlue(Picture newBg)
Method to do chromakey using a blue background |
void |
chromakeyRed(Picture newBg)
Method to do chromakey using a red background |
Picture |
clearBlue()
Method to clear the blue from a copy of the current picture (set the blue to 0 for all pixels) |
Picture |
clearBlue2()
Method to clear the blue from a copy of the current picture (set the blue to 0 for all pixels) |
Picture |
clearBlue3()
Method to clear the blue from a copy of the current picture (set the blue to 0 for all pixels) |
void |
clearSomeBlue()
Method to set the blue to zero if the distance from this color to blue is greater than 100 |
Picture |
clipToEllipse()
Method to clip the picture to an ellipse |
Picture |
clipToMessage(java.lang.String message)
Method to create a new picture from this picture that shows the part of the current picture that is inside a text message |
void |
copy(Picture source,
int x,
int y)
Method to copy the passed picture into the current picture at the given x and y position in the current picture |
void |
copy(Picture sourcePicture,
int startX,
int startY,
int endX,
int endY,
int targetStartX,
int targetStartY)
Method to copy from the passed source picture to current picture object The copying will start at startX, startY, and end at endX-1 and endY-1 The copy will be placed starting at targetStartX, targetStartY |
void |
copy2D(Picture source,
int x,
int y)
Method to copy the passed picture into the current picture at the given x and y position in the current picture |
static Picture |
copyFlowerLarger()
Method to copy a flower but scaled to 2x normal size |
static Picture |
copyFlowerSmaller()
Method to copy the flower but smaller (half as big) |
static Picture |
copyKatie()
Method to copy the picture of Katie to the canvas |
static Picture |
copyKatieLeftRotation()
Method to copy the picture of Katie but rotate her left 90 degrees on the resulting picture |
static Picture |
copyKatieMidway()
Method to copy the picture of Katie to 100, 100 in the canvas |
static Picture |
copyKatiesFace()
Method to copy just Katie's face to the canvas |
void |
copyNonWhitePixels(Picture sourcePicture,
int startX,
int startY,
int endX,
int endY,
int targetStartX,
int targetStartY)
Method to copy from the passed source picture to current picture object The copying will start at startX, startY, and end at endX-1 and endY-1 The copy will be placed starting at targetStartX, targetStartY |
void |
copyPicture(Picture sourcePict,
java.awt.Rectangle sourceRect,
java.awt.Rectangle targetRect,
java.awt.Composite composite)
Method to copy a picture into the current picture using the passed composite rule |
void |
copyPictureTo(Picture sourcePicture,
int xStart)
Method that will copy all of the passed source picture into the current picture object starting with the left corner given by xStart |
void |
copyPictureTo(Picture sourcePicture,
int xStart,
int yStart)
Method that will copy all of the passed source picture into the current picture object starting with the left corner given by xStart, yStart |
int |
countWhitePixels()
Method to count the number of white pixels in a picture |
static Picture |
createCollage()
Method to create a collage from the flower pictures. |
static Picture |
createCollageBetter()
Method to create a collage of flowers |
static Picture |
createComposite()
Method to try different composite rules in a picture with a gradient painted rectangle and a texture painted ellipse |
Picture |
darken()
Method to darken the color in a copy of the current picture |
Picture |
decreaseBlue()
Method to decrease the blue in a copy of the current picture by 30% |
Picture |
decreaseGreen()
Method to decrease the green in a copy of the current picture by 30% |
Picture |
decreaseRed()
Method to decrease the red by half in a copy of the current picture |
void |
doubleRedInRange(int startX,
int startY,
int endX,
int endY,
double distance,
java.awt.Color compareColor)
Method to double the red in a picture in a rectangular area if it is less than the passed distance to the passed color |
void |
drawBox(java.awt.Color color,
int topLeftX,
int topLeftY,
int width,
int height)
Method to draw a filled box on the current picture |
static Picture |
drawExample()
Method to show using drawing on a picture |
static Picture |
drawFace()
Method to draw a face to demonstrate drawing ovals and arcs |
static Picture |
drawFilledRectangles()
Method to draw a picture with a succession of filled rectangles with the top left corner the darkest and the bottom right the lightest |
static Picture |
drawGrayEffect()
Method to draw a gray effect picture |
void |
drawGrid()
Method to draw a grid on a picture |
void |
drawHorizontalCenteredString(java.lang.String text,
int y)
Method to draw a horizontally centered string on the current picture |
static Picture |
drawRectangles()
Method to draw a picture with a succession of rectangles |
void |
drawString(java.lang.String text,
int x,
int y)
Method to draw a string on the current picture |
void |
drawSun(int x,
int y,
int width,
int height)
Method to add a gradient painted sun to the current picture |
void |
drawWideX(java.awt.Color color,
float width)
Method to add two crossed lines to a picture. |
void |
drawX(java.awt.Color color)
Method to add two crossed lines to a picture. |
void |
edgeDetection(double amount)
Method to do a simple edge detection by comparing the absolute value of the difference between the color intensities (average of the color values) between a pixel and the pixel below it. |
Picture |
grayscale()
Method to change a copy of the current picture to grayscale |
Picture |
grayscaleWithLuminance()
Method to change a copy of the current picture to gray scale with luminance |
void |
highlightLightAndDark(double amount,
java.awt.Color replacementColor)
Method to replace the pixel colors in the current picture object that have a color distance less than the passed amount to white or black with the passed replacement color |
Picture |
increaseRed()
Method to increase the amount of red by 30% in a copy of the current picture |
Picture |
increaseRed2()
Method to increase the amount of red by 1.3 in a copy of the current picture |
Picture |
increaseRed3()
Method to increase the amount of red by 1.3 in a copy of the current picture |
Picture |
lighten()
Method to lighten the colors in a copy of the current picture |
Picture |
lighten2()
Method to lighten the colors in a copy of the current picture |
Picture |
makeSunset()
Method to simulate a sunset by decreasing the green and blue in a copy of the current picture |
Picture |
makeSunset2()
Method to make a copy of the current picture that looks like it was taken at sunset by reducing the blue and green to make it look more red |
static void |
makeTurtleMovie(java.lang.String outputDirectory)
Method to show a turtle crawling across the beach |
Picture |
mirrorHorizontal()
Method to mirror around a horizontal line in the middle based on the height. |
Picture |
mirrorHorizontalBottomToTop()
Method to mirror around a horiztonal line in the middle based on the height of the picture. |
static Picture |
mirrorTemple()
Method to mirror the piedmont of the temple |
static Picture |
mirrorTemple2()
Method to mirror the piedmont of the temple |
static Picture |
mirrorTemple3()
Method to mirror the piedmont of the temple |
Picture |
mirrorVertical()
Method to mirror around a vertical line in the middle of the picture based on the width. |
Picture |
negate()
Method to negate a copy of the current picture |
static Picture |
overlapPictures(Picture p1,
Picture p2,
int startOverlap)
Method to create a new picture by overlapping one picture with another horizontally. |
static Picture |
pickAndShow()
Method to allow the user to pick a file name and show a picture. |
void |
posterize()
Method to posterize (reduce the number of colors) in the picture The number of reds, greens, and blues will be 4 |
void |
posterize(int numLevels)
Method to posterize (reduce the number of colors) in the picture |
void |
removeRedEye(int startX,
int startY,
int endX,
int endY,
java.awt.Color newColor)
Method to remove red eye from the current picture object in the rectangle defined by startX, startY, endX, endY. |
Picture |
rotate(int degrees)
Method to create a new picture by rotating the current picture by the given degrees |
Picture |
scale(double xFactor,
double yFactor)
Method to create a new picture by scaling the current picture by the given x and y factors |
Picture |
scaleUp(int numTimes)
Method to create a new picture that is scaled up by the passed number of times. |
void |
sepiaTint()
Method to change the current picture to a sepia tint (modify the middle colors to a light brown and the light colors to a light yellow and make the shadows darker |
void |
setBlue()
Method to set the blue to zero if the current blue value is greater than 100 |
Picture |
shear(double xFactor,
double yFactor)
Method to create a new picture by shearing the current picture by the given x and y factors |
static Picture |
showNamed(java.lang.String fileName)
Method to show a picture created from a passed file name |
static Picture |
showSpecificPicture()
Method to show a specific picture where the file name to show is specified in the method. |
static void |
showTurtleMovie()
Method to show a turtle crawling across the beach |
void |
swapBackground(Picture oldBackground,
Picture newBackground)
Method to replace the background in the current picture with the background from another picture |
void |
swapBackground(Picture oldBackground,
Picture newBackground,
double threshold)
Method to replace the background in the current picture with the background from another picture |
java.lang.String |
toString()
Method to return a string with information about this picture. |
static Picture |
turnKatieRedHead()
Method to turn to turn Katie into a red head |
static Picture |
turnKatieRedHeadInRange()
Method to turn to turn Katie into a red head using a range |
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 frompublic 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 static Picture pickAndShow()
public static Picture showSpecificPicture()
public static Picture showNamed(java.lang.String fileName)
fileName
- the name of the file to create the picture from
public Picture decreaseRed()
public Picture increaseRed()
public Picture clearBlue()
public Picture makeSunset()
public Picture decreaseGreen()
public Picture decreaseBlue()
public Picture makeSunset2()
public Picture changeRed(double amount)
amount
- the amount to change the red by
public Picture changeColors(double redAmount, double greenAmount, double blueAmount)
redAmount
- the amount to change the red valuegreenAmount
- the amount to change the green valueblueAmount
- the amount to change the blue value
public Picture clearBlue2()
public Picture clearBlue3()
public Picture lighten()
public Picture darken()
public Picture negate()
public Picture grayscale()
public Picture grayscaleWithLuminance()
public Picture increaseRed2()
public Picture increaseRed3()
public Picture lighten2()
public Picture mirrorVertical()
public Picture mirrorHorizontal()
public Picture mirrorHorizontalBottomToTop()
public static Picture mirrorTemple()
public static Picture mirrorTemple2()
public static Picture mirrorTemple3()
public static Picture copyKatie()
public static Picture copyKatieMidway()
public static Picture copyKatiesFace()
public static Picture createCollage()
public void copyPictureTo(Picture sourcePicture, int xStart)
sourcePicture
- the picture object to copyxStart
- the x position to start the copy intopublic static Picture createCollageBetter()
public void copy(Picture sourcePicture, int startX, int startY, int endX, int endY, int targetStartX, int targetStartY)
sourcePicture
- the source picture to copy fromstartX
- the starting x value in the source picturestartY
- the starting y value in the source pictureendX
- the ending x value in the source pictureendY
- the ending y value in the source picturetargetStartX
- the starting x value in the current picturetargetStartY
- the starting y value in the current picturepublic void copyNonWhitePixels(Picture sourcePicture, int startX, int startY, int endX, int endY, int targetStartX, int targetStartY)
sourcePicture
- the source picture to copy fromstartX
- the starting x value in the source picturestartY
- the starting y value in the source pictureendX
- the ending x value in the source pictureendY
- the ending y value in the source picturetargetStartX
- the starting x value in the current picturetargetStartY
- the starting y value in the current picturepublic static Picture blendPictures()
public void copyPictureTo(Picture sourcePicture, int xStart, int yStart)
sourcePicture
- the picture object to copyxStart
- the x position to start the copy into on the targetyStart
- the y position to start the copy into on the targetpublic static Picture copyKatieLeftRotation()
public static Picture copyFlowerSmaller()
public static Picture copyFlowerLarger()
public static Picture turnKatieRedHead()
public static Picture turnKatieRedHeadInRange()
public void doubleRedInRange(int startX, int startY, int endX, int endY, double distance, java.awt.Color compareColor)
startX
- the x value at the top left of the rectangular areastartY
- the y value at the top left of the rectangular areaendX
- the bottom right x value of the rectangular areaendY
- the bottom right y value of the rectangular areadistance
- the amount that the distance must be less thancompareColor
- the color to compare the current pixel color topublic void changePixelsWithinDistance(java.awt.Color compareColor, double distance, double redFactor, double greenFactor, double blueFactor, int startX, int startY, int endX, int endY)
compareColor
- the color to compare the current pixel color todistance
- the distance that this should be within (less than)redFactor
- the amount to multiply the current red value bygreenFactor
- the amount to multiply the current green value byblueFactor
- the amount to multiply the current blue value bystartX
- the starting x value to use in checking the pixelsstartY
- the starting y value to use in checking the pixelsendX
- the ending x value to use in checking the pixels (< this)endY
- the ending y value to use in checking the pixels (< this)public void removeRedEye(int startX, int startY, int endX, int endY, java.awt.Color newColor)
startX
- the top left corner x value of a rectanglestartY
- the top left corner y value of a rectangleendX
- the bottom right corner x value of a rectangleendY
- the bottom right corner y value of a rectanglenewColor
- the new color to usepublic void sepiaTint()
public void posterize()
public void posterize(int numLevels)
numLevels
- the number of color levels to usepublic void highlightLightAndDark(double amount, java.awt.Color replacementColor)
replacementColor
- the new color to usepublic Picture scaleUp(int numTimes)
public void blur(int numPixels)
numPixels
- the number of pixels to average in all directions
so if the numPixels is 2 then we will average all pixels in the
rectangle defined by 2 before the current pixel to 2 after the
current pixelpublic void edgeDetection(double amount)
amount
- if the absolute value of the differences in the
color average is less than this
set the color to white, else blackpublic void swapBackground(Picture oldBackground, Picture newBackground)
oldBackground
- a picture with the old background to replacenewBackground
- a picture with the new background to usepublic void swapBackground(Picture oldBackground, Picture newBackground, double threshold)
oldBackground
- a picture with the old background to replacenewBackground
- a picture with the new background to usethreshold
- if the distance between the current pixel
color and the background
pixel color is less than this amount use the new background pixel colorpublic void chromakey(Picture newBg)
newBg
- the new background image to use to replace
the blue from the current picturepublic void chromakeyBlue(Picture newBg)
newBg
- the new background image to use to replace
the blue from the current picturepublic void chromakeyRed(Picture newBg)
newBg
- the new background image to use to replace
the red from the current picturepublic void blueOneHundred()
public void blueChange()
public void clearSomeBlue()
public void setBlue()
public int countWhitePixels()
public void drawGrid()
public static Picture addBoxToBeach()
public void drawBox(java.awt.Color color, int topLeftX, int topLeftY, int width, int height)
color
- the color to draw the box withtopLeftX
- the top left x coordinate of the boxtopLeftY
- the top left y coordinate of the boxwidth
- the width of the boxheight
- the height of the boxpublic static Picture drawExample()
public static Picture drawFace()
public void drawString(java.lang.String text, int x, int y)
text
- the string to drawx
- the x location to start aty
- the y location of the baselinepublic void drawHorizontalCenteredString(java.lang.String text, int y)
text
- the string to drawy
- the y location of the baselinepublic static Picture drawGrayEffect()
public static Picture drawFilledRectangles()
public static Picture drawRectangles()
public void drawX(java.awt.Color color)
public void drawWideX(java.awt.Color color, float width)
public Picture rotate(int degrees)
degrees
- the number of degrees to rotate by
public Picture shear(double xFactor, double yFactor)
xFactor
- multiplier to use to shift in x direction based on y indexyFactor
- multiplier to use to shift in y direction based on x index
public Picture scale(double xFactor, double yFactor)
xFactor
- the amount to scale in xyFactor
- the amount to scale in y
public static Picture createComposite()
public void copy(Picture source, int x, int y)
source
- the picture to copyx
- the x of the uppper left corner to copy toy
- the y to the upper left corner to copy topublic void copy2D(Picture source, int x, int y)
source
- the picture to copyx
- the x of the uppper left corner to copy toy
- the y to the upper left corner to copy topublic static Picture overlapPictures(Picture p1, Picture p2, int startOverlap)
p1
- the first picture to displayp2
- the second picture to displaystartOverlap
- the x position where the overlap begins
public void drawSun(int x, int y, int width, int height)
x
- the x location for the upper left corner of the
rectangle enclosing the suny
- the y location for the upper left corner of the
rectangle enclosing the sunwidth
- the width of the enclosing rectangleheight
- the height of the enclosing rectanglepublic Picture clipToEllipse()
public Picture clipToMessage(java.lang.String message)
message
- the message to show
public Picture blendPictures(Picture sourcePict, double sourceAlpha)
sourcePict
- the source picturesourceAlpha
- the amount of the source picture to use
public void copyPicture(Picture sourcePict, java.awt.Rectangle sourceRect, java.awt.Rectangle targetRect, java.awt.Composite composite)
sourcePict
- the source picture to copy fromsourceRect
- the rectangle that describes what area to copy fromtargetRect
- the rectangle that describes what area to copy intocomposite
- the composite to usepublic static void showTurtleMovie()
public static void makeTurtleMovie(java.lang.String outputDirectory)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |