<?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>JH on Java</title>
	<atom:link href="http://www.jhkuperus.nl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jhkuperus.nl</link>
	<description>Random Ramblings of an Engineer</description>
	<lastBuildDate>Thu, 10 Nov 2011 19:39:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>And now for something completely different &#8230;</title>
		<link>http://www.jhkuperus.nl/articles/personal/and-now-for-something-completely-different/</link>
		<comments>http://www.jhkuperus.nl/articles/personal/and-now-for-something-completely-different/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 22:04:22 +0000</pubDate>
		<dc:creator>Jan-Hendrik Kuperus</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[magic]]></category>
		<category><![CDATA[magic the gathering]]></category>
		<category><![CDATA[mtg]]></category>
		<category><![CDATA[trading cards]]></category>

		<guid isPermaLink="false">http://www.jhkuperus.nl/?p=247</guid>
		<description><![CDATA[It&#8217;s &#8230; time to sell some Magic the Gathering cards. Say what now? Yep, really, I&#8217;m selling my entire collection of Magic the Gathering cards. I even dedicated a new page on this website to it, go ahead and click &#8216;Magic&#8217; in the top navigation bar. That page will contain the most up-to-date information about [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s &#8230; time to sell some <em>Magic the Gathering</em> cards. Say what now? Yep, really, I&#8217;m selling my entire collection of <em>Magic the Gathering</em> cards. I even dedicated a new page on this website to it, go ahead and click &#8216;Magic&#8217; in the top navigation bar. That page will contain the most up-to-date information about my collection. </p>
<p>So why the heck am I selling it? Well, it has been years since I played the game. It was a nice game to play with fellow students at the University and it was always a very good feeling to open up a new pack of cards and discover the new treasure. I remember the crisp sound of a fresh boosterpack being opened. There is still some tingling left when I browse my collection, but still it is time to give it up.</p>
<p>Collecting and playing Magic can take up the same amount of time as a full time job, or even more. I no longer have that kind of time on my hands, since I am working as a freelance Java Specialist. This job requires me to put a lot of time and energy in developing my network, my name and of course my expertise. Combine that with a very nice girlfriend and a social life and there is no more time left for Magic. After many months of doubt, I finally decided to sell the whole lot.</p>
<p>If you are interested, drop me a message, either as a reply or through the <a href="/contact">Contact page</a>. Be sure to keep an eye on the <a href="/magic">Magic page</a>, since I will update it with more details about my collection.</p>
<p>&#8211;JH</p>
<p>PS: The next post will again be on software development, I promise <img src='http://www.jhkuperus.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.jhkuperus.nl/articles/personal/and-now-for-something-completely-different/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GWT: Dynamically Changing CSS Styles</title>
		<link>http://www.jhkuperus.nl/articles/java/gwt-dynamically-changing-css-styles/</link>
		<comments>http://www.jhkuperus.nl/articles/java/gwt-dynamically-changing-css-styles/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 07:42:36 +0000</pubDate>
		<dc:creator>Jan-Hendrik Kuperus</dc:creator>
				<category><![CDATA[GWT]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.jhkuperus.nl/?p=201</guid>
		<description><![CDATA[Are you building a Google Web Toolkit application? Has someone asked you to personalize colors or images for their account? If so, you may have tried to look for things like dynamic CSS in GWT as well. While Googling these terms, I could not find what I needed. After some more Googling and reading some [...]]]></description>
			<content:encoded><![CDATA[<p>Are you building a Google Web Toolkit application? Has someone asked you to personalize colors or images for their account? If so, you may have tried to look for things like dynamic CSS in GWT as well. While Googling these terms, I could not find what I needed. After some more Googling and reading some not so helpful posts, I found a project titled <a href="http://advanced-gwt.sourceforge.net/">Advanced GWT Components</a>.</p>
<p>This project has a set of widgets which support switching themes at runtime. That was exactly what I was looking for, but I had no need for the widgets. So I picked the project apart and adapted the way it changes CSS on runtime to fit our application. In this post I will take you through the pieces of code we used to complete this. <strong>Note:</strong> this is going to be quite a long and code heavy post ^_^</p>
<p><span id="more-201"></span></p>
<p>We&#8217;ve got the following:</p>
<ul>
<li>GWT views with UIBinder</li>
<li>Default styling in CSS</li>
<li>Only a few things which are customizable in the application (mostly colors)</li>
<li>A preference page which allows users to change these colors</li>
<li>A servlet that generates CSS based on the settings</li>
</ul>
<p>The (highly simplified) diagram below shows the main components and their interactions. Basically what happens is the user performs some action in the GWT Client that changes something like a color setting. This causes the client to send the update over RPC to the server. After a successful store, an event is triggered inside the GWT client that this setting has been altered. Some listener picks up the event and changes the CSS reference. This change forces the browser to load the &#8216;new&#8217; CSS file from the server. The server then generates this CSS file based on the settings. By now the circle is round and the updated CSS is loaded and applied.</p>
<p><img src="http://www.jhkuperus.nl/wp-content/uploads/2011/06/Screen-shot-2011-06-16-at-16.42.24.png" alt="Diagram of GWT Client/Server interaction for dynamic CSS" title="GWT/CSS Interaction" width="523" height="248" class="aligncenter size-full wp-image-209" /></p>
<p>I&#8217;m not going to talk about the Settings page and the RPC call as these are just standard GWT. You can simply incorporate the following parts into your GWT application and fire the SettingChangedEvent (or any other event) and change the CSS to reload it.</p>
<h1>Coding Time!</h1>
<p>Let&#8217;s introduce some pieces of code we have here. Our settings backend stores settings with a String key and fires off events of changes in settings to the GWT client. The Event triggered to notify the application of these changes looks like this:</p>
<pre class="brush:java">
/**
 * An Event of this type indicates one of the settings has been changed.
 *
 * @author J.H. Kuperus
 */
public class SettingChangedEvent extends GwtEvent&lt;SettingChangedEvent.Handler&gt; {

  /** Handler interface for the {@link SettingChangedEvent}. */
  public interface Handler extends EventHandler {
    void onSettingChanged(SettingChangedEvent event);
  }

  private String propertyName;

  public SettingChangedEvent(String propertyName) {
    this.propertyName = propertyName;
  }

  public String getPropertyName() {
    return propertyName;
  }

  // --- Boilerplate code for GWTEvents

  // ...
}
</pre>
<p>It simply passes the name of the changed setting around. This is what we respond to on the client side to change the CSS. If it is any property that is part of the dynamic CSS, we change the URL of the referenced CSS document, causing it to be reloaded by the browser. The piece of code that handles the event looks like this:</p>
<pre class="brush:java">
public class ColorChangeListener implements SettingChangedEvent.Handler {

  @Inject
  public ColorChangeListener(EventBus eventBus) {
    eventBus.addHandler(SettingChangedEvent.TYPE, this);
  }

  public void onSettingChanged(SettingChangedEvent event) {
    if (event.getPropertyName().startsWith("core.color")) {
      // If the color has changed, force a reload on the CSS
      ThemeUtil.setLinkHref("themeCssElement", "/activeTheme.css"
          + "?v=" + System.currentTimeMillis());
    }
  }
}
</pre>
<p>The listener implements the event&#8217;s Handler interface and registers itself to the EventBus. Note that we are using GIT injection to resolve these dependencies. If you obtain your EventBus in a different fashion, adjust your code accordingly.</p>
<p>The parameter added to the URL of the CSS-file is purely bogus, but prevents any proxy or browser from caching the file. The TemeUtil.setLinkHref is the piece of code I borrowed from the Advanced GWT Components library and looks like this:</p>
<pre class="brush:java">
public class ThemeUtil {
  public static native void setLinkHref(String linkElementId, String url) /*-{
    var link = $doc.getElementById(linkElementId);
    if (link != null &#038;&#038; link != undefined) {
      link.href = url;
    }
  }-*/;
}
</pre>
<p>The setLinkHref method is a native piece of JavaScript that tries to find the element identified by the linkElementId and sets its href property to the specified URL. In order for all of this to work, you must also include your dynamic CSS in your main HTML file. We simply added the following to the &lt;head&gt; section:</p>
<pre class="brush:html">
<link type="text/css" rel="stylesheet" href="/activeTheme.css?v=1" id="themeCssElement"/>
</pre>
<p>Alright, that&#8217;s all the client code required for this work. Now let&#8217;s hop over to the last piece we need to build: the CSS servlet. This servlet basically just extends the HttpServlet class and implements the service() method to write a standard CSS file. In our app, we use a class called ServerSettings to retrieve the stored colors from the Datastore. Adapt this to your situation as needed:</p>
<pre class="brush:java">
public class CssThemeServlet extends BaseServlet {

  @Inject
  private ServerSettings settings;

  @Override
  protected void service(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    res.setContentType("text/css");
    PrintWriter writer = res.getWriter();

    StringValue coreColor1Setting = settings.getStringSetting("core.color1");
    StringValue coreColor2Setting = settings.getStringSetting("core.color2");

    writer.println(".themedGradientBackground {");
    writer.println("    background-image: -moz-linear-gradient(top, "
      + colorStop1 + ", " + colorStop2 + ");");
    writer.println("    background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, "
      + colorStop1 + "), color-stop(1, " + colorStop2 + "));");
    writer.println("}");
  }
}
</pre>
<p>You can write any CSS you want here, however, writing it with println-statements will get crazy fast. So think about a using a template engine, or putting it in a JSP. We are probably going for Velocity.</p>
<p>The last step to make all of this work, is to serve the URL used above (/activeTheme.css) with the CssThemeServlet. You either put it in your web.xml, or in you Guice ServletModule. Choose the appropriate method for your setup:</p>
<pre class="brush:xml">
  &lt;servlet&gt;
    &lt;servlet-name&gt;cssTheme&lt;/servlet-name&gt;
    &lt;servlet-class&gt;CssThemeServlet&lt;/servlet-class&gt;
  &lt;/servlet&gt;

  &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;cssTheme&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/activeTheme.css&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
</pre>
<pre class="brush:java">
  serve("/activeTheme.css").with(CssThemeServlet.class);
</pre>
<p>Last but certainly not least, we still need to fire the Event somewhere. This is most likely done from a drop down or list box. Implement the appropriate event handler for your box (probably something like onChange):</p>
<pre class="brush:java">
public void onChange(ChangeEvent event) {
  // if event.getSource() is our list box
  eventBus.fireEvent(new SettingChangedEvent("theme"));
}
</pre>
<p>Now you can use the classes from your dynamic CSS in your widgets to provide dynamic themed colors, borders, shadows, backgrounds, whatever your want. If you have any questions, feel free to leave a comment. Happy theming! ^_^</p>
<p>&#8211;JH</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jhkuperus.nl/articles/java/gwt-dynamically-changing-css-styles/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The Road to an Agile Project &#8211; Visualize!</title>
		<link>http://www.jhkuperus.nl/articles/agile/the-road-to-an-agile-project-visualize/</link>
		<comments>http://www.jhkuperus.nl/articles/agile/the-road-to-an-agile-project-visualize/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 13:08:17 +0000</pubDate>
		<dc:creator>Jan-Hendrik Kuperus</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[scrum]]></category>

		<guid isPermaLink="false">http://www.jhkuperus.nl/?p=189</guid>
		<description><![CDATA[Hello and welcome back! In this series of posts I am trying to give other teams of developers out there some path to embracing agile methodologies, such as Scrum. Previously, in my Prequel post, I described how you could start doing regular standup meetings in any type of project to increase your teams awareness about [...]]]></description>
			<content:encoded><![CDATA[<p>Hello and welcome back! In this series of posts I am trying to give other teams of developers out there some path to embracing agile methodologies, such as Scrum. Previously, in my <a href="http://www.jhkuperus.nl/articles/agile/the-road-to-an-agile-project-the-prequel/">Prequel</a> post, I described how you could start doing regular standup meetings in any type of project to increase your teams awareness about each member&#8217;s work.</p>
<p>Assuming your team has now incorporated standup meetings, preferably on a daily basis, it is time to take the next step. Agile methodologies generally rely on a rather simple notice: <strong>Visualized Management</strong>! Now don&#8217;t get scared, the word &#8216;Management&#8217; here does not mean you need <em>another</em> manager. When done right, this visualization can eliminate the need for a manager. Now doesn&#8217;t that sound sweet? <img src='http://www.jhkuperus.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-189"></span></p>
<p>Probably the best known example of this visual management is the Scrum Board, or Activity Board, or ToDo Board. However you call it, it&#8217;s a big board containing lot&#8217;s of post-its all describing work. Some of this work is yet to be done, some of it is in progress and hopefully, some of it is already done. What status a particular piece of work is in should be apparent from its location on the board.</p>
<p>Most boards contain three columns: <em>To Do</em>, <em>In Progress</em> and <em>Done</em>. These columns are however not mandatory, you can make any set of columns you like. You could for example also create columns for each expertise in your team, like To Do, In Design, In Development, In Test, Done. The possibilities are literally limitless, all you need to do is find a set of columns that work for your team. (And don&#8217;t be afraid to modify it if you are missing something, or feel a column is not required).</p>
<p>You could start by asking  your team members to write down what task they are working on right now and put all those post-its in an <em>In Progress</em>-column. Ask them to move the post-it to the <em>Done</em>-column when they complete the task and then write a new note for the next task. The next step would be for people to write things they know still need to be done, or things which are discovered along the way down and put them in a <em>To Do</em>-column. Slowly but surely, you will begin to see progress!</p>
<p>If you are already working in sprint-like increments, you can cleanup all the <em>Done</em> work at the end of a sprint and (re)populate the board with work at the beginning of a sprint. If you have not yet incorporated such increments in your work style, then you could make sure a certain minimum amount of work is on the board. Don&#8217;t put an entire project&#8217;s worth of work on the board or you might risk your team members feeling overwhelmed.</p>
<h2>Why is this important?</h2>
<p>Why does this help you be more agile? For one thing, it helps during the daily standup meeting since you can now talk about the things that are on the board. It helps people remember what they were doing and hopefully takes away the number of &#8220;let&#8217;s see, what did I do yesterday?&#8221;-questions during a standup <img src='http://www.jhkuperus.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . </p>
<p>It also provides a very visible way to demonstrate the progress of the project. Anyone interested in the progress of the project can simply walk up to the board and see what is currently being worked on. Ideally this should stop management from continuously asking your developers what the status of the project is. If they still do, simply explain the board to them and refer them to it. Let your developers do what they do best: write code.</p>
<p>A very nice extra piece of visual management would be to create a (burndown) chart which displays the rate at which tasks are being performed. We all know how much management loves to look at charts, but with a burndown chart, they might need require some &#8216;training&#8217;. You see, management is used to the paradigm that an upward trend is good and a downward trend is bad. On a burndown chart we display a line of work that still has to be done. Usually this starts out at some arbitrary number of tasks and goes down over time as work is completed. Make sure management understands this <img src='http://www.jhkuperus.nl/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>If you are looking for some more pointers on creating your own board, check out some of these links:</p>
<ul>
<li><a href="http://www.xqa.com.ar/visualmanagement/elements-of-taskboard-design/">Elements of taskboard design</a> &#8211; A very nice explanation of a very detailed board</li>
<li><a href="http://agilesoftwaredevelopment.com/blog/jackmilunsky/burndown-charts-its-not-about-staying-below-line">Burndown Charts</a> &#8211; A good explanation of what a burndown chart can tell you</li>
</ul>
<p>Try it sometime. Just pu</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jhkuperus.nl/articles/agile/the-road-to-an-agile-project-visualize/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Road to an Agile Project &#8211; The Prequel</title>
		<link>http://www.jhkuperus.nl/articles/agile/the-road-to-an-agile-project-the-prequel/</link>
		<comments>http://www.jhkuperus.nl/articles/agile/the-road-to-an-agile-project-the-prequel/#comments</comments>
		<pubDate>Fri, 10 Dec 2010 13:27:16 +0000</pubDate>
		<dc:creator>Jan-Hendrik Kuperus</dc:creator>
				<category><![CDATA[Agile]]></category>
		<category><![CDATA[agile]]></category>
		<category><![CDATA[javafx]]></category>
		<category><![CDATA[scrum]]></category>
		<category><![CDATA[visage]]></category>

		<guid isPermaLink="false">http://www.jhkuperus.nl/?p=176</guid>
		<description><![CDATA[Well hullo there! It has been quite some time since my last post. A lot has happened recently, some of which prevented me from posting regularly. Let&#8217;s just blame the current economic conditions for that. Since my last post, we have pretty much finished our JavaFX project. I was at the NLJUG&#8217;s JFall where I [...]]]></description>
			<content:encoded><![CDATA[<p>Well hullo there! It has been quite some time since my last post. A lot has happened recently, some of which prevented me from posting regularly. Let&#8217;s just blame the current economic conditions for that.</p>
<p>Since my last post, we have pretty much finished our JavaFX project. I was at the NLJUG&#8217;s JFall where I hosted a JavaFX workshop all afternoon and I have been to Devoxx in Antwerp where I met Richard Bair and Jasper Potts from the Oracle JavaFX team.</p>
<p>I have also joined Stephen Chin in the maintenance of the Visage language. This is the continuation of the JavaFX Script language as an open source project (see <a href="http://code.google.com/p/visage/">Google Code</a>).</p>
<p><strong>Now shut it, you mentioned something about agile&#8230;</strong></p>
<p><span id="more-176"></span></p>
<p>Yes I did. We have recently moved into a new engineering phase of a large project at work. We had previously used some agile concepts here, but never really moved into full blown Scrum or anything. This time we have, or rather, we are migrating to a real Scrum project setting.</p>
<p>So I thought it would be nice to share how we are currently moving to a more agile project. Although I think we are pretty late to actually fully embrace it, I&#8217;m sure there are still plenty of others out there struggling to go agile. I intend to chronicle the steps we took and discuss the ups and downs we perceived.</p>
<p>Today, the first step: standup meetings. The first thing we picked up (again) were the standup meetings every morning. This is probably the easiest piece of Agile/Scrum to incorporate into an existing team. It can however be hard for people to adjust to these meetings.</p>
<p>The first thing you need for a good standup is a leader. This should be a Scrum Master if you have one, or one of the team members who can maintain order. This is due to the first pitfall with taking up a standup meeting: taking too long.</p>
<p>The key to a good standup and a good feeling among your team is to really keep it short. Make it clear to everyone that they should only briefly answer these three questions:</p>
<ol>
<li>What have you achieved since the last meeting?</li>
<li>What are you planning to do today?</li>
<li>Is anything hindering you in those plans?</li>
</ol>
<p>People initially tend to take a while explaining their answer to the first question. They may actually feel like they have to defend what they are doing. This is <strong>not</strong> true and such feelings should be countered as soon as possible. Make sure everyone understands that the goal is just to increase team communication and team spirit. If someone hears a colleague struggle with a problem that he is familiar with, he may be triggered to help. If someone hears a colleague work on something in which he is also interested, a nice discussion might come up. Just make sure the discussion takes place <strong>after</strong> the standup. This is where the leader should stop any deviations in their tracks and keep the standup going.</p>
<p>The second question also does not require long answers. If you can say it in one sentence, that will do, as long as everyone has an idea of what you will be working on. This is mostly just meant to make sure the whole team knows what is happening and to potentially spot conflicts. Although the answer to this question is somewhat a commitment to the team about what you will do, it should never be used against anyone. Heck, if something goes terribly wrong, or someone interrupts you, you can name those interruptions during the next standup. If required you can name those interruptions as your &#8216;problems&#8217;.</p>
<p>The third question is hardly ever answered with anything else than &#8216;no problems&#8217;. It is however a very important question. From time to time, something might actually be holding you back. It can be silly things like &#8216;we ran out of sugar&#8217;, to really serious issues like trouble at the homefront. If at all possible, the leader / scrum master should try to take these problems away. The power of the scrum master is obviously limited here, but offloading certain things can help you be more productive.</p>
<p>That&#8217;s it for now, next time I&#8217;ll write about taking up a rhythm by adopting sprints. If you have any questions or other experiences about standups, feel free to leave me a comment.</p>
<p>&#8211;JH</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jhkuperus.nl/articles/agile/the-road-to-an-agile-project-the-prequel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaFX&#8217;s largest annoyance</title>
		<link>http://www.jhkuperus.nl/articles/java/javafx/javafxs-largest-annoyance/</link>
		<comments>http://www.jhkuperus.nl/articles/java/javafx/javafxs-largest-annoyance/#comments</comments>
		<pubDate>Mon, 13 Sep 2010 14:17:51 +0000</pubDate>
		<dc:creator>Jan-Hendrik Kuperus</dc:creator>
				<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[binding]]></category>
		<category><![CDATA[exceptions]]></category>
		<category><![CDATA[javafx]]></category>

		<guid isPermaLink="false">http://www.jhkuperus.nl/?p=168</guid>
		<description><![CDATA[JavaFX is great for building user interfaces. There is however one large annoyance that is probably considered a feature. JavaFX swallows NullPointerExceptions, among others. NPE&#8217;s are meant to signal development errors. In other words, if you see an NPE, you can call your developer and tell him he screwed up. Some developers even need them [...]]]></description>
			<content:encoded><![CDATA[<p>JavaFX is great for building user interfaces. There is however one large annoyance that is probably considered a feature. JavaFX swallows <code>NullPointerException</code>s, among others.</p>
<p>NPE&#8217;s are meant to signal development errors. In other words, if you see an NPE, you can call your developer and tell him he screwed up. Some developers even need them to be reminded of the pieces of an application they were working on.</p>
<p><span id="more-168"></span></p>
<p>The fact that JavaFX swallows many exceptions, makes it hard to find out if you made a programming booboo or not. As an example, today my colleague was working on a zooming/scaling algorithm. The calculations were all correct, since we could check them by the many <code>FX.println</code> statements we added to the algorithm:</p>
<pre class="brush:java">
-----------------------
Scale factor: 2.5
sceneX: 254.0
sceneY: 158.0
... etc
topLeft X: 0.0
topLeft Y: 0.0
-----------------------
</pre>
<p>It all seemed a-okay, with one exception: the <code>topLeft</code> X and Y remained at 0.0, even though the following statements were included in the algorithm:</p>
<pre class="brush:java">
topLeft.x = x;
topLeft.y = y;
</pre>
<p>Now, after some more <code>println</code> statements and some name-calling, we found that the <code>topLeft</code> object was <code>null</code>. It simply had not been initialized. Normally, in Java, this would have become apparent the very first time we ran the application, but now it required fifteen minutes of wonder and debugging.</p>
<p>If someone can explain the use of this feature to me, I invite them to leave a comment. On the other hand, I would like to ask the JavaFX people to at least give me a way to turn this off, so I can tell my colleague he made a booboo <img src='http://www.jhkuperus.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&#8211;JH</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jhkuperus.nl/articles/java/javafx/javafxs-largest-annoyance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaFX : Centering Controls</title>
		<link>http://www.jhkuperus.nl/articles/java/javafx/javafx-centering-controls/</link>
		<comments>http://www.jhkuperus.nl/articles/java/javafx/javafx-centering-controls/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 14:30:11 +0000</pubDate>
		<dc:creator>Jan-Hendrik Kuperus</dc:creator>
				<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[bindstorm]]></category>
		<category><![CDATA[javafx]]></category>
		<category><![CDATA[layout]]></category>

		<guid isPermaLink="false">http://www.jhkuperus.nl/?p=162</guid>
		<description><![CDATA[Across the blogosphere, I found a post on how to center controls by using binding. The proposed method certainly works, but there is a catch. When you are doing your layout by binding the layoutX and layoutY properties of your controls, you may experience a degradation of performance while resizing or scrolling. This will probably [...]]]></description>
			<content:encoded><![CDATA[<p>Across the blogosphere, I found a post on <a href="http://javafxscripting.blogspot.com/2010/09/how-to-centre-nodes-using-bind.html">how to center controls by using binding</a>. The proposed method certainly works, but there is a catch.</p>
<p>When you are doing your layout by binding the <code>layoutX</code> and <code>layoutY</code> properties of your controls, you may experience a degradation of performance while resizing or scrolling. This will probably not be noticeable with only a handful of controls/shapes on screen. If however you start drawing hundreds of shapes/controls with this method, you will certainly see the slowdown. Let&#8217;s see why&#8230;</p>
<p><span id="more-162"></span></p>
<p>Currently, I am involved in building an application that visualizes railway tracks and train positions on screen. This visualization literally consists of hundreds of lines, circles and triangles. At first we also used binding to perform the layout of these shapes, but eventually scrolling and zooming became very slow.</p>
<p>Eventually, we decided to switch the layout from binding to a <code>Panel</code>&#8216;s <code>onLayout</code> function. This performed a lot better. The reason this performs better lies in the different timings of binding and calls to <code>onLayout</code>.</p>
<p>A bound variable will be updated any time its source variable is updated. If you bind a lot of controls&#8217; layout to the size of a <code>Scene</code>, you will eventually end up with something called <strong>bindstorm</strong> (term coined by <a href="http://www.informit.com/articles/article.aspx?p=1353604">Jim Conners</a>).</p>
<p>The JavaFX platform performs layout functions only periodically, on so-called pulses. All the JavaFX layout container classes have optimizations to perform their layout as efficiently as possible, during these pulses. Because resizing will trigger a new layout on the next pulse, layouting is done less frequently than bind updates, causing these actions to be more smoothly and less cpu-hungry.</p>
<p>We certainly saw an increase in performance when we switched to the <code>onLayout</code> method. However, I may have misinterpreted the cause. If I am wrong about the way these pulses work, I invite someone from the JavaFX team to correct me in a comment. <img src='http://www.jhkuperus.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Now, coming back to the post I referred to in the first section of my rambling, let&#8217;s talk about centering controls. Knowing the difference between bind and the way layout containers work, I think it is better to let a highly optimized container handle the centering of your controls. There are a number of different containers you can use for this.</p>
<p>The code sample below is derived from the bind-example, only this time notice the <code>Stack</code> and the <code>LayoutInfo</code> objects, which make sure the <code>Label</code> remains centered.</p>
<pre class="brush:java">
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.TextOrigin;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.layout.Stack;
import javafx.scene.layout.LayoutInfo;
import javafx.scene.text.Text;
import javafx.geometry.HPos;
import javafx.geometry.VPos;

Stage {
  title: "Centering Nodes"
  var scene: Scene;
  scene: scene = Scene {
    width: 400
    height: 100
    content: Stack {
      layoutInfo: LayoutInfo {
        width: bind scene.width
        height: bind scene.height
      } // end LayoutInfo
      content: Text {
        textOrigin: TextOrigin.TOP
        font : Font.font(null, FontWeight.BOLD, 16)
        content: "Look ma! I centered this text!"
        layoutInfo: LayoutInfo {
          hpos: HPos.CENTER
          vpos: VPos.CENTER
        } // end LayoutInfo
      } // end Text
    } // end Stack
  } // end Scene
} // end Stage
</pre>
<p>The only binding I used in this example, is the size of the <code>Stack</code>. If the user now resizes the window, binding makes sure the <code>Stack</code> is resized. JavaFX then requests the <code>Stack</code> to redo its layout on the next pulse. Due to the <code>vpos</code> and <code>hpos</code> hints, the <code>Stack</code> knows that this control must be centered. All calculations will then also be handled by the <code>Stack</code>, which takes everything like effects, translations and transforms into account.</p>
<p>Happy layouting!</p>
<p>&#8211;JH</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jhkuperus.nl/articles/java/javafx/javafx-centering-controls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaFX Grid Component Worries</title>
		<link>http://www.jhkuperus.nl/articles/java/javafx-grid-component-worries/</link>
		<comments>http://www.jhkuperus.nl/articles/java/javafx-grid-component-worries/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 12:30:40 +0000</pubDate>
		<dc:creator>Jan-Hendrik Kuperus</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[javafx]]></category>
		<category><![CDATA[jfxtras]]></category>

		<guid isPermaLink="false">http://www.jhkuperus.nl/?p=153</guid>
		<description><![CDATA[If you&#8217;re working with JavaFX, you will probably know these two truths: The JFXtras library has some really awesome components The JavaFX platform is trying out new controls in the preview packages A good thing about this, is that the JavaFX team is taking the good stuff from the JFXtras library and putting it into [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.jhkuperus.nl/wp-content/uploads/2010/09/Button-layout.png" alt="" title="Button layout" width="202" height="217" class="alignright size-full wp-image-154" />
<p>If you&#8217;re working with JavaFX, you will probably know these two truths:</p>
<ul>
<li>The <a href="http://www.jfxtras.org">JFXtras library</a> has some really awesome components</li>
<li>The JavaFX platform is trying out new controls in the preview packages</li>
</ul>
<p>A good thing about this, is that the JavaFX team is taking the good stuff from the JFXtras library and putting it into the platform. A bad thing about it is you start to expect the preview controls have the same functionality as the JFXtras controls.</p>
<p><span id="more-153"></span></p>
<p>I was working with the <code>Grid</code> layout container from the preview packages and ran into a wall. I was trying to make a node have a <code>vspan</code> of 2, and two nodes in the next column, like the image on the right here.
</p>
<p>The code I tried, was simple enough:</p>
<pre class="brush:java">
def s = Stage {
   title: "Grid"
   scene: Scene {
       content: [
            Grid {
                id: "debug"
               rows: [
                   GridRow { cells: [
                       Button { text: "..."
                         layoutInfo: GridLayoutInfo {
                           vspan: 2
                           vfill: true} }
                       Button { text: "..."}
                   ] }
                   GridRow { cells: [
                       Button { text: "..." }
                   ] }
               ]
           }
       ]
   }
}
</pre>
<p>That should have worked. However, when starting the little test application, the result looked like this:</p>
<p><img src="http://www.jhkuperus.nl/wp-content/uploads/2010/09/Grid-buttons.png" alt="" title="Grid buttons" width="130" height="68" class="aligncenter size-full wp-image-156" /></p>
<p>The <code>vspan</code> does not seem to work as expected. At first I thought I was doing something wrong. Then I tried to switch out the preview <code>Grid</code> with the JFXtras <code>XGrid</code>. Check out the result:</p>
<p><img src="http://www.jhkuperus.nl/wp-content/uploads/2010/09/XGrid-buttons.png" alt="" title="XGrid buttons" width="130" height="71" class="aligncenter size-full wp-image-158" /></p>
<p>Tadaaa, that was the result I was looking for. As it turns out, the preview container does not handle the <code>vspan</code> attribute correctly. I guess that&#8217;s why it&#8217;s called a preview <img src='http://www.jhkuperus.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Another small illustration of the differences. Amy Fowler has <a href="http://code.google.com/p/jfxtras/source/browse/common/test/org/jfxtras/scene/layout/AimGridSpanDemo.fx">an example at JFXtras</a> with the <code>XGrid</code> container. I switched out the <code>XGrid</code> with the normal <code>Grid</code> and got these two results:</p>
<p><img src="http://www.jhkuperus.nl/wp-content/uploads/2010/09/XGrid-Amy-Example.png" alt="" title="XGrid Amy Example" width="344" height="147" class="aligncenter size-full wp-image-157" /><img src="http://www.jhkuperus.nl/wp-content/uploads/2010/09/Grid-Amy-Example.png" alt="" title="Grid Amy Example" width="266" height="136" class="aligncenter size-full wp-image-155" /></p>
<p> Bottom line is: if you need <code>vspan</code> right now, use the <code>XGrid</code>. If you only need <code>hspan</code>, you can safely use the preview container, as long as you keep in mind that it may change in the next JavaFX release.
<p>Cheers!</p>
<p>&#8211;JH</p>
<p>Originally posted at <a href="http://java.sogeti.nl/JavaBlog/2010/09/08/javafx-grid-component-worries/">Java Competence Network Blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jhkuperus.nl/articles/java/javafx-grid-component-worries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moving Lines Around In JavaFX</title>
		<link>http://www.jhkuperus.nl/articles/java/javafx/moving-lines-around-in-javafx/</link>
		<comments>http://www.jhkuperus.nl/articles/java/javafx/moving-lines-around-in-javafx/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 11:37:15 +0000</pubDate>
		<dc:creator>Jan-Hendrik Kuperus</dc:creator>
				<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[javafx]]></category>

		<guid isPermaLink="false">http://www.jhkuperus.nl/?p=131</guid>
		<description><![CDATA[Did you know, you can define &#8216;relative&#8217; Lines in JavaFX? When you&#8217;re drawing complex visualizations, you sometimes want to have a Line that is horizontal and 10 pixels long, no matter what. No problem you say, just define its starting point as (x, y) and its end point as (x+10, y): Line { startX: 40 [...]]]></description>
			<content:encoded><![CDATA[<p>Did you know, you can define &#8216;relative&#8217; <code>Line</code>s in JavaFX? When you&#8217;re drawing complex visualizations, you sometimes want to have a <code>Line</code> that is horizontal and 10 pixels long, no matter what. No problem you say, just define its starting point as (x, y) and its end point as (x+10, y):</p>
<pre class="brush:java">Line {
  startX: 40
  startY: 40
  endX: 50
  endY: 40
}</pre>
<p>Sure, easy peasy. What if you want this <code>Line</code> to move around based on some variable&#8217;s value?<span id="more-131"></span> You could alter the definition so its properties are bound:</p>
<pre class="brush:java">var linePosition : Number = 40;

Line {
  startX: 40
  startY: bind linePosition
  endX: 50
  endY: bind linePosition
}</pre>
<p>Works like a charm. However, doesn&#8217;t this start to feel like a lot of information for just a horizontal line? And what if I alo want to change its x-position? What you can do in JavaFX is actually define a <strong>horizontal line</strong>, simply define it relative to its origin:</p>
<pre class="brush:java">Line {
  endX: 10
}</pre>
<p>This makes a horizontal line of 10 pixels long. Now, if you want to move this around, instead of changing its <code>startX, startY, endX</code> and <code>endY</code> properties, use <code>layoutX</code> and <code>layoutY</code>:</p>
<pre class="brush:java">Line {
  endX: 10
  layoutX: 40
  layoutY: 40</pre>
<p>To me, this reads exactly like what it is: a <strong>horizontal line who&#8217;s origin is (40, 40)</strong>. It makes it a lot easier to check whether the <code>Line</code> is in its correct place, if it is the right size, etc.</p>
<p>Same thing goes for <strong>vertical</strong> and <strong>diagonal</strong> <code>Line</code>s obviously:</p>
<pre class="brush:java">// Vertical
Line {
  endY: 10
}

// Diagonal
Line {
  endX: 10
  endY: 10
}</pre>
<p>Happy layouting! <img src='http://www.jhkuperus.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&#8211;JH</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jhkuperus.nl/articles/java/javafx/moving-lines-around-in-javafx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaFX Transitions : An Oddity</title>
		<link>http://www.jhkuperus.nl/articles/java/javafx/javafx-transitions-a-oddity/</link>
		<comments>http://www.jhkuperus.nl/articles/java/javafx/javafx-transitions-a-oddity/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 19:54:18 +0000</pubDate>
		<dc:creator>Jan-Hendrik Kuperus</dc:creator>
				<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[javafx]]></category>

		<guid isPermaLink="false">http://www.jhkuperus.nl/?p=121</guid>
		<description><![CDATA[I&#8217;ve been working on a nice looking application in JavaFX with some nifty transitions.  Doing so, I noticed an odd &#8216;requirement&#8217; when working with Transitions. The problem arose when I tried to split my interface into different files. On one stage, I used two Stacks that each represented a state. Each Stack was defined in [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a nice looking application in JavaFX with some nifty transitions.  Doing so, I noticed an odd &#8216;requirement&#8217; when working with Transitions. The problem arose when I tried to split my interface into different files. On one stage, I used two Stacks that each represented a state. Each Stack was defined in its own JavaFX script and another Script contained the transitions and event handlers.</p>
<p>What happened was that not all Transitions seemed to work. I have not yet been able to determine the root cause of it, but the Transition seemed unable to update properties of its target node. After some frustrated trial and error, I discovered a working solution: put the Transitions in the same file as their target node.</p>
<p>Again, I have not yet found the root cause. If someone can tell me why this is a problem, please let me know. I can&#8217;t stand not understanding <img src='http://www.jhkuperus.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&#8211;JH</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jhkuperus.nl/articles/java/javafx/javafx-transitions-a-oddity/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Apple Mail And Outlook: Making Signatures Interoperable</title>
		<link>http://www.jhkuperus.nl/articles/apple/apple-mail-and-outlook-making-signatures-interoperable/</link>
		<comments>http://www.jhkuperus.nl/articles/apple/apple-mail-and-outlook-making-signatures-interoperable/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 08:53:05 +0000</pubDate>
		<dc:creator>Jan-Hendrik Kuperus</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[interoperable]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[mail]]></category>
		<category><![CDATA[outlook]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.jhkuperus.nl/?p=114</guid>
		<description><![CDATA[Recently I switched from using Windows and Outlook at work to my brand-spankin&#8217; new MacBook with Apple Mail. The first thing I ran into was getting replies to my emails that my signature was all borked. After a long search I have finally been able to fix these so they look good in my colleagues&#8217; [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>Recently I switched from using Windows and Outlook at work to my brand-spankin&#8217; new MacBook with Apple Mail. The first thing I ran into was getting replies to my emails that my signature was all borked.</p>
<p>After a long search I have finally been able to fix these so they look good in my colleagues&#8217; Outlook. The problem lies with the editor in Apple Mail, somehow it just makes completely borked HTML that Outlook interprets differently.</p>
<p>The good news is that the solution is devilishly simple. Just follow these steps for each signature you want:</p>
<ul>
<li>Create the signature in Apple Mail</li>
<li>Save the signature</li>
<li>Close Apple Mail</li>
<li>Open ~/Library/Mail/Signatures</li>
<li>Open one of the .webarchive files with TextEdit</li>
<li>Make the signature the way you want it in TextEdit</li>
<li>Save it and re-open Mail and you&#8217;re done!</li>
</ul>
<p>Cheers!</p>
<p>&#8211;JH</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jhkuperus.nl/articles/apple/apple-mail-and-outlook-making-signatures-interoperable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

