private void crearImagen() {

    XYSeries serie = new XYSeries("Serie");
    Iterator<Double> iterator = ejercicio.getHistoricoSolucion().iterator();
    for (int i = 0; i < ejercicio.getHistoricoSolucion().size(); i++) {
      serie.add(i, iterator.next());
    }

    XYSeriesCollection coleccionSeries = new XYSeriesCollection();
    coleccionSeries.addSeries(serie);

    JFreeChart chart =
        ChartFactory.createXYLineChart(
            "Comportamiento Simulated Annealing",
            "Ciclo",
            "Solucion",
            coleccionSeries,
            PlotOrientation.VERTICAL,
            false,
            false,
            true);

    ChartPanel panel = new ChartPanel(chart);
    panel.setMouseZoomable(true);
    this.add(panel);
  }
  /**
   * DOCUMENT ME!
   *
   * @throws IllegalStateException DOCUMENT ME!
   */
  private void init() {
    final String json = (String) cidsBean.getProperty("uri"); // NOI18N
    final ObjectMapper mapper = new ObjectMapper();
    final IDFCurve curve;
    try {
      curve = mapper.readValue(new StringReader(json), IDFCurve.class);
    } catch (IOException ex) {
      final String message = "cannot read idf data from uri"; // NOI18N
      LOG.error(message, ex);
      throw new IllegalStateException(message, ex);
    }

    // Create Chart
    final XYDataset dataset = createDataset(curve);
    final String name = (String) cidsBean.getProperty("name"); // NOI18N
    final String xAxisTitle = "Duration (min)";
    final String yAxisTitle = "Intensity (mm/h)";

    final JFreeChart chart = createChart(dataset, name, xAxisTitle, yAxisTitle);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setMouseZoomable(true, true);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setPopupMenu(null);
    pnlChart.add(chartPanel, BorderLayout.CENTER);
  }
Beispiel #3
0
 public PeriodAxisDemo2(String s) {
   super(s);
   XYDataset xydataset = createDataset();
   JFreeChart jfreechart = createChart(xydataset);
   ChartPanel chartpanel = new ChartPanel(jfreechart);
   chartpanel.setPreferredSize(new Dimension(500, 270));
   chartpanel.setMouseZoomable(true, true);
   setContentPane(chartpanel);
 }
Beispiel #4
0
  protected void initialize() {
    setLayout(new GridLayout(1, 1));
    seriescollection = new XYSeriesCollection();
    JFreeChart chart = createDaySeriesChartWithColors(null, seriescollection, true);
    ChartPanel chartpanel = new ChartPanel(chart, false);
    chartpanel.setMouseZoomable(true, false);

    add(chartpanel);
  }
