<?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>Silveira Neto &#187; netbeans</title>
	<atom:link href="http://silveiraneto.net/tag/netbeans/feed/" rel="self" type="application/rss+xml" />
	<link>http://silveiraneto.net</link>
	<description>JavaFX, Game Development, Pixel Art, etc.</description>
	<lastBuildDate>Tue, 16 Jun 2009 09:35:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>pt-br</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>JavaFX 1.1 for Linux workaround</title>
		<link>http://silveiraneto.net/2009/05/16/javafx-11-for-linux-workaround/</link>
		<comments>http://silveiraneto.net/2009/05/16/javafx-11-for-linux-workaround/#comments</comments>
		<pubDate>Sat, 16 May 2009 11:53:15 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[HuaSong Liu]]></category>
		<category><![CDATA[jaunty jackalope]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[javafx4linux]]></category>
		<category><![CDATA[jfx]]></category>
		<category><![CDATA[Kaesar Alnijres]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[Weiqi Gao]]></category>
		<category><![CDATA[workaround]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=2581</guid>
		<description><![CDATA[Download
javafx4linux.tar.bz2 (~ 36Mb).
Installing
1) Extract the javafx4linux.tar.bz2 file. In this example I&#8217;m placing it on my Desktop. After the installing process you can remove it.


2) Open your NetBeans 6.5 and go at Tools → Plugins and go to Downloaded tab. In a plain and new NetBeans installation there will be no plugin in this tab yet.




3) [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Download</strong></p>
<blockquote><p><a title="JavaFX for Linux" href="http://silveiraneto.net/downloads/javafx4linux.tar.bz2">javafx4linux.tar.bz2</a> (~ 36Mb).</p></blockquote>
<p><strong>Installing</strong></p>
<p>1) Extract the javafx4linux.tar.bz2 file. In this example I&#8217;m placing it on my Desktop. After the installing process you can remove it.</p>
<p style="text-align: center;"><strong><a href="http://silveiraneto.net/wp-content/uploads/2009/05/javafx_linux_ubuntu_extract.png"><img class="size-medium wp-image-2593 aligncenter" title="javafx linux ubuntu extract" src="http://silveiraneto.net/wp-content/uploads/2009/05/javafx_linux_ubuntu_extract-500x312.png" alt="javafx linux ubuntu extract" width="500" height="312" /></a><br />
</strong></p>
<p>2) Open your NetBeans 6.5 and go at <em>Tools</em> → <em>Plugins</em> and go to <em>Downloaded</em> tab. In a plain and new NetBeans installation there will be no plugin in this tab yet.</p>
<p style="text-align: center;"><strong><a href="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step01.png"><img class="alignnone size-medium wp-image-2582" title="netbeans javafx linux step01" src="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step01-500x312.png" alt="netbeans javafx linux step01" width="500" height="312" /></a><br />
</strong></p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step02.png"><img class="size-medium wp-image-2583 aligncenter" title="netbeans javafx linux step02" src="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step02-500x312.png" alt="netbeans javafx linux step02" width="500" height="312" /></a></p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step03.png"><img class="size-medium wp-image-2584 aligncenter" title="netbeans javafx linux step03" src="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step03-500x312.png" alt="netbeans javafx linux step03" width="500" height="312" /></a></p>
<p>3) Click on the <em>Add Plugins</em> button and head to the directory you extracted the file and select all .nbm files.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step04.png"><img class="size-medium wp-image-2585 aligncenter" title="netbeans javafx linux step 04" src="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step04-500x312.png" alt="netbeans javafx linux step 04" width="500" height="312" /></a></p>
<p>4) You will see a list of 22 plugins selected. Click on the <em>Install</em> button.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step05.png"><img class="size-medium wp-image-2586 aligncenter" title="netbeans javafx linux step 05" src="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step05-500x312.png" alt="netbeans javafx linux step 05" width="500" height="312" /></a></p>
<p>5) Just keep clicking on the <em>Next</em> button.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step06.png"><img class="size-medium wp-image-2587 aligncenter" title="netbeans javafx linux step 6" src="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step06-500x312.png" alt="netbeans javafx linux step 6" width="500" height="312" /></a></p>
<p>6) Check the license agreement accept box.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step07.png"><img class="size-medium wp-image-2588 aligncenter" title="netbeans javafx linux step 7" src="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step07-500x312.png" alt="netbeans javafx linux step 7" width="500" height="312" /></a></p>
<p>7) You&#8217;ll see a warning because the Linux pluggin is not signed. Don&#8217;t worry, just click <em>Continue</em>.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step08.png"><img class="size-medium wp-image-2589 aligncenter" title="netbeans javafx linux step 8" src="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step08-500x312.png" alt="netbeans javafx linux step 8" width="500" height="312" /></a></p>
<p> <img src='http://silveiraneto.net/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> Click on Finish to restart NetBeans.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step09.png"><img class="size-medium wp-image-2590 aligncenter" title="netbeans javafx linux step 9" src="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step09-500x312.png" alt="netbeans javafx linux step 9" width="500" height="312" /></a></p>
<p>9) Now we can test it. Go at <em>File</em> → <em>New Project</em>, select the JavaFX on <em>Categories</em> and <em>JavaFX Script Application</em> on Projects.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step10.png"><img class="alignnone size-medium wp-image-2591" title="netbeans javafx linux step 10" src="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step10-500x312.png" alt="netbeans javafx linux step 10" width="500" height="312" /></a></p>
<p>10) Put some code and run it. There is. JavaFX on Linux.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step11.png"><img class="size-medium wp-image-2592 aligncenter" title="netbeans javafx linux step 11" src="http://silveiraneto.net/wp-content/uploads/2009/05/netbeans_javafx_linux_step11-500x312.png" alt="netbeans javafx linux step 11" width="500" height="312" /></a></p>
<p><strong>Considerations</strong></p>
<p>This is not a official of JavaFX for Linux! This solution was tested on Ubuntu 9.04 &#8220;Jaunty Jackalope&#8221; with Java 6 update 13 and NetBeans 6.5.1, but should also work with others Linux distributions and Java versions greater than 5.</p>
<p><strong>Known bugs</strong></p>
<p>As a non official workaround for JavaFX for Linux you may notice some drawbacks. Some parts of the JavaFX runtime rely on native implementations on the specific operational system. You may not use some multimedia capabilities as video playback, JavaFX Mobile emulator and some performance issues in some effects. Despite that, is perfectly possible to develop applications using JavaFX on NetBeans.</p>
<p><strong>Thanks</strong></p>
<p>I&#8217;d like to thanks some guys around the world. <a href="http://www.weiqigao.com/blog/2008/12/04/using_javafx_1_0_on_linux.html">Weiqi Gao&#8217;s original post on JavaFX on Linux</a>, <a href="http://java.dzone.com/tips/javafx-11-linux-netbeans">HuaSong Liu article on DZone</a> and <a href="http://java-javafx-iipt.blogspot.com/2009/03/javafx-111-netbeans-651-on-linux.html">Kaesar Alnijres post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2009/05/16/javafx-11-for-linux-workaround/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Arduino and Java</title>
		<link>http://silveiraneto.net/2009/03/01/arduino-and-java/</link>
		<comments>http://silveiraneto.net/2009/03/01/arduino-and-java/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 02:31:34 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Comm]]></category>
		<category><![CDATA[Dave Brink]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[Robotics]]></category>
		<category><![CDATA[RXTX]]></category>
		<category><![CDATA[Serial]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=2344</guid>
		<description><![CDATA[
Arduino is a free popular platform for embedded programming based on a simple I/O board easily programmable. Interfacing it with Java allow us to create sophisticated interfaces and take advantages from the several API available in the Java ecosystem.
I&#8217;m following the original Arduino and Java interfacing tutorial by Dave Brink but in a more practical [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/03/arduino.png"><img class="size-full wp-image-2356 aligncenter" title="Arduino" src="http://silveiraneto.net/wp-content/uploads/2009/03/arduino.png" alt="Arduino" width="559" height="316" /></a></p>
<p><a title="Arduino Project" href="http://arduino.cc">Arduino</a> is a free popular platform for embedded programming based on a simple I/O board easily programmable. Interfacing it with Java allow us to create sophisticated interfaces and take advantages from the several API available in the Java ecosystem.</p>
<p><small>I&#8217;m following the original <a title="Dave Brink" href="http://www.arduino.cc/playground/Interfacing/Java">Arduino and Java interfacing tutorial by Dave Brink</a> but in a more practical approach and with more details.</small></p>
<p><strong>Step 1) Install the Arduino IDE</strong></p>
<p>This is not a completely mandatory step but it will easy a lot our work. Our program will borrow some <a title="Arduino Software" href="http://arduino.cc/en/Main/Software">Arduino IDE</a> libraries and configurations  like which serial port it is using and at which <a title="Boud Rate at Wikipedia" href="http://en.wikipedia.org/wiki/Baud">boud rate</a>. At the moment I wrote this tutorial the version of Arduino IDE was 0013.</p>
<p><strong>Step 2) Prepare your Arduino</strong></p>
<p>Connect your Arduino to the serial port in your computer. Here I&#8217;m connecting my Arduino with my laptop throught a USB.</p>
<pre style="text-align: center;" lang="C"><img src="http://farm4.static.flickr.com/3562/3321316792_993cbff274.jpg" alt="Arduino" /></pre>
<p>Make sure your Arduino IDE is configured and communicating well if your Arduino. Let put on it a little program that sends to us a mensage:</p>

<div class="wp_syntax"><div class="code"><pre class="c c" style="font-family:monospace;"><span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  Serial.<span style="color: #202020;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">9600</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Is there anybody out there?&quot;</span><span style="color: #009900;">&#41;</span>;
  delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1000</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Step 3) Install RXTX Library</strong></p>
