<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>mxshrestha &#187; extending container in javafx</title>
	<atom:link href="http://mxshrestha.wordpress.com/tag/extending-container-in-javafx/feed/" rel="self" type="application/rss+xml" />
	<link>http://mxshrestha.wordpress.com</link>
	<description>Just another WordPress.com site</description>
	<lastBuildDate>Sun, 03 Jul 2011 14:53:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mxshrestha.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>mxshrestha &#187; extending container in javafx</title>
		<link>http://mxshrestha.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://mxshrestha.wordpress.com/osd.xml" title="mxshrestha" />
	<atom:link rel='hub' href='http://mxshrestha.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Why use Custom Node and Container?</title>
		<link>http://mxshrestha.wordpress.com/2011/04/13/why-use-custom-node-and-container/</link>
		<comments>http://mxshrestha.wordpress.com/2011/04/13/why-use-custom-node-and-container/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 04:24:51 +0000</pubDate>
		<dc:creator>mxshrestha</dc:creator>
				<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[container]]></category>
		<category><![CDATA[customnode]]></category>
		<category><![CDATA[extending container in javafx]]></category>
		<category><![CDATA[extending custom node in JavaFx]]></category>
		<category><![CDATA[javafx container]]></category>
		<category><![CDATA[javaFx container custom node]]></category>
		<category><![CDATA[JavaFX customNode]]></category>
		<category><![CDATA[JavaFX extending Container]]></category>
		<category><![CDATA[JavaFX extending custom node]]></category>

		<guid isPermaLink="false">http://mxshrestha.wordpress.com/?p=78</guid>
		<description><![CDATA[JavaFx has many predefined nodes and layout containers made readily available for use. Also, JavaFx provides the facility to extend custom node to create user defined node and container to create user defined layout.  Predefined nodes like imageview, rectangle, circle, groups, HBox, VBox, e.t.c are great and easy to use and provides lot of flexibility [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mxshrestha.wordpress.com&#038;blog=19635110&#038;post=78&#038;subd=mxshrestha&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>JavaFx has many predefined nodes and layout containers made readily  available for use. Also, JavaFx provides the facility to extend custom  node to create user defined node and container to create user defined  layout.  Predefined nodes like imageview, rectangle, circle, groups,  HBox, VBox, e.t.c are great and easy to use and provides lot of  flexibility with predefined functions for the nodes. So, when to create a  user defined node or user defined container?</p>
<p>Creating a user defined node by extending custom node allows user to  add more flexibility and customization on a node.Consider a group node  which has a rectangle node and a ImageView node centered within the  rectangle. Now, lets say we have five such group nodes within a VBox  node and the visibility of rectangle on all group within the VBox is set  to false. Now using the functions defined for VBox, we can easily  select each group node within it and request focus for each group node  but it would be very tedious or impossible to turn the visibility of  rectangle inside the group to true. This is where extending custom node  comes to play. We can create a custom node with the group and rectangle  and the VBox with the group and rectangle within it. Now in the custom  node we can define a function which can turn the visibility of rectangle  to true and false. Now using this custom node instead of just the VBox  that we used  earlier, we can set the visibility of rectangle to true or  false at any point or any where in the code.</p>
<p>Similarly a user  defined container by extending container class allows user to add more  flexibility and customization for laying out nodes. Using predefined  layout containers like HBox, Tiles, VBox, e.t.c it is possible to create  attractive and interesting layouts but the layouts are constrained.  Lets say we want to develop an image gallery such that the first row  displays one image, second row displays two image, third row displays  three image and so on.  It is possible to create such image gallery  using HBox, Tiles, or VBox but the code would look nasty and would be  tedious to do so. However, by extending a container and creating a  custom layout we can do so easily using the positionNode() and  layoutNode() methods provided. We can easily use a for loop and within  it use the positionNode() function to position the images. Also, for  resizable nodes we can resize the nodes within the container.</p>
<p>From  my perspective, extending customNode and container provides great  flexibility and customization,but it is always good to use predefined  nodes unless creating custom node or container is really required. It  keeps the code simple and manageable. While extending custom Node or  container, it is always required to override the create() function and  the doLayout() function respectively.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mxshrestha.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mxshrestha.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mxshrestha.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mxshrestha.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mxshrestha.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mxshrestha.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mxshrestha.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mxshrestha.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mxshrestha.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mxshrestha.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mxshrestha.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mxshrestha.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mxshrestha.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mxshrestha.wordpress.com/78/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mxshrestha.wordpress.com&#038;blog=19635110&#038;post=78&#038;subd=mxshrestha&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mxshrestha.wordpress.com/2011/04/13/why-use-custom-node-and-container/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1f4ea083984734d1b9e5fa748d25bfdb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mxshrestha</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating a node using javafx.scene.layout.Container</title>
		<link>http://mxshrestha.wordpress.com/2011/02/16/creating-a-node-using-javafx-scene-layout-container/</link>
		<comments>http://mxshrestha.wordpress.com/2011/02/16/creating-a-node-using-javafx-scene-layout-container/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 01:09:53 +0000</pubDate>
		<dc:creator>mxshrestha</dc:creator>
				<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[container in javafx]]></category>
		<category><![CDATA[extending container in javafx]]></category>
		<category><![CDATA[javafx container]]></category>
		<category><![CDATA[javafx.scene.layout.container]]></category>

		<guid isPermaLink="false">http://mxshrestha.wordpress.com/?p=24</guid>
		<description><![CDATA[Containers can be extended to create a custom node. Extending a container helps manage and position multiple nodes. The subclass extending the Container must override the function doLayout() of the class Container. Containers provide methods to position and specify the sizes of the node. The subclass extending the container should also override the getPrefWidth and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mxshrestha.wordpress.com&#038;blog=19635110&#038;post=24&#038;subd=mxshrestha&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Containers can be extended to create a custom node. Extending a container helps manage and position multiple nodes. The subclass extending the Container must override the function doLayout() of the class Container. Containers provide methods to position and specify the sizes of the node. The subclass extending the container should also override the getPrefWidth and getPrefHeight methods to make sure the layout is resized correctly. Functions  provided by Container class to handle position and sizes of the node are:</p>
<ul>
<li><code>getManaged(content:Node[]):Node[]</code></li>
<li><code>resizeNode(node:Node, width:Number, height:Number):Boolean</code></li>
<li><code>positionNode(node:Node, x:Number, y:Number):Void</code></li>
<li><code>layoutNode(node:Node, x:Number, y:Number, width:Number, height:Number):Boolean</code></li>
</ul>
<p>A simple example of creating a wall of thumbnail extending container class is:</p>
<p><pre class="brush: javafx;">

import javafx.scene.layout.Container;

public class ThumbNailContainer extends Container
{
package var imageList: String[];
package var thumbNails: ThumbNails[]; //ThumbNails is a class that
                                         //creates a thumbnail of the image.

    package function generateThumbs():Void
    {

        thumbNails = for (images in imageList)
                    {
                       ThumbNails
                       {
                          imgUrl:images;
                       }
                    }
    }

//doLayout() function overridden to create own custom layout.
 override function doLayout():Void
 {
    var x = 0;
    var y = 0;
    var temp = 0;

    generateThumbs();

    for (images in thumbNails)
    {

       setNodeWidth(images, 100);//sets the width of the node.
                                //In this case the thumbnails are the node.
       setNodeHeight(images, 100);//sets the height of the node.
                                 //In this case the thumbnails are the node
      if (x &lt; 600)
      {
          positionNode(images, x += temp, y); //positions the node
          temp = 110;
      }
      else
      {
         x = 0;
         temp = 0;
         y += 110;
      }
 }

 content = thumbNails;//sets the content as the sequeces of thumbnails
 }


</pre></p>
<p>More info: <a href="http://download.oracle.com/docs/cd/E17802_01/javafx/javafx/1.3/docs/api/javafx.scene.layout/javafx.scene.layout.Container.html" rel="nofollow">http://download.oracle.com/docs/cd/E17802_01/javafx/javafx/1.3/docs/api/javafx.scene.layout/javafx.scene.layout.Container.html</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mxshrestha.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mxshrestha.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mxshrestha.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mxshrestha.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mxshrestha.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mxshrestha.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mxshrestha.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mxshrestha.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mxshrestha.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mxshrestha.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mxshrestha.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mxshrestha.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mxshrestha.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mxshrestha.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mxshrestha.wordpress.com&#038;blog=19635110&#038;post=24&#038;subd=mxshrestha&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mxshrestha.wordpress.com/2011/02/16/creating-a-node-using-javafx-scene-layout-container/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1f4ea083984734d1b9e5fa748d25bfdb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mxshrestha</media:title>
		</media:content>
	</item>
	</channel>
</rss>