Beispiel #5
0
  protected void initialize() {
    setLayout(new GridLayout(1, 1));
    setBorder(BorderFactory.createTitledBorder("Advertiser Profit"));
    setBackground(TACAAViewerConstants.CHART_BACKGROUND);

    XYSeriesCollection seriescollection = new XYSeriesCollection();
    series = new XYSeries(advertiser);
    seriescollection.addSeries(series);

    JFreeChart chart = createDaySeriesChartWithColor(null, seriescollection, legendColor);
    ChartPanel chartpanel = new ChartPanel(chart, false);
    chartpanel.setMouseZoomable(true, false);

    add(chartpanel);
  }
  private void createUI() {

    final XYPlot plot = getPlot();
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    plot.setNoDataMessage(NO_DATA_MESSAGE);
    int confidenceDSIndex = 0;
    int regressionDSIndex = 1;
    int scatterpointsDSIndex = 2;
    plot.setDataset(confidenceDSIndex, acceptableDeviationDataset);
    plot.setDataset(regressionDSIndex, regressionDataset);
    plot.setDataset(scatterpointsDSIndex, scatterpointsDataset);

    plot.addAnnotation(r2Annotation);

    final DeviationRenderer identityRenderer = new DeviationRenderer(true, false);
    identityRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT);
    identityRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT);
    plot.setRenderer(confidenceDSIndex, identityRenderer);

    final DeviationRenderer regressionRenderer = new DeviationRenderer(true, false);
    regressionRenderer.setSeriesPaint(0, StatisticChartStyling.REGRESSION_DATA_PAINT);
    regressionRenderer.setSeriesFillPaint(0, StatisticChartStyling.REGRESSION_DATA_FILL_PAINT);
    plot.setRenderer(regressionDSIndex, regressionRenderer);

    final XYErrorRenderer scatterPointsRenderer = new XYErrorRenderer();
    scatterPointsRenderer.setDrawXError(true);
    scatterPointsRenderer.setErrorStroke(new BasicStroke(1));
    scatterPointsRenderer.setErrorPaint(StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT);
    scatterPointsRenderer.setSeriesShape(0, StatisticChartStyling.CORRELATIVE_POINT_SHAPE);
    scatterPointsRenderer.setSeriesOutlinePaint(
        0, StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT);
    scatterPointsRenderer.setSeriesFillPaint(0, StatisticChartStyling.CORRELATIVE_POINT_FILL_PAINT);
    scatterPointsRenderer.setSeriesLinesVisible(0, false);
    scatterPointsRenderer.setSeriesShapesVisible(0, true);
    scatterPointsRenderer.setSeriesOutlineStroke(0, new BasicStroke(1.0f));
    scatterPointsRenderer.setSeriesToolTipGenerator(
        0,
        (dataset, series, item) -> {
          final XYIntervalSeriesCollection collection = (XYIntervalSeriesCollection) dataset;
          final Comparable key = collection.getSeriesKey(series);
          final double xValue = collection.getXValue(series, item);
          final double endYValue = collection.getEndYValue(series, item);
          final double yValue = collection.getYValue(series, item);
          return String.format(
              "%s: mean = %6.2f, sigma = %6.2f | %s: value = %6.2f",
              getRasterName(), yValue, endYValue - yValue, key, xValue);
        });
    plot.setRenderer(scatterpointsDSIndex, scatterPointsRenderer);

    final boolean autoRangeIncludesZero = false;
    final boolean xLog = scatterPlotModel.xAxisLogScaled;
    final boolean yLog = scatterPlotModel.yAxisLogScaled;
    plot.setDomainAxis(
        StatisticChartStyling.updateScalingOfAxis(
            xLog, plot.getDomainAxis(), autoRangeIncludesZero));
    plot.setRangeAxis(
        StatisticChartStyling.updateScalingOfAxis(
            yLog, plot.getRangeAxis(), autoRangeIncludesZero));

    createUI(createChartPanel(chart), createInputParameterPanel(), bindingContext);

    plot.getDomainAxis().addChangeListener(domainAxisChangeListener);
    scatterPlotDisplay.setMouseWheelEnabled(true);
    scatterPlotDisplay.setMouseZoomable(true);
  }
  public ChartWindow(String title) {

    this.symbol = title;
    thisp = this;
    // initialize the main layout
    setTitle(title);
    mainpanel = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    mainpanel.setLayout(gbl);

    // build a toolbar
    //		add a plain status bar
    this.statusLine = new JLabel("Done");
    this.getContentPane().add(statusLine, BorderLayout.SOUTH);

    statusLine.setBackground(new Color(0, 0, 0));
    statusLine.setForeground(new Color(255, 255, 255));
    statusLine.setOpaque(true);

    //
    x1 = new TimeSeries("symbol", FixedMillisecond.class);
    dataset1.addSeries(x1);

    System.out.println("Populated.");

    //
    chart = createChart(dataset1);
    System.out.println("constr.");

    // chart.getXYPlot().setOrientation(PlotOrientation.VERTICAL);

    chart.setAntiAlias(false);

    chartPanel = new ChartPanel(chart);

    //

    int i = 0;
    gbc.anchor = gbc.NORTHWEST;
    gbc.fill = gbc.BOTH;
    gbc.weightx = 1;
    gbc.gridx = 0;

    gbc.weighty = 1;
    gbc.gridy = i;
    gbl.setConstraints(chartPanel, gbc);

    mainpanel.add(chartPanel);
    // System.out.println("add");
    setVisible(true);
    setSize(new Dimension(400, 300));

    // chartPanel.setPopupMenu(buildPopupMenu());
    chartPanel.setMouseZoomable(true);
    chartPanel.setHorizontalAxisTrace(true);
    chartPanel.setVerticalAxisTrace(true);
    chartPanel.setHorizontalZoom(true);

    chartPanel.setOpaque(true);
    chartPanel.setBackground(new Color(0, 0, 0));

    this.getContentPane().add(mainpanel, BorderLayout.CENTER);

    this.setSize(600, 400);
    this.toFront();
    this.show();
  }
