public static SVGUtils newInstance(Callback<ImageView, Void> callback) { return new SVGUtils(callback); }
private double getSvgWidth(WebEngine webEngine) { final Object result = getSvgDomProperty(webEngine, "offsetWidth"); //$NON-NLS-1$ if (result instanceof Integer) { return (Integer) result; } return -1; }
/** * This method will attempt to load the given svgImage URL into an ImageView node that will be * provided asynchronously via the provided {@link Callback}, and it will be sized to the given * prefWidth / prefHeight. * * <p> * Note that it is valid to pass in -1 to prefWidth and / or prefHeight as an indicator to the SVG * loader. If both values are -1, the default width of the SVG will be used. If one of the values is * -1, then the SVG will be sized to ensure that it remains proportional. * * @param svgImage The image to load. * @param prefWidth The preferred width of the image when loaded, or -1 if there is no preferred * width. * @param prefHeight The preferred height of the image when loaded, or -1 if there is no preferred * height. * @param callback The {@link Callback} that will be called when the SVG image is loaded, where the * {@link ImageView} containing the rendered image will be available. */ public void loadSVGImage(final URL svgImage, final double prefWidth, final double prefHeight) { loadSVGImage(svgImage, prefWidth, prefHeight, callback, null); }
/** * This method will attempt to load the given svgImage URL into the provided {@link WritableImage}, * with the SVG scaled to fit the size of the WritableImage. * * @param svgImage The image to load. * @param outputImage The location to write the loaded image once it has been rendered (it will not * happen synchronously). * @throws NullPointerException The outputImage argument must be non-null. */ public void loadSVGImage(final URL svgImage, final WritableImage outputImage) { if (outputImage == null) { throw new NullPointerException("outputImage can not be null"); //$NON-NLS-1$ } final double w = outputImage.getWidth(); final double h = outputImage.getHeight(); loadSVGImage(svgImage, w, h, null, outputImage); }
private double getSvgHeight(WebEngine webEngine) { final Object result = getSvgDomProperty(webEngine, "offsetHeight"); //$NON-NLS-1$ if (result instanceof Integer) { return (Integer) result; } return -1; }