[Schmitzm-commits] r129 - trunk/src/schmitzm/geotools/styling

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sat May 30 18:28:52 CEST 2009


Author: alfonx
Date: 2009-05-30 18:28:52 +0200 (Sat, 30 May 2009)
New Revision: 129

Modified:
   trunk/src/schmitzm/geotools/styling/StylingUtil.java
Log:
* Moved methods from AtlasStyler's Utilities.java to schmitzm's StylingUtil.java

Modified: trunk/src/schmitzm/geotools/styling/StylingUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/styling/StylingUtil.java	2009-05-30 16:27:26 UTC (rev 128)
+++ trunk/src/schmitzm/geotools/styling/StylingUtil.java	2009-05-30 16:28:52 UTC (rev 129)
@@ -12,6 +12,7 @@
 package schmitzm.geotools.styling;
 
 import java.awt.Color;
+import java.awt.RenderingHints;
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -27,6 +28,7 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.SortedMap;
 import java.util.TreeMap;
 
@@ -40,13 +42,16 @@
 import org.geotools.coverage.Category;
 import org.geotools.coverage.GridSampleDimension;
 import org.geotools.coverage.grid.GridCoverage2D;
+import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader;
 import org.geotools.data.FeatureSource;
 import org.geotools.data.memory.MemoryFeatureCollection;
 import org.geotools.factory.CommonFactoryFinder;
+import org.geotools.factory.GeoTools;
 import org.geotools.factory.Hints;
 import org.geotools.feature.Feature;
 import org.geotools.feature.FeatureCollection;
 import org.geotools.feature.GeometryAttributeType;
+import org.geotools.filter.ConstantExpression;
 import org.geotools.gui.swing.ExceptionMonitor;
 import org.geotools.renderer.lite.RendererUtilities;
 import org.geotools.resources.i18n.Vocabulary;
@@ -55,10 +60,13 @@
 import org.geotools.styling.ColorMapEntry;
 import org.geotools.styling.ColorMapEntryImpl;
 import org.geotools.styling.ColorMapImpl;
+import org.geotools.styling.ExternalGraphic;
 import org.geotools.styling.FeatureTypeStyle;
 import org.geotools.styling.FeatureTypeStyleImpl;
+import org.geotools.styling.Fill;
 import org.geotools.styling.Graphic;
 import org.geotools.styling.LineSymbolizer;
+import org.geotools.styling.Mark;
 import org.geotools.styling.PointSymbolizer;
 import org.geotools.styling.PolygonSymbolizer;
 import org.geotools.styling.RasterSymbolizer;
@@ -67,6 +75,7 @@
 import org.geotools.styling.RuleImpl;
 import org.geotools.styling.SLDParser;
 import org.geotools.styling.SLDTransformer;
+import org.geotools.styling.Stroke;
 import org.geotools.styling.Style;
 import org.geotools.styling.StyleBuilder;
 import org.geotools.styling.StyleFactory;
@@ -79,6 +88,7 @@
 import org.opengis.coverage.grid.GridCoverage;
 import org.opengis.filter.Filter;
 import org.opengis.filter.expression.Expression;
+import org.opengis.filter.expression.Literal;
 import org.opengis.filter.expression.NilExpression;
 
 import schmitzm.geotools.FilterUtil;
@@ -93,6 +103,9 @@
 import com.vividsolutions.jts.geom.MultiPolygon;
 import com.vividsolutions.jts.geom.Polygon;
 
+import schmitzm.geotools.feature.FeatureUtil.GeometryForm;
+import schmitzm.lang.LangUtil;
+
 /**
  * Diese Klasse enthaelt Hilfsfunktionen zum GeoTools-Styling
  * 
@@ -107,9 +120,13 @@
 	/** Transparente Farbe */
 	public static final Color TRANSPARENT_COLOR = new Color(0, 0, 0, 0);
 
-	/** Standard-Instanz eines {@link StyleBuilder}. */
+	/**
+	 * Standard-Instanz eines {@link StyleBuilder}.
+	 * 
+	 * @Deprecated Bitte nicht benutzen. Ich habe schlechte Efahrungen damit.
+	 *             Zumindest uin 2.4.
+	 */
 	public static final StyleBuilder STYLE_BUILDER = new StyleBuilder();
