openjump-gis / openjump

OpenJUMP, the Open Source GIS with more than one trick in its kangaroo pocket, takes the leap from svn to git. join the effort!
http://openjump.org
GNU General Public License v2.0
29 stars 14 forks source link

OpenJUMP core throws a No Class Def Foud Error on BitMapVertexStyle #92

Closed ma15569 closed 1 year ago

ma15569 commented 1 year ago

To reproduce the bug a) Create a project with with OpenJUMP Plus (with Batik embedded). Add a point layer and enable vertex symbology with external .png files as ymbols b) Load the project with OpenJUMP CORE (no batik embedded) and it throws the (No Class Def Foud Error) related to Batik class org/apache/batik/transcoder/TranscoderException.

In teory I was expecting no errors as OpenJUMP CORE or PLUS should manage the import of .png files via java.awt.image class ( see BitmapVertexStyle class from line 208)

I did a test I tried to change the code in both BitMapVertexStyle and BasicStylePanel

from: _if (fileName.toLowerCase().endsWith(".svg")) {

} else { }_ to: _try { } catch (Exception e){ }_ with no success. I ask if we can ship also OpenJUMP CORE with Batik as simple solution Best reagads Peppe
edeso commented 1 year ago

hey Peppe,

give me some time. i will have a look at it.

edeso commented 1 year ago

tried with OJ 2.2 CORE n PLUS,

  1. added a PNG image to OJ-PLUS/lib/ext/VertexImages/
  2. start OJ-PLUS
  3. create point layer, use VertexImage plugin to set image
  4. save dataset, project then
  5. start OJ-CORE
  6. open the saved project
  7. results in NPE's per styled point (see below)

Questions:

  1. VertexSymbols Extension is not part of OJ-Core. how do you expect the style to survive?
  2. how do you test? do you use packaged distributions or from within IDE? please provide more detailed steps so we can work out why your error is different from mine :)

[ERROR] 14:02:31.514 java.lang.NullPointerException
java.lang.NullPointerException
        at com.vividsolutions.jump.workbench.ui.renderer.SimpleFeatureCollectionRenderer.paint(SimpleFeatureCollectionRe
nderer.java:27)
        at com.vividsolutions.jump.workbench.ui.renderer.SimpleFeatureCollectionRenderer.paint(SimpleFeatureCollectionRe
nderer.java:58)
        at com.vividsolutions.jump.workbench.ui.renderer.SimpleRenderer.copyTo(SimpleRenderer.java:74)
        at com.vividsolutions.jump.workbench.ui.renderer.FeatureCollectionRenderer.copyTo(FeatureCollectionRenderer.java
:55)
        at com.vividsolutions.jump.workbench.ui.renderer.LayerRenderer.copyTo(LayerRenderer.java:93)
        at com.vividsolutions.jump.workbench.ui.renderer.RenderingManager.copyTo(RenderingManager.java:362)
        at com.vividsolutions.jump.workbench.ui.LayerViewPanel.paintComponent(LayerViewPanel.java:486)
        at java.desktop/javax.swing.JComponent.paint(Unknown Source)
        at java.desktop/javax.swing.JComponent.paintChildren(Unknown Source)
        at java.desktop/javax.swing.JSplitPane.paintChildren(Unknown Source)
        at java.desktop/javax.swing.JComponent.paint(Unknown Source)
        at java.desktop/javax.swing.JComponent.paintChildren(Unknown Source)
        at java.desktop/javax.swing.JComponent.paint(Unknown Source)
        at java.desktop/javax.swing.JComponent.paintChildren(Unknown Source)
        at java.desktop/javax.swing.JComponent.paint(Unknown Source)
        at java.desktop/javax.swing.JLayeredPane.paint(Unknown Source)
        at java.desktop/javax.swing.JComponent.paintChildren(Unknown Source)
        at java.desktop/javax.swing.JComponent.paint(Unknown Source)
        at java.desktop/javax.swing.JComponent.paintChildren(Unknown Source)
        at java.desktop/javax.swing.JComponent.paint(Unknown Source)
        at java.desktop/javax.swing.JComponent.paintChildren(Unknown Source)
        at java.desktop/javax.swing.JComponent.paint(Unknown Source)
        at java.desktop/javax.swing.JLayeredPane.paint(Unknown Source)
        at java.desktop/javax.swing.JComponent.paintChildren(Unknown Source)
        at java.desktop/javax.swing.JSplitPane.paintChildren(Unknown Source)
        at java.desktop/javax.swing.JComponent.paint(Unknown Source)
        at java.desktop/javax.swing.JComponent.paintChildren(Unknown Source)
        at java.desktop/javax.swing.JComponent.paint(Unknown Source)
        at java.desktop/javax.swing.JComponent.paintChildren(Unknown Source)
        at java.desktop/javax.swing.JComponent.paint(Unknown Source)
        at java.desktop/javax.swing.JLayeredPane.paint(Unknown Source)
        at java.desktop/javax.swing.JComponent.paintChildren(Unknown Source)
        at java.desktop/javax.swing.JComponent.paintToOffscreen(Unknown Source)
        at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBufferedImpl(Unknown Source)
        at java.desktop/javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
        at java.desktop/javax.swing.RepaintManager$PaintManager.paint(Unknown Source)
        at java.desktop/javax.swing.BufferStrategyPaintManager.paint(Unknown Source)
        at java.desktop/javax.swing.RepaintManager.paint(Unknown Source)
        at java.desktop/javax.swing.JComponent.paint(Unknown Source)
        at java.desktop/java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
        at java.desktop/sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
        at java.desktop/sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
        at java.desktop/java.awt.Container.paint(Unknown Source)
        at java.desktop/java.awt.Window.paint(Unknown Source)
        at java.desktop/javax.swing.RepaintManager$4.run(Unknown Source)
        at java.desktop/javax.swing.RepaintManager$4.run(Unknown Source)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at java.desktop/javax.swing.RepaintManager.paintDirtyRegions(Unknown Source)
        at java.desktop/javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source)
        at java.desktop/javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source)
        at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
        at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
        at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
edeso commented 1 year ago

hey @ma15569 please try the latest snapshot.

looks like the dejump styling supports SVG. if so, it might be a valid reason to re-add batik to CORE. could you give me a step-by-step how SVG styling with "Change Style" is supposed to work?

ma15569 commented 1 year ago

Hi Ede, sorry for the long delay. I try to summatize various question/answer >VertexSymbols Extension is not part of OJ-Core. how do you expect the style to survive?

No. I was talking about OpeJUMP embedded style (BitMapVertexStyle is a part of it, I will be a bit rendundant, sorry). BitMapVertexStyle is indedd a part of DeeJump project. VertexSymbols Extension is CadPLan external plugin.

how do you test? do you use packaged distributions or from within IDE? please provide more detailed steps so we can work out why your error is different from mine :)

Simply using any version of latest OpenJUMP (Core and Plus). It would be easy to use a) Frirst OJ CORE with embedded Batik to prepare the project and add basic verstex style b) Close OJ, remove Batik (as we usually ship with OpenJUMP core) and try to load the project.

could you give me a step-by-step how SVG styling with "Change Style" is supposed to work?

you can reproduce the error related to the absence of Batik in a quicker way. Using Openjump CORE:

Open OpenJUMP Create a layer and add a couple of points Click on Change Style Below the panel, enable Vertices size click on the lower button Change bitmap select a bitmap or a svg and then apply.

The software doesn't nothing (but the error is recordered into the log file) or, in rare cases, it shows the org/apache/batik/transcoder/TranscoderException

........................................................

The solution, if we do not want to ship Batik could be into the class org.openjump.core.ui.plugin.file.SaveImageAsSVGPlugIn (the only othe class into COre that uses Batik) where there is a sort checking the class on initilaize

public void initialize(PlugInContext context) throws Exception { super.initialize(context); ClassLoader cl = this.getClass().getClassLoader(); Class c = null, c2 = null; try { c = cl.loadClass("org.apache.batik.dom.GenericDOMImplementation"); c2 = cl.loadClass("org.apache.batik.svggen.SVGGraphics2D"); } catch (ClassNotFoundException e) { Logger.warn("Could not load class from batik", e); } if (c == null || c2 == null) { context.getWorkbenchFrame().log( this.getClass().getName()

edeso commented 1 year ago

just tested OJ 1.16 PLUS . using SVG as vertice bitmaps also throws an error there. seems like nobody uses this feature :))

with some testing it seems like an addititional 1MByte of batik jars solves the issue. all very unsatisfying for simply converting SVG to PNG to style some points. but that's the status quo it seems.

i really don't want to throw to much effort on this, so i'd say we readd this extended batik to CORE (+2MB) and add what's needed to PLUS (1MB).

for some reason this master PLUS distro would be 3MByte bigger than OJ 2.2.0 . didn't have time to investigate in depth, but 1MB alone comes from one of your new extensions Peppe.

ma15569 commented 1 year ago

Hi Ede, thanks for the comments.

Take your decision as the best you think. It is ok for me .

but 1MB alone comes from one of your new extensions Peppe. Which extension is related? I could solve the problem from here.

Il ven 14 apr 2023, 00:13 edeso @.***> ha scritto:

just tested OJ 1.16 PLUS . and using SVG as vertice bitmaps also throws an error there. seems like nobody uses this feature :))

