Archive

Archive for the ‘Rich User Interface’ Category

JavaOne 2012 Slide-Decks and Code Bundles

October 5th, 2012 Comments off

CON4643 – Contemporary User Interface Design Patterns in JavaFX 2.2

Wednesday, Oct 3, 1:00 PM – 2:00 PM – Hilton San Francisco – Imperial Ballroom B

Download the Slide Deck for CON4643
Download the Code bundle for CON4643

The deck contains some extra slides that lists the UI design patterns. There are actually over 100 patterns in Jenifer Tidwell’s 2010 second edition book.

On Wednesday, in the interest of saving time, I skipped over the ModalPanel (otherwise known as Light Box) design pattern. I have added it back to the slide deck and you can run it yourself from the code bundle.

The code compiles against Java SE 7 update 6, which bundles the JavaFX library jar.

For Java SE 6 update 29 and better, you need to, first, define the environment variable JAVAFX_HOME and point it to the Oracle JavaFX 2.2 distribution. The JavaFX SDK is a separate distribution for Java SE 6.

CON4648 – Scala, JavaFX, Java EE 7, and Enterprise Integration

Wednesday, Oct 3, 4:30 PM – 5:30 PM – Hilton San Francisco – Imperial Ballroom B

Download the Slide Deck for CON4648
The deck contains some extra slides and addenda from Wednesday’s technical session.
NB: This was not any code bundle for this talk

TUT5466 – JavaFX 2: A Java Developer’s Guide

Stephen Chin – Java Evangelist, Oracle
Peter Pilgrim – Developer Consultant, Independent Contractor

Tuesday, Oct 2, 12:30 PM – 2:30 PM – Hilton San Francisco – Continental Ballroom 1/2/3

Download the Slide Deck for TUT5466
Download the Code bundle for TUT5466

I wish to thank all of the attendees who came to my talks at JavaOne 2012. I very much hope you enjoyed the subject matter. Please feel free to inquire and ask further questions.

TUT5466 – JavaFX 2: A Java Developer’s Guide

October 2nd, 2012 Comments off

TUT5466 – JavaFX 2: A Java Developer’s Guide

Peter Pilgrim – Developer Consultant, Independent Contractor
Stephen Chin – Java Evangelist, Oracle

Tuesday, Oct 2, 12:30 PM – 2:30 PM – Hilton San Francisco – Continental Ballroom 1/2/3

Source Code is here temporarily

Build it with Gradle

A Note to self

task myZip(type: Zip) {
 from '.'
 into "${archivesBaseName}-${version}"
// into 'javafx-developer-guide-J1-2012'
 include 'src/**'
 include '*.xml'
 include '*.gradle'
 include '*.txt'
 exclude {
 details ->
 details.file.name.equals('.gradle')
 }
}

ScalaFX – Some Workarounds for SBT Issues

July 24th, 2012 Comments off

ScalaFX build does not work out of the box with SBT. Here is a little bit of extra help if you are new to ScalaFX, Scala and SBT; and are attempting to build the project yourself.

The Plugin configuration has the wrong URL, if your set up does not allow GIT as HTTP protocol. Fortunately, one can easily fix this by changing it to HTTPS.

Edit projects/plugins/project/PluginBuild.scala file

import sbt._

object MyPlugins extends Build {
  lazy val root = Project("root", file(".")) dependsOn (junitXmlListener)
  lazy val junitXmlListener = uri("git://github.com/ijuma/junit_xml_listener.git#fe434773255b451a38e8d889536ebc260f4225ce")
}

Change the Protocol from "git://..." to "https://github.com"

Next, edit the build.sbt in the root folder of the project. Uncomment or remove the line:-

testListeners <<= target.map(t => Seq(new eu.henkelmann.sbt.JUnitXmlTestsListener(t.getAbsolutePath)))

I am unsure why the Xml test listener was needed in the first place. However, we do not need it out of the box to compile and build the project.

Finally, upgrade the Scala version of the project to a 2.9.2 if you want

scalaVersion := "2.9.2"

In the ScalaFX, there are two source code roots.

unmanagedSourceDirectories in Compile <++= baseDirectory { base =>
  Seq(
    base / "src",
    base / "demo"
  )
}

No changes are required here. It is decidedly a un-Maven like structure for a project.

I believe, actually, we should split up the ScalaFX project into multiple modules. One module for the core and the other for the demonstrations. Lots of engineers are familiar with this type project organisation coming from Maven style world. The project committers, however, need to agree to this manoeuvre.

In the recent JavaPosse Episode 390, Dick Wall had some comments to say about the SBT. I agree with many of his comments that SBT is no longer a simple build tool. It is anything but. It is quite hard to get your head around this domain specific language and it is an illustration when such a DSL becomes a burden on the developer, its user base. Were it not for the fact that very fast build times are achievable, because of its incremental compilation features, I believe many users would leave SBT behind.

+PP+

Categories: Framework, JavaFX, Rich User Interface, Scala Tags:

Responses to a JavaFX Developer Guide: Devoxx 2011

November 18th, 2011 Comments off

I gathered the twitter responses to Stephen Chin and I, for our Devoxx University: A JavaFX Developer Guide on Tuesday. Thank you all for the kind responses, I searched using the term “Devoxx” and “JavaFX” on Twitter.

 

Public Responses

@Jakob48Skov Jakob Skov
#Devoxx #JavaFX Mobile = where the action is at, get moving JavaFX!

