|
Quick Lists
|
|
Bug ID:
|
4735659
|
|
Votes
|
1
|
|
Synopsis
|
1.4 REGRESSION: Scaling feature in HP LaserJet Printer doesn't work with JDK1.4
|
|
Category
|
java:classes_2d
|
|
Reported Against
|
1.4
|
|
Release Fixed
|
1.5(tiger)
|
|
State
|
10-Fix Delivered,
bug
|
|
Priority:
|
3-Medium
|
|
Related Bugs
|
|
|
Submit Date
|
22-AUG-2002
|
|
Description
|
FULL PRODUCT VERSION :
java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)
AND
java version "1.4.1-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1
Java HotSpot(TM) Client VM (build 1.4.1-rc-b19, mixed mode)
FULL OPERATING SYSTEM VERSION :
customer Windows 2000 [Version 5.00.2195]
EXTRA RELEVANT SYSTEM CONFIGURATION :
Printer - HP LaserJet 8150 with PCL 6 driver
A DESCRIPTION OF THE PROBLEM :
The scaling feature in the provided by the HP printer is not
working in jdk1.4.1 It doesn't work in Jdk1.4 also
The same program works fine with jdk1.3
Note : I've already submitted this bug for Jdk1.4 (Review
ID: 153851) and got a reply asking for sample code. I'm
resubmitting it with the sample code after testing with Jdk
1.4.1 also
REGRESSION. Last worked in version 1.3
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Execute the sample code using HP LaserJet 8150
2. Click the Properties button in the PrintDialog box
3. Choose the Effects tab and enter the percentage of
Scaling
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected result
When 50% scaling is chosen the output size should be 50%
scaled than the normal output
Actual result
The output isn't scaled. Its the same size as the normal
output
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error messages
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import javax.swing.table.*;
import java.util.Properties;
import java.util.Vector;
import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;
public class PrintJobTest extends JFrame implements ActionListener{
private JTable table;
private PrintJob pjob;
private Graphics pg;
private Vector rowVector,columnNames;
public PrintJobTest() {
super("PrintJob Test");
}
public static void main(String[] args) {
PrintJobTest printTest1 = new PrintJobTest();
printTest1.build();
}
//Builds the frame
public void build()
{
JPanel panel = new JPanel();
JPanel buttonPanel = new JPanel();
JButton button1 = new JButton("Print");
JButton button2 = new JButton("Exit");
buttonPanel.add(button1);
buttonPanel.add(button2);
button1.addActionListener(this);
button2.addActionListener(this);
this.getContentPane().add(buttonPanel,BorderLayout.SOUTH);
this.getContentPane().add(panel);
table = buildTable();
panel.add(table);
this.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.out.println("Window Closed.. Exiting");
if(pjob != null) pjob.end();
System.exit(0);
}
});
this.setSize(300,300);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand()=="Print")
{
System.out.println("Printing");
try
{
printTable();
}catch(Exception ex){
ex.printStackTrace();
}
}else if (e.getActionCommand()=="Exit")
{
System.out.println(" Exiting");
if(pjob != null) pjob.end();
System.exit(0);
}
}
/**
* Prints the results of the query displayed in the frame.
*/
private void printTable() {
pjob = Toolkit.getDefaultToolkit().getPrintJob(this,"PrintJob",null);
Dimension page = pjob.getPageDimension();
int margin = pjob.getPageResolution()/4; // set 1/4 inch margin
pg = pjob.getGraphics();
Vector columnValues;
Rectangle rows;
int numColumns = columnNames.size();
int numRows = rowVector.size();
int pheight = page.height - 2 * margin;
int x=50,y=50;
System.out.println("Num of Rows : " + numRows);
System.out.println("Num of Columns : " + numColumns);
pg.translate(x,y);
pg.setColor(Color.black);
for(int n = 0;n < columnNames.size(); n++)
{
String val = columnNames.elementAt(n).toString();
//System.out.println("Val : " + val);
pg.drawString(val, x, y);
x += 60;
}
for(int i = 0;i < numRows; i++)
{
x=50;
y += 20;
columnValues = (Vector) rowVector.get(i);
System.out.println("Row : " + i);
System.out.println("Values : " + columnValues);
for(int j=0;j < numColumns;j++)
{
System.out.println("Row : " + i + " Column : " + j);
//g2d.drawString(columnValues.elementAt(j).toString(), x, 0);
System.out.println("X : " + x + " Y : " + y);
String val = columnValues.elementAt(j).toString();
System.out.println("Val : " + val);
pg.drawString(val, x, y); //this.getValueAt(i,j).toString()
x += 60;
}
}
pg.dispose();
pjob.end();
}
private JTable buildTable()
{
Vector values;
JTable table1;
int x = 4; // no. of rows/columns
columnNames = new Vector();
rowVector = new Vector();
for(int i=1;i<=x;i++)
{
values = new Vector();
columnNames.add("Column "+i);
for(int j=1;j<=x;j++)
{
int num = i * 10 + j;
values.add(""+num);
}
rowVector.add(values);
}
table1 = new JTable(rowVector,columnNames);
table1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
return table1;
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
If I use PrinterJob class instead of PrintJob class,
scaling works fine. But this involves lot of changes in our
existing application and would consume a lot of time.
Release Regression From : 1.3
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Review ID: 163440)
======================================================================
|
|
Work Around
|
N/A
|
|
Evaluation
|
Committed to mantis.
xxxxx@xxxxx 2002-08-22
Device specific attributes are not passed in when we migrated to 2D printing. Fix is to use 2D print dialog.
xxxxx@xxxxx 2002-09-11
Fixed by using a unified 2D print dialog.
xxxxx@xxxxx 2003-03-19
|
|
Comments
|
Submitted On 23-JAN-2003
gkyang1
We have attempted to implement printerjob instead of
printjob in our code to solve the problem. However,
printerjob does not work the same way printjob works.
In our application, using printjob, a printjob is created and the
graphics object obtained for the printjob is passed to the
print function of other objects. The other objects' print
functions add to the graphics object and then the whole
graphics object is printed. An example is provided below.
When printerjob is used, the printerjob object is set to print a
single printable object and the graphics object in the printable
object is printed. This would not work with our application
without making extensive changes. This is because only one
printable object is set to print. We need to be able to pass
the graphics object through multiple objects before it's
printed.
Could you suggest a workaround using printjob to get scaling
to work? Also, please elaborate on the use of a 2D print dialog
as mentioned in the evaluation.
/* print function of AuditTrail object */
private void print() {
PrintJob pjob = getToolkit().getPrintJob(this, getTitle(),
printProps());
if (pjob != null) {
Graphics pg = pjob.getGraphics();
if (pg != null) {
pane.invalidate();
pg.setFont(new Font("monospaced", Font.PLAIN, 6));
header = headerSAT.setHeaderValues(false);
//Redraws the screen after making the above changes.
pane.validate();
}
pane.validate();
//pg graphics object passed to print funtion of gridDisplay
object
gridDisplay.print(pg, header, getTitle(), printFormatter);
pane.invalidate();
headerSAT.setHeaderValues(true);
pane.validate();
}
}
/* print function of gridDisplay object */
public void print(Graphics pg, HeaderPanel header, String title,
OatsGridFormatter format) {
...
PrintJob pjob = ((PrintGraphics)pg).getPrintJob();
Dimension page = pjob.getPageDimension();
int margin = pjob.getPageResolution()/4; // set 1/4 inch
margin
...
do {
int numRows = Math.min((int)(pheight/rowHeight),
getNumRows() -
currRow);
int startCol = 0, endCol;
do {
endCol = -1;
pg.setFont(pfont);
pg.setColor(Color.black);
pg.translate(margin, margin);
//pg graphics object passed to print funtion of
pTitle object
pTitle.print(pg);
// header
if ( header != null ) {
//pg graphics object passed to print funtion of
header object
header.print(pg, 8, 5);
int yOffset = 40;
pg.translate(0, header.getSize().height - yOffset);
}
...
}
pg.dispose();
pg = pjob.getGraphics();
startCol = endCol;
} while (endCol < columns.length);
} while (currRow < getNumRows());
pjob.end();
}
Submitted On 07-JUL-2003
gkyang1
What version of Java did this bug fix go in?
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |