<?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>Sebastian Oliva &#187; programming</title>
	<atom:link href="http://www.sebastianoliva.com/en/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sebastianoliva.com/en/</link>
	<description>mi Blag Personal</description>
	<lastBuildDate>Sun, 04 Sep 2011 04:02:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>GSoC, Week 5</title>
		<link>http://www.sebastianoliva.com/en/2011/07/gsoc-week-6/</link>
		<comments>http://www.sebastianoliva.com/en/2011/07/gsoc-week-6/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 05:47:00 +0000</pubDate>
		<dc:creator>tian</dc:creator>
				<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[GSOC-2011]]></category>
		<category><![CDATA[openSUSE @en]]></category>
		<category><![CDATA[gsoc]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[opensuse]]></category>
		<category><![CDATA[opensuse project]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.sebastianoliva.com/?p=191</guid>
		<description><![CDATA[Apart from what already was reported for the midterm, this weeks report includes the basics of the admin interface. It will use basic HTTP authentication, based on the documentation&#8217;s recommendation to implement. OpenID was shelved, due to the complexity, the need to add an extra data storage, and because advanced and granular authentication controls are [...]]]></description>
			<content:encoded><![CDATA[<p>Apart from what already was reported for the midterm, this weeks report includes the basics of the admin interface. It will use basic HTTP authentication, based on the documentation&#8217;s recommendation to implement. OpenID was shelved, due to the complexity, the need to add an extra data storage, and because advanced and granular authentication controls are not required at the moment. The other major change was adding support for different profiles, attached to the same device_id. This was implementing by changing the storage of the profiles collection from a binary data field to an array with the binaries. This was done to keep the same database design layout, and not affect performance.</p>
<p>Feel free to contact me for your comments or questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastianoliva.com/en/2011/07/gsoc-week-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Revamped shoebot.net</title>
		<link>http://www.sebastianoliva.com/en/2011/02/revamped-shoebot-net/</link>
		<comments>http://www.sebastianoliva.com/en/2011/02/revamped-shoebot-net/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 13:27:57 +0000</pubDate>
		<dc:creator>tian</dc:creator>
				<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[nodebox]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[shoebot]]></category>
		<category><![CDATA[websites]]></category>

		<guid isPermaLink="false">http://www.sebastianoliva.com/?p=131</guid>
		<description><![CDATA[The redesign of shoebot&#8217;s website is now live, go visit it now! It&#8217;s still missing some content and cleansing up, so feel free to leave your Critiques and Comments.]]></description>
			<content:encoded><![CDATA[<p>The redesign of <a href="http://shoebot.net/">shoebot&#8217;s website</a> is now live, go visit it now! It&#8217;s still missing some content and cleansing up, so feel free to leave your Critiques and Comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastianoliva.com/en/2011/02/revamped-shoebot-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using a Processing Sketch as a Java Component</title>
		<link>http://www.sebastianoliva.com/en/2010/05/using-a-processing-sketch-as-a-java-component/</link>
		<comments>http://www.sebastianoliva.com/en/2010/05/using-a-processing-sketch-as-a-java-component/#comments</comments>
		<pubDate>Sat, 01 May 2010 07:02:33 +0000</pubDate>
		<dc:creator>tian</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.sebastianoliva.com/?p=71</guid>
		<description><![CDATA[I really like Processing. Processing is a Visual Programming language, and it is based on Java. It is designed to run either as an Applet, a Standalone App, or as a Java Component; running a Processing Sketch as a Component is the one with less documentation, but probably one of the most interesting and powerful [...]]]></description>
			<content:encoded><![CDATA[<p>I really like <a href="http://processing.org"><em>Processing</em></a>. Processing is a Visual Programming language, and it is based on Java. It is designed to run either as an Applet, a Standalone App, or as a Java Component; running a Processing Sketch as a Component is the one with less documentation, but probably one of the most interesting and powerful applications of it.<br />
This is a small guide on setting up a Processing Sketch as a Java component, ready to use on your Swing or AWT desktop applications.<br />
<a href="http://www.sebastianoliva.com/wp-content/uploads/2010/03/JavaPro.png"><img src="http://www.sebastianoliva.com/wp-content/uploads/2010/03/JavaPro.png" alt="Processing Sketch Running on JFrame " title="JavaPro" width="376" height="357" class="aligncenter size-full wp-image-54" /></a><br />
<span id="more-71"></span><br />
I am assuming you have a basic notion of Object Oriented Programming, and preferably a base on Java, as it is obvious, you will need basic Processing skills.<br />
The first Step is to download Processing, I will not go too deep onto this, but just make sure you get the latest version for your OS.<br />
You will also need the Java Development Kit (JDK) and preferably an IDE (Integrated Development Environment) to help you along the way, two popular ones are <a href="http://www.netbeans.org/">NetBeans</a> and <a href="http://www.eclipse.org">Eclipse</a>.</p>
<p>After your environment is all set up, you will need a to create a new Project, just follow the instructions for your IDE.</p>
<p>The second step is to add to your project the library <code>core.jar</code>, which contains the basic Processing functionality. This library is found on the lib/ folder of the main Processing folder. For Linux this is located wherever you installed Processing, on Windows it is on Program Files/Processing, and in Mac it is located inside Processing.app, just Select the app, select File Menu > Show Package Contents and then open Resources folder.</p>
<p>Once you&#8217;ve added the library to your project, it&#8217;s real easy to start using it. PApplet is the class which Processing Applets extend, and it holds 2 very important methods, which you must implement to make a working Processing Sketch, this ones are <code>void setup()</code> and <code>void draw()</code>.<br />
You might note that this ones are quite similar to the ones on an average interactive Processing sketch, and you are totally right, in fact this ones are the exact equivalent as Processing converts your code to pure Java.</p>
<p>A basic and important thing to keep in mind is that PApplet extends from <code>java.awt.Component</code> so to your AWT of Swing based app, it will be no different from any other component, and it will be as easy to add to your JFrame or JPanel.</p>
<p>Let&#8217;s begin with a simple example</p>
<h3>Simple Processing</h3>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    size<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">400</span>, <span style="color: #cc66cc;">400</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    background<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>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> draw<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    background<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    fill<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">200</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    ellipseMode<span style="color: #009900;">&#40;</span>CENTER<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    ellipse<span style="color: #009900;">&#40;</span>mouseX,mouseY,<span style="color: #cc66cc;">40</span>,<span style="color: #cc66cc;">40</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now to add it to our application, we must create a class that extends PApplet, a JFrame to contain it and a Main class to launch it, your app then should look similar to this:</p>
<h3>Java Source Code</h3>
<h4>Main.java</h4>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">processJava</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">new</span> DisplayFrame<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setVisible</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h4>DisplayFrame.java</h4>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">processJava</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> DisplayFrame <span style="color: #000000; font-weight: bold;">extends</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JFrame</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> DisplayFrame<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;">this</span>.<span style="color: #006633;">setSize</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">600</span>, <span style="color: #cc66cc;">600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//The window Dimensions</span>
        setDefaultCloseOperation<span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">WindowConstants</span>.<span style="color: #006633;">EXIT_ON_CLOSE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JPanel</span> panel <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> javax.<span style="color: #006633;">swing</span>.<span style="color: #003399;">JPanel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        panel.<span style="color: #006633;">setBounds</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">20</span>, <span style="color: #cc66cc;">20</span>, <span style="color: #cc66cc;">600</span>, <span style="color: #cc66cc;">600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        processing.<span style="color: #006633;">core</span>.<span style="color: #006633;">PApplet</span> sketch <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CircleSketch<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        panel.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>sketch<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>panel<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        sketch.<span style="color: #006633;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//this is the function used to start the execution of the sketch</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">setVisible</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h4>CircleSketch.java</h4>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">processJava</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">processing.core.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CircleSketch <span style="color: #000000; font-weight: bold;">extends</span> PApplet <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    size<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">400</span>, <span style="color: #cc66cc;">400</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    background<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>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> draw<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    background<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    fill<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">200</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    ellipseMode<span style="color: #009900;">&#40;</span>CENTER<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    ellipse<span style="color: #009900;">&#40;</span>mouseX,mouseY,<span style="color: #cc66cc;">40</span>,<span style="color: #cc66cc;">40</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>It&#8217;s done, now just press run and enjoy.<br />
You now have no excuse to keep your processing sketches apart from your desktop applications.</p>
<p><strong>EDIT:</strong> Fixed a small typo on a class&#8217; name </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastianoliva.com/en/2010/05/using-a-processing-sketch-as-a-java-component/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Gotta Love Nodebox</title>
		<link>http://www.sebastianoliva.com/en/2010/01/gotta-love-nodebox/</link>
		<comments>http://www.sebastianoliva.com/en/2010/01/gotta-love-nodebox/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 06:56:54 +0000</pubDate>
		<dc:creator>tian</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geek Stuff]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[nodebox]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.sebastianoliva.com/?p=41</guid>
		<description><![CDATA[I really like Nodebox. The idea of mixing the Ease of use and Power of Python with the Rendering of Quartz, is simply great. One of my favourite things about it is the great quality of the rendering; it&#8217;s just gorgeous. Within a few hours, I went back to the level I had a few [...]]]></description>
			<content:encoded><![CDATA[<p>I really like Nodebox. The idea of mixing the Ease of use and Power of Python with the Rendering of Quartz, is simply great. One of my favourite things about it is the great quality of the rendering; it&#8217;s just gorgeous.<br />
<span id="more-41"></span><br />
<a href="http://www.sebastianoliva.com/wp-content/uploads/2010/01/beatles.png"><img src="http://www.sebastianoliva.com/wp-content/uploads/2010/01/beatles.png" alt="Beatles Similar Artists Graph" title="beatles" width="500" height="500" class="alignnone size-full wp-image-43" /></a></p>
<p>Within a few hours, I went back to the level I had a few years ago, when I started with Nodebox.<br />
One of the greatest things about it is the Excellent Typographic support, courtesy AAT and Quartz.</p>
<p><a href="http://www.sebastianoliva.com/wp-content/uploads/2010/01/blagamond.png"><img src="http://www.sebastianoliva.com/wp-content/uploads/2010/01/blagamond.png" alt="Garamond" title="GaramondPro" width="500" height="375" class="alignnone size-full wp-image-46" /></a></p>
<p>The only grip I used to have against it was the limit on libraries, as Nodebox restricts the Python environment, but after a few hours, I got a very simple solution:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>NodeBox<span style="color: #000000; font-weight: bold;">/</span>NodeBox.app<span style="color: #000000; font-weight: bold;">/</span>Contents<span style="color: #000000; font-weight: bold;">/</span>Resources<span style="color: #000000; font-weight: bold;">/</span>Python
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>Python<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2.5</span><span style="color: #000000; font-weight: bold;">/</span>site-packages <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>NodeBox<span style="color: #000000; font-weight: bold;">/</span>NodeBox.app<span style="color: #000000; font-weight: bold;">/</span>Contents<span style="color: #000000; font-weight: bold;">/</span>Resources<span style="color: #000000; font-weight: bold;">/</span>Python</pre></div></div>

<p>After this, all the import statements worked as a charm, so now it&#8217;s time to make use of it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sebastianoliva.com/en/2010/01/gotta-love-nodebox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

