Charts - Enhancing

To add functionality to JFreeChartProcessor.

-Checkout the release of the code you want to work with. Will refer to that directory as $CO_DIR.

-Edit rng schema $CO_DIR/src/java/org/orbeon/oxf/processor/converter/chart-converter-chart.rng to add any new tag.

    <grammar xmlns="http://relaxng.org/ns/structure/1.0"
        datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">

           ...
               <optional>
                    <element name="item-label">
                        <data type="boolean"/>
                    </element>
                </optional>
        ...
    </grammar>


-Edit src/java/org/orbeon/oxf/processor/serializer/legacy/JFreeChartSerializer.java.
    -Add attribute declaration and set/get methods for the value of the new tag to the static class ChartConfig.

        protected static class ChartConfig {
        ...
            private boolean itemLabel;
        ...
        ...
            public boolean isItemLabelVisible() {
                return itemLabel;
            }
            public void setItemLabelVisible(boolean visible) {
                this.itemLabel = visible;
            }
        }

    -Add sentences into createChartConfig method for calling the set methods of Chartconfig with the value provided by the tag.
     
      protected ChartConfig createChartConfig(org.orbeon.oxf.pipeline.api.PipelineContext context, org.orbeon.oxf.processor.ProcessorInput input) {
        ...
            Boolean itemLabelVis = XPathUtils.selectBooleanValue(doc, "/chart/item-label");
            chart.setItemLabelVisible(itemLabelVis.booleanValue());
        ...
      }

    -Add the jfreechart specific sentences to drawChart methos in order to add the specified feature to the chart.
    
       protected JFreeChart drawChart(ChartConfig chartConfig, final Dataset ds) {
        ...
        ...
               renderer.setBaseItemLabelsVisible(chartConfig.isItemLabelVisible());
        ...
        ...
       }

-Launch the command: ant
-Copy $CO_DIR/build/orbeon-war/WEB-INF/lib/orbeon.jar to the orbeon webapp proper directory in your running servlet container.
Comments