private boolean isPlannedStartTimeExceeded(
     ProcessProgressModel model, ProcessProgressInstance instance) {
   if (instance == null) {
     return model.getPlannedStartTime().before(new Date(this.now));
   } else {
     return model.getPlannedStartTime().before(instance.getStartTime());
   }
 }
  private boolean isProcessRunningLate(
      ProcessProgressModel model, ProcessProgressInstance instance) {
    boolean runningLate = false;

    long start = instance != null ? instance.getStartTime().getTime() : this.now;
    long end = model.getPlannedTerminationTime().getTime();

    if ((start + model.getEstimatedDuration()) > end) {
      runningLate = true;
    }

    long currentDuration = instance != null ? instance.getDuration() : 0;

    if (currentDuration > model.getEstimatedDuration()) {
      runningLate = true;
    }

    return runningLate;
  }
  private boolean isProcessRunningCritical(
      ProcessProgressModel model, ProcessProgressInstance instance) {

    boolean runningCritcal = false;

    long start = instance != null ? instance.getStartTime().getTime() : this.now;
    long end = model.getPlannedTerminationTime().getTime();

    if (start > end) {
      runningCritcal = true;
    }

    long currentDuration = instance != null ? instance.getDuration() : 0;
    long durationThreshold = model.getEstimatedDuration() / 100;
    durationThreshold = durationThreshold * (100 + model.getThresholdInPercentage());

    if (currentDuration > durationThreshold) {
      runningCritcal = true;
    }

    return runningCritcal;
  }
  public void calculateDiagramBars() {
    long startTime = instance != null ? instance.getStartTime().getTime() : 0;

    // calculate status and color
    this.calculateStatus(model, instance, predecessor);

    if (model.getPlannedStartTime() != null && model.getPlannedTerminationTime() != null) {
      // calculate barWidth
      this.calculateBarWidth(model.getPlannedStartTime(), model.getPlannedTerminationTime());

      // calculate barLeft
      this.calculateBarLeft(model.getPlannedStartTime(), startingPoint);
    }

    // calculate progressLeft
    this.calculateProgressLeft(startTime, startingPoint);

    // calculate progressWidth
    Calendar calculatedStartDate = timeUnit.calculateStartDate(startingPoint);
    this.progressWidth = 0;
    long duration = instance != null ? instance.getDuration() : 0;
    if (instance != null) {
      if (instance.getTerminationTime() != null) {
        this.progressWidth =
            new BigDecimal(new Long(duration).doubleValue())
                .divide(new BigDecimal(1000), BigDecimal.ROUND_HALF_UP)
                .divide(new BigDecimal(60), BigDecimal.ROUND_HALF_UP)
                .intValue();
      } else {
        BigDecimal nowBD =
            new BigDecimal(
                new Long(timeProvider.getCurrentTime() - calculatedStartDate.getTimeInMillis())
                    .doubleValue());
        double nowInTimeUnit =
            nowBD
                .divide(new BigDecimal(1000), 1, BigDecimal.ROUND_HALF_UP)
                .divide(new BigDecimal(60), 1, BigDecimal.ROUND_HALF_UP)
                .doubleValue();
        this.progressWidth = timeUnit.calculateSize(nowInTimeUnit) - getProgressLeft();
      }
    }

    if (model.getEstimatedDuration() != 0) {
      // calculate progress
      this.calculateProgress(duration, model.getEstimatedDuration());
      progressCalculated = true;
    }

    this.calculateIconStatus(instance);

    // calculate durationWidth
    this.durationWidth = new Long(model.getEstimatedDuration()).intValue() / 1000 / 60;

    if (model.getSuccessorId() != null && !"".equals(model.getSuccessorId())) {
      this.dependencyHeight = 0;
      //         this.dependencyWidth = 1;
    }

    // completed process instance
    if (instance != null && instance.getTerminationTime() != null) {
      this.completed = "background-color: #EEEFF7;";
      // this.durationWidth = 0;
      // this.barWidth = 0;
      // this.progressColor = this.color;
    }
  }