Package jahuwaldt.js.unit
Class UnitSet
- java.lang.Object
-
- jahuwaldt.js.unit.UnitSet
-
- All Implemented Interfaces:
java.lang.Cloneable
public final class UnitSet extends java.lang.Object implements java.lang.Cloneable
A class that contains a set of units (generally made self-consistent if not coherent) and also provides lists (sets) of related units.Modified by: Joseph A. Huwaldt
- Version:
- March 19, 2017
- Author:
- Joseph A. Huwaldt, Date: July 12, 2008
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
UnitSet.SetType
The different unit set types in this collection.static class
UnitSet.UnitSystem
The type of unit system being used.
-
Constructor Summary
Constructors Constructor Description UnitSet(UnitSet.UnitSystem system)
Construct a coherent set of units based on the system identification provided.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.measure.unit.Unit<javax.measure.quantity.Acceleration>
acceleration()
Return the acceleration units.void
addPropertyChangeListener(java.beans.PropertyChangeListener l)
void
addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener l)
javax.measure.unit.Unit<javax.measure.quantity.Angle>
angle()
Return the angular measure units for this unit set.javax.measure.unit.Unit<javax.measure.quantity.AngularVelocity>
angularVelocity()
Return the angular velocity units.javax.measure.unit.Unit<javax.measure.quantity.Area>
area()
Return the area units.void
clearPropertyChangeListeners()
java.lang.Object
clone()
Creates and returns a copy of this object.boolean
equals(java.lang.Object obj)
Compares this UnitSet against the specified object for strict equality.javax.measure.unit.Unit<javax.measure.quantity.Force>
force()
Return the force units.static javax.measure.unit.Unit[]
getSet(UnitSet.SetType type)
Returns an array of units of the specified type (array of related units).UnitSet.UnitSystem
getSystem()
Method that returns the Unit System for this unit set.int
hashCode()
Returns the hash code for this UnitSet.javax.measure.unit.Unit<Inertia>
inertia()
Return the inertia units.boolean
isCoherent()
Returntrue
if this unit set is coherent.boolean
isConsistent()
Returntrue
if this unit set is consistent.javax.measure.unit.Unit<javax.measure.quantity.Length>
length()
Return the length units for this unit set.void
makeConsistent()
Makes this unit set consistent by deriving a complete set of units for this application based on the fundamental or base units of time, length, mass and angle.javax.measure.unit.Unit<javax.measure.quantity.Mass>
mass()
Return the mass units for this unit set.javax.measure.unit.Unit<javax.measure.quantity.VolumetricDensity>
massDensity()
Return the mass density units.void
removePropertyChangeListener(java.beans.PropertyChangeListener l)
void
removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener l)
void
setAngle(javax.measure.unit.Unit<javax.measure.quantity.Angle> unit)
Method used to set the angular measure units in this unit set.void
setLength(javax.measure.unit.Unit<javax.measure.quantity.Length> unit)
Method used to set the length units in this unit set.void
setMass(javax.measure.unit.Unit<javax.measure.quantity.Mass> unit)
Method used to set the mass units in this unit set.void
setTime(javax.measure.unit.Unit<javax.measure.quantity.Duration> unit)
Method used to set the time units in this unit set.javax.measure.unit.Unit<javax.measure.quantity.Duration>
time()
Return the duration of time units for this unit set.javax.measure.unit.Unit<javax.measure.quantity.Torque>
torque()
Return the torque units.javax.measure.unit.Unit<javax.measure.quantity.Velocity>
velocity()
Return the velocity units.javax.measure.unit.Unit<javax.measure.quantity.Volume>
volume()
Return the volume units.
-
-
-
Constructor Detail
-
UnitSet
public UnitSet(UnitSet.UnitSystem system)
Construct a coherent set of units based on the system identification provided.- Parameters:
system
- The Unit System type.
-
-
Method Detail
-
getSystem
public UnitSet.UnitSystem getSystem()
Method that returns the Unit System for this unit set.- Returns:
- The UnitSystem for this unit set.
-
getSet
public static javax.measure.unit.Unit[] getSet(UnitSet.SetType type)
Returns an array of units of the specified type (array of related units).- Parameters:
type
- The unit type to return an array of units for.- Returns:
- The unit set array requested
-
isCoherent
public boolean isCoherent()
Returntrue
if this unit set is coherent. Coherent means that the derived units in this set are a product of powers of base units with no other proportionality factor than one.- Returns:
- true if this unit set is coherent.
- See Also:
isConsistent()
-
isConsistent
public boolean isConsistent()
Returntrue
if this unit set is consistent. Consistent means that the derived units are made up of powers of the base units though there may be conversion factors involved.- Returns:
- true if this unit set is consistent.
- See Also:
makeConsistent()
,isCoherent()
-
makeConsistent
public void makeConsistent()
Makes this unit set consistent by deriving a complete set of units for this application based on the fundamental or base units of time, length, mass and angle. Consistent means that the derived units in this set are all derived from the base units.- See Also:
isConsistent()
,isCoherent()
-
time
public javax.measure.unit.Unit<javax.measure.quantity.Duration> time()
Return the duration of time units for this unit set.- Returns:
- The units of durations of time.
-
setTime
public void setTime(javax.measure.unit.Unit<javax.measure.quantity.Duration> unit) throws javax.measure.converter.ConversionException
Method used to set the time units in this unit set. All units that have a time/duration component will be changed to use this time value after a call to "makeCoherent()".- Parameters:
unit
- the time unit to set this unit set to.- Throws:
javax.measure.converter.ConversionException
- if the provided unit is not compatible with time (seconds).- See Also:
makeConsistent()
-
length
public javax.measure.unit.Unit<javax.measure.quantity.Length> length()
Return the length units for this unit set.- Returns:
- The length units.
-
setLength
public void setLength(javax.measure.unit.Unit<javax.measure.quantity.Length> unit) throws javax.measure.converter.ConversionException
Method used to set the length units in this unit set. All units that have a length component will be changed to use this length value after a call to "makeCoherent()".- Parameters:
unit
- the length unit to set this unit set to.- Throws:
javax.measure.converter.ConversionException
- if the provided unit is not compatible with length (meters).- See Also:
makeConsistent()
-
mass
public javax.measure.unit.Unit<javax.measure.quantity.Mass> mass()
Return the mass units for this unit set.- Returns:
- The mass units.
-
setMass
public void setMass(javax.measure.unit.Unit<javax.measure.quantity.Mass> unit) throws javax.measure.converter.ConversionException
Method used to set the mass units in this unit set. All units that have a mass component will be changed to use this mass value after a call to "makeCoherent()".- Parameters:
unit
- the mass unit to set this unit set to.- Throws:
javax.measure.converter.ConversionException
- if the provided unit is not compatible with mass (kg).- See Also:
makeConsistent()
-
angle
public javax.measure.unit.Unit<javax.measure.quantity.Angle> angle()
Return the angular measure units for this unit set.- Returns:
- The angular measure units.
-
setAngle
public void setAngle(javax.measure.unit.Unit<javax.measure.quantity.Angle> unit) throws javax.measure.converter.ConversionException
Method used to set the angular measure units in this unit set. All units that have an angular measure component will be changed to use this value after a call to "makeCoherent()".- Parameters:
unit
- the angle unit to set this unit set to.- Throws:
javax.measure.converter.ConversionException
- if the provided unit is not compatible with angles (radian).- See Also:
makeConsistent()
-
area
public javax.measure.unit.Unit<javax.measure.quantity.Area> area()
Return the area units.- Returns:
- Area units
-
volume
public javax.measure.unit.Unit<javax.measure.quantity.Volume> volume()
Return the volume units.- Returns:
- Volume units
-
velocity
public javax.measure.unit.Unit<javax.measure.quantity.Velocity> velocity()
Return the velocity units.- Returns:
- Velocity units
-
acceleration
public javax.measure.unit.Unit<javax.measure.quantity.Acceleration> acceleration()
Return the acceleration units.- Returns:
- Acceleration units
-
force
public javax.measure.unit.Unit<javax.measure.quantity.Force> force()
Return the force units.- Returns:
- Force units
-
inertia
public javax.measure.unit.Unit<Inertia> inertia()
Return the inertia units.- Returns:
- Inertia units
-
massDensity
public javax.measure.unit.Unit<javax.measure.quantity.VolumetricDensity> massDensity()
Return the mass density units.- Returns:
- Mass density units.
-
angularVelocity
public javax.measure.unit.Unit<javax.measure.quantity.AngularVelocity> angularVelocity()
Return the angular velocity units.- Returns:
- Angular velocity units.
-
torque
public javax.measure.unit.Unit<javax.measure.quantity.Torque> torque()
Return the torque units.- Returns:
- The torque units.
-
clone
public java.lang.Object clone()
Creates and returns a copy of this object.- Returns:
- A clone of this UnitSet.
-
equals
public boolean equals(java.lang.Object obj)
Compares this UnitSet against the specified object for strict equality.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- the object to compare with.- Returns:
true
if this UnitSet is identical to that object;false
otherwise.
-
hashCode
public int hashCode()
Returns the hash code for this UnitSet.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the hash code value.
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
-
addPropertyChangeListener
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener l)
-
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
-
removePropertyChangeListener
public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener l)
-
clearPropertyChangeListeners
public void clearPropertyChangeListeners()
-
-