Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
a4166090
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a4166090
编写于
3月 30, 2011
作者:
M
mrkam
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7027693: /jfc/CodePointIM demo needs to be improved
Reviewed-by: alexp
上级
ed328ea1
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
63 addition
and
72 deletion
+63
-72
src/share/demo/jfc/CodePointIM/CodePointIM.java
src/share/demo/jfc/CodePointIM/CodePointIM.java
+7
-7
src/share/demo/jfc/CodePointIM/CodePointInputMethod.java
src/share/demo/jfc/CodePointIM/CodePointInputMethod.java
+50
-57
src/share/demo/jfc/CodePointIM/CodePointInputMethodDescriptor.java
.../demo/jfc/CodePointIM/CodePointInputMethodDescriptor.java
+6
-8
未找到文件。
src/share/demo/jfc/CodePointIM/CodePointIM.java
浏览文件 @
a4166090
/*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004,
2011,
Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -29,12 +29,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
import
java.util.Locale
;
import
java.util.MissingResourceException
;
import
java.util.ResourceBundle
;
public
class
CodePointIM
{
// Actually, the main method is not required for InputMethod.
...
...
@@ -42,11 +42,11 @@ public class CodePointIM {
// not correct and encourage their reading README.txt.
public
static
void
main
(
String
[]
args
)
{
try
{
ResourceBundle
resource
=
ResourceBundle
.
getBundle
(
"resources.codepoint"
,
ResourceBundle
resource
=
ResourceBundle
.
getBundle
(
"resources.codepoint"
,
Locale
.
getDefault
());
System
.
err
.
println
(
resource
.
getString
(
"warning"
));
}
catch
(
MissingResourceException
e
)
{
}
catch
(
MissingResourceException
e
)
{
System
.
err
.
println
(
e
.
toString
());
}
...
...
src/share/demo/jfc/CodePointIM/CodePointInputMethod.java
浏览文件 @
a4166090
/*
* Copyright (c) 2002, 20
04
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 20
11
, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -28,13 +28,8 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
package
com.sun.inputmethods.internal.codepointim
;
import
java.text.AttributedCharacterIterator
;
import
java.util.Map
;
import
java.awt.AWTEvent
;
import
java.awt.Toolkit
;
...
...
@@ -50,6 +45,7 @@ import java.io.IOException;
import
java.text.AttributedString
;
import
java.util.Locale
;
/**
* The Code Point Input Method is a simple input method that allows Unicode
* characters to be entered using their code point or code unit values. See the
...
...
@@ -63,14 +59,12 @@ public class CodePointInputMethod implements InputMethod {
private
static
final
int
ESCAPE
=
1
;
// \u0000 - \uFFFF
private
static
final
int
SPECIAL_ESCAPE
=
2
;
// \U000000 - \U10FFFF
private
static
final
int
SURROGATE_PAIR
=
3
;
// \uD800\uDC00 - \uDBFF\uDFFF
private
InputMethodContext
context
;
private
Locale
locale
;
private
StringBuffer
buffer
;
private
int
insertionPoint
;
private
int
format
=
UNSET
;
public
CodePointInputMethod
()
throws
IOException
{
}
...
...
@@ -221,7 +215,7 @@ public class CodePointInputMethod implements InputMethod {
private
void
waitDigit2
(
char
c
)
{
if
(
Character
.
digit
(
c
,
16
)
!=
-
1
)
{
buffer
.
insert
(
insertionPoint
++,
c
);
char
codePoint
=
(
char
)
getCodePoint
(
buffer
,
2
,
5
);
char
codePoint
=
(
char
)
getCodePoint
(
buffer
,
2
,
5
);
if
(
Character
.
isHighSurrogate
(
codePoint
))
{
format
=
SURROGATE_PAIR
;
buffer
.
append
(
"\\u"
);
...
...
@@ -383,7 +377,7 @@ public class CodePointInputMethod implements InputMethod {
private
void
finishComposition
()
{
int
len
=
buffer
.
length
();
if
(
len
==
6
&&
format
!=
SPECIAL_ESCAPE
)
{
char
codePoint
=
(
char
)
getCodePoint
(
buffer
,
2
,
5
);
char
codePoint
=
(
char
)
getCodePoint
(
buffer
,
2
,
5
);
if
(
Character
.
isValidCodePoint
(
codePoint
)
&&
codePoint
!=
0xFFFF
)
{
buffer
.
setLength
(
0
);
buffer
.
append
(
codePoint
);
...
...
@@ -400,11 +394,11 @@ public class CodePointInputMethod implements InputMethod {
}
}
else
if
(
len
==
12
&&
format
==
SURROGATE_PAIR
)
{
char
[]
codePoint
=
{
(
char
)
getCodePoint
(
buffer
,
2
,
5
),
(
char
)
getCodePoint
(
buffer
,
8
,
11
)
(
char
)
getCodePoint
(
buffer
,
2
,
5
),
(
char
)
getCodePoint
(
buffer
,
8
,
11
)
};
if
(
Character
.
isHighSurrogate
(
codePoint
[
0
])
&&
Character
.
isLowSurrogate
(
codePoint
[
1
]))
{
if
(
Character
.
isHighSurrogate
(
codePoint
[
0
])
&&
Character
.
isLowSurrogate
(
codePoint
[
1
]))
{
buffer
.
setLength
(
0
);
buffer
.
append
(
codePoint
);
sendCommittedText
();
...
...
@@ -418,7 +412,7 @@ public class CodePointInputMethod implements InputMethod {
private
int
getCodePoint
(
StringBuffer
sb
,
int
from
,
int
to
)
{
int
value
=
0
;
for
(
int
i
=
from
;
i
<=
to
;
i
++)
{
value
=
(
value
<<
4
)
+
Character
.
digit
(
sb
.
charAt
(
i
),
16
);
value
=
(
value
<<
4
)
+
Character
.
digit
(
sb
.
charAt
(
i
),
16
);
}
return
value
;
}
...
...
@@ -427,7 +421,6 @@ public class CodePointInputMethod implements InputMethod {
Toolkit
.
getDefaultToolkit
().
beep
();
}
public
void
activate
()
{
if
(
buffer
==
null
)
{
buffer
=
new
StringBuffer
(
12
);
...
...
src/share/demo/jfc/CodePointIM/CodePointInputMethodDescriptor.java
浏览文件 @
a4166090
/*
* Copyright (c) 2002, 20
04
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 20
11
, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
...
...
@@ -28,17 +28,15 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
*/
package
com.sun.inputmethods.internal.codepointim
;
import
java.awt.Image
;
import
java.awt.im.spi.InputMethodDescriptor
;
import
java.awt.im.spi.InputMethod
;
import
java.util.Locale
;
/**
* The CodePointInputMethod is a simple input method that allows Unicode
* characters to be entered via their hexadecimal code point values.
...
...
@@ -68,12 +66,12 @@ public class CodePointInputMethodDescriptor implements InputMethodDescriptor {
*/
public
Locale
[]
getAvailableLocales
()
{
Locale
[]
locales
=
{
new
Locale
(
""
,
""
,
""
),
};
new
Locale
(
""
,
""
,
""
),
};
return
locales
;
}
public
synchronized
String
getInputMethodDisplayName
(
Locale
inputLocale
,
Locale
displayLanguage
)
{
public
synchronized
String
getInputMethodDisplayName
(
Locale
inputLocale
,
Locale
displayLanguage
)
{
return
"CodePoint Input Method"
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录