[Schmitzm-commits] r946 - in trunk: src/schmitzm/geotools/styling src/schmitzm/swing src/skrueger/geotools/selection src_junit/schmitzm/jfree/feature/style

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Jul 26 19:13:45 CEST 2010


Author: alfonx
Date: 2010-07-26 19:13:42 +0200 (Mon, 26 Jul 2010)
New Revision: 946

Added:
   trunk/src/schmitzm/geotools/styling/StylingUtilTest.java
Modified:
   trunk/src/schmitzm/geotools/styling/StylingUtil.java
   trunk/src/schmitzm/swing/TestingUtil.java
   trunk/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java
   trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java
Log:
Kleine Aufr?\195?\164umarbeiten... 

Modified: trunk/src/schmitzm/geotools/styling/StylingUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/styling/StylingUtil.java	2010-07-23 17:11:46 UTC (rev 945)
+++ trunk/src/schmitzm/geotools/styling/StylingUtil.java	2010-07-26 17:13:42 UTC (rev 946)
@@ -175,13 +175,6 @@
 			.getStyleFactory(GeoTools.getDefaultHints());
 
 	/**
-	 * Standard-Instanz einer {@link StyleFactory}
-	 * 
-	 * @deprecated wurde ersetzt durch {@link #STYLE_FACTORY}
-	 */
-	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
@@ -227,7 +220,10 @@
 					zeroLit) }, new org.geotools.styling.Symbol[0],
 			FeatureUtil.FILTER_FACTORY2.literal(1), size3, zeroLit);
 
-	/** THis string is set as the Name of the Rules that describe selected features **/
+	/**
+	 * THis string is set as the Name of the Rules that describe selected
+	 * features
+	 **/
 	public static final String SELECTION_RULE_ID = "SelectionRule";
 
 	/**
@@ -1159,8 +1155,8 @@
 	}
 
 	/**
-	 * Returns <code>null</code> or any {@link FeatureTypeStyle} that is
-	 * SELECTION related.
+	 * Returns <code>null</code> or any {@link FeatureTypeStyle} contained in
+	 * the given {@link Style} that is SELECTION related.
 	 * 
 	 * @see {@link FeatureMapLayerSelectionSynchronizer#SELECTION_STYLING_FTS_NAME}
 	 */
@@ -1691,10 +1687,15 @@
 	 *            {@link FeatureCollection}, {@link GeometryAttributeType} or
 	 *            {@link FeatureSource}
 	 * 
+	 * @param type
+	 *            define the look of the selection style by choosing a constant
+	 *            from {@link SelectionStylesTypes}
+	 * 
 	 * @return a {@link Style} that is suitable to identify features of the
 	 *         given type as selected items.
 	 */
-	public static FeatureTypeStyle createSelectionStyle(Object geoObject) {
+	public static FeatureTypeStyle createSelectionFTStyle(Object geoObject,
+			SelectionStylesTypes type) {
 
 		if (geoObject instanceof GridCoverage2D
 				|| geoObject instanceof org.geotools.coverage.grid.io.AbstractGridCoverage2DReader) {
@@ -1703,6 +1704,12 @@
 			return GridUtil.createDefaultStyle().featureTypeStyles().get(0);
 		}
 
+		if (geoObject instanceof GeometryForm) {
+			// Wenn irgendwann mal selection für raster möglich ist, dann hier
+			// einen schöneren style erstellen.
+			return createSelectionFTStyle((GeometryForm) geoObject, type);
+		}
+
 		// We have vector-data. Now let's determine the type...
 		GeometryForm geometryForm = null;
 
@@ -1717,19 +1724,32 @@
 					.getGeometryForm((FeatureSource<SimpleFeatureType, SimpleFeature>) geoObject);
 		}
 
-		return createSelectionStyle(geometryForm);
+		return createSelectionFTStyle(geometryForm, type);
 
 	}
 
+	public static Style createSelectionStyle(Object geoObject,
+			SelectionStylesTypes type) {
+		FeatureTypeStyle fts = createSelectionFTStyle(geoObject, type);
+		Style style = STYLE_FACTORY.createStyle();
+		style.featureTypeStyles().clear();
+		style.featureTypeStyles().add(fts);
+		return style;
+
+	}
+
 	/**
 	 * @param geoObject
 	 *            the {@link GeometryForm} the selection style shall be created
 	 *            for.
+	 * @param type
+	 *            define the look of the selection style by choosing a constant
+	 *            from {@link SelectionStylesTypes}
 	 * 
 	 * @return a {@link Style} that is suitable to identify features of the
 	 *         given type as selected items.
 	 */
