public class LegendItemAttributes
extends java.lang.Object
Provides access to the customization of a specific item in the LegendBox.
The LegendItemAttributes
class allows you to configure how SeriesAttributes
, ConditionalAttributes
, CustomGridLine
, or setKeyLabels
of the Axis
are rendered in the LegendBox
.
First, a new LegendItemAttributes object needs to be created. Next, this object needs to be mapped to the specific object it will customize. The final stage consists of modifing methods of the LegendItemAttributes object such as setFontStyle
and setTextColor
. Notice that the isVisible
method is usefull if you do not want a specific object being displayed in the LegendBox
. For example, the following piece of code makes the first setSeries
of the Chart
invisible in the LegendBox
:
PopulateProductSales(chart1); chart1.getTitles().add(new TitleDockable("Wine Sales by Type")); chart1.getAxisY().getLabelsFormat().setFormat(AxisFormat.CURRENCY); LegendItemAttributes item; item = new LegendItemAttributes(); chart1.getData().setSeries(3); chart1.getLegendBox().getItemAttributes().set(((ILegendBoxItemCollection)chart1.getSeries()), 0, item); item.setVisible(false);
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; } }
Constructor and Description |
---|
LegendItemAttributes()
Constructs a newly allocated LegendItemAttributes object
|
Modifier and Type | Method and Description |
---|---|
java.util.EnumSet<FontStyle> |
getFontStyle()
Gets or sets the font style for the legend box item.
|
int |
getOrderIndex()
Gets or sets the index for ordering the LegendBox collections.
|
java.awt.Color |
getTextColor()
Gets or sets a value allowing you to set the text color for the legend item.
|
boolean |
isExpanded()
Allows the LegendBox items to be expanded or contracted.
|
boolean |
isInverted()
Gets or sets a value allowing you to invert the order of the LegendBox Items.
|
boolean |
isVisible()
Gets or sets a value allowing you hide or show the legend item.
|
void |
resetExpanded()
Set the property Expanded to its default value.
|
void |
resetFontStyle()
Set the property FontStyle to its default value.
|
void |
resetHasChildren()
Set the property HasChildren to its default value.
|
void |
resetInverted()
Set the property Inverted to its default value.
|
void |
resetOrderIndex()
Set the property OrderIndex to its default value.
|
void |
resetTextColor()
Set the property TextColor to its default value.
|
void |
resetVisible()
Set the property Visible to its default value.
|
void |
setExpanded(boolean value)
Allows the LegendBox items to be expanded or contracted.
|
void |
setFontStyle(java.util.EnumSet<FontStyle> value)
Gets or sets the font style for the legend box item.
|
void |
setInverted(boolean value)
Gets or sets a value allowing you to invert the order of the LegendBox Items.
|
void |
setOrderIndex(int value)
Gets or sets the index for ordering the LegendBox collections.
|
void |
setTextColor(java.awt.Color value)
Gets or sets a value allowing you to set the text color for the legend item.
|
void |
setVisible(boolean value)
Gets or sets a value allowing you hide or show the legend item.
|
public LegendItemAttributes()
public boolean isExpanded()
Allows the LegendBox items to be expanded or contracted.
chart1.getLegendBox().getItemAttributes().get(chart1.getSeries(), -1).setExpanded(true);
resetExpanded
public void setExpanded(boolean value)
Allows the LegendBox items to be expanded or contracted.
chart1.getLegendBox().getItemAttributes().get(chart1.getSeries(), -1).setExpanded(true);
value
- resetExpanded
public java.util.EnumSet<FontStyle> getFontStyle()
Gets or sets the font style for the legend box item.
For more information regarding the FontStyle type, please refer to the Documentation.
To set the text of the LegendBox for the second series of the chart to Bold:
LegendItemAttributes lia; lia = new LegendItemAttributes(); chart1.getLegendBox().getItemAttributes().set(chart1.getSeries(), 1, lia); lia.setFontStyle(FontStyle.BOLD);
resetFontStyle
public void setFontStyle(java.util.EnumSet<FontStyle> value)
Gets or sets the font style for the legend box item.
For more information regarding the FontStyle type, please refer to the Documentation.
To set the text of the LegendBox for the second series of the chart to Bold:
LegendItemAttributes lia; lia = new LegendItemAttributes(); chart1.getLegendBox().getItemAttributes().set(chart1.getSeries(), 1, lia); lia.setFontStyle(FontStyle.BOLD);
value
- resetFontStyle
public boolean isInverted()
Gets or sets a value allowing you to invert the order of the LegendBox Items.
LegendItemAttributes legendItemAttr;
legendItemAttr = new LegendItemAttributes();
chart1.getLegendBox().getItemAttributes().set(((ILegendBoxItemCollection)chart1.getSeries()), legendItemAttr);
legendItemAttr.setInverted(false);
PopulateCarProduction(chart1);
chart1.getTitles().add(new TitleDockable("Vehicles Production by Type"));
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; } }
LegendItemAttributes legendItemAttr;
legendItemAttr = new LegendItemAttributes();
chart1.getLegendBox().getItemAttributes().set(((ILegendBoxItemCollection)chart1.getSeries()), legendItemAttr);
legendItemAttr.setInverted(true);
PopulateCarProduction(chart1);
chart1.getTitles().add(new TitleDockable("Vehicles Production by Type"));
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; } }
resetInverted
public void setInverted(boolean value)
Gets or sets a value allowing you to invert the order of the LegendBox Items.
LegendItemAttributes legendItemAttr;
legendItemAttr = new LegendItemAttributes();
chart1.getLegendBox().getItemAttributes().set(((ILegendBoxItemCollection)chart1.getSeries()), legendItemAttr);
legendItemAttr.setInverted(false);
PopulateCarProduction(chart1);
chart1.getTitles().add(new TitleDockable("Vehicles Production by Type"));
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; } }
LegendItemAttributes legendItemAttr;
legendItemAttr = new LegendItemAttributes();
chart1.getLegendBox().getItemAttributes().set(((ILegendBoxItemCollection)chart1.getSeries()), legendItemAttr);
legendItemAttr.setInverted(true);
PopulateCarProduction(chart1);
chart1.getTitles().add(new TitleDockable("Vehicles Production by Type"));
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; } }
value
- resetInverted
public int getOrderIndex()
Gets or sets the index for ordering the LegendBox collections.
resetOrderIndex
public void setOrderIndex(int value)
Gets or sets the index for ordering the LegendBox collections.
value
- resetOrderIndex
public java.awt.Color getTextColor()
Gets or sets a value allowing you to set the text color for the legend item.
For more information regarding the Color type, please refer to the Documentation.
To set the text color of the LegendBox for the second series of the chart to Green:
LegendItemAttributes legendItemAttr;
legendItemAttr = new LegendItemAttributes();
chart1.getLegendBox().getItemAttributes().set(chart1.getSeries(), 1, legendItemAttr);
legendItemAttr.setTextColor(new java.awt.Color(0,128,0,255));
PopulateCarProduction(chart1);
chart1.getTitles().add(new TitleDockable("Vehicles Production by Type"));
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; } }
resetTextColor
public void setTextColor(java.awt.Color value)
Gets or sets a value allowing you to set the text color for the legend item.
For more information regarding the Color type, please refer to the Documentation.
To set the text color of the LegendBox for the second series of the chart to Green:
LegendItemAttributes legendItemAttr;
legendItemAttr = new LegendItemAttributes();
chart1.getLegendBox().getItemAttributes().set(chart1.getSeries(), 1, legendItemAttr);
legendItemAttr.setTextColor(new java.awt.Color(0,128,0,255));
PopulateCarProduction(chart1);
chart1.getTitles().add(new TitleDockable("Vehicles Production by Type"));
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; } }
value
- resetTextColor
public boolean isVisible()
Gets or sets a value allowing you hide or show the legend item.
When a legend item is hidden in the legend, the chart element will still be displayed in the chart.
To hide set the text of the LegendBox for the second series of the chart:
LegendItemAttributes legendItemAttr; legendItemAttr = new LegendItemAttributes(); chart1.getLegendBox().getItemAttributes().set(chart1.getSeries(), 1, legendItemAttr); legendItemAttr.setVisible(false);
resetVisible
public void setVisible(boolean value)
Gets or sets a value allowing you hide or show the legend item.
When a legend item is hidden in the legend, the chart element will still be displayed in the chart.
To hide set the text of the LegendBox for the second series of the chart:
LegendItemAttributes legendItemAttr; legendItemAttr = new LegendItemAttributes(); chart1.getLegendBox().getItemAttributes().set(chart1.getSeries(), 1, legendItemAttr); legendItemAttr.setVisible(false);
value
- resetVisible
public void resetExpanded()
isExpanded
public void resetFontStyle()
setFontStyle
public void resetHasChildren()
public void resetInverted()
isInverted
public void resetOrderIndex()
setOrderIndex
public void resetTextColor()
setTextColor
public void resetVisible()
isVisible
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.