Map<String, Integer> drawnHeadings, boolean drawNumberOfNodesInBox, boolean drawNeighborHighlightAsBoxes,
boolean drawAllNeighborsHighlight, boolean alignBoxInfoRelativeToBox, Map<String, Boolean> headerAlignment )
{
if( nodes != null )
{
Vector2D maxPos = new Vector2D( Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY );
Vector2D minPos = new Vector2D( Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY );
float maxRadius = Float.NEGATIVE_INFINITY;
synchronized( nodes )
{
maxRadius = getBoundaries( nodes, maxPos, minPos, maxRadius );
}
Vector2D maxPosScreen = transformPosition( minX, maxX, minY, maxY, minXPercent, maxXPercent, minYPercent, maxYPercent, width, height,
maxPos );
Vector2D minPosScreen = transformPosition( minX, maxX, minY, maxY, minXPercent, maxXPercent, minYPercent, maxYPercent, width, height,
minPos );
maxPosScreen.setX( maxPosScreen.getX() + maxRadius * nodeWidth );
maxPosScreen.setY( maxPosScreen.getY() + maxRadius * nodeWidth );
minPosScreen.setX( minPosScreen.getX() - maxRadius * nodeWidth );
minPosScreen.setY( minPosScreen.getY() - maxRadius * nodeWidth );
for( DNVNode node : allNodes.values() )
{
if( nodes.get( node.getId() ) == null )
{
// This is not one of the nodes inside the box
Vector2D screenPos = transformPosition( minX, maxX, minY, maxY, minXPercent, maxXPercent, minYPercent, maxYPercent, width,
height, node.getPosition() );
float x = screenPos.getX();
float y = screenPos.getY();
if( x >= minPosScreen.getX() && x <= maxPosScreen.getX() && y >= minPosScreen.getY() && y <= maxPosScreen.getY() )
{
// this node overlaps with the box, so don't draw it
if( !drawAllNeighborsHighlight )
{
return 0;
}
}
}
}
if( drawNeighborHighlightAsBoxes )
{
g2d.setColor( new Color( fillColor.getX(), fillColor.getY(), fillColor.getZ(), 0.7f ) );
g2d.fillRoundRect( (int)Math.round( minPosScreen.getX() ), (int)Math.round( minPosScreen.getY() ),
(int)Math.round( maxPosScreen.getX() - minPosScreen.getX() ), (int)Math.round( maxPosScreen.getY() - minPosScreen.getY() ),
10, 10 );
g2d.setStroke( new BasicStroke( 3 ) );
g2d.setColor( new Color( outlineColor.getX(), outlineColor.getY(), outlineColor.getZ(), 0.7f ) );
g2d.drawRoundRect( (int)Math.round( minPosScreen.getX() ), (int)Math.round( minPosScreen.getY() ),
(int)Math.round( maxPosScreen.getX() - minPosScreen.getX() ), (int)Math.round( maxPosScreen.getY() - minPosScreen.getY() ),
10, 10 );
}
else
{
for( DNVNode node : nodes.values() )
{
Vector3D color;
if( !node.hasProperty( "originalColor" ) )
{
node.setProperty( "originalColor", node.getColor().toString() );
color = fillColor;
}
else
{
color = new Vector3D( node.getColor() );
color.add( fillColor );
color.dotProduct( 0.5f );
}
node.setColor( color );
}
}
Vector2D position = new Vector2D();
Vector2D selectedNodeScreenPos = transformPosition( minX, maxX, minY, maxY, minXPercent, maxXPercent, minYPercent, maxYPercent, width,
height, selectedNode.getPosition() );
float xDiff = Math.abs( selectedNodeScreenPos.getX() - ( minPosScreen.getX() + ( maxPosScreen.getX() - minPosScreen.getX() ) / 2.0f ) );
float yDiff = Math.abs( selectedNodeScreenPos.getY() - ( minPosScreen.getY() + ( maxPosScreen.getY() - minPosScreen.getY() ) / 2.0f ) );
String key;
if( alignBoxInfoRelativeToBox )
{
if( headerAlignment.containsKey( "X-align" + selectedNode.getId() )
|| ( !headerAlignment.containsKey( "Y-align" + selectedNode.getId() ) && xDiff >= yDiff ) )
{
headerAlignment.put( "X-align" + selectedNode.getId(), true );
position = new Vector2D( minPosScreen.getX() + ( maxPosScreen.getX() - minPosScreen.getX() ) / 2.0f, 14 );
key = "X" + hops;
if( !drawnHeadings.containsKey( key ) )
{
Text t = new Text( "Dist " + hops, position, new Vector3D( 1, 1, 1 ), fillColor, 12, true, true, true, false, false, false,
true );
t.draw( g2d, pb, minXPercent, maxXPercent, minYPercent, maxYPercent, minX, maxX, minY, maxY, nodeWidth, height, overview );
drawnHeadings.put( key, 1 );
}
else
{
drawnHeadings.put( key, drawnHeadings.get( key ) + 1 );
}
}
else
{
headerAlignment.put( "Y-align" + selectedNode.getId(), true );
position = new Vector2D( 35, minPosScreen.getY() + ( maxPosScreen.getY() - minPosScreen.getY() ) / 2.0f );
key = "Y" + hops;
if( !drawnHeadings.containsKey( key ) )
{
Text t = new Text( "Dist " + hops, position, new Vector3D( 1, 1, 1 ), fillColor, 12, true, true, true, false, false, false,
true );
t.draw( g2d, pb, minXPercent, maxXPercent, minYPercent, maxYPercent, minX, maxX, minY, maxY, nodeWidth, height, overview );
drawnHeadings.put( key, 1 );
}
else
{
drawnHeadings.put( key, drawnHeadings.get( key ) + 1 );
}
}
}
else
{
position = new Vector2D( 70 * hops, 14 );
key = "Align" + hops;
if( !drawnHeadings.containsKey( key ) )
{
Text t = new Text( "Dist " + hops, position, new Vector3D( 1, 1, 1 ), fillColor, 12, true, true, true, false, false, false, true );
t.draw( g2d, pb, minXPercent, maxXPercent, minYPercent, maxYPercent, minX, maxX, minY, maxY, nodeWidth, height, overview );