/** Creates the chart panel, puts it on display. */
  public void resetChartPanel() {

    // this is the new "insert" - elastic boundaries chart panel
    //
    paintTheChart(this.chartData.getOriginalTimeseries());

    ChartPanel chartPanel = new ChartPanel(this.chart);

    chartPanel.setMinimumDrawWidth(0);
    chartPanel.setMinimumDrawHeight(0);
    chartPanel.setMaximumDrawWidth(1920);
    chartPanel.setMaximumDrawHeight(1200);

    chartPanel.setMouseWheelEnabled(true);

    // cleanup all the content
    //
    this.removeAll();

    // put the chart on show
    //
    this.add(chartPanel);

    // not sure if I need this
    //
    validate();
    repaint();
  }
 public static JPanel createDemoPanel() {
   JFreeChart jfreechart = createChart("Axis Offsets: 0", createDataset());
   CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
   categoryplot.setAxisOffset(RectangleInsets.ZERO_INSETS);
   ChartPanel chartpanel = new ChartPanel(jfreechart);
   chartpanel.setMinimumDrawWidth(0);
   chartpanel.setMinimumDrawHeight(0);
   JFreeChart jfreechart1 = createChart("Axis Offsets: 5", createDataset());
   ChartPanel chartpanel1 = new ChartPanel(jfreechart1);
   chartpanel1.setMinimumDrawWidth(0);
   chartpanel1.setMinimumDrawHeight(0);
   CategoryPlot categoryplot1 = (CategoryPlot) jfreechart1.getPlot();
   categoryplot1.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
   DemoPanel demopanel = new DemoPanel(new GridLayout(2, 1));
   demopanel.add(chartpanel);
   demopanel.add(chartpanel1);
   demopanel.addChart(jfreechart);
   demopanel.addChart(jfreechart1);
   return demopanel;
 }
 /**
  * Plot the timeseries at the panel.
  *
  * @param tsData The time series data.
  */
 public void showTimeSeries(double[] tsData) {
   paintTheChart(tsData);
   ChartPanel chartPanel = new ChartPanel(this.chart);
   chartPanel.setMinimumDrawWidth(0);
   chartPanel.setMinimumDrawHeight(0);
   chartPanel.setMaximumDrawWidth(1920);
   chartPanel.setMaximumDrawHeight(1200);
   this.removeAll();
   this.add(chartPanel);
   validate();
   repaint();
 }
Пример #4
0
 /** Fills the panel with event specific fields. */
 protected void fillPanel() {
   JLabel l;
   Box fdp = Box.createVerticalBox();
   fdp.setBorder(BorderFactory.createTitledBorder("Fundamental Diagram"));
   fdChart = makeFDChart();
   ChartPanel cp = new ChartPanel(fdChart);
   cp.setMinimumDrawWidth(100);
   cp.setMinimumDrawHeight(60);
   cp.setPreferredSize(new Dimension(250, 80));
   fdp.add(new JScrollPane(cp));
   JPanel prmp = new JPanel(new SpringLayout());
   l = new JLabel("Capacity:", JLabel.TRAILING);
   prmp.add(l);
   spinMaxFlow = new JSpinner(new SpinnerNumberModel(mf, 0, 99999, 1.0));
   spinMaxFlow.setEditor(new JSpinner.NumberEditor(spinMaxFlow, "####0.00"));
   spinMaxFlow.addChangeListener(this);
   spinMaxFlow.setName(nmSpinMaxFlow);
   l.setLabelFor(spinMaxFlow);
   prmp.add(spinMaxFlow);
   l = new JLabel("Cap.Drop:", JLabel.TRAILING);
   prmp.add(l);
   spinCapDrop = new JSpinner(new SpinnerNumberModel(drp, 0, 99999, 1.0));
   spinCapDrop.setEditor(new JSpinner.NumberEditor(spinCapDrop, "####0.00"));
   spinCapDrop.addChangeListener(this);
   spinCapDrop.setName(nmSpinCapDrop);
   l.setLabelFor(spinCapDrop);
   prmp.add(spinCapDrop);
   l = new JLabel("C.Density:", JLabel.TRAILING);
   prmp.add(l);
   spinCritDen = new JSpinner(new SpinnerNumberModel(cd, 0, 99999, 1.0));
   spinCritDen.setEditor(new JSpinner.NumberEditor(spinCritDen, "####0.00"));
   spinCritDen.addChangeListener(this);
   spinCritDen.setName(nmSpinCritDen);
   l.setLabelFor(spinCritDen);
   prmp.add(spinCritDen);
   l = new JLabel("  V:", JLabel.TRAILING);
   prmp.add(l);
   spinVff = new JSpinner(new SpinnerNumberModel(mf / cd, 0, 200, 1.0));
   spinVff.setEditor(new JSpinner.NumberEditor(spinVff, "#0.00"));
   spinVff.addChangeListener(this);
   spinVff.setName(nmSpinVff);
   l.setLabelFor(spinVff);
   prmp.add(spinVff);
   l = new JLabel("J.Density:", JLabel.TRAILING);
   prmp.add(l);
   spinJamDen = new JSpinner(new SpinnerNumberModel(jd, 0, 99999, 1.0));
   spinJamDen.setEditor(new JSpinner.NumberEditor(spinJamDen, "####0.00"));
   spinJamDen.addChangeListener(this);
   spinJamDen.setName(nmSpinJamDen);
   l.setLabelFor(spinJamDen);
   prmp.add(spinJamDen);
   l = new JLabel("  W:", JLabel.TRAILING);
   prmp.add(l);
   if (jd == cd) jd = cd + 1;
   int ulim = (int) Math.max(Math.ceil(mf / (jd - cd)), 999);
   spinWc = new JSpinner(new SpinnerNumberModel(mf / (jd - cd), 0, ulim, 1.0));
   spinWc.setEditor(new JSpinner.NumberEditor(spinWc, "#0.00"));
   spinWc.addChangeListener(this);
   spinWc.setName(nmSpinWc);
   l.setLabelFor(spinWc);
   prmp.add(spinWc);
   SpringUtilities.makeCompactGrid(prmp, 3, 4, 2, 2, 2, 2);
   fdp.add(prmp);
   // add(new JScrollPane(fdp));
   add(fdp);
   return;
 }
  private void displayRulesLengthHistogram() {

    // cleanup all the content
    //
    this.removeAll();
    validate();
    repaint();

    // construct the dataset
    //

    // [1.0] extract all the rules
    ArrayList<Integer> allRules = new ArrayList<Integer>();
    for (GrammarRuleRecord r : chartData.getGrammarRules()) {
      if (0 == r.ruleNumber()) {
        continue;
      }
      for (RuleInterval interval : r.getRuleIntervals()) {
        allRules.add(interval.getLength());
      }
    }

    // [2.0] make data
    Collections.sort(allRules);
    // final int minLength = allRules.get(0);
    final int maxLength = allRules.get(allRules.size() - 1);
    final int numberOfBins = maxLength / this.chartData.getSAXWindowSize() + 1;

    double[] values = new double[allRules.size()];
    for (int i = 0; i < allRules.size(); i++) {
      values[i] = allRules.get(i).doubleValue();
    }

    HistogramDataset dataset = new HistogramDataset();
    dataset.setType(HistogramType.FREQUENCY);

    dataset.addSeries(
        "Frequencies", values, numberOfBins, 0, numberOfBins * this.chartData.getSAXWindowSize());

    String plotTitle = "Rules Length Histogram";
    String xaxis = "Rule length";
    String yaxis = "Counts";

    PlotOrientation orientation = PlotOrientation.VERTICAL;
    boolean show = true;
    boolean toolTips = false;
    boolean urls = false;
    this.chart =
        ChartFactory.createHistogram(
            plotTitle, xaxis, yaxis, dataset, orientation, show, toolTips, urls);
    this.chart.removeLegend();

    NumberAxis myAxis =
        new NumberAxis(this.chart.getXYPlot().getDomainAxis().getLabel()) {

          private static final long serialVersionUID = 5839368758428973857L;

          @Override
          public List<NumberTick> refreshTicks(
              Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) {

            // List<NumberTick> allTicks = super.refreshTicks(g2, state, dataArea, edge);

            List<NumberTick> myTicks = new ArrayList<NumberTick>();

            for (int i = 0; i < numberOfBins; i++) {
              myTicks.add(
                  new NumberTick(
                      TickType.MAJOR,
                      i * chartData.getSAXWindowSize(),
                      String.valueOf(i * chartData.getSAXWindowSize()),
                      TextAnchor.CENTER,
                      TextAnchor.CENTER,
                      0.0d));
              // textAnchor, rotationAnchor, angle));
            }

            // for (Object tick : allTicks) {
            // NumberTick numberTick = (NumberTick) tick;
            //
            // if (TickType.MAJOR.equals(numberTick.getTickType())
            // && (numberTick.getValue() % chartData.getSAXWindowSize() != 0)) {
            // // myTicks.add(new NumberTick(TickType.MINOR, numberTick.getValue(), "", numberTick
            // // .getTextAnchor(), numberTick.getRotationAnchor(), numberTick.getAngle()));
            // continue;
            // }
            // myTicks.add(tick);
            // }
            return myTicks;
          }
        };

    this.chart.getXYPlot().setDomainAxis(myAxis);

    ChartPanel chartPanel = new ChartPanel(this.chart);
    chartPanel.setMinimumDrawWidth(0);
    chartPanel.setMinimumDrawHeight(0);
    chartPanel.setMaximumDrawWidth(1920);
    chartPanel.setMaximumDrawHeight(1200);

    // cleanup all the content
    //
    this.removeAll();

    // put the chart on show
    //
    this.add(chartPanel);

    validate();
    repaint();
  }
  /** Puts rules density on show. */
  private void displayRuleDensity() {

    // this is the new "insert" - elastic boundaries chart panel
    //
    paintTheChart(this.chartData.getOriginalTimeseries());
    ChartPanel chartPanel = new ChartPanel(this.chart);
    chartPanel.setMinimumDrawWidth(0);
    chartPanel.setMinimumDrawHeight(0);
    chartPanel.setMaximumDrawWidth(1920);
    chartPanel.setMaximumDrawHeight(1200);
    //
    this.removeAll();
    //
    this.add(chartPanel);

    // timeseriesPlot.clearDomainMarkers();
    int rulesNum = this.chartData.getRulesNumber();

    // find the rule density value
    int maxObservedCoverage = 0;
    int[] coverageArray = new int[chartData.getOriginalTimeseries().length];

    for (GrammarRuleRecord r : chartData.getGrammarRules()) {
      if (0 == r.ruleNumber()) {
        continue;
      }
      ArrayList<RuleInterval> arrPos = chartData.getRulePositionsByRuleNum(r.ruleNumber());
      for (RuleInterval saxPos : arrPos) {
        int start = saxPos.getStartPos();
        int end = saxPos.getEndPos();
        for (int j = start; j < end; j++) {
          if (CoverageCountStrategy.COUNT == this.session.getCountStrategy()) {
            coverageArray[j] = coverageArray[j] + 1;
          } else if (CoverageCountStrategy.LEVEL == this.session.getCountStrategy()) {
            coverageArray[j] = coverageArray[j] + r.getRuleLevel();
          } else if (CoverageCountStrategy.OCCURRENCE == this.session.getCountStrategy()) {
            coverageArray[j] = coverageArray[j] + r.getOccurrences().size();
          } else if (CoverageCountStrategy.YIELD == this.session.getCountStrategy()) {
            coverageArray[j] = coverageArray[j] + r.getRuleYield();
          } else if (CoverageCountStrategy.PRODUCT == this.session.getCountStrategy()) {
            coverageArray[j] = coverageArray[j] + r.getRuleLevel() * r.getOccurrences().size();
          }
          if (maxObservedCoverage < coverageArray[j]) {
            maxObservedCoverage = coverageArray[j];
          }
        }
      }
    }

    // since we know the maximal coverage value, we can compute the increment for a single coverage
    // interval
    double covIncrement = 1. / (double) maxObservedCoverage;

    for (int i = 0; i < rulesNum; i++) {
      GrammarRuleRecord r = chartData.getRule(i);
      if (0 == r.ruleNumber()) {
        continue;
      }
      ArrayList<RuleInterval> arrPos = chartData.getRulePositionsByRuleNum(i);
      for (RuleInterval saxPos : arrPos) {
        IntervalMarker marker = new IntervalMarker(saxPos.getStartPos(), saxPos.getEndPos());
        marker.setLabelOffsetType(LengthAdjustmentType.EXPAND);
        marker.setPaint(Color.BLUE);

        // marker.setAlpha((float) 0.05);
        if (CoverageCountStrategy.COUNT == this.session.getCountStrategy()) {
          marker.setAlpha((float) covIncrement);
        } else if (CoverageCountStrategy.LEVEL == this.session.getCountStrategy()) {
          marker.setAlpha((float) covIncrement * r.getRuleLevel());
        } else if (CoverageCountStrategy.OCCURRENCE == this.session.getCountStrategy()) {
          marker.setAlpha((float) covIncrement * r.getOccurrences().size());
        } else if (CoverageCountStrategy.YIELD == this.session.getCountStrategy()) {
          marker.setAlpha((float) covIncrement * r.getRuleYield());
        } else if (CoverageCountStrategy.PRODUCT == this.session.getCountStrategy()) {
          marker.setAlpha((float) covIncrement * (r.getRuleLevel() * r.getOccurrences().size()));
        }
        marker.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
        marker.setLabelPaint(Color.green);
        marker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
        marker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
        timeseriesPlot.addDomainMarker(marker, Layer.BACKGROUND);
      }
    }

    // not sure if I need this
    //
    validate();
    repaint();

    // and finally save the coverage curve
    //

    this.saveRuleDensityCurve(coverageArray);
  }
Пример #7
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);
    }
  }