private static void initBoxRefs(Map<Element,Bookmark> map, Box box) { Bookmark bookmark = map.get(box.getElement()); if (bookmark != null) { bookmark.setBox(box); } for (int i = 0, len = box.getChildCount(); i < len; i++) { initBoxRefs(map, box.getChild(i)); } }
public Box find(CssContext cssCtx, int absX, int absY, boolean findAnonymous) { PaintingInfo pI = getPaintingInfo(); if (pI != null && ! pI.getAggregateBounds().contains(absX, absY)) { return null; } Box result = null; for (int i = 0; i < getChildCount(); i++) { Box child = getChild(i); result = child.find(cssCtx, absX, absY, findAnonymous); if (result != null) { return result; } } Rectangle edge = getContentAreaEdge(getAbsX(), getAbsY(), cssCtx); return edge.contains(absX, absY) && getStyle().isVisible() ? this : null; }
public void clearSelection(List modified) { for (int i = 0; i < getChildCount(); i++) { Box child = getChild(i); child.clearSelection(modified); } }
protected void resetChildren(LayoutContext c) { int remaining = getChildCount(); for (int i = 0; i < remaining; i++) { Box box = getChild(i); box.reset(c); } }
Box box = fieldElem.getBox(); Element e = box.getElement(); String onValue = getValue(e); FSColor color = box.getStyle().getColor(); FSColor darker = box.getEffBackgroundColor(c).darkenColor(); createAppearances(cb, field, onValue, width, height, true, color, darker); createAppearances(cb, field, onValue, width, height, false, color, darker); Rectangle bounds = box.getContentAreaEdge(box.getAbsX(), box.getAbsY(), c); PageBox page = c.getRootLayer().getPage(c, bounds.y); field.setPlaceInPage(page.getPageNo()+1);
private PagePosition calcPDFPagePosition(CssContext c, String id, Box box) { PageBox page = _root.getLayer().getLastPage(c, box); if (page == null) { return null; } float x = box.getAbsX() + page.getMarginBorderPadding(c, CalculatedStyle.LEFT); float y = (page.getBottom() - (box.getAbsY() + box.getHeight())) + page.getMarginBorderPadding(c, CalculatedStyle.BOTTOM); x /= _dotsPerPoint; y /= _dotsPerPoint; PagePosition result = new PagePosition(); result.setId(id); result.setPageNo(page.getPageNo()); result.setX(x); result.setY(y); result.setWidth(box.getEffectiveWidth() / _dotsPerPoint); result.setHeight(box.getHeight() / _dotsPerPoint); return result; } }
public com.lowagie.text.Rectangle createTargetArea(RenderingContext c, Box box) { PageBox current = c.getPage(); boolean inCurrentPage = box.getAbsY() > current.getTop() && box.getAbsY() < current.getBottom(); if (inCurrentPage || box.isContainedInMarginBox()) { return createLocalTargetArea(c, box); } else { Rectangle bounds = box.getContentAreaEdge(box.getAbsX(), box.getAbsY(), c); PageBox page = _root.getLayer().getPage(c, bounds.y); float bottom = getDeviceLength(page.getBottom() - (bounds.y + bounds.height) + page.getMarginBorderPadding(c, CalculatedStyle.BOTTOM)); float left = getDeviceLength(page.getMarginBorderPadding(c, CalculatedStyle.LEFT) + bounds.x); com.lowagie.text.Rectangle result = new com.lowagie.text.Rectangle(left, bottom, left + getDeviceLength(bounds.width), bottom + getDeviceLength(bounds.height)); return result; } }
private com.itextpdf.text.Rectangle createLocalTargetArea(RenderingContext c, Box box, boolean useAggregateBounds) { Rectangle bounds; if (useAggregateBounds && box.getPaintingInfo() != null) { bounds = box.getPaintingInfo().getAggregateBounds(); } else { bounds = box.getContentAreaEdge(box.getAbsX(), box.getAbsY(), c); } Point2D docCorner = new Point2D.Double(bounds.x, bounds.y + bounds.height); Point2D pdfCorner = new Point.Double(); _transform.transform(docCorner, pdfCorner); pdfCorner.setLocation(pdfCorner.getX(), normalizeY((float) pdfCorner.getY())); com.itextpdf.text.Rectangle result = new com.itextpdf.text.Rectangle((float) pdfCorner.getX(), (float) pdfCorner.getY(), (float) pdfCorner.getX() + getDeviceLength(bounds.width), (float) pdfCorner.getY() + getDeviceLength(bounds.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; }
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 PaintingInfo calcPaintingInfo(CssContext c, boolean useCache) { PaintingInfo cached = getPaintingInfo(); if (cached != null && useCache) { return cached; } final PaintingInfo result = new PaintingInfo(); Rectangle bounds = getMarginEdge(getAbsX(), getAbsY(), c, 0, 0); result.setOuterMarginCorner( new Dimension(bounds.x + bounds.width, bounds.y + bounds.height)); result.setAggregateBounds(getPaintingClipEdge(c)); calcChildPaintingInfo(c, result, useCache); setPaintingInfo(result); return result; }
public void paintRootElementBackground(RenderingContext c) { PaintingInfo pI = getPaintingInfo(); if (pI != null) { if (getStyle().isHasBackground()) { paintRootElementBackground(c, pI); } else if (getChildCount() > 0) { Box body = getChild(0); body.paintRootElementBackground(c, pI); } } }
public List getElementBoxes(Element elem) { List result = new ArrayList(); for (int i = 0; i < getChildCount(); i++) { Box child = getChild(i); if (child.getElement() == elem) { result.add(child); } result.addAll(child.getElementBoxes(elem)); } return result; }
public void analyzePageBreaks(LayoutContext c, ContentLimitContainer container) { container.updateTop(c, getAbsY()); for (Iterator i = getChildIterator(); i.hasNext(); ) { Box b = (Box)i.next(); b.analyzePageBreaks(c, container); } container.updateBottom(c, getAbsY() + getHeight()); }
private void performFloatOperation(FloatOperation op, List floats) { for (Iterator i = floats.iterator(); i.hasNext();) { BoxOffset boxOffset = (BoxOffset) i.next(); BlockBox box = boxOffset.getBox(); box.setAbsX(box.getX() + getMaster().getAbsX() - boxOffset.getX()); box.setAbsY(box.getY() + getMaster().getAbsY() - boxOffset.getY()); op.operate(box); } }
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 void remove(String fieldName) { List values = (List) _radioButtonsByName.get(fieldName); if (values != null) { for (Iterator i = values.iterator(); i.hasNext();) { RadioButtonFormField field = (RadioButtonFormField) i.next(); _radioButtonsByElem.remove(field.getBox().getElement()); } } _radioButtonsByName.remove(fieldName); }