schmitzm.jfree.chart.style
Class ChartStyleXMLFactory<E extends ChartStyle>

java.lang.Object
  extended by schmitzm.jfree.chart.style.ChartStyleXMLFactory<E>
Direct Known Subclasses:
FeatureChartStyleXMLFactory

public class ChartStyleXMLFactory<E extends ChartStyle>
extends Object

This class defines a factory to create a chart style from XML.

Version:
1.0
Author:
Martin Schmitz

Constructor Summary
ChartStyleXMLFactory()
           
 
Method Summary
static Element addChildToElement(Element element, String childName)
          Creates an child element with no attributes.
static Element addChildToElement(Element element, String childName, boolean inclNullAttr, Object... attributes)
          Creates an child element and sets some attributes.
 void applyStyleFromXML(E chartStyle, Element element)
          Applies the chart style definition from XML (except the type and id!!
 ChartAxisStyle createAxisStyleFromXML(Element element)
          Creates a ChartLabelStyle from XML element.
 E createDefaultChartStyle(String id, ChartType type)
          Creates a default style for a chart type.
 Element createElementFromStyle(E style, String rootElementName)
          Creates a XML Element representing the ChartStyle.
 ChartLabelStyle createLabelStyleFromXML(Element element)
          Creates a ChartLabelStyle from XML element.
 ChartPlotStyle createPlotStyleFromXML(Element element)
          Creates a ChartPlotStyle from XML element.
 ChartRendererStyle createRendererStyleFromXML(Element element)
          Creates a ChartRendererStyle from XML element.
 E createStyleFromXML(Element element)
          Reads a chart definition from XML element.
 E createStyleFromXML(Element element, String id)
          Reads a chart definition from XML element.
 void writeStyleToFile(E style, String rootElementName, File filePath)
          Stores a ChartStyle to an XML file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChartStyleXMLFactory

public ChartStyleXMLFactory()
Method Detail

createStyleFromXML

public E createStyleFromXML(Element element)
Reads a chart definition from XML element. The chart style ID is taken from "id" attribute.

Parameters:
element - the XML element
factory - factory to create the style with

createStyleFromXML

public E createStyleFromXML(Element element,
                            String id)
Reads a chart definition from XML element.

Parameters:
element - the XML element
id - the ID for the style (if null the ID is taken from "id" attribute)

createDefaultChartStyle

public E createDefaultChartStyle(String id,
                                 ChartType type)
Creates a default style for a chart type.

Parameters:
id - a (unique) ID for the style
type - a chart type

applyStyleFromXML

public void applyStyleFromXML(E chartStyle,
                              Element element)
Applies the chart style definition from XML (except the type and id!!) to an existing ChartStyle object.

Parameters:
chartStyle - an existing chart style (null not permitted!)
element - element to read the properties from
Throws:
UnsupportedOperationException - if chartStyle or element is null

createLabelStyleFromXML

public ChartLabelStyle createLabelStyleFromXML(Element element)
Creates a ChartLabelStyle from XML element.

Parameters:
element - an element

createAxisStyleFromXML

public ChartAxisStyle createAxisStyleFromXML(Element element)
Creates a ChartLabelStyle from XML element.

Parameters:
element - an element

createRendererStyleFromXML

public ChartRendererStyle createRendererStyleFromXML(Element element)
Creates a ChartRendererStyle from XML element.

Parameters:
element - an element

createPlotStyleFromXML

public ChartPlotStyle createPlotStyleFromXML(Element element)
Creates a ChartPlotStyle from XML element.

Parameters:
element - an element

writeStyleToFile

public void writeStyleToFile(E style,
                             String rootElementName,
                             File filePath)
                      throws IOException
Stores a ChartStyle to an XML file.

Parameters:
style - style to store
rootElementName - name for the root element (if null "ChartType" is used)
filePath - file to store the style to
Throws:
IOException

createElementFromStyle

public Element createElementFromStyle(E style,
                                      String rootElementName)
Creates a XML Element representing the ChartStyle.

Parameters:
style - style to create an element for
rootElementName - name for the root element (if null "ChartStyle" is used)

addChildToElement

public static Element addChildToElement(Element element,
                                        String childName)
Creates an child element with no attributes. If an element is given, the new child is automatically added.

Parameters:
element - if not null the new element is added as child to this element
childName - name of the new child
Returns:
the new child element

addChildToElement

public static Element addChildToElement(Element element,
                                        String childName,
                                        boolean inclNullAttr,
                                        Object... attributes)
Creates an child element and sets some attributes. If an element is given, the new child is automatically added.

Parameters:
element - if not null the new element is added as child to this element
childName - name of the new child
inclNullAttr - if false attributes with value null are not set; if ALL attributes are null also the child is not created!
attributes - attribute/value pairs for the new child element
Returns:
the new child element