[Schmitzm-commits] r261 - in trunk/src: org/geotools/renderer/shape schmitzm/geotools/gui schmitzm/geotools/io schmitzm/jfree schmitzm/jfree/chart/style schmitzm/jfree/feature/style schmitzm/swing skrueger/geotools skrueger/i8n skrueger/swing

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jul 31 19:05:20 CEST 2009


Author: mojays
Date: 2009-07-31 19:05:18 +0200 (Fri, 31 Jul 2009)
New Revision: 261

Modified:
   trunk/src/org/geotools/renderer/shape/TransitionShapefileRenderer.java
   trunk/src/schmitzm/geotools/gui/FeatureTablePane.java
   trunk/src/schmitzm/geotools/gui/GeoMapPane.java
   trunk/src/schmitzm/geotools/gui/JEditorPane.java
   trunk/src/schmitzm/geotools/gui/JMapPane.java
   trunk/src/schmitzm/geotools/io/GeoImportUtil.java
   trunk/src/schmitzm/jfree/JFreeChartUtil.java
   trunk/src/schmitzm/jfree/chart/style/AbstractChartStyle.java
   trunk/src/schmitzm/jfree/chart/style/BasicChartStyle.java
   trunk/src/schmitzm/jfree/chart/style/ChartAxisStyle.java
   trunk/src/schmitzm/jfree/chart/style/ChartLabelStyle.java
   trunk/src/schmitzm/jfree/chart/style/ChartPlotStyle.java
   trunk/src/schmitzm/jfree/chart/style/ChartRendererStyle.java
   trunk/src/schmitzm/jfree/chart/style/ChartStyle.java
   trunk/src/schmitzm/jfree/chart/style/ChartStyleUtil.java
   trunk/src/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java
   trunk/src/schmitzm/jfree/feature/style/FeatureBasicChartStyle.java
   trunk/src/schmitzm/jfree/feature/style/FeatureChartStyle.java
   trunk/src/schmitzm/jfree/feature/style/FeatureChartStyleXMLFactory.java
   trunk/src/schmitzm/jfree/feature/style/FeatureChartUtil.java
   trunk/src/schmitzm/jfree/feature/style/FeatureScatterChartStyle.java
   trunk/src/schmitzm/swing/SelectionInputOption.java
   trunk/src/skrueger/geotools/MapView.java
   trunk/src/skrueger/geotools/StyledFeatureCollectionInterface.java
   trunk/src/skrueger/geotools/StyledFeatureSourceInterface.java
   trunk/src/skrueger/i8n/SwitchLanguageDialog.java
   trunk/src/skrueger/i8n/Translation.java
   trunk/src/skrueger/swing/TranslationAskJDialog.java
   trunk/src/skrueger/swing/TranslationEditJPanel.java
Log:
all methods dealing with features moved from JFreeChartUtil to FeatureChartUtil
imports organized

Modified: trunk/src/org/geotools/renderer/shape/TransitionShapefileRenderer.java
===================================================================
--- trunk/src/org/geotools/renderer/shape/TransitionShapefileRenderer.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/org/geotools/renderer/shape/TransitionShapefileRenderer.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -62,9 +62,7 @@
 import org.geotools.feature.GeometryAttributeType;
 import org.geotools.feature.SchemaException;
 import org.geotools.filter.FilterAttributeExtractor;
-import org.geotools.filter.Filters;
 import org.geotools.geometry.jts.Decimator;
-import org.geotools.geometry.jts.JTS;
 import org.geotools.geometry.jts.LiteCoordinateSequenceFactory;
 import org.geotools.geometry.jts.LiteShape2;
 import org.geotools.geometry.jts.ReferencedEnvelope;
@@ -101,7 +99,6 @@
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.referencing.operation.CoordinateOperation;
 import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.Operation;
 import org.opengis.referencing.operation.TransformException;
 
 import schmitzm.geotools.feature.FeatureOperationTreeFilter;

Modified: trunk/src/schmitzm/geotools/gui/FeatureTablePane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/FeatureTablePane.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/geotools/gui/FeatureTablePane.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -32,7 +32,6 @@
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Dimension;
-import java.io.IOException;
 
 import javax.swing.BorderFactory;
 import javax.swing.JScrollPane;
@@ -46,8 +45,6 @@
 import javax.swing.table.TableModel;
 
 import org.apache.log4j.Logger;
-import org.geotools.data.FeatureSource;
-import org.geotools.data.memory.MemoryDataStore;
 import org.geotools.feature.FeatureCollection;
 import org.geotools.map.DefaultMapLayer;
 import org.geotools.styling.Style;

Modified: trunk/src/schmitzm/geotools/gui/GeoMapPane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/GeoMapPane.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/geotools/gui/GeoMapPane.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -30,7 +30,6 @@
 package schmitzm.geotools.gui;
 
 import java.awt.Color;
-import java.awt.Dimension;
 import java.awt.Graphics;
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;

