<?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; Jim Clarke</title>
	<atom:link href="http://silveiraneto.net/tag/jim-clarke/feed/" rel="self" type="application/rss+xml" />
	<link>http://silveiraneto.net</link>
	<description></description>
	<lastBuildDate>Fri, 09 Mar 2012 04:13:27 +0000</lastBuildDate>
	<language>pt-br</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<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[<a href="http://silveiraneto.net/2008/11/21/inkscape-and-javafx-working-together/" title="Inkscape and JavaFX working together"></a>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 &#8230;<p class="read-more"><a href="http://silveiraneto.net/2008/11/21/inkscape-and-javafx-working-together/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://silveiraneto.net/2008/11/21/inkscape-and-javafx-working-together/" title="Inkscape and JavaFX working together"></a><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" 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" 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" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.paint.Color</span><span style="color: #339933;">;</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><span style="color: #339933;">;</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><span style="color: #339933;">;</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><span style="color: #339933;">;</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><span style="color: #339933;">;</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" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.paint.Color</span><span style="color: #339933;">;</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><span style="color: #339933;">;</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><span style="color: #339933;">;</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><span style="color: #339933;">;</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" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.input.MouseEvent</span><span style="color: #339933;">;</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><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.application.Frame</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.application.Stage</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.effect.SepiaTone</span><span style="color: #339933;">;</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. :D</span></p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/11/21/inkscape-and-javafx-working-together/feed/</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
	</channel>
</rss>

