Search This Blog

Tuesday, 19 October 2010

Quelea

So, I've started a new project on the side. It's something I've had on my mind for a while but something that I've never really had the incentive to start. Until now that is!

The project is essentially a lyrics projection system designed for use in churches, much like OpenLP, Opensong and Easyworship. All of the preceding are decent packages and I've used them all, but there's various things in each of them I like and don't like. The aim? To bring all the features I do like together into one neat, easy to use package that's comprehensive, reliable and open source. When I say "I" I actually mean a few people I've spoken to as well as myself - I'm definitely getting other input before ploughing ahead! :-)

The site's www.quelea.org - there's not much there at the moment but things are definitely on the way. (You may notice a few interesting things on there, I don't like to take everything quite 100% seriously!) I'm hoping by Christmas this year I'll have a bare bones working release to ship as an early alpha, and perhaps a few partially complete demos before then.

Technical details? It's written in Java, uses hsqldb for its song database and uses substance for its look and feel (might as well have something that looks nice when you get it for free! Definitely better than the default look and feel...) Swing can look pretty. Honest :-) Beyond that there's not an awful lot decided yet, though the schedule file format will probably be a zip file stuffed with XML files and resources required (vaguely like the new MS Office formats.)

Watch this space!

ListModel turns generic - at last

The features of project coin have been shouted about and argued over for a while now, and other various API changes have also made it into the spotlight - a fork-join framework in java.util.concurrent and the ability to have shaped windows for instance.

However, one thing that seems to have slipped under the spotlight is the fact that ListModel is now generic, a change that's well overdue in my opinion.

http://download-llnw.oracle.com/javase/7/docs/api/javax/swing/ListModel.html

Dealing with constant casting on list models thus far hasn't been nice, and I'm not sure why it's taken this long for the class to become generic - it's an obvious candidate and I struggle to see how it slipped under the carpet for both Java 5 and 6.

It's a relatively minor change in the grand scheme of things, but sometimes it's the minor changes that actually turn out to be the ones that work best and save most time. I'll certainly look forward to the day when I no longer need to cast everything coming out of listmodels!

Tuesday, 5 October 2010

Apricots

No, I haven't become addicted to the orange fruit growing on trees. But I have become a tad addicted to the game called apricots (again, nothing to do with the fruit and aside from "various reasons" I can't find any explanation as to why it's called this!)

It's a game where you have to fly a little plane around and shoot enemy bases whilst avoiding civilian houses, trees and skyscrapers. Grab it, it's free and has Linux and Windows versions: http://www.fishies.org.uk/apricots.html

It's rather simplistic, but highly addictive and I like the idea. Despite the fact the site claims it's still being developed, the last update was the best part of a decade ago, and after attempting to contact the author a while back and receiving no reply I'm pretty certain it's been abandoned. I'm considering taking the idea and rewriting it in Java with more modern looking graphics and gameplay - it'd be an interesting project on the side. That is if I can stop playing the thing...

Java puzzle - the solution

Though no-one's actually commented on the Java puzzle, I know at least two who attempted it... and one who, after a hint, got it bang on.

The key is that anonymous inner class that actually gets compiled into a separate class file - Main$1.class. It's this class that contains the code which prints out hello, so the following compiled and dropped in place would cause the program to print goodbye, without modifying Main.class:


package bosscode;

public class Main$1 implements Runnable {
public void run() {
System.out.println("goodbye");
}
}


The java.lang.Runnable in the original code was deliberately there to prevent the creation of an additional Runnable class in the bosscode package, which would have worked had Runnable not been declared with its package!

This actually highlights an interesting problem - it's entirely legal as far as the compiler's concerned to create a Main class and a Main$1 class in the same package, creating naming conflicts. Whilst this may seem unlikely, if the inner class isn't anonymous the name will take the form of Outer$Inner - so the potential is there to cause issues. In fact, whilst experimenting around with this puzzle in Netbeans it didn't show me any warnings that I'd created such a conflict, the last class to be compiled was just the one that dictated the output.

Of course, we can solve this problem altogether by never using a dollar sign in class names explicitly, reserving it as a special symbol for the compiler to use. I do wonder why this isn't strictly enforced though - it'd eliminate this problem (and this puzzle!) altogether.