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


Java AttributedCharacterIterator.Attribute方法代码示例

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


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

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

示例2: getAttribute

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
/**
 * Returns the value of the named attribute for the current character.
 * Returns null if the attribute is not defined.
 * @param attribute the key of the attribute whose value is requested.
 */
public Object getAttribute(AttributedCharacterIterator.Attribute attribute) {
    int pos = toModelPosition(getIndex());
    int childIndex = v.getViewIndex(pos, Position.Bias.Forward);
    if (attribute == TextAttribute.FONT) {
        return getFont(childIndex);
    } else if( attribute == TextAttribute.RUN_DIRECTION ) {
        return
            v.getDocument().getProperty(TextAttribute.RUN_DIRECTION);
    } else if (attribute == TextAttribute.NUMERIC_SHAPING) {
        return shaper;
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:TextLayoutStrategy.java

示例3: getAttribute

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
public Object getAttribute(AttributedCharacterIterator.Attribute att) {
    if (att == TextAttribute.FONT) {
        return fonts[getIndex()];
    } else if (att == TextAttribute.FOREGROUND) {
        return colors[getIndex()];
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:AttributedCharacters.java

示例4: getAttributes

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
public Map<AttributedCharacterIterator.Attribute,Object> getAttributes() {
    Map<AttributedCharacterIterator.Attribute,Object> m = new HashMap<AttributedCharacterIterator.Attribute,Object>(1);
    m.put(TextAttribute.FONT, fonts[getIndex()]);
    m.put(TextAttribute.FOREGROUND, colors[getIndex()]);

    return m;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:AttributedCharacters.java

示例5: getRunLimit

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
public int getRunLimit(AttributedCharacterIterator.Attribute att) {
    if ((att != TextAttribute.FONT) && (att != TextAttribute.FOREGROUND)) {
        return getEndIndex(); // undefined attribute
    }

    return getRunLimit();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:AttributedCharacters.java

示例6: getRunLimit

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
/**
 * Returns the index of the first character following the run
 * with respect to the given attribute containing the current character.
 */
public int getRunLimit(AttributedCharacterIterator.Attribute attribute) {
    if (attribute instanceof TextAttribute) {
        int pos = toModelPosition(getIndex());
        int i = v.getViewIndex(pos, Position.Bias.Forward);
        if (attribute == TextAttribute.FONT) {
            return toIteratorIndex(getFontBoundary(i, 1));
        }
    }
    return getEndIndex();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:TextLayoutStrategy.java

示例7: getRunStart

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
public int getRunStart(Set<? extends AttributedCharacterIterator.Attribute> attributes) {
    if ((attributes.contains(TextAttribute.FONT)) || attributes.contains(TextAttribute.FOREGROUND)) {
        return getRunStart();
    } else {
        return 0;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:AttributedCharacters.java

示例8: getTextAttribute

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
@SuppressWarnings("serial")
private static AttributedCharacterIterator.Attribute
    getTextAttribute(String name)
{
    if (jafa == null) {
        // fake attribute
        return new AttributedCharacterIterator.Attribute(name) { };
    } else {
        return (AttributedCharacterIterator.Attribute)jafa.getTextAttributeConstant(name);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:BidiBase.java

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

示例10: addAttribute

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
@Override
public void addAttribute(AttributedCharacterIterator.Attribute attribute, Object value) {
  if (!(attribute instanceof TextEntity)) {
    throw new IllegalArgumentException("Invalid attribute");
  }
  super.addAttribute(attribute, value);
}
 
开发者ID:AgeOfWar,项目名称:Telejam,代码行数:8,代码来源:Text.java

示例11: addAttributes

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
@Override
public void addAttributes(Map<? extends AttributedCharacterIterator.Attribute, ?> attributes, int beginIndex, int endIndex) {
  for (AttributedCharacterIterator.Attribute attribute : attributes.keySet()) {
    if (!(attribute instanceof TextEntity)) {
      throw new IllegalArgumentException("Invalid attribute(s)");
    }
  }
  super.addAttributes(attributes, beginIndex, endIndex);
}
 
开发者ID:AgeOfWar,项目名称:Telejam,代码行数:10,代码来源:Text.java

示例12: getTextAttribute

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
@SuppressWarnings("serial")
private static AttributedCharacterIterator.Attribute
    getTextAttribute(String name)
{
    if (clazz == null) {
        // fake attribute
        return new AttributedCharacterIterator.Attribute(name) { };
    } else {
        return (AttributedCharacterIterator.Attribute)getStaticField(clazz, name);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:BidiBase.java

示例13: getRunStart

import java.text.AttributedCharacterIterator; //导入方法依赖的package包/类
/**
 * Returns the index of the first character of the run
 * with respect to the given attribute containing the current character.
 */
public int getRunStart(AttributedCharacterIterator.Attribute attribute) {
    if (attribute instanceof TextAttribute) {
        int pos = toModelPosition(getIndex());
        int i = v.getViewIndex(pos, Position.Bias.Forward);
        if (attribute == TextAttribute.FONT) {
            return toIteratorIndex(getFontBoundary(i, -1));
        }
    }
    return getBeginIndex();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:TextLayoutStrategy.java


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