<?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>HiddenTao &#187; Java</title>
	<atom:link href="http://www.hiddentao.com/archives/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hiddentao.com</link>
	<description>software, websites, mobile, technology</description>
	<lastBuildDate>Mon, 30 Aug 2010 21:08:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>3D demo</title>
		<link>http://www.hiddentao.com/archives/2010/01/20/3d-demo/</link>
		<comments>http://www.hiddentao.com/archives/2010/01/20/3d-demo/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 12:23:24 +0000</pubDate>
		<dc:creator>ram</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.hiddentao.com/?p=726</guid>
		<description><![CDATA[A while back I decided to write a simple 3D graphics engine in Java after being inspired by Daniel Tebbutt&#8217;s Bedlam solver. Essentially I wanted to show a cube like his but with the added ability to split it apart so that you could see how the pieces fit together. As I got going with [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I decided to write a simple 3D graphics engine in Java after being inspired by <a href="http://danieltebbutt.com/bedlam.html" class="link-external">Daniel Tebbutt&#8217;s Bedlam solver</a>. Essentially I wanted to show a cube like his but with the added ability to split it apart so that you could see how the pieces fit together. As I got going with this I was enjoying it so much I put aside the puzzle algorithm and just started adding more 3D rendering features.</p>

<p>Fast forward many hours of coding and here is a simple demo (click the image to launch it):
<span id="more-726"></span></p>

<p><a href="#" class="imglink" title="Launch demo (requires Java 1.5+)" onclick="window.open('http://www.hiddentao.com/downloads/kai/applet.html','_blank','status=0,toolbar=0,location=0,menubar=0,scrollbars=0,directories=0,resizable=0,width=670,height=500')">
<img src="http://farm3.static.flickr.com/2770/4289736971_b0f35bc880.jpg" />
</a></p>

<p><em>The demo consists of 3 separate scenes. You can switch between by simply clicking in the window. Further mouse and keyboard controls are listed in the demo window itself. Debug output from the demo is viewable in the Java applet console</em></p>

<p><strong>Architecture</strong></p>

<p>I&#8217;ve tried to use good object-oriented programming as much as possible throughout. For example, each scene is represented as a hierarchical scenegraph and a <a href="http://en.wikipedia.org/wiki/Visitor_pattern" rel="nofollow" class="liwikipedia">Visitor</a> model to perform rendering. The renderer itself is obtained from a <a href="http://en.wikipedia.org/wiki/Factory_pattern" rel="nofollow" class="liwikipedia">Factory</a> which allows for different types of renderers (OpenGL, DirectX, Software, etc.). As is standard practice with scenegraphs, a matrix stack is used to allow for model-level transformations independent to world-level transformations.</p>

<p>At the moment the only available renderer is software-based. But the architecture allows for OpenGL or DirectX-based rendering to be added in future. I use the <code>Graphics2D.drawLine()</code> API call in Java to render the pixels. Everything else (e.g. z-buffer) is manually implemented. The engine supports wireframe-mode rendering and backface culling. There is a single source light in the scene whose direction can be modified (in the demo it&#8217;s always pointing forwards from the camera). The rasterizer currently uses flat shading &#8211; next would be to add <a href="http://en.wikipedia.org/wiki/Gouraud_shading" rel="nofollow" class="liwikipedia">Gouraud and Phong</a>, not to mention texturing.</p>

<p>3D rotation on world objects are performed using matrix multiplication. The camera is rotated using Quaternions since this made it simpler to use the <a href="http://www.devmaster.net/articles/viewing-systems/" class="link-external">UVN</a> camera model. The third scene in the demo above is animated; this is accomplished using a simple timer thread using which any number of events can be scheduled for execution at given time intervals.</p>

<p><strong>Performance</strong></p>

<p>When programming in Java it&#8217;s easy to not worry about memory usage and allocations since the garbage collector handles the freeing up of memory. But for graphics engines every allocation or garbage collection run will impact performance. So from the outset I&#8217;ve tried to pre-allocate memory where possible, by constructing temporary vectors and matrices for use during calculations later on. Thus, the vast majority of the matrix and vector multiplication which take place in the render loop don&#8217;t allocate any new memory when doing so.</p>

<p>However, when I finally started rendering things I found that the performance bottleneck was actually the rasterizer. The more polygons (triangles) that needed to be drawn and the larger they appeared on screen, the longer each frame took to render. Perhaps I can improve this by optimising the polygon order (e.g. render from farthest to nearest) and improving the raster algorithms. Eventually I want to switch to using OpenGL as the rendering system but since I&#8217;ve come so far with the software renderer it would be nice to see if I can improve it a bit more first.</p>

<p><strong>Download</strong></p>

<p>The engine code is licensed under the LGPL and is available <a href="http://www.hiddentao.com/code/3d-graphics/" class="liinternal">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hiddentao.com/archives/2010/01/20/3d-demo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple 3D graphics engine</title>
		<link>http://www.hiddentao.com/code/3d-graphics/</link>
		<comments>http://www.hiddentao.com/code/3d-graphics/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 09:22:48 +0000</pubDate>
		<dc:creator>ram</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[3D]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.hiddentao.com/?page_id=717</guid>
		<description><![CDATA[This is a simple 3D graphics engine I&#8217;ve written in Java 1.5 using the Swing windowing toolkit and parts of the Java2D API. It supports the following features: Hierarchical scenegraph including Mesh, Rotation, Translation and Light nodes. Triangle primitives with helpers for building cubes UVN camera with orthographic or perspective projection Timer scheduler for animating [...]]]></description>
			<content:encoded><![CDATA[<p>This is a simple 3D graphics engine I&#8217;ve written in Java 1.5 using the Swing windowing toolkit and parts of the Java2D API. It supports the following features:</p>

<ul>
<li>Hierarchical scenegraph including <code>Mesh</code>, <code>Rotation</code>, <code>Translation</code> and <code>Light</code> nodes.</li>
<li>Triangle primitives with helpers for building cubes</li>
<li>UVN camera with orthographic or perspective projection</li>
<li>Timer scheduler for animating the scene.</li>
<li>Rendering system abstraction

<ul>
<li>Renderers follow <code>Visitor</code> design pattern</li>
</ul></li>
<li>Software-based renderer

<ul>
<li>Wireframe/flat shading</li>
<li>Simple directional light</li>
<li>Backface culling</li>
<li>Pixel-level z-buffer</li>
</ul></li>
<li>Customizable interaction (i.e. user input) handlers</li>
</ul>

<p>More information can be found in the <a href="http://www.hiddentao.com/archives/2010/01/20/3d-demo/" class="liinternal">original blog posting</a>.</p>

<h2 id="demo">Demo</h2>

<p><button onclick="window.open('http://www.hiddentao.com/downloads/kai/applet.html','_blank','status=0,toolbar=0,location=0,menubar=0,scrollbars=0,directories=0,resizable=0,width=670,height=500')">Launch demo (requires Java 1.5+)</button></p>

<h2 id="download">Download</h2>

<p>The source code for this engine is licensed under the <a href="http://www.gnu.org/copyleft/lesser.html" title="GNU Lesser General Public License" class="link-external">LGPL 3</a>.</p>

<p><a href="http://www.hiddentao.com/downloads/kai-engine.zip" class="lizip">Download source code</a>.</p>

<p>Build instructions can be found in <code>README.txt</code> in the download package.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hiddentao.com/code/3d-graphics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Page Tagger 0.3.5 and Common-Utils</title>
		<link>http://www.hiddentao.com/archives/2010/01/16/page-tagger-0-3-5-and-common-utils/</link>
		<comments>http://www.hiddentao.com/archives/2010/01/16/page-tagger-0-3-5-and-common-utils/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 14:46:27 +0000</pubDate>
		<dc:creator>ram</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Common-Utils]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Page Tagger]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.hiddentao.com/?p=702</guid>
		<description><![CDATA[A new version of Page Tagger is now available. Grab it now from here or the WordPress plugin repository. Also, I&#8217;ve put up a few Java classes I wrote a while back as a small library called Common-Utils. Included within are the following: ArrayUtils &#8211; Utility methods to fill an array with a given value [...]]]></description>
			<content:encoded><![CDATA[<p>A new version of <a href="http://www.hiddentao.com/code/wordpress-page-tagger-plugin/" class="liinternal">Page Tagger</a> is now available. Grab it now from <a href="http://www.hiddentao.com/code/wordpress-page-tagger-plugin/" class="liinternal">here</a> or the <a href="http://wordpress.org/extend/plugins/page-tagger/" class="liwp">WordPress plugin repository</a>.</p>

<p>Also, I&#8217;ve put up a few Java classes I wrote a while back as a small library called <a href="http://www.hiddentao.com/code/common-utils/" title="Common-Utils" class="liinternal">Common-Utils</a>. Included within are the following:</p>

<ul>
<li><code>ArrayUtils</code> &#8211; Utility methods to fill an array with a given value or check if it contains a given value.</li>
<li><code>DynamicArray</code> &#8211; A resizable &#8220;static&#8221; array for when you don&#8217;t quite need the full flexibility of <code>ArrayList</code>.</li>
<li><code>NonMutableIterator</code> &#8211; Wraps around a normal <code>Iterator</code> and disables use of the <code>remove</code> method.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.hiddentao.com/archives/2010/01/16/page-tagger-0-3-5-and-common-utils/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Common-Utils</title>
		<link>http://www.hiddentao.com/code/common-utils/</link>
		<comments>http://www.hiddentao.com/code/common-utils/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 21:30:10 +0000</pubDate>
		<dc:creator>ram</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Common-Utils]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.hiddentao.com/?page_id=689</guid>
		<description><![CDATA[Common-Utils is a small of collection of Java utility classes I ended up writing for use in various projects. The code runs on Java 5 or above. ArrayUtils &#8211; Utility methods to fill an array with a given value or check if it contains a given value. NonMutableIterator &#8211; Wraps around a normal Iterator and [...]]]></description>
			<content:encoded><![CDATA[<p>Common-Utils is a small of collection of Java utility classes I ended up writing for use in various projects. The code runs on Java 5 or above.</p>

<ul>
<li><code>ArrayUtils</code> &#8211; Utility methods to fill an array with a given value or check if it contains a given value.</li>
<li><code>NonMutableIterator</code> &#8211; Wraps around a normal <code>Iterator</code> and disables use of the <code>remove</code> method.</li>
<li><code>JAbstractApplet</code> and <code>JAppletSimulator</code> &#8211; Classes for running applets as standalone applications.</li>
</ul>

<p>License: <a href="http://www.gnu.org/copyleft/lesser.html" title="GNU Lesser General Public License" class="link-external">LGPL 3</a>.</p>

<p>Current version: 0.1</p>

<h2 id="download">Download</h2>

<p><a href="http://www.hiddentao.com/downloads/common-utils-0.1.zip" class="lizip">Download source code and documentation</a>.</p>

<h2 id="changelog">Changelog</h2>

<ul>
<li>0.1 (Jan 15, 2010)

<ul>
<li>Initial release.</li>
</ul></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.hiddentao.com/code/common-utils/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;You are now friends with Android&#8221;</title>
		<link>http://www.hiddentao.com/archives/2009/09/19/you-are-now-friends-with-android/</link>
		<comments>http://www.hiddentao.com/archives/2009/09/19/you-are-now-friends-with-android/#comments</comments>
		<pubDate>Sat, 19 Sep 2009 21:35:43 +0000</pubDate>
		<dc:creator>ram</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Symbian]]></category>

		<guid isPermaLink="false">http://www.hiddentao.com/?p=529</guid>
		<description><![CDATA[Having worked at Symbian a few years ago and gotten to learn about mobile operating systems, I believe that Symbian have the best mobile OS kernel in terms of performance, responsiveness and robustness. Unfortunately almost the opposite can be said for the S60 UI layer (which Nokia makes) that sits on top of it. The [...]]]></description>
			<content:encoded><![CDATA[<p>Having worked at <a href="http://www.symbian.com" class="link-external">Symbian</a> a few years ago and gotten to learn about mobile operating systems, I believe that Symbian have the best mobile OS kernel in terms of performance, responsiveness and robustness. Unfortunately almost the opposite can be said for the S60 UI layer (which Nokia makes) that sits on top of it. The end result being that a lot of Symbian phones (a lot of which are Nokias) tend to feel slow and buggy more often than they should. Nevertheless, they do pack a lot of features and thus for the last 3 years I&#8217;ve happily moved around with a Nokia N73, running S60v3 on Symbian 9.1. 
<span id="more-529"></span>
Over the last year Symbian got bought outright by <a href="http://gizmodo.com/5019082/nokia-helps-buys-symbian-turns-it-open-source" class="link-external">Nokia</a> and they&#8217;ve now turned it into the <em>Symbian Foundation</em>, essentially mirroring what <a href="http://www.openhandsetalliance.com/" class="link-external">Google</a>, <a href="http://www.limofoundation.org/" class="link-external">LiMo</a> and others have done. Symbian (and consequentially Nokia) have a huge task ahead of them if they wish to remain competitive in the smartphone market.</p>

<p>After leaving Symbian I went to work a <a href="http://www.bluewhalesystems.com/" class="link-external">mobile software startup</a> whose primary concern was a mobile social networking app written in Java MIDP. Now, if you want to stay as true as you can to the &#8220;write once, run anywhere&#8221; principle for mobiles then Java is really the only choice since almost every phone out there has some sort of Java support, albeit each with its own various inconsistencies and quirks. Writing a mobile Java app was also a whole lot easier than writing one in Symbian C++. The availability of great development tools (Eclipse, JUnit, ProGuard, etc.) didn&#8217;t hurt either! Having worked on a mobile Java client I decided that if I was to build my own mobile app I&#8217;d have to do it in Java.</p>

<p>Then iPhone came along and 2 years later it&#8217;s now obvious that if you have a good idea for a mobile app and don&#8217;t mind learning to develop on the Mac then you might as well as write your app for the iPhone, thus giving yourself a real chance to earn a decent income from it. Many of my fellow engineers have had iPhones for a while and some of them are even starting to write apps for it, some lured by the prospect of <a href="http://www.wired.com/gadgetlab/2008/09/indie-developer/" class="link-external">making a killing</a>, others just wanting to do something cool for what is hailed as the &#8220;Jesus phone&#8221;.</p>

<p>My T-Mobile contract is about to expire and I started seriously thinking about whether to upgrade to an iPhone or an Android handset. After much deliberation, I bought myself a lovely little <a href="http://www.youtube.com/watch?v=QJN8cXyyEQM" class="link-external">T-Mobile G2 Touch</a> instead (also known as HTC Hero). It runs <a href="http://developer.android.com/sdk/android-1.5-highlights.html" class="link-external">Android 1.5</a>, the latest stable release of Google&#8217;s mobile OS. Android development is essentially done in Java (the bytecode format and VM varies) using APIs which are different to the MIDP ones. You can use Eclipse to code, test and debug your apps. It&#8217;s an open source OS, which means you&#8217;ll be able to find deployable versions of the OS on the web which even include features from the upcoming 2.0 release of Android (e.g. multi-touch) folded into the current stable release.</p>

<p>If you read around you&#8217;ll find that the Android Market and consequent ecosystem for paid apps is almost miniscule compared to the AppStore (see <a href="http://larvalabs.com/blog/iphone/android-market-sales/" class="link-external">article and comments</a> and <a href="http://larvalabs.com/blog/iphone/android-market-sales-follow-up/" class="link-external">follow-up</a>), but I&#8217;m hoping that this will improve in the near future. And anyway, if the Android app platform doesn&#8217;t really take off then atleast I&#8217;ll already have some mobile app development experience by the time I get my iPhone <img src='http://www.hiddentao.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>

<p><strong>Update (Sep19): I&#8217;ve shifted the instructions for updating the HTC Hero/T-Mobile G2 Touch firmware into a <a href="http://www.hiddentao.com/archives/2009/09/19/upgrading-your-htc-herot-mobile-g2-touch-to-the-latest-htc-firmware/" class="liinternal">new post</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hiddentao.com/archives/2009/09/19/you-are-now-friends-with-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
