Top posts

Latest articles


C# and custom drawing on the canvas

Posted by Jongerius under Development
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (No Ratings Yet)
Loading ... Loading ...

Part of the development of one of my pet projects, the UML Designer, requires some type of custom canvas to display the UML graphs. Sounds easy, especially since I’ve done similar things in Java. Unfortunately reality proves me wrong every time.

I started out by creating a custom component, which inherits from the Panel. This would give me pretty much a blank object that could be added to the GUI. The painting part on its own is not that difficult either. Done that hundreds of times. The problem is in adding the various objects to paint on top of the panel to the panel before drawing commences.

Ok, I’ll try to explain a little better. I keep track of what to draw in an array inside the custom panel. This because these objects contain more information then just how to draw. But they are not part of the component list of the panel. I need to add them dynamically just before drawing and remove them again after drawing. But I’ve yet to find the correct way of doing this.

Tried adding them in the onPaint method, but this doesn’t trigger them to be painted. So I’ll probably have to intercept the WM_PAINT message sent to the panel and attach the


Erasing partition stupidity

Posted by Jongerius under Development, General Rant
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (No Ratings Yet)
Loading ... Loading ...

Sometimes I just have the worst luck possible. Yesterday was one of those days. I recently had some issues with my HHD in my work laptop. So I thought why not install Ubuntu on a spare partition I never use.

So far for the good idea, but when Ubuntu asked me what partition to delete I wasn’t sure which was the spare one and which one contained all the source code of all applications and websites I developed. And you probably guessed it, I erased the wrong one.

Gone is a couple of days of work. Serves me right for not checking it in every day :-(


Advanced enum’s in Java

Posted by Jongerius under Development
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (1 votes, average: 5.00 out of 6)
Loading ... Loading ...

Ever since Java 1.4 the usage of the enum type is supported. For those who don’t know an enum is a more elegant way to store constant options. Below is a simple example of how it enhances your code:

public static final int ANIMAL_DOG    = 1;
public static final int ANIMAL_FISH   = 2;
public static final int ANIMAL_CAT    = 3;

Into something a bit more object oriented:

public enum Animal {
  Dog,
  Fish,
  Cat
}

But when you have the need to serialize the enum values then you may have to use a bit complicator code. It is supported just not out of the box. So lets say I want to predefine the ordinal number and add a name for each animal in my enum. Then I would have to add something similar to this:

public enum Animal {
  Dog(10, 'Swoop doggie'),
  Fish(20, 'Blub'),
  Cat(30, 'Garfunkel');

  int iOrdinal;
  String iName;

  private Animal(int aOrdinal, String aName) {
    iOrdinal = aOrdinal;
    iName = aName;
  }
}

Now each one of the enums values consists out of a name and a custom ordinal which can be used to save the value in a database or represent it in a form. Off course you would have to add methods to obtain the name and ordinal like:

public String getName()    { return iName; }
public int    getOrdinal() { return iOrdinal; }

That introduces a second problem, if you represent the enum Animal by its ordinal on for example a webpage you will need to be able to regenerate the correct enum value by its ordinal representation. To do this you could add a method to lookup the correct Animal for any ordinal like:

public static Animal getAnimal(int aOrdinal) {
 for(Animal lAnimal : values()) {
   if (lAnimal.getOrdinal() == aOrdinal) {
     return lAnimal;
   }
 }
 return Animal.Dog; // default value required
}

Started work on a Calendar plugin

Posted by Jongerius under Development, Webdevelopment
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (No Ratings Yet)
Loading ... Loading ...

Since my last work on a custom combobox went so smooth I decided that it is time to try and build yet another custom plugin for JQuery. This time round I’m building a custom calendar object. Now I know these already exists, but this is mostly an experiment to build more experience in developing for JQuery.

As this plugin will require a bit more work then the combobox I have no idea as to when I can release a first usable version. But as soon as I do I will publish it here ;-) .


PHP autoloader continued

Posted by Jongerius under Development, Webdevelopment
1 Star2 Stars3 Stars4 Stars5 Stars6 Stars (No Ratings Yet)
Loading ... Loading ...

A couple of days back I wrote something about some huge issues I had with the PHP autoloader technology. After reading up some more on the autoloader and some help from the PHP developers I finally tracked down the issue.

As it turns out the autoloader functionality is called when PHP is unable to find the class you are using automatically itself as a last effort. Though that wasn't the issue I encountered. It took me about 3 hours of debugging the function to find out there was a problem with the logic of the autoloader function I wrote myself, doh!

Something with breaking out of a loop to early :-( . After fixing this issue my autoloader was working beautifully. So I am happy to say that it is possible to write a modular PHP web application after all.

« Previous PageNext Page »