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; }
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); }
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)); } }
public double getHeight(StringBounder stringBounder) { double height = 0; for (Item it : project.getValidItems()) { final Dimension2D dim = stringBounder.calculateDimension(font, it.getCode()); height += dim.getHeight(); } return height; }
public double getWidth(StringBounder stringBounder) { double width = 0; for (Item it : project.getValidItems()) { final Dimension2D dim = stringBounder.calculateDimension(font, it.getCode()); width = Math.max(width, dim.getWidth()); } return width; }
public double getPosition(StringBounder stringBounder, Item item) { double pos = 0; for (Item it : project.getValidItems()) { if (it == item) { return pos; } final Dimension2D dim = stringBounder.calculateDimension(font, it.getCode()); pos += dim.getHeight(); } throw new IllegalArgumentException(); }
public void draw(UGraphic ug, double x, double y) { final StringBounder stringBounder = ug.getStringBounder(); ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK)); ug.apply(new UTranslate(x, y)) .draw(new URectangle(getWidth(stringBounder), getHeight(stringBounder))); for (Item it : project.getValidItems()) { final TextBlock b = Display.create("" + it.getCode()) .create(fontConfig, HorizontalAlignment.LEFT, new SpriteContainerEmpty()); final Dimension2D dim = b.calculateDimension(stringBounder); b.drawU(ug.apply(new UTranslate(x, y))); y += dim.getHeight(); ug.apply(new UTranslate(x, y)).draw(new ULine(getWidth(stringBounder), 0)); } }