@peter_pilgrim peter_pilgrim
"You are very much welcome! RT @celine_va: That Peter Pilgrim fellow sure likes doing presentations #javafx #devoxx"

@steveonjava Stephen Chin
"Christopher Oliver on JavaFX: At the end of the day0xE2 0×80 0xA6 bit.ly/w1NSam #Devoxx #JavaFX"

@Sharat_Chander Sharat Changle
"Waiting with anticipation to hear @steveonjava and @peter_pilgrim give their #JavaFX talk at #devoxx tomorrow. Should be a showstopper!"

@areljantweats Karel-Jan Misseghers
"at #devoxx, waiting 4 @peter_pilgrim and @steveonjava ‘s presentation on #JavaFX 2.0"

@reginatb38 ReginaTenBruggencate
"Sitting in the #javafx talk with @steveonjava and @peter_pilgrim #devoxx"

@thecoda Kevin Wright
"@steveonjava and @peter_pilgrim now talking on #javafx at #devoxx. Knowing Peter, I anticipate some #scala too :) "

@steveonjava Stephen Chin
"@MrBrown_K Congratulations on winning the SunSPOT! #Devoxx"

@reginatb38 ReginaTenBruggencate
"follow @steveonjava while he holds his #javaFX talk #devoxx he will tweet during his talk"

@celine_va Céline Van Acker
"At this rate we´ ll be abe to fit our source code in a tweet #javafx #devoxx"

@celine_va Céline Van Acker
"That Peter Pilgrim fellow sure likes doing presentations #javafx #devoxx"

@javaclimber Kevin Nilson
"@steveonjava and peter great #javafx talk at #devoxx"

@ponkiez Sander Tirez
"@steveonjava: The WebView let0xE2 0×80 0x99s you embed HTML5 content in your JavaFX app #Devoxx #JavaFX" Cool stuff

@MrBrown_K Koen Bruyndonckx
"@MrBrown_K good to be at #devoxx #javafx"

@MrBrown_K Koen Bruyndonckx
"@reginatb38: RT @steveonjava: Prefer JavaFX Properties #Devoxx #JavaFX"

@jospotargent Jos Potargent
‘"Bob’s your uncle". I love Peters’ way to show how straightforward things are in #javafx at #devoxx’

@html5guy HTML5 Guy
"The WebView let0xE2 0×80 0x99s you embed HTML5 content in your JavaFX app #Devoxx #JavaFX: The WebView let0xE2 0… bit.ly/tcK1wv"

@lospaul Torben Torbsen
"Can`t wait to see #JavaFX for Linux at #Devoxx 2012"

@pjvanaeken Pieter-Jan Van Aeken
"@lospaul: Can`t wait to see #JavaFX for Linux at #Devoxx 2012" -> not to mention a fully functional mac version"

@Arvraepe Arne Van Raepenbusch
"@steveonjava the using #rss [#css] in #javafx sample seems interesting! #devoxx"

@pjvanaeken Pieter-Jan Van Aeken
"the accordeon layout looks great and is surprisingly simple! The #JavaFX talk at #devoxx continues to be a great discovery"

@Mrxjn Mark Dechamps
"Bit of a slow start but #javafx now at full speed at #Devoxx ! Nice :) "

@Arvraepe Arne Van Raepenbusch
"@DarthBo @steveonjava even friends are getting excited :D javafx has some nice features! #javafx #devoxx"

@DarthBo Tibault Damman
"Wow, this #JavaFX is pretty cool! #Devoxx #sendmefreestuff"

@Arvraepe Arne Van Raepenbusch
"Ready for the second part of #JavaFX controls! @steveonjava #devoxx"

@pjvanaeken Pieter-Jan Van Aeken
"@steveonjava: Which do you prefer, builder or imperative syntax? #Devoxx #JavaFX" -> definitely the builder pattern. It looks very clean.

@stesieber Stefan Sieber
"I like the binding in JavaFx 2.0 it looks clean… even in Java. Maybe good for enterprise apps? @steveonjava #Devoxx #JavaFX"

@dooAppFX dooApp FX
"Great! New feature in JavaFX 2.0 – Observable Maps! #Devoxx #JavaFX (via @steveonjava)"

@Arvraepe Arne Van Raepenbusch
"Binding looks really easy and useful! @steveonjava #javafx #devoxx"

@pjvanaeken Pieter-Jan Van Aeken
"After a few basics, the demo action has started at #JavaFX #devoxx , this is surprisingly simple.. And Swing compatible!!"

@MrBrown_K Koen Bruyndonckx
"@steveonjava #javafx #devoxx cool, saw the SunSpot keynote at javapolis a couple of years ago :-) "

@Mini_Ananas Waudru Volders
"Second day @ #devoxx following #javafx in room 4. Seems interesting."

@hanevel Robin van Riel
"JavaFX 2.0 talk by @steveonjava and @peter_pilgrim. So far so good! #devoxx"

@stesieber Stefan Sieber
"ScalaFX example beats the pants of the original Java Builder version of the JavaFX Application by @steveonjava #devoxx #scala #scalafx"

@FredericVL F. Van Linthoudt
"Some nice stuff you can do with #JavaFX #Devoxx #teaser"

@celine_va Céline Van Acker
"Another year before Linux support? :( #devoxx #javafx"

@JoeriOfTheYear joeri verlooy
"That android flash book sure does look nice! Now let’s see what we can learn here. :) #devoxx #javaFX"

@stijndepestel Stijn De Pestel
"Wow, #JavaFX will open a new programming world for me! #Devoxx"

