Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
1ab59122
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1ab59122
编写于
6月 02, 2010
作者:
R
rupashka
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6857057: api/javax_swing/text/GlyphView/index.html#Methods test fails
Reviewed-by: peterz
上级
64a27af3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
252 addition
and
5 deletion
+252
-5
src/share/classes/javax/swing/text/Utilities.java
src/share/classes/javax/swing/text/Utilities.java
+19
-1
src/share/classes/javax/swing/text/WrappedPlainView.java
src/share/classes/javax/swing/text/WrappedPlainView.java
+6
-4
test/javax/swing/text/WrappedPlainView/6857057/StubBranchElement.java
...wing/text/WrappedPlainView/6857057/StubBranchElement.java
+87
-0
test/javax/swing/text/WrappedPlainView/6857057/StubLeafElement.java
.../swing/text/WrappedPlainView/6857057/StubLeafElement.java
+81
-0
test/javax/swing/text/WrappedPlainView/6857057/bug6857057.java
...javax/swing/text/WrappedPlainView/6857057/bug6857057.java
+59
-0
未找到文件。
src/share/classes/javax/swing/text/Utilities.java
浏览文件 @
1ab59122
...
...
@@ -403,6 +403,24 @@ public class Utilities {
return
txtCount
;
}
/**
* Adjust text offset so that the length of a resulting string as a whole
* fits into the specified width.
*/
static
int
adjustOffsetForFractionalMetrics
(
Segment
s
,
FontMetrics
fm
,
int
offset
,
int
width
)
{
// Sometimes the offset returned by getTabbedTextOffset is beyond the
// available area, when fractional metrics are enabled. We should
// guard against this.
if
(
offset
<
s
.
count
)
{
while
(
offset
>
0
&&
fm
.
charsWidth
(
s
.
array
,
s
.
offset
,
offset
+
1
)
>
width
)
{
offset
--;
}
}
return
offset
;
}
/**
* Determine where to break the given text to fit
* within the given span. This tries to find a word boundary.
...
...
@@ -425,7 +443,7 @@ public class Utilities {
int
txtCount
=
s
.
count
;
int
index
=
Utilities
.
getTabbedTextOffset
(
s
,
metrics
,
x0
,
x
,
e
,
startOffset
,
false
);
index
=
adjustOffsetForFractionalMetrics
(
s
,
metrics
,
index
,
x
-
x0
);
if
(
index
>=
txtCount
-
1
)
{
return
txtCount
;
...
...
src/share/classes/javax/swing/text/WrappedPlainView.java
浏览文件 @
1ab59122
...
...
@@ -108,7 +108,7 @@ public class WrappedPlainView extends BoxView implements TabExpander {
try
{
if
(
line
.
isLeaf
())
{
drawText
(
line
,
p0
,
p1
,
g
,
x
,
y
);
drawText
(
line
,
p0
,
p1
,
g
,
x
,
y
);
}
else
{
// this line contains the composed text.
int
idx
=
line
.
getElementIndex
(
p0
);
...
...
@@ -239,9 +239,11 @@ public class WrappedPlainView extends BoxView implements TabExpander {
tabBase
,
tabBase
+
currentWidth
,
this
,
p0
);
}
else
{
p
=
p0
+
Utilities
.
getTabbedTextOffset
(
segment
,
metrics
,
tabBase
,
tabBase
+
currentWidth
,
this
,
p0
,
false
);
int
offset
=
Utilities
.
getTabbedTextOffset
(
segment
,
metrics
,
tabBase
,
tabBase
+
currentWidth
,
this
,
p0
,
false
);
offset
=
Utilities
.
adjustOffsetForFractionalMetrics
(
segment
,
metrics
,
offset
,
currentWidth
);
p
=
p0
+
offset
;
}
SegmentCache
.
releaseSharedSegment
(
segment
);
return
p
;
...
...
test/javax/swing/text/WrappedPlainView/6857057/StubBranchElement.java
0 → 100644
浏览文件 @
1ab59122
/*
* Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
import
javax.swing.text.*
;
class
StubBranchElement
implements
Element
{
Document
document
=
new
DefaultStyledDocument
();
String
context
;
Element
[]
children
=
new
StubLeafElement
[
3
];
public
StubBranchElement
(
String
context
)
{
this
.
context
=
context
;
int
len
=
context
.
length
()
/
3
;
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
children
[
i
]
=
new
StubLeafElement
(
context
.
substring
(
len
*
i
,
len
*
(
i
+
1
)),
this
,
len
*
i
);
}
try
{
document
.
insertString
(
0
,
context
,
new
SimpleAttributeSet
());
}
catch
(
BadLocationException
e
)
{
}
}
public
Document
getDocument
()
{
return
document
;
}
public
Element
getParentElement
()
{
return
null
;
}
public
String
getName
()
{
return
"StubBranchElement"
;
}
public
AttributeSet
getAttributes
()
{
return
new
SimpleAttributeSet
();
}
public
int
getStartOffset
()
{
return
0
;
}
public
int
getEndOffset
()
{
return
document
.
getLength
();
}
public
int
getElementIndex
(
int
offset
)
{
return
offset
/
3
;
}
public
int
getElementCount
()
{
return
3
;
}
public
Element
getElement
(
int
index
)
{
return
children
[
index
];
}
public
boolean
isLeaf
()
{
return
false
;
}
public
Element
[]
getChildren
()
{
return
children
;
}
}
test/javax/swing/text/WrappedPlainView/6857057/StubLeafElement.java
0 → 100644
浏览文件 @
1ab59122
/*
* Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
import
javax.swing.text.*
;
class
StubLeafElement
implements
Element
{
Document
document
=
new
DefaultStyledDocument
();
String
context
;
Element
parent
;
int
position
;
public
StubLeafElement
(
String
context
,
Element
parent
,
int
position
)
{
this
.
context
=
context
;
this
.
parent
=
parent
;
this
.
position
=
position
;
try
{
document
.
insertString
(
0
,
context
,
new
SimpleAttributeSet
());
}
catch
(
BadLocationException
e
)
{
}
}
public
Document
getDocument
()
{
return
document
;
}
public
Element
getParentElement
()
{
return
parent
;
}
public
String
getName
()
{
return
"StubLeafElement"
;
}
public
AttributeSet
getAttributes
()
{
return
new
SimpleAttributeSet
();
}
public
int
getStartOffset
()
{
return
position
;
}
public
int
getEndOffset
()
{
return
position
+
document
.
getLength
();
}
public
int
getElementIndex
(
int
offset
)
{
return
0
;
}
public
int
getElementCount
()
{
return
0
;
}
public
Element
getElement
(
int
index
)
{
return
this
;
}
public
boolean
isLeaf
()
{
return
true
;
}
}
test/javax/swing/text/WrappedPlainView/6857057/bug6857057.java
0 → 100644
浏览文件 @
1ab59122
/*
* Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6857057
* @summary test that the JCK GlyphView2021 test doesn't fail
* @author Sergey Groznyh
* @run main bug6857057
*/
import
javax.swing.*
;
import
javax.swing.text.Element
;
import
javax.swing.text.GlyphView
;
import
javax.swing.text.View
;
public
class
bug6857057
{
bug6857057
()
{
Element
elem
=
new
StubBranchElement
(
" G L Y P H V"
);
GlyphView
view
=
new
GlyphView
(
elem
);
float
pos
=
elem
.
getStartOffset
();
float
len
=
elem
.
getEndOffset
()
-
pos
;
int
res
=
view
.
getBreakWeight
(
View
.
X_AXIS
,
pos
,
len
);
if
(
res
!=
View
.
ExcellentBreakWeight
)
{
throw
new
RuntimeException
(
"breakWeight != ExcellentBreakWeight"
);
}
}
public
static
void
main
(
String
[]
args
)
throws
Throwable
{
SwingUtilities
.
invokeLater
(
new
Runnable
()
{
public
void
run
()
{
new
bug6857057
();
}
});
System
.
out
.
println
(
"OK"
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录