org.openmali.types.twodee
Class Dim2i

java.lang.Object
  extended by org.openmali.types.twodee.Dim2i
All Implemented Interfaces:
Sized2i, Sized2iRO
Direct Known Subclasses:
ExtDim2i

public class Dim2i
extends java.lang.Object
implements Sized2i

A basic 2-dimensional unpositioned rectangle.


Field Summary
protected  boolean isDirty
           
 
Constructor Summary
Dim2i()
          Creates a new 2-dimensional unpositioned rectangle with zero position and size.
Dim2i(int width, int height)
          Creates a new 2-dimensional unpositioned rectangle.
Dim2i(Sized2iRO template)
          Creates a new 2-dimensional unpositioned rectangle and copies the template's coordinates.
 
Method Summary
 Dim2i add(int dw, int dh)
          Adds the deltas to the values.
 Dim2i addH(int dh)
          Adds the deltas to the values.
 Dim2i addW(int dw)
          Adds the deltas to the values.
 boolean equals(java.lang.Object o)
          
 boolean equals(Sized2iRO rect)
           
static Dim2i fromPool()
           
static Dim2i fromPool(int width, int height)
           
 float getAspect()
          
 int getHeight()
           
 int getWidth()
           
 boolean isDirty()
           
 Dim2i scale(int factW, int factH)
          Multiplies the values with these factors.
 Dim2i scaleH(int factH)
          Multiplies the values with these factors.
 Dim2i scaleW(int factW)
          Multiplies the values with these factors.
 Dim2i set(int width, int height)
          Sets this rectangle's coordinates to the given rectangle's ones.
 Dim2i set(Sized2iRO size)
          Sets this rectangle's coordinates to the given rectangle's ones.
 void setClean()
          Marks this object as not dirty.
 void setHeight(int height)
          Sets the height.
 Dim2i setSize(int width, int height)
          Sets the size.
 Dim2i setSize(Sized2iRO size)
          Sets the size.
 Dim2i setSize(Tuple2i size)
          Sets the size.
 void setWidth(int width)
          Sets the width.
static void toPool(Dim2i dim)
           
 java.lang.String toString()
          
 Tuple2i toTuple()
           
<T extends Tuple2i>
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

Dim2i

public Dim2i(int width,
             int height)
Creates a new 2-dimensional unpositioned rectangle.

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

Dim2i

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

Parameters:
template -

Dim2i

public Dim2i()
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 Dim2i setSize(int width,
                     int height)
Sets the size.

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

setWidth

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

Specified by:
setWidth in interface Sized2i

setHeight

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

Specified by:
setHeight in interface Sized2i

getWidth

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

getHeight

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

getAspect

public final float getAspect()

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

setSize

public final Dim2i setSize(Sized2iRO size)
Sets the size.

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

setSize

public final Dim2i setSize(Tuple2i size)
Sets the size.

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

toTuple

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

toTuple

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

set

public final Dim2i set(int width,
                       int 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 Dim2i set(Sized2iRO size)
Sets this rectangle's coordinates to the given rectangle's ones.

Parameters:
size -

add

public final Dim2i add(int dw,
                       int dh)
Adds the deltas to the values.

Parameters:
dw -
dh -

addW

public final Dim2i addW(int dw)
Adds the deltas to the values.

Parameters:
dw -

addH

public final Dim2i addH(int dh)
Adds the deltas to the values.

Parameters:
dh -

scale

public final Dim2i scale(int factW,
                         int factH)
Multiplies the values with these factors.

Parameters:
factW -
factH -

scaleW

public final Dim2i scaleW(int factW)
Multiplies the values with these factors.

Parameters:
factW -

scaleH

public final Dim2i scaleH(int factH)
Multiplies the values with these factors.

Parameters:
factH -

equals

public boolean equals(Sized2iRO 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 Dim2i fromPool()

fromPool

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

toPool

public static final void toPool(Dim2i dim)