@reginatb38 ReginaTenBruggencate
"Sitting in the #javafx talk with @steveonjava and @peter_pilgrim #devoxx"

@kareljantweats Karel-Jan Misseghers
"at #devoxx, waiting 4 @peter_pilgrim and @steveonjava ‘s presentation on #JavaFX 2.0"

@SvenBeeckman Sven Beeckman
"#Devoxx day 2, starting with #JavaFx"

@z17bbarb Benjamin Barbier
"JavaFX 2.0 – A Java Developer’s Guide – Devoxx 2011 -Devoxx bit.ly/tQExMR"

@stijndepestel Stijn De Pestel
"Starting second #Devoxx day starts with JavaFX. Later on some more #Android and the new #JDK7. Shame it’s the last day…"

Tweets by Stephen Chin

@steveonjava Stephen Chin
"JavaFX supports Windows, Mac OS X (preview) and Linux (2012) #Devoxx #JavaFX"

@steveonjava Stephen Chin
"For examples of skinnable controls check out the JFXtras project: jfxtras.org #Devoxx #JavaFX"

@steveonjava Stephen Chin
"You can consume events to stop bubbling up the hierarchy #Devoxx #JavaFX"

@steveonjava Stephen Chin
"BorderPane gives preference to top/bottom over right/left #Devoxx #JavaFX"

@steveonjava Stephen Chin
"Box Container Demo code can be found on @peter_pilgrim 0xE2 0×80 0x98s blog: xenonique.co.uk/blog/ #Devoxx #JavaFX"

@steveonjava Stephen Chin
"GridPane is powerful, but only rewards those who learn its intricacies #Devoxx #JavaFX"

@steveonjava Stephen Chin
"Prefer JavaFX Properties #Devoxx #JavaFX"

@steveonjava Stephen Chin
"Properties in GroovyFX as simple as: @FXBindable String firstName #Devoxx #JavaFX"

@steveonjava Stephen Chin
"The JavaFX ListView can handle millions of rows performantly #Devoxx #JavaFX"

@steveonjava Stephen Chin
"Trees in JavaFX can dynamically load data as you expand #Devoxx #JavaFX"

My Tweets

@peter_pilgrim peter_pilgrim
":-( Good UI need live demos RT @SvenNB: We all know POJO, but this was new POSGN – Plain Old Scene Graph Node #javafx #devoxx"

@peter_pilgrim peter_pilgrim
"A component is an encapsulation that binds a set of nodes with the operations that act on those nodes #Devoxx #JavaFX"

@peter_pilgrim peter_pilgrim
"I repeat, We WANT LINUX JavaFX 2.0 yesterday ;-) RT @reginatb38: RT @lospaul: Can`t wait to see #JavaFX for Linux at #Devoxx 2012"

@peter_pilgrim peter_pilgrim
"You are very much welcome! RT @celine_va: That Peter Pilgrim fellow sure likes doing presentations #javafx #devoxx"

@peter_pilgrim peter_pilgrim
"Congrats!! RT @MrBrown_K: @steveonjava: Woohoo i won the SunSpot thanks to the #JavaFX session at #Devoxx :-) )"

@peter_pilgrim peter_pilgrim
"Audioboo: Preparation for JavaFX University Talk at Devoxx 2011 boo.fm/b544872 #antwerp #devoxx #java #javafx #talk"

@peter_pilgrim peter_pilgrim
"Thanks! RT @Sharat_Chander: Waiting with anticipation to hear @steveonjava and @peter_pilgrim give their #JavaFX talk at #devoxx tomorrow."

@peter_pilgrim peter_pilgrim
"@steveonjava and I were working on our JavaFX Developer Guide presentation this morning at #Devoxx"

 

The slide deck, by the way, for our joint presentation: A JavaFX 2.0 Developer Guide is available from Slide Share. Stephen uploaded it a couple of days ago.

To provide any comments, do not hesitate, let us both know. Thank you.

JavaOne 2011 Progressive JavaFX 2.0

October 3rd, 2011 Comments off

Good Morning from California

I am presenting at JavaOne 2011 this year. The first of three talks on my trip to California this year. Today, I will give a talk today on Progressive JavaFX 2.0 in , which is expected to be released very soon.

 

JavaOne 2011

"Hotel, motel, Holiday Inn" – Say it loud! Say it proud! You better believe it

 

Session ID: 24085

Session Title: Progressive JavaFX 2.0 Custom Components

Venue / Room: Hotel Nikko – Nikko Ballroom II/III

Date and Time: 10/3/11, 17:30 – 18:30

 

Make sure you reach, because JavaFX 2.0 is the one successful story of the year, very personal and to my heart. Whereas Scala adoption rate has been a tremendous disappointment, especially in London, and the United Kingdom, in terms of businesses taking the necessary steps to embrace it. On the other hand, I really do believe that Java now has a fantastically brilliant framework for a graphics, media, and audio. It is called JavaFX 2.0, written in Java. Swing will no longer be innovated on from the community at large. If you considering new software development using Swing, may I make a bold attempt to dissuade you from this route, instead look at the competition and the user experience, usability ideas since 2007, on mobile devices, tablets and even desktop web. From the solid pizza base, of JavaFX 2.0, we can start to build world class components and user interfaces for the 21st century. We will ascend to new heights and exceed the boundaries of Swing and AWT UI/UX. Finally, we are on the verge of being very creative, very selective, and incredible. With JavaFX 2.0 we now have something big, exciting and meaningful, right around the corner.

 

JavaOne 2011

