gama-platform / gama.old

Main repository for developing the 1.x versions of GAMA
GNU General Public License v3.0
304 stars 99 forks source link

SVG-based aspect wrongly displayed without rotate #3822

Closed benoitgaudou closed 1 year ago

benoitgaudou commented 1 year ago

Describe the bug SVG file can be used as part of the aspect of agents, e.g.

draw svg_file("../includes/sheep.svg") size: 10 rotate: 45 color: #black;
Capture d’écran 2023-06-08 à 04 47 16

Nevertheless, when the rotate is omitted, the image is wrongly displayed:

draw svg_file("../includes/sheep.svg") size: 10 color: #black;
Capture d’écran 2023-06-08 à 04 48 00

Note : this issue is Java 2D display only (as SVG is not displayed in 3d displays).

To Reproduce Steps to reproduce the behavior:

  1. Test following "model": Test.zip

Desktop (please complete the following information):

AlexisDrogoul commented 1 year ago

@benoitgaudou Please test to see if the latest commit has solved this issue.

lesquoyb commented 1 year ago

update: the problem is still present on windows 11 with this error stack in eclipse console:

Runtime error java.lang.NullPointerException: Cannot invoke "msi.gama.metamodel.shape.IShape.getEnvelope()" because the return value of "msi.gama.util.file.GamaGeometryFile.getGeometry(msi.gama.runtime.IScope)" is null in OpenGL loop
com.google.common.util.concurrent.UncheckedExecutionException: java.lang.NullPointerException: Cannot invoke "msi.gama.metamodel.shape.IShape.getEnvelope()" because the return value of "msi.gama.util.file.GamaGeometryFile.getGeometry(msi.gama.runtime.IScope)" is null
    at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2051)
    at com.google.common.cache.LocalCache.get(LocalCache.java:3951)
    at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4848)
    at ummisco.gama.opengl.renderer.caches.GeometryCache.getEnvelope(GeometryCache.java:316)
    at ummisco.gama.opengl.OpenGL.getEnvelopeFor(OpenGL.java:1245)
    at ummisco.gama.opengl.scene.ObjectDrawer.applyScaling(ObjectDrawer.java:68)
    at ummisco.gama.opengl.scene.resources.ResourceDrawer._draw(ResourceDrawer.java:80)
    at ummisco.gama.opengl.scene.resources.ResourceDrawer._draw(ResourceDrawer.java:1)
    at ummisco.gama.opengl.scene.ObjectDrawer.draw(ObjectDrawer.java:51)
    at ummisco.gama.opengl.scene.layers.LayerObject.drawObjects(LayerObject.java:399)
    at ummisco.gama.opengl.scene.layers.LayerObject.drawAllObjects(LayerObject.java:381)
    at ummisco.gama.opengl.scene.layers.LayerObject.lambda$2(LayerObject.java:284)
    at ummisco.gama.opengl.OpenGL.compileAsList(OpenGL.java:1390)
    at ummisco.gama.opengl.scene.layers.LayerObject.doDrawing(LayerObject.java:284)
    at ummisco.gama.opengl.scene.layers.LayerObject.draw(LayerObject.java:264)
    at ummisco.gama.opengl.scene.ModelScene.draw(ModelScene.java:138)
    at ummisco.gama.opengl.renderer.helpers.SceneHelper.draw(SceneHelper.java:258)
    at ummisco.gama.opengl.renderer.JOGLRenderer.display(JOGLRenderer.java:210)
    at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692)
    at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674)
    at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:443)
    at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293)
    at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
    at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:782)
    at ummisco.gama.opengl.view.GamaGLAnimator.lambda$1(GamaGLAnimator.java:166)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:132)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4029)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3645)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550)
    at msi.gama.application.Application.start(Application.java:148)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1440)

when the display is 3d, and another one when it's 2d:

java.lang.NullPointerException: Cannot invoke "org.apache.batik.anim.dom.SVGOMDocument.getDocumentElement()" because the return value of "ummisco.gaml.extensions.image.GamaSVGFile.getDocument(msi.gama.runtime.IScope)" is null
    at ummisco.gaml.extensions.image.GamaSVGFile.fillBuffer(GamaSVGFile.java:469)
    at msi.gama.util.file.GamaGeometryFile.getGeometry(GamaGeometryFile.java:85)
    at msi.gaml.types.GamaGeometryType.staticCast(GamaGeometryType.java:128)
    at msi.gaml.operators.Cast.asGeometry(Cast.java:340)
    at msi.gaml.operators.Cast.asGeometry(Cast.java:355)
    at msi.gama.outputs.display.AWTDisplayGraphics.drawAsset(AWTDisplayGraphics.java:215)
    at msi.gaml.statements.draw.AssetDrawer.executeOn(AssetDrawer.java:73)
    at msi.gaml.statements.draw.DrawStatement.privateExecuteIn(DrawStatement.java:402)
    at msi.gaml.statements.draw.DrawStatement.privateExecuteIn(DrawStatement.java:368)
    at msi.gaml.statements.draw.DrawStatement.privateExecuteIn(DrawStatement.java:1)
    at msi.gaml.statements.AbstractStatement.executeOn(AbstractStatement.java:47)
    at msi.gaml.statements.AbstractStatementSequence.executeOn(AbstractStatementSequence.java:59)
    at msi.gama.runtime.ExecutionScope.execute(ExecutionScope.java:510)
    at msi.gama.runtime.IScope.execute(IScope.java:440)
    at msi.gama.runtime.IScope.execute(IScope.java:411)
    at msi.gaml.statements.AbstractStatementSequence.privateExecuteIn(AbstractStatementSequence.java:69)
    at msi.gaml.statements.AspectStatement.privateExecuteIn(AspectStatement.java:225)
    at msi.gaml.statements.AspectStatement.privateExecuteIn(AspectStatement.java:1)
    at msi.gaml.statements.AbstractStatement.executeOn(AbstractStatement.java:47)
    at msi.gaml.statements.AbstractStatementSequence.executeOn(AbstractStatementSequence.java:59)
    at msi.gaml.statements.AspectStatement.executeOn(AspectStatement.java:206)
    at msi.gaml.statements.AspectStatement.executeOn(AspectStatement.java:1)
    at msi.gama.runtime.ExecutionScope.execute(ExecutionScope.java:510)
    at msi.gama.runtime.IScope.execute(IScope.java:440)
    at msi.gama.outputs.layers.SpeciesLayer.drawPopulation(SpeciesLayer.java:105)
    at msi.gama.outputs.layers.SpeciesLayer.privateDraw(SpeciesLayer.java:73)
    at msi.gama.outputs.layers.AbstractLayer.draw(AbstractLayer.java:110)
    at msi.gama.outputs.display.LayerManager.drawLayersOn(LayerManager.java:176)
    at ummisco.gama.java2d.Java2DDisplaySurface.paintComponent(Java2DDisplaySurface.java:510)
    at java.desktop/javax.swing.JComponent.paint(JComponent.java:1119)
    at java.desktop/javax.swing.JComponent.paintToOffscreen(JComponent.java:5311)
    at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBufferedFPScales(RepaintManager.java:1721)
    at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1630)
    at java.desktop/javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1570)
    at java.desktop/javax.swing.RepaintManager.paint(RepaintManager.java:1337)
    at java.desktop/javax.swing.JComponent._paintImmediately(JComponent.java:5259)
    at java.desktop/javax.swing.JComponent.paintImmediately(JComponent.java:5069)
    at java.desktop/javax.swing.RepaintManager$4.run(RepaintManager.java:879)
    at java.desktop/javax.swing.RepaintManager$4.run(RepaintManager.java:862)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:862)
    at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:835)
    at java.desktop/javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:784)
    at java.desktop/javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1898)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:771)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:741)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Java error: nil value detected
    at msi.gama.runtime.exceptions.GamaRuntimeException.create(GamaRuntimeException.java:72)
    at ummisco.gaml.extensions.image.GamaSVGFile.fillBuffer(GamaSVGFile.java:475)
    at msi.gama.util.file.GamaGeometryFile.getGeometry(GamaGeometryFile.java:85)
    at msi.gaml.types.GamaGeometryType.staticCast(GamaGeometryType.java:128)
    at msi.gaml.operators.Cast.asGeometry(Cast.java:340)
    at msi.gaml.operators.Cast.asGeometry(Cast.java:355)
    at msi.gama.outputs.display.AWTDisplayGraphics.drawAsset(AWTDisplayGraphics.java:215)
    at msi.gaml.statements.draw.AssetDrawer.executeOn(AssetDrawer.java:73)
    at msi.gaml.statements.draw.DrawStatement.privateExecuteIn(DrawStatement.java:402)
    at msi.gaml.statements.draw.DrawStatement.privateExecuteIn(DrawStatement.java:368)
    at msi.gaml.statements.draw.DrawStatement.privateExecuteIn(DrawStatement.java:1)
    at msi.gaml.statements.AbstractStatement.executeOn(AbstractStatement.java:47)
    at msi.gaml.statements.AbstractStatementSequence.executeOn(AbstractStatementSequence.java:59)
    at msi.gama.runtime.ExecutionScope.execute(ExecutionScope.java:510)
    at msi.gama.runtime.IScope.execute(IScope.java:440)
    at msi.gama.runtime.IScope.execute(IScope.java:411)
    at msi.gaml.statements.AbstractStatementSequence.privateExecuteIn(AbstractStatementSequence.java:69)
    at msi.gaml.statements.AspectStatement.privateExecuteIn(AspectStatement.java:225)
    at msi.gaml.statements.AspectStatement.privateExecuteIn(AspectStatement.java:1)
    at msi.gaml.statements.AbstractStatement.executeOn(AbstractStatement.java:47)
    at msi.gaml.statements.AbstractStatementSequence.executeOn(AbstractStatementSequence.java:59)
    at msi.gaml.statements.AspectStatement.executeOn(AspectStatement.java:206)
    at msi.gaml.statements.AspectStatement.executeOn(AspectStatement.java:1)
    at msi.gama.runtime.ExecutionScope.execute(ExecutionScope.java:510)
    at msi.gama.runtime.IScope.execute(IScope.java:440)
    at msi.gama.outputs.layers.SpeciesLayer.drawPopulation(SpeciesLayer.java:105)
    at msi.gama.outputs.layers.SpeciesLayer.privateDraw(SpeciesLayer.java:73)
    at msi.gama.outputs.layers.AbstractLayer.draw(AbstractLayer.java:110)
    at msi.gama.outputs.display.LayerManager.drawLayersOn(LayerManager.java:176)
    at ummisco.gama.java2d.Java2DDisplaySurface.paintComponent(Java2DDisplaySurface.java:510)
    at java.desktop/javax.swing.JComponent.paint(JComponent.java:1119)
    at java.desktop/javax.swing.JComponent.paintToOffscreen(JComponent.java:5311)
    at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBufferedFPScales(RepaintManager.java:1721)
    at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1630)
    at java.desktop/javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1570)
    at java.desktop/javax.swing.RepaintManager.paint(RepaintManager.java:1337)
    at java.desktop/javax.swing.JComponent._paintImmediately(JComponent.java:5259)
    at java.desktop/javax.swing.JComponent.paintImmediately(JComponent.java:5069)
    at java.desktop/javax.swing.RepaintManager$4.run(RepaintManager.java:879)
    at java.desktop/javax.swing.RepaintManager$4.run(RepaintManager.java:862)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:862)
    at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:835)
    at java.desktop/javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:784)
    at java.desktop/javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1898)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:771)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:741)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.lang.NullPointerException: Cannot invoke "org.apache.batik.anim.dom.SVGOMDocument.getDocumentElement()" because the return value of "ummisco.gaml.extensions.image.GamaSVGFile.getDocument(msi.gama.runtime.IScope)" is null
    at ummisco.gaml.extensions.image.GamaSVGFile.fillBuffer(GamaSVGFile.java:469)
    ... 57 more