<p>We will use some libraries to acess the serial port, some of them relies on binary implementations on our system. Our first step is to install the <a title="RXTX" href="http://www.rxtx.org/">RXTX library</a> (Java CommAPI) in your system. In a Debian like Linux you can do that by:</p>
<blockquote><p>sudo apt-get install librxtx-java</p></blockquote>
<p>Or using a graphical package tool like Synaptic:</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_00.png"><img class="size-medium wp-image-2345 aligncenter" title="installing rxtx" src="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_00-500x296.png" alt="installing rxtx" width="500" height="296" /></a></p>
<p>For others systems like Windows see the <a title="RXTX Install" href="http://rxtx.qbang.org/wiki/index.php/Installation">RXTX installation docs</a>.</p>
<p><strong>Step 4) Start a new NetBeans project</strong></p>
<p>Again<strong>,</strong> this is not a mandatory step but will easy a lot our work. <a href="http://netbeans.org">NetBeans</a> is a free and open source Java IDE that will help us to develop our little application. Create a new project at <em>File → New Project</em> and choose at <em>Java</em> at <em>Categories </em>and <em>Java Application</em> at <em>Projects</em>.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_01.png"><img class="size-medium wp-image-2346 aligncenter" title="netbeans new project" src="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_01-500x323.png" alt="netbeans new project" width="500" height="323" /></a></p>
<p>Chose a name for your project. I called mine <em>SerialTalker</em>.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_02.png"><img class="size-medium wp-image-2347 aligncenter" title="name your project" src="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_02-500x314.png" alt="name your project" width="500" height="314" /></a></p>
<p><small>At the moment I wrote this tutorial I was using Netbeans version 6.5 and Java 6 update 10 but should work as well on newer and some older versions</small></p>
<p><strong>Step 5) Adding Libraries and a Working Directory<br />
</strong></p>
<p>On NetBeans the <em>Projects</em> tab, right-click your project and choose <em>Properties</em>.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_03.png"><img class="size-medium wp-image-2348 aligncenter" title="libraries" src="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_03-500x283.png" alt="libraries" width="500" height="283" /></a></p>
<p>On the <em>Project Properties</em> window select the <em>Libraries</em> on the <em>Categories</em> panel.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_04.png"><img class="size-medium wp-image-2349 aligncenter" title="Netbeans project libraries" src="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_04-499x340.png" alt="Netbeans project libraries" width="499" height="340" /></a></p>
<p>Click the <em>Add JAR/Folder</em> button.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_05.png"><img class="size-medium wp-image-2350 aligncenter" title="arduino directory" src="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_05-500x307.png" alt="arduino directory" width="500" height="307" /></a></p>
<p>Find where you placed your Arduino IDE installation. Inside this directory there&#8217;s a lib directory will some JAR files. Select all them and click <em>Ok</em>.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_06.png"><img class="size-medium wp-image-2351" title="jars libraries" src="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_06-500x307.png" alt="jars libraries" width="500" height="307" /></a></p>
<p>As we want to borrow the Arduino IDE configuration the program needs to know where is they configuration files.  There&#8217;s a simple way to do that.</p>
<p>Still in the  <em>Project Properties</em> window select <em>Run</em> at <em>Categories</em> panel. At <em>Working Directory</em> click in the <em>Browse</em> button and select the directory of your Arduino IDE. Mine is at <em>/home/silveira/arduino-0013</em>.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_08.png"><img class="size-medium wp-image-2353 aligncenter" title="Working directory" src="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_08-499x340.png" alt="Working directory" width="499" height="340" /></a></p>
<p>You can close now the <em>Project Properties</em> window. At this moment in autocomplete for these libraries are enable in your code.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_07.png"><img class="size-medium wp-image-2352 aligncenter" title="netbeans autocomplete" src="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_07-500x283.png" alt="netbeans autocomplete" width="500" height="283" /></a></p>
<p><strong>Step 6) Codding and running</strong></p>
<p>Here is the code you can replace at Main.java in your project:</p>

<div class="wp_syntax"><div class="code"><pre class="c c" style="font-family:monospace;">package serialtalk;
&nbsp;
import gnu.<span style="color: #202020;">io</span>.<span style="color: #202020;">CommPortIdentifier</span>;
import gnu.<span style="color: #202020;">io</span>.<span style="color: #202020;">SerialPort</span>;
import java.<span style="color: #202020;">io</span>.<span style="color: #202020;">InputStream</span>;
import java.<span style="color: #202020;">io</span>.<span style="color: #202020;">OutputStream</span>;
import processing.<span style="color: #202020;">app</span>.<span style="color: #202020;">Preferences</span>;
&nbsp;
public class Main <span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">static</span> InputStream input;
    <span style="color: #993333;">static</span> OutputStream output;
&nbsp;
    public <span style="color: #993333;">static</span> <span style="color: #993333;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> throws Exception<span style="color: #009900;">&#123;</span>
        Preferences.<span style="color: #202020;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        System.<span style="color: #202020;">out</span>.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Using port: &quot;</span> <span style="color: #339933;">+</span> Preferences.<span style="color: #202020;">get</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;serial.port&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
        CommPortIdentifier portId <span style="color: #339933;">=</span> CommPortIdentifier.<span style="color: #202020;">getPortIdentifier</span><span style="color: #009900;">&#40;</span>
                Preferences.<span style="color: #202020;">get</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;serial.port&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
        SerialPort port <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>SerialPort<span style="color: #009900;">&#41;</span>portId.<span style="color: #202020;">open</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;serial talk&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">4000</span><span style="color: #009900;">&#41;</span>;
        input <span style="color: #339933;">=</span> port.<span style="color: #202020;">getInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        output <span style="color: #339933;">=</span> port.<span style="color: #202020;">getOutputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        port.<span style="color: #202020;">setSerialPortParams</span><span style="color: #009900;">&#40;</span>Preferences.<span style="color: #202020;">getInteger</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;serial.debug_rate&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
                SerialPort.<span style="color: #202020;">DATABITS_8</span><span style="color: #339933;">,</span>
                SerialPort.<span style="color: #202020;">STOPBITS_1</span><span style="color: #339933;">,</span>
                SerialPort.<span style="color: #202020;">PARITY_NONE</span><span style="color: #009900;">&#41;</span>;
        <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>input.<span style="color: #202020;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span><span style="color:#800080;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                System.<span style="color: #202020;">out</span>.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>input.<span style="color: #202020;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now just compile and run (with your Arduino attached in your serial port and running the program of step 2).</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_09.png"><img class="size-medium wp-image-2354 aligncenter" title="voillá" src="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_java_netbeans_09-500x283.png" alt="voillá" width="500" height="283" /></a></p>
