Red Black Tree Visualization using HTML5 Canvas and GWT

I created a sample app that demonstrates HTML5 Canvas usage from Java through GWT. I think GWT is an excellent tool for migrating desktop apps into Web nowadays, especially for Java developers. So it’s worth giving it a try. Google has made significant progress on migrating desktop apps into Web during the last year. They propagated trend for HTML5 support and Javascript JIT compilers among modern browsers. So it’s possible to run Quake 2 or CAD software directly in browser at decent speed. Red Black Tree is a balanced BST tree. Details are described on Wikipedia. You can run this sample app directly on appspot (it works on iPhone too :-) ) Sample code can be found here: Browse on GitHub. Let’s start from initialization. First, we need to create Canvas element and add it to HTML. getContext2D is called to obtain drawing context. We register a timer to redraw frames frequently: So doUpdate is called every 50 ms and whenever redrawFrame is set to true, it redraws Canvas contents. In autoplay mode, we call processFrame in while loop. So whenever redraw procedure takes too long, we will process frames without redrawing them. This won’t slow down animation on low resources. Then, we need to draw a tree. We use drawTree procedure, which is recursive and draws nodes along with contents and connections between them: The best part is that we can do regular Java unit tests on Red Black tree to verify the correctness of implementation:

You May Also Like

Use asInstanceOf[T] carefully!

BackgroundScala has nice static type checking engine but from time to time there are situations when we must downcast some general object. If this casting is not possible we expect that virtual machine will throw ClassCastExeption as fast as possible. ...

[:en] Operational problems with Zookeeper

This post is a summary of what has been presented by Kathleen Ting on StrangeLoop conference. You can watch the original here: http://www.infoq.com/presentations/Misconfiguration-ZooKeeper I've decided to put this selection here for quick reference. ...This post is a summary of what has been presented by Kathleen Ting on StrangeLoop conference. You can watch the original here: http://www.infoq.com/presentations/Misconfiguration-ZooKeeper I've decided to put this selection here for quick reference. ...

Micro services on the JVM part 1 – Clojure

Micro services could be a buzzword of 2014 for me. Few months ago I was curious to try Dropwizard framework as a separate backend, but didn’t get the whole idea yet. But then I watched a mind-blowing “Micro-Services Architecture” talk by Fred George. Also, the 4.0 release notes of Spring covers microservices as an important rising trend as well. After 10 years of having SOA in mind, but still developing monoliths, it’s a really tempting idea to try to decouple systems into a set of independently developed and deployed RESTful services.

Micro services could be a buzzword of 2014 for me. Few months ago I was curious to try Dropwizard framework as a separate backend, but didn’t get the whole idea yet. But then I watched a mind-blowing “Micro-Services Architecture” talk by Fred George. Also, the 4.0 release notes of Spring covers microservices as an important rising trend as well. After 10 years of having SOA in mind, but still developing monoliths, it’s a really tempting idea to try to decouple systems into a set of independently developed and deployed RESTful services.