Modified: trunk/src/schmitzm/geotools/gui/JEditorPane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/JEditorPane.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/geotools/gui/JEditorPane.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -57,7 +57,6 @@
 import org.geotools.map.MapLayer;
 import org.geotools.referencing.crs.DefaultGeographicCRS;
 import org.geotools.renderer.GTRenderer;
-import org.geotools.renderer.lite.StreamingRenderer;
 import org.geotools.renderer.shape.TransitionShapefileRenderer;
 import org.geotools.styling.Style;
 

Modified: trunk/src/schmitzm/geotools/gui/JMapPane.java
===================================================================
--- trunk/src/schmitzm/geotools/gui/JMapPane.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/geotools/gui/JMapPane.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -60,6 +60,7 @@
 import org.geotools.coverage.grid.GridGeometry2D;
 import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader;
 import org.geotools.coverage.grid.io.AbstractGridFormat;
+import org.geotools.coverage.io.AbstractGridCoverageReader;
 import org.geotools.data.FeatureSource;
 import org.geotools.data.memory.MemoryFeatureCollection;
 import org.geotools.factory.GeoTools;

Modified: trunk/src/schmitzm/geotools/io/GeoImportUtil.java
===================================================================
--- trunk/src/schmitzm/geotools/io/GeoImportUtil.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/geotools/io/GeoImportUtil.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -66,7 +66,6 @@
 import org.geotools.gce.geotiff.GeoTiffReader;
 import org.geotools.gce.image.WorldImageReader;
 import org.geotools.geometry.Envelope2D;
-import org.geotools.gui.swing.ExceptionMonitor;
 import org.geotools.referencing.CRS;
 import org.geotools.referencing.crs.DefaultGeographicCRS;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;

Modified: trunk/src/schmitzm/jfree/JFreeChartUtil.java
===================================================================
--- trunk/src/schmitzm/jfree/JFreeChartUtil.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/jfree/JFreeChartUtil.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -30,15 +30,9 @@
 package schmitzm.jfree;
 
 import java.awt.Color;
-import java.util.ArrayList;
-import java.util.List;
 import java.util.Locale;
 
 import org.apache.log4j.Logger;
-import org.geotools.feature.AttributeType;
-import org.geotools.feature.Feature;
-import org.geotools.feature.FeatureCollection;
-import org.geotools.feature.FeatureIterator;
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.axis.NumberAxis;
 import org.jfree.chart.event.PlotChangeEvent;
@@ -47,7 +41,6 @@
 import org.jfree.chart.event.RendererChangeListener;
 import org.jfree.chart.labels.StandardXYToolTipGenerator;
 import org.jfree.chart.labels.XYToolTipGenerator;
-import org.jfree.chart.plot.CategoryPlot;
 import org.jfree.chart.plot.Plot;
 import org.jfree.chart.plot.PlotOrientation;
 import org.jfree.chart.plot.XYPlot;
@@ -71,26 +64,18 @@
 import org.jfree.chart.title.Title;
 import org.jfree.chart.urls.StandardXYURLGenerator;
 import org.jfree.chart.urls.XYURLGenerator;
-import org.jfree.data.category.CategoryDataset;
 import org.jfree.data.function.Function2D;
 import org.jfree.data.function.LineFunction2D;
-import org.jfree.data.general.Dataset;
 import org.jfree.data.general.DatasetUtilities;
 import org.jfree.data.statistics.Regression;
 import org.jfree.data.xy.XYDataset;
-import org.jfree.data.xy.XYSeries;
 import org.jfree.data.xy.XYSeriesCollection;
 
 import schmitzm.jfree.chart.renderer.SelectionXYLineAndShapeRenderer;
-import schmitzm.jfree.chart.selection.DatasetSelectionModel;
-import schmitzm.jfree.chart.selection.DatasetSelectionModelProvider;
 import schmitzm.jfree.chart.style.BasicChartStyle;
 import schmitzm.jfree.chart.style.ChartStyle;
 import schmitzm.jfree.chart.style.ChartStyleXMLFactory;
 import schmitzm.jfree.chart.style.ChartType;
-import schmitzm.jfree.feature.Feature2SeriesDatasetMapping;
-import schmitzm.jfree.feature.FeatureDatasetMetaData;
-import schmitzm.jfree.feature.FeatureDatasetSelectionModel;
 import schmitzm.jfree.feature.FeatureSeriesDatasetSelectionModel;
 import schmitzm.lang.LangUtil;
 import schmitzm.lang.ResourceProvider;
@@ -252,91 +237,8 @@
     throw new UnsupportedOperationException("CategoryItemRenderer could not be created for chart type: "+type); 
   }
 