Moi standing next to a large exhibit where Larry has spent some of his company’s billions of dollars ;-)

In the mean time, I am heading right now to the 37760 JavaOne Technical Keynote the second of the conference. 

Let me know your feedback on twitter: peter_pilgrim or Google+. Stay tuned.

PS: My California talk schedule is thus:

[1] JavaOne 2011 on 3rd October, Progressive JavaFX
[2] Silicon Valley Code Camp, 8th October
[3] Silicon Valley JavaFX, 13th October
[4] Devoxx 2011, JavaFX University Session

PS PS: My JavaOne 2011 Flickr Stream

 

JavaOne 2011

Bruno Souza (L), president of the Brazilian SOUJava JUG and Patrick Curran (R), Chairperson of the Java Community Process

 

JavaOne 2011

From L to R, Stephen Chin, JavaFX Guru; Tori Weildt, Oracle; Sven Reimers, NetBeans Dream Team

 

PS PS: My JavaOne 2011 Flickr Stream


Meet Your JavaOne 2011 Rich Media Track Reviewer

July 24th, 2011 Comments off

In April, 2011, I received one morning an email from Simon Ritter one of Sun Microsystems long standing Java Evangelists and now Oracle. The message was an invitation to be a part of Java SE, Client Side Technologies, and Rich User Experiences track. The track included all JavaFX sessions submitted along with any other UI related sessions. Simon had invited me to be track reviewer for JavaOne 2011. Of course, with hesitation, I said yes!

 

DSCF2721_400x533_bw

 

I submitted myself a couple of papers to JavaOne 2011 in a track that was fiercely competitive. I will be speaking on JavaFX 2.0. There is a lot to be said of the talented people who made it through to the end. I was a little bit surprised by a small number of proposals that were not relevant to Java platform. If you want some advice on submitting a J1 proposal then here is mine:

First rule: Know Your Audience; Do aim for Java relevant content when the organiser and reviewing committee explicitly say they are looking for it. Your proposal has to exploit features of the Java platform, probably in new unexpected and innovative ways.

Second rule: Promise Really Good Know-How and Transferable Content; write a decent abstract that rather aptly declares that you are going to serve the audience. Make sure that the proposal is sufficiently detailed. Remember that first impressions last, therefore check your English for any grammatical errors, hyperbole and nonsensical arguments.

Third rule: Provide Capable Evidence; Much of JavaOne presentation comes from a reputation. Respect is earned from previous behaviours. JavaOne should really not be your very first public speaking situation?! Your reputational risk is usually up against big-draws, including the rockstar developers, who keep coming back every year for another session or two. If you have in the past spoken well at other Java conference then it helps the reviewer make a decision about you.

 

DSCF2729_400x533_bw

 

Whilst there are places for brand new unknown speakers, these opportunities tends to be usually very far and between, so if this is your first public speaking situation then you must already better than very good. In fact, I was would expect you to be amazing. My advice is to attempt to hone your speaking skills at a much smaller scale conference. Here is an analogy, learn to play to crowd as a singer/musician at The Jazz Cafe, before you take on the stadium rock of the Tokyo Dome.

The audience is usually large for a popular technical session, and for the most popular talks there are people queuing up outside to get in that room. You can find yourself standing in-front of a 200 – 300 audience member set, easily.  Some JavaOne attendees travel long distances to get to San Francisco, from London, United Kingdom;  from Brisbane, Australia, Sao Paulo in Brazil; Brizzabane, Congo, St. Petersburg in Eastern Europe and Seoul, South Korea  to hear what is new and great about the Java platform. They are the ambassadors for their respective countries, territories and native language locales. As well as people from North America these are the people who are need to be impressed by your proposal, your talk.

Above all, JavaOne is about investment education, finding out what, where, and who are the things that I as a developer, designer or architect should spent my next 365 days studying for, learning about or interacting with.

If your topic is too narrow as a subject matter then, we, as program reviewers, working in the committee team, we have to think why is it so niché? So broad a category, then we have to think your proposal may not possibly cover all of what you promise. I do say promise, with conviction, because at JavaOne you have to perform in order to be a success. It is all about performance and delivery.

 

DSCF2723_400x567_crop_bw

 

I will be seeing you at JavaOne 2011 from 2nd – 6th October. I agree with Oracle it is time to move Java platform along. Thank you Oracle for taking the initiative.

PS: Thanks to the track reviewers in our team including Jim Clarke, Stephen Chin, Dean R Iverson, Simon Ritter, Jim Weaver and Geertjan Wielenga.

Swing Scala REPL: What Is Wrong Here?

March 22nd, 2011 3 comments

 

I just spent the best part of two hours attempting figure out an interactive REPL for Scala, a la the Groovy Console, but a very basic version. My progress has not been lightning fast. Why?

package swingrepl

import java.io._
import scala.swing._
import scala.swing.event._

import javax.swing.SwingUtilities
import scala.tools.nsc._
import scala.tools.nsc.interpreter._

/**
 * Swing version of the REPL
 * User: Peter
 * Date: 22/03/11
 * Time: 14:34
 */
object SwingRepl extends SimpleSwingApplication {

  def outputPane  = new TextArea {
    editable = false
    text = "Text output"
  }

  def replInvoker = new ReplInvoker( outputPane )
  replInvoker.start()

