use of prefuse.data.Node in project jo-client-platform by jo-source.
the class BeanRelationGraphImpl method contractExpandNodes.
private void contractExpandNodes(final Node node) {
if (node.get("expanded") == Expand.FULL) {
final Set<Node> outNodes = setEdges(node, false);
node.set("expanded", Expand.NOT);
final Iterator<Node> iteratorOutNodes = outNodes.iterator();
while (iteratorOutNodes.hasNext()) {
final Node elem = iteratorOutNodes.next();
contractExpandNodes(elem, false);
setNeighborEdges(elem, false);
checkExpandLevel(elem);
}
} else if (node.get("expanded") == Expand.NOT) {
final Set<Node> outNodes = setEdges(node, true);
node.set("expanded", Expand.FULL);
addNodeToCache(node);
final Iterator<Node> iteratorNodes = outNodes.iterator();
while (iteratorNodes.hasNext()) {
final Node elem = iteratorNodes.next();
loadModel(elem, false);
setNeighborEdges(elem, true);
checkExpandLevel(elem);
if (expandedNodesCache.contains(elem)) {
elem.set("expanded", Expand.NOT);
contractExpandNodes(elem);
}
}
}
}
use of prefuse.data.Node in project jo-client-platform by jo-source.
the class BeanRelationGraphImpl method setEdges.
private Set<Node> setEdges(final Node node, final boolean visible) {
final Set<Node> outNodes = new HashSet<Node>();
final Iterator<?> outEdges = node.outEdges();
while (outEdges.hasNext()) {
final Edge out = (Edge) outEdges.next();
outNodes.add(out.getTargetNode());
out.set("visible", visible);
}
return outNodes;
}
use of prefuse.data.Node in project jo-client-platform by jo-source.
the class BeanRelationGraphImpl method checkExpandLevel.
private void checkExpandLevel(final Node node) {
final Iterator<?> parents = node.inNeighbors();
while (parents.hasNext()) {
final Node parent = (Node) parents.next();
final int outEdges = parent.getOutDegree();
int count = 0;
final Iterator<?> itEdges = parent.outEdges();
while (itEdges.hasNext()) {
if ((Boolean) ((Edge) itEdges.next()).get("visible")) {
count++;
}
}
if (count == 0) {
parent.set("expanded", Expand.NOT);
} else if (count > 0 && count < outEdges) {
parent.set("expanded", Expand.PARTIALLY);
} else if (count == outEdges) {
parent.set("expanded", Expand.FULL);
}
}
}
use of prefuse.data.Node in project jo-client-platform by jo-source.
the class BeanRelationGraphImpl method initializeDisplayControlListener.
private void initializeDisplayControlListener() {
display.addControlListener(new DragControl() {
@Override
public void itemDragged(final VisualItem item, final MouseEvent e) {
if (layoutManager.getLabelEdgeLayout() != null) {
layoutManager.getLabelEdgeLayout().run();
super.itemDragged(item, e);
}
}
@Override
public void itemReleased(final VisualItem item, final MouseEvent e) {
item.set("position", new Point((int) item.getX(), (int) item.getY()));
super.itemReleased(item, e);
}
});
display.addControlListener(new PanControl());
display.addControlListener(new ZoomControl());
display.addControlListener(new WheelZoomControl());
display.addControlListener(new ZoomToFitControl());
display.addControlListener(new NeighborHighlightControl());
display.addControlListener(new FocusControl(NODES, 1) {
@Override
public void itemClicked(final VisualItem item, final MouseEvent e) {
if (item.isInGroup(EDGES)) {
return;
}
final int row = item.getRow();
final Node node = graph.getNode(row);
final double scale = display.getScale();
if ((Boolean) item.get("isParent")) {
if (item.get("expanded") == Expand.PARTIALLY) {
if (checkExpandIconHit(false, item, e, scale)) {
item.set("expanded", Expand.FULL);
loadModel(node, true);
runFilter();
return;
} else if (checkExpandIconHit(true, item, e, scale)) {
item.set("expanded", Expand.NOT);
loadModel(node, true);
runFilter();
return;
}
} else if (item.get("expanded") == Expand.FULL || item.get("expanded") == Expand.NOT) {
if (checkExpandIconHit(false, item, e, scale)) {
loadModel(node, true);
runFilter();
return;
}
}
}
if ((Boolean) node.get("marked")) {
node.set("marked", false);
markedNode = null;
} else {
node.set("marked", true);
markedNode = (NodeItem) item;
}
vis.run("marked");
runFilter();
runLayout(true);
}
});
final ToolTipControl ttc = new ToolTipControl("tooltip");
display.addControlListener(ttc);
}
use of prefuse.data.Node in project jo-client-platform by jo-source.
the class BeanRelationGraphImpl method addNodeToCache.
private void addNodeToCache(final Node node) {
if (expandedNodesCache.contains(node)) {
return;
}
if (expandedNodesCache.size() > MAX_EXPANDED_NODES_CACHE) {
final Node keyToRemove = expandedNodesCache.iterator().next();
expandedNodesCache.remove(keyToRemove);
}
expandedNodesCache.remove(node);
expandedNodesCache.add(node);
}
Aggregations