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


Java Annotation类代码示例

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


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

示例1: entrySet

import java.text.Annotation; //导入依赖的package包/类
public Set<Entry<Attribute, Object>> entrySet() {
    HashSet<Entry<Attribute, Object>> set = new HashSet<>();
    synchronized (AttributedString.this) {
        int size = runAttributes[runIndex].size();
        for (int i = 0; i < size; i++) {
            Attribute key = runAttributes[runIndex].get(i);
            Object value = runAttributeValues[runIndex].get(i);
            if (value instanceof Annotation) {
                value = AttributedString.this.getAttributeCheckRange(key,
                                                     runIndex, beginIndex, endIndex);
                if (value == null) {
                    continue;
                }
            }

            Entry<Attribute, Object> entry = new AttributeEntry(key, value);
            set.add(entry);
        }
    }
    return set;
}
 
开发者ID:Yun-Shan,项目名称:Yun_Shan-Common-Library,代码行数:22,代码来源:AttributedString.java

示例2: populateText

import java.text.Annotation; //导入依赖的package包/类
private void populateText(Paragraph p, AttributedString as, boolean insertBreakBefore, Direction blockDirection) {
    if (as != null) {
        List<Serializable> content = p.getContent();
        if (insertBreakBefore)
            content.add(ttmlFactory.createBr(ttmlFactory.createBreak()));
        AttributedCharacterIterator aci = as.getIterator();
        aci.first();
        StringBuffer sb = new StringBuffer();
        while (aci.current() != CharacterIterator.DONE) {
            int i = aci.getRunStart();
            int e = aci.getRunLimit();
            Annotation annotation = (Annotation) aci.getAttribute(TextAttribute.ANNOTATION);
            while (i < e) {
                sb.append(aci.setIndex(i++));
            }
            String text = sb.toString();
            if (annotation != null)
                content.add(ttmlFactory.createSpan(createSpan(text, (Attribute) annotation.getValue(), blockDirection)));
            else
                content.add(text);
            sb.setLength(0);
            aci.setIndex(e);
        }
    }
}
 
开发者ID:skynav,项目名称:ttt,代码行数:26,代码来源:Converter.java

示例3: main

import java.text.Annotation; //导入依赖的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

示例4: unpackAttributes

import java.text.Annotation; //导入依赖的package包/类
/**
     * Adds InputMethodHighlight to the attributes
     * @param attrs - text attributes
     * @return patched text attributes
     */
    Map<? extends Attribute, ?> unpackAttributes(Map<? extends Attribute, ?> attrs) {
        if (attrs.containsKey(TextAttribute.INPUT_METHOD_HIGHLIGHT)) {
            Map<TextAttribute, ?> styles = null;

            Object val = attrs.get(TextAttribute.INPUT_METHOD_HIGHLIGHT);

            if (val instanceof Annotation) {
                val = ((Annotation) val).getValue();
            }
//
//            if (val instanceof InputMethodHighlight) {
//                InputMethodHighlight ihl = ((InputMethodHighlight) val);
//                styles = ihl.getStyle();
//
//                if (styles == null) {
//                    Toolkit tk = Toolkit.getDefaultToolkit();
//                    styles = tk.mapInputMethodHighlight(ihl);
//                }
//            }

            if (styles != null) {
                HashMap<Attribute, Object> newAttrs = new HashMap<Attribute, Object>();
                newAttrs.putAll(attrs);
                newAttrs.putAll(styles);
                return newAttrs;
            }
        }

        return attrs;
    }
 
开发者ID:windwardadmin,项目名称:android-awt,代码行数:36,代码来源:TextRunBreaker.java

示例5: unpackAttributes

import java.text.Annotation; //导入依赖的package包/类
/**
     * Adds InputMethodHighlight to the attributes
     * @param attrs - text attributes
     * @return patched text attributes
     */
    Map<? extends Attribute, ?> unpackAttributes(Map<? extends Attribute, ?> attrs) {
        if (attrs.containsKey(TextAttribute.INPUT_METHOD_HIGHLIGHT)) {
            Map<TextAttribute, ?> styles = null;

            Object val = attrs.get(TextAttribute.INPUT_METHOD_HIGHLIGHT);

            if (val instanceof Annotation) {
                val = ((Annotation) val).getValue();
            }

//            if (val instanceof InputMethodHighlight) {
//                InputMethodHighlight ihl = ((InputMethodHighlight) val);
//                styles = ihl.getStyle();
//
//                if (styles == null) {
//                    Toolkit tk = Toolkit.getDefaultToolkit();
//                    styles = tk.mapInputMethodHighlight(ihl);
//                }
//            }

            if (styles != null) {
                HashMap<Attribute, Object> newAttrs = new HashMap<Attribute, Object>();
                newAttrs.putAll(attrs);
                newAttrs.putAll(styles);
                return newAttrs;
            }
        }

        return attrs;
    }
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:36,代码来源:TextRunBreaker.java

示例6: unpackAttributes

import java.text.Annotation; //导入依赖的package包/类
/**
 * Adds InputMethodHighlight to the attributes
 * @param attrs - text attributes
 * @return patched text attributes
 */
Map<? extends Attribute, ?> unpackAttributes(Map<? extends Attribute, ?> attrs) {
    if (attrs.containsKey(TextAttribute.INPUT_METHOD_HIGHLIGHT)) {
        Map<TextAttribute, ?> styles = null;

        Object val = attrs.get(TextAttribute.INPUT_METHOD_HIGHLIGHT);

        if (val instanceof Annotation) {
            val = ((Annotation) val).getValue();
        }

        if (val instanceof InputMethodHighlight) {
            InputMethodHighlight ihl = ((InputMethodHighlight) val);
            styles = ihl.getStyle();

            if (styles == null) {
                Toolkit tk = Toolkit.getDefaultToolkit();
                styles = tk.mapInputMethodHighlight(ihl);
            }
        }

        if (styles != null) {
            HashMap<Attribute, Object> newAttrs = new HashMap<Attribute, Object>();
            newAttrs.putAll(attrs);
            newAttrs.putAll(styles);
            return newAttrs;
        }
    }

    return attrs;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:36,代码来源:TextRunBreaker.java

示例7: testToString

import java.text.Annotation; //导入依赖的package包/类
/**
 * @tests java.text.Annotation.toString()
 */
public void testToString() {
       Annotation ant = new Annotation("HelloWorld");
       assertEquals("toString error.",
                    "java.text.Annotation[value=HelloWorld]",ant.toString());
       assertNotNull(new Annotation(null).toString());
       assertNotNull(new Annotation("value").toString());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:11,代码来源:AnnotationTest.java

示例8: setInputMethodHighlight

import java.text.Annotation; //导入依赖的package包/类
public void setInputMethodHighlight(Annotation f) {
this.imHighlight = f; update(EINPUT_METHOD_HIGHLIGHT); }
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:3,代码来源:AttributeValues.java

示例9: AnnotatedRange

import java.text.Annotation; //导入依赖的package包/类
public AnnotatedRange(Annotation annotation, int start, int end) {
    this.annotation = annotation;
    this.start = start;
    this.end = end;
}
 
开发者ID:skynav,项目名称:ttt,代码行数:6,代码来源:Converter.java

示例10: testAnnotation

import java.text.Annotation; //导入依赖的package包/类
/**
 * @tests java.text.Annotation(Object)
 */
public void testAnnotation() {
	assertNotNull(new Annotation(null));
	assertNotNull(new Annotation("value"));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:8,代码来源:AnnotationTest.java


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