Monday, July 27, 2009

JavaFX 1.2 Test Drive - Introduction

It's Showtime!

eLearning game Tech Test Train (video) is out for your viewing and learning pleasure. Please enjoy, test your JavaFX knowledge, learn, comment, vote, ask questions, send recommendations.

The game has been created entirely in JavaFX 1.2. It intentionally uses only a few lines of Java code, for the sake of purity and proof of concept.

Tech Test Train has been created according to the game story board, not as a JavaFX demo. We had to cut a few corners by the end and omit a few features due to the platform functional and performance problems, but we've made through majority of turns without cutting corners, and now know pretty well what works and how to make it work.

This series of articles will tell about our experience how to use current JavaFX technology for real world multimedia projects, how to work with it as a team of designers, artists, developers. It may be useful for companies and individuals that evaluate JavaFX as a platform for their next applications or mid- to long-term direction.

While I bear responsibility for most of this release coding, Tech Test Train is a team effort. I would like to mention the crew and people without whose support this release could not be possible: Octavian Tanase and Peter Fernandez (blessing); Sophia Mikulinsky (project management); Mary Lautner (program management); Cindy Church (game content); Linda Ross (game design); Dwayne Wolff (graphics and video); Tony Beckham (quality); Bae-Chul Kim (media playback); Rakesh Menon (performance); David Grieve, Craig Hansen-Sturm, Sandeep Konchady, Stuart Marks, Winston Prakash, Dmitri Trembovetski, Tony Wyant (advice); Jim Weaver (coaching and inspiration); Stephen Chin (review and bugs).

I am sure that Tech Test Train will help to create a bridge to cross a chasm between early adopters and early majority of JavaFX technology. There will be more applications like this, but Tech Test Train may be remembered among the first that paved the way to the new RIA era.

In the next chapters I will look into technical and process details. Please do not turn that dial...

Friday, July 17, 2009

Back from JavaFX retreat

After almost 3 months of silence, and certain loss of interest to JavaFX Blog, I am back from my JavaFX retreat where I worked on creating a real life JavaX application based on the latest JavaFX 1.2 release. It has been a real mid-term test drive of the technology.

I am planning a series of short articles with my turn-by-turn experience, and my opinion, paraphrasing Lee Iacocca, "where it works", and where I see a room for improvement.

This series may be a good reading for companies who, after Oracle' acquisition of Sun, and obvious Oracle' backing of Java and JavaFX technology, are waiting for some indicator to start JavaFX trial projects.

Stay tuned...

Monday, April 20, 2009

"OracleFX"?

Just hours after Oracle announced Sun's acquisition, many posts were published with analysis and speculations. Javalobby has the most profound talk and lengthy comments, with a dedicated column on the fate of Sun technologies. WSJ posted live blog from the Sun/Oracle conference call, along with its report and journal. While Gartner is still looking for the community input before speaking up in confidence, we would like to answer the following question: what is the future of Sun software, and JavaFX in particular, under Oracle Corp.?

By common opinion, the deal is appraised higher than the previous one with IBM in terms of Sun business and core competency survival, for reason far from the corporate strategy: Oracle and Sun have fewer areas in common, and a smaller number of technologies and organizations (as well as people) will be found redundant after the acquisition. This also bears a risk of not that smooth assimilation, but Oracle's CEO and President estimate it as very low.

There are 6 main Sun software products that I would like to discuss:
  • Solaris
  • Java
  • JavaFX
  • MySQL
  • Netbeans
  • Glassfish
I specifically mentioned JavaFX as a separate item for convenience, even though Sun committed to full integration and dissolution of JavaFX in the future releases of Java.

Solaris, along with Java and hardware, were explicitly mentioned by Larry Ellison at the conference call as technologies Oracle spent seven and a half billion dollars for.

The future of MySQL, NetBeans and Glassfish is a bit murky: for all these 3 product Oracle has at least one existing comparable in house. Not a subject to NIH rule, Oracle can easily transition to the new software set, if it is found to be better for making money off--business that Oracle has mastered to perfection. It looks like Oracle' engineering and marketing teams due diligence will make their call later this year.

For JavaFX, my prediction will be either complete hit or miss.

