Latest Publications

Getting into the RC airplane thing

rc_com2_damage.jpg

A couple of weeks ago, I finally bought my first RC airplane. I always wanted to fly one of these things when I was a kid, but never got to it. When a new hobby shop opened near work, I decided to take a peek to see if I should get an RC boat. I went with a friend from work who convinced me to get an airplane instead, so I got the HobbyZone Firebird Commander 2 model. This is a starter 2 channel plane, with this thing called “ACT” (Anti-Crash Technology) that makes it easier for you to fly.

Well, the ACT is not magical as you can see from the picture above. On my first day, I couldn’t find any good size fields to fly the thing in the first place. So I ended up messing up the wing on the first 2 tries, only flying the plane for a few seconds. Finally I ended up at a bigger location, and was successful flying the plane for a lot longer. Unfortunately I couldn’t land it, I didn’t really have enough space for a proper landing, and in one of the landing attempts the plane just nose dived and crashed. The wind didn’t help either, I should have followed the instructions and flown it with no wing.

The damages from this first day included:
(more…)

The “I can’t find the object I put in the map” code blooper of the day

dead_fish1.jpg

This one is fairly easy to catch, but it was a self inflicted code blooper that had me thinking for a bit.

public class Key implements java.io.Serializable
{
  String key;

  public Key(String key)
  {
    this.key = key;
  }

  @Override
  public String toString()
  {
    return key;
  }

  @Override
   public int hashCode()
   {
      super.hashCode();
   }

   @Override
   @SuppressWarnings("unchecked")
   public boolean equals(Object obj)
   {
       boolean retval = false;

       if (obj != null && getClass() == obj.getClass())
       {
         Key other = (Key)obj;
         retval = other.getKey().equals(getKey());
       }

      return retval;
   }
}

I used this class as a key into a Map. We would send this map over a serialized stream, and on the other side we couldn’t get the values by using the same keys (the keys are static finals/constants).

See if you can spot the error … it’s a bit obvious …

OK, you found it.

Yeah, it’s the hashCode(). You probably know about the equals()/hashCode() rule when using Maps.
Don’t know how that “super” got in there, but that was the problem. Simple of course. As a side note, I’ve been using Netbeans 6 and it has some interesting suggestions for genearting your equals and hashCode() methods. On the equals, I was a bit surprised to see it was using “getClass() == obj.getClass()“, I thought it would do “getClass().equals(obj.getClass())“, just because when I compare non primitive types I’m used to using the equals() method. Somehow this works, I guess because class definitions are loaded once? Intuitively I feel this is not the right way, but it works and seems to be accepted convention.

To be quite honest, I’ve been using “instanceof” for the longest time, and up until recently I didn’t know there was a debate about that one.

The 1 billion dollar penguin

I was on the way back from a trip, and at the JFK airport I decided to buy a couple of things for my girls. I picked an origami book and a plush “emperor” penguin doll. The lady at the counter just rings up the penguin and it comes up as totaling a billion dollars (including taxes)!

dsc08159.jpg

The poor lady at the counter couldn’t cancel the order for some reason, so she called another lady to help her, who called their manager, who called the main finance person, who then called some guy. I think they had like 5 people trying to figure out what happened to this register.

 

dsc08164.jpg

They took me to another store to pay for the item, which cost about 6$. It’s kind of funny, but I would have thought these cash registers wouldn’t even charge over a million dollars, specially at a store like this.

WHERE IS MY MOUSE?!?!? Based on a true event

This actually happened to me recently in real life. It was so bizarre I just had to capture it in cartoon form.

Click on comic strip to get the (readable) larger version …

mouse_attack_small.png

Just to clarify, the last panel showing me being attacked is not literally true, but in a funny way very close to the actual “exchange”. Needless to say, I did not take the mouse in question, although I wish I had. Would have made the whole thing funnier in the end.

A time to rest, a time to draw and a time to blog again …

this_tall_to_ride_small.jpg

Haven’t done much with some of my software projects outside of work lately, been kind of busy at work. Also took a nice little break over the 4th of July week, the family and I really needed that. I’m hoping to get back to blogging soon in a regular basis. In the meantime, here’s a drawing I’ve been working on recently, it didn’t take long to draw but I spent way too much time cleaning up the pencils and the line work. I think it’s time to invest in a graphic tablet.

JavaFX Clock update, now with transparency

This is an update to my previous entry “JavaFX Clock”.

jfxclock-transparent.jpg

