-
Bug
-
Resolution: Fixed
-
P4
-
1.3.1
-
tiger
-
sparc
-
solaris_7
Name: yyT116575 Date: 03/08/2001
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-beta-b15)
Java HotSpot(TM) Client VM (build 1.3.1beta-b15, mixed mode)
Run this program. When printed in Unix, the top circles fill correctly, the
bottom circles don't fill correctly.
Print to a file. View the output. After the g.translate(), 'eofill' operators
are replaced with 'fill'.
--
import java.awt.*;
import java.awt.geom.*;
import java.awt.event.*;
import java.awt.print.*;
import javax.swing.*;
public class FillPrintBug extends JComponent implements Printable {
public static void main(String[] args) {
JFrame frame = new JFrame("Fill Print Bug:generates incorrect PostScript");
final FillPrintBug bug = new FillPrintBug();
JButton button = new JButton("Print");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
bug.print();
}
});
frame.getContentPane().add(bug, BorderLayout.CENTER);
frame.getContentPane().add(button, BorderLayout.SOUTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.show();
}
GeneralPath path1 = new GeneralPath(PathIterator.WIND_EVEN_ODD);
GeneralPath path2 = new GeneralPath(PathIterator.WIND_EVEN_ODD);
GeneralPath path3 = new GeneralPath(PathIterator.WIND_EVEN_ODD);
public FillPrintBug() {
path1.append(new Ellipse2D.Double(100, 100, 100, 100), false);
path1.append(new Ellipse2D.Double(120, 120, 60, 60), false);
path1.append(new Ellipse2D.Double(140, 140, 20, 20), false);
path2.append(new Ellipse2D.Double(150, 100, 100, 100), false);
path2.append(new Ellipse2D.Double(170, 120, 60, 60), false);
path2.append(new Ellipse2D.Double(190, 140, 20, 20), false);
path3.append(new Ellipse2D.Double(-50, -50, 100, 100), false);
path3.append(new Ellipse2D.Double(-30, -30, 60, 60), false);
path3.append(new Ellipse2D.Double(-10, -10, 20, 20), false);
setPreferredSize(new java.awt.Dimension(360, 600));
}
public void print() {
PrinterJob printJob = PrinterJob.getPrinterJob();
if(printJob.printDialog()) {
printJob.setPrintable(this);
try {
printJob.print();
}
catch(Exception ex) {
ex.printStackTrace();
}
repaint(); // in case dialog trashed us
}
}
public int print(Graphics g, PageFormat pf, int pi) {
if(pi > 0) {
return Printable.NO_SUCH_PAGE;
}
setDoubleBuffered(false);
render((Graphics2D)g);
setDoubleBuffered(true);
return Printable.PAGE_EXISTS;
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
render((Graphics2D)g);
}
public void render(Graphics2D g) {
Rectangle clip = new Rectangle();
g.getClipBounds(clip);
g.setColor(Color.white);
g.fillRect(clip.x, clip.y, clip.width, clip.height);
g.setColor(Color.red);
g.fill(path1);
g.setColor(Color.black);
g.fill(path2);
g.translate(150, 400);
g.setColor(Color.red);
g.fill(path3);
g.translate(50, 0);
g.setColor(Color.black);
g.fill(path3);
}
}
--
Here is a sample print file:
%!PS-Adobe-3.0
%%BeginProlog
/imStr 0 def /heximageSrc{currentfile imStr readhexstring pop} def
/BD {bind def} bind def
/D {def} BD
/ISOF {
dup findfont dup length 1 add dict begin {
1 index /FID eq {pop pop} {D} ifelse
} forall /Encoding ISOLatin1Encoding D
currentdict end definefont
} BD
/NZ {dup 1 lt {pop 1} if} BD
/DS {
moveto 1 index stringwidth pop NZ sub
1 index length 1 sub NZ div 0
3 2 roll ashow newpath} BD
/F [
/Helvetica ISOF
/Helvetica-Bold ISOF
/Helvetica-Oblique ISOF
/Helvetica-BoldOblique ISOF
/Times-Roman ISOF
/Times-Bold ISOF
/Times-Italic ISOF
/Times-BoldItalic ISOF
/Courier ISOF
/Courier-Bold ISOF
/Courier-Oblique ISOF
/Courier-BoldOblique ISOF
] D
/SF {
F exch get exch scalefont setfont
(abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890) stringwidth
pop div
currentfont [1 0 0 -1 0 0]makefont exch scalefont setfont} BD
%%EndProlog
%%BeginSetup
1/#copies exch def
%%EndSetup
%%Page: 1 1
/pgSave save def
792.0 0 exch translate 1 -1 scale[72 300 div 0 0 72 300 div 0 0]concat
1.0 setgray
gsave
[4.166666666666667 0.0 0.0 4.166666666666667 -0.0 -0.0] concat
newpath
72.0 72.0 moveto
540.0 72.0 lineto
540.0 720.0 lineto
72.0 720.0 lineto
72.0 72.0 lineto
closepath
clip
newpath
72.0 72.0 moveto
540.0 72.0 lineto
540.0 720.0 lineto
72.0 720.0 lineto
72.0 72.0 lineto
closepath
fill
1.0 0.0 0.0 setrgbcolor
newpath
200.0 150.0 moveto
200.0 177.61424 177.61424 200.0 150.0 200.0 curveto
122.385765 200.0 100.0 177.61424 100.0 150.0 curveto
100.0 122.385765 122.385765 100.0 150.0 100.0 curveto
177.61424 100.0 200.0 122.385765 200.0 150.0 curveto
closepath
180.0 150.0 moveto
180.0 166.56854 166.56854 180.0 150.0 180.0 curveto
133.43146 180.0 120.0 166.56854 120.0 150.0 curveto
120.0 133.43146 133.43146 120.0 150.0 120.0 curveto
166.56854 120.0 180.0 133.43146 180.0 150.0 curveto
closepath
160.0 150.0 moveto
160.0 155.52284 155.52284 160.0 150.0 160.0 curveto
144.47716 160.0 140.0 155.52284 140.0 150.0 curveto
140.0 144.47716 144.47716 140.0 150.0 140.0 curveto
155.52284 140.0 160.0 144.47716 160.0 150.0 curveto
closepath
eofill
0.0 setgray
newpath
250.0 150.0 moveto
250.0 177.61424 227.61424 200.0 200.0 200.0 curveto
172.38576 200.0 150.0 177.61424 150.0 150.0 curveto
150.0 122.385765 172.38576 100.0 200.0 100.0 curveto
227.61424 100.0 250.0 122.385765 250.0 150.0 curveto
closepath
230.0 150.0 moveto
230.0 166.56854 216.56854 180.0 200.0 180.0 curveto
183.43146 180.0 170.0 166.56854 170.0 150.0 curveto
170.0 133.43146 183.43146 120.0 200.0 120.0 curveto
216.56854 120.0 230.0 133.43146 230.0 150.0 curveto
closepath
210.0 150.0 moveto
210.0 155.52284 205.52284 160.0 200.0 160.0 curveto
194.47716 160.0 190.0 155.52284 190.0 150.0 curveto
190.0 144.47716 194.47716 140.0 200.0 140.0 curveto
205.52284 140.0 210.0 144.47716 210.0 150.0 curveto
closepath
eofill
grestore
1.0 0.0 0.0 setrgbcolor
gsave
[4.166666666666667 0.0 0.0 4.166666666666667 625.0 1666.6666666666667] concat
newpath
-78.0 -328.0 moveto
390.0 -328.0 lineto
390.0 320.0 lineto
-78.0 320.0 lineto
-78.0 -328.0 lineto
closepath
clip
newpath
50.0 0.0 moveto
50.0 27.614237 27.614237 50.0 0.0 50.0 curveto
-27.614237 50.0 -50.0 27.614237 -50.0 0.0 curveto
-50.0 -27.614237 -27.614237 -50.0 0.0 -50.0 curveto
27.614237 -50.0 50.0 -27.614237 50.0 0.0 curveto
closepath
30.0 0.0 moveto
30.0 16.568542 16.568542 30.0 0.0 30.0 curveto
-16.568542 30.0 -30.0 16.568542 -30.0 0.0 curveto
-30.0 -16.568542 -16.568542 -30.0 0.0 -30.0 curveto
16.568542 -30.0 30.0 -16.568542 30.0 0.0 curveto
closepath
10.0 0.0 moveto
10.0 5.5228477 5.5228477 10.0 0.0 10.0 curveto
-5.5228477 10.0 -10.0 5.5228477 -10.0 0.0 curveto
-10.0 -5.5228477 -5.5228477 -10.0 0.0 -10.0 curveto
5.5228477 -10.0 10.0 -5.5228477 10.0 0.0 curveto
closepath
fill
grestore
0.0 setgray
gsave
[4.166666666666667 0.0 0.0 4.166666666666667 833.3333333333334
1666.6666666666667] concat
newpath
-128.0 -328.0 moveto
340.0 -328.0 lineto
340.0 320.0 lineto
-128.0 320.0 lineto
-128.0 -328.0 lineto
closepath
clip
newpath
50.0 0.0 moveto
50.0 27.614237 27.614237 50.0 0.0 50.0 curveto
-27.614237 50.0 -50.0 27.614237 -50.0 0.0 curveto
-50.0 -27.614237 -27.614237 -50.0 0.0 -50.0 curveto
27.614237 -50.0 50.0 -27.614237 50.0 0.0 curveto
closepath
30.0 0.0 moveto
30.0 16.568542 16.568542 30.0 0.0 30.0 curveto
-16.568542 30.0 -30.0 16.568542 -30.0 0.0 curveto
-30.0 -16.568542 -16.568542 -30.0 0.0 -30.0 curveto
16.568542 -30.0 30.0 -16.568542 30.0 0.0 curveto
closepath
10.0 0.0 moveto
10.0 5.5228477 5.5228477 10.0 0.0 10.0 curveto
-5.5228477 10.0 -10.0 5.5228477 -10.0 0.0 curveto
-10.0 -5.5228477 -5.5228477 -10.0 0.0 -10.0 curveto
5.5228477 -10.0 10.0 -5.5228477 10.0 0.0 curveto
closepath
fill
pgSave restore
showpage
%%EOF
(Review ID: 118333)
======================================================================