-	
 
 	/** Standard-Instanz eines {@link SLDTransformer}. */
 	public final static SLDTransformer SLDTRANSFORMER = new SLDTransformer();
@@ -123,7 +140,8 @@
 
 	/** Standard-Instanz einer {@link StyleFactory} */
 	public static final StyleFactory STYLE_FACTORY = CommonFactoryFinder
-			.getStyleFactory(new Hints(new HashMap()));
+			.getStyleFactory(GeoTools.getDefaultHints());
+
 	/**
 	 * Standard-Instanz einer {@link StyleFactory}
 	 * 
@@ -132,6 +150,92 @@
 	public static final StyleFactory styleFactory = STYLE_FACTORY;
 
 	/**
+	 * TODO SK
+	 * The following constants are used to speed up
+	 * {@link #createSelectionStyle(Object)}. I will "redo" them soon and also document them. This is still under construction.
+	 * TODO SK   
+	 */
+
+	static final Literal size0 = FeatureUtil.FILTER_FACTORY2.literal(13);
+	static final Literal size1 = FeatureUtil.FILTER_FACTORY2.literal(9);
+	static final Literal size2 = FeatureUtil.FILTER_FACTORY2.literal(7);
+	static final Literal size3 = FeatureUtil.FILTER_FACTORY2.literal(3);
+	static final Literal zeroLit = FeatureUtil.FILTER_FACTORY2.literal(0);
+
+	// static final Stroke SELECTION_STROKE1 =
+	// STYLE_FACTORY.createStroke(STYLE_BUILDER.colorExpression(Color.YELLOW),
+	// size2);
+
+	static final Stroke SELECTION_STROKE1 = STYLE_FACTORY.createStroke(
+			STYLE_BUILDER.colorExpression(Color.YELLOW.brighter()),
+			FeatureUtil.FILTER_FACTORY2.literal(4), FeatureUtil.FILTER_FACTORY2
+					.literal(1.), FeatureUtil.FILTER_FACTORY.literal("round"),
+			FeatureUtil.FILTER_FACTORY.literal("round"), new float[0],
+			FeatureUtil.FILTER_FACTORY2.literal(0), null, null);
+
+	static final Stroke SELECTION_STROKE2 = STYLE_FACTORY.createStroke(
+			STYLE_BUILDER.colorExpression(Color.BLACK),
+			FeatureUtil.FILTER_FACTORY2.literal(1.5),
+			FeatureUtil.FILTER_FACTORY2.literal(1.), FeatureUtil.FILTER_FACTORY
+					.literal("round"), FeatureUtil.FILTER_FACTORY
+					.literal("round"), new float[] { 3f, 3f },
+			FeatureUtil.FILTER_FACTORY2.literal(0), null, null);
+
+	static final Stroke SELECTION_STROKE3 = STYLE_FACTORY.createStroke(
+			STYLE_BUILDER.colorExpression(Color.WHITE),
+			FeatureUtil.FILTER_FACTORY2.literal(1.5),
+			FeatureUtil.FILTER_FACTORY2.literal(1.), FeatureUtil.FILTER_FACTORY
+					.literal("round"), FeatureUtil.FILTER_FACTORY
+					.literal("round"), new float[] { 3f, 3f },
+			FeatureUtil.FILTER_FACTORY2.literal(3), null, null);
+
+	static final Graphic SELECTION_GRAPHIC1 = STYLE_FACTORY.createGraphic(
+			new ExternalGraphic[0], new Mark[] { STYLE_FACTORY.createMark(
+					FeatureUtil.FILTER_FACTORY2.literal("square"), null,
+					STYLE_FACTORY.createFill(STYLE_BUILDER
+							.colorExpression(Color.WHITE)), size1, zeroLit) },
+			new org.geotools.styling.Symbol[0], FeatureUtil.FILTER_FACTORY2
+					.literal(1), size1, zeroLit);
+
+	static final Graphic SELECTION_GRAPHIC2 = STYLE_FACTORY.createGraphic(
+			new ExternalGraphic[0], new Mark[] { STYLE_FACTORY.createMark(
+					FeatureUtil.FILTER_FACTORY2.literal("circle"), null,
+					STYLE_FACTORY.createFill(STYLE_BUILDER
+							.colorExpression(Color.BLACK)), size2, zeroLit) },
+			new org.geotools.styling.Symbol[0], FeatureUtil.FILTER_FACTORY2
+					.literal(1), size2, zeroLit);
+
+	static final Graphic SELECTION_GRAPHIC3 = STYLE_FACTORY.createGraphic(
+			new ExternalGraphic[0], new Mark[] { STYLE_FACTORY.createMark(
+					FeatureUtil.FILTER_FACTORY2.literal("circle"), null,
+					STYLE_FACTORY.createFill(STYLE_BUILDER
+							.colorExpression(Color.YELLOW.brighter())), size3,
+					zeroLit) }, new org.geotools.styling.Symbol[0],
+			FeatureUtil.FILTER_FACTORY2.literal(1), size3, zeroLit);
+	static final Fill SELECTION_FILL1 = STYLE_FACTORY.createFill(STYLE_BUILDER
+			.colorExpression(Color.RED), null,
+			FeatureUtil.FILTER_FACTORY2.literal(1),
+			STYLE_FACTORY.createGraphic(new ExternalGraphic[0],
+					new Mark[] { STYLE_FACTORY.createMark(
+							FeatureUtil.FILTER_FACTORY2
+									.literal("circle"), null,
+							STYLE_FACTORY.createFill(STYLE_BUILDER
+									.colorExpression(Color.RED)), size3,
+							zeroLit) },
+					new org.geotools.styling.Symbol[0],
+					FeatureUtil.FILTER_FACTORY2.literal(1), size3,
+					zeroLit));
+
+	
+
+	// /**
+	// * Up to three {@link Style styles} suitable to present selected {@link
+	// Feature features} are cached here. (SK)
+	// */
+	// private static Map<GeometryForm,Style> selectionStyles = new
+	// HashMap<GeometryForm, Style>();
+
+	/**
 	 * Erstellt einen Default-Style fuer ein Geo-Objekt.
 	 * 
 	 * @param object
@@ -551,27 +655,24 @@
 	 * 
 	 * @param expression
 	 *            Expression, die einen String liefert
-	 * @param opacity
-	 *            Transparenz der Farbe
 	 */
