Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Printing routine flips my text by 180 degrees

Reply
Thread Tools

Printing routine flips my text by 180 degrees

 
 
lemmi
Guest
Posts: n/a
 
      03-29-2007
Hi,

I have a problem with a printing routine I wrote for a Swing
component. For some reason all text elements (g.drawString()) appear
rotated (by 180 degrees) when I use LANDSCAPE orientation. Has anyone
seen this before?

Dirk

 
Reply With Quote
 
 
 
 
Daniel Pitts
Guest
Posts: n/a
 
      03-29-2007
On Mar 29, 7:18 am, "lemmi" <(E-Mail Removed)> wrote:
> Hi,
>
> I have a problem with a printing routine I wrote for a Swing
> component. For some reason all text elements (g.drawString()) appear
> rotated (by 180 degrees) when I use LANDSCAPE orientation. Has anyone
> seen this before?
>
> Dirk


If you post an sscce <http://www.physci.org/codes/sscce.html>, it
might help us make suggestions for you.

 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Alexander_Sch=F6lling?=
Guest
Posts: n/a
 
      04-18-2007
Daniel Pitts schrieb:
> On Mar 29, 7:18 am, "lemmi" <(E-Mail Removed)> wrote:
>> Hi,
>>
>> I have a problem with a printing routine I wrote for a Swing
>> component. For some reason all text elements (g.drawString()) appear
>> rotated (by 180 degrees) when I use LANDSCAPE orientation. Has anyone
>> seen this before?
>>
>> Dirk

>
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
screen display rotated 180 degrees Old Ted LG Computer Support 6 08-26-2007 02:30 PM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-18-2007 10:11 AM
how to rotate an image 180 degrees Leo Koolsbergen Javascript 6 12-22-2004 07:40 AM
OnChange=submit(); command flips parent page... Mel Javascript 2 05-05-2004 05:58 PM
Canon RAW 180 ppi OK for printing? Michael Digital Photography 4 01-10-2004 02:48 PM



Advertisments