org.swtchart.internal.Legend Class Reference

A legend for chart. More...

Inheritance diagram for org.swtchart.internal.Legend:
Inheritance graph
[legend]
Collaboration diagram for org.swtchart.internal.Legend:
Collaboration graph
[legend]

List of all members.

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< ISeriessort (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

Detailed Description

A legend for chart.

Definition at line 37 of file Legend.java.


Constructor & Destructor Documentation

org.swtchart.internal.Legend.Legend ( Chart  chart,
int  style 
)

Member Function Documentation

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().

Here is the caller graph for this function:

void org.swtchart.internal.Legend.drawSymbol ( GC  gc,
Series  series,
Rectangle  r 
) [protected]

Draws the symbol of series.

Parameters:
gc the graphics context
series the series
r the rectangle to draw 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().

Here is the caller graph for this function:

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(...);
 
Parameters:
seriesId the series id
Returns:
the rectangle associated with the given series id in pixels.

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().

Here is the caller graph for this function:

static String org.swtchart.internal.Legend.getLegendLabel ( ISeries  series  )  [static, private]

Gets the legend label.

Parameters:
series the series
Returns:
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().

Here is the call graph for this function:

Here is the caller graph for this function:

int org.swtchart.internal.Legend.getPosition (  ) 
boolean org.swtchart.internal.Legend.isVisible (  ) 

Gets the visibility state.

Returns:
true if legend is visible

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  ) 
void org.swtchart.internal.Legend.setBackground ( Color  color  ) 

Sets the background color of legend.

Parameters:
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().

Here is the caller graph for this function:

void org.swtchart.internal.Legend.setFont ( Font  font  ) 

Sets the font.

Parameters:
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().

Here is the call graph for this function:

Here is the caller graph for this function:

void org.swtchart.internal.Legend.setForeground ( Color  color  ) 

Sets the foreground color of legend.

Parameters:
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().

Here is the caller graph for this function:

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.

Parameters:
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().

Here is the call graph for this function:

void org.swtchart.internal.Legend.setVisible ( boolean  visible  ) 

Sets legend visible.

Parameters:
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().

Here is the call graph for this function:

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.

  • The stacked series will be gathered, and the order of stack series will be reversed.
  • In the case of vertical orientation, the order of whole series will be reversed.
Parameters:
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
Returns:
the sorted series array

Definition at line 253 of file Legend.java.

ISeries [] org.swtchart.internal.Legend.sort ( ISeries[]  seriesArray  )  [private]

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).

Parameters:
seriesArray the series array
Returns:
the sorted 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().

Here is the call graph for this function:

Here is the caller graph for this function:

void org.swtchart.internal.Legend.updateLayoutData (  ) 

Member Data Documentation

Map<String, Rectangle> org.swtchart.internal.Legend.cellBounds [private]
final Color org.swtchart.internal.Legend.DEFAULT_BACKGROUND [static, private]
Initial value:
 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().

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]
Initial value:
 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().

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]
final int org.swtchart.internal.Legend.SYMBOL_WIDTH = 20 [static, private]

The documentation for this class was generated from the following file:

Generated on 26 Oct 2015 for SWTChart.org by  doxygen 1.6.1