當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。