Shape filled with a pattern not printed
Emmanuel Puybaret
puybaret at eteks.com
Tue May 20 14:26:39 UTC 2014
Hi,
Are there any news about the bug in Java 7u40 and 7u60 beta versions that prevents to print a shape filled with a pattern?
Here'a simple simple example to let you test this issue:
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();
}
}
}
The bug happens also when you choose to print to PDF in OSX print dialog box.
I reported this bug to Oracle in september 2013, but the URL keeps saying that the bug is not available:
http://bugs.sun.com/view_bug.do?bug_id=9007022
It would be nice to make submitted bugs public again when they are not related to a security issue.
It's so frustrating to wonder if someone else posted the same bug. :-(
Regards,
--
Emmanuel PUYBARET
Email : puybaret at eteks.com
Web : http://www.eteks.com
http://www.sweethome3d.com
More information about the macosx-port-dev
mailing list