/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.xwiki.rendering.macro.chart;

import java.util.HashMap;
import java.util.Map;

import org.xwiki.chart.ChartGenerator;
import org.xwiki.rendering.macro.descriptor.annotation.ParameterDescription;
import org.xwiki.rendering.macro.descriptor.annotation.ParameterMandatory;

/**
 * Parameters for chart macro.
 * 
 * @version $Id: $
 * @since 2.0M1
 */
public class ChartMacroParameters
{
    /**
     * @see ChartMacroParameters#getTitle()
     */
    private String title;
    
    /**
     * @see ChartMacroParameters#getHeight()
     */
    private int height = 300;
    
    /**
     * @see ChartMacroParameters#getWidth()
     */
    private int width = 400;
    
    /**
     * @see ChartMacroParameters#getType()
     */
    private String type;

    /**
     * @see ChartMacroParameters#getSource()
     */
    private String source = "xdom";
    
    /**
     * @see ChartMacroParameters#getParams()
     */
    private String params;
    
    /**
     * @return The title of the chart.
     */
    public String getTitle()
    {
        return title;
    }

    /**
     * @param title - refer to {@link #getTitle()}.
     */
    @ParameterDescription("The title of the chart.")
    public void setTitle(String title)
    {
        this.title = title;
    }

    /**
     * @return The width of the chart.
     */
    public int getWidth()
    {
        return width;
    }

    /**
     * @param width - refer to {@link #getWidth()}.
     */
    @ParameterDescription("The width of the chart.")
    public void setWidth(int width)
    {
        this.width = width;
    }

    /**
     * @return The height of the chart.
     */
    public int getHeight()
    {
        return height;
    }

    /**
     * @param height - refer to {@link #getHeight()}.
     */
    @ParameterDescription("The height of the chart.")
    public void setHeight(int height)
    {
        this.height = height;
    }
    
    /**
     * @return the type of the chart.
     */
    public String getType()
    {
        return type;
    }

    /**
     * @param chartType - refer to {@link #getType()}.
     */
    @ParameterMandatory
    @ParameterDescription("The type of the chart.")
    public void setType(String chartType)
    {
        this.type = chartType;
    }

    /**
     * @return a string describing the data source
     */
    public String getSource()
    {
        return source;
    }

    /**
     * @param source - refer to {@link #getSource()
     */
    @ParameterDescription("The string describing the data source.")
    public void setSource(String source)
    {
        this.source = source;
    }
        
    /**
     * @return Additional parameters for the data source.
     */
    public String getParams()
    {
        return params;
    }

    /**
     * @param params Additional parameters for the data source.
     */
    @ParameterDescription("Additional parameters for the datasource.")
    public void setParams(String params)
    {
        this.params = params;
    }

    /**
     * @return a Map containing all the parameters.
     */
    public Map<String, String> getParametersMap() {
        Map<String, String> map = new HashMap<String, String>();
        map.put(ChartGenerator.TITLE_PARAM, title);
        map.put(ChartGenerator.WIDTH_PARAM, String.valueOf(width));
        map.put(ChartGenerator.HEIGHT_PARAM, String.valueOf(height));
        map.put(ChartGenerator.TYPE_PARAM, type.toString());
        map.put(ChartDataSource.SOURCE, source);
        map.put(ChartDataSource.PARAMS, params);        
        return map;
    }
}

@@ -4009,19 +4009,23 @@
 ersMap()
+%0A   
  %7B%0A
-
         
@@ -4125,21 +4125,26 @@
 _PARAM, 
-t
+getT
 itle
+()
 );%0A     
@@ -4197,21 +4197,26 @@
 valueOf(
-w
+getW
 idth
+()
 ));%0A    
@@ -4271,22 +4271,27 @@
 valueOf(
-h
+getH
 eight
+()
 ));%0A    
@@ -4333,21 +4333,15 @@
 AM, 
-type.toString
+getType
 ());
@@ -4381,22 +4381,27 @@
 SOURCE, 
-s
+getS
 ource
+()
 );%0A     
@@ -4435,22 +4435,27 @@
 PARAMS, 
-p
+getP
 arams
+()
 );      

Use getters (best practice) + removed not needed toString() + applied style