com.miginfocom.util.gfx.geometry.links
Class ShapeLinkNumber

java.lang.Object
  extended by com.miginfocom.util.gfx.geometry.links.BoundsLinkNumber
      extended by com.miginfocom.util.gfx.geometry.links.ShapeLinkNumber
All Implemented Interfaces:
AtNumber, AtRefNumber, AtRefRangeNumber, java.io.Serializable
Direct Known Subclasses:
PolyLinkNumber

public class ShapeLinkNumber
extends BoundsLinkNumber

A link to some part of the bounds of a Shape. This base class only links to the bounds of the shape, either absolute or relative.

Since Shape.getBounds2D() always creates a new Rectangle to return, this generic class can create a lot of garbage for some sitiuations (one for each call to #get). Subclasses may improve upon this since they can override the methods and return the values possibly without always calling Shape.getBounds2D(). For instance PolyLinkNumber does this.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.miginfocom.util.gfx.geometry.links.BoundsLinkNumber
align, dim, X, Y
 
Constructor Summary
ShapeLinkNumber(java.awt.Shape shape, AtRefRangeNumber align, int dim)
          Constructor for a relative (percentage) value.
 
Method Summary
 boolean equals(java.lang.Object o)
           
protected  float getHorizontalValue(AtRefRangeNumber align)
          Uses the horizontal start and end value to get the value.
 java.awt.Shape getShape()
          Returns the shape.
protected  float getVerticalValue(AtRefRangeNumber align)
          Uses the vertival start and end value to get the value.
 java.lang.String toString()
           
 
Methods inherited from class com.miginfocom.util.gfx.geometry.links.BoundsLinkNumber
getAlign, getDimension, getIntValue, getIntValue, getIntValue, getValue, getValue, getValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ShapeLinkNumber

public ShapeLinkNumber(java.awt.Shape shape,
                       AtRefRangeNumber align,
                       int dim)
Constructor for a relative (percentage) value.

Parameters:
shape - The shape which's bounds to link to.
align - If the value that this link represents. Can be relative to the left, right or both bounds edges of the shape. The start and end position in dim will be ussed to get the value.
dim - The dimension. ShapeLinkNumber.X or ShapeLinkNumber.Y.
Method Detail

getHorizontalValue

protected float getHorizontalValue(AtRefRangeNumber align)
Description copied from class: BoundsLinkNumber
Uses the horizontal start and end value to get the value.

Specified by:
getHorizontalValue in class BoundsLinkNumber
Parameters:
align - The value to call AtRefRangeNumber.getValue(float, float) on.
Returns:
The value that getValue returns.

getVerticalValue

protected float getVerticalValue(AtRefRangeNumber align)
Description copied from class: BoundsLinkNumber
Uses the vertival start and end value to get the value.

Specified by:
getVerticalValue in class BoundsLinkNumber
Parameters:
align - The value to call AtRefRangeNumber.getValue(float, float) on.
Returns:
The value that getValue returns.

getShape

public java.awt.Shape getShape()
Returns the shape.

Returns:
he shape. Not null.

toString

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

equals

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


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.