1 19 20 28 29 package org.netbeans.modules.xml.nbprefuse.util; 30 31 import java.util.Iterator ; 32 import org.netbeans.modules.xml.nbprefuse.AnalysisConstants; 33 import prefuse.Visualization; 34 import prefuse.data.expression.Predicate; 35 import prefuse.data.expression.parser.ExpressionParser; 36 import prefuse.visual.EdgeItem; 37 import prefuse.visual.NodeItem; 38 39 43 public abstract class GraphUtilities { 44 45 46 53 public static void expandCollapseFileNode(NodeItem fileNode){ 54 if (fileNode == null){ 55 return; 56 } 57 Visualization vis = fileNode.getVisualization(); 58 boolean isExpanded = fileNode.getBoolean(AnalysisConstants.IS_EXPANDED); 59 fileNode.setBoolean(AnalysisConstants.IS_EXPANDED, !isExpanded); 60 61 Predicate p = (Predicate) 62 ExpressionParser.parse("["+AnalysisConstants.FILE_GROUP+"] = " + fileNode.getInt(AnalysisConstants.FILE_NODE_FILE_GROUP)); 64 vis.setVisible(AnalysisConstants.GRAPH_GROUP, p, !isExpanded); 65 66 67 Iterator outEdges = fileNode.outEdges(); 69 while(outEdges.hasNext()){ 70 EdgeItem edge = EdgeItem.class.cast(outEdges.next()); 71 if (edge.getString(AnalysisConstants.EDGE_TYPE).equals( 72 AnalysisConstants.FILE_EDGE_TYPE)){ 73 edge.setVisible(isExpanded); 74 } 75 } 76 } 77 78 } 79 | Popular Tags |