当前位置: 首页>>代码示例>>Java>>正文


Java AttributedCharacterIterator.next方法代码示例

本文整理汇总了Java中java.text.AttributedCharacterIterator.next方法的典型用法代码示例。如果您正苦于以下问题:Java AttributedCharacterIterator.next方法的具体用法?Java AttributedCharacterIterator.next怎么用?Java AttributedCharacterIterator.next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.text.AttributedCharacterIterator的用法示例。


在下文中一共展示了AttributedCharacterIterator.next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: write

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
@Override
public void write(Text text, Writer writer) throws IOException {
  AttributedCharacterIterator iterator = text.getIterator();

  Entry<Attribute, Object> lastAttribute = null;
  while (true) {
    if (iterator.getIndex() == iterator.getEndIndex()) {
      break;
    }

    Entry<Attribute, Object> entry = getAttribute(iterator);

    if (!Objects.equals(entry, lastAttribute)) {
      endEntity(lastAttribute, writer);
      beginEntity(entry, writer);
    }

    writer.write(iterator.current());

    lastAttribute = entry;
    iterator.next();
  }

  endEntity(lastAttribute, writer);
}
 
开发者ID:AgeOfWar,项目名称:Telejam,代码行数:26,代码来源:MarkdownTextWriter.java

示例2: getEntities

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
private List<String> getEntities(TextEntity entity) {
  AttributedCharacterIterator iterator = getIterator();
  List<String> entities = new ArrayList<>();
  StringBuilder builder = new StringBuilder();

  Map<AttributedCharacterIterator.Attribute, Object> last = Collections.emptyMap();
  while (iterator.getIndex() != iterator.getEndIndex()) {
    Map<AttributedCharacterIterator.Attribute, Object> curr = iterator.getAttributes();
    if (curr.containsKey(entity)) {
      builder.append(iterator.current());
    } else {
      if (last.containsKey(entity)) {
        entities.add(builder.toString());
        builder.setLength(0);
      }
    }
    last = curr;

    iterator.next();
  }
  if (last.containsKey(entity)) {
    entities.add(builder.toString());
  }

  return entities;
}
 
开发者ID:AgeOfWar,项目名称:Telejam,代码行数:27,代码来源:Text.java

示例3: select

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
/**
 * Selects the passed in field, returning true if it is found, false
 * otherwise.
 */
private boolean select(JFormattedTextField ftf, AttributedCharacterIterator iterator, DateFormat.Field field)
{
	int max = ftf.getDocument().getLength();

	iterator.first();
	do
	{
		Map<Attribute, Object> attrs = iterator.getAttributes();

		if( attrs != null && attrs.containsKey(field) )
		{
			int start = iterator.getRunStart(field);
			int end = iterator.getRunLimit(field);

			if( start != -1 && end != -1 && start <= max && end <= max )
			{
				ftf.select(start, end);
			}
			return true;
		}
	}
	while( iterator.next() != CharacterIterator.DONE );
	return false;
}
 
开发者ID:equella,项目名称:Equella,代码行数:29,代码来源:FlatterSpinnerUI.java

