[Schmitzm-commits] r452 - in branches/1.0-gt2-2.6/src: gtmig/org/geotools/swing schmitzm/geotools/feature schmitzm/geotools/gui schmitzm/geotools/styling skrueger/geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Oct 9 21:16:29 CEST 2009


Author: alfonx
Date: 2009-10-09 21:16:27 +0200 (Fri, 09 Oct 2009)
New Revision: 452

Modified:
   branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/JMapPane.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureUtil.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java
   branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java
   branches/1.0-gt2-2.6/src/skrueger/geotools/LegendIconFeatureRenderer.java
Log:
* AS-Feature: The labeling tab now has a preview pane and can set the priority column. Both still has to be improved.

Modified: branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/JMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/JMapPane.java	2009-10-09 18:45:57 UTC (rev 451)
+++ branches/1.0-gt2-2.6/src/gtmig/org/geotools/swing/JMapPane.java	2009-10-09 19:16:27 UTC (rev 452)
@@ -78,7 +78,7 @@
 
 public class JMapPane extends JPanel implements MouseListener,
 		MouseMotionListener, PropertyChangeListener, MapLayerListListener {
-	private static Logger LOGGER = Logger.getLogger(JMapPane.class.getName());
+	private static Logger LOGGER = Logger.getLogger(JMapPane.class);
 
 	private static final long serialVersionUID = -8647971481359690499L;
 

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureUtil.java	2009-10-09 18:45:57 UTC (rev 451)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/feature/FeatureUtil.java	2009-10-09 19:16:27 UTC (rev 452)
@@ -1734,7 +1734,7 @@
 	 * @author SK
 	 * @throws org.opengis.feature.IllegalAttributeException
 	 */
-	public static SimpleFeature createSampleFeature(SimpleFeatureType schema) {
+	public static SimpleFeature createSampleFeature(SimpleFeatureType schema, Object... values) {
 		SimpleFeature sampleFeature;
 
 //		Object[] attributes = getDefaultAttributeValues(schema);
@@ -1742,7 +1742,7 @@
 		try {
 			SimpleFeatureBuilder builder = new SimpleFeatureBuilder(schema);
 			sampleFeature = builder.buildFeature("createSampleFeature_"
-					+ new Random().nextInt());
+					+ new Random().nextInt(), values);
 
 		} catch (org.opengis.feature.IllegalAttributeException e) {
 			// Thrown if the SimpleFeatureType does not validate the attributes

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java	2009-10-09 18:45:57 UTC (rev 451)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/gui/JMapPane.java	2009-10-09 19:16:27 UTC (rev 452)
@@ -79,7 +79,6 @@
 import org.geotools.renderer.GTRenderer;
 import org.geotools.renderer.lite.RendererUtilities;
 import org.geotools.renderer.lite.StreamingRenderer;
-import org.geotools.resources.CRSUtilities;
 import org.geotools.resources.coverage.FeatureUtilities;
 import org.geotools.resources.image.ImageUtilities;
 import org.geotools.styling.Style;

Modified: branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java
===================================================================
--- branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java	2009-10-09 18:45:57 UTC (rev 451)
+++ branches/1.0-gt2-2.6/src/schmitzm/geotools/styling/StylingUtil.java	2009-10-09 19:16:27 UTC (rev 452)
@@ -114,6 +114,7 @@
 import schmitzm.geotools.feature.FeatureUtil.GeometryForm;
 import schmitzm.geotools.grid.GridUtil;
 import schmitzm.lang.LangUtil;
+import skrueger.geotools.StyledFeaturesInterface;
 
 import com.vividsolutions.jts.geom.Geometry;
 import com.vividsolutions.jts.geom.LineString;
@@ -177,34 +178,34 @@
 	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.), FILTER_FACTORY.literal("round"),
+//			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.), FILTER_FACTORY
+//					.literal("round"), 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.), FILTER_FACTORY
+//					.literal("round"), FILTER_FACTORY.literal("round"),
+//			new float[] { 3f, 3f }, FeatureUtil.FILTER_FACTORY2.literal(3),
+//			null, null);
 
-	// 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.), FILTER_FACTORY.literal("round"),
-			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.), FILTER_FACTORY
-					.literal("round"), 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.), FILTER_FACTORY
-					.literal("round"), 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,
@@ -229,24 +230,11 @@
 					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