Beispiel #8
0
  private void initGUI() {
    try {

      this.setOrientation(SWT.VERTICAL);

      this.setBackground(MainGui.cHART_DARKER);
      Color innerBgColor = MainGui.cHART_LIGHT;

      this.addDisposeListener(
          new DisposeListener() {

            public void widgetDisposed(DisposeEvent evt) {
              rootShellClosed(evt);
            }
          });

      this.addListener(
          SWT.Hide,
          new Listener() {

            @Override
            public void handleEvent(Event event) {
              ChartsComposite.this.shutDownDisplay();
            }
          });

      {
        try {
          // Set cross-platform Java L&F (also called "Metal")
          UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        } catch (UnsupportedLookAndFeelException e) {
          LOGGER.error(e);
        } catch (ClassNotFoundException e) {
          LOGGER.error(e);
        } catch (InstantiationException e) {
          LOGGER.error(e);
        } catch (IllegalAccessException e) {
          LOGGER.error(e);
        }

        mainChartComposite = new Composite(this, SWT.EMBEDDED | SWT.NO_BACKGROUND);
        final Frame chartFrame = SWT_AWT.new_Frame(mainChartComposite);
        final Panel rootHeavyPanel = new Panel();
        rootHeavyPanel.setLayout(new BorderLayout());
        chartFrame.add(rootHeavyPanel);

        mainChartWraper =
            new ChartMain(ChartsComposite.DEFAULT_START_DATE, JFreeChartTimePeriod.DAY);
        mainChartPanel =
            new ChartPanel(
                mainChartWraper.initChart(stripedCloseFunction), true, true, true, false, true) {
              private static final long serialVersionUID = 1L;

              @Override
              public void restoreAutoBounds() {
                // Do nothing (disable mouse left drag zoom)
              }
            };
        mainChartPanel.setMouseZoomable(false, false);
        mainChartPanel.setMinimumDrawWidth(0);
        mainChartPanel.setMinimumDrawHeight(0);
        mainChartPanel.setMaximumDrawWidth(Display.getCurrent().getClientArea().width);
        mainChartPanel.setMaximumDrawHeight(Display.getCurrent().getClientArea().height);

        mainChartPanel.getPopupMenu().addSeparator();
        JMenuItem deleteVLines = new JMenuItem("Remove vertical lines");
        deleteVLines.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                chartDisplayStrategy.removeVLines();
              }
            });
        mainChartPanel.getPopupMenu().add(deleteVLines);
        JMenuItem deleteHLines = new JMenuItem("Remove horizontal lines");
        deleteHLines.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                chartDisplayStrategy.removeHLines();
              }
            });
        mainChartPanel.getPopupMenu().add(deleteHLines);

        mainChartPanel.getPopupMenu().addSeparator();
        JMenuItem lookAndFeelInfoItem = new JMenuItem("Look and feel Info");
        lookAndFeelInfoItem.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                LOGGER.info(UIManager.getLookAndFeel());
              }
            });
        mainChartPanel.getPopupMenu().add(lookAndFeelInfoItem);

        mainChartPanel.addMouseListener(
            new ClickListener() {

              @Override
              public void singleClick(final MouseEvent event) {

                Display.getDefault()
                    .asyncExec(
                        new Runnable() {

                          @Override
                          public void run() {
                            Boolean isSlidingArea =
                                getMainChartWraper()
                                    .isSlidingArea(
                                        mainChartComposite.getSize().y, event.getPoint().y);
                            if (isSlidingArea) return;

                            int button = event.getButton();
                            if (button == MouseEvent.BUTTON1) {
                              Point2D clickPoint =
                                  mainChartPanel.translateScreenToJava2D(event.getPoint());
                              Rectangle2D plotArea = mainChartPanel.getScreenDataArea();

                              if (plotArea.getMaxY() > clickPoint.getY()
                                  && clickPoint.getY() > plotArea.getY()
                                  && plotArea.getMaxX() > clickPoint.getX()
                                  && clickPoint.getX() > plotArea.getX()) {
                                chartDisplayStrategy.addVLineAt(clickPoint, plotArea);
                              }
                            }
                          }
                        });
              }

              @Override
              public void doubleClick(final MouseEvent event) {

                Display.getDefault()
                    .asyncExec(
                        new Runnable() {

                          @Override
                          public void run() {
                            Boolean isSlidingArea =
                                getMainChartWraper()
                                    .isSlidingArea(
                                        mainChartComposite.getSize().y, event.getPoint().y);
                            if (isSlidingArea) return;

                            int button = event.getButton();
                            if (button == MouseEvent.BUTTON1) {
                              Point2D clickPoint = getPointCoordinates(event.getPoint());
                              Rectangle2D plotArea = mainChartPanel.getScreenDataArea();

                              if (plotArea.getMaxY() > clickPoint.getY()
                                  && clickPoint.getY() > plotArea.getY()
                                  && plotArea.getMaxX() > clickPoint.getX()
                                  && clickPoint.getX() > plotArea.getX()) {
                                chartDisplayStrategy.removeVLineAt(clickPoint, plotArea);
                                chartDisplayStrategy.removeHLineAt(clickPoint, plotArea);
                              }
                            }
                          }
                        });
              }
            });

        // Slider
        chartPanelFocusGain = false;
        mainChartPanel.addMouseListener(
            new MouseAdapter() {

              @Override
              public void mouseEntered(MouseEvent e) {
                chartPanelFocusGain = true;
              }

              @Override
              public void mouseExited(MouseEvent e) {
                chartPanelFocusGain = false;
              }

              @Override
              public void mousePressed(final MouseEvent e) {
                panelClickPosition = e.getPoint();
                Display.getDefault()
                    .asyncExec(
                        new Runnable() {

                          @Override
                          public void run() {
                            Boolean isSlidingArea =
                                getMainChartWraper()
                                    .isSlidingArea(mainChartComposite.getSize().y, e.getPoint().y);
                            if (isSlidingArea) {
                              isInPanelChartSlider = true;
                            } else {
                              isInPanelChartSlider = false;
                            }
                          }
                        });
              }

              @Override
              public void mouseReleased(final MouseEvent e) {
                Display.getDefault()
                    .asyncExec(
                        new Runnable() {

                          @Override
                          public void run() {
                            if (isInPanelChartSlider != null
                                && isInPanelChartSlider
                                && panelClickPosition != null) {
                              int indicChartSlideIncrement =
                                  (int)
                                      ((((double) panelClickPosition.y - e.getPoint().y)
                                              / (double) mainChartComposite.getSize().y)
                                          * 100);
                              chartDisplayStrategy.slideChart(indicChartSlideIncrement);
                            }
                            isInPanelChartSlider = false;
                          }
                        });
              }
            });

        // focus bizz (useful?)
        mainChartPanel.addMouseMotionListener(
            new MouseMotionListener() {

              @Override
              public void mouseMoved(final MouseEvent e) {

                // Sliding
                if (!closeRequested) {
                  Display.getDefault()
                      .asyncExec(
                          new Runnable() {

                            @Override
                            public void run() {

                              if (!closeRequested) {
                                try {
                                  Cursor cursor = ChartsComposite.this.getCursor();
                                  if (cursor == null
                                      || (!cursor.equals(CursorFactory.getCursor(SWT.CURSOR_WAIT))
                                          && !cursor.equals(
                                              CursorFactory.getCursor(SWT.CURSOR_APPSTARTING)))) {
                                    Boolean isSlidingArea =
                                        getMainChartWraper()
                                            .isSlidingArea(
                                                mainChartComposite.getSize().y, e.getPoint().y);
                                    if (isSlidingArea) {
                                      ChartsComposite.this.setCursor(
                                          CursorFactory.getCursor(SWT.CURSOR_SIZENS));
                                    } else {
                                      ChartsComposite.this.setCursor(
                                          CursorFactory.getCursor(SWT.CURSOR_ARROW));
                                    }
                                  }

                                } catch (Throwable e) {
                                  try {
                                    ChartsComposite.this.setCursor(
                                        CursorFactory.getCursor(SWT.CURSOR_ARROW));
                                  } catch (Throwable e1) {
                                    LOGGER.warn(e1, e1);
                                  }
                                  LOGGER.warn(e, e);
                                }
                              }
                            }
                          });
                }

                // Gain focus mgt
                if (!closeRequested) {
                  Display.getDefault()
                      .asyncExec(
                          new Runnable() {
                            public void run() {
                              try {
                                if (!closeRequested) {
                                  if (!mainChartComposite.isDisposed()
                                      && !mainChartComposite.isFocusControl()) {
                                    int cpt = 0;
                                    while (chartPanelFocusGain && cpt < 200) {
                                      Thread.sleep(10);
                                      cpt++;
                                    }
                                    if (chartPanelFocusGain && !mainChartComposite.isDisposed()) {
                                      mainChartComposite.forceFocus();
                                    }
                                  }
                                }
                              } catch (Throwable e) {
                                LOGGER.warn(e, e);
                              }
                            }
                          });
                }
              }

              @Override
              public void mouseDragged(MouseEvent e) {
                // Nothing
              }
            });

        mainChartComposite.addKeyListener(
            new org.eclipse.swt.events.KeyListener() {

              @Override
              public void keyReleased(org.eclipse.swt.events.KeyEvent e) {
                if (((e.stateMask & SWT.CTRL) == SWT.CTRL)
                    && ((e.stateMask & SWT.ALT) == SWT.ALT)
                    && (e.keyCode == 'p')) {
                  try {
                    chartDisplayStrategy.exportBarChartPng();
                  } catch (InvalidParameterException exception) {
                    chartDisplayStrategy.showPopupDialog(exception.getMessage(), "Ok", null, null);
                  }
                }
                if (e.keyCode == SWT.ARROW_UP) {
                  chartDisplayStrategy.slideChart(+1);
                }
                if (e.keyCode == SWT.ARROW_DOWN) {
                  chartDisplayStrategy.slideChart(-1);
                }
              }

              @Override
              public void keyPressed(org.eclipse.swt.events.KeyEvent e) {
                //
              }
            });

        mainChartComposite.addMouseTrackListener(
            new MouseTrackListener() {

              @Override
              public void mouseHover(org.eclipse.swt.events.MouseEvent e) {}

              @Override
              public void mouseExit(org.eclipse.swt.events.MouseEvent e) {}

              @Override
              public void mouseEnter(org.eclipse.swt.events.MouseEvent e) {
                mainChartPanel.requestFocusInWindow();
              }
            });

        rootHeavyPanel.add(mainChartPanel);
        chartFrame.pack();
        chartFrame.setVisible(true);
      }
      {
        chartBoutonsGroup = new Group(this, SWT.NONE);
        chartBoutonsGroup.setBackground(innerBgColor);
        GridLayout portfolioBoutonsGroupLayout = new GridLayout();
        portfolioBoutonsGroupLayout.numColumns = 1;
        portfolioBoutonsGroupLayout.verticalSpacing = 0;
        portfolioBoutonsGroupLayout.marginHeight = 0;
        chartBoutonsGroup.setLayout(portfolioBoutonsGroupLayout);
        GridData portfolioInfosGroupData = new GridData(GridData.FILL_HORIZONTAL);
        chartBoutonsGroup.setLayoutData(portfolioInfosGroupData);

        chartBoutonsGroup.setText("Portfolios charting : ");
        chartBoutonsGroup.setFont(MainGui.DEFAULTFONT);
        chartBoutonsGroup.setBackground(innerBgColor);

        {
          popusGroup = new Group(chartBoutonsGroup, SWT.NONE);
          GridData popusGroupData = new GridData(SWT.FILL, SWT.FILL, true, false);
          popusGroup.setLayoutData(popusGroupData);
          popusGroup.setBackground(innerBgColor);
          RowLayout popusGroupL = new RowLayout(SWT.HORIZONTAL);
          popusGroupL.justify = true;
          popusGroupL.fill = true;
          popusGroupL.wrap = false;
          popusGroupL.marginHeight = 0;
          popusGroup.setLayout(popusGroupL);
        }

        // Sliding
        {
          slidingGroup = new Group(chartBoutonsGroup, SWT.NONE);
          GridData slidingGroupData = new GridData(SWT.FILL, SWT.FILL, true, false);
          slidingGroup.setLayoutData(slidingGroupData);
          slidingGroup.setBackground(innerBgColor);
          GridLayout slidingGroupL = new GridLayout();
          slidingGroupL.numColumns = 5;
          slidingGroupL.marginHeight = 0;
          slidingGroupL.verticalSpacing = 0;
          slidingGroup.setLayout(slidingGroupL);
          /// start
          {
            startDateLabel = new Label(slidingGroup, SWT.NONE);
            GridData startOneYearBackData = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
            startOneYearBackData.horizontalSpan = 2;
            startDateLabel.setLayoutData(startOneYearBackData);
            startDateLabel.setText(
                DateFormat.getDateInstance(DateFormat.MEDIUM).format(slidingStartDate) + "");
            startDateLabel.setBackground(innerBgColor);
            startDateLabel.setFont(MainGui.DEFAULTFONT);
          }
          /// sliding sliders
          Composite slidingSliderGroup = new Composite(slidingGroup, SWT.NONE);
          slidingSliderGroup.setSize(1000, SWT.DEFAULT);
          GridData slidersGridData = new GridData(SWT.FILL, SWT.FILL, true, true);
          slidersGridData.verticalSpan = 2;
          slidingSliderGroup.setLayoutData(slidersGridData);
          slidingSliderGroup.setBackground(innerBgColor);
          slidingSliderGroup.setForeground(innerBgColor);
          FillLayout slidingSliderGroupL = new FillLayout(SWT.VERTICAL);
          slidingSliderGroup.setLayout(slidingSliderGroupL);
          {
            sliderStartDate = new Slider(slidingSliderGroup, SWT.HORIZONTAL);
            sliderStartDate.setThumb(1);
            sliderStartDate.setMaximum(100);
            sliderStartDate.addListener(
                SWT.MouseExit,
                new Listener() {

                  public void handleEvent(Event arg0) {
                    sliderChangesApply();
                  }
                });
          }
          {
            sliderEndDate = new Slider(slidingSliderGroup, SWT.HORIZONTAL);
            sliderEndDate.setThumb(1);
            sliderEndDate.setMinimum(0);
            sliderEndDate.setSelection(100);
            sliderEndDate.addListener(
                SWT.MouseExit,
                new Listener() {

                  public void handleEvent(Event arg0) {
                    sliderChangesApply();
                  }
                });
          }
          // end
          {
            endDateLabel = new Label(slidingGroup, SWT.NONE);
            GridData endOneYearBackData = new GridData(SWT.END, SWT.FILL, false, false);
            endOneYearBackData.horizontalSpan = 2;
            endDateLabel.setLayoutData(endOneYearBackData);
            endDateLabel.setText(
                DateFormat.getDateInstance(DateFormat.MEDIUM).format(slidingEndDate));
            endDateLabel.setBackground(innerBgColor);
            endDateLabel.setFont(MainGui.DEFAULTFONT);
          }

          // but start
          {
            Button startOneYearBack = new Button(slidingGroup, SWT.ARROW | SWT.LEFT);
            GridData startOneYearBackData = new GridData(SWT.END, SWT.FILL, false, true);
            startOneYearBack.setLayoutData(startOneYearBackData);
            startOneYearBack.setToolTipText("Move start date one year backward.");
            startOneYearBack.addSelectionListener(
                new SelectionListener() {

                  @Override
                  public void widgetSelected(SelectionEvent e) {
                    handle();
                  }

                  private void handle() {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(slidingStartDate);
                    calendar.add(Calendar.YEAR, -1);
                    firstStartDate = calendar.getTime();
                    sliderStartDate.setSelection(0);
                    startSliderUpdateConditional(
                        sliderStartDate, startDateLabel, sliderEndDate, endDateLabel);
                  }

                  @Override
                  public void widgetDefaultSelected(SelectionEvent e) {
                    handle();
                  }
                });
            startOneYearBack.addListener(
                SWT.MouseExit,
                new Listener() {

                  @Override
                  public void handleEvent(Event event) {
                    sliderChangesApply();
                  }
                });
          }

          {
            Button startOneYearForward = new Button(slidingGroup, SWT.ARROW | SWT.RIGHT);
            GridData startOneYearBackData = new GridData(SWT.BEGINNING, SWT.FILL, false, true);
            startOneYearForward.setLayoutData(startOneYearBackData);
            startOneYearForward.setToolTipText("Move start date one year forward.");
            startOneYearForward.addSelectionListener(
                new SelectionListener() {

                  @Override
                  public void widgetSelected(SelectionEvent e) {
                    handle();
                  }

                  private void handle() {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(slidingStartDate);
                    calendar.add(Calendar.YEAR, +1);
                    if (calendar.getTime().before(slidingEndDate)) {
                      firstStartDate = calendar.getTime();
                      sliderStartDate.setSelection(0);
                      startSliderUpdateConditional(
                          sliderStartDate, startDateLabel, sliderEndDate, endDateLabel);
                    } else {
                      chartDisplayStrategy.showPopupDialog(
                          "To move the start date further forward, you will need to move the end date first.",
                          "Ok",
                          null,
                          null);
                    }
                  }

                  @Override
                  public void widgetDefaultSelected(SelectionEvent e) {
                    handle();
                  }
                });
            startOneYearForward.addListener(
                SWT.MouseExit,
                new Listener() {

                  @Override
                  public void handleEvent(Event event) {
                    sliderChangesApply();
                  }
                });
          }
          /// but end

          {
            Button endOneYearBack = new Button(slidingGroup, SWT.ARROW | SWT.LEFT);
            GridData endOneYearBackData = new GridData(SWT.END, SWT.FILL, false, true);
            endOneYearBack.setLayoutData(endOneYearBackData);
            endOneYearBack.setToolTipText("Move end date one year backward.");
            endOneYearBack.addSelectionListener(
                new SelectionListener() {

                  @Override
                  public void widgetSelected(SelectionEvent e) {
                    handle();
                  }

                  private void handle() {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(slidingEndDate);
                    calendar.add(Calendar.YEAR, -1);
                    if (calendar.getTime().after(slidingStartDate)) {
                      lastEndDate = calendar.getTime();
                      sliderEndDate.setSelection(100);
                      endSliderUpdateConditional(
                          sliderEndDate, endDateLabel, sliderStartDate, startDateLabel);
                    } else {
                      chartDisplayStrategy.showPopupDialog(
                          "To move the end date further backward, you will need to move the start date first.",
                          "Ok",
                          null,
                          null);
                    }
                  }

                  @Override
                  public void widgetDefaultSelected(SelectionEvent e) {
                    handle();
                  }
                });
            endOneYearBack.addListener(
                SWT.MouseExit,
                new Listener() {

                  @Override
                  public void handleEvent(Event event) {
                    sliderChangesApply();
                  }
                });
          }
          {
            Button endOneYearForward = new Button(slidingGroup, SWT.ARROW | SWT.RIGHT);
            GridData endOneYearBackData = new GridData(SWT.BEGINNING, SWT.FILL, false, true);
            endOneYearForward.setLayoutData(endOneYearBackData);
            endOneYearForward.setToolTipText("Move end date one year forward.");
            endOneYearForward.addSelectionListener(
                new SelectionListener() {

                  @Override
                  public void widgetSelected(SelectionEvent e) {
                    handle();
                  }

                  private void handle() {
                    Calendar calendar = Calendar.getInstance();
                    calendar.setTime(slidingEndDate);
                    calendar.add(Calendar.YEAR, +1);
                    Date newDate = EventSignalConfig.getNewDate();
                    if (calendar.getTime().after(newDate)) {
                      calendar.setTime(newDate);
                    }
                    lastEndDate = calendar.getTime();
                    sliderEndDate.setSelection(100);
                    endSliderUpdateConditional(
                        sliderEndDate, endDateLabel, sliderStartDate, startDateLabel);
                  }

                  @Override
                  public void widgetDefaultSelected(SelectionEvent e) {
                    handle();
                  }
                });
            endOneYearForward.addListener(
                SWT.MouseExit,
                new Listener() {

                  @Override
                  public void handleEvent(Event event) {
                    sliderChangesApply();
                  }
                });
          }

          sliderStartDate.addListener(
              SWT.Selection,
              new Listener() {
                public void handleEvent(Event event) {
                  startSliderUpdateConditional(
                      sliderStartDate, startDateLabel, sliderEndDate, endDateLabel);
                }
              });

          sliderEndDate.addListener(
              SWT.Selection,
              new Listener() {

                public void handleEvent(Event event) {
                  endSliderUpdateConditional(
                      sliderEndDate, endDateLabel, sliderStartDate, startDateLabel);
                }
              });

          slidingGroup.layout();
        }
      }

      this.layout();
      this.pack();

    } catch (Exception e) {
      LOGGER.error("", e);
    }
  }