use of prefuse.visual.NodeItem in project qi4j-sdk by Qi4j.
the class StackedGraphDisplay method setSelectedValue.
@Override
public void setSelectedValue(Object object) {
if (object == null) {
return;
}
NodeItem item = null;
Iterator iter = m_vis.items(GRAPH_NODES);
while (iter.hasNext()) {
NodeItem tItem = (NodeItem) iter.next();
Object tObj = tItem.get(USER_OBJECT);
if (tObj.equals(object)) {
item = tItem;
break;
}
}
if (item != null) {
int depth = item.getDepth();
boolean relayout = false;
if (depth > stackedLayout.getZoom()) {
stackedLayout.zoom(depth);
relayout = true;
}
TupleSet ts = m_vis.getFocusGroup(Visualization.FOCUS_ITEMS);
ts.setTuple(item);
if (relayout) {
run();
} else {
m_vis.run(AUTO_PAN_ACTION);
}
}
}
use of prefuse.visual.NodeItem in project qi4j-sdk by Qi4j.
the class StackedLayout method run.
@Override
public void run(double frac) {
// setup
NodeItem root = getLayoutRoot();
layout(root, 0, 0);
Rectangle2D bounds = root.getBounds();
Display display = this.getVisualization().getDisplay(0);
Dimension size = new Dimension((int) bounds.getWidth(), (int) bounds.getHeight());
display.setSize(size);
if (!display.isValid()) {
display.validate();
}
}
use of prefuse.visual.NodeItem in project qi4j-sdk by Qi4j.
the class StackedLayout method arrangeChildHorizontally.
private void arrangeChildHorizontally(NodeItem parent) {
double maxH = 0;
for (int i = 0; i < parent.getChildCount(); i++) {
NodeItem node = (NodeItem) parent.getChild(i);
Rectangle2D bounds = node.getBounds();
maxH = Math.max(maxH, bounds.getHeight());
}
for (int i = 0; i < parent.getChildCount(); i++) {
NodeItem node = (NodeItem) parent.getChild(i);
Rectangle2D bounds = node.getBounds();
node.setBounds(bounds.getX(), bounds.getY(), bounds.getWidth(), maxH);
}
}
use of prefuse.visual.NodeItem in project qi4j-sdk by Qi4j.
the class StackedLayout method layout.
private void layout(NodeItem node, double x, double y) {
Dimension minSize = getItemMinSize(node, null);
node.setBounds(x, y, minSize.width, minSize.height);
int depth = node.getDepth();
if (depth > zoom) {
//System.out.println("depth: " + depth + " zoom: " + zoom);
node.setBounds(x, y, 0, 0);
node.setVisible(false);
} else {
node.setVisible(true);
}
double cx = x + INSET;
double cy = y + minSize.height;
Area area = new Area(node.getBounds());
boolean hasChild = false;
for (int i = 0; i < node.getChildCount(); i++) {
hasChild = true;
NodeItem child = (NodeItem) node.getChild(i);
layout(child, cx, cy);
area.add(new Area(child.getBounds()));
// shifting location calculation
Rectangle2D nodeRect = child.getBounds();
if (depth == 0) {
// layer
cy = cy + (INSET * 2) + nodeRect.getHeight();
}
if (depth == 1) {
// module
cx = cx + INSET + nodeRect.getWidth();
} else if (depth == 2) {
// type container
cx = cx + INSET + nodeRect.getWidth();
} else if (depth == 3) {
// type
cy = cy + INSET + nodeRect.getHeight();
}
}
Rectangle2D bounds = area.getBounds2D();
if (hasChild && depth <= zoom) {
bounds.setRect(x, y, bounds.getWidth() + INSET, bounds.getHeight() + INSET);
}
node.setBounds(x, y, bounds.getWidth(), bounds.getHeight());
//int depth = parent.getDepth();
if (depth == 0) {
arrangeChildVertically(node);
} else if (depth == 1) {
arrangeChildHorizontally(node);
} else if (depth == 2) {
arrangeChildHorizontally(node);
} else if (depth == 3) {
arrangeChildVertically(node);
}
}
use of prefuse.visual.NodeItem in project qi4j-sdk by Qi4j.
the class StackedLayout method arrangeChildVertically.
private void arrangeChildVertically(NodeItem parent) {
double maxW = 0;
for (int i = 0; i < parent.getChildCount(); i++) {
NodeItem node = (NodeItem) parent.getChild(i);
Rectangle2D bounds = node.getBounds();
maxW = Math.max(maxW, bounds.getWidth());
}
for (int i = 0; i < parent.getChildCount(); i++) {
NodeItem node = (NodeItem) parent.getChild(i);
Rectangle2D bounds = node.getBounds();
node.setBounds(bounds.getX(), bounds.getY(), maxW, bounds.getHeight());
}
}