+ 
   /**
-   * Creates a {@link Dataset} for 2 or more attributes of a {@link FeatureCollection}.
-   * According to the feature attribute type the method decides whether a {@link XYDataset}
-   * or a {@link CategoryDataset} is created:<br>
-   * In case of an non-numeric X attribute a {@link CategoryDataset} is created always.
-   * Otherwise the default is to create a {@link XYDataset}. The flag {@code forceCat}
-   * can be used to create {@link CategoryDataset} for numeric X attributes.  
-   * @param fc       a {@link FeatureCollection}
-   * @param forceCat forces a {@link CategoryDataset} also for numeric X attributes
-   * @param xAttr feature attribute used for the X-value
-   * @param yAttr feature attribute(s) used for the Y-value (at least one; for each a
-   *              series is created in the dataset)
-   */
-  public static Dataset createDataset(FeatureCollection fc, boolean forceCat, boolean sot, String xAttr, String... yAttr) {
-    
-    
-    
-    
-    return null;
-  }
-  
-  
-  /**
-   * Creates a {@link XYDataset} for 2 attributes of a {@link FeatureCollection}.
-   * @param fc    a {@link FeatureCollection}
-   * @param seriesKey   a (unique) key for the {@link XYSeries} in the dataset
-   * @param xAttr feature attribute used for the X-value
-   * @param yAttr feature attribute used for the Y-value
-   */
-  public static XYSeriesCollection createXYDataset(FeatureCollection fc, String seriesKey, String xAttr, String yAttr) {
-    // check data types of X- and Y-column
-    AttributeType xType = fc.getSchema().getAttributeType(xAttr);
-    if ( xType == null )
-      throw new UnsupportedOperationException("Unknown attribute: "+xAttr);
-    AttributeType yType = fc.getSchema().getAttributeType(yAttr);
-    if ( yType == null )
-      throw new UnsupportedOperationException("Unknown attribute: "+yAttr);
-    if ( !Number.class.isAssignableFrom(xType.getBinding()) )
-      throw new UnsupportedOperationException("Attribute must be numeric: "+xAttr);
-    if ( !Number.class.isAssignableFrom(yType.getBinding()) )
-      throw new UnsupportedOperationException("Attribute must be numeric: "+yAttr);
-    
-    
-    XYSeriesCollection           dataset   = new XYSeriesCollection();
-    Feature2SeriesDatasetMapping mapping   = new Feature2SeriesDatasetMapping(fc,dataset);
-    FeatureIterator              fi        = fc.features();
-    XYSeries                     xySeries  = new XYSeries(seriesKey,false,true);
-    dataset.addSeries(xySeries);
-    dataset.setGroup( new FeatureDatasetMetaData(mapping) );
-    for (int i=0; fi.hasNext(); i++) {
-      Feature f = fi.next();
-      Number xValue = (Number)f.getAttribute(xAttr);
-      Number yValue = (Number)f.getAttribute(yAttr);
-      // x-value NULL not permitted for XY dateset
-      if ( xValue == null )
-        continue;
-//      // TODO: here maybe filtering the several NULL aliases
-//      if ( yValue is a NULL alias )
-//        yValue = null;
-//      // TODO: her maybe ignore NULL values completely        
-//      if ( yValue == null )
-//        continue;
-      xySeries.add(xValue, yValue);
-      // Mapping between FID and data index in series
-      mapping.setMapping(f.getID(), seriesKey, i);
-      //LOGGER.debug(f.getID() + " --> "+i);
-    }
-    return dataset;
-  }
-  
-  /**
-   * Creates a {@link JFreeChart} which shows a point for each feature and
-   * a the appropriate regression line.
-   * @param fc      a {@link FeatureCollection}
-   * @param title   title for the chart (also used as key for the {@link XYSeries})
-   * @param xAttr   feature attribute used for the X-value
-   * @param yAttr   feature attribute used for the Y-value
-   * @param regressionLine indicates whether the regression line is shown
-   */
-  public static JFreeChart createRegressionChart(FeatureCollection fc, String title, String xAttr, String yAttr, boolean regressionLine) {
-    XYSeriesCollection  dataset = createXYDataset(fc, title, xAttr, yAttr);
-    return createRegressionChart(dataset, title, xAttr, yAttr, regressionLine);
-  }
-  
-  /**
    * Creates a {@link JFreeChart} which shows a point for each data iten and
    * a the appropriate regression line.
    * @param dataset        the data
@@ -424,45 +326,7 @@
     plot.setRenderer(datasetCount, renderer);
   }
 
-  /**
-   * @return all {@link DatasetSelectionModel DatasetSelectionModels} that can be reached via the renderers of this chart. 
-   */
-  public static List<FeatureDatasetSelectionModel<?>> getFeatureDatasetSelectionModelFor(JFreeChart chart) {
-	ArrayList<FeatureDatasetSelectionModel<?>> renderers = new ArrayList<FeatureDatasetSelectionModel<?>>();
-	
-	Plot plot = chart.getPlot();
-	
-	/** Collect renderers from XYPlot */	
-	if (plot instanceof XYPlot) {
-		XYPlot xyplot = (XYPlot)plot;
 
-		for (int i = 0; i < xyplot.getRendererCount(); i++) {
-			XYItemRenderer renderer = xyplot.getRenderer(i);
-			if (renderer instanceof DatasetSelectionModelProvider &&
-			    ((DatasetSelectionModelProvider)renderer).getSelectionModel() instanceof FeatureDatasetSelectionModel){
-				renderers.add( (FeatureDatasetSelectionModel)((DatasetSelectionModelProvider)renderer).getSelectionModel());
-			}
-		}
-	}
-	
-	/** Collect renderers from CategoryPlot */
-	if (plot instanceof CategoryPlot) {
-		CategoryPlot catPlot = (CategoryPlot)plot;
-		
-		for (int i = 0; i < catPlot.getRendererCount(); i++) {
-			CategoryItemRenderer renderer = catPlot.getRenderer(i);
-			if (renderer instanceof DatasetSelectionModelProvider &&
-					((DatasetSelectionModelProvider)renderer).getSelectionModel() instanceof FeatureDatasetSelectionModel){
-				renderers.add( (FeatureDatasetSelectionModel)((DatasetSelectionModelProvider)renderer).getSelectionModel());
-			}
-		}
-	}
-	
-	return renderers;
-  }
-  
-
-
 //###################
 //  BISHER NUR WILDE TESTS
 //###################

