Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8158195

Scaling of SVG images doesn't work javafx webkit

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 8u92
    • javafx
    • web
    • x86_64
    • generic

      FULL PRODUCT VERSION :
      java version "1.8.0_91"
      Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
      Java HotSpot(TM) Client VM (build 25.91-b14, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows 7 Service Pack 1

      A DESCRIPTION OF THE PROBLEM :
      Using transform: scale() does not work when setting it in the svg tag (<svg ...... transform="scale(2)"> or by setting the style attribute (transform: scale(2)). This works in every other browser.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create a simple SVG file. In the svg tag add the attribute transform: scale(1);
      <svg version="1.1" xmlns="http://www.w3.org/2000/svg"
      xmlns:xlink="http://www.w3.org/1999/xlink"
      viewBox="-100 -100 200 200" preserveAspectRatio="xMidYMid" xml:space="preserve"
      zoomAndPan="magnify" onload="diagramOnLoad(evt)" >

      <style>
      svg {
      transform: scale(1);
      }
      </style>


      <rect x="-100" y="-100" width="200" height="200" stroke-width="0.2" stroke="black" fill="lightgray" />
      <rect x="-50" y="-50" width="100" height="100" stroke-width="0.8" stroke="green" fill="none" />
      <circle cx="0" cy="0" r="80" stroke-width="0.8" stroke="red" fill="none" />

      <circle cx="0" cy="0" r="2" fill="orange" stroke="black" stroke-width="0.2" />
      <polyline stroke="black" stroke-width="0.2" points="0,-2 0,2 0,0 -2,0 2,0 0,0" fill="none" />
      </svg>


      2. Load the SVG file into a webkit browser
      3. Observe the size.
      4. Change the scale to 2. (transform: scale(2);)
      5. Load the SVG file into a Webkit browser



      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The zoom level should have changed.
      ACTUAL -
      No change to the diagram occurred. When you perform the same steps using IE, FireFox or Chrome, the zoom level changes.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package webviewsample;

      import java.io.File;

      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.layout.Region;
      import javafx.scene.paint.Color;
      import javafx.scene.web.WebEngine;
      import javafx.scene.web.WebView;
      import javafx.stage.FileChooser;
      import javafx.stage.Stage;

      @SuppressWarnings("restriction")
      public class SimpleSVGBrowser extends Application {
          private Scene scene;

          public class Browser extends Region {
           
              final WebView browser = new WebView();
              final WebEngine webEngine = browser.getEngine();
              final FileChooser fileChooser = new FileChooser();
              final Button fileChooserButton = new Button("Select File");
              
              File currentFile = null;
              public Browser(Stage stage) {

                  fileChooserButton.setOnAction(new EventHandler<ActionEvent>() {
                      @Override
                      public void handle(ActionEvent event) {
                          currentFile = fileChooser.showOpenDialog(null);
                           if(currentFile != null){
                                   webEngine.load("file:/"+currentFile);
                                  fileChooser.setInitialDirectory(currentFile.getParentFile());
                              }
                      }
                  });

                  
                  getChildren().add(browser);
                  getChildren().add(fileChooserButton);
              }
          }

          
          
          
          @Override
          public void start(Stage stage) throws Exception {
              // create scene
              stage.setTitle("Web View");
              Browser svgBrowser = new Browser(stage);
              scene = new Scene(svgBrowser, 750, 500, Color.web("#666970"));
              stage.setScene(scene);
              stage.show();
              
          }
          
          public static void main(String[] args) {
              launch(args);
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      No workaround. I have tried currentScale in the svg tag that did not work either.

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: