示例#1
0
 public SelectedChart getSelectedChart() {
   return timeChart.getSelectedChart();
 }
示例#2
0
 public void setChart(JFreeChart chart) {
   timeChart.setChart(chart);
   // Force the view to update the chart:
   chart.clearSubtitles();
 }
示例#3
0
 public boolean hasNextChart() {
   return timeChart.hasNextChart();
 }
示例#4
0
 public boolean hasPrevChart() {
   return timeChart.hasPrevChart();
 }
示例#5
0
 public void saveChartAsPNG(File file, int width, int height) throws IOException {
   timeChart.saveChartAsPNG(file, width, height);
 }
示例#6
0
 public void saveChartAsPNG(File file) throws IOException {
   timeChart.saveChartAsJPEG(file, 800, 600);
 }
示例#7
0
 public Integer getSelectedYear() {
   return timeChart.getSelectedYear();
 }
示例#8
0
 public void setYearRange(int start, int end) {
   timeChart.setYearRange(start, end);
 }
示例#9
0
  public TrendChart(Composite parent, int style) {
    super(parent, style);
    initCharts();

    setLayout(new FillLayout());

    SashForm sashForm = new SashForm(this, SWT.VERTICAL);

    timeChart = new TimeChartControlPanel<SelectedChart>(sashForm, SWT.BORDER);
    timeChart.addChartSelectionEntry("Trend View", SelectedChart.LINE);
    timeChart.addChartSelectionEntry("Bar View", SelectedChart.BAR);
    timeChart.addChartSelectionEntry("Both", SelectedChart.BOTH);

    JFreeChart chart = createChart(SelectedChart.LINE);
    setChart(chart);

    scrolledComposite = new ScrolledComposite(sashForm, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    scrolledComposite.setLayout(new FillLayout());

    optionComposite = new Composite(scrolledComposite, SWT.NONE);
    optionComposite.setLayout(new GridLayout(3, false));

    scrolledComposite.setContent(optionComposite);
    scrolledComposite.setMinSize(optionComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setAlwaysShowScrollBars(false);

    // Signals:
    boxListener =
        new SelectionListener() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            Button button = (Button) e.getSource();
            ChartIdentifier boxData = (ChartIdentifier) button.getData();
            assert (boxData != null);

            boolean checked = button.getSelection();

            if (boxData.paint == null) {
              boxData.paint = drawingSupplier.getNextPaint();
            }

            if (checked) {
              java.awt.Color paintColor = (java.awt.Color) boxData.paint;
              Color color =
                  new Color(null, paintColor.getRed(), paintColor.getGreen(), paintColor.getBlue());
              button.setBackground(color);
            } else {
              button.setBackground(null);
            }

            for (TrendChartListener listener : listeners) {
              listener.optionSelected(boxData, checked);
            }
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent e) {}
        };

    comboListener =
        new SelectionListener() {

          @Override
          public void widgetSelected(SelectionEvent e) {
            Combo combo = (Combo) e.getSource();
            DropDownData data = (DropDownData) combo.getData();
            assert (data != null);
            DropDownConfig config = data.getConfig();

            for (TrendChartListener listener : listeners) {
              listener.comboChanged(config);
            }
          }

          @Override
          public void widgetDefaultSelected(SelectionEvent e) {}
        };
  }