gov.sns.tools.plot
Class DateGraphFormat

java.lang.Object
  |
  +--java.text.Format
        |
        +--java.text.NumberFormat
              |
              +--java.text.DecimalFormat
                    |
                    +--gov.sns.tools.plot.DateGraphFormat
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class DateGraphFormat
extends java.text.DecimalFormat

DateGraphFormat is the subclass of the DecimalFormat class. It produces the x-axis markers as a date by using an internal date format. X-axis values are supposed to be the number of seconds since January 1, 1970, 00:00:00 GMT. To use this format for the x-axis call the method setNumberFormatX(DecimalFormat df) of the instance of FunctionGraphsJPanel class with the DateGraphFormat instance instead of DecimalFormat.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.text.NumberFormat
FRACTION_FIELD, INTEGER_FIELD
 
Constructor Summary
DateGraphFormat()
          Constructor with a default DateFormat (it is SimpleDateFormat("HH:mm:ss")).
DateGraphFormat(java.text.DateFormat dateFormatIn)
          Constructor with a DateFormat as a parameter.
DateGraphFormat(java.lang.String pattern)
          Constructor with a date format pattern as the parameter.
 
Method Summary
 java.lang.StringBuffer format(double t_sec, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
          The overridden format method of the DecimalFormat class.
static java.util.Date getDate(double seconds)
          Transforms the seconds since January 1, 1970, 00:00:00 GMT to the date.
 java.text.DateFormat getDateFormat()
          Returns the instance of the DateFormat class that is used to format the seconds to the date.
static double getSeconds(java.util.Date date)
          Transforms the date to the seconds since January 1, 1970, 00:00:00 GMT.
 void setDateFormat(java.text.DateFormat dateFormat)
          Sets the instance of the DateFormat class that will be used to format the seconds to the date.
 
Methods inherited from class java.text.DecimalFormat
applyLocalizedPattern, applyPattern, clone, equals, format, formatToCharacterIterator, getCurrency, getDecimalFormatSymbols, getGroupingSize, getMultiplier, getNegativePrefix, getNegativeSuffix, getPositivePrefix, getPositiveSuffix, hashCode, isDecimalSeparatorAlwaysShown, parse, setCurrency, setDecimalFormatSymbols, setDecimalSeparatorAlwaysShown, setGroupingSize, setMaximumFractionDigits, setMaximumIntegerDigits, setMinimumFractionDigits, setMinimumIntegerDigits, setMultiplier, setNegativePrefix, setNegativeSuffix, setPositivePrefix, setPositiveSuffix, toLocalizedPattern, toPattern
 
Methods inherited from class java.text.NumberFormat
format, format, format, getAvailableLocales, getCurrencyInstance, getCurrencyInstance, getInstance, getInstance, getIntegerInstance, getIntegerInstance, getMaximumFractionDigits, getMaximumIntegerDigits, getMinimumFractionDigits, getMinimumIntegerDigits, getNumberInstance, getNumberInstance, getPercentInstance, getPercentInstance, isGroupingUsed, isParseIntegerOnly, parse, parseObject, setGroupingUsed, setParseIntegerOnly
 
Methods inherited from class java.text.Format
format, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateGraphFormat

public DateGraphFormat()
Constructor with a default DateFormat (it is SimpleDateFormat("HH:mm:ss")).


DateGraphFormat

public DateGraphFormat(java.lang.String pattern)
Constructor with a date format pattern as the parameter.


DateGraphFormat

public DateGraphFormat(java.text.DateFormat dateFormatIn)
Constructor with a DateFormat as a parameter.

Method Detail

format

public java.lang.StringBuffer format(double t_sec,
                                     java.lang.StringBuffer toAppendTo,
                                     java.text.FieldPosition pos)
The overridden format method of the DecimalFormat class.

Overrides:
format in class java.text.DecimalFormat

getDateFormat

public java.text.DateFormat getDateFormat()
Returns the instance of the DateFormat class that is used to format the seconds to the date.


setDateFormat

public void setDateFormat(java.text.DateFormat dateFormat)
Sets the instance of the DateFormat class that will be used to format the seconds to the date.


getSeconds

public static double getSeconds(java.util.Date date)
Transforms the date to the seconds since January 1, 1970, 00:00:00 GMT.

Returns:
double as a number of seconds

getDate

public static java.util.Date getDate(double seconds)
Transforms the seconds since January 1, 1970, 00:00:00 GMT to the date.

Returns:
an instance of the Date class.