NetCharts Pro

netcharts.pro.common
Class NFFormat

java.lang.Object
  extended by netcharts.pro.common.NFBaseClass
      extended by netcharts.pro.common.NFFormat
All Implemented Interfaces:
java.lang.Cloneable, NFCDLGenerator

public class NFFormat
extends NFBaseClass
implements NFCDLGenerator

Provides formatting for data-derived labels found in axes and popup data labels, If the format type is INTEGER or FLOAT, the input data value is expected to be of type integer or float and will be parsed as such (if string conversion is necessary). The format itself is a C-language style sprintf format. Some examples:

        Data    Type    Format  Output
        1000    INTEGER %d      1000
        1000    INTEGER $,%d    $1,000
        1000    INTEGER %d%     1000%
        1000    FLOAT   %f      1000.0
        1000    FLOAT   %.2f    1000.00
        1000    FLOAT   $,.2f   $1,000.00
 
If the format type is SIMPLEDATE, the format syntax is consistent with those defined in the Java SimpleDateFormat spec. If the format type is DECIMAL, the format syntax is consistent with those defined in the Java DecimalFormat spec. If the format type is DATE, the format expression may include any of the following elements:
        Element Result
        %L      standard Java locale format ('Mon Jan 01 00:00:00 1996')
        %G      standard Java GMT format ('1 Jan 1996 00:00:00 GMT')
        %Y      year as YYYY (1900+)
        %y      year as YY (00-99)
        %M      month as MM (01-12)
        %N      long month name ("January", "February", ...)
        %n      short month name ("Jan", "Feb", ...)
        %W      long weekday name ("Sunday", "Monday", ...)
        %w      short weekday name ("Sun", "Mon", ...)
        %d      day of month as DD (01-31)
        %h      hour as HH (00-23)
        %m      minute as MM (00-59)
        %s      second as SS (00-59)
Details on formats can be found in the NetCharts documentation in the Axis section.


Field Summary
static int DATE
          Date format
static int DECIMAL
          Decimal format
static int FLOAT
          Floating point format
static java.util.Hashtable formatTypeMap
          The set of allowed format types.
static int INTEGER
          Integer format
static int NONE
          No format
static int SIMPLEDATE
          Simple Date format
 
Constructor Summary
NFFormat()
          Constructs a default format object
NFFormat(int formatType, java.lang.String format)
          Constructs a format object with the given type and expression
 
Method Summary
 java.lang.String getCDL()
          Generate CDL parameters representing this format
 void getCDL(java.lang.StringBuffer sb)
          Append CDL parameters representing this format to the given StringBuffer.
 void getCDL(java.lang.StringBuffer sb, boolean includeParens)
          Append CDL parameters representing this format to the given StringBuffer.
 java.lang.String getFormat()
          Gets the format expression.
 int getFormatType()
          Gets the type of format
 java.util.Date getTimeBase()
          Gets the time base.
 NFTimeUnit getTimeUnit()
          Gets the time unit.
 void setCDL(java.lang.Object cdlObject)
          Configures this object from a CDL parameter object.
 void setCDL(java.lang.String cdl)
          Configures this object from a CDL parameter representation.
 void setCDL(java.lang.String[] elements)
          Configures this object from a CDL parameter representation.
 void setFormat(java.lang.String format)
          Sets the format expression.
 void setFormatType(int formatType)
          Sets the type of format.
 void setTimeBase(java.util.Date timeBase)
          Sets the time base.
 void setTimeUnit(NFTimeUnit timeUnit)
          Sets the time unit.
 java.lang.String toString()
          Returns a new String object representing this format.
 
Methods inherited from class netcharts.pro.common.NFBaseClass
clone, getModified, getUserObject, setModified, setUserObject
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final int NONE
No format

See Also:
Constant Field Values

INTEGER

public static final int INTEGER
Integer format

See Also:
Constant Field Values

FLOAT

public static final int FLOAT
Floating point format

See Also:
Constant Field Values

DATE

public static final int DATE
Date format

See Also:
Constant Field Values

SIMPLEDATE

public static final int SIMPLEDATE
Simple Date format

See Also:
Constant Field Values

DECIMAL

public static final int DECIMAL
Decimal format

See Also:
Constant Field Values

formatTypeMap

