code: public static <S extends Shape> S resize(final S shape, final double width, final double height) {
  
          // compute original size
          final double originalWidth = shape.prefWidth(-1);
          final double originalHeight = shape.prefHeight(-1);
  
          final double scalingFactor = Math.min(width/originalWidth, height/originalHeight);
  
          // rescale
          shape.setScaleX(scalingFactor);
          shape.setScaleY(scalingFactor);
  
          return shape;
      }
docs: Method resize the given {@code Shape} with respect of its original aspect ratio but independent of its original size.
  
  Note: Out of performance reasons the given object will directly be manipulated.
  
  @param shape the shape to scale.
  @param width the width of the new shape.
  @param height the height of the new shape.
  @return the scaled {@code Shape} instance.