AStar: make it more reusable, write javadocs.

Signed-off-by: Jean-Yves Tinevez <jeanyves.tinevez@gmail.com>