All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sg.Pixel

java.lang.Object
   |
   +----sg.Pixel

public class Pixel
extends Object
The class Pixel defines an object representing the coordinates of a pixel for a simple graphics device. In a pixel coordinate system the x-coordinate increases as the pixel moves horzionally to the right, and the y-coordinate increases as the pixel moves vertically down.


Constructor Index

 o Pixel()
Constructs and initializes a Pixel initialized with (0, 0).
 o Pixel(int, int)
Constructs and initializes a Pixel from the specified x and y coordinates.
 o Pixel(Pixel)
Constructs and initializes a Pixel with the same location as the specified Pixel.

Method Index

 o equals(Pixel)
Checks whether two pixels are equal.
 o move(int, int)
Moves the pixel to the specified location.
 o toString()
Returns the String representation of the object Pixel.
 o translate(int, int)
Translates the pixel.

Constructors

 o Pixel
 public Pixel()
Constructs and initializes a Pixel initialized with (0, 0).

 o Pixel
 public Pixel(Pixel p) throws PixelException
Constructs and initializes a Pixel with the same location as the specified Pixel.

Parameters:
p - a pixel
Throws: PixelException
Throws exception if either coordinate of the pixel is negative.
 o Pixel
 public Pixel(int x,
              int y) throws PixelException
Constructs and initializes a Pixel from the specified x and y coordinates.

Parameters:
x - the x coordinate
y - the y coordinate
Throws: PixelException
Throws exception if either coordinate, x or y, is negative.

Methods

 o move
 public void move(int x,
                  int y)
Moves the pixel to the specified location.

Parameters:
x - the x coordinate of the new location
y - the y coordinate of the new location
Returns:
void
 o translate
 public void translate(int x,
                       int y)
Translates the pixel.

Parameters:
x - translate the x coordinate by this value
y - translate the y coordinate by this value
Returns:
void
 o equals
 public boolean equals(Pixel p)
Checks whether two pixels are equal.

Parameters:
p - check to see if object is equal to p.
Returns:
true if the coordinates of the two pixels are equal; false otherwise.
 o toString
 public String toString()
Returns the String representation of the object Pixel.

Returns:
String
Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index