<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<title>Romain Guy&apos;s Blog</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/gfx/" />
<modified>2006-09-27T01:12:05Z</modified>
<tagline></tagline>
<id>tag:weblogs.java.net,2008:/blog/gfx/250</id>
<generator url="http://www.movabletype.org/" version="3.01D">Movable Type</generator>
<copyright>Copyright (c) 2006, gfx</copyright>
<entry>
<title>Java2D Gradients Performance</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/gfx/archive/2006/09/java2d_gradient.html" />
<modified>2006-09-27T01:12:05Z</modified>
<issued>2006-09-27T01:07:03Z</issued>
<id>tag:weblogs.java.net,2006:/blog/gfx/250.5635</id>
<created>2006-09-27T01:07:03Z</created>
<summary type="text/plain">Gradients are one of my favorite Java2D tools and I just made some interesting discoveries about their performance.</summary>
<author>
<name>gfx</name>

<email>romain.guy@mac.com</email>
</author>
<dc:subject>Community: JavaDesktop</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/gfx/">
<![CDATA[<p>I feel weird. My hands are sweaty and my throat is sore. My heart's beating too fast... What's happening to me?! Wait, I know. I haven't blogged here for the past 7 months! Dammit. Sorry for that folks.</p>

<p>Back to gradients. I use Java2D gradients a lot. I mean, <strong><font size="+1">A LOT</font></strong>. Most of the time, gradients work perfectly fine and performance are more than enough, especially when you honor the clipping rectangle. In some rare occasions, a gradients does take quite some time to be painted. This happens when you are painting large areas with a gradients as in the following screenshot:</p>

<p><div style="text-align: center;"><a href="http://jext.free.fr/aerithosx2.png" target="_blank"><img src="http://jext.free.fr/aerithosx2_small.png" class="UserImage" style="border: 0px none" alt="Aerith" /></a></div></p>

<p>In this picture, the background gradient is about 700x500 pixels large. That's a lot of pixels. Since we were drawing full frame animations (60fps) on top of this gradient, the JVM wa a tad CPU hungry. We optimized this by painting the gradient in a buffer image that we use instead every time a repaint event occurs. Problem solved.</p>

<p>Or is it? Using a large picture was fine in this case because it was after all just a demo. But is it worth wasting 1,5MB or so of RAM? I think not. There's a very nifty trick you can use to optimize the drawing of large vertical and horizontal gradients: image resizing.</p>

<p>Instead of painting the gradient in a picture large enough to cover the area you want to repaint, paint it in a 1 pixel wide picture for vertical gradients or in a 1 pixel high picture for horizontal gradients. Then, at runtime, paint the picture with <code>drawImage(image, x, y, w, h, null)</code>. By passing the size of the component to this method call, you will get the result you wanted quickly and without wasting memory.</p>

<p>Here is an example of how you can use this trick:</p>

<pre>
    @Override
    protected void instrumentedPaintComponent(Graphics2D g2) {
        if (cache == null || cache.getHeight() != getHeight()) {
            cache = new BufferedImage(2, getHeight(),
                BufferedImage.TYPE_INT_RGB);
            Graphics2D g2d = cache.createGraphics();
            
            GradientPaint paint = new GradientPaint(0, 0, Color.BLACK,
                0, getHeight(), Color.WHITE);
            g2d.setPaint(paint);
            g2d.fillRect(0, 0, 2, getHeight());
            g2d.dispose();
        }
        g2.drawImage(cache, 0, 0, getWidth(), getHeight(), null);
    }
</pre>

<p>But how does this trick compare to the two previous techniques? Well, here I have made surprising discoveries. I wrote a simple app to test the speed difference between the 3 approaches on Windows and Mac OS X. I first ran the tests on Windows at two different sizes (small gradients, about 200x200 pixels, versus large gradients, about 300x800) with various command line flags to change the rendering pipeline. I then ran the tests on Mac OS X at two different sizes. All tests were using Java SE 6 b88. On the following diagrams, smaller numbers (even negatives due to the logarithmic scales) are better.</p>

<p><div style="text-align: center;"><img src="http://jext.free.fr/windowsperf.png" class="UserImage" style="border: 0px none" alt="Windows Performance (Small)" /></div></p>

<p><div style="text-align: center;"><img src="http://jext.free.fr/windowsperf2.png" class="UserImage" style="border: 0px none" alt="Windows Performance (Large)" /></div></p>

<p><div style="text-align: center;"><img src="http://jext.free.fr/macosxperf.png" class="UserImage" style="border: 0px none" alt="Mac OS X Performance" /></div></p>

<p>From these diagrams, two things are for sure on Windows: images are faster than regular gradients and the new OpenGL pipeline in Mustang is freakingly good. On Mac OS X though, all techniques are roughly the same. The main advantages of pictures over regular gradients is that whatever rendering pipeline you use, the results are almost the same on Windows.</p>

<p>Even though using 1 pixel wide/tall pictures is a bit slower than full size pictures, this technique is the best in terms of speed and memory usage. At least for horizontal and vertical gradients.</p>

<p>P.S: By the way, this is only a benchmark that continuously paints gradients using all three techniques for a given number of seconds and finally spits out the time spent in each implementation. It might not (and surely does not) reflect real world use at all :)</p>]]>

