com.miginfocom.util.gfx.geometry
Class AtPoint

java.lang.Object
  extended by com.miginfocom.util.gfx.geometry.AtPoint
All Implemented Interfaces:
java.io.Serializable

public class AtPoint
extends java.lang.Object
implements java.io.Serializable

Similar to Point2D but is immutable and much more flexible. The biggest difference is that this point has optional in- and/or out vectors, making it ideal to use as a node in a curve/b-spline.
Also since the x and y is a AtNumber the point can be relative to something else, even somthing that isn't static. This means, for instance, that a AtPoint can describe a point that is 10 pixels to the right and twenty pixels above the lower left corner of some other shape. Or in the middle of a PolygonShape.

See Also:
AtNumber, PolygonShape, RefPoint, ShapeLinkNumber, AbsRect, Serialized Form

Constructor Summary
AtPoint(AtNumber x, AtNumber y)
          Constructor.
AtPoint(AtNumber x, AtNumber y, float inCtrlDeltaX, float inCtrlDeltaY, float outCtrlDeltaX, float outCtrlDeltaY)
          Constructor for an absolute positioned point.
AtPoint(AtNumber x, AtNumber y, RefPoint inCtrlPoint, RefPoint outCtrlPoint)
          Constructor.
AtPoint(float x, float y)
          Constructor for an absolute positioned point.
AtPoint(float x, float y, float inCtrlDeltaX, float inCtrlDeltaY, float outCtrlDeltaX, float outCtrlDeltaY)
          Constructor for an absolute positioned point.
 
Method Summary
 void calculate(float[] coords)
          Fills in an array ordered: [x, y, inCtrlPoint.x, inCtrlPoint.y, outCtrlPoint.x, outCtrlPoint.y].
 boolean equals(java.lang.Object o)
           
 RefPoint getInCtrlPoint()
          Returns the "incoming" control point.
 RefPoint getOutCtrlPoint()
          Returns the "outgoing" control point.
 AtNumber getXNumber()
           
 AtNumber getYNumber()
           
 boolean hasInCtrlPoint()
          Returns if this point has an in ctrl point.
 boolean hasOutCtrlPoint()
          Returns if this point has an in ctrl point.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AtPoint

public AtPoint(float x,
               float y)
Constructor for an absolute positioned point.

Parameters:
x - The x value. (Simply wrapped to new RefValue(x))
y - The y value. (Simply wrapped to new RefValue(y))

AtPoint

public AtPoint(float x,
               float y,
               float inCtrlDeltaX,
               float inCtrlDeltaY,
               float outCtrlDeltaX,
               float outCtrlDeltaY)
Constructor for an absolute positioned point.

Parameters:
x - The x value. (Simply wrapped to new RefValue(x))
y - The y value. (Simply wrapped to new RefValue(y))
inCtrlDeltaX - The delta x-value if the incoming control point. (x will be added to the value to get the absolute coordinate).
If both this and inCtrlDeltaY is 0f no in ctrl point will be set.
inCtrlDeltaY - The delta y-value if the incoming control point. (y will be added to the value to get the absolute coordinate).
If both this and inCtrlDeltaX is 0f no in ctrl point will be set.
outCtrlDeltaX - The delta x-value if the outgoing control point. (x will be added to the value to get the absolute coordinate).
If both this and outCtrlDeltaY is 0f no out ctrl point will be set.
outCtrlDeltaY - The delta y-value if the outgoing control point. (y will be added to the value to get the absolute coordinate).
If both this and outCtrlDeltaX is 0f no out ctrl point will be set.

AtPoint

public AtPoint(AtNumber x,
               AtNumber y,
               float inCtrlDeltaX,
               float inCtrlDeltaY,
               float outCtrlDeltaX,
               float outCtrlDeltaY)
Constructor for an absolute positioned point.

Parameters:
x - The x value. (Simply wrapped to new RefValue(x))
y - The y value. (Simply wrapped to new RefValue(y))
inCtrlDeltaX - The delta x-value if the incoming control point. (x will be added to the value to get the absolute coordinate).
If both this and inCtrlDeltaY is 0f no in ctrl point will be set.
inCtrlDeltaY - The delta y-value if the incoming control point. (y will be added to the value to get the absolute coordinate).
If both this and inCtrlDeltaX is 0f no in ctrl point will be set.
outCtrlDeltaX - The delta x-value if the outgoing control point. (x will be added to the value to get the absolute coordinate).
If both this and outCtrlDeltaY is 0f no out ctrl point will be set.
outCtrlDeltaY - The delta y-value if the outgoing control point. (y will be added to the value to get the absolute coordinate).
If both this and outCtrlDeltaX is 0f no out ctrl point will be set.

AtPoint

public AtPoint(AtNumber x,
               AtNumber y)
Constructor.

Parameters:
x - The x value. Object overtaken and not cloned.
y - The y value. Object overtaken and not cloned.

AtPoint

public AtPoint(AtNumber x,
               AtNumber y,
               RefPoint inCtrlPoint,
               RefPoint outCtrlPoint)
Constructor.

Parameters:
x - The x value. Object overtaken and not cloned.
y - The y value. Object overtaken and not cloned.
inCtrlPoint - The "incoming" control point. if != null this point is used as a control point for the curve between the point "before this one" (normally in a PolygonShape). Mathematically it represents the incoming differentiate in this point. If null this point imposes no direction of the incoming "line" or curve.
outCtrlPoint - The "outgoing" control point. if != null this point is used as a control point for the curve between the point "after this one" (normally in a PolygonShape). Mathematically it represents the outgoing differentiate in this point. If null this point imposes no direction of the outgoing "line" or curve.
Method Detail

calculate

public final void calculate(float[] coords)
Fills in an array ordered: [x, y, inCtrlPoint.x, inCtrlPoint.y, outCtrlPoint.x, outCtrlPoint.y]. The same results can be obtained by getting the point and control point themselves but this method resolves them faster. If the in and/or out control points doesn't exist the corresponding elements will contain an undefined value.

Parameters:
coords - Array of at least length 6. Will be modified.
See Also:
hasInCtrlPoint(), hasOutCtrlPoint()

hasInCtrlPoint

public final boolean hasInCtrlPoint()
Returns if this point has an in ctrl point.

Returns:
true if there exists an in ctrl point.

hasOutCtrlPoint

public final boolean hasOutCtrlPoint()
Returns if this point has an in ctrl point.

Returns:
true if there exists an in ctrl point.

getInCtrlPoint

public final RefPoint getInCtrlPoint()
Returns the "incoming" control point. if != null this point is used as a control point for the curve between the point "before this one" (normally in a PolygonShape). Mathematically it represents the incoming differentiate in this point. If null this point imposes no direction of the incoming "line" or curve.

Returns:
The "incoming" control point. May be null.

getOutCtrlPoint

public final RefPoint getOutCtrlPoint()
Returns the "outgoing" control point. if != null this point is used as a control point for the curve between the point "after this one" (normally in a PolygonShape). Mathematically it represents the outgoing differentiate in this point. If null this point imposes no direction of the outgoing "line" or curve.

Returns:
The "outgoing" control point. May be null.

getXNumber

public final AtNumber getXNumber()

getYNumber

public final AtNumber getYNumber()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.