JavaFX 1.2 Fun For Linux and Solaris
Jim Weaver: Note: On May 31, 2009, when I went to http://javafx.com to download JavaFX 1.1, the JavaFX 1.2 SDK came down,...
So I thought I would update my instructions for getting JavaFX to run on Linux, previously blogged here, here and here:
Just download the Linux version and play:
It seems that the Solaris version is also available.
Hurray!
I will get on to my flight to San Francisco in a few hours. I will attend JavaOne and CommunitiyOne for the first time this year. I can't wait to join my co-authors Jim Weaver, Stephen Chin, and Dean Iverson to unveil our book Pro JavaFX Platform: the electronic version, updated for JavaFX 1.2, will be available today, and the print version will follow some time in June. I'm also excited about the chance to meet many of the people that make the Java community what it is today.
See you all there!
Oh, Really? (Joining the Crowd in Deriding Wolfram Day)
Fresh evidence that the web has made us stupid, even the geniuses at Wolfram Research:
How could they not know this?
Mark Volkmann: Clojure---Functional Programming for the JVM (And a Friday Quiz)
Just want to let everyone know that Mark Volkmann did the Clojure presentation at the St. Louis Java Users Group yesterday evening.
The slides are here:
Please also check out Mark's Clojure page for an constantly updated version of his February 2009 JNB article on the same topic.
CodeToJoy did a pre-game analysis.
In honor of the presentation, today's quiz is a clojure one:
Q: What would the following code produce:
(defn f [x [y z]]
[y [z x]])
(f 1 [2 3])
Zhou Bi Mathematical Manual (周髀算经)
My last excursion into ancient Chinese mathematical books, the post about Sea Island Mathematical Manual 172 days ago, generated some interest from some of my non-traditional readers.
Today, I would like to follow-up with a brief passage from another book: the Zhou Bi Mathematical Manual (周髀算经). It is written in the Zhou Dynasty (1046 BC–256 BC) about geometry and astronomy (Here Bi (髀) is the eight chi vertical pole that astronomers used to examine the shadow cast by the Sun). The opening dialog is between the Duke of Zhou (周公, about 1000 BC) and the astronomer Shang Gao (商高):
1. In the old time the Duke of Zhou asked Shang Gao: "I heard that your greatness is proficient with numbers. May I ask you a question about the ancient Bao Xi (包犧) who established the positions of the heaven and the degrees of the calendar. One cannot climb stairs to reach heaven, and one cannot measure the earth with chi (foot) and cun (inch). May I ask from where comes the numbers."
2. Shang Gao said: "The ways of the number, comes from the circle and the square. The circle comes from the square, and the square comes from the ju (carpenter's square). Ju comes from nine nines eighty-one. Thus fold the ju, form a gou (base) of three, gu (altitude) of four, and jing (hypotenuse) of five. Having squared on the outside, half one of the jus. Turn around and form a plate, there you get the root of three, four, and five. The two jus combined is twenty-five long, called the accumulation of ju. Thus what Yu (禹) used to rule the world, these numbers generated."
Original Chinese. 商高曰:“數之法,出於圓方。圓出於方,方出於矩。矩出於九九八十一。故折矩,以為句廣三,股脩四,徑隅五。既方之外,半其一矩。環而共盤,得成三、四、五。兩矩共長二十有五,是謂積矩。故禹之所以治天下者,此數之所生也。”
If the translation does not seem to make sense to you, it's because the original doesn't make much sense to me either, except that we know Shang Gao is talking about a right triangle with sides 3, 4, and 5; he's taking squares of the sides, and transforming the two smaller ones into the bigger one. He explained it with the use of ju, which is an instrument that is used to form right angles. How he did it was not clear at all.
Fortunately, a diagram and a rigorous proof of the Pythagorean Theorem was added to the book as a commentary by Zhao Shuang (赵爽) in 222 AD. Here is his diagram and a JavaFX applet that I wrote to make the transformations from c2 to a2 + b2 apparent.
The source code for the applet can be found here. It is the simplest kind of JavaFX application there is. I threw six triangles and three squares on the screen, and animated their rotation angles, fill colors, and opacity. Take a look at syntax of the animation:
var t = Timeline {
keyFrames: [ at(0.0s) { col=> Color.WHITE},
at(1.0s) { a2 => 0.0; a3 => 0.0; a4 => 0.0},
at(2.0s) { a2 => 90.0; a3 => 90.0; a4 => 90.0},
at(3.0s) { a3 => 90.0; a4 => 90.0},
at(4.0s) { a3 => 180.0; a4 => 180.0},
at(5.0s) { a4 => 180.0},
at(6.0s) { a4 => 270.0},
at(7.0s) { col=> Color.WHITE},
at(9.0s) { col=> Color.LIGHTGREEN},
at(10.0s) { b=> 0.0},
at(11.0s) { b=> 90.0},
at(12.0s) { c=> 0.0},
at(13.0s) { c=> -90.0},
at(14.0s) { o=> 0.0;},
KeyFrame { time: 14.0s
action: function() {
var q = stage.scene.content[0..1];
delete stage.scene.content[0..1];
insert q into stage.scene.content;
}
},
at(15.0s) { o=> 0.7 },
at(17.0s) { o=> 0.7 }]};
t.play();
Now that I've updated my workstation to Ubuntu 9.04 (for people who are puzzled by Ubuntu version numbers, like me six months ago, 9.04 is short for 2009-04; if the trend continues, the next version will be 9.10) which comes with the Sun JDK 1.6.0_13, including 64-bit new plugin and web start, I can play with JavaFX applets more easily. This post marks the official return of the applet (at least for me). The applet runs fine on in my browser. However, if you encounter any problem with the applet, please let me know so that I can try to fix the problems.
Dependency Injection Annotations To Come To A JVM Near You.
(Via Twitter, where else?)
Remember this (my blog reaction to Google Guice 1.0)? At the time I wondered:
Me:Guice, Or Something Like It, Should Be In The JDK
About the only thing that makes feel a little bit uncomfortable is the use of Guice specific imports in my application code.
Wouldn't it be nice if I don't have to do a
import com.google.inject.*;but do aimport java.lang.inject.*;instead?
It's been 779 days since then, but Bob Lee and Rod Johnson have just made public a (work-in-progress) JSR JSR ?: Annotations for Dependency Injection "to standardize a proven, non-controversial set of annotations that make injectable classes portable across frameworks."
Bob Lee: Five years ago, Spring 1.0 brought Java dependency injection into the mainstream. Three years later, Google Guice 1.0 introduced annotation-based dependency injection and made Java programming a little easier. Since then, developers have had to choose between a) writing external configuration or b) importing vendor-specific annotations.
Today, we hope to give developers the best of both worlds. Google Guice and SpringSource have partnered to standardize a proven, non-controversial set of annotations that make injectable classes portable across frameworks. At the moment, the set of specified annotations consists of:
- @Inject - Identifies injectable constructors, methods, and fields
- @Qualifier - Identifies qualifier annotations
- @Scope - Identifies scope annotations
- @Named - String-based qualifier
- @Singleton - Identifies a type that the injector only instantiates once
One additional interface is specified for use in conjunction with these annotations:
- Provider<T> - Provides instances of a type T. For any type T that can be injected, you can also inject Provider<T>.
QOTD: I'd Written FORTRAN Programs---John McCarthy
Guy Steele, Jr.: Q: What experience of practical computer programming did you have before 1958, before you tackled Lisp?John McCarthy: A: I'd written some FORTRAN programs.
View the Steele/McCarthy interview on InfoQ.
Friday Java Quiz: Shadowing A Variable Name
I haven't posted a quiz for 34 days. It's time to have one.
Q: Will the following code compile and run without exceptions under the ? If so, what will it print?
1 public class Foo { 2 public static void main(String[] args) { 3 int x = 1024; 4 { 5 int x = 2048; 6 System.out.println("In inner block, x = " + x); 7 } 8 System.out.println("In outer scope, x = " + x); 9 } 10 }