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 < getInlineChildCount(); i++) { Object child = getInlineChild(i); if (child instanceof Box) { result = ((Box)child).find(cssCtx, absX, absY, findAnonymous); if (result != null) { return result; } } } Rectangle edge = getContentAreaEdge(getAbsX(), getAbsY(), cssCtx); result = edge.contains(absX, absY) && getStyle().isVisible() ? this : null; if (! findAnonymous && result != null && getElement() == null) { return getParent().getParent(); } else { return result; } }
private int getPageRefY(Box box) { if (box instanceof InlineLayoutBox) { InlineLayoutBox iB = (InlineLayoutBox)box; return iB.getAbsY() + iB.getBaseline(); } else { return box.getAbsY(); } }
public String toString() { StringBuffer result = new StringBuffer(); result.append("InlineLayoutBox: "); if (getElement() != null) { result.append("<"); result.append(getElement().getNodeName()); result.append("> "); } else { result.append("(anonymous) "); } if (isStartsHere() || isEndsHere()) { result.append("("); if (isStartsHere()) { result.append("S"); } if (isEndsHere()) { result.append("E"); } result.append(") "); } result.append("(baseline="); result.append(_baseline); result.append(") "); result.append("(" + getAbsX() + "," + getAbsY() + ")->(" + getInlineWidth() + " x " + getHeight() + ")"); return result.toString(); }
public InlineLayoutBox copyOf() { InlineLayoutBox result = new InlineLayoutBox(); result.setElement(getElement()); result.setStyle(getStyle()); result.setHeight(getHeight()); result._pending = _pending; result.setContainingLayer(getContainingLayer()); return result; }
public void addAllChildren(List list, Layer layer) { for (int i = 0; i < getInlineChildCount(); i++) { Object child = getInlineChild(i); if (child instanceof Box) { if (((Box)child).getContainingLayer() == layer) { list.add(child); if (child instanceof InlineLayoutBox) { ((InlineLayoutBox)child).addAllChildren(list, layer); } } } } }
setColor(iB.getStyle().getColor()); setFont(iB.getStyle().getFSFont(c)); if (inlineText.getParent().getStyle().isTextJustify()) { JustificationInfo info = inlineText.getParent().getLineBox().getJustificationInfo(); if (info != null) { c.getTextRenderer().drawString( c.getOutputDevice(), text, iB.getAbsX() + inlineText.getX(), iB.getAbsY() + iB.getBaseline(), info); } else { c.getOutputDevice(), text, iB.getAbsX() + inlineText.getX(), iB.getAbsY() + iB.getBaseline()); c.getOutputDevice(), text, iB.getAbsX() + inlineText.getX(), iB.getAbsY() + iB.getBaseline());
if (iB.isStartsHere()) { previousIB = currentIB; currentIB = new InlineLayoutBox(c, iB.getElement(), style, maxAvailableWidth); currentLine.addChildForLayout(c, currentIB); } else { previousIB.addInlineChild(c, currentIB); if (currentIB.getElement() != null) { String name = c.getNamespaceHandler().getAnchorName(currentIB.getElement()); if (name != null) { c.addBoxId(name, currentIB); String id = c.getNamespaceHandler().getID(currentIB.getElement()); if (id != null) { c.addBoxId(id, currentIB); addFirstLetterBox(c, currentLine, currentIB, lbContext, maxAvailableWidth, remainingWidth); remainingWidth -= firstLetter.getInlineWidth(); if (currentIB.isStartsHere()) { pendingLeftMBP -= currentIB.getStyle().getMarginBorderPadding( c, maxAvailableWidth, CalculatedStyle.LEFT); currentIB.addInlineChild(c, inlineText); currentLine.setContainsContent(true); lbContext.setStart(lbContext.getEnd()); remainingWidth -= inlineText.getWidth();
for (int i = ilbs.size() - 1; i >= 0; i--) { InlineLayoutBox ilbt = (InlineLayoutBox) ilbs.get(i); if (ilbt.getAbsY() <= e.getY() && ilbt.getAbsX() <= e.getX()) { if (ilb == null || (ilbt.getAbsY() > ilb.getAbsY()) || (ilbt.getAbsY() == ilb.getAbsY() && ilbt.getX() > ilb.getX())) { if (ilbt.isContainsVisibleContent()) { boolean hasDecentTextNode = false; int x = ilbt.getAbsX(); for (Iterator it = ilbt.getInlineChildren().iterator(); it .hasNext();) { Object o = it.next(); int x = ilb.getAbsX(); InlineText lastItxt = null; for (Iterator it = ilb.getInlineChildren().iterator(); it.hasNext();) { Object o = it.next(); if (o instanceof InlineText) { CalculatedStyle style = ilb.getStyle(); if (containsWholeIlb) { offset = fndTxt.getEnd();
private static InlineBoxMeasurements calculateInlineMeasurements(LayoutContext c, InlineLayoutBox iB, VerticalAlignContext vaContext) { FSFontMetrics fm = iB.getStyle().getFSFontMetrics(c); CalculatedStyle style = iB.getStyle(); float lineHeight = style.getLineHeight(c); int halfLeading = Math.round((lineHeight - iB.getStyle().getFont(c).size) / 2); if (halfLeading > 0) { halfLeading = Math.round((lineHeight - iB.setBaseline(Math.round(fm.getAscent())); List decorations = calculateTextDecorations(iB, iB.getBaseline(), fm); if (decorations != null) { iB.setTextDecorations(decorations); result.setBaseline(iB.getY() + iB.getBaseline()); result.setInlineTop(iB.getY() - halfLeading); result.setInlineBottom(Math.round(result.getInlineTop() + lineHeight)); result.setTextTop(iB.getY()); result.setTextBottom((int) (result.getBaseline() + fm.getDescent())); RectPropertySet padding = iB.getPadding(c); BorderPropertySet border = iB.getBorder(c); result.setPaintingTop((int)Math.floor(iB.getY() - border.top() - padding.top())); result.setPaintingBottom((int)Math.ceil(iB.getY() + fm.getAscent() + fm.getDescent() + border.bottom() + padding.bottom()));
public Rectangle getBorderEdge(int left, int top, CssContext cssCtx) { // x, y pins the content area of the box so subtract off top border and padding // too float marginLeft = 0; float marginRight = 0; if (_startsHere || _endsHere) { RectPropertySet margin = (RectPropertySet)getMargin(cssCtx); if (_startsHere) { marginLeft = margin.left(); } if (_endsHere) { marginRight = margin.right(); } } BorderPropertySet border = getBorder(cssCtx); RectPropertySet padding = getPadding(cssCtx); Rectangle result = new Rectangle( (int)(left + marginLeft), (int)(top - border.top() - padding.top()), (int)(getInlineWidth(cssCtx) - marginLeft - marginRight), getHeight()); return result; }
private ElementBox createElementBox(Styleable styleable, Element element) { if (styleable instanceof InlineLayoutBox) { final InlineLayoutBox box = (InlineLayoutBox) styleable; final int width = Math.max(box.getInlineWidth(), box.getWidth()); return new ElementBox(element, box.getAbsX(), box.getAbsY(), width, box.getHeight()); } if (styleable instanceof Box) { final Box box = (Box) styleable; return new ElementBox(element, box.getAbsX(), box.getAbsY(), box.getWidth(), box.getHeight()); } return null; }
public void moveDot(ViewModelInfo pos) { this.dotInfo = pos; if (this.markInfo == null) { this.markInfo = pos; } fireStateChanged(); updateHighlights(); updateSystemSelection(); InlineText iT = this.dotInfo.text; InlineLayoutBox iB = iT.getParent(); adjustVisibility(new Rectangle(iB.getAbsX() + iT.getX(), iB.getAbsY(), 1, iB.getBaseline())); }
private static InlineLayoutBox addFirstLetterBox(LayoutContext c, LineBox current, InlineLayoutBox currentIB, LineBreakContext lbContext, int maxAvailableWidth, int remainingWidth) { CalculatedStyle previous = currentIB.getStyle(); currentIB.setStyle(c.getFirstLettersTracker().deriveAll(currentIB.getStyle())); InlineLayoutBox iB = new InlineLayoutBox(c, null, currentIB.getStyle(), maxAvailableWidth); iB.setStartsHere(true); iB.setEndsHere(true); currentIB.addInlineChild(c, iB); current.setContainsContent(true); InlineText text = layoutText(c, iB.getStyle(), remainingWidth, lbContext, true); iB.addInlineChild(c, text); iB.setInlineWidth(text.getWidth()); lbContext.setStart(lbContext.getEnd()); c.getFirstLettersTracker().clearStyles(); currentIB.setStyle(previous); return iB; }
public void drawTextDecoration( RenderingContext c, InlineLayoutBox iB, TextDecoration decoration) { setColor(iB.getStyle().getColor()); Rectangle edge = iB.getContentAreaEdge(iB.getAbsX(), iB.getAbsY(), c); fillRect(edge.x, iB.getAbsY() + decoration.getOffset(), edge.width, decoration.getThickness()); }
public List getElementWithContent() { // inefficient, but the lists in question shouldn't be very long List result = new ArrayList(); BlockBox container = (BlockBox)getLineBox().getParent(); while (true) { List elementBoxes = container.getElementBoxes(getElement()); for (int i = 0; i < elementBoxes.size(); i++) { InlineLayoutBox iB = (InlineLayoutBox)elementBoxes.get(i); iB.addToContentList(result); } if ( ! (container instanceof AnonymousBlockBox) || containsEnd(result)) { break; } container = addFollowingBlockBoxes(container, result); if (container == null) { break; } } return result; }
public void calculateTextDecoration(LayoutContext c) { List decorations = InlineBoxing.calculateTextDecorations(this, getBaseline(), getStyle().getFSFontMetrics(c)); setTextDecorations(decorations); }
for (Iterator i = openParents.iterator(); i.hasNext();) { InlineBox iB = (InlineBox)i.next(); currentIB = new InlineLayoutBox( c, iB.getElement(), iB.getStyle(), cbWidth); currentIB.setPending(prev.isPending()); first = false; } else { previousIB.addInlineChild(c, currentIB, false);
public void countJustifiableChars(CharCounts counts) { boolean justifyThis = getStyle().isTextJustify(); for (Iterator i = getInlineChildren().iterator(); i.hasNext(); ) { Object o = i.next(); if (o instanceof InlineLayoutBox) { ((InlineLayoutBox)o).countJustifiableChars(counts); } else if (o instanceof InlineText && justifyThis) { ((InlineText)o).countJustifiableChars(counts); } } }
public void collectText(RenderingContext c, StringBuffer buffer) throws IOException { for (Iterator i = getInlineChildren().iterator(); i.hasNext(); ) { Object obj = (Object)i.next(); if (obj instanceof InlineText) { buffer.append(((InlineText)obj).getTextExportText()); } else { ((Box)obj).collectText(c, buffer); } } }