Oracle is a server company, with a few nice front ends, such as Beehive, but they have Oracle famous server suite as a back end. We also can mention Java applet based Oracle Forms that is used inside Oracle E-Business Suite. Not that much space for RIA. From this perspective, it's hard to assume that JavaFX is a keeper.

But let's look into potential markets where Oracle can make money on Sun technologies.

Importance of nice GUI, running in the browser - Rich Internet Applications - has increased dramatically for the last years. The space, traditionally occupied by Adobe, attracted such big players as Microsoft and Sun. The leading server technology vendor can not ignore this trend, especially if its product line is getting more oriented toward consumers.

Another point: JavaFX runs on desktop and phones, and TV is next. With JavaFX, Oracle can get into mobile and home theater segments, and will be able to offer products competitive to Flash Lite, and Flash on TV that will be released this year. Considering the revenue stream that Sun generates off existing Java products, desktop and mobile, Oracle JavaFX mobile and TV business can bring a very attractive profit margin.

On the other hand, JavaFX Script is a new language, with a distinct syntax and steep learning curve. But if Oracle does not want to acquire Adobe, or pay hefty licensing fee for Microsoft Silverlight, using JavaFX for its GUI applications looks like a reasonable approach.

Being, perhaps, rationally optimistic, I would put "Long" on "OracleFX".

Please post your opinions and educated guesses.

Thursday, April 9, 2009

JavaFX 1.2 Release: Sneak Peek

How to create a fancy JavaFX button, a button that is worth learning a new language and dealing with a front line technology, button like this?


Simplicity itself. Just create a class extending CutomNode, draw there a rectangle and a text, take care of their relative positions, colors, etc. And then, if you really want to make it nice, you have to implement functions onMouseEntered() and onMouseExited() with changes of the button colors, and, perhaps, add to mousePressed() and mouseReleased() some nice pixel shifts to imitate movement of the button being pressed. That's it. (See the source below.) In JavaFX 1.1, that is.


class FancyButton extends CustomNode {

public var X: Number;
public var Y: Number;
public var width: Number;
public var height: Number;
public var caption: String;

var text: Text;

override function create() :Node {
return Group {
translateX: X
translateY: Y
content: [
Rectangle {
width: width
height: height
arcWidth: 20
arcHeight: 20
stroke: Color.BLACK
strokeWidth: 1
fill: LinearGradient {
startX: 0.0
startY: 0.0
endX: 0.0
endY: 1.0
proportional: true
stops: [
Stop {
offset: 0.0
color: Color.WHITE
},
Stop {
offset: 0.50
color: Color.LIGHTBLUE
},
Stop {
offset: 0.51
color: Color.LIGHTGREY
},
Stop {
offset: 1.0
color: Color.DARKBLUE
}
]
}
},
text = Text {
content: caption
fill: Color.RED
font: Font.font("Arial", FontWeight.BOLD, 14)
x: (width - text.boundsInLocal.width) / 2
y: (height - text.boundsInLocal.height) / 2 + 7
}
]
}
}
}

How to create the same fancy button in the upcoming JavaFX 1.2 release? Unfortunately, we do not have a well tested crystal ball handy, but our second-hand crystal ball says that it may be as easy as
var button = javafx.ui.Button {...}

Along with the Button, JavaFX 1.2, apparently, will have added the following UI controls:
  • Default Button
  • Radio Button
  • Check Box
  • Hyperlink
  • Label
  • Slider
  • Scroll bar
  • Combo Box
  • Text Box
  • List View
  • Progress Indicator
And all of these goodies, revealing a true WORA spirit of JavaFX, will look and work the same way on desktop as well as on the phone.

As Octavian Tanase, Sun Executive Director in charge of JavaFX, mentioned in his comment to my earlier post, even though you can use Swing controls with JavaFX, after 1.2 you will probably not need them that often.

The rumor also is that JavaFX 1.2 will switch to a direct graphic acceleration using CPU as well as major types of GPUs. On some benchmarks, JavaFX Script 1.0 shows 25x speed advantage over Groovy and JRuby. With graphics support rewrite in JavaFX 1.2, RIA platforms performance competition may get into a new phase.

Tuesday, March 31, 2009

James Gosling' Podcast on JavaFX

Listen to the latest interview with creator of Java James Gosling, talking about JavaFX, multiple languages, Swing, Garbage First, Modularity, JDK 7.

