double width = originalMaxX - originalMinX;
double minX = minXPercent * width + originalMinX;
double maxX = maxXPercent * width + originalMinX;
double minY = minYPercent * height + originalMinY;
double maxY = maxYPercent * height + originalMinY;
SubGraph subGraph = new SubGraph( graph, level );
if( graph.getVisibleNodes( level ).size() < 2000 || ( minXPercent == 0 && minYPercent == 0 && maxXPercent == 1 && maxYPercent == 1 ) )
{
subGraph.setEdges( graph.getVisibleEdges( level ) );
subGraph.setNodes( graph.getVisibleNodes( level ) );
return subGraph;
}
List<DNVNode> nodes = new ArrayList<DNVNode>( graph.getVisibleNodes( level ).values() );
DNVNode tempNode;
if( nodes != null )
{
for( Iterator<DNVNode> i = nodes.iterator(); i.hasNext(); )
{
tempNode = i.next();
if( tempNode.isVisible() && isNodeWithin( tempNode, minX, minY, maxX, maxY ) )
{
// Add the node
subGraph.add( tempNode );
// Add all the neighbor nodes
subGraph.addAllNodes( tempNode.getNeighbors( true ) );
// Add the edges to all the neighbors
subGraph.addAllEdges( tempNode.getFromEdges( true ) );
subGraph.addAllEdges( tempNode.getToEdges( true ) );
}
}
}
return subGraph;