use of y.base.Node in project binnavi by google.
the class TypeDependenceGraph method addMember.
/**
* Adds a member to the dependence graph and returns the set of base types that are affected by
* the changed compound type. This method assumes that all base type nodes that correspond to the
* member base type already exist.
*
* @return The set of base types that are affected by the new member.
*/
public DependenceResult addMember(final BaseType parentType, final BaseType memberType) {
Preconditions.checkNotNull(parentType, "IE02762: Parent type can not be null.");
Preconditions.checkNotNull(memberType, "IE02763: Member type can not be null.");
final Node memberTypeNode = Preconditions.checkNotNull(containedRelationMap.get(memberType), "Type node for member type must exist prior to adding a member.");
final Node parentNode = Preconditions.checkNotNull(containedRelationMap.get(parentType), "Type node for member parent must exist prior to adding a member");
if (willCreateCycle(parentType, memberType)) {
return new DependenceResult(false, ImmutableSet.<BaseType>of());
}
containedRelation.createEdge(memberTypeNode, parentNode);
final TypeSearch search = new TypeSearch(containedRelationMap.inverse());
search.start(containedRelation, containedRelationMap.get(parentType));
return new DependenceResult(true, search.getDependentTypes());
}
use of y.base.Node in project binnavi by google.
the class TypeDependenceGraph method createTypeNode.
// Creates a new type node or returns an existing type node.
private static Node createTypeNode(final BaseType baseType, final Graph graph, final BiMap<BaseType, Node> map) {
final Node node = map.get(baseType);
if (node == null) {
final Node newNode = graph.createNode();
map.put(baseType, newNode);
return newNode;
} else {
return node;
}
}
use of y.base.Node in project binnavi by google.
the class ZyGraphNodeBuilder method convertNode.
/**
* Creates a graph node from a raw node.
*
* @param node The raw node that provides the underlying data.
* @param graph2D The graph object where the node is created.
* @param graphSettings Graph settings used to build the graph.
*
* @return The created YNode/NaviNode pair.
*/
public static Pair<Node, NaviNode> convertNode(final INaviViewNode node, final Graph2D graph2D, final ZyGraphViewSettings graphSettings) {
Preconditions.checkNotNull(node, "IE00909: Node argument can not be null");
Preconditions.checkNotNull(graph2D, "IE00910: Graph2D argument can not be null");
// Create the node in the Graph2D
final Node yNode = createNode(graph2D, node);
final ZyLabelContent content = ZyGraphNodeBuilder.buildContent(node, graphSettings, null);
final IZyNodeRealizer realizer = createRealizer(node, content);
// Associate the user data with the Graph2D node
final NaviNode zyNode = new NaviNode(yNode, realizer, node);
realizer.setUserData(new ZyNodeData<NaviNode>(zyNode));
realizer.updateContentSelectionColor();
graph2D.setRealizer(yNode, realizer.getRealizer());
return new Pair<Node, NaviNode>(yNode, zyNode);
}
Aggregations