[Schmitzm-commits] r1416 - in trunk: schmitzm-core/src/test/java/de/schmitzm/testing schmitzm-gt/src/test/java/de/schmitzm/geotools schmitzm-gt/src/test/java/de/schmitzm/geotools/feature schmitzm-jfree-gt/src/test/java/de/schmitzm schmitzm-jfree-gt/src/test/java/de/schmitzm/jfree schmitzm-jfree-gt/src/test/java/de/schmitzm/jfree/feature schmitzm-jfree-gt/src/test/java/de/schmitzm/jfree/feature/style schmitzm-jfree-gt/src/test/java/de/schmitzm/jfree/testing
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Jan 27 12:01:04 CET 2011
Author: alfonx
Date: 2011-01-27 12:01:02 +0100 (Thu, 27 Jan 2011)
New Revision: 1416
Added:
trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/feature/
trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/feature/FeatureComparatorTest.java
trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/feature/FeatureUtilTest.java
trunk/schmitzm-jfree-gt/src/test/java/de/schmitzm/jfree/
trunk/schmitzm-jfree-gt/src/test/java/de/schmitzm/jfree/feature/
trunk/schmitzm-jfree-gt/src/test/java/de/schmitzm/jfree/feature/style/
trunk/schmitzm-jfree-gt/src/test/java/de/schmitzm/jfree/feature/style/FeatureChartStyleTest.java
trunk/schmitzm-jfree-gt/src/test/java/de/schmitzm/jfree/testing/
trunk/schmitzm-jfree-gt/src/test/java/de/schmitzm/jfree/testing/JFTestingUtil.java
Modified:
trunk/schmitzm-core/src/test/java/de/schmitzm/testing/TestingClass.java
trunk/schmitzm-core/src/test/java/de/schmitzm/testing/TestingUtil.java
Log:
TestingUtil =>
TestingUtil
GTTestingUtil extends TestingUtil
JFTestingUtil extends TestingUtil
Modified: trunk/schmitzm-core/src/test/java/de/schmitzm/testing/TestingClass.java
===================================================================
--- trunk/schmitzm-core/src/test/java/de/schmitzm/testing/TestingClass.java 2011-01-27 10:51:39 UTC (rev 1415)
+++ trunk/schmitzm-core/src/test/java/de/schmitzm/testing/TestingClass.java 2011-01-27 11:01:02 UTC (rev 1416)
@@ -14,6 +14,14 @@
new TestingUtil();
}
+ /**
+ * @return <code>true</code>, if a graphical environment is available (like
+ * Windows or X11).
+ */
+ public boolean isInteractive() {
+ return TestingUtil.INTERACTIVE;
+ }
+
/** Logger for our testing classes. */
protected static Logger log = Logger.getLogger(TestingClass.class);
Modified: trunk/schmitzm-core/src/test/java/de/schmitzm/testing/TestingUtil.java
===================================================================
--- trunk/schmitzm-core/src/test/java/de/schmitzm/testing/TestingUtil.java 2011-01-27 10:51:39 UTC (rev 1415)
+++ trunk/schmitzm-core/src/test/java/de/schmitzm/testing/TestingUtil.java 2011-01-27 11:01:02 UTC (rev 1416)
@@ -53,7 +53,7 @@
* Number of seconds to wait until a GUI should be closed by default. Can be
* set to -1 to always wait forever.
*/
- private static final int WAIT_MAX_DEFAULT = 3;
+ protected static final int WAIT_MAX_DEFAULT = 3;
private static boolean checkPixel(BufferedImage bi, int x, int y,
Color expected) {
@@ -214,21 +214,6 @@
JLabel imgLabel = new JLabel(new ImageIcon(image));
testGui(imgLabel, imgLabel.getClass().getSimpleName(), waitMax);
}
-//
-// public static void testGui(JFreeChart chart, String frameTitle)
-// throws Throwable {
-// testGui(chart, frameTitle, WAIT_MAX_DEFAULT);
-// }
-//
-// public static void testGui(JFreeChart chart, String frameTitle, int waitMax)
-// throws Throwable {
-// if (isInteractive()) {
-// ChartFrame chartFrame = new ChartFrame(frameTitle, chart);
-// chartFrame.pack();
-//
-// testGui(chartFrame, waitMax);
-// }
-// }
public static void testGui(JPanel jPanel, String title) throws Throwable {
testGui(jPanel, title, 3);
Added: trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/feature/FeatureComparatorTest.java
===================================================================
--- trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/feature/FeatureComparatorTest.java 2011-01-27 10:51:39 UTC (rev 1415)
+++ trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/feature/FeatureComparatorTest.java 2011-01-27 11:01:02 UTC (rev 1416)
@@ -0,0 +1,112 @@
+package de.schmitzm.geotools.feature;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.geotools.feature.FeatureCollection;
+import org.junit.Test;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
+
+import de.schmitzm.geotools.testing.GTTestingUtil;
+import de.schmitzm.testing.TestingClass;
+
+public class FeatureComparatorTest extends TestingClass {
+ /**
+ * If tests are run on a system with head, we may theoretically open dialgs,
+ * frames etc.
+ **/
+
+ @Test
+ public void testFeatureComparator() throws Exception {
+ // 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 = GTTestingUtil.TestDatasetsVector.kreise
+ .getFeatureCollection();
+
+ assertNotNull("Testfeatures konnten nicht gelesen werden", testFeatures);
+
+ String[] sortAttr = new String[] { "dm_u3", "jahr" };
+
+ // Show features unsorted
+ System.out.println("**** FEATURES UNSORTED ****");
+ showFeatures(new PipedFeatureIterator(testFeatures.features()), false,
+ sortAttr);
+ // Sort features
+ Vector<SimpleFeature> testFeaturesSorted = FeatureUtil.sortFeatures(
+ testFeatures, sortAttr);
+ // Show features unsorted
+ System.out.println("**** FEATURES SORTED ****");
+ showFeatures(testFeaturesSorted.iterator(), true, sortAttr);
+
+ }
+
+ /**
+ * Shows features.
+ *
+ * @param fi
+ * an iterator for the features
+ * @param checkSorting
+ * indicates whether the ordering is checked during showing
+ * @param attrName
+ * the attributes which are shown (and checked for ordering)
+ */
+ private void showFeatures(Iterator<SimpleFeature> fi, boolean checkSorting,
+ String... attrName) {
+ // Show features unsorted
+ SimpleFeature lastFeature = null;
+ for (; fi.hasNext();) {
+ SimpleFeature f = fi.next();
+ // Show ID and the specified attributes
+ if (isInteractive()) {
+ System.out.print(f.getID() + "\t");
+ for (String name : attrName)
+ System.out.print(f.getAttribute(name) + "\t");
+ System.out.println();
+ }
+ // Check sorting if at least 2 Features are present (optional)
+ if (checkSorting && lastFeature != null)
+ checkAscendingSort(lastFeature, f, attrName);
+
+ lastFeature = f;
+ }
+ }
+
+ /**
+ * Checks whether f1 <= f2 by fundamental methods :-) If not an assertion is
+ * thrown.
+ *
+ * @param lastFeature
+ * a feature
+ * @param f
+ * another feature
+ */
+ private void checkAscendingSort(SimpleFeature f1, SimpleFeature f2,
+ String... attrName) {
+ for (String name : attrName) {
+ Object a1 = f1.getAttribute(name);
+ Object a2 = f2.getAttribute(name);
+ // Attribute values must be Comparable
+ assertTrue("a1 must be Comparable", a1 instanceof Comparable);
+ assertTrue("a2 must be Comparable", a2 instanceof Comparable);
+
+ // f1 must be <= f2
+ int comp = ((Comparable) a1).compareTo(a2);
+ assertTrue("a1." + name + " must be <= a2." + name + "(" + a1
+ + " <= " + a2 + ")", comp <= 0);
+ // if f1 < f2, the other attributes must be ignored
+ if (comp < 0)
+ break;
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/feature/FeatureComparatorTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id URL
Name: svn:eol-style
+ native
Added: trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/feature/FeatureUtilTest.java
===================================================================
--- trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/feature/FeatureUtilTest.java 2011-01-27 10:51:39 UTC (rev 1415)
+++ trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/feature/FeatureUtilTest.java 2011-01-27 11:01:02 UTC (rev 1416)
@@ -0,0 +1,273 @@
+package de.schmitzm.geotools.feature;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.geotools.data.DataUtilities;
+import org.geotools.data.FeatureSource;
+import org.geotools.data.shapefile.ShapefileDataStore;
+import org.geotools.feature.FeatureCollection;
+import org.geotools.feature.GeometryAttributeType;
+import org.junit.Test;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
+import org.opengis.feature.type.GeometryDescriptor;
+
+import com.vividsolutions.jts.geom.Geometry;
+import com.vividsolutions.jts.geom.Point;
+import com.vividsolutions.jts.geom.Polygon;
+
+import de.schmitzm.geotools.feature.FeatureUtil.GeometryForm;
+import de.schmitzm.geotools.io.GeoImportUtil;
+import de.schmitzm.geotools.testing.GTTestingUtil.TestDatasetsVector;
+import de.schmitzm.testing.TestingClass;
+public class FeatureUtilTest extends TestingClass {
+
+ @Test
+ public void testFeatureTypeChecks() throws Exception {
+
+ GeometryDescriptor defaultGeometry = FeatureUtil.createFeatureType(
+ Polygon.class).getGeometryDescriptor();
+ assertTrue(FeatureUtil.getGeometryForm(defaultGeometry) == GeometryForm.POLYGON);
+ assertFalse(FeatureUtil.getGeometryForm(defaultGeometry) == GeometryForm.LINE);
+ assertFalse(FeatureUtil.getGeometryForm(defaultGeometry) == GeometryForm.POINT);
+
+ defaultGeometry = FeatureUtil.createFeatureType(Point.class)
+ .getGeometryDescriptor();
+ assertTrue(FeatureUtil.getGeometryForm(defaultGeometry) == GeometryForm.POINT);
+ assertFalse(FeatureUtil.getGeometryForm(defaultGeometry) == GeometryForm.POLYGON);
+ assertFalse(FeatureUtil.getGeometryForm(defaultGeometry) == GeometryForm.LINE);
+ }
+
+ @Test
+ public void testGetCQLAttributNames() throws Exception {
+ List<String> aa;
+
+ aa = FeatureUtil.getCQLAttributNames("1P_HH/HH_GES");
+ assertEquals(2, aa.size());
+ assertEquals("1P_HH", aa.get(0));
+ assertEquals("HH_GES", aa.get(1));
+
+ aa = FeatureUtil.getCQLAttributNames("fff*-3(de_fr/ddd)/100+2");
+ assertEquals(3, aa.size());
+ assertEquals("fff", aa.get(0));
+ assertEquals("de_fr", aa.get(1));
+ assertEquals("ddd", aa.get(2));
+
+ aa = FeatureUtil.getCQLAttributNames("gest_1lj/lebeng_ge");
+ assertEquals(2, aa.size());
+ assertEquals("gest_1lj", aa.get(0));
+ assertEquals("lebeng_ge", aa.get(1));
+
+ aa = FeatureUtil.getCQLAttributNames("de_fr/ddd");
+ assertEquals("de_fr", aa.get(0));
+ assertEquals("ddd", aa.get(1));
+
+ aa = FeatureUtil.getCQLAttributNames("3^a * -3^b*0.3 + s^3");
+ assertEquals(3, aa.size());
+ assertEquals("a", aa.get(0));
+ assertEquals("b", aa.get(1));
+ assertEquals("s", aa.get(2));
+
+ }
+
+ @Test
+ public void testCheckAttributeNameRestrictionsAndError() {
+ assertFalse(FeatureUtil.checkAttributeNameRestrictions("الح"));
+ assertFalse(FeatureUtil.checkAttributeNameRestrictions("aوض"));
+ }
+
+ @Test
+ public void testModifyFeatureSource() throws Exception {
+
+ FeatureSource<SimpleFeatureType, SimpleFeature> sourceFs = TestDatasetsVector.arabicInHeader
+ .getFeatureSource();
+ assertEquals(4, sourceFs.getSchema().getAttributeCount());
+ assertEquals("the_geom", sourceFs.getSchema().getDescriptor(0)
+ .getLocalName());
+ assertEquals("NOM_AGENCE", sourceFs.getSchema().getDescriptor(1)
+ .getLocalName());
+ assertEquals("SURFACE", sourceFs.getSchema().getDescriptor(2)
+ .getLocalName());
+ assertEquals(Integer.class, sourceFs.getSchema().getDescriptor(2)
+ .getType().getBinding());
+
+ // geht nur unter linux! Unte windows wird da kein UTF8 erwartet, sonder
+ // z.b. iso...
+ // assertEquals("�����", sourceFs.getSchema().getDescriptor(3)
+ // .getLocalName());
+
+ File outFile = File.createTempFile("testModifyFeatureSource", ".shp");
+ // File cpgFile = IOUtil.changeFileExt(outFile, "cpg");
+ // GeoExportUtil.writeCharset(cpgFile, Charset.forName("windows-1256"));
+
+ ShapefileDataStore outputFs = new ShapefileDataStore(
+ DataUtilities.fileToURL(outFile));
+
+ AttributeModificationRule[] destAttrs = new AttributeModificationRule[3];
+ destAttrs[0] = new AttributeModificationRule(0);
+ destAttrs[1] = new AttributeModificationRule(3, "arab", null, null,
+ null, null);
+ destAttrs[2] = new AttributeModificationRule(2);
+ Set<Object> nullValues = new HashSet<Object>();
+ nullValues.add(39207);
+ destAttrs[2].setNullValues(nullValues);
+ destAttrs[2].setNullValueAlias(-9999);
+
+ // // Umwandlung starten
+ FeatureUtil.modifyFeatureSource(sourceFs, outputFs, destAttrs);
+ outputFs.dispose();
+
+ // Testen, ob das gewünschte Ergebnis erstellt wurde
+ FeatureCollection<SimpleFeatureType, SimpleFeature> correctedFC = GeoImportUtil
+ .readFeaturesFromShapeFile(outFile);
+
+ // Schema testen
+ assertEquals(3, correctedFC.getSchema().getAttributeCount());
+ assertEquals("the_geom", correctedFC.getSchema().getDescriptor(0)
+ .getLocalName());
+
+ assertEquals("arab", correctedFC.getSchema().getDescriptor(1)
+ .getLocalName());
+
+ assertEquals("SURFACE", correctedFC.getSchema().getDescriptor(2)
+ .getLocalName());
+ assertEquals(Integer.class, correctedFC.getSchema().getDescriptor(2)
+ .getType().getBinding());
+
+ Iterator<SimpleFeature> fI = correctedFC.iterator();
+ try {
+ assertTrue(fI.hasNext());
+ SimpleFeature next = fI.next();
+ // TODO assertEquals("وكالة الحوض المائي للوكوس",
+ // next.getAttribute(1));
+ assertEquals(13591, next.getAttribute(2));
+ } finally {
+ correctedFC.close(fI);
+ }
+ }
+
+ @Test
+ public void testTransformAttributeValue() {
+ assertNull(FeatureUtil.transformAttributeValue(null, Integer.class));
+
+ assertEquals("3", FeatureUtil.transformAttributeValue(3, String.class));
+ assertEquals("3",
+ FeatureUtil.transformAttributeValue("3", String.class));
+ assertEquals("3.0",
+ FeatureUtil.transformAttributeValue(3., String.class));
+
+ assertEquals(3., FeatureUtil.transformAttributeValue(3, Double.class));
+ assertEquals(3., FeatureUtil.transformAttributeValue("3", Double.class));
+ assertEquals(3., FeatureUtil.transformAttributeValue(3l, Double.class));
+
+ assertEquals(3l, FeatureUtil.transformAttributeValue(3, Long.class));
+ assertEquals(3l, FeatureUtil.transformAttributeValue("3", Long.class));
+ assertEquals(3l, FeatureUtil.transformAttributeValue(3l, Long.class));
+
+ assertEquals(3l, FeatureUtil.transformAttributeValue(3, Long.class));
+ assertEquals(3l, FeatureUtil.transformAttributeValue("3", Long.class));
+ assertEquals(3l, FeatureUtil.transformAttributeValue(3l, Long.class));
+
+ try {
+ FeatureUtil.transformAttributeValue("A", Long.class);
+ fail();
+ } catch (Exception e) {
+
+ }
+ }
+
+ @Test
+ public void testCleanAttname() {
+ assertEquals("AEOEUSH", FeatureUtil.cleanAttname("äöush"));
+ assertEquals("N12312312", FeatureUtil.cleanAttname("12312312"));
+ assertEquals("N123123123", FeatureUtil.cleanAttname("123123123123"));
+ }
+
+ @Test
+ /**
+ * * <dataAttribute functionA="0.0" functionX="1.0" localname="C�R�ALIC_1" namespace="" visible="false" weight="15">
+
+ */
+ public void testFindBestMatchingAttribute() {
+ String s1 = "C�R�ALIC_1";
+ String s2 = Pattern.quote(s1);
+ s2 = s2.substring(2, s2.length() - 2);
+ String s3 = s2.replaceAll("�", ".");
+ // s3 = s3.replaceAll("@", ".");
+ Pattern compile = Pattern.compile(s3);
+ Matcher matcher = compile.matcher("CóRéALIC_1");
+
+ assertTrue(matcher.find());
+
+ }
+
+ @Test
+ /**
+ * * <dataAttribute functionA="0.0" functionX="1.0" localname="C�R�ALIC_1" namespace="" visible="false" weight="15">
+
+ */
+ public void testFindBestMatchingAttribute2() {
+ String s1 = "C�R�ALIC_1";
+ String s2 = Pattern.quote(s1);
+ s2 = s2.substring(2, s2.length() - 2);
+ String s3 = s2.replaceAll("[^\\w]", "[^\\\\w]");
+ // s3 = s3.replaceAll("@", ".");
+ Pattern compile = Pattern.compile(s3);
+
+ Matcher matcher = compile.matcher("COREALIC_1");
+ assertFalse(matcher.find());
+
+ matcher = compile.matcher("CóRéALIC_1");
+ assertTrue(matcher.find());
+
+ }
+
+ @Test
+ /**
+ * Tests, whether the different signatures of getGeometryForm all deal correctly with <code>null</code>
+ */
+ public void testGetGeometryFormNulls() {
+ GeometryForm gf;
+ gf = FeatureUtil.getGeometryForm((Class<?>) null);
+ assertEquals(GeometryForm.NONE, gf);
+
+ gf = FeatureUtil.getGeometryForm((FeatureCollection) null);
+ assertEquals(GeometryForm.NONE, gf);
+
+ gf = FeatureUtil.getGeometryForm((FeatureSource) null);
+ assertEquals(GeometryForm.NONE, gf);
+
+ gf = FeatureUtil.getGeometryForm((GeometryAttributeType) null);
+ assertEquals(GeometryForm.NONE, gf);
+
+ gf = FeatureUtil.getGeometryForm((GeometryDescriptor) null);
+ assertEquals(GeometryForm.NONE, gf);
+
+ gf = FeatureUtil.getGeometryForm((SimpleFeatureType) null);
+ assertEquals(GeometryForm.NONE, gf);
+ }
+
+ @Test
+ /**
+ * Tests, whether the different signatures of getGeometryForm all deal correctly with <code>null</code>
+ */
+ public void testGetGeometryFormGeometry() {
+ GeometryForm gf;
+ gf = FeatureUtil.getGeometryForm(Geometry.class);
+ assertEquals(GeometryForm.ANY, gf);
+
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/schmitzm-gt/src/test/java/de/schmitzm/geotools/feature/FeatureUtilTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id URL
Name: svn:eol-style
+ native
Added: trunk/schmitzm-jfree-gt/src/test/java/de/schmitzm/jfree/feature/style/FeatureChartStyleTest.java
===================================================================
--- trunk/schmitzm-jfree-gt/src/test/java/de/schmitzm/jfree/feature/style/FeatureChartStyleTest.java 2011-01-27 10:51:39 UTC (rev 1415)
+++ trunk/schmitzm-jfree-gt/src/test/java/de/schmitzm/jfree/feature/style/FeatureChartStyleTest.java 2011-01-27 11:01:02 UTC (rev 1416)
@@ -0,0 +1,1066 @@
+package de.schmitzm.jfree.feature.style;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.Graphics2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.geotools.feature.FeatureCollection;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.axis.AxisState;
+import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.axis.NumberTick;
+import org.jfree.chart.axis.NumberTickUnit;
+import org.jfree.chart.axis.TickUnits;
+import org.jfree.chart.axis.ValueTick;
+import org.jfree.chart.plot.XYPlot;
+import org.jfree.data.category.CategoryDataset;
+import org.jfree.data.category.DefaultCategoryDataset;
+import org.jfree.data.xy.XYSeriesCollection;
+import org.jfree.ui.RectangleEdge;
+import org.jfree.ui.TextAnchor;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
+
+import de.schmitzm.geotools.testing.GTTestingUtil;
+import de.schmitzm.io.IOUtil;
+import de.schmitzm.jfree.JFreeChartUtil;
+import de.schmitzm.jfree.chart.SelectableChartPanel;
+import de.schmitzm.jfree.chart.SelectableChartPanel.WindowSelectionMode;
+import de.schmitzm.jfree.chart.style.BasicChartStyle;
+import de.schmitzm.jfree.chart.style.ChartAxisStyle;
+import de.schmitzm.jfree.chart.style.ChartLabelStyle;
+import de.schmitzm.jfree.chart.style.ChartPlotStyle;
+import de.schmitzm.jfree.chart.style.ChartRendererStyle;
+import de.schmitzm.jfree.chart.style.ChartStyle;
+import de.schmitzm.jfree.chart.style.ChartStyleXMLFactory;
+import de.schmitzm.jfree.chart.style.ChartType;
+import de.schmitzm.jfree.data.RegressionDataset;
+import de.schmitzm.jfree.table.AggregationFunction;
+import de.schmitzm.jfree.testing.JFTestingUtil;
+import de.schmitzm.swing.SwingUtil;
+import de.schmitzm.testing.TestingClass;
+import de.schmitzm.testing.TestingUtil;
+
+public class FeatureChartStyleTest extends TestingClass {
+ FeatureChartStyleXMLFactory xmlFactoryFeature = new FeatureChartStyleXMLFactory();
+ ChartStyleXMLFactory<ChartStyle> xmlFactoryBasic = new ChartStyleXMLFactory<ChartStyle>();
+
+ @Test
+ public void testChartStyleCopyToWithScatterChartStyle() throws Throwable {
+
+ FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = GTTestingUtil.TestDatasetsVector.kreise
+ .getFeatureCollection();
+ FeatureChartStyle style1 = new FeatureScatterChartStyle("1");
+ style1.setAttributeName(0, "jahr");
+ style1.setAttributeName(1, "w_bev");
+ JFreeChart chart = style1.applyToFeatureCollection(testFeatures);
+ assertNotNull("applyToFeatureCollection lieferte null!", chart);
+ assertXMLOutputAndInput(xmlFactoryFeature, style1, "testCopyTo_01");
+
+ FeatureChartStyle style2 = new FeatureScatterChartStyle(style1.getID());
+ style1.copyTo(style2);
+ assertXMLOutputAndInput(xmlFactoryFeature, style2, "testCopyTo_02");
+
+ assertXMLEqual(xmlFactoryFeature, style1, style2, "testCopyTo_Eq");
+
+ JFTestingUtil.testGui(chart, "Sechs Linien (3x2), Zwei Achsen");
+ }
+
+ @Test
+ public void testChartStyleCopyToWithBasicChartStyle() throws Throwable {
+
+ FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = GTTestingUtil.TestDatasetsVector.kreise
+ .getFeatureCollection();
+ FeatureChartStyle style1 = new FeatureBasicChartStyle("1",
+ ChartType.BAR);
+ style1.setAttributeName(0, "jahr");
+ style1.setAttributeName(1, "w_bev");
+ JFreeChart chart = style1.applyToFeatureCollection(testFeatures);
+ assertNotNull("applyToFeatureCollection lieferte null!", chart);
+ assertXMLOutputAndInput(xmlFactoryFeature, style1, "testCopyTo_01");
+
+ FeatureChartStyle style2 = new FeatureBasicChartStyle(style1.getID(),
+ ChartType.BAR);
+ style1.copyTo(style2);
+ assertXMLOutputAndInput(xmlFactoryFeature, style2, "testCopyTo_02");
+
+ assertXMLEqual(xmlFactoryFeature, style1, style2, "testCopyTo_Eq");
+
+ JFTestingUtil.testGui(chart, "barchart");
+ }
+
+ @Test
+ public void testAutomaticAdjustmentsOnDualAxes() throws Throwable {
+ ChartAxisStyle domainAxisStyle = new ChartAxisStyle("jahreszahlen",
+ Color.red, 0., 0.);
+ ChartAxisStyle rangeAxisStyle = new ChartAxisStyle("deut. maenner",
+ Color.green, 0., 0.);
+ ChartAxisStyle rangeAxisStyle2 = new ChartAxisStyle(
+ "Weibl. Bevölkerung", Color.blue, 0., 0.);
+
+ BasicChartStyle barChartStyle = new BasicChartStyle(
+ "testBarChartWith2Axis", ChartType.BAR);
+
+ barChartStyle.setAxisStyle(0, domainAxisStyle);
+ barChartStyle.setAxisStyle(1, rangeAxisStyle);
+ barChartStyle.setAxisStyle(2, rangeAxisStyle2);
+
+ assertNull("Wenn nicht explizit gesetzt wird null geliefert",
+ barChartStyle.getRendererStyle(0));
+
+ ChartRendererStyle chartRendererStyle = new ChartRendererStyle();
+ chartRendererStyle.setDefaultPaint(Color.blue);
+ chartRendererStyle.setSeriesPaint(0, Color.green);
+ chartRendererStyle.setSeriesPaint(1, Color.red);
+ chartRendererStyle.setSeriesPaint(2, Color.GRAY);
+ barChartStyle.setRendererStyle(0, chartRendererStyle);
+ assertEquals(3, chartRendererStyle.getSeriesCount());
+
+ // Renderer style for the series dealing with the
+ // secondary axis.
+ ChartRendererStyle chartRendererStyle2 = new ChartRendererStyle();
+ chartRendererStyle2.setDefaultLineDashAttributes(5.0f, 5.0f);
+ chartRendererStyle2.setSeriesLineWidth(1, 10);
+ chartRendererStyle2.setSeriesLineDashAttributes(1, 10f, 10f);
+ barChartStyle.setRendererStyle(1, chartRendererStyle2);
+
+ CategoryDataset data1 = createSampleCategoryDataset1(true, 1);
+ CategoryDataset data2 = createSampleCategoryDataset2(true, -1);
+
+ JFreeChart barChart = barChartStyle.applyToDataset(data1, data2);
+ JFreeChartUtil.resetRangeAxisTickLabelVisibiliy(barChart);
+
+ assertNotNull("applyToDataset lieferte null!", barChart);
+
+ JFTestingUtil.testGui(barChart, "bar chart");
+ }
+
+ @Ignore
+ @Test
+ public void testLineChartDualAxis() throws Throwable {
+
+ FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = GTTestingUtil.TestDatasetsVector.kreise
+ .getFeatureCollection();
+
+ // Daten auf korrektheit überprüfen
+ String groupAttribName = "code"; // KreisZahl
+ SimpleFeatureType testDatenSchema = testFeatures.getSchema();
+ assertNotNull(testDatenSchema.getDescriptor(groupAttribName));
+ String variablenAttribName = "dm_u3"; // Deutsche "Männer" unter 3
+ // Jahren
+ assertNotNull(testDatenSchema.getDescriptor(variablenAttribName));
+ String labelAttribName = "title"; // Attribute mit Label für Series
+ assertNotNull(testDatenSchema.getDescriptor(labelAttribName));
+ String domainAttribName = "jahr"; // Diese Variable soll auf der X-Achse
+ assertNotNull(testDatenSchema.getDescriptor(domainAttribName));
+ String variablenAttribName2 = "w_bev"; // Frauen Bevölkerung
+ assertNotNull(testDatenSchema.getDescriptor(variablenAttribName2));
+
+ ChartAxisStyle domainAxisStyle = new ChartAxisStyle("jahreszahlen",
+ Color.red, 0., 0.);
+
+ ChartAxisStyle rangeAxisStyle = new ChartAxisStyle("deut. maenner",
+ Color.green, 0., 0.);
+
+ ChartAxisStyle rangeAxisStyle2 = new ChartAxisStyle(
+ "Weibl. Bevölkerung", Color.green, 0., 0.);
+
+ FeatureBasicChartStyle lineChartStyle = new FeatureBasicChartStyle(
+ "testDoubleLineChart", ChartType.LINE);
+ lineChartStyle.setAxisStyle(0, domainAxisStyle);
+ lineChartStyle.setAxisStyle(1, rangeAxisStyle);
+ lineChartStyle.setAxisStyle(2, rangeAxisStyle2);
+
+ lineChartStyle.setAttributeName(0, domainAttribName);
+ lineChartStyle.setAttributeName(1, variablenAttribName);
+ lineChartStyle.setAttributeName(2, variablenAttribName2);
+ lineChartStyle.setAttributeAxis(2, ChartStyle.RANGE_AXIS2);
+
+ lineChartStyle.setSeriesAttributeName(groupAttribName);
+
+ // lineChartStyle.setSeriesLegendTitleAttributeName(labelAttribName);
+
+ assertNull("Wenn nicht explizit gesetzt wird null geliefert",
+ lineChartStyle.getRendererStyle(0));
+
+ ChartRendererStyle chartRendererStyle = new ChartRendererStyle();
+
+ chartRendererStyle.setDefaultPaint(Color.blue);
+
+ chartRendererStyle.setSeriesPaint(0, Color.green);
+ chartRendererStyle.setSeriesPaint(1, Color.red);
+ chartRendererStyle.setSeriesPaint(2, Color.GRAY);
+ lineChartStyle.setRendererStyle(0, chartRendererStyle);
+
+ assertEquals(3, chartRendererStyle.getSeriesCount());
+
+ // Renderer style for the series dealing with the
+ // secondary axis.
+ ChartRendererStyle chartRendererStyle2 = new ChartRendererStyle();
+ chartRendererStyle2.setDefaultLineDashAttributes(5.0f, 5.0f);
+ chartRendererStyle2.setSeriesLineWidth(1, 10);
+ chartRendererStyle2.setSeriesLineDashAttributes(1, 10f, 10f);
+ lineChartStyle.setRendererStyle(1, chartRendererStyle2);
+
+ JFreeChart lineChart = lineChartStyle
+ .applyToFeatureCollection(testFeatures);
+ assertNotNull("applyToFeatureCollection lieferte null!", lineChart);
+ JFTestingUtil.testGui(lineChart, "Sechs Linien (3x2), Zwei Achsen");
+
+ assertXMLOutputAndInput(xmlFactoryFeature, lineChartStyle,
+ "testDoubleLineChart");
+
+ }
+
+ /**
+ * If tests are run on a system with head, we may theoretically open dialgs,
+ * frames etc.
+ **/
+
+ public CategoryDataset createSampleCategoryDataset1(boolean nullSecondary,
+ int valuesType) {
+ // row keys...
+ String series1 = "Series 1";
+ String series2 = JFreeChartUtil.DUMMY_SERIES_PREFIX + "1";
+
+ // column keys...
+ String category1 = "Category 1";
+ String category2 = "Category 2";
+ String category3 = "Category 3";
+ String category4 = "Category 4";
+
+ // create the dataset...
+ DefaultCategoryDataset dataset = new DefaultCategoryDataset();
+
+ // ValuesType 0 means an empty dataset
+ if (valuesType != 0) {
+ dataset.addValue(1.0 * valuesType, series1, category1);
+ dataset.addValue(4.0 * valuesType, series1, category2);
+ dataset.addValue(3.0 * valuesType, series1, category3);
+ dataset.addValue(5.0 * valuesType, series1, category4);
+ }
+
+ if (nullSecondary && valuesType != 0) {
+ dataset.addValue(null, series2, category1);
+ dataset.addValue(null, series2, category2);
+ dataset.addValue(null, series2, category3);
+ dataset.addValue(null, series2, category4);
+ }
+ return dataset;
+ }
+
+ public CategoryDataset createSampleCategoryDataset2(boolean nullPrimary,
+ int valuesType) {
+ // row keys...
+ String series1 = JFreeChartUtil.DUMMY_SERIES_PREFIX + "2";
+ String series2 = "Series 2";
+
+ // column keys...
+ String category1 = "Category 1";
+ String category2 = "Category 2";
+ String category3 = "Category 3";
+ String category4 = "Category 4";
+
+ // create the dataset...
+ DefaultCategoryDataset dataset = new DefaultCategoryDataset();
+
+ // ValuesType 0 means an empty dataset
+ if (nullPrimary && valuesType != 0) {
+ dataset.addValue(null, series1, category1);
+ dataset.addValue(null, series1, category2);
+ dataset.addValue(null, series1, category3);
+ dataset.addValue(null, series1, category4);
+ }
+
+ // ValuesType 0 means an empty dataset
+ if (valuesType != 0) {
+ dataset.addValue(75.0 * valuesType, series2, category1);
+ dataset.addValue(87.0 * valuesType, series2, category2);
+ dataset.addValue(96.0 * valuesType, series2, category3);
+ dataset.addValue(68.0 * valuesType, series2, category4);
+ }
+ return dataset;
+
+ }
+
+ @Test
+ @Ignore
+ public void testBarChartDualAxisWithSampleData() throws Throwable {
+ ChartAxisStyle domainAxisStyle = new ChartAxisStyle("jahreszahlen",
+ Color.red, 0., 0.);
+ ChartAxisStyle rangeAxisStyle = new ChartAxisStyle("deut. maenner",
+ Color.green, 0., 0.);
+ ChartAxisStyle rangeAxisStyle2 = new ChartAxisStyle(
+ "Weibl. Bevölkerung", Color.blue, 0., 0.);
+
+ BasicChartStyle barChartStyle = new BasicChartStyle(
+ "testBarChartWith2Axis", ChartType.BAR);
+
+ barChartStyle.setAxisStyle(0, domainAxisStyle);
+ barChartStyle.setAxisStyle(1, rangeAxisStyle);
+ barChartStyle.setAxisStyle(2, rangeAxisStyle2);
+
+ assertNull("Wenn nicht explizit gesetzt wird null geliefert",
+ barChartStyle.getRendererStyle(0));
+
+ ChartRendererStyle chartRendererStyle = new ChartRendererStyle();
+ chartRendererStyle.setDefaultPaint(Color.blue);
+ chartRendererStyle.setSeriesPaint(0, Color.green);
+ chartRendererStyle.setSeriesPaint(1, Color.red);
+ chartRendererStyle.setSeriesPaint(2, Color.GRAY);
+ barChartStyle.setRendererStyle(0, chartRendererStyle);
+ assertEquals(3, chartRendererStyle.getSeriesCount());
+
+ // Renderer style for the series dealing with the
+ // secondary axis.
+ ChartRendererStyle chartRendererStyle2 = new ChartRendererStyle();
+ chartRendererStyle2.setDefaultLineDashAttributes(5.0f, 5.0f);
+ chartRendererStyle2.setSeriesLineWidth(1, 10);
+ chartRendererStyle2.setSeriesLineDashAttributes(1, 10f, 10f);
+ barChartStyle.setRendererStyle(1, chartRendererStyle2);
+
+ CategoryDataset data1 = createSampleCategoryDataset1(true, 1);
+ CategoryDataset data2 = createSampleCategoryDataset2(true, 1);
+
+ JFreeChart barChart = barChartStyle.applyToDataset(data1, data2);
+ assertNotNull("applyToDataset lieferte null!", barChart);
+
+ JFTestingUtil.testGui(barChart, "bar chart");
+
+ File testFile = File.createTempFile("testDoubleLineChart", ".xml");
+ xmlFactoryBasic.writeStyleToFile(barChartStyle, "testDoubleLineChart",
+ testFile);
+
+ assertTrue(testFile.getAbsolutePath() + " wurde nicht geschrieben!",
+ testFile.exists());
+
+ String writtenXML = IOUtil.readFileAsString(testFile);
+
+ // XML wieder einlesen
+ ChartStyle lineChartAUsXMLgelesen = xmlFactoryBasic
+ .readStyleFromFile(testFile);
+
+ // Nochmal in XML schreiben
+ File testFile2 = File.createTempFile("testDoubleLineChart", ".xml");
+ xmlFactoryBasic.writeStyleToFile(lineChartAUsXMLgelesen,
+ "testDoubleLineChart", testFile2);
+ String readXML = IOUtil.readFileAsString(testFile2);
+ System.out.println(writtenXML);
+ System.out.println(readXML);
+ assertEquals(
+ "Nachdem das Style geschrieben, gelesen und wieder geschrieben wurde ist das XML nicht gleich!",
+ writtenXML, readXML);
+ }
+
+ @Test
+ public void testKECKbarChart() throws Throwable {
+ String titleAttName = "jahr";
+ String xAxisAttName = "title"; // "code";
+ String yAxisAttName = "dm_u3";
+ String yAxisAttName2 = "w_bev";
+ String groupAttName = "jahr";
+
+ FeatureCollection<SimpleFeatureType, SimpleFeature> features = GTTestingUtil.TestDatasetsVector.kreise
+ .getFeatureCollection();
+
+ log.info("BarChart für " + features.size() + " Features wird erstellt");
+
+ // Fürs testing ausgeben, wie die Werte der featurecollection sind.
+ {
+ Iterator<SimpleFeature> iterator = features.iterator();
+ while (iterator.hasNext()) {
+ SimpleFeature next = iterator.next();
+ System.out.println(next);
+ }
+ features.close(iterator);
+ // Hässiche Ausgabe, aber man sieht, dass es keine nULLS gibt.
+ }
+
+ ChartAxisStyle xAxisStyle = new ChartAxisStyle();
+ xAxisStyle.setLabel("Regionen");
+ ChartAxisStyle yAxisStyle = new ChartAxisStyle();
+ yAxisStyle.setLabel("Deutsch, Männlich unter 3 Jahre");
+ yAxisStyle.setValuesFont(SwingUtil.DEFAULT_FONT.deriveFont(20f));
+ yAxisStyle.setValuesPaint(Color.RED);
+ ChartAxisStyle yAxisStyle2 = new ChartAxisStyle();
+ yAxisStyle2.setLabel("Weiblich");
+ yAxisStyle2.setValuesFont(SwingUtil.DEFAULT_FONT.deriveFont(8f)
+ .deriveFont(Font.BOLD + Font.ITALIC));
+ yAxisStyle2.setValuesPaint(Color.BLUE);
+
+ FeatureBasicChartStyle chartStyle = new FeatureBasicChartStyle(
+ "keckBarChart", ChartType.BAR);
+ chartStyle.setLegend(true);
+ // Domain Axis
+ chartStyle.setAttributeName(0, xAxisAttName);
+ chartStyle.setAxisStyle(0, xAxisStyle);
+ // Range Axis
+ chartStyle.setAttributeName(1, yAxisAttName);
+ chartStyle.setSeriesAttributeName(groupAttName);
+ chartStyle.setAxisStyle(1, yAxisStyle);
+ // Range Axis 2
+ chartStyle.setAxisStyle(2, yAxisStyle2);
+ chartStyle.setAttributeName(2, yAxisAttName2);
+ chartStyle.setAttributeAxis(2, ChartStyle.RANGE_AXIS2);
+
+ chartStyle.setSeriesLegendTitleAttributeName(titleAttName);
+ chartStyle.setSortDomainAxis(true);
+ chartStyle.setForceCategories(true);
+
+ // Farben aus Palette zuweisen
+ ChartRendererStyle chartRendererStyle = new ChartRendererStyle();
+ chartRendererStyle.setSeriesLegendTooltip(0,
+ new ChartLabelStyle("test"));
+ chartRendererStyle.setDefaultLegendTooltip(new ChartLabelStyle("TEST"));
+ ChartRendererStyle chartRendererStyle2 = new ChartRendererStyle();
+ chartRendererStyle2.setSeriesLegendTooltip(0, new ChartLabelStyle(
+ "test2"));
+ chartRendererStyle2
+ .setDefaultLegendTooltip(new ChartLabelStyle("TEST2"));
+ chartStyle.setRendererStyle(0, chartRendererStyle);
+ chartStyle.setRendererStyle(1, chartRendererStyle2);
+
+ // Hintergrund auf weiss stellen
+ ChartPlotStyle chartPlotStyle = new ChartPlotStyle();
+ chartPlotStyle.setBackgroundPaint(Color.white);
+ chartPlotStyle.setRangeGridlineVisible(true);
+ chartPlotStyle.setRangeGridlinePaint(Color.darkGray);
+ chartStyle.setPlotStyle(chartPlotStyle);
+
+ JFreeChart barChart = chartStyle.applyToFeatureCollection(features);
+
+ // // Maximale Breite der Bars einstellen
+ // BarRenderer renderer = (BarRenderer) barChart.getCategoryPlot()
+ // .getRenderer();
+ // renderer.setMaximumBarWidth(0.1);
+
+ JFTestingUtil.testGui(barChart, "bar chart");
+
+ assertXMLOutputAndInput(xmlFactoryFeature, chartStyle,
+ "testKECKBarChart");
+ }
+
+ @Test
+ // @Ignore
+ public void testScatterChart() throws Throwable {
+
+ FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = GTTestingUtil.TestDatasetsVector.kreise.getFeatureCollection();
+ SimpleFeatureType testDatenSchema = testFeatures.getSchema();
+
+ // Daten auf korrektheit überprüfen
+ String attr1Name = "dm_u3"; // Deutsche "Männer" unter 3 Jahren
+ assertNotNull(testDatenSchema.getDescriptor(attr1Name));
+ String attr2Name = "w_bev"; // Frauen Bevölkerung
+ assertNotNull(testDatenSchema.getDescriptor(attr2Name));
+
+ FeatureScatterChartStyle chartStyle = new FeatureScatterChartStyle(
+ "testScatterChart");
+ ChartPlotStyle plotStyle = new ChartPlotStyle();
+ chartStyle.setPlotStyle(plotStyle);
+ chartStyle.setAttributeName(0, attr1Name);
+ chartStyle.setAttributeName(1, attr2Name);
+ chartStyle.setRegressionInfoVisible(true);
+ chartStyle.setRegressionLineVisible(true);
+ chartStyle.getPlotStyle().setCenterOriginSymetrically(true);
+ chartStyle.getPlotStyle().setCrosshairVisible(true);
+
+ JFreeChart chart = chartStyle.applyToFeatureCollection(testFeatures);
+ assertNotNull("applyToFeatureCollection lieferte null!", chart);
+ assertTrue( chart.getPlot() instanceof XYPlot );
+
+
+ if ( chartStyle.isRegressionLineVisible() ) {
+ assertTrue( chart.getXYPlot().getDataset(1) instanceof RegressionDataset );
+ RegressionDataset regrDataset = (RegressionDataset)chart.getXYPlot().getDataset(1);
+ double[] coeff = regrDataset.getOLSRegressionCoefficients();
+ double r = regrDataset.getR();
+ assertEquals( 0.995, r, 0.001);
+ System.out.println( coeff[1]+"x + "+coeff[0] );
+
+ // add the intercept coefficient to the dataset an create a new
+ // regression dataset
+ // -> the coefficients must still be the same!
+ // -> R must become stronger (greater)
+ XYSeriesCollection dataset2 = (XYSeriesCollection)chart.getXYPlot().getDataset();
+ dataset2.getSeries(0).add(0, regrDataset.getRegressionLineIntercept());
+
+ RegressionDataset regrDataset2 = JFreeChartUtil.createRegressionLineDataset(dataset2, 0, "regression line 2", 2);
+ assertTrue("R must become stronger",regrDataset.getR() < regrDataset2.getR());
+ assertEquals(regrDataset.getRegressionLineIntercept(), regrDataset2.getRegressionLineIntercept(), 0.00000001);
+ assertEquals(regrDataset.getRegressionLineSlope(), regrDataset2.getRegressionLineSlope(), 0.00000001);
+ }
+
+ if ( TestingUtil.INTERACTIVE ) {
+ SelectableChartPanel panel = new SelectableChartPanel(chart);
+ panel.setWindowSelectionMode( WindowSelectionMode.SELECT_SET );
+ JFTestingUtil.testGui(panel, "scatter chart");
+ }
+
+
+ // Check the XML output
+ assertXMLOutputAndInput(xmlFactoryFeature, chartStyle, "testScatter");
+
+ }
+
+ @Test
+ // @Ignore
+ public void testBarChartDualAxis() throws Throwable {
+
+ FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = GTTestingUtil.TestDatasetsVector.kreise
+ .getFeatureCollection();
+
+ // Daten auf korrektheit überprüfen
+ String groupAttribName = "code"; // KreisZahl
+ SimpleFeatureType testDatenSchema = testFeatures.getSchema();
+ assertNotNull(testDatenSchema.getDescriptor(groupAttribName));
+ String variablenAttribName = "dm_u3"; // Deutsche "Männer" unter 3
+ // Jahren
+ assertNotNull(testDatenSchema.getDescriptor(variablenAttribName));
+ String labelAttribName = "title"; // Attribute mit Label für Series
+ assertNotNull(testDatenSchema.getDescriptor(labelAttribName));
+ String domainAttribName = "jahr"; // Diese Variable soll auf der X-Achse
+ assertNotNull(testDatenSchema.getDescriptor(domainAttribName));
+ String variablenAttribName2 = "w_bev"; // Frauen Bevölkerung
+ assertNotNull(testDatenSchema.getDescriptor(variablenAttribName2));
+
+ ChartAxisStyle domainAxisStyle = new ChartAxisStyle("jahreszahlen",
+ Color.red, 0., 0.);
+
+ ChartAxisStyle rangeAxisStyle = new ChartAxisStyle("deut. maenner",
+ Color.green, 0., 0.);
+
+ ChartAxisStyle rangeAxisStyle2 = new ChartAxisStyle(
+ "Weibl. Bevölkerung", Color.blue, 0., 0.);
+
+ FeatureBasicChartStyle barChartStyle = new FeatureBasicChartStyle(
+ "testDoubleBarChart", ChartType.BAR);
+ barChartStyle.setForceCategories(true);
+ barChartStyle.setSortDomainAxis(true);
+ barChartStyle.setAxisStyle(0, domainAxisStyle);
+ barChartStyle.setAxisStyle(1, rangeAxisStyle);
+ barChartStyle.setAxisStyle(2, rangeAxisStyle2);
+
+ barChartStyle.setAttributeName(0, domainAttribName);
+ barChartStyle.setAttributeName(1, variablenAttribName);
+ barChartStyle.setAttributeName(2, variablenAttribName2);
+ barChartStyle.setAttributeAxis(2, ChartStyle.RANGE_AXIS2);
+
+ barChartStyle.setSeriesAttributeName(groupAttribName);
+
+ // barChartStyle.setSeriesLegendTitleAttributeName(labelAttribName);
+
+ assertNull("Wenn nicht explizit gesetzt wird null geliefert",
+ barChartStyle.getRendererStyle(0));
+
+ ChartRendererStyle chartRendererStyle = new ChartRendererStyle();
+
+ chartRendererStyle.setDefaultPaint(Color.blue);
+
+ chartRendererStyle.setSeriesPaint(0, Color.green);
+ chartRendererStyle.setSeriesPaint(1, Color.red);
+ chartRendererStyle.setSeriesPaint(2, Color.GRAY);
+ barChartStyle.setRendererStyle(0, chartRendererStyle);
+
+ assertEquals(3, chartRendererStyle.getSeriesCount());
+
+ // Renderer style for the series dealing with the
+ // secondary axis.
+ ChartRendererStyle chartRendererStyle2 = new ChartRendererStyle();
+ chartRendererStyle2.setDefaultLineDashAttributes(5.0f, 5.0f);
+ chartRendererStyle2.setSeriesLineWidth(1, 10);
+ chartRendererStyle2.setSeriesLineDashAttributes(1, 10f, 10f);
+ barChartStyle.setRendererStyle(1, chartRendererStyle2);
+
+ JFreeChart barChart = barChartStyle
+ .applyToFeatureCollection(testFeatures);
+ assertNotNull("applyToFeatureCollection lieferte null!", barChart);
+
+ JFTestingUtil.testGui(barChart, "bar chart");
+
+ File testFile = File.createTempFile("testDoubleLineChart", ".xml");
+ xmlFactoryFeature.writeStyleToFile(barChartStyle,
+ "testDoubleLineChart", testFile);
+
+ assertTrue(testFile.getAbsolutePath() + " wurde nicht geschrieben!",
+ testFile.exists());
+
+ String writtenXML = IOUtil.readFileAsString(testFile);
+
+ // XML wieder einlesen
+ FeatureChartStyle lineChartAUsXMLgelesen = xmlFactoryFeature
+ .readStyleFromFile(testFile);
+
+ // Nochmal in XML schreiben
+ File testFile2 = File.createTempFile("testDoubleLineChart", ".xml");
+ xmlFactoryFeature.writeStyleToFile(lineChartAUsXMLgelesen,
+ "testDoubleLineChart", testFile2);
+ String readXML = IOUtil.readFileAsString(testFile2);
+ System.out.println(writtenXML);
+ System.out.println(readXML);
+ assertEquals(
+ "Nachdem das Style geschrieben, gelesen und wieder geschrieben wurde ist das XML nicht gleich!",
+ writtenXML, readXML);
+ }
+
+ @Ignore
+ @Test
+ public void testBarChartSortedSeries() throws Throwable {
+
+ FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = GTTestingUtil.TestDatasetsVector.kreise
+ .getFeatureCollection();
+
+ // Daten auf korrektheit überprüfen
+ String groupAttribName = "jahr"; // KreisZahl
+ SimpleFeatureType testDatenSchema = testFeatures.getSchema();
+ assertNotNull(testDatenSchema.getDescriptor(groupAttribName));
+ String variablenAttribName = "dm_u3"; // Deutsche "Männer" unter 3
+ // Jahren
+ assertNotNull(testDatenSchema.getDescriptor(variablenAttribName));
+ String labelAttribName = "title"; // Attribute mit Label für Series
+ assertNotNull(testDatenSchema.getDescriptor(labelAttribName));
+ String domainAttribName = "code"; // Diese Variable soll auf der X-Achse
+ // angezeigt werden
+ assertNotNull(testDatenSchema.getDescriptor(domainAttribName));
+
+ ChartAxisStyle domainAxisStyle = new ChartAxisStyle("jahreszahlen",
+ Color.red, 0., 0.);
+ ChartAxisStyle rangeAxisStyle = new ChartAxisStyle("deut. maenner",
+ Color.green, 0., 0.);
+
+ FeatureBasicChartStyle barChartStyle = new FeatureBasicChartStyle(
+ "testLineChart", ChartType.BAR);
+
+ barChartStyle.setAxisStyle(0, domainAxisStyle);
+ barChartStyle.setAxisStyle(1, rangeAxisStyle);
+
+ // Jahreszahlen sollen nicht als zahlen interpretiert werden
+ barChartStyle.setForceCategories(true);
+
+ barChartStyle.setAttributeName(0, domainAttribName);
+ barChartStyle.setAttributeName(1, variablenAttribName);
+
+ 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);
+ assertNotNull("applyToFeatureCollection liefte null!", chart);
+
+ BufferedImage chartpng = chart.createBufferedImage(600, 400);
+ assertNotNull("Es konnte kein PNG aus dem Chart erstellt werden!",
+ chartpng);
+
+ JFTestingUtil
+ .testGui(chart,
+ "Die Balken sollten ihren Jahreszahlen entsprechend sortiert sein");
+ }
+
+ @Ignore
+ @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");
+
+ // In XML schreiben
+ File testFile = File.createTempFile("testWeightChart", ".xml");
+ xmlFactoryFeature.writeStyleToFile(weightChartStyle,
+ "testWeightedhart", testFile);
+
+ System.out.println(IOUtil.readFileAsString(testFile));
+
+ // XML wieder einlesen
+ FeatureChartStyle weightChartAusXMLgelesen = xmlFactoryFeature
+ .readStyleFromFile(testFile);
+ assertEquals(AggregationFunction.AVG_WEIGHTED,
+ weightChartAusXMLgelesen.getAttributeAggregation(1));
+ assertEquals("weight",
+ weightChartAusXMLgelesen
+ .getAttributeAggregationWeightAttributeName(1));
+
+ // Nochmal in XML schreiben
+ File testFile2 = File.createTempFile("testWeightChart", ".xml");
+ xmlFactoryFeature.writeStyleToFile(weightChartStyle,
+ "testWeightedhart", testFile2);
+
+ // XML wieder einlesen
+ FeatureChartStyle weightChartAusXMLgelesen2 = xmlFactoryFeature
+ .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));
+ }
+
+ @Ignore
+ @Test
+ public void testBarChartForcedCategories() throws Throwable {
+
+ // Testdatenshape einlesen
+ FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = GTTestingUtil.TestDatasetsVector.kreise
+ .getFeatureCollection();
+
+ // Daten auf korrektheit überprüfen
+ assertEquals("Testfeatures muss 3x3 Features enthalten", 3 * 3,
+ testFeatures.size());
+ String groupAttribName = "code"; // KreisZahl
+ SimpleFeatureType testDatenSchema = testFeatures.getSchema();
+ assertNotNull(testDatenSchema.getDescriptor(groupAttribName));
+ String variablenAttribName = "dm_u3"; // Deutsche "Männer" unter 3
+ // Jahren
+ assertNotNull(testDatenSchema.getDescriptor(variablenAttribName));
+ String labelAttribName = "title"; // Attribute mit Label für Series
+ assertNotNull(testDatenSchema.getDescriptor(labelAttribName));
+ String domainAttribName = "jahr"; // Diese Variable soll auf der X-Achse
+ // angezeigt werden
+ assertNotNull(testDatenSchema.getDescriptor(domainAttribName));
+
+ ChartAxisStyle domainAxisStyle = new ChartAxisStyle("jahreszahlen",
+ Color.red, 0., 0.);
+ ChartAxisStyle rangeAxisStyle = new ChartAxisStyle("deut. maenner",
+ Color.green, 0., 0.);
+
+ FeatureBasicChartStyle barChartStyle = new FeatureBasicChartStyle(
+ "testLineChart", ChartType.BAR);
+
+ barChartStyle.setAxisStyle(0, domainAxisStyle);
+ barChartStyle.setAxisStyle(1, rangeAxisStyle);
+
+ // Jahreszahlen sollen nicht als zahlen interpretiert werden
+ barChartStyle.setForceCategories(true);
+
+ barChartStyle.setAttributeName(0, domainAttribName);
+ barChartStyle.setAttributeName(1, variablenAttribName);
+
+ barChartStyle.setTooltips(true);
+
+ barChartStyle.setSeriesAttributeName(groupAttribName);
+
+ assertNull("Wenn nicht explizit gesetzt wird null geliefert",
+ barChartStyle.getRendererStyle(0));
+
+ ChartRendererStyle chartRendererStyle = new ChartRendererStyle();
+
+ chartRendererStyle.setSeriesLegendLabel(0, new ChartLabelStyle(
+ "test 1. label"));
+
+ chartRendererStyle.setSeriesPaint(0, Color.green);
+ chartRendererStyle.setSeriesPaint(1, Color.red);
+ chartRendererStyle.setSeriesPaint(2, Color.GRAY);
+ barChartStyle.setRendererStyle(0, chartRendererStyle);
+
+ assertEquals(3, chartRendererStyle.getSeriesCount());
+
+ JFreeChart lineChart = barChartStyle
+ .applyToFeatureCollection(testFeatures);
+ assertNotNull("applyToFeatureCollection liefte null!", lineChart);
+
+ JFTestingUtil.testGui(lineChart, "Drei Balken sein, forcedCategory");
+ }
+
+ // @Ignore
+ @Test
+ public void testLineChartAsCategories() throws Throwable {
+
+ FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = GTTestingUtil.TestDatasetsVector.kreise
+ .getFeatureCollection();
+
+ // Daten auf korrektheit überprüfen
+ String groupAttribName = "code"; // KreisZahl
+ SimpleFeatureType testDatenSchema = testFeatures.getSchema();
+ assertNotNull(testDatenSchema.getDescriptor(groupAttribName));
+ String variablenAttribName = "dm_u3"; // Deutsche "Männer" unter 3
+ // Jahren
+ assertNotNull(testDatenSchema.getDescriptor(variablenAttribName));
+ String labelAttribName = "title"; // Attribute mit Label für Series
+ assertNotNull(testDatenSchema.getDescriptor(labelAttribName));
+ String domainAttribName = "jahr"; // Diese Variable soll auf der X-Achse
+ // angezeigt werden
+ assertNotNull(testDatenSchema.getDescriptor(domainAttribName));
+
+ ChartAxisStyle domainAxisStyle = new ChartAxisStyle("jahreszahlen",
+ Color.red, 0., 0.);
+ ChartAxisStyle rangeAxisStyle = new ChartAxisStyle("deut. maenner",
+ Color.green, 0., 0.);
+
+ FeatureBasicChartStyle lineChartStyle = new FeatureBasicChartStyle(
+ "testLineChart", ChartType.LINE);
+ lineChartStyle.setAxisStyle(0, domainAxisStyle);
+ lineChartStyle.setAxisStyle(1, rangeAxisStyle);
+
+ // Jahreszahlen sollen nicht als zahlen interpretiert werden
+ lineChartStyle.setForceCategories(true);
+
+ lineChartStyle.setAttributeName(0, domainAttribName);
+ lineChartStyle.setAttributeName(1, variablenAttribName);
+
+ lineChartStyle.setTooltips(true);
+
+ lineChartStyle.setSeriesAttributeName(groupAttribName);
+
+ lineChartStyle.setSeriesLegendTitleAttributeName(labelAttribName);
+
+ assertNull("Wenn nicht explizit gesetzt wird null geliefert",
+ lineChartStyle.getRendererStyle(0));
+
+ ChartRendererStyle chartRendererStyle = new ChartRendererStyle();
+
+ // 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);
+ lineChartStyle.setRendererStyle(0, chartRendererStyle);
+
+ assertEquals(3, chartRendererStyle.getSeriesCount());
+
+ JFreeChart lineChart = lineChartStyle
+ .applyToFeatureCollection(testFeatures);
+ assertNotNull("applyToFeatureCollection liefte null!", lineChart);
+
+ JFTestingUtil.testGui(lineChart,
+ "drei linien, forcedCategories, mit series title kreisname");
+
+ // Jetzt nur soll noch eine Line kommen:
+ chartRendererStyle.setSeriesLegendLabel(0, null);
+ lineChartStyle.addSeriesAttributeNoDataValue("06532");
+ lineChartStyle.addSeriesAttributeNoDataValue("06531");
+ lineChart = lineChartStyle.applyToFeatureCollection(testFeatures);
+ assertNotNull("applyToFeatureCollection liefte null!", lineChart);
+
+ JFTestingUtil.testGui(lineChart,
+ "test line chart: soll nur line 06533 existieren!");
+
+ File testFile = File.createTempFile("testLineChart", ".xml");
+
+ xmlFactoryFeature.writeStyleToFile(lineChartStyle, "testLineChart",
+ testFile);
+ assertTrue(testFile.getAbsolutePath() + " wurde nicht geschrieben!",
+ testFile.exists());
+
+ String writtenXML = IOUtil.readFileAsString(testFile);
+ System.out.println(writtenXML);
+ assertTrue(
+ "<seriesAttr name=\"code\" nullAliases=\"06531;06532\" fehlt!",
+ writtenXML
+ .contains("<seriesAttr name=\"code\" nullAliases=\"06531;06532\""));
+
+ assertTrue("Nodatawerte wurden mehr als einmal in das XML geschrieben",
+ writtenXML.indexOf("06531;06532") == writtenXML
+ .lastIndexOf("06531;06532"));
+
+ // XML wieder einlesen
+ FeatureChartStyle lineChartAUsXMLgelesen = xmlFactoryFeature
+ .readStyleFromFile(testFile);
+
+ // Nochmal in XML schreiben
+ File testFile2 = File.createTempFile("testLineChart", ".xml");
+ xmlFactoryFeature.writeStyleToFile(lineChartAUsXMLgelesen,
+ "testLineChart", testFile2);
+ assertEquals(
+ "Nachdem das Style geschrieben, gelesen und wieder geschrieben wurde ist das XML nicht gleich!",
+ writtenXML, IOUtil.readFileAsString(testFile2));
+ }
+
+ // @Ignore
+ @Test
+ public void testLineChartNOTCategories() throws Throwable {
+
+ FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = GTTestingUtil.TestDatasetsVector.kreise
+ .getFeatureCollection();
+
+ // Daten auf korrektheit überprüfen
+ String groupAttribName = "code"; // KreisZahl
+ SimpleFeatureType testDatenSchema = testFeatures.getSchema();
+ assertNotNull(testDatenSchema.getDescriptor(groupAttribName));
+ String variablenAttribName = "dm_u3"; // Deutsche "Männer" unter 3
+ // Jahren
+ assertNotNull(testDatenSchema.getDescriptor(variablenAttribName));
+ String labelAttribName = "title"; // Attribute mit Label für Series
+ assertNotNull(testDatenSchema.getDescriptor(labelAttribName));
+ String domainAttribName = "jahr"; // Diese Variable soll auf der X-Achse
+ // angezeigt werden
+ assertNotNull(testDatenSchema.getDescriptor(domainAttribName));
+
+ ChartAxisStyle domainAxisStyle = new ChartAxisStyle("jahreszahlen",
+ Color.red, 0., 0.);
+
+ ChartAxisStyle rangeAxisStyle = new ChartAxisStyle("deut. maenner",
+ Color.green, 0., 0.);
+
+ FeatureBasicChartStyle lineChartStyle = new FeatureBasicChartStyle(
+ "testLineChart", ChartType.LINE);
+ lineChartStyle.setAxisStyle(0, domainAxisStyle);
+ lineChartStyle.setAxisStyle(1, rangeAxisStyle);
+
+ lineChartStyle.setAttributeName(0, domainAttribName);
+ lineChartStyle.setAttributeName(1, variablenAttribName);
+
+ lineChartStyle.setSeriesLegendTitleAttributeName(labelAttribName);
+
+ lineChartStyle.setTooltips(true);
+
+ lineChartStyle.setSeriesAttributeName(groupAttribName);
+
+ assertNull("Wenn nicht explizit gesetzt wird null geliefert",
+ lineChartStyle.getRendererStyle(0));
+
+ ChartRendererStyle chartRendererStyle = new ChartRendererStyle();
+
+ chartRendererStyle.setDefaultPaint(Color.blue);
+
+ chartRendererStyle.setSeriesPaint(0, Color.green);
+ chartRendererStyle.setSeriesPaint(1, Color.red);
+ chartRendererStyle.setSeriesPaint(2, Color.GRAY);
+ lineChartStyle.setRendererStyle(0, chartRendererStyle);
+
+ assertEquals(3, chartRendererStyle.getSeriesCount());
+
+ JFreeChart lineChart = lineChartStyle
+ .applyToFeatureCollection(testFeatures);
+ assertNotNull("applyToFeatureCollection liefte null!", lineChart);
+
+ 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();
+ NumberAxis numberAxis = new NumberAxis() {
+ @Override
+ public List refreshTicks(Graphics2D g2, AxisState state,
+ Rectangle2D dataArea, RectangleEdge edge) {
+
+ List<ValueTick> ticks = new ArrayList<ValueTick>();
+ TextAnchor ra = TextAnchor.CENTER;
+ TextAnchor ta = TextAnchor.CENTER;
+ ticks.add(new NumberTick(2005, "2005", ta, ra, 0.));
+ 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);
+ lineChartStyle.applyToChart(lineChart);
+
+ JFTestingUtil.testGui(lineChart,
+ "drei linien, NOT categories, KreisNamen series titles");
+
+ File testFile = File.createTempFile("testLineChart", ".xml");
+ xmlFactoryFeature.writeStyleToFile(lineChartStyle, "testLineChart",
+ testFile);
+
+ assertTrue(testFile.getAbsolutePath() + " wurde nicht geschrieben!",
+ testFile.exists());
+
+ String writtenXML = IOUtil.readFileAsString(testFile);
+
+ // XML wieder einlesen
+ FeatureChartStyle lineChartAUsXMLgelesen = xmlFactoryFeature
+ .readStyleFromFile(testFile);
+
+ // Nochmal in XML schreiben
+ File testFile2 = File.createTempFile("testLineChart", ".xml");
+ xmlFactoryFeature.writeStyleToFile(lineChartAUsXMLgelesen,
+ "testLineChart", testFile2);
+ assertEquals(
+ "Nachdem das Style geschrieben, gelesen und wieder geschrieben wurde ist das XML nicht gleich!",
+ writtenXML, IOUtil.readFileAsString(testFile2));
+ }
+
+ private <S extends ChartStyle> void assertXMLOutputAndInput(
+ ChartStyleXMLFactory<S> xmlFactory, S style, String fileName)
+ throws IOException {
+ File testFile = File.createTempFile(fileName, ".xml");
+ xmlFactory.writeStyleToFile(style, fileName, testFile);
+
+ assertTrue(testFile.getAbsolutePath() + " wurde nicht geschrieben!",
+ testFile.exists());
+
+ String writtenXML = IOUtil.readFileAsString(testFile);
+
+ // XML wieder einlesen
+ S chartAusXMLgelesen = xmlFactory.readStyleFromFile(testFile);
+
+ // Nochmal in XML schreiben
+ File testFile2 = File.createTempFile(fileName, ".xml");
+ xmlFactory.writeStyleToFile(chartAusXMLgelesen, fileName, testFile2);
+ String readXML = IOUtil.readFileAsString(testFile2);
+ System.out.println("##### WRITTEN XML #####");
+ System.out.println(writtenXML);
+ System.out.println("##### READ XML #####");
+ System.out.println(readXML);
+ System.out.println("#######################");
+
+ assertEquals(
+ "Nachdem das Style geschrieben, gelesen und wieder geschrieben wurde ist das XML nicht gleich!",
+ writtenXML, readXML);
+ }
+
+ private <S extends ChartStyle> void assertXMLEqual(
+ ChartStyleXMLFactory<S> xmlFactory, S style1, S style2,
+ String fileName) throws IOException {
+ File testFile1 = File.createTempFile(fileName, ".xml");
+ xmlFactory.writeStyleToFile(style1, fileName, testFile1);
+ assertTrue(testFile1.getAbsolutePath() + " wurde nicht geschrieben!",
+ testFile1.exists());
+ String writtenXML1 = IOUtil.readFileAsString(testFile1);
+
+ File testFile2 = File.createTempFile(fileName, ".xml");
+ xmlFactory.writeStyleToFile(style1, fileName, testFile2);
+ assertTrue(testFile2.getAbsolutePath() + " wurde nicht geschrieben!",
+ testFile2.exists());
+ String writtenXML2 = IOUtil.readFileAsString(testFile2);
+
+ System.out.println("##### STYLE 1 #####");
+ System.out.println(writtenXML1);
+ System.out.println("##### STYLE 2 #####");
+ System.out.println(writtenXML2);
+ System.out.println("#######################");
+
+ assertEquals(
+ "Nachdem Style 1 und 2 geschrieben und als String wieder eingelesen wurden, ist das XML nicht gleich!",
+ writtenXML1, writtenXML2);
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/schmitzm-jfree-gt/src/test/java/de/schmitzm/jfree/feature/style/FeatureChartStyleTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id URL
Name: svn:eol-style
+ native
Added: trunk/schmitzm-jfree-gt/src/test/java/de/schmitzm/jfree/testing/JFTestingUtil.java
===================================================================
--- trunk/schmitzm-jfree-gt/src/test/java/de/schmitzm/jfree/testing/JFTestingUtil.java 2011-01-27 10:51:39 UTC (rev 1415)
+++ trunk/schmitzm-jfree-gt/src/test/java/de/schmitzm/jfree/testing/JFTestingUtil.java 2011-01-27 11:01:02 UTC (rev 1416)
@@ -0,0 +1,25 @@
+package de.schmitzm.jfree.testing;
+
+import org.jfree.chart.ChartFrame;
+import org.jfree.chart.JFreeChart;
+
+import de.schmitzm.testing.TestingUtil;
+
+public class JFTestingUtil extends TestingUtil {
+
+ public static void testGui(JFreeChart chart, String frameTitle)
+ throws Throwable {
+ testGui(chart, frameTitle, WAIT_MAX_DEFAULT);
+ }
+
+ public static void testGui(JFreeChart chart, String frameTitle, int waitMax)
+ throws Throwable {
+ if (isInteractive()) {
+ ChartFrame chartFrame = new ChartFrame(frameTitle, chart);
+ chartFrame.pack();
+
+ testGui(chartFrame, waitMax);
+ }
+ }
+
+}
Property changes on: trunk/schmitzm-jfree-gt/src/test/java/de/schmitzm/jfree/testing/JFTestingUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id URL
Name: svn:eol-style
+ native
More information about the Schmitzm-commits
mailing list