From 6f994a0b0a49bbe8e8bc3eac5914442c649a6b59 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Tue, 9 Apr 2013 11:13:05 +0300 Subject: systemtap: Rename plugins. o.e.l.systemtap.ui.graphingapi.[ui,nonui] is weird at least. Proper naming is o.e.l.systemtap.graphingapi.core(ex nonui) and o.e.l.systemtap.graphingapi.ui (ex ui.graphingapi.ui). Change-Id: Id049b4ce32f0ee22a4a9eeb89a61477db01c72fd Reviewed-on: https://git.eclipse.org/r/11741 Tested-by: Hudson CI Reviewed-by: Alexander Kurtakov IP-Clean: Alexander Kurtakov Tested-by: Alexander Kurtakov --- .../graphingapi/ui/GraphingAPIUIPlugin.java | 60 ++++ .../systemtap/graphingapi/ui/Localization.java | 21 ++ .../graphingapi/ui/localization.properties | 148 +++++++++ .../ui/charts/AbstractChartBuilder.java | 197 ++++++++++++ .../ui/charts/AbstractChartWithAxisBuilder.java | 121 ++++++++ .../ui/charts/AbstractChartWithoutAxisBuilder.java | 25 ++ .../graphingapi/ui/charts/AreaChartBuilder.java | 40 +++ .../graphingapi/ui/charts/BarChartBuilder.java | 48 +++ .../graphingapi/ui/charts/LineChartBuilder.java | 52 ++++ .../graphingapi/ui/charts/PieChartBuilder.java | 64 ++++ .../graphingapi/ui/charts/ScatterChartBuilder.java | 41 +++ .../graphingapi/ui/datadisplay/DataGrid.java | 343 +++++++++++++++++++++ .../systemtap/graphingapi/ui/graphs/AChart.java | 136 ++++++++ .../systemtap/graphingapi/ui/graphs/AGraph.java | 242 +++++++++++++++ .../systemtap/graphingapi/ui/graphs/BarGraph.java | 141 +++++++++ .../graphingapi/ui/graphs/IBlockGraph.java | 16 + .../systemtap/graphingapi/ui/graphs/IGraph.java | 26 ++ .../graphingapi/ui/graphs/IScrollGraph.java | 16 + .../systemtap/graphingapi/ui/graphs/LineGraph.java | 122 ++++++++ .../systemtap/graphingapi/ui/graphs/PieChart.java | 110 +++++++ .../graphingapi/ui/graphs/ScatterGraph.java | 123 ++++++++ .../ui/preferences/DataTablePreferencePage.java | 55 ++++ .../ui/preferences/GraphPreferencePage.java | 73 +++++ .../GraphingAPIPreferenceConstants.java | 26 ++ .../ui/preferences/PreferenceInitializer.java | 34 ++ .../ui/widgets/ExceptionErrorDialog.java | 38 +++ .../graphingapi/ui/widgets/GraphAxis.java | 207 +++++++++++++ .../graphingapi/ui/widgets/GraphAxis2.java | 111 +++++++ .../graphingapi/ui/widgets/GraphCanvas.java | 216 +++++++++++++ .../graphingapi/ui/widgets/GraphComposite.java | 231 ++++++++++++++ .../graphingapi/ui/widgets/GraphLabel.java | 108 +++++++ .../graphingapi/ui/widgets/GraphLegend.java | 114 +++++++ .../graphingapi/ui/widgets/IGraphPrimitive.java | 54 ++++ .../ui/wizards/dataset/DataSetFactory.java | 156 ++++++++++ .../ui/wizards/dataset/DataSetWizard.java | 203 ++++++++++++ .../ui/wizards/dataset/ParsingWizardPage.java | 232 ++++++++++++++ .../wizards/dataset/SelectDataSetWizardPage.java | 109 +++++++ .../dataset/SelectRowParsingWizardPage.java | 133 ++++++++ .../dataset/SelectTableParsingWizardPage.java | 157 ++++++++++ .../ui/wizards/filter/AggregateFactory.java | 87 ++++++ .../ui/wizards/filter/AvailableFilterTypes.java | 123 ++++++++ .../ui/wizards/filter/FilterWizardPage.java | 63 ++++ .../ui/wizards/filter/MatchFilterWizardPage.java | 132 ++++++++ .../ui/wizards/filter/RangeFilterWizardPage.java | 182 +++++++++++ .../ui/wizards/filter/SelectFilterWizard.java | 95 ++++++ .../ui/wizards/filter/SelectFilterWizardPage.java | 123 ++++++++ .../ui/wizards/filter/SortFilterWizardPage.java | 112 +++++++ .../ui/wizards/filter/UniqueFilterWizardPage.java | 159 ++++++++++ .../graphingapi/ui/wizards/graph/GraphFactory.java | 176 +++++++++++ .../graphingapi/ui/wizards/graph/GraphModel.java | 91 ++++++ .../ui/wizards/graph/SelectGraphWizard.java | 77 +++++ .../ui/wizards/graph/SelectGraphWizardPage.java | 95 ++++++ .../ui/wizards/graph/SelectSeriesWizardPage.java | 338 ++++++++++++++++++++ 53 files changed, 6202 insertions(+) create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/GraphingAPIUIPlugin.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/Localization.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/localization.properties create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartBuilder.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartWithAxisBuilder.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartWithoutAxisBuilder.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AreaChartBuilder.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/BarChartBuilder.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/LineChartBuilder.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/PieChartBuilder.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/ScatterChartBuilder.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/datadisplay/DataGrid.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/graphs/AChart.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/graphs/AGraph.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/graphs/BarGraph.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/graphs/IBlockGraph.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/graphs/IGraph.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/graphs/IScrollGraph.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/graphs/LineGraph.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/graphs/PieChart.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/graphs/ScatterGraph.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/preferences/DataTablePreferencePage.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/preferences/GraphPreferencePage.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/preferences/GraphingAPIPreferenceConstants.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/preferences/PreferenceInitializer.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/widgets/ExceptionErrorDialog.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/widgets/GraphAxis.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/widgets/GraphAxis2.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/widgets/GraphCanvas.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/widgets/GraphComposite.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/widgets/GraphLabel.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/widgets/GraphLegend.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/widgets/IGraphPrimitive.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/dataset/DataSetFactory.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/dataset/DataSetWizard.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/dataset/ParsingWizardPage.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/dataset/SelectDataSetWizardPage.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/dataset/SelectRowParsingWizardPage.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/dataset/SelectTableParsingWizardPage.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/filter/AggregateFactory.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/filter/AvailableFilterTypes.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/filter/FilterWizardPage.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/filter/MatchFilterWizardPage.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/filter/RangeFilterWizardPage.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/filter/SelectFilterWizard.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/filter/SelectFilterWizardPage.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/filter/SortFilterWizardPage.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/filter/UniqueFilterWizardPage.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/graph/GraphFactory.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/graph/GraphModel.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/graph/SelectGraphWizard.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/graph/SelectGraphWizardPage.java create mode 100644 systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/wizards/graph/SelectSeriesWizardPage.java (limited to 'systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org') diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/GraphingAPIUIPlugin.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/GraphingAPIUIPlugin.java new file mode 100644 index 0000000000..3a76e00878 --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/GraphingAPIUIPlugin.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse + *******************************************************************************/ + +package org.eclipse.linuxtools.internal.systemtap.graphingapi.ui; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The main plugin class to be used in the desktop. + */ +public class GraphingAPIUIPlugin extends AbstractUIPlugin { + + public static final String PLUGIN_ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.ui"; //$NON-NLS-1$ + //The shared instance. + private static GraphingAPIUIPlugin plugin; + + /** + * The constructor. + */ + public GraphingAPIUIPlugin() { + plugin = this; + } + + /** + * This method is called when the plug-in is stopped + */ + @Override + public void stop(BundleContext context) throws Exception { + super.stop(context); + plugin = null; + } + + /** + * Returns the shared instance. + */ + public static GraphingAPIUIPlugin getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path. + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/Localization.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/Localization.java new file mode 100644 index 0000000000..f6f5e254de --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/Localization.java @@ -0,0 +1,21 @@ +package org.eclipse.linuxtools.internal.systemtap.graphingapi.ui; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +public class Localization { + private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.systemtap.graphingapi.ui.localization"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); + + private Localization() { + } + + public static String getString(String key) { + try { + return RESOURCE_BUNDLE.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } +} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/localization.properties b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/localization.properties new file mode 100644 index 0000000000..696bc0073c --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/internal/systemtap/graphingapi/ui/localization.properties @@ -0,0 +1,148 @@ +#DataDisplay +DataGrid.Row=Row +DataGrid.FormatAs=Format as... +DataGrid.AddFilter=Add filter... +DataGrid.RemoveFilter=Remove filter... +DataGrid.ManualyResize=Manually Resize + +#Graphs +AChart.Title=Title +AChart.Legend=Legend + +AGraph.xAxis=x-axis +AGraph.yAxis=y-axis +AGraph.GridLines=Grid Lines +AGraph.Normalize=Normalize +AGraph.SeriesAxis=series axis + +#Preferences +GraphingAPIPreferencePage.GraphDisplayPreferences=GraphingAPI Details + +GraphPreferencePage.GraphDisplayPreferences=Basic preferences for graph display. +GraphPreferencePage.ShowXGridLines=&Show X grid lines: +GraphPreferencePage.ShowYGridLines=&Show Y grid lines: +GraphPreferencePage.MaxDataItems=&Max data items: +GraphPreferencePage.ViewableDataItems=&Viewable data items: +GraphPreferencePage.XSeriesTicks=&X series ticks: +GraphPreferencePage.YSeriesTicks=&Y series ticks: + +DataTablePreferencePage.GraphDisplayPreferences=Basic preferences for graph display. +DataTablePreferencePage.JumpNewestEntry=&Jump to newest entry: +DataTablePreferencePage.AutoResizeColumns=&Auto resize columns: +DataTablePreferencePage.MaxDataItems=&Max data items: + +#Wigets +GraphAxis.Kilo=K +GraphAxis.Mega=M +GraphAxis.Giga=G +GraphAxis.Tera=T +GraphAxis.Peta=P +GraphAxis.Exa=E +GraphAxis.Zetta=Z +GraphAxis.Yotta=Y + +GraphLegend.Legend=Legend + +GraphComposite.ScaleValue=x + +#Wizards.DataSet +DataSetFactory.RowDataSet=Row Data Set +DataSetFactory.TableDataSet=Table Data Set +DataSetFactory.RowDataSetDescription=Script outputs simple rows of values.\n\n +DataSetFactory.DataSetExample=ie:\n +DataSetFactory.DataSetHeader=Col1\tCol2\tCol3\n +DataSetFactory.TableDataSetDescription=Script periodicaly outputs preformated tables of the values\n\n + +DataSetWizard.CreateDataSet=Create Data Set + +ParsingWizardPage.NumberOfColumns=Number of Columns: +ParsingWizardPage.RegularExpression=Regular Expression: +ParsingWizardPage.Title=Title: +ParsingWizardPage.Delimiter=Delimiter: + +SelectDataSetWizardPage.SelectDataSetType=Select Data Set Type + +SelectTableParsingWizardPage.SelectTableDataSetParsing=Select Table Data Set Parsing +SelectTableParsingWizardPage.TableDelimiter=Table Delimiter: + +SelectRowParsingWizardPage.SelectRowDataSetParsing=Select Row Data Set Parsing + +#Wizards.Filter +AvailableFilterTypes.MatchFilter=Match Filter +AvailableFilterTypes.RangeFilter=Range Filter +AvailableFilterTypes.SortFilter=Sort Filter +AvailableFilterTypes.UniqueFilter=Unique Filter +AvailableFilterTypes.MatchFilterDescription=This filter removes everything from the data set where the selected column's value does not match the chosen value. +AvailableFilterTypes.RangeFilterDescription=This filter will remove everying that is not included in the selected range of values. +AvailableFilterTypes.SortFilterDescription=This filter will sort the entire data set based on the selected column. No data will be removed. +AvailableFilterTypes.UniqueFilterDescription=This filter will remove all merge all entries in the data set that share a common value in the selected column. Data for the removed rows will be aggregated together based on the chosed aggregation method. + +AggregateFactory.AverageAggregate=Average Aggregate +AggregateFactory.CountAggregate=Count Aggregate +AggregateFactory.MaxAggregate=Max Aggregate +AggregateFactory.MinAggregate=Min Aggregate +AggregateFactory.SumAggregate=Sum Aggregate +AggregateFactory.AverageDescription=This aggregate will return the average of all of the items consolidated. +AggregateFactory.CountDescription=This aggregate will return the number of items consolidated. +AggregateFactory.MaxDescription=This aggregate will return the maximum value of all the items consolidated. +AggregateFactory.MinDescription=This aggregate will return the minimum value of all the items consolidated. +AggregateFactory.SumDescription=This aggregate will return the sum of all of the items consolidated. + +MatchFilterWizardPage.CreateMatchFilter=Create Match Filter +MatchFilterWizardPage.Column=Column: +MatchFilterWizardPage.CompareTo=String to compare to: +MatchFilterWizardPage.KeepMatching=Keep Matching +MatchFilterWizardPage.RemoveMatching=Remove Matching + +RangeFilterWizardPage.CreateRangeFilter=Create Range Filter +RangeFilterWizardPage.Column=Column: +RangeFilterWizardPage.LowerBound=Lower bound: +RangeFilterWizardPage.UpperBound=Upper bound: +RangeFilterWizardPage.InsideBounds=Inside Bounds +RangeFilterWizardPage.OutsideBounds=Outside Bounds +RangeFilterWizardPage.Inclusive=Inclusive + +SelectFilterWizard.CreateFilter=Create Filter + +SelectFilterWizardPage.SelectFilter=Select Filter + +SortFilterWizardPage.CreateSortFilter=Create Sort Filter +SortFilterWizardPage.Column=Column: +SortFilterWizardPage.Ascending=Ascending +SortFilterWizardPage.Descending=Descending + +UniqueFilterWizardPage.CreateUniqueFilter=Create Unique Filter +UniqueFilterWizardPage.Column=Column: +UniqueFilterWizardPage.Aggregate=Aggregate: + + +#Wizards.Graph +GraphFactory.BarGraph=Bar Graph +GraphFactory.PieChart=Pie Chart +GraphFactory.ScatterGraph=Scatter Graph +GraphFactory.AreaGraph=Area Graph +GraphFactory.LineGraph=Line Graph +GraphFactory.MeterChart=Meter Graph +GraphFactory.LineDescription=This is a simple line graph of a single set of data. Each (x,y) pair will be plotted a a single dot and connected with a solid line on the graph. +GraphFactory.BarDescription=This is a histagram of data. One series represents the categories and the other represents the value assigned to that category. +GraphFactory.AreaDescription=This is an Area Graph +GraphFactory.PieDescription=This is a pie chart +GraphFactory.ScatterDescription=This is a simple plot of one series of data vs another set. Each (x,y) pair will be plotted as a single dot on the graph. +GraphFactory.MeterDescription=This is a meter chart. + + +SelectGraphWizard.CreateGraph=Create Graph + +SelectGraphWizardPage.SelectGraph=Select Graph + +SelectSeriesWizardPage.Title=Title: +SelectSeriesWizardPage.XSeries=X Series: +SelectSeriesWizardPage.RowID=Row ID +SelectSeriesWizardPage.YSeries=Y Series +SelectSeriesWizardPage.SelectSeries=Select Series +SelectSeriesWizardPage.TitleNotSet=Title not set +SelectSeriesWizardPage.KeyFilter=Key filter: +SelectSeriesWizardPage.KeyNotSet=Key not set +SelectSeriesWizardPage.NA=NA +SelectSeriesWizardPage.UseHistoricalData=Use historical data? +SelectSeriesWizardPage.SeriesNotSelected=Series not selected, or share the same selection diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartBuilder.java new file mode 100644 index 0000000000..88a9565850 --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartBuilder.java @@ -0,0 +1,197 @@ +/**************************************************************** + * Copyright (c) 2006-2013 IBM Corp. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM - initial API and implementation + * + **************************************************************** + */ +package org.eclipse.linuxtools.systemtap.graphingapi.ui.charts; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.linuxtools.internal.systemtap.graphingapi.ui.GraphingAPIUIPlugin; +import org.eclipse.linuxtools.systemtap.graphingapi.core.adapters.IAdapter; +import org.eclipse.linuxtools.systemtap.graphingapi.ui.preferences.GraphingAPIPreferenceConstants; +import org.eclipse.linuxtools.systemtap.structures.listeners.IUpdateListener; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +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 Composite implements IUpdateListener{ + + /** + * Font name for all titles, labels, and values. + */ + protected final static String FONT_NAME = "MS Sans Serif"; //$NON-NLS-1$ + 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; + + public abstract void updateDataSet(); + + /** + * 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 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 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(); + } + + @Override + public void handleUpdateEvent() { + repaint(); + } + + protected void repaint() { + getDisplay().syncExec(new Runnable() { + @Override + public void run() { + updateDataSet(); + } + }); + } + +} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartWithAxisBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartWithAxisBuilder.java new file mode 100644 index 0000000000..734da829e6 --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartWithAxisBuilder.java @@ -0,0 +1,121 @@ +package org.eclipse.linuxtools.systemtap.graphingapi.ui.charts; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.linuxtools.internal.systemtap.graphingapi.ui.GraphingAPIUIPlugin; +import org.eclipse.linuxtools.systemtap.graphingapi.core.adapters.IAdapter; +import org.eclipse.linuxtools.systemtap.graphingapi.ui.preferences.GraphingAPIPreferenceConstants; +import org.eclipse.swt.widgets.Composite; +import org.swtchart.IAxis; +import org.swtchart.ISeries; +import org.swtchart.ITitle; +import org.swtchart.LineStyle; + +/** + * Builds the chart with axis. + * + * @author Qi Liang + */ +public abstract class AbstractChartWithAxisBuilder extends AbstractChartBuilder { + + /** + * Title of X axis. + */ + protected String xTitle = null; + protected boolean xLineGrid, yLineGrid; + + /** + * Create a chart series for that chart. + */ + protected abstract ISeries createChartISeries(int i); + + /** + * Constructor. + * + * @param dataSet + * data for chart + */ + + public AbstractChartWithAxisBuilder(IAdapter adapter, Composite parent, int style, String title) { + super(adapter, parent, style, title); + IPreferenceStore store = GraphingAPIUIPlugin.getDefault().getPreferenceStore(); + xLineGrid = store.getBoolean(GraphingAPIPreferenceConstants.P_SHOW_X_GRID_LINES); + yLineGrid = store.getBoolean(GraphingAPIPreferenceConstants.P_SHOW_Y_GRID_LINES); + } + + /** + * Builds X axis. + */ + @Override + protected void buildXAxis() { + String labels[] = adapter.getLabels(); + IAxis xAxis = this.chart.getAxisSet().getXAxis(0); + if (xLineGrid) + xAxis.getGrid().setStyle(LineStyle.SOLID); + else + 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(""); //$NON-NLS-1$ + } + + /** + * Builds Y axis. + */ + @Override + protected void buildYAxis() { + IAxis yAxis = this.chart.getAxisSet().getYAxis(0); + yAxis.getTitle().setText(""); //$NON-NLS-1$ + if (yLineGrid) + yAxis.getGrid().setStyle(LineStyle.SOLID); + else + yAxis.getGrid().setStyle(LineStyle.NONE); + yAxis.getTick().setForeground(BLACK); + } + + /** + * Builds X series. + */ + @Override + 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(); + } +} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartWithoutAxisBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartWithoutAxisBuilder.java new file mode 100644 index 0000000000..f953cba62b --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartWithoutAxisBuilder.java @@ -0,0 +1,25 @@ +package org.eclipse.linuxtools.systemtap.graphingapi.ui.charts; + +import org.eclipse.swt.widgets.Composite; + +import org.eclipse.linuxtools.systemtap.graphingapi.core.adapters.IAdapter; + + +/** + * Builds the chart with axis. + * + * @author Qi Liang + */ +public abstract class AbstractChartWithoutAxisBuilder extends AbstractChartBuilder { + + /** + * Constructor. + * + * @param dataSet + * data for chart + */ + + public AbstractChartWithoutAxisBuilder(IAdapter adapter, Composite parent, int style, String title) { + super(adapter, parent, style, title); + } +} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AreaChartBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AreaChartBuilder.java new file mode 100644 index 0000000000..ba909eb8e6 --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AreaChartBuilder.java @@ -0,0 +1,40 @@ +/**************************************************************** + * Copyright (c) 2006-2013 IBM Corp. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM - initial API and implementation + * + **************************************************************** + */ +package org.eclipse.linuxtools.systemtap.graphingapi.ui.charts; + +import org.eclipse.linuxtools.systemtap.graphingapi.core.adapters.IAdapter; +import org.eclipse.swt.widgets.Composite; +import org.swtchart.ILineSeries; +import org.swtchart.ISeries; + +/** + * Builds bar chart. + * + * @author Qi Liang + */ + +public class AreaChartBuilder extends LineChartBuilder { + + public static final String ID = "org.eclipse.linuxtools.systemtap.graphingapi.ui.charts.areachartbuilder"; //$NON-NLS-1$ + + public AreaChartBuilder(Composite parent, int style, String title,IAdapter adapter) { + super(parent, style, title, adapter); + } + + @Override + protected ISeries createChartISeries(int i) { + ILineSeries series = (ILineSeries) super.createChartISeries(i); + series.enableArea(true); + return series; + } +} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/BarChartBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/BarChartBuilder.java new file mode 100644 index 0000000000..c3d80e77ee --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/BarChartBuilder.java @@ -0,0 +1,48 @@ +/**************************************************************** + * Copyright (c) 2006-2013 IBM Corp. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM - initial API and implementation + * + **************************************************************** + */ +package org.eclipse.linuxtools.systemtap.graphingapi.ui.charts; + +import org.eclipse.swt.widgets.Composite; + +import org.eclipse.linuxtools.systemtap.graphingapi.core.adapters.IAdapter; + +import org.swtchart.IBarSeries; +import org.swtchart.ISeries; +import org.swtchart.ISeries.SeriesType; + +/** + * Builds bar chart. + * + * @author Qi Liang + */ + +public class BarChartBuilder extends AbstractChartWithAxisBuilder { + public static final String ID = "org.eclipse.linuxtools.systemtap.graphingapi.ui.charts.barchartbuilder"; //$NON-NLS-1$ + + public BarChartBuilder(Composite parent, int style, String title,IAdapter adapter) { + super(adapter, parent, style, title); + } + + @Override + 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; + } + + @Override + public void updateDataSet() { + buildXSeries(); + } +} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/LineChartBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/LineChartBuilder.java new file mode 100644 index 0000000000..4b88cfd4c7 --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/LineChartBuilder.java @@ -0,0 +1,52 @@ +/**************************************************************** + * Copyright (c) 2006-2013 IBM Corp. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM - initial API and implementation + * + **************************************************************** + */ +package org.eclipse.linuxtools.systemtap.graphingapi.ui.charts; + +import org.eclipse.swt.widgets.Composite; + +import org.eclipse.linuxtools.systemtap.graphingapi.core.adapters.IAdapter; + +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 { + + public static final String ID = "org.eclipse.linuxtools.systemtap.graphingapi.ui.charts.linechartbuilder"; //$NON-NLS-1$ + + public LineChartBuilder(Composite parent, int style, String title,IAdapter adapter) { + super(adapter, parent, style, title); + } + + @Override + public void updateDataSet() { + buildXSeries(); + } + + @Override + 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; + } +} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/PieChartBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/PieChartBuilder.java new file mode 100644 index 0000000000..c1e6223aac --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/PieChartBuilder.java @@ -0,0 +1,64 @@ +/**************************************************************** + * Copyright (c) 2006-2013 IBM Corp. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM - initial API and implementation + * + **************************************************************** + */ +package org.eclipse.linuxtools.systemtap.graphingapi.ui.charts; + +import org.eclipse.linuxtools.dataviewers.piechart.PieChart; +import org.eclipse.linuxtools.systemtap.graphingapi.core.adapters.IAdapter; +import org.eclipse.swt.widgets.Composite; + +/** + * Builds Pie chart. + */ +public class PieChartBuilder extends AbstractChartWithoutAxisBuilder { + public static final String ID = "org.eclipse.linuxtools.systemtap.graphingapi.ui.charts.piechartbuilder"; //$NON-NLS-1$ + + public PieChartBuilder(Composite parent, int style, String title,IAdapter adapter) { + super(adapter, parent, style, title); + } + + @Override + protected void createChart() { + this.chart = new PieChart(this, getStyle()); + } + + @Override + 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(); + } + + @Override + public void updateDataSet() { + buildXSeries(); + } +} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/ScatterChartBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/ScatterChartBuilder.java new file mode 100644 index 0000000000..24789f7d59 --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/ScatterChartBuilder.java @@ -0,0 +1,41 @@ +/**************************************************************** + * Copyright (c) 2006-2013 IBM Corp. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM - initial API and implementation + * + **************************************************************** + */ +package org.eclipse.linuxtools.systemtap.graphingapi.ui.charts; + +import org.eclipse.linuxtools.systemtap.graphingapi.core.adapters.IAdapter; +import org.eclipse.swt.widgets.Composite; +import org.swtchart.ILineSeries; +import org.swtchart.ISeries; +import org.swtchart.LineStyle; + +/** + * Builds bar chart. + * + * @author Qi Liang + */ + +public class ScatterChartBuilder extends LineChartBuilder { + public static final String ID = "org.eclipse.linuxtools.systemtap.graphingapi.ui.charts.scatterchartbuilder"; //$NON-NLS-1$ + + public ScatterChartBuilder(Composite parent, int style, String title,IAdapter adapter) { + super(parent, style, title, adapter); + } + + @Override + protected ISeries createChartISeries(int i) { + ILineSeries series = (ILineSeries)super.createChartISeries(i); + series.setSymbolColor(COLORS[i % COLORS.length]); + series.setLineStyle(LineStyle.NONE); + return series; + } +} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/datadisplay/DataGrid.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/datadisplay/DataGrid.java new file mode 100644 index 0000000000..2f0ddf4a46 --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/datadisplay/DataGrid.java @@ -0,0 +1,343 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse + *******************************************************************************/ + +package org.eclipse.linuxtools.systemtap.graphingapi.ui.datadisplay; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.linuxtools.internal.systemtap.graphingapi.ui.GraphingAPIUIPlugin; +import org.eclipse.linuxtools.internal.systemtap.graphingapi.ui.Localization; +import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.IDataSet; +import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.IFilteredDataSet; +import org.eclipse.linuxtools.systemtap.graphingapi.core.filters.IDataSetFilter; +import org.eclipse.linuxtools.systemtap.graphingapi.ui.preferences.GraphingAPIPreferenceConstants; +import org.eclipse.linuxtools.systemtap.graphingapi.ui.wizards.dataset.DataSetFactory; +import org.eclipse.linuxtools.systemtap.graphingapi.ui.wizards.filter.AvailableFilterTypes; +import org.eclipse.linuxtools.systemtap.graphingapi.ui.wizards.filter.SelectFilterWizard; +import org.eclipse.linuxtools.systemtap.structures.IFormattingStyles; +import org.eclipse.linuxtools.systemtap.structures.StringFormatter; +import org.eclipse.linuxtools.systemtap.structures.listeners.IUpdateListener; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MenuAdapter; +import org.eclipse.swt.events.MenuEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.MenuItem; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PlatformUI; + + + +public class DataGrid implements IUpdateListener { + public DataGrid(Composite composite, IDataSet set, int style) { + prefs = GraphingAPIUIPlugin.getDefault().getPreferenceStore(); + manualResize = !prefs.getBoolean(GraphingAPIPreferenceConstants.P_AUTO_RESIZE); + + dataSet = set; + filteredDataSet = (dataSet instanceof IFilteredDataSet) + ? (IFilteredDataSet)dataSet + : DataSetFactory.createFilteredDataSet(dataSet); + this.style = style; + clickLocation = new Point(-1, -1); + removedItems = 0; + createPartControl(composite); + } + + public void setLayoutData(Object data) { + table.setLayoutData(data); + } + + public IDataSet getDataSet() { return dataSet; } + public Control getControl() { return table; } + + public void createPartControl(Composite parent) { + table = new Table(parent, SWT.SINGLE | SWT.FULL_SELECTION); + table.setHeaderVisible(true); + table.setLinesVisible(true); + table.getVerticalBar().setVisible(true); + + String[] names = dataSet.getTitles(); + TableColumn column = new TableColumn(table, SWT.LEFT); + column.setText(Localization.getString("DataGrid.Row")); //$NON-NLS-1$ + column.pack(); + column.setMoveable(false); + column.setResizable(false); + + columnFormat = new IFormattingStyles[names.length]; + for(int i=0; i location && clickLocation.x < (location+=cols[i].getWidth())) + return i; + + return cols.length-1; + } + + public class MainMenuListener extends MenuAdapter { + @Override + public void menuShown(MenuEvent e) { + MenuItem item = ((Menu)e.widget).getItem(1); + item.setSelection(manualResize); + } + } + + public class MenuManualyResizedSelection extends SelectionAdapter { + @Override + public void widgetSelected(SelectionEvent e) { + manualResize = !manualResize; + } + } + + public class AddFilterSelection extends SelectionAdapter { + @Override + public void widgetSelected(SelectionEvent e) { + SelectFilterWizard wizard = new SelectFilterWizard(dataSet.getTitles()); + IWorkbench workbench = PlatformUI.getWorkbench(); + wizard.init(workbench, null); + WizardDialog dialog = new WizardDialog(workbench.getActiveWorkbenchWindow().getShell(), wizard); + dialog.create(); + dialog.open(); + + IDataSetFilter filter = wizard.getFilter(); + wizard.dispose(); + + if(null != filter) { + filteredDataSet.addFilter(filter); + table.removeAll(); + handleUpdateEvent(); + + MenuItem item = new MenuItem(filterMenu, SWT.CASCADE); + item.setText(AvailableFilterTypes.getFilterName(filter.getID())); + item.setData(filter); + item.addSelectionListener(new RemoveFilterSelection()); + } + } + } + + public class RemoveFilterSelection implements SelectionListener { + @Override + public void widgetSelected(SelectionEvent e) { + IDataSetFilter idsf = (IDataSetFilter)((MenuItem)e.widget).getData(); + e.widget.dispose(); + + if(filteredDataSet.removeFilter(idsf)) { + table.removeAll(); + handleUpdateEvent(); + } + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) {} + } + + public class FormatMenuListener extends MenuAdapter { + @Override + public void menuShown(MenuEvent e) { + MenuItem[] items = ((Menu)e.widget).getItems(); + boolean doubleValid = false, longValid = false; + String itemText; + + int selectedCol = Math.max(1, getSelectedColumn()); + + for(int i=0; i prefs.getInt(GraphingAPIPreferenceConstants.P_MAX_DATA_ITEMS)) { + int items = table.getItemCount()-prefs.getInt(GraphingAPIPreferenceConstants.P_MAX_DATA_ITEMS); + table.remove(0, items-1); + removedItems += items; + } + } + + //Resize the columns + TableColumn col = table.getColumn(0); + col.pack(); + if(!manualResize) { + TableColumn[] cols = table.getColumns(); + for(int i=1; i(); + + createLegend(); + createTitle(title); + + this.addPaintListener(paintListener); + + parent.addCheckOption(Localization.getString("AChart.Title"), titleListener); //$NON-NLS-1$ + parent.addCheckOption(Localization.getString("AChart.Legend"), legendListener); //$NON-NLS-1$ + } + + protected void createTitle(String title) { + this.title = new GraphLabel(this, title, this, 0.1f, SWT.BOLD); + } + + protected void createLegend() { + String[] labels = adapter.getLabels(); + String[] labels2 = new String[labels.length-1]; + Color[] colors = new Color[labels2.length]; + + for(int i=0; i[] elementList; + + public boolean showTitle, showLegend; + + private IAdapter adapter; +} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/graphs/AGraph.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/graphs/AGraph.java new file mode 100644 index 0000000000..191a7786b3 --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/graphs/AGraph.java @@ -0,0 +1,242 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse + *******************************************************************************/ + +package org.eclipse.linuxtools.systemtap.graphingapi.ui.graphs; + +import java.util.LinkedList; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; +import org.eclipse.linuxtools.internal.systemtap.graphingapi.ui.GraphingAPIUIPlugin; +import org.eclipse.linuxtools.internal.systemtap.graphingapi.ui.Localization; +import org.eclipse.linuxtools.systemtap.graphingapi.core.IGraphColorConstants; +import org.eclipse.linuxtools.systemtap.graphingapi.core.adapters.IAdapter; +import org.eclipse.linuxtools.systemtap.graphingapi.core.structures.DataPoint; +import org.eclipse.linuxtools.systemtap.graphingapi.ui.preferences.GraphingAPIPreferenceConstants; +import org.eclipse.linuxtools.systemtap.graphingapi.ui.widgets.GraphAxis; +import org.eclipse.linuxtools.systemtap.graphingapi.ui.widgets.GraphAxis2; +import org.eclipse.linuxtools.systemtap.graphingapi.ui.widgets.GraphComposite; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Button; + + + +public abstract class AGraph extends AChart { + public AGraph(GraphComposite parent, int style, String title, IAdapter adapt) { + super(parent, style, title, adapt); + adapter = adapt; + axes = new LinkedList(); + + 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); + + createAxis(Localization.getString("AGraph.xAxis"), xSeriesTicks, GraphAxis.HORIZONTAL); //$NON-NLS-1$ + createAxis(Localization.getString("AGraph.yAxis"), ySeriesTicks, GraphAxis.VERTICAL); //$NON-NLS-1$ + + GraphingAPIUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(propertyChangeListener); + + parent.addCheckOption(Localization.getString("AGraph.GridLines"), gridListener); //$NON-NLS-1$ + if(adapter.getSeriesCount() > 1) + parent.addCheckOption(Localization.getString("AGraph.Normalize"), normalizeListener); //$NON-NLS-1$ + } + + protected void createAxis(String title, int tickCount, int style) { + axes.add(new GraphAxis(this, title, tickCount, style)); + } + + protected void createAxis2(String title, int tickCount, int style) { + axes.add(new GraphAxis2(this, title, tickCount, style, this.axisColor)); + } + + //******************************************************Please remove + public Rectangle getArea(int items) { + int uBound = elementList[0].size(); + int lBound = (uBound > items) ? (uBound-items) : 0; + + int maxX = Integer.MIN_VALUE; + int minX = Integer.MAX_VALUE; + int maxY = Integer.MIN_VALUE; + int minY = Integer.MAX_VALUE; + + DataPoint p; + Object o; + + for(int j=0; j maxX) maxX = (int)p.x; + if(p.y < minY) minY = (int)p.y; + if(p.y > maxY) maxY = (int)p.y; + } + } + + return new Rectangle(minX, minY, maxX-minX, maxY-minY); + } + + private synchronized void rebound() { + getDisplay().syncExec(new Runnable() { + @Override + public void run() { + setGlobalArea(getArea(maxItems)); + setLocalArea(getArea(viewableItems)); + } + }); + } + + @Override + public synchronized void repaint() { + rebound(); + super.repaint(); + } + //*******************************************************End remove + + + /** + * Sets the category axis that is displayed to the axis belonging to the input series index. + * @param series Series to display the axis for. + */ + public void addSeriesAxis(int series) { + if(selectedSeries != (series+1)) { + removeSeriesAxis(); + seriesAxis = new GraphAxis2(this, Localization.getString("AGraph.SeriesAxis"), ySeriesTicks, //$NON-NLS-1$ + GraphAxis2.ALIGN_RIGHT | + GraphAxis2.HIDE_GRID_LINES | + GraphAxis2.UNNORMALIZED | + GraphAxis2.HIDE_TITLE, + new Color(this.getDisplay(), IGraphColorConstants.COLORS[series])); + selectedSeries = series+1; + axes.add(seriesAxis); + this.repaint(); + } + } + + /** + * Removes the series axis from the graph. + */ + public void removeSeriesAxis() { + if(null != seriesAxis) { + axes.remove(seriesAxis); + seriesAxis = null; + selectedSeries = -1; + this.repaint(); + } + } + + @Override + protected void paintAll(GC gc) { + for(GraphAxis axis: axes) { + axis.paint(gc); + } + super.paintAll(gc); + } + + @Override + public void dispose() { + GraphingAPIUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(propertyChangeListener); + + parent.removeCheckOption(Localization.getString("AGraph.Normalize")); //$NON-NLS-1$ + parent.removeCheckOption(Localization.getString("AGraph.GridLines")); //$NON-NLS-1$ + + normalizeListener = null; + gridListener = null; + + parent = null; + + super.dispose(); + } + + /* + * Listeners are below: + * gridListener - A SelectionListener for the Grid checkbox + * normalizeListener - A SelectionListener for the normalization checkbox + * propertyChangeListener - Detects changes in user preferences and applies them + */ + private final IPropertyChangeListener propertyChangeListener = new IPropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent event) { + IPreferenceStore store = GraphingAPIUIPlugin.getDefault().getPreferenceStore(); + if(event.getProperty().equals(GraphingAPIPreferenceConstants.P_MAX_DATA_ITEMS)) + maxItems = store.getInt(GraphingAPIPreferenceConstants.P_MAX_DATA_ITEMS); + else if(event.getProperty().equals(GraphingAPIPreferenceConstants.P_VIEWABLE_DATA_ITEMS)) + viewableItems = store.getInt(GraphingAPIPreferenceConstants.P_VIEWABLE_DATA_ITEMS); + else if(event.getProperty().equals(GraphingAPIPreferenceConstants.P_X_SERIES_TICKS)) { + xSeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_X_SERIES_TICKS); + for(GraphAxis a: axes) { + if(GraphAxis.HORIZONTAL == a.getType()) { + a.setTickCount(xSeriesTicks); + } + } + } else if(event.getProperty().equals(GraphingAPIPreferenceConstants.P_Y_SERIES_TICKS)) { + ySeriesTicks = store.getInt(GraphingAPIPreferenceConstants.P_Y_SERIES_TICKS); + for(GraphAxis a:axes) { + if(GraphAxis.VERTICAL == a.getType()) { + a.setTickCount(ySeriesTicks); + } + } + } else if(event.getProperty().equals(GraphingAPIPreferenceConstants.P_SHOW_X_GRID_LINES)) { + showXGrid = store.getBoolean(GraphingAPIPreferenceConstants.P_SHOW_X_GRID_LINES); + showGrid = showXGrid || showYGrid; + } else if(event.getProperty().equals(GraphingAPIPreferenceConstants.P_SHOW_X_GRID_LINES)) { + showYGrid = store.getBoolean(GraphingAPIPreferenceConstants.P_SHOW_X_GRID_LINES); + showGrid = showXGrid || showYGrid; + } + + repaint(); + } + }; + + private SelectionListener gridListener = new SelectionListener() { + @Override + public void widgetDefaultSelected(SelectionEvent e) {} + @Override + public void widgetSelected(SelectionEvent e) { + showGrid = ((Button)e.getSource()).getSelection(); + repaint(); + } + }; + + private SelectionListener normalizeListener = new SelectionListener() { + @Override + public void widgetDefaultSelected(SelectionEvent e) {} + @Override + public void widgetSelected(SelectionEvent e) { + normalize = ((Button)e.getSource()).getSelection(); + if(!normalize) removeSeriesAxis(); + handleUpdateEvent(); + } + }; + + protected LinkedList axes; + + private IAdapter adapter; + private boolean showYGrid, showXGrid; + + protected static int xSeriesTicks; + protected static int ySeriesTicks; + protected static int maxItems; + protected static int viewableItems; + protected int removedItems; + + public boolean showGrid, normalize; + + protected int selectedSeries; + protected GraphAxis seriesAxis; +} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/graphs/BarGraph.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/graphs/BarGraph.java new file mode 100644 index 0000000000..ec568cba72 --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/graphs/BarGraph.java @@ -0,0 +1,141 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse + *******************************************************************************/ + +package org.eclipse.linuxtools.systemtap.graphingapi.ui.graphs; + +import org.eclipse.linuxtools.systemtap.graphingapi.core.IGraphColorConstants; +import org.eclipse.linuxtools.systemtap.graphingapi.core.adapters.BlockAdapter; +import org.eclipse.linuxtools.systemtap.graphingapi.core.adapters.IAdapter; +import org.eclipse.linuxtools.systemtap.graphingapi.core.structures.DataPoint; +import org.eclipse.linuxtools.systemtap.graphingapi.core.structures.NumberType; +import org.eclipse.linuxtools.systemtap.graphingapi.ui.widgets.GraphComposite; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.GC; + + + +/** + * A Bar Graph implementation for the Graphing system. + * @author Henry Hughes + * @author Ryan Morse + */ +public class BarGraph extends AGraph implements IBlockGraph, IScrollGraph { + /** + * Default constructor for the bar graph. + * @param title Title of the graph. + * @param style Style code to use. + * @param adapt Dataset Adapter for the graph. + */ + public BarGraph(GraphComposite parent, int style, String title, IAdapter adapter) { + super(parent, style, title, adapter); + this.adapter = adapter; + fullUpdate = (adapter instanceof BlockAdapter) ? true : false; + handleUpdateEvent(); + } + + /** + * Paints all of the data elements to the screen + */ + @Override + public void paintElementList(GC gc) { + DataPoint[] points = new DataPoint[0]; + + Color temp = gc.getForeground(); + Color temp1 = gc.getBackground(); + + Color c; + Color c1; + + double xSize = super.getSize().x - (super.getXPadding()<<1); + xSize /= (super.getLocalWidth()+1); + xSize /= (elementList.length); + double ySize = super.getSize().y - (super.getYPadding()<<1); + ySize /= (super.getLocalHeight()); + + double px, py; + double pw=0, ph; + + for(int j=0; j>1, c.getGreen()>>1, c.getBlue()>>1); + gc.setForeground(c); + gc.setBackground(c1); + double width = WIDTH_PERCENT; + for(DataPoint point :points) { + px = super.getLocation().x + (((point.x * (elementList.length))-super.getLocalXMin()) * xSize) + super.getXPadding(); + px = px + ((j - elementList.length/2) * (xSize * width)); + pw = (xSize * width); + + py = super.getSize().y - super.getYPadding(); + ph = ((super.getLocalYMax() - point.y) * ySize) + super.getYPadding()-py; + gc.fillGradientRectangle((int)(px), (int)py, (int)pw, (int)ph, true); + } + } + + gc.setForeground(temp); + gc.setBackground(temp1); + } + + @Override + public boolean isMultiGraph() { + return adapter.getSeriesCount() > 0; + } + + /** + * Handles an update notification for new data in the Data Set. Causes the graph to add + * all new samples to the graph, and then repaint itself. + */ + @Override + public void handleUpdateEvent() { + if(null == adapter) return; + + this.getDisplay().syncExec(new Runnable() { + @Override + public void run() { + Object[][] data; + if(fullUpdate) { + for(int i=0; iScatterGraph + * and fires the Update Event when its done, causing the graph to draw itself. + */ + public LineGraph(GraphComposite parent, int style, String title, ScrollAdapter adapter) { + super(parent, style, title, adapter); + this.adapter = adapter; + handleUpdateEvent(); + } + + @Override + public void paintElementList(GC gc) { + DataPoint[] points = new DataPoint[0]; + + Color temp = gc.getForeground(); + Color c; + + double xSize = super.getSize().x - (super.getXPadding()<<1); + xSize /= (super.getLocalWidth()); + double ySize = super.getSize().y - (super.getYPadding()<<1); + ySize /= (super.getLocalHeight()); + + double px, py; + double px2, py2; + + for(int j=0; j 0; + } + + /** + * Updates the graph when the DataSet has more data, adding the new samples to the graph. + */ + @Override + public void handleUpdateEvent() { + if(null == adapter) return; + + this.getDisplay().syncExec(new Runnable() { + @Override + public void run() { + Object[][] data = adapter.getData(removedItems, adapter.getRecordCount()); + if(normalize) { + double max; + for(int j,i=0; i>1; + int py = (super.getSize().y - super.getYPadding() - pw)>>1; + + int angle1, angle0 = 0; + Number[] points = new Number[0]; + points = elementList[0].toArray(points); + for(int i=0; iGraph + * and fires the Update Event when its done, causing the graph to draw itself. + */ + public ScatterGraph(GraphComposite parent, int style, String title, ScrollAdapter adapter) { + super(parent, style, title, adapter); + this.adapter = adapter; + handleUpdateEvent(); + } + + @Override + public void paintElementList(GC gc) { + DataPoint[] points = new DataPoint[0]; + + Color temp = gc.getForeground(); + Color temp1 = gc.getBackground(); + Color c; + + double xSize = super.getSize().x - (super.getXPadding()<<1); + xSize /= (super.getLocalWidth()); + double ySize = super.getSize().y - (super.getYPadding()<<1); + ySize /= (super.getLocalHeight()); + + double px, py; + + for(int j=0; j>1); + + py = super.getLocalYMax() - point.y; + py *= ySize; + py += super.getYPadding() - (DIAMETER>>1); + + gc.fillOval((int)px, (int)py, DIAMETER, DIAMETER); + } + } + + gc.setForeground(temp); + gc.setBackground(temp1); + } + + @Override + public boolean isMultiGraph() { + return adapter.getSeriesCount() > 0; + } + + /** + * Updates the graph when the IDataSet has more data, adding the new samples to the graph. + */ + @Override + public void handleUpdateEvent() { + if(null == adapter) return; + + this.getDisplay().syncExec(new Runnable() { + @Override + public void run() { + Object[][] data = adapter.getData(removedItems, adapter.getRecordCount()); + + if(normalize) { + double max; + for(int j,i=0; i graph.getSize().y-graph.getYPadding()) + return true; + return false; + } + + @Override + public void calculateBounds() { + x1 = graph.getXPadding(); + y2 = graph.getSize().y-graph.getYPadding(); + locationX = graph.getXPadding(); + tickAmount = 0; + + if(type == HORIZONTAL) { + locationY = graph.getYPadding(); + y1 = graph.getSize().y-graph.getYPadding(); + x2 = graph.getSize().x-graph.getXPadding(); + x2a = (int)locationX; + y2a = graph.getSize().y-graph.getYPadding(); + + widthX = graph.getSize().x - (graph.getXPadding()<<1); + widthY = 0; + tickIncrament = ((graph.getLocalXMax()-graph.getLocalXMin())/(double)tickCount); + range = graph.getLocalXMax() - graph.getLocalXMin(); + localMin = graph.getLocalXMin(); + } else { + locationY = graph.getSize().y - graph.getYPadding(); + y1 = graph.getYPadding(); + x2 = graph.getXPadding(); + x2a = graph.getSize().x-graph.getXPadding(); + y2a = (int)locationY; + + widthX = 0; + widthY = graph.getSize().y - (graph.getYPadding()<<1); + tickIncrament = ((graph.getLocalYMax()-graph.getLocalYMin())/(double)tickCount); + range = graph.getLocalYMax() - graph.getLocalYMin(); + localMin = graph.getLocalYMin(); + } + } + + /** + * Calculates the width, in pixels, of the input string. + * @param gc GC to use for the calculation. + * @param s String to calculate. + * @return Width of the string in pixels. + */ + protected int stringWidth(GC gc, String s) { + int width = 0; + for(int i=0; i>1); + if(x < 0) + x = 0; + else if(x > graph.getSize().x-strWidth) + x = graph.getSize().x-strWidth; + + y -= (strHeight>>1); + if(y < 0) + y = 0; + else if(y > graph.getSize().y-strHeight) + y = graph.getSize().y-strHeight; + gc.drawText(val, x, y); + } + + protected void drawTitle(GC gc) { + //TODO: Implement this function. Has to rotate text for vertical bars + //http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/Rotateandflipanimage.htm + } + + /** + * Converts units on the input value using SI prefixes (1 million becomes 1M, etc) + */ + protected String getLabel(double val, int range) { + int metric = 0; + String pattern=".0"; //$NON-NLS-1$ + range /= tickCount; + while(val > 1000) { + val /= 1000; + metric++; + + range /= 10; + if(range < 1) + pattern += "0"; //$NON-NLS-1$ + } + + DecimalFormat format = new DecimalFormat(pattern); + return format.format(val) + PREFIXES[metric]; + } + + @Override + public void paint(GC gc) { + calculateBounds(); + + Color foreground = gc.getForeground(); + gc.setForeground(color); + + gc.drawLine(x1, y1, x2, y2); + drawTitle(gc); + for(int i=0; i<=tickCount; i++) { + drawGridLine(gc, (int)locationX, (int)locationY, (int)x2a, (int)y2a); + drawTick(gc, (int)locationX, (int)y2a, getLabel(localMin+tickAmount, range)); + + locationX += (widthX/(double)tickCount); + x2a += (widthX/(double)tickCount); + locationY -= (widthY/(double)tickCount); + y2a -= (widthY/(double)tickCount); + tickAmount += tickIncrament; + + } + gc.setForeground(foreground); + } + + public static final int VERTICAL = 0; + public static final int HORIZONTAL = 1; + //kilo, mega, giga, tera, peta, exa, zetta, yotta + protected static final String[] PREFIXES = { "", Localization.getString("GraphAxis.Kilo"), Localization.getString("GraphAxis.Mega"), Localization.getString("GraphAxis.Giga"), Localization.getString("GraphAxis.Tera"), Localization.getString("GraphAxis.Peta"), Localization.getString("GraphAxis.Exa"), Localization.getString("GraphAxis.Zetta"), Localization.getString("GraphAxis.Yotta") } ; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ + + protected int type; + protected int tickCount; + protected final AGraph graph; + protected Color color; + @SuppressWarnings("unused") + private String title; + + protected int x1, y1, x2, y2; + protected int widthX, widthY, range, localMin; + protected double locationX, locationY, x2a, y2a, tickAmount, tickIncrament; +} \ No newline at end of file diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/widgets/GraphAxis2.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/widgets/GraphAxis2.java new file mode 100644 index 0000000000..6f97183aa8 --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/widgets/GraphAxis2.java @@ -0,0 +1,111 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse + *******************************************************************************/ + +package org.eclipse.linuxtools.systemtap.graphingapi.ui.widgets; + +import org.eclipse.linuxtools.systemtap.graphingapi.ui.graphs.AGraph; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.GC; + + + +/** + * An extension to GraphAxis. + * @author Ryan Morse + */ +public class GraphAxis2 extends GraphAxis { + public GraphAxis2(AGraph graph, String title, int tickCount, int type, Color color) { + super(graph, title, tickCount, type&1); + this.type = type; + this.color = color; + } + + @Override + public void calculateBounds() { + x1 = graph.getXPadding(); + y1 = graph.getYPadding(); + x2 = graph.getSize().x-graph.getXPadding(); + y2 = graph.getSize().y-graph.getYPadding(); + locationX = graph.getXPadding(); + locationY = graph.getSize().y - graph.getYPadding(); + tickAmount = 0; + + switch(type&1) { + case VERTICAL: + widthX = 0; + widthY = graph.getSize().y - (graph.getYPadding()<<1); + tickIncrament = ((graph.getLocalYMax()-graph.getLocalYMin())/(double)tickCount); + range = graph.getLocalYMax() - graph.getLocalYMin(); + localMin = graph.getLocalYMin(); + break; + case HORIZONTAL: + widthX = graph.getSize().x - (graph.getXPadding()<<1); + widthY = 0; + tickIncrament = ((graph.getLocalXMax()-graph.getLocalXMin())/(double)tickCount); + range = graph.getLocalXMax() - graph.getLocalXMin(); + localMin = graph.getLocalXMin(); + break; + } + + switch(type&3) { + case ALIGN_BOTTOM: + locationY = graph.getYPadding(); + y1 = graph.getSize().y-graph.getYPadding(); + y2a = graph.getSize().y - graph.getYPadding(); + x2a = (int)locationX; + break; + case ALIGN_TOP: + y2 = graph.getYPadding(); + y2a = graph.getYPadding(); + x2a = (int)locationX; + break; + case ALIGN_LEFT: + x2 = graph.getXPadding(); + y2a = (int)locationY; + x2a = graph.getSize().x-graph.getXPadding(); + break; + case ALIGN_RIGHT: + locationX = graph.getSize().x-graph.getXPadding(); + x1 = graph.getSize().x-graph.getXPadding(); + y2a = (int)locationY; + x2a = graph.getXPadding(); + break; + } + } + + @Override + protected void drawGridLine(GC gc, int x1, int y1, int x2, int y2) { + if(HIDE_GRID_LINES != (HIDE_GRID_LINES&type)) + super.drawGridLine(gc, x1, y1, x2, y2); + } + + @Override + protected void drawTick(GC gc, int x, int y, String val) { + if(HIDE_TICKS != (HIDE_TICKS&type)) + super.drawTick(gc, x, y, val); + } + + @Override + protected void drawTitle(GC gc) { + if(HIDE_TITLE != (HIDE_TITLE&type)) + super.drawTitle(gc); + } + + public static final int ALIGN_LEFT = VERTICAL; //0 + public static final int ALIGN_TOP = HORIZONTAL; //1 + public static final int ALIGN_RIGHT = VERTICAL | 2; //2 + public static final int ALIGN_BOTTOM = HORIZONTAL | 2; //3 + + public static final int HIDE_GRID_LINES = 4; + public static final int HIDE_TITLE = 8; + public static final int HIDE_TICKS = 16; + public static final int UNNORMALIZED = 32; +} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/widgets/GraphCanvas.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/widgets/GraphCanvas.java new file mode 100644 index 0000000000..90300ffcd9 --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/widgets/GraphCanvas.java @@ -0,0 +1,216 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse + *******************************************************************************/ + +package org.eclipse.linuxtools.systemtap.graphingapi.ui.widgets; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.ScrollBar; + +/** + * The Graph Canvas class provides a Canvas type object that renders IGraphPrimitive objects on itself. + * It is an implementation of the IWidgetContainer interface and can be used by Graph Primitives to scale + * themselves. + * + * This class is the parent class of the entire Graph system, all of the decendents from Graph are + * based upon this class. + * @author Henry Hughes + * @author Ryan Morse + * @see org.eclipse.linuxtools.systemtap.graphingapi.ui.graphs.Graph + * + */ +public class GraphCanvas extends Canvas { + /** + * The default constructor for GraphCanvas. Creates a canvas of the appropriate size, then + * sets the internal area rectangles, the internal padding and scaling levels, enables scrolling, + * and sets the default axis color. + * @param parent Parent composite for this canvas. + * @param style SWT Style flags for this canvas (use SWT.NONE) + */ + public GraphCanvas(Composite parent, int style) { + super(parent, style | SWT.V_SCROLL | SWT.H_SCROLL); + + globalArea = new Rectangle(0, 0, 0, 0); + localArea = new Rectangle(0, 0, 0, 0); + + xpad = 10; + ypad = 10; + scale = 1.0; + autoScroll = true; + + axisColor = parent.getDisplay().getSystemColor(SWT.COLOR_GRAY); + + hBar = this.getHorizontalBar(); + vBar = this.getVerticalBar(); + hBar.addListener (SWT.Selection, new Listener () { + @Override + public void handleEvent (Event e) { + if(hBar.getSelection()+hBar.getThumb() == hBar.getMaximum()) + autoScroll = true; + else + autoScroll = false; + + setLocalArea(new Rectangle(hBar.getSelection(), localArea.y, localArea.width, localArea.height), true); + redraw(); + } + }); + + vBar.addListener (SWT.Selection, new Listener () { + @Override + public void handleEvent (Event e) { + autoScroll = false; + + setLocalArea(new Rectangle(localArea.x, vBar.getMaximum()-(vBar.getSelection()+vBar.getThumb())+vBar.getMinimum(), localArea.width, localArea.height), true); + redraw(); + } + }); + + } + /** + * An accessor to set the X padding width. Padding is defined as pixels inside the bounds + * of the drawable area that are left blank when rendering the graph. Valid values are integers + * greater than 0. The canvas will silently ignore requests to set the padding width to <=0. + * @param xpad New X padding value. + */ + public void setXPadding(int xpad) { this.xpad = xpad > 0 ? xpad : this.xpad; } + /** + * An accessor to set the Y padding width. Padding is defined as pixels inside the bounds + * of the drawable area that are left blank when rendering the graph. Valid values are integers + * greater than 0. The canvas will silently ignore requests to set the padding width to <=0. + * @param xpad New Y padding value. + */ + public void setYPadding(int ypad) { this.ypad = ypad > 0 ? ypad : this.ypad; } + /** + * Returns the current X padding value. + * @return The X padding width value, in pixels. + */ + public int getXPadding() { return xpad; } + /** + * Returns the current Y padding value. + * @return The Y padding width value, in pixels. + */ + public int getYPadding() { return ypad; } + + /** + * The repaint method is called when the graph is out of date and needs to be redrawn. This is an + * abstraction method around Canvas.redraw that synchronously executes the request + * on the display thread, blocking the calling thread until the repaint is completed. + */ + public synchronized void repaint() { + getDisplay().syncExec(new Runnable() { + @Override + public void run() { + redraw(); + } + }); + } + + /** + * Returns the size of the graphing area of the canvas. + */ + @Override + public Point getSize() { + Point p = new Point(super.getSize().x, super.getSize().y); + p.x -= vBar.getSize().x+5; + p.y -= hBar.getSize().y+5; + return p; + } + + /** + * Resets the canvas size to the specified area. + */ + public void setGlobalArea(Rectangle area) { + globalArea = area; + + hBar.setMinimum(getGlobalXMin()); + hBar.setMaximum (getGlobalXMax()); + vBar.setMinimum(getGlobalYMin()); + vBar.setMaximum (getGlobalYMax()); + } + + /** + * Sets the size of the graphing area to the specified area. + */ + public void setLocalArea(Rectangle area) { + setLocalArea(area, false); + } + + public void setLocalArea(Rectangle area, boolean force) { + if(autoScroll || force) { + localArea = area; + + hBar.setThumb (getLocalWidth()); + vBar.setThumb (getLocalHeight()); + + hBar.setIncrement(getLocalWidth()>>3); + hBar.setPageIncrement(getLocalWidth()); + vBar.setIncrement(getLocalHeight()>>3); + vBar.setPageIncrement(getLocalHeight()); + } + if(autoScroll) { + hBar.setSelection(hBar.getMaximum()); + vBar.setSelection(getGlobalYMax() - Math.min(getLocalYMax(), getGlobalYMax()) + getGlobalYMin()); + } + } + + public int getGlobalXMin() { + return globalArea.x; + } + + public int getLocalXMin() { + return localArea.x; + } + + public int getGlobalXMax() { + return globalArea.x+globalArea.width; + } + + public int getLocalXMax() { + return getLocalXMin() + getLocalWidth(); + } + + public int getGlobalYMin() { + return globalArea.y; + } + + public int getLocalYMin() { + return localArea.y; + } + + public int getGlobalYMax() { + return globalArea.y+globalArea.height; + } + + public int getLocalYMax() { + return getLocalYMin() + getLocalHeight(); + } + + public int getLocalWidth() { + return (int)(localArea.width / scale); + } + + public int getLocalHeight() { + return (int)(localArea.height / scale); + } + + protected Color axisColor; + private int xpad, ypad; + private ScrollBar hBar, vBar; + private Rectangle globalArea, localArea; + private boolean autoScroll; + private double scale; +} diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/widgets/GraphComposite.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/widgets/GraphComposite.java new file mode 100644 index 0000000000..15ea21d0de --- /dev/null +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/widgets/GraphComposite.java @@ -0,0 +1,231 @@ +/******************************************************************************* + * Copyright (c) 2006 IBM Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - Jeff Briggs, Henry Hughes, Ryan Morse + *******************************************************************************/ + +package org.eclipse.linuxtools.systemtap.graphingapi.ui.widgets; + +import java.util.ArrayList; + +import org.eclipse.linuxtools.systemtap.graphingapi.core.datasets.IDataSet; +import org.eclipse.linuxtools.systemtap.graphingapi.core.structures.GraphData; +import org.eclipse.linuxtools.systemtap.graphingapi.ui.charts.AbstractChartBuilder; +import org.eclipse.linuxtools.systemtap.graphingapi.ui.charts.AbstractChartWithoutAxisBuilder; +import org.eclipse.linuxtools.systemtap.graphingapi.ui.wizards.graph.GraphFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +import org.eclipse.swt.widgets.Button; +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 + * @author Ryan Morse + */ +public class GraphComposite extends Composite { + /** + * The default constructor: creates an internal composite for the Graph to render on, asks GraphFactory + * to create the graph from the given GraphData and DataSet, then initializes all buttons and listeners. + */ + public GraphComposite(Composite parent, int style, GraphData gd, IDataSet ds) { + super(parent, style); + FormLayout layout = new FormLayout(); + layout.marginWidth = 5; + layout.marginHeight = 5; + this.setLayout(layout); + checkOptions = new ArrayList