</content>
</entry>
<entry>
<title>A lot of free articles</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/gfx/archive/2006/03/a_lot_of_free_a.html" />
<modified>2006-06-09T00:45:50Z</modified>
<issued>2006-03-30T09:45:38Z</issued>
<id>tag:weblogs.java.net,2006:/blog/gfx/250.4408</id>
<created>2006-03-30T09:45:38Z</created>
<summary type="text/plain">If you can read French and like programming, you should enjoy what I have to announce.</summary>
<author>
<name>gfx</name>

<email>romain.guy@mac.com</email>
</author>
<dc:subject>Community</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/gfx/">
<![CDATA[<p>During the past 5 years and a half, I worked as a free lance journalist for a French computing magazine called Login:. Because of financial troubles, its publisher, Posse Press, has closed. I had a great time working for them and I enjoyed this job as it made me discover wonderful technologies.</p>

<p>Anyway, I decided to release all my work under the Creative Commons Attribution-ShareAlike 2.5 license. Among the 150+ articles you can download, you'll find about 80 related to Java. The others deal with various other programming technologies (XML, Squeak, Zope, GameBoy Advance, etc.) Some articles are old and most of them are targeted at beginners. Besides, this is only the text, there is no layout. So, well, don't expect me to do anything if there is something missing or wrong :)) Oh and they are all <b>in French</b>.</p>

<p>So here they are, packed by themes. Enjoy!</p>

<ul>
<li><a href="http://www.barberousse.info/gfx/">Mirror 1</a></li>
<li><a href="http://samva.info/gfx/">Mirror 2</a></li>
<li><a href="http://home.slaborde.net/gfx/">Mirror 3</a></li>
<li><a href="http://xfrogg.free.fr/Gfx/">Mirror 4</a></li>
</ul>]]>

</content>
</entry>
<entry>
<title>GroupLayout is integrated into Mustang</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/gfx/archive/2006/03/grouplayout_is.html" />
<modified>2006-06-09T00:45:50Z</modified>
<issued>2006-03-18T09:07:35Z</issued>
<id>tag:weblogs.java.net,2006:/blog/gfx/250.4344</id>
<created>2006-03-18T09:07:35Z</created>
<summary type="text/plain">Wow, I missed that putback in the source tree but here it is folks!</summary>
<author>
<name>gfx</name>