<p>There is. Now you can make your Java programs to talk with your Arduino using a IDE like NetBeans to create rich interfaces.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2009/03/01/arduino-and-java/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Tirei a SCSNI</title>
		<link>http://silveiraneto.net/2009/01/10/tirei-a-scsni/</link>
		<comments>http://silveiraneto.net/2009/01/10/tirei-a-scsni/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 15:13:21 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[português]]></category>
		<category><![CDATA[certificação]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[Net Feijão]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[NetBeans TV]]></category>
		<category><![CDATA[prova]]></category>
		<category><![CDATA[SCSNI]]></category>
		<category><![CDATA[Wagner Santos]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=2119</guid>
		<description><![CDATA[
Já fazem algumas semanas que chegou o resultado, mas eu não tive tempo de postar. Eu passei na prova da certificação SCSNI (Sun Certified Specialist for NetBeans IDE) durante a fase beta do exame. A notícia foi uma surpresa porque depois da prova eu realmente tinha achado que tinha levado bomba. Mas como a prova [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-2121 aligncenter" title="duke pulando" src="http://silveiraneto.net/wp-content/uploads/2009/01/duke_pulando.gif" alt="duke pulando" width="130" height="80" /></p>
<p>Já fazem algumas semanas que chegou o resultado, mas eu não tive tempo de postar. Eu passei na prova da certificação SCSNI (<a title="site da certificação" href="http://www.sun.com/training/certification/netbeans.html">Sun Certified Specialist for NetBeans IDE</a>) durante a fase beta do exame. A notícia foi uma surpresa porque depois da prova eu realmente tinha achado que tinha levado bomba. Mas como a prova era beta, ainda não estava definido qual ia ser a nota de corte, percentual mínimo que devia ser alcançado para você saber se passou ou não.</p>
<p>A certificação SCSNI cobre tópicos de configuração da IDE, setup de projetos, desenvolvimento Java SE, desenvolvimento Java Web EE, edição, testes, sondagem e depuração. Felizmente certificação não cobre toda as linguagens e plataformas que o NetBeans atualmente suporte e também deixa de fora a parte de plataforma. No entando é necessário saber o que é e o que não é suportado.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/01/duke_scsni.svg"><img class="size-full wp-image-2120 aligncenter" title="duke sun certified specialist for netbeans ide" src="http://silveiraneto.net/wp-content/uploads/2009/01/duke_sun_certified_specialist_for_netbeans_ide.png" alt="duke sun certified specialist for netbeans ide" width="300" height="360" /></a></p>
<p>Para quem pretende tirar essa certificação no futuro algumas dicas e links úteis:</p>
<ul>
<li>O grande Wagner Santos, que escreve o <a title="Net Feijão, sacou?" href="http://netfeijao.blogspot.com/">Net Feijão</a>, fez um <a title="NetBeans SCSNI Guide" href="http://sites.google.com/site/netbeansscsni/">excelente guia para a prova</a>, vale muito a pena dar uma olhada.</li>
<li>Eu também postei um <a title="SCSNI Guide" href="http://silveiraneto.net/2008/10/22/scsni-study-guide/">pequeno guia para prova</a>. Ainda tem vários tópicos incompletos mas pode ser útil.</li>
<li>Tenha sempre a mão <a title="NetBeans DOCS" href="http://www.netbeans.org/kb/index.html">documentação do NetBeans</a> é bastante vasta e cobre mais do que o necessário para a prova.</li>
<li>Assista todos os <a title="NetBeans DOCS" href="http://www.netbeans.org/kb/docs/screencasts.html">screencasts do NetBeans</a>. Muitas ds coisas que você precisa saber são mais fáceis de aprender vendo fazer do que lendo como faz. Depois de ver o screencast, tente reproduzir a aula. Há também o <a title="TV NetBeans" href="http://www.netbeans.tv/">NetBeans TV</a> que reune vários vídeos e tutoriais relacionados ao NetBeans.</li>
<li>Há no wiki do NetBeans uma <a title="Guia de Estudo" href="http://wiki.netbeans.org/CertExamStudyGuide">guia de estudo</a> com uma lista de materiais interessantes para a prova.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2009/01/10/tirei-a-scsni/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JavaFX, Simple Tile Set</title>
		<link>http://silveiraneto.net/2008/12/20/javafx-simple-tile-set/</link>
		<comments>http://silveiraneto.net/2008/12/20/javafx-simple-tile-set/#comments</comments>
		<pubDate>Sat, 20 Dec 2008 19:23:57 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[gamedev]]></category>
		<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[jfx]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[openjfx]]></category>
		<category><![CDATA[pixel art]]></category>
		<category><![CDATA[Tile Set]]></category>
		<category><![CDATA[tileset]]></category>
		<category><![CDATA[video game]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=1951</guid>
		<description><![CDATA[Tile sets are a very simple way to draw scenarios with repeated elements. From simple to complex ones using a very low footprint.
First step, load the png file that stores the tileset into a Image. The file tiles.png shoud be in the same directory of the source code. I adjusted some tiles from those tile [...]]]></description>
			<content:encoded><![CDATA[<p>Tile sets are a very simple way to draw scenarios with repeated elements. From simple to complex ones using a very low footprint.</p>
<p>First step, load the png file that stores the tileset into a <a title="JavaFX API" href="http://java.sun.com/javafx/1/docs/api/javafx.scene.image/javafx.scene.image.Image.html">Image</a>. The file tiles.png shoud be in the same directory of the source code. I adjusted some tiles from those tile set <a title="Tile set" href="http://silveiraneto.net/2008/08/31/my-free-tileset-version-2/">I&#8217;ve blogged here before</a> into a grid of 10&#215;10 tiles.</p>
<p style="text-align: center;"><img class="size-full wp-image-1955 aligncenter" title="Set of tiles, example" src="http://silveiraneto.net/wp-content/uploads/2008/12/tiles.png" alt="Set of tiles, example" width="320" height="320" /></p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;">var tileset <span style="color: #339933;">=</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>
   url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}tiles.png&quot;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Notice that each tile have 32 of height and 32 of width. We will assume this and use theses numbers when performing calculations to find a single tile in our tile set.</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;">def w <span style="color: #339933;">=</span> <span style="color: #cc66cc;">32</span>;
def h <span style="color: #339933;">=</span> <span style="color: #cc66cc;">32</span>;</pre></div></div>

<p>To display a Image in the screen we use a <a title="JavaFX API" href="http://java.sun.com/javafx/1/docs/api/javafx.scene.image/javafx.scene.image.ImageView.html">ImageView</a> node. A ImageView can have a viewport property to create crop or zoom effect. A viewport is just a <a href="http://java.sun.com/javafx/1/docs/api/javafx.geometry/javafx.geometry.Rectangle2D.html">Rectangle2D</a>, a object with position (minX and minY), height and width. If we want to display the first tile in the tileset we do</p>
<p style="text-align: center;"><img class="size-full wp-image-1956 aligncenter" title="first tile" src="http://silveiraneto.net/wp-content/uploads/2008/12/first_tile.png" alt="first tile" width="32" height="32" /></p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;">ImageView <span style="color: #009900;">&#123;</span>
   image<span style="color: #339933;">:</span> tileset
   viewport<span style="color: #339933;">:</span> <span style="color: #003399;">Rectangle2D</span><span style="color: #009900;">&#123;</span>
      minX<span style="color: #339933;">:</span> 0, minY<span style="color: #339933;">:</span> 0, height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span>, width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Notice that the minX determines the column and minY the row in the tileset. The first row is 0*32, the second row is 1*32 and so on. If we want to display the tile at the second line and third column of the tileset we do</p>
<p style="text-align: center;"><img class="size-full wp-image-1957 aligncenter" title="another_tile" src="http://silveiraneto.net/wp-content/uploads/2008/12/another_tile.png" alt="another_tile" width="32" height="32" /></p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;">ImageView <span style="color: #009900;">&#123;</span>
   image<span style="color: #339933;">:</span> tileset
   viewport<span style="color: #339933;">:</span> <span style="color: #003399;">Rectangle2D</span><span style="color: #009900;">&#123;</span>
      minX<span style="color: #339933;">:</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">32</span> , minY<span style="color: #339933;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">32</span>, height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span>, width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Those properties in a Rectangle2D are for init and read only. So I created a list with all Rectangles I can need for use as a viewport.</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;">def viewports <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>row in <span style="color: #009900;">&#91;</span>0..9<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>col in <span style="color: #009900;">&#91;</span>0..9<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #003399;">Rectangle2D</span><span style="color: #009900;">&#123;</span>
           minX<span style="color: #339933;">:</span> col <span style="color: #339933;">*</span> w, minY<span style="color: #339933;">:</span> row <span style="color: #339933;">*</span> h, height<span style="color: #339933;">:</span> w, width<span style="color: #339933;">:</span> h
       <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The scenario map is stored in another list. The first element of the list is 7, that is, the first tile in the scenario is the 7th tile from the tile set.</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;">var map <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
    <span style="color: #cc66cc;">7</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">8</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">26</span>, <span style="color: #cc66cc;">40</span>, <span style="color: #cc66cc;">41</span>, <span style="color: #cc66cc;">24</span>, <span style="color: #cc66cc;">13</span>, <span style="color: #cc66cc;">13</span>, <span style="color: #cc66cc;">23</span>, <span style="color: #cc66cc;">24</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">36</span>, <span style="color: #cc66cc;">50</span>, <span style="color: #cc66cc;">51</span>, <span style="color: #cc66cc;">34</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">34</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">25</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">57</span>, <span style="color: #cc66cc;">58</span>, <span style="color: #cc66cc;">44</span>, <span style="color: #cc66cc;">45</span>, <span style="color: #cc66cc;">46</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">35</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">27</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">6</span>, <span style="color: #cc66cc;">55</span>, <span style="color: #cc66cc;">56</span>,  <span style="color: #cc66cc;">5</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>, <span style="color: #cc66cc;">38</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">60</span>, <span style="color: #cc66cc;">13</span>, <span style="color: #cc66cc;">16</span>, <span style="color: #cc66cc;">47</span>, <span style="color: #cc66cc;">48</span>, <span style="color: #cc66cc;">15</span>, <span style="color: #cc66cc;">13</span>, <span style="color: #cc66cc;">61</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">70</span>,  <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">33</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">71</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">49</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">17</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>, <span style="color: #cc66cc;">18</span>,
<span style="color: #009900;">&#93;</span>;</pre></div></div>

<p>Finally to create a scenario with 100 tiles, 10 per row and with 10 rows, in a list called <em>tiles</em>. Each iteration of this loop creates a <em>ImageView</em>. Each <em>ImageView</em> will store a single tile. We get the tile number in the <em>map</em> list and so use it to index the <em>viewports</em> list.</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;">var tiles <span style="color: #339933;">=</span>  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>row in <span style="color: #009900;">&#91;</span>0..9<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>col in <span style="color: #009900;">&#91;</span>0..9<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      ImageView <span style="color: #009900;">&#123;</span>
         x<span style="color: #339933;">:</span> col <span style="color: #339933;">*</span> w, y<span style="color: #339933;">:</span> row <span style="color: #339933;">*</span> h,
         viewport<span style="color: #339933;">:</span> bind viewports<span style="color: #009900;">&#91;</span>map<span style="color: #009900;">&#91;</span>row <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">+</span> col<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span>
         image<span style="color: #339933;">:</span> tileset
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Additionally I added two things to transform this program also in a (extremely)  simple map editor. At each <em>ImageView</em> I added a callback for <em>onMouseClicked</em> event. When you click on a tile, it changes its <em>map</em> position, ie, the tile. The next tile for the left button and the last tile for any other button.</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;">onMouseClicked<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span> e<span style="color: #339933;">:</span> <span style="color: #003399;">MouseEvent</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #003399;">Void</span> <span style="color: #009900;">&#123;</span>
   var amount <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">button</span> <span style="color: #339933;">==</span> MouseButton.<span style="color: #006633;">PRIMARY</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#125;</span>;
   map<span style="color: #009900;">&#91;</span>row <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">+</span> col<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>map<span style="color: #009900;">&#91;</span>row <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">+</span> col<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> amount<span style="color: #009900;">&#41;</span> mod <span style="color: #cc66cc;">100</span>;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The other thing is to print the <em>map</em> list when the program is over. There is the full program:</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">tileeditor</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.stage.Stage</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.Scene</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.image.ImageView</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.image.Image</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.CustomNode</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.Group</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.Node</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.geometry.Rectangle2D</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.input.MouseEvent</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.input.MouseButton</span>;
&nbsp;
def w <span style="color: #339933;">=</span> <span style="color: #cc66cc;">32</span>;
def h <span style="color: #339933;">=</span> <span style="color: #cc66cc;">32</span>;
&nbsp;
var map <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
    <span style="color: #cc66cc;">7</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">8</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">26</span>, <span style="color: #cc66cc;">40</span>, <span style="color: #cc66cc;">41</span>, <span style="color: #cc66cc;">24</span>, <span style="color: #cc66cc;">13</span>, <span style="color: #cc66cc;">13</span>, <span style="color: #cc66cc;">23</span>, <span style="color: #cc66cc;">24</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">36</span>, <span style="color: #cc66cc;">50</span>, <span style="color: #cc66cc;">51</span>, <span style="color: #cc66cc;">34</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">34</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">25</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">57</span>, <span style="color: #cc66cc;">58</span>, <span style="color: #cc66cc;">44</span>, <span style="color: #cc66cc;">45</span>, <span style="color: #cc66cc;">46</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">35</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">27</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">6</span>, <span style="color: #cc66cc;">55</span>, <span style="color: #cc66cc;">56</span>,  <span style="color: #cc66cc;">5</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>, <span style="color: #cc66cc;">38</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">60</span>, <span style="color: #cc66cc;">13</span>, <span style="color: #cc66cc;">16</span>, <span style="color: #cc66cc;">47</span>, <span style="color: #cc66cc;">48</span>, <span style="color: #cc66cc;">15</span>, <span style="color: #cc66cc;">13</span>, <span style="color: #cc66cc;">61</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">70</span>,  <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">33</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">71</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">49</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">17</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>, <span style="color: #cc66cc;">18</span>,
<span style="color: #009900;">&#93;</span>;
&nbsp;
var tileset <span style="color: #339933;">=</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>
    url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}tiles.png&quot;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
def viewports <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>row in <span style="color: #009900;">&#91;</span>0..9<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>col in <span style="color: #009900;">&#91;</span>0..9<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #003399;">Rectangle2D</span><span style="color: #009900;">&#123;</span>
           minX<span style="color: #339933;">:</span> col <span style="color: #339933;">*</span> w, minY<span style="color: #339933;">:</span> row <span style="color: #339933;">*</span> h, height<span style="color: #339933;">:</span> w, width<span style="color: #339933;">:</span> h
       <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
var tiles <span style="color: #339933;">=</span>  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>row in <span style="color: #009900;">&#91;</span>0..9<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>col in <span style="color: #009900;">&#91;</span>0..9<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      ImageView <span style="color: #009900;">&#123;</span>
         x<span style="color: #339933;">:</span> col <span style="color: #339933;">*</span> w, y<span style="color: #339933;">:</span> row <span style="color: #339933;">*</span> h,
         viewport<span style="color: #339933;">:</span> bind viewports<span style="color: #009900;">&#91;</span>map<span style="color: #009900;">&#91;</span>row <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">+</span> col<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span>
         image<span style="color: #339933;">:</span> tileset
&nbsp;
         onMouseClicked<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span> e<span style="color: #339933;">:</span> <span style="color: #003399;">MouseEvent</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #003399;">Void</span> <span style="color: #009900;">&#123;</span>
            var amount <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">button</span> <span style="color: #339933;">==</span> MouseButton.<span style="color: #006633;">PRIMARY</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#125;</span>;
            map<span style="color: #009900;">&#91;</span>row <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">+</span> col<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>map<span style="color: #009900;">&#91;</span>row <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">+</span> col<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> amount<span style="color: #009900;">&#41;</span> mod <span style="color: #cc66cc;">100</span>;
         <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
Stage <span style="color: #009900;">&#123;</span>
    title<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;JavaFX Simple Tile Editor&quot;</span>
    scene<span style="color: #339933;">:</span> Scene <span style="color: #009900;">&#123;</span>
        content<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span> tiles <span style="color: #009900;">&#93;</span>
    <span style="color: #009900;">&#125;</span>
    onClose<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        println<span style="color: #009900;">&#40;</span>map<span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Here is the result for that<em> map</em></p>
<p style="text-align: center;"><img class="size-full wp-image-1961 aligncenter" title="tlemap javafx" src="http://silveiraneto.net/wp-content/uploads/2008/12/tilemap_javafx.png" alt="tlemap javafx" width="320" height="320" /></p>
<p>And you can try it yourself in your browser.<strong> <a title="Simple Tile Editor Online" href="http://silveiraneto.net/downloads/SimpleTileEditor/dist/JavaFxSandBox.html">Play it online now</a></strong>.</p>
<p>Here is a video of it working</p>
<p style="text-align: center;"><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/lxuBEoItB5E&amp;rel=0&amp;color1=0x006699&amp;color2=0x54abd6"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/lxuBEoItB5E&amp;rel=0&amp;color1=0x006699&amp;color2=0x54abd6" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></object></p>
<p><strong>Downloads:</strong></p>
<ul>
<li>Complete source code and project in NetBeans, <a title="Simple Tile Editor" href="http://silveiraneto.net/downloads/SimpleTileEditor.tar.bz2">SimpleTileEditor.tar.bz2</a>.</li>
<li>Video of it working, <a title="OGG Video" href="http://silveiraneto.net/downloads/javafx_tile_set.ogv">javafx_tile_set.ogv</a>.</li>
<li>Program main class, <a title="Main class" href="http://silveiraneto.net/downloads/SimpleTileEditor/src/tileeditor/Main.fx">Main.fx</a>.</li>
</ul>
<p><strong>Possibilities</strong></p>
<p>We are using just  a image that can handle 100 tiles, <a href="ttp://silveiraneto.net/wp-content/uploads/2008/12/tiles.png">tiles.png</a> with less than 30Kb. The map is also composed with 100 tiles. Each tile we can choose between 100 different tiles, so we can compose 10<sup>100</sup> different maps (one <a title="Wikipedia, english" href="http://en.wikipedia.org/wiki/Googol">googol</a><sup>10</sup> ). Most of them are useless and without any sense, but some are cool. <img src='http://silveiraneto.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/12/20/javafx-simple-tile-set/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NetBeans with JavaFX 1.0 on Linux</title>
		<link>http://silveiraneto.net/2008/12/18/netbeans-with-javafx-10-on-linux/</link>
		<comments>http://silveiraneto.net/2008/12/18/netbeans-with-javafx-10-on-linux/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 03:58:57 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[jfx]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[lolcat]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[openjfx]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=1941</guid>
		<description><![CDATA[Following Weiqi Gao&#8217;s steps it&#8217;s possible to already have a complete JavaFX development environment on Linux.

It&#8217;s all there for JavaFX development. Code complementation, live preview, the pallet with code snipets, templates, etc. Easier a lot my work. Those features already availiable on Windows and Mac OS X trought the regular JavaFX Kit.
]]></description>
			<content:encoded><![CDATA[<p>Following <a title="JavaFX NetBeans Linux" href="http://www.weiqigao.com/blog/2008/12/11/javafx_1_0_on_linux_netbeans_plugin.html">Weiqi Gao&#8217;s steps</a> it&#8217;s possible to already have a complete JavaFX development environment on Linux.</p>
<p><center><a href="http://silveiraneto.net/wp-content/uploads/2008/12/netbeans_linux_javafx.png"><img class="aligncenter size-medium wp-image-1942" title="netbeans_linux_javafx" src="http://silveiraneto.net/wp-content/uploads/2008/12/netbeans_linux_javafx-500x312.png" alt="netbeans_linux_javafx" width="500" height="312" /></a></center></p>
<p>It&#8217;s all there for JavaFX development. Code complementation, live preview, the pallet with code snipets, templates, etc. Easier a lot my work. Those features already availiable on Windows and Mac OS X trought the <a title="JavaFX Download" href="http://javafx.com/downloads/all.jsp">regular JavaFX Kit</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/12/18/netbeans-with-javafx-10-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NetBeans, palestra ao vivo</title>
		<link>http://silveiraneto.net/2008/11/24/netbeans-palestra-ao-vivo/</link>
		<comments>http://silveiraneto.net/2008/11/24/netbeans-palestra-ao-vivo/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 20:58:45 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[português]]></category>
		<category><![CDATA[Elluminate]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[OSUM]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=1790</guid>
		<description><![CDATA[
Estamos experimento uma coisa nova dentro do OSUM. Vamos começar a fazer os webinars, palestras ao vivo pela internet, agora em outras linguas além do Inglês.
Eu vou ministrar o primeiro em português amanhã, aqui está o relese:
Nós estamos introduzindo para os membros do OSUM seminários web ao vivo para prover treinamento em tempo real nas [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-1796 aligncenter" title="Microfone" src="http://silveiraneto.net/wp-content/uploads/2008/11/microphone_tb.png" alt="" width="100" height="100" /></p>
<p>Estamos experimento uma coisa nova dentro do <a title="Sun University Meetup" href="http://osum.sun.com">OSUM</a>. Vamos começar a fazer os webinars, palestras ao vivo pela internet, agora em outras linguas além do Inglês.</p>
<p>Eu vou ministrar o primeiro em português amanhã, aqui está o relese:</p>
<blockquote><p>Nós estamos introduzindo para os membros do OSUM seminários web ao vivo para prover treinamento em tempo real nas últimas tecnologias de Software Livre.</p>
<p>Temos o prazer de começar nossa série de seminários web com esta sessão sobre o recém lançado NetBeans 6.5.</p>
<p>Este seminário web vai introduzir as novas funcionalidades do NetBeans 6.5 como:<br />
→ Suporte robusto a PHP e JavaScript<br />
→ Depuração para Groovy a Grails<br />
→ Novas melhorarias para Java, Ruby e Rails, e desenvolvimento em C/C++<br />
→ Suporte nativo para Hibernate, importação de projetos Eclipse, e a <em>compilação ao salvar</em>.</p>
<p>Este seminário web também proverá uma demonstração detalhada das capacidades de edição da IDE NetBeans e o famoso Construtor de Interfaces Swing (Matisse).</p>
<p>Este seminário será conduzido por <a href="../">Silveira Neto</a>, Embaixador de Campus da Sun em Fortaleza, Ceará, membro do <a href="http://cejug.org/">CEJUG</a> (Ceará Java User Group), desenvolver e entusiasta de tecnologias de Software Livres.</p>
<p>Este seminário web será conduzido em <strong>Português</strong>. Por favor, consulte o <a href="http://osum.sun.com/events">Calendário de Eventos do OSUM</a> para informações da mesma seção em outras línguas.</p>
<p>Este seminário web está marcado para o dia <strong>25 de Novembro de 2008 as 20:00 no horário de Fortaleza, Ceará (UTC -3:00).</strong><br />
Isso corresponde a:<br />
→ 21:00 em São Paulo, Rio e demais estados de mesmo fuso horário do Ceará mas com horário de verão em vigência.<br />
→ 23:00 em UTC (Greenwich).</p>
<p>Por favor use o <a href="http://www.timeanddate.com/worldclock/meeting.html">World Clock Meeting Planner</a> para ajustar esse horário para sua localidade.</p>
<p>Este seminário web será conduzido usando o Elluminate Live! Você poderá escutar ao vivo o áudio nos auto-falantes ou fones de ouvido de seu computador e poderá fazer perguntas através do bate-papo em texto. Use o link URL provido no campo &#8220;Website or map&#8221; da seção. Por favor entre de 5 a 10 minutos antes para a configurar propriamente sua seção. Para maiores informações e requisitos mínimos do sistema use o <a href="http://osum.sun.com/notes/OSUM_Webinars_and_Elluminate_Live%21">Elluminate</a></p></blockquote>
<p><a title="OSUM" href="http://osum.sun.com/events/event/show?id=2181626%3AEvent%3A230761">Página do evento dentro do OSUM</a>.</p>
<p><strong><a title="Elluminate" href="https://sas.elluminate.com/site/external/launch/meeting.jnlp?password=M.F56F3B72E5B3D210444DB3F470601A">Link para assistir ao vivo via Elluminate</a></strong>.</p>
<p><strong>Aviso: </strong>House um erro durante a marcação da seção. Eu marquei que era de Fortaleza no Brasil mas o sistema do Elluminate entendeu que meu horário era o de Brasília, então ao invés de marcado para as 23:00 em UTC ficou marcado para 22:00 em UTC. Não houve tempo suficiente para eu avisar a todos então eu tive que começar no horário errado mesmo. Ainda assim houve uma boa participação, contamos com umas 15 pessoas e tudo ocorreu bem. Muita gente me disse que tentou entrar e não conseguiu então vou tentar fazer um bis dessa apresentação. Os slides que eu usei e a gravação serão divulgados em breve. Obrigado a todos e me desculpem pelo transtorno.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/11/24/netbeans-palestra-ao-vivo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inkscape and JavaFX working together</title>
		<link>http://silveiraneto.net/2008/11/21/inkscape-and-javafx-working-together/</link>
		<comments>http://silveiraneto.net/2008/11/21/inkscape-and-javafx-working-together/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 13:12:13 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[Bob Jamison]]></category>
		<category><![CDATA[getElementById]]></category>
		<category><![CDATA[Inkscape]]></category>
		<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[Jim Clarke]]></category>
		<category><![CDATA[Joshua Marinacci]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[Paths]]></category>
		<category><![CDATA[Rich Internet Applications]]></category>
		<category><![CDATA[SVG]]></category>
		<category><![CDATA[SVGPaths]]></category>
		<category><![CDATA[Tiger]]></category>
		<category><![CDATA[zlib]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=1727</guid>
		<description><![CDATA[Inkscape is a open source cross-platform vector graphics editor application that I use daily to create draws.

When Project Nile was launched, me and some others guys complained about lack of open source alternatives in the workflow of creation with JavaFX. So we developed a module inside Inkscape that converts your SVG drawings to JavaFX code.
Features

Both [...]]]></description>
			<content:encoded><![CDATA[<p>Inkscape is a open source cross-platform vector graphics editor application that I use daily to create draws.</p>
<p style="text-align: center;"><img class="size-full wp-image-1728 aligncenter" title="Inkscape 0.46" src="http://silveiraneto.net/wp-content/uploads/2008/11/800px-inkscape_046.png" alt="" width="500" height="339" /></p>
<p>When <a title="JavaFX Design workflow" href="http://developers.sun.com/mobility/jfx_designer_workflow.html">Project Nile</a> was launched, me and some others guys complained about lack of open source alternatives in the workflow of creation with JavaFX. So we developed a module inside Inkscape that converts your SVG drawings to JavaFX code.</p>
<h3>Features</h3>
<ul>
<li>Both are free and open source technologies, providing more tools on a powerful workflow for programmers and designers to develop Rich Internet Applications.</li>
<li>Comes natively with Inkscape. Install Inkscape an have JavaFX exporting out-of-the-box. No needing to install external plugins.</li>
<li>Provides a way to Inkscape users to make RIA applications reusing their work at drawing tool.</li>
<li>Provides a way to JavaFX programmers a tool for designers their graphics and interfaces.</li>
<li>Keep separated the JavaFX programming logic from the graphics resources but also provide a way to connect them.</li>
<li>They work on Windows, Mac OS, Linux, OpenSolaris and FreeBSD.</li>
</ul>
<h3>Workflow Example</h3>
<p style="text-align: center;"><img class="size-full wp-image-1779 aligncenter" title="Inkscape → JavaFX → NetBeans, workflow" src="http://silveiraneto.net/wp-content/uploads/2008/11/screenshot1.png" alt="" /></p>
<p>I&#8217;ll show here step by step how would be a designer-developer workflow from designing graphical elements, such interfaces, to integrating it to a JavaFX Script code in <a title="NetBeans" href="http://netbeans.org">NetBeans</a>. In this example I&#8217;m using Inkscape 0.46-devel, build from the unstable sources and NetBeans 6.1 with the JavaFX module. <a title="Inkscape Build Tutorial" href="http://silveiraneto.net/2008/08/04/compiling-inkscape/">See here how to build Inkscape from sources</a> and <a title="Parallel Build Benchmark" href="http://silveiraneto.net/2008/11/14/parallel-build-benchmark/">here how to do some optimizations on the build</a>.</p>
<p>Here&#8217;s a artwork (a modified version from another one I did in <a title="a girl I did" href="http://silveiraneto.net/2008/01/17/garota-com-uma-bazuca-e-um-gato-preto/">another post</a>) made with Inkscape.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2008/11/inkscape_draw_with.png"><img class="size-medium wp-image-1758 aligncenter" title="Inkscape 0.46-devel" src="http://silveiraneto.net/wp-content/uploads/2008/11/inkscape_draw_with-494x375.png" alt="" width="494" height="375" /></a></p>
<p>Doesn&#8217;t matter the complexity of the drawing it is made of discrete elements such circles, rectangles, paths and others. What the exporting module does is converting these SVG elements into JavaFX <a title="Scene Graph Project" href="https://scenegraph.dev.java.net/">Scene Graph</a> API elements.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2008/11/inkscape_draw_outline.png"><img class="size-medium wp-image-1759 aligncenter" title="inkscape 0.46-devel" src="http://silveiraneto.net/wp-content/uploads/2008/11/inkscape_draw_outline-494x375.png" alt="" width="494" height="375" /></a></p>
<p>To do that just click on <strong>File → Save As&#8230;</strong> or Shift+Ctrl+S.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2008/11/inkscape_saveas.png"><img class="size-medium wp-image-1763 aligncenter" title="inkscape_saveas" src="http://silveiraneto.net/wp-content/uploads/2008/11/inkscape_saveas-203x375.png" alt="" width="203" height="375" /></a></p>
<p>Select JavaFx as the output format.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2008/11/inkscape_select_javafx.png"><img class="alignnone size-full wp-image-1764" title="inkscape_select_javafx" src="http://silveiraneto.net/wp-content/uploads/2008/11/inkscape_select_javafx.png" alt="" width="424" height="385" /></a></p>
<p>And chose a name. I&#8217;m saving the drawing as <strong>Girl.fx</strong>.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2008/11/inkscape_save.png"><img class="size-full wp-image-1769 aligncenter" title="Inkscape saving as JavaFX" src="http://silveiraneto.net/wp-content/uploads/2008/11/inkscape_save.png" alt="" width="500" height="312" /></a></p>
<p>Now the drawing is a JavaFX class that extends from <a title="JavaFX API" href="http://javafx.com/releases/preview1/docs/api/javafx.scene/javafx.scene.CustomNode.html">CustomNode</a>. Once in your classpath (in this case the same directory of your main code) you can call it.</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;">Girl<span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2008/11/netbeans_javafx_girl_preview.png"><img class="size-medium wp-image-1771 aligncenter" title="netbeans javafx girl preview" src="http://silveiraneto.net/wp-content/uploads/2008/11/netbeans_javafx_girl_preview-500x283.png" alt="" width="500" height="283" /></a></p>
<p>Another example, the famous SVG tiger.</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;">Tiger<span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2008/11/javafx_inkscape_netbeans_tiger_svg.png"><img class="size-medium wp-image-1777 aligncenter" title="javafx inkscape netbeans tiger svg" src="http://silveiraneto.net/wp-content/uploads/2008/11/javafx_inkscape_netbeans_tiger_svg-500x283.png" alt="" width="500" height="283" /></a></p>
<p>Actually, you can get the elements of your drawing as attributes nodes of the main node. We use the name you gave to your object to name the attributes.</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.paint.Color</span>;
var girl <span style="color: #339933;">=</span> Girl<span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
girl.<span style="color: #006633;">rightiris</span>.<span style="color: #006633;">fill</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">LIME</span>;
girl.<span style="color: #006633;">fringe</span>.<span style="color: #006633;">fill</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">WHITE</span>;
girl.<span style="color: #006633;">backhair</span>.<span style="color: #006633;">fill</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">DARKGRAY</span>;
girl.<span style="color: #006633;">hair</span>.<span style="color: #006633;">fill</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">GRAY</span>;</pre></div></div>

<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2008/11/javafx_inkscape_girl_modified.png"><img class="size-medium wp-image-1772 aligncenter" title="javafx inkscape girl modified" src="http://silveiraneto.net/wp-content/uploads/2008/11/javafx_inkscape_girl_modified-500x283.png" alt="" width="500" height="283" /></a></p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.paint.Color</span>;
var girl <span style="color: #339933;">=</span> Girl<span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
girl.<span style="color: #006633;">rightiris</span>.<span style="color: #006633;">fill</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">GREEN</span>;
girl.<span style="color: #006633;">backhair</span>.<span style="color: #006633;">fill</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">DARKRED</span>;
girl.<span style="color: #006633;">hair</span>.<span style="color: #006633;">fill</span> <span style="color: #339933;">=</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span>;</pre></div></div>

<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2008/11/inkscape_girl_javafx_netbeans.png"><img class="size-medium wp-image-1784 aligncenter" title="inkscape red hair girl javafx netbeans" src="http://silveiraneto.net/wp-content/uploads/2008/11/inkscape_girl_javafx_netbeans-500x283.png" alt="" width="500" height="283" /></a></p>
<p>You can also put event handling by code.</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.input.MouseEvent</span>;
var p <span style="color: #339933;">=</span> Player<span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
p.<span style="color: #006633;">x</span>.<span style="color: #006633;">onMouseClicked</span> <span style="color: #339933;">=</span> function<span style="color: #009900;">&#40;</span> e<span style="color: #339933;">:</span> <span style="color: #003399;">MouseEvent</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #003399;">Void</span> <span style="color: #009900;">&#123;</span>
java.<span style="color: #006633;">lang</span>.<span style="color: #003399;">System</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span>0<span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2008/11/javafx_inkscape_player.png"><img class="size-medium wp-image-1778 aligncenter" title="javafx inkscape player" src="http://silveiraneto.net/wp-content/uploads/2008/11/javafx_inkscape_player-500x283.png" alt="" width="500" height="283" /></a></p>
<p>As a ordinary JavaFX Node, you can do whatever you do with a Node, like using it inside a application or applying effects or transformations.</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.application.Frame</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.application.Stage</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.effect.SepiaTone</span>;
&nbsp;
var girl <span style="color: #339933;">=</span> Girl<span style="color: #009900;">&#123;</span>
   scaleX<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0.5</span>
   scaleY<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0.5</span>
   effect<span style="color: #339933;">:</span> SepiaTone<span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003399;">Frame</span> <span style="color: #009900;">&#123;</span>
   visible<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">true</span>
   stage<span style="color: #339933;">:</span> Stage <span style="color: #009900;">&#123;</span>
      content<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>girl<span style="color: #009900;">&#93;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2008/11/inkscape_javafx_sepiatone.png"><img class="size-medium wp-image-1773 aligncenter" title="inkscape javafx sepiatone" src="http://silveiraneto.net/wp-content/uploads/2008/11/inkscape_javafx_sepiatone-500x283.png" alt="" width="500" height="283" /></a></p>
<p>Using this approach you can have the reference and total control under all those elements that compose your drawing. You can design complete interfaces and attach event handling by code.</p>
<h3>Source code</h3>
<p>The module is already on the main Inkscape dev tree and working properly. I guess it will be officially released to all users in the next Inkscape release.</p>
<ul>
<li><a title="Source Code" href="http://inkscape.svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/extension/internal/javafx-out.cpp">javafx-out.cpp</a></li>
<li><a title="Source Code" href="http://inkscape.svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/src/extension/internal/javafx-out.h">javafx-out.h</a></li>
</ul>
<h3>Still to do</h3>
<ul>
<li>Fix some problems with strokes.</li>
<li>Fix some problems in the gradients.</li>
<li>Use <a title="Zlib project" href="http://www.zlib.net/">Zlib</a> to create jfd files when the structure is too big.</li>
<li>Provide a dynamic method like getElementById in JavaScript.</li>
<li>Convert effects like blur to JavaFX effects.</li>
<li>There are some i18n errors in the module to be fixed.</li>
<li>Finish the adaption from Paths to SVGPaths.</li>
<li>Finish the adaption to the new JavaFX 1.0 syntax (coming December, 2).</li>
</ul>
<h3>Thanks!</h3>
<p>Thanks for all guys that worked on this module and also on the projects Inkscape and JavaFX. Specially thanks for Bob Jamison, <span class="HcCDpe">Jim Clarke,</span><span class="HcCDpe"> Joshua Marinacci and others. That&#8217;s my first contribution to a big free software, I&#8217;m very glad and I want to do much more. <img src='http://silveiraneto.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </span></p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/11/21/inkscape-and-javafx-working-together/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>JavaFX, Defuse the Bomb</title>
		<link>http://silveiraneto.net/2008/11/06/javafx-defuse-the-bomb/</link>
		<comments>http://silveiraneto.net/2008/11/06/javafx-defuse-the-bomb/#comments</comments>
		<pubDate>Thu, 06 Nov 2008 14:55:32 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[Bomb]]></category>
		<category><![CDATA[Collision]]></category>
		<category><![CDATA[defuse]]></category>
		<category><![CDATA[explosion]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Web Start]]></category>
		<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[JNLP]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[openjfx]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[sources]]></category>
		<category><![CDATA[webgame]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=1667</guid>
		<description><![CDATA[I continue to develop simple games demos to feel better the strengths and weakness of JavaFX for game development.
Preview:

Click to play via Java Web Start:

There&#8217;s a little JavaFX game demo where you have to transport a bomb to a defuse point without touching in the walls. I&#8217;m using the collision detection methods I described early [...]]]></description>
			<content:encoded><![CDATA[<p>I continue to develop simple games demos to feel better the strengths and weakness of JavaFX for game development.</p>
<p><strong>Preview:</strong></p>
<p><center><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/hR2LiKiBUgE&amp;rel=0&amp;color1=0x006699&amp;color2=0x54abd6"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/hR2LiKiBUgE&amp;rel=0&amp;color1=0x006699&amp;color2=0x54abd6" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></object></center></p>
<p><strong>Click to play via Java Web Start:</strong></p>
<p style="text-align: center;"><a title="Click to launch" href="http://silveiraneto.net/downloads/Defuse/dist/launch.jnlp"><img class="size-full wp-image-1474 aligncenter" title="webstart" src="../wp-content/uploads/2008/10/webstart.png" alt="" width="88" height="23" /></a></p>
<p>There&#8217;s a little JavaFX game demo where you have to transport a bomb to a defuse point without touching in the walls. I&#8217;m using the collision detection methods <a href="http://silveiraneto.net/2008/10/30/javafx-rectangular-collision-detection/">I described early in this post</a> to detect when the bomb hits a wall and then explode or when a bomb is inside the defuse point and the game ends. As it&#8217;s only a demo, it&#8217;s just one single level, but adding more levels would be easy.</p>
<p>Basically we have this four images:</p>
<p><a href="http://silveiraneto.net/wp-content/uploads/2008/11/bomb.png"><img class="alignnone size-full wp-image-1684" title="bomb" src="http://silveiraneto.net/wp-content/uploads/2008/11/bomb.png" alt="" width="80" height="41" /><br />
bomb.png</a></p>
<p><a href="http://silveiraneto.net/wp-content/uploads/2008/11/goal.png"><img class="alignnone size-full wp-image-1686" title="goal" src="http://silveiraneto.net/wp-content/uploads/2008/11/goal.png" alt="" width="120" height="72" /><br />
goal.png</a></p>
<p><a href="http://silveiraneto.net/wp-content/uploads/2008/11/floor.png"><img class="alignnone size-thumbnail wp-image-1685" title="floor" src="http://silveiraneto.net/wp-content/uploads/2008/11/floor-150x150.png" alt="" width="150" height="150" /><br />
floor.png</a></p>
<p><a href="http://silveiraneto.net/wp-content/uploads/2008/11/wall.png"><img class="alignnone size-thumbnail wp-image-1687" title="wall" src="http://silveiraneto.net/wp-content/uploads/2008/11/wall-150x150.png" alt="" width="150" height="150" /><br />
wall.png</a></p>
<p>The code is petty simple. A little bit more than 300 lines with even with all comments and declarations. I transform the bomb image into a draggable node, create a list of collidable nodes and a especial node, the goal. I check the collisions when the bomb is dragged by mouse, if it hits something, it blows up.</p>
<p>I use extensively the TimeLine class from the animation framework (javafx.animation) to create chained animations and even to control some game logic.</p>
<p>As I focused in the simplicity, I don&#8217;t declared any classes to after instantiate their objects. I just was using common classes from JavaFX and putting logic on ir throught event and binding to external variables.</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.application.Frame</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.application.Stage</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.animation.Timeline</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.animation.KeyFrame</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.animation.Interpolator</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.image.ImageView</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.image.Image</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.Group</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.Node</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.paint.Color</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.geometry.Circle</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.geometry.Rectangle</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.geometry.Shape</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.text.Text</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.Font</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.FontStyle</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.input.MouseEvent</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">/* Fade variable modified in some animations and used in the fadescreen */</span>
var fade <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">/* The Bomb */</span>
var lock <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>;
var tx <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span>;
var ty <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span>;
var bomb<span style="color: #339933;">:</span>Node <span style="color: #339933;">=</span> <span style="color: #003399;">Group</span><span style="color: #009900;">&#123;</span>
    opacity<span style="color: #339933;">:</span> bind bombfade;
    content<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
        ImageView <span style="color: #009900;">&#123;</span>
            image<span style="color: #339933;">:</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>
                url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}/bomb.png&quot;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>,
        Circle <span style="color: #009900;">&#123;</span>
            centerX<span style="color: #339933;">:</span> <span style="color: #cc66cc;">45</span>, centerY<span style="color: #339933;">:</span> <span style="color: #cc66cc;">21</span>, radius<span style="color: #339933;">:</span> <span style="color: #cc66cc;">7</span>, fill<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">LIME</span>
            opacity<span style="color: #339933;">:</span> bind led
        <span style="color: #009900;">&#125;</span>,
        Circle <span style="color: #009900;">&#123;</span>
            centerX<span style="color: #339933;">:</span> <span style="color: #cc66cc;">30</span>, centerY<span style="color: #339933;">:</span> <span style="color: #cc66cc;">30</span>, fill<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">WHITE</span>
            radius<span style="color: #339933;">:</span> bind fireradius
        <span style="color: #009900;">&#125;</span>,
    <span style="color: #009900;">&#93;</span>,
    var startX <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span>;
    var startY <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span>;
    translateX<span style="color: #339933;">:</span> bind tx
    translateY<span style="color: #339933;">:</span> bind ty
&nbsp;
    onMousePressed<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span> e<span style="color: #339933;">:</span> <span style="color: #003399;">MouseEvent</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #003399;">Void</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>lock<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000000; font-weight: bold;">return</span>;<span style="color: #009900;">&#125;</span>
        startX <span style="color: #339933;">=</span> e.<span style="color: #006633;">getDragX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> tx;
        startY <span style="color: #339933;">=</span> e.<span style="color: #006633;">getDragY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> ty;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    onMouseDragged<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span>e<span style="color: #339933;">:</span><span style="color: #003399;">MouseEvent</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #003399;">Void</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>lock<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000000; font-weight: bold;">return</span>;<span style="color: #009900;">&#125;</span>
        tx <span style="color: #339933;">=</span> e.<span style="color: #006633;">getDragX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> startX;
        ty <span style="color: #339933;">=</span> e.<span style="color: #006633;">getDragY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> startY;
        checkcollissions<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* Big rectangle that covers all the screen (bomb explosion or game end) */</span>
var fadescreen <span style="color: #339933;">=</span> <span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span>
    x<span style="color: #339933;">:</span> 0, y<span style="color: #339933;">:</span> 0, width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">640</span>, height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">480</span>, fill<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">WHITE</span>
    opacity<span style="color: #339933;">:</span> bind fade
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* The wood floor image for the scenario. */</span>
var floor <span style="color: #339933;">=</span> ImageView <span style="color: #009900;">&#123;</span>
    image<span style="color: #339933;">:</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>
        url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}/floor.png&quot;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* The goal image where the bomb should be placed. */</span>
var goal <span style="color: #339933;">=</span> ImageView <span style="color: #009900;">&#123;</span>
    x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">470</span>, y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">360</span>
    image<span style="color: #339933;">:</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>
        url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}/goal.png&quot;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* List of obstacles nodes that the bomb can collide with. */</span>
var obstacles <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
    <span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">120</span>, y<span style="color: #339933;">:</span> 0, width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">100</span>, height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">300</span>, fill<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">BLACK</span><span style="color: #009900;">&#125;</span>,
    <span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">350</span>, y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">200</span>, width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">100</span>, height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">300</span>, fill<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">BLACK</span><span style="color: #009900;">&#125;</span>,
    <span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">370</span>, y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">50</span>, width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">50</span>, height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">50</span>, fill<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">BLACK</span><span style="color: #009900;">&#125;</span>,
    <span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span>
        x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">250</span>, y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">120</span>, translateX<span style="color: #339933;">:</span> bind move, width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">100</span>, height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">50</span>
        fill<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">BLACK</span>
    <span style="color: #009900;">&#125;</span>,
<span style="color: #009900;">&#93;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">/* Visible representations of obstacles */</span>
var wallimage <span style="color: #339933;">=</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>
    url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}/wall.png&quot;</span>
<span style="color: #009900;">&#125;</span>
var walls <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>obs in obstacles<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    ImageView <span style="color: #009900;">&#123;</span>
        x<span style="color: #339933;">:</span> obs.<span style="color: #006633;">x</span>, y<span style="color: #339933;">:</span> obs.<span style="color: #006633;">y</span>, translateX<span style="color: #339933;">:</span> bind obs.<span style="color: #006633;">translateX</span>
        clip<span style="color: #339933;">:</span> obs, image<span style="color: #339933;">:</span> wallimage
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* Animation for a blinking green led */</span>
var led <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span>;
var bombclock <span style="color: #339933;">=</span> Timeline <span style="color: #009900;">&#123;</span>
    repeatCount<span style="color: #339933;">:</span> Timeline.<span style="color: #006633;">INDEFINITE</span>
    autoReverse<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">true</span>
    keyFrames <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time <span style="color: #339933;">:</span> 0s
            values <span style="color: #339933;">:</span> led <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.0</span> tween Interpolator.<span style="color: #006633;">LINEAR</span>
        <span style="color: #009900;">&#125;</span>,
        KeyFrame <span style="color: #009900;">&#123;</span>
            time <span style="color: #339933;">:</span> 1s
            values <span style="color: #339933;">:</span> led <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1.0</span> tween Interpolator.<span style="color: #006633;">LINEAR</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* Animation for the bomb explosion and game reset */</span>
var fireradius <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span>;
var explosion<span style="color: #339933;">:</span>Timeline <span style="color: #339933;">=</span> Timeline <span style="color: #009900;">&#123;</span>
    repeatCount<span style="color: #339933;">:</span> <span style="color: #cc66cc;">1</span>
    keyFrames <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time <span style="color: #339933;">:</span> 0s
            values <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                fireradius <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.0</span>,
                fade <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.0</span>
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>,
        KeyFrame <span style="color: #009900;">&#123;</span>
            time <span style="color: #339933;">:</span> 2s
            values <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                fireradius <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">200.0</span> tween Interpolator.<span style="color: #006633;">LINEAR</span>,
                fade <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1.0</span> tween Interpolator.<span style="color: #006633;">LINEAR</span>
            <span style="color: #009900;">&#93;</span>
            action<span style="color: #339933;">:</span> gamereset
        <span style="color: #009900;">&#125;</span>,
        KeyFrame <span style="color: #009900;">&#123;</span>
            time <span style="color: #339933;">:</span> 3s
            values<span style="color: #339933;">:</span> fade <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.0</span> tween Interpolator.<span style="color: #006633;">LINEAR</span>
        <span style="color: #009900;">&#125;</span>,
    <span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* Reset variables for initial values */</span>
function gamereset<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    lock <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>;
    fireradius <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span>;
    tx <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span>;
    ty <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span>;
    bombfade <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1.0</span>;
&nbsp;
    moveblock.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
    specialcollison.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
    bombclock.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* Animation when the bomb reaches the goal. Bomb disapear. */</span>
var bombfade <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1.0</span>;
var bomdisapear <span style="color: #339933;">=</span> Timeline <span style="color: #009900;">&#123;</span>
    repeatCount<span style="color: #339933;">:</span> <span style="color: #cc66cc;">1</span>
    keyFrames <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time <span style="color: #339933;">:</span> 1s
            values<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
                        bombfade <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.0</span> tween Interpolator.<span style="color: #006633;">EASEBOTH</span>,
                        fade <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.0</span>
            <span style="color: #009900;">&#93;</span>
        <span style="color: #009900;">&#125;</span>,
        KeyFrame <span style="color: #009900;">&#123;</span>
            time <span style="color: #339933;">:</span> 2s
            values<span style="color: #339933;">:</span>
                    fade <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1.0</span> tween Interpolator.<span style="color: #006633;">LINEAR</span>;
            action<span style="color: #339933;">:</span> gamereset
        <span style="color: #009900;">&#125;</span>,
        KeyFrame <span style="color: #009900;">&#123;</span>
            time <span style="color: #339933;">:</span> 3s
            values<span style="color: #339933;">:</span>
                    fade <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.0</span> tween Interpolator.<span style="color: #006633;">LINEAR</span>;
        <span style="color: #009900;">&#125;</span>,
    <span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* Animation for a moving block. */</span>
var move <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span>;
var moveblock <span style="color: #339933;">=</span> Timeline <span style="color: #009900;">&#123;</span>
    repeatCount<span style="color: #339933;">:</span> Timeline.<span style="color: #006633;">INDEFINITE</span>
    autoReverse<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">true</span>
    keyFrames <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time <span style="color: #339933;">:</span> 0s
            values <span style="color: #339933;">:</span>
                    move <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0.0</span>
        <span style="color: #009900;">&#125;</span>,
        KeyFrame <span style="color: #009900;">&#123;</span>
            time <span style="color: #339933;">:</span> 3s
            values <span style="color: #339933;">:</span>
                    move <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">200.0</span> tween Interpolator.<span style="color: #006633;">EASEBOTH</span>
        <span style="color: #009900;">&#125;</span>,
    <span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* Check and handle possible collisions. */</span>
function checkcollissions<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #003399;">Void</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>checkobstacles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        lock <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span>;
        specialcollison.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        moveblock.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        explosion.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>insidenode<span style="color: #009900;">&#40;</span>bomb,goal<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        lock <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span>;
        moveblock.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
        bomdisapear.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* There was a bug, when the bomb is stopped, not been gragged, in front of
the moving block, it could pass through it because checkcollissions() was
only called on mouse moving. This make sure checking this special case. */</span>
var specialcollison<span style="color: #339933;">:</span>Timeline <span style="color: #339933;">=</span> Timeline <span style="color: #009900;">&#123;</span>
    repeatCount<span style="color: #339933;">:</span> Timeline.<span style="color: #006633;">INDEFINITE</span>
    keyFrames <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
        KeyFrame <span style="color: #009900;">&#123;</span>
            time <span style="color: #339933;">:</span> 1s<span style="color: #339933;">/</span><span style="color: #cc66cc;">5</span>
            action<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>hitnode<span style="color: #009900;">&#40;</span>obstacles<span style="color: #009900;">&#91;</span>sizeof obstacles<span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>, bomb<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                    lock <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span>;
                    moveblock.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
                    explosion.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
                    specialcollison.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
* The next four functions are for collision detection.
* @See http://silveiraneto.net/2008/10/30/javafx-rectangular-collision-detection/
*/</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
 * Check collision between two rectangles.
 */</span>
function collission<span style="color: #009900;">&#40;</span>ax, ay, bx, by, cx, cy, dx, dy<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #003399;">Boolean</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> not <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>ax <span style="color: #339933;">&gt;</span> dx<span style="color: #009900;">&#41;</span>or<span style="color: #009900;">&#40;</span>bx <span style="color: #339933;">&lt;</span> cx<span style="color: #009900;">&#41;</span>or<span style="color: #009900;">&#40;</span>ay <span style="color: #339933;">&gt;</span> dy<span style="color: #009900;">&#41;</span>or<span style="color: #009900;">&#40;</span>by <span style="color: #339933;">&lt;</span> cy<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
 * Check if the first rectangle are inside the second.
 */</span>
function inside <span style="color: #009900;">&#40;</span>ax, ay, bx, by, cx, cy, dx, dy<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #003399;">Boolean</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>ax <span style="color: #339933;">&gt;</span> cx<span style="color: #009900;">&#41;</span> and <span style="color: #009900;">&#40;</span>bx <span style="color: #339933;">&lt;</span> dx<span style="color: #009900;">&#41;</span> and <span style="color: #009900;">&#40;</span>ay <span style="color: #339933;">&gt;</span> cy<span style="color: #009900;">&#41;</span> and <span style="color: #009900;">&#40;</span>by <span style="color: #339933;">&lt;</span> dy<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
function hitnode<span style="color: #009900;">&#40;</span>a<span style="color: #339933;">:</span> Node, b<span style="color: #339933;">:</span>Node<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #003399;">Boolean</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>collission<span style="color: #009900;">&#40;</span>
        a.<span style="color: #006633;">getBoundsX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, a.<span style="color: #006633;">getBoundsY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
        a.<span style="color: #006633;">getBoundsX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> a.<span style="color: #006633;">getWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, a.<span style="color: #006633;">getBoundsY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> a.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
        b.<span style="color: #006633;">getBoundsX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, b.<span style="color: #006633;">getBoundsY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
        b.<span style="color: #006633;">getBoundsX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> b.<span style="color: #006633;">getWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, b.<span style="color: #006633;">getBoundsY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> b.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
function insidenode<span style="color: #009900;">&#40;</span>a<span style="color: #339933;">:</span>Node,b<span style="color: #339933;">:</span>Node<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #003399;">Boolean</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>inside<span style="color: #009900;">&#40;</span>
        a.<span style="color: #006633;">getBoundsX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, a.<span style="color: #006633;">getBoundsY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
        a.<span style="color: #006633;">getBoundsX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> a.<span style="color: #006633;">getWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, a.<span style="color: #006633;">getBoundsY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> a.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
        b.<span style="color: #006633;">getBoundsX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, b.<span style="color: #006633;">getBoundsY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
        b.<span style="color: #006633;">getBoundsX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> b.<span style="color: #006633;">getWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, b.<span style="color: #006633;">getBoundsY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> b.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
* Check collision of bomb against each obstacle.
*/</span>
function checkobstacles<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #003399;">Boolean</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>obst in obstacles<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>hitnode<span style="color: #009900;">&#40;</span>obst, bomb<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span>;
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* Pack visual game elements in a Frame's Stage, unresizable. */</span>
<span style="color: #003399;">Frame</span> <span style="color: #009900;">&#123;</span>
    title<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;Defuse the Bomb&quot;</span>
    width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">640</span>
    height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">480</span>
    resizable<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">false</span>
    closeAction<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        java.<span style="color: #006633;">lang</span>.<span style="color: #003399;">System</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span> 0 <span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
    visible<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">true</span>
&nbsp;
    stage<span style="color: #339933;">:</span> Stage <span style="color: #009900;">&#123;</span>
        content<span style="color: #339933;">:</span> bind <span style="color: #009900;">&#91;</span>floor, goal, walls, bomb, fadescreen<span style="color: #009900;">&#93;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* Call gamereset to set initial values and start animations */</span>
gamereset<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</pre></div></div>

<p><strong>Downloads:</strong></p>
<ul>
<li>High definition video, <a href="http://http://silveiraneto.net/downloads/javafx_defuse.ogv">javafx_defuse.ogv</a>.</li>
<li>Entire project with sources and resources for NetBeans 6.1 with JavaFX pluggin, <a title="NetBeans project" href="http://silveiraneto.net/downloads/defuse.tar.bz2">defuse.tar.bz2</a>.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/11/06/javafx-defuse-the-bomb/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JavaFX, rectangular collision detection</title>
		<link>http://silveiraneto.net/2008/10/30/javafx-rectangular-collision-detection/</link>
		<comments>http://silveiraneto.net/2008/10/30/javafx-rectangular-collision-detection/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 15:26:36 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[jfx]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[openjfx]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rectangle collision]]></category>
		<category><![CDATA[rectangular collision]]></category>
		<category><![CDATA[rectangular collision detection]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=1629</guid>
		<description><![CDATA[
In a game I wrote some years ago we handled simple rectangular collisions. Given the points:

We did:

// returning 0 means collision
int collision&#40;int ax, int ay, int bx, int by, int cx, int cy, int dx, int dy&#41;&#123;
	return &#40;&#40;ax &#62; dx&#41;&#124;&#124;&#40;bx &#60; cx&#41;&#124;&#124;&#40;ay &#62; dy&#41;&#124;&#124;&#40;by &#60; cy&#41;&#41;;
&#125;

I&#8217;ll show here a little demo about how implement simple [...]]]></description>
			<content:encoded><![CDATA[<p><center><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/NRwRTHPGg6M&amp;rel=0&amp;color1=0x006699&amp;color2=0x54abd6"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/NRwRTHPGg6M&amp;rel=0&amp;color1=0x006699&amp;color2=0x54abd6" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></object></center></p>
<p>In <a title="Batalhão" href="http://batalhao.codigolivre.org.br/">a game</a> I wrote some years ago we handled simple rectangular collisions. Given the points:</p>
<p style="text-align: center;"><img class="size-full wp-image-1630 aligncenter" title="abcd" src="http://silveiraneto.net/wp-content/uploads/2008/10/abcd.png" alt="" width="200" height="145" /></p>
<p>We did:</p>

<div class="wp_syntax"><div class="code"><pre class="c c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// returning 0 means collision</span>
<span style="color: #993333;">int</span> collision<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> ax<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> ay<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> bx<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> by<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> cx<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> cy<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> dx<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> dy<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>ax <span style="color: #339933;">&gt;</span> dx<span style="color: #009900;">&#41;</span>||<span style="color: #009900;">&#40;</span>bx <span style="color: #339933;">&lt;</span> cx<span style="color: #009900;">&#41;</span>||<span style="color: #009900;">&#40;</span>ay <span style="color: #339933;">&gt;</span> dy<span style="color: #009900;">&#41;</span>||<span style="color: #009900;">&#40;</span>by <span style="color: #339933;">&lt;</span> cy<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I&#8217;ll show here a little demo about how implement simple rectangular collisions on JavaFX.<br />
First I created a movable rectangle using the same idea of draggable nodes I already had <a href="http://silveiraneto.net/2008/08/11/javafx-draggable-node/">posted before</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.input.MouseEvent</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.geometry.Rectangle</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MovableRectangle <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> attribute startX <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span>;
    <span style="color: #000000; font-weight: bold;">private</span> attribute startY <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span>;
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> attribute onMove <span style="color: #339933;">=</span> function<span style="color: #009900;">&#40;</span>e<span style="color: #339933;">:</span><span style="color: #003399;">MouseEvent</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #003399;">Void</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
&nbsp;
    override attribute onMousePressed <span style="color: #339933;">=</span> function<span style="color: #009900;">&#40;</span>e<span style="color: #339933;">:</span><span style="color: #003399;">MouseEvent</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #003399;">Void</span> <span style="color: #009900;">&#123;</span>
        startX <span style="color: #339933;">=</span> e.<span style="color: #006633;">getDragX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span>translateX;
        startY <span style="color: #339933;">=</span> e.<span style="color: #006633;">getDragY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span>translateY;
        onMove<span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    override attribute onMouseDragged <span style="color: #339933;">=</span> function<span style="color: #009900;">&#40;</span>e<span style="color: #339933;">:</span><span style="color: #003399;">MouseEvent</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #003399;">Void</span> <span style="color: #009900;">&#123;</span>
        translateX <span style="color: #339933;">=</span> e.<span style="color: #006633;">getDragX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span>startX;
        translateY <span style="color: #339933;">=</span> e.<span style="color: #006633;">getDragY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span>startY;
        onMove<span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In the main code I some important things:</p>
<ul>
<li><strong>colide</strong>, a color that represents the collision effect. White means no collision and gray means collision.</li>
<li><strong>rec1</strong> and <strong>rec2</strong>, the two rectangles that can collide.</li>
<li><strong>checkcollision()</strong> the function that checks and handles a possible collision.</li>
</ul>
<p>Here is the main code:</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.application.Frame</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.application.Stage</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.geometry.Rectangle</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.paint.Color</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.input.MouseEvent</span>;
&nbsp;
var colide <span style="color: #339933;">=</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">WHITE</span>;
&nbsp;
function checkcollision<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #003399;">Void</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>
        <span style="color: #009900;">&#40;</span>rec1.<span style="color: #006633;">getBoundsX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> rec2.<span style="color: #006633;">getBoundsX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> rec2.<span style="color: #006633;">getWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> or
        <span style="color: #009900;">&#40;</span>rec1.<span style="color: #006633;">getBoundsX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> rec1.<span style="color: #006633;">getWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> rec2.<span style="color: #006633;">getBoundsX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> or 
        <span style="color: #009900;">&#40;</span>rec1.<span style="color: #006633;">getBoundsY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> rec2.<span style="color: #006633;">getBoundsY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> rec2.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> or 
        <span style="color: #009900;">&#40;</span>rec1.<span style="color: #006633;">getBoundsY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> rec1.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> rec2.<span style="color: #006633;">getBoundsY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        colide <span style="color: #339933;">=</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">WHITE</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
        colide <span style="color: #339933;">=</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">LIGHTGRAY</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
var rec1<span style="color: #339933;">:</span> MovableRectangle <span style="color: #339933;">=</span> MovableRectangle <span style="color: #009900;">&#123;</span>
    x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">10</span>, y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">10</span>, width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">50</span>, height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">60</span>, fill<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span>
    onMove<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span>e<span style="color: #339933;">:</span><span style="color: #003399;">MouseEvent</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #003399;">Void</span> <span style="color: #009900;">&#123;</span>
        checkcollision<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
var rec2<span style="color: #339933;">:</span> MovableRectangle <span style="color: #339933;">=</span> MovableRectangle <span style="color: #009900;">&#123;</span>
    x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">100</span>, y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">100</span>, width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">70</span>, height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">30</span>, fill<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">BLUE</span>
    onMove<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span><span style="color: #003399;">MouseEvent</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #003399;">Void</span> <span style="color: #009900;">&#123;</span>
        checkcollision<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003399;">Frame</span> <span style="color: #009900;">&#123;</span>
    title<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;Rectangular Collisions&quot;</span>, width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">300</span>, height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">300</span>
    closeAction<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
        java.<span style="color: #006633;">lang</span>.<span style="color: #003399;">System</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span> 0 <span style="color: #009900;">&#41;</span>; 
    <span style="color: #009900;">&#125;</span>
    visible<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">true</span>
&nbsp;
    stage<span style="color: #339933;">:</span> Stage <span style="color: #009900;">&#123;</span>
        fill<span style="color: #339933;">:</span> bind colide
        content<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>rec1, rec2<span style="color: #009900;">&#93;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Try it via Java Web Start:</p>
<p><center><a href="http://silveiraneto.net/downloads/collisiondemo/launch.jnlp"><img src="http://silveiraneto.net/wp-content/uploads/2008/10/webstart.png" alt="Java Web Start" /></a></center></p>
<p>Some considerations:</p>
<ul>
<li>You can use rectangular collisions to create bounding boxes to handle collisions in more complex shapes or sprites. Is a common approach in 2d games to avoid more expensive calculations.</li>
<li>There are space for optimizations.</li>
<li>In this case I&#8217;m using only two objects. Some problems raises when I have N objects to handle.</li>
</ul>
<p>More generally, we can code:</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;">function collission<span style="color: #009900;">&#40;</span>ax, ay, bx, by, cx, cy, dx, dy<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #003399;">Boolean</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> not <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>ax <span style="color: #339933;">&gt;</span> dx<span style="color: #009900;">&#41;</span>or<span style="color: #009900;">&#40;</span>bx <span style="color: #339933;">&lt;</span> cx<span style="color: #009900;">&#41;</span>or<span style="color: #009900;">&#40;</span>ay <span style="color: #339933;">&gt;</span> dy<span style="color: #009900;">&#41;</span>or<span style="color: #009900;">&#40;</span>by <span style="color: #339933;">&lt;</span> cy<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
function hitnode<span style="color: #009900;">&#40;</span>a<span style="color: #339933;">:</span> Node, b<span style="color: #339933;">:</span>Node<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #003399;">Boolean</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>collission<span style="color: #009900;">&#40;</span>
        a.<span style="color: #006633;">getBoundsX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, a.<span style="color: #006633;">getBoundsY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
        a.<span style="color: #006633;">getBoundsX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> a.<span style="color: #006633;">getWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, a.<span style="color: #006633;">getBoundsY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> a.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
        b.<span style="color: #006633;">getX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, b.<span style="color: #006633;">getY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
        b.<span style="color: #006633;">getX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> b.<span style="color: #006633;">getWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, b.<span style="color: #006633;">getY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> b.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This way we can pass just two bounding boxes to hitnode and easily check collision of a node against a list of bounding boxes nodes.<br />
Using the same approach I also wrote this function to test if a Node is inside another Node:</p>

<div class="wp_syntax"><div class="code"><pre class="java java" style="font-family:monospace;">function inside <span style="color: #009900;">&#40;</span>ax, ay, bx, by, cx, cy, dx, dy<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #003399;">Boolean</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>ax <span style="color: #339933;">&gt;</span> cx<span style="color: #009900;">&#41;</span> and <span style="color: #009900;">&#40;</span>bx <span style="color: #339933;">&lt;</span> dx<span style="color: #009900;">&#41;</span> and <span style="color: #009900;">&#40;</span>ay <span style="color: #339933;">&gt;</span> cy<span style="color: #009900;">&#41;</span> and <span style="color: #009900;">&#40;</span>by <span style="color: #339933;">&lt;</span> dy<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span>
&nbsp;
function insidenode<span style="color: #009900;">&#40;</span>a<span style="color: #339933;">:</span>Node,b<span style="color: #339933;">:</span>Node<span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #003399;">Boolean</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span>inside<span style="color: #009900;">&#40;</span>
        a.<span style="color: #006633;">getBoundsX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, a.<span style="color: #006633;">getBoundsY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
        a.<span style="color: #006633;">getBoundsX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> a.<span style="color: #006633;">getWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, a.<span style="color: #006633;">getBoundsY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> a.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
        b.<span style="color: #006633;">getBoundsX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, b.<span style="color: #006633;">getBoundsY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
        b.<span style="color: #006633;">getBoundsX</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> b.<span style="color: #006633;">getWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, b.<span style="color: #006633;">getBoundsY</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> b.<span style="color: #006633;">getHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Soon I&#8217;ll post game examples showing how to use this method and others collission detection methods.</p>
<p><strong>Downloads:</strong></p>
<ul>
<li>The original video, <a href="http://silveiraneto.net/downloads/javafx_rectangular_collision_detection.ogg">javafx_rectangular_collision_detection.ogg</a></li>
<li>NetBeans 6.1 Project with sources, <a href="http://silveiraneto.net/downloads/javafx_rec_col.tar.gz">javafx_rec_col.tar.gz</a>. Needs <a href="http://javafx.netbeans.org">JavaFX module</a> installed.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/10/30/javafx-rectangular-collision-detection/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Ainda essa semana</title>
		<link>http://silveiraneto.net/2008/10/28/ainda-essa-semana/</link>
		<comments>http://silveiraneto.net/2008/10/28/ainda-essa-semana/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 01:51:10 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[português]]></category>
		<category><![CDATA[CEJUG]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[Opensolaris]]></category>
		<category><![CDATA[Palestras]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=1565</guid>
		<description><![CDATA[Ainda essa semana eu vou fazer três palestras. Olhe aí se você não vai estar por perto.  

29/10 &#8211; Quarta-feira 20:30 &#8211; Palestra sobre NetBeans no na VII Semana de TI e Telecomunicações da FIC.
30/10 &#8211; Sexta-feira 09:30 &#8211; Palestra sobre OpenSolaris também na VII Semana de TI e Telecomunicações da FIC.
01/11 &#8211; Sábado [...]]]></description>
			<content:encoded><![CDATA[<p>Ainda essa semana eu vou fazer três palestras. Olhe aí se você não vai estar por perto. <img src='http://silveiraneto.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<ul>
<li><strong>29/10 &#8211; Quarta-feira</strong> <strong>20:30</strong> &#8211; Palestra sobre <strong>NetBeans</strong> no na <em>VII Semana de TI e Telecomunicações</em> da <a title="Faculdade Integrada de Fortaleza" href="http://www.fic.br/v4/">FIC</a>.</li>
<li><strong>30/10 &#8211; Sexta-feira</strong> <strong>09:30</strong> &#8211; Palestra sobre <strong>OpenSolaris</strong> também na <em>VII Semana de TI e Telecomunicações</em> da <a title="Faculdade Integrada de Fortaleza" href="http://www.fic.br/v4/">FIC</a>.</li>
<li><strong>01/11</strong> &#8211; <strong>Sábado 15:20 &#8211; </strong>Palestra <strong>Apresentando o CEJUG e o poder do Java</strong> em Iguatu no <a title="CEJUG" href="http://www.cejug.org/display/cejug/Apresentando+o+CEJUG+e+o+poder+do+Java+e+Frameworks+AJAX+em+Iguatu">Encontro PHP &amp; Java</a>.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/10/28/ainda-essa-semana/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
