auc.simulator.relatcoord
Class CoordManager

java.lang.Object
  |
  +--auc.simulator.relatcoord.CoordManager

public class CoordManager
extends java.lang.Object

A class responsible for absolute/relative coordinate conversion and manipulation.


Constructor Summary
CoordManager()
          Construction, nothing really happens here ...
 
Method Summary
 int _dx(int position)
          Converts absolute coordinates to relative (x value).
 int _dy(int position)
          Converts absolute coordinates to relative (y value).
 void addCoordManagerListener(CoordManagerListener coordManagerListener)
          Adds a coord listener to this coord manager.
 double d(double position)
          Converts relative coordinates to absolute.
 int d(float position)
          Converts relative coordinates to absolute.
 int d(int position)
          Converts relative coordinates to absolute.
 int getHeight()
          Returns the height of the component whose coords are managed by this coord manager (relative coords).
 java.awt.Point getOrigin()
          Returns origin for coord management (relative coords).
 java.awt.Point getShift()
          Returns the shift point of the coord system.
 int getSideSize()
          Returns the size of the smaller side of the drawing area.
 int getWidth()
          Returns the width of the component whose coords are managed by this coord manager (relative coords).
 void scaleToHeight(int height)
          Scales the drawing area so that it would be equal to the specified height.
 void scaleToWidth(int width)
          Scales the drawing area so that it would be equal to the specified width.
 void setOrigin(java.awt.Point origin)
          Sets the origin for coord management (relative coords).
 void setShift(java.awt.Point shift)
          Sets the shift point of the coord system.
 void setSideSize(int size)
          Set the size of the smaller side of the drawing area.
 java.awt.Point updatePointCoords(java.awt.Point p)
          Accepts a point in relative coordinates and returns a new point having absolute coordinates.
 Vector2D updatePointCoords(Vector2D p)
          Accepts a point in relative coordinates and returns a new point having absolute coordinates.
 java.awt.Polygon updatePolygonCoords(java.awt.Polygon p)
          Accepts a polygon in relative coordinates and returns a new polygon having absolute coordinates.
 java.awt.Rectangle updateRectangleCoords(java.awt.Rectangle rect)
          Accepts a rectangle in relative coordinates and returns a new rectangle having absolute coordinates.
 void updateRelativeCoords(CoordManageable coordProvider)
          This method should be called when the size of the coordinate provider (a drawing area) changes and relative coordinates have to be recalculated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoordManager

public CoordManager()
Construction, nothing really happens here ...
Method Detail

addCoordManagerListener

public void addCoordManagerListener(CoordManagerListener coordManagerListener)
Adds a coord listener to this coord manager.
Parameters:
coordManagerListener - listener of the coordinate changes.

updateRelativeCoords

public void updateRelativeCoords(CoordManageable coordProvider)
This method should be called when the size of the coordinate provider (a drawing area) changes and relative coordinates have to be recalculated.
Parameters:
coordProvider - drawing area that implements the CoordmManageable interface.

d

public int d(int position)
Converts relative coordinates to absolute. Suits for both x and y coords. Integer version, doesn't take into account origin and shift values.
Parameters:
position - the value of the relative coordinate.
Returns:
the value of the absolute coordinate.

d

public int d(float position)
Converts relative coordinates to absolute. Suits for both x and y coords. Floating version, doesn't take into account origin and shift values.
Parameters:
position - the value of the relative coordinate.
Returns:
the value of the absolute coordinate.

d

public double d(double position)
Converts relative coordinates to absolute. Suits for both x and y coords. Double version, doesn't take into account origin and shift values.
Parameters:
position - the value of the relative coordinate.
Returns:
the value of the absolute coordinate.

_dx

public int _dx(int position)
Converts absolute coordinates to relative (x value). Origin and shift values are taken into account.
Parameters:
position - the value of the absolute coordinate.
Returns:
the value of the relative coordinate.

_dy

public int _dy(int position)
Converts absolute coordinates to relative (y value). Origin and shift values are taken into account.
Parameters:
position - the value of the absolute coordinate.
Returns:
the value of the relative coordinate.

updatePolygonCoords

public java.awt.Polygon updatePolygonCoords(java.awt.Polygon p)
Accepts a polygon in relative coordinates and returns a new polygon having absolute coordinates.
Parameters:
p - polygon having relative coordinates.
Returns:
polygon having absolute coordinates.

updatePointCoords

public java.awt.Point updatePointCoords(java.awt.Point p)
Accepts a point in relative coordinates and returns a new point having absolute coordinates.
Parameters:
p - point having relative coordinates.
Returns:
point having absolute coordinates.

updatePointCoords

public Vector2D updatePointCoords(Vector2D p)
Accepts a point in relative coordinates and returns a new point having absolute coordinates.
Parameters:
p - point having relative coordinates.
Returns:
point having absolute coordinates.

updateRectangleCoords

public java.awt.Rectangle updateRectangleCoords(java.awt.Rectangle rect)
Accepts a rectangle in relative coordinates and returns a new rectangle having absolute coordinates.
Parameters:
rect - rectangle having relative coordinates.
Returns:
rectangle having absolute coordinates.

getHeight

public int getHeight()
Returns the height of the component whose coords are managed by this coord manager (relative coords).
Returns:
the height of the component.

getWidth

public int getWidth()
Returns the width of the component whose coords are managed by this coord manager (relative coords).
Returns:
the width of the component.

setOrigin

public void setOrigin(java.awt.Point origin)
Sets the origin for coord management (relative coords).
Parameters:
origin - the origin of the coord system.

getOrigin

public java.awt.Point getOrigin()
Returns origin for coord management (relative coords).
Returns:
the origin of the coord system.

setSideSize

public void setSideSize(int size)
Set the size of the smaller side of the drawing area.
Parameters:
size - the size of the side.

getSideSize

public int getSideSize()
Returns the size of the smaller side of the drawing area.
Returns:
the size of the side.

setShift

public void setShift(java.awt.Point shift)
Sets the shift point of the coord system.
Parameters:
shift - the shift point.

getShift

public java.awt.Point getShift()
Returns the shift point of the coord system.
Returns:
the shift point.

scaleToWidth

public void scaleToWidth(int width)
Scales the drawing area so that it would be equal to the specified width.
Parameters:
width - the new width of the drawing area.

scaleToHeight

public void scaleToHeight(int height)
Scales the drawing area so that it would be equal to the specified height.
Parameters:
height - the new height of the drawing area.