public final class CustomLegendItem
extends java.lang.Object
Provides access to the customization of a specific custom item in the LegendBox.
A CustomLegendItem is an additional item added to the legend of a chart that contains relevant information to explain what is being depicted in a chart.
The CustomLegendItem fills the void when the series legend and values cannot convey the desired information. The supported members of the CustomLegendItem allow you to configure and add extra legend items to the standard legend box.
PopulateCarProduction(chart1);
chart1.getTitles().add(new TitleDockable("Vehicles Production by Type"));
chart1.setGallery(Gallery.LINES);
Annotations annots;
annots = new Annotations();
chart1.getExtensions().add(((IExtension)annots));
int w;
w = 14;
int h;
h = 14;
AnnotationPolygon polygon;
polygon = new AnnotationPolygon();
SfxNET.System.Drawing.Point[] p;
p = new SfxNET.System.Drawing.Point[] {new SfxNET.System.Drawing.Point(0, (h / 2)), new SfxNET.System.Drawing.Point((w / 2), h), new SfxNET.System.Drawing.Point(w, (h / 2)), new SfxNET.System.Drawing.Point((w / 2), 0)};
polygon.setVertices(p);
polygon.getChartBorder().setColor(new java.awt.Color(255,0,0,255));
polygon.getChartBorder().setWidth((short)2);
polygon.Attach(((DataUnit)6.0), ((DataUnit)10.0));
annots.getList().add(((AnnotationObject)polygon));
CustomLegendItem legendItem;
legendItem = new CustomLegendItem();
legendItem.setText("New Fiscal Year");
legendItem.setColor(new java.awt.Color(255,0,0,255));
legendItem.setMarkerShape(MarkerShape.DIAMOND);
chart1.getLegendBox().getCustomItems().add(legendItem);
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; } }
Constructor and Description |
---|
CustomLegendItem()
Constructs a newly allocated CustomLegendItem object
|
Modifier and Type | Method and Description |
---|---|
java.awt.Color |
getAlternateColor()
Gets or sets the background color of a custom legend item marker when a pattern is configured using the Pattern property.
|
PointAttributes |
getAttributes()
Gets or sets the PointAttributes object for the custom legend item.
|
BorderAttributes |
getBorder()
Gets a BorderAttributes object allowing you to modify the border properties for this CustomLegendItem.
|
java.awt.Color |
getColor()
Gets or sets the Color for the marker of the Custom Legend Item.
|
com.softwarefx.server.Link |
getLink()
Gets the Link object allowing you to associate a url to a CustomLegendItem.
|
MarkerShape |
getMarkerShape()
Represents the shape of the marker.
|
CustomLegendItem |
getParent()
Gets or sets a parent CustomLegendItem object
|
HatchStyle |
getPattern()
Gets or sets a HatchStyle pattern for the marker of a CustomLegendItem.
|
java.awt.Image |
getPicture()
Gets or sets an image to be used as a marker for a CustomLegendItem.
|
java.lang.String |
getText()
Gets or sets the text string of the custom legend item.
|
boolean |
isShowLine()
Gets or sets a value used to display a line marker for a CustomLegendItem.
|
void |
resetShowLine()
Set the property ShowLine to its default value.
|
void |
setAlternateColor(java.awt.Color value)
Gets or sets the background color of a custom legend item marker when a pattern is configured using the Pattern property.
|
void |
setAttributes(PointAttributes value)
Gets or sets the PointAttributes object for the custom legend item.
|
void |
setColor(java.awt.Color value)
Gets or sets the Color for the marker of the Custom Legend Item.
|
void |
setMarkerShape(MarkerShape value)
Represents the shape of the marker.
|
void |
setParent(CustomLegendItem value)
Gets or sets a parent CustomLegendItem object
|
void |
setPattern(HatchStyle value)
Gets or sets a HatchStyle pattern for the marker of a CustomLegendItem.
|
void |
setPicture(java.awt.Image value)
Gets or sets an image to be used as a marker for a CustomLegendItem.
|
void |
setShowLine(boolean value)
Gets or sets a value used to display a line marker for a CustomLegendItem.
|
void |
setText(java.lang.String value)
Gets or sets the text string of the custom legend item.
|
public CustomLegendItem()
public java.awt.Color getAlternateColor()
CustomLegendItem item; item = new CustomLegendItem(); item.setColor(new java.awt.Color(255,0,0,255)); item.setAlternateColor(new java.awt.Color(0,0,255,255)); item.setPattern(HatchStyle.BACKWARD_DIAGONAL); chart1.getLegendBox().getCustomItems().add(item);
public void setAlternateColor(java.awt.Color value)
CustomLegendItem item; item = new CustomLegendItem(); item.setColor(new java.awt.Color(255,0,0,255)); item.setAlternateColor(new java.awt.Color(0,0,255,255)); item.setPattern(HatchStyle.BACKWARD_DIAGONAL); chart1.getLegendBox().getCustomItems().add(item);
value
- public PointAttributes getAttributes()
CustomLegendItem item; item = new CustomLegendItem(); item.setColor(new java.awt.Color(255,0,0,255)); item.setText("Custom Item 1"); item.getAttributes().setMarkerSize((short)3); chart1.getLegendBox().getCustomItems().add(item);
public void setAttributes(PointAttributes value)
CustomLegendItem item; item = new CustomLegendItem(); item.setColor(new java.awt.Color(255,0,0,255)); item.setText("Custom Item 1"); item.getAttributes().setMarkerSize((short)3); chart1.getLegendBox().getCustomItems().add(item);
value
- public BorderAttributes getBorder()
Gets a BorderAttributes object allowing you to modify the border properties for this CustomLegendItem.
CustomLegendItem c;
c = new CustomLegendItem();
c.setText("Custom Item");
c.getChartBorder().setColor(new java.awt.Color(0,0,0,255));
chart1.getLegendBox().getCustomItems().add(c);
chart1.setGallery(Gallery.BAR);
PopulateBirthVariation(chart1);
chart1.getTitles().add(new TitleDockable("Data Birth Variation"));
public static void PopulateBirthVariation(Chart chart1) { BirthVariation[] variations = new BirthVariation[] { new BirthVariation("2007", 4.5, 4.9 ), new BirthVariation("2008", -1.8, 1.2 ), new BirthVariation("2009", 2.3, -2.6 ), new BirthVariation("2010", 2.0, 3.0), new BirthVariation("2011", -0.5, -1.7 ), new BirthVariation("2012", 3.1, -0.9 ) }; ObjectProvider objProvider = new ObjectProvider(variations); chart1.getDataSourceSettings().setDataSource(objProvider); }
public static class BirthVariation { public BirthVariation(String year, double male, double female) { this.setYear(year); this.setMale(male); this.setFemale(female); } private String privateYear; public final String getYear() { return privateYear; } public final void setYear(String value) { privateYear = value; } private double privateMale; public final double getMale() { return privateMale; } public final void setMale(double value) { privateMale = value; } private double privateFemale; public final double getFemale() { return privateFemale; } public final void setFemale(double value) { privateFemale = value; } }
public java.awt.Color getColor()
Gets or sets the Color for the marker of the Custom Legend Item.
Named colors are supported (e.g. Red), to use Hex notation you have to use quotes (e.g. "#FF00FF").
For more information regarding the Color type, please refer to the Documentation.
To set the color of the Custom Legend Item:
chart1.getLegendBox().getCustomItems().get(0).setColor(new java.awt.Color(165,42,42,255));
public void setColor(java.awt.Color value)
Gets or sets the Color for the marker of the Custom Legend Item.
Named colors are supported (e.g. Red), to use Hex notation you have to use quotes (e.g. "#FF00FF").
For more information regarding the Color type, please refer to the Documentation.
To set the color of the Custom Legend Item:
chart1.getLegendBox().getCustomItems().get(0).setColor(new java.awt.Color(165,42,42,255));
value
- public com.softwarefx.server.Link getLink()
chart1.getLegendBox().getCustomItems().get(0).getLink().setUrl("http://www.softwarefx.com");
public MarkerShape getMarkerShape()
Represents the shape of the marker.
If you hide the markers using the MarkerShape.None method, labels will be numbered.
The MarkerShape BorderAttributes may be configured by accessing the setBorder
method.
Selects an inverted triangles as the marker shape for the first custom legend item:
chart1.getLegendBox().getCustomItems().get(0).setMarkerShape(MarkerShape.INVERTED_TRIANGLE);
public void setMarkerShape(MarkerShape value)
Represents the shape of the marker.
If you hide the markers using the MarkerShape.None method, labels will be numbered.
The MarkerShape BorderAttributes may be configured by accessing the setBorder
method.
Selects an inverted triangles as the marker shape for the first custom legend item:
chart1.getLegendBox().getCustomItems().get(0).setMarkerShape(MarkerShape.INVERTED_TRIANGLE);
value
- public CustomLegendItem getParent()
CustomLegendItem ParentCustomLegendItem; ParentCustomLegendItem = new CustomLegendItem(); CustomLegendItem ChildCustomLegendItem; ChildCustomLegendItem = new CustomLegendItem(); ChildCustomLegendItem.setParent(ParentCustomLegendItem);
public void setParent(CustomLegendItem value)
CustomLegendItem ParentCustomLegendItem; ParentCustomLegendItem = new CustomLegendItem(); CustomLegendItem ChildCustomLegendItem; ChildCustomLegendItem = new CustomLegendItem(); ChildCustomLegendItem.setParent(ParentCustomLegendItem);
value
- public HatchStyle getPattern()
CustomLegendItem item; item = new CustomLegendItem(); chart1.getLegendBox().getCustomItems().add(item); item.setText("Warning"); item.setMarkerShape(MarkerShape.RECT); item.setColor(new java.awt.Color(255,0,0,255)); item.setAlternateColor(new java.awt.Color(0,0,255,255)); item.setPattern(HatchStyle.BACKWARD_DIAGONAL);
public void setPattern(HatchStyle value)
CustomLegendItem item; item = new CustomLegendItem(); chart1.getLegendBox().getCustomItems().add(item); item.setText("Warning"); item.setMarkerShape(MarkerShape.RECT); item.setColor(new java.awt.Color(255,0,0,255)); item.setAlternateColor(new java.awt.Color(0,0,255,255)); item.setPattern(HatchStyle.BACKWARD_DIAGONAL);
value
- public java.awt.Image getPicture()
Gets or sets an image to be used as a marker for a CustomLegendItem.
Setting this method will override any settings configured using the setMarkerShape
method.
Sets the first custom item marker to an image:
File imageFile = new File("image.png"); BufferedImage image = ImageIO.read(imageFile); chart1.getLegendBox().getCustomItems().get(0).setPicture(image);
public void setPicture(java.awt.Image value)
Gets or sets an image to be used as a marker for a CustomLegendItem.
Setting this method will override any settings configured using the setMarkerShape
method.
Sets the first custom item marker to an image:
File imageFile = new File("image.png"); BufferedImage image = ImageIO.read(imageFile); chart1.getLegendBox().getCustomItems().get(0).setPicture(image);
value
- public boolean isShowLine()
CustomLegendItem item; item = new CustomLegendItem(); item.setColor(new java.awt.Color(255,0,0,255)); item.setText("Custom Item 1"); item.setMarkerShape(MarkerShape.CIRCLE); item.setShowLine(true); chart1.getLegendBox().getCustomItems().add(item);
resetShowLine
public void setShowLine(boolean value)
CustomLegendItem item; item = new CustomLegendItem(); item.setColor(new java.awt.Color(255,0,0,255)); item.setText("Custom Item 1"); item.setMarkerShape(MarkerShape.CIRCLE); item.setShowLine(true); chart1.getLegendBox().getCustomItems().add(item);
value
- resetShowLine
public java.lang.String getText()
Gets or sets the text string of the custom legend item.
The setText
method of the LegendBox
object is used to access the CustomLegendItemCollection object of a chart. By accessing a CustomLegendItem from the collection, you can modify the text of the item using this method.
The setTextColor
method is used to control the color for a legend's text.
To add a custom legend item:
CustomLegendItem c; c = new CustomLegendItem(); c.setText("Custom Item"); c.setMarkerShape(MarkerShape.MARBLE); c.setColor(new java.awt.Color(255,165,0,255)); chart1.getLegendBox().getCustomItems().add(c);
public void setText(java.lang.String value)
Gets or sets the text string of the custom legend item.
The setText
method of the LegendBox
object is used to access the CustomLegendItemCollection object of a chart. By accessing a CustomLegendItem from the collection, you can modify the text of the item using this method.
The setTextColor
method is used to control the color for a legend's text.
To add a custom legend item:
CustomLegendItem c; c = new CustomLegendItem(); c.setText("Custom Item"); c.setMarkerShape(MarkerShape.MARBLE); c.setColor(new java.awt.Color(255,165,0,255)); chart1.getLegendBox().getCustomItems().add(c);
value
- public void resetShowLine()
isShowLine
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.