-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.2
-
x86
-
windows_nt
03, -1, -52, -103, 0, -1, -
103, 51, -1,
-103, 102, -1, -103, -103, -1, -103, -52, -1, -103, -1, -1, -
103, 0, 0, -52,
51, 0, -52, 102, 0, -52, -103, 0, -52, -52, 0, -52, -
1, 0, -52, 0,
51, -52, 51, 51, -52, 102, 51, -52, -103, 51, -52, -52, 51,
-52, -1, 51,
-52, 0, 102, -52, 51, 102, -52, 102, 102, -52, -103, 102, -52,
-52, 102, -52,
-1, 102, -52, 0, -103, -52, 51, -103, -52, 102, -103, -52, -103, -
103, -52, -52,
-103, -52, -1, -103, -52, 0, -52, -52, 51, -52, -52, 102, -52,
-52, -103, -52,
-52, -52, -52, -52, -1, -52, -52, 0, -1, -52, 51, -1, -52,
102, -1, -52,
-103, -1, -52, -52, -1, -52, -1, -1, -52, 0, 0, -1,
51, 0, -1, 102,
0, -1, -103, 0, -1, -52, 0, -1, -1, 0, -1, 0,
51, -1, 51, 51,
-1, 102, 51, -1, -103, 51, -1, -52, 51, -1, -1, 51, -
1, 0, 102, -1,
51, 102, -1, 102, 102, -1, -103, 102, -1, -52, 102, -1, -1,
102, -1, 0,
-103, -1, 51, -103, -1, 102, -103, -1, -103, -103, -1, -52, -
103, -1, -1, -103,
-1, 0, -52, -1, 51, -52, -1, 102, -52, -1, -103, -52, -1,
-52, -52, -1,
-1, -52, -1, 0, -1, -1, 51, -1, -1, 102, -1, -1, -
103, -1, -1, -52,
-1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 44, 0, 0,
0, 0, 97, 0, 48, 0, 0, 8, -1, 0, -111, 8,
28, 72, -80, -96,
-63, -125, 8, 19, 42, 92, -56, -80, -95, -61, -121, 16,
35, 74, -100, 72,
-79, -94, -59, -117, 24, 51, 106, -36, -56, -79, -93, 71, -114,
-41, 66, 94,
-5, 72, -46, -93, -56, -111, 37, 83, 102, 60, -87, -78, -
91, 69, -106, 46,
99, 70, -124, 41, -77, 38, 67, -102, 54, 115, 30, -60, -87,
-77, -89, 64,
-98, 62, 117, 2, 13, 106, 115, 40, 81, -103, 70, -113, -
70, 76, -86, 84,
37, -45, -90, 37, -97, 66, -3, 40, 117, 106, 71, -100,
115, 2, -107, 42,
21, 72, -49, 19, -97, 79, -76, -106, -14, 106, 80, -113, -42,
-82, 95, 37,
-62, -44, 3, -19, -92, 72, 86, 115, -106, -118, 68, 82, -54,
-19, -75, 82,
3, -21, -38, 13, -92, 118, -82, 94, -69, 34, -11, -12, 69,
-39, -16, -28,
95, -73, 120, 89, 1, 14, 41, 24, -30, 73, -59, -113, -37,
-70, 109, -4,
112, -82, -61, -59, -112, -33, 62, -74, -101, -10, -78, 93, -
72, 4, 3, -71,
-115, 91, 57, 100, -23, -109, -92, -23, -18, 29, 56, -25, 36,
-27, -62, -109,
17, 102, 102, -27, -40, -76, 103, -111, -87, 5, 74, 14, -119, -
105, 96, -21,
-112, -76, 79, -13, 78, -8, 4, -11, 105, -31, -67, 67, -97,
-20, 60, -80,
106, -13, -89, -94, -121, -33, 22, -2, 90, -32, 111, -37, 5,
-99, -1, 20,
-103, 60, -95, 72, 104, -57, 111, 95, -65, -53, -3, 28,
59, 65, -19, 72,
92, 51, -52, -116, 112, -79, -5, -10, -106, 13, 14, 69, 111,
124, 33, -5,
-99, -18, 1, -61, 55, 127, 62, 126, 127, -2, 11, -43, -89,
-48, 125, -14,
-27, 103, -41, 126, -124, 101, -25, 95, 121, 9, -34, 20, -40,
122, 11, 42,
20, -95, 119, 19, -90, 55, 33, 125, -36, 57, 8, 32, -
123, 13, 74, 88,
-31, 124, 21, 34, 8, -98, 66, 122, 100, 56, -99, 120, 8,
-30, -73, 33,
-121, -116, 41, -76, 91, 117, 30, 118, -56, 98, -118, 5, -82, -
120, 96, 72,
-28, -27, -123, -95, -116, 52, -42, 40, -29, -114, -22, 21,
116, 24, -116, 49,
10, -41, -29, 127, 60, -34, -8, 29, 87, 90, -71, 21, 92,
120, -80, -83,
8, -94, -115, 42, 94, 83, -94, -127, 79, 70, -11, -31, -
123, 33, 86, -119,
-60, 19, -103, -39, -43, -99, -106, 82, 114, 73, -91, -113, -84, -
107, -78, 27,
43, -91, 48, -105, -110, 81, 83, 38, 105, -43, -100, 116, -42,
105, -25, -99,
120, -26, -87, -25, -98, 6, 5, 4, 0, 59
};
}
-------------------------------------------------------------------------
(Review ID: 97034)
======================================================================
Name: mc57594 Date: 11/21/99
java version "1.2.2"
Classic VM (build JDK-1.2.2-W, native threads, symcjit)
This is a restatement of the report with review id 52412. Now with a rather
large example.
JDK1.2 introduced the java.awt.print package. It seems there are two different
implementations of the PrinterJob class depending on whether the page to print
contains any graphics. Unfortunately the graphics printing one is broken in
various ways. This was testet on NT4.0 Workstation machines with Fixpak 3/4 and
JDK1.2.1/JDK1.2.2 with a Postscript and a HP Deskjet 500 printer. To reproduce
compile the attached example program and run it twice as follows:
(A) java Print2DTest up border color text
(B) java Print2DTest up border color text logo
Each run produces a single default (letter) sized page on the default printer.
Page (A) contains no images.
Symptoms:
- job (B) is excessively large and slow to print (This is supposedly fixed
for JDK1.3, but as I understand only in the "old" java.awt.PrintJob API)
- the centered text starts out at approximately the same location on both
printouts, but on (A) it extends further to the right. This implies:
+ the addition of an image changes font appearance
+ one of the printer jobs lies about the actual font metrics (usually the
text only variant seems to be more accurate)
this is a real showstopper because the addition/removal of an image
entirely messes up any layout
- printout (B) shows fewer of the light gray stripes (if this doesn't show up
on your printer try different printer settings or change the colors in the
program). Therefore addition/removal of images also changes color appearance
which is also unacceptable.
- the absolute position is not as specified by the PageFormat object (exactly
1 inch margins). It looks like the hardware margins are added to this. This is
similar to bug 4179886, but it should be emphasized that the correct behaviour
is positioning according to the specified PageFormat (actually Paper)
independent of any clipping performed (if at all). The application should not
(in the default case) be required to query the printer properties (by whatever
means JDK1.3 provides) just to e.g. print something in the center of the page.
The enclosed sample program can also be used to verify the fix for bug 4186119
(LANDSCAPE text only printing broken) in JDK1.2.2 via
java Print2DTest left text
java Print2DTest right text
java Print2DTest down text
-------------------------------------------------------------------
/*
* Print2DTest - 2D printing engine testbed
*/
import java.awt.Color;
import java.awt.Graphics;
import java.awt.FontMetrics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.print.PageFormat;
import java.awt.print.Paper;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
public class Print2DTest
{
private static String args;
// this is not reentrant
public static void main (String[] args)
{
StringBuffer temp = new StringBuffer ();
for (int i = 0; i < args.length; i += 1)
{
if (i > 0)
{
temp.append ('|');
}
temp.append (args [i].toLowerCase ());
}
Print2DTest.args = temp.toString ();
PrinterJob job = PrinterJob.getPrinterJob ();
TestFormat format = new TestFormat ();
TestPrintable page = new TestPrintable ();
// set up job
if (checkargs ("printdialog"))
{
job.printDialog ();
}
// set up format
if (checkargs ("up"))
{
format.setRotation (TestFormat.HEADUP);
}
if (checkargs ("left"))
{
format.setRotation (TestFormat.HEADLEFT);
}
if (checkargs ("down"))
{
format.setRotation (TestFormat.HEADDOWN);
}
if (checkargs ("right"))
{
format.setRotation (TestFormat.HEADRIGHT);
}
if (checkargs ("pagedialog"))
{
format = (TestFormat) job.pageDialog (format);
}
// set up page
page.setBorder (checkargs ("border"));
page.setColor (checkargs ("color"));
if (checkargs ("logo"))
{
page.setImage (Toolkit.getDefaultToolkit ().createImage(Print2DTest.logo));
}
if (checkargs ("text"))
{
page.setText ("|becker & mohnberg Softwaregesellschaft mbH|");
}
// print page
try
{
job.setPrintable (page, job.validatePage (format));
job.print ();
}
catch (PrinterException e)
{
e.printStackTrace ();
}
// kill toolkit threads
System.exit (0);
}
private static boolean checkargs (String tag)
{
int index = Print2DTest.args.indexOf (tag);
return ((index >= 0)
&& ((index == 0)
|| (Print2DTest.args.charAt (index - 1) == '|'))
&& (((index + tag.length ()) == Print2DTest.args.length ())
|| (Print2DTest.args.charAt (index + tag.length ()) == '|')));
}
private static class TestPrintable
implements Printable
{
boolean border;
boolean color;
Image image;
String text;
public TestPrintable ()
{
this.border = false;
this.image = null;
this.text = null;
}
public void setBorder (boolean border)
{
this.border = border;
}
public void setColor (boolean color)
{
this.color = color;
}
public void setImage (Image image)
{
// synchronize image loading (the wrong way)
while ((image.getHeight (null) < 0)
|| (image.getWidth (null) < 0)
|| (!Toolkit.getDefaultToolkit ().prepareImage (image,image.getWidth (null), image.getHeight (null), null)))
{
Thread.yield ();
}
this.image = image;
}
public void setText (String text)
{
this.text = text;
}
public int print (Graphics gfx, PageFormat format, int index)
{
int result;
if (index == 0)
{
// print contents
int width = (int) Math.round (format.getImageableWidth ());
int height = (int) Math.round (format.getImageableHeight ());
int left = (int) Math.round (format.getImageableX ());
int top = (int) Math.round (format.getImageableY ());
int right = ((int) Math.round (format.getWidth ())) - left - width;
int bottom = ((int) Math.round (format.getHeight ())) - top - height;
FontMetrics metrics = gfx.getFontMetrics ();
if (this.color)
{
gfx.setColor (new Color (250, 250, 250));
gfx.fillRect (left + 12 , top + 12, width - 24, 36);
gfx.setColor (new Color (251, 251, 251));
gfx.fillRect (left + 12 , top + 48, width - 24, 36);
gfx.setColor (new Color (252, 252, 252));
gfx.fillRect (left + 12 , top + 84, width - 24, 36);
gfx.setColor (new Color (253, 253, 253));
gfx.fillRect (left + 12 , top + 120, width - 24, 36);
gfx.setColor (new Color (254, 254, 254));
gfx.fillRect (left + 12 , top + 156, width - 24, 36);
gfx.setColor (new Color (255, 255, 255));
gfx.fillRect (left + 12 , top + 192, width - 24, 36);
}
gfx.setColor (Color.black);
if (this.border)
{
// test clipping
double dleft = ((double) left) / 10.0;
double dtop = ((double) top) / 10.0;
double dright = ((double) right) / 10.0;
double dbottom = ((double) bottom) / 10.0;
for (int i = 0; i <= 10; i += 1)
{
gfx.drawRect ((int) (i * dleft), (int) (i * dtop),
width + ((int) ((10 - i) * dleft)) + ((int) ((10 - i)* dright)),
height + ((int) ((10 - i) * dtop)) + ((int) ((10 - i)* dbottom)));
}
}
if (this.image != null)
{
// image
gfx.drawImage (this.image, left + (width - this.image.getWidth(null)) / 2, top + height / 2 - this.image.getHeight (null) - metrics.getHeight(), null);
}
if (this.text != null)
{
// text
gfx.drawString (this.text, left + (width - metrics.stringWidth(this.text)) / 2, top + height / 2);
gfx.drawString (Print2DTest.args, left + 12, top + height - 12);
}
result = PAGE_EXISTS;
}
else
{
result = NO_SUCH_PAGE;
}
return result;
}
}
private static class TestFormat
extends PageFormat
{
static final short HEADUP = 0;
static final short HEADLEFT = 90;
static final short HEADDOWN = 180;
static final short HEADRIGHT = 270;
private short rotation;
public TestFormat ()
{
super ();
rotation = HEADUP;
}
public Object clone ()
{
return super.clone ();
}
public double getHeight ()
{
double height;
if ((rotation == HEADUP) || (rotation == HEADDOWN))
{
height = super.getHeight ();
}
else
{
height = super.getWidth ();
}
return height;
}
public double getImageableHeight ()
{
double height;
if ((rotation == HEADUP) || (rotation == HEADDOWN))
{
height = super.getImageableHeight ();
}
else
{
height = super.getImageableWidth ();
}
return height;
}
public double getImageableWidth ()
{
double width;
if ((rotation == HEADUP) || (rotation == HEADDOWN))
{
width = super.getImageableWidth();
}
else
{
width = super.getImageableHeight();
}
return width;
}
public double getImageableX ()
{
double x;
switch (rotation)
{
case HEADUP:
x = super.getImageableX ();
break;
case HEADLEFT:
x = super.getWidth () - super.getImageableWidth () -super.getImageableX ();
break;
case HEADDOWN:
x = super.getHeight () - super.getImageableHeight () -super.getImageableY ();
break;
case HEADRIGHT:
x = super.getImageableY ();
break;
default:
x = 0.0;
break;
}
return x;
}
public double getImageableY ()
{
double y;
switch (rotation)
{
case HEADUP:
y = super.getImageableY ();
break;
case HEADLEFT:
y = super.getWidth () - super.getImageableWidth () -super.getImageableX ();
break;
case HEADDOWN:
y = super.getHeight () - super.getImageableHeight () -super.getImageableY ();
break;
case HEADRIGHT:
y = super.getImageableX ();
break;
default:
y = 0.0;
break;
}
return y;
}
public double[] getMatrix ()
{
double[] matrix;
switch (rotation)
{
case HEADUP:
matrix = new double [] {1.0, 0.0, 0.0, 1.0, 0.0, 0.0};
break;
case HEADLEFT:
matrix = new double [] {0.0, -1.0, 1.0, 0.0, 0.0, super.getHeight ()};
break;
case HEADRIGHT:
matrix = new double [] {0.0, 1.0, -1.0, 0.0, super.getWidth (), 0.0};
break;
case HEADDOWN:
matrix = new double [] {-1.0, 0.0, 0.0, -1.0, super.getWidth (),super.getHeight ()};
break;
default:
matrix = null;
break;
}
return matrix;
}
public int getOrientation ()
{
return PORTRAIT;
}
public Paper getPaper ()
{
return super.getPaper ();
}
public double getWidth ()
{
double width;
if ((rotation == HEADUP) || (rotation == HEADDOWN))
{
width = super.getWidth();
}
else
{
width = super.getHeight();
}
return width;
}
public void setOrientation (int orientation)
{
switch (orientation)
{
case PORTRAIT:
rotation = HEADUP;
break;
case LANDSCAPE:
rotation = HEADLEFT;
break;
case REVERSE_LANDSCAPE:
rotation = HEADRIGHT;
break;
}
}
public void setPaper (Paper paper)
{
super.setPaper (paper);
}
public void setRotation (short rotation)
{
this.rotation = rotation;
}
}
private static final byte[] logo =
{
71, 73, 70, 56, 57, 97, 97, 0, 48, 0, -9, 0,
0, 0, 0, 0,
51, 0, 0, 102, 0, 0, -103, 0, 0, -52, 0, 0, -
1, 0, 0, 0,
51, 0, 51, 51, 0, 102, 51, 0, -103, 51, 0, -52,
51, 0, -1, 51,
0, 0, 102, 0, 51, 102, 0, 102, 102, 0, -103, 102, 0,
-52, 102, 0,
-1, 102, 0, 0, -103, 0, 51, -103, 0, 102, -103, 0, -103, -
103, 0, -52,
-103, 0, -1, -103, 0, 0, -52, 0, 51, -52, 0, 102, -
52, 0, -103, -52,
0, -52, -52, 0, -1, -52, 0, 0, -1, 0, 51, -1, 0,
102, -1, 0,
-103, -1, 0, -52, -1, 0, -1, -1, 0, 0, 0, 51,
51, 0, 51, 102,
0, 51, -103, 0, 51, -52, 0, 51, -1, 0, 51, 0,
51, 51, 51, 51,
51, 102, 51, 51, -103, 51, 51, -52, 51, 51, -1, 51,
51, 0, 102, 51,
51, 102, 51, 102, 102, 51, -103, 102, 51, -52, 102, 51, -1,
102, 51, 0,
-103, 51, 51, -103, 51, 102, -103, 51, -103, -103, 51, -52, -
103, 51, -1, -103,
51, 0, -52, 51, 51, -52, 51, 102, -52, 51, -103, -52, 51,
-52, -52, 51,
-1, -52, 51, 0, -1, 51, 51, -1, 51, 102, -1, 51, -
103, -1, 51, -52,
-1, 51, -1, -1, 51, 0, 0, 102, 51, 0, 102, 102, 0,
102, -103, 0,
102, -52, 0, 102, -1, 0, 102, 0, 51, 102, 51, 51, 102,
102, 51, 102,
-103, 51, 102, -52, 51, 102, -1, 51, 102, 0, 102, 102, 51,
102, 102, 102,
102, 102, -103, 102, 102, -52, 102, 102, -1, 102, 102, 0, -103,
102, 51, -103,
102, 102, -103, 102, -103, -103, 102, -52, -103, 102, -1, -103,
102, 0, -52, 102,
51, -52, 102, 102, -52, 102, -103, -52, 102, -52, -52, 102, -1,
-52, 102, 0,
-1, 102, 51, -1, 102, 102, -1, 102, -103, -1, 102, -52, -1,
102, -1, -1,
102, 0, 0, -103, 51, 0, -103, 102, 0, -103, -103, 0, -103,
-52, 0, -103,
-1, 0, -103, 0, 51, -103, 51, 51, -103, 102, 51, -103, -
103, 51, -103, -52,
51, -103, -1, 51, -103, 0, 102, -103, 51, 102, -103, 102, 102, -
103, -103, 102,
-103, -52, 102, -103, -1, 102, -103, 0, -103, -103, 51, -103, -103,
102, -103, -103,
-103, -103, -103, -52, -103, -103, -1, -103, -103, 0, -52, -103, 51,
-52, -103, 102,
-52, -103, -103, -52, -103, -52, -52, -1
103, 51, -1,
-103, 102, -1, -103, -103, -1, -103, -52, -1, -103, -1, -1, -
103, 0, 0, -52,
51, 0, -52, 102, 0, -52, -103, 0, -52, -52, 0, -52, -
1, 0, -52, 0,
51, -52, 51, 51, -52, 102, 51, -52, -103, 51, -52, -52, 51,
-52, -1, 51,
-52, 0, 102, -52, 51, 102, -52, 102, 102, -52, -103, 102, -52,
-52, 102, -52,
-1, 102, -52, 0, -103, -52, 51, -103, -52, 102, -103, -52, -103, -
103, -52, -52,
-103, -52, -1, -103, -52, 0, -52, -52, 51, -52, -52, 102, -52,
-52, -103, -52,
-52, -52, -52, -52, -1, -52, -52, 0, -1, -52, 51, -1, -52,
102, -1, -52,
-103, -1, -52, -52, -1, -52, -1, -1, -52, 0, 0, -1,
51, 0, -1, 102,
0, -1, -103, 0, -1, -52, 0, -1, -1, 0, -1, 0,
51, -1, 51, 51,
-1, 102, 51, -1, -103, 51, -1, -52, 51, -1, -1, 51, -
1, 0, 102, -1,
51, 102, -1, 102, 102, -1, -103, 102, -1, -52, 102, -1, -1,
102, -1, 0,
-103, -1, 51, -103, -1, 102, -103, -1, -103, -103, -1, -52, -
103, -1, -1, -103,
-1, 0, -52, -1, 51, -52, -1, 102, -52, -1, -103, -52, -1,
-52, -52, -1,
-1, -52, -1, 0, -1, -1, 51, -1, -1, 102, -1, -1, -
103, -1, -1, -52,
-1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 44, 0, 0,
0, 0, 97, 0, 48, 0, 0, 8, -1, 0, -111, 8,
28, 72, -80, -96,
-63, -125, 8, 19, 42, 92, -56, -80, -95, -61, -121, 16,
35, 74, -100, 72,
-79, -94, -59, -117, 24, 51, 106, -36, -56, -79, -93, 71, -114,
-41, 66, 94,
-5, 72, -46, -93, -56, -111, 37, 83, 102, 60, -87, -78, -
91, 69, -106, 46,
99, 70, -124, 41, -77, 38, 67, -102, 54, 115, 30, -60, -87,
-77, -89, 64,
-98, 62, 117, 2, 13, 106, 115, 40, 81, -103, 70, -113, -
70, 76, -86, 84,
37, -45, -90, 37, -97, 66, -3, 40, 117, 106, 71, -100,
115, 2, -107, 42,
21, 72, -49, 19, -97, 79, -76, -106, -14, 106, 80, -113, -42,
-82, 95, 37,
-62, -44, 3, -19, -92, 72, 86, 115, -106, -118, 68, 82, -54,
-19, -75, 82,
3, -21, -38, 13, -92, 118, -82, 94, -69, 34, -11, -12, 69,
-39, -16, -28,
95, -73, 120, 89, 1, 14, 41, 24, -30, 73, -59, -113, -37,
-70, 109, -4,
112, -82, -61, -59, -112, -33, 62, -74, -101, -10, -78, 93, -
72, 4, 3, -71,
-115, 91, 57, 100, -23, -109, -92, -23, -18, 29, 56, -25, 36,
-27, -62, -109,
17, 102, 102, -27, -40, -76, 103, -111, -87, 5, 74, 14, -119, -
105, 96, -21,
-112, -76, 79, -13, 78, -8, 4, -11, 105, -31, -67, 67, -97,
-20, 60, -80,
106, -13, -89, -94, -121, -33, 22, -2, 90, -32, 111, -37, 5,
-99, -1, 20,
-103, 60, -95, 72, 104, -57, 111, 95, -65, -53, -3, 28,
59, 65, -19, 72,
92, 51, -52, -116, 112, -79, -5, -10, -106, 13, 14, 69, 111,
124, 33, -5,
-99, -18, 1, -61, 55, 127, 62, 126, 127, -2, 11, -43, -89,
-48, 125, -14,
-27, 103, -41, 126, -124, 101, -25, 95, 121, 9, -34, 20, -40,
122, 11, 42,
20, -95, 119, 19, -90, 55, 33, 125, -36, 57, 8, 32, -
123, 13, 74, 88,
-31, 124, 21, 34, 8, -98, 66, 122, 100, 56, -99, 120, 8,
-30, -73, 33,
-121, -116, 41, -76, 91, 117, 30, 118, -56, 98, -118, 5, -82, -
120, 96, 72,
-28, -27, -123, -95, -116, 52, -42, 40, -29, -114, -22, 21,
116, 24, -116, 49,
10, -41, -29, 127, 60, -34, -8, 29, 87, 90, -71, 21, 92,
120, -80, -83,
8, -94, -115, 42, 94, 83, -94, -127, 79, 70, -11, -31, -
123, 33, 86, -119,
-60, 19, -103, -39, -43, -99, -106, 82, 114, 73, -91, -113, -84, -
107, -78, 27,
43, -91, 48, -105, -110, 81, 83, 38, 105, -43, -100, 116, -42,
105, -25, -99,
120, -26, -87, -25, -98, 6, 5, 4, 0, 59
};
}
-------------------------------------------------------------------------
(Review ID: 97034)
======================================================================
Name: mc57594 Date: 11/21/99
java version "1.2.2"
Classic VM (build JDK-1.2.2-W, native threads, symcjit)
This is a restatement of the report with review id 52412. Now with a rather
large example.
JDK1.2 introduced the java.awt.print package. It seems there are two different
implementations of the PrinterJob class depending on whether the page to print
contains any graphics. Unfortunately the graphics printing one is broken in
various ways. This was testet on NT4.0 Workstation machines with Fixpak 3/4 and
JDK1.2.1/JDK1.2.2 with a Postscript and a HP Deskjet 500 printer. To reproduce
compile the attached example program and run it twice as follows:
(A) java Print2DTest up border color text
(B) java Print2DTest up border color text logo
Each run produces a single default (letter) sized page on the default printer.
Page (A) contains no images.
Symptoms:
- job (B) is excessively large and slow to print (This is supposedly fixed
for JDK1.3, but as I understand only in the "old" java.awt.PrintJob API)
- the centered text starts out at approximately the same location on both
printouts, but on (A) it extends further to the right. This implies:
+ the addition of an image changes font appearance
+ one of the printer jobs lies about the actual font metrics (usually the
text only variant seems to be more accurate)
this is a real showstopper because the addition/removal of an image
entirely messes up any layout
- printout (B) shows fewer of the light gray stripes (if this doesn't show up
on your printer try different printer settings or change the colors in the
program). Therefore addition/removal of images also changes color appearance
which is also unacceptable.
- the absolute position is not as specified by the PageFormat object (exactly
1 inch margins). It looks like the hardware margins are added to this. This is
similar to bug 4179886, but it should be emphasized that the correct behaviour
is positioning according to the specified PageFormat (actually Paper)
independent of any clipping performed (if at all). The application should not
(in the default case) be required to query the printer properties (by whatever
means JDK1.3 provides) just to e.g. print something in the center of the page.
The enclosed sample program can also be used to verify the fix for bug 4186119
(LANDSCAPE text only printing broken) in JDK1.2.2 via
java Print2DTest left text
java Print2DTest right text
java Print2DTest down text
-------------------------------------------------------------------
/*
* Print2DTest - 2D printing engine testbed
*/
import java.awt.Color;
import java.awt.Graphics;
import java.awt.FontMetrics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.print.PageFormat;
import java.awt.print.Paper;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
public class Print2DTest
{
private static String args;
// this is not reentrant
public static void main (String[] args)
{
StringBuffer temp = new StringBuffer ();
for (int i = 0; i < args.length; i += 1)
{
if (i > 0)
{
temp.append ('|');
}
temp.append (args [i].toLowerCase ());
}
Print2DTest.args = temp.toString ();
PrinterJob job = PrinterJob.getPrinterJob ();
TestFormat format = new TestFormat ();
TestPrintable page = new TestPrintable ();
// set up job
if (checkargs ("printdialog"))
{
job.printDialog ();
}
// set up format
if (checkargs ("up"))
{
format.setRotation (TestFormat.HEADUP);
}
if (checkargs ("left"))
{
format.setRotation (TestFormat.HEADLEFT);
}
if (checkargs ("down"))
{
format.setRotation (TestFormat.HEADDOWN);
}
if (checkargs ("right"))
{
format.setRotation (TestFormat.HEADRIGHT);
}
if (checkargs ("pagedialog"))
{
format = (TestFormat) job.pageDialog (format);
}
// set up page
page.setBorder (checkargs ("border"));
page.setColor (checkargs ("color"));
if (checkargs ("logo"))
{
page.setImage (Toolkit.getDefaultToolkit ().createImage(Print2DTest.logo));
}
if (checkargs ("text"))
{
page.setText ("|becker & mohnberg Softwaregesellschaft mbH|");
}
// print page
try
{
job.setPrintable (page, job.validatePage (format));
job.print ();
}
catch (PrinterException e)
{
e.printStackTrace ();
}
// kill toolkit threads
System.exit (0);
}
private static boolean checkargs (String tag)
{
int index = Print2DTest.args.indexOf (tag);
return ((index >= 0)
&& ((index == 0)
|| (Print2DTest.args.charAt (index - 1) == '|'))
&& (((index + tag.length ()) == Print2DTest.args.length ())
|| (Print2DTest.args.charAt (index + tag.length ()) == '|')));
}
private static class TestPrintable
implements Printable
{
boolean border;
boolean color;
Image image;
String text;
public TestPrintable ()
{
this.border = false;
this.image = null;
this.text = null;
}
public void setBorder (boolean border)
{
this.border = border;
}
public void setColor (boolean color)
{
this.color = color;
}
public void setImage (Image image)
{
// synchronize image loading (the wrong way)
while ((image.getHeight (null) < 0)
|| (image.getWidth (null) < 0)
|| (!Toolkit.getDefaultToolkit ().prepareImage (image,image.getWidth (null), image.getHeight (null), null)))
{
Thread.yield ();
}
this.image = image;
}
public void setText (String text)
{
this.text = text;
}
public int print (Graphics gfx, PageFormat format, int index)
{
int result;
if (index == 0)
{
// print contents
int width = (int) Math.round (format.getImageableWidth ());
int height = (int) Math.round (format.getImageableHeight ());
int left = (int) Math.round (format.getImageableX ());
int top = (int) Math.round (format.getImageableY ());
int right = ((int) Math.round (format.getWidth ())) - left - width;
int bottom = ((int) Math.round (format.getHeight ())) - top - height;
FontMetrics metrics = gfx.getFontMetrics ();
if (this.color)
{
gfx.setColor (new Color (250, 250, 250));
gfx.fillRect (left + 12 , top + 12, width - 24, 36);
gfx.setColor (new Color (251, 251, 251));
gfx.fillRect (left + 12 , top + 48, width - 24, 36);
gfx.setColor (new Color (252, 252, 252));
gfx.fillRect (left + 12 , top + 84, width - 24, 36);
gfx.setColor (new Color (253, 253, 253));
gfx.fillRect (left + 12 , top + 120, width - 24, 36);
gfx.setColor (new Color (254, 254, 254));
gfx.fillRect (left + 12 , top + 156, width - 24, 36);
gfx.setColor (new Color (255, 255, 255));
gfx.fillRect (left + 12 , top + 192, width - 24, 36);
}
gfx.setColor (Color.black);
if (this.border)
{
// test clipping
double dleft = ((double) left) / 10.0;
double dtop = ((double) top) / 10.0;
double dright = ((double) right) / 10.0;
double dbottom = ((double) bottom) / 10.0;
for (int i = 0; i <= 10; i += 1)
{
gfx.drawRect ((int) (i * dleft), (int) (i * dtop),
width + ((int) ((10 - i) * dleft)) + ((int) ((10 - i)* dright)),
height + ((int) ((10 - i) * dtop)) + ((int) ((10 - i)* dbottom)));
}
}
if (this.image != null)
{
// image
gfx.drawImage (this.image, left + (width - this.image.getWidth(null)) / 2, top + height / 2 - this.image.getHeight (null) - metrics.getHeight(), null);
}
if (this.text != null)
{
// text
gfx.drawString (this.text, left + (width - metrics.stringWidth(this.text)) / 2, top + height / 2);
gfx.drawString (Print2DTest.args, left + 12, top + height - 12);
}
result = PAGE_EXISTS;
}
else
{
result = NO_SUCH_PAGE;
}
return result;
}
}
private static class TestFormat
extends PageFormat
{
static final short HEADUP = 0;
static final short HEADLEFT = 90;
static final short HEADDOWN = 180;
static final short HEADRIGHT = 270;
private short rotation;
public TestFormat ()
{
super ();
rotation = HEADUP;
}
public Object clone ()
{
return super.clone ();
}
public double getHeight ()
{
double height;
if ((rotation == HEADUP) || (rotation == HEADDOWN))
{
height = super.getHeight ();
}
else
{
height = super.getWidth ();
}
return height;
}
public double getImageableHeight ()
{
double height;
if ((rotation == HEADUP) || (rotation == HEADDOWN))
{
height = super.getImageableHeight ();
}
else
{
height = super.getImageableWidth ();
}
return height;
}
public double getImageableWidth ()
{
double width;
if ((rotation == HEADUP) || (rotation == HEADDOWN))
{
width = super.getImageableWidth();
}
else
{
width = super.getImageableHeight();
}
return width;
}
public double getImageableX ()
{
double x;
switch (rotation)
{
case HEADUP:
x = super.getImageableX ();
break;
case HEADLEFT:
x = super.getWidth () - super.getImageableWidth () -super.getImageableX ();
break;
case HEADDOWN:
x = super.getHeight () - super.getImageableHeight () -super.getImageableY ();
break;
case HEADRIGHT:
x = super.getImageableY ();
break;
default:
x = 0.0;
break;
}
return x;
}
public double getImageableY ()
{
double y;
switch (rotation)
{
case HEADUP:
y = super.getImageableY ();
break;
case HEADLEFT:
y = super.getWidth () - super.getImageableWidth () -super.getImageableX ();
break;
case HEADDOWN:
y = super.getHeight () - super.getImageableHeight () -super.getImageableY ();
break;
case HEADRIGHT:
y = super.getImageableX ();
break;
default:
y = 0.0;
break;
}
return y;
}
public double[] getMatrix ()
{
double[] matrix;
switch (rotation)
{
case HEADUP:
matrix = new double [] {1.0, 0.0, 0.0, 1.0, 0.0, 0.0};
break;
case HEADLEFT:
matrix = new double [] {0.0, -1.0, 1.0, 0.0, 0.0, super.getHeight ()};
break;
case HEADRIGHT:
matrix = new double [] {0.0, 1.0, -1.0, 0.0, super.getWidth (), 0.0};
break;
case HEADDOWN:
matrix = new double [] {-1.0, 0.0, 0.0, -1.0, super.getWidth (),super.getHeight ()};
break;
default:
matrix = null;
break;
}
return matrix;
}
public int getOrientation ()
{
return PORTRAIT;
}
public Paper getPaper ()
{
return super.getPaper ();
}
public double getWidth ()
{
double width;
if ((rotation == HEADUP) || (rotation == HEADDOWN))
{
width = super.getWidth();
}
else
{
width = super.getHeight();
}
return width;
}
public void setOrientation (int orientation)
{
switch (orientation)
{
case PORTRAIT:
rotation = HEADUP;
break;
case LANDSCAPE:
rotation = HEADLEFT;
break;
case REVERSE_LANDSCAPE:
rotation = HEADRIGHT;
break;
}
}
public void setPaper (Paper paper)
{
super.setPaper (paper);
}
public void setRotation (short rotation)
{
this.rotation = rotation;
}
}
private static final byte[] logo =
{
71, 73, 70, 56, 57, 97, 97, 0, 48, 0, -9, 0,
0, 0, 0, 0,
51, 0, 0, 102, 0, 0, -103, 0, 0, -52, 0, 0, -
1, 0, 0, 0,
51, 0, 51, 51, 0, 102, 51, 0, -103, 51, 0, -52,
51, 0, -1, 51,
0, 0, 102, 0, 51, 102, 0, 102, 102, 0, -103, 102, 0,
-52, 102, 0,
-1, 102, 0, 0, -103, 0, 51, -103, 0, 102, -103, 0, -103, -
103, 0, -52,
-103, 0, -1, -103, 0, 0, -52, 0, 51, -52, 0, 102, -
52, 0, -103, -52,
0, -52, -52, 0, -1, -52, 0, 0, -1, 0, 51, -1, 0,
102, -1, 0,
-103, -1, 0, -52, -1, 0, -1, -1, 0, 0, 0, 51,
51, 0, 51, 102,
0, 51, -103, 0, 51, -52, 0, 51, -1, 0, 51, 0,
51, 51, 51, 51,
51, 102, 51, 51, -103, 51, 51, -52, 51, 51, -1, 51,
51, 0, 102, 51,
51, 102, 51, 102, 102, 51, -103, 102, 51, -52, 102, 51, -1,
102, 51, 0,
-103, 51, 51, -103, 51, 102, -103, 51, -103, -103, 51, -52, -
103, 51, -1, -103,
51, 0, -52, 51, 51, -52, 51, 102, -52, 51, -103, -52, 51,
-52, -52, 51,
-1, -52, 51, 0, -1, 51, 51, -1, 51, 102, -1, 51, -
103, -1, 51, -52,
-1, 51, -1, -1, 51, 0, 0, 102, 51, 0, 102, 102, 0,
102, -103, 0,
102, -52, 0, 102, -1, 0, 102, 0, 51, 102, 51, 51, 102,
102, 51, 102,
-103, 51, 102, -52, 51, 102, -1, 51, 102, 0, 102, 102, 51,
102, 102, 102,
102, 102, -103, 102, 102, -52, 102, 102, -1, 102, 102, 0, -103,
102, 51, -103,
102, 102, -103, 102, -103, -103, 102, -52, -103, 102, -1, -103,
102, 0, -52, 102,
51, -52, 102, 102, -52, 102, -103, -52, 102, -52, -52, 102, -1,
-52, 102, 0,
-1, 102, 51, -1, 102, 102, -1, 102, -103, -1, 102, -52, -1,
102, -1, -1,
102, 0, 0, -103, 51, 0, -103, 102, 0, -103, -103, 0, -103,
-52, 0, -103,
-1, 0, -103, 0, 51, -103, 51, 51, -103, 102, 51, -103, -
103, 51, -103, -52,
51, -103, -1, 51, -103, 0, 102, -103, 51, 102, -103, 102, 102, -
103, -103, 102,
-103, -52, 102, -103, -1, 102, -103, 0, -103, -103, 51, -103, -103,
102, -103, -103,
-103, -103, -103, -52, -103, -103, -1, -103, -103, 0, -52, -103, 51,
-52, -103, 102,
-52, -103, -103, -52, -103, -52, -52, -1
- duplicates
-
JDK-4227245 42 Java2D+Printing Additional~PDL~output for win32
- Resolved