示例4: checkIteratorText

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
private static final void checkIteratorText(AttributedCharacterIterator iterator, String expectedText) throws Exception {
    if (iterator.getEndIndex() - iterator.getBeginIndex() != expectedText.length()) {
        throwException(iterator, "text length doesn't match between original text and iterator");
    }

    char c = iterator.first();
    for (int i = 0; i < expectedText.length(); i++) {
        if (c != expectedText.charAt(i)) {
            throwException(iterator, "text content doesn't match between original text and iterator");
        }
        c = iterator.next();
    }
    if (c != CharacterIterator.DONE) {
        throwException(iterator, "iterator text doesn't end with DONE");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:AttributedStringTest.java

示例5: ComponentLine

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
ComponentLine(AttributedCharacterIterator it, Font defaultFont, Color defaultColor) {
    for (char c = it.first(); c != CharacterIterator.DONE; c = it.next()) {
        Font font = (Font) it.getAttribute(TextAttribute.FONT);
        Color color = (Color) it.getAttribute(TextAttribute.FOREGROUND);
        mySymbols.add(new Symbol(c, createFont(font, defaultFont), createColor(color, defaultColor)));
    }
    checkSpaces(defaultFont, defaultColor);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ComponentLine.java

示例6: write

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
@Override
public void write(Text text, Writer writer) throws IOException {
  AttributedCharacterIterator iterator = text.getIterator();
  StringBuilder builder = new StringBuilder();

  Entry<Attribute, Object> lastAttribute = null;
  while (true) {
    if (iterator.getIndex() == iterator.getEndIndex()) {
      break;
    }

    Entry<Attribute, Object> entry = getAttribute(iterator);

    if (!Objects.equals(entry, lastAttribute)) {
      writer.write(escape(builder.toString()));
      builder.setLength(0);
      endEntity(lastAttribute, writer);
      beginEntity(entry, writer);
    }

    builder.append(iterator.current());

    lastAttribute = entry;
    iterator.next();
  }
  writer.write(escape(builder.toString()));
  endEntity(lastAttribute, writer);
}
 
开发者ID:AgeOfWar,项目名称:Telejam,代码行数:29,代码来源:HtmlTextWriter.java

示例7: getEntitiesWithValues

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private <T> List<Map.Entry<String, T>> getEntitiesWithValues(TextEntity entity) {
  AttributedCharacterIterator iterator = getIterator();
  List<Map.Entry<String, T>> entities = new ArrayList<>();
  StringBuilder builder = new StringBuilder();

  Map<AttributedCharacterIterator.Attribute, T> last = Collections.emptyMap();
  while (iterator.getIndex() != iterator.getEndIndex()) {
    Map<AttributedCharacterIterator.Attribute, T> curr =
        (Map<AttributedCharacterIterator.Attribute, T>) iterator.getAttributes();
    if (curr.containsKey(entity)) {
      builder.append(iterator.current());
    } else {
      if (last.containsKey(entity)) {
        entities.add(
            new AbstractMap.SimpleImmutableEntry<>(builder.toString(), last.get(entity))
        );
        builder.setLength(0);
      }
    }
    last = curr;

    iterator.next();
  }
  if (last.containsKey(entity)) {
    entities.add(
        new AbstractMap.SimpleImmutableEntry<>(builder.toString(), last.get(entity))
    );
  }

  return entities;
}
 
开发者ID:AgeOfWar,项目名称:Telejam,代码行数:33,代码来源:Text.java

示例8: equals

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
@Override
public boolean equals(Object obj) {
  if (obj == this) {
    return true;
  }

  if(!(obj instanceof Text)) {
    return false;
  }

  Text text = (Text) obj;

  if (this.length() != text.length()) {
    return false;
  }

  AttributedCharacterIterator it1 = this.getIterator();
  AttributedCharacterIterator it2 = text.getIterator();
  while (true) {
    if (it1.getIndex() == it1.getEndIndex()) {
      break;
    }

    if (it1.next() != it2.next()) {
      return false;
    }
    Map map1 = it1.getAttributes();
    Map map2 = it2.getAttributes();
    if (!map1.equals(map2)) {
      return false;
    }
  }
  return true;
}
 
开发者ID:AgeOfWar,项目名称:Telejam,代码行数:35,代码来源:Text.java

示例9: append

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
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);
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:14,代码来源:ScientificNumberFormatter.java

示例10: format

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
@Override
String format(
        AttributedCharacterIterator iterator,
        String preExponent) {
    int copyFromOffset = 0;
    StringBuilder result = new StringBuilder();
    for (
            iterator.first();
            iterator.current() != CharacterIterator.DONE;
        ) {
        Map<Attribute, Object> attributeSet = iterator.getAttributes();
        if (attributeSet.containsKey(NumberFormat.Field.EXPONENT_SYMBOL)) {
            append(
                    iterator,
                    copyFromOffset,
                    iterator.getRunStart(NumberFormat.Field.EXPONENT_SYMBOL),
                    result);
            copyFromOffset = iterator.getRunLimit(NumberFormat.Field.EXPONENT_SYMBOL);
            iterator.setIndex(copyFromOffset);
            result.append(preExponent);
            result.append(beginMarkup);
        } else if (attributeSet.containsKey(NumberFormat.Field.EXPONENT)) {
            int limit = iterator.getRunLimit(NumberFormat.Field.EXPONENT);
            append(
                    iterator,
                    copyFromOffset,
                    limit,
                    result);
            copyFromOffset = limit;
            iterator.setIndex(copyFromOffset);
            result.append(endMarkup);
        } else {
            iterator.next();
        }
    }
    append(iterator, copyFromOffset, iterator.getEndIndex(), result);
    return result.toString();
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:39,代码来源:ScientificNumberFormatter.java

示例11: char32AtAndAdvance

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
private static int char32AtAndAdvance(AttributedCharacterIterator iterator) {
    char c1 = iterator.current();
    char c2 = iterator.next();
    if (UCharacter.isHighSurrogate(c1)) {
        // If c2 is DONE, it will fail the low surrogate test and we
        // skip this block.
        if (UCharacter.isLowSurrogate(c2)) {
            iterator.next();
            return UCharacter.toCodePoint(c1, c2);
        }
    }
    return c1;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:14,代码来源:ScientificNumberFormatter.java

示例12: TextLayout

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
/**
 * Constructs a <code>TextLayout</code> from an iterator over styled text.
 * <p>
 * The iterator must specify a single paragraph of text because an
 * entire paragraph is required for the bidirectional
 * algorithm.
 * @param text the styled text to display
 * @param frc contains information about a graphics device which is needed
 *       to measure the text correctly.
 *       Text measurements can vary slightly depending on the
 *       device resolution, and attributes such as antialiasing.  This
 *       parameter does not specify a translation between the
 *       <code>TextLayout</code> and user space.
 */
public TextLayout(AttributedCharacterIterator text, FontRenderContext frc) {

    if (text == null) {
        throw new IllegalArgumentException("Null iterator passed to TextLayout constructor.");
    }

    int start = text.getBeginIndex();
    int limit = text.getEndIndex();
    if (start == limit) {
        throw new IllegalArgumentException("Zero length iterator passed to TextLayout constructor.");
    }

    int len = limit - start;
    text.first();
    char[] chars = new char[len];
    int n = 0;
    for (char c = text.first();
         c != CharacterIterator.DONE;
         c = text.next())
    {
        chars[n++] = c;
    }

    text.first();
    if (text.getRunLimit() == limit) {

        Map<? extends Attribute, ?> attributes = text.getAttributes();
        Font font = singleFont(chars, 0, len, attributes);
        if (font != null) {
            fastInit(chars, font, attributes, frc);
            return;
        }
    }

    standardInit(text, chars, frc);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:51,代码来源:TextLayout.java

示例13: TextLayout

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
/**
 * Constructs a {@code TextLayout} from an iterator over styled text.
 * <p>
 * The iterator must specify a single paragraph of text because an
 * entire paragraph is required for the bidirectional
 * algorithm.
 * @param text the styled text to display
 * @param frc contains information about a graphics device which is needed
 *       to measure the text correctly.
 *       Text measurements can vary slightly depending on the
 *       device resolution, and attributes such as antialiasing.  This
 *       parameter does not specify a translation between the
 *       {@code TextLayout} and user space.
 */
public TextLayout(AttributedCharacterIterator text, FontRenderContext frc) {

    if (text == null) {
        throw new IllegalArgumentException("Null iterator passed to TextLayout constructor.");
    }

    int start = text.getBeginIndex();
    int limit = text.getEndIndex();
    if (start == limit) {
        throw new IllegalArgumentException("Zero length iterator passed to TextLayout constructor.");
    }

    int len = limit - start;
    text.first();
    char[] chars = new char[len];
    int n = 0;
    for (char c = text.first();
         c != CharacterIterator.DONE;
         c = text.next())
    {
        chars[n++] = c;
    }

    text.first();
    if (text.getRunLimit() == limit) {

        Map<? extends Attribute, ?> attributes = text.getAttributes();
        Font font = singleFont(chars, 0, len, attributes);
        if (font != null) {
            fastInit(chars, font, attributes, frc);
            return;
        }
    }

    standardInit(text, chars, frc);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:51,代码来源:TextLayout.java

示例14: dumpIterator

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
private static final void dumpIterator(AttributedCharacterIterator iterator) {
    Set attributeKeys = iterator.getAllAttributeKeys();
    System.out.print("All attributes: ");
    Iterator keyIterator = attributeKeys.iterator();
    while (keyIterator.hasNext()) {
        Attribute key = (Attribute) keyIterator.next();
        System.out.print(key);
    }
    for(char c = iterator.first(); c != CharacterIterator.DONE; c = iterator.next()) {
        if (iterator.getIndex() == iterator.getBeginIndex() ||
                    iterator.getIndex() == iterator.getRunStart()) {
            System.out.println();
            Map attributes = iterator.getAttributes();
            Set entries = attributes.entrySet();
            Iterator attributeIterator = entries.iterator();
            while (attributeIterator.hasNext()) {
                Map.Entry entry = (Map.Entry) attributeIterator.next();
                System.out.print("<" + entry.getKey() + ": "
                            + entry.getValue() + ">");
            }
        }
        System.out.print(" ");
        System.out.print(c);
    }
    System.out.println();
    System.out.println("done");
    System.out.println();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:AttributedStringTest.java

示例15: iterateRun

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
private boolean iterateRun(AttributedCharacterIterator iterator, StringBuilder sb) {
	sb.setLength(0);
	int charCount = iterator.getRunLimit() - iterator.getRunStart();
	while (charCount-- >= 0) {
		char c = iterator.current();
		iterator.next();
		if (c == AttributedCharacterIterator.DONE) {
			return false;
		} else {
			sb.append(c);
		}
	}
	return true;
}
 
开发者ID:rototor,项目名称:pdfbox-graphics2d,代码行数:15,代码来源:PdfBoxGraphics2DFontTextDrawer.java


注:本文中的java.text.AttributedCharacterIterator.next方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。