diff options
author | Otavio Pontes | 2012-05-08 12:49:46 +0000 |
---|---|---|
committer | Otavio Pontes | 2012-05-08 12:49:46 +0000 |
commit | 0b037d1e0202bd0e11a93a743d0a76c9efbe866a (patch) | |
tree | 30994b5ff7aa5b2d67f8e3f703c2a94c56800bb3 /systemtap | |
parent | cd5da179787c5c4934baef968d84061d5a7180d3 (diff) | |
parent | 3fbec67d687e87e5b01de80483aa1b666bbc8420 (diff) | |
download | org.eclipse.linuxtools-0b037d1e0202bd0e11a93a743d0a76c9efbe866a.tar.gz org.eclipse.linuxtools-0b037d1e0202bd0e11a93a743d0a76c9efbe866a.tar.xz org.eclipse.linuxtools-0b037d1e0202bd0e11a93a743d0a76c9efbe866a.zip |
Merge branch 'feature/systemtap/no-birt'
Diffstat (limited to 'systemtap')
20 files changed, 390 insertions, 2927 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap-feature/feature.xml b/systemtap/org.eclipse.linuxtools.systemtap-feature/feature.xml index c60451bca2..f39096753a 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap-feature/feature.xml +++ b/systemtap/org.eclipse.linuxtools.systemtap-feature/feature.xml @@ -29,7 +29,6 @@ <import plugin="org.eclipse.ui.workbench.texteditor"/> <import plugin="org.eclipse.ui"/> <import plugin="org.eclipse.ui.forms"/> - <import plugin="org.eclipse.birt.chart.engine"/> <import plugin="org.eclipse.core.resources" version="3.4.1" match="greaterOrEqual"/> <import plugin="org.eclipse.ui.editors" version="3.4.0" match="greaterOrEqual"/> <import plugin="org.eclipse.ui.console" version="3.3.0" match="greaterOrEqual"/> diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.dashboard/src/org/eclipse/linuxtools/systemtap/ui/dashboard/DashboardAdapter.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.dashboard/src/org/eclipse/linuxtools/systemtap/ui/dashboard/DashboardAdapter.java index 11c1a59c05..1da70e93c9 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.dashboard/src/org/eclipse/linuxtools/systemtap/ui/dashboard/DashboardAdapter.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.dashboard/src/org/eclipse/linuxtools/systemtap/ui/dashboard/DashboardAdapter.java @@ -63,7 +63,7 @@ public class DashboardAdapter { * @param ds The data used to populate the graph. */ public DashboardAdapter(DashboardComposite parent, GraphData gd, IDataSet ds, String moduleName) { - folder = new CTabFolder(parent.deadComposite, SWT.NONE); + folder = new CTabFolder(parent.deadComposite, SWT.ALL); FormLayout layout = new FormLayout(); layout.marginHeight = 0; layout.marginWidth = 0; parent.deadComposite.setLayout(layout); @@ -325,4 +325,4 @@ public class DashboardAdapter { private static final Image maxImage = DashboardPlugin.getImageDescriptor("icons/actions/graph/maximize.gif").createImage(); private static final Image restoreImage = DashboardPlugin.getImageDescriptor("icons/actions/graph/restore.gif").createImage(); -}
\ No newline at end of file +} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/internal/systemtap/ui/graphing/actions/SaveGraphImageAction.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/internal/systemtap/ui/graphing/actions/SaveGraphImageAction.java index 70aee8430e..f1421ac5a8 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/internal/systemtap/ui/graphing/actions/SaveGraphImageAction.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/internal/systemtap/ui/graphing/actions/SaveGraphImageAction.java @@ -18,7 +18,8 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.linuxtools.internal.systemtap.ui.graphing.Localization; import org.eclipse.linuxtools.systemtap.ui.graphing.structures.GraphDisplaySet; import org.eclipse.linuxtools.systemtap.ui.graphing.views.GraphSelectorView; -import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.chart.widget.ChartCanvas; + +import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.AbstractChartBuilder; import org.eclipse.linuxtools.systemtap.ui.logging.LogManager; import org.eclipse.linuxtools.systemtap.ui.structures.listeners.ITabListener; import org.eclipse.swt.SWT; @@ -33,8 +34,6 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.PlatformUI; - - /** * This action is designed to allow for saving of the graph in the active window. * It will let the user select the location to save the image, and then save it as @@ -54,7 +53,7 @@ public class SaveGraphImageAction extends Action implements IWorkbenchWindowActi */ public void run(IAction act) { LogManager.logDebug("Start run", this); - ChartCanvas g = getGraph(); + AbstractChartBuilder g = getGraph(); try { PlatformUI.getWorkbench().getDisplay().update(); } catch(SWTException swte) { @@ -84,10 +83,10 @@ public class SaveGraphImageAction extends Action implements IWorkbenchWindowActi * graph is active it will return null. * @return The IGraph in tha active display set. */ - public ChartCanvas getGraph() { + public AbstractChartBuilder getGraph() { LogManager.logDebug("Start getGraph", this); IViewPart ivp = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(GraphSelectorView.ID); - ChartCanvas g = null; + AbstractChartBuilder g = null; GraphDisplaySet gds = ((GraphSelectorView)ivp).getActiveDisplaySet(); if(null != gds) @@ -101,9 +100,8 @@ public class SaveGraphImageAction extends Action implements IWorkbenchWindowActi * @param g The graph that needs to be converted to an image * @return The Image that was generated by the supplied Graph. */ - public ImageData getImage(ChartCanvas g) { + public ImageData getImage(AbstractChartBuilder canvas) { LogManager.logDebug("Start getImage", this); - ChartCanvas canvas = (ChartCanvas)g; GC gc = new GC(canvas); Image image = new Image(canvas.getDisplay(), canvas.getSize().x, canvas.getSize().y); gc.copyArea(image, 0, 0); diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/systemtap/ui/graphing/structures/GraphDisplaySet.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/systemtap/ui/graphing/structures/GraphDisplaySet.java index a0d770050a..bfbe985f06 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/systemtap/ui/graphing/structures/GraphDisplaySet.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphing/src/org/eclipse/linuxtools/systemtap/ui/graphing/structures/GraphDisplaySet.java @@ -20,7 +20,6 @@ import org.eclipse.linuxtools.internal.systemtap.ui.graphing.Localization; import org.eclipse.linuxtools.internal.systemtap.ui.graphing.preferences.GraphingPreferenceConstants; import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataSet; import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.structures.GraphData; -import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.chart.widget.ChartCanvas; import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.AbstractChartBuilder; import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.datadisplay.DataGrid; import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.widgets.GraphComposite; @@ -55,7 +54,6 @@ import org.eclipse.ui.PlatformUI; * @author Ryan Morse */ public class GraphDisplaySet { - @SuppressWarnings("unchecked") public GraphDisplaySet(Composite parent, IDataSet data) { LogManager.logDebug("Start GraphSelectorView:", this); LogManager.logInfo("Initializing", this); @@ -74,9 +72,9 @@ public class GraphDisplaySet { // } createPartControl(parent); - builders = new ArrayList(); + builders = new ArrayList<AbstractChartBuilder>(); // graphs = new ArrayList(); - tabListeners = new ArrayList(); + tabListeners = new ArrayList<ITabListener>(); LogManager.logDebug("End GraphSelectorView:", this); } @@ -126,7 +124,7 @@ public class GraphDisplaySet { public void close(CTabFolderEvent e) { int selected = folder.indexOf((CTabItem)e.item)-2; if(null != updater) - updater.removeUpdateListener((AbstractChartBuilder)builders.get(selected)); + updater.removeUpdateListener(builders.get(selected)); builders.remove(selected); fireTabCloseEvent(); } @@ -165,10 +163,10 @@ public class GraphDisplaySet { * Finds the graph that is open in the current tab * @return The graph that is currently visible on the screen */ - public ChartCanvas getActiveGraph() { + public AbstractChartBuilder getActiveGraph() { if(0 == builders.size() || folder.getSelectionIndex() < 2) return null; - return (ChartCanvas)builders.get(folder.getSelectionIndex()-2); + return builders.get(folder.getSelectionIndex()-2); } public void setFocus() {} @@ -203,7 +201,6 @@ public class GraphDisplaySet { */ public class ButtonClickListener implements SelectionListener { public void widgetDefaultSelected(SelectionEvent event) {} - @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent event) { CTabFolder folder = (CTabFolder)event.getSource(); @@ -242,7 +239,6 @@ public class GraphDisplaySet { } } - @SuppressWarnings("unchecked") public void addTabListener(ITabListener listener) { tabListeners.add(listener); } @@ -253,17 +249,17 @@ public class GraphDisplaySet { private void fireTabCloseEvent() { for(int i=0; i<tabListeners.size(); i++) - ((ITabListener)tabListeners.get(i)).tabClosed(); + (tabListeners.get(i)).tabClosed(); } private void fireTabOpenEvent() { for(int i=0; i<tabListeners.size(); i++) - ((ITabListener)tabListeners.get(i)).tabOpened(); + (tabListeners.get(i)).tabOpened(); } private void fireTabChangedEvent() { for(int i=0; i<tabListeners.size(); i++) - ((ITabListener)tabListeners.get(i)).tabChanged(); + (tabListeners.get(i)).tabChanged(); } private int lastSelectedTab; @@ -271,10 +267,8 @@ public class GraphDisplaySet { private CTabFolder folder; private ButtonClickListener listener; private UpdateManager updater; - @SuppressWarnings("unchecked") - private ArrayList tabListeners; + private ArrayList<ITabListener> tabListeners; // private ArrayList graphs; - @SuppressWarnings("unchecked") - private ArrayList builders; -}
\ No newline at end of file + private ArrayList<AbstractChartBuilder> builders; +} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/META-INF/MANIFEST.MF b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/META-INF/MANIFEST.MF index 59f1b2ab3a..378ae58cad 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/META-INF/MANIFEST.MF +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/META-INF/MANIFEST.MF @@ -7,7 +7,6 @@ Bundle-Activator: org.eclipse.linuxtools.internal.systemtap.ui.graphingapi.ui.Gr Bundle-Vendor: %bundleProvider Bundle-Localization: plugin Export-Package: - org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.chart.widget, org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts, org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.datadisplay, org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.graphs, @@ -21,6 +20,7 @@ Require-Bundle: org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui;visibility org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.ui.forms, - org.eclipse.birt.chart.engine;bundle-version="2.5.0" + org.swtchart, + org.eclipse.linuxtools.dataviewers.piechart Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/chart/widget/ChartCanvas.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/chart/widget/ChartCanvas.java deleted file mode 100644 index 7d31ec8c9b..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/chart/widget/ChartCanvas.java +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************** - * Licensed Material - Property of IBM - * - * ****-*** - * - * (c) Copyright IBM Corp. 2006. All rights reserved. - * - * US Government Users Restricted Rights - Use, duplication or - * disclosure restricted by GSA ADP Schedule Contract with - * IBM Corp. - * - **************************************************************** - */ -package org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.chart.widget; - - -import org.eclipse.birt.chart.api.ChartEngine; -import org.eclipse.birt.chart.device.IDeviceRenderer; -import org.eclipse.birt.chart.exception.ChartException; -import org.eclipse.birt.chart.factory.GeneratedChartState; -import org.eclipse.birt.chart.factory.Generator; -import org.eclipse.birt.chart.model.Chart; -import org.eclipse.birt.chart.model.attribute.Bounds; -import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl; -import org.eclipse.birt.core.framework.PlatformConfig; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.Rectangle; - -import org.eclipse.swt.widgets.Canvas; -import org.eclipse.swt.widgets.Composite; - - -import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.AbstractChartBuilder; - -public class ChartCanvas extends Canvas{ - protected IDeviceRenderer render = null; - protected Chart chart = null; - protected AbstractChartBuilder builder = null; - protected GeneratedChartState state = null; - // private boolean bFirstPaint = true; - - public ChartCanvas(Composite parent, int style) { - super(parent, style | SWT.V_SCROLL | SWT.H_SCROLL); - try { - // INITIALIZE THE SWT RENDERING DEVICE - //ChartEngine ce = ChartEngine.instance(); - // PluginSettings ps = PluginSettings.instance(); - - - PlatformConfig pf = new PlatformConfig(); - - //pf.setProperty( - //"STANDALONE", true); - - // Returns a singleton instance of the Chart Engine - - ChartEngine ce = ChartEngine.instance(pf); - - // Returns a singleton instance of the Generator - - // IGenerator gr = ce.getGenerator(); - - - try - { - render = ce.getRenderer("dv.SWT"); - } - catch ( ChartException ex ) - { - ex.printStackTrace( ); - } - //render = ps.getDevice("dv.PNG"); - - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - - addPaintListener(new PaintListener() { - - /** - * The SWT paint callback - */ - public void paintControl(PaintEvent pe) - { - if (chart == null) return; - try{ - render.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, pe.gc); - Composite co = (Composite) pe.getSource(); - Rectangle re = co.getClientArea(); - Bounds bo = BoundsImpl.create(re.x, re.y, re.width, re.height); - bo.scale(72d / render.getDisplayServer().getDpiResolution()); - Generator gr = Generator.instance(); - state = gr.build(render.getDisplayServer(), - chart, - bo, - null, - null, - null); - gr.render(render, state); - } catch (ChartException e) { - e.printStackTrace(); - } - } - } - ); - } - - public Chart getChart() { - return chart; - } - - public void setChart(AbstractChartBuilder builder) { - this.chart = builder.getChart(); - this.builder = builder; - - this.redraw(); - } - -public void handleUpdateEvent() { - // TODO Auto-generated method stub - //builder.build(); - builder.updateDataSet(); - chart = builder.getChart(); - chart = null; - this.redraw(); - this.update(); -} - -public synchronized void repaint() { - getDisplay().syncExec(new Runnable() { - boolean stop = false; - public void run() { - if(stop) return; - try { - redraw(); - } catch (Exception e) { - stop = true; - } - } - }); -} - - -} - diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/chart/widget/ChartWithToolTipCanvas.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/chart/widget/ChartWithToolTipCanvas.java deleted file mode 100644 index e6486c0d79..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/chart/widget/ChartWithToolTipCanvas.java +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************** - * Licensed Material - Property of IBM - * - * ****-*** - * - * (c) Copyright IBM Corp. 2006. All rights reserved. - * - * US Government Users Restricted Rights - Use, duplication or - * disclosure restricted by GSA ADP Schedule Contract with - * IBM Corp. - * - **************************************************************** - */ -package org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.chart.widget; - -import org.eclipse.birt.chart.device.IDeviceRenderer; -import org.eclipse.birt.chart.device.IUpdateNotifier; -import org.eclipse.birt.chart.model.Chart; -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.chart.widget.ChartCanvas; - -/** - * The canvas to draw chart with the tool tip to show the value. - * - * @author Qi Liang - */ -public class ChartWithToolTipCanvas extends ChartCanvas implements - IUpdateNotifier { - - public ChartWithToolTipCanvas(Composite parent, int style) { - super(parent, style); - render.setProperty(IDeviceRenderer.UPDATE_NOTIFIER, this); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.birt.chart.device.IUpdateNotifier#regenerateChart() - */ - public void regenerateChart() { - redraw(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.birt.chart.device.IUpdateNotifier#repaintChart() - */ - public void repaintChart() { - redraw(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.birt.chart.device.IUpdateNotifier#peerInstance() - */ - public Object peerInstance() { - return this; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.birt.chart.device.IUpdateNotifier#getDesignTimeModel() - */ - public Chart getDesignTimeModel() { - return chart; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.birt.chart.device.IUpdateNotifier#getRunTimeModel() - */ - public Chart getRunTimeModel() { - return state.getChartModel(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.birt.chart.device.IUpdateNotifier#getContext(java.lang.Object) - */ - public Object getContext(Object arg0) { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.birt.chart.device.IUpdateNotifier#putContext(java.lang.Object, - * java.lang.Object) - */ - public Object putContext(Object arg0, Object arg1) { - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.birt.chart.device.IUpdateNotifier#removeContext(java.lang.Object) - */ - public Object removeContext(Object arg0) { - return null; - } -}
\ No newline at end of file diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/chart/widget/ICanvas.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/chart/widget/ICanvas.java deleted file mode 100644 index 421e2a8ff0..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/chart/widget/ICanvas.java +++ /dev/null @@ -1 +0,0 @@ -package org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.chart.widget; diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/AbstractChartBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/AbstractChartBuilder.java index 4214e6838b..2d664bd8c1 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/AbstractChartBuilder.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/AbstractChartBuilder.java @@ -13,141 +13,209 @@ */ package org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.linuxtools.internal.systemtap.ui.graphingapi.ui.GraphingAPIUIPlugin; +import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.preferences.GraphingAPIPreferenceConstants; -import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; - -import org.eclipse.birt.chart.model.Chart; import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.adapters.IAdapter; import org.eclipse.linuxtools.systemtap.ui.structures.listeners.IUpdateListener; +import org.eclipse.swt.widgets.Display; + +import org.swtchart.Chart; +import org.swtchart.ITitle; + /** * Provides the common members and the framework to build one chart. * * @author Qi Liang */ -public abstract class AbstractChartBuilder extends Canvas implements IUpdateListener{ - - /** - * Font name for all titles, labels, and values. - */ - protected final static String FONT_NAME = "MS Sans Serif"; - - /** - * Provides data for chart. - */ - protected IAdapter adapter = null; - protected int xseries; - protected int[] yseries; - - /** - * Chart instance. - */ - protected Chart chart = null; - - /** - * Chart title. - */ - protected String title = null; - - /** - * Constructs one chart builder and associate it to one data set. - * - * @param dataSet - * data set - */ - - public AbstractChartBuilder(IAdapter adapter, Composite parent, int style) { - super(parent, style); - // TODO Auto-generated constructor stub - this.adapter = adapter; +public abstract class AbstractChartBuilder extends Composite implements IUpdateListener{ + + /** + * Font name for all titles, labels, and values. + */ + protected final static String FONT_NAME = "MS Sans Serif"; + protected int maxItems; + protected double scale = 1.0; + + /** + * Provides data for chart. + */ + protected IAdapter adapter = null; + protected int xseries; + protected int[] yseries; + + protected static final Color WHITE = new Color(Display.getDefault(), 255, 255, 255); + protected static final Color BLACK = new Color(Display.getDefault(), 0, 0, 0); + protected static final Color RED = new Color(Display.getDefault(), 255, 0, 0); + + protected static final Color[] COLORS = { + new Color(Display.getDefault(), 255, 0, 0), + new Color(Display.getDefault(), 0, 255, 0), + new Color(Display.getDefault(), 0, 0, 255), + new Color(Display.getDefault(), 255, 255, 0), + new Color(Display.getDefault(), 255, 0, 255), + new Color(Display.getDefault(), 0, 255, 255), + new Color(Display.getDefault(), 0, 0, 0), + new Color(Display.getDefault(), 64, 128, 128), + new Color(Display.getDefault(), 255, 165, 0), + new Color(Display.getDefault(), 128, 128, 128), + }; + /** + * Chart instance. + */ + protected Chart chart = null; + + /** + * Chart title. + */ + protected String title = null; + + /** + * Constructs one chart builder and associate it to one data set. + * + * @param dataSet + * data set + */ + + public AbstractChartBuilder(IAdapter adapter, Composite parent, int style, String title) { + super(parent, style); + this.adapter = adapter; + this.title = title; + this.setLayout(new FillLayout()); + IPreferenceStore store = GraphingAPIUIPlugin.getDefault().getPreferenceStore(); + maxItems = Math.min(store.getInt(GraphingAPIPreferenceConstants.P_VIEWABLE_DATA_ITEMS), + store.getInt(GraphingAPIPreferenceConstants.P_MAX_DATA_ITEMS)); } /** - * Builds one chart. - */ - public void build() { - createChart(); - buildPlot(); - buildLegend(); - buildTitle(); - buildXAxis(); - buildYAxis(); - buildXSeries(); - buildYSeries(); - updateDataSet(); - } - - /** - * Creates chart instance. - */ - protected abstract void createChart(); - - /** - * Builds plot. - */ - protected void buildPlot() { - - } - - /** - * Builds X axis. - */ - protected void buildXAxis() { - - } - - /** - * Builds Y axis. - */ - protected void buildYAxis() { - - } - - /** - * Builds X series. - */ - protected void buildXSeries() { - - } - - /** - * Builds Y series. - */ - protected void buildYSeries() { - - } - - /** - * Builds legend. - * - */ - protected void buildLegend() { - - } - - /** - * Builds the chart title. - */ - protected void buildTitle() { - } - - /** - * Returns the chart instance. - * - * @return the chart instance - */ - public Chart getChart() { - return chart; - } - - public void updateDataSet() - { - - } + * Builds one chart. + */ + public void build() { + createChart(); + buildPlot(); + buildLegend(); + buildTitle(); + buildXAxis(); + buildYAxis(); + buildXSeries(); + buildYSeries(); + updateDataSet(); + } + + /** + * Creates chart instance. + */ + protected void createChart() { + this.chart = new Chart(this, getStyle()); + } + + /** + * Builds plot. + */ + protected void buildPlot() { + this.chart.setBackground(WHITE); + this.chart.setBackgroundInPlotArea(WHITE); + } + + /** + * Builds X axis. + */ + protected void buildXAxis() { + + } + + /** + * Builds Y axis. + */ + protected void buildYAxis() { + + } + + /** + * Builds X series. + */ + protected void buildXSeries() { + + } + + /** + * Builds Y series. + */ + protected void buildYSeries() { + + } + + /** + * Builds legend. + * + */ + protected void buildLegend() { + chart.getLegend().setPosition(SWT.RIGHT); + } + + /** + * Builds the chart title. + */ + protected void buildTitle() { + ITitle ctitle = chart.getTitle(); + ctitle.setForeground(BLACK); + ctitle.setText(this.title); + } + + /** + * Returns the chart instance. + * + * @return the chart instance + */ + public Chart getChart() { + return chart; + } + + public void updateDataSet() { + + } public void setScale(double scale) { - + this.scale = scale; + handleUpdateEvent(); + } + + protected double getDoubleValue(Object o) { + if (o instanceof Integer) + return ((Integer)o).intValue(); + if (o instanceof Double) + return ((Double)o).doubleValue(); + return new Double(o.toString()).doubleValue(); + } + + public void handleUpdateEvent() { + try{ + repaint(); + }catch(Exception e) + { + //e.printStackTrace(); + } + } + + protected void repaint() { + getDisplay().syncExec(new Runnable() { + boolean stop = false; + public void run() { + if(stop) + return; + try { + updateDataSet(); + } catch (Exception e) { + stop = true; + } + } + }); } } diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/AbstractChartWithAxisBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/AbstractChartWithAxisBuilder.java index 0734b673f5..5c35ebaabb 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/AbstractChartWithAxisBuilder.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/AbstractChartWithAxisBuilder.java @@ -1,12 +1,14 @@ - package org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts; -import org.eclipse.birt.chart.model.component.Axis; -import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl; import org.eclipse.swt.widgets.Composite; import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.adapters.IAdapter; +import org.swtchart.IAxis; +import org.swtchart.ISeries; +import org.swtchart.ITitle; +import org.swtchart.LineStyle; + /** * Builds the chart with axis. * @@ -20,42 +22,90 @@ public abstract class AbstractChartWithAxisBuilder extends AbstractChartBuilder protected String xTitle = null; /** - * Title of Y axis. - */ - protected String yTitle = null; - - /** - * X axis. - */ - protected Axis xAxis = null; - - /** - * Y axis. - */ - protected Axis yAxis = null; - - /** * Constructor. * * @param dataSet * data for chart */ - public AbstractChartWithAxisBuilder(IAdapter adapter, Composite parent, int style) { - super(adapter, parent, style); + public AbstractChartWithAxisBuilder(IAdapter adapter, Composite parent, int style, String title) { + super(adapter, parent, style, title); + } + + /** + * Builds X axis. + */ + protected void buildXAxis() { + super.buildXAxis(); + String labels[] = adapter.getLabels(); + IAxis xAxis = this.chart.getAxisSet().getXAxis(0); + xAxis.getGrid().setStyle(LineStyle.NONE); + xAxis.getTick().setForeground(BLACK); + ITitle xTitle = xAxis.getTitle(); + xTitle.setForeground(BLACK); + + if (labels.length > 0) + xTitle.setText(labels[0]); + else + xTitle.setText(""); + } + + /** + * Builds Y axis. + */ + protected void buildYAxis() { + String labels[] = adapter.getLabels(); + IAxis yAxis = this.chart.getAxisSet().getYAxis(0); + yAxis.getTitle().setText(""); + yAxis.getGrid().setStyle(LineStyle.SOLID); + yAxis.getTick().setForeground(BLACK); + } + + /** + * Builds X series. + */ + protected void buildXSeries() { + Object data[][] = adapter.getData(); + if (data == null || data.length == 0) + return; + + int totalMaxItems = (int)Math.round(this.maxItems * scale); + int start = 0, len = Math.min(totalMaxItems, data.length); + if (totalMaxItems < data.length) { + start = data.length - totalMaxItems; + } + + double[] valx = new double[len]; + double[][] valy = new double[data[0].length-1][len]; + + ISeries allSeries[] = chart.getSeriesSet().getSeries(); + for (int i = 0; i < valx.length; i++) + for (int j = 0; j < data[start + i].length; j++) { + if (j == 0) + valx[i] = getDoubleValue(data[start + i][j]); + else + valy[j-1][i] = getDoubleValue(data[start + i][j]); + } + + for (int i = 0; i < valy.length; i++) { + ISeries series; + if (i >= allSeries.length) { + series = createChartISeries(i); + } else { + series = chart.getSeriesSet().getSeries()[i]; + } + series.setXSeries(valx); + series.setYSeries(valy[i]); + } + + chart.getAxisSet().adjustRange(); + chart.redraw(); } /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#createChart() - */ - protected void createChart() { - chart = ChartWithAxesImpl.create(); - } - - public void updateDataSet() - { - - } + * Create a chart series for that chart. + */ + protected ISeries createChartISeries(int i) { + return null; + } } diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/AbstractChartWithoutAxisBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/AbstractChartWithoutAxisBuilder.java index 6403fdd71a..869c20d06f 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/AbstractChartWithoutAxisBuilder.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/AbstractChartWithoutAxisBuilder.java @@ -1,8 +1,5 @@ - package org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts; -import org.eclipse.birt.chart.model.component.Axis; -import org.eclipse.birt.chart.model.impl.ChartWithoutAxesImpl; import org.eclipse.swt.widgets.Composite; import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.adapters.IAdapter; @@ -16,47 +13,13 @@ import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.adapters.IAdapter; public abstract class AbstractChartWithoutAxisBuilder extends AbstractChartBuilder { /** - * Title of X axis. - */ - protected String xTitle = null; - - /** - * Title of Y axis. - */ - protected String yTitle = null; - - /** - * X axis. - */ - protected Axis xAxis = null; - - /** - * Y axis. - */ - protected Axis yAxis = null; - - /** * Constructor. * * @param dataSet * data for chart */ - public AbstractChartWithoutAxisBuilder(IAdapter adapter, Composite parent, int style) { - super(adapter, parent, style); + public AbstractChartWithoutAxisBuilder(IAdapter adapter, Composite parent, int style, String title) { + super(adapter, parent, style, title); } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#createChart() - */ - protected void createChart() { - chart = ChartWithoutAxesImpl.create(); - } - - public void updateDataSet() - { - - } } diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/AreaChartBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/AreaChartBuilder.java index aac66432a7..a7d6d66dcd 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/AreaChartBuilder.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/AreaChartBuilder.java @@ -13,425 +13,30 @@ */ package org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts; -import org.eclipse.birt.chart.api.ChartEngine; -import org.eclipse.birt.chart.device.IDeviceRenderer; -import org.eclipse.birt.chart.exception.ChartException; -import org.eclipse.birt.chart.factory.GeneratedChartState; -import org.eclipse.birt.chart.factory.Generator; -import org.eclipse.birt.chart.model.ChartWithAxes; -import org.eclipse.birt.chart.model.attribute.AxisType; -import org.eclipse.birt.chart.model.attribute.Bounds; -import org.eclipse.birt.chart.model.attribute.ChartDimension; -import org.eclipse.birt.chart.model.attribute.IntersectionType; -import org.eclipse.birt.chart.model.attribute.LegendItemType; -import org.eclipse.birt.chart.model.attribute.LineStyle; -import org.eclipse.birt.chart.model.attribute.TickStyle; -import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl; -import org.eclipse.birt.chart.model.component.Axis; -import org.eclipse.birt.chart.model.component.Series; -import org.eclipse.birt.chart.model.component.impl.SeriesImpl; -import org.eclipse.birt.chart.model.data.NumberDataSet; -import org.eclipse.birt.chart.model.data.SeriesDefinition; -import org.eclipse.birt.chart.model.data.TextDataSet; - -import org.eclipse.birt.chart.model.data.impl.NumberDataElementImpl; -import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl; -import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl; -import org.eclipse.birt.chart.model.data.impl.TextDataSetImpl; - -import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl; - -import org.eclipse.birt.chart.model.type.AreaSeries; -import org.eclipse.birt.chart.model.type.impl.AreaSeriesImpl; -import org.eclipse.birt.core.framework.PlatformConfig; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; -import org.eclipse.linuxtools.internal.systemtap.ui.graphingapi.ui.GraphingAPIUIPlugin; import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.adapters.IAdapter; -import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.structures.NumberType; -import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.preferences.GraphingAPIPreferenceConstants; + +import org.swtchart.ILineSeries; +import org.swtchart.ISeries; /** * Builds bar chart. * * @author Qi Liang */ -@SuppressWarnings("deprecation") -public class AreaChartBuilder extends AbstractChartWithAxisBuilder { - - /** - * Constructor. - * - * @param dataSet - * data for chart - */ - /* public BarChartBuilder(String title,IDataSet dataSet,int Xseries, int[] Yseries) { - super(dataSet); - this.title = title; - System.out.println("reached barchartbuilder" + title); - this.xseries = Xseries; - System.out.println("reached barchartbuilder" + xseries); - //this.yseries = new int[Yseries.length]; - //System.arraycopy(yseries, 0, Yseries, 0, Yseries.length); - this.yseries = Yseries; - for (int i = 0; i<yseries.length; i++) - System.out.println(yseries[i]); - System.out.println("reached barchartbuilder" + yseries); - xTitle = "Cities"; - yTitle = "Technicians"; - } */ - - protected IDeviceRenderer render = null; - protected ChartWithAxes chart = null; - protected AbstractChartBuilder builder = null; - protected GeneratedChartState state = null; - - public AreaChartBuilder(Composite parent, int style, String title,IAdapter adapter) { - super(adapter, parent, style); - this.title = title; - this.parent = parent; - - try { - // INITIALIZE THE SWT RENDERING DEVICE - //PluginSettings ps = PluginSettings.instance(); - PlatformConfig pf = new PlatformConfig(); - ChartEngine ce = ChartEngine.instance(pf); - render = ce.getRenderer("dv.SWT"); - } catch (Exception e) { - // e.printStackTrace(); - } - this.addPaintListener(new painter()); - } - - private class painter implements PaintListener { - /** - * The SWT paint callback - */ - public void paintControl(PaintEvent pe) - { - if (chart == null) return; - try{ - render.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, pe.gc); - Composite co = (Composite) pe.getSource(); - Rectangle re = co.getClientArea(); - Bounds bo = BoundsImpl.create(re.x, re.y, re.width, re.height); - bo.scale(72d / render.getDisplayServer().getDpiResolution()); - Generator gr = Generator.instance(); - state = gr.build(render.getDisplayServer(), - chart, - bo, - null, - null, - null); - gr.render(render, state); - } catch (ChartException e) { - // e.printStackTrace(); - } - } - } - - - - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildChart() - */ - protected void createChart() { - //data = adapter.getData(); - //while (data.length == 0 ) { data = adapter.getData();} - IPreferenceStore store = GraphingAPIUIPlugin.getDefault().getPreferenceStore(); - xSeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_X_SERIES_TICKS); - ySeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_Y_SERIES_TICKS); - maxItems = store.getInt(GraphingAPIPreferenceConstants.P_MAX_DATA_ITEMS); - viewableItems = store.getInt(GraphingAPIPreferenceConstants.P_VIEWABLE_DATA_ITEMS); - - chart = ChartWithAxesImpl.create(); - - chart.setDimension(ChartDimension.TWO_DIMENSIONAL_LITERAL); - chart.setType("Line Chart"); - - // Plot - //chart.getBlock( ).setBackground(ColorDefinitionImpl.WHITE( ) ); - // Plot p = chart.getPlot( ); - /// p.getClientArea( ).setBackground(GradientImpl.create( ColorDefinitionImpl.create( 225,225,255 ),ColorDefinitionImpl.create( 255, 255, 225 ),-35,false ) ); - //p.getOutline( ).setVisible( true ); - // Title cwaBar.getTitle( ) .getLabel() .getCaption( ) .setValue( "Bar Chart with Multiple Y Series" );//$NON-NLS-1$ - // Legend - //Legend lg = cwaBar.getLegend( ); - //lg.getText( - //).getFont( ).setSize( 16 ); lg.getInsets( ).set( 10, 5, 0, 0 ); - // lg.setAnchor( Anchor.NORTH_LITERAL ); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildLegend() - */ - protected void buildLegend() { - createLegend(); - chart.getLegend().setItemType(LegendItemType.SERIES_LITERAL); - chart.getLegend().getClientArea().getOutline( ).setVisible( true ); - chart.getLegend().getText().getFont().setSize(7); - chart.getLegend().setVisible(true); - } - - protected void buildTitle() { - chart.getTitle().getLabel().getCaption().setValue(title); - chart.getTitle().getLabel().getCaption().getFont().setSize(10); - chart.getTitle().getLabel().getCaption().getFont().setName(FONT_NAME); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildXAxis() - */ - protected void buildXAxis() { - //labels = adapter.getLabels(); - xAxis = ((ChartWithAxes) chart).getPrimaryBaseAxes()[0]; - xAxis.getTitle().setVisible(true); - xAxis.getTitle().getCaption().setValue(labels[0]); - xAxis.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL); - xAxis.setType(AxisType.TEXT_LITERAL); - xAxis.getOrigin().setType(IntersectionType.VALUE_LITERAL); - xAxis.getTitle().getCaption().getFont().setSize(8); - xAxis.getLabel().getCaption().getFont().setSize(6); - } - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildYAxis() - */ - protected void buildYAxis() { - yAxis = ((ChartWithAxes) chart).getPrimaryOrthogonalAxis(xAxis); +public class AreaChartBuilder extends LineChartBuilder { - yAxis.getMajorGrid().getLineAttributes().setVisible(true); - // yAxis.getMajorGrid().getLineAttributes().setColor(ColorDefinitionImpl - // .GREY()); - yAxis.getMajorGrid().getLineAttributes() - .setStyle(LineStyle.DASHED_LITERAL); - yAxis.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL); + public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.areachartbuilder"; - yAxis.setType(AxisType.LINEAR_LITERAL); - yAxis.getOrigin().setType(IntersectionType.VALUE_LITERAL); - yAxis.getTitle().getCaption().getFont().setSize(8); - yAxis.getLabel().getCaption().getFont().setSize(6); - //yAxis.getScale().setStep(1.0); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildXSeries() - */ - protected void buildXSeries() { - - data = adapter.getData(); - - int starting = 0; - if (data.length > xSeriesTicks ) starting = data.length - xSeriesTicks; - x= new String[data.length - starting]; - - try { - for (int j=starting,k=0; j < data.length; j++,k++ ) - x[k] = data[j][0].toString(); - } catch (Exception e) - { - // e.printStackTrace(); - } - TextDataSet categoryValues = TextDataSetImpl.create(x); - // NumberDataSet categoryValues = NumberDataSetImpl.create(new double[] { 0, 1, 2, 3 }); - - Series seCategory = SeriesImpl.create(); - - seCategory.setDataSet(categoryValues); - - // Apply the color palette - SeriesDefinition sdX = SeriesDefinitionImpl.create(); - sdX.getSeriesPalette().update(1); - - xAxis.getSeriesDefinitions().add(sdX); - - sdX.getSeries().add(seCategory); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildYSeries() - */ - protected void buildYSeries() { - try{ - - //NumberDataSet orthoValuesDataSet1 = NumberDataSetImpl.create(new double[] { 4, 5, 6, 7}); - /* y = new Double[adapter.getSeriesCount()-1][data.length]; - for (int i =1; i <=adapter.getSeriesCount(); i++) - { - for (int j =0; j < data.length; j++ ) - y[i-1][j] = NumberType.obj2num(data[j][i]).doubleValue(); - } */ - - int starting = 0; - if (data.length > xSeriesTicks ) starting = data.length - xSeriesTicks; - int yseriescount = adapter.getSeriesCount(); - NumberDataSet orthoValuesDataSet[] = new NumberDataSet[yseriescount]; - AreaSeries as1[] = new AreaSeries[yseriescount]; - SeriesDefinition sdY[] = new SeriesDefinition[yseriescount]; - - - for (int i =1; i<=yseriescount;i++) - {y= new Double[data.length - starting]; - for (int j=starting,k=0; j < data.length; j++,k++ ) - { - y[k] = NumberType.obj2num(data[j][i]).doubleValue(); - if ( max < y[k]) max = y[k]; - if ( min > y[k]) min = y[k]; - } - orthoValuesDataSet[i-1]= NumberDataSetImpl.create(y); - as1[i-1]= (AreaSeries) AreaSeriesImpl.create(); - as1[i-1].setDataSet(orthoValuesDataSet[i-1]); - //bs1[i-1].getDisplayName(). - //bs1[i-1].getLabel().setVisible(true); - //bs1[i-1].setLabelPosition(Position.INSIDE_LITERAL); - - as1[i-1].setSeriesIdentifier(labels[i]); - // for ( int m = 0; i < ls1[i-1].getMarkers( ).size( ); i++ ) - // { - // ( (Marker) ls1[i-1].getMarkers( ).get( i ) ).setType( MarkerType.TRIANGLE_LITERAL ); - // ( (Marker) ls1[i-1].getMarkers( ).get( i ) ).setSize( 10 ); - // } - sdY[i-1] = SeriesDefinitionImpl.create(); - sdY[i-1].getSeriesPalette().update(0-i-2); - - yAxis.getSeriesDefinitions().add(sdY[i-1]); - sdY[i-1].getSeries().add(as1[i-1]); - } - - yAxis.getScale().setStep(max/2); - yAxis.getScale().setMax(NumberDataElementImpl.create(max)); - - }catch (Exception e) - { - // e.printStackTrace(); - } + public AreaChartBuilder(Composite parent, int style, String title,IAdapter adapter) { + super(parent, style, title, adapter); } - - public void updateDataSet() { - // Associate with Data Set - try{ - data = adapter.getData(); - int starting = 0; - if (data.length > xSeriesTicks ) starting = data.length - xSeriesTicks; - - - x= new String[data.length - starting]; - for (int j=starting,k =0; j < data.length; j++,k++ ) - x[k] = data[j][0].toString(); - // X-Axis - TextDataSet categoryValues = TextDataSetImpl.create(x); - - Axis xAxisPrimary = chart.getPrimaryBaseAxes()[0]; - SeriesDefinition sdX = (SeriesDefinition) xAxisPrimary - .getSeriesDefinitions().get(0); - ((Series) sdX.getSeries().get(0)).setDataSet(categoryValues); - - // Y-Axis - Axis yAxisPrimary = chart.getPrimaryOrthogonalAxis(xAxisPrimary); - // chart.getOrthogonalAxes(xAxisPrimary, arg1) - - - NumberDataSet orthoValuesDataSet1[] = new NumberDataSet[adapter.getSeriesCount()]; - for (int i=1; i<=adapter.getSeriesCount();i++) - { - y= new Double[data.length - starting]; - for (int j=starting,k=0; j < data.length; j++,k++ ) - { - y[k] = NumberType.obj2num(data[j][i]).doubleValue(); - if ( max < y[k]) max = y[k]; - } - orthoValuesDataSet1[i-1]= NumberDataSetImpl.create(y); - SeriesDefinition sdY = (SeriesDefinition) yAxisPrimary - .getSeriesDefinitions().get(i-1); - ((Series) sdY.getSeries().get(0)).setDataSet(orthoValuesDataSet1[i-1]); - - } - yAxis.getScale().setStep(max/5); - yAxis.getScale().setMax(NumberDataElementImpl.create(max)); - }catch(Exception e) - { - // e.printStackTrace(); - } - } - - - -public void handleUpdateEvent() { - // TODO Auto-generated method stub - - try{ - updateDataSet(); - repaint(); - }catch(Exception e) - { - //e.printStackTrace(); + protected ISeries createChartISeries(int i) { + ILineSeries series = (ILineSeries) super.createChartISeries(i); + series.enableArea(true); + return series; } } - -public synchronized void repaint() { - getDisplay().syncExec(new Runnable() { - boolean stop = false; - public void run() { - if(stop) return; - try { - redraw(); - } catch (Exception e) { - stop = true; - } - } - }); -} - -protected void createLegend() { - labels = adapter.getLabels(); - String[] labels2 = new String[labels.length-1]; -// Color[] colors = new Color[labels2.length]; - - for(int i=0; i<labels2.length; i++) { - labels2[i] = labels[i+1]; - // colors[i] = new Color(this.getDisplay(), IGraphColorConstants.COLORS[i]); - } - - //legend = new GraphLegend(this, labels2, colors); -} - -public void setScale(double scale) { - IPreferenceStore store = GraphingAPIUIPlugin.getDefault().getPreferenceStore(); - xSeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_X_SERIES_TICKS); - xSeriesTicks = (int) (((Integer)xSeriesTicks).doubleValue() * scale); - handleUpdateEvent(); -} - -String x[]; -Double y[]; -boolean fullUpdate; -Object data[][]; -Composite parent = null; -String labels[]; -protected static int xSeriesTicks; -protected static int ySeriesTicks; -protected static int maxItems; -protected static int viewableItems; -public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.areachartbuilder"; -Double min = 0.0; -Double max = 0.0; - -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/BarChartBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/BarChartBuilder.java index 6cc797089f..dd95d9fd12 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/BarChartBuilder.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/BarChartBuilder.java @@ -13,45 +13,13 @@ */ package org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts; -import org.eclipse.birt.chart.api.ChartEngine; -import org.eclipse.birt.chart.device.IDeviceRenderer; -import org.eclipse.birt.chart.exception.ChartException; -import org.eclipse.birt.chart.factory.GeneratedChartState; -import org.eclipse.birt.chart.factory.Generator; -import org.eclipse.birt.chart.model.ChartWithAxes; -import org.eclipse.birt.chart.model.attribute.AxisType; -import org.eclipse.birt.chart.model.attribute.Bounds; -import org.eclipse.birt.chart.model.attribute.ChartDimension; -import org.eclipse.birt.chart.model.attribute.IntersectionType; -import org.eclipse.birt.chart.model.attribute.LegendItemType; -import org.eclipse.birt.chart.model.attribute.LineStyle; -import org.eclipse.birt.chart.model.attribute.TickStyle; -import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl; -import org.eclipse.birt.chart.model.component.Axis; -import org.eclipse.birt.chart.model.component.Series; -import org.eclipse.birt.chart.model.component.impl.SeriesImpl; -import org.eclipse.birt.chart.model.data.NumberDataSet; -import org.eclipse.birt.chart.model.data.SeriesDefinition; -import org.eclipse.birt.chart.model.data.TextDataSet; -import org.eclipse.birt.chart.model.data.impl.NumberDataElementImpl; -import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl; -import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl; -import org.eclipse.birt.chart.model.data.impl.TextDataSetImpl; -import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl; -import org.eclipse.birt.chart.model.type.BarSeries; -import org.eclipse.birt.chart.model.type.impl.BarSeriesImpl; -import org.eclipse.birt.core.framework.PlatformConfig; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; -import org.eclipse.linuxtools.internal.systemtap.ui.graphingapi.ui.GraphingAPIUIPlugin; -import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.adapters.BlockAdapter; import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.adapters.IAdapter; -import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.structures.NumberType; -import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.preferences.GraphingAPIPreferenceConstants; + +import org.swtchart.IBarSeries; +import org.swtchart.ISeries; +import org.swtchart.ISeries.SeriesType; /** * Builds bar chart. @@ -59,382 +27,30 @@ import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.preferences.GraphingAP * @author Qi Liang */ -@SuppressWarnings("deprecation") public class BarChartBuilder extends AbstractChartWithAxisBuilder { + public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.barchartbuilder"; - /** - * Constructor. - * - * @param dataSet - * data for chart - */ - /* public BarChartBuilder(String title,IDataSet dataSet,int Xseries, int[] Yseries) { - super(dataSet); - this.title = title; - System.out.println("reached barchartbuilder" + title); - this.xseries = Xseries; - System.out.println("reached barchartbuilder" + xseries); - //this.yseries = new int[Yseries.length]; - //System.arraycopy(yseries, 0, Yseries, 0, Yseries.length); - this.yseries = Yseries; - for (int i = 0; i<yseries.length; i++) - System.out.println(yseries[i]); - System.out.println("reached barchartbuilder" + yseries); - xTitle = "Cities"; - yTitle = "Technicians"; - } */ - - protected IDeviceRenderer render = null; - protected ChartWithAxes chart = null; - protected AbstractChartBuilder builder = null; - protected GeneratedChartState state = null; - - public BarChartBuilder(Composite parent, int style, String title,IAdapter adapter) { - super(adapter, parent, style); - fullUpdate = (adapter instanceof BlockAdapter) ? true : false; - this.title = title; - this.parent = parent; - try { - // INITIALIZE THE SWT RENDERING DEVICE - //PluginSettings ps = PluginSettings.instance(); - PlatformConfig pf = new PlatformConfig(); - ChartEngine ce = ChartEngine.instance(pf); - render = ce.getRenderer("dv.SWT"); - } catch (Exception e) { - // TODO Auto-generated catch block - //e.printStackTrace(); - } - this.addPaintListener(new painter()); + super(adapter, parent, style, title); } - private class painter implements PaintListener { - /** - * The SWT paint callback - */ - public void paintControl(PaintEvent pe) - { - if (chart == null) return; - try{ - render.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, pe.gc); - Composite co = (Composite) pe.getSource(); - Rectangle re = co.getClientArea(); - Bounds bo = BoundsImpl.create(re.x, re.y, re.width, re.height); - bo.scale(72d / render.getDisplayServer().getDpiResolution()); - Generator gr = Generator.instance(); - state = gr.build(render.getDisplayServer(), - chart, - bo, - null, - null, - null); - gr.render(render, state); - } catch (ChartException e) { - // e.printStackTrace(); - } - } - } - - - - /* * (non-Javadoc) * * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildChart() */ protected void createChart() { - // data = adapter.getData(); - // while (data.length == 0 ) { data = adapter.getData();} - IPreferenceStore store = GraphingAPIUIPlugin.getDefault().getPreferenceStore(); - xSeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_X_SERIES_TICKS); - ySeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_Y_SERIES_TICKS); - maxItems = store.getInt(GraphingAPIPreferenceConstants.P_MAX_DATA_ITEMS); - viewableItems = store.getInt(GraphingAPIPreferenceConstants.P_VIEWABLE_DATA_ITEMS); - - chart = ChartWithAxesImpl.create(); - - chart.setDimension(ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL); - chart.setType("Bar Chart"); - chart.setSubType("Side-by-side"); - // Plot - //chart.getBlock( ).setBackground(ColorDefinitionImpl.WHITE( ) ); - // Plot p = chart.getPlot( ); - /// p.getClientArea( ).setBackground(GradientImpl.create( ColorDefinitionImpl.create( 225,225,255 ),ColorDefinitionImpl.create( 255, 255, 225 ),-35,false ) ); - //p.getOutline( ).setVisible( true ); - // Title cwaBar.getTitle( ) .getLabel() .getCaption( ) .setValue( "Bar Chart with Multiple Y Series" );//$NON-NLS-1$ - // Legend - //Legend lg = cwaBar.getLegend( ); - //lg.getText( - //).getFont( ).setSize( 16 ); lg.getInsets( ).set( 10, 5, 0, 0 ); - // lg.setAnchor( Anchor.NORTH_LITERAL ); - - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildLegend() - */ - protected void buildLegend() { - createLegend(); - chart.getLegend().setItemType(LegendItemType.SERIES_LITERAL); - chart.getLegend().getClientArea().getOutline( ).setVisible( true ); - chart.getLegend().getText().getFont().setSize(7); - chart.getLegend().setVisible(true); - - } - - protected void buildTitle() { - chart.getTitle().getLabel().getCaption().setValue(title); - chart.getTitle().getLabel().getCaption().getFont().setSize(10); - chart.getTitle().getLabel().getCaption().getFont().setName(FONT_NAME); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildXAxis() - */ - protected void buildXAxis() { - //labels = adapter.getLabels(); - xAxis = ((ChartWithAxes) chart).getPrimaryBaseAxes()[0]; - xAxis.getTitle().setVisible(true); - xAxis.getTitle().getCaption().getFont().setSize(8); - xAxis.getLabel().getCaption().getFont().setSize(6); - xAxis.getTitle().getCaption().setValue(labels[0]); - xAxis.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL); - xAxis.setType(AxisType.TEXT_LITERAL); - xAxis.getOrigin().setType(IntersectionType.VALUE_LITERAL); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildYAxis() - */ - protected void buildYAxis() { - yAxis = ((ChartWithAxes) chart).getPrimaryOrthogonalAxis(xAxis); - - yAxis.getMajorGrid().getLineAttributes().setVisible(true); - // yAxis.getMajorGrid().getLineAttributes().setColor(ColorDefinitionImpl - // .GREY()); - yAxis.getMajorGrid().getLineAttributes() - .setStyle(LineStyle.DASHED_LITERAL); - - - yAxis.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL); - - yAxis.setType(AxisType.LINEAR_LITERAL); - yAxis.getOrigin().setType(IntersectionType.VALUE_LITERAL); - yAxis.getTitle().getCaption().getFont().setSize(8); - yAxis.getLabel().getCaption().getFont().setSize(6); - //yAxis.getScale().setStep(1.0); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildXSeries() - */ - protected void buildXSeries() { - - data = adapter.getData(); - - int starting = 0; - if (data.length > xSeriesTicks ) starting = data.length - xSeriesTicks; - x= new String[data.length - starting]; - try { - for (int j=starting,k=0; j < data.length; j++,k++ ) - x[k] = data[j][0].toString(); - } catch (Exception e) - { - e.printStackTrace(); - } - // NumberDataSet categoryValues = NumberDataSetImpl.create(x); - // NumberDataSet categoryValues = NumberDataSetImpl.create(new double[] { 0, 1, 2, 3 }); - TextDataSet categoryValues = TextDataSetImpl.create(x); - - Series seCategory = SeriesImpl.create(); - - seCategory.setDataSet(categoryValues); - - // Apply the color palette - SeriesDefinition sdX = SeriesDefinitionImpl.create(); - sdX.getSeriesPalette().update(1); - - xAxis.getSeriesDefinitions().add(sdX); - - sdX.getSeries().add(seCategory); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildYSeries() - */ - protected void buildYSeries() { - try{ - - //NumberDataSet orthoValuesDataSet1 = NumberDataSetImpl.create(new double[] { 4, 5, 6, 7}); - /*for (int i=0; i < dataSet.getRow(yseries[0]).length; i++) - { - System.out.println(dataSet.getRow(yseries[0])[i]); - //System.out.println((Integer)dataSet.getRow(yseries[0])[i]); - } */ - /* y = new Double[adapter.getSeriesCount()-1][data.length]; - for (int i =1; i <=adapter.getSeriesCount(); i++) - { - for (int j =0; j < data.length; j++ ) - y[i-1][j] = NumberType.obj2num(data[j][i]).doubleValue(); - } */ - - int starting = 0; - if (data.length > xSeriesTicks ) starting = data.length - xSeriesTicks; - int yseriescount = adapter.getSeriesCount(); - NumberDataSet orthoValuesDataSet[] = new NumberDataSet[yseriescount]; - BarSeries bs1[] = new BarSeries[yseriescount]; - SeriesDefinition sdY[] = new SeriesDefinition[yseriescount]; - - - for (int i =1; i<=yseriescount;i++) - {y= new Double[data.length - starting]; - for (int j=starting,k=0; j < data.length; j++,k++ ) - { - y[k] = NumberType.obj2num(data[j][i]).doubleValue(); - if ( max < y[k]) max = y[k]; - if ( min > y[k]) min = y[k]; - } - //if (min > 0 ) min = min/2; - orthoValuesDataSet[i-1]= NumberDataSetImpl.create(y); - bs1[i-1]= (BarSeries) BarSeriesImpl.create(); - bs1[i-1].setDataSet(orthoValuesDataSet[i-1]); - //bs1[i-1].getDisplayName(). - //bs1[i-1].getLabel().setVisible(true); - //bs1[i-1].setLabelPosition(Position.INSIDE_LITERAL); - bs1[i-1].setRiserOutline(null); - bs1[i-1].setSeriesIdentifier(labels[i]); - sdY[i-1] = SeriesDefinitionImpl.create(); - sdY[i-1].getSeriesPalette().update(0-i-2); - - yAxis.getSeriesDefinitions().add(sdY[i-1]); - sdY[i-1].getSeries().add(bs1[i-1]); - } - - yAxis.getScale().setStep(max/2); - yAxis.getScale().setMax(NumberDataElementImpl.create(max)); - - }catch (Exception e) - { - // e.printStackTrace(); - } + super.createChart(); } - - - public void updateDataSet() { - // Associate with Data Set - try{ - data = adapter.getData(); - int starting = 0; - if (data.length > xSeriesTicks ) starting = data.length - xSeriesTicks; - - - x= new String[data.length - starting]; - for (int j=starting,k =0; j < data.length; j++,k++ ) - x[k] = data[j][0].toString(); - // X-Axis - TextDataSet categoryValues = TextDataSetImpl.create(x); - Axis xAxisPrimary = chart.getPrimaryBaseAxes()[0]; - SeriesDefinition sdX = (SeriesDefinition) xAxisPrimary - .getSeriesDefinitions().get(0); - ((Series) sdX.getSeries().get(0)).setDataSet(categoryValues); - // Y-Axis - Axis yAxisPrimary = chart.getPrimaryOrthogonalAxis(xAxisPrimary); - // chart.getOrthogonalAxes(xAxisPrimary, arg1) - - - NumberDataSet orthoValuesDataSet1[] = new NumberDataSet[adapter.getSeriesCount()]; - for (int i=1; i<=adapter.getSeriesCount();i++) - { - y= new Double[data.length - starting]; - for (int j=starting,k=0; j < data.length; j++,k++ ) - { - y[k] = NumberType.obj2num(data[j][i]).doubleValue(); - if ( max < y[k]) max = y[k]; - } - orthoValuesDataSet1[i-1]= NumberDataSetImpl.create(y); - SeriesDefinition sdY = (SeriesDefinition) yAxisPrimary - .getSeriesDefinitions().get(i-1); - ((Series) sdY.getSeries().get(0)).setDataSet(orthoValuesDataSet1[i-1]); - - } - yAxis.getScale().setStep(max/5); - yAxis.getScale().setMax(NumberDataElementImpl.create(max)); - }catch(Exception e) - { - // e.printStackTrace(); - } - } - - - -public void handleUpdateEvent() { - // TODO Auto-generated method stub - - try{ - updateDataSet(); - repaint(); - }catch(Exception e) - { - // e.printStackTrace(); + protected ISeries createChartISeries(int i) { + IBarSeries series = (IBarSeries)chart.getSeriesSet(). + createSeries(SeriesType.BAR, adapter.getLabels()[i+1]); + series.setBarColor(COLORS[i % COLORS.length]); + return series; } -} - -public synchronized void repaint() { - getDisplay().syncExec(new Runnable() { - boolean stop = false; - public void run() { - if(stop) return; - try { - redraw(); - } catch (Exception e) { - stop = true; - } - } - }); -} - -protected void createLegend() { - labels = adapter.getLabels(); - String[] labels2 = new String[labels.length-1]; -// Color[] colors = new Color[labels2.length]; - for(int i=0; i<labels2.length; i++) { - labels2[i] = labels[i+1]; - // colors[i] = new Color(this.getDisplay(), IGraphColorConstants.COLORS[i]); + public void updateDataSet() { + buildXSeries(); } - - //legend = new GraphLegend(this, labels2, colors); -} - -public void setScale(double scale) { - xSeriesTicks = (int) (((Integer)xSeriesTicks).doubleValue() * scale); - handleUpdateEvent(); -} - -String x[]; -Double y[]; -boolean fullUpdate; -Object data[][]; -Composite parent = null; -String labels[]; -protected int xSeriesTicks; -protected static int ySeriesTicks; -protected static int maxItems; -protected static int viewableItems; -public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.barchartbuilder"; -Double min = 0.0; -Double max = 0.0; - } diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/DialChartBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/DialChartBuilder.java deleted file mode 100644 index 07082e4c78..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/DialChartBuilder.java +++ /dev/null @@ -1,63 +0,0 @@ - -package org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts; - -import org.eclipse.birt.chart.model.component.Axis; -import org.eclipse.birt.chart.model.impl.DialChartImpl; -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.adapters.IAdapter; - -/** - * Builds the chart with axis. - * - * @author Qi Liang - */ -public abstract class DialChartBuilder extends AbstractChartBuilder { - - /** - * Title of X axis. - */ - protected String xTitle = null; - - /** - * Title of Y axis. - */ - protected String yTitle = null; - - /** - * X axis. - */ - protected Axis xAxis = null; - - /** - * Y axis. - */ - protected Axis yAxis = null; - - /** - * Constructor. - * - * @param dataSet - * data for chart - */ - - public DialChartBuilder(IAdapter adapter, Composite parent, int style) { - super(adapter, parent, style); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#createChart() - */ - protected void createChart() { - chart = DialChartImpl.create(); - } - - public void updateDataSet() - { - - } - - -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/LineChartBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/LineChartBuilder.java index 3cc9de127b..5d1b996861 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/LineChartBuilder.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/LineChartBuilder.java @@ -13,436 +13,48 @@ */ package org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts; -import org.eclipse.birt.chart.api.ChartEngine; -import org.eclipse.birt.chart.device.IDeviceRenderer; -import org.eclipse.birt.chart.exception.ChartException; -import org.eclipse.birt.chart.factory.GeneratedChartState; -import org.eclipse.birt.chart.factory.Generator; -import org.eclipse.birt.chart.model.ChartWithAxes; -import org.eclipse.birt.chart.model.attribute.AxisType; -import org.eclipse.birt.chart.model.attribute.Bounds; -import org.eclipse.birt.chart.model.attribute.ChartDimension; -import org.eclipse.birt.chart.model.attribute.IntersectionType; -import org.eclipse.birt.chart.model.attribute.LegendItemType; -import org.eclipse.birt.chart.model.attribute.LineStyle; -import org.eclipse.birt.chart.model.attribute.TickStyle; -import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl; -import org.eclipse.birt.chart.model.component.Axis; -import org.eclipse.birt.chart.model.component.Series; -import org.eclipse.birt.chart.model.component.impl.SeriesImpl; -import org.eclipse.birt.chart.model.data.NumberDataSet; -import org.eclipse.birt.chart.model.data.SeriesDefinition; -import org.eclipse.birt.chart.model.data.TextDataSet; - -import org.eclipse.birt.chart.model.data.impl.NumberDataElementImpl; -import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl; -import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl; -import org.eclipse.birt.chart.model.data.impl.TextDataSetImpl; - -import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl; - -import org.eclipse.birt.chart.model.type.LineSeries; -import org.eclipse.birt.chart.model.type.impl.LineSeriesImpl; -import org.eclipse.birt.core.framework.PlatformConfig; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; -import org.eclipse.linuxtools.internal.systemtap.ui.graphingapi.ui.GraphingAPIUIPlugin; import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.adapters.IAdapter; -import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.structures.NumberType; -import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.preferences.GraphingAPIPreferenceConstants; + +import org.swtchart.ILineSeries; +import org.swtchart.ISeries; +import org.swtchart.ISeries.SeriesType; +import org.swtchart.LineStyle; /** * Builds bar chart. * * @author Qi Liang */ + public class LineChartBuilder extends AbstractChartWithAxisBuilder { - /** - * Constructor. - * - * @param dataSet - * data for chart - */ - /* public BarChartBuilder(String title,IDataSet dataSet,int Xseries, int[] Yseries) { - super(dataSet); - this.title = title; - System.out.println("reached barchartbuilder" + title); - this.xseries = Xseries; - System.out.println("reached barchartbuilder" + xseries); - //this.yseries = new int[Yseries.length]; - //System.arraycopy(yseries, 0, Yseries, 0, Yseries.length); - this.yseries = Yseries; - for (int i = 0; i<yseries.length; i++) - System.out.println(yseries[i]); - System.out.println("reached barchartbuilder" + yseries); - xTitle = "Cities"; - yTitle = "Technicians"; - } */ - - protected IDeviceRenderer render = null; - protected ChartWithAxes chart = null; - protected AbstractChartBuilder builder = null; - protected GeneratedChartState state = null; + public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.linechartbuilder"; + public LineChartBuilder(Composite parent, int style, String title,IAdapter adapter) { - super(adapter, parent, style); - this.title = title; - this.parent = parent; - - try { - // INITIALIZE THE SWT RENDERING DEVICE - //PluginSettings ps = PluginSettings.instance(); - PlatformConfig pf = new PlatformConfig(); - ChartEngine ce = ChartEngine.instance(pf); - render = ce.getRenderer("dv.SWT"); - } catch (Exception e) { - // e.printStackTrace(); - } - this.addPaintListener(new painter()); + super(adapter, parent, style, title); } - private class painter implements PaintListener { - /** - * The SWT paint callback - */ - public void paintControl(PaintEvent pe) - { - if (chart == null) return; - try{ - render.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, pe.gc); - Composite co = (Composite) pe.getSource(); - Rectangle re = co.getClientArea(); - Bounds bo = BoundsImpl.create(re.x, re.y, re.width, re.height); - bo.scale(72d / render.getDisplayServer().getDpiResolution()); - Generator gr = Generator.instance(); - state = gr.build(render.getDisplayServer(), - chart, - bo, - null, - null, - null); - gr.render(render, state); - } catch (ChartException e) { - // e.printStackTrace(); - } - } - } - - - - /* * (non-Javadoc) * * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildChart() */ protected void createChart() { - //data = adapter.getData(); - //while (data.length == 0 ) { data = adapter.getData();} - - IPreferenceStore store = GraphingAPIUIPlugin.getDefault().getPreferenceStore(); - xSeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_X_SERIES_TICKS); - ySeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_Y_SERIES_TICKS); - maxItems = store.getInt(GraphingAPIPreferenceConstants.P_MAX_DATA_ITEMS); - viewableItems = store.getInt(GraphingAPIPreferenceConstants.P_VIEWABLE_DATA_ITEMS); - - chart = ChartWithAxesImpl.create(); - - chart.setDimension(ChartDimension.TWO_DIMENSIONAL_LITERAL); - chart.setType("Line Chart"); - - // Plot - //chart.getBlock( ).setBackground(ColorDefinitionImpl.WHITE( ) ); - // Plot p = chart.getPlot( ); - /// p.getClientArea( ).setBackground(GradientImpl.create( ColorDefinitionImpl.create( 225,225,255 ),ColorDefinitionImpl.create( 255, 255, 225 ),-35,false ) ); - //p.getOutline( ).setVisible( true ); - // Title cwaBar.getTitle( ) .getLabel() .getCaption( ) .setValue( "Bar Chart with Multiple Y Series" );//$NON-NLS-1$ - // Legend - //Legend lg = cwaBar.getLegend( ); - //lg.getText( - //).getFont( ).setSize( 16 ); lg.getInsets( ).set( 10, 5, 0, 0 ); - // lg.setAnchor( Anchor.NORTH_LITERAL ); - - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildLegend() - */ - protected void buildLegend() { - createLegend(); - chart.getLegend().setItemType(LegendItemType.SERIES_LITERAL); - chart.getLegend().getClientArea().getOutline( ).setVisible( true ); - chart.getLegend().getText().getFont().setSize(7); - chart.getLegend().setVisible(true); - - } - - protected void buildTitle() { - chart.getTitle().getLabel().getCaption().setValue(title); - chart.getTitle().getLabel().getCaption().getFont().setSize(10); - chart.getTitle().getLabel().getCaption().getFont().setName(FONT_NAME); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildXAxis() - */ - protected void buildXAxis() { - //labels = adapter.getLabels(); - xAxis = ((ChartWithAxes) chart).getPrimaryBaseAxes()[0]; - xAxis.getTitle().setVisible(true); - xAxis.getTitle().getCaption().setValue(labels[0]); - xAxis.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL); - xAxis.setType(AxisType.TEXT_LITERAL); - xAxis.getOrigin().setType(IntersectionType.VALUE_LITERAL); - xAxis.getTitle().getCaption().getFont().setSize(8); - xAxis.getLabel().getCaption().getFont().setSize(6); + super.createChart(); } - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildYAxis() - */ - protected void buildYAxis() { - yAxis = ((ChartWithAxes) chart).getPrimaryOrthogonalAxis(xAxis); - - yAxis.getMajorGrid().getLineAttributes().setVisible(true); - // yAxis.getMajorGrid().getLineAttributes().setColor(ColorDefinitionImpl - // .GREY()); - yAxis.getMajorGrid().getLineAttributes() - .setStyle(LineStyle.DASHED_LITERAL); - yAxis.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL); - -// - yAxis.setType(AxisType.LINEAR_LITERAL); - yAxis.getOrigin().setType(IntersectionType.VALUE_LITERAL); - yAxis.getTitle().getCaption().getFont().setSize(8); - yAxis.getLabel().getCaption().getFont().setSize(6); - //yAxis.getScale().setStep(1.0); - - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildXSeries() - */ - @SuppressWarnings("deprecation") - protected void buildXSeries() { - - data = adapter.getData(); - - int starting = 0; - if (data.length > xSeriesTicks ) starting = data.length - xSeriesTicks; - x= new String[data.length - starting]; - try { - for (int j=starting,k=0; j < data.length; j++,k++ ) - x[k] = data[j][0].toString(); - } catch (Exception e) - { - // e.printStackTrace(); - } - TextDataSet categoryValues = TextDataSetImpl.create(x); - // NumberDataSet categoryValues = NumberDataSetImpl.create(new double[] { 0, 1, 2, 3 }); - - Series seCategory = SeriesImpl.create(); - - seCategory.setDataSet(categoryValues); - - // Apply the color palette - SeriesDefinition sdX = SeriesDefinitionImpl.create(); - sdX.getSeriesPalette().update(1); - - xAxis.getSeriesDefinitions().add(sdX); - - sdX.getSeries().add(seCategory); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildYSeries() - */ - @SuppressWarnings("deprecation") - protected void buildYSeries() { - try{ - - //NumberDataSet orthoValuesDataSet1 = NumberDataSetImpl.create(new double[] { 4, 5, 6, 7}); - /*for (int i=0; i < dataSet.getRow(yseries[0]).length; i++) - { - System.out.println(dataSet.getRow(yseries[0])[i]); - //System.out.println((Integer)dataSet.getRow(yseries[0])[i]); - } */ - /* y = new Double[adapter.getSeriesCount()-1][data.length]; - for (int i =1; i <=adapter.getSeriesCount(); i++) - { - for (int j =0; j < data.length; j++ ) - y[i-1][j] = NumberType.obj2num(data[j][i]).doubleValue(); - } */ - - int starting = 0; - if (data.length > xSeriesTicks ) starting = data.length - xSeriesTicks; - int yseriescount = adapter.getSeriesCount(); - NumberDataSet orthoValuesDataSet[] = new NumberDataSet[yseriescount]; - LineSeries ls1[] = new LineSeries[yseriescount]; - SeriesDefinition sdY[] = new SeriesDefinition[yseriescount]; - - - for (int i =1; i<=yseriescount;i++) - {y= new Double[data.length - starting]; - for (int j=starting,k=0; j < data.length; j++,k++ ) - { - y[k] = NumberType.obj2num(data[j][i]).doubleValue(); - if ( max < y[k]) max = y[k]; - if ( min > y[k]) min = y[k]; - } - orthoValuesDataSet[i-1]= NumberDataSetImpl.create(y); - ls1[i-1]= (LineSeries) LineSeriesImpl.create(); - ls1[i-1].setDataSet(orthoValuesDataSet[i-1]); - //bs1[i-1].getDisplayName(). - //bs1[i-1].getLabel().setVisible(true); - //bs1[i-1].setLabelPosition(Position.INSIDE_LITERAL); - - ls1[i-1].setSeriesIdentifier(labels[i]); - ls1[i-1].getMarker().setSize(2); - // for ( int m = 0; i < ls1[i-1].getMarkers( ).size( ); i++ ) - // { - // ( (Marker) ls1[i-1].getMarkers( ).get( i ) ).setType( MarkerType.TRIANGLE_LITERAL ); - // ( (Marker) ls1[i-1].getMarkers( ).get( i ) ).setSize( 10 ); - // } - sdY[i-1] = SeriesDefinitionImpl.create(); - sdY[i-1].getSeriesPalette().update(0-i-2); - - yAxis.getSeriesDefinitions().add(sdY[i-1]); - sdY[i-1].getSeries().add(ls1[i-1]); - } - - yAxis.getScale().setStep(max/2); - yAxis.getScale().setMax(NumberDataElementImpl.create(max)); - - }catch (Exception e) - { - //e.printStackTrace(); - } - } - - - public void updateDataSet() { - // Associate with Data Set - try{ - data = adapter.getData(); - int starting = 0; - if (data.length > xSeriesTicks ) starting = data.length - xSeriesTicks; - - - x= new String[data.length - starting]; - for (int j=starting,k =0; j < data.length; j++,k++ ) - x[k] = data[j][0].toString(); - // X-Axis - TextDataSet categoryValues = TextDataSetImpl.create(x); - - Axis xAxisPrimary = chart.getPrimaryBaseAxes()[0]; - SeriesDefinition sdX = (SeriesDefinition) xAxisPrimary - .getSeriesDefinitions().get(0); - ((Series) sdX.getSeries().get(0)).setDataSet(categoryValues); - - // Y-Axis - Axis yAxisPrimary = chart.getPrimaryOrthogonalAxis(xAxisPrimary); - // chart.getOrthogonalAxes(xAxisPrimary, arg1) - - - NumberDataSet orthoValuesDataSet1[] = new NumberDataSet[adapter.getSeriesCount()]; - for (int i=1; i<=adapter.getSeriesCount();i++) - { - y= new Double[data.length - starting]; - for (int j=starting,k=0; j < data.length; j++,k++ ) - { - y[k] = NumberType.obj2num(data[j][i]).doubleValue(); - if ( max < y[k]) max = y[k]; - } - orthoValuesDataSet1[i-1]= NumberDataSetImpl.create(y); - SeriesDefinition sdY = (SeriesDefinition) yAxisPrimary - .getSeriesDefinitions().get(i-1); - ((Series) sdY.getSeries().get(0)).setDataSet(orthoValuesDataSet1[i-1]); - - } - yAxis.getScale().setStep(max/5); - yAxis.getScale().setMax(NumberDataElementImpl.create(max)); - }catch(Exception e) - { - // e.printStackTrace(); - } - } - - - -public void handleUpdateEvent() { - // TODO Auto-generated method stub - - try{ - updateDataSet(); - repaint(); - }catch(Exception e) - { -// e.printStackTrace(); + public void updateDataSet() { + buildXSeries(); } -} - -public synchronized void repaint() { - getDisplay().syncExec(new Runnable() { - boolean stop = false; - public void run() { - if(stop) return; - try { - redraw(); - } catch (Exception e) { - stop = true; - } - } - }); -} -protected void createLegend() { - labels = adapter.getLabels(); - String[] labels2 = new String[labels.length-1]; -// Color[] colors = new Color[labels2.length]; - - for(int i=0; i<labels2.length; i++) { - labels2[i] = labels[i+1]; - // colors[i] = new Color(this.getDisplay(), IGraphColorConstants.COLORS[i]); + protected ISeries createChartISeries(int i) { + ILineSeries series = (ILineSeries) chart.getSeriesSet(). + createSeries(SeriesType.LINE, adapter.getLabels()[i+1]); + series.setSymbolColor(COLORS[i % COLORS.length]); + series.setLineColor(COLORS[i % COLORS.length]); + series.setLineStyle(LineStyle.SOLID); + return series; } - - //legend = new GraphLegend(this, labels2, colors); -} - -public void setScale(double scale) { - IPreferenceStore store = GraphingAPIUIPlugin.getDefault().getPreferenceStore(); - xSeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_X_SERIES_TICKS); - xSeriesTicks = (int) (((Integer)xSeriesTicks).doubleValue() * scale); - handleUpdateEvent(); -} - - -String x[]; -Double y[]; -boolean fullUpdate; -Object data[][]; -Composite parent = null; -String labels[]; -protected int xSeriesTicks; -protected static int ySeriesTicks; -protected static int maxItems; -protected static int viewableItems; -public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.linechartbuilder"; -Double min = 0.0; -Double max = 0.0; - } diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/MeterChartBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/MeterChartBuilder.java deleted file mode 100644 index b4f274bdcf..0000000000 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/MeterChartBuilder.java +++ /dev/null @@ -1,412 +0,0 @@ -/**************************************************************** - * Licensed Material - Property of IBM - * - * ****-*** - * - * (c) Copyright IBM Corp. 2006. All rights reserved. - * - * US Government Users Restricted Rights - Use, duplication or - * disclosure restricted by GSA ADP Schedule Contract with - * IBM Corp. - * - **************************************************************** - */ -package org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts; - -import org.eclipse.birt.chart.api.ChartEngine; -import org.eclipse.birt.chart.device.IDeviceRenderer; -import org.eclipse.birt.chart.exception.ChartException; -import org.eclipse.birt.chart.factory.GeneratedChartState; -import org.eclipse.birt.chart.factory.Generator; -import org.eclipse.birt.chart.model.DialChart; -import org.eclipse.birt.chart.model.attribute.Bounds; -import org.eclipse.birt.chart.model.attribute.LegendItemType; -import org.eclipse.birt.chart.model.attribute.LineDecorator; -import org.eclipse.birt.chart.model.attribute.LineStyle; -import org.eclipse.birt.chart.model.attribute.Position; -import org.eclipse.birt.chart.model.attribute.TickStyle; -import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl; -import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionImpl; -import org.eclipse.birt.chart.model.attribute.impl.LineAttributesImpl; -import org.eclipse.birt.chart.model.component.DialRegion; -import org.eclipse.birt.chart.model.component.Series; -import org.eclipse.birt.chart.model.component.impl.DialRegionImpl; -import org.eclipse.birt.chart.model.component.impl.SeriesImpl; -import org.eclipse.birt.chart.model.data.NumberDataSet; -import org.eclipse.birt.chart.model.data.SeriesDefinition; -import org.eclipse.birt.chart.model.data.TextDataSet; -import org.eclipse.birt.chart.model.data.impl.NumberDataElementImpl; -import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl; -import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl; -import org.eclipse.birt.chart.model.data.impl.TextDataSetImpl; -import org.eclipse.birt.chart.model.impl.DialChartImpl; -import org.eclipse.birt.chart.model.type.DialSeries; -import org.eclipse.birt.chart.model.type.impl.DialSeriesImpl; -import org.eclipse.birt.core.framework.PlatformConfig; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.widgets.Composite; - -import org.eclipse.linuxtools.internal.systemtap.ui.graphingapi.ui.GraphingAPIUIPlugin; -import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.adapters.IAdapter; -import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.structures.NumberType; -import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.preferences.GraphingAPIPreferenceConstants; - -/** - * Builds bar chart. - * - * @author Qi Liang - */ -public class MeterChartBuilder extends AbstractChartWithoutAxisBuilder { - protected IDeviceRenderer render = null; - protected DialChart chart = null; - protected AbstractChartBuilder builder = null; - protected GeneratedChartState state = null; - // private boolean bFirstPaint = true; - - public MeterChartBuilder(Composite parent, int style, String title,IAdapter adapter) { - super(adapter, parent, style); - this.title = title; - this.parent = parent; - - try { - PlatformConfig pf = new PlatformConfig(); - ChartEngine ce = ChartEngine.instance(pf); - render = ce.getRenderer("dv.SWT"); - } catch (Exception e) { - e.printStackTrace(); - } - this.addPaintListener(new painter()); - } - - private class painter implements PaintListener { - /** - * The SWT paint callback - */ - public void paintControl(PaintEvent pe) - { - if (chart == null) return; - try{ - render.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, pe.gc); - Composite co = (Composite) pe.getSource(); - Rectangle re = co.getClientArea(); - Bounds bo = BoundsImpl.create(re.x, re.y, re.width, re.height); - bo.scale(72d / render.getDisplayServer().getDpiResolution()); - Generator gr = Generator.instance(); - state = gr.build(render.getDisplayServer(), - chart, - bo, - null, - null, - null); - gr.render(render, state); - } catch (ChartException e) { - e.printStackTrace(); - } - } - } - - - - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildChart() - */ - protected void createChart() { - data = adapter.getData(); - while (data.length == 0 ) { data = adapter.getData();} - IPreferenceStore store = GraphingAPIUIPlugin.getDefault().getPreferenceStore(); - xSeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_X_SERIES_TICKS); - ySeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_Y_SERIES_TICKS); - maxItems = store.getInt(GraphingAPIPreferenceConstants.P_MAX_DATA_ITEMS); - viewableItems = store.getInt(GraphingAPIPreferenceConstants.P_VIEWABLE_DATA_ITEMS); - - chart = (DialChart) DialChartImpl.create(); - chart.setDialSuperimposition( false ); - chart.setType( "Meter Chart" );//$NON-NLS-1$ - chart.setSubType( "Superimposed Meter Chart" );//$NON-NLS-1$ - //chart.setDimension(ChartDimension.TWO_DIMENSIONAL_LITERAL); - - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildLegend() - */ - protected void buildLegend() { - createLegend(); - chart.getLegend().setItemType(LegendItemType.CATEGORIES_LITERAL); - chart.getLegend().getClientArea().getOutline( ).setVisible( true ); - chart.getLegend().getText().getFont().setSize(12); - chart.getLegend().setVisible(false); - } - - protected void buildTitle() { - chart.getTitle().getLabel().getCaption().setValue(title); - chart.getTitle().getLabel().getCaption().getFont().setSize(14); - chart.getTitle().getLabel().getCaption().getFont().setName(FONT_NAME); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildXAxis() - */ - protected void buildXAxis() { - //labels = adapter.getLabels(); - /*xAxis = ((ChartWithAxes) chart).getPrimaryBaseAxes()[0]; - xAxis.getTitle().setVisible(true); - xAxis.getTitle().getCaption().setValue(labels[0]); - xAxis.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL); - xAxis.setType(AxisType.TEXT_LITERAL); - xAxis.getOrigin().setType(IntersectionType.VALUE_LITERAL);*/ - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildYAxis() - */ - protected void buildYAxis() { - /* yAxis = ((ChartWithAxes) chart).getPrimaryOrthogonalAxis(xAxis); - - yAxis.getMajorGrid().getLineAttributes().setVisible(true); - // yAxis.getMajorGrid().getLineAttributes().setColor(ColorDefinitionImpl - // .GREY()); - yAxis.getMajorGrid().getLineAttributes() - .setStyle(LineStyle.DASHED_LITERAL); - yAxis.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL); - - yAxis.setType(AxisType.LINEAR_LITERAL); - yAxis.getOrigin().setType(IntersectionType.VALUE_LITERAL); - - //yAxis.getScale().setStep(1.0); - System.out.println("reached linechartbuilder" + "built yaxis");*/ - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildXSeries() - */ - protected void buildXSeries() { - - data = adapter.getData(); - - int starting = 0; - if (data.length > xSeriesTicks ) starting = data.length - xSeriesTicks; - x= new String[data.length - starting]; - - try { - for (int j=starting,k=0; j < data.length; j++,k++ ) - x[k] = data[j][0].toString(); - } catch (Exception e) - { - e.printStackTrace(); - } - TextDataSet categoryValues = TextDataSetImpl.create(x); - // NumberDataSet categoryValues = NumberDataSetImpl.create(new double[] { 0, 1, 2, 3 }); - - Series seCategory = SeriesImpl.create(); - - seCategory.setDataSet(categoryValues); - - // Apply the color palette - sdX = SeriesDefinitionImpl.create(); - - //sdX.getSeriesPalette().update(1); - - // xAxis.getSeriesDefinitions().add(sdX); - - sdX.getSeries().add(seCategory); - chart.getSeriesDefinitions( ).add( sdX ); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildYSeries() - */ - protected void buildYSeries() { - try{ - int starting = 0; - if (data.length > xSeriesTicks ) starting = data.length - xSeriesTicks; - // int yseriescount = adapter.getSeriesCount(); - NumberDataSet orthoValuesDataSet; - DialSeries ds1; - SeriesDefinition sdY; - - - //for (int i =1; i<=yseriescount;i++) - int i=0; - y= new Double[data.length - starting]; - for (int j=starting,k=0; j < data.length; j++,k++ ) - { - y[k] = NumberType.obj2num(data[j][i]).doubleValue(); - if ( max < y[k]) max = y[k]; - if ( min > y[k]) min = y[k]; - } - orthoValuesDataSet = NumberDataSetImpl.create(y); - ds1= (DialSeries) DialSeriesImpl.create(); - ds1.setDataSet(orthoValuesDataSet); - - ds1.getLabel().setVisible(true); - ds1.setLabelPosition(Position.INSIDE_LITERAL); - - - ds1.setSeriesIdentifier(labels[i]); - //ds1.getDial( ).setFill( GradientImpl.create( ColorDefinitionImpl.create( 225,255,225 ),ColorDefinitionImpl.create( 225, 225, 255 ),45,false ) ); - ds1.getDial( ).getMinorGrid( ).getTickAttributes( ).setVisible( true ); - ds1.getDial( ).getMinorGrid( ).getTickAttributes( ).setColor( ColorDefinitionImpl.BLACK( ) ); - ds1.getDial( ).getMinorGrid( ).setTickStyle( TickStyle.BELOW_LITERAL ); - ds1.getNeedle( ).setDecorator( LineDecorator.CIRCLE_LITERAL ); - sdY = SeriesDefinitionImpl.create(); - sdY.getSeries().add(ds1); - sdX.getSeriesDefinitions().add(sdY); - ds1.getLabel( ) - .setOutline( LineAttributesImpl.create( ColorDefinitionImpl.GREY( ) - .darker( ), - LineStyle.SOLID_LITERAL, - 1 ) ); - // ds1.getLabel( ).setBackground( ColorDefinitionImpl.GREY( ).brighter( ) ); - DialRegion dregion1 = DialRegionImpl.create( ); - dregion1.setFill( ColorDefinitionImpl.GREEN( ) ); - dregion1.setOutline( LineAttributesImpl.create( ColorDefinitionImpl.BLACK( ) - .darker( ), - LineStyle.SOLID_LITERAL, - 1 ) ); - dregion1.setStartValue( NumberDataElementImpl.create( 70 ) ); - dregion1.setEndValue( NumberDataElementImpl.create( 90 ) ); - dregion1.setInnerRadius( 40 ); - dregion1.setOuterRadius( -1 ); - ds1.getDial( ).getDialRegions( ).add( dregion1 ); - - DialRegion dregion2 = DialRegionImpl.create( ); - dregion2.setFill( ColorDefinitionImpl.YELLOW( ) ); - dregion2.setOutline( LineAttributesImpl.create( ColorDefinitionImpl.BLACK( ) - .darker( ), - LineStyle.SOLID_LITERAL, - 1 ) ); - dregion2.setStartValue( NumberDataElementImpl.create( 40 ) ); - dregion2.setEndValue( NumberDataElementImpl.create( 70 ) ); - dregion2.setOuterRadius( 70 ); - ds1.getDial( ).getDialRegions( ).add( dregion2 ); - - DialRegion dregion3 = DialRegionImpl.create( ); - dregion3.setFill( ColorDefinitionImpl.RED( ) ); - dregion3.setOutline( LineAttributesImpl.create( ColorDefinitionImpl.BLACK( ) - .darker( ), - LineStyle.SOLID_LITERAL, - 1 ) ); - dregion3.setStartValue( NumberDataElementImpl.create( 0 ) ); - dregion3.setEndValue( NumberDataElementImpl.create( 40 ) ); - dregion3.setInnerRadius( 40 ); - dregion3.setOuterRadius( 90 ); - ds1.getDial( ).getDialRegions( ).add( dregion3 ); - ds1.getLabel().getCaption().getFont().setSize(6); - - - }catch (Exception e) - { - e.printStackTrace(); - } - } - - - public void updateDataSet() { - // Associate with Data Set - try{ - data = adapter.getData(); - int starting = 0; - if (data.length > xSeriesTicks ) starting = data.length - xSeriesTicks; - - - x= new String[data.length - starting]; - for (int j=starting,k =0; j < data.length; j++,k++ ) - x[k] = data[j][0].toString(); - TextDataSet categoryValues = TextDataSetImpl.create(x); - - SeriesDefinition sd = (SeriesDefinition) chart.getSeriesDefinitions().get(0); - ((Series) sd.getSeries().get(0)).setDataSet(categoryValues); - - int i=1; - y= new Double[data.length - starting]; - for (int j=starting,k=0; j < data.length; j++,k++ ) - { - y[k] = NumberType.obj2num(data[j][i]).doubleValue(); - if ( max < y[k]) max = y[k]; - } - - NumberDataSet orthoValuesDataSet1 = NumberDataSetImpl.create(y); - SeriesDefinition sdY = (SeriesDefinition) sd.getSeriesDefinitions().get(0); - ((Series) sdY.getSeries().get(0)).setDataSet(orthoValuesDataSet1); - // ((PieSeries) sdY.getSeries().get(0)).setExplosion(max.intValue()); - - }catch(Exception e) - { - e.printStackTrace(); - } - } - - - -public void handleUpdateEvent() { - // TODO Auto-generated method stub - - try{ - updateDataSet(); - repaint(); - }catch(Exception e) - { - e.printStackTrace(); - } -} - -public synchronized void repaint() { - getDisplay().syncExec(new Runnable() { - boolean stop = false; - public void run() { - if(stop) return; - try { - redraw(); - } catch (Exception e) { - stop = true; - } - } - }); -} - -protected void createLegend() { - labels = adapter.getLabels(); - String[] labels2 = new String[labels.length-1]; -// Color[] colors = new Color[labels2.length]; - - for(int i=0; i<labels2.length; i++) { - labels2[i] = labels[i+1]; - // colors[i] = new Color(this.getDisplay(), IGraphColorConstants.COLORS[i]); - } - - //legend = new GraphLegend(this, labels2, colors); -} - -String x[]; -Double y[]; -boolean fullUpdate; -Object data[][]; -Composite parent = null; -String labels[]; -SeriesDefinition sdX; -protected static int xSeriesTicks; -protected static int ySeriesTicks; -protected static int maxItems; -protected static int viewableItems; -public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.meterchartbuilder"; -Double min = 0.0; -Double max = 0.0; - -} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/PieChartBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/PieChartBuilder.java index 1b56849aa0..dfeedb3e0a 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/PieChartBuilder.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/PieChartBuilder.java @@ -13,357 +13,51 @@ */ package org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts; -import org.eclipse.birt.chart.api.ChartEngine; -import org.eclipse.birt.chart.device.IDeviceRenderer; -import org.eclipse.birt.chart.exception.ChartException; -import org.eclipse.birt.chart.factory.GeneratedChartState; -import org.eclipse.birt.chart.factory.Generator; -import org.eclipse.birt.chart.model.ChartWithoutAxes; -import org.eclipse.birt.chart.model.attribute.Bounds; -import org.eclipse.birt.chart.model.attribute.LegendItemType; -import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl; -import org.eclipse.birt.chart.model.component.Series; -import org.eclipse.birt.chart.model.component.impl.SeriesImpl; -import org.eclipse.birt.chart.model.data.NumberDataSet; -import org.eclipse.birt.chart.model.data.SeriesDefinition; -import org.eclipse.birt.chart.model.data.TextDataSet; -import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl; -import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl; -import org.eclipse.birt.chart.model.data.impl.TextDataSetImpl; -import org.eclipse.birt.chart.model.impl.ChartWithoutAxesImpl; -import org.eclipse.birt.chart.model.type.PieSeries; -import org.eclipse.birt.chart.model.type.impl.PieSeriesImpl; -import org.eclipse.birt.core.framework.PlatformConfig; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.linuxtools.dataviewers.piechart.PieChart; import org.eclipse.swt.widgets.Composite; -import org.eclipse.linuxtools.internal.systemtap.ui.graphingapi.ui.GraphingAPIUIPlugin; import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.adapters.IAdapter; -import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.structures.NumberType; -import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.preferences.GraphingAPIPreferenceConstants; /** - * Builds bar chart. - * - * @author Qi Liang + * Builds Pie chart. */ -@SuppressWarnings("deprecation") public class PieChartBuilder extends AbstractChartWithoutAxisBuilder { - protected IDeviceRenderer render = null; - protected ChartWithoutAxes chart = null; - protected AbstractChartBuilder builder = null; - protected GeneratedChartState state = null; - // private boolean bFirstPaint = true; - - public PieChartBuilder(Composite parent, int style, String title,IAdapter adapter) { - super(adapter, parent, style); - this.title = title; - this.parent = parent; - - try { - PlatformConfig pf = new PlatformConfig(); - ChartEngine ce = ChartEngine.instance(pf); - render = ce.getRenderer("dv.SWT"); - } catch (Exception e) { -// e.printStackTrace(); - } - this.addPaintListener(new painter()); - } - - private class painter implements PaintListener { - /** - * The SWT paint callback - */ - public void paintControl(PaintEvent pe) - { - if (chart == null) return; - try{ - render.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, pe.gc); - Composite co = (Composite) pe.getSource(); - Rectangle re = co.getClientArea(); - Bounds bo = BoundsImpl.create(re.x, re.y, re.width, re.height); - bo.scale(72d / render.getDisplayServer().getDpiResolution()); - Generator gr = Generator.instance(); - state = gr.build(render.getDisplayServer(), - chart, - bo, - null, - null, - null); - gr.render(render, state); - } catch (ChartException e) { - // e.printStackTrace(); - } - } - } - + public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.piechartbuilder"; - - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildChart() - */ - protected void createChart() { - // data = adapter.getData(); - // while (data.length == 0 ) { data = adapter.getData();} - IPreferenceStore store = GraphingAPIUIPlugin.getDefault().getPreferenceStore(); - xSeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_X_SERIES_TICKS); - ySeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_Y_SERIES_TICKS); - maxItems = store.getInt(GraphingAPIPreferenceConstants.P_MAX_DATA_ITEMS); - viewableItems = store.getInt(GraphingAPIPreferenceConstants.P_VIEWABLE_DATA_ITEMS); - - chart = ChartWithoutAxesImpl.create(); - - //chart.setDimension(ChartDimension.TWO_DIMENSIONAL_LITERAL); - chart.setType("Pie Chart"); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildLegend() - */ - protected void buildLegend() { - createLegend(); - chart.getLegend().setItemType(LegendItemType.CATEGORIES_LITERAL); - chart.getLegend().getClientArea().getOutline( ).setVisible( true ); - chart.getLegend().getText().getFont().setSize(7); - chart.getLegend().setVisible(true); - } - - protected void buildTitle() { - chart.getTitle().getLabel().getCaption().setValue(title); - chart.getTitle().getLabel().getCaption().getFont().setSize(10); - chart.getTitle().getLabel().getCaption().getFont().setName(FONT_NAME); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildXAxis() - */ - protected void buildXAxis() { - //labels = adapter.getLabels(); - /*xAxis = ((ChartWithAxes) chart).getPrimaryBaseAxes()[0]; - xAxis.getTitle().setVisible(true); - xAxis.getTitle().getCaption().setValue(labels[0]); - xAxis.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL); - xAxis.setType(AxisType.TEXT_LITERAL); - xAxis.getOrigin().setType(IntersectionType.VALUE_LITERAL);*/ - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildYAxis() - */ - protected void buildYAxis() { - /* yAxis = ((ChartWithAxes) chart).getPrimaryOrthogonalAxis(xAxis); - - yAxis.getMajorGrid().getLineAttributes().setVisible(true); - // yAxis.getMajorGrid().getLineAttributes().setColor(ColorDefinitionImpl - // .GREY()); - yAxis.getMajorGrid().getLineAttributes() - .setStyle(LineStyle.DASHED_LITERAL); - yAxis.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL); - - yAxis.setType(AxisType.LINEAR_LITERAL); - yAxis.getOrigin().setType(IntersectionType.VALUE_LITERAL); - - //yAxis.getScale().setStep(1.0); - System.out.println("reached linechartbuilder" + "built yaxis");*/ - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildXSeries() - */ - protected void buildXSeries() { - - data = adapter.getData(); - - int starting = 0; - if (data.length > xSeriesTicks ) starting = data.length - xSeriesTicks; - x= new String[data.length - starting]; - - try { - for (int j=starting,k=0; j < data.length; j++,k++ ) - x[k] = data[j][0].toString(); - } catch (Exception e) - { - // e.printStackTrace(); - } - TextDataSet categoryValues = TextDataSetImpl.create(x); - // NumberDataSet categoryValues = NumberDataSetImpl.create(new double[] { 0, 1, 2, 3 }); - - Series seCategory = SeriesImpl.create(); - seCategory.getLabel().getCaption().getFont().setSize(6); - seCategory.getLabel().setVisible(false); - seCategory.setDataSet(categoryValues); - //seCategory.getLabel().getCaption().setValue("a"); - // Apply the color palette - sdX = SeriesDefinitionImpl.create(); - sdX.getSeriesPalette().update(1); - - - // xAxis.getSeriesDefinitions().add(sdX); - - sdX.getSeries().add(seCategory); - - chart.getSeriesDefinitions( ).add( sdX ); - //chart.get - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildYSeries() - */ - protected void buildYSeries() { - try{ - int starting = 0; - if (data.length > xSeriesTicks ) starting = data.length - xSeriesTicks; - // int yseriescount = adapter.getSeriesCount(); - NumberDataSet orthoValuesDataSet; - PieSeries ps1; - SeriesDefinition sdY; - - - //for (int i =1; i<=yseriescount;i++) - int i=0; - y= new Double[data.length - starting]; - for (int j=starting,k=0; j < data.length; j++,k++ ) - { - y[k] = NumberType.obj2num(data[j][i]).doubleValue(); - if ( max < y[k]) max = y[k]; - if ( min > y[k]) min = y[k]; - } - orthoValuesDataSet = NumberDataSetImpl.create(y); - ps1= (PieSeries) PieSeriesImpl.create(); - ps1.setDataSet(orthoValuesDataSet); - //bs1[i-1].getDisplayName(). - //bs1[i-1].getLabel().setVisible(true); - //bs1[i-1].setLabelPosition(Position.INSIDE_LITERAL); - ps1.setExplosion( 1 ); - //ps1.setExplosionExpression( "Max" );//$NON-NLS-1$ - //Min Slice - //chart.setMinSlice( 10 ); - //chart.setMinSlicePercent( false ); - //chart.setMinSliceLabel( "Others" );//$NON-NLS-1$ - - //ps1.setSeriesIdentifier(labels[i]). -// ps1.getSeriesIdentifier(). - ps1.getLabel().getCaption().getFont().setSize(6); - - sdY = SeriesDefinitionImpl.create(); - sdY.getSeries().add(ps1); - - sdX.getSeriesDefinitions().add(sdY); - - - - }catch (Exception e) - { - // e.printStackTrace(); - } - } - - - public void updateDataSet() { - // Associate with Data Set - try{ - data = adapter.getData(); - int starting = 0; - if (data.length > xSeriesTicks ) starting = data.length - xSeriesTicks; - - - x= new String[data.length - starting]; - for (int j=starting,k =0; j < data.length; j++,k++ ) - x[k] = data[j][0].toString(); - TextDataSet categoryValues = TextDataSetImpl.create(x); - - SeriesDefinition sd = (SeriesDefinition) chart.getSeriesDefinitions().get(0); - ((Series) sd.getSeries().get(0)).setDataSet(categoryValues); - - int i=1; - y= new Double[data.length - starting]; - for (int j=starting,k=0; j < data.length; j++,k++ ) - { - y[k] = NumberType.obj2num(data[j][i]).doubleValue(); - if ( max < y[k]) max = y[k]; - } - - NumberDataSet orthoValuesDataSet1 = NumberDataSetImpl.create(y); - SeriesDefinition sdY = (SeriesDefinition) sd.getSeriesDefinitions().get(0); - ((Series) sdY.getSeries().get(0)).setDataSet(orthoValuesDataSet1); - // ((PieSeries) sdY.getSeries().get(0)).setExplosion(max.intValue()); - - }catch(Exception e) - { - // e.printStackTrace(); - } - } - - - -public void handleUpdateEvent() { - // TODO Auto-generated method stub - - try{ - updateDataSet(); - repaint(); - }catch(Exception e) - { - // e.printStackTrace(); + public PieChartBuilder(Composite parent, int style, String title,IAdapter adapter) { + super(adapter, parent, style, title); } -} - -public synchronized void repaint() { - getDisplay().syncExec(new Runnable() { - boolean stop = false; - public void run() { - if(stop) return; - try { - redraw(); - } catch (Exception e) { - stop = true; - } - } - }); -} - -protected void createLegend() { - labels = adapter.getLabels(); - String[] labels2 = new String[labels.length-1]; -// Color[] colors = new Color[labels2.length]; - for(int i=0; i<labels2.length; i++) { - labels2[i] = labels[i+1]; - // colors[i] = new Color(this.getDisplay(), IGraphColorConstants.COLORS[i]); + protected void createChart() { + this.chart = new PieChart(this, getStyle()); } - - //legend = new GraphLegend(this, labels2, colors); -} -String x[]; -Double y[]; -boolean fullUpdate; -Object data[][]; -Composite parent = null; -String labels[]; -SeriesDefinition sdX; -protected static int xSeriesTicks; -protected static int ySeriesTicks; -protected static int maxItems; -protected static int viewableItems; -public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.piechartbuilder"; -Double min = 0.0; -Double max = 0.0; + protected void buildXSeries() { + Object data[][] = adapter.getData(); + if (data == null || data.length == 0 || data[0].length == 0) + return; + + int start = 0, len = Math.min(this.maxItems, data.length); + if (this.maxItems < data.length) { + start = data.length - this.maxItems; + } + + double[][] values = new double[len][data[0].length-1]; + String[] labels = new String[len]; + + for (int i = 0; i < labels.length; i++) { + if (data[i].length < 2) + return; + labels[i] = data[start + i][0].toString(); + for (int j = 1; j < data[start + i].length; j++) + values[i][j-1] = getDoubleValue(data[start + i][j]); + } + + ((PieChart)this.chart).addPieChartSeries(labels, values); + chart.redraw(); + } + public void updateDataSet() { + buildXSeries(); + } } diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/ScatterChartBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/ScatterChartBuilder.java index b7534bcdfb..eb7d20c86d 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/ScatterChartBuilder.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/charts/ScatterChartBuilder.java @@ -13,413 +13,31 @@ */ package org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts; -import org.eclipse.birt.chart.api.ChartEngine; -import org.eclipse.birt.chart.device.IDeviceRenderer; -import org.eclipse.birt.chart.exception.ChartException; -import org.eclipse.birt.chart.factory.GeneratedChartState; -import org.eclipse.birt.chart.factory.Generator; -import org.eclipse.birt.chart.model.ChartWithAxes; -import org.eclipse.birt.chart.model.attribute.AxisType; -import org.eclipse.birt.chart.model.attribute.Bounds; -import org.eclipse.birt.chart.model.attribute.ChartDimension; -import org.eclipse.birt.chart.model.attribute.IntersectionType; -import org.eclipse.birt.chart.model.attribute.LegendItemType; -import org.eclipse.birt.chart.model.attribute.LineStyle; -import org.eclipse.birt.chart.model.attribute.Marker; -import org.eclipse.birt.chart.model.attribute.MarkerType; -import org.eclipse.birt.chart.model.attribute.TickStyle; -import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl; -import org.eclipse.birt.chart.model.component.Axis; -import org.eclipse.birt.chart.model.component.Series; -import org.eclipse.birt.chart.model.component.impl.SeriesImpl; -import org.eclipse.birt.chart.model.data.NumberDataSet; -import org.eclipse.birt.chart.model.data.SeriesDefinition; -import org.eclipse.birt.chart.model.data.TextDataSet; - -import org.eclipse.birt.chart.model.data.impl.NumberDataElementImpl; -import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl; -import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl; -import org.eclipse.birt.chart.model.data.impl.TextDataSetImpl; - -import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl; - -import org.eclipse.birt.chart.model.type.ScatterSeries; -import org.eclipse.birt.chart.model.type.impl.ScatterSeriesImpl; -import org.eclipse.birt.core.framework.PlatformConfig; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; -import org.eclipse.linuxtools.internal.systemtap.ui.graphingapi.ui.GraphingAPIUIPlugin; import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.adapters.IAdapter; -import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.structures.NumberType; -import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.preferences.GraphingAPIPreferenceConstants; + +import org.swtchart.ILineSeries; +import org.swtchart.ISeries; +import org.swtchart.LineStyle; /** * Builds bar chart. * * @author Qi Liang */ -@SuppressWarnings("deprecation") -public class ScatterChartBuilder extends AbstractChartWithAxisBuilder { - - /** - * Constructor. - * - * @param dataSet - * data for chart - */ - - - protected IDeviceRenderer render = null; - protected ChartWithAxes chart = null; - protected AbstractChartBuilder builder = null; - protected GeneratedChartState state = null; - // private boolean bFirstPaint = true; - - public ScatterChartBuilder(Composite parent, int style, String title,IAdapter adapter) { - super(adapter, parent, style); - this.title = title; - this.parent = parent; - try { - // INITIALIZE THE SWT RENDERING DEVICE - //PluginSettings ps = PluginSettings.instance(); - PlatformConfig pf = new PlatformConfig(); - ChartEngine ce = ChartEngine.instance(pf); - render = ce.getRenderer("dv.SWT"); - } catch (Exception e) { -// e.printStackTrace(); - } - this.addPaintListener(new painter()); - } - - private class painter implements PaintListener { - /** - * The SWT paint callback - */ - public void paintControl(PaintEvent pe) - { - if (chart == null) return; - try{ - render.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, pe.gc); - Composite co = (Composite) pe.getSource(); - Rectangle re = co.getClientArea(); - Bounds bo = BoundsImpl.create(re.x, re.y, re.width, re.height); - bo.scale(72d / render.getDisplayServer().getDpiResolution()); - Generator gr = Generator.instance(); - state = gr.build(render.getDisplayServer(), - chart, - bo, - null, - null, - null); - gr.render(render, state); - } catch (ChartException e) { - // e.printStackTrace(); - } - } - } - - - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildChart() - */ - protected void createChart() { - data = adapter.getData(); - while (data.length == 0 ) { data = adapter.getData();} - IPreferenceStore store = GraphingAPIUIPlugin.getDefault().getPreferenceStore(); - xSeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_X_SERIES_TICKS); - ySeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_Y_SERIES_TICKS); - maxItems = store.getInt(GraphingAPIPreferenceConstants.P_MAX_DATA_ITEMS); - viewableItems = store.getInt(GraphingAPIPreferenceConstants.P_VIEWABLE_DATA_ITEMS); +public class ScatterChartBuilder extends LineChartBuilder { + public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.scatterchartbuilder"; - chart = ChartWithAxesImpl.create(); - - chart.setDimension(ChartDimension.TWO_DIMENSIONAL_LITERAL); - chart.setType("Scatter Chart"); - - // Plot - //chart.getBlock( ).setBackground(ColorDefinitionImpl.WHITE( ) ); - // Plot p = chart.getPlot( ); - /// p.getClientArea( ).setBackground(GradientImpl.create( ColorDefinitionImpl.create( 225,225,255 ),ColorDefinitionImpl.create( 255, 255, 225 ),-35,false ) ); - //p.getOutline( ).setVisible( true ); - // Title cwaBar.getTitle( ) .getLabel() .getCaption( ) .setValue( "Bar Chart with Multiple Y Series" );//$NON-NLS-1$ - // Legend - //Legend lg = cwaBar.getLegend( ); - //lg.getText( - //).getFont( ).setSize( 16 ); lg.getInsets( ).set( 10, 5, 0, 0 ); - // lg.setAnchor( Anchor.NORTH_LITERAL ); - - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildLegend() - */ - protected void buildLegend() { - createLegend(); - chart.getLegend().setItemType(LegendItemType.SERIES_LITERAL); - chart.getLegend().getClientArea().getOutline( ).setVisible( true ); - chart.getLegend().setVisible(true); - chart.getLegend().getText().getFont().setSize(7); - - } - - protected void buildTitle() { - chart.getTitle().getLabel().getCaption().setValue(title); - chart.getTitle().getLabel().getCaption().getFont().setSize(10); - chart.getTitle().getLabel().getCaption().getFont().setName(FONT_NAME); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildXAxis() - */ - protected void buildXAxis() { - //labels = adapter.getLabels(); - xAxis = ((ChartWithAxes) chart).getPrimaryBaseAxes()[0]; - xAxis.getTitle().setVisible(true); - xAxis.getTitle().getCaption().setValue(labels[0]); - xAxis.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL); - xAxis.setType(AxisType.TEXT_LITERAL); - xAxis.getOrigin().setType(IntersectionType.VALUE_LITERAL); - xAxis.getTitle().getCaption().getFont().setSize(8); - xAxis.getLabel().getCaption().getFont().setSize(6); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildYAxis() - */ - protected void buildYAxis() { - yAxis = ((ChartWithAxes) chart).getPrimaryOrthogonalAxis(xAxis); - - yAxis.getMajorGrid().getLineAttributes().setVisible(true); - // yAxis.getMajorGrid().getLineAttributes().setColor(ColorDefinitionImpl - // .GREY()); - yAxis.getMajorGrid().getLineAttributes() - .setStyle(LineStyle.DASHED_LITERAL); - yAxis.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL); - - yAxis.setType(AxisType.LINEAR_LITERAL); - yAxis.getOrigin().setType(IntersectionType.VALUE_LITERAL); - yAxis.getLabel().getCaption().getFont().setSize(6); - //yAxis.getScale().setStep(1.0); - yAxis.getTitle().getCaption().getFont().setSize(8); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.chart.AbstractChartBuilder#buildXSeries() - */ - protected void buildXSeries() { - - data = adapter.getData(); - - int starting = 0; - if (data.length > xSeriesTicks ) starting = data.length - xSeriesTicks; - x= new String[data.length - starting]; - - try { - for (int j=starting,k=0; j < data.length; j++,k++ ) - x[k] = data[j][0].toString(); - } catch (Exception e) - { -// e.printStackTrace(); - } - TextDataSet categoryValues = TextDataSetImpl.create(x); - // NumberDataSet categoryValues = NumberDataSetImpl.create(new double[] { 0, 1, 2, 3 }); - - Series seCategory = SeriesImpl.create(); - - seCategory.setDataSet(categoryValues); - - // Apply the color palette - SeriesDefinition sdX = SeriesDefinitionImpl.create(); - sdX.getSeriesPalette().update(1); - - xAxis.getSeriesDefinitions().add(sdX); - - sdX.getSeries().add(seCategory); - } - - /* - * (non-Javadoc) - * - * @see com.ibm.examples.chart.widget.AbstractChartBuilder#buildYSeries() - */ - protected void buildYSeries() { - try{ - - - int starting = 0; - if (data.length > xSeriesTicks ) starting = data.length - xSeriesTicks; - int yseriescount = adapter.getSeriesCount(); - NumberDataSet orthoValuesDataSet[] = new NumberDataSet[yseriescount]; - ScatterSeries ss1[] = new ScatterSeries[yseriescount]; - SeriesDefinition sdY[] = new SeriesDefinition[yseriescount]; - - - for (int i =1; i<=yseriescount;i++) - {y= new Double[data.length - starting]; - for (int j=starting,k=0; j < data.length; j++,k++ ) - { - y[k] = NumberType.obj2num(data[j][i]).doubleValue(); - if ( max < y[k]) max = y[k]; - if ( min > y[k]) min = y[k]; - } - orthoValuesDataSet[i-1]= NumberDataSetImpl.create(y); - ss1[i-1]= (ScatterSeries) ScatterSeriesImpl.create(); - ss1[i-1].setDataSet(orthoValuesDataSet[i-1]); - //bs1[i-1].getDisplayName(). - //bs1[i-1].getLabel().setVisible(true); - //bs1[i-1].setLabelPosition(Position.INSIDE_LITERAL); - - ss1[i-1].setSeriesIdentifier(labels[i]); - ss1[i-1].getMarker().setSize(2); - //ss1[i-1].getMarkers(). - for ( int m = 0; m < ss1[i-1].getMarkers( ).size( ); m++ ) - { - ( (Marker) ss1[i-1].getMarkers( ).get( m ) ).setType( MarkerType.get(i)); - ( (Marker) ss1[i-1].getMarkers( ).get( m ) ).setSize(2); - } - // ss1[i-1].getLineAttributes().setVisible(true); - sdY[i-1] = SeriesDefinitionImpl.create(); - sdY[i-1].getSeriesPalette().update(0-i-2); - - yAxis.getSeriesDefinitions().add(sdY[i-1]); - sdY[i-1].getSeries().add(ss1[i-1]); - } - System.out.println("not bin updatedataset:" + max); - yAxis.getScale().setStep(max/2); - yAxis.getScale().setMax(NumberDataElementImpl.create(max)); - - }catch (Exception e) - { - // e.printStackTrace(); - } + public ScatterChartBuilder(Composite parent, int style, String title,IAdapter adapter) { + super(parent, style, title, adapter); } - - public void updateDataSet() { - // Associate with Data Set - try{ - data = adapter.getData(); - int starting = 0; - if (data.length > xSeriesTicks ) starting = data.length - xSeriesTicks; - - - x= new String[data.length - starting]; - for (int j=starting,k =0; j < data.length; j++,k++ ) - x[k] = data[j][0].toString(); - // X-Axis - TextDataSet categoryValues = TextDataSetImpl.create(x); - - Axis xAxisPrimary = chart.getPrimaryBaseAxes()[0]; - SeriesDefinition sdX = (SeriesDefinition) xAxisPrimary - .getSeriesDefinitions().get(0); - ((Series) sdX.getSeries().get(0)).setDataSet(categoryValues); - - // Y-Axis - Axis yAxisPrimary = chart.getPrimaryOrthogonalAxis(xAxisPrimary); - // chart.getOrthogonalAxes(xAxisPrimary, arg1) - - - NumberDataSet orthoValuesDataSet1[] = new NumberDataSet[adapter.getSeriesCount()]; - for (int i=1; i<=adapter.getSeriesCount();i++) - { - y= new Double[data.length - starting]; - for (int j=starting,k=0; j < data.length; j++,k++ ) - { - y[k] = NumberType.obj2num(data[j][i]).doubleValue(); - if ( max < y[k]) max = y[k]; - } - - orthoValuesDataSet1[i-1]= NumberDataSetImpl.create(y); - SeriesDefinition sdY = (SeriesDefinition) yAxisPrimary - .getSeriesDefinitions().get(i-1); - ((Series) sdY.getSeries().get(0)).setDataSet(orthoValuesDataSet1[i-1]); - - } - yAxis.getScale().setStep(max/5); - yAxis.getScale().setMax(NumberDataElementImpl.create(max)); - }catch(Exception e) - { - // e.printStackTrace(); - } - } - - - -public void handleUpdateEvent() { - // TODO Auto-generated method stub - - try{ - updateDataSet(); - repaint(); - }catch(Exception e) - { - //e.printStackTrace(); - } -} - -public synchronized void repaint() { - getDisplay().syncExec(new Runnable() { - boolean stop = false; - public void run() { - if(stop) return; - try { - redraw(); - } catch (Exception e) { - stop = true; - } - } - }); -} - -public void setScale(double scale) { - IPreferenceStore store = GraphingAPIUIPlugin.getDefault().getPreferenceStore(); - xSeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_X_SERIES_TICKS); - xSeriesTicks = (int) (((Integer)xSeriesTicks).doubleValue() * scale); - handleUpdateEvent(); -} - - -protected void createLegend() { - labels = adapter.getLabels(); - String[] labels2 = new String[labels.length-1]; -// Color[] colors = new Color[labels2.length]; - - for(int i=0; i<labels2.length; i++) { - labels2[i] = labels[i+1]; - // colors[i] = new Color(this.getDisplay(), IGraphColorConstants.COLORS[i]); + protected ISeries createChartISeries(int i) { + ILineSeries series = (ILineSeries)super.createChartISeries(i); + series.setSymbolColor(COLORS[i % COLORS.length]); + series.setLineStyle(LineStyle.NONE); + return series; } - - //legend = new GraphLegend(this, labels2, colors); -} - -String x[]; -Double y[]; -boolean fullUpdate; -Object data[][]; -Composite parent = null; -String labels[]; -protected static int xSeriesTicks; -protected static int ySeriesTicks; -protected static int maxItems; -protected static int viewableItems; -public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.scatterchartbuilder"; -Double min = 0.0; -Double max = 0.0; - } diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/widgets/GraphComposite.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/widgets/GraphComposite.java index e06f2c4eeb..8dcb1f8ff0 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/widgets/GraphComposite.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/widgets/GraphComposite.java @@ -15,8 +15,8 @@ import java.util.ArrayList; import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataSet; import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.structures.GraphData; -import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.chart.widget.ChartCanvas; import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.AbstractChartBuilder; +import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.AbstractChartWithoutAxisBuilder; import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.wizards.graph.GraphFactory; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionEvent; @@ -30,8 +30,6 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Scale; - - /** * A Composite type to contain a Graph object. * @author Henry Hughes @@ -106,6 +104,10 @@ public class GraphComposite extends Composite { //builder.setForeground(this.getDisplay().getSystemColor(SWT.COLOR_CYAN)); //this.setBackground(getDisplay().getSystemColor(SWT.COLOR_BLUE)); zoomScale.addSelectionListener(scaleListener); + + //The scale zoom scrool doesn't make sense for charts without axis + if (builder instanceof AbstractChartWithoutAxisBuilder) + this.configure(false); } /** @@ -199,9 +201,6 @@ public class GraphComposite extends Composite { public void dispose() { scaleListener = null; - if(null != canvas) canvas.dispose(); - canvas = null; - if(null != zoomScale) zoomScale.dispose(); zoomScale = null; @@ -236,7 +235,6 @@ public class GraphComposite extends Composite { }; private boolean sidebarVisible = true; - private ChartCanvas canvas; private AbstractChartBuilder builder; private Scale zoomScale; public double scale; diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/wizards/graph/GraphFactory.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/wizards/graph/GraphFactory.java index 471dc4e7a3..e2b59ec03c 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/wizards/graph/GraphFactory.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/ui/wizards/graph/GraphFactory.java @@ -25,7 +25,6 @@ import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.AbstractChartBu import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.AreaChartBuilder; import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.BarChartBuilder; import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.LineChartBuilder; -import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.MeterChartBuilder; import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.PieChartBuilder; import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.charts.ScatterChartBuilder; import org.eclipse.linuxtools.systemtap.ui.graphingapi.ui.graphs.PieChart; @@ -41,7 +40,6 @@ public final class GraphFactory { Localization.getString("GraphFactory.BarGraph"), Localization.getString("GraphFactory.AreaGraph"), Localization.getString("GraphFactory.PieChart"), - // Localization.getString("GraphFactory.MeterChart") }; private static final String[] graphDescriptions = new String[] { @@ -50,7 +48,6 @@ public final class GraphFactory { Localization.getString("GraphFactory.BarDescription"), Localization.getString("GraphFactory.AreaDescription"), Localization.getString("GraphFactory.PieDescription"), - //Localization.getString("GraphFactory.MeterDescription") }; private static final Image[] graphImages = new Image[] { @@ -59,7 +56,6 @@ public final class GraphFactory { GraphingAPIUIPlugin.getImageDescriptor("icons/graphs/BarGraph.gif").createImage(), GraphingAPIUIPlugin.getImageDescriptor("icons/graphs/AreaChart.gif").createImage(), GraphingAPIUIPlugin.getImageDescriptor("icons/graphs/PieChart.gif").createImage(), - //GraphingAPIUIPlugin.getImageDescriptor("icons/graphs/MeterChart.gif").createImage() }; private static final String[] graphIDs = new String[] { @@ -68,7 +64,6 @@ public final class GraphFactory { BarChartBuilder.ID, AreaChartBuilder.ID, PieChartBuilder.ID, - //MeterChartBuilder.ID }; public static String[] getAvailableGraphs(IDataSet data) { @@ -79,12 +74,11 @@ public final class GraphFactory { ids.add(AreaChartBuilder.ID); ids.add(BarChartBuilder.ID); ids.add(PieChartBuilder.ID); - // ids.add(MeterChartBuilder.ID); } if(data instanceof IBlockDataSet) { if(!ids.contains(BarChartBuilder.ID)) ids.add(BarChartBuilder.ID); - ids.add(PieChartBuilder.ID); + ids.add(PieChartBuilder.ID); } String[] id = new String[0]; @@ -147,40 +141,27 @@ public final class GraphFactory { builder = new ScatterChartBuilder(comp, style, gd.title, new ScrollAdapter((IHistoricalDataSet)data, gd.xSeries, gd.ySeries, gd.key)); break; case 1: - // g = new LineGraph(comp, SWT.NONE, gd.title, new ScrollAdapter((IHistoricalDataSet)data, gd.xSeries, gd.ySeries, gd.key)); builder = new LineChartBuilder(comp, style, gd.title, new ScrollAdapter((IHistoricalDataSet)data, gd.xSeries, gd.ySeries, gd.key)); break; case 2: if(!(data instanceof IBlockDataSet) || (null != gd.key)) - //g = new BarGraph(comp, SWT.NONE, gd.title, new ScrollAdapter((IHistoricalDataSet)data, gd.xSeries, gd.ySeries, gd.key)); { builder = new BarChartBuilder(comp, style, gd.title, new ScrollAdapter((IHistoricalDataSet)data, gd.xSeries, gd.ySeries, gd.key)); } else - //g = new BarGraph(comp, SWT.NONE, gd.title, new BlockAdapter((IBlockDataSet)data, gd.xSeries, gd.ySeries)); { builder = new BarChartBuilder(comp, style, gd.title, new BlockAdapter((IBlockDataSet)data, gd.xSeries, gd.ySeries)); } break; case 3: - // g = new PieChart(comp, SWT.NONE, gd.title, new BlockAdapter((IBlockDataSet)data, gd.xSeries, gd.ySeries)); builder = new AreaChartBuilder(comp, style, gd.title, new ScrollAdapter((IHistoricalDataSet)data, gd.xSeries, gd.ySeries, gd.key)); break; case 4: - // g = new PieChart(comp, SWT.NONE, gd.title, new BlockAdapter((IBlockDataSet)data, gd.xSeries, gd.ySeries)); - //builder = new PieChartBuilder(comp, style, gd.title, new BlockAdapter((IBlockDataSet)data, gd.xSeries, gd.ySeries)); builder = new PieChartBuilder(comp, style, gd.title, new ScrollAdapter((IHistoricalDataSet)data, gd.xSeries, gd.ySeries, gd.key)); break; - case 5: - // g = new PieChart(comp, SWT.NONE, gd.title, new BlockAdapter((IBlockDataSet)data, gd.xSeries, gd.ySeries)); - //builder = new PieChartBuilder(comp, style, gd.title, new BlockAdapter((IBlockDataSet)data, gd.xSeries, gd.ySeries)); - builder = new MeterChartBuilder(comp, style, gd.title, new ScrollAdapter((IHistoricalDataSet)data, gd.xSeries, gd.ySeries, gd.key)); - - break; - } return builder; } |