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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Jun 30 15:45:41 CEST 2010


Author: alfonx
Date: 2010-06-30 15:45:41 +0200 (Wed, 30 Jun 2010)
New Revision: 917

Modified:
   trunk/src/schmitzm/geotools/styling/StylingUtil.java
Log:
There are now two different Selection Styles to choose from via an enum

Modified: trunk/src/schmitzm/geotools/styling/StylingUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/styling/StylingUtil.java	2010-06-28 18:17:39 UTC (rev 916)
+++ trunk/src/schmitzm/geotools/styling/StylingUtil.java	2010-06-30 13:45:41 UTC (rev 917)
@@ -926,8 +926,7 @@
 	 * @return Always a {@link Style} that you can be applyed to a
 	 *         {@link GridCoverage}.
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static Style createStyleFromColorMap(ColorMap colorMap, String name,
 			String title) {
@@ -967,8 +966,7 @@
 	 * Removes all label information from the {@link ColorMapEntry}s of the
 	 * given {@link ColorMap}
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static ColorMap clearColorMapLabels(ColorMap colorMap) {
 		for (ColorMapEntry cme : colorMap.getColorMapEntries()) {
@@ -992,8 +990,7 @@
 	 *         colormap was provided.
 	 * 
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static Style createStyleFromColorMap(ColorMap colorMap, String name) {
 		return createStyleFromColorMap(colorMap, name, null);
@@ -1008,8 +1005,7 @@
 	 * @return An {@link Array} of {@link Style}s, can be length==0 if no
 	 *         UserStyles in SLD file. null if file not exists
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static Style[] loadSLD(URL url) {
 		InputStream openStream = null;
@@ -1032,8 +1028,7 @@
 	 * @return An {@link Array} of {@link Style}s, can be length==0. null if
 	 *         file not exists
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static Style[] loadSLD(InputStream inputStream) {
 
@@ -1061,8 +1056,7 @@
 	 * 
 	 * @return An {@link Array} of {@link Style}s, can be length==0
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static Style[] loadSLD(File sldFile) throws FileNotFoundException {
 
@@ -1087,8 +1081,7 @@
 	 *            {@link Style} to save. Any selectino related FeatureTypeStyle
 	 *            will be removed.
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 * 
 	 * @return <code>true</code> if the file was really written.
 	 *         <code>false</code> means, that the existing file already was
@@ -1124,8 +1117,7 @@
 	 *            {@link Style} to save. Any selectino related FeatureTypeStyle
 	 *            will be removed.
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 * @throws TransformerException
 	 */
 	public static final void saveStyleToSLD(Style style,
@@ -1286,8 +1278,7 @@
 	 *         sichtbaren regeln raussuchen, und dann direkt am anfang damitmit
 	 *         mitfiltern...
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static MemoryFeatureCollection filterSLDVisibleOnly(
 			final FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
@@ -1612,70 +1603,6 @@
 		return results;
 	}
 
-	// /**
-	// * Sorts a {@link ColorMap} by its quantity values. This is mentioned in
-	// the
-	// * OGC SLD Definition, page 52:
-	// * <p>
-	// * Quote: For example, a DEM raster giving elevations in meters above sea
-	// * level can be translated to a colored image with a ColorMap. The
-	// quantity
-	// * attributes of a color-map are used for translating between numeric
-	// * matrixes and color rasters and the ColorMap entries should be in order
-	// of
-	// * increasing numeric quantity so that intermediate numeric values can be
-	// * matched to a color (or be interpolated between two colors). Labels may
-	// be
-	// * used for legends or may be used in the future to match character
-	// values.
-	// * Not all systems can support opacity in colormaps. The default opacity
-	// is
-	// * 1.0 (fully opaque). Defaults for quantity and label are
-	// system-dependent.
-	// * </p>
-	// *
-	// * @param colorMap
-	// * {@link ColorMap} to sort by the quantity-field of the
-	// * {@link ColorMapEntry}s
-	// * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	// Tzeggai</a>
-	// */
-	// public static void sort(RemovableColorMapImpl colorMap) {
-	// ColorMapEntry[] colorMapEntries = colorMap.getColorMapEntries();
-	// SortedMap<Double, ColorMapEntry> tmap = new TreeMap<Double,
-	// ColorMapEntry>();
-	// // Add to a SortedMap
-	// for (ColorMapEntry cme : colorMapEntries) {
-	// tmap.put(getQuantityFromColorMapEntry(cme), cme);
-	// colorMap.removeColorMapEntry(cme);
-	// }
-	// // Recreate ColorMap from sorted quantity values
-	// for (ColorMapEntry cme : tmap.values()) {
-	// colorMap.addColorMapEntry(cme);
-	// }
-	// }
-
-	// /**
-	// * Lets assume that every quantity value is maximally listed once in a
-	// * {@link ColorMap}, then it makes some sense to use it as a key.
-	// *
-	// * @param quantityString
-	// * quantitiy as String
-	// * @return The first colorMap that has the same Quantity ( compared as
-	// * Strings)
-	// *
-	// * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	// Tzeggai</a>
-	// */
-	// public static ColorMapEntry getColorMapEntryByQuantityString(
-	// ColorMap colorMap, String quantityString) {
-	// for (ColorMapEntry cme : colorMap.getColorMapEntries()) {
-	// if (quantityString.equals(cme.getQuantity().toString()))
-	// return cme;
-	// }
-	// return null;
-	// }
-
 	/**
 	 * Clones a Style by converting it to XML and reading it back in.
 	 * 
@@ -1702,8 +1629,7 @@
 	 * 
 	 * @param graphicFill
 	 * @return
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static Graphic clone(Graphic graphic) {
 		DuplicatingStyleVisitor duplicatingStyleVisitor = new DuplicatingStyleVisitor();
@@ -1803,15 +1729,17 @@
 	 *         given type as selected items.
 	 */
 	public static FeatureTypeStyle createSelectionStyle(
-			GeometryForm geometryForm) {
-		Symbolizer[] symbolizers = createSelectionSymbolizers(geometryForm);
+			GeometryForm geometryForm, SelectionStylesTypes type) {
+		Symbolizer[] symbolizers = createSelectionSymbolizers(geometryForm, type);
 
 		return STYLE_BUILDER.createFeatureTypeStyle(symbolizers, 0.0,
 				Double.POSITIVE_INFINITY);
 	}
-
 	
-	
+	public enum SelectionStylesTypes {
+		LeftTop2RightBottom_lines, RightTop2LeftBottom_lines
+	}
+
 	/**
 	 * Creates a rule which paints features as selected.
 	 * 
@@ -1821,7 +1749,7 @@
 	 * @return
 	 */
 	public static Rule createSelectionRule(GeometryForm geometryForm,
-			String idPropertyName, List<String> selectionIds) {
+			String idPropertyName, List<String> selectionIds, SelectionStylesTypes type) {
 
 		if (idPropertyName == null)
 			throw new IllegalArgumentException();
@@ -1850,14 +1778,14 @@
 		}
 
 		// Symboizers
-		Symbolizer[] symbolizers = createSelectionSymbolizers(geometryForm);
+		Symbolizer[] symbolizers = createSelectionSymbolizers(geometryForm, type);
 		rule.symbolizers().addAll(Arrays.asList(symbolizers));
 
 		return rule;
 	}
 
 	public static Symbolizer[] createSelectionSymbolizers(
-			GeometryForm geometryForm) {
+			GeometryForm geometryForm, SelectionStylesTypes type) {
 		Symbolizer[] symbolizers = new Symbolizer[0];
 
 		switch (geometryForm) {
@@ -1878,7 +1806,14 @@
 			break;
 		case POLYGON: { // Black
 			Stroke outline = STYLE_BUILDER.createStroke(Color.red, 3);
-			Mark dots = STYLE_BUILDER.createMark("shape://backslash");
+			
+			Mark dots = null ;
+			if (type == SelectionStylesTypes.LeftTop2RightBottom_lines) {
+				dots = STYLE_BUILDER.createMark("shape://backslash");
+			} else {
+				dots = STYLE_BUILDER.createMark("shape://slash");
+			}
+			
 			dots.setStroke(STYLE_BUILDER.createStroke(Color.red, 3.));
 			Graphic fillGraphic = STYLE_BUILDER.createGraphic(null, dots, null);
 			fillGraphic.setSize(FILTER_FACTORY.literal(9.));
@@ -1887,7 +1822,7 @@
 			PolygonSymbolizer polS0 = STYLE_BUILDER.createPolygonSymbolizer(
 					outline, fill);
 			symbolizers = LangUtil.extendArray(symbolizers, polS0);
-		}
+			}
 
 			{ // White
 				Stroke outline = STYLE_BUILDER.createStroke(Color.yellow
@@ -1904,25 +1839,9 @@
 						.createPolygonSymbolizer(outline, fill);
 				symbolizers = LangUtil.extendArray(symbolizers, polS0);
 			}
-			// PolygonSymbolizer polS0 =
-			// STYLE_BUILDER.createPolygonSymbolizer(Color.RED);
-			// symbolizers = LangUtil.extendArray(symbolizers, polS0);
-
 			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);
-
 			LineSymbolizer ls = STYLE_BUILDER.createLineSymbolizer(Color.red,
 					3.);
 			symbolizers = LangUtil.extendArray(symbolizers, ls);
@@ -2058,8 +1977,7 @@
 	/**
 	 * Replaces the "main" color in a given {@link Symbolizer} element
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static void replaceSymbolizerColor(Symbolizer symb, Color oldColor,
 			Color newColor) {
@@ -2086,8 +2004,7 @@
 	/**
 	 * Replaces the "main" color in a given {@link LineSymbolizer} element
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static void replaceLineSymbolizerColor(LineSymbolizer ps,
 			Color oldColor, Color newColor) {
@@ -2100,8 +2017,7 @@
 	/**
 	 * Replaces the "main" color in a given {@link PointSymbolizer} element
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static void replacePointSymbolizerColor(PointSymbolizer ps,
 			Color oldColor, Color newColor) {
@@ -2116,8 +2032,7 @@
 	 * 
 	 * @param oldColor
 	 * @param newColor
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 * @param ps
 	 */
 	public static void replacePolygonSymbolizerColor(PolygonSymbolizer ps,
@@ -2178,8 +2093,7 @@
 	/**
 	 * Replaces the "main" color in a given {@link Graphic} element
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static void replaceGraphicColor(Graphic graphic, Color oldColor,
 			Color newColor) {
@@ -2206,8 +2120,7 @@
 	 * @param graphic
 	 *            If <code>null</code> returns <code>null</code>
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static Color getGraphicColor(Graphic graphic) {
 		if (graphic == null)
@@ -2235,8 +2148,7 @@
 	/**
 	 * @return the first {@link Color} used in a {@link Stroke}.
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static Color getStrokeColor(Stroke stroke) {
 		if (stroke == null)
@@ -2257,8 +2169,7 @@
 	/**
 	 * @return the first {@link Color} used in a {@link Fill}.
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static Color getFillColor(Fill fill) {
 		if (fill == null)
@@ -2278,8 +2189,7 @@
 	/**
 	 * @return the first {@link Color} used in a {@link Symbolizer}.
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static Color getSymbolizerColor(Symbolizer symb) {
 		if (symb == null)
@@ -2306,8 +2216,7 @@
 	/**
 	 * @return the first {@link Color} used in a {@link LineSymbolizer}.
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static Color getLineSymbolizerColor(LineSymbolizer ps) {
 		if (ps == null)
@@ -2324,8 +2233,7 @@
 	/**
 	 * @return the first {@link Color} used in a {@link PolygonSymbolizer}.
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static Color getPolygonSymbolizerColor(PolygonSymbolizer ps) {
 		if (ps == null)
@@ -2345,8 +2253,7 @@
 	/**
 	 * @return the first {@link Color} used in a {@link PointSymbolizer}.
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static Color getPointSymbolizerColor(PointSymbolizer ps) {
 		if (ps == null)
@@ -2364,8 +2271,7 @@
 	 * @param to
 	 *            {@link TextSymbolizer} target. May not be <code>null</code>.
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static void copyAllValues(final TextSymbolizer from,
 			final TextSymbolizer to) {
@@ -2488,8 +2394,7 @@
 	 *         sind, welche bei aktuellen Scale mit dem übergebenen Style
 	 *         gerendert werden.
 	 * 
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Tzeggai</a>
+	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons Tzeggai</a>
 	 */
 	public static FeatureCollection<SimpleFeatureType, SimpleFeature> filterSLDVisibleOnly(
 			final FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
@@ -2929,12 +2834,12 @@
 	}
 
 	/**
-	 * Converts a {@link StyledLayerDescriptor} or any of it's subcomponents to XML
+	 * Converts a {@link StyledLayerDescriptor} or any of it's subcomponents to
+	 * XML
 	 * 
 	 * @throws TransformerException
 	 */
-	public static String toXMLString(Object sld)
-			throws TransformerException {
+	public static String toXMLString(Object sld) throws TransformerException {
 		return SLDTRANSFORMER.transform(sld);
 	}
 



More information about the Schmitzm-commits mailing list