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

FX 8 3D : SubScene setFill and mouse event issues

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Cannot Reproduce
    • Affects Version/s: 8
    • Fix Version/s: 8
    • Component/s: javafx
    • Environment:

      JDK 8.0-b94, Linux, Mac, Windows

      Description

      1. LinearGradient and RadialGradient are not rendered correctly.
      2. If SubScene's parent has a Background set then SubScene receives mouse events only if SubScene.setFill() is set with a Paint object.

      package jiraissue;

      import javafx.application.Application;
      import javafx.event.EventHandler;
      import javafx.scene.Group;
      import javafx.scene.PerspectiveCamera;
      import javafx.scene.PointLight;
      import javafx.scene.Scene;
      import javafx.scene.SubScene;
      import javafx.scene.input.MouseEvent;
      import javafx.scene.layout.Background;
      import javafx.scene.layout.BackgroundFill;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.paint.Color;
      import javafx.scene.paint.CycleMethod;
      import javafx.scene.paint.LinearGradient;
      import javafx.scene.paint.RadialGradient;
      import javafx.scene.paint.Stop;
      import javafx.scene.shape.Cylinder;
      import javafx.stage.Stage;
      import javafx.stage.WindowEvent;

      public class SubSceneSetFill extends Application {
          
          public static void main(String[] args) {
              launch(args);
          }
          @Override public void start(Stage stage) {
              
              // SubScene

              final Group subSceneRoot = new Group();
              final SubScene subScene = new SubScene(subSceneRoot, 800, 800, true, false);
              
              final Stop[] stopsLG = new Stop[] {new Stop(0.0, Color.rgb(0, 73, 255)),
                                                 new Stop(0.7, Color.rgb(127, 164, 255)),
                                                 new Stop(1.0, Color.rgb(0, 73, 255))};
              final LinearGradient lg = new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, stopsLG);
              
              final Stop[] stopsRG = new Stop[]{new Stop(0.0, Color.LIGHTGRAY),
                                                new Stop(0.2, Color.BLACK),
                                                new Stop(1.0, Color.BLACK)};
              final RadialGradient rg = new RadialGradient(0, 0, 0.5, 0.5, 1, true, CycleMethod.NO_CYCLE, stopsRG);

              // Case 1. LinearGradient : strange position
      // subScene.setFill(rg);
              
              // Case 2. if SubScene's parent has a Background set
              // then SubScene receives mouse events only if
              // SubScene.setFill() is set with TRANSPARENT, an opaque Color, or Gradient
      // subScene.setFill(Color.YELLOWGREEN);
            
              // Test mouse events
              subScene.setOnMousePressed(new EventHandler<MouseEvent>() {
                  @Override public void handle(MouseEvent event) {
                      System.out.println("OnMousePressed = " + event);
                  }
              });

              // Viewing : Camera & Light
              
              // SubScene's camera
              final PerspectiveCamera perspectiveCamera = new PerspectiveCamera(true);
              perspectiveCamera.setFarClip(25);
              perspectiveCamera.setNearClip(0.1);
              perspectiveCamera.setFieldOfView(44);
              
              subScene.setCamera(perspectiveCamera);
             
              // SubScene's light
              final PointLight pointLight = new PointLight(Color.WHITE);
              pointLight.setTranslateZ(-20000);
                
              // Viewing group: camera and headlight
              final Group viewingGroup = new Group(perspectiveCamera, pointLight);
              viewingGroup.setTranslateZ(-5);
              
              // 3D model
              Cylinder cylinder = new Cylinder();
              
              subSceneRoot.getChildren().addAll(cylinder, viewingGroup);
              
              // Scene
              
              // SubScene's parent
              final BorderPane borderPane = new BorderPane();
              borderPane.setMinHeight(0);
              borderPane.setMinWidth(0);
              borderPane.setCenter(subScene);
              
              // Background
              borderPane.setBackground(new Background(new BackgroundFill(Color.YELLOW, null, null)));
                 
              final Scene scene = new Scene(borderPane, 850, 850, true);
             
              stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
                  @Override public void handle(WindowEvent event) {
                      System.exit(0);
                  }
              });
              stage.setScene(scene);
              stage.setTitle("SubSceneSetFill");
              
              stage.show();
          }
      }

        Attachments

          Activity

            People

            Assignee:
            ckyang Chien Yang (Inactive)
            Reporter:
            alammersdjfx August Lammersdorf (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: