public void setMargin ( Rectangle2D bounds , Direction ... dirs ) { for ( Direction dir : dirs ) { switch ( dir ) { case BOTTOM : combinedTransform . transform ( userBounds . getCenterX ( ) , userBounds . getMinY ( ) , ( x , y ) -> { inverse . transform ( x , y + bounds . getHeight ( ) , this :: updatePoint ) ; } ) ; break ; case LEFT : combinedTransform . transform ( userBounds . getMinX ( ) , userBounds . getCenterY ( ) , ( x , y ) -> { inverse . transform ( x - bounds . getWidth ( ) , y , this :: updatePoint ) ; } ) ; break ; case RIGHT : combinedTransform . transform ( userBounds . getMaxX ( ) , userBounds . getCenterY ( ) , ( x , y ) -> { inverse . transform ( x + bounds . getWidth ( ) , y , this :: updatePoint ) ; } ) ; break ; case TOP : combinedTransform . transform ( userBounds . getCenterX ( ) , userBounds . getMaxY ( ) , ( x , y ) -> { inverse . transform ( x , y - bounds . getHeight ( ) , this :: updatePoint ) ; } ) ; break ; } } }
Enlarges margin in screen coordinates to given directions