Daniel said:
If you post an sscce <
http://www.physci.org/codes/sscce.html>, it
might help us make suggestions for you.
The following code exhibits this problem:
------
/*
* GraphPageable.java
*
* Created on 27. Februar 2007, 10:07
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package de.gpkom.graph;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import org.jfree.chart.JFreeChart;
/**
* Printer class for a graph
* @author Alexander Schölling
*/
public class GraphPageable implements Printable {
/**
* Creates a new instance of GraphPageable
* @param g Graph
*/
public GraphPageable(JFreeChart g) {
graph=g;
}
/**
* Printing dialogs and printing
* @throws java.awt.print.PrinterException Passed through from
PrinterJob.print()
*/
public void print() throws PrinterException {
PrinterJob job=PrinterJob.getPrinterJob();
PageFormat alt=job.defaultPage();
PageFormat format=job.pageDialog(alt);
if (format.equals(alt)) return;
job.setPrintable(this, format);
if (job.printDialog()) {
job.print();
}
}
/**
* Printing
* @param graphics GraphicsContext
* @param pageFormat PaqeFormat
* @param i Page number
* @throws java.awt.print.PrinterException Passed through
* @return Printable.NO_SUCH_PAGE or Printable.PAGE_EXISTS
*/
public int print(Graphics graphics, PageFormat pageFormat, int i)
throws PrinterException {
if (i>0) return Printable.NO_SUCH_PAGE;
Graphics2D g2=(Graphics2D)graphics;
g2.translate(pageFormat.getImageableX(),
pageFormat.getImageableY());
graph.draw(g2, new
Rectangle((int)pageFormat.getImageableWidth(),
(int)pageFormat.getImageableHeight()));
return Printable.PAGE_EXISTS;
}
private JFreeChart graph;
}
-----
As soon as I change the orientation from portrait to landscape _in the
print dialog_, the strings (Graph label, title, etc.) are turned upside
down. Even the diagonally printed strings are turned 180°.
Yours,
Alexander