public static <
          NodeType extends ZyGraphNode<?> & ISelectableNode & IViewableNode,
          EdgeType extends ZyGraphEdge<?, ?, ?>>
      void centerNodes(final AbstractZyGraph<NodeType, ?> graph, final Set<NodeType> nodes) {
    Preconditions.checkNotNull(nodes, "Error: Nodes argument is null");
    Preconditions.checkArgument(!nodes.isEmpty(), "Error: Nodes argument is empty");

    // To center all nodes, we calculate the bounding box that includes all nodes.
    final Rectangle2D box = GraphHelpers.calculateBoundingBox(nodes);

    // Center the graph to make sure all nodes are visible.
    graph
        .getView()
        .setCenter(box.getX() + (box.getWidth() / 2.), box.getY() + (box.getHeight() / 2.));

    graph.updateViews();
  }
Centers the screen on a list of nodes.

@param nodes The list of nodes in question.
java/zylib/src/main/java/com/google/security/zynamics/zylib/yfileswrap/gui/zygraph/functions/MoveFunctions.java