Forums

Full Version: semantic zooming
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This demo shows how to implement sematic zooming - label rendering which reacts on how close/far the user zooms into/out of the graph.

Based on a solution by Jeffrey posted in the prefuse forum

http://sourceforge.net/forum/message.php?msg_id=3349056

In this demo, the renderer changes when the user zooms out far enough. (scale < 0.77)

The RenderFactory used in this demo
Code:
public class MyRendererFactory extends DefaultRendererFactory {
    private Display display;

    public MyRendererFactory(LabelRenderer lr,Display disp) {
        super(lr);
        this.display = disp;
    }

    public Renderer getRenderer(VisualItem item) {
        if (item.isInGroup(edges) || display.getScale() > 0.76)
            return super.getRenderer(item);
        else
            return new ShapeRenderer(26);
    }
}

Guest

Should be able to do the same thing with a predicate that gets the zoom amount and returns true when far away renderer when it gets to far out.

Dont know if it would be simpler, but it would mean you would not have to create your own class.

Grahar64
Hello Garhar,

sounds like an interesting solution.
It would be great if you can also post your solution in form of a modification of the GraphView demo. That would make it most likely more easy for others to compare the two solutions and choose the one more suitable for them (particular for newbies)

greets

martin
Reference URL's