getAttribute实例例java,Java AttributedCharacterIterator.getAttribute方法代码示例
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)+".)");
}
}
getAttribute实例例java,Java AttributedCharacterIterator.getAttribute方法代码示例相关推荐
- java kryo_Kryo框架使用方法代码示例
Kryo框架的source已移至https://github.com/EsotericSoftware/kryo ,进入此页面,然后点击右边的Download Zip按钮,就能下载到最新版本的Kryo ...
- java readtimeout_Java HttpURLConnection.getReadTimeout方法代码示例
import java.net.HttpURLConnection; //导入方法依赖的package包/类 /** * 得到响应对象 * * @param urlConnection * @retu ...
- java invalidate_Java Component.invalidate方法代码示例
import java.awt.Component; //导入方法依赖的package包/类 /** Installs the component we will embed to display t ...
- java hasmoreelements_Java IOException.hasMoreElements方法代码示例
import java.io.IOException; //导入方法依赖的package包/类 /** * fileName���� ���� package �������� ������ ���� ...
- java methode_Java Method.getTypeParameters方法代码示例
import java.lang.reflect.Method; //导入方法依赖的package包/类 private void validateRuleMethod(MethodRuleDefin ...
- java setmethod_Java Operation.setJavaMethod方法代码示例
import com.sun.tools.internal.ws.processor.model.Operation; //导入方法依赖的package包/类 private void createJ ...
- java cancel_Java RunnableFuture.cancel方法代码示例
import java.util.concurrent.RunnableFuture; //导入方法依赖的package包/类 @Test public void testSnapshotAsyncC ...
- java getevent_Java ActionEvent.getWhen方法代码示例
import java.awt.event.ActionEvent; //导入方法依赖的package包/类 @Override final public void actionPerformed(A ...
- java getdocument_Java Element.getDocument方法代码示例
import javax.swing.text.Element; //导入方法依赖的package包/类 /** * Writes out all empty elements (all tags t ...
- java deepcopy_Java JsonNode.deepCopy方法代码示例
import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类 /** * Applies this schema rule t ...
最新文章
- Cell二连发 | 广东CDC/耶鲁大学利用纳米孔测序揭示中/美新冠病毒基因组流行病学传播规律...
- 在安装完成oracle的时候,需要su - oracle,但有时候出现ulimit pize...
- 系统分析的几个好工具
- 岩板铺地好吗_威廉顿岩板1200x2700x9mm,上墙铺地非常好看大气
- 004_JavaScript版本
- 信息熵和交叉熵的细节理解
- SAP移动类型103解析
- 关闭Apache的目录浏览功能
- 受检异常 非受检异常_这样设计 Java 异常更优雅,赶紧学
- python装饰器作用和功能_python装饰器大详解
- 【英语学习】【WOTD】resurrection 释义/词源/示例
- java sort 效率_性能对比:collections.sort vs treeSet sort vs java8 stream.sorted
- java oracle 中文列_java oracle中文乱码怎么办
- maxscale mysql 主从_MariaDB主从配置与MaxScale实现MySQL读写分离
- 网络视频和移动营销 一根绳子上的蚂蚱
- 高通410 随身WIFI刷入Debian系统(玩法合集)
- CaptureScreenshot
- 四年上册级计算机教学计划,四年级上学期教学计划(通用5篇)
- 项目管理方法工具总结—挣值分析
- 毕业论文避免查重率过高技巧
热门文章
- R6300V2 从 DD-WRT 回刷恢复 官方原厂固件 DD-WRT to R6300V2
- windows终止处理程序( __try __finally) 简单解析
- Eclipse 工具的安装和配置
- 数据访问组件SqlHelper
- Windows与Linux比较:相似与不同
- springboot项目中使用spring的xml文件
- 在vs中用正则表达式查找字符并替换
- gitlab ssh key
- MyBatis3整合Spring3、SpringMVC3
- 《嵌入式Linux软硬件开发详解——基于S5PV210处理器》——2.3 SLC Nand Flash芯片