-	// SimpleFeature features} are cached here. (SK)
-	// */
-	// private static Map<GeometryForm,Style> selectionStyles = new
-	// HashMap<GeometryForm, Style>();
-
 	/**
-	 * Erstellt einen Default-Style fuer ein Geo-Objekt.
+	 * Erstellt einen Default-Style fuer die Klassen/Interfaces:
+	 * StyledFeaturesInterface, GridCoverage2D, FeatureCollection, FeatureSource
+	 * und GeometryAttributeType.
 	 * 
 	 * @param object
 	 *            {@link GridCoverage2D},
@@ -256,24 +244,30 @@
 	 * 
 	 */
 	public static Style createDefaultStyle(Object object) {
-		Style style = STYLE_FACTORY.createStyle(); // SK.. nicer default than
+		Style style = STYLE_BUILDER.createStyle(); // SK.. nicer default than
 		// null !
 
+		if (object instanceof StyledFeaturesInterface)
+			style = FeatureUtil
+					.createDefaultStyle(((StyledFeaturesInterface<?>) object)
+							.getSchema().getGeometryDescriptor());
+
 		if (object instanceof GridCoverage2D
 				|| object instanceof AbstractGridCoverage2DReader)
 			style = GridUtil.createDefaultStyle();
 
 		if (object instanceof FeatureCollection)
-			style = FeatureUtil.createDefaultStyle((FeatureCollection<SimpleFeatureType, SimpleFeature>) object);
-
-		if (object instanceof GeometryAttributeType)
 			style = FeatureUtil
-					.createDefaultStyle((GeometryAttributeType) object);
+					.createDefaultStyle((FeatureCollection<SimpleFeatureType, SimpleFeature>) object);
 
 		if (object instanceof FeatureSource)
 			style = FeatureUtil.createDefaultStyle(((FeatureSource) object)
 					.getSchema().getGeometryDescriptor());
 
+		if (object instanceof GeometryAttributeType)
+			style = FeatureUtil
+					.createDefaultStyle((GeometryAttributeType) object);
+
 		return style;
 	}
 
@@ -1098,15 +1092,15 @@
 	 */
 	public static final void saveStyleToSLD(Style style, File exportFile,
 			Charset charset) throws TransformerException, IOException {
-//
-//		if (charset != null) {
-//			LOGGER
-//					.warn("Explicitly setting the Chartset to "
-//							+ charset
-//							+ "! Steve thinks that this is a bad idea, because it doesn't"
-//							+ " transform the content but just declares the header.");
-//			SLDTRANSFORMER.setEncoding(charset);
-//		}
+		//
+		// if (charset != null) {
+		// LOGGER
+		// .warn("Explicitly setting the Chartset to "
+		// + charset
+		// + "! Steve thinks that this is a bad idea, because it doesn't"
+		// + " transform the content but just declares the header.");
+		// SLDTRANSFORMER.setEncoding(charset);
+		// }
 		SLDTRANSFORMER.setIndentation(2);
 		SLDTRANSFORMER.transform(style, new FileWriter(exportFile));
 
@@ -1115,8 +1109,8 @@
 	}
 
 	/**
-	 * Saves the {@link Style} to OGC SLD using UTF-8 as charset.
-	 * Overwrites any existing file.
+	 * Saves the {@link Style} to OGC SLD using UTF-8 as charset. Overwrites any
+	 * existing file.
 	 * 
 	 * @param style
 	 *            {@link Style} to save
@@ -1341,7 +1335,8 @@
 	 * @return {@link List} or all {@link TextSymbolizer}s found in the
 	 *         {@link Style}.
 	 */
