private void drawRuler(final GanttRenderingData data) {
   ruler.draw(
       data.getDurations(),
       data.getGraphics(),
       data.getGraphics().getClipping().x,
       data.getGraphics().getClipping().width);
 }
 private void drawDurations(final GanttRenderingData data, final GanttDraw ganttDrawData) {
   colorByTypeMap.clear();
   for (final IDuration d : data.getDurations()) {
     drawDurationItem(data, d, ganttDrawData);
     if (d.contains(data.getMarker())) {
       data.setMarkerAt(d);
     }
   }
 }
  private IDrawableRuler computeScaler(final GanttRenderingData data) {
    final Rectangle dataScreenArea = getDataArea(data);
    if (data.isLog()) {
      List<Span> spans = new ArrayList<Span>(Span.valueOfDurations(data.getDurations()));

      if (data.getDurations().size() > 0) {
        ITaskDuration first = data.getDurations().get(0);
        ITaskDuration last = data.getDurations().get(data.getDurations().size() - 1);
        Span emptyBefore = Span.valueOf(data.getLogspan().getStart(), first.getStartTime());
        spans.add(0, emptyBefore);

        Span emptyAfter =
            Span.valueOf(last.getStartTime() + last.getDurationTime(), data.getLogspan().getEnd());
        spans.add(emptyAfter);
      }
      return new FixedMidPointRuler(
          dataScreenArea.x, dataScreenArea.width, data.getTransform(), data.getMarker(), spans);

    } else {
      long firstDuration = data.getLogspan().getStart();
      long lastDuration = 0;

      if (data.getMarker() <= 0) {
        lastDuration = (long) (firstDuration + ((TIME_RANGE / data.getZoomLevel()) / 2));
      } else {
        firstDuration = (long) (data.getMarker() - ((TIME_RANGE / data.getZoomLevel()) / 2));
        if (firstDuration < 0) {
          firstDuration = data.getLogspan().getStart();
        }
        lastDuration = (long) (data.getMarker() + ((TIME_RANGE / data.getZoomLevel()) / 2));
      }

      return new SimpleLinearScaleRuler(
          data.getMarker(),
          Span.valueOf(firstDuration, lastDuration),
          Span.valueOf(dataScreenArea.x, dataScreenArea.width));
    }
  }
  @SuppressWarnings("unchecked")
  GanttDraw draw(final GanttRenderingData data, final boolean drawB) {

    // Check pre-conditions JEKB ugly fix data.getDurations() == null
    if ((data.getDurations() == null) || (data.getDurations().size() < 1)) {
      drawEmpty(data);
      return ClassicGantRenderer.EMPTY_GANTT_DRAW;
    }

    Collections.sort(data.getDurations());

    // compute a ruler only when drawB is drawn.
    if (drawB) {
      ruler = computeScaler(data);
    }

    // Graphics Setup
    data.getGraphics().setAntialias(SWT.OFF);
    data.getGraphics().setFont(font);
    final GanttDraw ganttDrawData = new GanttDraw(data.getGraphics(), ruler);
    lanes.clear();
    int laneIndex = 0;
    for (final IArtifact user : data.getTasks()) {
      final TaskLaneEntry entry = new TaskLaneEntry(user);
      entry.setLane(laneIndex++);
      lanes.put(user.getName(), entry);
    }

    drawColumnNames(data, lanes, ganttDrawData);
    drawGrid(data, laneIndex);

    final Rectangle clipping = data.getGraphics().getClipping();
    data.getGraphics()
        .setClipping(
            new Rectangle(
                data.getBounds().x,
                data.getBounds().y,
                data.getBounds().width,
                data.getBounds().height));

    this.typeReg = TypeRegistry.getInstance();

    data.getGraphics().setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));

    data.getGraphics().setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));

    if (drawB) {
      drawDurations(data, ganttDrawData);
      drawMarker(data);
      drawRuler(data);
      LegendRenderer r = new LegendRenderer();
      r.drawLegend(
          data.getGraphics().getClipping().width / 2,
          Graphics.valueOf(data.getGraphics()),
          colorByTypeMap,
          false);
    }

    data.getGraphics().setClipping(clipping);

    data.setDrawnSize(
        new Point(
            data.getBounds().width,
            ClassicGantRenderer.LANE_START + (lanes.size() + 1) * ClassicGantRenderer.LANE_HEIGHT));

    // if (drawB) {
    ganttDrawData.setBounds(SWTUtil.convert(data.getBounds()));
    // } else {
    // }
    return ganttDrawData;
  }