Ejemplo n.º 1
0
 @Override
 public void doit(PropertyChangeEvent evt, Display display) {
   if (!displayType.isDisposed()) {
     String type = displayType.getItem(displayType.getSelectionIndex());
     chartFrame.setChart(createChart(type));
     chartFrame.redraw();
   }
 }
Ejemplo n.º 2
0
  public void refresh() {
    total.setText(format(totals.getCurrentValue()));
    totalMin.setText("(" + format(totals.getMin()));
    totalMax.setText(" " + format(totals.getMax()) + " ");
    totalAvg.setText(format(totals.getAvg()) + ")");

    final XYPlot plot = (XYPlot) chart.getChart().getPlot();
    final TimeTableXYDataset dataset = (TimeTableXYDataset) plot.getDataset();
    dataset.clear();

    final Date now = new Date();

    if (parts.isEmpty()) {
      fillDataset(dataset, totals, now);
    } else {
      for (final MeasurementsDisplay<T> m : parts.values()) {
        final Measurements<T> measurements = m.measurements;
        fillDataset(dataset, measurements, now);
        m.label.setText(format(m.measurements.getCurrentValue()));
        m.labelMin.setText("(" + format(m.measurements.getMin()));
        m.labelMax.setText(" " + format(m.measurements.getMax()) + " ");
        m.labelAvg.setText(format(m.measurements.getAvg()) + ")");
      }
    }
  }
Ejemplo n.º 3
0
  @Override
  public void createPartControl(Composite parent) {
    Composite body = new Composite(parent, SWT.NONE);
    body.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    body.setLayout(new GridLayout());

    Account account = getAccount();
    intervalReport =
        new TimeIntervalReport(
            account, TimeIntervalReport.Interval.DAY, PriceProviderFactory.getInstance());
    intervalReport.addPropertyChangeListener(changeListener);

    String chartType = StringUtils.defaultString(account.getConfigurationValue(CHART_TYPE), "all");
    JFreeChart chart = createChart(chartType);
    chartFrame = new ChartComposite(body, SWT.NONE, chart, true);
    chartFrame.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    displayType = new Combo(body, SWT.READ_ONLY);
    for (TimeChart.RANGE r : TimeChart.RANGE.values()) {
      displayType.add(r.getName());
    }
    displayType.setText(chartType);
    displayType.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            Combo c = (Combo) e.getSource();
            String type = c.getItem(c.getSelectionIndex());
            timeChart.setChartType(type);
            dirty = true;
            firePropertyChange(IEditorPart.PROP_DIRTY);
          }
        });
  }
Ejemplo n.º 4
0
  @Override
  public void dispose() {

    try {

      // clear our componenents
      // ... freeze charts
      if (chart != null) chart.setNotify(false);
      // ... empty data
      if (dataset != null) dataset.clear();

      // ... dispose chart composites
      if (chartComposites != null && !chartComposites.isDisposed()) chartComposites.dispose();

      if (form != null) form.dispose();
      if (toolkit != null) toolkit.dispose();

    } catch (RuntimeException e) {
      e.printStackTrace();
    }

    super.dispose();
  }
Ejemplo n.º 5
0
  /** Creates the chart below the statistics table */
  private void createChart() {
    mAllocCountDataSet = new DefaultCategoryDataset();
    mChart =
        ChartFactory.createBarChart(
            null,
            "Size",
            "Count",
            mAllocCountDataSet,
            PlotOrientation.VERTICAL,
            false,
            true,
            false);

    // get the font to make a proper title. We need to convert the swt font,
    // into an awt font.
    Font f = mStatisticsBase.getFont();
    FontData[] fData = f.getFontData();

    // event though on Mac OS there could be more than one fontData, we'll only use
    // the first one.
    FontData firstFontData = fData[0];

    java.awt.Font awtFont =
        SWTUtils.toAwtFont(mStatisticsBase.getDisplay(), firstFontData, true /* ensureSameSize */);

    mChart.setTitle(new TextTitle("Allocation count per size", awtFont));

    Plot plot = mChart.getPlot();
    if (plot instanceof CategoryPlot) {
      // get the plot
      CategoryPlot categoryPlot = (CategoryPlot) plot;

      // set the domain axis to draw labels that are displayed even with many values.
      CategoryAxis domainAxis = categoryPlot.getDomainAxis();
      domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);

      CategoryItemRenderer renderer = categoryPlot.getRenderer();
      renderer.setBaseToolTipGenerator(
          new CategoryToolTipGenerator() {
            @Override
            public String generateToolTip(CategoryDataset dataset, int row, int column) {
              // get the key for the size of the allocation
              ByteLong columnKey = (ByteLong) dataset.getColumnKey(column);
              String rowKey = (String) dataset.getRowKey(row);
              Number value = dataset.getValue(rowKey, columnKey);

              return String.format(
                  "%1$d %2$s of %3$d bytes", value.intValue(), rowKey, columnKey.getValue());
            }
          });
    }
    mChartComposite =
        new ChartComposite(
            mStatisticsBase,
            SWT.BORDER,
            mChart,
            ChartComposite.DEFAULT_WIDTH,
            ChartComposite.DEFAULT_HEIGHT,
            ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH,
            ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT,
            3000, // max draw width. We don't want it to zoom, so we put a big number
            3000, // max draw height. We don't want it to zoom, so we put a big number
            true, // off-screen buffer
            true, // properties
            true, // save
            true, // print
            false, // zoom
            true); // tooltips

    mChartComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
  }
 public void refresh(Map<String, List<String[]>> viewData) {
   this.prviewData = viewData;
   initChartData(viewData);
   jfreeChartComp.setChart(computeChart());
   jfreeChartComp.forceRedraw();
 }
 /** create a chart with empty dataset,so as to clear the blocking key chart. */
 public void clearChart() {
   JFreeChart jfreechart =
       createBarChart("Number of rows", new HistogramDataset(), false); // $NON-NLS-1$
   jfreeChartComp.setChart(jfreechart);
   jfreeChartComp.forceRedraw();
 }
