Java开发网 |
注册 |
登录 |
帮助 |
搜索 |
排行榜 |
发帖统计
|
您没有登录 |
» Java开发网 » Java SE 综合讨论区
打印话题 寄给朋友 订阅主题 |
作者 | Re:求助关于Java的抗锯齿实现 [Re:widewindow] |
widewindow
发贴: 9 积分: 0 |
于 2008-06-09 12:01
I followed your advice and posted the question on javaranch. I got some useful infomation there. The URL is: http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=2&t=017410 There, it was said the algorighm is released in JDK 7. I'll study the source package and try to find the algorithm. Thank you! |
作者 | Re:求助关于Java的抗锯齿实现 [Re:widewindow] |
widewindow
发贴: 9 积分: 0 |
于 2008-06-11 10:50
I use following simple but completely runnable java program to test anti-aliasing: /* * Copyright 2000 David Flanagan. All rights reserved. * This code is from the book Java Examples in a Nutshell, 2nd Edition. * It is provided AS-IS, WITHOUT ANY WARRANTY either expressed or implied. * You may study, use, and modify it for any non-commercial purpose. * You may distribute it non-commercially as long as you retain this notice. * For a commercial use license, or to purchase the book (recommended), * visit http://www.davidflanagan.com/javaexamples2. */ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import javax.swing.JFrame; import javax.swing.JPanel; /** A demonstration of anti-aliasing */ class AntiAlias extends JPanel{ static final int WIDTH = 650, HEIGHT = 350; // Size of our example public String getName() { return "AntiAliasing"; } public int getWidth() { return WIDTH; } public int getHeight() { return HEIGHT; } /** Draw the example */ public void paint(Graphics g1) { Graphics2D g = (Graphics2D) g1; BufferedImage image = // Create an off-screen image new BufferedImage(65, 35, BufferedImage.TYPE_INT_ARG; Graphics2D ig = image.createGraphics(); // Get its Graphics for drawing // Set the background to a gradient fill. The varying color of // the background helps to demonstrate the anti-aliasing effect ig.setPaint(new GradientPaint(0, 0, Color.black, 65, 35, Color.white)); ig.fillRect(0, 0, 65, 35); // Set drawing attributes for the foreground. // Most importantly, turn on anti-aliasing. ig.setStroke(new BasicStroke(2.0f)); // 2-pixel lines ig.setFont(new Font("Serif", Font.BOLD, 18)); // 18-point font ig.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); /*ig.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); ig.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);*/ ig.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY); // Now draw pure blue text and a pure red oval ig.setColor(Color.blue); //ig.drawString("Java", 9, 22); //ig.setColor(Color.red); //ig.drawOval(1, 1, 32, 32); ig.drawLine(13, 0, 19, 0); ig.drawLine(10, 1, 22, 1); ig.drawLine(8, 2, 24, 2); ig.drawLine(7, 3, 25, 3); ig.drawLine(6, 4, 26, 4); ig.drawLine(5, 5, 27, 5); ig.drawLine(4, 6, 28, 6); ig.drawLine(3, 7, 29, 7); ig.drawLine(3, 8, 29, 8); ig.drawLine(2, 9, 30, 9); ig.drawLine(2, 10, 30, 10); ig.drawLine(2, 11, 30, 11); ig.drawLine(1, 12, 31, 12); ig.drawLine(1, 13, 31, 13); ig.drawLine(1, 14, 31, 14); ig.drawLine(1, 15, 31, 15); ig.drawLine(1, 16, 31, 16); ig.drawLine(1, 17, 31, 17); ig.drawLine(1, 18, 31, 18); ig.drawLine(2, 19, 30, 19); ig.drawLine(2, 20, 30, 20); ig.drawLine(2, 21, 30, 21); ig.drawLine(3, 22, 29, 22); ig.drawLine(3, 23, 29, 23); ig.drawLine(4, 24, 28, 24); ig.drawLine(5, 25, 27, 25); ig.drawLine(6, 26, 26, 26); ig.drawLine(7, 27, 25, 27); ig.drawLine(8, 28, 24, 28); ig.drawLine(10, 29, 22, 29); ig.drawLine(13, 30, 19, 30); // Finally, scale the image by a factor of 10 and display it // in the window. This will allow us to see the anti-aliased pixels g.drawImage(image, AffineTransform.getScaleInstance(10, 10), this); // Draw the image one more time at its original size, for comparison g.drawImage(image, 0, 0, this); } public static void main(String[] a) { JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setContentPane(new AntiAlias()); f.setSize(400,400); f.setVisible(true); } } My question is, is there any debugging tool that can trace into the system code after f.setVisible(true); ? From there, I think the anti-aliasing job is down by the java system modules. |
作者 | Re:求助关于Java的抗锯齿实现 [Re:widewindow] |
JiafanZhou
版主 发贴: 736 积分: 61 |
于 2008-06-13 15:50
Sorry I replied you late. I am kind of busy these days. Now to answer your previous questions, of course there are lots of debugging tools for Java programs in the market place. The one I use is the embedded debugger in Eclipse IDE. And it is very easy to learn and use, followings are the steps: 1. Download the latest Eclipse IDE, available at http://www.eclipse.org/. 2. Create a new Java project in Eclipse. 3. Create a new Java class called "AntiAlias". 4. Set a breakpoint at the line you want the debugger to stop. 4. Run debugging. Any problems, let me know. Regards, Jiafan When I was a kid I used to pray every night for a new bike. Then I realized that The Lord doesn't work that way, so I stole one and asked him to forgive me. |
作者 | Re:求助关于Java的抗锯齿实现 [Re:widewindow] |
widewindow
发贴: 9 积分: 0 |
于 2008-06-13 16:32
Thank you for your reply. I used quite a bit time to read some of JRE7's source code, I think MOST likely, the anti-alias code should be in Pisces modules. Later, I visited http://openjdk.java.net/groups/2d to find the full source code is in https://phoneme.dev.java.net/svn/phoneme/components/pisces/trunk, for your conveniences, please use Subversion to check out the source code, it's profound and not easy to understand. I don't know how much time I should spend to understand it. Surely I'll follow your guide to debug the java example. Thank you! |
作者 | Re:求助关于Java的抗锯齿实现 [Re:widewindow] |
JiafanZhou
版主 发贴: 736 积分: 61 |
于 2008-06-27 16:22
Link this thread to the following thread. http://www.cjsdn.net/post/view?bid=46&id=194763&tpg=1&ppg=1&sty=1#194826 looks very similar issue to me. When I was a kid I used to pray every night for a new bike. Then I realized that The Lord doesn't work that way, so I stole one and asked him to forgive me. |
作者 | Re:求助关于Java的抗锯齿实现 [Re:widewindow] |
jancyu2008
发贴: 36 积分: 0 |
于 2008-07-01 23:29
I don't understand !!!!!!!!!! Every day thinking about JAVA, because I like to Welcome to My pagehttp://jeakylau.51.com My E-mail:jeakylau@126.com My QQ : 529163539 |
已读帖子 新的帖子 被删除的帖子 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |