Class Pixel

java.lang.Object
  extended by Pixel

public class Pixel
extends Object

The Pixel is the underlying data-structure in a Picture. Each Pixel represents a color, stored as separate integer values for red, green and blue. Each value is between 0 and 255. Collectively, these RGB (Red-Green-Blue) values form the color of the Pixel.

Author:
Richard Wicentowski

Constructor Summary
Pixel(int r, int g, int b)
          Create a Pixel with the specified RGB values.
 
Method Summary
 boolean equals(Object other)
          Determine if this Pixel is equal to another Object.
 int getBlue()
          Returns the blue component of the Pixel.
 int[] getComponents()
          Returns the RGB components of this Pixel as a 3-place int array.
 int getGreen()
          Returns the green component of the Pixel.
 int getRed()
          Returns the red component of the Pixel.
 void setBlue(int blue)
          Set the blue component of the Pixel.
 void setGreen(int green)
          Set the green component of the Pixel.
 void setRed(int red)
          Set the red component of the Pixel.
 String toString()
          Return the String representation of this Pixel as a triple (R, G, B).
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Pixel

public Pixel(int r,
             int g,
             int b)
Create a Pixel with the specified RGB values.

Parameters:
r - the red component of the Pixel
g - the green component of the Pixel
b - the blue component of the Pixel
Method Detail

getRed

public int getRed()
Returns the red component of the Pixel.

Returns:
the red component of the Pixel.

getGreen

public int getGreen()
Returns the green component of the Pixel.

Returns:
the green component of the Pixel.

getBlue

public int getBlue()
Returns the blue component of the Pixel.

Returns:
the blue component of the Pixel.

setRed

public void setRed(int red)
Set the red component of the Pixel.

Parameters:
red - the new value of this Pixel's red component.

setGreen

public void setGreen(int green)
Set the green component of the Pixel.

Parameters:
green - the new value of this Pixel's green component.

setBlue

public void setBlue(int blue)
Set the blue component of the Pixel.

Parameters:
blue - the new value of this Pixel's blue component.

getComponents

public int[] getComponents()
Returns the RGB components of this Pixel as a 3-place int array.

Returns:
the RGB components of this Pixel as a 3-place int array.

toString

public String toString()
Return the String representation of this Pixel as a triple (R, G, B).

Overrides:
toString in class Object
Returns:
the String representation of this Pixel.

equals

public boolean equals(Object other)
Determine if this Pixel is equal to another Object.

Overrides:
equals in class Object
Returns:
true if every component has the same value; false otherwise.