Archive

Comments on our presentation

We got a lot of questions and positiv feedback on our presentation and we are very thankful for that. There were also two persons who pointed out, what they believed was, mistakes/errors in our presentation. This post is about those errors.

First of all one person told us that when we draw our component in the paintComponent() method we must consider the space that the border will use. If the border uses five pixels on the edges then we cannot paint anything on those 5 pixels. Yes that’s understood and maybe we should have said it but our goal is to make the code, in the presentation, easy to understand and that’s why we didn’t include it.

Secondly someone told us that when we change the location of the component in the Kinetic Scrolling code we shouldn’t do it directly but instead do it later, probably by using SwingUtilities.invokeLater(). The reason was that every time we changed the location of the component events will be fired and the source of those events will be our KineticScrolling component. I don’t understand what’s wrong with that? I believe that the KineticScrolling component should be what caused the event and nothing else, At least as long as we are running on the EDT. I’m going to investigate this further and let you know what the right way is.

JavaFX Rocks

Yes I know that our presentations are named “Swing Rocks” but I just have to save that I think that JavaFX really Rocks. At least the new 1.2 version. The controls are really good looking, performance seems to have increased a lot and I know there are other really nice featues in this version. Can wait to start working with JavaFX.

JavaOne presentation finished

Today we held our presentation at JavaOne and I think it went alright. No tomatoes were thrown at us and all our demos worked as expected. We had a couple of questions that we, thankfully, could answer and some good discussions afterwards. Now it’s time to relax, attend a few sessions, have a few beers (not at the same time as the sessions) and perhaps start to think about our next application.

By the way someone commented on the thread safety (of lack of?) when we change the location of the Kinetic Scrolling component. Don’t know if it’s  a big deal but we will have a look at it before we open source the code. Thank you for telling us.

One more day

Now it’s only one day left until we get to get up ridiculously early, stand in way too many lines at various airport, and hopefully end up safe in San Francisco. I’m not that excited about the flight from Frankfurt to San Francisco, flights shouldn’t have to take a two-digit number of hours. I’ve bought a big battery for my little netbook, but I really hope to sleep through as much of the flight as possible. We aren’t super prepared for our talk yet, but we have some time to rehearse in San Francisco, and we’re both pretty confident that we’ll be ready well in time for thursday.

The last few days we’ve fixed the problem that prevented Feedjii from running on OS X, but our solution isn’t perfect yet. As we’ll probably be busy preparing for our talk in San Francisco, I wouldn’t count on a new beta release until we’re back home again. Feel free to drop us an e-mail if you’re going to JavaOne and feel like meeting up. I’m sure we’ll have time for a beer or two, despite our busy schedule :-)

Write once, run anywhere?

A lot of people have let us know that Feedjii doesn’t seem to play well with OS X. This is of course a shame, especially since I’m a long time mac-user. The thing most people seem to have problems with is the class com.sun.awt.AWTUtilities is missing. I could be wrong, but I believe this class was introduced in Java 6 update 10, and with the latest official Java version from Apple, I think all we’re getting is Java 6 update 7. In Feedjii, this class is used to create the (custom) rounded corners of the application window, and we should clearly have some kind of fallback mechanism here.

The somewhat embarrassing reason we didn’t test this ourselves is that I was totally convinced I couldn’t run Java 6 on my iMac. As far as I know, it’s only available for 64-bit Intel processors, and I simply didn’t think my Core 2 Duo was one of them. When I checked this morning, I was surprised to see that I actually had Java 6 installed, so I guess I was simply wrong. I hope we can add a nice workaround for this problem, and ultimately also get our application running on Java 5. Obviously without some of the bling-bling, but running nonetheless.

Thanks for your patience!

Beta version of Feedjii is available

It’s been a lot of work but finally we beleive that we have something that looks like a beta release of feedjii (just in time for JavaOne)

Start Feedjii here

Feel free to test run it, we are more than happy to hear what you think of it.

When JavaOne is over we plan to open source the entire application as well as individual components.

Scheduled

Our JavaOne presentation has now been assigned to a time slot in the conference schedule. Here are the details:

ID#: TS-5072
Title: Swing Rocks: A Tribute to Filthy-Rich Clients
Date: 04-JUN-09
Time: 09:30 AM-10:30 AM
Room: Hall E 135

Please note that the room assignment isn’t final, it might change based on the number of attendees who pre-roll. We really hope to see you there!

See you at … JavaOne!

Yup, it’s true, our presentation got accepted for JavaOne, so in a few short months we’re going to San Francisco! We’re thrilled about this, and we will spend the spring fine tuning Feedjii and our presentation. I’m personally most concerned about the language (english that is, not Java), my english used to be pretty good, but now it’s a bit rusty. I’m thinking about creative ways to practice, but I guess nothing beats meeting actual native speakers. Our presentation isn’t scheduled yet, but we’ll let you know about the time and date as soon as we know it. For now, all I can say that if you’re in San Francisco between the 1st and 5th of june, you know where to find us!

