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


Java AttributedCharacterIterator.getRunStart方法代码示例

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


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

示例1: 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

示例2: checkIteratorSubranges

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
private static final void checkIteratorSubranges(AttributedCharacterIterator iterator, int[] expectedLimits) throws Exception {
    int previous = 0;
    char c = iterator.first();
    for (int i = 0; i < expectedLimits.length; i++) {
         if (iterator.getRunStart() != previous || iterator.getRunLimit() != expectedLimits[i]) {
             throwException(iterator, "run boundaries are not as expected: " + iterator.getRunStart() + ", " + iterator.getRunLimit());
         }
         previous = expectedLimits[i];
         c = iterator.setIndex(previous);
    }
    if (c != CharacterIterator.DONE) {
        throwException(iterator, "iterator's run sequence doesn't end with DONE");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:AttributedStringTest.java

示例3: 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

示例4: 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

示例5: main

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        String text = "Hello world";
        AttributedString as = new AttributedString(text);

        // add non-Annotation attributes
        as.addAttribute(TextAttribute.WEIGHT,
                        TextAttribute.WEIGHT_LIGHT,
                        0,
                        3);
        as.addAttribute(TextAttribute.WEIGHT,
                        TextAttribute.WEIGHT_BOLD,
                        3,
                        5);
        as.addAttribute(TextAttribute.WEIGHT,
                        TextAttribute.WEIGHT_EXTRABOLD,
                        5,
                        text.length());

        // add Annotation attributes
        as.addAttribute(TextAttribute.WIDTH,
                        new Annotation(TextAttribute.WIDTH_EXTENDED),
                        0,
                        3);
        as.addAttribute(TextAttribute.WIDTH,
                        new Annotation(TextAttribute.WIDTH_CONDENSED),
                        3,
                        4);

        AttributedCharacterIterator aci = as.getIterator(null, 2, 4);

        aci.first();
        int runStart = aci.getRunStart();
        if (runStart != 2) {
            throw new Exception("1st run start is wrong. ("+runStart+" should be 2.)");
        }

        int runLimit = aci.getRunLimit();
        if (runLimit != 3) {
            throw new Exception("1st run limit is wrong. ("+runLimit+" should be 3.)");
        }

        Object value = aci.getAttribute(TextAttribute.WEIGHT);
        if (value != TextAttribute.WEIGHT_LIGHT) {
            throw new Exception("1st run attribute is wrong. ("
                                +value+" should be "+TextAttribute.WEIGHT_LIGHT+".)");
        }

        value = aci.getAttribute(TextAttribute.WIDTH);
        if (value != null) {
            throw new Exception("1st run annotation is wrong. ("
                                +value+" should be null.)");
        }

        aci.setIndex(runLimit);
        runStart = aci.getRunStart();
        if (runStart != 3) {
            throw new Exception("2nd run start is wrong. ("+runStart+" should be 3.)");
        }

        runLimit = aci.getRunLimit();
        if (runLimit != 4) {
            throw new Exception("2nd run limit is wrong. ("+runLimit+" should be 4.)");
        }
        value = aci.getAttribute(TextAttribute.WEIGHT);
        if (value != TextAttribute.WEIGHT_BOLD) {
            throw new Exception("2nd run attribute is wrong. ("
                                +value+" should be "+TextAttribute.WEIGHT_BOLD+".)");
        }

        value = aci.getAttribute(TextAttribute.WIDTH);
        if (!(value instanceof Annotation)
            || (((Annotation)value).getValue() !=  TextAttribute.WIDTH_CONDENSED)) {
            throw new Exception("2nd run annotation is wrong. (" + value + " should be "
                                + new Annotation(TextAttribute.WIDTH_CONDENSED)+".)");
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:78,代码来源:getRunStartLimitTest.java


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