com.miginfocom.util.gfx.geometry
Class AlignRect

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

public final class AlignRect
extends java.lang.Object
implements PlaceRect

The align rect solves the (almost) only use case that AbsRect can't solve; aligning something that already has a certain size, such as an image or icon within the reference rectangle.

If you have an AShape for instance and wants to align that within some bounds, using the native size as the size, and thus not specifying the size explicitly, as normal with AbsRect, you should use this class.

See Also:
Serialized Form

Constructor Summary
AlignRect(AtRefRangeNumber xAlign, AtRefRangeNumber yAlign)
          Constructor.
AlignRect(AtRefRangeNumber xAlign, AtRefRangeNumber yAlign, java.awt.Insets resize)
          Constructor.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 java.awt.Rectangle getRect(java.awt.Rectangle r)
          Since this mothod doesn't take a referentioal size it's useless here.
 java.awt.Rectangle getRect(java.awt.Rectangle r, java.awt.Dimension refSize)
          Returns a rectangle that might be translated, scaled and checked for max/min bounds.
 java.awt.Insets getResize()
           
 AtRefRangeNumber getXAlign()
           
 AtRefRangeNumber getYAlign()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AlignRect

public AlignRect(AtRefRangeNumber xAlign,
                 AtRefRangeNumber yAlign)
Constructor.

Parameters:
xAlign - The x alignment. E.g. AtFraction(0.5f) or AtStart(10f). Not null.
yAlign - The y alignment. E.g. AtFraction(1f) or AtEnd(-10f). Not null.

AlignRect

public AlignRect(AtRefRangeNumber xAlign,
                 AtRefRangeNumber yAlign,
                 java.awt.Insets resize)
Constructor.

Parameters:
xAlign - The x alignment. E.g. AtFraction(0.5f) or AtStart(10f). Not null.
yAlign - The y alignment. E.g. AtFraction(1f) or AtEnd(-10f). Not null.
resize - If non-null resizes the rectangle with an absolute number of pixels at the last stage. Positive values enlarges the rectangle. Object is cloned for local storage.
Method Detail

getRect

public java.awt.Rectangle getRect(java.awt.Rectangle r)
Since this mothod doesn't take a referentioal size it's useless here. r is returned directly.

Specified by:
getRect in interface PlaceRect
Parameters:
r - Returned
Returns:
r

getRect

public java.awt.Rectangle getRect(java.awt.Rectangle r,
                                  java.awt.Dimension refSize)
Description copied from interface: PlaceRect
Returns a rectangle that might be translated, scaled and checked for max/min bounds.

Specified by:
getRect in interface PlaceRect
Parameters:
r - The rectangle that is to be used as the source. Not null. Will not be changed.
refSize - If x1, y1, x2 and/or y2 is null (in this)) the horizontal/vertical size if taken from this dimension instead. If null the size is taken from r.
This can for instance be the size on an Image that you are trying to alighn within some bounds.
Returns:
A new rectangle. Never null.

getXAlign

public AtRefRangeNumber getXAlign()

getYAlign

public AtRefRangeNumber getYAlign()

getResize

public java.awt.Insets getResize()

equals

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

toString

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


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.