01: /*
02: * uDig - User Friendly Desktop Internet GIS client http://udig.refractions.net (C) 2004, Refractions Research Inc. This
03: * library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
04: * License as published by the Free Software Foundation; version 2.1 of the License. This library is distributed in the
05: * hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
07: */
08: package net.refractions.udig.render.internal.feature.shapefile;
09:
10: import java.awt.RenderingHints;
11: import java.util.HashMap;
12: import java.util.logging.Handler;
13: import java.util.logging.Level;
14: import java.util.logging.LogRecord;
15: import java.util.logging.Logger;
16:
17: import net.refractions.udig.project.ILayer;
18: import net.refractions.udig.project.ProjectBlackboardConstants;
19: import net.refractions.udig.project.internal.render.SelectionLayer;
20: import net.refractions.udig.render.internal.feature.basic.BasicFeatureRenderer;
21: import net.refractions.udig.render.internal.feature.basic.RendererPlugin;
22: import net.refractions.udig.render.internal.feature.basic.Trace;
23:
24: import org.geotools.data.DefaultQuery;
25: import org.geotools.data.Query;
26: import org.geotools.filter.Filter;
27: import org.geotools.renderer.GTRenderer;
28: import org.geotools.renderer.lite.StreamingRenderer;
29: import org.geotools.renderer.shape.ShapefileRenderer;
30:
31: /**
32: * The default victim renderer. Based on the Lite-Renderer from Geotools.
33: *
34: * @author Jesse Eichar
35: * @version $Revision: 1.9 $
36: */
37: public class ShapefileFeatureRenderer extends BasicFeatureRenderer {
38: ShapefileRenderer renderer;
39:
40: public ShapefileFeatureRenderer() {
41: ClassLoader current = getClass().getClassLoader();
42: try {
43: Thread.currentThread().setContextClassLoader(
44: ShapefileRenderer.class.getClassLoader());
45: Logger logger = Logger
46: .getLogger("org.geotools.renderer.shape");//$NON-NLS-1$
47: if (RendererPlugin.isDebugging(Trace.FINEST)) {
48: logger.setLevel(Level.FINE);
49: logger.addHandler(new Handler() {
50:
51: @Override
52: public void publish(LogRecord record) {
53: System.err.println(record.getMessage());
54: }
55:
56: @Override
57: public void flush() {
58: System.err.flush();
59: }
60:
61: @Override
62: public void close() throws SecurityException {
63:
64: }
65:
66: });
67: } else {
68: logger.setLevel(Level.SEVERE);
69: }
70: } finally {
71: Thread.currentThread().setContextClassLoader(current);
72: }
73: }
74:
75: @Override
76: protected GTRenderer getRenderer() {
77: if (renderer == null) {
78: renderer = new ShapefileRenderer(map);
79: HashMap<String, Object> rendererHints = new HashMap<String, Object>();
80: rendererHints.put("optimizedDataLoadingEnabled", true); //$NON-NLS-1$
81: renderer.setRendererHints(rendererHints);
82: renderer
83: .removeRenderListener(StreamingRenderer.DEFAULT_LISTENER);
84: renderer.addRenderListener(listener);
85:
86: RenderingHints hints = new RenderingHints(
87: RenderingHints.KEY_ANTIALIASING,
88: RenderingHints.VALUE_ANTIALIAS_ON);
89: renderer.setJava2DHints(hints);
90: }
91: renderer.setContext(map);
92: return renderer;
93: }
94:
95: }
|