Devoxx 2008 University Wednesday
Join the DZone community and get the full member experience.
Join For FreeThe third day of the Devoxx 2008 conference included a keynote from Danny Coward and a great talk on concurrency from Brian Goetz.
Keynote: JavaFX: The Platform for Rich Internet Applications
Danny Coward,
Robert Brewin was schedule to give the key note, but unfortunately he had a business meeting. So we all got a very reasonable replacement speaker, Danny Coward. He gave a decent key note speech about the strategy of JavaFX. Clearly the marketing slant of the speech was directed to catch up with Adobe Flex and other nascient technologies.
What was really good was the fact that the FX demonstration were shown in front of live audience for the first time. There were no blow ups as far I as know, unlike JavaOne, earlier this year. Let us not forgot that the European developers, most of them, do not get the chance to fly out to California. JavaFX samples definitely rocked, especially when the video 9 box high definitin video example was pulled out from the browser onto the desktop. The browser was just closed, and the media played on without interruption. My goodness I cannot tell you how proud I was and how grateful I was to see Java client side suddenly rock-and-roll. There were tears in my eye, ever so slightly. Oh yes the example to slaver over, if you ever catch that clever Josh Marinacci, is called Video9Box.
BorderLayout Component
Yours truly recently downloaded the JavaFX 1.0 SDK and much to his chagrin, he found that the kit had no BorderPanel component anymore. This was a major head ache for me, and I presume other developers wer feeling the pain porting code from Preview to Full Candidate Release. Here is my version of the "missing" BorderLayout.
I make no guarantees for its complete operation. If you have had experience developing user interfaces before, for example X Windows / OSF Motif then it should be really easy to work it out. See my other Blog on Devoxx Thursday for some bullet point items on this BorderLayout.
I really enjoyed this presentation, because it was explained the concept of virtual machines so clearly. The jist of Goetz piece was the fact that we are moving from time sliced single CPU machines to the multiple cores CPU machine, where truly parallel operation is physically possible. This presentation would not have made any sense, without a chart of the Moore's law and Goetz explaining how the processor speed has stagnated and in some "chip" line have actually decreased year to year, whereas the number of cores on a chip are doubling. We already have quad-core on desktop and some high end enterprise profile have rack based systems with 768 cores.
Goetz argued that it is not about utilising every single core simultaneously on the machine for our program, but can we, as software engineers, can keep pace with the hardware innovations. He pointed out that the Javac used to have a least often used optimisation flags, but as the Sun Hotspot JVM got better optimising byte code dynamically, it turns out that a compiler can churn badly organised byte code. HotSpot will reorganise the byte code with its adaptive profiling and regeneration algorithms.
A subsequent part of Goetz talk was about the JSR 166y proposal, which includes the new concurrent utilitities, such as Fork-Join. Overall this was talk not to be missed.
Keynote: JavaFX: The Platform for Rich Internet Applications
Danny Coward,Robert Brewin was schedule to give the key note, but unfortunately he had a business meeting. So we all got a very reasonable replacement speaker, Danny Coward. He gave a decent key note speech about the strategy of JavaFX. Clearly the marketing slant of the speech was directed to catch up with Adobe Flex and other nascient technologies.
What was really good was the fact that the FX demonstration were shown in front of live audience for the first time. There were no blow ups as far I as know, unlike JavaOne, earlier this year. Let us not forgot that the European developers, most of them, do not get the chance to fly out to California. JavaFX samples definitely rocked, especially when the video 9 box high definitin video example was pulled out from the browser onto the desktop. The browser was just closed, and the media played on without interruption. My goodness I cannot tell you how proud I was and how grateful I was to see Java client side suddenly rock-and-roll. There were tears in my eye, ever so slightly. Oh yes the example to slaver over, if you ever catch that clever Josh Marinacci, is called Video9Box.
BorderLayout Component
Yours truly recently downloaded the JavaFX 1.0 SDK and much to his chagrin, he found that the kit had no BorderPanel component anymore. This was a major head ache for me, and I presume other developers wer feeling the pain porting code from Preview to Full Candidate Release. Here is my version of the "missing" BorderLayout.
// XenonBorderPanel.fx, (c) Licence: LGPL: Peter Pilgrim, Created on 08-Dec-2008, 17:31:14
package com.xenonsoft.goliath.game.ui;
import javafx.lang.FX;
import javafx.scene.paint.Color;
import javafx.scene.Node;
import javafx.scene.Group;
import javafx.scene.layout.Container;
import javafx.scene.layout.Resizable;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.ext.swing.SwingButton;
import javafx.ext.swing.SwingComponent;
import java.lang.Math;
/**
* A class to keep a record of the child constraints
*/
protected class ChildConstraint {
public var prefWidth: Number = 0;
public var prefHeight: Number = 0;
public var resizeWidth: Number = 0;
public var resizeHeight: Number = 0;
override function toString(): String {
return "[width={%7.2f width},height={%7.2f height}, resizeWidth={%7.2f resizeWidth},resizeHeight={%7.2f resizeHeight}]"
}
}
/**
* @author Peter Pilgrim
*/
public class XenonBorderPanel extends Container, Resizable {
public var debug = false;
protected function updateChildComponent( newChild:Node, oldChild: Node )
{
if ( newChild != oldChild ) {
if ( oldChild != null ) {
delete oldChild from content;
}
if ( newChild != null ) {
insert newChild into content;
}
}
}
public var top: Node on replace oldValue {
updateChildComponent(top,oldValue);
};
public var left: Node on replace oldValue {
updateChildComponent(left,oldValue);
};
public var right: Node on replace oldValue {
updateChildComponent(right,oldValue);
};
public var bottom: Node on replace oldValue {
updateChildComponent(bottom,oldValue);
};
public var center: Node on replace oldValue {
updateChildComponent(center,oldValue);
};
// Protected variables to this class and subclasses
protected var leftChildConstraint: ChildConstraint;
protected var rightChildConstraint: ChildConstraint;
protected var topChildConstraint: ChildConstraint;
protected var bottomChildConstraint: ChildConstraint;
protected var centerChildConstraint: ChildConstraint;
/** maximum preferred width of top, center and bottom children */
protected var maxPrefWidth: Number;
/** the maximum height of left, center and right children */
protected var middleHeight;
/** full width of left, center and right children summed */
protected var fullWidth;
public var spacing:Number on replace {
impl_requestLayout();
}
init {
impl_layout = doBorderLayout;
}
public function requestLayout():Void {
impl_requestLayout();
}
public function getPreferredSize(node:Node): ChildConstraint {
var constraint = ChildConstraint{ };
if ( node != null ) {
if ( node instanceof SwingComponent) {
// Swing Component do not initialise the shadow FX variables min/max/prefs
var component = (node as SwingComponent).getJComponent();
constraint.prefWidth = component.getPreferredSize().width;
constraint.prefHeight = component.getPreferredSize().height;
constraint.resizeWidth = constraint.prefWidth;
constraint.resizeHeight = constraint.prefHeight;
}
else {
constraint.prefWidth = node.boundsInLocal.width;
constraint.prefHeight = node.boundsInLocal.height;
constraint.resizeWidth = constraint.prefWidth;
constraint.resizeHeight = constraint.prefHeight;
}
if (debug) FX.println("getPreferredSize() ) id={node.id} constraint={constraint}");
}
return constraint;
}
public function setChildBounds( node: Node, x: Number, y: Number, constraint: ChildConstraint): Void
{
if (node instanceof Resizable) {
var resizable = node as Resizable;
resizable.width = constraint.resizeWidth;
resizable.height = constraint.resizeHeight;
}
node.impl_layoutX = x;
node.impl_layoutY = y;
if (debug) FX.println("setChildBounds() id={node.id} x={%7.2f x}, y={%7.2f y}, constraint={constraint}");
}
public function calculatePreferredSize():Void {
leftChildConstraint = getPreferredSize(left);
rightChildConstraint = getPreferredSize(right);
topChildConstraint = getPreferredSize(top);
bottomChildConstraint = getPreferredSize(bottom);
centerChildConstraint = getPreferredSize(center);
// Compute maximum center preferred width
maxPrefWidth = Math.max(topChildConstraint.prefWidth, centerChildConstraint.prefWidth);
maxPrefWidth = Math.max(maxPrefWidth,bottomChildConstraint.prefWidth);
// Computer maximum center preferred height
middleHeight = Math.max(leftChildConstraint.prefHeight, centerChildConstraint.prefHeight);
middleHeight = Math.max(middleHeight, rightChildConstraint.prefHeight);
// Compute the full width of the border layout minimum requirement
fullWidth = 2*spacing + leftChildConstraint.prefWidth + maxPrefWidth + rightChildConstraint.prefWidth;
minimumWidth = fullWidth;
// Compute the minium height of the border layout
minimumHeight = 2*spacing + topChildConstraint.prefHeight + middleHeight + bottomChildConstraint.prefHeight;
preferredWidth = fullWidth;
preferredHeight = 2*spacing + topChildConstraint.prefHeight + middleHeight + bottomChildConstraint.prefHeight;
}
public function doBorderLayout(g:Group):Void {
var x:Number = 0;
var y:Number = 0;
calculatePreferredSize();
// calculate the real size
if ( width > 0.0 and width > preferredWidth and center != null) {
centerChildConstraint.resizeWidth = width - (2 * spacing + leftChildConstraint.prefWidth + rightChildConstraint.prefWidth);
maxPrefWidth = Math.max(topChildConstraint.prefWidth, centerChildConstraint.resizeWidth);
maxPrefWidth = Math.max(maxPrefWidth,bottomChildConstraint.prefWidth);
}
if ( height > 0.0 and height > preferredHeight and center != null) {
centerChildConstraint.resizeHeight = height - (2*spacing + topChildConstraint.prefHeight + bottomChildConstraint.prefHeight);
middleHeight = Math.max(leftChildConstraint.prefHeight, centerChildConstraint.resizeHeight);
middleHeight = Math.max(middleHeight, rightChildConstraint.prefHeight);
}
fullWidth = 2*spacing + leftChildConstraint.prefWidth + maxPrefWidth + rightChildConstraint.prefWidth;
if ( top != null ) {
topChildConstraint.resizeWidth = fullWidth;
setChildBounds(top, x, y, topChildConstraint);
y += topChildConstraint.prefHeight + spacing;
}
x = 0;
if ( left != null ) {
leftChildConstraint.resizeHeight = middleHeight;
setChildBounds(left, x, y, leftChildConstraint);
x += leftChildConstraint.prefWidth + spacing;
}
if ( center != null ) {
setChildBounds(center, x, y, centerChildConstraint);
x += centerChildConstraint.resizeWidth + spacing;
}
if ( right != null ) {
rightChildConstraint.resizeHeight = middleHeight;
setChildBounds(right, x, y, rightChildConstraint);
x += rightChildConstraint.prefHeight + spacing;
}
x = 0;
y += middleHeight + spacing;
if ( bottom != null ) {
bottomChildConstraint.resizeWidth = fullWidth;
setChildBounds(bottom, x, y, bottomChildConstraint);
}
if (debug) {
FX.println("boundsInParent={boundsInParent}");
FX.println("parent.boundsInLocal={parent.boundsInLocal}");
FX.println("parent.boundsInParent={parent.boundsInParent}");
FX.println("parent.boundsInScene={parent.boundsInScene}");
}
}
}
public function run(): Void {
var border: XenonBorderPanel;
var stage: Stage;
var scene: Scene;
stage = Stage {
title: "Test XenonBorderPanel"
width: 600;
height: 800;
onClose: function() {
FX.exit();
}
scene: scene = Scene {
content: border = XenonBorderPanel {
width: bind scene.width
height: bind scene.height
top: SwingButton {
// foreground: Color.AZURE
id: "Top"
text: "Top"
action: function(): Void {
FX.println("Top");
}
}
center: SwingButton {
id: "Center"
text: "Center"
action: function(): Void {
FX.println("Center");
}
}
bottom: SwingButton {
id: "Bottom"
text: "Bottom"
action: function(): Void {
FX.println("Bottom");
}
}
left: SwingButton {
id: "Left"
text: "Left"
action: function(): Void {
FX.println("Left");
}
}
right: SwingButton {
id: "Right"
text: "Right"
action: function(): Void {
FX.println("Right");
}
}
}
}
}
}
// The End
I make no guarantees for its complete operation. If you have had experience developing user interfaces before, for example X Windows / OSF Motif then it should be really easy to work it out. See my other Blog on Devoxx Thursday for some bullet point items on this BorderLayout.
From Concurrent to Parallel
Brian GoetzI really enjoyed this presentation, because it was explained the concept of virtual machines so clearly. The jist of Goetz piece was the fact that we are moving from time sliced single CPU machines to the multiple cores CPU machine, where truly parallel operation is physically possible. This presentation would not have made any sense, without a chart of the Moore's law and Goetz explaining how the processor speed has stagnated and in some "chip" line have actually decreased year to year, whereas the number of cores on a chip are doubling. We already have quad-core on desktop and some high end enterprise profile have rack based systems with 768 cores.
Goetz argued that it is not about utilising every single core simultaneously on the machine for our program, but can we, as software engineers, can keep pace with the hardware innovations. He pointed out that the Javac used to have a least often used optimisation flags, but as the Sun Hotspot JVM got better optimising byte code dynamically, it turns out that a compiler can churn badly organised byte code. HotSpot will reorganise the byte code with its adaptive profiling and regeneration algorithms.
A subsequent part of Goetz talk was about the JSR 166y proposal, which includes the new concurrent utilitities, such as Fork-Join. Overall this was talk not to be missed.
Al Coda
Visual VM looks like the ultimate profiling tool. It rocks!Shout Outs!
Jo Voereendecker, JAVAWUG speaker and member.
Fabrizio Giudici, Italian blogger supremo
Alex Buckley, good talking to you about closures lack of appearance in JDK 7 and various other small language changes.
Devoxx
Opinions expressed by DZone contributors are their own.
Comments