FULL PRODUCT VERSION :
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Darwin 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64
EXTRA RELEVANT SYSTEM CONFIGURATION :
I don't think it's bound to the printer since I tested in preview mode and with two printers, and the same bug appeared each time.
A DESCRIPTION OF THE PROBLEM :
Printing a shape with a TexturePaint instance as paint doesn't work
REGRESSION. Last worked in version 6u45
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the program below, and accept to print.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expected the printed page would show a rectangle filled with a pattern
ACTUAL -
The printed page showed only an empty rectangle
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.awt.print.*;
public class PatternFillBug {
public static void main(String [] args) throws PrinterException {
PrinterJob printerJob = PrinterJob.getPrinterJob();
printerJob.setPrintable(new Printable() {
public int print(Graphics g, PageFormat pageFormat,
int index) throws PrinterException {
if (index == 1) {
return NO_SUCH_PAGE;
}
// Create a simple pattern
BufferedImage patternImage = new BufferedImage(2, 2, BufferedImage.TYPE_INT_ARGB);
Graphics gImage = patternImage.getGraphics();
gImage.setColor(Color.WHITE);
gImage.drawLine(0, 1, 1, 0);
gImage.setColor(Color.BLACK);
gImage.drawLine(0, 0, 1, 1);
gImage.dispose();
Graphics2D g2D = (Graphics2D)g;
// Fill a part of the page with pattern
Rectangle2D.Double shape = new Rectangle2D.Double(pageFormat.getImageableX(), pageFormat.getImageableY(),
pageFormat.getImageableWidth() / 5, pageFormat.getImageableHeight() / 5);
g2D.setPaint(new TexturePaint(patternImage, new Rectangle2D.Double(0, 0,
pageFormat.getImageableWidth() / 50, pageFormat.getImageableHeight() / 50)));
g2D.fill(shape);
// Surround it with a rectangle
g2D.setPaint(Color.BLACK);
g2D.draw(shape);
return PAGE_EXISTS;
}
});
// Show print dialog and print
if (printerJob.printDialog()) {
printerJob.print();
}
}
}
---------- END SOURCE ----------