<email>romain.guy@mac.com</email>
</author>
<dc:subject>Community: JavaDesktop</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/gfx/">
<![CDATA[<p>I'm just relaying the information from <a href="http://www.javalobby.org/java/forums/t66080.html">JavaLobby</a> but <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6375459">GroupLayout has been integrated into Mustang b76</a>. GroupLayout is the layout manager that makes NetBeans' Matisse GUI builder shine. So, <a href="http://download.java.net/jdk6/binaries/">go grab Mustang</a>, download <a href="http://www.netbeans.info/downloads/download.php?type=5.0">NetBeans 5.0</a> and enjoy!</p>

<p>Please note that this new features still required the approval from the JSR 270 EG. You can find more information about Java SE 6 JSR on the JCP web site: http://www.jcp.org/en/jsr/detail?id=270</p>]]>

</content>
</entry>
<entry>
<title>Make Swing... er... Swing!</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/gfx/archive/2006/02/make_swing_er_s.html" />
<modified>2006-06-09T00:45:50Z</modified>
<issued>2006-02-07T09:24:41Z</issued>
<id>tag:weblogs.java.net,2006:/blog/gfx/250.4064</id>
<created>2006-02-07T09:24:41Z</created>
<summary type="text/plain">A good looking GUI needs a bit more than just fancy graphics. It needs life, animation! Java SE provides everything you need to make your Swing apps swing, but there&apos;s an easier way.</summary>
<author>
<name>gfx</name>

<email>romain.guy@mac.com</email>
</author>
<dc:subject>Community: JavaDesktop</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/gfx/">
<![CDATA[<p>Most GUI are really boring. And I really mean it. Admit it, you'd rather listen to a French stammerer trying to recite a bad English translation of <i>War and Peace</i> during a rainy Sunday afternoon (and boy what a long afternoon it would be) than look yet again at some applications. Besides cool aesthetics, a way to make a GUI for appealing (just talking about the look here) is to introduce animations. Some get it right (Apple), and some get it really wrong (the first thing I do with a fresh Windows install - after muting the sounds - is to shut down all the animations). But that's not the point. Bad or good, we just want animations in our Swing application.</p>

<p><code>javax.swing.Timer</code> is the preferred way to animate a component, an effect or whatever in Swing. Despite a lack of precision, no better than the native timing resolution (which would be around 15ms on Windows), this timer is really easy to use as it relies on <code>ActionListener</code> and as it posts all its events in the EDT. Unfortunately, this timer's API is very crude and gives you the bare minimum:</p>

<pre>
Timer crudeTimer = new Timer(1000 / 30, new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    }
});
crudeTimer.start();
</pre>

<p>That, is a simple timer firing an event 30 times per second (or so it claims at least.) So, what is missing here? Too many things to make animations easy to develop. First, this timer doesn't track the elapsed time. You have to do that by yourself using <code>System.currentTimeMillis()</code> or better yet <code>System.nanoTime()</code>. This timer also doesn't care about the duration of the animation. You have to test the elapsed time against a given delay and stop the timer accordingly, using this beautiful expression: <code>((Timer) e).stop()</code>. What about repeating an animation? Going back and forth? You get the point, <code>Timer</code>'s useful but way too generic for our purpose. I have written so many Timer/ActionListener pairs full of tangled and ugly Java code that I feel pretty confident to herein conclude about the timers: <b>@#!</b>.</p>

<p>Let me introduce you to the solution of the wise man, <a href="http://timingframework.dev.java.net/">Chet Haase's timing framework</a>. Before you run away bewildered by such a powerful imagination to name a framework, take a deep breath, sit down and stay focused for a couple more minutes, will you? It's worth it. I swear. Chet ran into the exact same problems as the aforementioned ones. But Chet is not lazy, Chet is full of resources. Chet built a solution to this problem. Bestow our eternal gratitude on Chet (or whatever that is you want to bestow on Chet.) Anyway, Chet wrote a <a href="http://today.java.net/pub/a/today/2005/02/15/timing.html">comprehensive and really interesting introduction to his framework</a> that I urge you to read. I won't delve into the details here but the point is, hitherto you were striving to create animations for Swing UI and now it's much easier. How so? Let's take a look at a simple example a nice looking but boring, static button:</p>

<br /><div style="text-align: center;"><img src="http://jext.free.fr/boring_button.png" /><br /><font size="-1"><em>Evidence #1. A boring button.</em></font></div><br /><br />

<p>Usually, Swing developers make buttons more interactive by introducing a rollover effect. The nice thing is you just need to call somethin like <code>JButton.setRolloverIcon()</code> to make it work. Unfortunately, the change is sudden and doesn't look so sexy. The solution is to animate the rollover effect. In my case, I added a highlight in the background that gradually appears when the mouse moves over the button. The animation is vey fast (about 300 ms) so it's not annoying but you can still notice it. Here is the animated result:</p>

<br /><div style="text-align: center;"><img src="http://jext.free.fr/cool_button.png" /><br /><font size="-1"><em>Evidence #2. A cool button (and <a href="http://jext.free.fr/cool_button.mov">animated</a>)</em></font></div><br /><br />

<p>When the mouse exits the button, the contrary happens, and the highlights fades out. In this particular case, I took care of animation consistency. For instance, if you enter the button then exits halfway throught the animation then enter again, you will see the animation react properly. It won't jump to its extreme values. Believe me, that's a pain to handle with <code>javax.swing.Timer</code>. Now, thanks to Chet's timing framework, things are way better than they used to be:</p>

<pre>
private final class HiglightHandler extends MouseAdapter {
    private TimingController timer;
    private Cycle cycle = new Cycle(300, 1000 / 30);
    private Envelope envelope = new Envelope(1, 0,
                                             RepeatBehavior.FORWARD,
                                             EndBehavior.HOLD);
    
    @Override
    public void mouseEntered(MouseEvent e) {
        animate(true);
    }
    
    @Override
    public void mouseExited(MouseEvent e) {
        animate(false);
    }

    private void animate(boolean forward) {
        if (timer != null && timer.isRunning()) {
            timer.stop();
        }
        timer = new TimingController(cycle, envelope, new AnimateGhost(true));
        timer.start();
    }
}

private final class AnimateGhost implements TimingTarget {
    private boolean forward;
    private float oldValue;

    AnimateGhost(boolean forward) {
        this.forward = forward;
        oldValue = ghostValue;
    }

    public void timingEvent(long cycleElapsedTime,
                            long totalElapsedTime,
                            float fraction) {
        ghostValue = oldValue + fraction * (forward ? 1.0f : -1.0f);
        repaint();
    }

    public void begin() {
    }

    public void end() {
    }
}
</pre>

<p>This code might seem a bit long but when you look more closely you'll see it is very easy. You can see a mouse adapter that handle the mouse enter/exit events and start the animation accordingly. All three fields from <code>HiglightHandler</code> uses classes from Chet's timing framework. The <code>Cycle</code> defines the total duration of the animation as well as its number of frames per second. The <code>Envelope</code> describes the animation itself: it is played once, with no initial delay, it goes forward in time (to get a time fraction going from 0.0 to 1.0) and holds its last value when the animation is over. Finally, the <code>TimingTarget</code> is where the nicest thing happens: the <code>timingEvent()</code> callback gives you everything you need to animate your GUI. In our case we just use the <code>fraction</code> (our position in time) and use it to modify the <code>ghostValue</code>. This value is just used as the transparency level of the white highlight you can see in the second screenshot.</p>

<p>As you can see, this small framework makes things easier both for the author of the code but also for the readers. Chet, Chris and I are currently using this framework almost everyday and as we go along, Chet is discovering new things to integrate into it. You can expect really nice things in a near future, like non-linear progressions. In the meantime, give it a try, I'm sure you will love it.</p>

<p>I couldn't post a webstart demo of the small effect I presented here but I'll try to do that this week if I have some time. Yet, you can download the <a href="http://jext.free.fr/cool_button.mov">animation</a> (QuickTime format, 46kb) to see what it looks like. You can also check the talk <a href="http://jroller.com/page/gfx?entry=desktop_java_presentation">Desktop Java in Action</a> Richard Bair and I gave at JavaPolis. At the end of the presentation, in the <em>FX</em> section, I talk more about how to use Swing's timers for animations and the related problems.</p>]]>

</content>
</entry>
<entry>
<title>Video Presentation: Desktop Java in Action</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/gfx/archive/2006/01/video_presentat.html" />
<modified>2006-06-09T00:45:50Z</modified>
<issued>2006-01-05T07:25:47Z</issued>
<id>tag:weblogs.java.net,2006:/blog/gfx/250.3889</id>
<created>2006-01-05T07:25:47Z</created>
<summary type="text/plain">If you speak french, you can download a video of Desktop Java in Action. Otherwise, get the slides.</summary>
<author>
<name>gfx</name>

<email>romain.guy@mac.com</email>
</author>
<dc:subject>Community: JavaDesktop</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/gfx/">
<![CDATA[<p><a href="http://weblogs.java.net/blog/rbair">Richard Bair</a> and I have created a presentation entitled <i>Desktop Java in Action</i> for <a href="http://www.javapolis.com">JavaPolis</a>. I also presented this talk in Paris at Sun Microsystems. I recently made the <a href="http://www.jroller.com/page/gfx/?anchor=desktop_java_presentation">slids of the talk available online</a> but as every slide set, they lack a lot of information given by the speaker(s).</p>

<p>If you speak french, you are very lucky because <a href="http://www.developpez.com">Developpez</a>, a french programming network, offers a <a href="http://java.developpez.tv/javadesktop-dec2005/">video of the presentation online for free</a>. The talk is 3 hours long but they did a great job by slicing it into more than 20 parts. Each part has a short description that will help you find your favorite topics.</p>

<p>If you do not speak french, don't worry, all JavaPolis talks will be available as videos within a couple of months.</p>]]>

</content>
</entry>
<entry>
<title>NetBeans with anti aliasing</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/gfx/archive/2006/01/netbeans_with_a.html" />
<modified>2006-06-09T00:45:50Z</modified>
<issued>2006-01-02T23:42:20Z</issued>
<id>tag:weblogs.java.net,2006:/blog/gfx/250.3877</id>
<created>2006-01-02T23:42:20Z</created>
<summary type="text/plain">I said it several times: I use Eclipse. But yet another reason for me to use Eclipse instead of NetBeans is now gone.</summary>
<author>
<name>gfx</name>

<email>romain.guy@mac.com</email>
</author>
<dc:subject>Community: Java Tools</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/gfx/">
<![CDATA[<p>I have Mustang as my primary VM for work and personal use. Yet I had to reinstall Tiger to be able to run NetBeans 5.0 beta2 properly because I kept getting a nasty exception regarding some XML things. Anyway, I couldn't use NB on Mustang, meaning I couldn't benefit from the subpixel anti aliasing. Hopefully, the NB guys told me today it is a bug in the JDK itself and it has been fixed in b61 so I installed a nightly build of Mustang b65 and it now works perfectly!</p>

<div style="text-align: center"><a href="http://www.progx.org/users/Gfx/nbaa.png"><img src="http://www.progx.org/users/Gfx/nbaa_small.png" alt="NB with anti aliasing" /></a></div><br />

<p>It looks so much better now! Unfortunately there is still a bug in Mustang's rasterizer which makes my favorite fixed width font (<a href="http://www.dafont.com/en/font.php?file=bitstream_vera_mono">BitStream Vera Sans Mono</a> free, GPL font) look really bad at small sizes.</p>]]>

</content>
</entry>
<entry>
<title>JavaPolis 2005</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/gfx/archive/2005/12/javapolis_2005.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2005-12-05T10:49:25Z</issued>
<id>tag:weblogs.java.net,2005:/blog/gfx/250.3736</id>
<created>2005-12-05T10:49:25Z</created>
<summary type="text/plain">JavaPolis 2005 is taking place next week. If you want to meet two new members of the Swing Team and see some cool stuff, come to Antwerp.</summary>
<author>
<name>gfx</name>

<email>romain.guy@mac.com</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/gfx/">
<![CDATA[<a href="http://www.javapolis.com/confluence/display/JP05/Home"><img src="http://www.javapolis.com/confluence/download/attachments/10033/javapolis.gif" alt="JavaPolis 2005" /></a>

<p><a href="http://www.javapolis.com/confluence/display/JP05/Home">JavaPolis</a> is European Java conference taking place from December 12th to December 16th in Antwerp, Belgium. This new installment will be the occasion fo attend interesting sessions by very interesting guys, like Ben Galbraith, Karsten Lentzsh, Heliott Rusty Harol, Graham Hamilton, Joshua Bloch, Neal Gafter and many others. It's not as big as JavaOne but whether you like Java SE, Java EE, Open Source projects or desktop applications, you'll find what you want there. All the content from the previous years is available on the web site, so go check it out.</p>

<p><a href="http://weblogs.java.net/blog/rbair/">Richard Bair</a>, leader of the <a href="http://www.swinglabs.org">SwingLabs</a> project, and I will give a talk on Monday entitled <i>Desktop Java in Action</i>. We'll talk about SwingX, data binding, UI special effects and more. I will also present <i>Extreme Swing</i> on Thursday, just before Karsten's JGoodies session, to explain how to create 2.5D/3D effects with Swing and Java2D.</p>

<p>As a bonus, I will finally go home for a few days after 7 months in the US. I have to catch up on the food and the beer. Anyway, if you happen to be at JavaPolis next week and if you want to talk about Swing, Java2D and UI design, comme see us anytime!</p>]]>

</content>
</entry>
<entry>
<title><![CDATA[Fa&ccedil;ade, gaming redefined]]></title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/gfx/archive/2005/11/faade_gaming_re.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2005-11-29T04:07:41Z</issued>
<id>tag:weblogs.java.net,2005:/blog/gfx/250.3706</id>
<created>2005-11-29T04:07:41Z</created>
<summary type="text/plain"><![CDATA[Every now and then, a group of few people come up with a bright idea that shakes the world of video games. Fa&ccedil;ade might just be one of them and it's Java powered.]]></summary>
<author>
<name>gfx</name>

<email>romain.guy@mac.com</email>
</author>
<dc:subject>Community: Java Games</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/gfx/">
<![CDATA[<p>I am what you would call a "gamer". I have been playing video games starting with the NES. Since then I owned many consoles and dozens of video games. My love for video games is due do the stories and the wonderful worlds game designers imagine for us. That's why even though I bought 4 consoles since I arrived in the US 7 months ago I am not a hard-core gamer. Once the story has been told, the game is over and I want to play at my own pace. I can spend weeks without playing and when I play, it cannot be more than a few hours a week and this makes me happy.</p>

<div style="text-align: center"><a href="http://jext.free.fr/games1.jpg"><img src="http://jext.free.fr/games1_small.jpg" alt="Project Gotham Racing 3" /></a><br /><font size="-1"><i>Beautiful? Booooring!</i></font></div><br />

<p>I should be thrilled by the recent release of the XBox 360 but I am not. I am, actually, sad. As the hardware becomes more and more complex, game developers need more and more time to create their games, most of the time for the sake of better graphics. I love good looking games but most of them don't entertain me anymore. And despite its incredible power the XBox 360 only offers me games I've played with millions of times before. I've always liked Nintendo's approach to gaming and I cannot thank them enough for what they are doing with the Nintendo DS and the Revolution: the hardware forces game developers to be creative, to bring us a new breed of video games. I don't want yet another Blizzard's RTS, another Madden NFL iteration, another boring FPS with dark hallways... I want more of ICO, Shadow of the Colossus, Wario Ware, Pac Pix, Meteos!</p>

<div style="text-align: center"><a href="http://jext.free.fr/games2.jpg"><img src="http://jext.free.fr/games2_small.jpg" alt="Yoshi Touch and Go" /></a><br /><font size="-1"><i>You mean I have to BLOW in my Nintendo DS to get rid of the clouds? Gimme that game!</i></font></div><br />

<p><a href="http://www.interactivestory.net">Fa&ccedil;ade</a> might just be what I was waiting for. This innovative game is in fact an AI based art/research experiment. Presented as a one-act drama, Fa&ccedil;ade first appears as crude-looking, very short game. Yet, thanks to 5 years of engineering, its authors managed to create a novel architecture which supports emotions, body language, facial expressions, natural language generation and parsing and a drama-managed plot.</p>

<p>The game doesn't even dictate you who you are. When launching the game you are asked to choose a name, and therefore your sex. You are then dropped in the game itself, a 3D world in which you interact through a first person point of view. The game starts at the front door of two of your friends, Trip and Grace, who invited you over for dinner. As the drama unfolds it becomes apparent their couple is having trouble and you are the witness of their unhappiness. What should you do? I can't tell. It's different every time you play the game. The characters react to your actions (you can comfort, hug and kiss them) and to your words (you can talk to them at anytime by simply typing something on your keyboard) so it's really up to you. You can try to help them the way you want. Or you can just sit tight and see what happens. There is no goal other than experiencing a good moment of what gaming could be.</p>

<p>Even though it's not graphically appealing, Fa&ccedil;ade is technically impressive in the way it parses the sentences you type. I also really enjoyed the generation of natural dialogues. Characters hesitate, interrupt each other and so on. It's not perfect but it's refreshing. Also the lips-syncing might no be very good but look at the facial expressions and the body language of Trip and Grace. After having seen bland and neutral states on characters faces in almost every 3D video game I played to, I'm thrilled.</p>

<p>So please, if you are on Windows, go to <a href="http://www.interactivestory.net">the official web site</a> and download your free copy of the game. Some of you will love it, some will find it deeply boring but I doubt you will remain unconcerned about it.</p>

<p>Oh and I wouldn't worry too much if you are not on Windows and cannot play the game. After all, it's written in Java and OpenGL and the authors seem interested in any help to port the game to another OS (at least MacOS X).</p>]]>

</content>
</entry>
<entry>
<title>Twinkle Teaser</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/gfx/archive/2005/11/twinkle_teaser.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2005-11-11T01:09:44Z</issued>
<id>tag:weblogs.java.net,2005:/blog/gfx/250.3611</id>
<created>2005-11-11T01:09:44Z</created>
<summary type="text/plain">I&apos;m still working on it and I&apos;m late but I have a cool teaser.</summary>
<author>
<name>gfx</name>

<email>romain.guy@mac.com</email>
</author>
<dc:subject>Community: JavaDesktop</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/gfx/">
<![CDATA[<p>I recently posted a screenshot of Twinkle, a demo involving Java2D, Swing and OpenGL. Here is a video showing Twinkle in action (so far):</p>

<ul>
<li><a href="http://jext.free.fr/twinkle.avi">Teaser in XViD format</a></li>
<li><a href="http://jext.free.fr/twinkle.mov">Teaser in QuickTime 7/H.264 format</a></li>
</ul>

<p>I will never thank enough Chris Campbell and Ken Russel for giving us these realy cool feature.</p>]]>

</content>
</entry>
<entry>
<title>Twinkle, a Java2D/OpenGL Demo</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/gfx/archive/2005/11/twinkle_a_java2.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2005-11-09T09:24:50Z</issued>
<id>tag:weblogs.java.net,2005:/blog/gfx/250.3589</id>
<created>2005-11-09T09:24:50Z</created>
<summary type="text/plain">I have spent the past few days playing with JOGL and the new OpenGL pipeline in Mustang. Here is a sneak preview of a soon to be released demo.</summary>
<author>
<name>gfx</name>

<email>romain.guy@mac.com</email>
</author>
<dc:subject>Community: JavaDesktop</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/gfx/">
<![CDATA[<p>The new OpenGL pipeline in Mustang let external API composite a Swing UI with an OpenGL scene. This allows JOGL to efficiently mix Swing and 3D. <i>Twinkle</i>, a simple photo viewer (it looks like Microsoft Max :), benefit from this. Take a look for yourself:</p>

<div style="text-align: center"><a href="http://jext.free.fr/twinkle.png"><img src="http://jext.free.fr/twinkle_small.png" alt="Twinkle" /></a></div><br />

<p>In this screenshot, the black background, the pictures strip on top and the caption at the bottom are drawn with Java2D. You can think of this scene as a composition of three layers: a 2D background, a 3D layer and a 2D foreground.</p>

<p>I'm working on another demo called <i>BackSeat</i> using this pipeline. It is a bit more complicated but still remains in the "2.5D space". Chris Campbell and I are also trying to figure out the basic utility methods and classes one might need to easily create such scenes. I already have a few things I will release along with Twinkle source code. Even though you need to know a bit about OpenGL (I started learning for these demos), they let you quickly set up a scene containing billboards and reflected textured quads using anti-aliasing, depth of field or motion blur.</p>

<p>Stay tuned.</p>]]>

</content>
</entry>
<entry>
<title>Twice the IDE</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/gfx/archive/2005/10/twice_the_ide.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2005-10-24T23:26:22Z</issued>
<id>tag:weblogs.java.net,2005:/blog/gfx/250.3484</id>
<created>2005-10-24T23:26:22Z</created>
<summary type="text/plain">I recently said I&apos;ll be using two IDEs at the same time. The good news is, it works really well.</summary>
<author>
<name>gfx</name>

<email>romain.guy@mac.com</email>
</author>
<dc:subject>Community: Java Tools</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/gfx/">
<![CDATA[<p>Using Eclipse for the code, NetBeans for profiling, how cool is that? Well, it is, especially when you have a dual screen setup. I know a lot of developers do have such a setup today. Mine is a bit weird though:</p>

<div style="text-align: center"><a href="http://jext.free.fr/twoide.png"><img src="http://jext.free.fr/twoide_small.png" alt="Two IDEs" /></a></div><br /><br />

<p>Anyway, I have been quite successful using two IDEs so far so I'm ready to switch to next gear and use NetBeans 5.0 GUI Builder for my UIs. Eclipse, as any decent IDE/source editor, knows when a file has changed on the hard drive and asks to reload it. And anyway, source code versioning tools come in handy in such cases :)</p>

<p>As much as I love writing my UIs by hand, I'm getting tired of fiddling with layout managers. I do my best to make my life easier with other tasks, so why not with this one?</p>

<p>Do you or did you successfully used two IDEs for the same project at the same time? I'd be interested in hearing from similar experiences.</p>]]>

</content>
</entry>
<entry>
<title>Flock, rediscover the web</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/gfx/archive/2005/10/flock_rediscove.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2005-10-21T13:37:53Z</issued>
<id>tag:weblogs.java.net,2005:/blog/gfx/250.3469</id>
<created>2005-10-21T13:37:53Z</created>
<summary type="text/plain">I just installed Flock and I am writing this entry from within this new web browser. Flock provides a brand new way to browse the web and interact with social networks: blogs, del.icio.us, flickr, etc. It&apos;s been a while since...</summary>
<author>
<name>gfx</name>

<email>romain.guy@mac.com</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/gfx/">
<![CDATA[I just installed <a href="http://www.flock.com/">Flock</a> and I am writing this entry from within this new web browser. Flock provides a brand new way to browse the web and interact with social networks: blogs, del.icio.us, flickr, etc. It's been a while since we have seen real innovation amid web browsers but this is it. Go try it out, you might not regret it, despit the bugs.<br /><br /><p><a href="http://jext.free.fr/flock.png"><img alt="Flock" src="http://jext.free.fr/flock_small.png" style="border: 0px solid ; width: 450px; height: 281px;" /></a></p>Flock also contains many powerful features, like a full index for the pages you visited. This allows you to find pages in your history with their content instead of just their title or URL. Oooh I'm so excited by what this application could become!<br /><p><a href="http://jext.free.fr/flock3.png"><img alt="Flock" src="http://jext.free.fr/flock3_small.png" style="border: 0px solid ; width: 450px; height: 281px;" /></a></p>]]>

</content>
</entry>
<entry>
<title>Unexpected Java Tool</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/gfx/archive/2005/10/unexpected_java.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2005-10-10T21:49:05Z</issued>
<id>tag:weblogs.java.net,2005:/blog/gfx/250.3411</id>
<created>2005-10-10T21:49:05Z</created>
<summary type="text/plain">While looking for an efficient graping tool for Windows, I discovered a very interesting feature of Maple.</summary>
<author>
<name>gfx</name>

<email>romain.guy@mac.com</email>
</author>
<dc:subject>Community: JavaDesktop</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/gfx/">
<![CDATA[<p>When I'm home and need to tweak and plot an equation, I use an excellent tool that ships with MacOS X 10.4, Grapher. Easy to use, it fits my purpose and provides a good user experience:</p>

<div style="text-align: center"><a href="http://jext.free.fr/grapher.png"><img src="http://jext.free.fr/grapher_small.png" alt="Tiger Grapher" /></a></div><br /><br />

<p>As I don't want to carry both my laptops to the office every day, I bring only my Windows box, on which I have yet to find a tool to replace Grapher. I have tried several tools and none convinced me yet. Nevertheless, I decided to give <a href=http://www.maplesoft.com/">Maple 10</a> a try. I learned how to use Maple a few years ago at school and I was wondering what new stuff it could offer. Well, first of all, it seems to be written mostly in Java (at leat the whole UI is). The UI is also much easier for newcomers and now provides completion, context sensitive menus, and so forth. But that's not my point. Maple proved to be a valuable Java development tool.</p>

<p>It turns out Maple offers a language translation feature that can turn calculations, equations and even "Maple script" procedures into another language. Among the available targets are C, FORTRAN, MATLAB, Visual Basic and... Java. Take this example for instance:</p>

<div style="text-align: center"><a href="http://jext.free.fr/maple1.png"><img src="http://jext.free.fr/maple1_small.png" alt="Maple" /></a></div><br /><br />

<p>To use this equation in my Java source code I can just right click on it and go to the Language Conversion menu:</p>

<div style="text-align: center"><a href="http://jext.free.fr/maple2.png"><img src="http://jext.free.fr/maple2_small.png" alt="Maple" /></a></div><br /><br />

<p>And here is the result:</p>

<div style="text-align: center"><a href="http://jext.free.fr/maple3.png"><img src="http://jext.free.fr/maple3_small.png" alt="Maple" /></a></div><br /><br />

<p>I'll grand you this feature is not the best one I have ever seen to boost my productivity but it's sure really handy, especially when you don't want to mess up parenthesis and other weird mathematical stuff. You can also optimize the computation and then generate the code:</p>

<div style="text-align: center"><a href="http://jext.free.fr/maple4.png"><img src="http://jext.free.fr/maple4_small.png" alt="Maple" /></a></div><br /><br />

<p>This version makes it easier to break the computation into several methods which can be very useful when you know some parts won't change at runtime. I was happily surprised to find a good Java asset with Maple :)</p>]]>

</content>
</entry>
<entry>
<title>SwingFX: Cancelable Infinite Progress</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/gfx/archive/2005/10/swingfx_cancell.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2005-10-07T00:18:34Z</issued>
<id>tag:weblogs.java.net,2005:/blog/gfx/250.3395</id>
<created>2005-10-07T00:18:34Z</created>
<summary type="text/plain">Michael Bushe just joined the SwingFX project and offers us a cancelable variation of the infinite progress panel.</summary>
<author>
<name>gfx</name>

<email>romain.guy@mac.com</email>
</author>
<dc:subject>Community: JavaDesktop</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/gfx/">
<![CDATA[<p>Many months ago, <a href="http://www.codecraig.com/weblog/">Craig</a> and I started the <a href="https://swingfx.dev.java.net/">SwingFX project</a>. One of the first components to be added was the infinite progress panel <a href="http://www.jroller.com/page/gfx/20050215#wait_with_style_in_swing">I described in a blog entry</a>:

<div style="text-align: center"><a href="http://www.progx.org/users/Gfx/waitwithstyle2.png"><img src="http://www.progx.org/users/Gfx/waitwithstyle2_small.png" alt="SwingFX" /></a></div><br /><br />

<p>This component was quite successful (I've recently seen a variation in <a href="http://www.zvalley.com/zen.htm">ZValley's ZEN</a>) but it remains quite simple. Michael Bushe just added a very valuable feature, the ability to cancel the current running task:

<div style="text-align: center"><a href="http://jext.free.fr/cancellable.png"><img src="http://jext.free.fr/cancellable_small.png" alt="SwingFX" /></a></div><br /><br />

<p>You can get it today in SwingFX <a href="https://swingfx.dev.java.net/source/browse/*checkout*/swingfx/swingfx.jar">binaries</a>, <a href="https://swingfx.dev.java.net/source/browse/*checkout*/swingfx/swingfx_src.jar">source</a> and 
<a href="https://swingfx.dev.java.net/source/browse/*checkout*/swingfx/swingfx_doc.jar">documentation</a>. I also suggest you to take a look at the rubberband API, it can prove to be useful in some applications.</p> ]]>

</content>
</entry>
<entry>
<title>Drag and Drop Effects and Java2D Performances</title>
<link rel="alternate" type="text/html" href="http://weblogs.java.net/blog/gfx/archive/2005/10/drag_and_drop_e.html" />
<modified>2008-01-02T17:42:16Z</modified>
<issued>2005-10-04T05:09:25Z</issued>
<id>tag:weblogs.java.net,2005:/blog/gfx/250.3373</id>
<created>2005-10-04T05:09:25Z</created>
<summary type="text/plain">While writing a new Swing/Java2D demo I ran into very interesting issues with pictures painting.</summary>
<author>
<name>gfx</name>

<email>romain.guy@mac.com</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://weblogs.java.net/blog/gfx/">
<![CDATA[<p>You can run the <a href="http://www.progx.org/users/Gfx/apps/collage.jnlp">WebStart demo</a> or <a href="http://www.progx.org/users/Gfx/photocollagedemo.zip">download its source code</a>.</p>

<p>Once the application is started, you can drag and drop pictures from the list on the left to the image viewer on the right and trigger a cool looking animation.</p>

<div style="text-align: center"><a href="http://jext.free.fr/collage1.png"><img src="http://jext.free.fr/collage1_small.png" alt="Photo Collage" /></a></div>
<br /><br />
<div style="text-align: center"><a href="http://jext.free.fr/collage4.png"><img src="http://jext.free.fr/collage4_small.png" alt="Photo Collage" /></a></div><br />

<p>When writing this application, I found serious performances issues with J2SE 1.5. There were also some problems with Java SE 1.6 but far less important. Chris Campbell and Chet Haase really helped me on this. It turns out that loading an image with <code>ImageIO</code> does not necessarily provide a picture in a compatible format with the default screen configuration. When drawing such pictures you lose performances, especially when scaling them. An easy way to work around this problem is to convert them into compatible images:</p>

<pre>
  public static BufferedImage loadCompatibleImage(URL resource) throws IOException {
    BufferedImage image = ImageIO.read(resource);
    GraphicsConfiguration configuration = GraphicsEnvironment.
      getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
    BufferedImage compatibleImage = configuration.createCompatibleImage(image.getWidth(),
                                                                        image.getHeight());
    Graphics g = compatibleImage.getGraphics();
    g.drawImage(image, 0, 0, null);
    g.dispose();
    return compatibleImage;
  }
</pre>

<p>I <a href="http://www.jroller.com/page/gfx/?anchor=drag_and_drop_effects_part">wrote a longer explanation</a> you might want to check out if you need to perform heavy drawings with pictures in your application.</p>]]>

</content>
</entry>

</feed>