[Schmitzm-commits] r1076 - in trunk: src/schmitzm/jfree/feature/style src_junit/schmitzm/jfree/feature/style
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Oct 5 12:07:50 CEST 2010
Author: mojays
Date: 2010-10-05 12:07:49 +0200 (Tue, 05 Oct 2010)
New Revision: 1076
Modified:
trunk/src/schmitzm/jfree/feature/style/FeatureChartStyle.java
trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java
Log:
FeatureChartStyle.Dummy: copyTo-methods overwritten (empty) to avoid unintended interaction with superclass method
FeatureChartStyleTest: test for copy of FeatureBasicChartStyle and test for copy of FeatureScatterChartStyle
Modified: trunk/src/schmitzm/jfree/feature/style/FeatureChartStyle.java
===================================================================
--- trunk/src/schmitzm/jfree/feature/style/FeatureChartStyle.java 2010-10-05 09:03:30 UTC (rev 1075)
+++ trunk/src/schmitzm/jfree/feature/style/FeatureChartStyle.java 2010-10-05 10:07:49 UTC (rev 1076)
@@ -35,6 +35,7 @@
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
+import schmitzm.jfree.chart.style.AbstractChartStyle;
import schmitzm.jfree.chart.style.ChartStyle;
import schmitzm.jfree.table.style.TableChartStyle;
@@ -45,309 +46,6 @@
* @version 1.0
*/
public interface FeatureChartStyle extends TableChartStyle<FeatureCollection<SimpleFeatureType, SimpleFeature>> {
-//
-// /**
-// * Returns the maximum number of feature attributes that can be specified by
-// * this style.
-// * @return -1 if there is no limit for range attributes
-// */
-// public int getMaxAttributeCount();
-//
-// /**
-// * Returns the number of feature attributes defined in this style.
-// */
-// public int getAttributeCount();
-//
-// /**
-// * Removes all style informations about an attribute and reorganizes the
-// * attribute indexes so there is an continuous order.
-// * @param idx an attribute index
-// */
-// public void removeAttribute(int idx);
-//
-// /**
-// * Returns the name of a feature attribute needed to create a chart for this
-// * style.
-// * @param idx attribute index (0=domain; 1=1st range series; 2=2nd range
-// * series; ...)
-// */
-// public String getAttributeName(int idx);
-//
-// /**
-// * Sets the name of a feature attribute needed to create a chart for this
-// * style.
-// * @see #setNoDataValues(idx, Set) to set NoDataValues for this attribute.
-// * @param idx attribute index (0=domain; 1=1st range series; 2=2nd range
-// * series; ...)
-// * @param attrName feature attribute name
-// */
-// public void setAttributeName(int idx, String attrName);
-//
-// /**
-// * Sets whether the features are sorted according to the domain attribute
-// * (before creating a {@link Dataset}).
-// */
-// public void setSortDomainAxis(boolean sort);
-//
-// /**
-// * Returns whether the features are sorted according to the domain attribute
-// * (before creating a {@link Dataset}).
-// * @return {@code false} as default
-// */
-// public boolean isSortDomainAxis();
-//
-// /**
-// * Sets whether a {@link CategoryDataset} is forced for a numeric domain
-// * attribute. The default is to create {@link XYDataset} for a numeric and
-// * {@link CategoryDataset} for a non-numeric domain attribute.
-// */
-// public void setForceCategories(boolean forceCategories);
-//
-// /**
-// * Returns whether a {@link CategoryDataset} is forced for a numeric domain
-// * attribute. The default is to create {@link XYDataset} for a numeric and
-// * {@link CategoryDataset} for a non-numeric domain attribute.
-// * @return {@code false} as default
-// */
-// public boolean isForceCategories();
-//
-// /**
-// * Sets whether the attribute data is normalized for an attribute (before
-// * creating a {@link Dataset}).
-// * @param idx attribute index (0=domain; 1=1st range series; 2=2nd range
-// * series; ...)
-// * @param normalize indicates the normalize property
-// */
-// public void setAttributeNormalized(int idx, Boolean normalize);
-//
-// /**
-// * Returns whether the attribute data is normalized for an attribute (before
-// * creating a {@link Dataset}).
-// * @param idx attribute index (0=domain; 1=1st range series; 2=2nd range
-// * series; ...)
-// * @return {@code false} as default
-// */
-// public boolean isAttributeNormalized(int idx);
-//
-// /**
-// * Sets an arithmetical function which is calculated on the attribute values
-// * (when creating a {@link Dataset} from Features). The function is calculated
-// * on all values with the same domain value (X/category). If no function is
-// * set, duplicate domain values are ignored (only the "last" value is shown,
-// * because of replacement behavior).
-// * @param idx attribute index (1=1st range series; 2=2nd range series; ...)
-// * @param func defines the calculated function
-// * @exception IllegalArgumentException if function is set on domain attribute
-// * (0)
-// */
-// public void setAttributeAggregation(int idx, AggregationFunction func);
-//
-// /**
-// * Returns an arithmetical function which is calculated on the attribute
-// * values (when creating a {@link Dataset} from Features). The function is
-// * calculated on all values with the same domain value (X/category). If no
-// * function is set, duplicate domain values are ignored (only the "last" value
-// * is shown, because of replacement behavior).
-// * @param idx attribute index (1=1st range series; 2=2nd range series; ...)
-// * @return {@code null} for index 0 (domain axis)
-// */
-// public AggregationFunction getAttributeAggregation(int idx);
-//
-// /**
-// * Sets the values, which are interpreted as "No Data".
-// * @param idx attribute index the "No Data" values are set for
-// * @param noDataValues the "No Data" values
-// */
-// public void setNoDataValues(int idx, Set<Object> noDataValues);
-//
-// /**
-// * Returns the values, which are interpreted as "No Data".
-// * @param idx attribute index the "No Data" values are returned for
-// */
-// public Set<Object> getNoDataValues(int idx);
-//
-// /**
-// * Sets a value, which is interpreted as "No Data".
-// * @param idx attribute index the "No Data" value is set for
-// * @param noDataValue the "No Data" value
-// */
-// public void addNoDataValue(int idx, Object noDataValue);
-//
-// /**
-// * Removes a "No Data" value for an attribute.
-// * @param idx attribute index the "No Data" value is removed for
-// * @param noDataValue the "No Data" value to remove
-// * @return {@code false} if the value was not an "No Data" value
-// */
-// public boolean removeNoDataValue(int idx, Object noDataValue);
-//
-// /**
-// * Checks whether the given value is one of the "No data" values for the
-// * attribute.
-// * @param idx attribute index the "No Data" value is checked for
-// * @param value an attribute value
-// */
-// public boolean isNoDataValue(int idx, Object value);
-//
-// /**
-// * Checks whether the given value is one of the "No data" values for the
-// * attribute. In this case this method returns {@code null}, otherwise the
-// * value itself.
-// * @param idx attribute index the "No Data" value is checked for
-// * @param value an attribute value
-// * @return {@code null} if the given value is one of the "No data" values
-// */
-// public <T> T filterNoDataValue(int idx, T value);
-//
-// /**
-// * Sets the feature attribute the i-th chart attribute is weighted with.<br>
-// * <b>Note:</b>
-// * <ul>
-// * <li>The weight attribute can not be set for the domain attribute 0.</li>
-// * <li>Do not forget to set the NULL values for the weight attributes, too!</li>
-// * </ul>
-// * @param idx the feature attribute
-// * @param weightAttribName name of the weight attribute
-// * @see #setWeightAttributeNoDataValues(idx, Set) to set NoDataValues for this
-// * attribute.<br/>
-// * @exception IllegalArgumentException if weight attribute is set for
-// * attribute 0
-// **/
-// public void setAttributeAggregationWeightAttributeName(int idx,
-// String weightAttribName);
-//
-// /**
-// * Returns the feature attribute the i-th chart attribute is weighted with.
-// * <b>Note:</b><br>
-// * This method returns {@code null} unless a
-// * {@linkplain AggregationFunction#isWeighted() weighted} aggregation function
-// * is set for the i-th attribute.
-// * @param idx the feature attribute
-// * @see #setAttributeAggregationWeightAttributeName(int, String)
-// **/
-// public String getAttributeAggregationWeightAttributeName(int idx);
-//
-// /**
-// * Sets the values, which are interpreted as "No Data" for the optional weight
-// * attribute.
-// * @param idx weight attribute index the "No Data" values are set for
-// * @param noDataValues the "No Data" values
-// */
-// public void setWeightAttributeNoDataValues(int idx, Set<Object> noDataValues);
-//
-// /**
-// * Returns the values, which are interpreted as "No Data" for the
-// * weight attribute.
-// * @param idx weight attribute index the "No Data" values are returned for
-// */
-// public Set<Object> getWeightAttributeNoDataValues(int idx);
-//
-// /**
-// * Sets a value, which is interpreted as "No Data" for the weight
-// * attribute.
-// * @param idx attribute index the "No Data" value is set for
-// * @param noDataValue the "No Data" value
-// */
-// public void addWeightAttributeNoDataValue(int idx, Object noDataValue);
-//
-// /**
-// * Removes a "No Data" value for a weight attribute.
-// * @param idx attribute index the "No Data" value is removed for
-// * @param noDataValue the "No Data" value to remove
-// * @return {@code false} if the value was not an "No Data" value
-// */
-// public boolean removeWeightAttributeNoDataValue(int idx, Object noDataValue);
-//
-// /**
-// * Checks whether the given value is one of the "No data" values for the
-// * weight attribute.
-// * @param idx weight attribute index the "No Data" value is checked for
-// * @param value an attribute value
-// * @return {@code false} is not weight attribute is set for attribute i
-// * @see #setAttributeAggregationWeightAttributeName(int, String)
-// */
-// public boolean isWeightAttributeNoDataValue(int idx, Object value);
-//
-// /**
-// * Checks whether the given value is one of the "No data" values for the
-// * attribute. In this case this method returns {@code null}, otherwise the
-// * value itself.
-// * @param idx attribute index the "No Data" value is checked for
-// * @param value an attribute value
-// * @return {@code null} if the given value is one of the "No data" values
-// */
-// public <T> T filterWeightAttributeNoDataValue(int idx, T value);
-//
-// /**
-// * Defines the attribute whose values are used to define
-// * groups. For each group value a series is created in the chart
-// * dataset.
-// * @param attrName feature attribute name
-// */
-// public void setSeriesAttributeName(String attrName);
-//
-// /**
-// * Returns the attribute whose values are used to define
-// * groups. For each group value a series is created in the chart
-// * dataset.
-// */
-// public String getSeriesAttributeName();
-//
-// /**
-// * Sets the values, which are interpreted as "No Data" for the
-// * series attribute.
-// * @param noDataValues the "No Data" values
-// */
-// public void setSeriesAttributeNoDataValues(Set<Object> noDataValues);
-//
-// /**
-// * Returns the values, which are interpreted as "No Data" for the
-// * series attribute.
-// */
-// public Set<Object> getSeriesAttributeNoDataValues();
-//
-// /**
-// * Sets a value, which is interpreted as "No Data" for the
-// * series attribute.
-// * @param noDataValue the "No Data" value
-// */
-// public void addSeriesAttributeNoDataValue(Object noDataValue);
-//
-// /**
-// * Removes a "No Data" value for the series attribute.
-// * @param noDataValue the "No Data" value to remove
-// * @return {@code false} if the value was not an "No Data" value
-// */
-// public boolean removeSeriesAttributeNoDataValue(Object noDataValue);
-//
-// /**
-// * Checks whether the given value is one of the "No data" values for the
-// * series attribute.
-// * @param value an attribute value
-// */
-// public boolean isSeriesAttributeNoDataValue(Object value);
-//
-// /**
-// * Checks whether the given value is one of the "No data" values for the
-// * series attribute. In this case this method returns {@code null}, otherwise the
-// * value itself.
-// * @param value an attribute value
-// * @return {@code null} if the given value is one of the "No data" values
-// */
-// public <T> T filterSeriesAttributeNoDataValue(T value);
-//
-// /**
-// * Defines the attribute whose values are used to define the legend
-// * title for the series defined by {@link #setSeriesAttributeName(String)}.
-// * @param attrName feature attribute name
-// */
-// public void setSeriesLegendTitleAttributeName(String attrName);
-//
-// /**
-// * Returns the attribute whose values are used to define the legend
-// * title for the series defined by {@link #setSeriesAttributeName(String)}.
-// */
-// public String getSeriesLegendTitleAttributeName();
/**
* Creates a chart according to the given feature collection.
@@ -374,73 +72,7 @@
* @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
*/
public static class Dummy extends TableChartStyle.Dummy<FeatureCollection<SimpleFeatureType, SimpleFeature>> implements FeatureChartStyle {
-// /**
-// * Indicates whether the features are sorted according to the domain
-// * attribute (before creating a {@link Dataset}).
-// */
-// protected boolean sortDomainAxis;
-// /**
-// * Indicates whether a {@link CategoryDataset} is forced for a numeric
-// * domain attribute. The default is to create {@link XYDataset} for a
-// * numeric and {@link CategoryDataset} for a non-numeric domain attribute.
-// */
-// protected boolean forceCategories;
-//
-// /**
-// * Holds the attributes needed to specify the chart data from feature
-// * collection (0 = attribute for domain axis; others assigned to the range
-// * axis as series).
-// */
-// protected Map<Integer, String> attrNames = new HashMap<Integer, String>();
-//
-// /**
-// * Indicates for each attribute whether the attribute data is normalized
-// * (before creating a {@link Dataset}).
-// */
-// protected Map<Integer, Boolean> normalizeAttr = new HashMap<Integer, Boolean>();
-//
-// /**
-// * Holds the maximum number of attributes the style can be defined defined
-// * for (-1 = no limit).
-// */
-// protected int maxAttrCount = -1;
-//
-// /** Holds the number of attributes the style is defined for. */
-// protected int maxAttrIdx = 0;
-//
-// /** Holds the "No Data" values for each attribute. */
-// protected Map<Integer, Set<Object>> noDataValues = new HashMap<Integer, Set<Object>>();
-//
-// /** Holds the aggregation function for each attribute. */
-// protected Map<Integer, AggregationFunction> aggrFuncs = new HashMap<Integer, AggregationFunction>();
-//
-// /**
-// * Holds the weight attributes needed to weight the attribute values of
-// * {@link #attrNames} if a {@linkplain AggregationFunction#isWeighted()
-// * weighted} aggregation function is set.
-// */
-// protected Map<Integer, String> weightAttrNames = new HashMap<Integer, String>();
-//
-// /** Holds the "No Data" values for each weight attribute. */
-// protected Map<Integer, Set<Object>> weightAttrNoDataValues = new HashMap<Integer, Set<Object>>();
-//
-//
-// /**
-// * Holds the attribute name of the series attribute, whose values are
-// * used to define groups. For each group a series is created in the
-// * dataset.
-// */
-// protected String seriesAttrName = null;
-//
-// /** Holds the "No Data" values for the series attribute. */
-// protected Set<Object> seriesAttrNoDataValues = new HashSet<Object>();
-//
-// /**
-// * Holds the name of the attribute, whose values define the legend
-// * title for the series defined by {@link #seriesAttrName}.
-// */
-// protected String seriesLegendTitleAttrName = null;
-//
+
/**
* Creates a new dummy. This constructor is protected so that only derived
* classes can instantiate a dummy! There is no limit for the number of
@@ -462,587 +94,42 @@
super(id, maxAttrCount);
}
-// /**
-// * Updates the local variable for the number of attributes the maximum index
-// * (key) of the several hash maps.
-// */
-// private void updateAttributeCount() {
-// maxAttrIdx = LangUtil.max(attrNames.keySet(),
-// normalizeAttr.keySet(),
-// noDataValues.keySet(),
-// aggrFuncs.keySet(),
-// weightAttrNames.keySet(),
-// weightAttrNoDataValues.keySet()
-// );
-//
-// if (maxAttrCount > 0 && maxAttrIdx >= maxAttrCount)
-// throw new IllegalArgumentException("Only " + maxAttrCount +
-// " attributes can be specified for " +
-// LangUtil.getSimpleClassName(this));
-// }
-//
-// /**
-// * Removes all style informations about an attribute and reorganizes the
-// * attribute indexes so there is an continuous order.
-// * @param idx an attribute
-// */
-// @Override
-// public void removeAttribute(int idx) {
-// // clear sets and maps of the removed attribute
-// Set<Object> noDataValues = getNoDataValues(idx);
-// if (noDataValues != null)
-// noDataValues.clear();
-//
-// // remove the attribute by move the "greater" attributes
-// // one position "forward"
-// int maxIdx = getAttributeCount() - 1;
-// for (int i = idx; i < maxIdx; i++) {
-// this.attrNames.put(i, this.attrNames.get(i + 1));
-// this.normalizeAttr.put(i, this.normalizeAttr.get(i + 1));
-// this.noDataValues.put(i, this.noDataValues.get(i + 1));
-// }
-//
-// // delete the last attribute, because now is is stored
-// // one position forward
-// this.attrNames.remove(maxIdx);
-// this.normalizeAttr.remove(maxIdx);
-// this.noDataValues.remove(maxIdx);
-//
-// updateAttributeCount();
-// }
-//
-// /**
-// * Creates a (deep) clone of this style. The properties of the super class (
-// * {@link AbstractChartStyle}) are <b>ignored</b> because they are unused
-// * for the dummy.
-// */
-// @Override
-// public AbstractChartStyle copy() {
-// return (AbstractChartStyle) copyTo((FeatureChartStyle) new Dummy(""));
-// }
-//
-// /**
-// * Copies all properties of this style to another one. The properties of the
-// * super class ({@link AbstractChartStyle}) are <b>ignored</b> because they
-// * are unused for the dummy.
-// * @param dest destination object (if {@code null} the copy is created by
-// * {@link #copy()})
-// * @return {@code dest} or the new instance
-// */
-// @Override
-// public ChartStyle copyTo(ChartStyle dest) {
-// // !! do NOT copy the super class properties !!
-// // !! copy only this classes properties !!
-// // !! Reason: the dummy does not maintain the !!
-// // !! super class properties and we !!
-// // !! do not want to overwrite them !!
-// if (dest instanceof FeatureChartStyle) {
-// FeatureChartStyle destFCS = (FeatureChartStyle) dest;
-// destFCS.setSortDomainAxis(isSortDomainAxis());
-// destFCS.setForceCategories(isForceCategories());
-//
-// // Clear the attribute names, normalization, aggregation,
-// // etc.
-// // NOTE: The no data value set must NOT be cleared deep,
-// // because these sets may originate from somewhere else!
-// // So only the hash entry is set to NULL.
-// int max = destFCS.getMaxAttributeCount();
-// for (int i = 0; i < max; i++) {
-// destFCS.setAttributeName(i, null);
-// destFCS.setAttributeNormalized(i, null);
-// destFCS.setAttributeAggregation(i, null);
-// destFCS.setAttributeAggregationWeightAttributeName(i, null);
-// destFCS.setNoDataValues(i, null);
-// destFCS.setWeightAttributeNoDataValues(i, null);
-// }
-//
-// // Copy attribute names, normalization, aggregation, etc.
-// for (Integer idx : attrNames.keySet())
-// if (getAttributeName(idx) != null)
-// destFCS.setAttributeName(idx, getAttributeName(idx));
-// for (Integer idx : normalizeAttr.keySet())
-// if (isAttributeNormalized(idx))
-// destFCS.setAttributeNormalized(idx, isAttributeNormalized(idx));
-// for (Integer idx : aggrFuncs.keySet())
-// destFCS.setAttributeAggregation(idx, getAttributeAggregation(idx));
-// for (Integer idx : weightAttrNames.keySet())
-// destFCS.setAttributeAggregationWeightAttributeName(idx, getAttributeAggregationWeightAttributeName(idx));
-//
-// // The nodata value set are not copies deep, because these
-// // sets may originate from somewhere else, so the only
-// // are "redirected".
-// for (Integer idx : noDataValues.keySet())
-// destFCS.setNoDataValues(idx, getNoDataValues(idx));
-// for (Integer idx : weightAttrNoDataValues.keySet())
-// destFCS.setNoDataValues(idx, getWeightAttributeNoDataValues(idx));
-// }
-//
-// return dest;
-// }
-//
-// /**
-// * Returns the maximum number of feature attributes that can be specified by
-// * this style.
-// * @return -1 if there is no limit for range attributes
-// */
-// @Override
-// public int getMaxAttributeCount() {
-// return maxAttrCount;
-// }
-//
-// /**
-// * Returns the number of feature attributes defined in this style.
-// */
-// @Override
-// public int getAttributeCount() {
-// return maxAttrIdx + 1;
-// }
-//
-// /**
-// * Returns the name of a feature attribute needed to create a chart for this
-// * style.
-// * @param idx attribute index (0=domain; 1=1st range series; 2=2nd range
-// * series; ...)
-// */
-// @Override
-// public String getAttributeName(int idx) {
-// return attrNames.get(idx);
-// }
-//
-// /**
-// * Sets the name of a feature attribute needed to create a chart for this
-// * style.
-// * @param idx attribute index (0=domain; 1=1st range series; 2=2nd range
-// * series; ...)
-// * @param attrName feature attribute name
-// */
-// @Override
-// public void setAttributeName(int idx, String attrName) {
-// attrNames.put(idx, attrName);
-// updateAttributeCount();
-// }
-//
-// /**
-// * Sets whether the features are sorted according to the domain attribute
-// * (before creating a {@link Dataset}).
-// */
-// @Override
-// public void setSortDomainAxis(boolean sortDomainAxis) {
-// this.sortDomainAxis = sortDomainAxis;
-// }
-//
-// /**
-// * Returns whether the features are sorted according to the domain attribute
-// * (before creating a {@link Dataset}).
-// * @return {@code false} as default
-// */
-// @Override
-// public boolean isSortDomainAxis() {
-// return sortDomainAxis;
-// }
-//
-// /**
-// * Sets whether a {@link CategoryDataset} is forced for a numeric domain
-// * attribute. The default is to create {@link XYDataset} for a numeric and
-// * {@link CategoryDataset} for a non-numeric domain attribute.
-// */
-// @Override
-// public void setForceCategories(boolean forceCategories) {
-// this.forceCategories = forceCategories;
-// }
-//
-// /**
-// * Returns whether a {@link CategoryDataset} is forced for a numeric domain
-// * attribute. The default is to create {@link XYDataset} for a numeric and
-// * {@link CategoryDataset} for a non-numeric domain attribute.
-// * @return {@code false} as default
-// */
-// @Override
-// public boolean isForceCategories() {
-// return forceCategories;
-// }
-//
-// /**
-// * Sets whether the attribute data is normalized for an attribute (before
-// * creating a {@link Dataset}).
-// * @param idx attribute index (0=domain; 1=1st range series; 2=2nd range
-// * series; ...)
-// * @param normalize indicates the normalize property
-// */
-// @Override
-// public void setAttributeNormalized(int idx, Boolean normalize) {
-// normalizeAttr.put(idx, normalize);
-// updateAttributeCount();
-// }
-//
-// /**
-// * Returns whether the attribute data is normalized for an attribute (before
-// * creating a {@link Dataset}).
-// * @param idx attribute index (0=domain; 1=1st range series; 2=2nd range
-// * series; ...)
-// * @return {@code false} as default
-// */
-// @Override
-// public boolean isAttributeNormalized(int idx) {
-// Boolean normalize = normalizeAttr.get(idx);
-// return normalize != null && normalize;
-// }
-//
-// /**
-// * Sets an arithmetical function which is calculated on the attribute values
-// * (when creating a {@link Dataset} from Features). The function is
-// * calculated on all values with the same domain value (X/category). If no
-// * function is set, duplicate domain values are ignored (only the "last"
-// * value is shown, because of replacement behavior).
-// * @param idx attribute index (1=1st range series; 2=2nd range series; ...)
-// * @param func defines the calculated function
-// * @exception IllegalArgumentException if function is set on domain
-// * attribute (0)
-// */
-// @Override
-// public void setAttributeAggregation(int idx, AggregationFunction func) {
-// if (idx == 0 && func != null)
-// throw new IllegalArgumentException(
-// "Aggregation function not allowed for attribute 0 (domain attribute)!");
-// aggrFuncs.put(idx, func);
-// }
-//
-// /**
-// * Returns an arithmetical function which is calculated on the attribute
-// * values (when creating a {@link Dataset} from Features). The function is
-// * calculated on all values with the same domain value (X/category). If no
-// * function is set, duplicate domain values are ignored (only the "last"
-// * value is shown, because of replacement behavior).
-// * @param idx attribute index (1=1st range series; 2=2nd range series; ...)
-// * @return {@code null} for index 0 (domain axis)
-// */
-// @Override
-// public AggregationFunction getAttributeAggregation(int idx) {
-// if (idx == 0)
-// return null;
-// return aggrFuncs.get(idx);
-// }
-//
-// /**
-// * Sets the values, which are interpreted as "No Data".
-// * @param idx attribute index the "No Data" values are set for
-// * @param noDataValues the "No Data" values
-// */
-// public void setNoDataValues(int idx, Set<Object> noDataValues) {
-// this.noDataValues.put(idx, noDataValues);
-// updateAttributeCount();
-// }
-//
-// /**
-// * Returns the values, which are interpreted as "No Data".
-// * @param idx attribute index the "No Data" values are returned for
-// */
-// public Set<Object> getNoDataValues(int idx) {
-// return this.noDataValues.get(idx);
-// }
-//
-// /**
-// * Sets a value, which is interpreted as "No Data".
-// * @param idx attribute index the "No Data" value is set for
-// * @param noDataValue the "No Data" value
-// */
-// public void addNoDataValue(int idx, Object noDataValue) {
-// Set<Object> noDataValues = getNoDataValues(idx);
-// if (noDataValues == null) {
-// noDataValues = new HashSet<Object>();
-// setNoDataValues(idx, noDataValues);
-// }
-// noDataValues.add(noDataValue);
-// }
-//
-// /**
-// * Removes a "No Data" value for an attribute.
-// * @param idx attribute index the "No Data" value is removed for
-// * @param noDataValue the "No Data" value to remove
-// * @return {@code false} if the value was not an "No Data" value
-// */
-// public boolean removeNoDataValue(int idx, Object noDataValue) {
-// Set<Object> noDataValues = getNoDataValues(idx);
-// if (noDataValues == null)
-// return false;
-// return noDataValues.remove(noDataValue);
-// }
-//
-// /**
-// * Checks whether the given value is one of the "No data" values for the
-// * attribute.
-// * @param idx attribute index the "No Data" value is checked for
-// * @param value an attribute value
-// */
-// public boolean isNoDataValue(int idx, Object value) {
-// Set<Object> noDataValues = getNoDataValues(idx);
-// if (noDataValues == null)
-// return false;
-// return noDataValues.contains(value);
-// }
-//
-// /**
-// * Checks whether the given value is one of the "No data" values for the
-// * attribute. In this case this method returns {@code null}, otherwise the
-// * value itself.
-// * @param idx attribute index the "No Data" value is checked for
-// * @param value an attribute value
-// * @return {@code null} if the given value is one of the "No data" values
-// */
-// public <T> T filterNoDataValue(int idx, T value) {
-// if (isNoDataValue(idx, value))
-// return null;
-// return value;
-// }
-//
-// /**
-// * Sets the feature attribute the i-th chart attribute is weighted with.<br>
-// * <b>Note:</b>
-// * <ul>
-// * <li>The weight attribute can not be set for the domain attribute 0.</li>
-// * <li>Do not forget to set the NULL values for the weight attributes, too!</li>
-// * </ul>
-// * @param idx the feature attribute
-// * @param weightAttrName name of the weight attribute
-// * @see #setWeightAttributeNoDataValues(idx, Set) to set NoDataValues for this
-// * attribute.<br/>
-// * @exception IllegalArgumentException if weight attribute is set for
-// * attribute 0
-// **/
-// @Override
-// public void setAttributeAggregationWeightAttributeName(int idx,
-// String weightAttrName) {
-// if (idx == 0 && weightAttrName != null)
-// throw new IllegalArgumentException(
-// "Weight attribute not allowed for attribute 0 because aggregation function not allowed for domain attribute!");
-// weightAttrNames.put(idx, weightAttrName);
-// }
-//
-// /**
-// * Returns the feature attribute the i-th chart attribute is weighted with.
-// * <b>Note:</b><br>
-// * This method returns {@code null} unless a
-// * {@linkplain AggregationFunction#isWeighted() weighted} aggregation
-// * function is set for the i-th attribute.
-// * @param idx the feature attribute
-// * @see #setAttributeAggregationWeightAttributeName(int, String)
-// **/
-// @Override
-// public String getAttributeAggregationWeightAttributeName(int idx) {
-// AggregationFunction af = getAttributeAggregation(idx);
-// if (af == null || !af.isWeighted() || idx == 0)
-// return null;
-// return weightAttrNames.get(idx);
-// }
-//
-// /**
-// * Sets the values, which are interpreted as "No Data" for the optional weight
-// * attribute.
-// * @param idx weight attribute index the "No Data" values are set for
-// * @param noDataValues the "No Data" values
-// */
-// @Override
-// public void setWeightAttributeNoDataValues(int idx, Set<Object> noDataValues) {
-// if (idx == 0 && noDataValues != null)
-// throw new IllegalArgumentException(
-// "Weight attribute not allowed for attribute 0 because aggregation function not allowed for domain attribute!");
-// weightAttrNoDataValues.put(idx, noDataValues);
-// }
-//
-// /**
-// * Returns the values, which are interpreted as "No Data" for the
-// * weight attribute.
-// * @param idx weight attribute index the "No Data" values are returned for
-// */
-// @Override
-// public Set<Object> getWeightAttributeNoDataValues(int idx) {
-// return weightAttrNoDataValues.get(idx);
-// }
-//
-// /**
-// * Sets a value, which is interpreted as "No Data" for the weight
-// * attribute.
-// * @param idx attribute index the "No Data" value is set for
-// * @param noDataValue the "No Data" value
-// */
-// @Override
-// public void addWeightAttributeNoDataValue(int idx, Object noDataValue) {
-// Set<Object> noDataValues = getWeightAttributeNoDataValues(idx);
-// if (noDataValues == null) {
-// noDataValues = new HashSet<Object>();
-// setWeightAttributeNoDataValues(idx, noDataValues);
-// }
-// noDataValues.add(noDataValue);
-// }
-//
-// /**
-// * Removes a "No Data" value for a weight attribute.
-// * @param idx attribute index the "No Data" value is removed for
-// * @param noDataValue the "No Data" value to remove
-// * @return {@code false} if the value was not an "No Data" value
-// */
-// @Override
-// public boolean removeWeightAttributeNoDataValue(int idx, Object noDataValue) {
-// Set<Object> noDataValues = getWeightAttributeNoDataValues(idx);
-// if (noDataValues == null)
-// return false;
-// return noDataValues.remove(noDataValue);
-// }
-//
-// /**
-// * Checks whether the given value is one of the "No data" values for the
-// * weight attribute.
-// * @param idx weight attribute index the "No Data" value is checked for
-// * @param value an attribute value
-// * @return {@code false} is not weight attribute is set for attribute i
-// * @see #setAttributeAggregationWeightAttributeName(int, String)
-// */
-// @Override
-// public boolean isWeightAttributeNoDataValue(int idx, Object value) {
-// Set<Object> noDataValues = getWeightAttributeNoDataValues(idx);
-// if (noDataValues == null)
-// return false;
-// return noDataValues.contains(value);
-// }
-//
-// /**
-// * Checks whether the given value is one of the "No data" values for the
-// * attribute. In this case this method returns {@code null}, otherwise the
-// * value itself.
-// * @param idx attribute index the "No Data" value is checked for
-// * @param value an attribute value
-// * @return {@code null} if the given value is one of the "No data" values
-// */
-// @Override
-// public <T> T filterWeightAttributeNoDataValue(int idx, T value) {
-// if (isWeightAttributeNoDataValue(idx, value))
-// return null;
-// return value;
-// }
-//
-// /**
-// * Defines the attribute whose values are used to define
-// * groups. For each group value a series is created in the chart
-// * dataset.
-// * @param attrName feature attribute name
-// */
-// @Override
-// public void setSeriesAttributeName(String attrName) {
-// this.seriesAttrName = attrName;
-// }
-//
-// /**
-// * Returns the attribute whose values are used to define
-// * groups. For each group value a series is created in the chart
-// * dataset.
-// */
-// @Override
-// public String getSeriesAttributeName() {
-// return seriesAttrName;
-// }
-//
-// /**
-// * Sets the values, which are interpreted as "No Data" for the
-// * series attribute.
-// * @param noDataValues the "No Data" values
-// */
-// @Override
-// public void setSeriesAttributeNoDataValues(Set<Object> noDataValues) {
-// seriesAttrNoDataValues = noDataValues;
-// }
-//
-// /**
-// * Returns the values, which are interpreted as "No Data" for the
-// * series attribute.
-// */
-// @Override
-// public Set<Object> getSeriesAttributeNoDataValues() {
-// return this.seriesAttrNoDataValues;
-// }
-//
-// /**
-// * Sets a value, which is interpreted as "No Data" for the
-// * series attribute.
-// * @param noDataValue the "No Data" value
-// */
-// @Override
-// public void addSeriesAttributeNoDataValue(Object noDataValue) {
-// Set<Object> noDataValues = getSeriesAttributeNoDataValues();
-// if (noDataValues == null) {
-// noDataValues = new HashSet<Object>();
-// setSeriesAttributeNoDataValues(noDataValues);
-// }
-// noDataValues.add(noDataValue);
-// }
-//
-// /**
-// * Removes a "No Data" value for the series attribute.
-// * @param noDataValue the "No Data" value to remove
-// * @return {@code false} if the value was not an "No Data" value
-// */
-// @Override
-// public boolean removeSeriesAttributeNoDataValue(Object noDataValue) {
-// Set<Object> noDataValues = getSeriesAttributeNoDataValues();
-// if (noDataValues == null)
-// return false;
-// return noDataValues.remove(noDataValue);
-// }
-//
-// /**
-// * Checks whether the given value is one of the "No data" values for the
-// * series attribute.
-// * @param value an attribute value
-// */
-// @Override
-// public boolean isSeriesAttributeNoDataValue(Object value) {
-// Set<Object> noDataValues = getSeriesAttributeNoDataValues();
-// if (noDataValues == null)
-// return false;
-// return noDataValues.contains(value);
-// }
-//
-// /**
-// * Checks whether the given value is one of the "No data" values for the
-// * series attribute. In this case this method returns {@code null}, otherwise the
-// * value itself.
-// * @param value an attribute value
-// * @return {@code null} if the given value is one of the "No data" values
-// */
-// @Override
-// public <T> T filterSeriesAttributeNoDataValue(T value) {
-// if (isSeriesAttributeNoDataValue(value))
-// return null;
-// return value;
-// }
-//
-// /**
-// * Defines the attribute whose values are used to define the legend
-// * title for the series defined by {@link #setSeriesAttributeName(String)}.
-// * @param attrName feature attribute name
-// */
-// public void setSeriesLegendTitleAttributeName(String attrName) {
-// seriesLegendTitleAttrName = attrName;
-// }
-//
-// /**
-// * Returns the attribute whose values are used to define the legend
-// * title for the series defined by {@link #setSeriesAttributeName(String)}.
-// */
-// public String getSeriesLegendTitleAttributeName() {
-// return seriesLegendTitleAttrName;
-// }
-//
-// /**
-// * Does nothing, but always throws a {@link UnsupportedOperationException},
-// * because the dummy can not provide this functionality.
-// */
-// @Override
-// public JFreeChart applyToDataset(Dataset dataset) {
-// throw new UnsupportedOperationException(
-// "FeatureChartStyle.Dummy does not implement applyToDataset(..)");
-// }
+ /**
+ * Creates a (deep) clone of this style. The properties of the super class (
+ * {@link AbstractChartStyle}) are <b>ignored</b> because they are unused
+ * for the dummy.
+ */
+ @Override
+ public AbstractChartStyle copy() {
+ return (AbstractChartStyle) copyTo((FeatureChartStyle) new FeatureChartStyle.Dummy(""));
+ }
/**
+ * Copies all properties of this style to another one. The properties of the
+ * super class ({@link AbstractChartStyle}) are <b>ignored</b> because they
+ * are unused for the dummy.
+ * @param dest destination object (if {@code null} the copy is created by
+ * {@link #copy()})
+ * @return {@code dest} or the new instance
+ */
+ @Override
+ public ChartStyle copyTo(ChartStyle dest) {
+ // !! do NOT copy the super class properties !!
+ // !! copy only this classes properties !!
+ // !! Reason: the dummy does not maintain the !!
+ // !! super class properties and we !!
+ // !! do not want to overwrite them !!
+ if (dest instanceof FeatureChartStyle) {
+ // No own properties yet for FeatureChartStyle to copy
+ // Note: this method must be overwritten anyway, so that the
+ // super-method is NOT called!!
+ }
+
+ return dest;
+ }
+
+
+ /**
* Does nothing, but always throws a {@link UnsupportedOperationException},
* because the dummy can not provide this functionality.
*/
Modified: trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java
===================================================================
--- trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java 2010-10-05 09:03:30 UTC (rev 1075)
+++ trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java 2010-10-05 10:07:49 UTC (rev 1076)
@@ -58,10 +58,41 @@
ChartStyleXMLFactory xmlFactoryBasic = new ChartStyleXMLFactory();
@Test
- public void testChartStyleCopyTo() throws IOException, CQLException,
+ public void testChartStyleCopyToWithScatterChartStyle() throws IOException, CQLException,
InterruptedException {
FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = TestingUtil2.getTestFeatures();
+ 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");
+
+
+ if (INTERACTIVE) {
+ ChartFrame chartFrame = new ChartFrame(
+ "Sechs Linien (3x2), Zwei Achsen", chart);
+ chartFrame.pack();
+ chartFrame.setVisible(true);
+ while (chartFrame.isVisible()) {
+ Thread.sleep(100);
+ }
+ }
+ }
+
+ @Test
+ public void testChartStyleCopyToWithBasicChartStyle() throws IOException, CQLException,
+ InterruptedException {
+
+ FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = TestingUtil2.getTestFeatures();
FeatureChartStyle style1 = new FeatureBasicChartStyle("1", ChartType.BAR);
style1.setAttributeName(0, "jahr");
style1.setAttributeName(1, "w_bev");
@@ -86,11 +117,9 @@
Thread.sleep(100);
}
}
+ }
-
- }
-
- @Ignore
+ @Ignore
@Test
public void testLineChartDualAxis() throws IOException, CQLException,
InterruptedException {
More information about the Schmitzm-commits
mailing list