| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
| I think you might be making this a lot harder than it needs to be? I've looked at your code and I think you are misunderstanding the scale() method. The scale() method does not "scale" what already has been drawn. Rather it's a "transform" that affects what WILL be drawn. Something like this: // The paint method of a JPanel or similar SWING component. public void paint(Graphics g) { Graphics2D g2 = (Graphics2D)g.create(); g2.setFont(new Font("Arial", Font.PLAIN, 12)); // set to what ever scaling factor gets the font to the right size you need. g2.scale(0.5, 0.5); // This position will be scaled too so you'll have to take that into account as well. // For example, assuming the example above with a 50% scaling in both vertical and // horizontal then a position of (100, 100) would be "transformed" to (50, 50). g2.drawString("Foobar", 100, 100); g2.dispose(); } An alternative to this is to apply a transform directly to the font itself. Take a look at Font.deriveFont(AffineTransform). For the AffineTransform object you'd want something like AffineTransform.getScaleInstance(double, double) and pass that to deriveFont then use that font to do the drawing. That way you don't have to apply the scale transform to the Graphics2D object so you don't have to worry about the scaling affecting the location. On Aug 28, 2008, at 9:18 PM, xxxx xxxx wrote: |
_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden This email sent to email@hidden
| References: | |
| >Font Problem (From: xxxx xxxx <email@hidden>) | |
| >Re: Font Problem (From: Galen Rhodes <email@hidden>) | |
| >RE: Font Problem (From: xxxx xxxx <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.