public class Legend extends org.eclipse.swt.widgets.Composite implements ILegend, org.eclipse.swt.events.PaintListener
| Modifier and Type | Field and Description |
|---|---|
private java.util.Map<java.lang.String,org.eclipse.swt.graphics.Rectangle> |
cellBounds
the map between series id and cell bounds
|
private Chart |
chart
the plot chart
|
private static org.eclipse.swt.graphics.Color |
DEFAULT_BACKGROUND
the default background
|
private static int |
DEFAULT_FONT_SIZE
the default font size
|
private static org.eclipse.swt.graphics.Color |
DEFAULT_FOREGROUND
the default foreground
|
private static int |
DEFAULT_POSITION
the default position
|
private org.eclipse.swt.graphics.Font |
defaultFont
the default font
|
private static int |
LINE_WIDTH
the line width
|
private static int |
MARGIN
the margin
|
private int |
position
the position of legend
|
private static int |
SYMBOL_WIDTH
the width of area to draw symbol
|
private boolean |
visible
the state indicating the legend visibility
|
| Constructor and Description |
|---|
Legend(Chart chart,
int style)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispose() |
protected void |
drawSymbol(org.eclipse.swt.graphics.GC gc,
Series series,
org.eclipse.swt.graphics.Rectangle r)
Draws the symbol of series.
|
org.eclipse.swt.graphics.Rectangle |
getBounds(java.lang.String seriesId)
Gets the rectangle associated with the given series id on legend.
|
private static java.lang.String |
getLegendLabel(ISeries series)
Gets the legend label.
|
int |
getPosition()
Gets the position of legend.
|
boolean |
isVisible()
Gets the visibility state.
|
void |
paintControl(org.eclipse.swt.events.PaintEvent e) |
void |
setBackground(org.eclipse.swt.graphics.Color color)
Sets the background color of legend.
|
void |
setFont(org.eclipse.swt.graphics.Font font)
Sets the font.
|
void |
setForeground(org.eclipse.swt.graphics.Color color)
Sets the foreground color of legend.
|
void |
setPosition(int value)
Sets the position of legend.
|
void |
setVisible(boolean visible)
Sets legend visible.
|
private ISeries[] |
sort(ISeries[] seriesArray)
Sorts the given series array.
|
private static java.util.List<ISeries> |
sort(java.util.List<ISeries> seriesList,
boolean isCategoryEnabled,
boolean isVertical)
Sorts the given series list which belongs to a certain x axis.
|
void |
updateLayoutData()
Update the layout data.
|
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabListcomputeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBaraddControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, updateaddDisposeListener, addListener, checkWidget, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetBackground, getFont, getForegroundprivate Chart chart
private boolean visible
private int position
private static final int MARGIN
private static final int SYMBOL_WIDTH
private static final int LINE_WIDTH
private static final org.eclipse.swt.graphics.Color DEFAULT_FOREGROUND
private static final org.eclipse.swt.graphics.Color DEFAULT_BACKGROUND
private org.eclipse.swt.graphics.Font defaultFont
private static final int DEFAULT_FONT_SIZE
private static final int DEFAULT_POSITION
private java.util.Map<java.lang.String,org.eclipse.swt.graphics.Rectangle> cellBounds
public Legend(Chart chart, int style)
chart - the chartstyle - the stylepublic void setVisible(boolean visible)
ILegendsetVisible in interface ILegendsetVisible in class org.eclipse.swt.widgets.Controlvisible - the visibility statepublic boolean isVisible()
ILegendpublic void setFont(org.eclipse.swt.graphics.Font font)
ILegendpublic void setForeground(org.eclipse.swt.graphics.Color color)
ILegendsetForeground in interface ILegendsetForeground in class org.eclipse.swt.widgets.Controlcolor - the foreground colorpublic void setBackground(org.eclipse.swt.graphics.Color color)
ILegendsetBackground in interface ILegendsetBackground in class org.eclipse.swt.widgets.Controlcolor - the background colorpublic int getPosition()
ILegendgetPosition in interface ILegendpublic void setPosition(int value)
ILegendsetPosition in interface ILegendvalue - the position of legend that can be SWT.LEFT,
SWT.RIGHT, SWT.TOP or SWT.BOTTOM.public org.eclipse.swt.graphics.Rectangle getBounds(java.lang.String seriesId)
ILegendMouse listener can be added by casting ILegend to Control.
Control legend = (Control) chart.getLegend(); legend.addMouseListener(...);
public void dispose()
dispose in class org.eclipse.swt.widgets.Widgetprivate ISeries[] sort(ISeries[] seriesArray)
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
sort(List, boolean, boolean).
seriesArray - the series arrayprivate static java.util.List<ISeries> sort(java.util.List<ISeries> seriesList, boolean isCategoryEnabled, boolean isVertical)
seriesList - the series list which belongs to a certain x axisisCategoryEnabled - true if category is enabledisVertical - true in the case of vertical orientationpublic void updateLayoutData()
private static java.lang.String getLegendLabel(ISeries series)
series - the seriesprotected void drawSymbol(org.eclipse.swt.graphics.GC gc,
Series series,
org.eclipse.swt.graphics.Rectangle r)
gc - the graphics contextseries - the seriesr - the rectangle to draw the symbol of seriespublic void paintControl(org.eclipse.swt.events.PaintEvent e)
paintControl in interface org.eclipse.swt.events.PaintListener