Chart FX for Java 6.5

SoftwareFX.ChartFX
Class ConstantLine

java.lang.Object
  extended by SoftwareFX.ChartFX.Line
      extended by SoftwareFX.ChartFX.ConstantLine

public final class ConstantLine
extends Line

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()
          Gets the Alignment.
 int getAxis()
          Gets the Axis.
 int getFlags()
          Gets the Flags.
 java.awt.Font getFont()
          Gets the Font.
 int getLineAlignment()
          Gets the LineAlignment.
 Link getLink()
          Gets the Link object for a selected ConstantLine item.
 int getPoint()
          Gets the Point.
 int getSeries()
          Gets the Series.
 java.lang.String getText()
          Gets the Text.
 java.awt.Color getTextColor()
          Gets the TextColor.
 java.lang.String getURL()
          Deprecated. You should use ConstantLine.getLink().getUrl instead.
 double getValue()
          Gets the Value.
 boolean isOutsideText()
          Gets the OutsideText.
 boolean isShowLine()
          Gets the ShowLine.
 boolean isShowText()
          Gets the ShowText.
 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 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 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.
 
Methods inherited from class SoftwareFX.ChartFX.Line
getColor, getEndCap, getStartCap, getStyle, getWidth, setColor, setEndCap, setStartCap, setStyle, setWidth
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConstantLine

public ConstantLine()
Method Detail

getAlignment

public int getAlignment()

Gets the Alignment. For more detail see setAlignment(int).


getAxis

public int getAxis()

Gets the Axis. For more detail see setAxis(int).


getFlags

public int getFlags()

Gets the Flags. For more detail see setFlags(int).


getFont

public java.awt.Font getFont()

Gets the Font. For more detail see setFont(java.awt.Font).


getLineAlignment

public int getLineAlignment()

Gets the LineAlignment. For more detail see setLineAlignment(int).


getLink

public Link getLink()

Gets the Link object for a selected ConstantLine item.

