<?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/"
	>

<channel>
	<title>Ben Jones</title>
	<atom:link href="http://blogs.standardsco.com/wpmu/bjones/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.standardsco.com/wpmu/bjones</link>
	<description>EduBytes on learning and process</description>
	<pubDate>Thu, 09 Jul 2009 21:52:42 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tutorials and learning</title>
		<link>http://blogs.standardsco.com/wpmu/bjones/2009/07/09/tutorials-and-learning/</link>
		<comments>http://blogs.standardsco.com/wpmu/bjones/2009/07/09/tutorials-and-learning/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 21:52:42 +0000</pubDate>
		<dc:creator>Ben Jones</dc:creator>
		
		<category><![CDATA[Content writing]]></category>

		<guid isPermaLink="false">http://blogs.standardsco.com/wpmu/bjones/?p=45</guid>
		<description><![CDATA[Some time ago, a colleague of mine asked me to write a tutorial aimed at a non-typical piece of software that lead the reader from the inception of an idea to a finished product. As an educator, It was extremely difficult to ignore such an open suggestion. This following piece is what that challenge produced.
-=-=-=-=-

 [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago, a colleague of mine asked me to write a tutorial aimed at a non-typical piece of software that lead the reader from the inception of an idea to a finished product. As an educator, It was extremely difficult to ignore such an open suggestion. This following piece is what that challenge produced.</p>
<p>-=-=-=-=-</p>
<div class="page">
<p>            <img class="pLeft" align="left" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/sample_helm.png" alt="Our final goal" width="200" height="285" /><br />
<h3 class="pTut">Quick modeling an early 15th Century German Barbutte</h3>
<p class="definition">A Barbutte is a visorless war helmet of fifteenth century Italian design, often with distinctive &#8220;T&#8221; shaped or &#8220;Y&#8221; shaped opening for the eyes and mouth. The Barbutte resembles classical Greek helmets and may have been influenced by a renewed interest in ancient artifacts.<br />- Wikipedia</p>
<p class="paraTut">This beginner level XSI 6 tutorial provides a &#8220;how-to&#8221; for creating a simple mesh of a German variant of the Barbutte. I will focus mainly on a couple of techniques that lend themselves to rapid modeling; namely, extrusions and polygon bridging. Quick modeling lays out the basic mesh from which modifications that are more detailed can be made later. In our case, we are looking to get the most model out of the fewest operations as reasonable. However, you can  always employ other methods based on your tools and experience. For now, this works quite well enough.</p>
<p class="paraTut">Since the top of the Barbutte is an oblong dome that wraps down in the back slightly, let us start with that premise. We can use the extrusion tool to create this shape rather quickly with just two arcs. The first arc, referred to as the <span class="objName">crown_path</span>, is a simple 200-degree; while, the second arc, referred to as the <span class="objName">crown_shape</span>, is a simple 180-degree arc. The <span class="objName">crown_shape</span> then extrudes along the <span class="objName">crown_path</span> to create the <span class="objName">crown</span> of the helm.</p>
<p>            <img class="pRight" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_1.png" alt="The arc properties dialog" width="251" /></p>
<p class="paraTut">Both of these arcs will be created in exactly the same manner. We will begin with creating the <span class="objName">crown_path</span>.</p>
<ol class="details">
<li>Select <span class="objCommand">Model-&gt;Get-&gt;Primitive-&gt;Curve-&gt;Arc</span></li>
<li>Name the arc &#8216;<span class="objNameBare">crown_path</span>&#8216;</li>
<li>Set the End Angle to 200</li>
</ol>
<p class="paraTut">Now close this dialog and repeat the process for the <span class="objName">crown_shape</span>.</p>
<ol class="details">
<li>Select <span class="objCommand">Model-&gt;Get-&gt;Primitive-&gt;Curve-&gt;Arc</span></li>
<li>Name the arc &#8216;<span class="objNameBare">crown_shape</span>&#8216;</li>
<li>Set the End Angle to 180</li>
</ol>
<p class="paraTut">Again, close the dialog when finished. Now, there is not to see since both arcs are in the same plane. Our plan is to extrude the <span class="objName">crown_shape</span> along the <span class="objName">crown_path</span>. This means that we will need to reorient the <span class="objName">crown_shape</span> to get the desired final shape.</p>
<p>            <img class="pLeft" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_2a.png" alt="The transform panel settings" width="101" /><br />
            <img class="pRight" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_2b.png" alt="The select panel" width="101" /></p>
<p class="paraTut">First, make sure that the <span class="objName">crown_shape</span> is the currently selected arc (white color usually indicates this state). The re-orientation occurs in two phases. First, we are spinning the arc about its axis. Then, we are going to reset the axis while leaving the arc in the new position. On the Transform Panel,</p>
<ol class="details">
<li>Set the X rotation to 90</li>
<li>Set the Y rotation to -90</li>
<li>On the Select panel, click the CENTER button to active the arc&#8217;s center</li>
<li>Back on the Transform Panel, set all rotations to 0</li>
<li>Back on the Select Panel, click the OBJECT button to deactivate the arc&#8217;s center</li>
</ol>
<p>            <img class="pRight" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_3.png" alt="The crown_path and crown_shape arcs" width="250" /></p>
<p class="paraTut">Currently, we have our two arcs as shown to the right; where the <span class="objName">crown_shape</span> is the white arc and the <span class="objName">crown_path</span> is the long black arc. The arcs are now ready for the extrusion operation.</p>
<ol class="details">
<li>Select <span class="objCommand">Model-&gt;Create-&gt;Poly.Mesh-&gt;Extrude Along Curve</span></li>
<li>Drag the pick session cursor across the <span class="objName">crown_path</span> arc, then release it</li>
<li>Right click the mouse to end pick session</li>
</ol>
<p class="paraTut">This extrudes our <span class="objName">crown_shape</span> along the <span class="objName">crown_path</span> producing a smooth <span class="objName">crown</span> portion of the helm (see the image below).</p>
<p>            <img class="pLeft" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_4.png" alt="After extruding the crown_shape along the crown_path" width="250" /></p>
<p class="paraTut">Now we have something to work with; currently, it looks more like half a doughnut than a helm.</p>
<p class="paraTut">We need to close in the doughnut hole first. To do this, we are going to collapse the inner edges of that gap on both sides.</p>
<ol class="details">
<li>Press the E key to enter &#8220;Tagged Edges&#8221; mode</li>
<li>Select one of the front gaps&#8217; edges (see the below left-side image)</li>
</ol>
<p>            <img class="pLeft" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_4b.png" alt="Selecting the first inner gap edge" width="250" /><br />
            <img class="pRight" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_4c.png" alt="All the inner gaps edges selected" width="250" /></p>
<p class="paraTut">As on the left:</p>
<ol class="details">
<li>Right click that edge to activate the contextual menu</li>
<li>Select the <span class="objCommand">Select Edge Loop (no corners)</span> option</li>
<li>Select another of the front gaps&#8217; edges</li>
<li>Hold down the Control Key</li>
<li>Select any edge from the back gap</li>
<li>Release the Control Key</li>
<li>Right click to end the edge selection pick session</li>
</ol>
<p>            <img class="pLeft" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_4d.png" alt="After collasping the edges into a single component" width="250" /><br />
            <img class="pRight" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_4e.png" alt="Before translating the gaps points" width="250" /></p>
<p class="paraTut">You should have edges selected according to the above right-side image.</p>
<p class="paraTut">Now, collapse all of these edges into single components as follows:</p>
<ol class="details">
<li>Right click one of the selected edges to activate the contextual menu again</li>
<li>Select the <span class="objCommand">Collapse Components</span> option</li>
</ol>
<p>            <img class="pLeft" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_4f.png" alt="After translating the gaps points" width="250" /></p>
<p class="paraTut">Once selected, these two points need to be moved down until they are at least level with the bottom edge on the right side of the <span class="objName">crown</span>.</p>
<ol class="details">
<li>Press T to enter &#8220;Tagged Point&#8221; mode</li>
<li>Drag the selection area over the two new points as shown in the above right image</li>
<li>Press the V key to enter Translate mode</li>
<li>Grab the Y axis handle (green) and pull it downward until it is about where the image to the left indicates</li>
</ol>
<p></p>
<p class="paraTut">With the gaps filled on both sides, we now have the <span class="objName">crown</span> of the helm roughed out in its most basic form. The next step is to create the skirting that comes down from the bottom of the <span class="objName">crown</span>, which protects the head from eye level down to the shoulders. Again, we want to keep this simple and quick. The idea is to extrude the bottom edge of the <span class="objName">crown</span> downward to produce the skirting. We will do this for the entire <span class="objName">crown</span> and not worry about the details of the face area until later.</p>
<p>            <img class="pRight" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_7.png" alt="Selecting the first bottom edge" width="250" /></p>
<p class="paraTut">To accomplish this, we need to select an edge, and then expand that selection to include all the bottom edges.</p>
<ol class="details">
<li>Press the E key to enter &#8220;Tagged Edge&#8221; editing mode</li>
<li>Select a bottom edge of the <span class="objName">crown</span> (shown in red)</li>
<li>Right click the mouse to get the contextual menu</li>
<li>Select the <span class="objCommand">Select Edge Loop (around corners)</span> option</li>
<li>Now select some other bottom edge section</li>
</ol>
<p>            <img class="pRight" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_8.png" alt="All the bottom edges selected" width="250" /></p>
<p class="paraTut">This should give you something like the image to the right where the entire bottom edge is red. If only the left side is red and right side is not included; not to worry, we can add the right side.</p>
<ol class="details">
<li>Hold down the Control key</li>
<li>Right click on a bottom edge to get the contextual menu</li>
<li>Select the <span class="objCommand">Select Edge Loop (around corners)</span> option</li>
<li>Now select a bottom edge section from the right side</li>
<li>Release the Control Key</li>
</ol>
<p class="paraTut">With the entire bottom edge selected, the extrusion of the <span class="objName">crown</span> begins. We are not only going to extrude it down but add a little scaling and some translation to make the skirt more life like.</p>
<ol class="details">
<li>Right click the currently selected bottom edge to get the contextual menu</li>
<li>Select the <span class="objCommand">Extrude along Axis</span> option</li>
</ol>
<p>            <img class="pLeft" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_8bb.png" alt="Settings for the extrude tab" width="200" /><br />
            <img class="pRight" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_8cc.png" alt="Settings for the transform tab" width="200" /></p>
<p class="paraTut">On the Extrude tab,</p>
<ol class="details">
<li>Increase the length to 8</li>
<li>Uncheck the Y</li>
<li>Check the Z</li>
<li>Set the number of Subdivisions to 5</li>
</ol>
<p class="paraTut">On the Transform tab,</p>
<ol class="details">
<li>Set the X scaling to 1.03</li>
<li>Set the Z scaling to 1.025</li>
<li>Set the Z translation to 0.5</li>
</ol>
<p>            <img class="pRight" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_4g.png" alt="After extruding the crown's skirt" width="200" /></p>
<p class="paraTut">The skirt should now extends down from the <span class="objName">crown</span> and sweeps to the left some. Here is a shaded view of where we currently stand in the process. In fact, from this step forward working in a shaded view makes life a bit easier. There are number of things left to complete before we are finished with the mesh.</p>
<p class="paraTut">From this view, the helm is beginning to take shape. We can see the rounded <span class="objName">crown</span> that dips down more in the back, the neck-skirting coming down and flaring out to the back. Unfortunately, our poor knight has no way to see since there is no visor area. This is our next set of steps, developing the helm&#8217;s facial opening and nasal guard.</p>
<p class="paraTut">To begin with, let us switch to the right view port since the helm&#8217;s face appears on the right side of our current view. Again, use a shaded view for working ease. Looking at the mesh, it seems a little narrow. We will have to widen the entire helm to give it proportions that are more normal. After that, we will cut away the face opening and the put the nasal guard into place.</p>
<p>            <img class="pLeft" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_9bb.png" alt="Scaling the helm's width" width="200" /><br />
            <img class="pRight" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_9cc.png" alt="Selecting the facial openings" width="200" /></p>
<ol class="details">
<li>Press the Space Bar to reset the object</li>
<li>Press the X key to enter scaling mode</li>
<li>Grab the Z axis handle (blue) and drag it to the left</li>
</ol>
<p class="paraTut">Size the helm until it is about as wide as the image to the right. Now we can cut away the face openings.</p>
<ol class="details">
<li>Reset the object with the Space Bar</li>
<li>Press the U key</li>
<li>Highlight the indicated polygons</li>
<li>Press the delete key to remove these from the mesh.</li>
</ol>
<p class="paraTut">Now the nasal guard can be added the to <span class="objName">crown</span> by extruding a pair of edges from top center of the eye opening down between the cheek pieces. As in the skirt extrusion extruded the <span class="objName">crown</span> skirt down, we are going to add some adjustments to this extrusion, namely scaling to narrow the nasal as it descends.</p>
<p>            <img class="pLeft" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_10aa.png" alt="Selecting the two nasal starting edges" width="200" /><br />
            <img class="pLeft" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_10a.png" alt="The Extrude tab settings for the nasal" width="200" /></p>
<ol class="details">
<li>Press the E key</li>
<li>Select the two edges on the top of the eye opening above the gap in the cheek pieces</li>
<li>Right click the selected edges and select the <span class="objCommand">Extrude along Axis</span> option</li>
</ol>
<p class="paraTut">On the Extrude tab,</p>
<ol class="details">
<li>Set the length to 5</li>
<li>Set the number of Subdivisions to 4</li>
<li>Uncheck the Y</li>
<li>Check the Z</li>
</ol>
<p class="paraTut">On the Transform tab,</p>
<ol class="details">
<li>Set the X scaling to 0.7</li>
</ol>
<p>            <img class="pRight" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_10bb.png" alt="After extruding the nasal, select these two edges" width="200" /><br />
            <img class="pRight" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_10b.png" alt="The Transform tab settings for the nasal" width="200" /></p>
<p class="paraTut">The extrusion should leave us with the nasal looking much like the one to the right. Coming down from the <span class="objName">crown</span> and narrowing to a more pointed form as it passes down into the gap between the two cheek pieces.</p>
<p class="paraTut">The image to the right is not exactly what you would have at this point. I have jumped ahead slightly by selecting the two adjoining nasal edges in the upper corner of the eye opening on the right side. This is in preparation for our next step.</p>
<p class="paraTut">Barbuttes typically had very rounded eye openings that angled slightly toward where the tip of the nose might be on the wearer. We need to soften these corners and an a bit of angle.</p>
<p class="paraTut">Specifically, we would like to flare the upper nasal more gracefully into the <span class="objName">crown</span> and round out the lower back corners of the eye openings and add some upward arching to the tops of each eye. Since I have already selected those two nasal edges, let us start with those.</p>
<p>            <img class="pLeft" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_11aa.png" alt="The corners have been bridged" width="200" /></p>
<ol class="details">
<li>Right click the selected edges (from the image above)</li>
<li>Select the <span class="objCommand">Bridge Boundary Edges</span> option</li>
<li>The properties on the dialog are sufficient, so no changes are needed here</li>
</ol>
<p class="paraTut">This creates a polygon between those two edges, which gives the nasal a smoother broader connection to the <span class="objName">crown</span>. Repeat this procedure for the opposite side of the nasal as well. Additionally, use the same procedure to bridge the corner edges on the lower back corners of each eye opening. When finished, there should be four new polygons on the mesh as in the image to the left.<br />
            We will save the arching of the tops of the eye openings for little later.</p>
<p>            <img class="pRight" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_12a.png" alt="After de-selecting the lower back edges" width="200" /><br />
            <img class="pRight" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_12.png" alt="Selecting the crown's seam edge" width="200" /></p>
<p class="paraTut">Now let us add the <span class="objName">crown&#8217;s</span> seam edge. This slight raised edge runs upward along the bridge of the nasal over the top centerline of the helm and down the backside.</p>
<ol class="details">
<li>Select a vertical edge in the center of the nasal</li>
<li>Right that selected edge</li>
<li>Select the <span class="objCommand">Select Edge Loop (no corners)</span> option</li>
<li>Select another edge along that same line</li>
<li>In the Camera View, Hold down the Control Key</li>
<li>De-select the red edges from the base of the <span class="objName">crown</span> to the bottom of the skirt</li>
<li>Release the Control Key</li>
</ol>
<p>            <img class="pLeft" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_13aa.png" alt="The Transform panel settings" width="135" /><br />
            <img class="pRight" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_13bb.png" alt="The seam edge is scaled and marked hard" width="200" /></p>
<p class="paraTut">To make the <span class="objName">crown&#8217;s</span> seam edge stand out clearly, we must give it some relief above the normal curvature of the <span class="objName">crown</span> and make it a non-deforming hard edge.</p>
<p class="paraTut">Scaling the seam edge in both the X and Y axis pushes the edge above the <span class="objName">crown&#8217;s</span> curvature and adds a bit of ridge line to the nasal as well.</p>
<p class="paraTut">On the Transform Panel</p>
<ol class="details">
<li>Hold down the Shift Key</li>
<li>Click on both the X and Y buttons</li>
<li>Click on the GLOBAL button</li>
<li>Inside the viewport, gently drag the mouse until the seam rises slightly</li>
<li>Press the E key to return to the &#8220;Tagged Edge&#8221; mode</li>
<li>Right click on the seam to get the contextual menu</li>
<li>Select the <span class="objCommand">Mark Edge Hard</span> option</li>
</ol>
<p>            <img class="pLeft" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_14aa.png" alt="Moving the back eye opening points" width="200" /></p>
<p class="paraTut">Arching the tops of the eye openings remains the last addition to the basic mesh for this tutorial.<br />
            Nothing beats some simple point edits to accomplish this feat; however, let&#8217;s do this one with a little magnetic assistance.<br />
            Using the modify tool in magnetic mode, pushing points actually slides them across the existing surface of the mesh.<br />
            This is a great time saving since the points stay relative to the mesh and don&#8217;t drift out into space.</p>
<ol class="details">
<li>Switch to the Front Viewport</li>
<li>Press the T key to enter &#8220;Tagged Point&#8221; mode</li>
<li>Drag a selection rectangle over the point at the back of the eye opening</li>
<li>Press the M key to enter modify mode</li>
<li>Highlight only the Magnet</li>
<li>Hold the Shift Key down</li>
<li>Carefully slid the selected point toward the left</li>
</ol>
<p>            <img class="pRight" src="http://blogs.standardsco.com/user_images/bjones/barbutte/images/step_14cc.png" alt="After moving the eye opening points" width="200" /></p>
<p class="paraTut">By using the Rectangular select from the &#8220;Tagged Point&#8221;, we selected the point on the opposite eye opening in addition to the one visible. The Shift key tied to the translation to both points so that the move was identical for each point. So it&#8217;s an exact two for one edit. We can now use the same technique for modifying the top of the eye opening to create a gentle arch for both eyes at once. Grab each point along the brow (top of the eye opening) and push them up until it looks something like the image to the right.</p>
<p class="paraTut">This concludes the basic mesh construction intended for the tutorial. XSI offers many methods for achieving any single task so feel free to experiment with alternative methods or approaches.   Perhaps I&#8217;ll continue this later to refine the mesh with a form fitting make over, add some rolled edges, and a few additional modifications to get helm up to historical standards. So stayed tuned.</p>
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blogs.standardsco.com/wpmu/bjones/2009/07/09/tutorials-and-learning/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Sapphire is out</title>
		<link>http://blogs.standardsco.com/wpmu/bjones/2008/12/26/33/</link>
		<comments>http://blogs.standardsco.com/wpmu/bjones/2008/12/26/33/#comments</comments>
		<pubDate>Fri, 26 Dec 2008 17:40:18 +0000</pubDate>
		<dc:creator>Ben Jones</dc:creator>
		
		<category><![CDATA[JavaFX]]></category>

		<guid isPermaLink="false">http://blogs.standardsco.com/wpmu/bjones/?p=33</guid>
		<description><![CDATA[Seems that the Blogosphere is interested in Sapphire.  Since Jim Weaver posted his first blog regarding Sapphire, it has been carried over to DZone, then into JavaLobby, then out to several other technology blogs and now has landed as an item of interest on the Sun Microsystems front page.
Thanks everyone for your interest and [...]]]></description>
			<content:encoded><![CDATA[<p>Seems that the Blogosphere is interested in Sapphire.  Since <a href="http://learnjavafx.typepad.com/weblog/">Jim Weaver</a> posted his first blog regarding Sapphire, it has been carried over to DZone, then into JavaLobby, then out to several other technology blogs and now has landed as an item of interest on the <a href="http://java.sun.com/">Sun Microsystems</a> front page.</p>
<p>Thanks everyone for your interest and commentary on this JavaFX application.  Below is a snapshot of the Sun page.  Please head on over to Sun and express your support for JavaFX.</p>
<p><a href="http://blogs.standardsco.com/wpmu/bjones/files/2008/12/sun_web_page_screen_shot.gif"><img class="size-medium wp-image-32 alignleft" src="http://blogs.standardsco.com/wpmu/bjones/files/2008/12/sun_web_page_screen_shot-300x196.gif" alt="Sun site inclusion" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.standardsco.com/wpmu/bjones/2008/12/26/33/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A brief charting example</title>
		<link>http://blogs.standardsco.com/wpmu/bjones/2008/12/20/a-brief-charting-example/</link>
		<comments>http://blogs.standardsco.com/wpmu/bjones/2008/12/20/a-brief-charting-example/#comments</comments>
		<pubDate>Sun, 21 Dec 2008 05:21:16 +0000</pubDate>
		<dc:creator>Ben Jones</dc:creator>
		
		<category><![CDATA[JavaFX]]></category>

		<guid isPermaLink="false">http://blogs.standardsco.com/wpmu/bjones/?p=24</guid>
		<description><![CDATA[This is the technical writeup I provided to Jim Weaver for his updated blog with some editorial changes.
One of the features of JavaFX that makes it attractive to real-time application developers is its ability to tie graphical elements to models through the binding mechanism. This mechanism makes it possible for the current state of the [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em>This is the technical writeup I provided to <a href="http://learnjavafx.typepad.com/weblog/">Jim Weaver</a> for his updated blog with some editorial changes.</em></strong></p>
<p>One of the features of JavaFX that makes it attractive to real-time application developers is its ability to tie graphical elements to models through the binding mechanism. This mechanism makes it possible for the current state of the model to be reflected in the interface without the need to create any type of polling system.</p>
<p>In our Sapphire application, we collect real-time data from classroom observations. The observer records classroom events by pressing various buttons. These events are displayed in several dashboard type displays which are actively tied to supporting models. One of these displays in a time lime of events created by a series of colored rectangles. The size, placement and color of the rectangles represent different relationships in the event data. Every time an event is pressed, the data changes and the bound display automatically updates.</p>
<p>To achieve this, you only need three things: a data model, a display element, and an event driver of some type. Let&#8217;s take a look at one of the visual building blocks, the <strong>TimeOnTaskBlock </strong>class:</p>
<pre>
public class TimeOnTaskBlock extends CustomNode {

public var aboveColor:Color = Color.GREEN;
public var belowColor:Color = Color.RED;

public var seconds:Integer;
public var startingMark:Integer;
public var zoneWidth:Integer = 600;
public var zoneSeconds:Integer = 3600;
public var height:Integer = 100;
public var maxSegments:Number = 5;
public var segment:Number = 0;
public var x:Integer;
public var scale:Number = 0.95;

  public override function create(): Node {
    return Group {

      var maxDisplayHeight:Number = height/2;

      content: [
        Rectangle {
          x: bind zoneWidth * startingMark / zoneSeconds;
          y: bind height/2 - scale * ((maxDisplayHeight) * segment/maxSegments)
          width: bind zoneWidth * seconds / zoneSeconds;
          height: bind scale * (maxDisplayHeight * segment/maxSegments)
          fill: bind aboveColor
          strokeWidth:0
        },
        Rectangle {
          x: bind zoneWidth * startingMark / zoneSeconds;
          y: bind height / 2
          width: bind zoneWidth * seconds / zoneSeconds;
          height: bind scale * (maxDisplayHeight - (maxDisplayHeight * segment/maxSegments))
          fill: bind belowColor
          strokeWidth:0
        }
      ]
      effect: Lighting {
        light: DistantLight { azimuth: 225 elevation: 60 }
        surfaceScale: 2
      }
    };
  }
}</pre>
<p>This custom node represents what will be displayed. It is a pair of scaled rectangles stacked on top of each other. The various attributes define shape, size, and placement. Notice the use of the the <strong>DistantLight </strong>effect to give the rectangles in the graph some depth. The next building block up from this is another custom node that handles the visual orchestration of the time blocks nodes. The <strong>DisplayTimeChart </strong>node is effectively the dashboard element being displayed. It has a data member holding a sequence of <strong>TimeOnTaskBlock </strong>nodes. Let&#8217;s take a peek at this node:</p>
<pre>public class TimeOnTaskBlock extends CustomNode {

public var aboveColor:Color = Color.GREEN;
public var belowColor:Color = Color.RED;

public var seconds:Integer;
public var startingMark:Integer;
public var zoneWidth:Integer = 600;
public var zoneSeconds:Integer = 3600;
public var height:Integer = 100;
public var maxSegments:Number = 5;
public var segment:Number = 0;
public var x:Integer;
public var scale:Number = 0.95;

  public override function create(): Node {
    return Group {

      var maxDisplayHeight:Number = height/2;

      content: [
        Rectangle {
          x: bind zoneWidth * startingMark / zoneSeconds;
          y: bind height/2 - scale * ((maxDisplayHeight) * segment/maxSegments)
          width: bind zoneWidth * seconds / zoneSeconds;
          height: bind scale * (maxDisplayHeight * segment/maxSegments)
          fill: bind aboveColor
          strokeWidth:0
        },
        Rectangle {
          x: bind zoneWidth * startingMark / zoneSeconds;
          y: bind height / 2
          width: bind zoneWidth * seconds / zoneSeconds;
          height: bind scale * (maxDisplayHeight - (maxDisplayHeight * segment/maxSegments))
          fill: bind belowColor
          strokeWidth:0
        }
      ]
      effect: Lighting {
        light: DistantLight { azimuth: 225 elevation: 60 }
        surfaceScale: 2
      }
    };
  }
}</pre>
<p>The <strong>TimeDisplayChart </strong>serves a couple of purposes. First it builds the overall dashboard element. This defines the usual display space, necessary labeling and element placements. Please note two aspects of this class: the group where its content is bound to the <strong>displayBlocks </strong>sequence and the second group composed of a solo <strong>TimeOnTaskBlock</strong>. By binding the content of a group to a data source, any changes in the data source will be made available to the group automatically. This effectively produces a self-updating display since we bound a displayable node. The second group which is a single instance of the <strong>TimeOnTaskBlock </strong>serves another purpose. It covers the span of time since the last data change and the current time. Since the data model stores only past events, we need a means of showing data yet to be stored. It&#8217;s real-time after all.</p>
<p>To place all of this into an application, an instance of <strong>TimeDisplayChart </strong>is placed into a group as follows:</p>
<pre>Group {
  translateY:310
  translateX:10
  content:[
    TimeDisplayChart{
      width:600
      height:100
      zoneSeconds:3600
      zoneWidth:600
      background:Color.#969696
      timer: bind timer
      displayTicker: bind displayTicker
      currentSegment: bind appState.currentSegment
      timeMark: bind appState.currentTimeMark
      onColor: bind appState.onColor
      offColor:bind appState.offColor
      displayBlocks: bind displayblocks
    }
  ]
}</pre>
<p>Here we can see the various attributes of the custom node being bound to different data sources and conditions that exit within the larger context of the application. The bindings create an active communication channel between application state data and the graphical elements. It&#8217;s convenient, responsive, and easy to manage during the development process.</p>
<p>You can find a wealth of information about JavaFX and what people are doing with this RIA technology over at <a href="http://learnjavafx.typepad.com/weblog/">Jim Weaver&#8217;s JavaFX blog</a> and of course at Sun&#8217;s <a href="http://javafx.com/">JavaFX</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.standardsco.com/wpmu/bjones/2008/12/20/a-brief-charting-example/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Sapphire in the Wild!</title>
		<link>http://blogs.standardsco.com/wpmu/bjones/2008/12/18/sapphire-in-the-wild/</link>
		<comments>http://blogs.standardsco.com/wpmu/bjones/2008/12/18/sapphire-in-the-wild/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 01:59:56 +0000</pubDate>
		<dc:creator>Ben Jones</dc:creator>
		
		<category><![CDATA[JavaFX]]></category>

		<guid isPermaLink="false">http://blogs.standardsco.com/wpmu/bjones/?p=18</guid>
		<description><![CDATA[Sapphire, the classroom observation tool, has hit the web for its public debut. Written in the newly released official JavaFX 1.0 from Sun Microsystems,  Sapphire brings advanced Rich Internet Application technology to educators focused on observing classrooms. The Community Edition which is available from our website was featured by the prominent JavaFX blogger and author [...]]]></description>
			<content:encoded><![CDATA[<p>Sapphire, the classroom observation tool, has hit the web for its public debut. Written in the newly released official JavaFX 1.0 from Sun Microsystems,  Sapphire brings advanced Rich Internet Application technology to educators focused on observing classrooms. The Community Edition which is available from our website was featured by the prominent JavaFX blogger and author Jim Weaver. Check out the JavaLobby posting at <a href="http://learnjavafx.typepad.com/weblog/2008/12/javafx-in-the-wild-sapphire-ce.html?intcmp=2223">JavaFX in the wild</a>.</p>
<p>Thank you Jim Weaver for your interests in our JavaFX endeavors.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.standardsco.com/wpmu/bjones/2008/12/18/sapphire-in-the-wild/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Behavioral Action Model - Part Three</title>
		<link>http://blogs.standardsco.com/wpmu/bjones/2008/03/01/behavioral-action-model-part-three/</link>
		<comments>http://blogs.standardsco.com/wpmu/bjones/2008/03/01/behavioral-action-model-part-three/#comments</comments>
		<pubDate>Sat, 01 Mar 2008 21:30:21 +0000</pubDate>
		<dc:creator>Ben Jones</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blogs.standardsco.com/wpmu/bjones/?p=14</guid>
		<description><![CDATA[In part two, the conceptual underpinnings of the behavioral action model were discussed. We took a simple function from part one and coaxed it into a class then encapsulated that class into an Object. A loader function on the body tag&#8217;s &#8220;onload&#8221; method would then do real work of binding elements to their respective functionality.
In [...]]]></description>
			<content:encoded><![CDATA[<p>In part two, the conceptual underpinnings of the behavioral action model were discussed. We took a simple function from part one and coaxed it into a class then encapsulated that class into an Object. A loader function on the body tag&#8217;s &#8220;<i>onload</i>&#8221; method would then do real work of binding elements to their respective functionality.</p>
<p>In this tutorial, we are going to gloss over that actual mechanics of how the loader operates except to say that it is keyed to CSS selectors. They are effectively the glue between the element, its action and the supporting functionality.</p>
<p>Let&#8217; start by resurrecting the simple page from part one:</p>
<pre>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;My Test&lt;/title&gt;
&lt;script type="text/javascript" src="link.js"&gt;&lt;/script&gt;
&lt;link rel="stylesheet" type="text/css" href="goLink.css"/&gt;
&lt;/head&gt;
&lt;body onload="link();"&gt;

    &lt;button class="goLink" id="mybutton"&gt;My Page&lt;/button&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>First, we need to modify this page slightly. Instead of loading the Link class directly, we are going to use a loader class, namely &#8220;<strong>Behaviour</strong>&#8220;. This class has a few methods available, of which, we are most interested in the &#8220;<i>apply</i>&#8221; and &#8220;<i>register</i>&#8221; methods. The &#8220;<i>register</i>&#8221; method simply informs the Behaviour script of an Object that contains an action; while the &#8220;<i>apply</i>&#8221; method performs the necessary parsing and binding between our &#8220;<strong>bam_classes</strong>&#8221; Object and the page&#8217;s DOM.</p>
<p>Since these file are external files, includes are necessary which brings up a couple of important issues, nomenclature and file organization. Regardless of your preferences, be very consistent and well organized. In this tutorial, I will place scripts and css into their own directories. With that in mind, we are ready to make some modifications. First, the web page code needs to include the &#8220;<strong>Behaviour</strong>&#8221; class and our &#8220;<strong>bam_classes</strong>&#8221; class which can be found in the &#8220;bam.js&#8221; file.</p>
<pre>
&lt;script type="text/javascript" src="scripts/js/lib/behaviour.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="scripts/js/actions/bam.js"&gt;&lt;/script&gt;
</pre>
<p>An important browser note here, be sure to use the full tag notation for these types of includes instead of the self-closing notation.  Some, not mentioned here, browsers continue to have quirky support for this notation when applied to includes.</p>
<p>Next we need to use the &#8220;<i>apply</i>&#8221; method of the <strong>Behaviour</strong> class as our loader in the body&#8217;s &#8220;<strong>onload</strong>&#8221; method:</p>
<pre>
&lt;body onload="Behaviour.apply();"&gt;
</pre>
<p>While we&#8217;re making modification to the page, let&#8217;s move the css into its own directory as well. With all of this finished, the original page now looks like the following:</p>
<pre>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;My Test&lt;/title&gt;
&lt;script type="text/javascript" src="scripts/js/lib/behaviour.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="scripts/js/actions/bam.js"&gt;&lt;/script&gt;
&lt;link rel="stylesheet" type="text/css" href="css/bam.css"/&gt;
&lt;/head&gt;
&lt;body onload="Behaviour.apply();

    &lt;button class="goLink" id="mybutton"&gt;My Page&lt;/button&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Our next modification is the creation of the &#8220;bam.js&#8221; which is essentially our &#8220;bam_classes&#8221; Object from part two saved as a file. However, there is an important addition, the inclusion of a call to the &#8220;<i>register</i>&#8221; method from the &#8220;<strong>Behaviour</strong>&#8221; class. This call makes our object known to any calls to the &#8220;<i>apply</i>&#8221; method.</p>
<p>For brevity sake, here is the &#8220;bam.js&#8221; file as it now stands.</p>
<pre>
var bam_classes =
{
	'button.goLink #mybutton' : function(element)
	{
		element.onclick     = function() { };
		element.onmouseover = function() { };
		element.onmouseout  = function() { };
	}
};

Behaviour.register(bam_classes);
</pre>
<p>Before you cry foul and tell me that it&#8217;s not exactly like part two&#8217;s &#8220;bam_classes&#8221;, let me agree. I have good reasons for     stripping out the code from the onclick method and space padding the id token used in the key. In its current state, the &#8220;<strong>Behaviour</strong>&#8221; class has a parser flaw that is unable to resolve an id delimiter (#) that has no preceding space which is part of a larger css selector; namely &#8220;tag.class#id&#8217; needs to be &#8216;tag.class  #id&#8217; instead). A minor inconvenience, but one that needs some attention.</p>
<p>Digressing briefly, I need to discuss the &#8220;<strong>bam_class</strong>&#8220;, or more specifically - action files. Action files  contain the &#8220;binding action to our functionality&#8221;. Therefore, the container Object should be as clean and simple as possible.  It is very tempting to pour all the actual functionality code into the various methods within a class. However, it is not required to have the code reside here and in my experience a mistake to do so. Consider the Object as a holder for prototypes of functions defined elsewhere. This helps clear the clutter and confusion of mixing control code with execution code.</p>
<p>So where do I place the code? You have two choices really, in the same file as the Object (but not in the Object) or as an external file or files. For simple applications where the functionality will only be used with the action file, then in the same file is really convenient. If you plan to have a library of functions that exists and are usable independent of the behavior actions, then store the code outside the action file. Again, this is purely dependent upon you personal preferences of course.</p>
<p>For these considerations, I stripped out the code from within the methods in preparation of placing it into an outside<br />
declaration, in effect &#8220;stubbing&#8221; the prototype. Using the onlick method from our Link class, we now have:</p>
<pre>
element.onclick = function()  	{ do_click(this);  };
</pre>
<p>Fundamentally, the &#8220;do_click(this)&#8221; is just a function that takes an argument. The function can be placed anywhere really, we&#8217;ll place in the action file. There is now an argument &#8220;<em>this</em>&#8221; which is a Javascript reserved  word. It is similar to other object oriented languages and provides a self contained reference to the current Object, in our case, the Object reference that created the event to which our action is attached. My digression has ended for the moment and I should demonstrate what the action file &#8220;bam.js&#8221; contains.</p>
<pre>
var bam_classes =
{
	'button.goLink #mybutton' : function(element)
	{
		element.onclick = function()  	{ do_click(this); };
		element.onmouseover = function()  { do_mouseOver(this); };
		element.onmouseout = function()  { do_mouseOut(this);  };
	}
};

Behaviour.register(bam_classes);

/** Supporting function definition **/
function do_click(reference)
{
	alert('The button was pressed");
}

function do_mouseOver(reference)
{
	// nothing yet
}

function do_mouseOut(reference)
{
	// nothing yet
}
</pre>
<p>With the actual method code pulled out into their own definitions, we are free to code up whatever we need without entangling the control logic. You have virtually complete freedom to manipulate the DOM, do client-side validations, make Ajax calls, or whatever needs to be accomplished.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.standardsco.com/wpmu/bjones/2008/03/01/behavioral-action-model-part-three/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Beahvioral Action Model- Part Two</title>
		<link>http://blogs.standardsco.com/wpmu/bjones/2008/02/15/beahvioral-action-model-part-two/</link>
		<comments>http://blogs.standardsco.com/wpmu/bjones/2008/02/15/beahvioral-action-model-part-two/#comments</comments>
		<pubDate>Fri, 15 Feb 2008 16:42:23 +0000</pubDate>
		<dc:creator>Ben Jones</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blogs.standardsco.com/wpmu/bjones/?p=11</guid>
		<description><![CDATA[In Part One, we built a very simple page with a single button that made use of some Behavioral Action Model techniques. From part one, we had the following function that provided the muscle for our button:

function link()
{
  var btn     = document.getElementById("mybutton");
  btn.onclick = function() { self.location = 'mypage.html'; [...]]]></description>
			<content:encoded><![CDATA[<p>In Part One, we built a very simple page with a single button that made use of some Behavioral Action Model techniques. From part one, we had the following function that provided the muscle for our button:</p>
<pre>
function link()
{
  var btn     = document.getElementById("mybutton");
  btn.onclick = function() { self.location = 'mypage.html'; }
}
</pre>
<p>This function was made available to the document by means of the body tag&#8217;s &#8220;<strong>onload</strong>&#8221; method. This works just fine for a few functions but breaks down rather quickly when the complexity begins to rise. Fear not though, the mechanism still applies. With a little coaxing and a touch JavaScript&#8217;s flexibility, we can continue undaunted.</p>
<p>For starters, it would more convenient if we didn&#8217;t need to actually create a &#8220;<i>btn</i>&#8221; reference from within the function. Something more like the following perhaps:</p>
<pre>
function link()
{
  btn.onclick = function() { self.location = 'mypage.html'; }
}
</pre>
<p>We could then pass the &#8220;<i>btn</i>&#8221; reference in as an argument of the function:</p>
<pre>
function link(btn)
{
  btn.onclick = function() { self.location = 'mypage.html'; }
}
</pre>
<p>To make all of this a bit more &#8220;generic&#8221;, let&#8217;s replace the &#8220;<i>btn</i>&#8221; name for something less specific, like &#8220;element&#8221;.<br />
Rewriting the above function with our substitution yields the following.</p>
<pre>
function link(element)
{
  element.onclick = function() { self.location = 'mypage.html'; }
}
</pre>
<p>At this point, we have returned to something extremely similar to our original &#8220;<i>goto</i>&#8221; function from part one:</p>
<pre>
function goto(url) { self.location = url; }
</pre>
<p>Although these two are similar, there are some major differences. While the latter &#8220;<i>goto</i>&#8220;, function is just that, a function. The former &#8220;<i>link</i>&#8221; function has evolved into JavaScript&#8217;s version of a class. This classifying, if you&#8217;ll pardon the expression, has created a class Link that contains an &#8220;<strong>onclick</strong>&#8221; method. We can add additional methods as well.</p>
<pre>
function Link(element)
{
  element.onclick     = function() { self.location = 'mypage.html'; };
  element.onmouseover = function() { };
  element.onmouseout  = function() { };
}
</pre>
<p>The Link class now has some extra muscle that be applied to the element under differing contexts. It can now respond to &#8220;<strong>click</strong>&#8220;,  &#8220;<strong>mouseover</strong>&#8220;, and  &#8220;<strong>mouseout</strong>&#8221; events. This is fine, but how do we make use of this improved link function? </p>
<p>In part one, we used the onload method to install the script that directly bound itself to the element. This time we will inject a little abstraction into the mixture giving us a lot more flexibility. Instead of loading &#8220;<strong>Link</strong>&#8221; class directly, we&#8217;ll install a loader function that will in turn load this class.  We still have an issue with the <strong>&#8220;Link</strong>&#8221; class itself. It is not directly bound to an element as it was originally, but rather accepts a reference to one instead. So, how do we tie our class to the desired element or elements?</p>
<p>In JavaScript, classes are Objects and can be thus be members of other Objects. We can in fact store our &#8220;<strong>Link</strong>&#8221; class with all its methods within another Object, like an array. This would give us the ability to<br />
store many other classes; Luckily, JavaScript offers us not only an array but also an associative array (otherwise known as maps, or hashes).  Why is this so lucky you ask? </p>
<p>Associative arrays are special in that the array stores data as key-value pairs where the key is literally the means to access the value. This is ideal for our purposes since the key can be a text string instead of a numerical index. Let&#8217;s use the &#8220;<strong>Link</strong>&#8221; class to illustrate this point.</p>
<pre>
function Link(element)
{
  element.onclick     = function() { self.location = 'mypage.html'; };
  element.onmouseover = function() { };
  element.onmouseout  = function() { };
}
</pre>
<p>If we extract the class name to use as the key, namely &#8220;Link&#8221;. Then the contents of the class become the matching value. Since the key is text, it has been set into single quotes.</p>
<pre>
'Link' : function (element)
{
  element.onclick     = function() { self.location = 'mypage.html'; };
  element.onmouseover = function() { };
  element.onmouseout  = function() { };
}
</pre>
<p>The colon denotes an associative pair. The text string on the left is the key; while, the remaining class definition becomes the value on the right hand side. Now that our class has been converted into a key-value pair, it needs to be added to a container Object. We&#8217;ll name our Object &#8220;<strong>bam_classes</strong>&#8221; and make the assignment as follows:</p>
<pre>
var bam_classes =
{
'Link' : function (element)
{
  element.onclick     = function() { self.location = 'mypage.html'; };
  element.onmouseover = function() { };
  element.onmouseout  = function() { };
}
};
</pre>
<p>Having our class definition stored as a value tied to its function name as the key further adds a subtle layer of abstraction. Remember that the name is a text string and thus could be any string and not necessarily a traditional function or class name, like &#8220;myFunc&#8221; or &#8220;accountsPayable&#8221;. Pulling a quote from part One, …&#8221;any valid element tag, class,<br />
attribute, or combination thereof can be used&#8221; brings us to an important juncture.</p>
<p>In part one, our button element was styled with the class &#8220;<i>goLink</i>&#8221; and had and id attribute of &#8220;<i>mybutton</i>&#8220;. There is no reason why we can&#8217;t use this information as the key for our class definition that is stored in the &#8220;<strong>bam_classes</strong>&#8221; Object. Fortunately, CSS provides a convenient nomenclature for just this case: </p>
<pre>
var bam_classes =
{
'button.goLink#mybutton' : function (element)
{
  element.onclick     = function() { self.location = 'mypage.html'; };
  element.onmouseover = function() { };
  element.onmouseout  = function() { };
}
};
</pre>
<p>Having the ability to use CSS selectors as the key for stored classes is a major step forward in both expressive power and the extraction of control and logic code from presentation code. We can now tie functionality to elements as broadly as all <strong>buttons</strong>, or as discretely as <strong>button</strong> of &#8220;<i>some_class</i>&#8221; that has an id of &#8220;<i>some_id</i>&#8220;</p>
<p>Finally, we have reached the point where we jump back to the loader function that is being called in the body&#8217;s &#8220;<strong>onload</strong>&#8221; method. The purpose of the loader class is to attach all our functionality encapsulated in the <strong>bam_classes</strong> Object to their corresponding elements. The loader extracts the keys from the <strong>bam_classes</strong> Object then parses through the DOM elements within the document looking for matches.  Each matched element becomes a reference that is used by the attached function.</p>
<p><strong><em>{end part two}</em></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.standardsco.com/wpmu/bjones/2008/02/15/beahvioral-action-model-part-two/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Behavioral Action Model - Part One</title>
		<link>http://blogs.standardsco.com/wpmu/bjones/2008/02/03/behavioral-action-model/</link>
		<comments>http://blogs.standardsco.com/wpmu/bjones/2008/02/03/behavioral-action-model/#comments</comments>
		<pubDate>Sun, 03 Feb 2008 19:23:10 +0000</pubDate>
		<dc:creator>Ben Jones</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blogs.standardsco.com/wpmu/bjones/?p=3</guid>
		<description><![CDATA[This is a brief tutorial on using the behavioral action model. Fundamentally, this is just a clean separation between HTML and Javascript scripting that relies on Javascript&#8217;s ability to modify the DOM. In essence, we are attaching Javascript functions to events on DOM elements using CSS as an identification system.
Let&#8217;s start with a simple button [...]]]></description>
			<content:encoded><![CDATA[<p>This is a brief tutorial on using the behavioral action model. Fundamentally, this is just a clean separation between HTML and Javascript scripting that relies on Javascript&#8217;s ability to modify the DOM. In essence, we are attaching Javascript functions to events on DOM elements using CSS as an identification system.</p>
<p>Let&#8217;s start with a simple button element that will link us to another page:</p>
<pre>&lt;button onclick="javascript:location='mypage.html'"&gt;My Page&lt;/button&gt;</pre>
<p>Nothing fancy, a very basic button that gets the job done with no styling. Now create a basic style for the button that gives us a font of choice and a size of 20 pixels.</p>
<pre>.goLink { font-family:Verdana; font-size:20px; }</pre>
<p>There, a basic style. Now let&#8217;s apply that style to our button:</p>
<pre>&lt;button class="goLink" onclick="javascript:location='mypage.html'"&gt;My Page&lt;/button&gt;</pre>
<p>Again, this is nothing fancy, just a basic button and an applied style. From this point, things begin to diverge.<br />
What we intend to happen is that when the button is &#8220;<strong>clicked</strong>&#8221; we jump to the link provided.<br />
Since our goal is to pull out the javascript, let&#8217;s start by cleaning up the button a bit into<br />
something a little more concise.</p>
<pre>&lt;button onclick="goto('mypage.html');'"&gt;My Page&lt;/button&gt;</pre>
<p>This is a little cleaner, but now requires a supporting Javascript function like below:</p>
<pre>
function goto(url)
{
  self.location = url;
}
</pre>
<p>We now have a Javascript function that actually does the work when its called from within the<br />
button by the &#8220;<strong>onclick</strong>&#8220;. But we still have Javascript in our button! Yes, but not for long.<br />
Lets rewrite the button again and this time pull out the &#8220;<strong>onclick</strong>&#8221; event entirely.</p>
<pre>&lt;button class="goLink"&gt;My Page&lt;/button&gt;</pre>
<p>There, a really minimal button indeed. Unfortunately, our button no longer jumps to the page when clicked.<br />
To fix this, we need to re-attach that &#8220;<em>goto</em>&#8221; function to the button without embedding it back into<br />
the button. Using Javascript we can grab the element in question with a &#8220;<strong>getElementById</strong>&#8221; call<br />
but we don&#8217;t have an &#8220;<em>id</em>&#8221; attribute on that button. So let&#8217;s add one:</p>
<pre>&lt;button class="goLink" id="mybutton"&gt;My Page&lt;/button&gt;</pre>
<p>Now we can do something like this:</p>
<pre>var btn = document.getElementById("mybutton");</pre>
<p>Doing this gives us a Javascript object that is referenced to the button element. We now have a means<br />
by which to re-attach our &#8220;<em>goto</em>&#8221; function. This looks a little like the following:</p>
<pre>btn.onclick = goto;</pre>
<p>That statement literally adds an &#8220;<strong>onclick</strong>&#8221; method onto our object &#8220;<em>btn</em>&#8221; and<br />
assigns it to a function called &#8220;<em>goto</em>&#8220;.<br />
So, we&#8217;re getting closer by the moment. What we need to do now is package all this up a little neater and make<br />
it accessible to the browser. In fact, we could even define the &#8220;<em>goto</em>&#8221; function within this little<br />
package making everything even more concise.</p>
<pre>
function link()
{
  var btn     = document.getElementById("mybutton");
  btn.onclick = function() { self.location = 'mypage.html'; }
}
</pre>
<p>To activate this link function, we need to use the &#8220;<strong>onload</strong>&#8221; method of the body element.</p>
<pre>&lt;body onload="link();"&gt;</pre>
<p>By using the &#8220;<strong>onload</strong>&#8221; we&#8217;re telling the browser to load up the functionality found in our &#8220;<em>link</em>&#8221;<br />
function and this would in turn make our button do its intended business. So what does this really look like in practice.<br />
Let&#8217;s look at a little page that uses this technique.</p>
<pre>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;My Test&lt;/title&gt;
&lt;style&gt;
   .goLink { font-family:Verdana; font-size:20px; }
&lt;/style&gt;
&lt;script&gt;
function link()
{
  var btn     = document.getElementById("mybutton");
  btn.onclick = function() { self.location = 'mypage.html'; }
}
&lt;/script&gt;

&lt;body onload="link();"&gt;

&lt;button class="goLink" id="mybutton"&gt;My Page&lt;/button&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>We should now pull out the CSS definitions and all the Javascript from the HTML file and place<br />
them into their own external files much like the following rewrite of the page:</p>
<pre>
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;My Test&lt;/title&gt;

&lt;script type="text/javascript" src="link.js"&gt;&lt;/script&gt;
&lt;link rel="stylesheet" type="text/css" href="goLink.css"/&gt;
&lt;/head&gt;

&lt;body onload="link();"&gt;

&lt;button class="goLink" id="mybutton"&gt;My Page&lt;/button&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>By doing this, we have very tight and clean HTML and likewise concise supporting files for<br />
both the CSS and the Javascript.</p>
<p>Now comes the next step, ramping up the possibilities. We are not limited to using only id<br />
attributes to attach functionality, any valid element tag, class, attribute, or combination<br />
thereof can be used for this purpose. Using CSS notation, we could have attached our &#8220;<em>goto</em>&#8221;<br />
function more specifically to the button using something like &#8216;button.goLink#mybutton&#8217;.<br />
Our link function would have to be rewritten to look for buttons, then for those buttons<br />
of class &#8220;<em>goLink</em>&#8221; which then have an id attribute of &#8220;<em>mybutton</em>&#8220;.<br />
While this might seem a bit much, it is extremely useful and very practical.</p>
<p>This is where a nice little Javascript library comes into play, called &#8220;Behaviour&#8221;, that<br />
allows us to chain together our definitions into a single<br />
Javascript object and then apply those definitions to the entire DOM with a single call.<br />
Nice. Very nice indeed.</p>
<p><strong><em>{end part one}</em></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.standardsco.com/wpmu/bjones/2008/02/03/behavioral-action-model/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