Ejemplo n.º 8
0
  @Override
  public void createPartControl(Composite parent) {

    super.createPartControl(parent);

    messages.traceTech("init the form...", getClass());

    toolkit = new FormToolkit(parent.getDisplay());
    parent.setLayout(new FillLayout());
    form = toolkit.createScrolledForm(parent);

    RowLayout layout = new RowLayout(SWT.VERTICAL);
    layout.center = false;
    layout.fill = false;
    layout.pack = true;
    layout.justify = false;
    form.getBody().setLayout(layout);

    form.getBody()
        .addControlListener(
            new ControlListener() {

              @Override
              public void controlResized(ControlEvent e) {
                manageResized();
              }

              @Override
              public void controlMoved(ControlEvent e) {}
            });

    labelIteration = toolkit.createLabel(form.getBody(), "not data displayed yet");
    // TODO separator toolkit.createSeparator(form.getBody(), );
    compositeCharts = toolkit.createComposite(form.getBody());
    compositeCharts.setLayoutData(new RowData());
    compositeCharts.setLayout(new GridLayout(1, false));

    // create the chart

    // create dataset
    dataset = new DefaultCategoryDataset();

    // create plot
    plot = new EnhancedSpiderWebPlot(dataset);
    plot.setMaxValue(1.0);
    plot.setWebFilled(true);
    plot.setInteriorGap(0.2D);
    plot.setBackgroundPaint(Color.WHITE);

    // create chart
    chart = new JFreeChart("1th Pareto front", TextTitle.DEFAULT_FONT, plot, false);
    LegendTitle legendtitle = new LegendTitle(plot);
    legendtitle.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legendtitle);
    chart.getPlot().setBackgroundPaint(Color.white);
    chart.setBackgroundPaint(Color.WHITE);

    // create host composite
    chartComposites =
        new ChartComposite(
            compositeCharts, SWT.NONE, chart, true // use a buffer
            );
    chartComposites.setSize(preferedWidth, preferedHeight);
    chartComposites.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    chartComposites.setBackground(compositeCharts.getBackground());

    // update display
    form.getBody().layout(true);

    form.reflow(true);
  }
Ejemplo n.º 9
0
  public SensorWidget(
      final Composite parent,
      final int style,
      final Measurements<T> totals,
      final Measurements<T>... parts) {
    super(parent, style);

    this.totals = totals;

    setLayout(new GridLayout(1, false));
    setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    TimeTableXYDataset dataset = new TimeTableXYDataset();
    XYBarRenderer renderer = new StackedXYBarRenderer(0.0);
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setDrawBarOutline(false);
    renderer.setShadowVisible(false);

    if (parts == null || parts.length == 0) {
      renderer.setSeriesPaint(0, Color.green);
    }

    XYPlot plot = new XYPlot(dataset, new DateAxis("Time"), new NumberAxis("Count"), renderer);

    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setUpperMargin(0.0);
    plot.getRangeAxis().setLabel(null);
    plot.getDomainAxis().setLabel(null);

    JFreeChart realChart = new JFreeChart(plot);
    realChart.setTitle((String) null);

    chart = new ChartComposite(this, SWT.NONE, realChart, true);
    chart.setLayoutData(new GridData(300, 180));

    final Composite labels = new Composite(this, SWT.NONE);
    labels.setLayout(new GridLayout(5, false));

    final Label totalLabel = new Label(labels, SWT.NONE);
    totalLabel.setText(totals.getName());

    total = new Label(labels, SWT.BOLD);
    final FontData[] fd = total.getFont().getFontData();
    fd[0].setStyle(SWT.BOLD);
    total.setFont(new Font(getDisplay(), fd));
    totalMin = new Label(labels, SWT.NONE);
    totalMax = new Label(labels, SWT.NONE);
    totalAvg = new Label(labels, SWT.NONE);

    if (parts != null && parts.length > 0) {
      for (Measurements<T> part : parts) {
        final Label label = new Label(labels, SWT.NONE);
        label.setText(part.getName());
        final Label valueLabel = new Label(labels, SWT.BOLD);
        valueLabel.setFont(new Font(getDisplay(), fd));
        this.parts.put(
            part.getName(),
            new MeasurementsDisplay<T>(
                part,
                valueLabel,
                new Label(labels, SWT.NONE),
                new Label(labels, SWT.NONE),
                new Label(labels, SWT.NONE)));
      }
    }
  }