    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.

##

abbmap
  a map that translates prefixes into powers
abbreviate
  if true, use the abbreviation for the scale prefix
abbreviations
  a container for the prefixes
abbrevList
  prefix abbreviations
fixed
  if true, the prefix to be used is fixed
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).
minpow
  the smallest (most negative) power supported.
myname
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.
powerList
  the prefix powers
prefixes
  a container for the prefixes
prefixList
  the supported prefixes
prefmap
  a map that translates prefixes into powers
unit
  the base measurement unit (e.g.

##

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

##

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

##

unit

      protected String unit

  the base measurement unit (e.g. "m", "g", "Gauss", etc.)

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).

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.

fixed

      protected boolean fixed

  if true, the prefix to be used is fixed

abbreviate

      protected boolean abbreviate

  if true, use the abbreviation for the scale prefix

prefixList

      protected final static String prefixList[]

  the supported prefixes

abbrevList

      protected final static String abbrevList[]

  prefix abbreviations

powerList

      protected final static int powerList[]

  the prefix powers

prefixes

      protected Vector prefixes

  a container for the prefixes

abbreviations

      protected Vector abbreviations

  a container for the prefixes

prefmap

      protected Hashtable prefmap

  a map that translates prefixes into powers

abbmap

      protected Hashtable abbmap

  a map that translates prefixes into powers

minpow

      protected int minpow

  the smallest (most negative) power supported.

myname

      protected final static String myname

##

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

MetricAxisPosFormatter

      public MetricAxisPosFormatter()

  format values with no base unit (only prefix will appear). By default, the most appropriate prefix abbreviation will be used.

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

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

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.

##

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

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

valueOf

      public synchronized double valueOf(String s) throws NumberFormatException

  parse the String representation of a floating point number
  Overrides:
    valueOf in class GenericAxisPosFormatter

clone

      public synchronized Object clone()

Overrides:
  clone in class GenericAxisPosFormatter

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

setUnit

      public void setUnit(String unitName)

  set the basic unit (word or abbreviation)

setAbbreviated

      public void setAbbreviated(boolean useAbbreviation)

  set whether abbreviations are used

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).

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.

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).

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).

getDefPrefixPower

      public int getDefPrefixPower()

  return the current default output prefix power that will be used by toString(double) when isFixed() = true.

isFixed

      public boolean isFixed()

  return true if this formatter will use a fixed prefix

isAbbreviated

      public boolean isAbbreviated()

  return whether abbreviations are used

usePrefix

      public synchronized void usePrefix(int power,
                                         String prefix)

  use a given prefix for the specified power

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

useAbbrev

      public synchronized void useAbbrev(int power,
                                         String abbrev)

  use a given abbreviation for the specified power

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.

initialize

      protected void initialize()

  loads the prefix and abbreviation lists

revmap

      protected void revmap()

  update the reverse maps

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.

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

main

      public static void main(String args[])

    All Packages  Class Hierarchy  This Package  Previous  Next  Index