Example #1
0
 private int getNbCase() {
   int result = 0;
   final Instant end = project.getEnd();
   for (Instant cur = project.getStart();
       cur.compareTo(end) <= 0;
       cur = cur.next(project.getDayClose())) {
     result++;
   }
   return result;
 }
Example #2
0
 public SortedMap<Instant, Double> getAbscisse(StringBounder stringBounder) {
   final SortedMap<Instant, Double> pos = new TreeMap<Instant, Double>();
   final double caseWidth = getCaseWidth(stringBounder);
   final Instant end = project.getEnd();
   double x = 0;
   for (Instant cur = project.getStart();
       cur.compareTo(end) <= 0;
       cur = cur.next(project.getDayClose())) {
     pos.put(cur, x);
     x += caseWidth;
   }
   return Collections.unmodifiableSortedMap(pos);
 }
Example #3
0
  public void draw(UGraphic ug, final double x, double y) {
    final StringBounder stringBounder = ug.getStringBounder();
    final double monthHeight = getMonthHeight(stringBounder);
    final double caseWidth = getCaseWidth(stringBounder);
    final double caseHeight = getCaseHeight(stringBounder);
    final int nb = getNbCase();

    ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
    ug.apply(new UTranslate(x, y)).draw(new URectangle(nb * caseWidth, monthHeight));
    final Instant end = project.getEnd();

    Month printed = null;

    double curx = x;
    for (Instant cur = project.getStart();
        cur.compareTo(end) <= 0;
        cur = cur.next(project.getDayClose())) {
      final Day d = cur.getDay();
      if (printed == null || d.getMonth() != printed) {
        ug.apply(new UTranslate(curx, y)).draw(new ULine(0, monthHeight));
        printed = d.getMonth();
        final TextBlock b =
            Display.create(printed.name())
                .create(fontConfig, HorizontalAlignment.LEFT, new SpriteContainerEmpty());
        final Dimension2D dim = b.calculateDimension(stringBounder);
        b.drawU(ug.apply(new UTranslate(curx, (y + (monthHeight - dim.getHeight()) / 2))));
      }
      curx += caseWidth;
    }

    curx = x;
    y += monthHeight;
    ug.apply(new UTranslate(x, y)).draw(new URectangle(nb * caseWidth, caseHeight));

    for (Instant cur = project.getStart();
        cur.compareTo(end) <= 0;
        cur = cur.next(project.getDayClose())) {
      final Day d = cur.getDay();
      final TextBlock b =
          Display.create("" + d.getNumDay())
              .create(fontConfig, HorizontalAlignment.LEFT, new SpriteContainerEmpty());
      final Dimension2D dim = b.calculateDimension(stringBounder);
      b.drawU(
          ug.apply(
              new UTranslate(
                  (curx + (caseWidth - dim.getWidth()) / 2),
                  (y + (caseHeight - dim.getHeight()) / 2))));
      curx += caseWidth;
      ug.apply(new UTranslate(curx, y)).draw(new ULine(0, caseHeight));
    }
  }