while (iterator.getIndex() < end) { buffer.append(iterator.current()); iterator.next(); AttributedCharacterIterator.Attribute attribute = it.next(); iterator.setIndex(start); while (iterator.getIndex() < end) { Object value = iterator.getAttribute(attribute); int runStart = iterator.getRunStart(attribute);
/** * 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); } }
TextLayout layout = measure.nextLayout(availWidth, newLineCheck.getIndex(), false); float ascent = layout.getAscent(); yPos += ascent;
/** * Get the current index. * <br><b>Specified by:</b> java.text.CharacterIterator. */ public int getIndex() { return aci.getIndex(); }
/** * Get the current index. * <br><b>Specified by:</b> java.text.CharacterIterator. */ public int getIndex() { return aci.getIndex(); }
/** * Returns the current index. */ public int getIndex() { return reorderedACI.getIndex(); }
/** * Returns the current index. */ public int getIndex() { return reorderedACI.getIndex(); }
/** * Get the current index. * <br><b>Specified by:</b> java.text.CharacterIterator. */ public int getIndex() { return aci.getIndex(); }
/** * Returns the current index. */ public int getIndex() { return reorderedACI.getIndex(); }
public int getIndex() { return aci.getIndex(); }
/** {@inheritDoc} */ public int getIndex() { return this.currentOffset() + this.realIterators.get(this.currentList).getIndex(); }
private static void copyAsSuperscript( AttributedCharacterIterator iterator, int start, int limit, StringBuilder result) { int oldIndex = iterator.getIndex(); iterator.setIndex(start); while (iterator.getIndex() < limit) { int aChar = char32AtAndAdvance(iterator); int digit = UCharacter.digit(aChar); if (digit < 0) { throw new IllegalArgumentException(); } result.append(SUPERSCRIPT_DIGITS[digit]); } iterator.setIndex(oldIndex); }
/** * Collects all characters from an {@link AttributedCharacterIterator}. * @param runaci the character iterator * @return the characters */ protected CharSequence collectCharacters(AttributedCharacterIterator runaci) { StringBuffer chars = new StringBuffer(); for (runaci.first(); runaci.getIndex() < runaci.getEndIndex();) { chars.append(runaci.current()); runaci.next(); } return chars; }
static void append( AttributedCharacterIterator iterator, int start, int limit, StringBuilder result) { int oldIndex = iterator.getIndex(); iterator.setIndex(start); for (int i = start; i < limit; i++) { result.append(iterator.current()); iterator.next(); } iterator.setIndex(oldIndex); } }
public void append(String text, Color foreground) { if(text.length() == 0) { throw new IllegalArgumentException("text must not be empty"); } AttributedString replacementText = new AttributedString(plainText + text); replacementText.addAttributes(paragraphText.getIterator().getAttributes(), 0, plainText.length()); AttributedCharacterIterator charIt = paragraphText.getIterator(); while(charIt.current() != AttributedCharacterIterator.DONE) { replacementText.addAttributes(charIt.getAttributes(), charIt.getIndex(), charIt.getEndIndex() + 1); charIt.next(); } replacementText.addAttribute(TextAttribute.FOREGROUND, foreground, plainText.length(), plainText.length() + text.length()); paragraphText = replacementText; computePlainString(); invalidateLayout(); }
public void append(String text, Color foreground) { AttributedString replacementText = new AttributedString(plainText + text); replacementText.addAttributes(paragraphText.getIterator().getAttributes(), 0, plainText.length()); AttributedCharacterIterator charIt = paragraphText.getIterator(); while(charIt.current() != AttributedCharacterIterator.DONE) { replacementText.addAttributes(charIt.getAttributes(), charIt.getIndex(), charIt.getEndIndex() + 1); charIt.next(); } replacementText.addAttribute(TextAttribute.FOREGROUND, foreground, plainText.length(), plainText.length() + text.length()); paragraphText = replacementText; computePlainString(); invalidateLayout(); }
/** * */ protected void exportStyledText(JRStyledText styledText) throws IOException { String text = styledText.getText(); int runLimit = 0; AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator(); while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length()) { exportStyledTextRun(iterator.getAttributes(), text.substring(iterator.getIndex(), runLimit)); iterator.setIndex(runLimit); } }
/** * */ protected void exportStyledText(JRStyledText styledText) throws IOException { String text = styledText.getText(); int runLimit = 0; AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator(); while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length()) { exportStyledTextRun(iterator.getAttributes(), text.substring(iterator.getIndex(), runLimit)); iterator.setIndex(runLimit); } }
/** * */ protected void exportStyledText(JRStyle style, JRStyledText styledText) throws IOException { String text = styledText.getText(); int runLimit = 0; AttributedCharacterIterator iterator = styledText.getAttributedString().getIterator(); while(runLimit < styledText.length() && (runLimit = iterator.getRunLimit()) <= styledText.length()) { runHelper.export(style, iterator.getAttributes(), text.substring(iterator.getIndex(), runLimit)); iterator.setIndex(runLimit); } }
/** * Stores the field indices of the years in the {@link #minPos} and {@link #maxPos} fields. */ private static void findYears(final AttributedCharacterIterator it, final RangeFormat.Field field, final FieldPosition pos) { it.setIndex(it.getRunLimit(field)); it.setIndex(it.getRunLimit(DateFormat.Field.YEAR)); pos.setBeginIndex(it.getIndex()); it.setIndex(it.getRunLimit(DateFormat.Field.YEAR)); pos.setEndIndex(it.getIndex()); }