NullpointerException: Util#colorToCss / SimpleGaugeSkin

Issue #4 resolved
Steffen created an issue

I am developing a Dashboard containing widgets, and SimpleGauge is one of the available widgets..
On Drag&Drop i receive multiple NullpointerExceptions:

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
    at eu.hansolo.enzo.common.Util.colorToCss(Util.java:82)
    at eu.hansolo.enzo.gauge.skin.SimpleGaugeSkin.handleControlPropertyChanged(SimpleGaugeSkin.java:231)
    at eu.hansolo.enzo.gauge.skin.SimpleGaugeSkin.lambda$registerListeners$60(SimpleGaugeSkin.java:164)
    at eu.hansolo.enzo.gauge.skin.SimpleGaugeSkin$$Lambda$32/92682911.invalidated(Unknown Source)
    at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:135)
    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:80)
    at javafx.beans.property.ObjectPropertyBase.fireValueChangedEvent(ObjectPropertyBase.java:105)
    at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112)
    at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:145)
    at javafx.css.StyleableObjectProperty.set(StyleableObjectProperty.java:82)
    at javafx.css.StyleableObjectProperty.applyStyle(StyleableObjectProperty.java:68)
    at javafx.scene.CssStyleHelper.resetToInitialValues(CssStyleHelper.java:442)
    at javafx.scene.CssStyleHelper.createStyleHelper(CssStyleHelper.java:222)
    at javafx.scene.Node.impl_processCSS(Node.java:8877)
    at javafx.scene.Parent.impl_processCSS(Parent.java:1250)
    at javafx.scene.control.Control.impl_processCSS(Control.java:872)
    at javafx.scene.Parent.impl_processCSS(Parent.java:1281)
    at javafx.scene.Parent.impl_processCSS(Parent.java:1281)
    at javafx.scene.Parent.impl_processCSS(Parent.java:1281)
    at javafx.scene.control.Control.impl_processCSS(Control.java:872)
    at javafx.scene.Node.processCSS(Node.java:8732)
    at javafx.scene.Node.processCSS(Node.java:8725)
    at javafx.scene.Node.processCSS(Node.java:8725)
    at javafx.scene.Node.processCSS(Node.java:8725)
    at javafx.scene.Node.processCSS(Node.java:8725)
    at javafx.scene.Scene.doCSSPass(Scene.java:561)
    at javafx.scene.Scene.access$3500(Scene.java:198)
    at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2366)
    at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:330)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:479)
    at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:460)
    at com.sun.javafx.tk.quantum.QuantumToolkit$13.run(QuantumToolkit.java:327)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinDnDClipboard.push(Native Method)
    at com.sun.glass.ui.win.WinSystemClipboard.pushToSystem(WinSystemClipboard.java:234)
    at com.sun.glass.ui.SystemClipboard.flush(SystemClipboard.java:51)
    at com.sun.glass.ui.ClipboardAssistance.flush(ClipboardAssistance.java:59)
    at com.sun.javafx.tk.quantum.QuantumClipboard.flush(QuantumClipboard.java:274)
    at com.sun.javafx.tk.quantum.QuantumToolkit.startDrag(QuantumToolkit.java:1149)
    at javafx.scene.Scene$DnDGesture.dragDetectedProcessed(Scene.java:2911)
    at javafx.scene.Scene$DnDGesture.process(Scene.java:2972)
    at javafx.scene.Scene$DnDGesture.access$8400(Scene.java:2867)
    at javafx.scene.Scene$MouseHandler.process(Scene.java:3705)
    at javafx.scene.Scene$MouseHandler.access$1800(Scene.java:3414)
    at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1676)
    at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2467)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:314)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:243)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:345)
    at com.sun.glass.ui.View.handleMouseEvent(View.java:526)
    at com.sun.glass.ui.View.notifyMouse(View.java:898)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.access$300(WinApplication.java:39)
    at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)
    at java.lang.Thread.run(Thread.java:744)

Comments (8)

  1. Steffen reporter

    And the SimpleGauge I use:

    mGauge = SimpleGaugeBuilder
                    .create()
                    .animationDuration(100)
                    .sectionFill0(Color.web("#97b329"))
                    .sectionFill1(Color.web("#aacc2a"))
                    .sectionFill2(Color.web("#d4ea35"))
                    .sectionFill3(Color.web("#f2de31"))
                    .sectionFill4(Color.web("#fccb2e"))
                    .sectionFill5(Color.web("#f3a429"))
                    .sectionFill6(Color.web("#f18c23"))
                    .sectionFill7(Color.web("#f65821"))
                    .sectionFill8(Color.web("#f3351f"))
                    .sectionFill9(Color.web("#f61319"))
                    .sections(new Section(0, 1 * pSize.getMult()), new Section(1 * pSize.getMult(), 2 * pSize.getMult()),
                            new Section(2 * pSize.getMult(), 3 * pSize.getMult()), new Section(3 * pSize.getMult(), 4 * pSize.getMult()),
                            new Section(4 * pSize.getMult(), 5 * pSize.getMult()), new Section(5 * pSize.getMult(), 6 * pSize.getMult()),
                            new Section(6 * pSize.getMult(), 7 * pSize.getMult()), new Section(7 * pSize.getMult(), 8 * pSize.getMult()),
                            new Section(8 * pSize.getMult(), 9 * pSize.getMult()), new Section(9 * pSize.getMult(), 10 * pSize.getMult()))
                    .minValue(0).maxValue(10 * pSize.getMult()).value(0).customFontEnabled(true).customFont(Fonts.elektra(20))
                    .build();
    

    I use custom section fill colors instead of css style class because it prevents some caching issues in JavaFX.

  2. Gerrit Grunwald repo owner

    oh I think I see the problem, could you try to set sections in the SimpleGaugeBuilder before you set the SectionColors? Guess I have to adjust the setter calling in the builder. Other solution might be to set the section colors after you called the SimpleGaugeBuilder.

  3. Steffen reporter

    Yes, reordering the Builder statements fixes the issue!
    Do you want to resolve the issue now or do you want to adjust the Builder first?

  4. Gerrit Grunwald repo owner

    Okidoki, I won't find the time to fix it today but I will try to fix it tomorrow. Thanx for testing and merry christmas :)

  5. Log in to comment