Prev: Transactional cache with web application (JBoss Cache?)
Next: Are there any tools which generates Java code to reading XML files?
From: Elliot on 23 Mar 2010 17:51 HI I use the following code to print some barcode which is rotated 90 degrees down the left side of a page which prints in landscape: g2d.translate(haX + intBarCodeHeight, 0); g2d.rotate(90.0 * Math.PI / 180.0); // convert radians, which are about 57 degrees, to degrees g2d.drawImage(img,haY, 0,intBarCodeWidth,intBarCodeHeight, null); The barcode prints correctly; however anything that prints after it is also rotated and offset (due to g2d.translate(...) I imagine.) I've tried variations on all of the following with no joy. // g2d = (Graphics2D) g; // Bring 2D contect back to normal rotations // g2d.translate(pf.getImageableX(), pf.getImageableY()); // g2d.rotate(360.0 * Math.PI / 180.0); // Bring 2D contect back to normal rotations How can I reset g2d to print normally? Thanks in advance. Elliot
From: Knute Johnson on 23 Mar 2010 17:59 On 3/23/2010 2:51 PM, Elliot wrote: > HI > I use the following code to print some barcode which is rotated 90 > degrees down the left side of a page which prints in landscape: > > g2d.translate(haX + intBarCodeHeight, > 0); > g2d.rotate(90.0 * Math.PI / 180.0); // convert > radians, which are about 57 degrees, to degrees > g2d.drawImage(img,haY, > 0,intBarCodeWidth,intBarCodeHeight, null); > > The barcode prints correctly; however anything that prints after it is > also rotated and offset (due to g2d.translate(...) I imagine.) > > I've tried variations on all of the following with no joy. > > // g2d = (Graphics2D) g; // Bring 2D contect back > to normal rotations > // g2d.translate(pf.getImageableX(), > pf.getImageableY()); > // g2d.rotate(360.0 * Math.PI / 180.0); // Bring > 2D contect back to normal rotations > > How can I reset g2d to print normally? > > Thanks in advance. > > Elliot Save it before you mutate it. AffineTransform at = g2d.getTransform(); // mutate g2d.setTransform(at); // do something you don't want twisted up -- Knute Johnson email s/nospam/knute2010/
From: Jeff Higgins on 23 Mar 2010 18:10 On 3/23/2010 5:51 PM, Elliot wrote: > HI > I use the following code ... Can you the procedure outlined in the example? <http://java.sun.com/javase/6/docs/api/java/awt/Graphics2D.html#setTransform(java.awt.geom.AffineTransform)>
From: Elliot on 24 Mar 2010 08:12 Knute, You are the man. Java is not really my language; I wanted to save the original graphics context but didn't know how. This did it Thanks Elliot
From: Roedy Green on 24 Mar 2010 12:51
On Tue, 23 Mar 2010 14:51:47 -0700 (PDT), Elliot <eselick(a)gmail.com> wrote, quoted or indirectly quoted someone who said : >How can I reset g2d to print normally? see http://mindprod.com/jgloss/affinetransform.html -- Roedy Green Canadian Mind Products http://mindprod.com Responsible Development is the style of development I aspire to now. It can be summarized by answering the question, �How would I develop if it were my money?� I�m amazed how many theoretical arguments evaporate when faced with this question. ~ Kent Beck (born: 1961 age: 49) , evangelist for extreme programming. |