|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JPanel com.jidesoft.chart.Legend
public class Legend
A graphical component to display a legend corresponding to a Chart. Usually a Legend is generated as one entry per ChartModel displayed in the Chart, but sometimes, such as when displaying a pie chart, it is more useful to display a legend item for every point in a model. To use this mode, set the generateFromPoints property to be true. (See the comments on setGenerateFromPoints() for more details on how to name the items in the legend.)
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static int |
CENTER
|
static int |
LEADING
|
static int |
LEFT
|
static String |
PROPERTY_AT_FRONT
|
static String |
PROPERTY_COLUMNS
|
static String |
PROPERTY_GENERATE_FROM_POINTS
|
static String |
PROPERTY_KEY_LABEL_GAP
|
static String |
PROPERTY_LABEL_COLOR
|
static String |
PROPERTY_LEGEND_BACKGROUND
|
static String |
PROPERTY_ORDER_REVERSED
|
static String |
PROPERTY_ROLLOVER_MODEL
|
static String |
PROPERTY_TITLE
|
static String |
PROPERTY_TITLE_COLOR
|
static String |
PROPERTY_TITLE_LABEL
|
static int |
RIGHT
|
static int |
TRAILING
|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
Legend()
Create a Legend object. |
|
Legend(boolean wrap,
int alignment)
|
|
Legend(Chart chart)
Create a Legend from the supplied chart and using 1 column for the layout of the entries |
|
Legend(Chart chart,
boolean wrap)
Create a Legend as a row of items that optionally wrap around when there is not enough space |
|
Legend(Chart chart,
boolean wrap,
int alignment)
Create a Legend as a row of items. |
|
Legend(Chart chart,
int cols)
Create a Legend from the supplied chart and using the supplied number of columns |
Method Summary | |
---|---|
void |
addChart(Chart chart)
Add a chart to the legend; i.e. |
void |
addExcludedModels(ChartModel... models)
Exclude the supplied models from the Legend |
void |
addExcludedPoints(Chartable... points)
Exclude the supplied points from the Legend (when using generateFromPoints) |
Legend |
addIncludedModel(ChartModel model)
|
Legend |
addLegendItem(LegendItem item)
|
void |
clear()
Clear references to all charts from this legend object. |
void |
clearExcludedModels()
Empty out the set of excluded models |
void |
clearExcludedPoints()
Empty out the set of excluded points |
protected JLabel |
createLegendLabel(Chartable chartable)
|
protected JLabel |
createLegendLabel(ChartModel model)
|
protected JLabel |
createLegendLabel(String labelString)
|
protected com.jidesoft.chart.LegendPair |
createLegendPair(LegendItem legendItem,
JLabel label)
|
protected JLabel |
createLegendTitle(String titleString)
|
protected LegendItem |
createModelLegendItem(ChartModel model,
Chart chart)
|
protected LegendItem |
createPointLegendItem(Chartable chartable,
ChartModel model,
Chart chart)
|
void |
draw(Graphics g)
By implementing the Drawable interface, it makes it possible for
a Legend to be added to be displayed within a chart rather than just next to it. |
int |
getKeyLabelGap()
Returns the pixel gap between each graphical key item and its label in the legend |
Color |
getLabelColor()
Returns the color used for the labels in the legend |
Paint |
getLegendBackground()
Returns the Paint used for the legend background. |
String |
getTitle()
Returns the title of the legend |
Color |
getTitleColor()
Returns the color used for the title in the legend |
JLabel |
getTitleLabel()
Returns the title label as a component |
boolean |
isAtFront()
Should the Legend be drawn in front of the ChartModels when used as a Drawable? |
boolean |
isGenerateFromPoints()
Returns whether the legend is generated based on points. |
boolean |
isOrderReversed()
Returns whether the order of the elements is reversed or the same as the order in which they were added to the chart. |
void |
paintComponent(Graphics g)
|
void |
removeChart(Chart chart)
Remove the models contained by the supplied chart from the legend |
void |
removeExcludedModels(ChartModel... models)
Remove the supplied models from the set of models that have been excluded from the Legend |
void |
removeExcludedPoints(Chartable... points)
Remove the supplied points from the set of points to exclude from the Legend |
Legend |
removeIncludedModel(ChartModel model)
|
Legend |
removeLegendItem(LegendItem item)
|
void |
setAtFront(boolean atFront)
Specify whether the Legend should appear in front of the chart models when added as a Drawable to the chart. |
void |
setBorder(Border border)
This method modifies the default behaviour of JComponent. |
void |
setColumns(int columns)
Set the number of columns to use for the items in the legend. |
void |
setFont(Font font)
Sets the font to use for the Legend items |
void |
setGenerateFromPoints(boolean generateFromPoints)
By default a Legend will be generated as one entry per chart model that is displayed on the chart. |
void |
setKeyLabelGap(int keyLabelGap)
Specify the gap in pixels between each graphical key item and its label in the legend |
void |
setLabelColor(Color labelColor)
Specify the color to use for the labels in the legend |
void |
setLegendBackground(Paint background)
Specifies the Paint to use for the background of the Legend. |
void |
setOrderReversed(boolean orderReversed)
Specify whether the order of iterating through the models should be reversed when generating the legend. |
void |
setTitle(String title)
Set the title to use for this legend. |
void |
setTitleColor(Color titleColor)
Specifies the color to use for the title of the legend |
void |
setTitleLabel(JLabel titleLabel)
Sets the title for this legend |
protected void |
updateLegend()
Recreate the legend object, taking account of the specified number of columns |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int LEFT
public static final int CENTER
public static final int LEADING
public static final int RIGHT
public static final int TRAILING
public static final String PROPERTY_GENERATE_FROM_POINTS
public static final String PROPERTY_TITLE
public static final String PROPERTY_TITLE_COLOR
public static final String PROPERTY_COLUMNS
public static final String PROPERTY_KEY_LABEL_GAP
public static final String PROPERTY_LABEL_COLOR
public static final String PROPERTY_LEGEND_BACKGROUND
public static final String PROPERTY_ORDER_REVERSED
public static final String PROPERTY_AT_FRONT
public static final String PROPERTY_TITLE_LABEL
public static final String PROPERTY_ROLLOVER_MODEL
Constructor Detail |
---|
public Legend()
public Legend(boolean wrap, int alignment)
public Legend(Chart chart)
chart
- the chart for which to create a legendpublic Legend(Chart chart, boolean wrap)
chart
- the chart from which the legend items are to be takenwrap
- whether to allow legend items to wrap around to the next rowpublic Legend(Chart chart, boolean wrap, int alignment)
wrap
is set to true, then the alignment parameter
is used in the layout.
chart
- the chart from which the legend items are to be takenwrap
- whether to allow legend items to wrap around to the next rowalignment
- when wrap is true, the horizontal alignment used for legend items. One of LEFT, CENTER, RIGHT, LEADING or TRAILING.LEFT
,
RIGHT
,
CENTER
,
LEADING
,
TRAILING
public Legend(Chart chart, int cols)
chart
- the chart for which to create a legendcols
- the number of columns to use in the layout of the legendMethod Detail |
---|
public int getKeyLabelGap()
public void setKeyLabelGap(int keyLabelGap)
keyLabelGap
- the gap in pixelspublic Paint getLegendBackground()
public void setLegendBackground(Paint background)
background
- the Paint to use for the background of the Legendpublic Color getLabelColor()
public void setLabelColor(Color labelColor)
labelColor
- the color to use for the legend labelspublic Color getTitleColor()
public void setTitleColor(Color titleColor)
titleColor
- the color to use in the title of the legendpublic void addExcludedModels(ChartModel... models)
models
- the models to exclude from the Legendpublic void removeExcludedModels(ChartModel... models)
models
- the models to remove the excluded setpublic void clearExcludedModels()
public Legend addIncludedModel(ChartModel model)
public Legend removeIncludedModel(ChartModel model)
public Legend addLegendItem(LegendItem item)
public Legend removeLegendItem(LegendItem item)
public void addExcludedPoints(Chartable... points)
points
- the points to exclude from the Legendpublic void removeExcludedPoints(Chartable... points)
points
- the points to reinstate as Legend itemspublic void clearExcludedPoints()
public void setBorder(Border border)
setBorder
in class JComponent
public void addChart(Chart chart)
chart
- the chart to add to the Legendpublic void removeChart(Chart chart)
chart
- the chart for which the models should be removedpublic void setColumns(int columns)
columns
- the number of columns to use for items in the legendpublic void clear()
public String getTitle()
public void setTitle(String title)
getTitleLabel()
and then modify it; or create the label
yourself and supply it using the setTitleLabel()
method.
title
- the title to use for the legendgetTitleLabel()
,
setTitleLabel(JLabel)
public JLabel getTitleLabel()
public void setTitleLabel(JLabel titleLabel)
titleLabel
- the ready-made JLabel to use for the titlepublic boolean isGenerateFromPoints()
public void setGenerateFromPoints(boolean generateFromPoints)
ChartPoint
, for instance), then the name is taken from the
name property of the object.
generateFromPoints
- whether to generate the legend based on pointspublic boolean isOrderReversed()
public void setOrderReversed(boolean orderReversed)
orderReversed
- whether to reverse the orderpublic void setFont(Font font)
setFont
in class JComponent
font
- the font to use for the Legend itemsprotected void updateLegend()
protected LegendItem createPointLegendItem(Chartable chartable, ChartModel model, Chart chart)
protected LegendItem createModelLegendItem(ChartModel model, Chart chart)
protected com.jidesoft.chart.LegendPair createLegendPair(LegendItem legendItem, JLabel label)
protected JLabel createLegendLabel(Chartable chartable)
protected JLabel createLegendLabel(ChartModel model)
protected JLabel createLegendLabel(String labelString)
protected JLabel createLegendTitle(String titleString)
public boolean isAtFront()
isAtFront
in interface Frontable
public void setAtFront(boolean atFront)
setAtFront
in interface Frontable
atFront
- whether the object is to be shown in front of ChartModels.public void draw(Graphics g)
Drawable
interface, it makes it possible for
a Legend to be added to be displayed within a chart rather than just next to it.
draw
in interface Drawable
g
- the Graphics context onto which the legend should be drawnpublic void paintComponent(Graphics g)
paintComponent
in class JComponent
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |