public BlockBox copyOf() { BlockBox result = new BlockBox(); result.setStyle(getStyle()); result.setElement(getElement()); return result; }
private static void layoutInlineBlockContent( LayoutContext c, BlockBox containingBlock, BlockBox inlineBlock, int initialY) { inlineBlock.setContainingBlock(containingBlock); inlineBlock.setContainingLayer(c.getLayer()); inlineBlock.initStaticPos(c, containingBlock, initialY); inlineBlock.calcCanvasLocation(); inlineBlock.layout(c); }
public void paint(RenderingContext c, ITextOutputDevice outputDevice, BlockBox box) { Rectangle contentBounds = box.getContentAreaEdge(box.getAbsX(), box.getAbsY(), c); ReplacedElement element = box.getReplacedElement(); outputDevice.drawImage( ((ITextImageElement)element).getImage(), contentBounds.x, contentBounds.y); }
public void calcCanvasLocation() { if (isFloated()) { FloatManager manager = _floatedBoxData.getManager(); Point offset = manager.getOffset(this); setAbsX(manager.getMaster().getAbsX() + getX() - offset.x); setAbsY(manager.getMaster().getAbsY() + getY() - offset.y); LineBox lineBox = getLineBox(); if (lineBox == null) { Box parent = getParent(); if (parent != null) { setAbsX(parent.getAbsX() + parent.getTx() + getX()); setAbsY(parent.getAbsY() + parent.getTy() + getY()); } else if (isStyled() && getStyle().isAbsFixedOrInlineBlockEquiv()) { Box cb = getContainingBlock(); if (cb != null) { setAbsX(cb.getAbsX() + getX()); setAbsY(cb.getAbsY() + getY()); setAbsX(lineBox.getAbsX() + getX()); setAbsY(lineBox.getAbsY() + getY()); if (isReplaced()) { Point location = getReplacedElement().getLocation(); if (location.x != getAbsX() || location.y != getAbsY()) { getReplacedElement().setLocation(getAbsX(), getAbsY());
public int calcInlineBaseline(CssContext c) { if (isReplaced() && getReplacedElement().hasBaseline()) { Rectangle bounds = getContentAreaEdge(getAbsX(), getAbsY(), c); return bounds.y + getReplacedElement().getBaseline() - getAbsY(); } else { LineBox lastLine = findLastLineBox(); if (lastLine == null) { return getHeight(); } else { return lastLine.getAbsY() + lastLine.getBaseline() - getAbsY(); } } }
public SelectFormField(LayoutContext c, BlockBox box, int cssWidth, int cssHeight) { _options = readOptions(box.getElement()); initDimensions(c, box, cssWidth, cssHeight); float fontSize = box.getStyle().getFSFont(c).getSize2D(); // FIXME: findbugs possible loss of precision, cf. int / (float)2 _baseline = (int)(getHeight() / 2 + (fontSize * 0.3f)); }
public void reset(LayoutContext c) { super.reset(c); setTopMarginCalculated(false); setBottomMarginCalculated(false); setDimensionsCalculated(false); setMinMaxCalculated(false); setChildrenHeight(0); if (isReplaced()) { getReplacedElement().detach(c); setReplacedElement(null); } if (getChildrenContentType() == BlockBox.CONTENT_INLINE) { removeAllChildren(); } if (isFloated()) { _floatedBoxData.getManager().removeFloat(this); _floatedBoxData.getDrawingLayer().removeFloat(this); } if (getStyle().isRunning()) { c.getRootLayer().removeRunningBlock(this); } }
public void layout() { LayoutContext c = newLayoutContext(); BlockBox root = BoxBuilder.createRootBox(c, _doc); root.setContainingBlock(new ViewportBox(getInitialExtents(c))); root.layout(c); Dimension dim = root.getLayer().getPaintingDimension(c); root.getLayer().trimEmptyPages(c, dim.height); root.getLayer().layoutPages(c); _root = root; }
c.setCurrentMarkerData(null); block.setContainingBlock(currentLine.getParent()); block.setContainingLayer(currentLine.getContainingLayer()); block.setStaticEquivalent(currentLine); block.setY(currentLine.getY() + block.getFloatedBoxData().getMarginFromSibling()); } else { block.setY(currentLine.getY() + currentLine.getHeight()); block.calcInitialFloatedCanvasLocation(c); int initialY = block.getY(); block.layout(c); (pendingFloats.size() > 0 || block.getWidth() > avail) && currentLine.isContainsContent()) { block.reset(c); result.setPending(true); } else { if (c.isPrint()) { positionFloatOnPage(c, currentLine, block, initialY != block.getY()); c.getRootLayer().ensureHasPage(c, block);
private void calcExtraPageClearance(LayoutContext c) { if (c.isPageBreaksAllowed() && c.getExtraSpaceTop() > 0 && (getStyle().isSpecifiedAsBlock() || getStyle().isListItem())) { PageBox first = c.getRootLayer().getFirstPage(c, this); if (first != null && first.getTop() + c.getExtraSpaceTop() > getAbsY()) { int diff = first.getTop() + c.getExtraSpaceTop() - getAbsY(); setY(getY() + diff); c.translate(0, diff); calcCanvasLocation(); } } }
public void exportText(Writer writer) throws IOException { RenderingContext c = newRenderingContext(); c.setPageCount(_root.getLayer().getPages().size()); _root.exportText(c, writer); }
private static void layoutBlockChild0(LayoutContext c, BlockBox parent, BlockBox child, boolean needPageClear, int childOffset, int trimmedPageCount) { child.setNeedPageClear(needPageClear); child.initStaticPos(c, parent, childOffset); child.initContainingLayer(c); child.calcCanvasLocation(); c.translate(0, childOffset); repositionBox(c, child, trimmedPageCount); child.layout(c); c.translate(-child.getX(), -child.getY()); }
private int calcDelta(CssContext cssCtx, LineBox line, BoxDistance boxDistance) { BlockBox floated = boxDistance.getBox(); Rectangle rect = floated.getBorderEdge(floated.getAbsX(), floated.getAbsY(), cssCtx); int bottom = rect.y + rect.height; return bottom - line.getAbsY(); }
_rootBox.reset(_layout_context); } else { _rootBox = BoxBuilder.createRootBox(_layout_context, _doc); _rootBox.setContainingBlock(new ViewportBox(getInitialExtents(_layout_context))); _rootBox.layout(_layout_context); Layer rootLayer = _rootBox.getLayer(); _hasFixedContent = rootLayer.containsFixedContent();
private void layout(int width) { Rectangle rect = new Rectangle(0, 0, width, DEFAULT_HEIGHT); sharedContext.set_TempCanvas(rect); BlockBox root = BoxBuilder.createRootBox(layoutContext, doc); root.setContainingBlock(new ViewportBox(rect)); root.layout(layoutContext); this.root = root; }
@Override public void paint(RenderingContext renderingContext, ITextOutputDevice outputDevice, BlockBox blockBox) { PdfContentByte cb = outputDevice.getWriter().getDirectContent(); float width = (float) (cssWidth / outputDevice.getDotsPerPoint()); float height = (float) (cssHeight / outputDevice.getDotsPerPoint()); PdfTemplate template = cb.createTemplate(width, height); Graphics2D g2d = template.createGraphics(width, height); PrintTranscoder prm = new PrintTranscoder(); TranscoderInput ti = new TranscoderInput(svg); prm.transcode(ti, null); PageFormat pg = new PageFormat(); Paper pp = new Paper(); pp.setSize(width, height); pp.setImageableArea(0, 0, width, height); pg.setPaper(pp); prm.print(g2d, pg, 0); g2d.dispose(); PageBox page = renderingContext.getPage(); float x = blockBox.getAbsX() + page.getMarginBorderPadding(renderingContext, CalculatedStyle.LEFT); float y = (page.getBottom() - (blockBox.getAbsY() + cssHeight)) + page.getMarginBorderPadding( renderingContext, CalculatedStyle.BOTTOM); x /= outputDevice.getDotsPerPoint(); y /= outputDevice.getDotsPerPoint(); cb.addTemplate(template, x, y); }
public static void layoutAbsolute( LayoutContext c, LineBox currentLine, BlockBox box) { MarkerData markerData = c.getCurrentMarkerData(); c.setCurrentMarkerData(null); if (box.getStyle().isFixed()) { box.setContainingBlock(c.getRootLayer().getMaster().getContainingBlock()); } else { box.setContainingBlock(c.getLayer().getMaster()); } box.setStaticEquivalent(currentLine); // If printing, don't layout until we know where its going if (! c.isPrint()) { box.layout(c); } else { c.pushLayer(box); c.getLayer().setRequiresLayout(true); c.popLayer(); } c.setCurrentMarkerData(markerData); }
BlockBox root = renderer.getRootBox(); List pageList = root.getLayer().getPages() PageBox page = (PageBox)pageList.get(2); List childBoxList = page.getChildren(); Box childBox = (Box)childBoxList.get(0); // etc... until you locate your table
UserAgentCallback userAgentCallback, int cssWidth, int cssHeight) { Element element = blockBox.getElement(); if (element == null) { return null;