  def inputPane: TextArea = new TextArea {
    text = "List(1,2,3,4,5) map ( n => n * n )"
    editable = true
    listenTo(keys)

    reactions += {
      case e: KeyPressed => {
        // println("keyCode =" +e.peer.getKeyCode+", keyChar = "+e.peer.getKeyChar)
        if ( e.peer.isControlDown && e.key == Key.Enter ) {
          replInvoker.interpret( text )
        }
      }

      case _ =>
    }
  }


  def scrollInputPane = new ScrollPane( inputPane )
  def scrollOutputPane = new ScrollPane( outputPane )

  def splitPane = new SplitPane( Orientation.Horizontal, scrollInputPane, scrollOutputPane )  {
    dividerLocation =  100
  }

  def top = new MainFrame {
    title = "Swing REPL"
    preferredSize = new Dimension(900, 900 )
    contents = splitPane
  }


  /**
   * Programmatically launching the Scala REPL
   */
  class ReplInvoker( val outputPane: TextComponent ) {
    private val swriter = new StringWriter()
    private val pwriter = new PrintWriter( swriter ) {
      override def println( line: String ) {
        super.println( line )
        System.out.println("println line="+line)
        outputPane.text = swriter.toString()
      }
      override def print( line: String ) {
        super.print( line )
        System.out.println("print line="+line)
        System.out.println("swriter.toString="+swriter.toString )

        SwingUtilities.invokeLater( new Runnable() {
          override def run(): Unit = {
            outputPane.text = outputPane.text +"\n"+ line +"\n"
            outputPane.peer.validate()
          }
        })
      }
    }

    private val cmd = new InterpreterCommand(Nil, println )
    println("cmd="+cmd)
    private val settings = cmd.settings
    println("settings="+settings)

    settings.usejavacp.value = true

    private val interpreter = new Interpreter(settings, pwriter ) {
      override def reset() = { super.reset; unleash() }
      override def unleash() = { super.unleash;  }
    }
    println("interpreter="+interpreter)
    private val completion = new Completion(interpreter)

    def start() {
       println("ReplInvoker.start")
    }

    def interpret(cmd: String): Unit = {
      println("replInvoker.interpret "+cmd )
      interpreter.interpret(cmd)
    }
  }
}

I really do not understand why this code is not working at all. It is a Swing application to programmatically invokes Scala NSC REPL. I have two JEditorPanes in set horizontally in a JSplitPane. The upper editor pane is a reserved for text entry. The lower editor pane is not editable is reserved for capturing the output of the Scala.

To fire the REPL interactively in the upper pane, hold the CTRL key and pressed the RETURN/ENTER key. Invoking the REPL works fine. However it is the update to the lower pane that causes concern. I can see the interactive REPL returning a result, yet the JEditorPane is not being updated. Is this a Swing Scala bug? Or does Java Swing bug?

I suspected the cause was a Swing multithreading problem hence I used SwingUtilites.invokeLater to make sure the update was on the Event Dispatch Thread, however to no avail. JComponent.repaint() nada, JComponent.validate() nada. What gives?

Oh yes in case you are wondering, JavaFX 2.0 early access does not yet have a multi-line equivalent of JTextComponent.

I will be very interested in finding out what is wrong with this picture? If you know the answer, then a pint of Staropramen is on me. Thanks

Categories: Rich User Interface, Scala, Swing Tags:

JavaPosse Episode 328: JavaFX The Sequel

November 3rd, 2010 2 comments

Hello

I was rather pleased that the JavaPosse released the RoundUp 2010 session that I chaired JavaFX The Sequel podcast episode 328. The Roundup  is a yearly unconference session organised by Bruce Eckel and JavaPosse and takes place in February or March at Crested Butte, Colorado, USA. Roundup 2010 was particular interesting, because we had just over one year of JavaFX releases since the version 1.0 in late 2008.

At the time the podcast was recorded, in March 2010, JavaFX Script was still the chosen way that Sun/Oracle were positioning the next Java rich user technology, JavaFX. We were still looking forward to the full JavaFX 1.3 release and all developers were mucking around with the JavaFX 1.2.2 release. During the conference Tor Norbye, a Sun/Oracle employee back then, had access to the non-public JavaFX 1.3 release branch and he gave us valuable in to the up and coming new features in 1.3.

DSCF1056


Here is a picture of me at the JavaPosse Round Up 2010 at the fabulous restaurant Django at the top of the mountain resort that is Crested Butte.  The cost is the restaurant is exhorbitant: one of everything, with two deserts for about USD 270.  Recognisable folk include Frederick Simon (JFrog) , Robert Cooper, etc

In the podcost, there were a number of salient points that I liked and still are valid:

  • JavaFX could have had an active travelling adovocate (an evangelist) like James Ward does for Adobe Flex
  • JavaFX Script really required the equivalent of Tour de Flex from its earliest inception
  • Modularisation of the Java runtime platform and how much this is crucial for JavaFX deployment in the past, present and future. Breaking up the JRE means that deployment of JVM application could be cheaper, faster and smaller for distribution
  • In my opinion Sun/Oracle marketing chose the wrang name, “JavaFX” was far too close to the Adobe “Flex”. This was also confusing for non-IT people in the financial market industry where the term FX means Foreign Exchange or the further abbrevation of FOREX
  • The expense of providing tooling for the JavaFX Script eventually caused it’s eventual ejection from commercial Sun/Oracle development. The overall cost of investing in building a domain specific language was underestimated, especially if it was statically compiled and required interaction with Java APIs, IDEs and debuggers
  • JavaFX Script was also a victim of the merger and acquisition between Oracle and Sun Microsystems (2009-2010)
  • It was far too hard to get into the JavaFX Partner Program as an individual and therefore outsiders could not innovate with the JavaFX SDK team to provide better solutions
  • The inability of Swing developers to embed a JavaFX Script application in their own existing Swing applications

