A legend for chart. More...
Public Member Functions | |
Legend (Chart chart, int style) | |
Constructor. | |
void | setVisible (boolean visible) |
Sets legend visible. | |
boolean | isVisible () |
Gets the visibility state. | |
void | setFont (Font font) |
Sets the font. | |
void | setForeground (Color color) |
Sets the foreground color of legend. | |
void | setBackground (Color color) |
Sets the background color of legend. | |
int | getPosition () |
Gets the position of legend. | |
void | setPosition (int value) |
Sets the position of legend. | |
Rectangle | getBounds (String seriesId) |
Gets the rectangle associated with the given series id on legend. | |
void | dispose () |
void | updateLayoutData () |
Update the layout data. | |
void | paintControl (PaintEvent e) |
Protected Member Functions | |
void | drawSymbol (GC gc, Series series, Rectangle r) |
Draws the symbol of series. | |
Private Member Functions | |
ISeries[] | sort (ISeries[] seriesArray) |
Sorts the given series array. | |
Static Private Member Functions | |
static List< ISeries > | sort (List< ISeries > seriesList, boolean isCategoryEnabled, boolean isVertical) |
Sorts the given series list which belongs to a certain x axis. | |
static String | getLegendLabel (ISeries series) |
Gets the legend label. | |
Private Attributes | |
Chart | chart |
the plot chart | |
boolean | visible |
the state indicating the legend visibility | |
int | position |
the position of legend | |
Font | defaultFont |
the default font | |
Map< String, Rectangle > | cellBounds |
the map between series id and cell bounds | |
Static Private Attributes | |
static final int | MARGIN = 5 |
the margin | |
static final int | SYMBOL_WIDTH = 20 |
the width of area to draw symbol | |
static final int | LINE_WIDTH = 2 |
the line width | |
static final Color | DEFAULT_FOREGROUND |
the default foreground | |
static final Color | DEFAULT_BACKGROUND |
the default background | |
static final int | DEFAULT_FONT_SIZE = Constants.SMALL_FONT_SIZE |
the default font size | |
static final int | DEFAULT_POSITION = SWT.RIGHT |
the default position |
A legend for chart.
Definition at line 37 of file Legend.java.
org.swtchart.internal.Legend.Legend | ( | Chart | chart, | |
int | style | |||
) |
Constructor.
chart | the chart | |
style | the style |
Definition at line 85 of file Legend.java.
References org.swtchart.internal.Legend.cellBounds, org.swtchart.internal.Legend.DEFAULT_BACKGROUND, org.swtchart.internal.Legend.DEFAULT_FONT_SIZE, org.swtchart.internal.Legend.DEFAULT_FOREGROUND, org.swtchart.internal.Legend.DEFAULT_POSITION, org.swtchart.internal.Legend.defaultFont, org.swtchart.internal.Legend.position, org.swtchart.internal.Legend.setBackground(), org.swtchart.internal.Legend.setFont(), org.swtchart.internal.Legend.setForeground(), and org.swtchart.internal.Legend.visible.
void org.swtchart.internal.Legend.dispose | ( | ) |
Definition at line 189 of file Legend.java.
References org.swtchart.internal.Legend.defaultFont.
Referenced by org.swtchart.Chart.dispose().
void org.swtchart.internal.Legend.drawSymbol | ( | GC | gc, | |
Series | series, | |||
Rectangle | r | |||
) | [protected] |
Draws the symbol of series.
Definition at line 381 of file Legend.java.
References org.swtchart.internal.Legend.LINE_WIDTH, org.swtchart.internal.Legend.SYMBOL_WIDTH, and org.swtchart.internal.Legend.visible.
Referenced by org.swtchart.internal.Legend.paintControl().
Rectangle org.swtchart.internal.Legend.getBounds | ( | String | seriesId | ) |
Gets the rectangle associated with the given series id on legend.
This method is typically used for mouse listener to check whether mouse cursor is on legend for a certain series.
Mouse listener can be added by casting ILegend
to Control
.
Control legend = (Control) chart.getLegend(); legend.addMouseListener(...);
seriesId | the series id |
Implements org.swtchart.ILegend.
Definition at line 181 of file Legend.java.
References org.swtchart.internal.Legend.cellBounds.
Referenced by org.swtchart.internal.Legend.updateLayoutData().
static String org.swtchart.internal.Legend.getLegendLabel | ( | ISeries | series | ) | [static, private] |
Gets the legend label.
Definition at line 362 of file Legend.java.
References org.swtchart.ISeries.getDescription(), and org.swtchart.ISeries.getId().
Referenced by org.swtchart.internal.Legend.paintControl(), and org.swtchart.internal.Legend.updateLayoutData().
int org.swtchart.internal.Legend.getPosition | ( | ) |
Gets the position of legend.
Implements org.swtchart.ILegend.
Definition at line 161 of file Legend.java.
References org.swtchart.internal.Legend.position.
Referenced by org.swtchart.internal.ChartLayout.adjustForMostLeftRightTickLabel(), org.swtchart.internal.ChartLayout.computePlotAreaSize(), org.swtchart.internal.ChartLayout.layoutBottomAxis(), org.swtchart.internal.ChartLayout.layoutLeftAxis(), org.swtchart.internal.ChartLayout.layoutLegend(), org.swtchart.internal.ChartLayout.layoutPlot(), org.swtchart.internal.ChartLayout.layoutRightAxis(), and org.swtchart.internal.ChartLayout.layoutTopAxis().
boolean org.swtchart.internal.Legend.isVisible | ( | ) |
Gets the visibility state.
Implements org.swtchart.ILegend.
Definition at line 117 of file Legend.java.
References org.swtchart.internal.Legend.visible.
void org.swtchart.internal.Legend.paintControl | ( | PaintEvent | e | ) |
Definition at line 421 of file Legend.java.
References org.swtchart.internal.Legend.cellBounds, org.swtchart.internal.Legend.chart, org.swtchart.internal.Legend.drawSymbol(), org.swtchart.ILegend.getBackground(), org.swtchart.ILegend.getFont(), org.swtchart.ILegend.getForeground(), org.swtchart.ISeries.getId(), org.swtchart.internal.Legend.getLegendLabel(), org.swtchart.ISeriesSet.getSeries(), org.swtchart.Chart.getSeriesSet(), org.swtchart.internal.Legend.MARGIN, org.swtchart.internal.Legend.SYMBOL_WIDTH, and org.swtchart.internal.Legend.visible.
void org.swtchart.internal.Legend.setBackground | ( | Color | color | ) |
Sets the background color of legend.
color | the background color |
Implements org.swtchart.ILegend.
Definition at line 150 of file Legend.java.
References org.swtchart.internal.Legend.DEFAULT_BACKGROUND.
Referenced by org.swtchart.internal.Legend.Legend().
void org.swtchart.internal.Legend.setFont | ( | Font | font | ) |
Sets the font.
font | the font |
Implements org.swtchart.ILegend.
Definition at line 125 of file Legend.java.
References org.swtchart.internal.Legend.chart, org.swtchart.internal.Legend.defaultFont, and org.swtchart.Chart.updateLayout().
Referenced by org.swtchart.internal.Legend.Legend().
void org.swtchart.internal.Legend.setForeground | ( | Color | color | ) |
Sets the foreground color of legend.
color | the foreground color |
Implements org.swtchart.ILegend.
Definition at line 138 of file Legend.java.
References org.swtchart.internal.Legend.DEFAULT_FOREGROUND.
Referenced by org.swtchart.internal.Legend.Legend().
void org.swtchart.internal.Legend.setPosition | ( | int | position | ) |
Sets the position of legend.
If the position is SWT.LEFT
or SWT.RIGHT
, the orientation of series on legend will be vertical. If the position is SWT.TOP
or SWT.BOTTOM
, the orientation will be horizontal.
position | the position of legend that can be SWT.LEFT , SWT.RIGHT , SWT.TOP or SWT.BOTTOM . |
Implements org.swtchart.ILegend.
Definition at line 168 of file Legend.java.
References org.swtchart.internal.Legend.chart, org.swtchart.internal.Legend.DEFAULT_POSITION, org.swtchart.internal.Legend.position, and org.swtchart.Chart.updateLayout().
void org.swtchart.internal.Legend.setVisible | ( | boolean | visible | ) |
Sets legend visible.
visible | the visibility state |
Implements org.swtchart.ILegend.
Definition at line 104 of file Legend.java.
References org.swtchart.internal.Legend.chart, and org.swtchart.Chart.updateLayout().
static List<ISeries> org.swtchart.internal.Legend.sort | ( | List< ISeries > | seriesList, | |
boolean | isCategoryEnabled, | |||
boolean | isVertical | |||
) | [static, private] |
Sorts the given series list which belongs to a certain x axis.
seriesList | the series list which belongs to a certain x axis | |
isCategoryEnabled | true if category is enabled | |
isVertical | true in the case of vertical orientation |
Definition at line 253 of file Legend.java.
Sorts the given series array.
For instance, if there are two stack series in horizontal orientation, the top of stack series should appear at top of legend.
If there are multiple x axes, the given series array will be sorted with x axis first. And then, the series in each x axis will be sorted with Legend#sort(List, boolean, boolean).
seriesArray | the series array |
Definition at line 209 of file Legend.java.
References org.swtchart.internal.Legend.chart, org.swtchart.Chart.getAxisSet(), org.swtchart.Chart.getOrientation(), org.swtchart.IAxisSet.getXAxis(), and org.swtchart.ISeries.getXAxisId().
Referenced by org.swtchart.internal.Legend.updateLayoutData().
void org.swtchart.internal.Legend.updateLayoutData | ( | ) |
Update the layout data.
Definition at line 283 of file Legend.java.
References org.swtchart.internal.Legend.cellBounds, org.swtchart.internal.Legend.chart, org.swtchart.internal.Legend.getBounds(), org.swtchart.ILegend.getFont(), org.swtchart.internal.Legend.getLegendLabel(), org.swtchart.ISeriesSet.getSeries(), org.swtchart.Chart.getSeriesSet(), org.swtchart.Chart.getTitle(), org.swtchart.internal.Legend.MARGIN, org.swtchart.internal.Legend.position, org.swtchart.internal.Legend.sort(), org.swtchart.internal.Legend.SYMBOL_WIDTH, and org.swtchart.internal.Legend.visible.
Referenced by org.swtchart.Chart.updateLayout().
Map<String, Rectangle> org.swtchart.internal.Legend.cellBounds [private] |
the map between series id and cell bounds
Definition at line 75 of file Legend.java.
Referenced by org.swtchart.internal.Legend.getBounds(), org.swtchart.internal.Legend.Legend(), org.swtchart.internal.Legend.paintControl(), and org.swtchart.internal.Legend.updateLayoutData().
Chart org.swtchart.internal.Legend.chart [private] |
the plot chart
Definition at line 40 of file Legend.java.
Referenced by org.swtchart.internal.Legend.paintControl(), org.swtchart.internal.Legend.setFont(), org.swtchart.internal.Legend.setPosition(), org.swtchart.internal.Legend.setVisible(), org.swtchart.internal.Legend.sort(), and org.swtchart.internal.Legend.updateLayoutData().
final Color org.swtchart.internal.Legend.DEFAULT_BACKGROUND [static, private] |
Display.getDefault() .getSystemColor(SWT.COLOR_WHITE)
the default background
Definition at line 62 of file Legend.java.
Referenced by org.swtchart.internal.Legend.Legend(), and org.swtchart.internal.Legend.setBackground().
final int org.swtchart.internal.Legend.DEFAULT_FONT_SIZE = Constants.SMALL_FONT_SIZE [static, private] |
the default font size
Definition at line 69 of file Legend.java.
Referenced by org.swtchart.internal.Legend.Legend().
final Color org.swtchart.internal.Legend.DEFAULT_FOREGROUND [static, private] |
Display.getDefault() .getSystemColor(SWT.COLOR_BLACK)
the default foreground
Definition at line 58 of file Legend.java.
Referenced by org.swtchart.internal.Legend.Legend(), and org.swtchart.internal.Legend.setForeground().
final int org.swtchart.internal.Legend.DEFAULT_POSITION = SWT.RIGHT [static, private] |
the default position
Definition at line 72 of file Legend.java.
Referenced by org.swtchart.internal.Legend.Legend(), and org.swtchart.internal.Legend.setPosition().
Font org.swtchart.internal.Legend.defaultFont [private] |
the default font
Definition at line 66 of file Legend.java.
Referenced by org.swtchart.internal.Legend.dispose(), org.swtchart.internal.Legend.Legend(), and org.swtchart.internal.Legend.setFont().
final int org.swtchart.internal.Legend.LINE_WIDTH = 2 [static, private] |
the line width
Definition at line 55 of file Legend.java.
Referenced by org.swtchart.internal.Legend.drawSymbol().
final int org.swtchart.internal.Legend.MARGIN = 5 [static, private] |
the margin
Definition at line 49 of file Legend.java.
Referenced by org.swtchart.internal.Legend.paintControl(), and org.swtchart.internal.Legend.updateLayoutData().
int org.swtchart.internal.Legend.position [private] |
the position of legend
Definition at line 46 of file Legend.java.
Referenced by org.swtchart.internal.Legend.getPosition(), org.swtchart.internal.Legend.Legend(), org.swtchart.internal.Legend.setPosition(), and org.swtchart.internal.Legend.updateLayoutData().
final int org.swtchart.internal.Legend.SYMBOL_WIDTH = 20 [static, private] |
the width of area to draw symbol
Definition at line 52 of file Legend.java.
Referenced by org.swtchart.internal.Legend.drawSymbol(), org.swtchart.internal.Legend.paintControl(), and org.swtchart.internal.Legend.updateLayoutData().
boolean org.swtchart.internal.Legend.visible [private] |
the state indicating the legend visibility
Definition at line 43 of file Legend.java.
Referenced by org.swtchart.internal.Legend.drawSymbol(), org.swtchart.internal.Legend.isVisible(), org.swtchart.internal.Legend.Legend(), org.swtchart.internal.Legend.paintControl(), and org.swtchart.internal.Legend.updateLayoutData().