예제 #1
0
파일: TimeLine.java 프로젝트: GusevAlex/PPU
  @AfterCompose
  public void doAfterCompose(@ContextParam(ContextType.VIEW) Component view) throws Exception {

    Selectors.wireComponents(view, this, false);

    String id = Executions.getCurrent().getParameter("id");

    if (id != null) {
      Date currentDate = Calendar.getInstance().getTime();
      bandinfoMonth.setDate(currentDate);
      bandinfoYear.setDate(currentDate);

      Project Project = (Project) new WorkWithProject().getEntity(new Integer(id));

      discrName = "Для проекта: " + Project.getName();

      ParseCorrection parseCorrection = new ParseCorrection();
      Object[] o = Project.getCorrectionsProject().toArray();

      CorrectionsProject[] cor = new CorrectionsProject[o.length];

      for (int i = 0; i < o.length; i++) cor[i] = (CorrectionsProject) o[i];

      parseCorrection.getModelByCorrection(cor);

      bandinfoMonth.setModel(parseCorrection.getModelByCorrection(cor));
      bandinfoYear.setModel(parseCorrection.getModelByCorrection(cor));

      setDataInChart();
    }
  }
예제 #2
0
파일: TimeLine.java 프로젝트: GusevAlex/PPU
  private void setDataInChart() {
    Chart chartOptional = chart.getChart();
    chartOptional.setPlotBorderWidth(0);
    chartOptional.setBackgroundColor("");
    chartOptional.setPlotShadow(false);

    chart.getTooltip().setPointFormat("{series.name}: <b>{point.percentage:.1f}%</b>");

    PiePlotOptions plotOptions = chart.getPlotOptions().getPie();
    plotOptions.setAllowPointSelect(true);
    plotOptions.setCursor("pointer");
    plotOptions.getDataLabels().setEnabled(false);
    plotOptions.setShowInLegend(true);

    Series series = chart.getSeries();
    series.setType("pie");
    series.setName("Browser share");

    String id = Executions.getCurrent().getParameter("id");

    if (id != null) {
      long[] pointMas = new long[5];
      Project Project = (Project) new WorkWithProject().getEntity(new Integer(id));

      Integer[] intMas = new Integer[Project.getCorrectionsProject().size()];

      int i = 0;
      for (CorrectionsProject cor : Project.getCorrectionsProject()) intMas[i++] = cor.getId();

      Arrays.sort(intMas);

      long timeLong = 0;
      String nameCor = new String();

      for (int num : intMas) {
        for (CorrectionsProject cor : Project.getCorrectionsProject())
          if (cor.getId() == num) {
            int numIndex = 0;

            if (nameCor.equals("Создается")) numIndex = 0;
            else if (nameCor.equals("Создан")) numIndex = 1;
            else if (nameCor.equals("Планирование")) numIndex = 2;
            else if (nameCor.equals("На согласовании")) numIndex = 3;
            else if (nameCor.equals("Выполняется")) numIndex = 4;

            if (timeLong != 0) pointMas[numIndex] += cor.getCorrectionDate().getTime() - timeLong;

            timeLong = cor.getCorrectionDate().getTime();
            nameCor = cor.getValueAfter();
          }
      }

      {
        long difDate = 0;
        for (CorrectionsProject cor : Project.getCorrectionsProject())
          if (cor.getValueAfter().equals("Выполнено")) {
            difDate = cor.getCorrectionDate().getTime();
          }

        if (!Project.getExpirationDate().after(Calendar.getInstance().getTime()))
          difDate = Calendar.getInstance().getTime().getTime();
        else difDate = Project.getExpirationDate().getTime();

        int numIndex = 0;

        if (nameCor.equals("Создается")) numIndex = 0;
        else if (nameCor.equals("Создан")) numIndex = 1;
        else if (nameCor.equals("Планирование")) numIndex = 2;
        else if (nameCor.equals("На согласовании")) numIndex = 3;
        else if (nameCor.equals("Выполняется")) numIndex = 4;

        if (timeLong != 0) pointMas[numIndex] += difDate - timeLong;
      }

      series.addPoint(new Point("Создается", pointMas[0]));
      series.addPoint(new Point("Создан", pointMas[1]));
      Point point = new Point("Планирование", pointMas[2]);
      point.setSliced(true);
      point.setSelected(true);
      series.addPoint(point);
      series.addPoint(new Point("На согласовании", pointMas[3]));
      series.addPoint(new Point("Выполняется", pointMas[4]));
    }
  }