[Schmitzm-commits] r876 - in trunk: doc src/schmitzm/jfree/feature/style src/schmitzm/jfree/table/style

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri May 28 21:54:45 CEST 2010


Author: mojays
Date: 2010-05-28 21:54:39 +0200 (Fri, 28 May 2010)
New Revision: 876

Modified:
   trunk/doc/Chart style XML structure.pdf
   trunk/src/schmitzm/jfree/feature/style/FeatureChartStyleXMLFactory.java
   trunk/src/schmitzm/jfree/table/style/TableChartStyleXMLFactory.java
Log:
XML-definition for chart styles changed: <featureAttributes> renamed to <tableAttributes> because of new java class structure
Old-fashioned <featureAttributes> is still working but on XML creation, only <tableAttributes> is written from now on!

Modified: trunk/doc/Chart style XML structure.pdf
===================================================================
(Binary files differ)

Modified: trunk/src/schmitzm/jfree/feature/style/FeatureChartStyleXMLFactory.java
===================================================================
--- trunk/src/schmitzm/jfree/feature/style/FeatureChartStyleXMLFactory.java	2010-05-28 15:37:56 UTC (rev 875)
+++ trunk/src/schmitzm/jfree/feature/style/FeatureChartStyleXMLFactory.java	2010-05-28 19:54:39 UTC (rev 876)
@@ -29,6 +29,8 @@
  ******************************************************************************/
 package schmitzm.jfree.feature.style;
 
+import org.jdom.Element;
+
 import schmitzm.jfree.chart.style.ChartType;
 import schmitzm.jfree.table.style.TableChartStyle;
 import schmitzm.jfree.table.style.TableChartStyleXMLFactory;
@@ -43,6 +45,22 @@
 public class FeatureChartStyleXMLFactory extends TableChartStyleXMLFactory<FeatureChartStyle> {
 
   /**
+   * Applies the chart style definition from XML (<b>except the type and id!!</b>)
+   * to an existing {@link FeatureChartStyle} object.
+   * @param chartStyle an existing chart style ({@code null} not permitted!)
+   * @param element    element to read the properties from
+   */
+  @Override
+  public void applyStyleFromXML(FeatureChartStyle chartStyle, Element element) {
+    // Apply the normal ChartStyle properties and the TableChartStyle
+    // properties
+    super.applyStyleFromXML(chartStyle, element);
+    
+    // Interpret XML for special FeatureChartStyle properties
+    // ... (currently there are none)
+  }
+  
+  /**
    * Creates a default style for a chart type.
    * @param id   a (unique) ID for the style
    * @param type a chart type
@@ -60,4 +78,19 @@
     throw new UnsupportedOperationException("Style for this chart type not yet supported for features: "+type);
   }
 
+  /**
+   * Creates a XML {@link Element} representing the {@link FeatureChartStyle}.
+   * @param style           style to create an element for
+   * @param rootElementName name for the root element (if {@code null} "ChartType" is 
+   *                        used)
+   */
+  @Override
+  public Element createElementFromStyle(FeatureChartStyle style, String rootElementName) {
+    Element root = super.createElementFromStyle(style, rootElementName);
+
+    // Create XML for special FeatureChartStyle properties
+    // ... (currently there are none)
+    
+    return root;
+  }
 }

Modified: trunk/src/schmitzm/jfree/table/style/TableChartStyleXMLFactory.java
===================================================================
--- trunk/src/schmitzm/jfree/table/style/TableChartStyleXMLFactory.java	2010-05-28 15:37:56 UTC (rev 875)
+++ trunk/src/schmitzm/jfree/table/style/TableChartStyleXMLFactory.java	2010-05-28 19:54:39 UTC (rev 876)
@@ -70,18 +70,22 @@
       }
     }
     
-    // Attribute definitions in <attributes> element
-    Element featureElement = element.getChild("featureAttributes");
-    if ( featureElement == null )
-      throw new UnsupportedOperationException("<featureAttributes> element necessary for FeatureChartStyle!");
+    // Attribute definitions in <tableAttributes> element
+    Element attributesElement = element.getChild("tableAttributes");
+    if ( attributesElement == null )
+      // try old-fashioned XML-definition with <featureAttributes>
+      // TODO: remove this temporary work-around!
+      attributesElement = element.getChild("featureAttributes");
+    if ( attributesElement == null )
+      throw new UnsupportedOperationException("<tableAttributes> element necessary for TableChartStyle!");
 
     // Read domain attribute
-    Element domainAttrElem = featureElement.getChild("domainAttr");
+    Element domainAttrElem = attributesElement.getChild("domainAttr");
     if ( domainAttrElem == null )
-      throw new UnsupportedOperationException("Attribute <domainAttr> required for FeatureChartType");
+      throw new UnsupportedOperationException("Attribute <domainAttr> required for TableChartStyle");
     String domainAttrName = XMLUtil.getAttribute(domainAttrElem, "name");
     if ( domainAttrName == null )
-      throw new UnsupportedOperationException("Attribute 'name' necessary for <domainAttr> element of FeatureChartStyle!");
+      throw new UnsupportedOperationException("Attribute 'name' necessary for <domainAttr> element of TableChartStyle!");
     chartStyle.setAttributeName(0, domainAttrName);
     chartStyle.setAttributeNormalized(0, XMLUtil.getBooleanAttribute(domainAttrElem, "normalize", false));
     chartStyle.setSortDomainAxis(XMLUtil.getBooleanAttribute(domainAttrElem, "sort", false));
@@ -92,13 +96,13 @@
     
     // Read all range attribute definitions
     int rangeAttrNo = 0;
-    for (Element rangeAttrElem : (List<Element>)featureElement.getChildren("rangeAttr") ) {
-      String featureAttrName = XMLUtil.getAttribute(rangeAttrElem, "name");
-      if ( featureAttrName == null )
-        throw new UnsupportedOperationException("Attribute 'name' necessary for <rangeAttr> element of FeatureChartStyle!");
+    for (Element rangeAttrElem : (List<Element>)attributesElement.getChildren("rangeAttr") ) {
+      String tableAttrName = XMLUtil.getAttribute(rangeAttrElem, "name");
+      if ( tableAttrName == null )
+        throw new UnsupportedOperationException("Attribute 'name' necessary for <rangeAttr> element of TableChartStyle!");
       // Apply attributes to style
       rangeAttrNo++;
-      chartStyle.setAttributeName(rangeAttrNo, featureAttrName);
+      chartStyle.setAttributeName(rangeAttrNo, tableAttrName);
       chartStyle.setAttributeNormalized(rangeAttrNo, XMLUtil.getBooleanAttribute(rangeAttrElem, "normalize", false));
       nullAliases = XMLUtil.getSetAttribute(rangeAttrElem, "nullAliases");
       if (nullAliases != null)
@@ -118,11 +122,11 @@
     }
 
     // Read (optional) series attribute (its values defines the series groups)
-    Element seriesAttrElem = featureElement.getChild("seriesAttr");
+    Element seriesAttrElem = attributesElement.getChild("seriesAttr");
     if ( seriesAttrElem != null ) {
       String seriesAttrName = XMLUtil.getAttribute(seriesAttrElem, "name");
       if ( seriesAttrName == null )
-        throw new UnsupportedOperationException("Attribute 'name' necessary for <seriesAttr> element of FeatureChartStyle!");
+        throw new UnsupportedOperationException("Attribute 'name' necessary for <seriesAttr> element of TableChartStyle!");
       chartStyle.setSeriesAttributeName(seriesAttrName);
       nullAliases = XMLUtil.getSetAttribute(seriesAttrElem, "nullAliases");
       if (nullAliases != null)
@@ -154,8 +158,8 @@
   public Element createElementFromStyle(E style, String rootElementName) {
     Element root = super.createElementFromStyle(style, rootElementName);
     
-    // Create and add element <featureAttributes>
-    Element attrElem = addChildToElement(root, "featureAttributes");
+    // Create and add element <tableAttributes>
+    Element attrElem = addChildToElement(root, "tableAttributes");
     
     // Domain attribute definition
     if ( style.getAttributeCount() > 0 )



More information about the Schmitzm-commits mailing list