-	public static FeatureTypeStyle createSelectionStyle(
+	public static FeatureTypeStyle createSelectionFTStyle(
 			GeometryForm geometryForm, SelectionStylesTypes type) {
 		Symbolizer[] symbolizers = createSelectionSymbolizers(geometryForm,
 				type);
@@ -1739,7 +1759,7 @@
 	}
 
 	public enum SelectionStylesTypes {
-		LeftTop2RightBottom_lines, RightTop2LeftBottom_lines
+		LeftTop2RightBottom_lines, RightTop2LeftBottom_lines, Outline_only, LeftTop2RightBottom_lines_biggaps, RightTop2LeftBottom_lines_biggaps, RightTop2LeftBottom_lines_smallgaps, LeftTop2RightBottom_lines_smallgaps
 	}
 
 	/**
@@ -1792,13 +1812,22 @@
 	public static Symbolizer[] createSelectionSymbolizers(
 			GeometryForm geometryForm, SelectionStylesTypes type) {
 		Symbolizer[] symbolizers = new Symbolizer[0];
-//
-//		// TODO Not a good idea to put the 500 here as constant!
-//		final Function offsetFunction = FilterUtil.FILTER_FAC2.function(
-//				"offset", FilterUtil.FILTER_FAC2.property("the_geom"),
-//				FilterUtil.FILTER_FAC2.literal(-500), FilterUtil.FILTER_FAC2
-//						.literal(500));
+		//
+		// // TODO Not a good idea to put the 500 here as constant!
+		// final Function offsetFunction = FilterUtil.FILTER_FAC2.function(
+		// "offset", FilterUtil.FILTER_FAC2.property("the_geom"),
+		// FilterUtil.FILTER_FAC2.literal(-500), FilterUtil.FILTER_FAC2
+		// .literal(500));
 
+		double size = 15.;
+		if (type == SelectionStylesTypes.RightTop2LeftBottom_lines_smallgaps
+				|| type == SelectionStylesTypes.LeftTop2RightBottom_lines_smallgaps) {
+			size = 10.;
+		} else if (type == SelectionStylesTypes.RightTop2LeftBottom_lines_biggaps
+				|| type == SelectionStylesTypes.LeftTop2RightBottom_lines_biggaps) {
+			size = 20.;
+		}
+
 		switch (geometryForm) {
 
 		case POINT:
@@ -1815,69 +1844,68 @@
 			symbolizers = LangUtil.extendArray(symbolizers, ps3);
 
 			break;
-		case POLYGON: { // Black
 
-//			// Dark shadow
-//			PolygonSymbolizer polSshadow = STYLE_BUILDER
-//					.createPolygonSymbolizer(STYLE_BUILDER.createStroke(
-//							Color.DARK_GRAY, 2, 0.7), null);
-//			symbolizers = LangUtil.extendArray(new Symbolizer[] { polSshadow },
-//					symbolizers);
+		case POLYGON:
+			String markShapeName = "";
+			if (type == SelectionStylesTypes.LeftTop2RightBottom_lines
+					|| type == SelectionStylesTypes.LeftTop2RightBottom_lines_smallgaps
+					|| type == SelectionStylesTypes.LeftTop2RightBottom_lines_biggaps) {
+				markShapeName = "shape://backslash";
+			} else if (type == SelectionStylesTypes.RightTop2LeftBottom_lines
+					|| type == SelectionStylesTypes.RightTop2LeftBottom_lines_smallgaps
+					|| type == SelectionStylesTypes.RightTop2LeftBottom_lines_biggaps) {
+				markShapeName = "shape://slash";
+			}
 
-			// <ogc:Function name="offset">
-			// <ogc:PropertyName>the_geom</ogc:PropertyName>
-			// <ogc:Literal>0.00004</ogc:Literal>
-			// <ogc:Literal>-0.00004</ogc:Literal>
-			// </ogc:Function>
+			{
 
-			Stroke outline = STYLE_BUILDER.createStroke(Color.red, 3);
+				Stroke outline = STYLE_BUILDER.createStroke(Color.red, 3);
 
-			Mark dots = null;
-			if (type == SelectionStylesTypes.LeftTop2RightBottom_lines) {
-				dots = STYLE_BUILDER.createMark("shape://backslash");
-			} else {
-				dots = STYLE_BUILDER.createMark("shape://slash");
-			}
+				Fill fill = null;
+				if (type != SelectionStylesTypes.Outline_only) {
 
-			dots.setStroke(STYLE_BUILDER.createStroke(Color.red, 3.));
-			Graphic fillGraphic = STYLE_BUILDER.createGraphic(null, dots, null);
-			fillGraphic.setSize(FILTER_FACTORY.literal(9.));
-			Fill fill = STYLE_BUILDER.createFill();
-			fill.setGraphicFill(fillGraphic);
-			PolygonSymbolizer polS0 = STYLE_BUILDER.createPolygonSymbolizer(
-					outline, fill);
-			// Add an offset to create a shadow effect
-			// Calculating the centroid of the whole Polygon so that not every
-			// Insel
-			// gets a chart
-//			polS0.setGeometry(offsetFunction);
+					Mark fillMark = STYLE_BUILDER.createMark(markShapeName);
+					fillMark.setStroke(STYLE_BUILDER
+							.createStroke(Color.red, 3.));
 
-			symbolizers = LangUtil.extendArray(symbolizers, polS0);
-		}
+					Graphic fillGraphic = STYLE_BUILDER.createGraphic(null,
+							fillMark, null);
 
+					fillGraphic.setSize(FILTER_FACTORY.literal(size));
+
+					fill = STYLE_BUILDER.createFill();
+					fill.setGraphicFill(fillGraphic);
+				}
+
+				PolygonSymbolizer polS0 = STYLE_BUILDER
+						.createPolygonSymbolizer(outline, fill);
+
+				symbolizers = LangUtil.extendArray(symbolizers, polS0);
+			}
+
 			{ // White
 				Stroke outline = STYLE_BUILDER.createStroke(Color.yellow
 						.brighter(), 1);
-				Mark dots = null;
 
-				if (type == SelectionStylesTypes.LeftTop2RightBottom_lines) {
-					dots = STYLE_BUILDER.createMark("shape://backslash");
-				} else {
-					dots = STYLE_BUILDER.createMark("shape://slash");
+				Fill fill = null;
+
+				if (type != SelectionStylesTypes.Outline_only) {
+					Mark fillMark = STYLE_BUILDER.createMark(markShapeName);
+					fillMark.setStroke(STYLE_BUILDER.createStroke(Color.yellow
+							.brighter(), 1.));
+					Graphic fillGraphic = STYLE_BUILDER.createGraphic(null,
+							fillMark, null);
+					fillGraphic.setSize(FILTER_FACTORY.literal(size));
+					fill = STYLE_BUILDER.createFill();
+					fill.setGraphicFill(fillGraphic);
 				}
 
-				dots.setStroke(STYLE_BUILDER.createStroke(Color.yellow
-						.brighter(), 1.));
-				Graphic fillGraphic = STYLE_BUILDER.createGraphic(null, dots,
-						null);
-				fillGraphic.setSize(FILTER_FACTORY.literal(9.));
-				Fill fill = STYLE_BUILDER.createFill();
-				fill.setGraphicFill(fillGraphic);
 				PolygonSymbolizer polS0 = STYLE_BUILDER
 						.createPolygonSymbolizer(outline, fill);
-//				polS0.setGeometry(offsetFunction);
+				// polS0.setGeometry(offsetFunction);
 				symbolizers = LangUtil.extendArray(symbolizers, polS0);
 			}
+
 			break;
 
 		case LINE:

Added: trunk/src/schmitzm/geotools/styling/StylingUtilTest.java
===================================================================
--- trunk/src/schmitzm/geotools/styling/StylingUtilTest.java	2010-07-23 17:11:46 UTC (rev 945)
+++ trunk/src/schmitzm/geotools/styling/StylingUtilTest.java	2010-07-26 17:13:42 UTC (rev 946)
@@ -0,0 +1,84 @@
+package schmitzm.geotools.styling;
+
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.GraphicsEnvironment;
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+import junit.framework.TestCase;
+
+import org.geotools.feature.FeatureCollection;
+import org.geotools.geometry.jts.ReferencedEnvelope;
+import org.geotools.map.DefaultMapContext;
+import org.geotools.map.DefaultMapLayer;
+import org.geotools.renderer.lite.StreamingRenderer;
+import org.geotools.styling.Style;
+import org.junit.Test;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
+
+import schmitzm.geotools.JTSUtil;
+import schmitzm.geotools.styling.StylingUtil.SelectionStylesTypes;
+import schmitzm.swing.TestingUtil;
+
+public class StylingUtilTest extends TestCase {
+
+	boolean INTERACTIVE = !GraphicsEnvironment.isHeadless();
+
+	@Test
+	public void testSelectionStyles() throws Throwable {
+
+		FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = TestingUtil
+				.getTestFeatures();
+		
+		JPanel jPanel = new JPanel();
+
+		for (SelectionStylesTypes st : SelectionStylesTypes.values()) {
+			Style style = StylingUtil.createSelectionStyle(testFeatures, st);
+
+			DefaultMapContext mc = new DefaultMapContext();
+			mc.addLayer(new DefaultMapLayer(testFeatures, style));
+
+			StreamingRenderer sr = new StreamingRenderer();
+			sr.setContext(mc);
+			
+			// DIe Bounds werden vom selected Feature genommen
+			ReferencedEnvelope bounds = testFeatures.getBounds();
+			Double imageW = 300.;
+			Double imageH = imageW * bounds.getHeight() / bounds.getWidth();
+
+			if (imageH > 200.) {
+				imageH = 200.;
+				imageW = imageH * bounds.getWidth() / bounds.getHeight();
+			}
+
+			BufferedImage img = new BufferedImage(imageW.intValue(), imageH
+					.intValue(), BufferedImage.TYPE_INT_ARGB);
+			Graphics2D gr = (Graphics2D) img.getGraphics();
+
+			gr.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
+					RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+			gr.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+					RenderingHints.VALUE_ANTIALIAS_ON);
+			gr.setRenderingHint(RenderingHints.KEY_RENDERING,
+					RenderingHints.VALUE_RENDER_QUALITY);
+
+			sr.paint(gr, new Rectangle(new Dimension(imageW
+					.intValue(), imageH.intValue())), JTSUtil
+					.expandEnvelope(testFeatures.getBounds(), .1));
+
+			gr.dispose();
+
+			jPanel.add(new JLabel(new ImageIcon(img, st.toString())));
+		}
+		TestingUtil.testPanel(jPanel, "Different selection styles");
+
+	}
+
+}


Property changes on: trunk/src/schmitzm/geotools/styling/StylingUtilTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native

Modified: trunk/src/schmitzm/swing/TestingUtil.java
===================================================================
--- trunk/src/schmitzm/swing/TestingUtil.java	2010-07-23 17:11:46 UTC (rev 945)
+++ trunk/src/schmitzm/swing/TestingUtil.java	2010-07-26 17:13:42 UTC (rev 946)
@@ -1,14 +1,24 @@
 package schmitzm.swing;
 
+import static org.junit.Assert.assertNotNull;
+
 import java.awt.GraphicsEnvironment;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.io.IOException;
+import java.net.URL;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 
 import javax.swing.JComponent;
 import javax.swing.JFrame;
 
+import org.geotools.feature.FeatureCollection;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
+
+import schmitzm.geotools.io.GeoImportUtil;
+import schmitzm.jfree.feature.style.FeatureChartStyleTest;
 import schmitzm.lang.LangUtil;
 
 /**
@@ -19,7 +29,6 @@
 public class TestingUtil {
 
 	public static final boolean INTERACTIVE = !GraphicsEnvironment.isHeadless();
-	
 
 	/**
 	 * Opens a {@link JFrame} and shows the passed {@link JComponent}. If a
@@ -27,9 +36,11 @@
 	 * The test is skipped if the JVM is running headless.
 	 * 
 	 * @param contentPane
-	 * @param title can be used to explain the tests what to check
+	 * @param title
+	 *            can be used to explain the tests what to check
 	 */
-	public static void testPanel(JComponent contentPane, String title) throws Throwable {
+	public static void testPanel(JComponent contentPane, String title)
+			throws Throwable {
 
 		final AtomicBoolean stopFlag = new AtomicBoolean(false);
 
@@ -60,9 +71,33 @@
 
 	}
 
-
 	public static void testPanel(JComponent contentPane) throws Throwable {
-		testPanel(contentPane,contentPane.getClass().getSimpleName());
+		testPanel(contentPane, contentPane.getClass().getSimpleName());
 	}
 
+	final static String resLocation = "/schmitzm/jfree/feature/style/testLineChartShape/testKreiseLineChart.shp";
+
+	/**
+	 * Stellt Test-Features zur Verfügung, WENN die Anwendung im maven scope
+	 * <code>test</code> läuft.
+	 */
+	public static FeatureCollection<SimpleFeatureType, SimpleFeature> getTestFeatures()
+			throws IOException {
+		// Testdatenshape einlesen
+		URL resourceUrl = FeatureChartStyleTest.class.getResource(resLocation);
+
+		if (resourceUrl == null)
+			throw new IllegalStateException(resLocation
+					+ " wurde nicht gefunden!");
+
+		FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = GeoImportUtil
+				.readFeaturesFromShapeURL(resourceUrl);
+
+		if (testFeatures == null)
+			throw new IllegalStateException(
+					"Testfeatures konnten nicht gelesen werden");
+
+		return testFeatures;
+	}
+
 }

Modified: trunk/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java
===================================================================
--- trunk/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java	2010-07-23 17:11:46 UTC (rev 945)
+++ trunk/src/skrueger/geotools/selection/FeatureMapLayerSelectionSynchronizer.java	2010-07-26 17:13:42 UTC (rev 946)
@@ -73,6 +73,7 @@
 import schmitzm.geotools.map.event.FeatureSelectedEvent;
 import schmitzm.geotools.map.event.JMapPaneListener;
 import schmitzm.geotools.styling.StylingUtil;
+import schmitzm.geotools.styling.StylingUtil.SelectionStylesTypes;
 import skrueger.geotools.MapPaneToolBar;
 import skrueger.geotools.StyledFeaturesInterface;
 
@@ -224,7 +225,8 @@
 				// remove any selection rules first.
 
 				FeatureTypeStyle selectionFTStyle = StylingUtil
-						.createSelectionStyle(styledLayer.getGeoObject());
+						.createSelectionFTStyle(styledLayer.getGeoObject(),
+								SelectionStylesTypes.LeftTop2RightBottom_lines);
 
 				selectionFTStyle.setName(SELECTION_STYLING_FTS_NAME);
 
@@ -321,8 +323,11 @@
 	 * Analyzes whether the selection has changed in comparison to the selection
 	 * stored in the mapLayer.Style
 	 * 
-	 * @param newSelection a List<String> of all newly selected FIDs
-	 * @param originalStyle the original {@link Style} that has an earlier selection coded into the {@link Style}
+	 * @param newSelection
+	 *            a List<String> of all newly selected FIDs
+	 * @param originalStyle
+	 *            the original {@link Style} that has an earlier selection coded
+	 *            into the {@link Style}
 	 * @return <code>true</code> if changed.
 	 */
 	private boolean selectionChanged(Vector<String> newSelection,

Modified: trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java
===================================================================
--- trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java	2010-07-23 17:11:46 UTC (rev 945)
+++ trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java	2010-07-26 17:13:42 UTC (rev 946)
@@ -41,39 +41,28 @@
 import schmitzm.jfree.chart.style.ChartRendererStyle;
 import schmitzm.jfree.chart.style.ChartType;
 import schmitzm.jfree.table.AggregationFunction;
+import schmitzm.swing.TestingUtil;
 
 public class FeatureChartStyleTest {
 	private static Logger log = Logger.getLogger(FeatureChartStyleTest.class);
-	
+
 	FeatureChartStyleXMLFactory xmlFactory = new FeatureChartStyleXMLFactory();
 
-	/** If tests are run on a system with head, we may theoretically open dialgs, frames etc. **/
+	/**
+	 * If tests are run on a system with head, we may theoretically open dialgs,
+	 * frames etc.
+	 **/
 
 	boolean INTERACTIVE = !GraphicsEnvironment.isHeadless();
-	
-	String resLocation = "/schmitzm/jfree/feature/style/testLineChartShape/testKreiseLineChart.shp";
-	
-	
-	
 
 	@Test
-	public void testBarChartSortedSeries() throws IOException, InterruptedException {
+	public void testBarChartSortedSeries() throws IOException,
+			InterruptedException {
 
-		// Testdatenshape einlesen
-		URL resourceUrl = FeatureChartStyleTest.class.getResource(
-						resLocation);
-		assertNotNull(resLocation+" wurde nicht gefunden!",
-				resourceUrl);
-		
-		FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = GeoImportUtil
-				.readFeaturesFromShapeURL(resourceUrl);
+		FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = TestingUtil
+				.getTestFeatures();
 
-		assertNotNull("Testfeatures konnten nicht aus " + resourceUrl
-				+ " gelesen werden", testFeatures);
-
 		// Daten auf korrektheit überprüfen
-		assertEquals("Testfeatures muss 3x3 Features enthalten", 3 * 3,
-				testFeatures.size());
 		String groupAttribName = "jahr"; // KreisZahl
 		SimpleFeatureType testDatenSchema = testFeatures.getSchema();
 		assertNotNull(testDatenSchema.getDescriptor(groupAttribName));
@@ -93,7 +82,7 @@
 
 		FeatureBasicChartStyle barChartStyle = new FeatureBasicChartStyle(
 				"testLineChart", ChartType.BAR);
-		
+
 		barChartStyle.setAxisStyle(0, domainAxisStyle);
 		barChartStyle.setAxisStyle(1, rangeAxisStyle);
 
@@ -106,14 +95,13 @@
 		barChartStyle.setTooltips(true);
 
 		barChartStyle.setSeriesAttributeName(groupAttribName);
-		
+
 		barChartStyle.setSortDomainAxis(true);
 
 		assertNull("Wenn nicht explizit gesetzt wird null geliefert",
 				barChartStyle.getRendererStyle(0));
 
-		JFreeChart chart = barChartStyle
-				.applyToFeatureCollection(testFeatures);
+		JFreeChart chart = barChartStyle.applyToFeatureCollection(testFeatures);
 		assertNotNull("applyToFeatureCollection liefte null!", chart);
 
 		BufferedImage chartpng = chart.createBufferedImage(600, 400);
@@ -122,7 +110,8 @@
 
 		if (INTERACTIVE) {
 			ChartFrame chartFrame = new ChartFrame(
-					"Die Balken sollten ihren Jahreszahlen entsprechend sortiert sein", chart);
+					"Die Balken sollten ihren Jahreszahlen entsprechend sortiert sein",
+					chart);
 			chartFrame.pack();
 			chartFrame.setVisible(true);
 			while (chartFrame.isVisible()) {
@@ -130,63 +119,58 @@
 			}
 		}
 	}
-	
-	
-	
-	
-	
+
 	@Test
 	public void saveAndLoadWeightedChart() throws IOException {
 		FeatureBasicChartStyle weightChartStyle = new FeatureBasicChartStyle(
 				"testLineChart", ChartType.BAR);
 		weightChartStyle.setAttributeName(0, "attX");
 		weightChartStyle.setAttributeName(1, "attY");
-		weightChartStyle.setAttributeAggregation(1, AggregationFunction.AVG_WEIGHTED);
-		weightChartStyle.setAttributeAggregationWeightAttributeName(1, "weight");
-	
-		
+		weightChartStyle.setAttributeAggregation(1,
+				AggregationFunction.AVG_WEIGHTED);
+		weightChartStyle
+				.setAttributeAggregationWeightAttributeName(1, "weight");
+
 		// In XML schreiben
 		File testFile = File.createTempFile("testWeightChart", ".xml");
 		xmlFactory.writeStyleToFile(weightChartStyle, "testWeightedhart",
 				testFile);
-		
+
 		System.out.println(IOUtil.readFileAsString(testFile));
-		
+
 		// XML wieder einlesen
-		FeatureChartStyle weightChartAusXMLgelesen = xmlFactory.readStyleFromFile(testFile);
-		assertEquals(AggregationFunction.AVG_WEIGHTED, weightChartAusXMLgelesen.getAttributeAggregation(1));
-		assertEquals("weight", weightChartAusXMLgelesen.getAttributeAggregationWeightAttributeName(1));
-		
+		FeatureChartStyle weightChartAusXMLgelesen = xmlFactory
+				.readStyleFromFile(testFile);
+		assertEquals(AggregationFunction.AVG_WEIGHTED, weightChartAusXMLgelesen
+				.getAttributeAggregation(1));
+		assertEquals("weight", weightChartAusXMLgelesen
+				.getAttributeAggregationWeightAttributeName(1));
 
 		// Nochmal in XML schreiben
 		File testFile2 = File.createTempFile("testWeightChart", ".xml");
 		xmlFactory.writeStyleToFile(weightChartStyle, "testWeightedhart",
 				testFile2);
-		
+
 		// XML wieder einlesen
-		FeatureChartStyle weightChartAusXMLgelesen2 = xmlFactory.readStyleFromFile(testFile2);
-		assertEquals("weight", weightChartAusXMLgelesen2.getAttributeAggregationWeightAttributeName(1));
+		FeatureChartStyle weightChartAusXMLgelesen2 = xmlFactory
+				.readStyleFromFile(testFile2);
+		assertEquals("weight", weightChartAusXMLgelesen2
+				.getAttributeAggregationWeightAttributeName(1));
 
 		assertEquals(
 				"Nachdem das Style geschrieben, gelesen und wieder geschrieben wurde ist das XML nicht gleich!",
-				IOUtil.readFileAsString(testFile), IOUtil.readFileAsString(testFile2));
+				IOUtil.readFileAsString(testFile), IOUtil
+						.readFileAsString(testFile2));
 	}
 
 	@Test
-	public void testBarChartForcedCategories() throws IOException, InterruptedException {
+	public void testBarChartForcedCategories() throws IOException,
+			InterruptedException {
 
 		// Testdatenshape einlesen
-		URL resourceUrl = FeatureChartStyleTest.class.getResource(
-						resLocation);
-		assertNotNull(resLocation+" wurde nicht gefunden!",
-				resourceUrl);
-		
-		FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = GeoImportUtil
-				.readFeaturesFromShapeURL(resourceUrl);
+		FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = TestingUtil
+				.getTestFeatures();
 
-		assertNotNull("Testfeatures konnten nicht aus " + resourceUrl
-				+ " gelesen werden", testFeatures);
-
 		// Daten auf korrektheit überprüfen
 		assertEquals("Testfeatures muss 3x3 Features enthalten", 3 * 3,
 				testFeatures.size());
@@ -209,7 +193,7 @@
 
 		FeatureBasicChartStyle barChartStyle = new FeatureBasicChartStyle(
 				"testLineChart", ChartType.BAR);
-		
+
 		barChartStyle.setAxisStyle(0, domainAxisStyle);
 		barChartStyle.setAxisStyle(1, rangeAxisStyle);
 
@@ -256,24 +240,14 @@
 			}
 		}
 	}
-	
-	
-	
+
 	@Test
-	public void testLineChartAsCategories() throws IOException, CQLException, InterruptedException {
+	public void testLineChartAsCategories() throws IOException, CQLException,
+			InterruptedException {
 
-		// Testdatenshape einlesen
-		URL resourceUrl = FeatureChartStyleTest.class.getResource(
-						resLocation);
-		assertNotNull(resLocation+" wurde nicht gefunden!",
-				resourceUrl);
-		
-		FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = GeoImportUtil
-				.readFeaturesFromShapeURL(resourceUrl);
+		FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = TestingUtil
+				.getTestFeatures();
 
-		assertNotNull("Testfeatures konnten nicht aus " + resourceUrl
-				+ " gelesen werden", testFeatures);
-
 		// Daten auf korrektheit überprüfen
 		String groupAttribName = "code"; // KreisZahl
 		SimpleFeatureType testDatenSchema = testFeatures.getSchema();
@@ -306,7 +280,7 @@
 		lineChartStyle.setTooltips(true);
 
 		lineChartStyle.setSeriesAttributeName(groupAttribName);
-		
+
 		lineChartStyle.setSeriesLegendTitleAttributeName(labelAttribName);
 
 		assertNull("Wenn nicht explizit gesetzt wird null geliefert",
@@ -314,11 +288,11 @@
 
 		ChartRendererStyle chartRendererStyle = new ChartRendererStyle();
 
-//		chartRendererStyle.setSeriesLegendLabel(0, new ChartLabelStyle(
-//				"test 1. label"));
+		// chartRendererStyle.setSeriesLegendLabel(0, new ChartLabelStyle(
+		// "test 1. label"));
 
 		chartRendererStyle.setDefaultPaint(Color.blue);
-		
+
 		chartRendererStyle.setSeriesPaint(0, Color.green);
 		chartRendererStyle.setSeriesPaint(1, Color.red);
 		chartRendererStyle.setSeriesPaint(2, Color.GRAY);
@@ -336,7 +310,8 @@
 
 		if (INTERACTIVE) {
 			ChartFrame chartFrame = new ChartFrame(
-					"drei linien, forcedCategories, mit series title kreisname", lineChart);
+					"drei linien, forcedCategories, mit series title kreisname",
+					lineChart);
 			chartFrame.pack();
 			chartFrame.setVisible(true);
 			while (chartFrame.isVisible()) {
@@ -360,7 +335,7 @@
 				Thread.sleep(100);
 			}
 		}
-		
+
 		File testFile = File.createTempFile("testLineChart", ".xml");
 		xmlFactory.writeStyleToFile(lineChartStyle, "testLineChart", testFile);
 
@@ -379,8 +354,9 @@
 						.lastIndexOf("06531;06532"));
 
 		// XML wieder einlesen
-		FeatureChartStyle lineChartAUsXMLgelesen = xmlFactory.readStyleFromFile(testFile);
-		
+		FeatureChartStyle lineChartAUsXMLgelesen = xmlFactory
+				.readStyleFromFile(testFile);
+
 		// Nochmal in XML schreiben
 		File testFile2 = File.createTempFile("testLineChart", ".xml");
 		xmlFactory.writeStyleToFile(lineChartAUsXMLgelesen, "testLineChart",
@@ -390,25 +366,13 @@
 				writtenXML, IOUtil.readFileAsString(testFile2));
 	}
 
-	
-	
-	
-
 	@Test
-	public void testLineChartNOTCategories() throws IOException, CQLException, InterruptedException {
+	public void testLineChartNOTCategories() throws IOException, CQLException,
+			InterruptedException {
 
-		// Testdatenshape einlesen
-		URL resourceUrl = FeatureChartStyleTest.class.getResource(
-						resLocation);
-		assertNotNull(resLocation+" wurde nicht gefunden!",
-				resourceUrl);
-		
-		FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = GeoImportUtil
-				.readFeaturesFromShapeURL(resourceUrl);
+		FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = TestingUtil
+				.getTestFeatures();
 
-		assertNotNull("Testfeatures konnten nicht aus " + resourceUrl
-				+ " gelesen werden", testFeatures);
-
 		// Daten auf korrektheit überprüfen
 		String groupAttribName = "code"; // KreisZahl
 		SimpleFeatureType testDatenSchema = testFeatures.getSchema();
@@ -424,7 +388,7 @@
 
 		ChartAxisStyle domainAxisStyle = new ChartAxisStyle("jahreszahlen",
 				Color.red, 0., 0.);
-		
+
 		ChartAxisStyle rangeAxisStyle = new ChartAxisStyle("deut. maenner",
 				Color.green, 0., 0.);
 
@@ -435,7 +399,7 @@
 
 		lineChartStyle.setAttributeName(0, domainAttribName);
 		lineChartStyle.setAttributeName(1, variablenAttribName);
-		
+
 		lineChartStyle.setSeriesLegendTitleAttributeName(labelAttribName);
 
 		lineChartStyle.setTooltips(true);
@@ -448,7 +412,7 @@
 		ChartRendererStyle chartRendererStyle = new ChartRendererStyle();
 
 		chartRendererStyle.setDefaultPaint(Color.blue);
-		
+
 		chartRendererStyle.setSeriesPaint(0, Color.green);
 		chartRendererStyle.setSeriesPaint(1, Color.red);
 		chartRendererStyle.setSeriesPaint(2, Color.GRAY);
@@ -463,14 +427,14 @@
 		BufferedImage chartpng = lineChart.createBufferedImage(600, 400);
 		assertNotNull("Es konnte kein PNG aus dem Chart erstellt werden!",
 				chartpng);
-		
+
 		lineChart.getXYPlot().getDomainAxis().setAutoTickUnitSelection(false);
 		TickUnits units = new TickUnits();
 		NumberFormat myNumberFormat = NumberFormat.getNumberInstance();
 		units.add(new NumberTickUnit(2005, myNumberFormat));
 		units.add(new NumberTickUnit(2007, myNumberFormat));
 		units.add(new NumberTickUnit(2008, myNumberFormat));
-//		da = lineChart.getXYPlot().getDomainAxis();
+		// da = lineChart.getXYPlot().getDomainAxis();
 		NumberAxis numberAxis = new NumberAxis() {
 			@Override
 			public List refreshTicks(Graphics2D g2, AxisState state,
@@ -483,9 +447,9 @@
 				ticks.add(new NumberTick(2006, "2006", ta, ra, 0.));
 				ticks.add(new NumberTick(2007, "2007", ta, ra, 0.));
 				ticks.add(new NumberTick(2008, "2008", ta, ra, 0.));
-				
+
 				return ticks;
-				
+
 			}
 		};
 		lineChart.getXYPlot().setDomainAxis(numberAxis);
@@ -493,14 +457,15 @@
 
 		if (INTERACTIVE) {
 			ChartFrame chartFrame = new ChartFrame(
-					"drei linien, NOT categories, KreisNamen series titles", lineChart);
+					"drei linien, NOT categories, KreisNamen series titles",
+					lineChart);
 			chartFrame.pack();
 			chartFrame.setVisible(true);
 			while (chartFrame.isVisible()) {
 				Thread.sleep(100);
 			}
 		}
-		
+
 		File testFile = File.createTempFile("testLineChart", ".xml");
 		xmlFactory.writeStyleToFile(lineChartStyle, "testLineChart", testFile);
 
@@ -510,8 +475,9 @@
 		String writtenXML = IOUtil.readFileAsString(testFile);
 
 		// XML wieder einlesen
-		FeatureChartStyle lineChartAUsXMLgelesen = xmlFactory.readStyleFromFile(testFile);
-		
+		FeatureChartStyle lineChartAUsXMLgelesen = xmlFactory
+				.readStyleFromFile(testFile);
+
 		// Nochmal in XML schreiben
 		File testFile2 = File.createTempFile("testLineChart", ".xml");
 		xmlFactory.writeStyleToFile(lineChartAUsXMLgelesen, "testLineChart",



More information about the Schmitzm-commits mailing list