private static InlineText layoutText(LayoutContext c, CalculatedStyle style, int remainingWidth, LineBreakContext lbContext, boolean needFirstLetter) { InlineText result = null; result = new InlineText(); result.setMasterText(lbContext.getMaster()); result.setTextNode(lbContext.getTextNode()); if (needFirstLetter) { Breaker.breakFirstLetter(c, lbContext, remainingWidth, style); } else { Breaker.breakText(c, lbContext, remainingWidth, style); } result.setSubstring(lbContext.getStart(), lbContext.getEnd()); result.setWidth(lbContext.getWidth()); return result; }
InlineText iT = (InlineText)o; iT.setX(iT.getX() + Math.round(result)); float adj = iT.calcTotalAdjustment(info); result += adj; runningTotal += adj;
public void clearSelection(List modified) { boolean changed = false; for (int i = 0; i < getInlineChildCount(); i++) { Object obj = getInlineChild(i); if (obj instanceof Box) { ((Box)obj).clearSelection(modified); } else { changed |= ((InlineText)obj).clearSelection(); } } if (changed) { modified.add(this); } }
public void trimTrailingSpace(LayoutContext c) { if (! isEmpty() && _masterText.charAt(_end-1) == ' ') { _end--; setWidth(c.getTextRenderer().getWidth(c.getFontContext(), getParent().getStyle().getFSFont(c), getSubstring())); setTrimmedTrailingSpace(true); } }
public boolean updateSelection(RenderingContext c, Rectangle selection) { ensureGlyphPositions(c); float[] positions = _glyphPositions; int y = getParent().getAbsY(); int offset = getParent().getAbsX() + getX(); y, 1, getParent().getHeight()); if (selection.intersects(target)) { if (! found) {
public void trimTrailingSpace(LayoutContext c) { InlineText text = findTrailingText(); if (text != null) { InlineLayoutBox iB = text.getParent(); IdentValue whitespace = iB.getStyle().getWhitespace(); if (whitespace == IdentValue.NORMAL || whitespace == IdentValue.NOWRAP) { text.trimTrailingSpace(c); } } }
public void drawSelection(RenderingContext c, InlineText inlineText) { if (inlineText.isSelected()) { InlineLayoutBox iB = inlineText.getParent(); String text = inlineText.getSubstring(); if (text != null && text.length() > 0) { FSFont font = iB.getStyle().getFSFont(c); c.getOutputDevice(), font, inlineText.getSubstring()); font, glyphVector, inlineText.getSelectionStart(), iB.getAbsX() + inlineText.getX(), iB.getAbsY() + iB.getBaseline()); font, glyphVector, inlineText.getSelectionEnd() - 1, iB.getAbsX() + inlineText.getX(), iB.getAbsY() + iB.getBaseline()); Graphics2D graphics = getGraphics(); double scaleX = graphics.getTransform().getScaleX(); boolean allSelected = (text.length() == inlineText.getSelectionEnd()-inlineText.getSelectionStart()); int startX = (inlineText.getSelectionStart() == inlineText.getStart())?iB.getAbsX() + inlineText.getX():(int)Math.round(start.x/scaleX); int endX = (allSelected)?startX+inlineText.getWidth():(int)Math.round((end.x + end.width)/scaleX); _graphics.setColor(UIManager.getColor("TextArea.selectionBackground")); // FIXME fillRect(
if (o instanceof InlineText) { InlineText txt = (InlineText) o; if (txt.getTextNode() != null) { hasDecentTextNode = true; break; if (o instanceof InlineText) { InlineText txt = (InlineText) o; if (txt.getTextNode() != null) { if ((e.getX() >= x + txt.getX() && e.getX() < x + txt.getX() + txt.getWidth()) || containsWholeIlb) { fndTxt = txt; break; } else { if (e.getX() < x + txt.getX()) { String txt = fndTxt.getMasterText(); offset = fndTxt.getEnd(); } else { for (offset = fndTxt.getStart(); offset < fndTxt.getEnd(); offset++) { int w = getTextWidth(lc, style, txt.substring(fndTxt.getStart(), offset + 1)); if (w + x + fndTxt.getX() > e.getX()) { break; Node node = fndTxt.getTextNode(); try { r.setStart(node, offset);
for (int i = 0; i < inlineText.getSelectionStart(); i++) { vector.setGlyphPosition(i, new Point2D.Float(-100000, -100000)); for (int i = inlineText.getSelectionEnd(); i < inlineText.getSubstring().length(); i++) { vector.setGlyphPosition(i, new Point2D.Float(-100000, -100000)); if(inlineText.getParent().getStyle().isTextJustify()) { JustificationInfo info = inlineText.getParent().getLineBox().getJustificationInfo(); if(info!=null) { String string = inlineText.getSubstring(); float adjust = 0.0f; for (int i = inlineText.getSelectionStart(); i < inlineText.getSelectionEnd(); i++) { char ch = string.charAt(i); if (i != 0) { c.getOutputDevice(), glyphVector, iB.getAbsX() + inlineText.getX(), iB.getAbsY() + iB.getBaseline());
private void drawFontMetrics(RenderingContext c, InlineText inlineText) { InlineLayoutBox iB = inlineText.getParent(); String text = inlineText.getSubstring(); setColor(new FSRGBColor(0xFF, 0x33, 0xFF)); FSFontMetrics fm = iB.getStyle().getFSFontMetrics(null); int width = c.getTextRenderer().getWidth( c.getFontContext(), iB.getStyle().getFSFont(c), text); int x = iB.getAbsX() + inlineText.getX(); int y = iB.getAbsY() + iB.getBaseline(); drawLine(x, y, x + width, y); y += (int) Math.ceil(fm.getDescent()); drawLine(x, y, x + width, y); y -= (int) Math.ceil(fm.getDescent()); y -= (int) Math.ceil(fm.getAscent()); drawLine(x, y, x + width, y); }
InlineText iT = (InlineText) itr.next(); iT.setSelectionStart((short) Math.max(0, Math.min(selTxtSt, iT.getEnd()) - iT.getStart())); iT.setSelectionEnd((short) Math.max(0, Math.min(iT.getEnd(), selTxtEnd) - iT.getStart()));
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 void ensureGlyphPositions(RenderingContext c) { if (_glyphPositions == null) { FSGlyphVector glyphVector = c.getTextRenderer().getGlyphVector( c.getOutputDevice(), getParent().getStyle().getFSFont(c), getSubstring()); _glyphPositions = c.getTextRenderer().getGlyphPositions( c.getOutputDevice(), getParent().getStyle().getFSFont(c), glyphVector); } }
public String calculate(RenderingContext c, FSFunction function, InlineText text) { InlineLayoutBox iB = text.getParent(); LineBox lineBox = iB.getLineBox(); int leaderWidth = iB.getContainingBlockWidth() - iB.getLineBox().getWidth() + text.getWidth(); int count = (int) ((leaderWidth - (2 * spaceWidth)) / valueWidth);
private Box getElementContainerBox(InlineText t) { Box b = t.getParent(); while (b.getElement() == null) { b = b.getParent(); } return b; }
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 String getSubstring() { if (getMasterText() != null) { if (_start == -1 || _end == -1) { throw new RuntimeException("negative index in InlineBox"); } if (_end < _start) { throw new RuntimeException("end is less than setStartStyle"); } return getMasterText().substring(_start, _end); } else { throw new RuntimeException("No master text set!"); } }
public void drawSelection(RenderingContext c, InlineText inlineText) { if (inlineText.isSelected()) { InlineLayoutBox iB = inlineText.getParent(); String text = inlineText.getSubstring(); if (text != null && text.length() > 0) { FSFont font = iB.getStyle().getFSFont(c); c.getOutputDevice(), font, inlineText.getSubstring()); font, glyphVector, inlineText.getSelectionStart(), iB.getAbsX() + inlineText.getX(), iB.getAbsY() + iB.getBaseline()); font, glyphVector, inlineText.getSelectionEnd() - 1, iB.getAbsX() + inlineText.getX(), iB.getAbsY() + iB.getBaseline()); Graphics2D graphics = getGraphics(); double scaleX = graphics.getTransform().getScaleX(); boolean allSelected = (text.length() == inlineText.getSelectionEnd()-inlineText.getSelectionStart()); int startX = (inlineText.getSelectionStart() == inlineText.getStart())?iB.getAbsX() + inlineText.getX():(int)Math.round(start.x/scaleX); int endX = (allSelected)?startX+inlineText.getWidth():(int)Math.round((end.x + end.width)/scaleX); _graphics.setColor(UIManager.getColor("TextArea.selectionBackground")); // FIXME fillRect(
if (o instanceof InlineText) { InlineText txt = (InlineText) o; if (txt.getTextNode() != null) { hasDecentTextNode = true; break; if (o instanceof InlineText) { InlineText txt = (InlineText) o; if (txt.getTextNode() != null) { if ((e.getX() >= x + txt.getX() && e.getX() < x + txt.getX() + txt.getWidth()) || containsWholeIlb) { fndTxt = txt; break; } else { if (e.getX() < x + txt.getX()) { String txt = fndTxt.getMasterText(); offset = fndTxt.getEnd(); } else { for (offset = fndTxt.getStart(); offset < fndTxt.getEnd(); offset++) { int w = getTextWidth(lc, style, txt.substring(fndTxt.getStart(), offset + 1)); if (w + x + fndTxt.getX() > e.getX()) { break; Node node = fndTxt.getTextNode(); try { r.setStart(node, offset);
public void trimTrailingSpace(LayoutContext c) { if (! isEmpty() && _masterText.charAt(_end-1) == ' ') { _end--; setWidth(c.getTextRenderer().getWidth(c.getFontContext(), getParent().getStyle().getFSFont(c), getSubstring())); setTrimmedTrailingSpace(true); } }