-	public static Color getColorFromExpression(Expression expression,
-			Double opacity) {
+	public static Color getColorFromExpression(Expression expression) {
 		if (expression == null)
 			return null;
 
-		return Color.decode((String) expression.evaluate(null));
+		if (expression instanceof ConstantExpression) {
+			ConstantExpression a = (ConstantExpression) expression;
+			Object obj = a.getValue();
+			if (obj instanceof Color) {
+				return (Color) obj;
+			}
+		}
 
-		// // int colorInt = Integer.decode( (String)
-		// expression.getValue(null)); // gt2-2.3.4
-		// int colorInt = Integer.decode( (String) expression.evaluate(null));
-		// // gt2-2-4-2
-		//
-		// return new Color(
-		// (colorInt >> 16) & 0xFF,
-		// (colorInt >> 8) & 0xFF,
-		// colorInt & 0xFF,
-		// new Double(Math.ceil(255.0 * opacity.floatValue())).intValue()
-		// );
+		return Color.decode(expression.toString());
+
+		// Old way Martin did it:
+		// return Color.decode((String) expression.evaluate(null));
+
 	}
 
 	/**
@@ -587,10 +688,10 @@
 				|| entry.getColor().evaluate(null) == null) // gt2-2-4-2
 			return null;
 
-		// Transparenz
-		Double opacity = getOpacityFromColorMapEntry(entry);
-		// Farbe
-		return getColorFromExpression(entry.getColor(), opacity);
+		// // Transparenz
+		// Double opacity = getOpacityFromColorMapEntry(entry);
+
+		return getColorFromExpression(entry.getColor());
 	}
 
 	/**
@@ -1031,7 +1132,8 @@
 	 */
 	public static TextSymbolizer getTextSymbolizer(final Style style,
 			final Feature f) {
-		if (f == null) return null;
+		if (f == null)
+			return null;
 		try {
 			if (style != null) {
 
@@ -1039,10 +1141,10 @@
 					for (final Rule r : fts.getRules()) {
 
 						final Filter filter = r.getFilter();
-//
-//						System.out.println(f);
-//						System.out.println(filter);
-//						System.out.println();
+						//
+						// System.out.println(f);
+						// System.out.println(filter);
+						// System.out.println();
 
 						if (filter != null && (!filter.evaluate(f))) {
 							continue;
@@ -1075,8 +1177,8 @@
 	 * 
 	 * @author Stefan A. Krüger
 	 * 
-	 * @return {@link List} or all {@link TextSymbolizer}s found in
-	 *         the {@link Style}.
+	 * @return {@link List} or all {@link TextSymbolizer}s found in the
+	 *         {@link Style}.
 	 */
 	public static List<TextSymbolizer> getTextSymbolizers(final Style style) {
 		List<TextSymbolizer> results = new ArrayList<TextSymbolizer>();
@@ -1167,12 +1269,12 @@
 	// }
 	// return null;
 	// }
-	
 
-
 	/**
-	 * Clones a Style by converting it to XML and reading it back in.  
-	 * @param style the {@link Style} to be copied.
+	 * Clones a Style by converting it to XML and reading it back in.
+	 * 
+	 * @param style
+	 *            the {@link Style} to be copied.
 	 */
 	public static Style clone(Style style) {
 
@@ -1192,37 +1294,37 @@
 		}
 	}
 
-
 	public static Symbolizer clone(Symbolizer sym) {
 		if (sym == null) {
 			throw new RuntimeException("cant clone null");
 		}
-		
+
 		/**
-		 * Doing some corrections. Otherwise the Symbolizer can not be converted to XML
+		 * Doing some corrections. Otherwise the Symbolizer can not be converted
+		 * to XML
 		 */
 		if (sym instanceof PointSymbolizer) {
-			PointSymbolizer ps = (PointSymbolizer)sym;
+			PointSymbolizer ps = (PointSymbolizer) sym;
 			Graphic graphic = ps.getGraphic();
-			
-			if (graphic.getSize() instanceof NilExpression){
+
+			if (graphic.getSize() instanceof NilExpression) {
 				graphic.setSize(FilterUtil.FILTER_FAC.literal(10.));
 			}
 			try {
 				SLDTRANSFORMER.transform(graphic);
 			} catch (TransformerException e) {
-				LOGGER.error("gr",e);
+				LOGGER.error("gr", e);
 			}
 		}
-		
+
 		Style style = STYLE_BUILDER.createStyle(sym); // TODO Mag ich das?
-		
 
-		Filter allwaysTrueFilter = FilterUtil.FILTER_FAC2.equals(FilterUtil.FILTER_FAC2.literal("1"),
-				FilterUtil.FILTER_FAC2.literal("1"));
+		Filter allwaysTrueFilter = FilterUtil.FILTER_FAC2.equals(
+				FilterUtil.FILTER_FAC2.literal("1"), FilterUtil.FILTER_FAC2
+						.literal("1"));
 
-		style.getFeatureTypeStyles()[0].getRules()[0].setFilter(allwaysTrueFilter);
-		
+		style.getFeatureTypeStyles()[0].getRules()[0]
+				.setFilter(allwaysTrueFilter);
 
 		String xml;
 		try {
@@ -1253,7 +1355,8 @@
 	 */
 	public static Graphic clone(Graphic graphic) {
 		try {
-			PointSymbolizer ps = STYLE_FACTORY.createPointSymbolizer(graphic, "ACHTUNG");
+			PointSymbolizer ps = STYLE_FACTORY.createPointSymbolizer(graphic,
+					"ACHTUNG");
 
 			Style style = STYLE_BUILDER.createStyle(ps);
 
@@ -1276,33 +1379,252 @@
 		}
 		return null;
 	}
-	
+
 	/**
 	 * Creates a new {@link BrewerPalette} with only one scheme (which includes
 	 * all colors). The suitablity of the palette is set to "unknown" for all
 	 * viewer types.
-	 * @param name   name for the palette (also the description is set to this value)
-	 * @param colors colors for the palette
+	 * 
+	 * @param name
+	 *            name for the palette (also the description is set to this
+	 *            value)
+	 * @param colors
+	 *            colors for the palette
 	 */
-	public static BrewerPalette createBrewerPalette(String name, Color[] colors) throws IOException {
-	  BrewerPalette palette = new BrewerPalette();
-      palette.setColors(colors);
-      palette.setName(name);
-      palette.setDescription(name);
+	public static BrewerPalette createBrewerPalette(String name, Color[] colors)
+			throws IOException {
+		BrewerPalette palette = new BrewerPalette();
+		palette.setColors(colors);
+		palette.setName(name);
+		palette.setDescription(name);
 
-      // set suitability to UNKNOWN for all viewers
-      PaletteSuitability suitability = new PaletteSuitability();
-      suitability.setSuitability(colors.length, new String[] {"?","?","?","?","?","?"} );
-      palette.setPaletteSuitability(suitability);
+		// set suitability to UNKNOWN for all viewers
+		PaletteSuitability suitability = new PaletteSuitability();
+		suitability.setSuitability(colors.length, new String[] { "?", "?", "?",
+				"?", "?", "?" });
+		palette.setPaletteSuitability(suitability);
 
-      // set the only scheme for the palette (include all colors)
-      int[] schema = new int[colors.length];
-      for (int j=0; j<schema.length; j++)
-        schema[j] = j;
-      SampleScheme sampleScheme = new SampleScheme();
-      sampleScheme.setSampleScheme(schema.length, schema);
-      palette.setColorScheme(sampleScheme);
-      
-      return palette;
+		// set the only scheme for the palette (include all colors)
+		int[] schema = new int[colors.length];
+		for (int j = 0; j < schema.length; j++)
+			schema[j] = j;
+		SampleScheme sampleScheme = new SampleScheme();
+		sampleScheme.setSampleScheme(schema.length, schema);
+		palette.setColorScheme(sampleScheme);
+
+		return palette;
 	}
+
+	/**
+	 * @param geoObject
+	 *            {@link GridCoverage2D}, {@link AbstractGridCoverage2DReader},
+	 *            {@link FeatureCollection}, {@link GeometryAttributeType} or
+	 *            {@link FeatureSource}
+	 * 
+	 * @return a {@link Style} that is suitable to identify features of the
+	 *         given type as selected items.
+	 */
+	public static Style createSelectionStyle(Object geoObject) {
+
+		if (geoObject instanceof GridCoverage2D
+				|| geoObject instanceof org.geotools.coverage.grid.io.AbstractGridCoverage2DReader) {
+			// Wenn irgendwann mal selection für raster möglich ist, dann hier
+			// einen schöneren style erstellen.
+			return GridUtil.createDefaultStyle();
+		}
+
+		// We have vector-data. Now let's determine the type...
+		GeometryForm geometryForm = null;
+
+		if (geoObject instanceof FeatureCollection) {
+			geometryForm = FeatureUtil
+					.getGeometryForm((FeatureCollection) geoObject);
+		} else if (geoObject instanceof GeometryAttributeType) {
+			geometryForm = FeatureUtil
+					.getGeometryForm((GeometryAttributeType) geoObject);
+		} else if (geoObject instanceof FeatureSource) {
+			geometryForm = FeatureUtil
+					.getGeometryForm((FeatureSource) geoObject);
+		}
+
+		// /**
+		// * Let's see if we have a cached version of the requested style.
+		// */
+		// if (selectionStyles.containsKey(geometryForm))
+		// return selectionStyles.get(geometryForm);
+
+		Style style = STYLE_FACTORY.createStyle();
+		style.addFeatureTypeStyle(STYLE_FACTORY.createFeatureTypeStyle());
+		Symbolizer[] symbolizers = new Symbolizer[0];
+
+		switch (geometryForm) {
+	
+		case POINT:
+			PointSymbolizer ps = STYLE_FACTORY.createPointSymbolizer();
+			ps.setGraphic(SELECTION_GRAPHIC1);
+			symbolizers = LangUtil.extendArray(symbolizers, ps);
+
+			PointSymbolizer ps2 = STYLE_FACTORY.createPointSymbolizer();
+			ps2.setGraphic(SELECTION_GRAPHIC2);
+			symbolizers = LangUtil.extendArray(symbolizers, ps2);
+
+			PointSymbolizer ps3 = STYLE_FACTORY.createPointSymbolizer();
+			ps3.setGraphic(SELECTION_GRAPHIC3);
+			symbolizers = LangUtil.extendArray(symbolizers, ps3);
+
+			break;
+		case POLYGON:
+
+			PolygonSymbolizer polS0 = STYLE_FACTORY.createPolygonSymbolizer();
+
+			Fill SELECTION_FILL0 = STYLE_FACTORY.createFill(STYLE_BUILDER
+					.colorExpression(Color.YELLOW.brighter()));
+
+			polS0.setFill(SELECTION_FILL0);
+			symbolizers = LangUtil.extendArray(symbolizers, polS0);
+
+	
+			
+//			
+//			PolygonSymbolizer polS = STYLE_FACTORY.createPolygonSymbolizer();
+//			
+//			Fill SELECTION_FILL1 = STYLE_FACTORY.createFill(STYLE_BUILDER
+//					.colorExpression(Color.RED), null,
+//					FeatureUtil.FILTER_FACTORY2.literal(1),
+//					STYLE_FACTORY.createGraphic(new ExternalGraphic[0],
+//							new Mark[] { STYLE_FACTORY.createMark(
+//									FeatureUtil.FILTER_FACTORY2
+//									.literal("hatch"), null,
+//									STYLE_FACTORY.createFill(STYLE_BUILDER
+//											.colorExpression(Color.YELLOW
+//													.brighter())), size1,
+//													zeroLit) },
+//													new org.geotools.styling.Symbol[0],
+//													FeatureUtil.FILTER_FACTORY2.literal(1), size1,
+//													zeroLit));
+//			
+//			
+//			polS.setFill(SELECTION_FILL1);
+//			symbolizers = LangUtil.extendArray(symbolizers, polS);
+			
+			PolygonSymbolizer polS = STYLE_FACTORY.createPolygonSymbolizer();
+			polS.setFill(SELECTION_FILL1);
+			symbolizers = LangUtil.extendArray(symbolizers, polS);
+
+	
+//			
+//			
+//			PolygonSymbolizer polS2 = STYLE_FACTORY.createPolygonSymbolizer();
+//			Mark hatchMark1 = STYLE_FACTORY.createMark(
+//					FeatureUtil.FILTER_FACTORY2.literal("hatch"), null,
+//					STYLE_FACTORY.createFill(STYLE_BUILDER
+//							.colorExpression(Color.RED)), size1,
+//					zeroLit);
+//		
+//			Fill SELECTION_FILL2 = STYLE_FACTORY.createFill(STYLE_BUILDER
+//					.colorExpression(Color.GREEN.brighter()), null,
+//					FeatureUtil.FILTER_FACTORY2.literal(1), STYLE_FACTORY
+//							.createGraphic(new ExternalGraphic[0],
+//									new Mark[] { hatchMark1 },
+//									new org.geotools.styling.Symbol[0],
+//									FeatureUtil.FILTER_FACTORY2.literal(1),
+//									size1, FeatureUtil.FILTER_FACTORY2
+//											.literal(90)));
+//			polS2.setFill(SELECTION_FILL2);
+//			symbolizers = LangUtil.extendArray(symbolizers, polS2);
+
+//			
+//			PolygonSymbolizer polS3 = STYLE_FACTORY.createPolygonSymbolizer();
+//			Mark hatchMark2 = STYLE_FACTORY.createMark(
+//					FeatureUtil.FILTER_FACTORY2.literal("x"), null,
+//					STYLE_FACTORY.createFill(STYLE_BUILDER
+//							.colorExpression(Color.WHITE)), size0,
+//					zeroLit);
+//		
+//			Fill SELECTION_FILL3 = STYLE_FACTORY.createFill(STYLE_BUILDER
+//					.colorExpression(Color.GREEN.brighter()), null,
+//					FeatureUtil.FILTER_FACTORY2.literal(1), STYLE_FACTORY
+//							.createGraphic(new ExternalGraphic[0],
+//									new Mark[] { hatchMark2 },
+//									new org.geotools.styling.Symbol[0],
+//									FeatureUtil.FILTER_FACTORY2.literal(1),
+//									size0, FeatureUtil.FILTER_FACTORY2
+//											.literal(15)));
+//			polS3.setFill(SELECTION_FILL3);
+//			symbolizers = LangUtil.extendArray(symbolizers, polS3);
+//
+//
+//			
+//			PolygonSymbolizer polS4 = STYLE_FACTORY.createPolygonSymbolizer();
+//			Mark hatchMark3 = STYLE_FACTORY.createMark(
+//					FeatureUtil.FILTER_FACTORY2.literal("x"), null,
+//					STYLE_FACTORY.createFill(STYLE_BUILDER
+//							.colorExpression(Color.BLACK)), size1,
+//					zeroLit);
+//		
+//			Fill SELECTION_FILL4 = STYLE_FACTORY.createFill(STYLE_BUILDER
+//					.colorExpression(Color.GREEN.brighter()), null,
+//					FeatureUtil.FILTER_FACTORY2.literal(1), STYLE_FACTORY
+//							.createGraphic(new ExternalGraphic[0],
+//									new Mark[] { hatchMark3 },
+//									new org.geotools.styling.Symbol[0],
+//									FeatureUtil.FILTER_FACTORY2.literal(1),
+//									size1, FeatureUtil.FILTER_FACTORY2
+//											.literal(60)));
+//			polS4.setFill(SELECTION_FILL4);
+//			symbolizers = LangUtil.extendArray(symbolizers, polS4);
+//			
+//
+//			
+//			PolygonSymbolizer polS5 = STYLE_FACTORY.createPolygonSymbolizer();
+//			Mark hatchMark4 = STYLE_FACTORY.createMark(
+//					FeatureUtil.FILTER_FACTORY2.literal("x"), null,
+//					STYLE_FACTORY.createFill(STYLE_BUILDER
+//							.colorExpression(Color.YELLOW.brighter())), size2,
+//					zeroLit);
+//		
+//			Fill SELECTION_FILL5 = STYLE_FACTORY.createFill(STYLE_BUILDER
+//					.colorExpression(Color.GREEN.brighter()), null,
+//					FeatureUtil.FILTER_FACTORY2.literal(1), STYLE_FACTORY
+//							.createGraphic(new ExternalGraphic[0],
+//									new Mark[] { hatchMark4 },
+//									new org.geotools.styling.Symbol[0],
+//									FeatureUtil.FILTER_FACTORY2.literal(1),
+//									size2, FeatureUtil.FILTER_FACTORY2
+//											.literal(60)));
+//			polS5.setFill(SELECTION_FILL5);
+//			symbolizers = LangUtil.extendArray(symbolizers, polS5);
+//			
+
+//			break;
+		case LINE:
+			LineSymbolizer ls = STYLE_FACTORY.createLineSymbolizer();
+			ls.setStroke(SELECTION_STROKE1);
+			symbolizers = LangUtil.extendArray(symbolizers, ls);
+
+			LineSymbolizer ls2 = STYLE_FACTORY.createLineSymbolizer();
+			ls2.setStroke(SELECTION_STROKE2);
+			symbolizers = LangUtil.extendArray(symbolizers, ls2);
+
+			LineSymbolizer ls3 = STYLE_FACTORY.createLineSymbolizer();
+			ls3.setStroke(SELECTION_STROKE3);
+			symbolizers = LangUtil.extendArray(symbolizers, ls3);
+			break;
+
+			
+		default:
+			throw new IllegalArgumentException("Provide a suitable object.");
+		}
+
+		style.getFeatureTypeStyles()[0].setRules(new Rule[] { STYLE_FACTORY
+				.createRule() });
+		style.getFeatureTypeStyles()[0].getRules()[0]
+				.setSymbolizers(symbolizers);
+
+		// selectionStyles.put(geometryForm, style);
+
+		return style;
+
+	}
+
 }



More information about the Schmitzm-commits mailing list