• Post Reply Bookmark Topic Watch Topic
  • New Topic

How is java's anti-aliasing implemented?

 
johnery woods
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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 ]
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • 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
  • 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: 42970
73
  • Mark post as helpful
  • send pies
  • 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
  • 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: 42970
73
  • Mark post as helpful
  • send pies
  • 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.
 
Paper has not yet been outlawed – so let your Java Swing application print with wild abandon: JPDF
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!