<?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>Dalton Filho &#187; Java</title>
	<atom:link href="http://www.daltonfilho.com/category/programming/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.daltonfilho.com</link>
	<description></description>
	<lastBuildDate>Sun, 13 Sep 2009 03:41:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>wxMatisse update #1</title>
		<link>http://www.daltonfilho.com/2008/06/08/wxmatisse-update-1/</link>
		<comments>http://www.daltonfilho.com/2008/06/08/wxmatisse-update-1/#comments</comments>
		<pubDate>Sun, 08 Jun 2008 20:16:26 +0000</pubDate>
		<dc:creator>Dalton Filho</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[wxMatisse]]></category>

		<guid isPermaLink="false">http://www.daltonfilho.com/2008/06/08/wxmatisse-update-1/</guid>
		<description><![CDATA[wxMatisse is finally set up on <a href="https://wxmatisse.dev.java.net/">java.net</a>. Right now only 4 widgets, one top level window and one layout manager is supported. You are more than invited to collaborate! Growing the project is really easy with its current architecture. The next milestone is supporting the maximum number of widgets using null layout on a JFrame.
<p style="text-align: center"><a href="https://wxmatisse.dev.java.net/files/documents/8976/99540/translation_process.png" title="wxMatisse translation process"><img src="http://www.daltonfilho.com/wp-content/uploads/2008/06/translation_process_small.png" alt="wxMatisse translation process" /></a></p>]]></description>
			<content:encoded><![CDATA[<p>wxMatisse is finally set up on <a href="https://wxmatisse.dev.java.net/">java.net</a>. Right now only 4 widgets, one top level window and one layout manager is supported. You are more than invited to collaborate! Growing the project is really easy with its current architecture. The next milestone is supporting the maximum number of widgets using null layout on a JFrame.</p>
<p style="text-align: center"><a href="https://wxmatisse.dev.java.net/files/documents/8976/99540/translation_process.png" title="wxMatisse translation process"><img src="http://www.daltonfilho.com/wp-content/uploads/2008/06/translation_process_small.png" alt="wxMatisse translation process" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.daltonfilho.com/2008/06/08/wxmatisse-update-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing wxMatisse</title>
		<link>http://www.daltonfilho.com/2008/05/25/introducing-wxmatisse/</link>
		<comments>http://www.daltonfilho.com/2008/05/25/introducing-wxmatisse/#comments</comments>
		<pubDate>Sun, 25 May 2008 23:00:39 +0000</pubDate>
		<dc:creator>Dalton Filho</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Matisse]]></category>
		<category><![CDATA[Swing]]></category>
		<category><![CDATA[wxWidgets]]></category>

		<guid isPermaLink="false">http://www.daltonfilho.com/2008/05/25/introducing-wxmatisse/</guid>
		<description><![CDATA[Towards the end of a <a href="http://www.daltonfilho.com/2008/02/23/wxwidgets-on-windows-using-netbeans-60-with-mingw-msys/" target="_blank">previous post</a> I've exposed my thought of a wxWidgets plugin for NetBeans, more specifically, a plugin for C++ wxWidgets. If you have followed the tutorial through, you've probably realized how difficult it is to set up wxWidgets to be used on Windows using NetBeans. Even after the environment is completely configured, you still lack the power of tools like Matisse to prototype your frames. For now, a simple tool will address this problem: it's called wxMatisse. wxMatisse is a tool that uses windows created by Matisse to create equivalent windows in C++ wxWidgets. ]]></description>
			<content:encoded><![CDATA[<p>Towards the end of a <a href="http://www.daltonfilho.com/2008/02/23/wxwidgets-on-windows-using-netbeans-60-with-mingw-msys/" target="_blank">previous post</a> I&#8217;ve exposed my thought of a wxWidgets plugin for NetBeans, more specifically, a plugin for C++ wxWidgets. If you have followed the tutorial through, you&#8217;ve probably realized how difficult it is to set up wxWidgets to be used on Windows using NetBeans. Even after the environment is completely configured, you still lack the power of tools like Matisse to prototype your frames. For now, a simple tool will address this problem: it&#8217;s called wxMatisse. wxMatisse is a tool that uses windows created by Matisse to create equivalent windows in C++ wxWidgets. The use case is simple: on a window created by Matisse, you select a context menu: &#8220;Create wxWidgets window&#8230;&#8221;. You then decide if you want to use event tables or <code>Connect()</code>, and if you want to use separate header and cpp files, for example. It&#8217;s basically a Swing to wxWidgets translator, but it does not translate Swing code; instead, it reads the windows&#8217; properties and child members to create the wxWidgets equivalent. The samples below demonstrate the pre-alpha capabilities of the translator:</p>
<p><strong>Window created by Matisse (Java)<br />
</strong></p>
<p><img src="http://www.daltonfilho.com/wp-content/uploads/2008/05/matisse.png" alt="Window created by Matisse" /></p>
<p><strong>Window created by wxMatisse (C++)<br />
</strong></p>
<p><img src="http://www.daltonfilho.com/wp-content/uploads/2008/05/wxmatisse.png" alt="wxmatisse.png" /></p>
<p><strong>Code created by Matisse</strong></p>
<pre name="code" class="java">
public class MatisseTest extends javax.swing.JFrame {    

/** Creates new form MatisseTest */
public MatisseTest() {
    initComponents();
}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
    button2 = new javax.swing.JButton();
    button1 = new javax.swing.JButton();
    panel1 = new javax.swing.JPanel();
    button3 = new javax.swing.JButton();
    panel2 = new javax.swing.JPanel();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    getContentPane().setLayout(null);
    button2.setLabel("Right button");
    getContentPane().add(button2);
    button2.setBounds(210, 310, 130, 30);
    button1.setLabel("Left button");
    getContentPane().add(button1);
    button1.setBounds(50, 310, 130, 30);
    panel1.setBackground(new java.awt.Color(204, 102, 255));
    panel1.setLayout(null);
    button3.setLabel("North button");
    panel1.add(button3);
    button3.setBounds(20, 20, 250, 60);
    panel2.setBackground(new java.awt.Color(255, 255, 0));
    panel2.setLayout(null);
    panel1.add(panel2);
    panel2.setBounds(20, 100, 250, 130);
    getContentPane().add(panel1);
    panel1.setBounds(50, 40, 290, 250);

    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width-410)/2, (screenSize.height-403)/2, 410, 403);
}//GEN-END:initComponents

// Variables declaration - do not modify//GEN-BEGIN:variables

    private javax.swing.JButton button1;
    private javax.swing.JButton button2;
    private javax.swing.JButton button3;
    private javax.swing.JPanel panel1;
    private javax.swing.JPanel panel2;

// End of variables declaration//GEN-END:variables

}</pre>
<p><strong>Code created by wxMatisse</strong></p>
<pre name="code" class="cpp">
// File created by wxMatisse

#ifndef _MATISSETEST_H
#define _MATISSETEST_H

#include &lt;wx/frame.h&gt;
#include &lt;wx/button.h&gt;
#include &lt;wx/panel.h&gt;

class MatisseTest : public wxFrame { 

public:

	MatisseTest(const wxString &amp;title);

private:

	wxPanel *wxpanel2;

	wxPanel *wxpanel1;

	wxButton *wxbutton1;

	wxButton *wxbutton2;

	wxButton *wxbutton3;

	void initComponents();

	enum {
		WXBUTTON1 = wxID_HIGHEST + 1,
		WXBUTTON2,
		WXBUTTON3,
		WXPANEL1,
		WXPANEL2
	};

};

#endif 	 /* _MATISSETEST_H */</pre>
<pre name="code" class="cpp">
// File created by wxMatisse

#include "matisse.h"

MatisseTest::MatisseTest(const wxString &amp;title) : wxFrame((wxFrame*) NULL, wxID_ANY, title) {
	initComponents();
}

void MatisseTest::initComponents() {
	wxbutton1 = new wxButton(this, WXBUTTON1, _T("Right button"), wxPoint(210, 310), wxSize(130, 30));
	wxbutton2 = new wxButton(this, WXBUTTON2, _T("Left button"), wxPoint(50, 310), wxSize(130, 30));
	wxpanel1 = new wxPanel(this, WXPANEL1, wxPoint(50, 40), wxSize(290, 250));
	wxpanel1-&gt;SetBackgroundColour(wxColour(204, 102, 255));
	wxbutton3 = new wxButton(wxpanel1, WXBUTTON3, _T("North button"), wxPoint(20, 20), wxSize(250, 60));
	wxpanel2 = new wxPanel(wxpanel1, WXPANEL2, wxPoint(20, 100), wxSize(250, 130));
	wxpanel2-&gt;SetBackgroundColour(wxColour(255, 255, 0));
}</pre>
<p>There are still many things to do until I release version 0.1, of course. For now, only null layout is supported. Support for other layout managers will be added in the future. The goal is to be able to translate all windows created by Matisse as long as they use the supported layout managers. As expected, there will be no support for widgets that wxWidgets offers for an operating system exclusively. Unlike Matisse, you will have total freedom to modify the generated code, as there is no coming back from it. The windows that wxMatisse translates need not be created by Matisse: as this translator uses the properties of the window rather than code, it does not rely on any code convention.  As long as the code compiles and runs, the code can be a complete mess that wxMatisse will still work. wxMatisse will be useful for migration projects where code needs to be translated from Java to C++. I will open the wxMatisse project on <a href="http://java.net/" target="_blank">java.net</a> as soon as the project support all the basic widgets in null layout. If you want to collaborate, or if you know anything about NetBeans programming and want to give a hand, you&#8217;re more than welcome to join the project!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.daltonfilho.com/2008/05/25/introducing-wxmatisse/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java ranked 8th on Google&#8217;s Zeitgeist 2007</title>
		<link>http://www.daltonfilho.com/2008/01/01/java-ranked-8th-on-googles-zeitgeist-2007/</link>
		<comments>http://www.daltonfilho.com/2008/01/01/java-ranked-8th-on-googles-zeitgeist-2007/#comments</comments>
		<pubDate>Tue, 01 Jan 2008 11:39:42 +0000</pubDate>
		<dc:creator>Dalton Filho</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://www.daltonfilho.com/2008/01/01/java-ranked-8th-on-googles-zeitgeist-2007/</guid>
		<description><![CDATA[The <a href="http://www.google.com/intl/en/press/zeitgeist2007/mind.html" target="_blank">results</a> are in: Java has hit the top of mind on Google's Zeitgeist 2007, scoring the 8th position on the "what ..." list. But... "what?" Exactly. If even the average Joe is wondering what is Java, I don't see how that can be a good thing. What these results tell me is not that there is a burst of new developers willing to learn Java, or that the language is so utterly good that even non-technical people are curious.  Google's Zeitgeist will probably never feature wxWidgets or C++, because they're just invisible to the end user. You don't see a wxWidgets logo when a wxWidgets application is loading, nor do you ask a user to update his libc. I would rather hear "I don't know what is Java" than to hear "Oh, I know. It is that <em>thing</em> that was <em>bugging</em> me!" Java needs better integration with browsers and OSes. Java should be invisible to the end-user.]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.google.com/intl/en/press/zeitgeist2007/mind.html" target="_blank">results</a> are in: Java has hit the top of mind on Google&#8217;s Zeitgeist 2007, scoring the 8th position on the &#8220;what &#8230;&#8221; list. But&#8230; &#8220;what?&#8221; Exactly. If even the average Joe is wondering what is Java, I don&#8217;t see how that can be a good thing. What these results tell me is not that there is a burst of new developers willing to learn Java, or that the language is so utterly good that even non-technical people are curious.  Google&#8217;s Zeitgeist will probably never feature wxWidgets or C++, because they&#8217;re just invisible to the end user. You don&#8217;t see a wxWidgets logo when a wxWidgets application is loading, nor do you ask a user to update his libc. I would rather hear &#8220;I don&#8217;t know what is Java&#8221; than to hear &#8220;Oh, I know. It is that <em>thing</em> that was <em>bugging</em> me!&#8221; Java needs better integration with browsers and OSes. Java should be invisible to the end-user.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.daltonfilho.com/2008/01/01/java-ranked-8th-on-googles-zeitgeist-2007/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>JAI saves the day</title>
		<link>http://www.daltonfilho.com/2007/12/23/jai-saves-the-day/</link>
		<comments>http://www.daltonfilho.com/2007/12/23/jai-saves-the-day/#comments</comments>
		<pubDate>Sun, 23 Dec 2007 19:33:28 +0000</pubDate>
		<dc:creator>Dalton Filho</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[image manipulation]]></category>
		<category><![CDATA[JAI]]></category>

		<guid isPermaLink="false">http://www.daltonfilho.com/2007/12/23/jai-saves-the-day/</guid>
		<description><![CDATA[A while ago I was working on a new feature of a CG project that involved loading hundreds of textures from disk. So far, so good. The images, however, were like an order from the devil: I needed RGBA images, but the images were all in BMP format (no chance for alpha channels) and splitted. How great is that?! To solve this problem, I had two alternatives: the first was joining and converting the images manually. If you consider the ammount of images (422) and the average time to join and convert them (aprox. 3 minutes), that would take more than 21 hours (assuming the bore factor wouldn't spoil my productivity in the meanwhile). Fortunately, there was a second alternative: automating the whole process. As I could not find a program that could supply my very specific need, I knew I had to make a little program for that, and there came JAI for the rescue.]]></description>
			<content:encoded><![CDATA[<p>A while ago I was working on a new feature of a CG project that involved loading hundreds of textures from disk. So far, so good. The images, however, were like an order from the devil: I needed RGBA images, but the images were all in BMP format (no chance for alpha channels) and splitted. How great is that?! To solve this problem, I had two alternatives: the first was joining and converting the images manually. If you consider the ammount of images (422) and the average time to join and convert them (aprox. 3 minutes), that would take more than 21 hours (assuming the bore factor wouldn&#8217;t spoil my productivity in the meanwhile). Fortunately, there was a second alternative: automating the whole process. As I could not find a program that could supply my very specific need, I knew I had to make a little program for that, and there came <a href="http://java.sun.com/javase/technologies/desktop/media/jai/" title="Java Advanced Imaging" target="_blank">JAI</a> for the rescue. I took almost an hour googling, reading API docs and trying different commands until I found the ones I needed to create an alpha channel from a color and saving the image to PNG format as below:</p>
<pre name="code" class="java">
    /**
     * Reads an image from disk and exports it to PNG format using <code>
     * alphaColor</code> as the transparent color.
     *
     * @param alphaColor the color to use as the trasparent color
     * @param src the path of the source image
     * @param dst the destination path of the exported image
     */
    void toPNG(Color alphaColor, String src, String dst) {
        RenderedImage image = JAI.create("fileload", src);

        PNGEncodeParam.RGB param = new PNGEncodeParam.RGB();

        param.setTransparentRGB(new int[]{alphaColor.getRed(),
                                          alphaColor.getGreen(),
                                          alphaColor.getBlue()});

        JAI.create("filestore", image, dst, "PNG", param);
    }</pre>
<p>The resize code:</p>
<pre name="code" class="java">
    /**
     * Reads an image from the given <code>src</code> and writes it to the
     * given <code>dst</code> resized to the given <code>width</code> and
     * <code>height</code>.
     *
     * @param src the path of the source image
     * @param dst the destination path of the exported image
     * @param width the width of the new image
     * @param height the height of the new image
     */
    void writeResizedPNGImage(String src, String dst, int width,
                              int height) {

        RenderedImage image = JAI.create("fileload", src);

        BufferedImage buf = new BufferedImage(width, height, BufferedImage
                                             .TYPE_INT_ARGB);

        Graphics2D g = buf.createGraphics();

        AffineTransform transform = new AffineTransform();

        // Resize to fit
        transform.setToScale(width / (double) image.getWidth(),
                             height / (double) image.getHeight());

        g.drawRenderedImage(image, transform);

        JAI.create("filestore", buf, dst, "PNG");
    }</pre>
<p>Useful links: <a href="https://jai.dev.java.net/binary-builds.html" title="Java Advanced Imaging download" target="_blank">JAI download</a>. <a href="http://java.sun.com/products/java-media/jai/docs/index.html" title="Java Advanced Imaging API docs" target="_blank">JAI API docs</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.daltonfilho.com/2007/12/23/jai-saves-the-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