Now that there is a new Roadmap for JavaFX 2.0 since the JavaOne 2010 conference, some items from the above are now mute.

  • Since JavaFX 2.0 APIs are being rewritten into Java language, therefore Swing developers will be to get full access to the new scenegraph model from Java for the first time ever
  • Because the API is now rewritten in Java, means the door is suddenly thrown open to the alternative JVM languages such as Scala, Groovy, Clojure, Fantom, Erjang and others. Java is now the Mother language for client UI on the JVM
  • The expensive tooling issue for JavaFX Script has gone away from Sun/Oracle point of view. Developers will be able to use all their favourite Java IDEs, debuggers and testing frameworks and toolkits for Java.
  • The elegance and the power of JavaFX Script will be sorely missed, even though it will continue with next open source project of Visagé. No one outside of Sun/Oracle can see how elegant JavaFX Script binding feature will be implemented in the Java API for JavaFX 2.0. (This new Java binding implementation will become a crucial cornerstone of the DSL, see below)

In order to solve the lack of uptake issue for JavaFX, I think we need more context outside JavaFX (2.0) to become a reality, namely:

  • A core league of developers, outside of Sun/Oracle, must create Domain Specific Language implementations for the JavaFX 2.0 API in their favourite alternate JVM language of choice
  • The PRISM rendering pipeline must be completed and released with the JDK release in version 6 and 7
  • The brand new Java plugin that uses PRISM exclusively must also be completed on time. This is essential to show off the hardware accelerated 2D and 3D graphics applications, which run inside web browser runtime such as Firefox, Opera and Google Chrome
  • PRISM requires improved 3D primitives support. It needs the basics: planes, polygons, pyramids, meshes, surfaces, spheres, dodecahedrons, toroids, etc and not just cubes that we saw in the JavaOne 2010 keynote demonstrations
  • The web start JNLP should be enhanced to allow dynamics properties and capabilities added to the application in order allows system administrators to customise deployment
  • Media must be supported, at least in the output mode, e.g. H.264 video, MP3 playback, positioning, seeking and scrubbing.  (If the Sun/Oracle team could also rush-release the ability to record audio input then that would be a superb bonus.  See the popular Android Market application the Talking Tomcat)
  • JavaFX requires the mountain of runtime support that is OpenJDK 7 and Jigsaw and the ability reduce the payload for downloading, installing and running an JavaFX application from a remote web server
  • Keep the status quo of releasing Windows, MacOS and Linux essential. Sun/Oracle originally heavily investing in Windows JavaFX releases, I think recent history has shown that Linux and MacOS runtimes are now crucially important. It may be actually true in 2011 that Oracle Corp  must invest some of the stockpile of billions of USD that it has in bank accounts in keeping Write Once Run Everywhere alive.

There is lot of work still be done in 2011.

Peter Pilgrim. Out. 3 November 2010 ;-)

( Updated 5 November 2010 )

Categories: Java, JavaFX, Rich User Interface Tags:

JavaOne 2010 Videos: JavaFX CSS and UI Testing

October 26th, 2010 Comments off

Hello All

Here is some JavaOne 2010 video that I have been editing recently. The first one is a short video, 3 minutes long, consist of yours truly impromptu interviews of passersby at the conference.  The footage was shot on the final day of the conference, the Thursday, just after the morning Java keynote. This was one of the keynotes that took place in Moscone Center.

The second video, is edit of Richard Bair and Jasper Potts, JavaFX CSS session. Unfortunately I was saving the battery for the camcorder until much latter sessions, I think I had not charged it the night before. The second video features Alex Ruiz talking about Java UI Testing in-depth. It was one of the highlights of the conference, and explains why he created FEST.

Please Enjoy Responsibility ;-)

This is Peter Pilgrim. Out.

Categories: Java, JavaFX, Rich User Interface Tags:

A Domain Specific Language for JavaFX 2.0 and Scala

October 10th, 2010 Comments off

Hello and Welcome

Two weeks ago, at the JavaOne 2010 Conference in San Francisco, there was an announcement that Oracle will no longer supporting JavaFX Script as a language. In fact, Sun.Oracle will refactor the current implementation into a Java API and framework in the 2.0.

As many have reported (and obviously mis-reported) Oracle made business and technological decisions about the future of JavaFX. In this blog, I already mentioned a conversation at JavaOne 2010 I had with Brian Goetz, where he explained that the biggest issue creating tools around JavaFX Script was expensive, in comparision to the availability of existing tools for Java. Building the even the essential JavaFX Script tooling for the language was too high a barrier to reach in order to bring JavaFX Script up the same high quality standard. Oracle decision to discontinue in-house development of JavaFX Script  was, then, a time-to-market decision and also reflection of the prototypical experience that following the JavaFX Script platform. Sun.Oracle have learnt many lessons in their drive to implement around compiled JavaFX Script.

The most important innovation in the JavaFX Script language is the binding syntax. It looks incredibly simple but imposes so much hard thinking under the surface of the proverbial architectural iceberg. Just like so many instructional pyramid design in software architectures around the world, JavaFX Script language sits on the top of the ice berg, the easy target, the white motionless precipice of mountain, which innocently languishes above the sealine. Of course, everyone knows it is what lies beneath the sea, which makes an iceberg so formidably dangerous to shipping vessels. Sun.Oracle have been building below this sea-level and have been for a few years already. They will continue to do hard to engineering especially the binding and updates of properties in the implementation of JavaFX 2.0.

