Recently in Java Category

FXContainer v0.1

| 2 Comments | No TrackBacks
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 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...
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

Netbeans 6 has great Maven 2 support. Unfortunately, my company is still using Maven 1, and there's no change in sight. There are mevenide builds for Netbeans 6 available, but the plugin has trouble finding MAVEN_HOME, at least on Windows.

I scoured Jira, and found a fix. Assuming that you have already downloaded and installed the correct version of mevenide,  add the following entry to the netbeans_default_options variable in netbeans.conf: -J-DEnv-MAVEN_HOME=\"YourPathToMavenHome\". That's it!

Well, not quite. Adding this line fixes some of the problems, but the plugin itself it still very flawed on NB6.*, so much so that I am back to using NetBeans 5.5 for all of my development work. I can get the project to build, but that is about it. Here's a list of things I haven't figured out how to fix yet...

  1. NetBeans uses the JDK it is running on for code completion and error checking. So, if your project uses JDK 1.5, but your IDE is running on JDK 1.6, expect 1.6 level code completion and error checking.
  2. NetBeans is unable to resolve dependencies upon other maven projects. So, if project A depends upon project B, and both of them are in my workspace, NetBeans will draw red lines all over your code.
This is a real bummer because NetBeans 6 is a great IDE, and I'd love to use it as my every day IDE. Without Maven 1 support, it's a non starter.

Yahoo Maps in Swing!

| No Comments | No TrackBacks

I found a page documenting the tile naming schemes of the various online map providers today. With that information, and the JxMapViewer component from swingx-ws, I was able to hack together a Yahoo Maps mash-up in under an hour.

The code still has a bug in it: latitude / longitude do not translate correctly. The marker on the map should be placed on London. I'll have to do some more tweaking to see if I can finish this up. The code needed to do this is surprisingly short:

I said I wouldn't, but I did it anyway. This morning, I built a batch file and a pom to install the NetBeans distribution of Jax-WS into my local maven 2 repository. I based my approach on this post, which detailed the process using a unix shell.

I use Windows at work, so I created a batch file to install the jars and a pom into my local repository. The group ids for each package are the public group prepended with 'local'. To use the library, include the following dependency in your project pom:

<dependency>
       <groupId>local.sun.java.net</groupId>
       <artifactId>jaxws-ri</artifactId>
       <version>2.1</version>
       <type>pom</type>
</dependency>

You can download a zip file containing the jars and the bat file here: jaxws21.zip Just unzip and click install.bat.

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 an archive of recent entries in the Java category.

General is the previous category.

JavaFX is the next category.

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

Pages

OpenID accepted here Learn more about OpenID
Powered by Movable Type 4.31-en