Class ITrapezoid

java.lang.Object
  |
  +--ITrapezoid
All Implemented Interfaces:
ITrapez

class ITrapezoid
extends java.lang.Object
implements ITrapez

This class implements ITrapez and manage creating and managing Trapezim


Field Summary
(package private)  IPoint ne
          North-East vertex
(package private)  IPoint nw
          North-West vertex
(package private)  IPoint se
          South-East vertex
(package private)  IPoint sw
          South-West vertex
 
Fields inherited from interface ITrapez
NE, NONE, NW, SE, SW
 
Constructor Summary
ITrapezoid(int nwX, int nwY, int swX, int swY, int seX, int seY, int neX, int neY)
          Construct a new ITrapezoid with the specified x,y
ITrapezoid(IPoint nw, IPoint sw, int northernEdgeWidth, int southernEdgeWidth)
          Construct a new ITrapezoid with the given vertices and widths
ITrapezoid(IPoint nw, IPoint sw, IPoint se, IPoint ne)
          Construct a new ITrapezoid with the specified vertices
 
Method Summary
 IPoint getVertex(int position)
          Return the vertex that is associated with the given position.
 void move(int deltaX, int deltaY)
          Construct a new circle with the specified center, radius and color
 void reshape(int position, int deltaX, int deltaY)
          Reshape this ITrapezoid according to the given parameters.
 int whichVertex(IPoint v)
          If the given IPoint vertex is one of this ITrapezoid's vertices then return its position within this ITrapezoid, otherwise return NONE.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

nw

IPoint nw
North-West vertex

sw

IPoint sw
South-West vertex

se

IPoint se
South-East vertex

ne

IPoint ne
North-East vertex
Constructor Detail

ITrapezoid

public ITrapezoid(int nwX,
                  int nwY,
                  int swX,
                  int swY,
                  int seX,
                  int seY,
                  int neX,
                  int neY)
Construct a new ITrapezoid with the specified x,y
Parameters:
nwX - the X position of the North-West vertex
nwY - the Y position of the North-West vertex
swX - the X position of the South-West vertex
swY - the Y position of the South-West vertex
seX - the X position of the South-East vertex
seY - the Y position of the South-East vertex
neX - the X position of the North-East vertex
neY - the Y position of the North-East vertex

ITrapezoid

public ITrapezoid(IPoint nw,
                  IPoint sw,
                  IPoint se,
                  IPoint ne)
Construct a new ITrapezoid with the specified vertices
Parameters:
nw - an IPoint (x,y) of the North-West vertex
sw - an IPoint (x,y) of the South-West vertex
se - an IPoint (x,y) of the South-East vertex
ne - an IPoint (x,y) of the North-East vertex

ITrapezoid

public ITrapezoid(IPoint nw,
                  IPoint sw,
                  int northernEdgeWidth,
                  int southernEdgeWidth)
Construct a new ITrapezoid with the given vertices and widths
Parameters:
nw - an IPoint (x,y) of the North-West vertex
sw - an IPoint (x,y) of the South-West vertex
northernEdgeWidth - the width of the northern edge
southernEdgeWidth - the width of the southern edge
Method Detail

move

public void move(int deltaX,
                 int deltaY)
Construct a new circle with the specified center, radius and color
Specified by:
move in interface ITrapez
Parameters:
center - a 2D point representing the center
radius - a float representing the radius
shapeColor - the color of the circle

whichVertex

public int whichVertex(IPoint v)
If the given IPoint vertex is one of this ITrapezoid's vertices then return its position within this ITrapezoid, otherwise return NONE.
Specified by:
whichVertex in interface ITrapez
Parameters:
v - an IPoint (x,y value) representing a position
Returns:
the number of a vertex if found or NONE if not.

getVertex

public IPoint getVertex(int position)
Return the vertex that is associated with the given position. 'position' must be one of: NW, SW, SE, NE.
Specified by:
getVertex in interface ITrapez
Parameters:
position - 1 - 4, indicating one of the vertices
Returns:
an IPoint (x,y values) of given vertex

reshape

public void reshape(int position,
                    int deltaX,
                    int deltaY)
Reshape this ITrapezoid according to the given parameters. The specified vertex is moved according to the given parameters. All the other vertices move accordingly so that the trapezoid will remain X-aligned.
Specified by:
reshape in interface ITrapez
Parameters:
position - 1 - 4, indicating one of the vertices
deltaX - the delta on the X asix
deltaY - the delta on the Y asix