Remarks:
  • 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.

  • See Also:
    Link.setUrl(java.lang.String), Link.setTarget(java.lang.String), Link

    getPoint

    public int getPoint()

    Gets the Point. For more detail see setPoint(int).


    getSeries

    public int getSeries()

    Gets the Series. For more detail see setSeries(int).


    getText

    public java.lang.String getText()

    Gets the Text. For more detail see setText(java.lang.String).


    getTextColor

    public java.awt.Color getTextColor()

    Gets the TextColor. For more detail see setTextColor(java.awt.Color).


    getURL

    public java.lang.String getURL()
    Deprecated. You should use ConstantLine.getLink().getUrl instead.

    See Also:
    getLink()

    getValue

    public double getValue()

    Gets the Value. For more detail see setValue(double).


    isOutsideText

    public boolean isOutsideText()

    Gets the OutsideText. For more detail see setOutsideText(boolean).


    isShowLine

    public boolean isShowLine()

    Gets the ShowLine. For more detail see setShowLine(boolean).


    isShowText

    public boolean isShowText()

    Gets the ShowText. For more detail see setShowText(boolean).


    setAlignment

    public void setAlignment(int value)

    Specifies the alignment for the constant line text relative to the configured X or Y axis.

    Values:
    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.
    ValueDescription
    StringAlignment.STRING_ALIGNMENT_NEARSpecifies 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.
    StringAlignment.STRING_ALIGNMENT_CENTERSpecifies that alignment is centered between origin and extent (width) of the formatting rectangle.
    StringAlignment.STRING_ALIGNMENT_FARSpecifies that alignment is to the far extent (right side) of the formatting rectangle.

    Remarks:
  • 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 StripeStripe Class .

  • In the following chart, the constant line Alignment has been set to StringAlignment.Center:

  • See Also:
    setAxis(int), setFont(java.awt.Font), setText(java.lang.String), setValue(double), Stripe

    setAxis

    public void setAxis(int value)

    Used to associate the selected constant line with one of the axes.

    Values:
    AxisItem : Allows Axis selection for properties needing axis assignment.
    ValueDescription
    AxisItem.YPrimary Y Axis.
    AxisItem.Y2Secondary Y Axis.
    AxisItem.XPrimary X Axis.
    AxisItem.X2Secondary X Axis.

    Remarks:
  • 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 Class .

  • In this chart, the constant line has been configured to the X axis:

  • See Also:
    setAlignment(int), Line.setColor(java.awt.Color), Line.setStyle(int), setText(java.lang.String), setValue(double), Stripe, Line

    setFlags

    public void setFlags(int value)

    Used to control additional settings for the selected constant line.

    Values:
    ConstantFlag : ConstantLine enums.
    ValueDescription
    ConstantFlag.DEFAULTSets all constant line styles back to default.
    ConstantFlag.HIDE_TEXTDoes not display label associated with the selected constant line.
    ConstantFlag.HIDEHides the selected constant line and text.
    ConstantFlag.BACK_ONLYDraws constant line only in the background of the 3D wall when chart is in 3D mode.
    ConstantFlag.COLOR_TEXTMakes text color same color as constant line.
    ConstantFlag.HIDE_LINEHides the selected constant line.
    ConstantFlag.OUTSIDE_TEXTDisplays the text for the constant line outside the chart area.
    ConstantFlag.SHOW_VALUEDescription goes here

    Remarks:
  • 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.

  • See Also:
    setAxis(int), setFont(java.awt.Font), setText(java.lang.String), setTextColor(java.awt.Color), Axis.setStyle(int), Stripe, Axis, Line

    setFont

    public void setFont(java.awt.Font value)

    Allows you to modify the text font attributes for the selected constant line.

    Remarks:
  • 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.

  • See Also:
    setAlignment(int), setText(java.lang.String), setTextColor(java.awt.Color), Chart.setFont(java.awt.Font), Chart

    setLineAlignment

    public void setLineAlignment(int value)

    Specifies the alignment of the constant line text relative to the constant line object.

    Values:
    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.
    ValueDescription
    StringAlignment.STRING_ALIGNMENT_NEARSpecifies 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.
    StringAlignment.STRING_ALIGNMENT_CENTERSpecifies that alignment is centered between origin and extent (width) of the formatting rectangle.
    StringAlignment.STRING_ALIGNMENT_FARSpecifies that alignment is to the far extent (right side) of the formatting rectangle.

    Remarks:
  • 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:

  • See Also:
    setAxis(int), setFont(java.awt.Font), setShowText(boolean), setText(java.lang.String), setValue(double), Stripe

    setOutsideText

    public void setOutsideText(boolean value)

    Allows you to position the constant line text outside the chart area.

    Remarks:
  • 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:

  • See Also:
    setText(java.lang.String), setShowText(boolean), Chart

    setPoint

    public void setPoint(int value)

    Gets or sets a value indicating the point a ConstantLine is associated.

    Remarks:
  • When utilizing the Highlight feature, developers may want to associate a SeriesAttributes or PointAttributeswith 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.

  • See Also:
    setSeries(int), SeriesAttributes, PointAttributes

    setSeries

    public void setSeries(int value)

    Gets or sets a value indicating the series a ConstantLine is associated.

    Remarks:
  • When utilizing the Highlight feature, developers may want to associate a SeriesAttributesor 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.

  • See Also:
    setPoint(int), SeriesAttributes, PointAttributes

    setShowLine

    public void setShowLine(boolean value)

    Allows you to show or hide a constant line in the chart.

    Remarks:
  • 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.

  • See Also:
    setShowText(boolean), Stripe

    setShowText

    public void setShowText(boolean value)

    Used to show or hide the constant line text in a chart.

    Remarks:
  • 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.

  • See Also:
    setOutsideText(boolean), setShowLine(boolean)

    setText

    public void setText(java.lang.String value)

    Used to set a text label for a selected constant line.

    Remarks:
  • 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 StripeStripe Class .

  • You can change the text color using the setTextColor(java.awt.Color) property.

  • See Also:
    setAlignment(int), setAxis(int), setTextColor(java.awt.Color), setValue(double), Title.setText(java.lang.String), Stripe

    setTextColor

    public void setTextColor(java.awt.Color value)

    Used to change the text color for the constant line text.

    Remarks:
  • 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 StripeStripe Class .

  • For more information regarding the Color type, please refer to the Java API Documentation.

  • See Also:
    setAlignment(int), setAxis(int), setFont(java.awt.Font), setText(java.lang.String), setValue(double), Stripe

    setURL

    public void setURL(java.lang.String value)
    Deprecated. You should use ConstantLine.getLink().setUrl instead.

    See Also:
    getLink()

    setValue

    public void setValue(double value)

    Used to set a value for the selected constant line.

    Remarks:
  • 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 AxisBase.setMin(double) or AxisBase.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 AxisBase.setMax(double)property.

  • To highlight a range of values in a particular axis, please refer to the StripeStripe Class .

  • Here the ConstantLine value has been set to 150.75 on the Y Axis:

  • See Also:
    setAxis(int), Line.setColor(java.awt.Color), Line.setStyle(int), setText(java.lang.String), setTextColor(java.awt.Color), Stripe, Line

    http://www.softwarefx.com

    2007 Software FX, Inc. All Rights Reserved. Chart FX is a registered trademark of Software FX, Inc
    All other names are trademarks or registered trademarks of their respective owners.