schmitzm.jfree.feature.style
Class FeatureChartUtil

java.lang.Object
  extended by schmitzm.jfree.feature.style.FeatureChartUtil

public class FeatureChartUtil
extends Object

This class contains static utility methods related to chart styles based on FeatureCollection.

Version:
1.0
Author:
Martin Schmitz

Field Summary
static FeatureChartStyleXMLFactory FEATURE_CHART_STYLE_FACTORY
          Instance of ChartStyleXMLFactory.
 
Constructor Summary
FeatureChartUtil()
           
 
Method Summary
static HashMap<String,StaticBin1D> calcStatisticsForNormalization( fc, FeatureChartStyle chartStyle)
          Calculates statistics needed to normalize data.
static boolean correctAttributeNames(FeatureChartStyle featureChartStyle, SimpleFeatureType schema)
          After loading from XML, a FeatureChartStyle contains whatever is written in the XML.
static DefaultCategoryDataset createCategoryDataset( fc, FeatureChartStyle chartStyle)
          Creates a XYDataset for 2 (or more) attributes of a FeatureCollection.
static Dataset createDataset( fc, FeatureChartStyle style)
          Creates a Dataset for 1 or more attributes of a FeatureCollection.
static XYSeriesCollection createXYDataset( fc, FeatureChartStyle chartStyle)
          Creates a XYDataset for 2 (or more) attributes of a FeatureCollection.
static List<FeatureDatasetSelectionModel<?,?,?>> getFeatureDatasetSelectionModelFor(JFreeChart chart)
          Returns all DatasetSelectionModels that can be reached via the renderers of a chart.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FEATURE_CHART_STYLE_FACTORY

public static final FeatureChartStyleXMLFactory FEATURE_CHART_STYLE_FACTORY
Instance of ChartStyleXMLFactory.

Constructor Detail

FeatureChartUtil

public FeatureChartUtil()
Method Detail

getFeatureDatasetSelectionModelFor

public static List<FeatureDatasetSelectionModel<?,?,?>> getFeatureDatasetSelectionModelFor(JFreeChart chart)
Returns all DatasetSelectionModels that can be reached via the renderers of a chart.

Parameters:
chart - a chart

createDataset

public static Dataset createDataset( fc,
                                    FeatureChartStyle style)
Creates a Dataset for 1 or more attributes of a FeatureCollection. According to the feature attribute type the method decides whether a XYDataset or a CategoryDataset is created:
In case of an non-numeric X attribute a CategoryDataset is created always. Otherwise the default is to create a XYDataset. The flag forceCat can be used to create CategoryDataset for numeric X attributes.

Parameters:
fc - a FeatureCollection
forceCat - forces a CategoryDataset also for numeric X attributes
sort - sorts the features according to xAttr before creating the dataset
xAttr - feature attribute used for the X-value
yAttr - feature attribute(s) used for the Y-value (at least one; for each a series is created in the dataset)

createXYDataset

public static XYSeriesCollection createXYDataset( fc,
                                                 FeatureChartStyle chartStyle)
Creates a XYDataset for 2 (or more) attributes of a FeatureCollection. XYDateset can only be created for numeric attributes.

Parameters:
fc - a FeatureCollection
style - defines the attributes used to create the dataset from, as well as the sorting and normalization properties
Throws:
IllegalArgumentException - if less then 2 attributes are specified
UnsupportedOperationException - if attributes are not numeric

calcStatisticsForNormalization

public static HashMap<String,StaticBin1D> calcStatisticsForNormalization( fc,
                                                                         FeatureChartStyle chartStyle)
Calculates statistics needed to normalize data. If normalization is not used, this function returns an empty map.

Parameters:
fc - FeatureCollection where the data comes from
chartStyle - ChartStyle to determine which attributes shall be normalized.

createCategoryDataset

public static DefaultCategoryDataset createCategoryDataset( fc,
                                                           FeatureChartStyle chartStyle)
Creates a XYDataset for 2 (or more) attributes of a FeatureCollection. XYDateset can only be created for numeric attributes.

Parameters:
fc - a FeatureCollection
style - defines the attributes used to create the dataset from, as well as the sorting and normalization properties
Throws:
IllegalArgumentException - if less then 2 attributes are specified
UnsupportedOperationException - if attributes are not numeric

correctAttributeNames

public static boolean correctAttributeNames(FeatureChartStyle featureChartStyle,
                                            SimpleFeatureType schema)
After loading from XML, a FeatureChartStyle contains whatever is written in the XML. But the DBF Schema can change quickly by accident! This method checks an FeatureChartStyle against a schema and corrects upperCase/lowerCase problems where possible. Returns false if attributes had to be removed from the FeatureChartStyle.