Some highlights:
  • James' 2 currently favorite languages: Scala and JavaFX
  • James compared JavaFX to a functional language (such as Scala)
  • Power of JavaFX binding: constructing the data flow network
  • By design, Java appealed to C and C++ programmers. JavaFX does not have to.
  • James' PhD thesis was, in essence, about JavaFX binding construct--so James liked very much Chris Oliver' F3 language when he first saw it
  • It's really easy to embed Swing components into JavaFX, including coolest like NASA World Wind. There is nothing as complex as NASA World Wind in Flash.

Monday, March 30, 2009

3D and JavaFX

I had a chance to watch recently "Monsters vs. Aliens", in IMAX 3D format. The movie was a brilliant piece of art, as most DreamWorks creations, and 3D added quite an edge to it. I left the theater under impression that 2D projectors will be replaced with 3D ones soon.

According to WSJ, "Hollywood plans to release as many as 45 3D films over the next two and a half to three years". "This weekend makes me confident that this is the beginning of the era, not just a passing fad," said DreamWorks CEO Jeffrey Katzenberg, referring to 3D. "This film certainly established a beachhead, and there are many more 3D films coming from talented and important filmmakers."

Spoiled by fun and ubiquity of 3D, the movie goers will demand 3D technology on the computer screens as well, at least in a form of 3D objects on a flat screen. What JavaFX can do to address this upcoming market?

JavaFX 1.1 API does not support 3D. Rumor is that later this year it will--Java3D is available (see a cool sample), and the task requires just a simple matter of integration. However, JavaFX has never been alien to the 3D, as shows this 2-years old Chris Oliver' demo. It was also refreshing to find out about German company InteractiveMesh (blogged by Jim Weaver), owned by August Lammersdorf and pushing JavaFX 3D to the new level .


The company page provides samples of JavaFX 1.1 apps and applets with 3D rendering, along with source and library download. (I'm sure, NetBeans users would appreciate NetBeans project, so, perhaps, August can oblige us in the future).


Thanks to InteractiveMesh, we can look under the hood of this beautiful implementation:

  • Java 3D renders off-screen into a lightweight component which is added via a resizable JavaFX SwingComponent to JavaFX Scene
  • The Java 3D rendering loop runs in parallel to the JavaFX painting loop with a minimal synchronized overlap. It is implemented as Java class FXCanvas3D, derived from JCanvas3D and available under the BSD license, and Java interface FXCanvas3DRepainter.
  • A Double Off-screen Buffer and a controlling Lock with two Conditions were introduced to ensure that the threads of both loops access the common image data deadlock-free. These two buffers are: BufferedImage which Java 3D is rendering into and a BufferedImage which JavaFX is drawing. Both images have an identical format type. Only for the period of time when integer values are copied from the first into the second image, the loops interrupt their regular tasks controlled by one of the two Lock's Condition. The other Condition guarantees that during resizing of the FXCanvas3D panel the Java 3D renderer thread isn't blocked.
  • The web page samples provide an implementation of the corresponding SwingComponent named as FXCanvas3DComp. This JavaFX class has the interface FXCanvas3DRepainter implemented and allows a FXCanvas3D object to call 'repaintFXCanvas3D()' from its 'postSwap()' method. The repaint request is handled by a FX.deferAction() - an equivalent to SwingUtilities.invokeLater() - and is executed on the EDT. The assigned function calls first 'copyOffScreenBuffer()' while the Java 3D renderer thread is waiting, and then calls 'repaint()' on the FXCanvas3D object. This completes the cycle of 3D off-screen rendering and image drawing.
  • The duration of one cycle on a multi-core system can be estimated as ( max(Java 3D loop, JavaFX loop) + image copying + thread handling ) ms. The cost of the extra BufferedImage in comparison to JCanvas3D is about ( image.width x image.height x 4 ) bytes of CPU memory.
  • Initiating the Java 3D engine, the 3D scene, and the FXCanvas3D object asynchronously is implemented with 'async operation' (see James Clarke' post), and is reliable and effective
Will InteractiveMesh' work help Sun JavaFX team to speed up the release of JavaFX 3D API? The time will tell. For now, the first generation of JavaFX "Monsters vs. Aliens" games may be implemented in 2D.