diff options
author | Andrew Ferrazzutti | 2013-11-12 15:24:54 +0000 |
---|---|---|
committer | Roland Grunberg | 2013-11-27 17:55:46 +0000 |
commit | 031af9262f4616a356467ca2bd8632fb376aa0a6 (patch) | |
tree | 8405c60e79537a63eafd7727a115ff8c850d00b3 /systemtap | |
parent | bbf18d37537819d2e66060228db1c975716227a9 (diff) | |
download | org.eclipse.linuxtools-031af9262f4616a356467ca2bd8632fb376aa0a6.tar.gz org.eclipse.linuxtools-031af9262f4616a356467ca2bd8632fb376aa0a6.tar.xz org.eclipse.linuxtools-031af9262f4616a356467ca2bd8632fb376aa0a6.zip |
1) When capturing a script's output to display it in a graph,
don't attempt to plot null or invalid values so as to
avoid causing an error.
2) Add labels on individual pie charts to signify which series
each pie represents. Also show a "No data" label when all pie
charts are empty.
3) Increase the version number of linuxtools.dataviewers
to account for the new public API added by 1) and 2).
Also add some public documentation.
Change-Id: I326f583ae7924c397e4771f2cc49fb605ff548a8
Signed-off-by: Andrew Ferrazzutti <aferrazz@redhat.com>
Reviewed-on: https://git.eclipse.org/r/18931
Tested-by: Hudson CI
Reviewed-by: Roland Grunberg <rgrunber@redhat.com>
IP-Clean: Roland Grunberg <rgrunber@redhat.com>
Tested-by: Roland Grunberg <rgrunber@redhat.com>
Diffstat (limited to 'systemtap')
4 files changed, 99 insertions, 28 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartBuilder.java index 32b20f2caf..25ee92aa54 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartBuilder.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartBuilder.java @@ -169,14 +169,21 @@ public abstract class AbstractChartBuilder extends Composite implements IUpdateL handleUpdateEvent(); } - protected double getDoubleValue(Object o) { + protected Double getDoubleValue(Object o) { + if (o == null) { + return null; + } if (o instanceof Integer) { - return ((Integer)o).intValue(); + return ((Integer)o).doubleValue(); } if (o instanceof Double) { - return ((Double)o).doubleValue(); + return (Double) o; + } + try { + return new Double(o.toString()); + } catch (NumberFormatException e) { + return null; } - return new Double(o.toString()).doubleValue(); } @Override diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartWithAxisBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartWithAxisBuilder.java index f5db7291b6..448a1200cb 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartWithAxisBuilder.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/AbstractChartWithAxisBuilder.java @@ -95,32 +95,56 @@ public abstract class AbstractChartWithAxisBuilder extends AbstractChartBuilder return; int totalMaxItems = (int)Math.round(this.maxItems * scale); - int start = 0, len = Math.min(totalMaxItems, data.length); + int start = 0, len = Math.min(totalMaxItems, data.length), leny = data[0].length-1; if (totalMaxItems < data.length) { start = data.length - totalMaxItems; } - double[] valx = new double[len]; - double[][] valy = new double[data[0].length-1][len]; + Double[] all_valx = new Double[len]; + Double[][] all_valy = new Double[leny][len]; ISeries allSeries[] = chart.getSeriesSet().getSeries(); - for (int i = 0; i < valx.length; i++) - for (int j = 0; j < data[start + i].length; j++) { - if (j == 0) - valx[i] = getDoubleValue(data[start + i][j]); - else - valy[j-1][i] = getDoubleValue(data[start + i][j]); + for (int i = 0; i < len; i++) { + for (int j = 0; j < leny + 1; j++) { + Double val = getDoubleValue(data[start + i][j]); + if (j == 0) { + if (val != null) { + all_valx[i] = val; + } else { + break; + } + } else if (val != null) { + all_valy[j-1][i] = val; + } } + } - for (int i = 0; i < valy.length; i++) { + for (int i = 0; i < leny; i++) { ISeries series; if (i >= allSeries.length) { series = createChartISeries(i); } else { series = chart.getSeriesSet().getSeries()[i]; } - series.setXSeries(valx); - series.setYSeries(valy[i]); + + double[] valx = new double[len]; + double[] valy = new double[len]; + int len_trim = 0; + for (int j = 0; j < len; j++) { + if (all_valx[j] != null && all_valy[i][j] != null) { + valx[len_trim] = all_valx[j].doubleValue(); + valy[len_trim] = all_valy[i][j].doubleValue(); + len_trim++; + } + } + double[] valx_trim = new double[len_trim]; + double[] valy_trim = new double[len_trim]; + for (int j = 0; j < len_trim; j++) { + valx_trim[j] = valx[j]; + valy_trim[j] = valy[j]; + } + series.setXSeries(valx_trim); + series.setYSeries(valy_trim); } chart.getAxisSet().adjustRange(); diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/PieChartBuilder.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/PieChartBuilder.java index c1e6223aac..c7a1389e60 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/PieChartBuilder.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/charts/PieChartBuilder.java @@ -22,13 +22,18 @@ import org.eclipse.swt.widgets.Composite; public class PieChartBuilder extends AbstractChartWithoutAxisBuilder { public static final String ID = "org.eclipse.linuxtools.systemtap.graphingapi.ui.charts.piechartbuilder"; //$NON-NLS-1$ - public PieChartBuilder(Composite parent, int style, String title,IAdapter adapter) { + public PieChartBuilder(Composite parent, int style, String title, IAdapter adapter) { super(adapter, parent, style, title); } @Override protected void createChart() { - this.chart = new PieChart(this, getStyle()); + String[] allNames = adapter.getLabels(); + String[] ySeriesNames = new String[allNames.length - 1]; + for (int i = 0; i < ySeriesNames.length; i++) { + ySeriesNames[i] = allNames[i+1]; + } + this.chart = new PieChart(this, getStyle(), ySeriesNames); } @Override @@ -37,23 +42,54 @@ public class PieChartBuilder extends AbstractChartWithoutAxisBuilder { if (data == null || data.length == 0 || data[0].length == 0) return; - int start = 0, len = Math.min(this.maxItems, data.length); + int start = 0, len = Math.min(this.maxItems, data.length), leny = data[0].length-1; if (this.maxItems < data.length) { start = data.length - this.maxItems; } - double[][] values = new double[len][data[0].length-1]; - String[] labels = new String[len]; + Double[][] all_values = new Double[len][leny]; + String[] all_labels = new String[len]; - for (int i = 0; i < labels.length; i++) { + for (int i = 0; i < all_labels.length; i++) { if (data[i].length < 2) return; - labels[i] = data[start + i][0].toString(); - for (int j = 1; j < data[start + i].length; j++) - values[i][j-1] = getDoubleValue(data[start + i][j]); + Object label = data[start + i][0]; + if (label != null) { + all_labels[i] = data[start + i][0].toString(); + for (int j = 1; j < data[start + i].length; j++) { + Double val = getDoubleValue(data[start + i][j]); + if (val != null) { + all_values[i][j-1] = val; + } else { + all_labels[i] = null; + break; + } + } + } + } + + double[][] values = new double[len][leny]; + String[] labels = new String[len]; + int len_trim = 0; + for (int i = 0; i < len; i++) { + if (all_labels[i] != null) { + labels[len_trim] = all_labels[i]; + for (int j = 0; j < leny; j++) { + values[len_trim][j] = all_values[i][j].doubleValue(); + } + len_trim++; + } + } + double[][] values_trim = new double[len_trim][leny]; + String[] labels_trim = new String[len_trim]; + for (int i = 0; i < len_trim; i++) { + labels_trim[i] = labels[i]; + for (int j = 0; j < leny; j++) { + values_trim[i][j] = values[i][j]; + } } - ((PieChart)this.chart).addPieChartSeries(labels, values); + ((PieChart)this.chart).addPieChartSeries(labels_trim, values_trim); chart.redraw(); } diff --git a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/datadisplay/DataGrid.java b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/datadisplay/DataGrid.java index 2f0ddf4a46..4aef7194d1 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/datadisplay/DataGrid.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.graphingapi.ui/src/org/eclipse/linuxtools/systemtap/graphingapi/ui/datadisplay/DataGrid.java @@ -291,8 +291,12 @@ public class DataGrid implements IUpdateListener { os = filteredDataSet.getRow(i); item.setText(0, "" + i); //$NON-NLS-1$ - for(j=0; j<os.length; j++) - item.setText(j+1, columnFormat[j].format(os[j].toString())); + for(j=0; j<os.length; j++) { + //Ignore null items + if (os[j] != null) { + item.setText(j+1, columnFormat[j].format(os[j].toString())); + } + } } if(FULL_UPDATE != (style & FULL_UPDATE)) { |