Recently in JavaFX Category

After playing around with the modification I made im my previous post to MediaView, I was able to come up with a solution that works for any Node you pass in. The class is called FXContainer. Its purpose it to scale its contents to whatever width & height you specify, while maintaining the aspect ratio of the original.

By default, this results in the "black bar" effect that you've probably seen used to maintain aspect ratio in movies. That is usually appropriate, but there are also times when you may want the content expanded to fit the FXContainer, while still respecting the aspect ratio. For example, you may want a background image to fill the entire frame, but not become distorted. That is what the fillDimensions attribute does.

Here are screenshots demonstating the FXContainer:
fillFalse.png fillTrue.png
Here is the source code.
You can run the demo via webstart below. I have pack200 enabled, which will greatly reduce the download size for those of you using the Java 1.6.10 beta.

Since the JavaFX Preview SDK was released, I have been toying around with its video support. Overall, it is really, really good. I'm impressed and I've only hit the tip of the iceberg. Of course, there is room for improvement. For example, the current MediaView class does not have any concept of width nor height, whereas the ImageView class does. I was able to fix that with this amazingly short piece of code.
Yes, that is really it. To use it, just swap out ImprovedMediaView for MediaView, and set your width, height, and fill like this...
The result looks like this:
imv-cap1.png
imv-cap2.png

In anticipation of the JavaFX SDK preview release, I have whipped up a very primitive JavaFX Script brush for Syntax Highlighter. Adding the brush is easy, so I will not bore you with boilerplate. Include the brush, set your code class to "jfx", and you get nicely highlighted JavaFX Script code on your blog!

Download the brush here: http://coffeejolts.com/downloads/shBrushJavaFX.js

Here is a sample from James Weaver's blog, highlighted using my brush:
Sun has posted some slides from a presentation on Java Media Components on the JavaONE website. Unfortunately, the demos weren't included, but the source code in the slides hints at a very simple to use media API.

For example:

I am SO looking forward to the SDK pre-release.
http://dsc.sun.com/learning/javaoneonline/2008/pdf/TS-6509.pdf

I was hacking around on the JavaFX 2D Tutorial application when I noticed a bug in the ImageView class. Setting antialias: true actually disables antialiasing; and setting antialias: false enables antialiasing.

antialias: true

antialias: false:

ClockUI.fx

I went back and applied this to the sellmic.com clock that I've been hacking on. You can launch the clock with antialiasing enabled below.


I have been playing around with the clock on http://sellmic.com/blog/2007/05/20/javafx-clock/, which is really cool. A number of people commented that the implementation was chewing up too many CPU cycles, so I decided to see if I could fix that. I found that the timer loop was the culprit. After modifying the code to use a Swing timer, CPU usage is almost 0%. You can launch the new Clock via webstart below.

Source
ClockUI.fx
JfxClock.fx

About this Archive

This page is a archive of recent entries in the JavaFX category.

Java is the previous category.

Mobile Computing is the next category.

Find recent content on the main index or look in the archives to find all content.

Pages

Powered by Movable Type 4.2-en