Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6229507
Votes 0
Synopsis ImageableWidth wrong after switch to LANDSCAPE in native pageDialog
Category java:classes_2d
Reported Against
Release Fixed 7(b14)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs 4694478 , 6228728
Submit Date 15-FEB-2005
Description
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
 customer  Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
The PrinterJob native pageDialog miscalculates the PageFormat  ImageableWidth after switching from PORTRAIT to LANDSCAPE for printers with different minimum top and bottom margins.

What should happen (and did prior to 1.5.0), is that the new left margin should be the old top margin and the new right margin should be the old bottom margin.  This is what it shows in the Page Setup dialog GUI.  But the PageFormat returned by the pageDialog has both the new left and right margins equal to the old, larger bottom margin.  The new ImageableWidth should be identical to the old ImageableHeight, but instead is smaller.  If you have more generous margins, the problem doesn't show but at the minimum margin settings, the new PageFormat incorrectly enforces the larger of the minimum top and bottom margins on both the new left and right margins.



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and build program provided below

Run on a system where the default printer has different minimum top and bottom margins.  For example, I'm using an HP OfficeJet G85.

The first Page Setup dialog will come up showing the minimum margins.  Hit OK to print out these minimum margins.

A second Page Setup dialog will come up.  Select Landscape and note the changed margins.  Now hit OK and compare the second ouptut to the first output, in particular note the incorrect margins and the new ImageableWidth not equal to the old ImageableHeight.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Here's the result on 1.4.2 for an HP OfficeJet G85:

before:
HWO: 792.0 612.0 1
iHWXY: 753.84 576.0 18.0 5.04
LRTB: 18.0 18.0 5.04 33.11999999999997

after:
HWO: 612.0 792.0 0
iHWXY: 576.0 753.84 33.120000000000005 18.0
LRTB: 33.120000000000005 5.039999999999964 18.0 18.0
ACTUAL -
Here's the result on 1.5.0 for the same printer:

before:
HWO: 792.0 612.0 1
iHWXY: 753.84 576.0 18.0 5.04
LRTB: 18.0 18.0 5.04 33.11999999999997

after:
HWO: 612.0 792.0 0
iHWXY: 576.0 725.76 33.120000000000005 18.0
LRTB: 33.120000000000005 33.120000000000005 18.0 18.0

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.print.*;

public class Test {
	static public void main(String args[]) {
		PrinterJob pj = PrinterJob.getPrinterJob();
		PageFormat pf = pj.defaultPage();
		Paper paper = new Paper();
		paper.setImageableArea(0.0, 0.0, pf.getWidth(), pf.getHeight());
		paper.setSize(pf.getWidth(), pf.getHeight());
		pf.setPaper(paper);
		pf.setOrientation(PageFormat.PORTRAIT);
		pf = pj.pageDialog(pf); // just say OK
		// now we have the minimum margins

		System.out.println("\nbefore:");
		printPageFormat(pf);
		PageFormat newpf = pj.pageDialog(pf); // switch to landscape, say OK
		System.out.println("\nafter:");
		printPageFormat(newpf); // imageableWidth is wrong
	}

	static void printPageFormat(PageFormat pf) {
		double pLM = pf.getImageableX();
		double pTM = pf.getImageableY();
		double pRM = pf.getWidth() - pf.getImageableWidth() - pLM;
		double pBM = pf.getHeight() - pf.getImageableHeight() - pTM;

		double pH = pf.getHeight();
		double pW = pf.getWidth();
		int orientation = pf.getOrientation();

		System.out.println("HWO: " + pH + " " + pW + " " + orientation);
		System.out.println("iHWXY: " + pf.getImageableHeight()
			+ " " + pf.getImageableWidth()
			+ " " + pf.getImageableX() + " " + pf.getImageableY());
		System.out.println("LRTB: " + pLM + " " + pRM + " " + pTM + " " + pBM);
	}
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Workarounds:

1) Revert to 1.4.2

2) Use more generous margins

3) Use the cross-platform dialog, which appears to be OK.

Release Regression From : 1.3.1
The above release value was the last known release where this 
bug was known to work. Since then there has been a regression.
  xxxxx@xxxxx   2005-2-15 19:30:21 GMT
Work Around
N/A
Evaluation
The PageFormat returned assumes landscape is always 90 degree rotation so the imageable dimensions are wrong in this printer.  We  need to redo the fix for 4694478 and fix 6228728 at the same time.  Removing regression tag since it last worked in 1.3.x.
  xxxxx@xxxxx   2005-03-01 19:05:39 GMT
Comments
  
  Include a link with my name & email   

Submitted On 21-JAN-2009
utilisateur
You should backport it to JDK6 !



PLEASE NOTE: JDK6 is formerly known as Project Mustang