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

Radial gradients don't work from stylesheet

XMLWordPrintable

      Take the following javafx code:

      Stage {
          title: "Radial Gradient CSS"
          scene: Scene {
              width: 250
              height: 80
              stylesheets: "{__DIR__}styles.css"
              content: [
                  Rectangle {
                      width: 200
                      height: 80
                  }
              ]
          }
      }

      with this stylesheet:

      Rectangle {
          -fx-fill: linear (0%,0%) to (100%,100%) stops (0%, blue) (100%, red);

          -fx-fill: radial 100% stops (0%, blue) (100%, red);
          -fx-fill: radial (25%, 25%), 100% stops (0%, blue) (100%, red);
          -fx-fill: radial (25%,25%), 100% stops (0%, blue) (100%, red) reflect;
          -fx-fill: radial (25%,25%), 100% focus(25%,25%) stops (0%, blue) (100%, red);
      }

      The linear gradient works fine, but the four versions of the radial gradient does not. None of the four generates a parser error but the following exception is thrown in each case:

      Unexpected exception caught in MasterTimer.timePulse():
      java.lang.ClassCastException: javafx.scene.paint.CycleMethod cannot be cast to com.sun.stylesheet.css.Size
              at com.sun.stylesheet.css.Type$Type$Script$1Type$ObjLit$10.derive(Type.fx:160)
              at com.sun.stylesheet.css.Type$PaintType.getParsedValue(Type.fx:646)
              at com.sun.stylesheet.css.Type$PaintType.convert(Type.fx:635)
              at com.sun.stylesheet.css.Type.convert(Type.fx:211)
              at com.sun.stylesheet.StyleHelper.lookup(StyleHelper.fx:330)
              at com.sun.stylesheet.StyleHelper.transitionToState(StyleHelper.fx:168)
              at javafx.scene.Node.impl_processCSS(Node.fx:3107)
              at javafx.scene.Parent.impl_processCSS(Parent.fx:875)
              at javafx.scene.Scene.doCSSPass(Scene.fx:285)
              at javafx.scene.Scene$ScenePulseListener.pulse(Scene.fx:924)
              at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.fx:143)
              at com.sun.javafx.tk.Toolkit.handleMasterTimerPulse(Toolkit.fx:132)
              at com.sun.javafx.tk.Toolkit$1com$ObjLit$5.firePulseImpl(Toolkit.fx:304)
              at com.sun.scenario.ToolkitAccessor.firePulse(ToolkitAccessor.java:55)
              at com.sun.scenario.scenegraph.JSGPanelRepainter$FrameDisplay.run(JSGPanelRepainter.java:133)
              at com.sun.scenario.animation.AbstractMasterTimer.timePulseImpl(AbstractMasterTimer.java:420)
              at com.sun.scenario.animation.AbstractMasterTimer$MainLoop.run(AbstractMasterTimer.java:296)
              at com.sun.embeddedswing.EmbeddedEventQueue.doPulse(EmbeddedEventQueue.java:570)
              at com.sun.embeddedswing.EmbeddedEventQueue.access$000(EmbeddedEventQueue.java:82)
              at com.sun.embeddedswing.EmbeddedEventQueue$2.run(EmbeddedEventQueue.java:473)
              at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:633)
              at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
              at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

            dgrieve David Grieve
            diversonjfx Dean Iverson (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: