Class ncsa.horizon.coordinates.formatters.MetricAxisPosFormatter
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ncsa.horizon.coordinates.formatters.MetricAxisPosFormatter

java.lang.Object
   |
   +----ncsa.horizon.coordinates.formatters.GenericAxisPosFormatter
           |
           +----ncsa.horizon.coordinates.formatters.MetricAxisPosFormatter

public class MetricAxisPosFormatter
extends GenericAxisPosFormatter
support for printing out double values as floating point numbers appended by a metric unit.

The base unit is usually specified in the constructor.


Variable Index

 o abbmap
a map that translates prefixes into powers
 o abbreviate
if true, use the abbreviation for the scale prefix
 o abbreviations
a container for the prefixes
 o abbrevList
prefix abbreviations
 o fixed
if true, the prefix to be used is fixed
 o ipower
the native base ten logarithmic scale; it is assumed that the input values to the toString(double) methods are in units of 10^ipower (relative to the base unit).
 o minpow
the smallest (most negative) power supported.
 o myname
 o opower
the desired output base ten logarithmic scale; if fixed equals true, toString(double) will attempt to print the value in units of 10^opower (relative to the base unit), assuming there is a known prefix for that power.
 o powerList
the prefix powers
 o prefixes
a container for the prefixes
 o prefixList
the supported prefixes
 o prefmap
a map that translates prefixes into powers
 o unit
the base measurement unit (e.g.

Constructor Index

 o MetricAxisPosFormatter()
format values with no base unit (only prefix will appear).
 o MetricAxisPosFormatter(String)
format values of specified units.
 o MetricAxisPosFormatter(String, int)
format values using the specified unit and the prefix abbreviation for the specified power
 o MetricAxisPosFormatter(String, int, boolean)
format values using the specified unit and the prefix abbreviation for the specified power
 o MetricAxisPosFormatter(String, int, int, boolean)
format values using the specified unit and the prefix for the specified power

Method Index

 o AbbrevFor(int)
return the prefix abbreviation that will be used for a given power, or null if one is not known.
 o clone()
 o fixPrefix()
when formatting values with toString(double), attempt to use the current default output prefix (set either at construction or during the last call to fixPrefix(int).
 o fixPrefix(int)
when formatting values with toString(double), attempt to use the prefix associated with this power.
 o freePrefix()
when formatting values with toString(double), attempt to use the current default output prefix (set either at construction or during the last call to fixPrefix(int).
 o getDefPrefixPower()
return the current default output prefix power that will be used by toString(double) when isFixed() = true.
 o initialize()
loads the prefix and abbreviation lists
 o isAbbreviated()
return whether abbreviations are used
 o isFixed()
return true if this formatter will use a fixed prefix
 o main(String[])
 o maxPower(Vector, int, int)
return the higest power that is less than or equal to the requested power for which there is a name in the given list.
 o prefixFor(int)
return the prefix that will be used for a given power, or null if one is not known
 o revmap()
update the reverse maps
 o scaleValue(double, StringBuffer)
scale the input value and return unit appropriate for that scale
 o setAbbreviated(boolean)
set whether abbreviations are used
 o setMinPower(int)
shift the lists of prefixes and abbreviations to use a new minimum power.
 o setUnit(String)
set the basic unit (word or abbreviation)
 o setUnitPower(int)
assume that the values input to toString(double) will be in units of 10^power (relative to the current unit name).
 o toString(double)
return a value as a string with a specified precision
 o toString(double, int)
return a value as a string with a specified precision
 o useAbbrev(int, String)
use a given abbreviation for the specified power
 o usePrefix(int, String)
use a given prefix for the specified power
 o valueOf(String)
parse the String representation of a floating point number

Variables

 o unit
  protected String unit
the base measurement unit (e.g. "m", "g", "Gauss", etc.)
 o ipower
  protected int ipower
the native base ten logarithmic scale; it is assumed that the input values to the toString(double) methods are in units of 10^ipower (relative to the base unit).
 o opower
  protected int opower
the desired output base ten logarithmic scale; if fixed equals true, toString(double) will attempt to print the value in units of 10^opower (relative to the base unit), assuming there is a known prefix for that power.
 o fixed
  protected boolean fixed
if true, the prefix to be used is fixed
 o abbreviate
  protected boolean abbreviate
if true, use the abbreviation for the scale prefix
 o prefixList
  protected final static String prefixList[]
the supported prefixes
 o abbrevList
  protected final static String abbrevList[]
prefix abbreviations
 o powerList
  protected final static int powerList[]
the prefix powers
 o prefixes
  protected Vector prefixes
a container for the prefixes
 o abbreviations
  protected Vector abbreviations
a container for the prefixes
 o prefmap
  protected Hashtable prefmap
a map that translates prefixes into powers
 o abbmap
  protected Hashtable abbmap
a map that translates prefixes into powers
 o minpow
  protected int minpow
the smallest (most negative) power supported.
 o myname
  protected final static String myname

Constructors

 o MetricAxisPosFormatter
  public MetricAxisPosFormatter(String unit)
format values of specified units. By default, it will be assumed that values input to toString will be in units of this unit, and the most appropriate prefix abbreviation will be used.
Parameters:
unit - the unit name, can be an abbreviation
 o MetricAxisPosFormatter
  public MetricAxisPosFormatter()
format values with no base unit (only prefix will appear). By default, the most appropriate prefix abbreviation will be used.
 o MetricAxisPosFormatter
  public MetricAxisPosFormatter(String unit,
                                int inPower)
format values using the specified unit and the prefix abbreviation for the specified power
Parameters:
unit - the unit name, can be an abbreviation
inPower - assume that values input to toString(double) will be in units of 10^inPower, relative to unit
 o MetricAxisPosFormatter
  public MetricAxisPosFormatter(String unit,
                                int inPower,
                                boolean useAbbreviation)
format values using the specified unit and the prefix abbreviation for the specified power
Parameters:
unit - the unit name, can be an abbreviation
inPower - assume that values input to toString(double) will be in units of 10^inPower, relative to unit
 o MetricAxisPosFormatter
  public MetricAxisPosFormatter(String unit,
                                int inPower,
                                int outPower,
                                boolean useAbbreviation)
format values using the specified unit and the prefix for the specified power
Parameters:
unit - the unit name, can be an abbreviation
inPower - assume that values input to toString(double) will be in units of 10^inPower, relative to unit
outPower - the power for the prefix to be used; if a prefix for this power is not known, the highest valued prefix that is less than request will be used.
useAbbreviation - if true, the prefix abbreviation should be used.

Methods

 o toString
  public String toString(double val)
return a value as a string with a specified precision
Parameters:
val - the input value
Overrides:
toString in class GenericAxisPosFormatter
 o toString
  public String toString(double val,
                         int prec)
return a value as a string with a specified precision
Parameters:
val - the input value
prec - the number of places right of the decimal point
Overrides:
toString in class GenericAxisPosFormatter
 o valueOf
  public synchronized double valueOf(String s) throws NumberFormatException
parse the String representation of a floating point number
Overrides:
valueOf in class GenericAxisPosFormatter
 o clone
  public synchronized Object clone()
Overrides:
clone in class GenericAxisPosFormatter
 o maxPower
  public static int maxPower(Vector list,
                             int power,
                             int minpow)
return the higest power that is less than or equal to the requested power for which there is a name in the given list.
Parameters:
list - the Vector to check
power - the requested power
minpow - the minimum power in the list
 o setUnit
  public void setUnit(String unitName)
set the basic unit (word or abbreviation)
 o setAbbreviated
  public void setAbbreviated(boolean useAbbreviation)
set whether abbreviations are used
 o setUnitPower
  public void setUnitPower(int power)
assume that the values input to toString(double) will be in units of 10^power (relative to the current unit name).
 o fixPrefix
  public void fixPrefix(int power)
when formatting values with toString(double), attempt to use the prefix associated with this power. If a prefix is not known for this power, use the prefix of the maximum power less than this power for which a prefix is known.
 o fixPrefix
  public void fixPrefix()
when formatting values with toString(double), attempt to use the current default output prefix (set either at construction or during the last call to fixPrefix(int).
 o freePrefix
  public void freePrefix()
when formatting values with toString(double), attempt to use the current default output prefix (set either at construction or during the last call to fixPrefix(int).
 o getDefPrefixPower
  public int getDefPrefixPower()
return the current default output prefix power that will be used by toString(double) when isFixed() = true.
 o isFixed
  public boolean isFixed()
return true if this formatter will use a fixed prefix
 o isAbbreviated
  public boolean isAbbreviated()
return whether abbreviations are used
 o usePrefix
  public synchronized void usePrefix(int power,
                                     String prefix)
use a given prefix for the specified power
 o prefixFor
  public synchronized String prefixFor(int power)
return the prefix that will be used for a given power, or null if one is not known
 o useAbbrev
  public synchronized void useAbbrev(int power,
                                     String abbrev)
use a given abbreviation for the specified power
 o AbbrevFor
  public synchronized String AbbrevFor(int power)
return the prefix abbreviation that will be used for a given power, or null if one is not known.
 o initialize
  protected void initialize()
loads the prefix and abbreviation lists
 o revmap
  protected void revmap()
update the reverse maps
 o setMinPower
  protected synchronized void setMinPower(int power)
shift the lists of prefixes and abbreviations to use a new minimum power. This will only lower the value of minpow.
 o scaleValue
  protected synchronized double scaleValue(double val,
                                           StringBuffer unitBuf)
scale the input value and return unit appropriate for that scale
Parameters:
val - the input value
unitBuf - a buffer to append unit to
Returns:
double the scaled value
 o main
  public static void main(String args[])

All Packages  Class Hierarchy  This Package  Previous  Next  Index