GraphEditorHisto.java

Go to the documentation of this file.
00001 package edu.rice.cs.hpc.viewer.graph;
00002 
00003 import java.io.IOException;
00004 import java.text.DecimalFormat;
00005 
00006 import org.eclipse.jface.dialogs.MessageDialog;
00007 import org.swtchart.Chart;
00008 import org.swtchart.IAxis;
00009 import org.swtchart.IAxisSet;
00010 import org.swtchart.IAxisTick;
00011 import org.swtchart.IBarSeries;
00012 import org.swtchart.ISeries.SeriesType;
00013 
00014 import edu.rice.cs.hpc.data.experiment.metric.MetricRaw;
00015 import edu.rice.cs.hpc.data.experiment.scope.Scope;
00016 
00017 public class GraphEditorHisto extends GraphEditorBase {
00018 
00019     public static final String ID = "edu.rice.cs.hpc.viewer.graph.GraphEditorHisto";
00020     
00021 
00022     //@Override
00023     protected void plotData(Scope scope, MetricRaw metric) {
00024         final int bins = 10;
00025         
00026         double y_values[], x_values[];
00027         try {
00028             y_values = this.threadData.getMetrics(metric, scope.getCCTIndex());
00029 
00030         } catch (IOException e) {
00031             MessageDialog.openError(this.getSite().getShell(), "Error reading file !", e.getMessage());
00032             return;
00033         }           
00034 
00035         Histogram histo = new Histogram(bins, y_values);
00036         y_values = histo.getAxisY();
00037         x_values = histo.getAxisX();
00038         double min = histo.min();
00039         double max = histo.max();
00040         double single = 0.1 * (max-min)/bins;
00041 
00042         Chart chart = this.getChart();
00043         
00044         IAxisSet axisSet = chart.getAxisSet();
00045         IAxisTick xTick = axisSet.getXAxis(0).getTick();
00046         xTick.setFormat(new DecimalFormat("0.###E0##"));
00047         IAxisTick yTick = axisSet.getYAxis(0).getTick();
00048         yTick.setFormat(new DecimalFormat("#######"));
00049 
00050         IAxis axis = axisSet.getXAxis(0); 
00051         axis.getRange().lower = min - single;
00052         axis.getRange().upper = max + single;
00053         
00054         // create scatter series
00055         IBarSeries scatterSeries = (IBarSeries) chart.getSeriesSet()
00056                 .createSeries(SeriesType.BAR, metric.getDisplayName() );
00057         scatterSeries.setXSeries(x_values);
00058         scatterSeries.setYSeries(y_values);
00059 
00060         chart.getAxisSet().getXAxis(0).getTitle().setText( "Metric Value" );
00061         chart.getAxisSet().getYAxis(0).getTitle().setText( "Frequency" );
00062     }
00063 
00064 }

Generated on 5 May 2015 for HPCVIEWER by  doxygen 1.6.1