001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002-2006, Geotools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * Created on 08 June 2002, 00:04
017: */
018: package org.geotools.svg;
019:
020: import junit.framework.Test;
021: import junit.framework.TestCase;
022: import junit.framework.TestSuite;
023:
024: /**
025: * DOCUMENT ME!
026: *
027: * @author James
028: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/demo/svgsupport/src/test/java/org/geotools/svg/SVGTest.java $
029: */
030: public class SVGTest extends TestCase {
031: public SVGTest(java.lang.String testName) throws Exception {
032: super (testName);
033: }
034:
035: public static void main(java.lang.String[] args) {
036: junit.textui.TestRunner.run(suite());
037: }
038:
039: public static Test suite() {
040: TestSuite suite = new TestSuite(SVGTest.class);
041:
042: return suite;
043: }
044:
045: public void testGenerateSVG() {
046: String stylefile = "simple.sld";
047: String gmlfile = "simple.gml";
048: createSVG("simple.sld", "simple.gml", "simple.svg");
049: }
050:
051: public void testBlueLake() {
052: String stylefile = "bluelake.sld";
053: String gmlfile = "bluelake.gml";
054: //createSVG(stylefile, gmlfile, "bluelake.svg");
055: }
056:
057: public void testNameFilterSVG() {
058: createSVG("nameFilter.sld", "simple.gml", "nameFilter.svg");
059: }
060:
061: /**
062: * DOCUMENT ME!
063: *
064: * @param stylefile
065: * @param gmlfile
066: * @param outfile DOCUMENT ME!
067: */
068: private void createSVG(final String stylefile,
069: final String gmlfile, final String outfile) {
070: /* TODO: restore GML reading
071: try {
072: GenerateSVG gen = new GenerateSVG();
073: File testFile = TestData.file( this, gmlfile );
074: // DataSource ds = new GMLDataSource(url);
075: // FeatureCollection fc = ds.getFeatures(Query.ALL);
076:
077: URI uri = testFile.toURI();
078: Map hints = new HashMap();
079: Object obj = DocumentFactory.getInstance( uri, hints );
080: System.out.println( "what is this:"+obj );
081:
082: FeatureCollection fc = null;
083: File f = TestData.file( this, stylefile );
084:
085: MapContext mapContext = new DefaultMapContext();
086: StyleFactory sFac = StyleFactory.createStyleFactory();
087: SLDStyle reader = new SLDStyle(sFac, f);
088: Style[] style = reader.readXML();
089: mapContext.addLayer(fc, style[0]);
090:
091: File file = TestData.temp( this, outfile );
092: FileOutputStream out = new FileOutputStream( file );
093:
094: gen.setCanvasSize(new Dimension(500, 500));
095: gen.go(mapContext, fc.getBounds(), out);
096: } catch (Exception e) {
097: System.out.println(e);
098: e.printStackTrace();
099: fail("failed because of exception " + e.toString());
100: }
101: */
102: }
103: }
|