public TreeMap(Tree t, String label) {
super(new Visualization());
// add the tree to the visualization
VisualTree vt = m_vis.addTree(tree, t);
m_vis.setVisible(treeEdges, null, false);
// ensure that only leaf nodes are interactive
Predicate noLeaf = (Predicate)ExpressionParser.parse("childcount()>0");
m_vis.setInteractive(treeNodes, noLeaf, false);
// add labels to the visualization
// first create a filter to show labels only at top-level nodes
Predicate labelP = (Predicate)ExpressionParser.parse("treedepth()=1");
// now create the labels as decorators of the nodes
m_vis.addDecorators(labels, treeNodes, labelP, LABEL_SCHEMA);
// set up the renderers - one for nodes and one for labels
DefaultRendererFactory rf = new DefaultRendererFactory();
rf.add(new InGroupPredicate(treeNodes), new NodeRenderer());
rf.add(new InGroupPredicate(labels), new LabelRenderer(label));
m_vis.setRendererFactory(rf);
// border colors
final ColorAction borderColor = new BorderColorAction(treeNodes);
final ColorAction fillColor = new FillColorAction(treeNodes);
// color settings
ActionList colors = new ActionList();
colors.add(fillColor);
colors.add(borderColor);
m_vis.putAction("colors", colors);
// animate paint change
ActionList animatePaint = new ActionList(400);
animatePaint.add(new ColorAnimator(treeNodes));
animatePaint.add(new RepaintAction());
m_vis.putAction("animatePaint", animatePaint);
// create the single filtering and layout action list
ActionList layout = new ActionList();
layout.add(new SquarifiedTreeMapLayout(tree));
layout.add(new LabelLayout(labels));
layout.add(colors);
layout.add(new RepaintAction());
m_vis.putAction("layout", layout);
// initialize our display
setSize(700,600);
setItemSorter(new TreeDepthItemSorter());
addControlListener(new ControlAdapter() {
public void itemEntered(VisualItem item, MouseEvent e) {
item.setStrokeColor(borderColor.getColor(item));
item.getVisualization().repaint();
}
public void itemExited(VisualItem item, MouseEvent e) {
item.setStrokeColor(item.getEndStrokeColor());
item.getVisualization().repaint();
}
});
searchQ = new SearchQueryBinding(vt.getNodeTable(), label);
m_vis.addFocusGroup(Visualization.SEARCH_ITEMS, searchQ.getSearchSet());
searchQ.getPredicate().addExpressionListener(new UpdateListener() {
public void update(Object src) {
m_vis.cancel("animatePaint");
m_vis.run("colors");