question: private Rectangle2D createAlignedRectangle2D ( Size2D dimensions , Rectangle2D frame , HorizontalAlignment hAlign , VerticalAlignment vAlign ) { double x = Double . NaN ; double y = Double . NaN ; if ( hAlign == HorizontalAlignment . LEFT ) { x = frame . getX ( ) ; } else if ( hAlign == HorizontalAlignment . CENTER ) { x = frame . getCenterX ( ) - ( dimensions . width / 2.0 ) ; } else if ( hAlign == HorizontalAlignment . RIGHT ) { x = frame . getMaxX ( ) - dimensions . width ; } if ( vAlign == VerticalAlignment . TOP ) { y = frame . getY ( ) ; } else if ( vAlign == VerticalAlignment . CENTER ) { y = frame . getCenterY ( ) - ( dimensions . height / 2.0 ) ; } else if ( vAlign == VerticalAlignment . BOTTOM ) { y = frame . getMaxY ( ) - dimensions . height ; } return new Rectangle2D . Double ( x , y , dimensions . width , dimensions . height ) ; }
target:  Creates a rectangle that is aligned to the frame.