Package org.swtchart.internal
Class Legend
- java.lang.Object
-
- org.eclipse.swt.widgets.Widget
-
- org.eclipse.swt.widgets.Control
-
- org.eclipse.swt.widgets.Scrollable
-
- org.eclipse.swt.widgets.Composite
-
- org.swtchart.internal.Legend
-
- All Implemented Interfaces:
java.util.EventListener
,org.eclipse.swt.events.PaintListener
,org.eclipse.swt.graphics.Drawable
,org.eclipse.swt.internal.SWTEventListener
,ILegend
public class Legend extends org.eclipse.swt.widgets.Composite implements ILegend, org.eclipse.swt.events.PaintListener
A legend for chart.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.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.void
updateLayoutData()
Update the layout data.-
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, computeSize, drawBackground, getBackgroundMode, getChildren, getClientArea, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
-
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getBorderWidth, getHorizontalBar, getScrollbarsMode, getVerticalBar
-
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, 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, 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, update
-
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, getData, getData, getDisplay, getListeners, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.swtchart.ILegend
getBackground, getFont, getForeground
-
-
-
-
Constructor Detail
-
Legend
public Legend(Chart chart, int style)
Constructor.- Parameters:
chart
- the chartstyle
- the style
-
-
Method Detail
-
setVisible
public void setVisible(boolean visible)
Description copied from interface:ILegend
Sets legend visible.- Specified by:
setVisible
in interfaceILegend
- Overrides:
setVisible
in classorg.eclipse.swt.widgets.Control
- Parameters:
visible
- the visibility state
-
isVisible
public boolean isVisible()
Description copied from interface:ILegend
Gets the visibility state.
-
setFont
public void setFont(org.eclipse.swt.graphics.Font font)
Description copied from interface:ILegend
Sets the font.
-
setForeground
public void setForeground(org.eclipse.swt.graphics.Color color)
Description copied from interface:ILegend
Sets the foreground color of legend.- Specified by:
setForeground
in interfaceILegend
- Overrides:
setForeground
in classorg.eclipse.swt.widgets.Control
- Parameters:
color
- the foreground color
-
setBackground
public void setBackground(org.eclipse.swt.graphics.Color color)
Description copied from interface:ILegend
Sets the background color of legend.- Specified by:
setBackground
in interfaceILegend
- Overrides:
setBackground
in classorg.eclipse.swt.widgets.Control
- Parameters:
color
- the background color
-
getPosition
public int getPosition()
Description copied from interface:ILegend
Gets the position of legend.- Specified by:
getPosition
in interfaceILegend
- Returns:
- the position of legend.
-
setPosition
public void setPosition(int value)
Description copied from interface:ILegend
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.- Specified by:
setPosition
in interfaceILegend
- Parameters:
value
- the position of legend that can be SWT.LEFT, SWT.RIGHT, SWT.TOP or SWT.BOTTOM.
-
getBounds
public org.eclipse.swt.graphics.Rectangle getBounds(java.lang.String seriesId)
Description copied from interface:ILegend
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(...);
-
dispose
public void dispose()
- Overrides:
dispose
in classorg.eclipse.swt.widgets.Widget
-
updateLayoutData
public void updateLayoutData()
Update the layout data.
-
drawSymbol
protected void drawSymbol(org.eclipse.swt.graphics.GC gc, Series series, org.eclipse.swt.graphics.Rectangle r)
Draws the symbol of series.- Parameters:
gc
- the graphics contextseries
- the seriesr
- the rectangle to draw the symbol of series
-
paintControl
public void paintControl(org.eclipse.swt.events.PaintEvent e)
- Specified by:
paintControl
in interfaceorg.eclipse.swt.events.PaintListener
-
-