Art Of Programming

musings by Dmytrii Nagirniak

Draw2d - Unpleasant Bug

I am using the draw2d library and implemented quite a lot of stuff already. I used one of samples to get started and was testing and playing with my implementation on a separate HTML page.

It was time to integrate client-side part with the server. I haven’t expected any problems.
So I just put all the stuff on a real page, implemented some C# code.

But after I started to play with my diagram I could not get context menu or double click on the connectors, I could not connect two figures…
Well, actually I could, but the connectors were at incorrect location of the screen and it looked like it is "shifted"…
See the problem now?

The problem is that a paint area should always start at top left absolute position. What a horrible discovery.

I spent lots of my time for this stuff and now it seems to be unacceptable.

The solution I found should solve the problem, BUT (as always, there’s a but) I should use NO NAMESPACE version of this library. I don’t really like it because of 2 reasons:

  1. I have to rewrite lots of code.
  2. It’s much more error prone and might conflict with other JavaScript implementation.

But I don’t see any choice for now. I have to start removing all the namespaces I used so carefully…

Comments