[geotk] applet to display raster

Ramzi Oueslati ramzi at oueslati.org
Tue Jan 11 12:00:26 EST 2011


Hello Martin and thanks for the quick reply.
(Sorry. You will receive this twice but first reply was not sent to the list)

I tried the code you suggest and the output is a little different
whether it runs from the web browser or the appletviewer. It worked
right away without the "ImageIO.scanForPlugins();". This latter code
does not change anything to the output by the way. Here it is the
output:

>From web browser

org.geotoolkit.image.io.plugin.WorldFileImageReader$GIF at b041b0
org.geotoolkit.image.io.plugin.WorldFileImageReader$BMP at 6e9b6a
org.geotoolkit.image.io.plugin.WorldFileImageReader$TXT at 1cf243b
org.geotoolkit.image.io.plugin.WorldFileImageReader$PNG at bc0eba
org.geotoolkit.image.io.plugin.WorldFileImageReader$JPEG at eebf17
org.geotoolkit.image.io.plugin.RawTiffImageReader$Spi at 395aaf
org.geotoolkit.image.io.plugin.WorldFileImageReader$ASC at a638fc
com.sun.imageio.plugins.wbmp.WBMPImageReaderSpi at 73bc22
org.geotoolkit.image.io.plugin.WorldFileImageReader$Records at 177ab84
org.geotoolkit.image.io.plugin.RawImageReader$Spi at 16602cb
com.sun.imageio.plugins.gif.GIFImageReaderSpi at c3d062
com.sun.imageio.plugins.bmp.BMPImageReaderSpi at 84de3c
com.sun.imageio.plugins.png.PNGImageReaderSpi at 3bce70
com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi at a02839
org.geotoolkit.image.io.plugin.AsciiGridReader$Spi at 12cfd62
org.geotoolkit.image.io.plugin.TextRecordImageReader$Spi at b8f675
org.geotoolkit.image.io.plugin.TextMatrixImageReader$Spi at 1a1b2f

>From appletviewer

org.geotoolkit.image.io.plugin.WorldFileImageReader$GIF at 46d228
org.geotoolkit.image.io.plugin.GeoTiffImageReader$TIFF at 1a99347
org.geotoolkit.image.io.plugin.WorldFileImageReader$TXT at 12f1bf0
org.geotoolkit.image.io.plugin.WorldFileImageReader$Records at 3aff84
org.geotoolkit.image.io.plugin.WorldFileImageReader$ASC at 1347124
org.geotoolkit.image.io.plugin.WorldFileImageReader$TIFF at 28305d
org.geotoolkit.image.io.plugin.WorldFileImageReader$JPEG at acdd02
com.sun.imageio.plugins.wbmp.WBMPImageReaderSpi at 3a5794
com.sun.media.imageioimpl.plugins.jpeg2000.J2KImageReaderSpi at 6214f5
org.geotoolkit.image.io.plugin.WorldFileImageReader$PNG at f0b4a3
org.geotoolkit.image.io.plugin.WorldFileImageReader$BMP at 1980630
com.sun.media.imageioimpl.plugins.pnm.PNMImageReaderSpi at 114b82b
com.sun.media.imageioimpl.plugins.raw.RawImageReaderSpi at ded0f0
com.sun.imageio.plugins.gif.GIFImageReaderSpi at 4ac216
org.geotoolkit.image.io.plugin.TextRecordImageReader$Spi at 1754699
org.geotoolkit.image.io.plugin.AsciiGridReader$Spi at 2f729e
com.sun.media.imageioimpl.plugins.tiff.TIFFImageReaderSpi at 778255
com.sun.imageio.plugins.jpeg.JPEGImageReaderSpi at 13f136e
com.sun.media.imageioimpl.plugins.wbmp.WBMPImageReaderSpi at 1493102
com.sun.imageio.plugins.png.PNGImageReaderSpi at f1f051
com.sun.imageio.plugins.bmp.BMPImageReaderSpi at 13936e1
org.geotoolkit.image.io.plugin.RawImageReader$Spi at 18488ef
org.geotoolkit.image.io.plugin.TextMatrixImageReader$Spi at d7b7d9
org.geotoolkit.image.io.plugin.RawTiffImageReader$Spi at 1a78071
com.sun.media.imageioimpl.plugins.bmp.BMPImageReaderSpi at 1922f46

I also run the applet after adding the IIORegistry line at the
beginning of the init method but this produces new errors. I will take
a look at it later.

Best regards,
Ramzi

2011/1/11 Martin Desruisseaux <martin.desruisseaux at geomatys.fr>:
> Hello Ramzi
>
> I need to explore this issue more. However in the main time, there is some
> guess:
>
> 1) Could you try to add the following code and check the result in the
> Applet viewer please?
>
>        Iterator<ImageReaderSpi> it =
> IIORegistry.getDefaultInstance().getServiceProviders(ImageReaderSpi.class,
> true);
>        while (it.hasNext()) {
>            System.out.println(it.next());
>        }
>
> 2) If the above does not show any readers in the
> "org.geotoolkit.image.io.plugin" namespace, could you try to add the
> following before the loop?
>
>        ImageIO.scanForPlugins();
>
> 3) If the above still don't work, could you try the following (I'm not sure
> abot the exact name of GeoTiffImageReader.Spi)?
>
>        IIORegistry.getDefaultInstance().registerServiceProvider(new
> GeoTiffImageReader.Spi(), ImageReaderSpi.class);
>
> The transformation problem is probably a similar issue; both Image I/O and
> referencing use the same META-INF/services registration mechanism. Let see
> first if the above make any difference in the Image I/O case...
>
>    Regards,
>
>        Martin
>
>
>
> Le 11/01/11 16:35, Ramzi Oueslati a écrit :
>>
>> Hello list,
>>
>> I'm trying to make an applet display a geotiff coverage. I first tried
>> to make the code run as a java application. So far so good. Then I
>> changed the code to make it an applet.
>> The applet runs fine through appletviewer but fails through the web
>> browser. There are 2 errors: one is related to jpeg and the other is
>> related to tiff. Here they are:
>>
>> # display tiff coverage #
>>
>> org.geotoolkit.coverage.io.CoverageStoreException: Can't read file
>> "world.tiff".
>> No suitable image reader for this input.
>>        at
>> org.geotoolkit.coverage.io.ImageCoverageReader.setInput(ImageCoverageReader.java:398)
>>        at
>> org.geotoolkit.coverage.io.GridCoverageReaders.createSimpleReader(GridCoverageReaders.java:136)
>>        at
>> com.spotimage.sdi.applet.OOApplet$1.actionPerformed(OOApplet.java:69)
>>        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
>>        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown
>> Source)
>>        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown
>> Source)
>>        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
>>        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown
>> Source)
>>        at java.awt.Component.processMouseEvent(Unknown Source)
>>        at javax.swing.JComponent.processMouseEvent(Unknown Source)
>>        at java.awt.Component.processEvent(Unknown Source)
>>        at java.awt.Container.processEvent(Unknown Source)
>>        at java.awt.Component.dispatchEventImpl(Unknown Source)
>>        at java.awt.Container.dispatchEventImpl(Unknown Source)
>>        at java.awt.Component.dispatchEvent(Unknown Source)
>>        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown
>> Source)
>>        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
>>        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
>>        at java.awt.Container.dispatchEventImpl(Unknown Source)
>>        at java.awt.Component.dispatchEvent(Unknown Source)
>>        at java.awt.EventQueue.dispatchEvent(Unknown Source)
>>        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown
>> Source)
>>        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>>        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
>> Source)
>>        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>        at java.awt.EventDispatchThread.run(Unknown Source)
>> Caused by: org.geotoolkit.image.io.UnsupportedImageFormatException: No
>> suitable image reader for this input.
>>        at org.geotoolkit.image.io.XImageIO.getReader(XImageIO.java:355)
>>        at
>> org.geotoolkit.image.io.XImageIO.getReaderBySuffix(XImageIO.java:493)
>>        at
>> org.geotoolkit.image.io.XImageIO.getReaderBySuffix(XImageIO.java:468)
>>        at
>> org.geotoolkit.coverage.io.ImageCoverageReader.createImageReader(ImageCoverageReader.java:455)
>>        at
>> org.geotoolkit.coverage.io.ImageCoverageReader.setInput(ImageCoverageReader.java:332)
>>        ... 26 more
>>
>> # display jpeg coverage #
>>
>> org.opengis.referencing.operation.TransformException: Can't transform
>> envelope.
>>        at org.geotoolkit.referencing.CRS.transform(CRS.java:1456)
>>        at
>> org.geotoolkit.display.primitive.AbstractReferencedGraphic2D.setEnvelope(AbstractReferencedGraphic2D.java:174)
>>        at
>> org.geotoolkit.display2d.container.stateless.AbstractLayerJ2D.<init>(AbstractLayerJ2D.java:70)
>>        at
>> org.geotoolkit.display2d.container.statefull.StatefullCoverageLayerJ2D.<init>(StatefullCoverageLayerJ2D.java:65)
>>        at
>> org.geotoolkit.display2d.container.stateless.StatelessContextJ2D.parseLayer(StatelessContextJ2D.java:127)
>>        at
>> org.geotoolkit.display2d.container.stateless.StatelessContextJ2D.layerChange(StatelessContextJ2D.java:200)
>>        at
>> org.geotoolkit.map.ContextListener$Weak.layerChange(ContextListener.java:100)
>>        at
>> org.geotoolkit.map.DefaultMapContext.fireLayerChange(DefaultMapContext.java:231)
>>        at
>> org.geotoolkit.map.DefaultMapContext$AdapterList.add(DefaultMapContext.java:390)
>>        at
>> org.geotoolkit.map.DefaultMapContext$AdapterList.add(DefaultMapContext.java:360)
>>        at java.util.AbstractList.add(Unknown Source)
>>        at
>> com.spotimage.sdi.applet.OOApplet$1.actionPerformed(OOApplet.java:73)
>>        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
>>        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown
>> Source)
>>        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown
>> Source)
>>        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
>>        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown
>> Source)
>>        at java.awt.Component.processMouseEvent(Unknown Source)
>>        at javax.swing.JComponent.processMouseEvent(Unknown Source)
>>        at java.awt.Component.processEvent(Unknown Source)
>>        at java.awt.Container.processEvent(Unknown Source)
>>        at java.awt.Component.dispatchEventImpl(Unknown Source)
>>        at java.awt.Container.dispatchEventImpl(Unknown Source)
>>        at java.awt.Component.dispatchEvent(Unknown Source)
>>        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown
>> Source)
>>        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
>>        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
>>        at java.awt.Container.dispatchEventImpl(Unknown Source)
>>        at java.awt.Component.dispatchEvent(Unknown Source)
>>        at java.awt.EventQueue.dispatchEvent(Unknown Source)
>>        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown
>> Source)
>>        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>>        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
>> Source)
>>        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>        at java.awt.EventDispatchThread.run(Unknown Source)
>> Caused by: org.opengis.referencing.operation.OperationNotFoundException:
>> No transformation available from system "ImageCRS[Grid]" to
>> "GeographicCRS[WGS84(DD)]".
>>        at
>> org.geotoolkit.referencing.operation.DefaultCoordinateOperationFactory.createOperation(DefaultCoordinateOperationFactory.java:339)
>>        at org.geotoolkit.referencing.CRS.transform(CRS.java:1454)
>>        ... 35 more
>> Jan 11, 2011 4:26:47 PM org.geotoolkit.map.DefaultMapContext getBounds
>> WARNING: Data source and map context coordinate system differ, yet it
>> was not possible to get a projected bounds estimate...
>> org.opengis.referencing.operation.TransformException: Can't transform
>> envelope.
>>        at org.geotoolkit.referencing.CRS.transform(CRS.java:1456)
>>        at
>> org.geotoolkit.map.DefaultMapContext.getBounds(DefaultMapContext.java:136)
>>        at
>> com.spotimage.sdi.applet.OOApplet$1.actionPerformed(OOApplet.java:74)
>>        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
>>        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown
>> Source)
>>        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown
>> Source)
>>        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
>>        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown
>> Source)
>>        at java.awt.Component.processMouseEvent(Unknown Source)
>>        at javax.swing.JComponent.processMouseEvent(Unknown Source)
>>        at java.awt.Component.processEvent(Unknown Source)
>>        at java.awt.Container.processEvent(Unknown Source)
>>        at java.awt.Component.dispatchEventImpl(Unknown Source)
>>        at java.awt.Container.dispatchEventImpl(Unknown Source)
>>        at java.awt.Component.dispatchEvent(Unknown Source)
>>        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown
>> Source)
>>        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
>>        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
>>        at java.awt.Container.dispatchEventImpl(Unknown Source)
>>        at java.awt.Component.dispatchEvent(Unknown Source)
>>        at java.awt.EventQueue.dispatchEvent(Unknown Source)
>>        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown
>> Source)
>>        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>>        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
>> Source)
>>        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>        at java.awt.EventDispatchThread.run(Unknown Source)
>> Caused by: org.opengis.referencing.operation.OperationNotFoundException:
>> No transformation available from system "ImageCRS[Grid]" to
>> "GeographicCRS[WGS84(DD)]".
>>        at
>> org.geotoolkit.referencing.operation.DefaultCoordinateOperationFactory.createOperation(DefaultCoordinateOperationFactory.java:339)
>>        at org.geotoolkit.referencing.CRS.transform(CRS.java:1454)
>>        ... 26 more
>> Jan 11, 2011 4:26:47 PM org.geotoolkit.map.DefaultMapContext getBounds
>> WARNING: Data source and map context coordinate system differ, yet it
>> was not possible to get a projected bounds estimate...
>> org.opengis.referencing.operation.TransformException: Can't transform
>> envelope.
>>        at org.geotoolkit.referencing.CRS.transform(CRS.java:1456)
>>        at
>> org.geotoolkit.map.DefaultMapContext.getBounds(DefaultMapContext.java:136)
>>        at
>> com.spotimage.sdi.applet.OOApplet$1.actionPerformed(OOApplet.java:74)
>>        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
>>        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown
>> Source)
>>        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown
>> Source)
>>        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
>>        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown
>> Source)
>>        at java.awt.Component.processMouseEvent(Unknown Source)
>>        at javax.swing.JComponent.processMouseEvent(Unknown Source)
>>        at java.awt.Component.processEvent(Unknown Source)
>>        at java.awt.Container.processEvent(Unknown Source)
>>        at java.awt.Component.dispatchEventImpl(Unknown Source)
>>        at java.awt.Container.dispatchEventImpl(Unknown Source)
>>        at java.awt.Component.dispatchEvent(Unknown Source)
>>        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown
>> Source)
>>        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
>>        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
>>        at java.awt.Container.dispatchEventImpl(Unknown Source)
>>        at java.awt.Component.dispatchEvent(Unknown Source)
>>        at java.awt.EventQueue.dispatchEvent(Unknown Source)
>>        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown
>> Source)
>>        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>>        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
>> Source)
>>        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>        at java.awt.EventDispatchThread.run(Unknown Source)
>> Caused by: org.opengis.referencing.operation.OperationNotFoundException:
>> No transformation available from system "ImageCRS[Grid]" to
>> "GeographicCRS[WGS84(DD)]".
>>        at
>> org.geotoolkit.referencing.operation.DefaultCoordinateOperationFactory.createOperation(DefaultCoordinateOperationFactory.java:339)
>>        at org.geotoolkit.referencing.CRS.transform(CRS.java:1454)
>>        ... 26 more
>> org.opengis.referencing.operation.TransformException: Can't transform
>> envelope.
>>        at org.geotoolkit.referencing.CRS.transform(CRS.java:1456)
>>        at
>> org.geotoolkit.display.canvas.DefaultCanvasController2D.setVisibleArea(DefaultCanvasController2D.java:272)
>>        at
>> org.geotoolkit.display2d.canvas.J2DCanvasVolatile$DelayedController.setVisibleArea(J2DCanvasVolatile.java:299)
>>        at
>> com.spotimage.sdi.applet.OOApplet$1.actionPerformed(OOApplet.java:74)
>>        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
>>        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown
>> Source)
>>        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown
>> Source)
>>        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
>>        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown
>> Source)
>>        at java.awt.Component.processMouseEvent(Unknown Source)
>>        at javax.swing.JComponent.processMouseEvent(Unknown Source)
>>        at java.awt.Component.processEvent(Unknown Source)
>>        at java.awt.Container.processEvent(Unknown Source)
>>        at java.awt.Component.dispatchEventImpl(Unknown Source)
>>        at java.awt.Container.dispatchEventImpl(Unknown Source)
>>        at java.awt.Component.dispatchEvent(Unknown Source)
>>        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown
>> Source)
>>        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
>>        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
>>        at java.awt.Container.dispatchEventImpl(Unknown Source)
>>        at java.awt.Component.dispatchEvent(Unknown Source)
>>        at java.awt.EventQueue.dispatchEvent(Unknown Source)
>>        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown
>> Source)
>>        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
>>        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
>> Source)
>>        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
>>        at java.awt.EventDispatchThread.run(Unknown Source)
>> Caused by: org.opengis.referencing.operation.OperationNotFoundException:
>> No transformation available from system "ImageCRS[Grid]" to
>> "GeographicCRS[WGS84(DD)]".
>>        at
>> org.geotoolkit.referencing.operation.DefaultCoordinateOperationFactory.createOperation(DefaultCoordinateOperationFactory.java:339)
>>        at org.geotoolkit.referencing.CRS.transform(CRS.java:1454)
>>        ... 27 more
>>
>>
>> I understand that the first issue seems to be related to the
>> imagereader and the second seems to be a transformation issue. But it
>> works fine through the appletviewer which makes me think that it is
>> probably a missing library issue. Could you please help me ?
>>
>> Basically the applet allows the user to select a file in the local
>> file system (jpeg or tiff). Then it shows the coverage image.
>> The applet's jar is signed in order to run outside the security
>> sandbox to allow local file system access. I checked that every
>> required jar (geotk + extra) is provided with the applet. Every
>> dependent jar had to be signed as well. Please let me know if you want
>> me to provide the code.
>>
>> Kind regards,
>> Ramzi
>
> _______________________________________________
> Geotoolkit mailing list
> Geotoolkit at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/geotoolkit
>


More information about the Geotoolkit mailing list