-
Bug
-
Resolution: Duplicate
-
P3
-
7
FULL PRODUCT VERSION :
java version " 1.7.0_17 "
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
Also found ont 1.6.0, different versions up to the latest update 45
A DESCRIPTION OF THE PROBLEM :
After applying a rotation transformation of 45? degrees (+- n x 90?) to a graphics object, lines and shapes having a line width (stroke with) are printed as thin lines, although on the screen they have the line width correctly applied.
The problem occurs with PDF printers as well as norma printers.
The attached test case shows this very well. Click on the panel to start printing the shapes.
P.S. I reported this bug on 9.4.2013 already, but since I cannot find it any more and never got any feedback I assume it was not correctly transmitted.
P.P.S. Can I get notified of progress etc. regarding this issue via email?
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Printed lines and shapes looks equal to screen.
ACTUAL -
Lines are fat on screen, but thin (hairlines) on print out.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.*;
import java.awt.print.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
/**
* Tests a printing bug.
* @author Matthias Basler, GEOGRAT Informationssystem GmbH
* @since 08.04.2013
*/
public class PrintDialog extends JFrame{
/** Demonstrates a printing bug.
@param args */
public static void main(String[] args) {
PrintDialog dlg = new PrintDialog();
dlg.setPreferredSize(new Dimension(600,800));
dlg.setDefaultCloseOperation(EXIT_ON_CLOSE);
Canvas printPanel = new Canvas();
dlg.setLayout(new BorderLayout());
dlg.add(printPanel, BorderLayout.CENTER);
dlg.pack();
dlg.setLocationRelativeTo(null);
dlg.setVisible(true);
}
public PrintDialog() {
super( " Print bug test case - Click to start print. " );
}
static class Canvas extends JPanel implements Printable{
public Canvas() {
super.setBackground(Color.WHITE);
addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent ev) {
try {
print();
} catch (PrinterException ex) { ex.printStackTrace(); }
}
});
}
protected void paintComponent(Graphics g) {
double rotation = 45.0; //Set this to something different than 45? and it will print fat.
super.paintComponent(g);
Graphics2D g2d = (Graphics2D)g;
AffineTransform at = new AffineTransform();
at.translate(200, 300);
at.rotate(Math.toRadians(rotation));
AffineTransform old_transform = g2d.getTransform();
g2d.transform(at);
Stroke oldStroke = g2d.getStroke();
g2d.setStroke(new BasicStroke(10f));
try {
g2d.draw(new Ellipse2D.Double(-10, -10, 20, 20));
g2d.draw(new Line2D.Double(25, -10, 25, 10));
g2d.draw(new Line2D.Double(-30, 0, 0, -25));
} finally {
g2d.setStroke(oldStroke);
g2d.setTransform(old_transform);
}
}
private void print() throws PrinterException{
PrinterJob printerjob = PrinterJob.getPrinterJob();
printerjob.setJobName( " Testdruck " );
/*PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
printServiceAttributeSet.add(new PrinterName( " PDFCreator " , null));
PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, printServiceAttributeSet);
printerjob.setPrintService( printServices[0]);*/
boolean print = printerjob.printDialog();
if (print) {
System.out.println(printerjob.getPrintService().toString());
printerjob.setPrintable(this, printerjob.defaultPage());
printerjob.print();
}
}
@Override
public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {
if (pageIndex == 0)
this.paintComponent(g);
return pageIndex == 0 ? PAGE_EXISTS : NO_SUCH_PAGE;
}
}
}
---------- END SOURCE ----------
java version " 1.7.0_17 "
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
Also found ont 1.6.0, different versions up to the latest update 45
A DESCRIPTION OF THE PROBLEM :
After applying a rotation transformation of 45? degrees (+- n x 90?) to a graphics object, lines and shapes having a line width (stroke with) are printed as thin lines, although on the screen they have the line width correctly applied.
The problem occurs with PDF printers as well as norma printers.
The attached test case shows this very well. Click on the panel to start printing the shapes.
P.S. I reported this bug on 9.4.2013 already, but since I cannot find it any more and never got any feedback I assume it was not correctly transmitted.
P.P.S. Can I get notified of progress etc. regarding this issue via email?
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Printed lines and shapes looks equal to screen.
ACTUAL -
Lines are fat on screen, but thin (hairlines) on print out.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.*;
import java.awt.print.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
/**
* Tests a printing bug.
* @author Matthias Basler, GEOGRAT Informationssystem GmbH
* @since 08.04.2013
*/
public class PrintDialog extends JFrame{
/** Demonstrates a printing bug.
@param args */
public static void main(String[] args) {
PrintDialog dlg = new PrintDialog();
dlg.setPreferredSize(new Dimension(600,800));
dlg.setDefaultCloseOperation(EXIT_ON_CLOSE);
Canvas printPanel = new Canvas();
dlg.setLayout(new BorderLayout());
dlg.add(printPanel, BorderLayout.CENTER);
dlg.pack();
dlg.setLocationRelativeTo(null);
dlg.setVisible(true);
}
public PrintDialog() {
super( " Print bug test case - Click to start print. " );
}
static class Canvas extends JPanel implements Printable{
public Canvas() {
super.setBackground(Color.WHITE);
addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent ev) {
try {
print();
} catch (PrinterException ex) { ex.printStackTrace(); }
}
});
}
protected void paintComponent(Graphics g) {
double rotation = 45.0; //Set this to something different than 45? and it will print fat.
super.paintComponent(g);
Graphics2D g2d = (Graphics2D)g;
AffineTransform at = new AffineTransform();
at.translate(200, 300);
at.rotate(Math.toRadians(rotation));
AffineTransform old_transform = g2d.getTransform();
g2d.transform(at);
Stroke oldStroke = g2d.getStroke();
g2d.setStroke(new BasicStroke(10f));
try {
g2d.draw(new Ellipse2D.Double(-10, -10, 20, 20));
g2d.draw(new Line2D.Double(25, -10, 25, 10));
g2d.draw(new Line2D.Double(-30, 0, 0, -25));
} finally {
g2d.setStroke(oldStroke);
g2d.setTransform(old_transform);
}
}
private void print() throws PrinterException{
PrinterJob printerjob = PrinterJob.getPrinterJob();
printerjob.setJobName( " Testdruck " );
/*PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
printServiceAttributeSet.add(new PrinterName( " PDFCreator " , null));
PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, printServiceAttributeSet);
printerjob.setPrintService( printServices[0]);*/
boolean print = printerjob.printDialog();
if (print) {
System.out.println(printerjob.getPrintService().toString());
printerjob.setPrintable(this, printerjob.defaultPage());
printerjob.print();
}
}
@Override
public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {
if (pageIndex == 0)
this.paintComponent(g);
return pageIndex == 0 ? PAGE_EXISTS : NO_SUCH_PAGE;
}
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-6457721 Stroke width incorrect while printing with an AffineTransform
-
- Open
-
-
JDK-6788453 Graphics.draw and drawPolygon do not print some thin lines on certain printers
-
- Closed
-