|
Chart FX for Java 6.5 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SoftwareFX.ChartFX.ValueFormat
public final class ValueFormat
Provides access to the ValueFormat object.
The ValueFormat Class members allow you to format values as numbers, dates, currency, scientific and time. These properties may be applied to many different objects including axis labels, point labels, and in the data editor.
Constructor Summary | |
---|---|
ValueFormat()
|
Method Summary | |
---|---|
java.lang.String |
formatDateTime(java.util.Date date)
Returns an expression formatted as a date or time. |
java.lang.String |
formatNumber(double d)
Returns an expression formatted as a number. |
java.lang.String |
getCulture()
Gets the Culture. |
java.lang.String |
getCustomFormat()
Gets the CustomFormat. |
int |
getDecimals()
Gets the Decimals. |
int |
getFormat()
Gets the Format. |
void |
setCulture(java.lang.String value)
Allows you to localize labels and data for a specific language and region. |
void |
setCustomFormat(java.lang.String value)
Allows you to set a custom format to the selected label, mouseover tip or value. |
void |
setDecimals(int value)
Allows you to set the number of decimals for the selected label, mouseover tip or value. |
void |
setFormat(int value)
Used to format the selected label, mouseover tip or value to numbers, date, time, scientific or currency. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ValueFormat()
Method Detail |
---|
public java.lang.String formatDateTime(java.util.Date date)
Returns an expression formatted as a date or time.
This method is used to format axis labels and should be used in conjunction with the AxisBase.getLabelsFormat()
property.
date
- setCustomFormat(java.lang.String)
,
setDecimals(int)
,
setFormat(int)
,
formatNumber(double)
,
Axis
public java.lang.String formatNumber(double d)
Returns an expression formatted as a number.
This method is used to format axis labels and should be used in conjunction with the AxisBase.getLabelsFormat()
property.
d
- Required. Expression to be formatted.setCustomFormat(java.lang.String)
,
setDecimals(int)
,
setFormat(int)
,
formatDateTime(java.util.Date)
,
Axis
public java.lang.String getCulture()
Gets the Culture. For more detail see setCulture(java.lang.String)
.
public java.lang.String getCustomFormat()
Gets the CustomFormat. For more detail see setCustomFormat(java.lang.String)
.
public int getDecimals()
Gets the Decimals. For more detail see setDecimals(int)
.
public int getFormat()
Gets the Format. For more detail see setFormat(int)
.
public void setCulture(java.lang.String value)
Allows you to localize labels and data for a specific language and region.
Culture attributes set with this property will effect only selected data and labels, to set localization attributes for the entire chart, please use the ChartCore.setCulture(java.lang.String)
property of the Chart
class.
If no attributes are set using this property or the Chart class ChartCore.setCulture(java.lang.String)
property, then Chart FX inherits the system culture.
When setting this property, you may need the Languaje Code and/or Country Code constants for the desired culture. For more information, please refer to the java.util.Locale documentation.
Example:
chart1.getAxisY().getLabelsFormat().setCulture("es-ES");
ChartCore.setCulture(java.lang.String)
,
ChartCore.setMessageText(java.lang.String, java.lang.String)
,
Chart
public void setCustomFormat(java.lang.String value)
Allows you to set a custom format to the selected label, mouseover tip or value.
This property must be invoked before data has been ChartCore.setDataSource(SoftwareFX.ChartFX.IDataProvider)
or ChartCore.openData(int, int, int)
to the chart.
This property may be used in conjunction with the Axis.getDataFormat()
and AxisBase.getLabelsFormat()
properties.
When a CustomFormat is applied to a selected axis, any formatting assigned using the setDecimals(int)
property will be ignored.
The following table shows the characters you can use to create user-defined number formats and the meaning of each:
Character 0 ( Digit placeholder).
Display a digit or a zero. If there is a digit in the expression being formatted in the position where the 0 appears in the format string, display it; otherwise, display a zero in that position. If the number being formatted has fewer digits than there are zeros (on either side of the decimal) in the format expression, leading or trailing zeros are displayed. If the number has more digits to the right of the decimal separator than there are zeros to the right of the decimal separator in the format expression, the number is rounded to as many decimal places as there are zeros. If the number has more digits to the left of the decimal separator than there are zeros to the left of the decimal separator in the format expression, the extra digits are displayed without modification.
Character # (Digit placeholder)
Display a digit or nothing. If there is a digit in the expression being formatted in the position where the # appears in the format string, display it; otherwise, display nothing in that position. This symbol works like the 0 digit placeholder, except that leading and trailing zeros aren't displayed if the number has the same or fewer digits than there are # characters on either side of the decimal separator in the format expression.
Character . (Decimal placeholder)
The decimal placeholder determines how many digits are displayed to the left and right of the decimal separator. If the format expression contains only number signs to the left of this symbol, numbers smaller than 1 begin with a decimal separator. If you want a leading zero to always be displayed with fractional numbers, use 0 as the first digit placeholder to the left of the decimal separator instead. The actual character used as a decimal placeholder in the formatted output depends on the Number Format specified for the development workstation. For some countries, a comma is used as the decimal separator.
Character , (Thousand separator)
The thousand separator separates thousands from hundreds within a number that has four or more places to the left of the decimal separator. Standard use of the thousand separator is specified if the format contains a comma surrounded by digit placeholders (0 or #). Two adjacent commas or a comma immediately to the left of the decimal separator (whether or not a decimal is specified) means "scale the number by dividing it by 1000, rounding as needed." You can scale large numbers using this technique. For example, you can use the format string "##0,," to represent 100 million as 100. Numbers smaller than 1 million are displayed as 0. Two adjacent commas in any position other than immediately to the left of the decimal separator are treated simply as specifying the use of a thousand separator. The actual character used as the thousand separator in the formatted output depends on the Number Format specified in the International section of the Control Panel. For some countries, a period is used as the thousand separator.
Character ; (expression separator)
The following example has two sections: the first defines the format for positive values and zeros; the second section defines the format for negative values. "$#,##0;($#,##0)"
If you include semicolons with nothing between them, the missing section is printed using the default format. For example, the following format displays positive as currency and negative values using the default format: "$#,##0;"
The following table shows the characters you can use to create user-defined date/time formats and the meaning of each, but check Java API documentation for a updated information:
Character C
Display the date as ddddd and display the time as t t t t t, in that order. Only date information is displayed if there is no fractional part to the date serial number; only time information is displayed if there is no integer portion.
Date Parameters:
Character d
Display the day as a number without a leading zero (1-31).
Character dd
Display the day as a number with a leading zero (01-31).
Character ddd
Display the day as an abbreviation (Sun-Sat).
Character dddd
Display the day as a full name (Sunday-Saturday).
Character ddddd
Display a date serial number as a complete date (including day, month, and year) formatted according to the Short Date setting in the International section of the Windows Control Panel. The default Short Date format is m/d/yy.
Character dddddd
Display a date serial number as a complete date (including day, month, and year) formatted according to the Long Date setting in the International section of the Control Panel. The default Long Date format is mmmm dd, yyyy.
Character M
Display the month as a number without a leading zero (1-12).
Character MM
Display the month as a number with a leading zero (01-12).
Character MMM
Display the month as an abbreviation (Jan-Dec).
Character MMMM
Display the month as a full month name (January-December).
Character y
Display the day of the year as a number (1-366).
Character yy
Display the year as a two-digit number (00-99).
Character yyyy Display the year as a four-digit number (100-9999).
Time Parameters:
Character h
Display the hour as a number without leading zeros (0-11) using a 12-hour clock
Character hh
Display the hour as a number with leading zeros (00-11) using a 12-hour clock
Character H
Display the hour as a number (0-23) using a 24-hour clock.
Character HH
Display the hour as a number with leading zeros (00-23) using a 24-hour clock.
Character m
Display the minute as a number without leading zeros (0-59).
Character mm
Display the minute as a number with leading zeros (00-59).
Character s
Display the second as a number without leading zeros (0-59).
Character ss
Display the second as a number with leading zeros (00-59).
Character t
One character time-marker string, such as A or P
Character tt
Multicharacter time-marker string such as AM or PM
Format Display
m/d/yy ==> 12/7/58
d-MMMM-yy ==> 7-December-58
d-MMMM ==> 7 December
MMMM-yy ==> December 58
h:mm ==> 20:50
h:mm:ss ==> 20:50:35
m/d/yy h:mm ==> 12/7/58 20:50
When using dates the custom format is a composite string containing different formats to use depending on the interval:
<day format>;<month format>;<abbreviated year format>;<quarter format>;<year format>
Where:
<day format> = Regular date format (Default = Default Date Format)
<month format> = How the labels are display if the interval is month (default = "MMM")
<abbreviated year format> = When interval is Month or Quarter, the year is displayed when it changes (Default = 'YY)
<quarter format> = When the interval is Quarter. Use {q} as the placeholder for the Quarter number (Default = Q{q})
<year format> = Used when the interval is a year or more.
Note: You can set a CustomFormat for each interval to ensure labels are viewed in the same format.
Axis.getDataFormat()
,
AxisBase.getLabelsFormat()
,
setDecimals(int)
,
Axis
,
Chart
public void setDecimals(int value)
Allows you to set the number of decimals for the selected label, mouseover tip or value.
This property may be used in conjunction with the Axis.getDataFormat()
and AxisBase.getLabelsFormat()
properties.
When a setCustomFormat(java.lang.String)
is applied to a selected axis, any formatting assigned using the Decimals property will be ignored.
Axis.getDataFormat()
,
AxisBase.getLabelsFormat()
,
setCustomFormat(java.lang.String)
,
Axis
public void setFormat(int value)
Used to format the selected label, mouseover tip or value to numbers, date, time, scientific or currency.
AxisFormat :
Defines the valid formats to may be apply to an axis.Value | Description |
---|---|
AxisFormat.NONE | Displays a Number without formatting. |
AxisFormat.NUMBER | Displays a Number, as defined in the International section of the Control Panel. |
AxisFormat.CURRENCY | Displays Currency, as defined in the International section of the Control Panel. |
AxisFormat.SCIENTIFIC | Displays standard scientific notation. |
AxisFormat.PERCENTAGE | Displays numbers multiplied by 100 with a percent sign (%) appended to the right; display two digits to the right of the decimal separator. |
AxisFormat.DATE | Displays a Short Date, as defined in the International section of the Control Panel. |
AxisFormat.LONG_DATE | Displays a Long Date, as defined in the International section of the Control Panel. |
AxisFormat.TIME | Displays Time, as defined in the International section of the Control Panel. |
AxisFormat.DATE_TIME | Displays Date-Time, as defined in the International section of the Control Panel. |
This property may be used in conjunction with the Axis.getDataFormat()
and AxisBase.getLabelsFormat()
properties.
Axis.getDataFormat()
,
AxisBase.getLabelsFormat()
,
Axis
|
http://www.softwarefx.com | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |