本文整理汇总了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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
示例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();
}