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();
/** * If fields list is not null, find and add the fields of this format to * the fields list by iterating through its AttributedCharacterIterator * * @param format * the format to find fields for * @param arg * object to format * @param begin * the index where the string this format has formatted begins */ private void handleFormat(Format format, Object arg, int begin, List<FieldContainer> fields) { if (fields == null) { return; } AttributedCharacterIterator iterator = format.formatToCharacterIterator(arg); while (iterator.getIndex() != iterator.getEndIndex()) { int start = iterator.getRunStart(); int end = iterator.getRunLimit(); Iterator<?> it = iterator.getAttributes().keySet().iterator(); while (it.hasNext()) { AttributedCharacterIterator.Attribute attribute = (AttributedCharacterIterator.Attribute) it.next(); Object value = iterator.getAttribute(attribute); fields.add(new FieldContainer(begin + start, begin + end, attribute, value)); } iterator.setIndex(end); } }
private AttributedString(AttributedCharacterIterator iterator, int start, int end, Set<Attribute> attributes) { if (start < iterator.getBeginIndex() || end > iterator.getEndIndex() || start > end) { throw new IllegalArgumentException();
nextBreak = it.getEndIndex(); if(endIndex < it.getEndIndex() && text.charAt(endIndex) == '\n'){ measurer.setPosition(endIndex + 1); if(endIndex == it.getEndIndex()) { break;
while (measurer.getPosition() < characterIterator.getEndIndex() && currentHeight <= boxHeight) {
int end = paragraph.getEndIndex(); int length = end - begin; char[] text = new char[length + 1]; // One more char for AttributedCharacterIterator.DONE
private WrappedLines breakLines(Graphics2D g) { Dimension size = label.getSize(); float maxWidth = size.width; AttributedString attributedText = new AttributedString(label.getText(), textAttributes()); AttributedCharacterIterator textIterator = attributedText.getIterator(); FontRenderContext fontRendering = g.getFontRenderContext(); LineBreakMeasurer measurer = new LineBreakMeasurer(textIterator, fontRendering); WrappedLines lines = new WrappedLines(); while(measurer.getPosition() < textIterator.getEndIndex()) { TextLayout layout = measurer.nextLayout(maxWidth); lines.add(layout); } return lines; }
float remain = h; AttributedCharacterIterator newLineCheck = text.getIterator(); while (measure.getPosition() < textIter.getEndIndex()) {
while (measurer.getPosition() < charIterator.getEndIndex()) { measurer.setPosition(0); while (measurer.getPosition() < charIterator.getEndIndex()) { TextLayout textLayout = measurer.nextLayout(wrapWidth); float ascent = textLayout.getAscent();
while (lineMeasurer.getPosition() < iter.getEndIndex()) {
/** * Returns the end index of the text. */ public int getEndIndex() { return reorderedACI.getEndIndex(); }
/** * 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 BaseAString(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); /*if( text==null ){ length = 0; }else{ length = length(text); }*/ }
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 last glyph in the text node. */ public Mark selectLast(TextNode node) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; TextHit textHit = new TextHit(aci.getEndIndex()-1, false); return new BasicTextPainter.BasicMark(node, textHit); }
public TextLayout(AttributedCharacterIterator text, FontRenderContext frc) { if (text == null){ // awt.03='{0}' iterator parameter is null throw new IllegalArgumentException(Messages.getString("awt.03", "text")); //$NON-NLS-1$ //$NON-NLS-2$ } if (text.getBeginIndex() == text.getEndIndex()){ // awt.04='{0}' iterator parameter has zero length throw new IllegalArgumentException(Messages.getString("awt.04", "text")); //$NON-NLS-1$ //$NON-NLS-2$ } this.breaker = new TextRunBreaker(text, frc); caretManager = new CaretManager(breaker); }
AttributedCharacterIterator paragraph = attrString.getIterator(); int paragraphStart = paragraph.getBeginIndex(); int paragraphEnd = paragraph.getEndIndex(); FontRenderContext frc = awtCanvas.getGraphicObject().getFontRenderContext(); LineBreakMeasurer lineMeasurer = new LineBreakMeasurer(paragraph, frc);
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(); } } }
/** 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(); } } }