|
Chart FX for Java 6.2 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectSoftwareFX.ChartFX.ConstantLine
Provides access to the ConstantLine object.
Constant lines are one of the most useful objects when it comes to highlighting information in the chart area. You may want to create a constant line to highlight limits or specific points of interest in the chart. For example, in a scientific application, you may want to use the constant line object to highlight an alarm limit, or in a financial application you may want to use the constant line to highlight a target price or date.
Constant lines are lines that you can draw anywhere in the chart area and they associate themselves with a particular value in the axis that they're assigned to, as illustrated in the following figure.
To create a constant line you don't need a whole new data series and you can also configure labels and line styles, colors and width.
If you want to highlight a range of values instead of a specific value, please refer to the Stripe object.
Constructor Summary | |
ConstantLine()
|
Method Summary | |
int |
getAlignment()
Specifies the alignment for the constant line text relative to the configured X or Y axis. |
int |
getAxis()
Used to associate the selected constant line with one of the axes. |
java.awt.Color |
getColor()
Allows you to set the line color for a selected line. |
int |
getEndCap()
Allows you to configure a marker shape at the ending of a selected line. |
int |
getFlags()
Used to control additional settings for the selected constant line. |
java.awt.Font |
getFont()
Allows you to modify the text font attributes for the selected constant line. |
int |
getLineAlignment()
Specifies the alignment of the constant line text relative to the constant line object. |
Link |
getLink()
Gets the Link object for a selected ConstantLine item. |
int |
getPoint()
Gets or sets a value indicating the point a ConstantLine is associated. |
int |
getSeries()
Gets or sets a value indicating the series a ConstantLine is associated. |
int |
getStartCap()
Allows you to configure a marker shape at the beginning of a selected line. |
int |
getStyle()
Allows you to set the line style for a selected line. |
java.lang.String |
getText()
Used to set a text label for a selected constant line. |
java.awt.Color |
getTextColor()
Used to change the text color for the constant line text. |
java.lang.String |
getURL()
Deprecated. You should use ConstantLine.getLink().getUrl instead. |
double |
getValue()
Used to set a value for the selected constant line. |
int |
getWidth()
Gets or sets the line width for a selected line. |
boolean |
isOutsideText()
Allows you to position the constant line text outside the chart area. |
boolean |
isShowLine()
Allows you to show or hide a constant line in the chart. |
boolean |
isShowText()
Used to show or hide the constant line text in a chart. |
void |
setAlignment(int value)
Specifies the alignment for the constant line text relative to the configured X or Y axis. |
void |
setAxis(int value)
Used to associate the selected constant line with one of the axes. |
void |
setColor(java.awt.Color value)
Allows you to set the line color for a selected line. |
void |
setEndCap(int value)
Allows you to configure a marker shape at the ending of a selected line. |
void |
setFlags(int value)
Used to control additional settings for the selected constant line. |
void |
setFont(java.awt.Font value)
Allows you to modify the text font attributes for the selected constant line. |
void |
setLineAlignment(int value)
Specifies the alignment of the constant line text relative to the constant line object. |
void |
setOutsideText(boolean value)
Allows you to position the constant line text outside the chart area. |
void |
setPoint(int value)
Gets or sets a value indicating the point a ConstantLine is associated. |
void |
setSeries(int value)
Gets or sets a value indicating the series a ConstantLine is associated. |
void |
setShowLine(boolean value)
Allows you to show or hide a constant line in the chart. |
void |
setShowText(boolean value)
Used to show or hide the constant line text in a chart. |
void |
setStartCap(int value)
Allows you to configure a marker shape at the beginning of a selected line. |
void |
setStyle(int value)
Allows you to set the line style for a selected line. |
void |
setText(java.lang.String value)
Used to set a text label for a selected constant line. |
void |
setTextColor(java.awt.Color value)
Used to change the text color for the constant line text. |
void |
setURL(java.lang.String value)
Deprecated. You should use ConstantLine.getLink().setUrl instead. |
void |
setValue(double value)
Used to set a value for the selected constant line. |
void |
setWidth(int value)
Gets or sets the line width for a selected line. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ConstantLine()
Method Detail |
public int getAlignment()
Specifies the alignment for the constant line text relative to the configured X or Y axis.
StringAlignment :
The StringAlignment type specifies how a string is aligned in reference to the bounding rectangle. A bounding rectangle is used to define the area in which the text displays. Value | Description |
STRING_ALIGNMENT_NEAR | Specifies that alignment is towards the origin of the bounding rectangle. May be used for alignment of characters along the line or for alignment of lines within the rectangle. For a right to left bounding rectangle, the origin is at the upper right. |
STRING_ALIGNMENT_CENTER | Specifies that alignment is centered between origin and extent (width) of the formatting rectangle. |
STRING_ALIGNMENT_FAR | Specifies that alignment is to the far extent (right side) of the formatting rectangle. |
You need to specify the constant line text with setText(java.lang.String)
property in order to see the alignment.
In order to create a constant line, you must first set the constant line value with the setValue(double)
property and the axis associated with it using the setAxis(int)
property.
To change the font for constant lines, please refer to the setFont(java.awt.Font)
property.
To highlight a range of values in a particular axis, please refer to the Stripe
Stripe
.
In the following chart, the constant line Alignment has been set to StringAlignment.Center:
setAxis(int)
,
setFont(java.awt.Font)
,
setText(java.lang.String)
,
setValue(double)
,
Stripe
public int getAxis()
Used to associate the selected constant line with one of the axes.
AxisItem :
Allows Axis selection for properties needing axis assignment.Value | Description |
Y | Primary Y Axis. |
Y2 | Secondary Y Axis. |
X | Primary X Axis. |
X2 | Secondary X Axis. |
If no axis is specified, the default axis is the Y axis.
When assigned to any of the Y axes (left or right), the constant line will be a horizontal line that will cross the chart from left to right. When assigned to the X axis, the constant line will be a vertical line that will cross the chart from top to bottom.
Use the setValue(double)
property to set where the constant line will be positioned on the X or Y axis.
It is common practice to label the constant line to indicate what it represents in the chart. For example, a constant line may show the text "Alarm Limit" so the user is aware of its importance. The label for a constant line can be set using the setText(java.lang.String)
Property.
To highlight a range of values in a particular axis, please refer to the Stripe
.
In this chart, the constant line has been configured to the X axis:
setAlignment(int)
,
Line.setColor(java.awt.Color)
,
Line.setStyle(int)
,
setText(java.lang.String)
,
setValue(double)
,
Stripe
,
Line
public java.awt.Color getColor()
Allows you to set the line color for a selected line.
When this property is applied to an axis line, both the primary and secondary axes are affected. For instance, when you change the X axis line color using this property both axes lines above and below the chart area are colored.
You may also control the Line.setWidth(int)
and Line.setStyle(int)
of the selected line using the supported members of the Line .
The Line.setEndCap(int)
and Line.setStartCap(int)
properties allow you to configured various shapes at the beginning and ending of a selected line.
For more information regarding the Color type, please refer to the Java API Documentation.
Line.setEndCap(int)
,
Line.setStartCap(int)
,
Line.setStyle(int)
,
Line.setWidth(int)
,
Chart.getAxisY()
,
Chart.getAxisX()
,
Chart.getConstantLines()
,
Chart
,
ConstantLine
public int getEndCap()
Allows you to configure a marker shape at the ending of a selected line.
LineCap :
Specifies the available cap styles with which a line can end.Value | Description |
ANCHOR_MASK | Specifies a mask used to check whether a line cap is an anchor cap. |
ARROW_ANCHOR | Specifies an arrow-shaped anchor cap. |
CUSTOM | Specifies a custom line cap. |
DIAMOND_ANCHOR | Specifies a diamond anchor cap. |
FLAT | Specifies a flat line cap. |
NO_ANCHOR | Specifies no anchor. |
ROUND | Specifies a round line cap. |
ROUND_ANCHOR | Specifies a round anchor cap. |
SQUARE | Specifies a square line cap. |
SQUARE_ANCHOR | Specifies a square anchor line cap. |
TRIANGLE | Specifies a triangular line cap. |
When this property is applied to an axis line, both the primary and secondary axes are affected. For instance, when you change the X axis EndCap using this property both axes lines above and below the chart area are modified.
An starting marker shape may be applied to lines using the Line.setStartCap(int)
property.
You can also control Line.setColor(java.awt.Color)
, Line.setStyle(int)
and Line.setWidth(int)
for a selected line object using the supported members of the Line .
Line.setStartCap(int)
,
Line.setColor(java.awt.Color)
,
Line.setStyle(int)
,
Line.setWidth(int)
,
Chart.getAxisX()
,
Chart.getAxisY()
,
Chart
public int getFlags()
Used to control additional settings for the selected constant line.
ConstantFlag :
ConstantLine enums.Value | Description |
DEFAULT | Sets all constant line styles back to default. |
HIDE_TEXT | Does not display label associated with the selected constant line. |
HIDE | Hides the selected constant line and text. |
BACK_ONLY | Draws constant line only in the background of the 3D wall when chart is in 3D mode. |
COLOR_TEXT | Makes text color same color as constant line. |
HIDE_LINE | Hides the selected constant line. |
OUTSIDE_TEXT | Displays the text for the constant line outside the chart area. |
SHOW_VALUE | Description goes here |
This property is a word property. This means all settings represent a bit in the word that you need to turn on or off according to the desired result. For this purpose you need to use the bitwise operators (And, Or, Not, Xor) provided by your development tool.
Because it is a word property, you must make sure you use these operators to turn on/off bits and avoid losing previous settings to the property.
For example, if you want to use the ConstantFlag.HideText setting.
The right way of setting this property is:
chart1.getConstantLine(0).setFlags(chart1.getConstantLine(0).getFlags() | ConstantFlag.HIDE_TEXT);
If you type the following code:
chart1.getConstantLine(0).setFlags(ConstantFlag.HIDE_TEXT);
(WRONG!)
you will erase all other settings in the property causing an erratic behavior of the library.
setAxis(int)
,
setFont(java.awt.Font)
,
setText(java.lang.String)
,
setTextColor(java.awt.Color)
,
Axis.setStyle(int)
,
Stripe
,
Axis
,
Line
public java.awt.Font getFont()
Allows you to modify the text font attributes for the selected constant line.
You can set the font for the entire chart using the Chart
class Chart.setFont(java.awt.Font)
property.
When setting a font in Chart FX, you must create a new font object with the desired attributes and assign that object to the desired chart element every time you want to change the font.
For more information regarding the Font type, please refer to the Java API Documentation.
setAlignment(int)
,
setText(java.lang.String)
,
setTextColor(java.awt.Color)
,
Chart.setFont(java.awt.Font)
,
Chart
public int getLineAlignment()
Specifies the alignment of the constant line text relative to the constant line object.
StringAlignment :
The StringAlignment type specifies how a string is aligned in reference to the bounding rectangle. A bounding rectangle is used to define the area in which the text displays. Value | Description |
STRING_ALIGNMENT_NEAR | Specifies that alignment is towards the origin of the bounding rectangle. May be used for alignment of characters along the line or for alignment of lines within the rectangle. For a right to left bounding rectangle, the origin is at the upper right. |
STRING_ALIGNMENT_CENTER | Specifies that alignment is centered between origin and extent (width) of the formatting rectangle. |
STRING_ALIGNMENT_FAR | Specifies that alignment is to the far extent (right side) of the formatting rectangle. |
You need to specify the constant line text with setText(java.lang.String)
property in order to see the alignment.
In order to create a constant line, you must first set the constant line value with the setValue(double)
property and the axis it will be associated to with the setAxis(int)
property.
To change the font for all constant lines in a chart, please refer to the setFont(java.awt.Font)
property.
Use the setShowText(boolean)
property to show or hide the constant line text.
In the following chart, the constant line LineAlignment has been set to StringAlignment.Center:
setAxis(int)
,
setFont(java.awt.Font)
,
setShowText(boolean)
,
setText(java.lang.String)
,
setValue(double)
,
Stripe
public Link getLink()
Gets the Link object for a selected ConstantLine item.
Developers may obtain the Link object for an annotation item using this property. Using the supported Link class members, developers may configure a Link#setURL
and Link.setTarget(java.lang.String)
for the object.
Link.setUrl(java.lang.String)
,
Link.setTarget(java.lang.String)
,
Link
public int getPoint()
Gets or sets a value indicating the point a ConstantLine is associated.
When utilizing the Highlight feature, developers may want to associate a SeriesAttributes
or PointAttributes
with the ConstantLine. When that series or point is highlighted, the ConstantLine object will be highlighted as well.
You can also may also set this property equal to one of the HighlightState enumerations. Specifying Always indicates the constant line will always keep its highlighted state; Never indicates the constant line will never display a highlighted state.
setSeries(int)
,
SeriesAttributes
,
PointAttributes
public int getSeries()
Gets or sets a value indicating the series a ConstantLine is associated.
When utilizing the Highlight feature, developers may want to associate a SeriesAttributes
or PointAttributes
with the ConstantLine. When that series or point is highlighted, the ConstantLine object will be highlighted as well.
You can also may also set this property equal to on of the HighlightState enumerations. Specifying Always indicates the constant line will always keep its highlighted state; Never indicates the constant line will never display a highlighted state.
setPoint(int)
,
SeriesAttributes
,
PointAttributes
public int getStartCap()
Allows you to configure a marker shape at the beginning of a selected line.
LineCap :
Specifies the available cap styles with which a line can end.Value | Description |
ANCHOR_MASK | Specifies a mask used to check whether a line cap is an anchor cap. |
ARROW_ANCHOR | Specifies an arrow-shaped anchor cap. |
CUSTOM | Specifies a custom line cap. |
DIAMOND_ANCHOR | Specifies a diamond anchor cap. |
FLAT | Specifies a flat line cap. |
NO_ANCHOR | Specifies no anchor. |
ROUND | Specifies a round line cap. |
ROUND_ANCHOR | Specifies a round anchor cap. |
SQUARE | Specifies a square line cap. |
SQUARE_ANCHOR | Specifies a square anchor line cap. |
TRIANGLE | Specifies a triangular line cap. |
When this property is applied to an axis line, both the primary and secondary axes are affected. For instance, when you change the X axis StartCap using this property both axes lines above and below the chart area are modified.
An ending marker shape may be applied to lines using the Line.setEndCap(int)
property.
You can also control Line.setColor(java.awt.Color)
, Line.setStyle(int)
and Line.setWidth(int)
for a selected line object using the supported members of the Line .
Line.setEndCap(int)
,
Line.setColor(java.awt.Color)
,
Line.setStyle(int)
,
Line.setWidth(int)
,
Chart.getAxisX()
,
Chart.getAxisY()
,
Chart
public int getStyle()
Allows you to set the line style for a selected line.
DashStyle :
Specifies the style with which dashed lines are drawn.Value | Description |
CUSTOM | Specifies a user-defined custom dash style. |
DASH | Specifies a line consisting of dashes. |
DASH_DOT | Specifies a line consisting of a repeating pattern of dash-dot. |
DASH_DOT_DOT | Specifies a line consisting of a repeating pattern of dash-dot-dot. |
DOT | Specifies a line consisting of dots. |
SOLID | Specifies a solid line. |
When this property is applied to an axis line, both the primary and secondary axes are affected. For instance, when you change the X axis line style using this property both axes lines above and below the chart area are effected.
You may also control the Line.setWidth(int)
and Line.setColor(java.awt.Color)
of the selected line using the supported members of the Line .
The Line.setEndCap(int)
and Line.setStartCap(int)
properties allow you to configured various shapes at the beginning and ending of a selected line.
The image below depicts a 'DashDotDot' Line style assigned to the Y axis:
Line.setEndCap(int)
,
Line.setStartCap(int)
,
Line.setColor(java.awt.Color)
,
Line.setWidth(int)
,
Chart.getAxisY()
,
Chart.getAxisX()
,
Chart.getConstantLines()
,
Chart
,
ConstantLine
public java.lang.String getText()
Used to set a text label for a selected constant line.
When the constant line is associated with any of the Y axes, the default text alignment is Near (Left). On the other hand, if the label is associated with the X axis the default text alignment is Near (bottom). You can modify the text alignment with the setAlignment(int)
property.
In order to create a constant line, you must first set the constant line value with the setValue(double)
property and associate it with an axis using the setAxis(int)
property.
To change the font for all constant lines in a chart, please refer to the setFont(java.awt.Font)
property.
To highlight a range of values on a particular axis, please refer to the Stripe
Stripe
.
You can change the text color using the setTextColor(java.awt.Color)
property.
setAlignment(int)
,
setAxis(int)
,
setTextColor(java.awt.Color)
,
setValue(double)
,
Title.setText(java.lang.String)
,
Stripe
public java.awt.Color getTextColor()
Used to change the text color for the constant line text.
You can add text for the constant line using the setText(java.lang.String)
property.
When the constant line is associated with any of the Y axes, the default text alignment is Near (Left). On the other hand, if the label is associated with the X axis the default text alignment is Near (bottom). You can modify the text alignment with the setAlignment(int)
property.
In order to create a constant line, you must first set the constant line value with the setValue(double)
property and associate it with an axis using the setAxis(int)
property.
To change the font for all constant lines in a chart, please refer to the setFont(java.awt.Font)
property.
To highlight a range of values on a particular axis, please refer to the Stripe
Stripe
.
For more information regarding the Color type, please refer to the Java API Documentation.
setAlignment(int)
,
setAxis(int)
,
setFont(java.awt.Font)
,
setText(java.lang.String)
,
setValue(double)
,
Stripe
public java.lang.String getURL()
ConstantLine.getLink().getUrl
instead.
getLink()
public double getValue()
Used to set a value for the selected constant line.
The value of the constant goes in strict relationship with the Axis scale that is related to, as follows:
- If the constant line is associated with a numerical axis, the value of the constant is a double according to the scale values set for that particular axis. Please remember a constant line may be associated to the X axis in an XY Plot where the X axis is a numerical axis with specific scale values.
- If the constant line is associated with a categorical axis (X axis in charts other than XY Plots), the value is an integer specifying the point index you want to associate the constant line to. In these cases, the constant line will be drawn starting at the Major tick mark for the selected point.
Please note that if you set a constant line out of the range of the visible axis scale values, Chart FX will not recalculate the scale and you must set the Axis.setMin(double)
or Axis.setMax(double)
accordingly so the constant line can be seen.
For example, if you set a value of 1000 for a constant line in the Y axis, while the Y axis scale is from 0 to 500. The constant line will not be visible and you must set a new maximum value using the Axis.setMax(double)
property.
To highlight a range of values in a particular axis, please refer to the Stripe
Stripe
.
Here the ConstantLine value has been set to 150.75 on the Y Axis:
setAxis(int)
,
Line.setColor(java.awt.Color)
,
Line.setStyle(int)
,
setText(java.lang.String)
,
setTextColor(java.awt.Color)
,
Stripe
,
Line
public int getWidth()
Gets or sets the line width for a selected line.
When this property is applied to an axis line, both the primary and secondary axes are affected. For instance, when you change the X axis line width using this property both axes lines above and below the chart area are effected.
You may also control the Line.setStyle(int)
and Line.setColor(java.awt.Color)
of the selected line using the supported members of the Line .
The Line.setEndCap(int)
and Line.setStartCap(int)
properties allow you to configured various shapes at the beginning and ending of a selected line.
Line.setEndCap(int)
,
Line.setStartCap(int)
,
Line.setStyle(int)
,
Line.setColor(java.awt.Color)
,
Chart.getAxisY()
,
Chart.getAxisX()
,
Chart.getConstantLines()
,
Chart
,
ConstantLine
public boolean isOutsideText()
Allows you to position the constant line text outside the chart area.
When this property is set to True, the text associated with the constant line is placed in the axis label area. (outside the charting area)
In the following chart, the constant line text is set as OutsideText:
setText(java.lang.String)
,
setShowText(boolean)
,
Chart
public boolean isShowLine()
Allows you to show or hide a constant line in the chart.
When you hide a constant line using this property, any text associated with the line will remain in the chart. Use the ShowText property to show or hide the constant line text.
setShowText(boolean)
,
Stripe
public boolean isShowText()
Used to show or hide the constant line text in a chart.
If you hide the text for a selected constant line, the constant line is still visible. To hide the constant line use the setShowLine(boolean)
property.
To configure the constant line text outside the chart area, use the setOutsideText(boolean)
property.
setOutsideText(boolean)
,
setShowLine(boolean)
public void setAlignment(int value)
Specifies the alignment for the constant line text relative to the configured X or Y axis.
StringAlignment :
The StringAlignment type specifies how a string is aligned in reference to the bounding rectangle. A bounding rectangle is used to define the area in which the text displays. Value | Description |
STRING_ALIGNMENT_NEAR | Specifies that alignment is towards the origin of the bounding rectangle. May be used for alignment of characters along the line or for alignment of lines within the rectangle. For a right to left bounding rectangle, the origin is at the upper right. |
STRING_ALIGNMENT_CENTER | Specifies that alignment is centered between origin and extent (width) of the formatting rectangle. |
STRING_ALIGNMENT_FAR | Specifies that alignment is to the far extent (right side) of the formatting rectangle. |
You need to specify the constant line text with setText(java.lang.String)
property in order to see the alignment.
In order to create a constant line, you must first set the constant line value with the setValue(double)
property and the axis associated with it using the setAxis(int)
property.
To change the font for constant lines, please refer to the setFont(java.awt.Font)
property.
To highlight a range of values in a particular axis, please refer to the Stripe
Stripe
.
In the following chart, the constant line Alignment has been set to StringAlignment.Center:
setAxis(int)
,
setFont(java.awt.Font)
,
setText(java.lang.String)
,
setValue(double)
,
Stripe
public void setAxis(int value)
Used to associate the selected constant line with one of the axes.
AxisItem :
Allows Axis selection for properties needing axis assignment.Value | Description |
Y | Primary Y Axis. |
Y2 | Secondary Y Axis. |
X | Primary X Axis. |
X2 | Secondary X Axis. |
If no axis is specified, the default axis is the Y axis.
When assigned to any of the Y axes (left or right), the constant line will be a horizontal line that will cross the chart from left to right. When assigned to the X axis, the constant line will be a vertical line that will cross the chart from top to bottom.
Use the setValue(double)
property to set where the constant line will be positioned on the X or Y axis.
It is common practice to label the constant line to indicate what it represents in the chart. For example, a constant line may show the text "Alarm Limit" so the user is aware of its importance. The label for a constant line can be set using the setText(java.lang.String)
Property.
To highlight a range of values in a particular axis, please refer to the Stripe
.
In this chart, the constant line has been configured to the X axis:
setAlignment(int)
,
Line.setColor(java.awt.Color)
,
Line.setStyle(int)
,
setText(java.lang.String)
,
setValue(double)
,
Stripe
,
Line
public void setColor(java.awt.Color value)
Allows you to set the line color for a selected line.
When this property is applied to an axis line, both the primary and secondary axes are affected. For instance, when you change the X axis line color using this property both axes lines above and below the chart area are colored.
You may also control the Line.setWidth(int)
and Line.setStyle(int)
of the selected line using the supported members of the Line .
The Line.setEndCap(int)
and Line.setStartCap(int)
properties allow you to configured various shapes at the beginning and ending of a selected line.
For more information regarding the Color type, please refer to the Java API Documentation.
Line.setEndCap(int)
,
Line.setStartCap(int)
,
Line.setStyle(int)
,
Line.setWidth(int)
,
Chart.getAxisY()
,
Chart.getAxisX()
,
Chart.getConstantLines()
,
Chart
,
ConstantLine
public void setEndCap(int value)
Allows you to configure a marker shape at the ending of a selected line.
LineCap :
Specifies the available cap styles with which a line can end.Value | Description |
ANCHOR_MASK | Specifies a mask used to check whether a line cap is an anchor cap. |
ARROW_ANCHOR | Specifies an arrow-shaped anchor cap. |
CUSTOM | Specifies a custom line cap. |
DIAMOND_ANCHOR | Specifies a diamond anchor cap. |
FLAT | Specifies a flat line cap. |
NO_ANCHOR | Specifies no anchor. |
ROUND | Specifies a round line cap. |
ROUND_ANCHOR | Specifies a round anchor cap. |
SQUARE | Specifies a square line cap. |
SQUARE_ANCHOR | Specifies a square anchor line cap. |
TRIANGLE | Specifies a triangular line cap. |
When this property is applied to an axis line, both the primary and secondary axes are affected. For instance, when you change the X axis EndCap using this property both axes lines above and below the chart area are modified.
An starting marker shape may be applied to lines using the Line.setStartCap(int)
property.
You can also control Line.setColor(java.awt.Color)
, Line.setStyle(int)
and Line.setWidth(int)
for a selected line object using the supported members of the Line .
Line.setStartCap(int)
,
Line.setColor(java.awt.Color)
,
Line.setStyle(int)
,
Line.setWidth(int)
,
Chart.getAxisX()
,
Chart.getAxisY()
,
Chart
public void setFlags(int value)
Used to control additional settings for the selected constant line.
ConstantFlag :
ConstantLine enums.Value | Description |
DEFAULT | Sets all constant line styles back to default. |
HIDE_TEXT | Does not display label associated with the selected constant line. |
HIDE | Hides the selected constant line and text. |
BACK_ONLY | Draws constant line only in the background of the 3D wall when chart is in 3D mode. |
COLOR_TEXT | Makes text color same color as constant line. |
HIDE_LINE | Hides the selected constant line. |
OUTSIDE_TEXT | Displays the text for the constant line outside the chart area. |
SHOW_VALUE | Description goes here |
This property is a word property. This means all settings represent a bit in the word that you need to turn on or off according to the desired result. For this purpose you need to use the bitwise operators (And, Or, Not, Xor) provided by your development tool.
Because it is a word property, you must make sure you use these operators to turn on/off bits and avoid losing previous settings to the property.
For example, if you want to use the ConstantFlag.HideText setting.
The right way of setting this property is:
chart1.getConstantLine(0).setFlags(chart1.getConstantLine(0).getFlags() | ConstantFlag.HIDE_TEXT);
If you type the following code:
chart1.getConstantLine(0).setFlags(ConstantFlag.HIDE_TEXT);
(WRONG!)
you will erase all other settings in the property causing an erratic behavior of the library.
setAxis(int)
,
setFont(java.awt.Font)
,
setText(java.lang.String)
,
setTextColor(java.awt.Color)
,
Axis.setStyle(int)
,
Stripe
,
Axis
,
Line
public void setFont(java.awt.Font value)
Allows you to modify the text font attributes for the selected constant line.
You can set the font for the entire chart using the Chart
class Chart.setFont(java.awt.Font)
property.
When setting a font in Chart FX, you must create a new font object with the desired attributes and assign that object to the desired chart element every time you want to change the font.
For more information regarding the Font type, please refer to the Java API Documentation.
setAlignment(int)
,
setText(java.lang.String)
,
setTextColor(java.awt.Color)
,
Chart.setFont(java.awt.Font)
,
Chart
public void setLineAlignment(int value)
Specifies the alignment of the constant line text relative to the constant line object.
StringAlignment :
The StringAlignment type specifies how a string is aligned in reference to the bounding rectangle. A bounding rectangle is used to define the area in which the text displays. Value | Description |
STRING_ALIGNMENT_NEAR | Specifies that alignment is towards the origin of the bounding rectangle. May be used for alignment of characters along the line or for alignment of lines within the rectangle. For a right to left bounding rectangle, the origin is at the upper right. |
STRING_ALIGNMENT_CENTER | Specifies that alignment is centered between origin and extent (width) of the formatting rectangle. |
STRING_ALIGNMENT_FAR | Specifies that alignment is to the far extent (right side) of the formatting rectangle. |
You need to specify the constant line text with setText(java.lang.String)
property in order to see the alignment.
In order to create a constant line, you must first set the constant line value with the setValue(double)
property and the axis it will be associated to with the setAxis(int)
property.
To change the font for all constant lines in a chart, please refer to the setFont(java.awt.Font)
property.
Use the setShowText(boolean)
property to show or hide the constant line text.
In the following chart, the constant line LineAlignment has been set to StringAlignment.Center:
setAxis(int)
,
setFont(java.awt.Font)
,
setShowText(boolean)
,
setText(java.lang.String)
,
setValue(double)
,
Stripe
public void setOutsideText(boolean value)
Allows you to position the constant line text outside the chart area.
When this property is set to True, the text associated with the constant line is placed in the axis label area. (outside the charting area)
In the following chart, the constant line text is set as OutsideText:
setText(java.lang.String)
,
setShowText(boolean)
,
Chart
public void setPoint(int value)
Gets or sets a value indicating the point a ConstantLine is associated.
When utilizing the Highlight feature, developers may want to associate a SeriesAttributes
or PointAttributes
with the ConstantLine. When that series or point is highlighted, the ConstantLine object will be highlighted as well.
You can also may also set this property equal to one of the HighlightState enumerations. Specifying Always indicates the constant line will always keep its highlighted state; Never indicates the constant line will never display a highlighted state.
setSeries(int)
,
SeriesAttributes
,
PointAttributes
public void setSeries(int value)
Gets or sets a value indicating the series a ConstantLine is associated.
When utilizing the Highlight feature, developers may want to associate a SeriesAttributes
or PointAttributes
with the ConstantLine. When that series or point is highlighted, the ConstantLine object will be highlighted as well.
You can also may also set this property equal to on of the HighlightState enumerations. Specifying Always indicates the constant line will always keep its highlighted state; Never indicates the constant line will never display a highlighted state.
setPoint(int)
,
SeriesAttributes
,
PointAttributes
public void setShowLine(boolean value)
Allows you to show or hide a constant line in the chart.
When you hide a constant line using this property, any text associated with the line will remain in the chart. Use the ShowText property to show or hide the constant line text.
setShowText(boolean)
,
Stripe
public void setShowText(boolean value)
Used to show or hide the constant line text in a chart.
If you hide the text for a selected constant line, the constant line is still visible. To hide the constant line use the setShowLine(boolean)
property.
To configure the constant line text outside the chart area, use the setOutsideText(boolean)
property.
setOutsideText(boolean)
,
setShowLine(boolean)
public void setStartCap(int value)
Allows you to configure a marker shape at the beginning of a selected line.
LineCap :
Specifies the available cap styles with which a line can end.Value | Description |
ANCHOR_MASK | Specifies a mask used to check whether a line cap is an anchor cap. |
ARROW_ANCHOR | Specifies an arrow-shaped anchor cap. |
CUSTOM | Specifies a custom line cap. |
DIAMOND_ANCHOR | Specifies a diamond anchor cap. |
FLAT | Specifies a flat line cap. |
NO_ANCHOR | Specifies no anchor. |
ROUND | Specifies a round line cap. |
ROUND_ANCHOR | Specifies a round anchor cap. |
SQUARE | Specifies a square line cap. |
SQUARE_ANCHOR | Specifies a square anchor line cap. |
TRIANGLE | Specifies a triangular line cap. |
When this property is applied to an axis line, both the primary and secondary axes are affected. For instance, when you change the X axis StartCap using this property both axes lines above and below the chart area are modified.
An ending marker shape may be applied to lines using the Line.setEndCap(int)
property.
You can also control Line.setColor(java.awt.Color)
, Line.setStyle(int)
and Line.setWidth(int)
for a selected line object using the supported members of the Line .
Line.setEndCap(int)
,
Line.setColor(java.awt.Color)
,
Line.setStyle(int)
,
Line.setWidth(int)
,
Chart.getAxisX()
,
Chart.getAxisY()
,
Chart
public void setStyle(int value)
Allows you to set the line style for a selected line.
DashStyle :
Specifies the style with which dashed lines are drawn.Value | Description |
CUSTOM | Specifies a user-defined custom dash style. |
DASH | Specifies a line consisting of dashes. |
DASH_DOT | Specifies a line consisting of a repeating pattern of dash-dot. |
DASH_DOT_DOT | Specifies a line consisting of a repeating pattern of dash-dot-dot. |
DOT | Specifies a line consisting of dots. |
SOLID | Specifies a solid line. |
When this property is applied to an axis line, both the primary and secondary axes are affected. For instance, when you change the X axis line style using this property both axes lines above and below the chart area are effected.
You may also control the Line.setWidth(int)
and Line.setColor(java.awt.Color)
of the selected line using the supported members of the Line .
The Line.setEndCap(int)
and Line.setStartCap(int)
properties allow you to configured various shapes at the beginning and ending of a selected line.
The image below depicts a 'DashDotDot' Line style assigned to the Y axis:
Line.setEndCap(int)
,
Line.setStartCap(int)
,
Line.setColor(java.awt.Color)
,
Line.setWidth(int)
,
Chart.getAxisY()
,
Chart.getAxisX()
,
Chart.getConstantLines()
,
Chart
,
ConstantLine
public void setText(java.lang.String value)
Used to set a text label for a selected constant line.
When the constant line is associated with any of the Y axes, the default text alignment is Near (Left). On the other hand, if the label is associated with the X axis the default text alignment is Near (bottom). You can modify the text alignment with the setAlignment(int)
property.
In order to create a constant line, you must first set the constant line value with the setValue(double)
property and associate it with an axis using the setAxis(int)
property.
To change the font for all constant lines in a chart, please refer to the setFont(java.awt.Font)
property.
To highlight a range of values on a particular axis, please refer to the Stripe
Stripe
.
You can change the text color using the setTextColor(java.awt.Color)
property.
setAlignment(int)
,
setAxis(int)
,
setTextColor(java.awt.Color)
,
setValue(double)
,
Title.setText(java.lang.String)
,
Stripe
public void setTextColor(java.awt.Color value)
Used to change the text color for the constant line text.
You can add text for the constant line using the setText(java.lang.String)
property.
When the constant line is associated with any of the Y axes, the default text alignment is Near (Left). On the other hand, if the label is associated with the X axis the default text alignment is Near (bottom). You can modify the text alignment with the setAlignment(int)
property.
In order to create a constant line, you must first set the constant line value with the setValue(double)
property and associate it with an axis using the setAxis(int)
property.
To change the font for all constant lines in a chart, please refer to the setFont(java.awt.Font)
property.
To highlight a range of values on a particular axis, please refer to the Stripe
Stripe
.
For more information regarding the Color type, please refer to the Java API Documentation.
setAlignment(int)
,
setAxis(int)
,
setFont(java.awt.Font)
,
setText(java.lang.String)
,
setValue(double)
,
Stripe
public void setURL(java.lang.String value)
ConstantLine.getLink().setUrl
instead.
getLink()
public void setValue(double value)
Used to set a value for the selected constant line.
The value of the constant goes in strict relationship with the Axis scale that is related to, as follows:
- If the constant line is associated with a numerical axis, the value of the constant is a double according to the scale values set for that particular axis. Please remember a constant line may be associated to the X axis in an XY Plot where the X axis is a numerical axis with specific scale values.
- If the constant line is associated with a categorical axis (X axis in charts other than XY Plots), the value is an integer specifying the point index you want to associate the constant line to. In these cases, the constant line will be drawn starting at the Major tick mark for the selected point.
Please note that if you set a constant line out of the range of the visible axis scale values, Chart FX will not recalculate the scale and you must set the Axis.setMin(double)
or Axis.setMax(double)
accordingly so the constant line can be seen.
For example, if you set a value of 1000 for a constant line in the Y axis, while the Y axis scale is from 0 to 500. The constant line will not be visible and you must set a new maximum value using the Axis.setMax(double)
property.
To highlight a range of values in a particular axis, please refer to the Stripe
Stripe
.
Here the ConstantLine value has been set to 150.75 on the Y Axis:
setAxis(int)
,
Line.setColor(java.awt.Color)
,
Line.setStyle(int)
,
setText(java.lang.String)
,
setTextColor(java.awt.Color)
,
Stripe
,
Line
public void setWidth(int value)
Gets or sets the line width for a selected line.
When this property is applied to an axis line, both the primary and secondary axes are affected. For instance, when you change the X axis line width using this property both axes lines above and below the chart area are effected.
You may also control the Line.setStyle(int)
and Line.setColor(java.awt.Color)
of the selected line using the supported members of the Line .
The Line.setEndCap(int)
and Line.setStartCap(int)
properties allow you to configured various shapes at the beginning and ending of a selected line.
Line.setEndCap(int)
,
Line.setStartCap(int)
,
Line.setStyle(int)
,
Line.setColor(java.awt.Color)
,
Chart.getAxisY()
,
Chart.getAxisX()
,
Chart.getConstantLines()
,
Chart
,
ConstantLine
|
http://www.softwarefx.com | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |