I have the following problem:
I imported a ArcInfoGrid and added it (as a RenderedGridCoverage) to
StyledMapPane. AFTER showing the grid in StyledMapPane, I want to change
the GridCoverage (better: the underlying WritableRaster) manually.
How can I update the StyledMapPane (or the RenderedGridCoverage), so the
changes become visible?
Attached to this mail you find an example program to comprehend my
problem and my attempts to solve it.
After renaming the attachment to .zip and unzip it into an empty
directory (I attached gt2-arcgrid-2.1.x.jar too because this is not part
of the standard geotools lib, but I need it for the ArcInfoGrid import).
In a windows system (with an installed JRE) you can use the batch-File
to start my program. All you have to do, is to change the path to JAI
and GEOTOOLS 2.1.M3 in the runGridUpdateTest.bat.
If you need my sample grid file, send a mail (spad@...).
If you do following steps (in my program), the changes become visible:
1) Import the grid
2) Modify the grid (change the upper left 100x100 Pixels to value 3)
3) Show the grid
But if you do the following (and that is what I want), the changes
aren't displayed in StyledMapPane:
1) Import the grid
2) Show the grid
3) Modify the grid (change the upper left 100x100 Pixels to value 3)
4) Update grid in map (invoke
Here my attempts to solve the problem:
First I tried to invoke
StyledMapPane.getRenderer().getLayers().repaint() but this didn't
Then I tried to use the "build-in update mechanism" by using the
GridCoverage gc = ...
RenderedGridCoverage gridLayer = new RenderedGridCoverage(gc);
A call of WritableRenderedImage.getWritableTile(0,0) (get the
WritableRaster to change manually) and
WritableRenderedImage.releaseWritableTile(0,0) (after finishing the
changes) should inform the TileObserver (my RenderedGridCoverage in the
MapPane) about the changes. And the RenderedGridCoverage should initiate
a repaint (as it is described in the JavaDoc of
But this does not work, too. I think this is because the
GridCoverage-Class produces a java.awt.image.BufferedImage as
implementation of java.awt.image.WritableRenderedImage.
And when I looked into the JDK1.5.0_01 source code of
java.awt.image.BufferedImage, I recognized, that the corresponding
methods (eg. BufferedImage.addTileObserver(..) or
BufferedImage.releaseWritableTile(..)) are empty!! They do nothing!!
So I understand, why my ImageObserver (my RenderedGridCoverage) isn't
But this is unfortunately no solution for my problem!! :-) How can I
update the Grid-Visualization in the StyledMapPane after manually
changing the underlying WritableRaster?
Who can help me?