use of y.base.Node in project binnavi by google.
the class TypeDependenceGraph method deleteType.
/**
* Delete the given base type. If other types still depend on this type, the set of affected types
* is returned.
*
* @param baseType The base type to delete.
* @return Returns The set of base types that depend on the deleted type.
*/
public ImmutableSet<BaseType> deleteType(final BaseType baseType) {
Preconditions.checkNotNull(baseType, "IE02766: Base type can not be null.");
final Node containedTypeNode = containedRelationMap.get(baseType);
Preconditions.checkNotNull(containedTypeNode, "Unable to delete type: corresponding node not found in the dependence graph.");
final ImmutableSet<BaseType> affectedTypes = determineDependentTypes(baseType);
containedRelation.removeNode(containedTypeNode);
containedRelationMap.remove(baseType);
return affectedTypes;
}
use of y.base.Node in project binnavi by google.
the class ZyGraphBuilder method convertNodes.
/**
* Converts the nodes of a view into Graph2D nodes.
*
* @param nodes The nodes to convert.
* @param graph2D The graph where the nodes are inserted.
* @param rawNodeToNodeMap Keeps track of view node => graph node mappings.
* @param graphSettings Graph settings used to build the graph.
*/
private void convertNodes(final Collection<INaviViewNode> nodes, final Graph2D graph2D, final Map<INaviViewNode, Node> rawNodeToNodeMap, final ZyGraphViewSettings graphSettings) {
for (final INaviViewNode node : nodes) {
final Pair<Node, NaviNode> result = ZyGraphNodeBuilder.convertNode(node, graph2D, graphSettings);
// Keep track of the view node => Graph2D node mapping
rawNodeToNodeMap.put(node, result.first());
m_ynodeToNodeMap.put(result.first(), result.second());
}
}
use of y.base.Node in project binnavi by google.
the class ZyGraphBuilder method setupGroupNodes.
/**
* Puts nodes that have raw parent group nodes into the corresponding yFiles group nodes.
*
* @param nodes The nodes to be put into their parent group nodes.
* @param graph2D The yFiles graph the nodes belong to.
* @param rawNodeToNodeMap Maps between raw nodes and yFiles nodes.
*/
private static void setupGroupNodes(final Iterable<INaviViewNode> nodes, final Graph2D graph2D, final Map<INaviViewNode, Node> rawNodeToNodeMap) {
for (final INaviViewNode node : nodes) {
if (node.getParentGroup() != null) {
final Node child = rawNodeToNodeMap.get(node);
final Node parent = rawNodeToNodeMap.get(node.getParentGroup());
graph2D.getHierarchyManager().setParentNode(child, parent);
}
}
}
use of y.base.Node in project binnavi by google.
the class ZyGraphBuilder method convert.
/**
* Converts a view to a Graph2D object.
*
* @param nodes Nodes to convert.
* @param edges Edges to convert.
* @param graphSettings Graph settings used to build the graph.
* @param adjustColors True, to initialize the colors of the nodes. False, otherwise.
*
* @return The created Graph2D object.
* @throws LoadCancelledException Thrown if loading the graph was cancelled.
*/
public Graph2D convert(final Collection<INaviViewNode> nodes, final Collection<INaviEdge> edges, final ZyGraphViewSettings graphSettings, final boolean adjustColors) throws LoadCancelledException {
Preconditions.checkNotNull(nodes, "IE00905: View can not be null");
Preconditions.checkNotNull(edges, "IE00906: Edges argument can not be null");
if (!m_loadReporter.report(GraphBuilderEvents.Started)) {
throw new LoadCancelledException();
}
m_loadReporter.start();
final Graph2D graph2D = new Graph2D();
final HierarchyManager hierarchyManager = new HierarchyManager(graph2D);
graph2D.setHierarchyManager(hierarchyManager);
hierarchyManager.addHierarchyListener(new GroupNodeRealizer.StateChangeListener());
checkCancellation(GraphBuilderEvents.InitializedGraph);
// Keep track of all connections between view nodes and yfiles nodes
final HashMap<INaviViewNode, Node> rawNodeToNodeMap = new HashMap<INaviViewNode, Node>();
// To convert the view into a Graph2D object, it is necessary to convert every node
// and every edge from the view into the corresponding yfiles objects.
convertNodes(nodes, graph2D, rawNodeToNodeMap, graphSettings);
checkCancellation(GraphBuilderEvents.ConvertedNodes);
convertEdges(edges, graph2D, rawNodeToNodeMap, adjustColors);
checkCancellation(GraphBuilderEvents.ConvertedEdges);
setupGroupNodes(nodes, graph2D, rawNodeToNodeMap);
checkCancellation(GraphBuilderEvents.CreatedGroupNodes);
checkCancellation(GraphBuilderEvents.Finished);
return graph2D;
}
use of y.base.Node in project binnavi by google.
the class CViewGraphSynchronizer method updateParentNode.
/**
* Updates the parent group node of a node.
*
* @param node The node whose parent group node is updated.
* @param groupNode The new parent group node.
*/
private void updateParentNode(final INaviViewNode node, final INaviGroupNode groupNode) {
final Node mappedNaviNode = m_mappings.getYNode(node);
final Node mappedGroupNode = groupNode == null ? null : m_mappings.getYNode(groupNode);
if (mappedNaviNode != null) {
// We need this null-check here because a group node can lose all
// of its members to another group node while the group node itself
// is also added to the new group. Since empty group nodes are
// automatically removed, the original group node can already be
// removed from the graph before the changedParentGroup event is sent.
m_graph.getGraph().getHierarchyManager().setParentNode(mappedNaviNode, mappedGroupNode);
m_graph.updateViews();
}
}
Aggregations