-	public static List<TextSymbolizer> getVisibleTextSymbolizers(final Style style) {
+	public static List<TextSymbolizer> getVisibleTextSymbolizers(
+			final Style style) {
 		List<TextSymbolizer> results = new ArrayList<TextSymbolizer>();
 		try {
 			if (style != null) {
@@ -1359,30 +1354,43 @@
 							 * .literal("1"), ff2.literal("2"));
 							 */
 							try {
-								
-							Filter f = r.getFilter();
-							if (f instanceof And) {
-								And and = (And) f;
-								if (and.getChildren() != null) {
-									Filter candidateF = and.getChildren()
-											.get(0);
-									if (candidateF instanceof PropertyIsEqualTo) {
-										final PropertyIsEqualTo compare = (PropertyIsEqualTo) candidateF;
-										if (compare.getExpression1() instanceof Literal && compare.getExpression2() instanceof Literal) {
-											Literal test1 = (Literal)compare.getExpression1();
-											Literal test2 = (Literal)compare.getExpression2();
-											if (   test1.toString().equals("1") && test2.toString().equals("2")){
-												// This TextSymbolizer is disabled using ASUtil.allwaysFalseFilter
-//												LOGGER.debug("Ignoring Rule "+ r +" because the filter is "+f);
-												continue;
+
+								Filter f = r.getFilter();
+								if (f instanceof And) {
+									And and = (And) f;
+									if (and.getChildren() != null) {
+										Filter candidateF = and.getChildren()
+												.get(0);
+										if (candidateF instanceof PropertyIsEqualTo) {
+											final PropertyIsEqualTo compare = (PropertyIsEqualTo) candidateF;
+											if (compare.getExpression1() instanceof Literal
+													&& compare.getExpression2() instanceof Literal) {
+												Literal test1 = (Literal) compare
+														.getExpression1();
+												Literal test2 = (Literal) compare
+														.getExpression2();
+												if (test1.toString()
+														.equals("1")
+														&& test2.toString()
+																.equals("2")) {
+													// This TextSymbolizer is
+													// disabled using
+													// ASUtil.allwaysFalseFilter
+													// LOGGER.debug("Ignoring Rule "+
+													// r
+													// +" because the filter is "+f);
+													continue;
+												}
 											}
 										}
 									}
 								}
+							} catch (Exception e) {
+								LOGGER
+										.debug(
+												"Checking for textSymbolizer allwaysFalseFilter",
+												e);
 							}
-							}catch (Exception e) {
-								LOGGER.debug("Checking for textSymbolizer allwaysFalseFilter",e);
-							}
 						}
 
 						results.addAll(getTextSymbolizers(r.getSymbolizers()));
@@ -1398,10 +1406,6 @@
 		return results;
 	}
 
-	
-	
-	
-
 	/**
 	 * @param style
 	 *            A {@link Style} to search for all {@link TextSymbolizer}s . No
@@ -1433,10 +1437,6 @@
 		return results;
 	}
 
-	
-	
-	
-	
 	/**
 	 * @param symbolizers
 	 *            List of Symbolizers to search for all {@link TextSymbolizer}s

Modified: branches/1.0-gt2-2.6/src/skrueger/geotools/LegendIconFeatureRenderer.java
===================================================================
--- branches/1.0-gt2-2.6/src/skrueger/geotools/LegendIconFeatureRenderer.java	2009-10-09 18:45:57 UTC (rev 451)
+++ branches/1.0-gt2-2.6/src/skrueger/geotools/LegendIconFeatureRenderer.java	2009-10-09 19:16:27 UTC (rev 452)
@@ -111,6 +111,13 @@
 		// In GT 2.4.5 it we have to create a new one all the time!
 		
 		// TODO TEST, whether we still need to recreate the renderer here....
+		// TODO TEST, whether we still need to recreate the renderer here....
+		// TODO TEST, whether we still need to recreate the renderer here....
+		// TODO TEST, whether we still need to recreate the renderer here....
+		// TODO TEST, whether we still need to recreate the renderer here....
+		// TODO TEST, whether we still need to recreate the renderer here....
+		// TODO TEST, whether we still need to recreate the renderer here....
+		// TODO TEST, whether we still need to recreate the renderer here....
 		return new LegendIconFeatureRenderer();
 //		 return instance;
 	}
@@ -471,9 +478,7 @@
 
 		// TODO scaleDenominator = 100000000000000000000000000000d; Was ist das
 		// fuer ein Quatsch?
-		final double scaleDenominator = 100000000000000000000000000000d;
-		final NumberRange scaleRange = new NumberRange(scaleDenominator,
-				scaleDenominator);
+		final NumberRange<Integer> scaleRange = NumberRange.create(Integer.MAX_VALUE,Integer.MAX_VALUE);
 
 		try {
 
@@ -504,7 +509,7 @@
 
 				if (style2d != null) {
 					new StyledShapePainter(null).paint(graphics, shape,
-							style2d, scaleDenominator);
+							style2d, Integer.MAX_VALUE );
 				}
 			}
 		} catch (Exception e) {



More information about the Schmitzm-commits mailing list