com.miginfocom.util.gfx.geometry.numbers
Class AtFraction

java.lang.Object
  extended by com.miginfocom.util.gfx.geometry.numbers.AtFraction
All Implemented Interfaces:
AtRefNumber, AtRefRangeNumber, java.io.Serializable

public final class AtFraction
extends java.lang.Object
implements AtRefNumber

A value that is a aligned somewhere between start and end. Basically returns start + (end - start) * f. E.g. 0.3f is 30% from start.

See Also:
Serialized Form

Field Summary
static AtFraction CENTER
          Same as new AtFraction(0.5f) but can be used to avoid creating new objects.
static AtFraction END
          Same as new AtFraction(1f) but can be used to avoid creating new objects.
static AtFraction START
          Same as new AtFraction(0f) but can be used to avoid creating new objects.
 
Constructor Summary
AtFraction(float p)
          Constructor.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 float getFraction()
          Returns the percent value sent into the constructor.
 int getIntValue(float ref)
          Returns a value rounded to an int, possibly depending on the ref.
 int getIntValue(float start, float end)
          Returns start + (end - start) * d rounded to the closest int.
 float getValue(float ref)
          Returns a value, possibly depending on the ref.
 float getValue(float start, float end)
          Returns start + (end - start) * d.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

START

public static final AtFraction START
Same as new AtFraction(0f) but can be used to avoid creating new objects. Could also been namnd ZERO or NONE.


CENTER

public static final AtFraction CENTER
Same as new AtFraction(0.5f) but can be used to avoid creating new objects. Could also been namnd MIDDLE or HALF.


END

public static final AtFraction END
Same as new AtFraction(1f) but can be used to avoid creating new objects. Could also been namnd FULL or ONE.

Constructor Detail

AtFraction

public AtFraction(float p)
Constructor.

Parameters:
p - The alignment somewhere between start and end. 0.0 is at start and 1.0 is at end.
Method Detail

getValue

public float getValue(float ref)
Description copied from interface: AtRefNumber
Returns a value, possibly depending on the ref.

Specified by:
getValue in interface AtRefNumber
Parameters:
ref - Some reference value. Might be used or disregarded depending on implementation.
Returns:
The value

getIntValue

public int getIntValue(float ref)
Description copied from interface: AtRefNumber
Returns a value rounded to an int, possibly depending on the ref.

Specified by:
getIntValue in interface AtRefNumber
Parameters:
ref - Some reference value. Might be used or disregarded depending on implementation.
Returns:
The value, rounded to an int.

getValue

public final float getValue(float start,
                            float end)
Returns start + (end - start) * d.

Specified by:
getValue in interface AtRefRangeNumber
Parameters:
start - The start value.
end - The end value.
Returns:
start + (end - start) * d

getIntValue

public final int getIntValue(float start,
                             float end)
Returns start + (end - start) * d rounded to the closest int.

Specified by:
getIntValue in interface AtRefRangeNumber
Parameters:
start - The start value.
end - The end value.
Returns:
start + (end - start) * d rounded to the closest int.

getFraction

public final float getFraction()
Returns the percent value sent into the constructor.

Returns:
The percent value sent into the constructor.

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.