<?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; custom component</title>
	<atom:link href="http://www.jug-muenster.de/tag/custom-component/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>Thu, 24 Nov 2011 07:04:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
	<atom:link rel="hub" href="http://superfeedr.com/hubbub" />
			<item>
		<title>SteelSeries Java Swing component library</title>
		<link>http://www.jug-muenster.de/steelseries-java-swing-component-library-715/</link>
		<comments>http://www.jug-muenster.de/steelseries-java-swing-component-library-715/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 22:41:01 +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=715</guid>
		<description><![CDATA[Here we go again&#8230; A few months ago i started a new project where i again focussed on gauges (i love that stuff). It took me some time because i only work on the project on my spare time (which is rare) but now i finished a first version of a little library that contains [...]
Weitere Artikel:<ol>
<li><a href='http://www.jug-muenster.de/custom-swing-component-227/' rel='bookmark' title='Custom swing component'>Custom swing component</a></li>
<li><a href='http://www.jug-muenster.de/steelseries-update-768/' rel='bookmark' title='SteelSeries update'>SteelSeries update</a></li>
<li><a href='http://www.jug-muenster.de/java-autoconversion-textfield-component-638/' rel='bookmark' title='Java AutoConversion textfield component'>Java AutoConversion textfield component</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><p>Here we go again&#8230;</p>
<p>A few months ago i started a new project where i again focussed on gauges (i love that stuff). It took me some time because i only work on the project on my spare time (which is rare) but now i finished a first version of a little library that contains a lot of gauges for Java applications&#8230;</p>
<p>First of all i have to mention that this library was not meant to be a professional components library and should not be used on mission critical software. Means if you use the library it&#8217;s on your own risk !</p>
<p>I&#8217;ve never before created a component library and for me it was and is a great challenge to dive deeper into the Java universe&#8230;</p>
<p>But now let&#8217;s have some fun&#8230;</p>
<p>The library contains two general types of gauges, radial and linear ones and some little candy in the form of additional components like a Radar component etc.</p>
<p>I add some properties to the gauges that hopefuly will be useful for some of you.</p>
<p>Here is a short list of the most interesting features:</p>
<ul>
<li>frameDesign (metal, shiny metal, blackmetal)</li>
<li>backgroundColor (dark gray, light gray, white, black, beige, red, green blue)</li>
<li>pointer/bar color (red, green, blue, yellow, orange)</li>
<li>a three colored track to visualize areas of special interest (e.g. a critical temperature range)</li>
<li>thresholdIndicator</li>
<li>blinking threshold led (red, green, blue, orange, yellow)</li>
<li>adjustable tickmarks</li>
<li>indicators for min. and max. measured values</li>
<li>auto reset to zero feature</li>
</ul>
<p>It should be possible for you to create your own components out of these library and  if you&#8217;ll take a look at the <a href="http://kenai.com/projects/steelseries/pages/Home">source</a> you will find components like Radial1Lcd, Radial2Lcd and Radial3Lcd where i used <a href="http://www.netbeans.org">Netbeans</a> matisse gui builder to create the component from the FrameCircular and DisplaySingle components.</p>
<p>So you should be able to check read the sourcecode of these components and see how i did it (the easiest way would be to use <a href="http://www.netbeans.org">Netbeans</a> to check the source).</p>
<p style="font-size: 14px;">But to give you a impression, let pictures speak&#8230;<span id="more-715"></span><strong>Radial gauges&#8230;</strong></p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-1.png" border="0" alt="ishot-1.png" width="240" height="240" /></p>
<p><strong>Radial4 component</strong></p>
<p>backgroundColor: beige</p>
<p>frameDesign: blackMetal</p>
<p>pointerColor: orange</p>
<p>ledColor: orange</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-31.png" border="0" alt="ishot-3.png" width="240" height="240" /></p>
<p><strong>Radial2Lcd component</strong></p>
<p>backgroundColor: white</p>
<p>frameDesign: metal</p>
<p>pointerColor: red</p>
<p>ledColor: red</p>
<p>lcdColor: beige</p>
<p>digitalFont</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-21.png" border="0" alt="ishot-2.png" width="240" height="240" /></p>
<p><strong>Radial4 component</strong></p>
<p>backgroundColor: black</p>
<p>frameDesign: shinyMetal</p>
<p>pointerColor: green</p>
<p>track: 70, 90, 100</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-51.png" border="0" alt="ishot-5.png" width="240" height="240" /></p>
<p><strong>Radial1Square component</strong></p>
<p>backgroundColor: green</p>
<p>frameDesign: metal</p>
<p>pointerColor: red</p>
<p>ledColor: yellow</p>
<p>track: 0, 50, 100</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-41.png" border="0" alt="ishot-4.png" width="240" height="240" /></p>
<p><strong>Radial3Lcd component</strong></p>
<p>backgroundColor: lightGray</p>
<p>frameDesign: blackMetal</p>
<p>pointerColor: blue</p>
<p>ledColor: blue</p>
<p>lcdColor: blueBlue</p>
<p>track: 40, 55, 70</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-101.png" border="0" alt="ishot-10.png" width="240" height="240" /></p>
<p><strong>Radial1Vertical component</strong></p>
<p>backgroundColor: beige</p>
<p>frameDesign: metal</p>
<p>pointerColor: red</p>
<p>ledColor: red</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-111.png" border="0" alt="ishot-11.png" width="240" height="240" /></p>
<p><strong>Radial1Vertical component</strong></p>
<p>backgroundColor: white</p>
<p>frameDesign: blackMetal</p>
<p>pointerColor: yellow</p>
<p>ledColor: orange</p>
<p>track: 0, 75, 100</p>
<p>threshold: 75</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-8.png" border="0" alt="ishot-8.png" width="240" height="240" /></p>
<p><strong>DigitalRadialLcd component</strong></p>
<p>backgroundColor: black</p>
<p>frameDesign: blackMetal</p>
<p>lcdColor: green</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-9.png" border="0" alt="ishot-9.png" width="240" height="240" /></p>
<p><strong>DisplayCircular component</strong></p>
<p>backgroundColor: blue</p>
<p>frameDesign: shinyMetal</p>
<p>digitalFont</p>
<hr />
<p style="font-size: 14px;"><strong>Linear gauges&#8230;</strong></p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-61.png" border="0" alt="ishot-6.png" width="180" height="440" /></p>
<p><strong>Linear component</strong></p>
<p>backgroundColor: darkGray</p>
<p>frameDesign: metal</p>
<p>ledColor: orange</p>
<p>valueColor: orange</p>
<p>track: 70, 85, 100</p>
<p>threshold: 50</p>
<p>vertical orientation</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-71.png" border="0" alt="ishot-7.png" width="180" height="440" /></p>
<p><strong>Linear component</strong></p>
<p>backgroundColor: beige</p>
<p>frameDesign: blackMetal</p>
<p>ledColor: red</p>
<p>valueColor: red</p>
<p>lcdColor: green</p>
<p>digitalFont</p>
<p>minMeasuredValue: 0</p>
<p>maxMeasuredValue: 70</p>
<p>vertical orientation</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-12.png" border="0" alt="ishot-12.png" width="473" height="180" /></p>
<p><strong>Linear component</strong></p>
<p>backgroundColor: white</p>
<p>frameDesign: shinyMetal</p>
<p>valueColor: green</p>
<p>ledColor: green</p>
<p>track 80, 90, 100</p>
<p>threshold: 80</p>
<p>orientation: horizontal</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/ishot-13.png" border="0" alt="ishot-13.png" width="473" height="180" /></p>
<p><strong>Linear component</strong></p>
<p>backgroundColor: lightGray</p>
<p>frameDesign: blackMetal</p>
<p>valueColor: yellow</p>
<p>ledColor: yellow</p>
<p>lcdColor: standard</p>
<p>track: 0, 70, 100</p>
<hr /><strong>The Candy stuff comes here&#8230;</strong></p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/Altimeter.png" border="0" alt="Altimeter.png" width="240" height="240" /><span style="text-decoration: underline;"><strong>Altimeter component</strong></span></p>
<p>A component that behave like a altimeter that you might know from airplanes. It has three pointers</p>
<p>10 ft        :  the big fast pointer</p>
<p>100 ft      : the smaller slower pointer</p>
<p>1000 ft    : the pointer with the triangle at the end, moving very slow</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/Clock.png" border="0" alt="Clock.png" width="240" height="240" /></p>
<p><strong>Clock component</strong></p>
<p>Just a simple analog clock component in the same look as the other gauges.</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/Compass.png" border="0" alt="Compass.png" width="240" height="240" /><strong> </strong></p>
<p><strong>Compass component</strong></p>
<p>A compass component that takes values in the range from -360&#8230;360 degrees.</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/Level.png" border="0" alt="Level.png" width="240" height="240" /><strong> </strong></p>
<p><strong>Level component</strong></p>
<p>A clinometer component that takes values in the range from -360&#8230;360 degrees.</p>
<p><img style="float: left;" src="http://www.jug-muenster.de/wp-content/uploads/2010/08/Radar.png" border="0" alt="Radar.png" width="240" height="240" /><strong> </strong></p>
<p><strong>Radar component</strong></p>
<p>This is a little bit special component that like a lot. You could define a home position in the component which will then represent the center of the component.</p>
<p>Now you could add poi objects that represent locations defined by their latitude and longitude and the component will show these poi&#8217;s on the screen if they are in the range of the radar which could be defined.</p>
<p>This means if you read out data from a gps device and set the home position to the current position of the gps from time to time you could add some poi&#8217;s and they will appear and disappear on the radar screen when you move&#8230;</p>
<p>Download the library <a href="http://idisk.mac.com/han.solo-Public/SteelSeries.jar">here</a>&#8230;</p>
<p>I also create a project on <a href="http://kenai.com/projects/steelseries/pages/Home">Kenai</a> where you could download the sourcecode or might want to participate&#8230;</p>
<p>There is a special blog that i created to present my <a href="http://www.java.com">Java</a> Swing related stuff in more detail, please find it <a href="http://www.harmonic-code.org">here</a>. In that blog i will try to give you a more detailed view at the creation of these components.</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/custom-swing-component-227/' rel='bookmark' title='Custom swing component'>Custom swing component</a></li>
<li><a href='http://www.jug-muenster.de/steelseries-update-768/' rel='bookmark' title='SteelSeries update'>SteelSeries update</a></li>
<li><a href='http://www.jug-muenster.de/java-autoconversion-textfield-component-638/' rel='bookmark' title='Java AutoConversion textfield component'>Java AutoConversion textfield component</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jug-muenster.de/steelseries-java-swing-component-library-715/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/java7-launch-event-1122/' rel='bookmark' title='Java7 Launch Event'>Java7 Launch Event</a></li>
<li><a href='http://www.jug-muenster.de/steelseries-java-swing-component-library-715/' rel='bookmark' title='SteelSeries Java Swing component library'>SteelSeries Java Swing component library</a></li>
<li><a href='http://www.jug-muenster.de/swing-worldclock-427/' rel='bookmark' title='Swing Worldclock'>Swing Worldclock</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/java7-launch-event-1122/' rel='bookmark' title='Java7 Launch Event'>Java7 Launch Event</a></li>
<li><a href='http://www.jug-muenster.de/steelseries-java-swing-component-library-715/' rel='bookmark' title='SteelSeries Java Swing component library'>SteelSeries Java Swing component library</a></li>
<li><a href='http://www.jug-muenster.de/swing-worldclock-427/' rel='bookmark' title='Swing Worldclock'>Swing Worldclock</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='Swing Worldclock'>Swing Worldclock</a></li>
<li><a href='http://www.jug-muenster.de/custom-swing-component-227/' rel='bookmark' title='Custom swing component'>Custom swing component</a></li>
<li><a href='http://www.jug-muenster.de/steelseries-java-swing-component-library-715/' rel='bookmark' title='SteelSeries Java Swing component library'>SteelSeries Java Swing component library</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='Swing Worldclock'>Swing Worldclock</a></li>
<li><a href='http://www.jug-muenster.de/custom-swing-component-227/' rel='bookmark' title='Custom swing component'>Custom swing component</a></li>
<li><a href='http://www.jug-muenster.de/steelseries-java-swing-component-library-715/' rel='bookmark' title='SteelSeries Java Swing component library'>SteelSeries Java Swing component library</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='Swing Weather Worldclock'>Swing Weather Worldclock</a></li>
<li><a href='http://www.jug-muenster.de/steelseries-java-swing-component-library-715/' rel='bookmark' title='SteelSeries Java Swing component library'>SteelSeries Java Swing component library</a></li>
<li><a href='http://www.jug-muenster.de/swing-event-departure-board-518/' rel='bookmark' title='Swing event departure board'>Swing event departure board</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='Swing Weather Worldclock'>Swing Weather Worldclock</a></li>
<li><a href='http://www.jug-muenster.de/steelseries-java-swing-component-library-715/' rel='bookmark' title='SteelSeries Java Swing component library'>SteelSeries Java Swing component library</a></li>
<li><a href='http://www.jug-muenster.de/swing-event-departure-board-518/' rel='bookmark' title='Swing event departure board'>Swing event departure board</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>

<!-- Dynamic page generated in 0.372 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2011-12-17 21:26:07 -->

