Package org.swtchart
Class Chart
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.Chart
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable,org.eclipse.swt.widgets.Listener
public class Chart
extends org.eclipse.swt.widgets.Composite
implements org.eclipse.swt.widgets.Listener
A chart which are composed of title, legend, axes and plot area.
-
Field Summary
Fields inherited from class org.eclipse.swt.widgets.Control
handle -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()voidenableCompress(boolean enabled) Enables compressing series.Gets the set of axes.org.eclipse.swt.graphics.ColorGets the background color in plot area.Gets the legend.intGets the state of chart orientation.org.eclipse.swt.widgets.CompositeGets the plot area.Gets the set of series.getTitle()Gets the chart title.voidhandleEvent(org.eclipse.swt.widgets.Event event) booleanGets the state indicating if compressing series is enabled.booleanGets the state indicating if the update of chart appearance is suspended.voidredraw()voidrenderOffscreenImage(org.eclipse.swt.graphics.Image image) Renders off-screen image.voidSaves to file with given format.voidsetBackground(org.eclipse.swt.graphics.Color color) voidsetBackgroundInPlotArea(org.eclipse.swt.graphics.Color color) Sets the background color in plot area.voidsetOrientation(int orientation) Sets the state of chart orientation.voidsuspendUpdate(boolean suspend) Suspends the update of chart appearance.voidupdate()voidUpdates the layout of chart elements.Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabListMethods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBarMethods inherited from class org.eclipse.swt.widgets.Control
addControlListener, 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, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverseMethods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.swt.graphics.Drawable
isAutoScalable
-
Constructor Details
-
Chart
public Chart(org.eclipse.swt.widgets.Composite parent, int style) Constructor.- Parameters:
parent- the parent composite on which chart is placedstyle- the style of widget to construct
-
-
Method Details
-
getTitle
Gets the chart title.- Returns:
- the chart title
-
getLegend
Gets the legend.- Returns:
- the legend
-
getAxisSet
Gets the set of axes.- Returns:
- the set of axes
-
getPlotArea
public org.eclipse.swt.widgets.Composite getPlotArea()Gets the plot area.- Returns:
- the plot area
-
getSeriesSet
Gets the set of series.- Returns:
- the set of series
-
setBackground
public void setBackground(org.eclipse.swt.graphics.Color color) - Overrides:
setBackgroundin classorg.eclipse.swt.widgets.Control
-
getBackgroundInPlotArea
public org.eclipse.swt.graphics.Color getBackgroundInPlotArea()Gets the background color in plot area. This method is identical with getPlotArea().getBackground().- Returns:
- the background color in plot area
-
setBackgroundInPlotArea
public void setBackgroundInPlotArea(org.eclipse.swt.graphics.Color color) Sets the background color in plot area.- Parameters:
color- the background color in plot area. If null is given, default background color will be set.- Throws:
IllegalArgumentException- if given color is disposed
-
setOrientation
public void setOrientation(int orientation) Sets the state of chart orientation. The horizontal orientation means that X axis is horizontal as usual, while the vertical orientation means that Y axis is horizontal.- Overrides:
setOrientationin classorg.eclipse.swt.widgets.Control- Parameters:
orientation- the orientation which can be SWT.HORIZONTAL or SWT.VERTICAL
-
getOrientation
public int getOrientation()Gets the state of chart orientation. The horizontal orientation means that X axis is horizontal as usual, while the vertical orientation means that Y axis is horizontal.- Overrides:
getOrientationin classorg.eclipse.swt.widgets.Control- Returns:
- the orientation which can be SWT.HORIZONTAL or SWT.VERTICAL
-
enableCompress
public void enableCompress(boolean enabled) Enables compressing series. By default, compressing series is enabled, and normally there should be no usecase to disable it. However, if you suspect that something is wrong in compressing series, you can disable it to isolate the issue.- Parameters:
enabled- true if enabling compressing series
-
isCompressEnabled
public boolean isCompressEnabled()Gets the state indicating if compressing series is enabled.- Returns:
- true if compressing series is enabled
-
suspendUpdate
public void suspendUpdate(boolean suspend) Suspends the update of chart appearance.By default, when the chart model is changed (e.g. adding new series or changing chart properties), the chart appearance is updated accordingly.
However, when doing a lot of changes in the chart model at once, it is inefficient that the update happens many times unnecessarily. In this case, you may want to defer the update until completing whole model changes in order to have better performance.
For example, suppose there is a chart having a large number of series, the following example code disables the update during changing the model.
try { // suspend update chart.suspendUpdate(true); // do some changes for a large number of series for (ISeries series : chart.getSeriesSet().getSeries()) { series.enableStack(true); } } finally { // resume update chart.suspendUpdate(false); }Note that the update has to be resumed right after completing the model changes in order to avoid showing an incompletely updated chart.- Parameters:
suspend- true to suspend the update of chart appearance
-
isUpdateSuspended
public boolean isUpdateSuspended()Gets the state indicating if the update of chart appearance is suspended.- Returns:
- true if the update of chart appearance is suspended
-
handleEvent
public void handleEvent(org.eclipse.swt.widgets.Event event) - Specified by:
handleEventin interfaceorg.eclipse.swt.widgets.Listener
-
updateLayout
public void updateLayout()Updates the layout of chart elements. -
update
public void update()- Overrides:
updatein classorg.eclipse.swt.widgets.Control
-
dispose
public void dispose()- Overrides:
disposein classorg.eclipse.swt.widgets.Widget
-
redraw
public void redraw()- Overrides:
redrawin classorg.eclipse.swt.widgets.Control
-
save
Saves to file with given format.- Parameters:
filename- the file nameformat- the format (SWT.IMAGE_*). The supported formats depend on OS.
-
renderOffscreenImage
public void renderOffscreenImage(org.eclipse.swt.graphics.Image image) Renders off-screen image.- Parameters:
image- The image to render off-screen
-