Modified: trunk/src/schmitzm/jfree/chart/style/AbstractChartStyle.java
===================================================================
--- trunk/src/schmitzm/jfree/chart/style/AbstractChartStyle.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/jfree/chart/style/AbstractChartStyle.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -40,15 +40,11 @@
 package schmitzm.jfree.chart.style;
 
 import java.awt.Color;
-import java.awt.Paint;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Set;
 import java.util.Vector;
 
 import org.apache.log4j.Category;
-import org.apache.log4j.Logger;
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.axis.Axis;
 import org.jfree.chart.labels.CategoryToolTipGenerator;
@@ -66,11 +62,9 @@
 import org.jfree.chart.urls.StandardCategoryURLGenerator;
 import org.jfree.chart.urls.StandardXYURLGenerator;
 import org.jfree.chart.urls.XYURLGenerator;
-import org.jfree.data.general.Dataset;
 
 import schmitzm.jfree.JFreeChartUtil;
 import schmitzm.lang.LangUtil;
-import skrueger.i8n.Translation;
 
 /**
  * This class provides an abstract implementation for chart styles.

Modified: trunk/src/schmitzm/jfree/chart/style/BasicChartStyle.java
===================================================================
--- trunk/src/schmitzm/jfree/chart/style/BasicChartStyle.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/jfree/chart/style/BasicChartStyle.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -44,16 +44,6 @@
 import org.jfree.chart.plot.CategoryPlot;
 import org.jfree.chart.plot.PlotOrientation;
 import org.jfree.chart.plot.XYPlot;
-import org.jfree.chart.renderer.category.CategoryStepRenderer;
-import org.jfree.chart.renderer.category.StackedAreaRenderer;
-import org.jfree.chart.renderer.category.StackedBarRenderer;
-import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2;
-import org.jfree.chart.renderer.xy.StackedXYBarRenderer;
-import org.jfree.chart.renderer.xy.XYAreaRenderer;
-import org.jfree.chart.renderer.xy.XYItemRenderer;
-import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
-import org.jfree.chart.renderer.xy.XYStepAreaRenderer;
-import org.jfree.chart.renderer.xy.XYStepRenderer;
 import org.jfree.data.category.CategoryDataset;
 import org.jfree.data.general.Dataset;
 import org.jfree.data.xy.IntervalXYDataset;

Modified: trunk/src/schmitzm/jfree/chart/style/ChartAxisStyle.java
===================================================================
--- trunk/src/schmitzm/jfree/chart/style/ChartAxisStyle.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/jfree/chart/style/ChartAxisStyle.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -30,7 +30,6 @@
 package schmitzm.jfree.chart.style;
 
 import java.awt.Color;
-import java.awt.Paint;
 import java.text.DateFormat;
 import java.text.Format;
 import java.text.NumberFormat;

Modified: trunk/src/schmitzm/jfree/chart/style/ChartLabelStyle.java
===================================================================
--- trunk/src/schmitzm/jfree/chart/style/ChartLabelStyle.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/jfree/chart/style/ChartLabelStyle.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -30,7 +30,6 @@
 package schmitzm.jfree.chart.style;
 
 import java.awt.Color;
-import java.awt.Paint;
 import java.util.Locale;
 
 import org.apache.log4j.Category;

Modified: trunk/src/schmitzm/jfree/chart/style/ChartPlotStyle.java
===================================================================
--- trunk/src/schmitzm/jfree/chart/style/ChartPlotStyle.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/jfree/chart/style/ChartPlotStyle.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -30,28 +30,11 @@
 package schmitzm.jfree.chart.style;
 
 import java.awt.Color;
-import java.awt.Insets;
-import java.awt.Paint;
-import java.text.DateFormat;
-import java.text.Format;
-import java.text.NumberFormat;
-import java.util.HashMap;
-import java.util.Map;
 
 import org.apache.log4j.Category;
-import org.jfree.chart.JFreeChart;
-import org.jfree.chart.axis.Axis;
-import org.jfree.chart.axis.CategoryAxis;
-import org.jfree.chart.axis.CategoryLabelPositions;
-import org.jfree.chart.axis.DateAxis;
-import org.jfree.chart.axis.NumberAxis;
-import org.jfree.chart.event.PlotChangeEvent;
 import org.jfree.chart.plot.CategoryPlot;
 import org.jfree.chart.plot.Plot;
 import org.jfree.chart.plot.XYPlot;
-import org.jfree.chart.renderer.AbstractRenderer;
-import org.jfree.chart.renderer.xy.XYBarRenderer;
-import org.jfree.data.general.Dataset;
 import org.jfree.ui.RectangleInsets;
 
 import schmitzm.jfree.JFreeChartUtil;

Modified: trunk/src/schmitzm/jfree/chart/style/ChartRendererStyle.java
===================================================================
--- trunk/src/schmitzm/jfree/chart/style/ChartRendererStyle.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/jfree/chart/style/ChartRendererStyle.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -30,27 +30,12 @@
 package schmitzm.jfree.chart.style;
 
 import java.awt.Color;
-import java.awt.Paint;
-import java.text.DateFormat;
-import java.text.Format;
-import java.text.NumberFormat;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.log4j.Category;
-import org.jfree.chart.JFreeChart;
-import org.jfree.chart.axis.Axis;
-import org.jfree.chart.axis.CategoryAxis;
-import org.jfree.chart.axis.CategoryLabelPositions;
-import org.jfree.chart.axis.DateAxis;
-import org.jfree.chart.axis.NumberAxis;
-import org.jfree.chart.event.RendererChangeEvent;
-import org.jfree.chart.plot.CategoryPlot;
-import org.jfree.chart.plot.XYPlot;
 import org.jfree.chart.renderer.AbstractRenderer;
 import org.jfree.chart.renderer.xy.XYBarRenderer;
-import org.jfree.data.general.Dataset;
 
 import schmitzm.jfree.JFreeChartUtil;
 import schmitzm.lang.LangUtil;

Modified: trunk/src/schmitzm/jfree/chart/style/ChartStyle.java
===================================================================
--- trunk/src/schmitzm/jfree/chart/style/ChartStyle.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/jfree/chart/style/ChartStyle.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -30,9 +30,7 @@
 package schmitzm.jfree.chart.style;
 
 import java.awt.Color;
-import java.awt.Paint;
 
-
 import org.apache.log4j.Logger;
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.plot.PlotOrientation;

Modified: trunk/src/schmitzm/jfree/chart/style/ChartStyleUtil.java
===================================================================
--- trunk/src/schmitzm/jfree/chart/style/ChartStyleUtil.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/jfree/chart/style/ChartStyleUtil.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -29,9 +29,7 @@
  ******************************************************************************/
 package schmitzm.jfree.chart.style;
 
-import java.io.File;
 import java.io.IOException;
-import java.net.URISyntaxException;
 import java.net.URL;
 
 import org.jdom.Document;

Modified: trunk/src/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java
===================================================================
--- trunk/src/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/jfree/chart/style/ChartStyleXMLFactory.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -32,7 +32,6 @@
 import java.awt.Color;
 import java.io.File;
 import java.io.FileOutputStream;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.text.DateFormat;

Modified: trunk/src/schmitzm/jfree/feature/style/FeatureBasicChartStyle.java
===================================================================
--- trunk/src/schmitzm/jfree/feature/style/FeatureBasicChartStyle.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/jfree/feature/style/FeatureBasicChartStyle.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -31,12 +31,10 @@
 
 import org.geotools.feature.FeatureCollection;
 import org.jfree.chart.JFreeChart;
-import org.jfree.chart.plot.PlotOrientation;
 import org.jfree.data.category.CategoryDataset;
 import org.jfree.data.general.Dataset;
 import org.jfree.data.xy.XYDataset;
 
-import schmitzm.jfree.JFreeChartUtil;
 import schmitzm.jfree.chart.style.BasicChartStyle;
 import schmitzm.jfree.chart.style.ChartType;
 
@@ -187,7 +185,7 @@
     @Override
     public JFreeChart applyToFeatureCollection(FeatureCollection fc) {
         //    Dataset dataset = null; // TODO: Create dataset from FeatureCollection by utility method
-        Dataset dataset = JFreeChartUtil.createXYDataset(fc, getTitleStyle().getLabel(), getAttributeName(DOMAIN_AXIS), getAttributeName(RANGE_AXIS));
+        Dataset dataset = FeatureChartUtil.createXYDataset(fc, getTitleStyle().getLabel(), getAttributeName(DOMAIN_AXIS), getAttributeName(RANGE_AXIS));
         return applyToDataset(dataset);
     }
 }

