01: /*
02: * uDig - User Friendly Desktop Internet GIS client
03: * http://udig.refractions.net
04: * (C) 2004, Refractions Research Inc.
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: */
17: package net.refractions.udig.render.internal.feature.shapefile;
18:
19: import net.refractions.udig.project.internal.render.SelectionLayer;
20: import net.refractions.udig.project.render.IRenderContext;
21: import net.refractions.udig.project.render.IRenderMetrics;
22: import net.refractions.udig.project.render.IRenderMetricsFactory;
23: import net.refractions.udig.project.render.IRenderer;
24:
25: import org.geotools.data.FeatureSource;
26: import org.geotools.data.shapefile.ShapefileDataStore;
27:
28: /**
29: * The RenderMetricsFactory object for the BasicFeatureRenderer Extension
30: *
31: * @author Jesse Eichar
32: * @version $Revision: 1.9 $
33: */
34: public class ShapefileFeatureMetricsFactory implements
35: IRenderMetricsFactory {
36:
37: /**
38: * @see net.refractions.udig.project.render.IRenderMetricsFactory#createMetrics(net.refractions.udig.project.render.IRenderContext)
39: */
40: public IRenderMetrics createMetrics(IRenderContext context) {
41: return new ShapefileFeatureMetrics(context, this );
42: }
43:
44: /**
45: * @see net.refractions.udig.project.render.IRenderMetricsFactory#canRender(net.refractions.udig.project.render.IRenderContext)
46: */
47: public boolean canRender(IRenderContext context) {
48: try {
49: // if( context.getLayer() instanceof SelectionLayer)
50: // return false;
51: FeatureSource fs = context.getGeoResource().resolve(
52: FeatureSource.class, null);
53: return fs != null
54: && (fs.getDataStore() instanceof ShapefileDataStore);
55: // && (
56: // (MultiPolygon.class.isAssignableFrom(fs.getSchema().getDefaultGeometry().getType())) ||
57: // (MultiLineString.class.isAssignableFrom(fs.getSchema().getDefaultGeometry().getType()) ) ));
58: } catch (Throwable t) {
59: return false;
60: }
61: }
62:
63: /**
64: * @see IRenderMetricsFactory#getRendererType()
65: */
66: public Class<? extends IRenderer> getRendererType() {
67: return ShapefileFeatureRenderer.class;
68: }
69:
70: }
|