[x3d-public] Simple example of X3DConcreteNode/addChild problem

John Carlson yottzumm at gmail.com
Tue May 14 09:33:01 PDT 2019


Example of error generated below.  (minimal amount of code) Jupyter export attached.  I hope you can address the issue sometime with X3DJSAIL.  My best guess is that pyjnius is going through getSuperclass() and finding the abstract classes’ method setIS().  We can try deleting getSuperclass call in pyjnius if you think it’s appropriate.
 My suggestion is to delete setIS from X3DConcreteNode.java or implement addChild in X3DConcreteNode.java, which may just cascade the error.  I think deleting setIS might be preferable, but test both cases.   Consider a wrapping, like:

Transform(Transform().setIS(IS())).addChild(Shape())  # hasn’t been tested, but ew.

A jnius.cast would work similarly.  We can go with a cast if you like.  Please look into a cast to see what you prefer.  Also, try converting to Java.

Now do you see where the abstract class is coming from?  Do you agree on what’s introducing the abstract class (not me)?

Good news is, I and Michael figured out how to run the code in Jupyter Lab (anaconda).  There are instructions online that work with the conda.bat command install jnius (see conda install on pyjnius website)  WooHoo! Highly recommended, but a bit stilted to start with.

Code is back to you! Looking for changes to X3DConcreteNode.java.  I can make changes to the serializer if we decide wrapping or casting is appropriate.  I just think we’ll be wrapping the wrapping the wrapping.  It seems better to me to add or delete abstract methods.

No, I don’t know why @Override didn’t work.
# This code shows the error
import jnius_config
jnius_config.set_classpath('.', 'c:/x3d-code/www.web3d.org/x3d/stylesheets/java/jars/X3DJSAIL.3.3.full.jar')

from jnius import autoclass
Shape = autoclass('org.web3d.x3d.jsail.Shape.ShapeObject')
Transform = autoclass('org.web3d.x3d.jsail.Grouping.TransformObject')
IS = autoclass('org.web3d.x3d.jsail.Core.ISObject')


Transform().setIS(IS()).addChild(Shape())
-------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-62dabff95a4e> in <module>
      8 
      9 
---> 10 Transform().setIS(IS()).addChild(Shape())

AttributeError: 'org.web3d.x3d.jsail.X3DConcreteNode' object has no attribute 'addChild'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20190514/cc4ff4ad/attachment-0002.html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20190514/cc4ff4ad/attachment-0003.html>


More information about the x3d-public mailing list