The advantages on concentrating on the bottom of the iceberg are:

  • Hardware accelerated graphics architecture and pipeline (a unified temporarily Java2D and Prism worlds. Eventually Java 2D / AWT will go away, several years into the future)
  • Presentation of a unified scene graph architecture thorough 2d and 3d views, think of NetBeans rewritten using scenegraph elements.
  • A brand new Prism based applet and JNLP web startable applications, which will be deployable from the get-go
  • Allow JVM language authors and enthusiasts to create DSL in their own favourite programming languages that (re-)use the forthcoming JavaFX for Java 2.0 API

It is this last one item that I concentrate here. Since JavaOne 2010, yours truly has been seriously ruminating over a possible Scala Domain Specific Language for JavaFX 2.0 for Java API, especially knowing that Sun.Oracle will deliver this functionality in 6-8 months as promised. The bad old days of Sun Microsystem loss of focus over a wide range of products of tentative monetisation are truly gone for ever, especially in Larry Ellison’s open Oracle world.

This is my speculative buy in to the JavaFX 2.0 API. I believe Sun.Oracle will choose a variant of Builder Pattern for the Java API, the Named Parameter Idiom, rather than the legacy JavaBeans, setters and getters. Here is the Node.java in my personal opinion:

package uk.co.xenonique.javafx;

/**
 * Research JavaFX for Java API 2.0
 * @author Peter Pilgrim, 26 September 2010
 */
public abstract class Node {

    private boolean blocksMouse;
    private Bounds boundsInLocal = new Bounds();
    private Bounds boundsInParent = new Bounds();
    private Node clip;
    private boolean focused;
    private boolean hover;
    private String id;
    private Bounds layoutBounds = new Bounds();
    private float layoutX;
    private float layoutY;
    private boolean managed;
    private float opacity;
    private boolean pressed;
    private Parent parent;
    private boolean visible;

    public Node() { super(); }

    public boolean isBlocksMouse() {
        return blocksMouse;
    }

    public Node setBlocksMouse(boolean blocksMouse) {
        this.blocksMouse = blocksMouse;
        return this;
    }

    public Bounds getBoundsInLocal() {
        return boundsInLocal;
    }

    public Bounds getBoundsInParent() {
        return boundsInParent;
    }
    ...

    public boolean isFocused() {
        return focused;
    }

    public boolean isHover() {
        return hover;
    }

    public String getId() {
        return id;
    }

    public Node setId(String id) {
        this.id = id;
        return this;
    }

    public Bounds getLayoutBounds() {
        return layoutBounds;
    }

    public float getLayoutX() {
        return layoutX;
    }

    public float getLayoutY() {
        return layoutY;
    }

    public boolean isManaged() {
        return managed;
    }

    public Node setManaged(boolean managed) {
        this.managed = managed;
        return this;
    }

    public float getOpacity() {
        return opacity;
    }

    public Node setOpacity(float opacity) {
        this.opacity = opacity;
        return this;
    }

    public Parent getParent() {
        return parent;
    }

    public Node setParent(Parent parent) {
        this.parent = parent;
        return this;
    }

    public boolean isPressed() {
        return pressed;
    }

    public boolean isVisible() {
        return visible;
    }

    public Node setVisible(boolean visible) {
        this.visible = visible;
        return this;
    }

    ...

    @Override
    public String toString() {
        return "Node{" + "blocksMouse=" + blocksMouse + ", boundsInLocal=" + boundsInLocal + ", boundsInParent=" + boundsInParent + ", clip=" + clip +
                ", focused=" + focused + ", hover=" + hover + ", id=" + id + ", layoutBounds=" + layoutBounds +
                ", layoutX=" + layoutX + ", layoutY=" + layoutY + ", managed=" + managed + ", opacity=" + opacity +
                ", pressed=" + pressed + ", parent=" + parent + ", visible=" + visible + '}';
    }
}

A Node is the base abstract class that represents one scenegraph node in the new Prism architecture  Remember that top of that iceberg, I was just talking about. It is simply a one-to-one between the abstract node and the underlying implementation rendering primitive in your GPU.

Please note, every Node can have a parent, and are there is no node that is not parentable:

package uk.co.xenonique.javafx;

import java.util.*;

/**
 * @author Peter Pilgrim
 */
public abstract class Parent extends Node {

    protected List<Node> children = new ArrayList<Node>();
    protected boolean needsLayout;

    public Parent() {
    }

    public List<Node> getChildren() {
        return children;
    }

    protected Parent setChildren(List<Node> children) {
        this.children = children;
        return this;
    }

...
    @Override
    public String toString() {
        return "Parent{" + "children=" + children + ", needsLayout=" + needsLayout + '}';
    }

}

Parent and Node are abstract classes. Group is the simplest container type of Parent and it is a concrete type. A Group represents a collection of scene graph nodes, which is not the same as a Container (which not shown in this blog article). So here is the Java API version of a Group.

package uk.co.xenonique.javafx;

import java.util.*;

public class Group extends Parent {

    public Group() {
    }

    public List<Node> getContent() {
        return getChildren();
    }

    public void setContent(List<Node> content) {
        this.setContent( content );
    }
    ...
}

The Group is simple implementation of a Parent in a nutshell.

Let us look at the Shape as a Java class, or at the very least the basics of it. A Shape is a type of node that stores additional painting attributes, for example, the fill and stroke colour. In JavaFX SDK 1.3 these properties are actually Paint types, but for the purposes of research, I made them colours.