Modified: trunk/src/schmitzm/jfree/feature/style/FeatureChartStyle.java
===================================================================
--- trunk/src/schmitzm/jfree/feature/style/FeatureChartStyle.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/jfree/feature/style/FeatureChartStyle.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -31,7 +31,6 @@
 
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Vector;
 
 import org.geotools.feature.FeatureCollection;
 import org.jfree.chart.JFreeChart;

Modified: trunk/src/schmitzm/jfree/feature/style/FeatureChartStyleXMLFactory.java
===================================================================
--- trunk/src/schmitzm/jfree/feature/style/FeatureChartStyleXMLFactory.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/jfree/feature/style/FeatureChartStyleXMLFactory.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -34,11 +34,9 @@
 import org.geotools.feature.FeatureCollection;
 import org.jdom.Element;
 
-import schmitzm.jfree.chart.style.ChartLabelStyle;
 import schmitzm.jfree.chart.style.ChartStyle;
 import schmitzm.jfree.chart.style.ChartStyleXMLFactory;
 import schmitzm.jfree.chart.style.ChartType;
-import schmitzm.lang.LangUtil;
 import schmitzm.xml.XMLUtil;
 
 /**

Modified: trunk/src/schmitzm/jfree/feature/style/FeatureChartUtil.java
===================================================================
--- trunk/src/schmitzm/jfree/feature/style/FeatureChartUtil.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/jfree/feature/style/FeatureChartUtil.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -29,9 +29,32 @@
  ******************************************************************************/
 package schmitzm.jfree.feature.style;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import org.geotools.feature.AttributeType;
+import org.geotools.feature.Feature;
 import org.geotools.feature.FeatureCollection;
+import org.geotools.feature.FeatureIterator;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.plot.CategoryPlot;
+import org.jfree.chart.plot.Plot;
+import org.jfree.chart.plot.XYPlot;
+import org.jfree.chart.renderer.category.CategoryItemRenderer;
+import org.jfree.chart.renderer.xy.XYItemRenderer;
+import org.jfree.data.category.CategoryDataset;
+import org.jfree.data.general.Dataset;
+import org.jfree.data.xy.XYDataset;
+import org.jfree.data.xy.XYSeries;
+import org.jfree.data.xy.XYSeriesCollection;
 
+import schmitzm.jfree.JFreeChartUtil;
+import schmitzm.jfree.chart.selection.DatasetSelectionModel;
+import schmitzm.jfree.chart.selection.DatasetSelectionModelProvider;
 import schmitzm.jfree.chart.style.ChartStyleXMLFactory;
+import schmitzm.jfree.feature.Feature2SeriesDatasetMapping;
+import schmitzm.jfree.feature.FeatureDatasetMetaData;
+import schmitzm.jfree.feature.FeatureDatasetSelectionModel;
 
 /**
  * This class contains static utility methods related to chart styles based on
@@ -42,4 +65,130 @@
 public class FeatureChartUtil {
   /** Instance of {@link ChartStyleXMLFactory}. */
   public static final FeatureChartStyleXMLFactory FEATURE_CHART_STYLE_FACTORY = new FeatureChartStyleXMLFactory();
