|
From: Greg E. <gr...@er...> - 2009-01-22 02:27:21
|
Hi Michael,
This does not quite work because the the compiler is unable to locate
the newly defined method in the anonymous subclass. But, creating a
named subclass of DefaultMapLayer with your dataChanged method does
work.
You have to override all of the constructors in DefaultMapLayer, since
it has no public constructor, like so:
public class UpdatingMapLayer
extends DefaultMapLayer
{
UpdatingMapLayer(AbstractGridCoverage2DReader reader, Style style)
throws Exception
{
super(reader, style);
}
UpdatingMapLayer(AbstractGridCoverage2DReader reader, Style style,
String title)
throws Exception
{
super(reader, style, title);
}
UpdatingMapLayer(CollectionSource source, Style style, String title)
{
super(source, style, title);
}
UpdatingMapLayer(Collection collection, Style style)
{
super(collection, style);
}
UpdatingMapLayer(Collection collection, Style style, String title)
{
super(collection, style, title);
}
UpdatingMapLayer(FeatureCollection<SimpleFeatureType,
SimpleFeature> collection, Style style)
{
super(collection, style);
}
UpdatingMapLayer(FeatureCollection<SimpleFeatureType,
SimpleFeature> collection, Style style, String title)
{
super(collection, style, title);
}
UpdatingMapLayer(FeatureSource<SimpleFeatureType, SimpleFeature>
featureSource, Style style)
{
super(featureSource, style);
}
UpdatingMapLayer(FeatureSource<SimpleFeatureType, SimpleFeature>
featureSource, Style style, String title)
{
super(featureSource, style, title);
}
UpdatingMapLayer(GridCoverage coverage, Style style)
throws Exception
{
super(coverage, style);
}
UpdatingMapLayer(GridCoverage coverage, Style style, String title)
throws Exception
{
super(coverage, style, title);
}
public void dataChanged()
{
sourceListener.changed(null);
}
}
Cheers,
Greg
On Jan 21, 2009, at 4:53 PM, Michael Bedward wrote:
> Greg,
>
> Could you test this for me please ?
>
> // instead of myMapContext.addLayer( myGrid, myStyle ) do
> this...
> //
> MapLayer myGridLayer = new DefaultMapLayer(myGrid, myStyle) {
> public void dataChanged() {
> sourceListener.changed(null);
> }
> };
>
> myMapContext.addLayer(myGridLayer);
>
> // later when you've changed the grid data
> myGridLayer.dataChanged();
>
> Fingers crossed...
>
> Michael
|