public Rectangle getBorderEdge(int left, int top, CssContext cssCtx) { RectPropertySet margin = getMargin(cssCtx); Rectangle result = new Rectangle(left + (int) margin.left(), top + (int) margin.top(), getWidth() - (int) margin.left() - (int) margin.right(), getHeight() - (int) margin.top() - (int) margin.bottom()); return result; }
public Rectangle getBorderEdge(int left, int top, CssContext cssCtx) { RectPropertySet margin = getMargin(cssCtx); Rectangle result = new Rectangle(left + (int) margin.left(), top + (int) margin.top(), getWidth() - (int) margin.left() - (int) margin.right(), getHeight() - (int) margin.top() - (int) margin.bottom()); return result; }
private void moveClear(CssContext cssCtx, BlockFormattingContext bfc, Box current, List floats) { if (floats.size() == 0) { return; } // Translate from box coords to BFC coords Point offset = bfc.getOffset(); Rectangle bounds = current.getBorderEdge( current.getX()-offset.x, current.getY()-offset.y, cssCtx); int y = findLowestY(cssCtx, floats); if (bounds.y < y) { // Translate bottom margin edge of lowest float back to box coords // and set the box's border edge to that value bounds.y = y; bounds.translate(offset.x, offset.y); current.setY(bounds.y - (int)current.getMargin(cssCtx).top()); } }
private void moveClear(CssContext cssCtx, BlockFormattingContext bfc, Box current, List floats) { if (floats.size() == 0) { return; } // Translate from box coords to BFC coords Point offset = bfc.getOffset(); Rectangle bounds = current.getBorderEdge( current.getX()-offset.x, current.getY()-offset.y, cssCtx); int y = findLowestY(cssCtx, floats); if (bounds.y < y) { // Translate bottom margin edge of lowest float back to box coords // and set the box's border edge to that value bounds.y = y; bounds.translate(offset.x, offset.y); current.setY(bounds.y - (int)current.getMargin(cssCtx).top()); } }
public Rectangle getPaddingEdge(int left, int top, CssContext cssCtx) { RectPropertySet margin = getMargin(cssCtx); RectPropertySet border = getBorder(cssCtx); Rectangle result = new Rectangle(left + (int) margin.left() + (int) border.left(), top + (int) margin.top() + (int) border.top(), getWidth() - (int) margin.width() - (int) border.width(), getHeight() - (int) margin.height() - (int) border.height()); return result; }
public Rectangle getPaddingEdge(int left, int top, CssContext cssCtx) { RectPropertySet margin = getMargin(cssCtx); RectPropertySet border = getBorder(cssCtx); Rectangle result = new Rectangle(left + (int) margin.left() + (int) border.left(), top + (int) margin.top() + (int) border.top(), getWidth() - (int) margin.width() - (int) border.width(), getHeight() - (int) margin.height() - (int) border.height()); return result; }
/** * Sets the new current document, where the new document is located * relative, e.g using a relative URL. * * @param filename * The new document to load */ protected void setDocumentRelative(String filename) { String url = _sharedContext.getUac().resolveURI(filename); if (isAnchorInCurrentDocument(filename)) { String id = getAnchorId(filename); Box box = _sharedContext.getBoxById(id); if (box != null) { Point pt; if (box.getStyle().isInline()) { pt = new Point(0 /* box.getAbsX() */, box.getAbsY()); } else { RectPropertySet margin = box.getMargin(_layout_context); pt = new Point(0 /* box.getAbsX() + (int) margin.left() */, box.getAbsY() + (int) margin.top()); } setOrigin(pt); return; } } Document dom = loadDocument(url); setDocument(dom, url); }
public Rectangle getContentAreaEdge(int left, int top, CssContext cssCtx) { RectPropertySet margin = getMargin(cssCtx); RectPropertySet border = getBorder(cssCtx); RectPropertySet padding = getPadding(cssCtx); Rectangle result = new Rectangle( left + (int)margin.left() + (int)border.left() + (int)padding.left(), top + (int)margin.top() + (int)border.top() + (int)padding.top(), getWidth() - (int)margin.width() - (int)border.width() - (int)padding.width(), getHeight() - (int) margin.height() - (int) border.height() - (int) padding.height()); return result; }
private PdfDestination createDestination(RenderingContext c, Box box) { PdfDestination result = null; PageBox page = _root.getLayer().getPage(c, getPageRefY(box)); if (page != null) { int distanceFromTop = page.getMarginBorderPadding(c, CalculatedStyle.TOP); distanceFromTop += box.getAbsY() + box.getMargin(c).top() - page.getTop(); result = new PdfDestination(PdfDestination.XYZ, 0, page.getHeight(c) / _dotsPerPoint - distanceFromTop / _dotsPerPoint, 0); result.addPage(_writer.getPageReference(_startPageNo + page.getPageNo() + 1)); } return result; }
public int getMarginBorderPadding(CssContext cssCtx, int which) { BorderPropertySet border = getBorder(cssCtx); RectPropertySet margin = getMargin(cssCtx); RectPropertySet padding = getPadding(cssCtx); switch (which) { case CalculatedStyle.LEFT: return (int)(margin.left() + border.left() + padding.left()); case CalculatedStyle.RIGHT: return (int)(margin.right() + border.right() + padding.right()); case CalculatedStyle.TOP: return (int)(margin.top() + border.top() + padding.top()); case CalculatedStyle.BOTTOM: return (int)(margin.bottom() + border.bottom() + padding.bottom()); default: throw new IllegalArgumentException(); } }
public Rectangle getContentAreaEdge(int left, int top, CssContext cssCtx) { RectPropertySet margin = getMargin(cssCtx); RectPropertySet border = getBorder(cssCtx); RectPropertySet padding = getPadding(cssCtx); Rectangle result = new Rectangle( left + (int)margin.left() + (int)border.left() + (int)padding.left(), top + (int)margin.top() + (int)border.top() + (int)padding.top(), getWidth() - (int)margin.width() - (int)border.width() - (int)padding.width(), getHeight() - (int) margin.height() - (int) border.height() - (int) padding.height()); return result; }
public int getMarginBorderPadding(CssContext cssCtx, int which) { BorderPropertySet border = getBorder(cssCtx); RectPropertySet margin = getMargin(cssCtx); RectPropertySet padding = getPadding(cssCtx); switch (which) { case CalculatedStyle.LEFT: return (int)(margin.left() + border.left() + padding.left()); case CalculatedStyle.RIGHT: return (int)(margin.right() + border.right() + padding.right()); case CalculatedStyle.TOP: return (int)(margin.top() + border.top() + padding.top()); case CalculatedStyle.BOTTOM: return (int)(margin.bottom() + border.bottom() + padding.bottom()); default: throw new IllegalArgumentException(); } }
private PdfDestination createDestination(RenderingContext c, Box box) { PdfDestination result = null; PageBox page = _root.getLayer().getPage(c, getPageRefY(box)); if (page != null) { int distanceFromTop = page.getMarginBorderPadding(c, CalculatedStyle.TOP); distanceFromTop += box.getAbsY() + box.getMargin(c).top() - page.getTop(); result = new PdfDestination(PdfDestination.XYZ, 0, page.getHeight(c) / _dotsPerPoint - distanceFromTop / _dotsPerPoint, 0); result.addPage(_writer.getPageReference(_startPageNo + page.getPageNo() + 1)); } return result; }
private PdfDestination createDestination(RenderingContext c, Box box) { PdfDestination result; PageBox page = _root.getLayer().getPage(c, getPageRefY(box)); int distanceFromTop = page.getMarginBorderPadding(c, CalculatedStyle.TOP); distanceFromTop += box.getAbsY() + box.getMargin(c).top() - page.getTop(); result = new PdfDestination(PdfDestination.XYZ, 0, page.getHeight(c) / _dotsPerPoint - distanceFromTop / _dotsPerPoint, 0); result.addPage(_writer.getPageReference(_startPageNo + page.getPageNo() + 1)); return result; }
private PdfDestination createDestination(RenderingContext c, Box box) { PdfDestination result; PageBox page = _root.getLayer().getPage(c, getPageRefY(box)); int distanceFromTop = page.getMarginBorderPadding(c, CalculatedStyle.TOP); distanceFromTop += box.getAbsY() + box.getMargin(c).top() - page.getTop(); result = new PdfDestination( PdfDestination.XYZ, 0, page.getHeight(c) / _dotsPerPoint - distanceFromTop / _dotsPerPoint, 0); result.addPage(_writer.getPageReference(_startPageNo + page.getPageNo()+1)); return result; }
private PdfDestination createDestination(RenderingContext c, Box box) { PdfDestination result; PageBox page = _root.getLayer().getPage(c, getPageRefY(box)); int distanceFromTop = page.getMarginBorderPadding(c, CalculatedStyle.TOP); distanceFromTop += box.getAbsY() + box.getMargin(c).top() - page.getTop(); result = new PdfDestination( PdfDestination.XYZ, 0, page.getHeight(c) / _dotsPerPoint - distanceFromTop / _dotsPerPoint, 0); result.addPage(_writer.getPageReference(_startPageNo + page.getPageNo()+1)); return result; }
/** * Sets the new current document, where the new document * is located relative, e.g using a relative URL. * * @param filename The new document to load */ protected void setDocumentRelative(String filename) { String url = getSharedContext().getUac().resolveURI(filename); if (isAnchorInCurrentDocument(filename)) { String id = getAnchorId(filename); Box box = getSharedContext().getBoxById(id); if (box != null) { Point pt; if (box.getStyle().isInline()) { pt = new Point(box.getAbsX(), box.getAbsY()); } else { RectPropertySet margin = box.getMargin(getLayoutContext()); pt = new Point( box.getAbsX() + (int)margin.left(), box.getAbsY() + (int)margin.top()); } scrollTo(pt); return; } } Document dom = loadDocument(url); setDocument(dom, url); }
/** * Sets the new current document, where the new document * is located relative, e.g using a relative URL. * * @param filename The new document to load */ protected void setDocumentRelative(String filename) { String url = getSharedContext().getUac().resolveURI(filename); if (isAnchorInCurrentDocument(filename)) { String id = getAnchorId(filename); Box box = getSharedContext().getBoxById(id); if (box != null) { Point pt; if (box.getStyle().isInline()) { pt = new Point(box.getAbsX(), box.getAbsY()); } else { RectPropertySet margin = box.getMargin(getLayoutContext()); pt = new Point( box.getAbsX() + (int)margin.left(), box.getAbsY() + (int)margin.top()); } scrollTo(pt); return; } } Document dom = loadDocument(url); setDocument(dom, url); }