+
+  /**
+   * Returns all {@link DatasetSelectionModel DatasetSelectionModels} that can be reached
+   * via the renderers of a chart. 
+   * @param chart a chart
+   */
+  public static List<FeatureDatasetSelectionModel<?>> getFeatureDatasetSelectionModelFor(JFreeChart chart) {
+    ArrayList<FeatureDatasetSelectionModel<?>> renderers = new ArrayList<FeatureDatasetSelectionModel<?>>();
+    
+    Plot plot = chart.getPlot();
+    
+    /** Collect renderers from XYPlot */    
+    if (plot instanceof XYPlot) {
+        XYPlot xyplot = (XYPlot)plot;
+
+        for (int i = 0; i < xyplot.getRendererCount(); i++) {
+            XYItemRenderer renderer = xyplot.getRenderer(i);
+            if (renderer instanceof DatasetSelectionModelProvider &&
+                ((DatasetSelectionModelProvider)renderer).getSelectionModel() instanceof FeatureDatasetSelectionModel){
+                renderers.add( (FeatureDatasetSelectionModel)((DatasetSelectionModelProvider)renderer).getSelectionModel());
+            }
+        }
+    }
+    
+    /** Collect renderers from CategoryPlot */
+    if (plot instanceof CategoryPlot) {
+        CategoryPlot catPlot = (CategoryPlot)plot;
+        
+        for (int i = 0; i < catPlot.getRendererCount(); i++) {
+            CategoryItemRenderer renderer = catPlot.getRenderer(i);
+            if (renderer instanceof DatasetSelectionModelProvider &&
+                    ((DatasetSelectionModelProvider)renderer).getSelectionModel() instanceof FeatureDatasetSelectionModel){
+                renderers.add( (FeatureDatasetSelectionModel)((DatasetSelectionModelProvider)renderer).getSelectionModel());
+            }
+        }
+    }
+    
+    return renderers;
+  }
+  
+  /**
+   * Creates a {@link Dataset} for 2 or more attributes of a {@link FeatureCollection}.
+   * According to the feature attribute type the method decides whether a {@link XYDataset}
+   * or a {@link CategoryDataset} is created:<br>
+   * In case of an non-numeric X attribute a {@link CategoryDataset} is created always.
+   * Otherwise the default is to create a {@link XYDataset}. The flag {@code forceCat}
+   * can be used to create {@link CategoryDataset} for numeric X attributes.  
+   * @param fc       a {@link FeatureCollection}
+   * @param forceCat forces a {@link CategoryDataset} also for numeric X attributes
+   * @param xAttr feature attribute used for the X-value
+   * @param yAttr feature attribute(s) used for the Y-value (at least one; for each a
+   *              series is created in the dataset)
+   */
+  public static Dataset createDataset(FeatureCollection fc, boolean forceCat, boolean sot, String xAttr, String... yAttr) {
+    
+    
+    
+    
+    return null;
+  }
+  
+  /**
+   * Creates a {@link XYDataset} for 2 attributes of a {@link FeatureCollection}.
+   * @param fc    a {@link FeatureCollection}
+   * @param seriesKey   a (unique) key for the {@link XYSeries} in the dataset
+   * @param xAttr feature attribute used for the X-value
+   * @param yAttr feature attribute used for the Y-value
+   */
+  public static XYSeriesCollection createXYDataset(FeatureCollection fc, String seriesKey, String xAttr, String yAttr) {
+    // check data types of X- and Y-column
+    AttributeType xType = fc.getSchema().getAttributeType(xAttr);
+    if ( xType == null )
+      throw new UnsupportedOperationException("Unknown attribute: "+xAttr);
+    AttributeType yType = fc.getSchema().getAttributeType(yAttr);
+    if ( yType == null )
+      throw new UnsupportedOperationException("Unknown attribute: "+yAttr);
+    if ( !Number.class.isAssignableFrom(xType.getBinding()) )
+      throw new UnsupportedOperationException("Attribute must be numeric: "+xAttr);
+    if ( !Number.class.isAssignableFrom(yType.getBinding()) )
+      throw new UnsupportedOperationException("Attribute must be numeric: "+yAttr);
+    
+    
+    XYSeriesCollection           dataset   = new XYSeriesCollection();
+    Feature2SeriesDatasetMapping mapping   = new Feature2SeriesDatasetMapping(fc,dataset);
+    FeatureIterator              fi        = fc.features();
+    XYSeries                     xySeries  = new XYSeries(seriesKey,false,true);
+    dataset.addSeries(xySeries);
+    dataset.setGroup( new FeatureDatasetMetaData(mapping) );
+    for (int i=0; fi.hasNext(); i++) {
+      Feature f = fi.next();
+      Number xValue = (Number)f.getAttribute(xAttr);
+      Number yValue = (Number)f.getAttribute(yAttr);
+      // x-value NULL not permitted for XY dateset
+      if ( xValue == null )
+        continue;
+//      // TODO: here maybe filtering the several NULL aliases
+//      if ( yValue is a NULL alias )
+//        yValue = null;
+//      // TODO: her maybe ignore NULL values completely        
+//      if ( yValue == null )
+//        continue;
+      xySeries.add(xValue, yValue);
+      // Mapping between FID and data index in series
+      mapping.setMapping(f.getID(), seriesKey, i);
+      //LOGGER.debug(f.getID() + " --> "+i);
+    }
+    return dataset;
+  }
+  
+  /**
+   * Creates a {@link JFreeChart} which shows a point for each feature and
+   * a the appropriate regression line.
+   * @param fc      a {@link FeatureCollection}
+   * @param title   title for the chart (also used as key for the {@link XYSeries})
+   * @param xAttr   feature attribute used for the X-value
+   * @param yAttr   feature attribute used for the Y-value
+   * @param regressionLine indicates whether the regression line is shown
+   */
+  public static JFreeChart createRegressionChart(FeatureCollection fc, String title, String xAttr, String yAttr, boolean regressionLine) {
+    XYSeriesCollection  dataset = createXYDataset(fc, title, xAttr, yAttr);
+    return JFreeChartUtil.createRegressionChart(dataset, title, xAttr, yAttr, regressionLine);
+  }
+
+
+
+
 }

Modified: trunk/src/schmitzm/jfree/feature/style/FeatureScatterChartStyle.java
===================================================================
--- trunk/src/schmitzm/jfree/feature/style/FeatureScatterChartStyle.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/jfree/feature/style/FeatureScatterChartStyle.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -35,8 +35,6 @@
 import org.jfree.data.general.Dataset;
 import org.jfree.data.xy.XYDataset;
 
