When scale with AffineTransform, the size is correct but the x, y is not...

When I scale wither an image or some text by adding an AffineTrasnform.getScaleInstance(double sx, double sy), the size of the text or image is correct. however, it does not properly place the x, y. For example:
1. Original background image: 284, 213
2. Original x, y = 35, 35
3. Scaled background image: 700, 525
4. Scaled x, y: 94, 112
That is incorrect. The x should have been 86 and y should have been 86. Why are they being translated to 94 and 112?
My AffineTransform:
AffineTransform scaleTransform = AffineTransform.getScaleInstance( 2.464788732394366, 2.464788732394366 );

camickr wrote:
So where is your SSCCE?To see how it's off, check the pixel spots in photoshop. Scale the original "Some String" to the proper size and you'll see it ends up in a slightly different spot.
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
import java.awt.image.*;
import java.io.*;
public class TestScale extends JPanel
     public void paintComponent(Graphics g)
          Graphics2D graphics = ( Graphics2D ) g;
          //Location
          int x = 35;
          int y = 35;
          //I have to rotate it (so that's why I'm including it in this SSCCE)
          double theta = Math.toRadians( 15 );
          AffineTransform transform = AffineTransform.getRotateInstance( theta, ( double ) x, ( double ) y );
          //Set the transform
          graphics.setTransform( transform );
          //Draw normally
          graphics.drawString( "Some string", x, y );
          //Now adjust the transform to scale it
          transform.scale( 2.464788732394366, 2.464788732394366 );
          graphics.setTransform( transform );
          graphics.drawString( "Some string", x, y );
     public static void main(String[] args)
          JFrame frame = new JFrame("Display image");
          TestScale panel = new TestScale();
          frame.getContentPane().add(panel);
          frame.setSize( 704, 560);
          frame.setVisible( true );
}

Similar Messages

Maybe you are looking for

  • Can i record with more than one audio interface

    I need to record 16 tracks, I have two different audio iterface, in GarageBand i can only find one of them, if i go to prefrenses-audio, I can set any of them as my audio interface, but only one at the time. Any tips to how I can use bouth simultanio

  • Does it matter where the external usb hub is plugged in?

    I just got e new 7 port powered usb hub from Sitecom to connect a camera (once in a while) or card reader, printer(s), scanner, external drive etc. When I use one of the four ports on the backside of the iMac, only 1 -and only this one- specific port

  • How to convert .mov files to MP3?

    I am recording an entire book for someone who can't read. I'm using Quicktime Pro to do the recording. I want to burn a CD for her that she'll be able to play on any old CD player. How do I converrt the .mov files to MP3 or other usable format?

  • Upgrading from Acrobat 6.0 Pro to Acrobat XI Pro

    My company recently upgraded from Windows XP Pro to Windows 7 Pro.  We have our old copy of Acrobat 6.0 and it is not compatible with Windows 7.  I was wondering since we cannot load Acrobat 6.0 onto our computers in order to receive the upgrade. I d

  • CS6 lags when using brushes (MBP, Intuos)

    Hello! I'm using a MBP (Late 2011, i7, discrete ATI Radeon 6570m) with 16 Gigs of RAM, a 256GB SSD Samsung 830 and a Wacom Intuos5 tablet. My secondary screen is a Dell U2711. Ps is already updated to 13.0.1 Everytime i use a brush tool (healing, clo