We’ll probably write a lot about our preparations here, and now you can follow us on Twitter as well. Have a nice weekend!

(Un)TimingFramework – solution

As I wrote in a previous post Timing Framework have been acting kind of strange lately. The problem is that when animating, say a movement (a simple moving line is enough), for two seconds the application takes much longer time and the result isn’t even close to good looking. A 2 second animation ends up taking 6 seconds and still doesn’t look good. Yes Houston we have a problem!!!

So I’ve been working on this problem for a couple of month and I’ve tried a lot of different things and tried to blame everything from Timing Framework and Java to Windows and the hardware and just when I was about to give up and accept the fact I stumbled apon the solution. And this time it’s really working.

So what’s the problem? It turns out that the problem is related to both Java and the native platform. Timing Framework uses a swing timer and the swing timer uses wait(time) and notify() internally. Unfortenately wait and notify lacks the kind of resolution that we need and to be more precise, on Windows, the resolution is approximately 16 ms. This means that the maximum frame rate that we can get is 1000(ms)/16(ms)  = 62 FPS. This is not enough for our application since we use an animation time of 2 seconds and in that time the component that we scroll moves 500-1500 pixels. That means, worst case, that each animation loop will make the component move 1500/(62*2) = 12 pixels. And i’m pretty sure that not even a drunk and half blind person won’t notice the choppy behaviour.

And the solution is….. simple. Write your own TimingSource.

A TimingSource is a class in TimingFramework that handles the timing and all you have to do is write 4 simple methods and add the new TimingSource to your Animation class and your done. I guess I don’t have to remind you NOT to use wait() and notify() in your solution? What should you use? Well I guess there are several ways to do it but we have done it as simple as possible and used Thread.sleep(time) which actually works as expected with an accurate precision. If you’re using Linux or some other operating system then  you don’t have this issue and I have no idé why you’ve read this far.

Below is our implementation of TimingSource. Note that this is a first version and no brain power has been consumed creating it. This will of cource change in the future.

public class NanoSource extends TimingSource {

	private long resolution;
	private boolean stop = false;

	@Override
	public void start() {
		new Thread() {

			@Override
			public void run() {
				while (!stop) {
					try {
						sleep(resolution);
					} catch (Exception e) {
						e.printStackTrace();
					}
					timingEvent();
				}
			}
		}.start();
	}

	@Override
	public void stop() {
		stop = true;
	}

	@Override
	public void setResolution(int res) {
		resolution = res;
	}

	@Override
	public void setStartDelay(int arg0) {
		// add delay
	}
}

And then all you have to do to make your Animator use your new TimingSource is:

Animator animator = new Animator(2000, timingTarget);
animator.setTimer(new NanoSource());
animator.start();

and your done.

That’s it for this time

Ps. Yes I know that we’ve promised to opensource/publish our feed reader and yes we are going to do exactly that but we need just a little bit more time. Ds.

Tips and Tricks

The Kinetic Scrolling component will be released very very soon but I ran into something exciting that I want to share with you:

1.  DebugGraphics is a Swing class that can really help when debugging your Swing applications. It supports three different modes: Buffered_Option (Show buffered operations in a separate Frame), Flash_Option (Flash graphics operations) and Log_Option (Log graphics operations).

I’ve tried the Flash_Option and efter some fine tuning of the DebugGraphics object (invoked setFlashColor and setFlashTime)  I saw some  easy to understand debug painting on the screen. All it does is flashing the next draw operation in a user defined color before painting the real operation. Neat.

2. Next is not that exiting (and if you thought the previous one was then your as big a geek as I am)  but at JFokus we got a question about JPanel and JComponent. We were talking about how to create your own component and said that you should override JComponent when someone asked why we didn’t override JPanel instead. Well we didn’t really know and to be honest we did just that in the beginning but switched to JComponent because it felt better. Anyway, the reason for using JComponent instead of JPanel is really simple: JPanel is meant to be used as a container for other components and because of that contains some extra logic for handling children. If you don’t want any overhead don’t use JPanel when writing your own component.

3. Have you read Swing links of the week by Kirill Grouchnikov? If not you’ve missed something. A month ago he decided to stop writing the much appreciated Swing links posts due to limited time. Nothing to do about it but the good news are that a guy named Jonathan Giles picked up the thread and are now writing Swing links of the week. Thank you. You can find his blog at http://www.jogiles.co.nz/blog/

4. Tip of the day: if you already haven’t, open the JComponent API and go through the methods and I promise that you will find a new useful method everytime you do. At least I do.

5. Do you know what happends when you press Ctrl-Shift-F1 when running a Swing application? You don’t? It prints out all information about all component in the visible Frame. LayoutManager, position, text values and everything else you might (or might not) want to know.

That’s it.