|
Chart FX 7 for Java Server | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.softwarefx.chartfx.server.ValueFormat
public class ValueFormat
Provides access to the ValueFormat object.
The ValueFormat members allow you to format values as numbers, dates, currency, scientific and time. These properties may be applied to axis labels (using the Axis.getLabelsFormat()
property of the Axis
Class
), and point labels (using the Axis.getDataFormat()
of the Axis
Class
).
Constructor Summary | |
---|---|
ValueFormat()
|
Method Summary | |
---|---|
String |
formatDateTime(Date dt)
Returns an expression formatted as a date or time. |
String |
formatNumber(double d)
Returns an expression formatted as a number. |
Locale |
getCulture()
Gets the Culture. |
String |
getCustomFormat()
Gets the CustomFormat. |
int |
getDecimals()
Gets the Decimals. |
AxisFormat |
getFormat()
Gets the Format. |
boolean |
isDate()
Returns a value indicating whether or not a value is a Date. |
boolean |
isDateTime()
Returns a value indicating whether or not a value is a DateTime. |
boolean |
isPercentage()
Returns a value indicating whether or not a value is a Percentage. |
boolean |
isTime()
Returns a value indicating whether or not a value is a Time. |
double |
parse(String s)
Converts a formatted expression to a number. |
void |
setCulture(Locale value)
Allows you to localize labels and data for a specific language and region. |
void |
setCustomFormat(String value)
Sets a custom format to the selected label, mouseover tip or value. |
void |
setDecimals(int value)
Sets the number of decimals for the selected label, mouseover tip or value. |
void |
setFormat(AxisFormat 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 String formatDateTime(Date dt)
Returns an expression formatted as a date or time.
The FormatDateTime method returns a string of a DateTime with the same format as the selected Axis.
The formatNumber(double)
method returns a string of a double value with the same format as the selected Axis.
The setFormat(com.softwarefx.chartfx.server.AxisFormat)
property is used to format the selected label, mouseover tip or value to numbers, date, time, scientific or currency.
The setCustomFormat(java.lang.String)
property gets or sets a custom format to the selected label, mouseover tip or value.
The setDecimals(int)
property gets or sets the number of decimals for the selected label, mouseover tip or value.
The Axis.getDataFormat()
and Axis.getLabelsFormat()
properties are used to access the respective ValueFormat objects in a chart.
dt
- Date expression to be formatted.setCustomFormat(java.lang.String)
,
setDecimals(int)
,
setFormat(com.softwarefx.chartfx.server.AxisFormat)
,
Axis.getDataFormat()
,
Axis.getLabelsFormat()
,
formatNumber(double)
,
Axis
public String formatNumber(double d)
Returns an expression formatted as a number.
The FormatNumber method returns a string of a double value with the same format as the selected Axis.
The formatDateTime(java.util.Date)
method returns a string of a DateTime with the same format as the selected Axis.
The setFormat(com.softwarefx.chartfx.server.AxisFormat)
property is used to format the selected label, mouseover tip or value to numbers, date, time, scientific or currency.
The setCustomFormat(java.lang.String)
property gets or sets a custom format to the selected label, mouseover tip or value.
The setDecimals(int)
property gets or sets the number of decimals for the selected label, mouseover tip or value.
The Axis.getDataFormat()
and Axis.getLabelsFormat()
properties are used to access the respective ValueFormat objects in a chart.
d
- Expression to be formatted.setCustomFormat(java.lang.String)
,
setDecimals(int)
,
setFormat(com.softwarefx.chartfx.server.AxisFormat)
,
Axis.getDataFormat()
,
Axis.getLabelsFormat()
,
formatDateTime(java.util.Date)
,
parse(java.lang.String)
,
Axis
public Locale getCulture()
Gets the Culture. For more detail see setCulture(java.util.Locale)
.
public 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 AxisFormat getFormat()
Gets the Format. For more detail see setFormat(com.softwarefx.chartfx.server.AxisFormat)
.
public boolean isDate()
Returns a value indicating whether or not a value is a Date.
The isDateTime()
property returns a value indicating whether a value is a DateTime.
The isPercentage()
property returns a value indicating whether a value is a Percentage.
The isTime()
property returns a value indicating whether a value is a Time.
The Axis.getDataFormat()
and Axis.getLabelsFormat()
properties are used to access the respective ValueFormat objects in a chart.
isDateTime()
,
isPercentage()
,
setFormat(com.softwarefx.chartfx.server.AxisFormat)
,
setCustomFormat(java.lang.String)
,
Axis.getDataFormat()
,
Axis.getLabelsFormat()
,
Axis
public boolean isDateTime()
Returns a value indicating whether or not a value is a DateTime.
The isDate()
property returns a value indicating whether a value is a Date.
The isPercentage()
property returns a value indicating whether a value is a Percentage.
The isTime()
property returns a value indicating whether a value is a Time.
The Axis.getDataFormat()
and Axis.getLabelsFormat()
properties are used to access the respective ValueFormat objects in a chart.
isDate()
,
isPercentage()
,
setFormat(com.softwarefx.chartfx.server.AxisFormat)
,
setCustomFormat(java.lang.String)
,
Axis.getDataFormat()
,
Axis.getLabelsFormat()
,
Axis
public boolean isPercentage()
Returns a value indicating whether or not a value is a Percentage.
The isDateTime()
property returns a value indicating whether a value is a DateTime.
The isTime()
property returns a value indicating whether a value is a Time.
The isDate()
property returns a value indicating whether a value is a Date.
The Axis.getDataFormat()
and Axis.getLabelsFormat()
properties are used to access the respective ValueFormat objects in a chart.
isDate()
,
isDateTime()
,
setFormat(com.softwarefx.chartfx.server.AxisFormat)
,
setCustomFormat(java.lang.String)
,
Axis.getDataFormat()
,
Axis.getLabelsFormat()
,
Axis
public boolean isTime()
Returns a value indicating whether or not a value is a Time.
The isDateTime()
property returns a value indicating whether a value is a DateTime.
The isPercentage()
property returns a value indicating whether a value is a Percentage.
The isDate()
property returns a value indicating whether a value is a Date.
The Axis.getDataFormat()
and Axis.getLabelsFormat()
properties are used to access the respective ValueFormat objects in a chart.
isDate()
,
isDateTime()
,
isPercentage()
,
setFormat(com.softwarefx.chartfx.server.AxisFormat)
,
setCustomFormat(java.lang.String)
,
Axis.getDataFormat()
,
Axis.getLabelsFormat()
,
Axis
public double parse(String s)
Converts a formatted expression to a number.
The Parse method expects a string of the same format as configured for the selected axis. This method is also culturally aware.
The setFormat(com.softwarefx.chartfx.server.AxisFormat)
property is used to format the selected label, mouseover tip or value to numbers, date, time, scientific or currency.
The formatDateTime(java.util.Date)
method returns a string of a DateTime with the same format as the selected Axis.
The formatNumber(double)
method returns a string of a double value with the same format as the selected Axis.
The Axis.getDataFormat()
and Axis.getLabelsFormat()
properties are used to access the respective ValueFormat objects in a chart.
s
- Formatted expression to be parsed.Axis.getDataFormat()
,
Axis.getLabelsFormat()
,
formatNumber(double)
,
formatDateTime(java.util.Date)
,
Axis
public void setCulture(Locale value)
Allows you to localize labels and data for a specific language and region.
Culture attributes set with this property will affect only selected data and labels, to set localization attributes for the entire chart, please use the Chart.setCulture(java.util.Locale)
property of the Chart
Class
.
If no attributes are set using this property or the Chart class Chart.setCulture(java.util.Locale)
property, then Chart FX inherits the system Locale.
When setting this property, you may need the Language Code and/or Country Code constants for the desired culture. For more information, please refer to the Locale
documentation.
Below is the X axis labels set to the "Russian-Russia" culture:
chart1.getAxisX().getLabelsFormat().setFormat(AxisFormat.DATE);
chart1.getAxisY().getLabelsFormat().setFormat(AxisFormat.CURRENCY);
chart1.getAxisX().getLabelsFormat().setCulture(new java.util.Locale("ru", "RU"));
Similarly, the following chart has its Y axis labels set to the "English-Britain" culture:
chart1.getAxisX().getLabelsFormat().setFormat(AxisFormat.DATE);
chart1.getAxisY().getLabelsFormat().setFormat(AxisFormat.CURRENCY);
chart1.getAxisY().getLabelsFormat().setCulture(new java.util.Locale("en", "GB"));
Chart.setCulture(java.util.Locale)
,
Chart.setMessageText(java.lang.String, java.lang.String)
,
Chart
public void setCustomFormat(String value)
Sets a custom format to the selected label, mouseover tip or value.
This property must be invoked before data has been bound or passed to the chart using the Chart.setDataSource(com.softwarefx.chartfx.server.dataproviders.IDataSource)
or Chart.getData()
properties of the Chart
respectively.
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 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
Below, the labels of the X axis display the name of the month as well as the year:
Axis.getDataFormat()
,
Axis.getLabelsFormat()
,
setDecimals(int)
,
setCulture(java.util.Locale)
,
Axis
,
Chart
public void setDecimals(int value)
Sets the number of decimals for the selected label, mouseover tip or value.
When a setCustomFormat(java.lang.String)
is applied to a selected axis, any formatting assigned using the Decimals property will be ignored.
Below, the labels of the chart are rendered with only one decimal:
Axis.getDataFormat()
,
Axis.getLabelsFormat()
,
setCustomFormat(java.lang.String)
,
setCulture(java.util.Locale)
,
Axis
public void setFormat(AxisFormat value)
Used to format the selected label, mouseover tip or value to numbers, date, time, scientific or currency.
Below, the labels of the Y axis are formatted as to the US currency:
Similarly, the labels of the Y axis are here formatted as to the Euro currency when the culture is "France":
Axis.getDataFormat()
,
Axis.getLabelsFormat()
,
setCulture(java.util.Locale)
,
Axis
|
http://www.softwarefx.com | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |