Reimplemented EventQueue; minor optimizations

Reimplemented EventQueue based on SortedSet to provide O(log n)
operation running time.

Fixed some rounding issues of the AlgorithmPainter class where
rounding was done with a simple (int) cast instead of performing
an actual rounding operation.
rearranged a formula
added stubs for some actions