public DataMountain(Table t) {
super(new Visualization());
m_vis.addTable("data", t);
LabelRenderer nodeRenderer = new LabelRenderer(null, "image");
nodeRenderer.setTextField(null);
nodeRenderer.setVerticalAlignment(Constants.BOTTOM);
nodeRenderer.setHorizontalPadding(0);
nodeRenderer.setVerticalPadding(0);
nodeRenderer.setMaxImageDimensions(100,100);
m_vis.setRendererFactory(new DefaultRendererFactory(nodeRenderer));
ActionList init = new ActionList();
init.add(new RandomLayout());
init.add(new DataMountainSizeAction());
m_vis.putAction("init", init);
ActionList update = new ActionList();
update.add(new DataMountainSizeAction());
update.add(new ColorAction("data", VisualItem.STROKECOLOR) {
public int getColor(VisualItem item) {
return ColorLib.rgb((item.isHover() ? 255 : 0), 0, 0);
}
});
update.add(new RepaintAction());
m_vis.putAction("update", update);
// we run this to make sure the forces are stabilized
ActionList preforce = new ActionList(1000);
preforce.add(new DataMountainForceLayout(true));
m_vis.putAction("preforce", preforce);
// this will cause docs to move out of the way when dragging
final ForceDirectedLayout fl = new DataMountainForceLayout(false);
ActivityListener fReset = new ActivityAdapter() {
public void activityCancelled(Activity a) {
fl.reset();
}
};
ActionList forces = new ActionList(Activity.INFINITY);
forces.add(fl);
forces.add(update);
forces.addActivityListener(fReset);
m_vis.putAction("forces", forces);
setSize(640,450);
setDamageRedraw(false); // disable due to Java2D image clipping errors
setBorder(BorderFactory.createEmptyBorder(30,20,5,20));
setItemSorter(new DataMountainSorter());
addControlListener(new DataMountainControl());
// pre-load images, otherwise they will be loaded asynchronously
nodeRenderer.getImageFactory().preloadImages(m_vis.items(),"image");
// initialize and present the interface
m_vis.run("init");
m_vis.runAfter("preforce", "update");
m_vis.run("preforce");