question: private static void fitToRectangle ( final PhyloTreeView treeView , final Rectangle rect ) { final PhyloTree tree = treeView . getPhyloTree ( ) ; double minX = Integer . MAX_VALUE ; double minY = Integer . MAX_VALUE ; double maxX = Integer . MIN_VALUE ; double maxY = Integer . MIN_VALUE ; for ( Node v = tree . getFirstNode ( ) ; v != null ; v = tree . getNextNode ( v ) ) { final Point2D loc = treeView . getLocation ( v ) ; minX = Math . min ( minX , loc . getX ( ) ) ; minY = Math . min ( minY , loc . getY ( ) ) ; maxX = Math . max ( maxX , loc . getX ( ) ) ; maxY = Math . max ( maxY , loc . getY ( ) ) ; } final double mX = ( ( maxX - minX ) != 0 ? rect . getWidth ( ) / ( maxX - minX ) : 0 ) ; final double mY = ( ( maxY - minY ) != 0 ? rect . getHeight ( ) / ( maxY - minY ) : 0 ) ; for ( Node v = tree . getFirstNode ( ) ; v != null ; v = tree . getNextNode ( v ) ) { final Point2D loc = treeView . getLocation ( v ) ; treeView . setLocation ( v , rect . getX ( ) + mX * ( loc . getX ( ) - minX ) , rect . getY ( ) + mY * ( loc . getY ( ) - minY ) ) ; } }
target:  fit coordinates into rect