I modified the code (JFXClock.fx) to use the JNA library so that the clock can be contained in a transparent window. I also added a right click menu (JFX is really cool for writing menus) so you can pause, resize and exit the application. I didn’t find a corresponding JFX wrapper class for JPopupMenu, but since you can call Java code from JFX it was doable. The syntax is a bit strange, you have to get a handle to the corresponding JComponent in order to add the menus to the popupmenu. I also miss isPopupTrigger(), but there’s an attribute to the mouse event class in jfx to get the mouse button “number”.

Transparent JFXClock

Opaque JFXClock

Updated! 

I was getting some strange exceptions with the example JNA jar file, but thanks to technomage it’s working much better now. I also added an “Alwas on Top” menu item.

Why are there two versions? Well, the Windows version pegs the CPU to almost 100% in my machine. There is some issue with some of the code that JNA uses to handle transparent windows, and every time the clock animates it seems to throw a very long stack trace. Have to investigate what is happening, here’s the stack trace … I was even thinking of not posting this version, but at least it doesn’t lock up my PC. If you get in trouble remember you can stop the animation and everything should be back to normal.

The “opaque” version will turn off the transparency so at least you can play around with the clock outside of JFXPad.

I’m also interested in finding out if the transparent version works in other platforms other than XP. It should work fine on most Windows versions, not sure about Vista. Included in the JNLP download are the binaries for Windows, Linux and Apple (although for this effect, you don’t seem to need JNA in the Mac).

JavaFX Clock

javafx-clock.jpg

For my next JFX script I slightly modified the clock example Chris Oliver wrote, and added some artwork to it so it looks somewhat like one of the Google desktop gadgets I use. The gadget is very low res, so I decided to make the image files much bigger so users can resize it without it looking like a pixelated mess. I made the seconds hand jump every second instead of moving continuously, and like the gadget, it has a very quick animation that moves the hand back a bit to give it a “spring” feel.

The script is here:
http://sellmic.com/lab/dev/jfx/clock/Clock.fx

From JFXPad, you can just copy and paste that URL drag and drop the Clock.fx link into the ‘location’ text field then hit go, and the script will load and show the clock animation. (note: There’s some weird bug in JFXPad, were you can’t paste text)

I’m also thinking of making this a Glossitope gadget, but have to figure out how to load JFX in that environment.

Update to this entry in this post : JavaFX Clock update, now with transparency

Ewoks on a Plane

I did this some time ago, we were creating some really dumb parody posters of movie sequels that should never be made …

Parody poster

With Samuel L. Jackson, this could be considered a proper sequel to Return of the Jedi (maybe he’s a long lost relative to Mace Windu).

“Easy Deployment Is Finally Here” session, my notes

From the last couple of posts it seems my blog is turning into a JavaFX blog, but what I really want to do is make sure I capture some important notes from last week’s JavaOne before I forget eveything. One interesting session that surprised me was the “Easy Deployment is Finally Here” by Ethan Nicholas, I almost skipped it thinking it was going to be about some minor WebStart improvements. I’m glad I didn’t skip it, it was all about the new “Consumer JRE”.

Improved installation experience

First, the Java installer has gone through some minor yet very positive usability improvements.

new-jre-installer.jpg

Some changes to note:

  • The scary license is not shown anymore, unless the user chooses to view it.
  • “Custom setup” button has been removed, if you want to change the default installation folder, there’s a simpler “change” button right on the first screen.
  • The title bar now reads “Java Setup” instead of the full Java name with version and ugly ™ text.
  • The progress section of the installer now has a banner explaining what Java is.
  • Friendlier screen when installation is complete. It says “Thank you!” instead of “Complete”. It doesn’t use the word “wizard” (a developer’s term) and it offers the option to restart the browser automatically.

Not too exciting? Well, I’m a usability geek, so don’t be surprised :-) (more…)

My first JavaFX program

jfx-program

So for my first JFX program, I decided to animate my friend Carlos. He just starts from the left corner and when you click him goes all the way to the right. Nothing to fancy. The main purpose of this little program is just to get my head around the syntax, which is quite different from what I’m used to, and to learn a bit about how animation works.

What I’d like to do now is do a more complicated animation sequence, when the character goes to the right, I’d like to have him bounce a bit and then pause, then go back to the original position.

Also, if anybody knows how to cancel an animation let me know. If he’s animating and you click on the character a couple of times, he starts getting seizures.
(more…)