Java catch up to Go version

This patchset adds the mega pixel semantic and new object pattern to the Java version. It includes also some refactorings for readability and to be closer to the Go version. Whats still missing is the benchmark semantic.