Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools')
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/IGraphColorConstants.java245
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/adapters/BlockAdapter.java172
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/adapters/IAdapter.java38
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/adapters/ScrollAdapter.java177
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/AverageAggregate.java43
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/CountAggregate.java40
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/IDataAggregate.java17
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/MaxAggregate.java44
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/MinAggregate.java44
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/SumAggregate.java42
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IBlockDataSet.java16
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IDataEntry.java25
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IDataSet.java35
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IDataSetParser.java30
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IFilteredDataSet.java21
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IHistoricalDataSet.java22
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/row/FilteredRowDataSet.java157
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/row/RowDataSet.java183
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/row/RowEntry.java79
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/row/RowParser.java88
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/table/FilteredTableDataSet.java169
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/table/TableDataSet.java204
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/table/TableEntry.java112
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/table/TableParser.java104
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/IDataSetFilter.java23
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/MatchFilter.java76
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/RangeFilter.java114
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/SortFilter.java89
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/UniqueFilter.java110
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/internal/GraphingAPINonUIPlugin.java65
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/internal/Localization.java22
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/internal/localization.properties5
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/ChartStreamDaemon.java65
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/ChartStreamDaemon2.java55
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/DataPoint.java26
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/GraphData.java20
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/NumberType.java105
37 files changed, 2882 insertions, 0 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/IGraphColorConstants.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/IGraphColorConstants.java
new file mode 100644
index 0000000000..61d8424e8b
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/IGraphColorConstants.java
@@ -0,0 +1,245 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui;
+
+import org.eclipse.swt.graphics.RGB;
+
+public interface IGraphColorConstants {
+ static final RGB[] COLORS = new RGB[] {
+ new RGB(0, 0, 255),
+ new RGB(255, 0, 0),
+ new RGB(0, 255, 0),
+ new RGB(255, 0, 255),
+ new RGB(0, 255, 255),
+ new RGB(255, 255, 0),
+ new RGB(127, 127, 255),
+ new RGB(255, 127, 127),
+ new RGB(127, 255, 127),
+
+ new RGB(255, 255, 255),
+ new RGB(255, 255, 204),
+ new RGB(255, 255, 153),
+ new RGB(255, 255, 102),
+ new RGB(255, 255, 51),
+ new RGB(255, 255, 0),
+ new RGB(255, 204, 255),
+ new RGB(255, 204, 204),
+ new RGB(255, 204, 153),
+ new RGB(255, 204, 102),
+ new RGB(255, 204, 51),
+ new RGB(255, 204, 0),
+ new RGB(255, 153, 255),
+ new RGB(255, 153, 204),
+ new RGB(255, 153, 153),
+ new RGB(255, 153, 102),
+ new RGB(255, 153, 51),
+ new RGB(255, 153, 0),
+ new RGB(255, 102, 255),
+ new RGB(255, 102, 204),
+ new RGB(255, 102, 153),
+ new RGB(255, 102, 102),
+ new RGB(255, 102, 51),
+ new RGB(255, 102, 0),
+ new RGB(255, 51, 255),
+ new RGB(255, 51, 204),
+ new RGB(255, 51, 153),
+ new RGB(255, 51, 102),
+ new RGB(255, 51, 51),
+ new RGB(255, 51, 0),
+ new RGB(255, 0, 255),
+ new RGB(255, 0, 204),
+ new RGB(255, 0, 153),
+ new RGB(255, 0, 102),
+ new RGB(255, 0, 51),
+ new RGB(255, 0, 0),
+ new RGB(204, 255, 255),
+ new RGB(204, 255, 204),
+ new RGB(204, 255, 153),
+ new RGB(204, 255, 102),
+ new RGB(204, 255, 51),
+ new RGB(204, 255, 0),
+ new RGB(204, 204, 255),
+ new RGB(204, 204, 204),
+ new RGB(204, 204, 153),
+ new RGB(204, 204, 102),
+ new RGB(204, 204, 51),
+ new RGB(204, 204, 0),
+ new RGB(204, 153, 255),
+ new RGB(204, 153, 204),
+ new RGB(204, 153, 153),
+ new RGB(204, 153, 102),
+ new RGB(204, 153, 51),
+ new RGB(204, 153, 0),
+ new RGB(204, 102, 255),
+ new RGB(204, 102, 204),
+ new RGB(204, 102, 153),
+ new RGB(204, 102, 102),
+ new RGB(204, 102, 51),
+ new RGB(204, 102, 0),
+ new RGB(204, 51, 255),
+ new RGB(204, 51, 204),
+ new RGB(204, 51, 153),
+ new RGB(204, 51, 102),
+ new RGB(204, 51, 51),
+ new RGB(204, 51, 0),
+ new RGB(204, 0, 255),
+ new RGB(204, 0, 204),
+ new RGB(204, 0, 153),
+ new RGB(204, 0, 102),
+ new RGB(204, 0, 51),
+ new RGB(204, 0, 0),
+ new RGB(153, 255, 255),
+ new RGB(153, 255, 204),
+ new RGB(153, 255, 153),
+ new RGB(153, 255, 102),
+ new RGB(153, 255, 51),
+ new RGB(153, 255, 0),
+ new RGB(153, 204, 255),
+ new RGB(153, 204, 204),
+ new RGB(153, 204, 153),
+ new RGB(153, 204, 102),
+ new RGB(153, 204, 51),
+ new RGB(153, 204, 0),
+ new RGB(153, 153, 255),
+ new RGB(153, 153, 204),
+ new RGB(153, 153, 153),
+ new RGB(153, 153, 102),
+ new RGB(153, 153, 51),
+ new RGB(153, 153, 0),
+ new RGB(153, 102, 255),
+ new RGB(153, 102, 204),
+ new RGB(153, 102, 153),
+ new RGB(153, 102, 102),
+ new RGB(153, 102, 51),
+ new RGB(153, 102, 0),
+ new RGB(153, 51, 255),
+ new RGB(153, 51, 204),
+ new RGB(153, 51, 153),
+ new RGB(153, 51, 102),
+ new RGB(153, 51, 51),
+ new RGB(153, 51, 0),
+ new RGB(153, 0, 255),
+ new RGB(153, 0, 204),
+ new RGB(153, 0, 153),
+ new RGB(153, 0, 102),
+ new RGB(153, 0, 51),
+ new RGB(153, 0, 0),
+ new RGB(102, 255, 255),
+ new RGB(102, 255, 204),
+ new RGB(102, 255, 153),
+ new RGB(102, 255, 102),
+ new RGB(102, 255, 51),
+ new RGB(102, 255, 0),
+ new RGB(102, 204, 255),
+ new RGB(102, 204, 204),
+ new RGB(102, 204, 153),
+ new RGB(102, 204, 102),
+ new RGB(102, 204, 51),
+ new RGB(102, 204, 0),
+ new RGB(102, 153, 255),
+ new RGB(102, 153, 204),
+ new RGB(102, 153, 153),
+ new RGB(102, 153, 102),
+ new RGB(102, 153, 51),
+ new RGB(102, 153, 0),
+ new RGB(102, 102, 255),
+ new RGB(102, 102, 204),
+ new RGB(102, 102, 153),
+ new RGB(102, 102, 102),
+ new RGB(102, 102, 51),
+ new RGB(102, 102, 0),
+ new RGB(102, 51, 255),
+ new RGB(102, 51, 204),
+ new RGB(102, 51, 153),
+ new RGB(102, 51, 102),
+ new RGB(102, 51, 51),
+ new RGB(102, 51, 0),
+ new RGB(102, 0, 255),
+ new RGB(102, 0, 204),
+ new RGB(102, 0, 153),
+ new RGB(102, 0, 102),
+ new RGB(102, 0, 51),
+ new RGB(102, 0, 0),
+ new RGB(51, 255, 255),
+ new RGB(51, 255, 204),
+ new RGB(51, 255, 153),
+ new RGB(51, 255, 102),
+ new RGB(51, 255, 51),
+ new RGB(51, 255, 0),
+ new RGB(51, 204, 255),
+ new RGB(51, 204, 204),
+ new RGB(51, 204, 153),
+ new RGB(51, 204, 102),
+ new RGB(51, 204, 51),
+ new RGB(51, 204, 0),
+ new RGB(51, 153, 255),
+ new RGB(51, 153, 204),
+ new RGB(51, 153, 153),
+ new RGB(51, 153, 102),
+ new RGB(51, 153, 51),
+ new RGB(51, 153, 0),
+ new RGB(51, 102, 255),
+ new RGB(51, 102, 204),
+ new RGB(51, 102, 153),
+ new RGB(51, 102, 102),
+ new RGB(51, 102, 51),
+ new RGB(51, 102, 0),
+ new RGB(51, 51, 255),
+ new RGB(51, 51, 204),
+ new RGB(51, 51, 153),
+ new RGB(51, 51, 102),
+ new RGB(51, 51, 51),
+ new RGB(51, 51, 0),
+ new RGB(51, 0, 255),
+ new RGB(51, 0, 204),
+ new RGB(51, 0, 153),
+ new RGB(51, 0, 102),
+ new RGB(51, 0, 51),
+ new RGB(51, 0, 0),
+ new RGB(0, 255, 255),
+ new RGB(0, 255, 204),
+ new RGB(0, 255, 153),
+ new RGB(0, 255, 102),
+ new RGB(0, 255, 51),
+ new RGB(0, 255, 0),
+ new RGB(0, 204, 255),
+ new RGB(0, 204, 204),
+ new RGB(0, 204, 153),
+ new RGB(0, 204, 102),
+ new RGB(0, 204, 51),
+ new RGB(0, 204, 0),
+ new RGB(0, 153, 255),
+ new RGB(0, 153, 204),
+ new RGB(0, 153, 153),
+ new RGB(0, 153, 102),
+ new RGB(0, 153, 51),
+ new RGB(0, 153, 0),
+ new RGB(0, 102, 255),
+ new RGB(0, 102, 204),
+ new RGB(0, 102, 153),
+ new RGB(0, 102, 102),
+ new RGB(0, 102, 51),
+ new RGB(0, 102, 0),
+ new RGB(0, 51, 255),
+ new RGB(0, 51, 204),
+ new RGB(0, 51, 153),
+ new RGB(0, 51, 102),
+ new RGB(0, 51, 51),
+ new RGB(0, 51, 0),
+ new RGB(0, 0, 255),
+ new RGB(0, 0, 204),
+ new RGB(0, 0, 153),
+ new RGB(0, 0, 102),
+ new RGB(0, 0, 51),
+ new RGB(0, 0, 0)
+ };
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/adapters/BlockAdapter.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/adapters/BlockAdapter.java
new file mode 100644
index 0000000000..137cc5b8e6
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/adapters/BlockAdapter.java
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.adapters;
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IBlockDataSet;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataSet;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.internal.Localization;
+
+public class BlockAdapter implements IAdapter {
+ public BlockAdapter(IBlockDataSet data, int xSeries, int[] ySeries) {
+ this.data = data;
+ this.xSeries = xSeries;
+ this.ySeries = ySeries;
+ }
+
+ public Number getXMax() {
+ return getXMax(0, getRecordCount());
+ }
+
+ public Number getXMax(int start, int end) {
+ return getSeriesMax(xSeries, start, end);
+ }
+
+ public Number getYMax() {
+ return getYMax(0, getRecordCount());
+ }
+
+ public Number getYMax(int start, int end) {
+ Number max = new Double(Double.MIN_VALUE);
+ Number a;
+ for(int i=0; i<ySeries.length; i++) {
+ a = getSeriesMax(ySeries[i], start, end);
+ max = (max.doubleValue()) > a.doubleValue() ? max : a;
+ }
+ return max;
+ }
+
+ public Number getYSeriesMax(int y) {
+ return getYSeriesMax(y, 0, getRecordCount());
+ }
+
+ public Number getYSeriesMax(int y, int start, int end) {
+ return getSeriesMax(ySeries[y], start, end);
+ }
+
+ public Number getSeriesMax(int series) {
+ return getSeriesMax(series, 0, getRecordCount());
+ }
+
+ public Number getSeriesMax(int series, int start, int end) {
+ if(start < 0 || end > data.getRowCount() || start > end)
+ return null;
+
+ Number max = new Double(Double.NEGATIVE_INFINITY);
+ Number cur;
+
+ Object[] dataColumn = data.getColumn(series, start, end);
+ for(int i=0; i<dataColumn.length; i++) {
+ try {
+ cur = new Double(Double.parseDouble(dataColumn[i].toString()));
+ if(max.doubleValue() < cur.doubleValue())
+ max = cur;
+ } catch (NumberFormatException e) {}
+ }
+ return max;
+ }
+
+ public Number getXMin() {
+ return getXMin(0, getRecordCount());
+ }
+
+ public Number getXMin(int start, int end) {
+ return getSeriesMin(xSeries, start, end);
+ }
+
+ public Number getYMin() {
+ return getYMin(0, getRecordCount());
+ }
+
+ public Number getYMin(int start, int end) {
+ Number min = new Double(Double.MIN_VALUE);
+ Number a;
+ for(int i=0; i<ySeries.length; i++) {
+ a = getSeriesMin(ySeries[i], start, end);
+ min = (min.doubleValue()) < a.doubleValue() ? min : a;
+ }
+ return min;
+ }
+
+ public Number getYSeriesMin(int y) {
+ return getYSeriesMin(y, 0, getRecordCount());
+ }
+
+ public Number getYSeriesMin(int y, int start, int end) {
+ return getSeriesMin(ySeries[y], start, end);
+ }
+
+ public Number getSeriesMin(int series) {
+ return getSeriesMin(series, 0, getRecordCount());
+ }
+
+ public Number getSeriesMin(int series, int start, int end) {
+ if(start < 0 || end > data.getRowCount() || start > end)
+ return null;
+
+ Number min = new Double(Double.POSITIVE_INFINITY);
+ Number cur;
+
+ Object[] dataColumn = data.getColumn(series, start, end);
+ for(int i=0; i<dataColumn.length; i++) {
+ try {
+ cur = new Double(Double.parseDouble(dataColumn[i].toString()));
+ if(min.doubleValue() > cur.doubleValue())
+ min = cur;
+ } catch (NumberFormatException e) {}
+ }
+ return min;
+ }
+
+ public String[] getLabels() {
+ String[] labels = data.getTitles();
+
+ String[] labels2 = new String[ySeries.length + 1];
+ labels2[0] = (IDataSet.COL_ROW_NUM == xSeries) ? Localization.getString("BlockAdapter.RowNum") : labels[xSeries];
+
+ for(int i=0; i<ySeries.length; i++)
+ labels2[i+1] = labels[ySeries[i]];
+
+ return labels2;
+ }
+
+ public int getSeriesCount() {
+ return ySeries.length;
+ }
+
+ public int getRecordCount() {
+ return data.getRowCount();
+ }
+
+ public Object[][] getData() {
+ return getData(0, getRecordCount());
+ }
+
+ //[Row][Column]
+ public Object[][] getData(int start, int end) {
+ Object[][] o = new Object[Math.min(end-start,getRecordCount())][ySeries.length+1];
+
+ Object[] row;
+ for(int j,i=0; i<o.length; i++) {
+ row = data.getRow(i+start);
+ o[i][0] = (IDataSet.COL_ROW_NUM == xSeries) ? new Integer(i) : row[xSeries];
+
+ for(j=0; j<ySeries.length; j++)
+ o[i][j+1] = row[ySeries[j]];
+ }
+
+ return o;
+ }
+
+ private IBlockDataSet data;
+ private int xSeries;
+ private int[] ySeries;
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/adapters/IAdapter.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/adapters/IAdapter.java
new file mode 100644
index 0000000000..107d08c05c
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/adapters/IAdapter.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.adapters;
+
+public interface IAdapter {
+ public Number getXMax();
+ public Number getXMax(int start, int end);
+ public Number getYMax();
+ public Number getYMax(int start, int end);
+ public Number getYSeriesMax(int series);
+ public Number getYSeriesMax(int series, int start, int end);
+ public Number getSeriesMax(int series);
+ public Number getSeriesMax(int series, int start, int end);
+
+ public Number getXMin();
+ public Number getXMin(int start, int end);
+ public Number getYMin();
+ public Number getYMin(int start, int end);
+ public Number getYSeriesMin(int series);
+ public Number getYSeriesMin(int series, int start, int end);
+ public Number getSeriesMin(int series);
+ public Number getSeriesMin(int series, int start, int end);
+
+ public String[] getLabels();
+ public int getRecordCount();
+ public int getSeriesCount();
+ public Object[][] getData();
+ public Object[][] getData(int start, int end);
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/adapters/ScrollAdapter.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/adapters/ScrollAdapter.java
new file mode 100644
index 0000000000..5ff4990386
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/adapters/ScrollAdapter.java
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.adapters;
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataSet;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IHistoricalDataSet;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.internal.Localization;
+
+public class ScrollAdapter implements IAdapter {
+ public ScrollAdapter(IHistoricalDataSet data, int xSeries, int[] ySeries, String key) {
+ this.data = data;
+ this.xSeries = xSeries;
+ this.ySeries = ySeries;
+ this.key = key;
+ }
+
+ public Number getXMax() {
+ return getXMax(0, getRecordCount());
+ }
+
+ public Number getXMax(int start, int end) {
+ return getSeriesMax(xSeries, start, end);
+ }
+
+ public Number getYMax() {
+ return getYMax(0, getRecordCount());
+ }
+
+ public Number getYMax(int start, int end) {
+ Number max = new Double(Double.MIN_VALUE);
+ Number a;
+ for(int i=0; i<ySeries.length; i++) {
+ a = getSeriesMax(ySeries[i], start, end);
+ max = (max.doubleValue()) > a.doubleValue() ? max : a;
+ }
+ return max;
+ }
+
+ public Number getYSeriesMax(int y) {
+ return getYSeriesMax(y, 0, getRecordCount());
+ }
+
+ public Number getYSeriesMax(int y, int start, int end) {
+ return getSeriesMax(ySeries[y], start, end);
+ }
+
+ public Number getSeriesMax(int series) {
+ return getSeriesMax(series, 0, getRecordCount());
+ }
+
+ public Number getSeriesMax(int series, int start, int end) {
+ if(start < 0 || end > data.getRowCount() || start > end)
+ return null;
+
+ Number max = new Double(Double.NEGATIVE_INFINITY);
+ Number cur;
+
+ Object[] dataColumn = data.getHistoricalData(key, series, start, end);
+ for(int i=0; i<dataColumn.length; i++) {
+ try {
+ cur = new Double(Double.parseDouble(dataColumn[i].toString()));
+ if(max.doubleValue() < cur.doubleValue())
+ max = cur;
+ } catch (NumberFormatException e) {}
+ }
+ return max;
+ }
+
+ public Number getXMin() {
+ return getXMin(0, getRecordCount());
+ }
+
+ public Number getXMin(int start, int end) {
+ return getSeriesMin(xSeries, start, end);
+ }
+
+ public Number getYMin() {
+ return getYMin(0, getRecordCount());
+ }
+
+ public Number getYMin(int start, int end) {
+ Number min = new Double(Double.MIN_VALUE);
+ Number a;
+ for(int i=0; i<ySeries.length; i++) {
+ a = getSeriesMin(ySeries[i], start, end);
+ min = (min.doubleValue()) < a.doubleValue() ? min : a;
+ }
+ return min;
+ }
+
+ public Number getYSeriesMin(int y) {
+ return getYSeriesMin(y, 0, getRecordCount());
+ }
+
+ public Number getYSeriesMin(int y, int start, int end) {
+ return getSeriesMin(ySeries[y], start, end);
+ }
+
+ public Number getSeriesMin(int series) {
+ return getSeriesMin(series, 0, getRecordCount());
+ }
+
+ public Number getSeriesMin(int series, int start, int end) {
+ if(start < 0 || end > data.getRowCount() || start > end)
+ return null;
+
+ Number min = new Double(Double.POSITIVE_INFINITY);
+ Number cur;
+
+ Object[] dataColumn = data.getHistoricalData(key, series, start, end);
+ for(int i=0; i<dataColumn.length; i++) {
+ try {
+ cur = new Double(Double.parseDouble(dataColumn[i].toString()));
+ if(min.doubleValue() > cur.doubleValue())
+ min = cur;
+ } catch (NumberFormatException e) {}
+ }
+ return min;
+ }
+
+ public String[] getLabels() {
+ String[] labels = data.getTitles();
+
+ String[] labels2 = new String[ySeries.length + 1];
+ labels2[0] = (IDataSet.COL_ROW_NUM == xSeries) ? Localization.getString("ScrollAdapter.RowNum") : labels[xSeries];
+
+ for(int i=0; i<ySeries.length; i++)
+ labels2[i+1] = labels[ySeries[i]];
+
+ return labels2;
+ }
+
+ public int getSeriesCount() {
+ return ySeries.length;
+ }
+
+ public int getRecordCount() {
+ return data.getEntryCount();
+ }
+
+ public Object[][] getData() {
+ return getData(0, getRecordCount());
+ }
+
+ //[Row][Column]
+ public Object[][] getData(int start, int end) {
+ Object[][] o = new Object[Math.min(end-start,getRecordCount())][ySeries.length+1];
+
+ Object[] x = data.getHistoricalData(key, xSeries, start, end);
+ Object[][] y = new Object[ySeries.length][data.getEntryCount()];
+
+ for(int i=0; i<ySeries.length; i++)
+ y[i] = data.getHistoricalData(key, ySeries[i], start, end);
+
+ for(int j,i=0; i<o.length; i++) {
+ o[i][0] = x[i];
+ for(j=0; j<ySeries.length; j++)
+ o[i][j+1] = y[j][i];
+ }
+
+ return o;
+ }
+
+ private IHistoricalDataSet data;
+ private int xSeries;
+ private int[] ySeries;
+ private String key;
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/AverageAggregate.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/AverageAggregate.java
new file mode 100644
index 0000000000..b8e9131038
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/AverageAggregate.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.aggregates;
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.structures.NumberType;
+
+public class AverageAggregate implements IDataAggregate {
+
+ /**
+ * Ensure column isn't empty, then get the average of all the column's values.
+ *
+ * @param column The column to average.
+ *
+ * @return Average of all the column's values.
+ */
+ public Number aggregate(Number[] column) {
+ if(column == null || column.length == 0)
+ return null;
+
+ double num = 0;
+
+ for(int i=0; i<column.length; i++)
+ num += column[i].doubleValue();
+
+ num /= column.length;
+ return NumberType.getNumber(column[0], num);
+ }
+
+ public String getID() {
+ return ID;
+ }
+
+ public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.aggregates.AverageAggregate";
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/CountAggregate.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/CountAggregate.java
new file mode 100644
index 0000000000..cd0750dd87
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/CountAggregate.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.aggregates;
+
+public class CountAggregate implements IDataAggregate {
+
+ /**
+ * Ensure column isn't empty, then get the count of the column's values.
+ *
+ * @param column The column to count.
+ *
+ * @return Count of that column's values.
+ */
+ public Number aggregate(Number[] column) {
+ if(column == null || column.length == 0)
+ return null;
+
+ int num = 0;
+
+ for(int i=0; i<column.length; i++)
+ num++;
+
+ return new Integer(num);
+ }
+
+ public String getID() {
+ return ID;
+ }
+
+ public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.aggregates.CountAggregate";
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/IDataAggregate.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/IDataAggregate.java
new file mode 100644
index 0000000000..1558e24f1b
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/IDataAggregate.java
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.aggregates;
+
+public interface IDataAggregate {
+ public Number aggregate(Number[] column);
+ public String getID();
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/MaxAggregate.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/MaxAggregate.java
new file mode 100644
index 0000000000..7da69d4795
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/MaxAggregate.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.aggregates;
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.structures.NumberType;
+
+public class MaxAggregate implements IDataAggregate {
+
+ /**
+ * Ensure column isn't empty, then get the maximum of all the column's values.
+ *
+ * @param column The column to search.
+ *
+ * @return Maximum of all the column's values.
+ */
+ public Number aggregate(Number[] column) {
+ if(column == null || column.length == 0)
+ return null;
+
+ double num = Double.NEGATIVE_INFINITY;
+
+ for(int i=0; i<column.length; i++) {
+ if(num < column[i].doubleValue())
+ num = column[i].doubleValue();
+ }
+
+ return NumberType.getNumber(column[0], num);
+ }
+
+ public String getID() {
+ return ID;
+ }
+
+ public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.aggregates.MaxAggregate";
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/MinAggregate.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/MinAggregate.java
new file mode 100644
index 0000000000..bf86ddd8f3
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/MinAggregate.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.aggregates;
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.structures.NumberType;
+
+public class MinAggregate implements IDataAggregate {
+
+ /**
+ * Ensure column isn't empty, then get the minimum of all the column's values.
+ *
+ * @param column The column to search.
+ *
+ * @return Minimum of all the column's values.
+ */
+ public Number aggregate(Number[] column) {
+ if(column == null || column.length == 0)
+ return null;
+
+ double num = Double.POSITIVE_INFINITY;
+
+ for(int i=0; i<column.length; i++) {
+ if(num > column[i].doubleValue())
+ num = column[i].doubleValue();
+ }
+
+ return NumberType.getNumber(column[0], num);
+ }
+
+ public String getID() {
+ return ID;
+ }
+
+ public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.aggregates.MinAggregate";
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/SumAggregate.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/SumAggregate.java
new file mode 100644
index 0000000000..09a3bb23ec
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/aggregates/SumAggregate.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.aggregates;
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.structures.NumberType;
+
+public class SumAggregate implements IDataAggregate {
+
+ /**
+ * Ensure column isn't empty, then get the sum total of all the column's values.
+ *
+ * @param column The column to total.
+ *
+ * @return The sum total of all the column's values.
+ */
+ public Number aggregate(Number[] column) {
+ if(column == null || column.length == 0)
+ return null;
+
+ double num = 0;
+
+ for(int i=0; i<column.length; i++)
+ num += column[i].doubleValue();
+
+ return NumberType.getNumber(column[0], num);
+ }
+
+ public String getID() {
+ return ID;
+ }
+
+ public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.aggregates.SumAggregate";
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IBlockDataSet.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IBlockDataSet.java
new file mode 100644
index 0000000000..d9681b9bb4
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IBlockDataSet.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.datasets;
+
+public interface IBlockDataSet extends IDataSet {
+ public Object[][] getData();
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IDataEntry.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IDataEntry.java
new file mode 100644
index 0000000000..1a408ab214
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IDataEntry.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.datasets;
+
+public interface IDataEntry {
+ public int getRowCount();
+ public int getColCount();
+ public Object get(String key, int col);
+ public Object[] getRow(int row);
+ public Object[] getRow(String key);
+ public Object[] getColumn(int col);
+ public Object[][] getData();
+ public IDataEntry copy();
+ public void putRow(int row, Object[] data);
+ public boolean remove(int row);
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IDataSet.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IDataSet.java
new file mode 100644
index 0000000000..5a6efba3f4
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IDataSet.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.datasets;
+
+import java.io.File;
+
+
+public interface IDataSet {
+ public String[] getTitles();
+ public String getID();
+ public boolean writeToFile(File file);
+ public boolean readFromFile(File file);
+
+ public int getRowCount();
+ public int getColCount();
+
+ public Object[] getRow(int row);
+ public Object[] getColumn(int col);
+ public Object[] getColumn(int col, int start, int end);
+
+ public void setData(IDataEntry entry);
+
+ public boolean remove(IDataEntry entry);
+
+ public static final int COL_ROW_NUM = -1;
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IDataSetParser.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IDataSetParser.java
new file mode 100644
index 0000000000..dd1cb1d827
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IDataSetParser.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.datasets;
+
+import org.eclipse.ui.IMemento;
+
+
+public interface IDataSetParser {
+ public IDataEntry parse(StringBuilder entry);
+ public boolean saveXML(IMemento target);
+
+ public static final String XMLDataSetSettings = "DataSetSettings";
+ public static final String XMLparsingExpression = "parsingExpression";
+ public static final String XMLparsingSpacer = "parsingSpacer";
+ public static final String XMLColumn = "Column";
+ public static final String XMLdataset = "dataset";
+ public static final String XMLFile = "File";
+ public static final String XMLSeries = "Series";
+ public static final String XMLname = "name";
+ public static final String XMLDelimiter = "Delimiter";
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IFilteredDataSet.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IFilteredDataSet.java
new file mode 100644
index 0000000000..cb496d1b08
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IFilteredDataSet.java
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.datasets;
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.filters.IDataSetFilter;
+
+public interface IFilteredDataSet extends IDataSet {
+ public void addFilter(IDataSetFilter filter);
+ public IDataSetFilter[] getFilters();
+ public void clearFilters();
+ public boolean removeFilter(IDataSetFilter filter);
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IHistoricalDataSet.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IHistoricalDataSet.java
new file mode 100644
index 0000000000..d0ca7d7d7a
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/IHistoricalDataSet.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.datasets;
+
+public interface IHistoricalDataSet extends IDataSet {
+ public void append(IDataEntry entry) throws ArrayIndexOutOfBoundsException;
+
+ public Object[] getHistoricalData(String key, int col);
+ public Object[] getHistoricalData(String key, int col, int start, int end);
+ public int getEntryCount();
+ public IDataEntry getEntry(int entry);
+ public boolean remove(int entry);
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/row/FilteredRowDataSet.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/row/FilteredRowDataSet.java
new file mode 100644
index 0000000000..0958a4773f
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/row/FilteredRowDataSet.java
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.datasets.row;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataEntry;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IFilteredDataSet;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.filters.IDataSetFilter;
+
+
+
+public class FilteredRowDataSet extends RowDataSet implements IFilteredDataSet {
+ public FilteredRowDataSet(RowDataSet data) {
+ super(data.getTitles());
+ original = data;
+ this.data = data.data;
+ filters = new ArrayList<IDataSetFilter>();
+
+ filtersChanged = false;
+ topData = null;
+ dataCount = data.getRowCount();
+ }
+
+ public FilteredRowDataSet(String[] titles) {
+ this(new RowDataSet(titles));
+ }
+
+ //Overwrite methods to insure data is removed from the original DataSet
+ public void append(IDataEntry entry) throws ArrayIndexOutOfBoundsException {
+ original.append(entry);
+ }
+
+ public boolean remove(IDataEntry entry) {
+ return original.remove(entry);
+ }
+
+ public boolean remove(int entry) {
+ return original.remove(entry);
+ }
+ //End overwrite methods to insure data is removed from the original DataSet
+
+ //Overwrite to ensure the data returned has all the filters applied
+ public Object[] getColumn(int col, int start, int end) {
+ rebuildDataSet();
+ return super.getColumn(col, start, end);
+ }
+
+ public Object[] getRow(int row) {
+ rebuildDataSet();
+ return super.getRow(row);
+ }
+
+ //public int getRowCount() - calls getEntryCount();
+
+ public Object[] getHistoricalData(String key, int col, int start, int end) {
+ rebuildDataSet();
+ return super.getHistoricalData(key, col, start, end);
+ }
+
+ public int getEntryCount() {
+ rebuildDataSet();
+ return super.getEntryCount();
+ }
+
+ public IDataEntry getEntry(int entry) {
+ rebuildDataSet();
+ return super.getEntry(entry);
+ }
+ //End overwrite to ensure the data returned has all the filters applied
+
+ //IFilteredDataSet Methods
+ public void addFilter(IDataSetFilter filter) {
+ filters.add(filter);
+ filtersChanged = true;
+ }
+
+ public boolean removeFilter(IDataSetFilter filter) {
+ filtersChanged = filters.remove(filter);
+ return filtersChanged;
+ }
+
+ public void clearFilters() {
+ filters.clear();
+ filtersChanged = true;
+ }
+
+ public IDataSetFilter[] getFilters() {
+ IDataSetFilter[] f = new IDataSetFilter[filters.size()];
+ filters.toArray(f);
+ return f;
+ }
+ //End IFilteredDataSet Methods
+
+ @SuppressWarnings("unchecked")
+ private void rebuildDataSet() {
+ IDataEntry top = original.getEntry(original.getEntryCount()-1);
+
+ if(filtersChanged || dataCount != original.getRowCount() || topData != top) {
+ dataCount = original.getRowCount();
+ topData = top;
+
+ ArrayList[] filterData = getFilterData();
+ for(int i=0; i<filters.size(); i++)
+ filterData = ((IDataSetFilter)filters.get(i)).filter(filterData);
+ setFilteredData(filterData);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private ArrayList[] getFilterData() {
+ ArrayList[] data = new ArrayList[original.getColCount()];
+ for(int i=0; i<data.length; i++)
+ data[i] = new ArrayList<Object>();
+
+ Object[] row;
+ for(int j,i=0; i<original.getRowCount(); i++) {
+ row = original.getRow(i);
+ for(j=0; j<data.length; j++)
+ data[j].add(row[j]);
+ }
+
+ return data;
+ }
+
+ @SuppressWarnings("unchecked")
+ private void setFilteredData(ArrayList[] data) {
+ this.data = new ArrayList<IDataEntry>();
+
+ RowEntry entry;
+ Object[] row;
+ for(int j,i=0; i<data[0].size(); i++) {
+ row = new Object[data.length];
+ entry = new RowEntry();
+ for(j=0; j<data.length; j++)
+ row[j] = data[j].get(i);
+ entry.putRow(0, row);
+ this.data.add(entry);
+ }
+ }
+
+ private RowDataSet original;
+ private ArrayList<IDataSetFilter> filters;
+
+ private boolean filtersChanged;
+ private int dataCount;
+ private Object topData;
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/row/RowDataSet.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/row/RowDataSet.java
new file mode 100644
index 0000000000..82d7d5ef11
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/row/RowDataSet.java
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.datasets.row;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataEntry;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IHistoricalDataSet;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.internal.Localization;
+
+
+
+public class RowDataSet implements IHistoricalDataSet {
+ //IDataSet Methods
+ public RowDataSet(String[] titles) {
+ this.titles = titles;
+ data = new ArrayList<IDataEntry>();
+ }
+
+ public void setData(IDataEntry entry) {
+ append(entry);
+ }
+
+ public void append(IDataEntry entry) throws ArrayIndexOutOfBoundsException {
+ RowEntry dataBlock = (RowEntry)entry;
+ if(dataBlock.getRow(null).length != this.getColCount())
+ throw new ArrayIndexOutOfBoundsException(Localization.getString("RowDataSet.ArraySizeMismatch") + dataBlock.getRow(null).length + " != " + this.getColCount());
+
+ data.add(entry);
+ }
+
+ public String[] getTitles() {
+ return titles;
+ }
+
+ public Object[] getColumn(int col) {
+ return getColumn(col, 0, getRowCount());
+ }
+
+ public Object[] getColumn(int col, int start, int end) {
+ return getHistoricalData(null, col, start, end);
+ }
+
+ public Object[] getRow(int row) {
+ IDataEntry entry = getEntry(row);
+ if(null != entry)
+ return entry.getRow(null);
+ return null;
+ }
+
+ public int getRowCount() {
+ return getEntryCount();
+ }
+
+ public int getColCount() {
+ if(null == titles)
+ return -1;
+ return titles.length;
+ }
+
+ public boolean readFromFile(File file) {
+ try {
+ FileReader fr = new FileReader(file);
+ BufferedReader br = new BufferedReader(fr);
+
+ br.readLine(); //Skip the ID
+ br.readLine(); //Skip the Titles
+ String line;
+ RowEntry entry;
+ while(null != (line = br.readLine())) {
+ entry = new RowEntry();
+ entry.putRow(0, line.split(", "));
+ append(entry);
+ }
+ return true;
+ } catch(FileNotFoundException fnfe) {
+ } catch(IOException ioe) {
+ } catch(ArrayIndexOutOfBoundsException aioobe) {}
+ return false;
+ }
+
+ public boolean writeToFile(File file) {
+ try {
+ file.createNewFile();
+ FileOutputStream fos = new FileOutputStream(file);
+ PrintStream ps = new PrintStream(fos);
+
+ String line = "";
+ Object[] dataRow;
+
+ //ID
+ ps.print(ID + "\n");
+
+ //Labels
+ int i, j;
+ for(i=0; i<titles.length; i++)
+ line += titles[i] + ", ";
+ ps.print(line + "\n");
+
+ //Data
+ for(i=0; i<getRowCount(); i++) {
+ dataRow = getRow(i);
+ line = "";
+ for(j=0; j<dataRow.length; j++)
+ line += dataRow[j].toString() + ", ";
+ ps.print(line + "\n");
+ }
+ return true;
+ } catch(FileNotFoundException e) {
+ } catch(IOException e) {}
+ return false;
+ }
+
+ public String getID() {
+ return ID;
+ }
+ //End IDataSet Methods
+
+ //IHistoricalDataSet Methods
+ public Object[] getHistoricalData(String key, int col) {
+ return getHistoricalData(key, col, 0, getRowCount());
+ }
+
+ public Object[] getHistoricalData(String key, int col, int start, int end) {
+ if(start > end || start < 0 || end > getRowCount() || col < COL_ROW_NUM || col >= this.getColCount())
+ return null;
+
+ if(COL_ROW_NUM == col) {
+ Integer[] rows = new Integer[Math.min(end-start, data.size())];
+ for(int i=0;i<rows.length; i++)
+ rows[i] = new Integer(start+i+1);
+ return rows;
+ }
+
+ Object[] d = new Object[Math.min(end-start, data.size())];
+
+ for(int i=0; i<d.length; i++)
+ d[i] = ((IDataEntry)data.get(start+i)).getColumn(col)[0];
+ return d;
+ }
+
+ public int getEntryCount() {
+ return data.size();
+ }
+
+ public boolean remove(IDataEntry entry) {
+ return data.remove(entry);
+ }
+
+ public boolean remove(int entry) {
+ if(entry < 0 || entry >= data.size())
+ return false;
+ return (null != data.remove(entry));
+ }
+
+ public IDataEntry getEntry(int entry) {
+ if(entry < 0 || entry >= getEntryCount())
+ return null;
+ else
+ return (IDataEntry)data.get(entry);
+ }
+ //End IHistoricalDataSet Methods
+
+ protected ArrayList<IDataEntry> data;
+ private String[] titles;
+ public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.rowdataset";
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/row/RowEntry.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/row/RowEntry.java
new file mode 100644
index 0000000000..f5d346d383
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/row/RowEntry.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.datasets.row;
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataEntry;
+
+public class RowEntry implements IDataEntry {
+ public RowEntry() {
+ data = null;
+ }
+
+ public int getRowCount() {
+ if(null != data)
+ return 1;
+ return 0;
+ }
+
+ public int getColCount() {
+ return (null == data) ? 0 : data.length;
+ }
+
+ public Object get(String key, int col) {
+ return (0 <= col && col < getColCount()) ? data[col] : null;
+ }
+
+ public Object[] getRow(int row) {
+ if(0 == row)
+ return data;
+ return null;
+ }
+
+ public Object[] getRow(String key) {
+ return data;
+ }
+
+ public Object[] getColumn(int col) {
+ if(0 <= col && getColCount() > col)
+ return new Object[] {get(null, col)};
+ return null;
+ }
+
+ public Object[][] getData() {
+ return new Object[][] {getRow(null)};
+ }
+
+ public IDataEntry copy() {
+ RowEntry entry = new RowEntry();
+ if(null != data) {
+ entry.data = new Object[data.length];
+ System.arraycopy(data, 0, entry.data, 0, data.length);
+ }
+
+ return entry;
+ }
+
+ public void putRow(int row, Object[] data) {
+ if(0 == row)
+ this.data = data;
+ }
+
+ public boolean remove(int row) {
+ if(row == 0) {
+ data = null;
+ return true;
+ } else
+ return false;
+ }
+
+ private Object[] data;
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/row/RowParser.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/row/RowParser.java
new file mode 100644
index 0000000000..227d751bd3
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/row/RowParser.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.datasets.row;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataEntry;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataSetParser;
+import org.eclipse.ui.IMemento;
+
+
+
+public class RowParser implements IDataSetParser {
+ public RowParser(String[] regEx) {
+ this.regEx = regEx;
+ buildPattern();
+ }
+
+ public RowParser(IMemento source) {
+ IMemento[] children = source.getChildren(IDataSetParser.XMLSeries);
+ regEx = new String[children.length<<1];
+ for(int j=0; j<children.length; j++) {
+ regEx[j<<1] = children[j].getString(IDataSetParser.XMLparsingExpression);
+ regEx[(j<<1)+1] = children[j].getString(IDataSetParser.XMLparsingSpacer);
+ }
+ buildPattern();
+ }
+
+ private void buildPattern() {
+ StringBuilder wholeRegExpr = new StringBuilder();
+ for(int i=0; i<regEx.length; i++)
+ wholeRegExpr.append('(' + regEx[i] + ')');
+ wholePattern = Pattern.compile(wholeRegExpr.toString());
+ }
+
+ public IDataEntry parse(StringBuilder s) {
+ if(null == s)
+ return null;
+
+ RowEntry e = null;
+ Matcher wholeMatcher = wholePattern.matcher(s);
+
+ if(wholeMatcher.find()) {
+ e = new RowEntry();
+ Object[] data = new Object[regEx.length>>1];
+
+ int group=0, j;
+
+ for(int i=0; i<regEx.length; i++) {
+ group++;
+ for(j=0; j<regEx[i].length(); j++)
+ if(regEx[i].charAt(j) == ')')
+ group++;
+
+ if(0 == (i&1))
+ data[i>>1] = wholeMatcher.group(group);
+ }
+ e.putRow(0, data);
+ s.delete(0, wholeMatcher.end());
+ }
+
+ return e;
+ }
+
+ public boolean saveXML(IMemento target) {
+ target.putString(IDataSetParser.XMLdataset, RowDataSet.ID);
+ IMemento child2;
+ for(int i=0; i<regEx.length>>1; i++) {
+ child2 = target.createChild(IDataSetParser.XMLSeries);
+ child2.putString(IDataSetParser.XMLparsingExpression, regEx[i<<1]);
+ child2.putString(IDataSetParser.XMLparsingSpacer, regEx[(i<<1)+1]);
+ }
+ return true;
+ }
+
+ private String[] regEx;
+ private Pattern wholePattern;
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/table/FilteredTableDataSet.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/table/FilteredTableDataSet.java
new file mode 100644
index 0000000000..67d3c6c30b
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/table/FilteredTableDataSet.java
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.datasets.table;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataEntry;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IFilteredDataSet;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.filters.IDataSetFilter;
+
+
+
+public class FilteredTableDataSet extends TableDataSet implements IFilteredDataSet {
+ public FilteredTableDataSet(TableDataSet data) {
+ super(data.getTitles());
+ original = data;
+ this.data = data.data;
+ filters = new ArrayList<IDataSetFilter>();
+
+ filtersChanged = false;
+ historical = false;
+ topData = null;
+ dataCount = data.getRowCount();
+ }
+
+ public FilteredTableDataSet(String[] titles) {
+ this(new TableDataSet(titles));
+ }
+
+ //Overwrite methods to insure data is removed from the original DataSet
+ public void append(IDataEntry entry) throws ArrayIndexOutOfBoundsException {
+ original.append(entry);
+ }
+
+ public boolean remove(IDataEntry entry) {
+ return original.remove(entry);
+ }
+
+ public boolean remove(int entry) {
+ return original.remove(entry);
+ }
+ //End overwrite methods to insure data is removed from the original DataSet
+
+ //Overwrite to ensure the data returned has all the filters applied
+ public Object[] getColumn(int col, int start, int end) {
+ rebuildDataSet();
+ return super.getColumn(col, start, end);
+ }
+
+ public Object[] getRow(int row) {
+ rebuildDataSet();
+ return super.getRow(row);
+ }
+
+ public int getRowCount() {
+ rebuildDataSet();
+ return super.getRowCount();
+ }
+
+ public Object[] getHistoricalData(String key, int col, int start, int end) {
+ return original.getHistoricalData(key, col, start, end);
+ //rebuildHistoricalDataSet();
+ //return super.getHistoricalData(key, col, start, end);
+ }
+
+ public int getEntryCount() {
+ return original.getEntryCount();
+ //rebuildHistoricalDataSet();
+ //return super.getEntryCount();
+ }
+
+ public IDataEntry getEntry(int entry) {
+ return original.getEntry(entry);
+ //rebuildHistoricalDataSet();
+ //return super.getEntry(entry);
+ }
+
+ public Object[][] getData() {
+ rebuildDataSet();
+ return super.getData();
+ }
+ //End overwrite to ensure the data returned has all the filters applied
+
+ //IFilteredDataSet Methods
+ public void addFilter(IDataSetFilter filter) {
+ filters.add(filter);
+ filtersChanged = true;
+ }
+
+ public boolean removeFilter(IDataSetFilter filter) {
+ filtersChanged = filters.remove(filter);
+ return filtersChanged;
+ }
+
+ public void clearFilters() {
+ filters.clear();
+ filtersChanged = true;
+ }
+
+ public IDataSetFilter[] getFilters() {
+ IDataSetFilter[] f = new IDataSetFilter[filters.size()];
+ filters.toArray(f);
+ return f;
+ }
+ //End IFilteredDataSet Methods
+
+ @SuppressWarnings("unchecked")
+ private void rebuildDataSet() {
+ IDataEntry top = original.getEntry(original.getEntryCount()-1);
+
+ if(filtersChanged || dataCount != original.getRowCount() || topData != top || historical) {
+ dataCount = original.getRowCount();
+ topData = top;
+ historical = false;
+
+ ArrayList[] filterData = getFilterData();
+ for(int i=0; i<filters.size(); i++)
+ filterData = ((IDataSetFilter)filters.get(i)).filter(filterData);
+ setFilteredData(filterData);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private ArrayList[] getFilterData() {
+ ArrayList[] data = new ArrayList[original.getColCount()];
+ for(int i=0; i<data.length; i++)
+ data[i] = new ArrayList();
+
+ Object[][] table = original.getData();
+ for(int j,i=0; i<original.getRowCount(); i++) {
+ for(j=0; j<data.length; j++)
+ data[j].add(table[i][j]);
+ }
+
+ return data;
+ }
+
+ @SuppressWarnings("unchecked")
+ private void setFilteredData(ArrayList[] data) {
+ this.data = new ArrayList<TableEntry>();
+
+ TableEntry entry = new TableEntry();
+ Object[] row;
+ for(int j,i=0; i<data[0].size(); i++) {
+ row = new Object[data.length];
+ for(j=0; j<data.length; j++)
+ row[j] = data[j].get(i);
+ entry.add(row);
+ }
+ this.data.add(entry);
+ }
+
+ private TableDataSet original;
+ private ArrayList<IDataSetFilter> filters;
+
+ private boolean filtersChanged;
+ private int dataCount;
+ private Object topData;
+ private boolean historical;
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/table/TableDataSet.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/table/TableDataSet.java
new file mode 100644
index 0000000000..05ae546d22
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/table/TableDataSet.java
@@ -0,0 +1,204 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.datasets.table;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IBlockDataSet;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataEntry;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IHistoricalDataSet;
+
+
+
+public class TableDataSet implements IHistoricalDataSet, IBlockDataSet {
+ public TableDataSet(String[] labels) {
+ if(null == labels)
+ this.titles = new String[0];
+ else {
+ this.titles = labels;
+ }
+ data = new ArrayList<TableEntry>();
+ }
+
+ //IDataSet Methods
+ public String[] getTitles() {
+ return titles;
+ }
+
+ public String getID() {
+ return ID;
+ }
+
+ public boolean readFromFile(File file) {
+ try {
+ FileReader fr = new FileReader(file);
+ BufferedReader br = new BufferedReader(fr);
+
+ br.readLine(); //Skip the ID
+ br.readLine(); //Skip the Titles
+ String line;
+ TableEntry entry = new TableEntry();
+ while(null != (line = br.readLine())) {
+ if(line.equals("")) {
+ append(entry);
+ entry = new TableEntry();
+ } else
+ entry.add(line.split(", "));
+ }
+ return true;
+ } catch(FileNotFoundException fnfe) {
+ } catch(IOException ioe) {
+ } catch(ArrayIndexOutOfBoundsException aioobe) {}
+ return false;
+ }
+
+ public boolean writeToFile(File file) {
+ try {
+ file.createNewFile();
+ FileOutputStream fos = new FileOutputStream(file);
+ PrintStream ps = new PrintStream(fos);
+ StringBuilder b = new StringBuilder();
+
+ //ID
+ b.append(ID + "\n");
+
+ //Labels
+ int i, j, k;
+ for(i=0; i<titles.length; i++)
+ b.append(titles[i] + ", ");
+ b.append("\n");
+
+ //Data
+ TableEntry e;
+ Object[] o;
+ for(i=0; i<data.size(); i++) {
+ e = (TableEntry)data.get(i);
+ for(j=0; j<e.getRowCount(); j++) {
+ o = e.getRow(j);
+ for(k=0; k<o.length; k++)
+ b.append(o[k].toString() + ", ");
+ b.append("\n");
+ }
+ b.append("\n");
+ }
+ ps.print(b.toString());
+ return true;
+ } catch(FileNotFoundException e) {
+ } catch(IOException e) {}
+ return false;
+ }
+
+ public int getRowCount() {
+ if(data.size() > 0)
+ return ((TableEntry)data.get(data.size()-1)).getRowCount();
+ else
+ return 0;
+ }
+
+ public int getColCount() {
+ return titles.length;
+ }
+
+ public Object[] getRow(int row) {
+ return ((TableEntry)data.get(data.size()-1)).getRow(row);
+ }
+
+ public Object[] getColumn(int col) {
+ return getColumn(col, 0, getRowCount());
+ }
+
+ public Object[] getColumn(int col, int start, int end) {
+ if(start > end || start < 0 || end > getEntryCount() || col < COL_ROW_NUM || col >= this.getColCount())
+ return null;
+ if(COL_ROW_NUM == col) {
+ Integer[] rows = new Integer[Math.min(end-start, getRowCount())];
+ for(int i=0;i<rows.length; i++)
+ rows[i] = new Integer(start+i+1);
+ return rows;
+ }
+ return ((TableEntry)data.get(data.size()-1)).getColumn(col, start, end);
+ }
+
+ public void setData(IDataEntry data) {
+ append(data);
+ }
+
+ public boolean remove(IDataEntry entry) {
+ return data.remove(entry);
+ }
+ //End IDataSet Methods
+
+ //IHistoricalDataSet Methods
+ public void append(IDataEntry data) {
+ if(data instanceof TableEntry)
+ this.data.add((TableEntry)data);
+ }
+
+ public Object[] getHistoricalData(String key, int col) {
+ return getHistoricalData(key, col, 0, getEntryCount());
+ }
+
+ public Object[] getHistoricalData(String key, int col, int start, int end) {
+ if(start > end || start < 0 || end > getEntryCount() || col < COL_ROW_NUM || col >= this.getColCount())
+ return null;
+
+ if(COL_ROW_NUM == col) {
+ Integer[] rows = new Integer[Math.min(end-start, data.size())];
+ for(int i=0;i<rows.length; i++)
+ rows[i] = new Integer(start+i+1);
+ return rows;
+ }
+
+ Object[] d = new Object[Math.min(end-start, getEntryCount())];
+
+ for(int i=0; i<d.length; i++) {
+ d[i] = getEntry(i+start).get(key, col);
+ if(null == d[i])
+ d[i] = new Integer(0);
+ }
+ return d;
+ }
+
+ public int getEntryCount() {
+ return data.size();
+ }
+
+ public IDataEntry getEntry(int entry) {
+ if(entry >=0 && entry < getEntryCount())
+ return (TableEntry)data.get(entry);
+ return null;
+ }
+
+ public boolean remove(int entry) {
+ if(entry < 0 || entry >= data.size())
+ return false;
+ return (null != data.remove(entry));
+ }
+ //End IHistoricalDataSet Methods
+
+ //IBlockDataSet Methods
+ public Object[][] getData() {
+ return ((TableEntry)data.get(getEntryCount()-1)).getData();
+ }
+ //End IBlockDataSet Methods
+
+ public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.tabledataset";
+ protected ArrayList<TableEntry> data;
+ private String[] titles;
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/table/TableEntry.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/table/TableEntry.java
new file mode 100644
index 0000000000..0011984166
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/table/TableEntry.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.datasets.table;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataEntry;
+
+
+
+public class TableEntry implements IDataEntry {
+ public TableEntry() {
+ bodyContent = new ArrayList<Object[]>();
+ }
+
+ public int getRowCount() {
+ return bodyContent.size();
+ }
+
+ public int getColCount() {
+ if(getRowCount() > 0) {
+ try {
+ return ((Object [])bodyContent.get(0)).length;
+ } catch(Exception cce) {}
+ }
+ return 0;
+ }
+
+ public Object get(String key, int col) {
+ if(col >= 0 && col < getColCount()) {
+ Object[] row = getRow(key);
+ if(null != row)
+ return row[col];
+ }
+ return null;
+ }
+
+ public Object[][] getData() {
+ Object[][] d = new Object[getRowCount()][getColCount()];
+ for(int i=0; i<getRowCount(); i++) {
+ d[i] = getRow(i);
+ }
+ return d;
+ }
+
+ public Object[] getRow(int row) {
+ if(row < 0 || row >= getRowCount())
+ return null;
+ return (Object[])bodyContent.get(row);
+ }
+
+ public Object[] getRow(String key) {
+ Object[] row;
+ for(int i=0; i<bodyContent.size(); i++) {
+ row = (Object[])bodyContent.get(i);
+ if(row[0].toString().equals(key))
+ return row;
+ }
+ return null;
+ }
+
+ public Object[] getColumn(int col) {
+ return getColumn(col, 0, getRowCount());
+ }
+
+ public Object[] getColumn(int col, int start, int end) {
+ if(0 <= col && getColCount() > col && start >=0 && end > start && end <= getRowCount()) {
+ Object[] res = new Object[Math.min(end-start, getRowCount())];
+ for(int i=0; i<res.length; i++)
+ res[i] = ((Object[])bodyContent.get(i+start))[col];
+ return res;
+ }
+ return null;
+ }
+
+ public void putRow(int row, Object[] data) {
+ if(row >= bodyContent.size())
+ add(data);
+ else if(row >= 0) {
+ bodyContent.add(row, data);
+ bodyContent.remove(row+1);
+ }
+ }
+
+ public void add(Object[] data) {
+ if(null != data && (data.length == getColCount() || getRowCount() == 0))
+ bodyContent.add(data);
+ }
+
+ public IDataEntry copy() {
+ TableEntry entry = new TableEntry();
+ for(int i=0; i<bodyContent.size(); i++)
+ entry.add((Object[])bodyContent.get(i));
+
+ return entry;
+ }
+
+ public boolean remove(int row) {
+ return (null != bodyContent.remove(row));
+ }
+
+ private ArrayList<Object[]> bodyContent; //ArrayList of arrays
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/table/TableParser.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/table/TableParser.java
new file mode 100644
index 0000000000..217e37a54c
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/datasets/table/TableParser.java
@@ -0,0 +1,104 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.datasets.table;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataEntry;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataSetParser;
+import org.eclipse.ui.IMemento;
+
+
+
+public class TableParser implements IDataSetParser {
+ public TableParser(String[] regEx, String delimiter) {
+ this.regEx = regEx;
+ this.delimiter = delimiter;
+ buildPattern();
+ }
+
+ public TableParser(IMemento source) {
+ IMemento[] children = source.getChildren(IDataSetParser.XMLSeries);
+ regEx = new String[children.length<<1];
+ for(int j=0; j<children.length; j++) {
+ regEx[j<<1] = children[j].getString(IDataSetParser.XMLparsingExpression);
+ regEx[(j<<1)+1] = children[j].getString(IDataSetParser.XMLparsingSpacer);
+ }
+ IMemento del = source.getChild(IDataSetParser.XMLDelimiter);
+ delimiter = del.getString(IDataSetParser.XMLparsingExpression);
+ buildPattern();
+ }
+
+ private void buildPattern() {
+ StringBuilder wholeRegExpr = new StringBuilder();
+ for(int i=0; i<regEx.length; i++)
+ wholeRegExpr.append('(' + regEx[i] + ')');
+ wholePattern = Pattern.compile(wholeRegExpr.toString());
+ delimPattern = Pattern.compile(delimiter);
+ }
+
+ public IDataEntry parse(StringBuilder s) {
+ if(null == s)
+ return null;
+
+ TableEntry e = null;
+
+ Matcher wholeMatcher = wholePattern.matcher(s);
+ Matcher delimMatcher = delimPattern.matcher(s);
+
+ Object[] data;
+ int end = 0;
+ if(delimMatcher.find()) {
+ e = new TableEntry();
+ end = delimMatcher.start();
+
+ int group, j;
+ while(wholeMatcher.find() && wholeMatcher.end() < end) {
+ group = 0;
+ data = new Object[regEx.length>>1];
+ for(int i=0; i<regEx.length; i++) {
+ group++;
+ for(j=0; j<regEx[i].length(); j++)
+ if(regEx[i].charAt(j) == ')')
+ group++;
+
+ if(0 == (i&1))
+ data[i>>1] = wholeMatcher.group(group);
+ }
+ e.add(data);
+ }
+ s.delete(0, delimMatcher.end());
+ }
+
+ return e;
+ }
+
+ public boolean saveXML(IMemento target) {
+ target.putString(IDataSetParser.XMLdataset, TableDataSet.ID);
+ IMemento child;
+ for(int i=0; i<regEx.length>>1; i++) {
+ child = target.createChild(IDataSetParser.XMLSeries);
+ child.putString(IDataSetParser.XMLparsingExpression, regEx[i<<1]);
+ child.putString(IDataSetParser.XMLparsingSpacer, regEx[(i<<1)+1]);
+ }
+ child = target.createChild(IDataSetParser.XMLDelimiter);
+ child.putString(IDataSetParser.XMLparsingExpression, delimiter);
+ return true;
+ }
+
+ private String[] regEx;
+ private String delimiter;
+
+ private Pattern wholePattern;
+ private Pattern delimPattern;
+} \ No newline at end of file
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/IDataSetFilter.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/IDataSetFilter.java
new file mode 100644
index 0000000000..b30fca05e1
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/IDataSetFilter.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.filters;
+
+import java.util.ArrayList;
+
+import org.eclipse.ui.IMemento;
+
+public interface IDataSetFilter {
+ @SuppressWarnings("unchecked")
+ public ArrayList[] filter(ArrayList[] data);
+ public String getID();
+ public void writeXML(IMemento parent);
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/MatchFilter.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/MatchFilter.java
new file mode 100644
index 0000000000..121209d6b9
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/MatchFilter.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.filters;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.systemtap.ui.structures.Copier;
+import org.eclipse.ui.IMemento;
+
+
+
+public class MatchFilter implements IDataSetFilter {
+ public MatchFilter(int column, Object value, int style) {
+ this.column = column;
+ this.value = value;
+ this.style = style;
+ }
+
+ /**
+ * Apply the MatchFilter to the passed dataset.
+ *
+ * @param data The dataset to filter.
+ *
+ * @return The filtered dataset.
+ */
+ @SuppressWarnings("unchecked")
+ public ArrayList[] filter(ArrayList[] data) {
+ if(column < 0 || column >= data.length)
+ return null;
+
+ ArrayList[] newData = Copier.copy(data);
+ boolean equals;
+ for(int j, i=newData[column].size()-1; i>=0; i--) {
+ equals = newData[column].get(i).toString().equals(value.toString()); //TODO: Find better equivilance method
+ if((equals && REMOVE_MATCHING == (style & 1)) || (!equals && KEEP_MATCHING == (style & 1))) {
+ for(j=0; j<newData.length; j++)
+ newData[j].remove(i);
+ }
+ }
+ return newData;
+ }
+
+ public String getID() {
+ return ID;
+ }
+
+ /**
+ * Preserve what filter was applied.
+ *
+ * @param parent Parent object of the new child Memento to create.
+ */
+ public void writeXML(IMemento parent) {
+ IMemento child = parent.createChild("Filter", ID);
+ child.putInteger("column", column);
+ child.putString("value", value.toString());
+ child.putInteger("style", style);
+ }
+
+ private int column;
+ private Object value;
+ private int style;
+
+ public static final int KEEP_MATCHING = 0;
+ public static final int REMOVE_MATCHING = 1;
+
+ public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.filters.MatchFilter";
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/RangeFilter.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/RangeFilter.java
new file mode 100644
index 0000000000..25ea29d1e2
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/RangeFilter.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.filters;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.structures.NumberType;
+import org.eclipse.linuxtools.systemtap.ui.structures.Copier;
+import org.eclipse.ui.IMemento;
+
+
+
+public class RangeFilter implements IDataSetFilter {
+ public RangeFilter(int column, Number lowerBound, Number upperBound, int style) {
+ this.column = column;
+ this.lowerBound = lowerBound;
+ this.upperBound = upperBound;
+ this.style = style;
+ }
+
+ /**
+ * Apply the RangeFilter to the passed dataset.
+ *
+ * @param data The dataset to filter.
+ *
+ * @return The filtered dataset.
+ */
+ @SuppressWarnings("unchecked")
+ public ArrayList[] filter(ArrayList[] data) {
+ if(column < 0 || column >= data.length)
+ return null;
+
+ ArrayList[] newData = Copier.copy(data);
+ for(int j,i=newData[column].size()-1; i>=0; i--) {
+ if(!inBounds(NumberType.obj2num(newData[column].get(i)))) {
+ for(j=0; j<newData.length; j++)
+ newData[j].remove(i);
+ }
+ }
+ return newData;
+ }
+
+ public String getID() {
+ return ID;
+ }
+
+ /**
+ * Verify that the number passed is in the bounds of the created filter.
+ *
+ * @param num The number to verify.
+ *
+ * @return True if the number is within bounds.
+ */
+ private boolean inBounds(Number num) {
+ if(INSIDE_BOUNDS == (style & 1)) {
+ if(INCLUSIVE == (style & 2)) {
+ if(num.doubleValue() > upperBound.doubleValue()
+ || num.doubleValue() < lowerBound.doubleValue())
+ return false;
+ } else {
+ if(num.doubleValue() >= upperBound.doubleValue()
+ || num.doubleValue() <= lowerBound.doubleValue())
+ return false;
+ }
+ }
+
+ if(OUTSIDE_BOUNDS == (style & 1)) {
+ if(INCLUSIVE == (style & 2)) {
+ if(num.doubleValue() < upperBound.doubleValue()
+ && num.doubleValue() > lowerBound.doubleValue())
+ return false;
+ } else {
+ if(num.doubleValue() <= upperBound.doubleValue()
+ && num.doubleValue() >= lowerBound.doubleValue())
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Preserve what filter was applied.
+ *
+ * @param parent Parent object of the new child Memento to create.
+ */
+ public void writeXML(IMemento parent) {
+ IMemento child = parent.createChild("Filter", ID);
+ child.putInteger("column", column);
+ child.putString("low", lowerBound.toString());
+ child.putString("high", upperBound.toString());
+ child.putInteger("style", style);
+ }
+
+ private int column;
+ private Number upperBound;
+ private Number lowerBound;
+ private int style;
+
+ public static final int INSIDE_BOUNDS = 0;
+ public static final int OUTSIDE_BOUNDS = 1;
+
+ public static final int INCLUSIVE = 2;
+ public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.filters.RangeFilter";
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/SortFilter.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/SortFilter.java
new file mode 100644
index 0000000000..9cd9178c25
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/SortFilter.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.filters;
+
+import java.util.ArrayList;
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.structures.NumberType;
+import org.eclipse.linuxtools.systemtap.ui.structures.Copier;
+import org.eclipse.linuxtools.systemtap.ui.structures.IndexedObject;
+import org.eclipse.linuxtools.systemtap.ui.structures.Sort;
+import org.eclipse.ui.IMemento;
+
+
+
+public class SortFilter implements IDataSetFilter {
+ public SortFilter(int column, int ordering) {
+ this.column = column;
+ this.style = (ordering==ASCENDING ? ASCENDING : DESCENDING);
+ }
+
+ /**
+ * Apply the RangeFilter to the passed dataset.
+ *
+ * @param data The dataset to filter.
+ *
+ * @return The filtered dataset.
+ */
+ @SuppressWarnings("unchecked")
+ public ArrayList[] filter(ArrayList[] data) {
+ if(column < 0 || column >= data.length)
+ return null;
+
+ ArrayList[] newData = Copier.copy(data);
+ IndexedObject[] items = new IndexedObject[newData[0].size()];
+
+ try {
+ for(int i=0; i<newData[column].size(); i++)
+ items[i] = new IndexedObject(i, NumberType.cleanObj2Num(newData[column].get(i)));
+ } catch(NumberFormatException nfe) {
+ for(int i=0; i<newData[column].size(); i++)
+ items[i] = new IndexedObject(i, newData[column].get(i));
+ }
+
+ Sort.quicksort(items, 0, items.length-1);
+
+ for(int j, i=0; i<newData.length; i++) {
+ for(j=0; j<items.length; j++) {
+ if(DESCENDING == style)
+ newData[i].add(newData[i].get(items[items.length-j-1].index));
+ else
+ newData[i].add(newData[i].get(items[j].index));
+ }
+ for(j=0; j<items.length; j++)
+ newData[i].remove(0);
+ }
+ return newData;
+ }
+
+ public String getID() {
+ return ID;
+ }
+
+ /**
+ * Preserve what filter was applied.
+ *
+ * @param parent Parent object of the new child Memento to create.
+ */
+ public void writeXML(IMemento parent) {
+ IMemento child = parent.createChild("Filter", ID);
+ child.putInteger("column", column);
+ child.putInteger("style", style);
+ }
+
+ private int column;
+ private int style;
+
+ public static final int ASCENDING = 0;
+ public static final int DESCENDING = 1;
+ public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.filters.SortFilter";
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/UniqueFilter.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/UniqueFilter.java
new file mode 100644
index 0000000000..4a08d7469c
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/filters/UniqueFilter.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.filters;
+
+import java.util.ArrayList;
+
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.aggregates.IDataAggregate;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.structures.NumberType;
+import org.eclipse.linuxtools.systemtap.ui.structures.Copier;
+import org.eclipse.ui.IMemento;
+
+
+
+public class UniqueFilter implements IDataSetFilter {
+ public UniqueFilter(int column, IDataAggregate aggregate, int style) {
+ this.column = column;
+ this.aggregate = aggregate;
+ this.style = style;
+ }
+
+ /**
+ * Verify that the number passed is in the bounds of the created filter.
+ *
+ * @param num The number to verify.
+ *
+ * @return True if the number is within bounds.
+ */
+ @SuppressWarnings("unchecked")
+ public ArrayList[] filter(ArrayList[] data) {
+ if(column < 0 || column >= data.length)
+ return null;
+
+ ArrayList[] newData = Copier.copy(data);
+ ArrayList[] aggregates = new ArrayList[newData.length];
+ for(int i=0; i<aggregates.length;i++)
+ aggregates[i] = new ArrayList();
+
+ for(int k,j,i=newData[0].size()-1; i>=0; i--) {
+ for(j=i-1; j>=0; j--) {
+ if(newData[column].get(i).toString().equals(newData[column].get(j).toString())) { //TODO: Find better equivilance method
+ i--;
+ for(k=0; k<newData.length; k++) {
+ aggregates[k].add(newData[k].get(j));
+ newData[k].remove(j);
+ }
+ }
+ }
+ for(k=0; k<newData.length; k++) {
+ aggregates[k].add(newData[k].get(i));
+ if(k!=column) {
+ newData[k].remove(i);
+ try {
+ newData[k].add(i, aggregate.aggregate(NumberType.cleanObj2Num(aggregates[k].toArray())));
+ } catch(NumberFormatException nfe) {
+ newData[k].add(i, columnMerge(aggregates[k].toArray()));
+ }
+ }
+ aggregates[k].clear();
+ }
+ }
+ return newData;
+ }
+
+ /**
+ * Merges two passed columns into a StringBuilder object.
+ *
+ * @param col The columns to merge.
+ *
+ * @return The StringBuilder object made as a result of the merge.
+ */
+ private String columnMerge(Object[] col) {
+ StringBuilder sb = new StringBuilder(col[0].toString());
+ for(int i=1; i<col.length; i++) {
+ if(sb.indexOf(col[i].toString()) < 0)
+ sb.append("/" + col[i].toString());
+ }
+ return sb.toString();
+ }
+
+ public String getID() {
+ return ID;
+ }
+
+ /**
+ * Preserve what filter was applied.
+ *
+ * @param parent Parent object of the new child Memento to create.
+ */
+ public void writeXML(IMemento parent) {
+ IMemento child = parent.createChild("Filter", ID);
+ child.putInteger("column", column);
+ child.putString("aggregate", aggregate.getID());
+ child.putInteger("style", style);
+ }
+
+ private int column;
+ private IDataAggregate aggregate;
+ private int style;
+ public static final String ID = "org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.filters.UniqueFilter";
+} \ No newline at end of file
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/internal/GraphingAPINonUIPlugin.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/internal/GraphingAPINonUIPlugin.java
new file mode 100644
index 0000000000..06e36a97ba
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/internal/GraphingAPINonUIPlugin.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.internal;
+
+import org.eclipse.ui.plugin.*;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class GraphingAPINonUIPlugin extends AbstractUIPlugin {
+
+ //The shared instance.
+ private static GraphingAPINonUIPlugin plugin;
+
+ /**
+ * The constructor.
+ */
+ public GraphingAPINonUIPlugin() {
+ plugin = this;
+ }
+
+ /**
+ * This method is called upon plug-in activation
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /**
+ * This method is called when the plug-in is stopped
+ */
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ plugin = null;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static GraphingAPINonUIPlugin 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("org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui", path);
+ }
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/internal/Localization.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/internal/Localization.java
new file mode 100644
index 0000000000..6250f6f872
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/internal/Localization.java
@@ -0,0 +1,22 @@
+package org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.internal;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Localization {
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.internal.localization";
+
+ 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.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/internal/localization.properties b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/internal/localization.properties
new file mode 100644
index 0000000000..fb17d5caa3
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/internal/localization.properties
@@ -0,0 +1,5 @@
+ScrollAdapter.RowNum=Row Num
+
+BlockAdapter.RowNum=Row Num
+
+RowDataSet.ArraySizeMismatch=Array size mismatch
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/ChartStreamDaemon.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/ChartStreamDaemon.java
new file mode 100644
index 0000000000..c5f4f86bdc
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/ChartStreamDaemon.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.structures;
+
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataEntry;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataSet;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataSetParser;
+import org.eclipse.linuxtools.systemtap.ui.structures.listeners.IGobblerListener;
+
+
+
+public class ChartStreamDaemon implements IGobblerListener {
+ public ChartStreamDaemon(IDataSet d, IDataSetParser p) {
+ data = d;
+ outputData = new StringBuilder("");
+ parser = p;
+ disposed = false;
+ }
+
+ /**
+ * Takes one line from the output data and appends it to data object.
+ */
+ protected void pushData() {
+ if(null == data || null == parser)
+ return;
+
+ IDataEntry e = parser.parse(outputData);
+ if(null != e)
+ data.setData(e);
+ }
+
+ public void handleDataEvent(String line) {
+ outputData.append(line);
+ this.pushData();
+ }
+
+ public boolean isDisposed() {
+ return disposed;
+ }
+
+ public void dispose() {
+ if(!disposed) {
+ disposed = true;
+ data = null;
+ if(null != outputData)
+ outputData.delete(0, outputData.length());
+ outputData = null;
+ parser = null;
+ }
+ }
+
+ protected IDataSet data;
+ protected StringBuilder outputData;
+ protected IDataSetParser parser;
+ private boolean disposed;
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/ChartStreamDaemon2.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/ChartStreamDaemon2.java
new file mode 100644
index 0000000000..e31b27fb95
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/ChartStreamDaemon2.java
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.structures;
+
+
+import org.eclipse.linuxtools.systemtap.ui.consolelog.structures.ScriptConsole;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataSet;
+import org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui.datasets.IDataSetParser;
+
+
+/**
+ * Listens for data events and populates the internal <code>DataSet</code> with the data
+ * that was received and matched the regExpr
+ * @author Ryan Morse
+ */
+public class ChartStreamDaemon2 extends ChartStreamDaemon {
+ public ChartStreamDaemon2(ScriptConsole console, IDataSet d, IDataSetParser p) {
+ super(d, p);
+
+ }
+
+ /**
+ * Changes the internal <code>DataSet</code> and parsing expression.
+ * @param d The new <code>DataSet</code> to store the parsed output.
+ * @param regExpr String[] containing the RegEx patterns to match against.
+ */
+ public void setParser(IDataSet d, IDataSetParser p) {
+ data = d;
+ parser = p;
+ if(0 != outputData.length())
+ outputData.delete(0, outputData.length()-1);
+ outputData.append(console.getOutput());
+ }
+
+ /**
+ * Disposes of all the internal data.
+ */
+ public void dispose() {
+ if(!isDisposed()) {
+ super.dispose();
+ console = null;
+ }
+ }
+
+ private ScriptConsole console;
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/DataPoint.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/DataPoint.java
new file mode 100644
index 0000000000..6074f0cfd9
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/DataPoint.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.structures;
+
+public class DataPoint {
+ public DataPoint() {
+ this(0, 0);
+ }
+
+ public DataPoint(double x, double y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ public double x;
+ public double y;
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/GraphData.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/GraphData.java
new file mode 100644
index 0000000000..fc81a838a4
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/GraphData.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.structures;
+
+public class GraphData {
+ public int xSeries;
+ public int[] ySeries;
+ public String key;
+ public String graphID;
+ public String title;
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/NumberType.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/NumberType.java
new file mode 100644
index 0000000000..5e19408ce5
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.graphingapi.nonui/src/org/eclipse/linuxtools/systemtap/ui/graphingapi/nonui/structures/NumberType.java
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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.ui.graphingapi.nonui.structures;
+
+public final class NumberType {
+
+ /**
+ * Returns a new instance of the passed in num of type orig.
+ *
+ * @param orig The desired datatype.
+ * @param num The number to replicate.
+ *
+ * @return The new cast number.
+ */
+ public static Number getNumber(Number orig, double num) {
+ if(orig instanceof Long)
+ return new Long((long)num);
+ else if(orig instanceof Double)
+ return new Double(num);
+ else if(orig instanceof Float)
+ return new Float((float)num);
+ else if(orig instanceof Byte)
+ return new Byte((byte)num);
+ else if(orig instanceof Short)
+ return new Short((short)num);
+ return new Integer((int)num);
+ }
+
+ /**
+ * Takes an array of objects and returns an array of Numbers.
+ *
+ * @param o The array of objects to convert.
+ *
+ * @return The array of Numbers from o.
+ */
+ public static Number[] obj2num(Object[] o) {
+ Number[] arr = new Number[o.length];
+ for(int i = 0; i < o.length; i++)
+ arr[i] = obj2num(o[i]);
+
+ return arr;
+ }
+
+ /**
+ * Takes an array of Numbers and returns an array of objects.
+ *
+ * @param o The array of Numbers to convert.
+ *
+ * @return The array of objects from o.
+ */
+ public static Number obj2num(Object o) {
+ Number n = null;
+
+ try {
+ n = cleanObj2Num(o);
+ } catch(NumberFormatException e ) {
+ n = new Long(0);
+ }
+ return n;
+ }
+
+ /**
+ * Returns an array of Numbers type if they are Numbers, otherwise, returns Doubles and Longs as appropriate
+ * based on whether or not it has a '.'
+ *
+ * @param o The object array to clean.
+ *
+ * @return The Number array cleaned.
+ */
+ public static Number[] cleanObj2Num(Object[] o) throws NumberFormatException {
+ Number[] arr = new Number[o.length];
+ for(int i = 0; i < o.length; i++)
+ arr[i] = cleanObj2Num(o[i]);
+
+ return arr;
+ }
+
+ /**
+ * Returns a Number type if its a Number, otherwise, returns Doubles and Longs as appropriate
+ * based on whether or not it has a '.'
+ *
+ * @param o The object to clean.
+ *
+ * @return The Number object cleaned.
+ */
+ public static Number cleanObj2Num(Object o) throws NumberFormatException {
+ if(o instanceof Number)
+ return (Number)o;
+ else {
+ if(o.toString().contains("."))
+ return new Double(Double.parseDouble(o.toString()));
+ else
+ return new Long(Long.parseLong(o.toString()));
+ }
+ }
+}

Back to the top