if (iterator.getBeginIndex() > iterator.getEndIndex()) { throw new IllegalArgumentException("Invalid substring range"); for (int i = iterator.getBeginIndex(); i < iterator.getEndIndex(); i++) { buffer.append(iterator.current()); iterator.next();
private AttributedString(AttributedCharacterIterator iterator, int start, int end, Set<Attribute> attributes) { if (start < iterator.getBeginIndex() || end > iterator.getEndIndex() || start > end) { throw new IllegalArgumentException();
int begin = paragraph.getBeginIndex(); int end = paragraph.getEndIndex(); int length = end - begin;
public void setPosition(int pos) { if (tm.aci.getBeginIndex() > pos || maxpos < pos) { // awt.33=index is out of range throw new IllegalArgumentException(Messages.getString("awt.33")); //$NON-NLS-1$ } position = pos; } }
private int sumUpToNotIncluding(final int limit) { int offset = 0; for (int i = 0; i < limit; i++) { final AttributedCharacterIterator ci = this.realIterators.get(i); offset += ci.getEndIndex() - ci.getBeginIndex(); } return offset; }
/** * Constructs an AttributedString instance with the given attributed * text represented by AttributedCharacterIterator. * @param text The text for this attributed string. * @exception NullPointerException if <code>text</code> is null. */ public AttributedString(AttributedCharacterIterator text) { // If performance is critical, this constructor should be // implemented here rather than invoking the constructor for a // subrange. We can avoid some range checking in the loops. this(text, text.getBeginIndex(), text.getEndIndex(), null); }
public void insertChar(AttributedCharacterIterator newText, int pos) { tm.insertChar(newText, pos); bi.setText(newText); position = newText.getBeginIndex(); maxpos++; }
protected void printAttrs(AttributedCharacterIterator aci) { aci.first(); int start = aci.getBeginIndex(); System.out.print("AttrRuns: "); while (aci.current() != CharacterIterator.DONE) { int end = aci.getRunLimit(); System.out.print(""+(end-start)+", "); aci.setIndex(end); start = end; } System.out.println(""); }
@Override public void drawString(AttributedCharacterIterator iterator, int x, int y) { StringBuilder builder = new StringBuilder(iterator.getEndIndex() - iterator.getBeginIndex()); while (iterator.next() != AttributedCharacterIterator.DONE) { builder.append(iterator.current()); } drawString(builder.toString(), x, y); }
protected void printAttrs(AttributedCharacterIterator aci) { aci.first(); int start = aci.getBeginIndex(); System.out.print("AttrRuns: "); while (aci.current() != CharacterIterator.DONE) { int end = aci.getRunLimit(); System.out.print(""+(end-start)+", "); aci.setIndex(end); start = end; } System.out.println(""); }
public void insertChar(AttributedCharacterIterator newParagraph, int insertPos) { AttributedCharacterIterator oldAci = aci; aci = newParagraph; if ((oldAci.getEndIndex() - oldAci.getBeginIndex()) - (aci.getEndIndex() - aci.getBeginIndex()) != -1) { breaker = new TextRunBreaker(aci, this.frc); tmc = new TextMetricsCalculator(breaker); } else { breaker.insertChar(newParagraph, insertPos); } }
public void deleteChar(AttributedCharacterIterator newParagraph, int deletePos) { AttributedCharacterIterator oldAci = aci; aci = newParagraph; if ((oldAci.getEndIndex() - oldAci.getBeginIndex()) - (aci.getEndIndex() - aci.getBeginIndex()) != 1) { breaker = new TextRunBreaker(aci, this.frc); tmc = new TextMetricsCalculator(breaker); } else { breaker.deleteChar(newParagraph, deletePos); } }
private void updateImeInUseState(InputMethodEvent event) { AttributedCharacterIterator aci = event.getText(); if(aci != null) { int inputLen = aci.getEndIndex() - aci.getBeginIndex(); int committedLen = event.getCommittedCharacterCount(); imeInUse = inputLen > 0 && inputLen != committedLen; } else imeInUse = false; }
/** * Selects the first glyph in the text node. */ public Mark selectFirst(TextNode node) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; TextHit textHit = new TextHit(aci.getBeginIndex(), false); return new BasicTextPainter.BasicMark(node, textHit); }
/** * Selects the first glyph in the text node. */ public Mark selectFirst(TextNode node) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; TextHit textHit = new TextHit(aci.getBeginIndex(), false); return new BasicTextPainter.BasicMark(node, textHit); }
attrString.addAttribute(TextAttribute.FONT, awtPaintFront.font); AttributedCharacterIterator paragraph = attrString.getIterator(); int paragraphStart = paragraph.getBeginIndex(); int paragraphEnd = paragraph.getEndIndex(); FontRenderContext frc = awtCanvas.getGraphicObject().getFontRenderContext();
public Mark getMark(TextNode node, int index, boolean leadingEdge) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; if ((index < aci.getBeginIndex()) || (index > aci.getEndIndex())) return null; TextHit textHit = new TextHit(index, leadingEdge); return new BasicTextPainter.BasicMark(node, textHit); }
public Mark getMark(TextNode node, int index, boolean leadingEdge) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; if ((index < aci.getBeginIndex()) || (index > aci.getEndIndex())) return null; TextHit textHit = new TextHit(index, leadingEdge); return new BasicTextPainter.BasicMark(node, textHit); }
public Mark getMark(TextNode node, int index, boolean leadingEdge) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; if ((index < aci.getBeginIndex()) || (index > aci.getEndIndex())) return null; TextHit textHit = new TextHit(index, leadingEdge); return new BasicTextPainter.BasicMark(node, textHit); }
/** Replaces an empty iterator by an iterator conatining one space. */ private static void replaceEmptyIterators(AttributedCharacterIterator[] iters) { for (int i = 0; i < iters.length; i++) { AttributedCharacterIterator achit = iters[i]; if (achit.getBeginIndex() == achit.getEndIndex()) { AttributedCharacters at = new AttributedCharacters(); at.append(' ', getFontInstance(), Color.white); iters[i] = at.iterator(); } } }