package uk.co.xenonique.javafx;

public abstract class Shape extends Node {

    protected Color fill   = new Color( 0x999966);
    protected Color stroke = new Color(0xFF9900);
    protected float strokeWidth = 1.0F;

    public Shape() {
        super();
    }

    public Color getFill() {
        return fill;
    }

    public Shape setFill(Color fill) {
        this.fill = fill;
        return this;
    }
     ...
}

Finally, here is the outline of the remaining JavaFX for Java API classes that we need. Namely, they are the Rectangle, Stage and the Scene classes:

package uk.co.xenonique.javafx;

/**
 * @author Peter Pilgrim
 */
public class Rectangle extends Shape {
    private float x;
    private float y;
    private float width;
    private float height;

    public Rectangle() {
    }

    public float getHeight() {
        return height;
    }

    public Rectangle setHeight(float height) {
        this.height = height;
        return this;
    }

    ...
}

The Stage:

package uk.co.xenonique.javafx;

public class Stage {

    private String title;
    private float width;
    private float height;
    private float x;
    private float y;
    private Bounds stageBounds;
    private Bounds screenBounds;
    private Scene scene;
    private boolean visible;
    private float opacity;

    public Stage() {
    }

    public float getWidth() {
        return width;
    }

    public Stage setWidth(float width) {
        this.width = width;
        return this;
    }

    public Scene getScene() {
        return scene;
    }

    public Stage setScene(Scene scene) {
        this.scene = scene;
        return this;
    }
    ...
}

Finally, the Scene:

package uk.co.xenonique.javafx;

import java.util.*;

public class Scene extends Parent {

    public Scene() {
    }

    public List<Node> getContent() {
        return getChildren();
    }

    public Scene setContent(Node content) {
        this.setContent( content );
        return this;
    }
    ...

}

I have left out the details and the implementation of several standard JavaFX SDK features such as Paint and Effect types. As Sun.Oracle develops their API these will no doubt be answered.

So how on earth do we call this Java API from Scala? What could it look like? Here is a work-in-progress Domain Specific Language example based on my own attempts of modelling these Java API classes. So far it looks like this:

object TestDSL {
  def main(args: Array[String]) {
    val builder = new FXBuilder()
    import builder._

    val s1 = stage("Demo") { s =>
      val s2 = scene { s =>
        group { g =>
          rectangle() { n =>
            n.setX(50)
            .setY(50)
            .setWidth(100)
            .setHeight(200)
            .setFill( new Color( 0xFFCC00 ) )
            .setStrokeWidth(2.0F)
            .setStroke(new Color( 0xCC9900) )
          }
        }
      }
    }
    s1.setVisible(true)
  }
}

Writing a Scala DSL is not easy to tell the truth. Having attended the Scala LiftOff USA on the Friday after JavaOne 2010, I sought some advice, notably from Bill Venners and anyone else expert enough to answer DSL questions.  The best advice I was given, simply, was to take things rather slowly. Build my DSL steadily and deliberately, and the more experience Scala enthusiasts suggested starting with an internal DSL. The DSL above is an internal one. Here are some observations so far:

  • The Scala DSL at this stage is not at all a full replacement for JavaFX Script or Visage project. Scala does not support declarative instantiation of objects in 2.8.0-final.
  • The closures in Groovy have an implicit “it” parameter that are passed to them, in this way Groovy Builders can hide an implicit context. See examples of code that use Groovy’s XML, Ant and Swing builders and you will see this. In Scala we cannot replicate this. Therefore, please  note the explicit closure parameter inside each of the closures.
  • Each closure parameter represents the JavaFX Java object in question. Hence, we can chain the operations together in the form n.setX(10).setY(10).setWidth(100).setHeight(100) etc in the named parameter idiom. (Perhaps a future version of Scala might support optional declaration of attributes on a Scala class).
  • Because of forthcoming binding, therefore Scala case classes cannot be used to implement thin wrappers over the JavaFX 2.0 Java peer classes. Case classes are immutable.
  • Due to the way Scala is calling Java classes it is not possible to support in-fix operations directly. So the following does not cut it: n setX 10 setY 10 setWidth 100 setHeight 100.
  • The advantage of using an FXBuilder and an explicit closure parameter should make binding using the official Java APIs easier rather than harder. If you need to call a specific API routine your closure has the object instance.
  • The FXBuilder DSL is a lightweight wrapper around the JavaFX for Java API.
  • The FXBuilder also knows how to add a Node to Parent. It would have to be extended to handle collections of nodes, namely List[Node].

Of course, Scala is a statically typed language and there is great type safety with it. Getting the code with the mock JavaFX API classes to compile required some enduration as my knowledge of Scala does not quite match my long Java experience just yet. It is the first cut and writing any DSL is a long road and an investment. The equivalent JavaFX Script/ Visage looks this:

def s1:Stage = Stage {
   scene: Scene {
       content: Group {
            content: Rectangle {
                x: 50 y: 50 width: 200 height: 200
                fill: Color.web("#FFCC00")
                strokeWidth: 2.0 stroke: Color.web("#CC9900")
            }
       }
}

All the fun of the fair is the phase that Brits say to there is the road is open, optimistics and fun can be had. Scala and JavaFX does look good at this point. This is Peter Pilgrim. Out.

PS: I am all ears for your opinions by the way. Get in touch please with your views.

Categories: Java, JavaFX, Rich User Interface, Scala Tags: