public double getWidth(StringBounder stringBounder) { final TextBlock timeHeader = project.getTimeHeader(dayWith); final Row row = getMainRow(); final TextBlock headers = row.header(); return headers.calculateDimension(stringBounder).getWidth() + timeHeader.calculateDimension(stringBounder).getWidth() + 1; }
public void drawU(UGraphic ug) { final double suppY1 = north.calculateDimension(ug.getStringBounder()).getHeight(); ug = ug.apply(new UTranslate(0, suppY1)); ug.apply(new UChangeColor(borderColor)) .apply(getThickness()) .apply(new UChangeBackColor(backColor)) .draw(Diamond.asPolygon(skinParam().shadowing())); // final Dimension2D dimNorth = north.calculateDimension(ug.getStringBounder()); north.drawU(ug.apply(new UTranslate(Diamond.diamondHalfSize * 1.5, -suppY1))); // final Dimension2D dimSouth = south.calculateDimension(ug.getStringBounder()); south.drawU( ug.apply(new UTranslate(Diamond.diamondHalfSize * 1.5, 2 * Diamond.diamondHalfSize))); // south.drawU(ug.apply(new UTranslate(-(dimSouth.getWidth() - 2 * Diamond.diamondHalfSize) / 2, // 2 * Diamond.diamondHalfSize))); final Dimension2D dimWeat1 = west1.calculateDimension(ug.getStringBounder()); west1.drawU( ug.apply( new UTranslate(-dimWeat1.getWidth(), -dimWeat1.getHeight() + Diamond.diamondHalfSize))); final Dimension2D dimEast1 = east1.calculateDimension(ug.getStringBounder()); east1.drawU( ug.apply( new UTranslate( Diamond.diamondHalfSize * 2, -dimEast1.getHeight() + Diamond.diamondHalfSize))); }
public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); final Dimension2D dimLabel = label.calculateDimension(stringBounder); final Dimension2D dimTotal = calculateDimensionAlone(stringBounder); ug = ug.apply(new UChangeColor(borderColor)) .apply(new UStroke(1.5)) .apply(new UChangeBackColor(backColor)); ug.draw(Diamond.asPolygon(shadowing(), dimTotal.getWidth(), dimTotal.getHeight())); north.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight()))); south.drawU(ug.apply(new UTranslate(4 + dimTotal.getWidth() / 2, dimTotal.getHeight()))); final double lx = (dimTotal.getWidth() - dimLabel.getWidth()) / 2; final double ly = (dimTotal.getHeight() - dimLabel.getHeight()) / 2; label.drawU(ug.apply(new UTranslate(lx, ly))); final Dimension2D dimWeat = west.calculateDimension(stringBounder); west.drawU( ug.apply( new UTranslate(-dimWeat.getWidth(), -dimWeat.getHeight() + dimTotal.getHeight() / 2))); final Dimension2D dimEast = east.calculateDimension(stringBounder); east.drawU( ug.apply( new UTranslate(dimTotal.getWidth(), -dimEast.getHeight() + dimTotal.getHeight() / 2))); }
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 void draw(UGraphic ug, double x, double y) { final TextBlock timeHeader = project.getTimeHeader(dayWith); final Row row = getMainRow(); final TextBlock headers = row.header(); final double deltaX = headers.calculateDimension(ug.getStringBounder()).getWidth(); final double deltaY = timeHeader.calculateDimension(ug.getStringBounder()).getHeight(); headers.drawU(ug.apply(new UTranslate(x, (y + deltaY)))); final TextBlock tbRow = row.asTextBloc(project.getTimeConverter(dayWith)); tbRow.drawU(ug.apply(new UTranslate((x + deltaX), (y + deltaY)))); timeHeader.drawU(ug.apply(new UTranslate((x + deltaX), y))); }
public final void drawU(UGraphic ug) { final UEllipse circle = new UEllipse(SIZE, SIZE); if (getSkinParam().shadowing()) { circle.setDeltaShadow(4); } ug = ug.apply( new UChangeBackColor( SkinParamUtils.getColor( getSkinParam(), ColorParam.classBackground, getStereo()))) .apply( new UChangeColor( SkinParamUtils.getColor(getSkinParam(), ColorParam.classBorder, getStereo()))); if (url != null) { ug.startUrl(url); } ug.apply(new UStroke(1.5)).draw(circle); final Dimension2D dimDesc = desc.calculateDimension(ug.getStringBounder()); final double widthDesc = dimDesc.getWidth(); // final double totalWidth = Math.max(widthDesc, SIZE); final double x = SIZE / 2 - widthDesc / 2; final double y = SIZE; desc.drawU(ug.apply(new UTranslate(x, y))); if (url != null) { ug.closeAction(); } }
private Point2D getTextBlockPosition(StringBounder stringBounder) { final Point2D pt1 = worm.get(0); final Point2D pt2 = worm.get(1); final Dimension2D dim = textBlock.calculateDimension(stringBounder); final double y = (pt1.getY() + pt2.getY()) / 2 - dim.getHeight() / 2; return new Point2D.Double(Math.max(pt1.getX(), pt2.getX()) + 4, y); }
@Override public void draw(Graphics2D g2d) { final Dimension2D dimTotal = getDimension(StringBounderUtils.asStringBounder(g2d)); // Shape ellipse = new Ellipse2D.Double(0, 0, dimTotal.getWidth(), // dimTotal.getHeight()); final GeneralPath ellipse = new GeneralPath(); final double h = dimTotal.getHeight(); final double w = dimTotal.getWidth(); ellipse.append(new QuadCurve2D.Double(0, h / 2, 0, 0, w / 2, 0), true); ellipse.append(new QuadCurve2D.Double(w / 2, 0, w, 0, w, h / 2), true); ellipse.append(new QuadCurve2D.Double(w, h / 2, w, h, w / 2, h), true); ellipse.append(new QuadCurve2D.Double(w / 2, h, 0, h, 0, h / 2), true); g2d.setColor(getYellow()); g2d.fill(ellipse); g2d.setColor(getRed()); g2d.draw(ellipse); final Dimension2D nameDim = name.calculateDimension(StringBounderUtils.asStringBounder(g2d)); final double posx = (w - nameDim.getWidth()) / 2; final double posy = (h - nameDim.getHeight()) / 2; final Shape rect = new Rectangle2D.Double(posx, posy, nameDim.getWidth(), nameDim.getHeight()); // g2d.draw(rect); g2d.setColor(Color.BLACK); name.drawTOBEREMOVED(g2d, posx, posy); }
@Override public void draw(ColorMapper colorMapper, Graphics2D g2d) { final Dimension2D dim = textBlock.calculateDimension(StringBounderUtils.asStringBounder(g2d)); final int width = (int) dim.getWidth(); final int height = (int) dim.getHeight(); g2d.setColor(Color.BLACK); g2d.drawRect(0, 0, width, height); // textBlock.drawTOBEREMOVED(colorMapper, g2d, 0, 0); }
private void manage(UGraphic ug, double x, double y, int n, String last, double pendingX) { final double width = n * dayWidth - pendingX; ug.apply(new UTranslate(x + pendingX, y)).draw(new URectangle(width, getHeight())); final TextBlock b = Display.create(last) .create(fontConfig, HorizontalAlignment.LEFT, new SpriteContainerEmpty()); final Dimension2D dimText = b.calculateDimension(ug.getStringBounder()); final double diffX = width - dimText.getWidth(); final double diffY = getHeight() - dimText.getHeight(); b.drawU(ug.apply(new UTranslate((x + pendingX + diffX / 2), (y + diffY / 2)))); }
private void manage(UGraphic ug, double x, double y, int n, String last, double pendingX) { final double width = n * dayWidth - pendingX; ug.draw(x + pendingX, y, new URectangle(width, getHeight())); final TextBlock b = TextBlockUtils.create( Arrays.asList(last), fontConfig, HorizontalAlignement.LEFT, new SpriteContainerEmpty()); final Dimension2D dimText = b.calculateDimension(ug.getStringBounder()); final double diffX = width - dimText.getWidth(); final double diffY = getHeight() - dimText.getHeight(); b.drawU(ug, x + pendingX + diffX / 2, y + diffY / 2); }
@Override public Dimension2D getDimension(StringBounder stringBounder) { final Dimension2D nameDim = name.calculateDimension(stringBounder); // final double eps = Math.sqrt(nameDim.getWidth() / // nameDim.getHeight()); // final double diag = Math.sqrt(nameDim.getWidth() * nameDim.getWidth() // + nameDim.getHeight() // * nameDim.getHeight()); // return new Dimension2DDouble(diag * eps, diag / eps); final double eps = 1.7; return new Dimension2DDouble(nameDim.getWidth() * eps, nameDim.getHeight() * eps); }
public double getMaxX(StringBounder stringBounder) { double result = -Double.MAX_VALUE; for (Point2D pt : worm) { result = Math.max(result, pt.getX()); } if (textBlock != null) { final Point2D position = getTextBlockPosition(stringBounder); final Dimension2D dim = textBlock.calculateDimension(stringBounder); result = Math.max(result, position.getX() + dim.getWidth()); } return result; }
public Dimension2D getDimension(StringBounder stringBounder) { if (dimension == null) { dimension = getDimensionSlow(stringBounder); if (name != null) { final Dimension2D dimName = name.calculateDimension(stringBounder); final double widthName = dimName.getWidth(); if (widthName > dimension.getWidth()) { dimension = new Dimension2DDouble(widthName, dimension.getHeight()); } } } return dimension; }
private FtileGeometry calculateDimensionAlone(StringBounder stringBounder) { final Dimension2D dimLabel = label.calculateDimension(stringBounder); final Dimension2D dim; if (dimLabel.getWidth() == 0 || dimLabel.getHeight() == 0) { dim = new Dimension2DDouble(Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2); } else { dim = Dimension2DDouble.delta( Dimension2DDouble.atLeast( dimLabel, Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2), Diamond.diamondHalfSize * 2, 0); } return new FtileGeometry(dim, dim.getWidth() / 2, 0, dim.getHeight()); }
public void drawLineInternal( final UGraphic ug, Stencil stencil, double y, UStroke defaultStroke) { stencil = addSkip(stencil); final UStroke strokeToUse = style == '\0' ? defaultStroke : getStroke(); final UGraphic ugStroke = ug.apply(strokeToUse); if (title == null) { drawHLine(stencil, y, ugStroke); return; } final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder()); drawHLine(firstHalf(stencil, dimTitle.getWidth()), y, ugStroke); final double startingX = stencil.getStartingX(ug.getStringBounder(), y); final double endingX = stencil.getEndingX(ug.getStringBounder(), y); drawTitleInternal(ug, startingX, endingX, y, false); drawHLine(secondHalf(stencil, dimTitle.getWidth()), y, ugStroke); }
public void drawTitleInternal( UGraphic ug, double startingX, double endingX, double y, boolean clearArea) { if (title == null || blankTitle) { return; } final double widthToUse = endingX - startingX; final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder()); final double space = (widthToUse - dimTitle.getWidth()) / 2; final double x1 = startingX + space; final double y1 = y - dimTitle.getHeight() / 2 - 0.5; ug = ug.apply(new UTranslate(x1, y1)); if (clearArea) { ug.apply(getStroke()).draw(new URectangle(dimTitle)); } title.drawU(ug); }
private double getQualifierMargin( StringBounder stringBounder, UFont fontQualif, String qualif, SpriteContainer spriteContainer) { if (qualif != null) { final TextBlock b = TextBlockUtils.create( Arrays.asList(qualif), new FontConfiguration(fontQualif, HtmlColorUtils.BLACK), HorizontalAlignement.LEFT, spriteContainer); final Dimension2D dim = b.calculateDimension(stringBounder); return Math.max(dim.getWidth(), dim.getHeight()); } return 0; }
@Override protected void drawInternalU(UGraphic ug, Area area) { final TextBlock textBlock = getTextBlock(); final StringBounder stringBounder = ug.getStringBounder(); final Dimension2D dimStickman = stickman.calculateDimension(stringBounder); final double delta = (getPreferredWidth(stringBounder) - dimStickman.getWidth()) / 2; if (head) { textBlock.drawU( ug.apply(new UTranslate(getTextMiddlePostion(stringBounder), dimStickman.getHeight()))); ug = ug.apply(new UTranslate(delta, 0)); } else { textBlock.drawU(ug.apply(new UTranslate(getTextMiddlePostion(stringBounder), 0))); ug = ug.apply(new UTranslate(delta, getTextHeight(stringBounder))); } stickman.drawU(ug); }
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)); } }
private Dimension2D getDimensionSlow(StringBounder stringBounder) { initPlayField(stringBounder); Dimension2D dim; if (playField == null) { dim = name.calculateDimension(stringBounder); } else { try { dim = playField.solve(); // final double frameWidth = // frame.getPreferredWidth(stringBounder); final double frameHeight = frame.getPreferredHeight(stringBounder); dim = Dimension2DDouble.delta(dim, 0, frameHeight); } catch (IOException e) { e.printStackTrace(); throw new RuntimeException(); } catch (InterruptedException e) { e.printStackTrace(); throw new RuntimeException(); } } return dim; // return Dimension2DDouble.delta(dim, margin * 2); }
public double getSouthLabelHeight(StringBounder stringBounder) { final Dimension2D dimSouth = south.calculateDimension(stringBounder); return dimSouth.getHeight(); }
public Dimension2D calculateDimension(StringBounder stringBounder) { final Dimension2D dim = desc.calculateDimension(stringBounder); return Dimension2DDouble.delta(dim, MARGIN * 2); }
public FtileGeometry calculateDimension(StringBounder stringBounder) { final double suppY1 = north.calculateDimension(stringBounder).getHeight(); final Dimension2D dim = new Dimension2DDouble(Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2 + suppY1); return new FtileGeometry(dim, dim.getWidth() / 2, suppY1, dim.getHeight()); }
public double getEastLabelWidth(StringBounder stringBounder) { final Dimension2D dimEast = east1.calculateDimension(stringBounder); return dimEast.getWidth(); }
public Dimension2D getPreferredDimension(StringBounder stringBounder, double x, double y) { if (text.equals("-")) { return new Dimension2DDouble(10, 5); } return block.calculateDimension(stringBounder); }
@Override public double getPreferredHeight(StringBounder stringBounder) { final Dimension2D dimStickman = stickman.calculateDimension(stringBounder); return dimStickman.getHeight() + getTextHeight(stringBounder); }
@Override public double getPreferredWidth(StringBounder stringBounder) { final Dimension2D dimStickman = stickman.calculateDimension(stringBounder); return Math.max(dimStickman.getWidth(), getTextWidth(stringBounder)); }
@Override public Dimension2D getDimension(StringBounder stringBounder) { final Dimension2D dim = textBlock.calculateDimension(stringBounder); return new Dimension2DDouble(dim.getWidth(), dim.getHeight()); }
public Dimension2D getTextDim(StringBounder stringBounder) { final TextBlock bloc = createTextBloc(); return bloc.calculateDimension(stringBounder); }