|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Pixel
public class Pixel
Class that references a pixel in a picture. A pixel has an x and y location in a picture. A pixel knows how to get and set the red, green, blue, and alpha values in the picture. A pixel also knows how to get and set the color using a Color object.
Constructor Summary | |
---|---|
Pixel(DigitalPicture picture,
int x,
int y)
A constructor that take the x and y location for the pixel and the picture the pixel is coming from |
Method Summary | |
---|---|
double |
colorDistance(Color testColor)
Method to get the distance between this pixel's color and the passed color |
static double |
colorDistance(Color color1,
Color color2)
Method to compute the color distances between two color objects |
int |
getAlpha()
Method to get the amount of alpha (transparency) at this pixel. |
double |
getAverage()
Method to get the average of the colors of this pixel |
int |
getBlue()
Method to get the amount of blue at this pixel. |
static int |
getBlue(int value)
Method to get the blue value from a pixel represented as an int |
Color |
getColor()
Method to get a color object that represents the color at this pixel. |
int |
getGreen()
Method to get the amount of green at this pixel. |
static int |
getGreen(int value)
Method to get the green value from a pixel represented as an int |
Color |
getMostCommonColorInRange(int dist)
Method to return the most common color in the given range from the current pixel in the picture or just return this color. |
int |
getRed()
Method to get the amount of red at this pixel. |
static int |
getRed(int value)
Method to get the red value from a pixel represented as an int |
int |
getX()
Method to get the x location of this pixel. |
int |
getY()
Method to get the y location of this pixel. |
void |
setAlpha(int value)
Method to set the alpha (transparency) to a new alpha value |
void |
setBlue(int value)
Method to set the blue to a new blue value |
void |
setColor(Color newColor)
Method to set the pixel color to the passed in color object. |
void |
setGreen(int value)
Method to set the green to a new green value |
void |
setRed(int value)
Method to set the red to a new red value |
String |
toString()
Method to return a string with information about this pixel |
void |
updatePicture(int alpha,
int red,
int green,
int blue)
Method to update the picture based on the passed color values for this pixel |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Pixel(DigitalPicture picture, int x, int y)
picture
- the picture that the pixel is inx
- the x location of the pixel in the picturey
- the y location of the pixel in the pictureMethod Detail |
---|
public int getX()
public int getY()
public int getAlpha()
public int getRed()
public static int getRed(int value)
value
- the color value as an int
public int getGreen()
public static int getGreen(int value)
value
- the color value as an int
public int getBlue()
public static int getBlue(int value)
value
- the color value as an int
public Color getColor()
public void setColor(Color newColor)
newColor
- the new color to usepublic void updatePicture(int alpha, int red, int green, int blue)
alpha
- the alpha (transparency) at this pixelred
- the red value for the color at this pixelgreen
- the green value for the color at this pixelblue
- the blue value for the color at this pixelpublic void setRed(int value)
value
- the new value to usepublic void setGreen(int value)
value
- the value to usepublic void setBlue(int value)
value
- the new value to usepublic void setAlpha(int value)
value
- the new value to usepublic double colorDistance(Color testColor)
testColor
- the color to compare to
public static double colorDistance(Color color1, Color color2)
color1
- a color objectcolor2
- a color object
public double getAverage()
public String toString()
toString
in class Object
public Color getMostCommonColorInRange(int dist)
dist
- the distance to use for the range
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |