[Schmitzm-commits] r439 - branches/1.0-gt2-2.6/src/schmitzm/geotools
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Oct 5 15:09:41 CEST 2009
Author: mojays
Date: 2009-10-05 15:09:40 +0200 (Mon, 05 Oct 2009)
New Revision: 439
Modified:
branches/1.0-gt2-2.6/src/schmitzm/geotools/GTUtil.java
Log:
Renderer instantiated by GTUtil.createGTRenderer(..) can be set dynamically.
Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/GTUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/GTUtil.java 2009-10-05 13:04:01 UTC (rev 438)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/GTUtil.java 2009-10-05 13:09:40 UTC (rev 439)
@@ -54,6 +54,19 @@
public class GTUtil {
private static Logger LOGGER = Logger.getLogger( GTUtil.class.getName() );
+ /**
+ * Specifies the types of renderer used by {@link GTUtil#createGTRenderer()}.
+ */
+ public static enum GTRendererType {
+ /** {@link GTUtil#createGTRenderer()} uses {@link StreamingRenderer}. */
+ StreamingRenderer,
+ /** {@link GTUtil#createGTRenderer()} uses {@link ShapefileRenderer}. */
+ ShapefileRenderer
+ }
+ /** Holds the renderer type instantiated by
+ * {@link GTUtil#createGTRenderer()}. */
+ private static GTRendererType rendererType = GTRendererType.ShapefileRenderer;
+
/** Konstante fuer das CRS "WGS84" (erzeugt als "EPSG:4326")*/
public static CoordinateReferenceSystem WGS84 = null;
@@ -193,10 +206,38 @@
* @param mapContext a {@link MapContext} (can be {@code null})
*/
public static GTRenderer createGTRenderer(MapContext mapContext) {
- GTRenderer renderer = new StreamingRenderer();
-
+ GTRenderer renderer = createGTRenderer();
if ( mapContext != null )
renderer.setContext(mapContext);
return renderer;
}
+
+ /**
+ * Creates a {@link GTRenderer}. This method can be used all over
+ * a project, so the renderer can be switched easily.
+ */
+ public static GTRenderer createGTRenderer() {
+ switch ( rendererType ) {
+ case ShapefileRenderer: return new ShapefileRenderer();
+ case StreamingRenderer: return new StreamingRenderer();
+ }
+ throw new UnsupportedOperationException("Renderer type not supported: "+rendererType);
+ }
+
+ /**
+ * Sets the renderer used by {@link #createGTRenderer()}.
+ * @param rType renderer type
+ * @see GTRendererType
+ */
+ public static void setGTRendererType(GTRendererType rType) {
+ rendererType = rType;
+ }
+
+ /**
+ * Returns the renderer used by {@link #createGTRenderer()}.
+ * @see GTRendererType
+ */
+ public static GTRendererType getGTRendererType() {
+ return rendererType;
+ }
}
More information about the Schmitzm-commits
mailing list