public static java.util.Hashtable formatTypeMap
The set of allowed format types. Consists of NONE, INTEGER, FLOAT, DATE, SIMPLEDATE, DECIMAL.

Constructor Detail

NFFormat

public NFFormat()
Constructs a default format object


NFFormat

public NFFormat(int formatType,
                java.lang.String format)
Constructs a format object with the given type and expression

Parameters:
formatType - One of NONE, INTEGER, FLOAT, DATE, SIMPLEDATE
format - A format expression
Method Detail

setFormatType

public void setFormatType(int formatType)
Sets the type of format.

If the value passed is not a valid format type an IllegalArgumentException will be thrown.

Parameters:
formatType - One of NONE, INTEGER, FLOAT, DATE, SIMPLEDATE, DECIMAL

getFormatType

public int getFormatType()
Gets the type of format

Returns:
one of NONE, INTEGER, FLOAT, DATE, SIMPLEDATE, DECIMAL or INTEGER if not set.

setFormat

public void setFormat(java.lang.String format)
Sets the format expression.

Parameters:
format - See documentation above or NetCharts documentation on specific formats.

getFormat

public java.lang.String getFormat()
Gets the format expression.

Returns:
format See documentation above or NetCharts documentation on specific formats.

setTimeBase

public void setTimeBase(java.util.Date timeBase)
Sets the time base. This is used only when the format type is either DATE or SIMPLEDATE. When automatically generating axis labels this provides the "start" date.

Parameters:
timeBase -

getTimeBase

public java.util.Date getTimeBase()
Gets the time base. This is used only when the format type is either DATE or SIMPLEDATE. When automatically generating axis labels this provides the "start" date.

Returns:
timeBase

setTimeUnit

public void setTimeUnit(NFTimeUnit timeUnit)
Sets the time unit. This indicates the weight to be applied to each consecutive value. For example, if the scale of an axis is set so that the min is 0 and the max is 100 with a step of 10, and then the time unit is set to "1d" this means that every axis tic represents one day (1d).

Parameters:
timeUnit -

getTimeUnit

public NFTimeUnit getTimeUnit()
Gets the time unit. This indicates the weight to be applied to each consecutive value. For example, if the scale of an axis is set so that the min is 0 and the max is 100 with a step of 10, and then the time unit is set to "1d" this means that every axis tic represents one day (1d).

Returns:
timeUnit

setCDL

public void setCDL(java.lang.Object cdlObject)
Configures this object from a CDL parameter object.

Parameters:
cdlObject - CDL in a String form or in a user object.

setCDL

public void setCDL(java.lang.String cdl)
Configures this object from a CDL parameter representation.

Specified by:
setCDL in interface NFCDLGenerator
Parameters:
cdl - CDL in the form: (formatType, formatExpression, "timeBase", "timeunit")

setCDL

public void setCDL(java.lang.String[] elements)
Configures this object from a CDL parameter representation.

Parameters:
cdl - CDL in the form: (formatType, formatExpression, "timeBase", "timeunit")

getCDL

public java.lang.String getCDL()
Generate CDL parameters representing this format

Specified by:
getCDL in interface NFCDLGenerator
Returns:
CDL in the form: (formatType, formatExpression, "timebase", "timeunit")

getCDL

public void getCDL(java.lang.StringBuffer sb)
Append CDL parameters representing this format to the given StringBuffer.

Parameters:
sb - Target buffer to append the CDL parameters

getCDL

public void getCDL(java.lang.StringBuffer sb,
                   boolean includeParens)
Append CDL parameters representing this format to the given StringBuffer.

Parameters:
sb - Target buffer to append the CDL parameters
includeParens - Whether to surround the param with parentheses

toString

public java.lang.String toString()
Returns a new String object representing this format.

Specified by:
toString in interface NFCDLGenerator
Overrides:
toString in class java.lang.Object
Returns:
A new String object in the same form as that given by getCDL().

NetCharts Pro


Visual Mining, Inc.
2099 Gaither Rd.
Suite 220
Rockville, MD 20850
800.308.0731
301.947.8293 FAX

Copyright © Visual Mining, Inc. 1996 - 2011
All Rights Reserved.

NetCharts Pro TM is a registered trademark of Visual Mining, Inc. Other brands and their products are trademarks of their respective holders.

Last Modified: Jun 28, 2011