|
Prev: Echo Port 7
Next: Notification of low memory condition
From: Jason Cavett on 8 Jul 2008 12:25 I just want to make sure I understand correctly. If I'm using the Windows, Metal (Ocean) or GTK L&F, antialiasing is automatically detected by Java? Is this true? If not, what would I have to do to turn antialiasing on? (I've been reading various articles online, and there are inconsistent answers, so I wanted to check here.) Thanks
From: Knute Johnson on 8 Jul 2008 14:31 Jason Cavett wrote: > I just want to make sure I understand correctly. > > If I'm using the Windows, Metal (Ocean) or GTK L&F, antialiasing is > automatically detected by Java? Is this true? If not, what would I > have to do to turn antialiasing on? (I've been reading various > articles online, and there are inconsistent answers, so I wanted to > check here.) > > > Thanks Swing components are now anti-aliased by default. If you want to anti-alias your drawing you need to add RenderingHints to the Graphics2D you are drawing with. Swing components and in fact all graphics contexts are now Graphics2D I believe, even though they are passed as Graphics. paintComponent(Graphics g2D) { Graphics2D g = (Graphics2D)g2D; g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); ... There are numerous options for RenderingHints, check out the docs. If you want to see an example of an anti-aliased drawing, check out my analog clock. http://rabbitbrush.frazmtn.com/clock.html Just recompile it and comment out the rendering hints and you can see the difference easily. -- Knute Johnson email s/nospam/knute2008/ -- Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ------->>>>>>http://www.NewsDemon.com<<<<<<------ Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
From: CD1 on 9 Jul 2008 09:50 You can turn anti-alias on by running your JVM with the option "- Dswing.aatext=true". For example, if you want to run your class "App" with anti-alias on, just call the JVM: java -Dswing.aatext=true App This is valid for Java 5 and 6, at least (don't know if it works for Java 1.4), and only for the Swing classes. But if you want to draw something yourself with anti-alias, do as Jason said.
From: Roedy Green on 9 Jul 2008 17:53 On Tue, 8 Jul 2008 09:25:14 -0700 (PDT), Jason Cavett <jason.cavett(a)gmail.com> wrote, quoted or indirectly quoted someone who said : >If I'm using the Windows, Metal (Ocean) or GTK L&F, antialiasing is >automatically detected by Java? Is this true? If not, what would I >have to do to turn antialiasing on? (I've been reading various >articles online, and there are inconsistent answers, so I wanted to >check here.) see http://mindprod.com/jgloss/antialiasing.html -- Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
From: Jason Cavett on 9 Jul 2008 18:04
On Jul 9, 9:50 am, CD1 <cristiandei...(a)gmail.com> wrote: > You can turn anti-alias on by running your JVM with the option "- > Dswing.aatext=true". For example, if you want to run your class "App" > with anti-alias on, just call the JVM: > > java -Dswing.aatext=true App > > This is valid for Java 5 and 6, at least (don't know if it works for > Java 1.4), and only for the Swing classes. But if you want to draw > something yourself with anti-alias, do as Jason said. That doesn't work for 1.4. Looks like it works for 5. I'm not sure whether or not it works for 6. When I looked up that value online, some websites said that 6 was enabled AA based on the system settings. (Roedy's website seems to agree.) Thanks for the info. |