• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How is java's anti-aliasing implemented?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I noticed that java run time environment deal with anti-aliasing perfectly. What you need to do is just draw on Graphics2D, the java run time will do the anti-aliasing for you automatically. I'm especially interested in its anti-aliasing for circle or oval, as java is open sourced, can I find the source code for its anti-aliasing in src.zip? Thank you!
[ June 08, 2008: Message edited by: Bear Bibeault ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
welcome to JavaRanch.

Most of the actual drawing code is not part of the java.* classes, but is left to subclassses that a particular JRE implements. You'll see that a lot of methods java.awt.Graphics and Graphics2D are abstract; they're implemented by platform-specific classes that are not part of src.zip.

Of course, now that Version 7 of the Sun JDK is released under the GPL, the source for those classes are available, too. Check its source repository (somewhere on dev.java.net).
 
johnery woods
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much for your reply.

I followed your advice and download JDK7, there are lots of source code inside. Could you give me some hint which module should I read?

Actually, my knowledge about java is very limited, I'm developing a GO game(a kind of very interesting board game) under Windows platform. I have achieved the state that I can draw round stones on the window's client area, except for anti-aliasing. Although I have tried to do the anti-aliasing my self, but the effect is not good enough compared with CGoban 3.0, a java Go game client. I look into the client and find it uses following hints for stone drawing:
stoneImage[i] = new BufferedImage(a + d, a + d, BufferedImage.TYPE_INT_ARGB/* 2 */);
Graphics2D stoneGraphics = stoneImage[i].createGraphics();
stoneGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
stoneGraphics.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
stoneGraphics.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
stoneGraphics.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);

My dream is to use the smae algorithm used by Java to draw perfect looking of stones in my game. Could you help me?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any class that extends java.awt.Graphics or Graphics2D should be a good starting point.

As to the rendering hints, I'm not sure what you've asking. Have you read their javadocs? Have you tried them in your code to see whether they make any difference?
 
johnery woods
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your suggestion. I'm beginning to read the Docs. As I've spent so much time in it, if I cannot solve the problem quickly, I may consider studying the subject after I complete the new version of my program.

The rendering hints are used by a java game to draw stones, the output is perfect. The program itself doesn't do anti-aliasing, but let JRE do.

On windows platform, system debuggers like WinDbg or SoftICE are available to trace into system modules or components, in assembly-level, of cause. I'd like to know if such kind of tool is available on Java platform?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are various decent debuggers available for Java. JSwat is a nice standalone tool, while all of the IntelliJ, JDeveloper, NetBeans and Eclipse IDEs have debuggers built in as well.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic