public class CustomGridLine extends Line
Provides access to the CustomGridLine object.
CustomGridLines are one of the most useful objects when it comes to highlighting information in the chart area. You may want to create a Line to highlight limits or specific points of interest in the chart. For example, in a scientific application, you may want to use the CustomGridLine to highlight an alarm limit, or in a financial application, you may want to use the CustomGridLine to highlight a target price or date.
CustomGridLines 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:
PopulateCarProduction(chart1);
chart1.getTitles().add(new TitleDockable("Monthly Vehicles Production by Type"));
/* Add a custom grid line to the Y axis *\/
CustomGridLine custom;
custom = new CustomGridLine();
custom.setValue(1000);
custom.setColor(new java.awt.Color(255,0,0,255));
custom.setStyle(DashStyle.DASH);
custom.getTitle().setText("Minimum Production Allowed");
custom.getTitle().setFont(new java.awt.Font("Segoe UI",java.awt.Font.PLAIN, 7));
custom.getTitle().setTextColor(new java.awt.Color(139,0,0,255));
chart1.getAxisY().getCustomGridLines().add(custom);
/* Add a custom grid line to the X axis *\/
custom = new CustomGridLine();
custom.setValue(6.5);
custom.setColor(new java.awt.Color(0,128,0,255));
custom.setWidth((short)2);
custom.getTitle().setText("New Fiscal Year");
custom.getTitle().setFont(new java.awt.Font("Segoe UI",java.awt.Font.PLAIN, 8));
custom.getTitle().setTextColor(new java.awt.Color(0,100,0,255));
chart1.getAxisX().getCustomGridLines().add(custom);
chart1.getLegendBox().getItemAttributes().get(((ILegendBoxItemCollection)chart1.getAxisY().getCustomGridLines())).setVisible(false);
chart1.getLegendBox().getItemAttributes().get(((ILegendBoxItemCollection)chart1.getAxisX().getCustomGridLines())).setVisible(false);
public static void PopulateCarProduction(Chart chart1) { CarProduction[] production = new CarProduction[] { new CarProduction("Jan", 1760, 535, 695 ) , new CarProduction("Feb", 1849, 395, 688 ) , new CarProduction("Mar", 2831, 685, 1047 ) , new CarProduction("Apr", 2851, 984, 1652 ) , new CarProduction("May", 2961, 1579, 1889 ) , new CarProduction("Jun", 1519, 1539, 1766 ) , new CarProduction("Jul", 2633, 1489, 1361 ) , new CarProduction("Aug", 1140, 650, 874 ) , new CarProduction("Sep", 1626, 653, 693 ) , new CarProduction("Oct", 1478, 2236, 786 ) , new CarProduction("Nov", 1306, 1937, 599 ) , new CarProduction("Dec", 1607, 2138, 678 ) }; ObjectProvider objProvider = new ObjectProvider(production); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class CarProduction { private CarProduction(String month, int sedan, int coupe, int SUV) { this.setMonth(month); this.setSedan(sedan); this.setCoupe(coupe); this.setSUV(SUV); } private String privateMonth; public final String getMonth() { return privateMonth; } public final void setMonth(String value) { privateMonth = value; } private int privateSedan; public final int getSedan() { return privateSedan; } public final void setSedan(int value) { privateSedan = value; } private int privateCoupe; public final int getCoupe() { return privateCoupe; } public final void setCoupe(int value) { privateCoupe = value; } private int privateSUV; public final int getSUV() { return privateSUV; } public final void setSUV(int value) { privateSUV = value; } }
You can create as many CustomGridLine objects as you need, and you can also configure labels, line width, styles, colors, etc.
If you want to highlight a range of values instead of a specific value, please refer to the AxisSection
.
Constructor and Description |
---|
CustomGridLine()
Constructs a newly allocated CustomGridLine object
|
CustomGridLine(CustomGridLineCalculation value,
java.lang.String text)
Constructs a newly allocated CustomGridLine object
|
CustomGridLine(CustomGridLineValue value,
java.lang.String text)
Constructs a newly allocated CustomGridLine object
|
CustomGridLine(double value,
java.lang.String text)
Constructs a newly allocated CustomGridLine object
|
Modifier and Type | Method and Description |
---|---|
StringAlignment |
getAlignment()
Description goes here
|
java.util.EnumSet<CustomGridLineStyles> |
getExtraStyle()
Allows you to set additional visual attributes in a custom grid line.
|
java.awt.Font |
getFont()
Description goes here
|
ConditionalHighlightAttributes |
getHighlight()
Returns a HighlightCustomGridLineAttributes object for a CustomGridLine.
|
StringAlignment |
getLineAlignment()
Description goes here
|
com.softwarefx.server.Link |
getLink()
Gets the Link Object for a selected CustomGridLine.
|
SeriesReference |
getSeries()
Returns the associated series for a CustomGridLine.
|
java.lang.String |
getText()
Description goes here
|
java.awt.Color |
getTextColor()
Description goes here
|
Title |
getTitle()
Gets or sets the title for a specific CustomGridLine.
|
CustomGridLineValue |
getValue()
Gets or sets the Value for a CustomGridLine.
|
double |
getValueDouble()
Gets or sets the Value for a CustomGridLine.
|
boolean |
isAdjustable()
Allows to move the selected CustomGridLine using the mouse.
|
boolean |
isOutsideText()
Gets or Set the OutsideText which controls the positioning of the CustomGridLine label outside the chart area.
|
boolean |
isShowLine()
Gets or Set the ShowLine, which shows or hides the CustomGridLine line.
|
boolean |
isShowText()
Gets or Set the Showtext, which shows or hides the CustomGridLine text.
|
void |
resetExtraStyle()
Set the property ExtraStyle to its default value.
|
void |
resetOutsideText()
Set the property OutsideText to its default value.
|
void |
resetShowLine()
Set the property ShowLine to its default value.
|
void |
resetShowText()
Set the property ShowText to its default value.
|
void |
setAdjustable(boolean value)
Allows to move the selected CustomGridLine using the mouse.
|
void |
setAlignment(StringAlignment value)
Description goes here
|
void |
setExtraStyle(java.util.EnumSet<CustomGridLineStyles> value)
Allows you to set additional visual attributes in a custom grid line.
|
void |
setFont(java.awt.Font value)
Description goes here
|
void |
setLineAlignment(StringAlignment value)
Description goes here
|
void |
setOutsideText(boolean value)
Set the OutsideText which controls the positioning of the CustomGridLine label outside the chart area.
|
void |
setShowLine(boolean value)
Set the ShowLine, which shows or hides the CustomGridLine line.
|
void |
setShowText(boolean value)
Set the Showtext, which shows or hides the CustomGridLine text.
|
void |
setText(java.lang.String value)
Description goes here
|
void |
setTextColor(java.awt.Color value)
Description goes here
|
void |
setValue(CustomGridLineCalculation value)
Gets or sets the Value for a CustomGridLine.
|
void |
setValue(CustomGridLineValue value)
Gets or sets the Value for a CustomGridLine.
|
void |
setValue(double value)
Gets or sets the Value for a CustomGridLine.
|
getColor, getEndCap, getStartCap, getStyle, getWidth, resetColor, resetEndCap, resetSeriesIndex, resetStartCap, resetStyle, resetWidth, setColor, setEndCap, setStartCap, setStyle, setWidth
public CustomGridLine()
public CustomGridLine(CustomGridLineCalculation value, java.lang.String text)
value
- text
- public CustomGridLine(CustomGridLineValue value, java.lang.String text)
value
- text
- public CustomGridLine(double value, java.lang.String text)
value
- text
- public boolean isAdjustable()
CustomGridLine customGridLine; customGridLine = new CustomGridLine(((CustomGridLineValue)100.0), "Upper Limit"); customGridLine.setAdjustable(true); chart1.getAxisY().getCustomGridLines().add(customGridLine);
public void setAdjustable(boolean value)
CustomGridLine customGridLine; customGridLine = new CustomGridLine(((CustomGridLineValue)100.0), "Upper Limit"); customGridLine.setAdjustable(true); chart1.getAxisY().getCustomGridLines().add(customGridLine);
value
- public StringAlignment getAlignment()
public void setAlignment(StringAlignment value)
value
- public java.util.EnumSet<CustomGridLineStyles> getExtraStyle()
chart1.getAxisY().getCustomGridLines().add(new CustomGridLine(((CustomGridLineValue)30.0), "test")); java.util.EnumSet<CustomGridLineStyles> style = chart1.getAxisY().getCustomGridLines().get(0).getExtraStyle(); style.add(CustomGridLineStyles.HIDE_TEXT); chart1.getAxisY().getCustomGridLines().get(0).setExtraStyle(style);
resetExtraStyle
public void setExtraStyle(java.util.EnumSet<CustomGridLineStyles> value)
chart1.getAxisY().getCustomGridLines().add(new CustomGridLine(((CustomGridLineValue)30.0), "test")); java.util.EnumSet<CustomGridLineStyles> style = chart1.getAxisY().getCustomGridLines().get(0).getExtraStyle(); style.add(CustomGridLineStyles.HIDE_TEXT); chart1.getAxisY().getCustomGridLines().get(0).setExtraStyle(style);
value
- resetExtraStyle
public java.awt.Font getFont()
public void setFont(java.awt.Font value)
value
- public ConditionalHighlightAttributes getHighlight()
public StringAlignment getLineAlignment()
public void setLineAlignment(StringAlignment value)
value
- public com.softwarefx.server.Link getLink()
CustomGridLine cgl; cgl = new CustomGridLine(((CustomGridLineValue)100.0), "Limit"); cgl.getLink().setUrl("http://www.softwarefx.com"); chart1.getAxisY().getCustomGridLines().add(cgl);
public boolean isOutsideText()
Gets or Set the OutsideText which controls the positioning of the CustomGridLine label outside the chart area.
CustomGridLine customGridLine;
customGridLine = new CustomGridLine(((CustomGridLineValue)50000.0), "Upper Limit");
customGridLine.setOutsideText(true);
chart1.getAxisY().getCustomGridLines().add(customGridLine);
PopulateProductSales(chart1);
chart1.getTitles().add(new TitleDockable("Wine Sales by Type"));
chart1.getAxisY().getLabelsFormat().setFormat(AxisFormat.CURRENCY);
public static void PopulateProductSales(Chart chart1) { ProductSales[] data = new ProductSales[]{ new ProductSales("Jan", 12560, 23400, 34500), new ProductSales("Feb", 13400, 21000, 38900), new ProductSales("Mar", 16700, 17000, 42100), new ProductSales("Apr", 12000, 19020, 43800), new ProductSales("May", 15800, 26500, 37540), new ProductSales("Jun", 9800, 27800, 32580), new ProductSales("Jul", 17800, 29820, 34000), new ProductSales("Aug", 19800, 17800, 38000), new ProductSales("Sep", 23200, 32000, 41300), new ProductSales("Oct", 16700, 26500, 46590), new ProductSales("Nov", 11800, 23000, 48700), new ProductSales("Dec", 13400, 15400, 49100) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class ProductSales { public ProductSales(String month, double white, double red, double sparkling) { this.setMonth(month); this.setWhite(white); this.setRed(red); this.setSparkling(sparkling); } private String privateMonth; public final String getMonth() { return privateMonth; } public final void setMonth(String value) { privateMonth = value; } private double privateWhite; public final double getWhite() { return privateWhite; } public final void setWhite(double value) { privateWhite = value; } private double privateRed; public final double getRed() { return privateRed; } public final void setRed(double value) { privateRed = value; } private double privateSparkling; public final double getSparkling() { return privateSparkling; } public final void setSparkling(double value) { privateSparkling = value; } }
resetOutsideText
public void setOutsideText(boolean value)
Set the OutsideText which controls the positioning of the CustomGridLine label outside the chart area.
CustomGridLine customGridLine;
customGridLine = new CustomGridLine(((CustomGridLineValue)50000.0), "Upper Limit");
customGridLine.setOutsideText(true);
chart1.getAxisY().getCustomGridLines().add(customGridLine);
PopulateProductSales(chart1);
chart1.getTitles().add(new TitleDockable("Wine Sales by Type"));
chart1.getAxisY().getLabelsFormat().setFormat(AxisFormat.CURRENCY);
public static void PopulateProductSales(Chart chart1) { ProductSales[] data = new ProductSales[]{ new ProductSales("Jan", 12560, 23400, 34500), new ProductSales("Feb", 13400, 21000, 38900), new ProductSales("Mar", 16700, 17000, 42100), new ProductSales("Apr", 12000, 19020, 43800), new ProductSales("May", 15800, 26500, 37540), new ProductSales("Jun", 9800, 27800, 32580), new ProductSales("Jul", 17800, 29820, 34000), new ProductSales("Aug", 19800, 17800, 38000), new ProductSales("Sep", 23200, 32000, 41300), new ProductSales("Oct", 16700, 26500, 46590), new ProductSales("Nov", 11800, 23000, 48700), new ProductSales("Dec", 13400, 15400, 49100) }; ObjectProvider objProvider = new ObjectProvider(data); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class ProductSales { public ProductSales(String month, double white, double red, double sparkling) { this.setMonth(month); this.setWhite(white); this.setRed(red); this.setSparkling(sparkling); } private String privateMonth; public final String getMonth() { return privateMonth; } public final void setMonth(String value) { privateMonth = value; } private double privateWhite; public final double getWhite() { return privateWhite; } public final void setWhite(double value) { privateWhite = value; } private double privateRed; public final double getRed() { return privateRed; } public final void setRed(double value) { privateRed = value; } private double privateSparkling; public final double getSparkling() { return privateSparkling; } public final void setSparkling(double value) { privateSparkling = value; } }
value
- resetOutsideText
public SeriesReference getSeries()
Returns the associated series for a CustomGridLine.
public boolean isShowLine()
Gets or Set the ShowLine, which shows or hides the CustomGridLine line.
CustomGridLine customGridLine; customGridLine = new CustomGridLine(((CustomGridLineValue)100.0), "Upper Limit"); customGridLine.setShowLine(false); chart1.getAxisY().getCustomGridLines().add(customGridLine);
resetShowLine
public void setShowLine(boolean value)
Set the ShowLine, which shows or hides the CustomGridLine line.
CustomGridLine customGridLine; customGridLine = new CustomGridLine(((CustomGridLineValue)100.0), "Upper Limit"); customGridLine.setShowLine(false); chart1.getAxisY().getCustomGridLines().add(customGridLine);
value
- resetShowLine
public boolean isShowText()
Gets or Set the Showtext, which shows or hides the CustomGridLine text.
CustomGridLine customGridLine; customGridLine = new CustomGridLine(((CustomGridLineValue)100.0), "Upper Limit"); customGridLine.setShowText(false); chart1.getAxisY().getCustomGridLines().add(customGridLine);
resetShowText
public void setShowText(boolean value)
Set the Showtext, which shows or hides the CustomGridLine text.
CustomGridLine customGridLine; customGridLine = new CustomGridLine(((CustomGridLineValue)100.0), "Upper Limit"); customGridLine.setShowText(false); chart1.getAxisY().getCustomGridLines().add(customGridLine);
value
- resetShowText
public java.lang.String getText()
public void setText(java.lang.String value)
value
- public java.awt.Color getTextColor()
public void setTextColor(java.awt.Color value)
value
- public Title getTitle()
Gets or sets the title for a specific CustomGridLine.
CustomGridLine CustomGridLine1; CustomGridLine1 = new CustomGridLine(); CustomGridLine1.getTitle().setText("Custom GridLine Title"); chart1.getAxisY().getCustomGridLines().add(CustomGridLine1);
public void setValue(CustomGridLineCalculation value)
Gets or sets the Value for a CustomGridLine.
The value of the CustomGridLine goes in strict relationship with the Axis scale that is related to, as follows:
- If the CustomGridLine 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 note that a CustomGridLine 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 CustomGridLine 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 CustomGridLine to; in this case, the CustomGridLine will be drawn starting at the Major tick mark for the selected point.
Please note that if you set a CustomGridLine out of the range of the visible axis scale values, Chart FX will not recalculate the scale and you must set the setMin
or setMax
accordingly so the custom line can be seen.
For example, if you set a value of 1000 for a CustomGridLine in the Y axis, while the Y axis scale is from 0 to 500; then the custom line will not be visible and you will have to set a new maximum value using the setMax
method of the axis that the custom line is attached to in order to see it on the chart.
The CustomGridLine's Value can be set using this method, or by specifying it when creating the CustomGridLine:
To add a CustomGridLine to the Y Axis at 50.75:
CustomGridLine c2; c2 = new CustomGridLine(); c2.setValue(50.75); chart1.getAxisX().getCustomGridLines().add(c2);
value
- public CustomGridLineValue getValue()
Gets or sets the Value for a CustomGridLine.
The value of the CustomGridLine goes in strict relationship with the Axis scale that is related to, as follows:
- If the CustomGridLine 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 note that a CustomGridLine 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 CustomGridLine 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 CustomGridLine to; in this case, the CustomGridLine will be drawn starting at the Major tick mark for the selected point.
Please note that if you set a CustomGridLine out of the range of the visible axis scale values, Chart FX will not recalculate the scale and you must set the setMin
or setMax
accordingly so the custom line can be seen.
For example, if you set a value of 1000 for a CustomGridLine in the Y axis, while the Y axis scale is from 0 to 500; then the custom line will not be visible and you will have to set a new maximum value using the setMax
method of the axis that the custom line is attached to in order to see it on the chart.
The CustomGridLine's Value can be set using this method, or by specifying it when creating the CustomGridLine:
To add a CustomGridLine to the Y Axis at 50.75:
CustomGridLine c2; c2 = new CustomGridLine(); c2.setValue(50.75); chart1.getAxisX().getCustomGridLines().add(c2);
public void setValue(CustomGridLineValue value)
Gets or sets the Value for a CustomGridLine.
The value of the CustomGridLine goes in strict relationship with the Axis scale that is related to, as follows:
- If the CustomGridLine 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 note that a CustomGridLine 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 CustomGridLine 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 CustomGridLine to; in this case, the CustomGridLine will be drawn starting at the Major tick mark for the selected point.
Please note that if you set a CustomGridLine out of the range of the visible axis scale values, Chart FX will not recalculate the scale and you must set the setMin
or setMax
accordingly so the custom line can be seen.
For example, if you set a value of 1000 for a CustomGridLine in the Y axis, while the Y axis scale is from 0 to 500; then the custom line will not be visible and you will have to set a new maximum value using the setMax
method of the axis that the custom line is attached to in order to see it on the chart.
The CustomGridLine's Value can be set using this method, or by specifying it when creating the CustomGridLine:
To add a CustomGridLine to the Y Axis at 50.75:
CustomGridLine c2; c2 = new CustomGridLine(); c2.setValue(50.75); chart1.getAxisX().getCustomGridLines().add(c2);
value
- public double getValueDouble()
Gets or sets the Value for a CustomGridLine.
The value of the CustomGridLine goes in strict relationship with the Axis scale that is related to, as follows:
- If the CustomGridLine 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 note that a CustomGridLine 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 CustomGridLine 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 CustomGridLine to; in this case, the CustomGridLine will be drawn starting at the Major tick mark for the selected point.
Please note that if you set a CustomGridLine out of the range of the visible axis scale values, Chart FX will not recalculate the scale and you must set the setMin
or setMax
accordingly so the custom line can be seen.
For example, if you set a value of 1000 for a CustomGridLine in the Y axis, while the Y axis scale is from 0 to 500; then the custom line will not be visible and you will have to set a new maximum value using the setMax
method of the axis that the custom line is attached to in order to see it on the chart.
The CustomGridLine's Value can be set using this method, or by specifying it when creating the CustomGridLine:
To add a CustomGridLine to the Y Axis at 50.75:
CustomGridLine c2; c2 = new CustomGridLine(); c2.setValue(50.75); chart1.getAxisX().getCustomGridLines().add(c2);
public void setValue(double value)
Gets or sets the Value for a CustomGridLine.
The value of the CustomGridLine goes in strict relationship with the Axis scale that is related to, as follows:
- If the CustomGridLine 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 note that a CustomGridLine 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 CustomGridLine 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 CustomGridLine to; in this case, the CustomGridLine will be drawn starting at the Major tick mark for the selected point.
Please note that if you set a CustomGridLine out of the range of the visible axis scale values, Chart FX will not recalculate the scale and you must set the setMin
or setMax
accordingly so the custom line can be seen.
For example, if you set a value of 1000 for a CustomGridLine in the Y axis, while the Y axis scale is from 0 to 500; then the custom line will not be visible and you will have to set a new maximum value using the setMax
method of the axis that the custom line is attached to in order to see it on the chart.
The CustomGridLine's Value can be set using this method, or by specifying it when creating the CustomGridLine:
To add a CustomGridLine to the Y Axis at 50.75:
CustomGridLine c2; c2 = new CustomGridLine(); c2.setValue(50.75); chart1.getAxisX().getCustomGridLines().add(c2);
value
- public void resetExtraStyle()
setExtraStyle
public void resetOutsideText()
isOutsideText
public void resetShowLine()
isShowLine
public void resetShowText()
isShowText
2014 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.