org.openmali.types.twodee
Class Dim2f

java.lang.Object
  extended by org.openmali.types.twodee.Dim2f
All Implemented Interfaces:
Sized2f, Sized2fRO
Direct Known Subclasses:
ExtDim2f

public class Dim2f
extends java.lang.Object
implements Sized2f

A basic 2-dimensional unpositioned rectangle.


Field Summary
protected  boolean isDirty
           
 
Constructor Summary
Dim2f()
          Creates a new 2-dimensional unpositioned rectangle with zero position and size.
Dim2f(float width, float height)
          Creates a new 2-dimensional unpositioned rectangle.
Dim2f(Sized2fRO template)
          Creates a new 2-dimensional unpositioned rectangle and copies the template's coordinates.
 
Method Summary
 Dim2f add(float dw, float dh)
          Adds the deltas to the values.
 Dim2f addH(float dh)
          Adds the deltas to the values.
 Dim2f addW(float dw)
          Adds the deltas to the values.
 boolean equals(java.lang.Object o)
          
 boolean equals(Sized2fRO rect)
           
static Dim2f fromPool()
           
static Dim2f fromPool(int width, int height)
           
 float getAspect()
          
 float getHeight()
           
 float getWidth()
           
 boolean isDirty()
           
 Dim2f scale(float factW, float factH)
          Multiplies the values with these factors.
 Dim2f scaleH(float factH)
          Multiplies the values with these factors.
 Dim2f scaleW(float factW)
          Multiplies the values with these factors.
 Dim2f set(float width, float height)
          Sets this rectangle's coordinates to the given rectangle's ones.
 Dim2f set(Sized2fRO size)
          Sets this rectangle's coordinates to the given rectangle's ones.
 void setClean()
          Marks this object as not dirty.
 void setHeight(float height)
          Sets the height.
 Dim2f setSize(float width, float height)
          Sets the size.
 Dim2f setSize(Sized2fRO size)
          Sets the size.
 Dim2f setSize(Tuple2f size)
          Sets the size.
 void setWidth(float width)
          Sets the width.
static void toPool(Dim2f dim)
           
 java.lang.String toString()
          
 Tuple2f toTuple()
           
<T extends Tuple2f>
T
toTuple(T tuple)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

isDirty

protected boolean isDirty
Constructor Detail

Dim2f

public Dim2f(float width,
             float height)
Creates a new 2-dimensional unpositioned rectangle.

Parameters:
width - the rectangle's width
height - the rectangle's height

Dim2f

public Dim2f(Sized2fRO template)
Creates a new 2-dimensional unpositioned rectangle and copies the template's coordinates.

Parameters:
template -

Dim2f

public Dim2f()
Creates a new 2-dimensional unpositioned rectangle with zero position and size.

Method Detail

isDirty

public final boolean isDirty()
Returns:
true, if this object has been modified since the last setClean() call.
See Also:
setClean()

setClean

public void setClean()
Marks this object as not dirty.


setSize

public Dim2f setSize(float width,
                     float height)
Sets the size.

Specified by:
setSize in interface Sized2f
Returns:
this instance back again.

setWidth

public final void setWidth(float width)
Sets the width.

Specified by:
setWidth in interface Sized2f

setHeight

public final void setHeight(float height)
Sets the height.

Specified by:
setHeight in interface Sized2f

getWidth

public final float getWidth()
Specified by:
getWidth in interface Sized2fRO
Returns:
the rectangle's width

getHeight

public final float getHeight()
Specified by:
getHeight in interface Sized2fRO
Returns:
the rectangle's height

getAspect

public final float getAspect()

Specified by:
getAspect in interface Sized2fRO
Returns:
the aspect ratio calculated by (getWidth() / getHeight()). If getHeight() is 0, 0 is returned.

setSize

public final Dim2f setSize(Sized2fRO size)
Sets the size.

Specified by:
setSize in interface Sized2f
Returns:
this instance back again.

setSize

public final Dim2f setSize(Tuple2f size)
Sets the size.

Specified by:
setSize in interface Sized2f
Returns:
this instance back again.

toTuple

public <T extends Tuple2f> T toTuple(T tuple)
Returns:
this size as a tuple.

toTuple

public Tuple2f toTuple()
Returns:
this size as a tuple.

set

public final Dim2f set(float width,
                       float height)
Sets this rectangle's coordinates to the given rectangle's ones.

Parameters:
width - the rectangle's width
height - the rectangle's height

set

public final Dim2f set(Sized2fRO size)
Sets this rectangle's coordinates to the given rectangle's ones.

Parameters:
size -

add

public final Dim2f add(float dw,
                       float dh)
Adds the deltas to the values.

Parameters:
dw -
dh -

addW

public final Dim2f addW(float dw)
Adds the deltas to the values.

Parameters:
dw -

addH

public final Dim2f addH(float dh)
Adds the deltas to the values.

Parameters:
dh -

scale

public final Dim2f scale(float factW,
                         float factH)
Multiplies the values with these factors.

Parameters:
factW -
factH -

scaleW

public final Dim2f scaleW(float factW)
Multiplies the values with these factors.

Parameters:
factW -

scaleH

public final Dim2f scaleH(float factH)
Multiplies the values with these factors.

Parameters:
factH -

equals

public boolean equals(Sized2fRO rect)

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

fromPool

public static final Dim2f fromPool()

fromPool

public static final Dim2f fromPool(int width,
                                   int height)

toPool

public static final void toPool(Dim2f dim)