|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectinfo.monitorenter.util.units.AUnit
public abstract class AUnit
A unit.
UnitFactory
,
IUnitSystem
,
UnitSystemSI
,
Serialized FormField Summary | |
---|---|
protected int |
m_decimals
Decimals for rounding. |
protected double |
m_factor
The factor a result of getValue(double) had to be multiplied with if the real
(unitless) value has to be calculated. |
protected AUnit |
m_nexLowerUnit
The next smaller unit to this one within this unit's IUnitSystem . |
protected AUnit |
m_nextHigherUnit
The next greater unit to this one within this unit's IUnitSystem . |
protected String |
m_unitName
The short unit name of this unit a result of getValue(double) has to be related with
to know the this result is displayed in a unit. |
Constructor Summary | |
---|---|
protected |
AUnit()
Protected constructor to ensure package access only. |
Method Summary | |
---|---|
int |
getDecimals()
Returns the number of decimals that should be be taken into account if the method getValue(double) is invoked (rounding). |
double |
getFactor()
Returns the factor a result of getValue(double) had to be multiplied with if the real
(unitless) value has to be calculated. |
String |
getLabel(double value)
Returns the the value divided by this unit's factor, rounded to this unit's configured decimals and suffixed by the unit name. |
AUnit |
getNexLowerUnit()
Returns the next smaller unit to this one within this unit's IUnitSystem . |
AUnit |
getNextHigherUnit()
Returns the next greater unit to this one within this unit's IUnitSystem . |
String |
getUnitName()
Retunrns the short unit name of this unit a result of getValue(double) has to be
related with to know the this result is displayed in a unit. |
double |
getValue(double value)
Transforms the given absolute value into the represented unit value by dividing by the specific factor. |
void |
setDecimals(int aftercomma)
Define how many decimals should be taken into account if the method getValue(double)
is invoked (rounding). |
String |
toString()
Returns the same as getUnitName() , prefer calling this directly if desired. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int m_decimals
protected double m_factor
getValue(double)
had to be multiplied with if the real
(unitless) value has to be calculated.
protected AUnit m_nexLowerUnit
IUnitSystem
.
protected AUnit m_nextHigherUnit
IUnitSystem
.
protected String m_unitName
getValue(double)
has to be related with
to know the this result is displayed in a unit.
Constructor Detail |
---|
protected AUnit()
Use UnitFactory.getInstance()
and UnitFactory.getUnit(double, IUnitSystem)
to
obtain a proper unit.
Method Detail |
---|
public int getDecimals()
getValue(double)
is invoked (rounding).
getValue(double)
is invoked (rounding).public double getFactor()
getValue(double)
had to be multiplied with if the real
(unitless) value has to be calculated.
For performance reason (fast access) factor is public. This is against "safety by desing" so do never set this value.
getValue(double)
had to be multiplied with if the real
(unitless) value has to be calculated.public String getLabel(double value)
value
- the value for the label.
getUnitName()
,
getDecimals()
public AUnit getNexLowerUnit()
IUnitSystem
.
If this is already the smallest unit, this will be returned so add
unit == unit.getLowerUnit()
as the termination criteria in loops to search for
the smallest unit (to avoid endless loops).
IUnitSystem
.public AUnit getNextHigherUnit()
IUnitSystem
.
If this is already the greates unit, this will be returned so add
unit == unit.getNextHigherUnit()
as the termination criteria in loops to search
for the greatest unit (to avoid endless loops).
IUnitSystem
.public String getUnitName()
getValue(double)
has to be
related with to know the this result is displayed in a unit.
getValue(double)
has to be
related with to know the this result is displayed in a unit.
public double getValue(double value)
The result is rounded using the actual decimal setting.
value
- the value to represent in this unit.
public void setDecimals(int aftercomma)
getValue(double)
is invoked (rounding).
aftercomma
- the number of decimals that should be taken into account if the method
getValue(double)
is invoked (rounding)public String toString()
getUnitName()
, prefer calling this directly if desired.
toString
in class Object
getUnitName()
, prefer calling this directly if desired.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |