| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
|
Initially I was doing it this way, scaling the g2d item prior to drawing to it - this was giving me the problems with the output described earlier... But only after saving and loading a font from a file on my mac. It may seem strange to save and load the font at the same time, but this is a compressed version of the full application that I am creating. One problem that I see with this is that if I draw to the full-sized graphics2d object after setting the font in this manner - then the full size image actually does appear the same way that the scaled image appears - it's really odd! Ok, tried the affinetransform of the font - this resulted in BOTH the old good location string and the bad location string being centered to the full graphics2d, rather than the scaled (0.5) graphics2d object (which would appear to be 1/4 the screen width)... only now the font appears much smaller. So.. sadly its not working :( any other ideas? CC: email@hidden From: email@hidden To: email@hidden Subject: Re: Font Problem Date: Thu, 28 Aug 2008 21:50:31 -0400 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: See what people are saying about Windows Live. Check out featured posts. Check It Out! |
_______________________________________________ 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>) | |
| >Re: Font Problem (From: Galen Rhodes <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.