Class SubScene

java.lang.Object
javafx.scene.Node
javafx.scene.SubScene
All Implemented Interfaces:
Styleable, EventTarget

public non-sealed class SubScene extends Node
The SubScene class is the container for content in a scene graph. SubScene provides separation of different parts of a scene, each of which can be rendered with a different camera, depth buffer, or scene anti-aliasing. A SubScene is embedded into the main scene or another sub-scene.

An application may request depth buffer support or scene anti-aliasing support at the creation of a SubScene. A sub-scene with only 2D shapes and without any 3D transforms does not need a depth buffer nor scene anti-aliasing support. A sub-scene containing 3D shapes or 2D shapes with 3D transforms may use depth buffer support for proper depth sorted rendering; to avoid depth fighting (also known as Z fighting), disable depth testing on 2D shapes that have no 3D transforms. See depthTest for more information. A sub-scene with 3D shapes may enable scene anti-aliasing to improve its rendering quality.

The depthBuffer and antiAliasing flags are conditional features. With the respective default values of: false and SceneAntialiasing.DISABLED. See ConditionalFeature.SCENE3D for more information.

Possible use cases are:

  • Mixing 2D and 3D content
  • Overlay for UI controls
  • Underlay for background
  • Heads-up display

A default headlight will be added to a SubScene that contains one or more Shape3D nodes, but no light nodes. This light source is a Color.WHITE PointLight placed at the camera position.

Since:
JavaFX 8.0
  • Property Details

  • Constructor Details

    • SubScene

      public SubScene(Parent root, double width, double height)
      Creates a SubScene for a specific root Node with a specific size.
      Parameters:
      root - The root node of the scene graph
      width - The width of the sub-scene
      height - The height of the sub-scene
      Throws:
      NullPointerException - if root is null
    • SubScene

      public SubScene(Parent root, double width, double height, boolean depthBuffer, SceneAntialiasing antiAliasing)
      Constructs a SubScene consisting of a root, with a dimension of width and height, specifies whether a depth buffer is created for this scene and specifies whether scene anti-aliasing is requested.

      A sub-scene with only 2D shapes and without any 3D transforms does not need a depth buffer nor scene anti-aliasing support. A sub-scene containing 3D shapes or 2D shapes with 3D transforms may use depth buffer support for proper depth sorted rendering; to avoid depth fighting (also known as Z fighting), disable depth testing on 2D shapes that have no 3D transforms. See depthTest for more information. A sub-scene with 3D shapes may enable scene anti-aliasing to improve its rendering quality.

      Parameters:
      root - The root node of the scene graph
      width - The width of the sub-scene
      height - The height of the sub-scene
      depthBuffer - The depth buffer flag
      antiAliasing - The sub-scene anti-aliasing attribute. A value of null is treated as DISABLED.

      The depthBuffer and antiAliasing flags are conditional features. With the respective default values of: false and SceneAntialiasing.DISABLED. See ConditionalFeature.SCENE3D for more information.

      Throws:
      NullPointerException - if root is null
      See Also:
  • Method Details

    • getAntiAliasing

      public final SceneAntialiasing getAntiAliasing()
      Return the defined SceneAntialiasing for this SubScene.

      Note: this is a conditional feature. See ConditionalFeature.SCENE3D and SceneAntialiasing for more information.

      Returns:
      the SceneAntialiasing for this sub-scene
      Since:
      JavaFX 8.0
    • isDepthBuffer

      public final boolean isDepthBuffer()
      Retrieves the depth buffer attribute for this SubScene.
      Returns:
      the depth buffer attribute.
    • setRoot

      public final void setRoot(Parent value)
      Sets the value of the root property.
      Property description:
      Defines the root Node of the SubScene scene graph. If a Group is used as the root, the contents of the scene graph will be clipped by the SubScene's width and height. SubScene doesn't accept null root.
      Parameters:
      value - the value for the root property
      See Also:
    • getRoot

      public final Parent getRoot()
      Gets the value of the root property.
      Property description:
      Defines the root Node of the SubScene scene graph. If a Group is used as the root, the contents of the scene graph will be clipped by the SubScene's width and height. SubScene doesn't accept null root.
      Returns:
      the value of the root property
      See Also:
    • rootProperty

      public final ObjectProperty<Parent> rootProperty()
      Defines the root Node of the SubScene scene graph. If a Group is used as the root, the contents of the scene graph will be clipped by the SubScene's width and height. SubScene doesn't accept null root.
      Returns:
      the root property
      See Also:
    • setCamera

      public final void setCamera(Camera value)
      Sets the value of the camera property.
      Property description:
      Specifies the type of camera use for rendering this SubScene. If camera is null, a parallel camera is used for rendering. It is illegal to set a camera that belongs to other Scene or SubScene.

      Note: this is a conditional feature. See ConditionalFeature.SCENE3D for more information.

      Default value:
      null
      Parameters:
      value - the value for the camera property
      See Also:
    • getCamera

      public final Camera getCamera()
      Gets the value of the camera property.
      Property description:
      Specifies the type of camera use for rendering this SubScene. If camera is null, a parallel camera is used for rendering. It is illegal to set a camera that belongs to other Scene or SubScene.

      Note: this is a conditional feature. See ConditionalFeature.SCENE3D for more information.

      Default value:
      null
      Returns:
      the value of the camera property
      See Also:
    • cameraProperty

      public final ObjectProperty<Camera> cameraProperty()
      Specifies the type of camera use for rendering this SubScene. If camera is null, a parallel camera is used for rendering. It is illegal to set a camera that belongs to other Scene or SubScene.

      Note: this is a conditional feature. See ConditionalFeature.SCENE3D for more information.

      Default value:
      null
      Returns:
      the camera property
      See Also:
    • setWidth

      public final void setWidth(double value)
      Sets the value of the width property.
      Property description:
      Defines the width of this SubScene
      Default value:
      0.0
      Parameters:
      value - the value for the width property
      See Also:
    • getWidth

      public final double getWidth()
      Gets the value of the width property.
      Property description:
      Defines the width of this SubScene
      Default value:
      0.0
      Returns:
      the value of the width property
      See Also:
    • widthProperty

      public final DoubleProperty widthProperty()
      Defines the width of this SubScene
      Default value:
      0.0
      Returns:
      the width property
      See Also:
    • setHeight

      public final void setHeight(double value)
      Sets the value of the height property.
      Property description:
      Defines the height of this SubScene
      Default value:
      0.0
      Parameters:
      value - the value for the height property
      See Also:
    • getHeight

      public final double getHeight()
      Gets the value of the height property.
      Property description:
      Defines the height of this SubScene
      Default value:
      0.0
      Returns:
      the value of the height property
      See Also:
    • heightProperty

      public final DoubleProperty heightProperty()
      Defines the height of this SubScene
      Default value:
      0.0
      Returns:
      the height property
      See Also:
    • setFill

      public final void setFill(Paint value)
      Sets the value of the fill property.
      Property description:
      Defines the background fill of this SubScene. Both a null value meaning paint no background and a Paint with transparency are supported. The default value is null.
      Default value:
      null
      Parameters:
      value - the value for the fill property
      See Also:
    • getFill

      public final Paint getFill()
      Gets the value of the fill property.
      Property description:
      Defines the background fill of this SubScene. Both a null value meaning paint no background and a Paint with transparency are supported. The default value is null.
      Default value:
      null
      Returns:
      the value of the fill property
      See Also:
    • fillProperty

      public final ObjectProperty<Paint> fillProperty()
      Defines the background fill of this SubScene. Both a null value meaning paint no background and a Paint with transparency are supported. The default value is null.
      Default value:
      null
      Returns:
      the fill property
      See Also:
    • userAgentStylesheetProperty

      public final ObjectProperty<String> userAgentStylesheetProperty()
      Gets the userAgentStylesheet property.
      Returns:
      the userAgentStylesheet property
      Since:
      JavaFX 8u20
      See Also:
    • getUserAgentStylesheet

      public final String getUserAgentStylesheet()
      Get the URL of the user-agent stylesheet that will be used by this SubScene. If the URL has not been set, the platform-default user-agent stylesheet will be used.

      For additional information about using CSS with the scene graph, see the CSS Reference Guide.

      Returns:
      The URL of the user-agent stylesheet that will be used by this SubScene, or null if has not been set.
      Since:
      JavaFX 8u20
    • setUserAgentStylesheet

      public final void setUserAgentStylesheet(String url)
      Set the URL of the user-agent stylesheet that will be used by this SubScene in place of the the platform-default user-agent stylesheet. If the URL does not resolve to a valid location, the platform-default user-agent stylesheet will be used.

      The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL does not have a [scheme:] component, the URL is considered to be the [path] component only. Any leading '/' character of the [path] is ignored and the [path] is treated as a path relative to the root of the application's classpath.

      The RFC 2397 "data" scheme for URLs is supported in addition to the protocol handlers that are registered for the application. If a URL uses the "data" scheme and the MIME type is either empty, "text/plain", or "text/css", the payload will be interpreted as a CSS file. If the MIME type is "application/octet-stream", the payload will be interpreted as a binary CSS file (see Stylesheet.convertToBinary(File, File)).

      For additional information about using CSS with the scene graph, see the CSS Reference Guide.

      Parameters:
      url - the URL of the user-agent stylesheet
      Since:
      JavaFX 8u20