oss-bandb / GraphView

Android GraphView is used to display data in graph structures.
Apache License 2.0
1.04k stars 129 forks source link

SugiyamaAlgorithm.run() not called but methods referencing this.graph being called #53

Closed renyuneyun closed 4 years ago

renyuneyun commented 4 years ago

This error appears when I (my app) tried to draw an empty graph with SugiyamaAlgorithm.

The error thrown is java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List de.blox.graphview.Graph.getEdges()' on a null object reference. Digging into the source code of ths library, it's because the drawEdges() method being called when this.graph == null.

However, I'm pretty confused why the drawEdges() method is defined with a graph parameter but the body uses this.graph instead...

(It seem drawEdges() is the only one resulting in serious problems. The only other method being called before run() is called is getGraphSize(), which will return the default Size size = new Size(0, 0);)

GregorBlock commented 4 years ago

Hi @renyuneyun we couldn't reproduce the issue. Can you post the stacktrace or example code of this issue.

However, I'm pretty confused why the drawEdges() method is defined with a graph parameter but the body uses this.graph instead...

This is intended, because the Sugiyama algorithm needs to change the graph to work.

renyuneyun commented 4 years ago

Here is the stacktrace:

    java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List de.blox.graphview.Graph.getEdges()' on a null object reference
        at de.blox.graphview.layered.SugiyamaEdgeRenderer.render(SugiyamaEdgeRenderer.java:32)
        at de.blox.graphview.layered.SugiyamaAlgorithm.drawEdges(SugiyamaAlgorithm.java:852)
        at de.blox.graphview.GraphNodeContainerView.dispatchDraw(GraphNodeContainerView.java:304)
        at android.view.View.updateDisplayListIfDirty(View.java:19232)
        at android.view.View.draw(View.java:20094)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
        at com.otaliastudios.zoom.ZoomLayout.drawChild(ZoomLayout.kt:163)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4116)
        at android.view.View.draw(View.java:20369)
        at android.view.View.updateDisplayListIfDirty(View.java:19241)
        at android.view.View.draw(View.java:20094)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4116)
        at android.view.View.updateDisplayListIfDirty(View.java:19232)
        at android.view.View.draw(View.java:20094)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4116)
        at android.view.View.updateDisplayListIfDirty(View.java:19232)
        at android.view.View.draw(View.java:20094)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
        at androidx.coordinatorlayout.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1246)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4116)
        at android.view.View.draw(View.java:20369)
        at android.view.View.updateDisplayListIfDirty(View.java:19241)
        at android.view.View.draw(View.java:20094)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
        at androidx.drawerlayout.widget.DrawerLayout.drawChild(DrawerLayout.java:1426)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4116)
        at android.view.View.draw(View.java:20369)
        at android.view.View.updateDisplayListIfDirty(View.java:19241)
        at android.view.View.draw(View.java:20094)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4116)
        at android.view.View.updateDisplayListIfDirty(View.java:19232)
        at android.view.View.draw(View.java:20094)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4116)
        at android.view.View.updateDisplayListIfDirty(View.java:19232)
        at android.view.View.draw(View.java:20094)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4116)
        at android.view.View.updateDisplayListIfDirty(View.java:19232)
        at android.view.View.draw(View.java:20094)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4116)
        at android.view.View.updateDisplayListIfDirty(View.java:19232)
        at android.view.View.draw(View.java:20094)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4116)
        at android.view.View.draw(View.java:20369)
        at com.android.internal.policy.DecorView.draw(DecorView.java:781)
        at android.view.View.updateDisplayListIfDirty(View.java:19241)
        at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:690)
        at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:696)
        at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:805)
        at android.view.ViewRootImpl.draw(ViewRootImpl.java:3526)
        at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3316)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2685)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1637)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7797)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1172)
        at android.view.Choreographer.doCallbacks(Choreographer.java:984)
GregorBlock commented 4 years ago

This should be fixed in version 0.6.1. Sorry it took so long, but we had a lot of work to do.