with some testing it seems like an addititional 1MByte of batik jars solves the issue. all very unsatisfying for simply converting SVG to PNG to style some points. but that's the status quo it seems.

i really don't want to throw to much effort on this, so i'd say we readd this extended batik to CORE (+2MB) and add what's needed to PLUS (1MB).

for some reason this master PLUS distro would be 3MByte bigger than OJ 2.2.0 . didn't have time to investigate in depth, but 1MB alone comes from one of your new extensions Peppe.

— Reply to this email directly, view it on GitHub https://github.com/openjump-gis/openjump/issues/92#issuecomment-1507674812, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQSYPM6UCGQKZXSJ3NKP7B3XBB3BDANCNFSM6AAAAAAWVETMGM . You are receiving this because you were mentioned.Message ID: @.***>

ma15569 commented 1 year ago

Ok, I understand better. The new Ok Plus has my Raster tools extension as plugin. It is a quite large project comparing to regular plugin, maybe comparable to Sextante. It is big as it has many Raster tools and algorithm, on the other hand it is much smaller comparing to Sextante as I tried to use only Open jump libraries. Technically it works fine with Openjunp Core, except a Raster Álgebra calculator which requires an external lib (embedded in OJ plus). There is a new step of this project (September? the last one): a small georeferencing Raster plugin, limited to affine transformation, and an help

Il ven 14 apr 2023, 14:51 Giuseppe Aruta @.***> ha scritto:

Hi Ede, thanks for the comments.

Take your decision as the best you think. It is ok for me .

but 1MB alone comes from one of your new extensions Peppe. Which extension is related? I could solve the problem from here.

Il ven 14 apr 2023, 00:13 edeso @.***> ha scritto:

just tested OJ 1.16 PLUS . and using SVG as vertice bitmaps also throws an error there. seems like nobody uses this feature :))

with some testing it seems like an addititional 1MByte of batik jars solves the issue. all very unsatisfying for simply converting SVG to PNG to style some points. but that's the status quo it seems.

i really don't want to throw to much effort on this, so i'd say we readd this extended batik to CORE (+2MB) and add what's needed to PLUS (1MB).

for some reason this master PLUS distro would be 3MByte bigger than OJ 2.2.0 . didn't have time to investigate in depth, but 1MB alone comes from one of your new extensions Peppe.

— Reply to this email directly, view it on GitHub https://github.com/openjump-gis/openjump/issues/92#issuecomment-1507674812, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQSYPM6UCGQKZXSJ3NKP7B3XBB3BDANCNFSM6AAAAAAWVETMGM . You are receiving this because you were mentioned.Message ID: @.***>

edeso commented 1 year ago

right, that one. maybe you can have a look, just to make sure that you made it as small as possible :)

apart from that, there is still 1MB growth that is so far unaccounted for.

edeso commented 1 year ago

hey Peppe,

pls test if https://github.com/openjump-gis/openjump/commit/ae9bb5f94073c60657d22d701f9d45be3cdaf292 snapshots for OJ CORE and PLUS fix this issue.

ma15569 commented 1 year ago

Hi Ede, works fine form me. This new OpenJUMP distro (Core and Plus) has the the 14 Batik libraries (2 Mb), comparing to none (Core) and six Batik libraries (1 Mb) in Plus. Posssibly the six libraries woud have been enough (http://www.object-refinery.com/blog/blog-20140423.html) But, for a precautionary approach, your solution can bypass possible problems in th efuture Thanks

edeso commented 1 year ago

works fine form me. This new OpenJUMP distro (Core and Plus) has the the 14 Batik libraries (2 Mb), comparing to none (Core) and six Batik libraries (1 Mb) in Plus.

indeed

Posssibly the six libraries woud have been enough (http://www.object-refinery.com/blog/blog-20140423.html)

sorry. no. as i wrote the additional deps are needed by batik-transcoder to style vertices. internally SVG decorations need to be converted to images (PNG).

But, for a precautionary approach, your solution can bypass possible problems in th efuture

agreed, will close the ticket as solved.