-import schmitzm.jfree.JFreeChartUtil;
-import schmitzm.jfree.chart.style.ChartStyle;
 import schmitzm.jfree.chart.style.ScatterChartStyle;
 
 /**
@@ -177,7 +175,7 @@
   public JFreeChart applyToFeatureCollection(FeatureCollection fc) {
     // TODO: Check the attribute data and create a CategoryDataset if
     //       a non-numeric column is specified
-    Dataset dataset = JFreeChartUtil.createXYDataset(
+    Dataset dataset = FeatureChartUtil.createXYDataset(
         fc,
         getTitleStyle().getLabel(),
         getAttributeName(0),

Modified: trunk/src/schmitzm/swing/SelectionInputOption.java
===================================================================
--- trunk/src/schmitzm/swing/SelectionInputOption.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/schmitzm/swing/SelectionInputOption.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -29,7 +29,6 @@
  ******************************************************************************/
 package schmitzm.swing;
 
-import java.awt.Component;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
@@ -41,9 +40,7 @@
 import javax.swing.BoxLayout;
 import javax.swing.Icon;
 import javax.swing.JComboBox;
-import javax.swing.JList;
 import javax.swing.JRadioButton;
-import javax.swing.plaf.basic.BasicComboBoxRenderer;
 
 /**
  * Diese Klasse stellt eine Auswahl-Eingabe-Option fuer das {@link MultipleOptionPane}

Modified: trunk/src/skrueger/geotools/MapView.java
===================================================================
--- trunk/src/skrueger/geotools/MapView.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/skrueger/geotools/MapView.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -38,8 +38,6 @@
 import javax.swing.JSplitPane;
 
 import org.apache.log4j.Logger;
-import org.geotools.renderer.lite.StreamingRenderer;
-import org.geotools.renderer.shape.TransitionShapefileRenderer;
 
 import schmitzm.geotools.gui.GeoMapPane;
 import schmitzm.geotools.gui.JMapPane;

Modified: trunk/src/skrueger/geotools/StyledFeatureCollectionInterface.java
===================================================================
--- trunk/src/skrueger/geotools/StyledFeatureCollectionInterface.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/skrueger/geotools/StyledFeatureCollectionInterface.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -29,12 +29,8 @@
  ******************************************************************************/
 package skrueger.geotools;
 
-import java.util.Map;
-
 import org.geotools.feature.FeatureCollection;
 
-import skrueger.AttributeMetaData;
-
 /**
  * {@link StyledLayerInterface} which contains a {@link FeatureCollection} as geo object.<br>
  */

Modified: trunk/src/skrueger/geotools/StyledFeatureSourceInterface.java
===================================================================
--- trunk/src/skrueger/geotools/StyledFeatureSourceInterface.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/skrueger/geotools/StyledFeatureSourceInterface.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -29,12 +29,8 @@
  ******************************************************************************/
 package skrueger.geotools;
 
-import java.util.Map;
-
 import org.geotools.data.FeatureSource;
 
-import skrueger.AttributeMetaData;
-
 /**
  * {@link StyledLayerInterface} which contains a {@link FeatureSource} as geo object.<br>
  */

Modified: trunk/src/skrueger/i8n/SwitchLanguageDialog.java
===================================================================
--- trunk/src/skrueger/i8n/SwitchLanguageDialog.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/skrueger/i8n/SwitchLanguageDialog.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -33,7 +33,6 @@
 import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.Insets;
-import java.awt.Window;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.MouseWheelListener;

Modified: trunk/src/skrueger/i8n/Translation.java
===================================================================
--- trunk/src/skrueger/i8n/Translation.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/skrueger/i8n/Translation.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -37,7 +37,6 @@
 import java.util.Locale;
 
 import javax.swing.JComponent;
-import javax.swing.JTable;
 
 import org.apache.log4j.Logger;
 

Modified: trunk/src/skrueger/swing/TranslationAskJDialog.java
===================================================================
--- trunk/src/skrueger/swing/TranslationAskJDialog.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/skrueger/swing/TranslationAskJDialog.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -38,7 +38,6 @@
 import java.awt.event.KeyEvent;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
-import java.util.Locale;
 
 import javax.swing.AbstractAction;
 import javax.swing.Action;
@@ -52,9 +51,6 @@
 import javax.swing.JRootPane;
 import javax.swing.KeyStroke;
 
-import schmitzm.geotools.styling.StylingUtil;
-import schmitzm.lang.LangUtil;
-import schmitzm.lang.ResourceProvider;
 import schmitzm.swing.SwingUtil;
 import skrueger.i8n.Translation;
 

Modified: trunk/src/skrueger/swing/TranslationEditJPanel.java
===================================================================
--- trunk/src/skrueger/swing/TranslationEditJPanel.java	2009-07-31 16:50:12 UTC (rev 260)
+++ trunk/src/skrueger/swing/TranslationEditJPanel.java	2009-07-31 17:05:18 UTC (rev 261)
@@ -30,13 +30,11 @@
 package skrueger.swing;
 
 import java.awt.BorderLayout;
-import java.awt.Container;
 import java.awt.Dimension;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.KeyEvent;
 import java.awt.event.KeyListener;
-import java.beans.PropertyChangeListener;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;



More information about the Schmitzm-commits mailing list