Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
3bb17d8a
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,发现更多精彩内容 >>
提交
3bb17d8a
编写于
4月 30, 2015
作者:
A
alexsch
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8044444: The output's 'Page-n' footer does not show completely
Reviewed-by: prr, serb
上级
b10d38cb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
326 addition
and
20 deletion
+326
-20
src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java
src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java
+34
-0
src/share/classes/sun/print/RasterPrinterJob.java
src/share/classes/sun/print/RasterPrinterJob.java
+28
-20
test/java/awt/print/PageFormat/ImageableAreaTest.java
test/java/awt/print/PageFormat/ImageableAreaTest.java
+264
-0
未找到文件。
src/macosx/classes/sun/lwawt/macosx/CPrinterJob.java
浏览文件 @
3bb17d8a
...
...
@@ -36,6 +36,10 @@ import java.security.PrivilegedAction;
import
javax.print.*
;
import
javax.print.attribute.PrintRequestAttributeSet
;
import
javax.print.attribute.HashPrintRequestAttributeSet
;
import
javax.print.attribute.standard.Media
;
import
javax.print.attribute.standard.MediaPrintableArea
;
import
javax.print.attribute.standard.MediaSize
;
import
javax.print.attribute.standard.MediaSizeName
;
import
javax.print.attribute.standard.PageRanges
;
import
sun.java2d.*
;
...
...
@@ -741,4 +745,34 @@ public final class CPrinterJob extends RasterPrinterJob {
protected
void
startPage
(
PageFormat
arg0
,
Printable
arg1
,
int
arg2
,
boolean
arg3
)
throws
PrinterException
{
// TODO Auto-generated method stub
}
@Override
protected
MediaSize
getMediaSize
(
Media
media
,
PrintService
service
,
PageFormat
page
)
{
if
(
media
==
null
||
!(
media
instanceof
MediaSizeName
))
{
return
getDefaultMediaSize
(
page
);
}
MediaSize
size
=
MediaSize
.
getMediaSizeForName
((
MediaSizeName
)
media
);
return
size
!=
null
?
size
:
getDefaultMediaSize
(
page
);
}
private
MediaSize
getDefaultMediaSize
(
PageFormat
page
){
final
int
inch
=
72
;
Paper
paper
=
page
.
getPaper
();
float
width
=
(
float
)
(
paper
.
getWidth
()
/
inch
);
float
height
=
(
float
)
(
paper
.
getHeight
()
/
inch
);
return
new
MediaSize
(
width
,
height
,
MediaSize
.
INCH
);
}
@Override
protected
MediaPrintableArea
getDefaultPrintableArea
(
PageFormat
page
,
double
w
,
double
h
)
{
final
float
dpi
=
72.0f
;
Paper
paper
=
page
.
getPaper
();
return
new
MediaPrintableArea
(
(
float
)
(
paper
.
getImageableX
()
/
dpi
),
(
float
)
(
paper
.
getImageableY
()
/
dpi
),
(
float
)
(
paper
.
getImageableWidth
()
/
dpi
),
(
float
)
(
paper
.
getImageableHeight
()
/
dpi
),
MediaPrintableArea
.
INCH
);
}
}
\ No newline at end of file
src/share/classes/sun/print/RasterPrinterJob.java
浏览文件 @
3bb17d8a
...
...
@@ -560,18 +560,8 @@ public abstract class RasterPrinterJob extends PrinterJob {
}
Media
media
=
(
Media
)
attSet
.
get
(
Media
.
class
);
if
(
media
==
null
)
{
media
=
(
Media
)
service
.
getDefaultAttributeValue
(
Media
.
class
);
}
if
(!(
media
instanceof
MediaSizeName
))
{
media
=
MediaSizeName
.
NA_LETTER
;
}
MediaSize
size
=
MediaSize
.
getMediaSizeForName
((
MediaSizeName
)
media
);
if
(
size
==
null
)
{
size
=
MediaSize
.
NA
.
LETTER
;
}
MediaSize
size
=
getMediaSize
(
media
,
service
,
page
);
Paper
paper
=
new
Paper
();
float
dim
[]
=
size
.
getSize
(
1
);
//units == 1 to avoid FP error
double
w
=
Math
.
rint
((
dim
[
0
]*
72.0
)/
Size2DSyntax
.
INCH
);
...
...
@@ -580,9 +570,11 @@ public abstract class RasterPrinterJob extends PrinterJob {
MediaPrintableArea
area
=
(
MediaPrintableArea
)
attSet
.
get
(
MediaPrintableArea
.
class
);
double
ix
,
iw
,
iy
,
ih
;
if
(
area
==
null
)
{
area
=
getDefaultPrintableArea
(
page
,
w
,
h
);
}
if
(
area
!=
null
)
{
double
ix
,
iw
,
iy
,
ih
;
// Should pass in same unit as updatePageAttributes
// to avoid rounding off errors.
ix
=
Math
.
rint
(
...
...
@@ -593,8 +585,25 @@ public abstract class RasterPrinterJob extends PrinterJob {
area
.
getWidth
(
MediaPrintableArea
.
INCH
)
*
DPI
);
ih
=
Math
.
rint
(
area
.
getHeight
(
MediaPrintableArea
.
INCH
)
*
DPI
);
paper
.
setImageableArea
(
ix
,
iy
,
iw
,
ih
);
page
.
setPaper
(
paper
);
return
page
;
}
else
{
protected
MediaSize
getMediaSize
(
Media
media
,
PrintService
service
,
PageFormat
page
)
{
if
(
media
==
null
)
{
media
=
(
Media
)
service
.
getDefaultAttributeValue
(
Media
.
class
);
}
if
(!(
media
instanceof
MediaSizeName
))
{
media
=
MediaSizeName
.
NA_LETTER
;
}
MediaSize
size
=
MediaSize
.
getMediaSizeForName
((
MediaSizeName
)
media
);
return
size
!=
null
?
size
:
MediaSize
.
NA
.
LETTER
;
}
protected
MediaPrintableArea
getDefaultPrintableArea
(
PageFormat
page
,
double
w
,
double
h
)
{
double
ix
,
iw
,
iy
,
ih
;
if
(
w
>=
72.0
*
6.0
)
{
ix
=
72.0
;
iw
=
w
-
2
*
72.0
;
...
...
@@ -609,10 +618,9 @@ public abstract class RasterPrinterJob extends PrinterJob {
iy
=
h
/
6.0
;
ih
=
h
*
0.75
;
}
}
paper
.
setImageableArea
(
ix
,
iy
,
iw
,
ih
);
page
.
setPaper
(
paper
);
return
page
;
return
new
MediaPrintableArea
((
float
)
(
ix
/
DPI
),
(
float
)
(
iy
/
DPI
),
(
float
)
(
iw
/
DPI
),
(
float
)
(
ih
/
DPI
),
MediaPrintableArea
.
INCH
);
}
protected
void
updatePageAttributes
(
PrintService
service
,
...
...
@@ -811,7 +819,7 @@ public abstract class RasterPrinterJob extends PrinterJob {
}
protected
PageFormat
getPageFormatFromAttributes
()
{
if
(
attributes
==
null
)
{
if
(
attributes
==
null
||
attributes
.
isEmpty
()
)
{
return
null
;
}
return
attributeToPageFormat
(
getPrintService
(),
this
.
attributes
);
...
...
test/java/awt/print/PageFormat/ImageableAreaTest.java
0 → 100644
浏览文件 @
3bb17d8a
/*
* Copyright (c) 2015, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.awt.BorderLayout
;
import
java.awt.Color
;
import
java.awt.Dialog
;
import
java.awt.FlowLayout
;
import
java.awt.print.Printable
;
import
java.awt.print.PrinterException
;
import
java.awt.print.PrinterJob
;
import
java.text.MessageFormat
;
import
javax.print.attribute.HashPrintRequestAttributeSet
;
import
javax.print.attribute.PrintRequestAttributeSet
;
import
javax.print.attribute.standard.Copies
;
import
javax.print.attribute.standard.DialogTypeSelection
;
import
javax.print.attribute.standard.MediaPrintableArea
;
import
javax.swing.JButton
;
import
javax.swing.JDialog
;
import
javax.swing.JFrame
;
import
javax.swing.JPanel
;
import
javax.swing.JTable
;
import
javax.swing.JTextArea
;
import
javax.swing.SwingUtilities
;
import
javax.swing.table.AbstractTableModel
;
import
javax.swing.table.TableModel
;
/**
* @test
* @bug 8044444
* @summary The output's 'Page-n' footer does not show completely
* @author Alexandr Scherbatiy
* @run main/manual ImageableAreaTest
*/
public
class
ImageableAreaTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
createAndShowTestDialog
(
"1. Press the Print Table button\n"
+
" Java print dialog should appear.\n"
+
"2. Press the Print button on the Java Print dialog.\n"
+
"2. Check that the page number is correctly printed.\n"
+
"If so, press PASS, else press FAIL."
,
"Page number is not correctly printed!"
,
ImageableAreaTest:
:
printWithJavaPrintDialog
);
createAndShowTestDialog
(
"1. Press the Print Table button\n"
+
" The table should be printed without the print dialog.\n"
+
"2. Check that the page number is correctly printed.\n"
+
"If so, press PASS, else press FAIL."
,
"Page number is not correctly printed!"
,
ImageableAreaTest:
:
printWithoutPrintDialog
);
createAndShowTestDialog
(
"1. Press the Print Table button\n"
+
" Java print dialog should appear.\n"
+
"2. Press the Print button on the Java Print dialog.\n"
+
"3. Check that the table has about half size of the printed page\n"
+
"If so, press PASS, else press FAIL."
,
"Custom imageable area is not correctly printed!"
,
ImageableAreaTest:
:
printWithCustomImageareaSize
);
}
});
}
private
static
void
printWithJavaPrintDialog
()
{
final
JTable
table
=
createAuthorTable
(
42
);
Printable
printable
=
table
.
getPrintable
(
JTable
.
PrintMode
.
NORMAL
,
new
MessageFormat
(
"Author Table"
),
new
MessageFormat
(
"Page - {0}"
));
PrinterJob
job
=
PrinterJob
.
getPrinterJob
();
job
.
setPrintable
(
printable
);
boolean
printAccepted
=
job
.
printDialog
();
if
(
printAccepted
)
{
try
{
job
.
print
();
closeFrame
();
}
catch
(
PrinterException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
private
static
void
printWithoutPrintDialog
()
{
final
JTable
table
=
createAuthorTable
(
42
);
PrintRequestAttributeSet
pras
=
new
HashPrintRequestAttributeSet
();
pras
.
add
(
new
Copies
(
1
));
try
{
boolean
printAccepted
=
table
.
print
(
JTable
.
PrintMode
.
FIT_WIDTH
,
new
MessageFormat
(
"Author Table"
),
new
MessageFormat
(
"Page - {0}"
),
false
,
pras
,
false
);
closeFrame
();
if
(!
printAccepted
)
{
throw
new
RuntimeException
(
"User cancels the printer job!"
);
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
private
static
void
printWithCustomImageareaSize
()
{
final
JTable
table
=
createAuthorTable
(
18
);
PrintRequestAttributeSet
printAttributes
=
new
HashPrintRequestAttributeSet
();
printAttributes
.
add
(
DialogTypeSelection
.
NATIVE
);
printAttributes
.
add
(
new
Copies
(
1
));
printAttributes
.
add
(
new
MediaPrintableArea
(
0.25f
,
0.25f
,
8.0f
,
5.0f
,
MediaPrintableArea
.
INCH
));
Printable
printable
=
table
.
getPrintable
(
JTable
.
PrintMode
.
NORMAL
,
new
MessageFormat
(
"Author Table"
),
new
MessageFormat
(
"Page - {0}"
)
);
PrinterJob
job
=
PrinterJob
.
getPrinterJob
();
job
.
setPrintable
(
printable
);
boolean
printAccepted
=
job
.
printDialog
(
printAttributes
);
if
(
printAccepted
)
{
try
{
job
.
print
(
printAttributes
);
closeFrame
();
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
else
{
throw
new
RuntimeException
(
"User cancels the printer job!"
);
}
}
private
static
JFrame
frame
;
private
static
void
closeFrame
()
{
if
(
frame
!=
null
)
{
frame
.
setVisible
(
false
);
frame
.
dispose
();
}
}
private
static
JTable
createAuthorTable
(
int
rows
)
{
final
String
[]
headers
=
{
"Book"
,
"Title"
};
final
Object
[][]
data
=
new
Object
[
rows
][
2
];
for
(
int
i
=
0
;
i
<
rows
;
i
++)
{
int
n
=
i
+
1
;
data
[
i
]
=
new
Object
[]{
"Book: "
+
n
,
"Title: "
+
n
};
}
TableModel
dataModel
=
new
AbstractTableModel
()
{
public
int
getColumnCount
()
{
return
headers
.
length
;
}
public
int
getRowCount
()
{
return
data
.
length
;
}
public
Object
getValueAt
(
int
row
,
int
col
)
{
return
data
[
row
][
col
];
}
public
String
getColumnName
(
int
column
)
{
return
headers
[
column
];
}
public
Class
getColumnClass
(
int
col
)
{
return
getValueAt
(
0
,
col
).
getClass
();
}
public
void
setValueAt
(
Object
aValue
,
int
row
,
int
column
)
{
data
[
row
][
column
]
=
aValue
;
}
public
boolean
isCellEditable
(
int
row
,
int
col
)
{
return
false
;
}
};
JTable
table
=
new
JTable
(
dataModel
);
table
.
setGridColor
(
Color
.
BLUE
);
table
.
setBackground
(
Color
.
WHITE
);
table
.
setForeground
(
Color
.
BLACK
);
table
.
setSize
(
600
,
800
);
frame
=
new
JFrame
();
frame
.
setSize
(
400
,
600
);
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
frame
.
add
(
table
);
frame
.
setVisible
(
true
);
return
table
;
}
private
static
int
testCount
;
private
static
void
createAndShowTestDialog
(
String
description
,
String
failMessage
,
Runnable
action
)
{
final
JDialog
dialog
=
new
JDialog
();
dialog
.
setTitle
(
"Test: "
+
(++
testCount
));
dialog
.
setModalityType
(
Dialog
.
ModalityType
.
APPLICATION_MODAL
);
JTextArea
textArea
=
new
JTextArea
(
description
);
textArea
.
setEditable
(
false
);
final
JButton
testButton
=
new
JButton
(
"Print Table"
);
final
JButton
passButton
=
new
JButton
(
"PASS"
);
passButton
.
setEnabled
(
false
);
passButton
.
addActionListener
((
e
)
->
{
dialog
.
dispose
();
});
final
JButton
failButton
=
new
JButton
(
"FAIL"
);
failButton
.
setEnabled
(
false
);
failButton
.
addActionListener
((
e
)
->
{
throw
new
RuntimeException
(
failMessage
);
});
testButton
.
addActionListener
((
e
)
->
{
testButton
.
setEnabled
(
false
);
action
.
run
();
passButton
.
setEnabled
(
true
);
failButton
.
setEnabled
(
true
);
});
JPanel
mainPanel
=
new
JPanel
(
new
BorderLayout
());
mainPanel
.
add
(
textArea
,
BorderLayout
.
CENTER
);
JPanel
buttonPanel
=
new
JPanel
(
new
FlowLayout
());
buttonPanel
.
add
(
testButton
);
buttonPanel
.
add
(
passButton
);
buttonPanel
.
add
(
failButton
);
mainPanel
.
add
(
buttonPanel
,
BorderLayout
.
SOUTH
);
dialog
.
add
(
mainPanel
);
dialog
.
pack
();
dialog
.
setVisible
(
true
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录