<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>diederickdevries.net &#187; java</title>
	<atom:link href="http://www.diederickdevries.net/blog/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.diederickdevries.net/blog</link>
	<description>Of penguins and coffee (mostly).</description>
	<lastBuildDate>Fri, 03 Feb 2012 17:08:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Java 3d in a NetBeans Platform Application</title>
		<link>http://www.diederickdevries.net/blog/2011/11/12/java-3d-in-a-netbeans-platform-application/</link>
		<comments>http://www.diederickdevries.net/blog/2011/11/12/java-3d-in-a-netbeans-platform-application/#comments</comments>
		<pubDate>Sat, 12 Nov 2011 11:25:31 +0000</pubDate>
		<dc:creator>diederick</dc:creator>
				<category><![CDATA[cool stuff]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[j3d]]></category>
		<category><![CDATA[j3dcore]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[java3d]]></category>
		<category><![CDATA[netbeans]]></category>

		<guid isPermaLink="false">http://www.diederickdevries.net/blog/?p=1192</guid>
		<description><![CDATA[If you want an excellent introduction into Java 3D, look no further than here. I was following the tutorial I found there to get started with what looked to me as the perfect way of spending a Friday evening, when, somewhere at the end, it told me that: (&#8230;) it does not mix very well [...]]]></description>
			<content:encoded><![CDATA[<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.diederickdevries.net%2Fblog%2F2011%2F11%2F12%2Fjava-3d-in-a-netbeans-platform-application%2F&amp;title=Java%203d%20in%20a%20NetBeans%20Platform%20Application" id="wpa2a_2"><img src="http://www.diederickdevries.net/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>If you want an excellent introduction into Java 3D, look no further than <a href="http://www.java3d.org/tutorial.html">here</a>. I was following the tutorial I found there to get started with what looked to me as the perfect way of spending a Friday evening, when, somewhere at the end, it told me that:</p>
<blockquote><p>(&#8230;) <span style="font-family: TIMES; font-size: small;">it does not mix very well with Sun.s swing user interface components. These components are called &#8220;lightweight&#8221; Lightweight components can be hidden by a Canvas3D even if they are supposed to be at the front.</span></p></blockquote>
<p>Obviously, I had been planning on embedding hugely impressive 3D animations into a NetBeans Platform Application, and I was not going to be disappointed, so I fired up NetBeans and did it anyway. Here&#8217;s how.</p>
<p>Preconditions: The j3dcore JAR files are downloaded and unpacked.  You can find them <a href="http://java3d.java.net/binary-builds.html">here</a>. I never trust generic Linux installers, because I have no idea what distro those people had in mind when creating them. So I chose one from the zip binaries and ignored the installers. Select the appropriate one for your machine. Unpack the zip file. There&#8217;s a second zip file inside. Unpack it too. Put the JAR files and the <code>.so</code> file somewhere where you want to keep them.</p>
<p>There appears to exist a NetBeans <a href="http://plugins.netbeans.org/plugin/32144/java-3d">plugin</a> for java-3d, but my NetBeans (7.0.1) didn&#8217;t find it, and at least one user comment indicates massive issues, so I didn&#8217;t bother with it.</p>
<ol>
<li>Create a new Application: File -&gt; New Project. In the Wizard, under Choose Project, select NetBeans Modules -&gt; NetBeans Platform Application and click Next. Enter the name of the application. I called it Test3D. Click Finish.</li>
<li>The j3dcore JAR files have to be wrapped into a Module. Expand the Test3D project node, right click Modules and select Add New. Use j3dcore as your project name and click Next.  Use net.java.j3dcore as the Module&#8217;s code name base.</li>
<li>Right click the j3dcore module node and choose Properties. Under Libraries, click the Wrapped JARs tab and click Add JAR. Navigate to the j3dcore JAR files, select them all (hold shift or ctrl) and click OK.</li>
<li>You now have a library wrapper module, but you lack the shared object file that will allow them to use you graphics adapter. In Test3D, expand the Important Files node. Open the Project Properties file, and add the following line:
<p><code>run.args.extra=-J-Djava.library.path=&lt;the path to the location of your .so file&gt;</code></p>
<p>Do not include the name of the file itself. Be sure to add this to the Project Properties file of your main project, Test3D, and not the wrapper module. It has its own Project Properties file.</li>
<li>Add a new module that creates and displays your 3D scene. Right click Modules under Test3D and click Add New. Enter a name. I chose Universe. Enter your code name base and click Finish.</li>
<li>Add a new TopComponent. Right click the Universe node and click New -&gt; Other. In the New File wizard, select Module Development -&gt; Window. Select Editor as Window Placement and select Open on Application Start. Click Next. Enter UniverseTopComponent after Class Name Prefix and click Finish.</li>
<li>Open UniverseTopComponent. In the Design View, add a JPanel that fully covers the TopComponent. Right click it, select Change Variable Name and enter myUniverse. Right click it again, choose Set Layout -&gt; Border Layout.</li>
<li>Switch to the Source Editor, and change the constructor into this:</li>
</ol>
<blockquote><blockquote>
<pre class="brush: java">
    public UniverseTopComponent() {

        initComponents();
        setName(NbBundle.getMessage(UniverseTopComponent.class,
                &quot;CTL_UniverseTopComponent&quot;));
        setToolTipText(NbBundle.getMessage(UniverseTopComponent.class,
                &quot;HINT_UniverseTopComponent&quot;));

        GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
        Canvas3D canvas = new Canvas3D(config);
        myUniverse.add(canvas, BorderLayout.CENTER);        

        BranchGroup group = new BranchGroup();

        Sphere sphere = new Sphere(0.2f);
        group.addChild(sphere);

        Color3f lightColor = new Color3f(1.8f, 0.1f, 0.1f);
        BoundingSphere bounds =
                new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);

        Vector3f lightDirection = new Vector3f(4.0f, -7.0f, -12.0f);
        DirectionalLight light = new DirectionalLight(lightColor, lightDirection);
        light.setInfluencingBounds(bounds);
        group.addChild(light);

        SimpleUniverse universe = new SimpleUniverse(canvas);
        universe.getViewingPlatform().setNominalViewingTransform();
        universe.addBranchGraph(group);

    }
</pre>
</blockquote>
</blockquote>
<ol start="9">
<li>Right click the editor window and select Fix Imports from the popup menu. Then build and run the project. Your output should look like this:</li>
</ol>
<div id="attachment_1200" class="wp-caption aligncenter" style="width: 548px"><a href="http://www.diederickdevries.net/blog/2011/11/12/java-3d-in-a-netbeans-platform-application/test3d/" rel="attachment wp-att-1200"><img class="size-full wp-image-1200" title="test3d" src="http://www.diederickdevries.net/blog/wp-content/uploads/2011/11/test3d.png" alt="Screenshot Test3d Example Application" width="538" height="495" /></a><p class="wp-caption-text">Test3D with Universe Window</p></div>
<p>Conclusion: it is possible to embed a Java 3D scene into a NetBeans Platform Application.</p>

]]></content:encoded>
			<wfw:commentRss>http://www.diederickdevries.net/blog/2011/11/12/java-3d-in-a-netbeans-platform-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Native look and feel for Swing under Linux</title>
		<link>http://www.diederickdevries.net/blog/2011/04/19/native-look-and-feel-for-swing-under-linux/</link>
		<comments>http://www.diederickdevries.net/blog/2011/04/19/native-look-and-feel-for-swing-under-linux/#comments</comments>
		<pubDate>Tue, 19 Apr 2011 18:41:30 +0000</pubDate>
		<dc:creator>diederick</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[gtk]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[kde]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[qt4]]></category>
		<category><![CDATA[swing]]></category>

		<guid isPermaLink="false">http://www.diederickdevries.net/blog/?p=893</guid>
		<description><![CDATA[This one is not really an eye-opener, but I use this blog to record and archive stuff I find out at some point, so here&#8217;s a post about getting NetBeans Platform Applications use GTK instead of Metal. Since the Swing Application Framework (SAF) has been deprecated and developing NetBeans Platform Applications (NPA) is the new [...]]]></description>
			<content:encoded><![CDATA[<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.diederickdevries.net%2Fblog%2F2011%2F04%2F19%2Fnative-look-and-feel-for-swing-under-linux%2F&amp;title=Native%20look%20and%20feel%20for%20Swing%20under%20Linux" id="wpa2a_4"><img src="http://www.diederickdevries.net/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>This one is not really an eye-opener, but I use this blog to record and archive stuff I find out at some point, so here&#8217;s a post about getting NetBeans Platform Applications use GTK instead of Metal.</p>
<p>Since the Swing Application Framework (SAF) has been <a href="http://netbeans.org/kb/68/java/gui-saf.html">deprecated</a> and developing <a href="http://netbeans.org/features/platform/">NetBeans Platform Applications</a> (NPA) is the new and better way to do these things, I&#8217;ve bought a good <a href="http://www.packtpub.com/netbeans-platform-6-9-developers-guide/book">book</a> on the subject, and am quite satisfied with the way Java desktop applications are to be developed these days.</p>
<p>However, under Linux, Swing applications default to the ugly Metal widget set:</p>
<div id="attachment_894" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-894" href="http://www.diederickdevries.net/blog/2011/04/19/native-look-and-feel-for-swing-under-linux/metal/"><img class="size-medium wp-image-894" title="metal" src="http://www.diederickdevries.net/blog/wp-content/uploads/2011/04/metal-300x225.png" alt="" width="300" height="225" /></a><p class="wp-caption-text">Metal widget set. Click to zoom.</p></div>
<p style="text-align: center;">&nbsp;</p>
<p>On the command line and using SAF it is in fact pretty <a title="QT4 look and feel for Swing" href="http://www.diederickdevries.net/blog/2009/04/29/qt4-look-and-feel-for-swing/">easy</a> to make Swing use the GTK widgets. This way Java applications get a native look and feel under Linux. With NPA however, there is no right place to insert a few lines of code to do this at startup.</p>
<p>To make NetBeans itself use the GTK widgets, I always start the IDE like this:</p>
<pre># netbeans --laf com.sun.java.swing.plaf.gtk.GTKLookAndFeel</pre>
<p>Since NetBeans is itself an NPA,  I figured the trick would be to specify this option somewhere in the application&#8217;s configuration. I googled around a bit and found the answer <a href="http://wiki.netbeans.org/DevFaqPlatformRuntimeProperties">here</a>. The trick is to add a single line to the <code>project.properties</code> file, which can be found inside the Important Files folder within the NPA project. That line is:</p>
<pre>run.args.extra=--laf com.sun.java.swing.plaf.gtk.GTKLookAndFeel</pre>
<p>And now, under KDE4, my application looks like this:</p>
<div id="attachment_895" class="wp-caption aligncenter" style="width: 310px"><a rel="attachment wp-att-895" href="http://www.diederickdevries.net/blog/2011/04/19/native-look-and-feel-for-swing-under-linux/gtk/"><img class="size-medium wp-image-895" title="gtk" src="http://www.diederickdevries.net/blog/wp-content/uploads/2011/04/gtk-300x225.png" alt="" width="300" height="225" /></a><p class="wp-caption-text">GTK widget set. Click to zoom.</p></div>
<p style="text-align: center;">&nbsp;</p>
<p>Not exactly a KDE4 look-and-feel, but I have lots of applications (Gimp, GQView,  LibreOffice) that use GTK so it still looks native on my desktop, and GTK is a lot prettier than Metal.</p>
<p>Now why it is a good idea to write desktop applications instead of web applications, especially in Java, is something that Geertjan Wielenga <a href="http://java.dzone.com/why-desktop-not-webapp">talks</a> about on his blog. Well worth the read.</p>

]]></content:encoded>
			<wfw:commentRss>http://www.diederickdevries.net/blog/2011/04/19/native-look-and-feel-for-swing-under-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Elite</title>
		<link>http://www.diederickdevries.net/blog/2011/04/14/elite/</link>
		<comments>http://www.diederickdevries.net/blog/2011/04/14/elite/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 19:27:35 +0000</pubDate>
		<dc:creator>diederick</dc:creator>
				<category><![CDATA[cool stuff]]></category>
		<category><![CDATA[lifestyle]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[ocjp]]></category>

		<guid isPermaLink="false">http://www.diederickdevries.net/blog/?p=832</guid>
		<description><![CDATA[Today, I found this in my mail: The &#8220;success kit&#8221; included a lifetime membership card for (&#8230;) an elite group of Oracle Certified Professionals (&#8230;) And I had hoped for a coffee pack But still. Excellent.]]></description>
			<content:encoded><![CDATA[<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.diederickdevries.net%2Fblog%2F2011%2F04%2F14%2Felite%2F&amp;title=Elite" id="wpa2a_6"><img src="http://www.diederickdevries.net/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>Today, I found this in my mail:</p>
<p><a rel="attachment wp-att-833" href="http://www.diederickdevries.net/blog/2011/04/14/elite/ocjp/"><img class="aligncenter size-full wp-image-833" title="ocjp" src="http://www.diederickdevries.net/blog/wp-content/uploads/2011/04/ocjp-e1302807438788.png" alt="" width="450" height="316" /></a></p>
<p>The &#8220;success kit&#8221; included a lifetime membership card for</p>
<blockquote><p>(&#8230;) an elite group of Oracle Certified Professionals (&#8230;)</p></blockquote>
<p>And I had hoped for a coffee pack <img src='http://www.diederickdevries.net/blog/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>But still. Excellent.</p>

]]></content:encoded>
			<wfw:commentRss>http://www.diederickdevries.net/blog/2011/04/14/elite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deploying EJB3 In Action code examples in NetBeans</title>
		<link>http://www.diederickdevries.net/blog/2011/03/25/deploying-ejb3-in-action-code-examples-in-netbeans-2/</link>
		<comments>http://www.diederickdevries.net/blog/2011/03/25/deploying-ejb3-in-action-code-examples-in-netbeans-2/#comments</comments>
		<pubDate>Fri, 25 Mar 2011 08:34:08 +0000</pubDate>
		<dc:creator>diederick</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[ejb3]]></category>
		<category><![CDATA[glassfish]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[netbeans]]></category>

		<guid isPermaLink="false">http://www.diederickdevries.net/blog/?p=569</guid>
		<description><![CDATA[I&#8217;m currently learning Enterprise Java Beans 3 using Debu Panda et al.&#8217;s book EJB3 in Action. The material is not very hard but there&#8217;s lots of stuff to memorize, and the best way to do that is by running the code examples and trying to change it (and break it). The easiest way to do [...]]]></description>
			<content:encoded><![CDATA[<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.diederickdevries.net%2Fblog%2F2011%2F03%2F25%2Fdeploying-ejb3-in-action-code-examples-in-netbeans-2%2F&amp;title=Deploying%20EJB3%20In%20Action%20code%20examples%20in%20NetBeans" id="wpa2a_8"><img src="http://www.diederickdevries.net/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>I&#8217;m currently learning <a href="http://www.oracle.com/technetwork/java/docs-135218.html">Enterprise Java Beans 3</a> using Debu Panda et al.&#8217;s book<a href="http://www.manning.com/panda/"> EJB3 in Action</a>. The material is not very hard but there&#8217;s lots of stuff to memorize, and the best way to do that is by running the code examples and trying to change it (and break it). The easiest way to do that is by using an IDE, but the book isn&#8217;t very  helpful in that area, and I didn&#8217;t find it really transparent or straightforward, so here&#8217;s a write up of what I did to make the code examples of the first chapter work in <a href="http://netbeans.org/">NetBeans</a>.</p>
<p>You&#8217;ll need a NetBeans installation with most of the trimmings for this to work. Make sure GlassFish Server 3 and JavaDB are working.</p>
<p>The first chapter is about a simple <a href="http://en.wikipedia.org/wiki/Hello_world_program">Hello World</a> application. To deploy it, we need an EJB3 module and a Web Application Module. The latter will be the client, replacing the client application provided by the book.</p>
<ol>
<li>In NetBeans, create a new project: Java EE -&gt; Enterprise Application (click Next).</li>
<li>Enter <code>HelloUser</code> as project name and click Next.</li>
<li>Click Enable Context and Dependency Injection and click Finish.</li>
<li>Download and unzip the example sources.</li>
<li>Within the newly created directory, locate the directory <code>glassfish/chapter1/src/ejb/bean/ejb3inaction</code>, and copy it to <code>HelloUser/HelloUser-ejb/src/java/</code> within your NetBeans project directory.</li>
<li>From the example sources directory,  locate the directory <code>glassfish/chapter1/src/ejb/client/ejb3inaction</code>, and copy it to <code>HelloUser/HelloUser-war/src/java/</code> within your NetBeans project directory.</li>
</ol>
<p>The client class provided by the book is a very simple illustration of what has been explained so far:</p>
<pre class="brush: java">
package ejb3inaction.buslogic;

import ejb3inaction.example.HelloUser;

import javax.ejb.EJB;

public class HelloUserClient {

    @EJB
    private static HelloUser helloUser;

    public static void main(String[] args) {
        helloUser.sayHello(&quot;Curious George&quot;);
        System.out.println(&quot;Invoked EJB successfully .. see server console for output&quot;);
    }
}
</pre>
<p>This is not something that I could run from inside NetBeans, so I wrote a <a href="http://www.novocode.com/doc/servlet-essentials/">servlet</a> that contains the same code.</p>
<ol>
<li>In the Projects frame, expand HelloUser-war -> Source Packages -> ejb3inaction.example. This package was created when we copied the files to HelloUser-war, back in step 6.</li>
<li>Right click the package node and click New Servlet&#8230;</li>
<li>Use <code>HelloUserServlet</code> as class name and select Add information to deployment descriptor (web.xml). Click Finish.</li>
<li>Replace everything between the import statements and the HttpServlet methods (they&#8217;re folded) with the following:</li>
</ol>
<pre class="brush: java">
import javax.ejb.EJB;

public class HelloUserServlet extends HttpServlet {

    @EJB
    private HelloUser bean;

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType(&quot;text/html;charset=UTF-8&quot;);

        bean.sayHello(&quot;Curious George&quot;);

        PrintWriter out = response.getWriter();
        try {
            out.println(&quot;&lt;html&gt;&quot;);
            out.println(&quot;&lt;head&gt;&quot;);
            out.println(&quot;&lt;title&gt;Servlet HelloUserServlet&lt;/title&gt;&quot;);
            out.println(&quot;&lt;/head&gt;&quot;);
            out.println(&quot;&lt;body&gt;&quot;);
            out.println(&quot;&lt;p&gt;Invoked EJB successfully .. see server console for output&lt;/p&gt;&quot;);
            out.println(&quot;&lt;/body&gt;&quot;);
            out.println(&quot;&lt;/html&gt;&quot;);
        } finally {
            out.close();
        }
    } 
</pre>
<p>As you can see, it is very easy to create a servlet that does what the main method in the client class from the book does, by simply copying a few lines and removing a few unneeded ones from the default servlet created by NetBeans.</p>
<p>When you run the project, your web browser will come up but you won&#8217;t see the output yet. Direct it to <code>http://localhost:8080/HelloUser-war/HelloUserServlet</code>. You should see a single line of text. In NetBeans, go to the output window and select the GlassFish Server 3 tab. There should be a line starting with the word <code>INFO</code>, followed by the text from <code>HelloUserBean.sayHello()</code>.</p>
<p>Now let&#8217;s see if this approach will work equally well for the rest of the examples in the book.</p>

]]></content:encoded>
			<wfw:commentRss>http://www.diederickdevries.net/blog/2011/03/25/deploying-ejb3-in-action-code-examples-in-netbeans-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sogyo</title>
		<link>http://www.diederickdevries.net/blog/2010/11/22/sogyo/</link>
		<comments>http://www.diederickdevries.net/blog/2010/11/22/sogyo/#comments</comments>
		<pubDate>Mon, 22 Nov 2010 15:06:35 +0000</pubDate>
		<dc:creator>diederick</dc:creator>
				<category><![CDATA[cool stuff]]></category>
		<category><![CDATA[lifestyle]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[sogyo]]></category>

		<guid isPermaLink="false">http://www.diederickdevries.net/blog/?p=408</guid>
		<description><![CDATA[Since the start of this month I have been looking for a new job, because my current position at the Research and Documentation Centre of the Dutch Ministry of Justice will end January 31st next year. Barely a day after leaving my resume at nationalevacaturebank.nl, I got a few dozen calls from recuiting agencies and [...]]]></description>
			<content:encoded><![CDATA[<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.diederickdevries.net%2Fblog%2F2010%2F11%2F22%2Fsogyo%2F&amp;title=Sogyo" id="wpa2a_10"><img src="http://www.diederickdevries.net/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>Since the start of this month I have been looking for a new job, because my current position at the <a href="http://english.wodc.nl/">Research and Documentation Centre</a> of the Dutch Ministry of Justice will end January 31st next year. Barely a day after leaving my <a href="http://www.diederickdevries.net/goodies/20101024%20cv-en.pdf">resume</a> at <a href="http://www.nationalevacaturebank.nl/">nationalevacaturebank.nl</a>, I got a few dozen calls from recuiting agencies and other companies, interested in getting to know me. One of those companies was <a href="http://www.sogyo.nl/">Sogyo</a>, a smallish company in <a href="http://maps.google.nl/maps?hl=nl&amp;client=firefox-a&amp;q=De+Bilt&amp;ie=UTF8&amp;hq=&amp;hnear=De+Bilt,+Utrecht&amp;gl=nl&amp;ei=yWLkTOEPhZc6laaRkwE&amp;oi=geocode_result&amp;ved=0CBoQ8gEwAA&amp;z=13">De Bilt</a>, specialised in software architecture,  development and integration.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="321" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=2918019&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" /><embed type="application/x-shockwave-flash" width="400" height="321" src="http://vimeo.com/moogaloop.swf?clip_id=2918019&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=&amp;fullscreen=1&amp;autoplay=0&amp;loop=0" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><em>(Promotional video in Dutch)</em></p>
<p>When I arrived at Sogyo for my first interview, I was a little early, so I was offered a cup of coffee and  asked to wait a few moments. While enjoying the coffee, I looked at the books in a book case, and was pleasantly surprised to find <a href="http://www.diederickdevries.net/blog/?now_reading_author=naomi-klein&amp;now_reading_title=the-shock-doctrine-the-rise-of-disaster-capitalism">Noami Klein&#8217;s The Shock Doctrine</a>. It appears I&#8217;ll be feeling quite at home there.</p>
<p>I&#8217;ll start working there February first.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 217px; width: 1px; height: 1px; overflow: hidden;"><em>promotional video in Dutch.</em></div>

]]></content:encoded>
			<wfw:commentRss>http://www.diederickdevries.net/blog/2010/11/22/sogyo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Netbeans ignores class (+ solution)</title>
		<link>http://www.diederickdevries.net/blog/2010/03/03/netbeans-ignores-class-solution/</link>
		<comments>http://www.diederickdevries.net/blog/2010/03/03/netbeans-ignores-class-solution/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 19:08:22 +0000</pubDate>
		<dc:creator>diederick</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[netbeans]]></category>

		<guid isPermaLink="false">http://www.diederickdevries.net/blog/?p=233</guid>
		<description><![CDATA[The weirdest thing happened while I was programming with my favorite IDE, Netbeans 6.8, today. When I work on big applications, I usually split them in two or three projects (usually model, view, controller). Then I import the projects in the main application project. At some point Netbeans suddenly told me it couldn&#8217;t find a [...]]]></description>
			<content:encoded><![CDATA[<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.diederickdevries.net%2Fblog%2F2010%2F03%2F03%2Fnetbeans-ignores-class-solution%2F&amp;title=Netbeans%20ignores%20class%20%28%2B%20solution%29" id="wpa2a_12"><img src="http://www.diederickdevries.net/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>The weirdest thing happened while I was programming with my favorite IDE, <a href="http://netbeans.org/">Netbeans</a> 6.8, today. When I work on big applications, I usually split them in two or three projects (usually model, view, controller). Then I import the projects in the main application project. At some point Netbeans suddenly told me it couldn&#8217;t find a class in an imported project to which I referred, even though nothing was wrong with it, and everything compiled perfectly using Ant. Netbeans however insisted the class wasn&#8217;t there and produced error messages and enough red warning lines to make it unworkable.</p>
<p>I googled around a bit, but found nothing. So before trying to find the actual problem, I made a copy of the class that Netbeans couldn&#8217;t find, deleted the old one, and renamed the copy to the original. And then the problem was gone.</p>
<p>What gives?</p>

]]></content:encoded>
			<wfw:commentRss>http://www.diederickdevries.net/blog/2010/03/03/netbeans-ignores-class-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>QT4 look and feel for Swing</title>
		<link>http://www.diederickdevries.net/blog/2009/04/29/qt4-look-and-feel-for-swing/</link>
		<comments>http://www.diederickdevries.net/blog/2009/04/29/qt4-look-and-feel-for-swing/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 19:14:36 +0000</pubDate>
		<dc:creator>diederick</dc:creator>
				<category><![CDATA[howto]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[kubuntu]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[qt4]]></category>

		<guid isPermaLink="false">http://www.diederickdevries.net/blog/?p=98</guid>
		<description><![CDATA[UPDATE (2009-05-09): The &#8216;laf&#8217; option to the Netbeans executable should be preceeded by a double dash (&#8211;laf) instead of a single one. Corrected. From the first moment that I used Linux, some 9 years ago, I was a KDE user. When KDE 4 came, I switched to Gnome, because I found KDE 4 unstable and [...]]]></description>
			<content:encoded><![CDATA[<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.diederickdevries.net%2Fblog%2F2009%2F04%2F29%2Fqt4-look-and-feel-for-swing%2F&amp;title=QT4%20look%20and%20feel%20for%20Swing" id="wpa2a_14"><img src="http://www.diederickdevries.net/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p><em>UPDATE (2009-05-09): The &#8216;laf&#8217; option to the Netbeans executable should be preceeded by a double dash (&#8211;laf) instead of a single one. Corrected</em>.</p>
<p>From the first moment that I used <a href="http://www.linuxjournal.com/article/3652">Linux,</a> some 9 years ago, I was a <a href="http://www.kde.org/screenshots/kde2shots.php">KDE</a> user. When <a href="http://www.kde.org/">KDE 4</a> came, I switched to <a href="http://www.gnome.org/">Gnome</a>, because I found KDE 4 unstable and slow. I like eye-candy, but not at the expense of speed.</p>
<p>However, I&#8217;ve been trying out <a href="http://www.kubuntu.org/">Kubuntu</a> 9.04 for a few days now, and I must say I like it. It is faster than Gnome with <a href="http://www.compiz-fusion.org/">Compiz</a>, just as stable and it looks way better than Gnome. That, and the one complaint I have about Gnome, its <a href="http://mail.gnome.org/archives/usability/2005-December/msg00021.html">lack of functionality to protect users for getting confused</a>, is slowly converting me back to KDE again.</p>
<p>But since Java is my language of choice whenever databases are concerned, I write my desktop applications for personal use in Swing. I hate the default Metal look and feel, so I&#8217;m happy to report that I have found out how to give Swing applications a QT4 look.</p>
<p>First, you have to install a gtk qt4 engine. On Kubuntu, you do that like this:</p>
<p><code><br />
# sudo apt-get install gtk-qt-engine-kde4<br />
</code></p>
<p>In your swing application, insert this piece of code into the main method:</p>
<pre class="brush: java">
try {
    UIManager.setLookAndFeel
        (&quot;com.sun.java.swing.plaf.gtk.GTKLookAndFeel&quot;);
} catch (Exception ex) {
    System.out.println (ex);
}
</pre>
<p>If you&#8217;re using the Netbeans Application Framework, insert it in the constructor of xView.java, where x is usually the name of your project.</p>
<p>In addition, if you want Netbeans to look QT4 as well, start it like this:</p>
<p><code><br />
# /opt/netbeans-6.5.1/bin/netbeans --laf com.sun.java.swing.plaf.gtk.GTKLookAndFeel<br />
</code></p>

]]></content:encoded>
			<wfw:commentRss>http://www.diederickdevries.net/blog/2009/04/29/qt4-look-and-feel-for-swing/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Fractal map creation</title>
		<link>http://www.diederickdevries.net/blog/2009/04/10/fractal-map-creation/</link>
		<comments>http://www.diederickdevries.net/blog/2009/04/10/fractal-map-creation/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 19:16:47 +0000</pubDate>
		<dc:creator>diederick</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[fractal map]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.diederickdevries.net/blog/?p=68</guid>
		<description><![CDATA[For a small msx adventure game I&#8217;m creating, I needed a map with three islands. A big one and two smaller ones. I&#8217;m not going to tell you what kind of game it is and if  I will ever finish it (because chances are I won&#8217;t), but that&#8217;s not the point here. The point it, [...]]]></description>
			<content:encoded><![CDATA[<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.diederickdevries.net%2Fblog%2F2009%2F04%2F10%2Ffractal-map-creation%2F&amp;title=Fractal%20map%20creation" id="wpa2a_16"><img src="http://www.diederickdevries.net/blog/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p><p>For a small <a href="http://www.msx.org">msx</a> adventure game I&#8217;m creating, I needed a map with three islands. A big one and two smaller ones. I&#8217;m not going to tell you what kind of game it is and if  I will ever finish it (because chances are I won&#8217;t), but that&#8217;s not the point here. The point it, how did I create the maps.</p>
<p>Using a small <a href="http://www.java.com">Java</a> program called Fractalzoom, which I wrote yesterday evening. Fractalzoom is a small <a href="http://en.wikipedia.org/wiki/Command-line_interface">cli</a> tool that takes a square <a href="http://en.wikipedia.org/wiki/Graphics_Interchange_Format">gif image</a> and randomly replaces its pixels with their neighbours. The function (I always call static java methods functions, because that&#8217;s what they really are) that does the work is really simple:</p>
<pre class="brush: java">
public static void process(Gif gif, Options options) throws Exception {
  if (options.isVerbose())
  System.out.print (&quot;Processing: &quot;);

  for (int n = 0; n &lt; options.getIterations(); n++) {
    if (options.isVerbose())
    System.out.print (&quot;.&quot;);
    for (int i = 1; i &lt; gif.getHeight()-1; i++) {
      for (int j = 1; j &lt; gif.getWidth()-1; j++) {

        int[] choices = new int[4];

        choices[0] = gif.getPaletteIndex(gif.getPixel(i, j-1)); // left
        choices[1] = gif.getPaletteIndex(gif.getPixel(i, j+1)); // right
        choices[2] = gif.getPaletteIndex(gif.getPixel(i-1, j)); // up
        choices[3] = gif.getPaletteIndex(gif.getPixel(i+1, j)); // down

        int choice = (int)Math.round(Math.random()*(choices.length-1));
        gif.setPixel(i, j, gif.getColour(choices[choice]));
      }
    }
  }
}
</pre>
<p>Gif is a wrapper class I created to facilitate using <a href="http://www.geocities.com/yuwen_66/">Wen Yu&#8217;s gifcodec</a>, which lets me edit gif files. You should know that the gif format stores 256 colours in a palette and then uses their indexes throughout the rest of the file for each pixel. (Actually, it uses compression, but that&#8217;s not important here). What the code above does is visit every pixel in the file, find out the indexes of its neighbouring pixels, and then replaces it with one of them.</p>
<p>To use it, I create an image of for example 10 x 10 pixels. I use <a href="http://www.gimp.org/">the Gimp.</a> I fill it entirely with a dark blue colour, and then make a few pixels green, so that I have the rough outlines of my three islands. Then I scale it to 1000 percent, using <strong>no interpolation</strong> (that is important: I want 10&#215;10 squares for each original pixel, and no anti-aliasing).</p>
<p><em>UPDATE: Instead of using Gimp for scaling, you can use <a href="http://www.imagemagick.org/script/index.php">ImageMagick</a> to do it from a shell, which is nice if you have a lot of tiles:</em></p>
<p><code><span style="text-decoration: line-through;"># convert infile.gif -scale 1000% outfile.gif</span></code></p>
<pre># mogrify -scale 1000% *.gif</pre>
<p>The resulting image is this:</p>
<div id="attachment_72" class="wp-caption aligncenter" style="width: 110px"><img class="size-full wp-image-72" title="stage1" src="http://www.diederickdevries.net/blog/wp-content/uploads/2009/04/stage1.gif" alt="stage1.gif: the original 10x10 pixels image, scaled up ten times." width="100" height="100" /><p class="wp-caption-text">The original 10x10 pixels image, scaled up ten times.</p></div>
<p>Then I unleash Fractalzoom:</p>
<p><code># fractalzoom stage1.gif</code></p>
<p>I get an image just as big, but with rigged coastlines:</p>
<div id="attachment_73" class="wp-caption aligncenter" style="width: 110px"><img class="size-full wp-image-73" title="stage1-zoomed" src="http://www.diederickdevries.net/blog/wp-content/uploads/2009/04/stage1-zoomed.gif" alt="stage1-zoomed" width="100" height="100" /><p class="wp-caption-text">stage1-zoomed: the scaled up version of the original image, after one run through fractalzoom.</p></div>
<p style="text-align: left;">After that, I open it again in the Gimp, scaled it up 10 times again (again: no interpolation), and add elevated terrain using brown and white:</p>
<div id="attachment_74" class="wp-caption aligncenter" style="width: 410px"><img class="size-full wp-image-74" title="stage2" src="http://www.diederickdevries.net/blog/wp-content/uploads/2009/04/stage2.gif" alt="stage2" width="400" height="400" /><p class="wp-caption-text">stage2 with elevated terrain, scaled up.</p></div>
<p style="text-align: left;">
<p>Next, I use Fractalzoom again, same as before. The image is larger, so it does more iterations. The result is this:</p>
<div id="attachment_75" class="wp-caption aligncenter" style="width: 410px"><img class="size-full wp-image-75" title="stage2-zoomed" src="http://www.diederickdevries.net/blog/wp-content/uploads/2009/04/stage2-zoomed.gif" alt="stage2-zoomed: the final version of my map, with rigged elevated terrain." width="400" height="400" /><p class="wp-caption-text">stage2-zoomed: the final version of my map, with rigged elevated terrain.</p></div>
<p>The result is a usable and realistic looking map (well, at least for my purposes). My islands have rigged coastal lines, bays, lakes, small islands of their coasts  and mountains with snow caps. If you think you can use it, you can download fractalzoom <a href="http://www.diederickdevries.net/goodies/fractalzoom.tar.bz2">here</a>. It should work on any machine with java 6.</p>
<p><em>UPDATE: After creating the map, I needed to divide it into tiles. The easiest way of doing this is using ImageMagick again:</em></p>
<p><code># convert -crop 100x100 infile.gif outfile-%d.gif</code></p>
<p><em>The above results in tiles of 100 by 100 pixels each with the same name as the original file, appended with a number. The number of each individual tile designates where the tile is when ordered from left to right, top to bottom.</em></p>

]]></content:encoded>
			<wfw:commentRss>http://www.diederickdevries.net/blog/2009/04/10/fractal-map-creation/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

