/*
 *  The MIT License (MIT)
 *
 *  View the full license at:
 *  https://github.com/hendrixjoseph/FamilyTree/blob/master/LICENSE.md
 *
 *  Copyright (c) 2015 Joseph Hendrix
 *
 *  Hosted on GitHub at https://github.com/hendrixjoseph/FamilyTree
 *
 */

package edu.wright.hendrix11.d3.wordCloud;

import edu.wright.hendrix11.d3.MasterComponent;

import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
import javax.faces.component.FacesComponent;

import java.util.Map;

/**
 * @author Joe Hendrix
 */
@FacesComponent(value = WordCloudComponent.COMPONENT_TYPE)
@ResourceDependencies({
                              @ResourceDependency(library = "js", name = "d3.min.js"),
                              @ResourceDependency(library = "js", name = "d3.layout.cloud.js")
                      })
public class WordCloudComponent extends MasterComponent
{
    /**
     *
     */
    public static final String COMPONENT_FAMILY = "edu.wright.hendrix11.d3";
    /**
     *
     */
    public static final String COMPONENT_TYPE = "edu.wright.hendrix11.d3.wordCloud.WordCloudComponent";
    /**
     *
     */
    public static final String DEFAULT_RENDERER = "edu.wright.hendrix11.d3.chart.WordCloudRenderer";

    /**
     *
     */
    public WordCloudComponent()
    {
        setRendererType(DEFAULT_RENDERER);
    }

    @Override
    public String getFamily()
    {
        return COMPONENT_FAMILY;
    }

    /**
     * @return
     */
    public Integer getWidth()
    {
        return (Integer) getStateHelper().eval(PropertyKeys.width, null);
    }

    /**
     * @param width
     */
    public void setWidth(Integer width)
    {
        getStateHelper().put(PropertyKeys.width, width);
    }

    /**
     * @return
     */
    public Integer getHeight()
    {
        return (Integer) getStateHelper().eval(PropertyKeys.height, null);
    }

    /**
     * @param height
     */
    public void setHeight(Integer height)
    {
        getStateHelper().put(PropertyKeys.height, height);
    }

    /**
     * @return
     */
    public Integer getPadding()
    {
        return (Integer) getStateHelper().eval(PropertyKeys.padding, null);
    }

    /**
     * @param padding
     */
    public void setPadding(Integer padding)
    {
        getStateHelper().put(PropertyKeys.padding, padding);
    }

    /**
     * @return
     */
    public String getFont()
    {
        return (String) getStateHelper().eval(PropertyKeys.font, null);
    }

    /**
     * @param font
     */
    public void setFont(String font)
    {
        getStateHelper().put(PropertyKeys.font, font);
    }

    /**
     * @return
     */
    public Map<String, Integer> getWords()
    {
        return (Map<String, Integer>) getStateHelper().eval(PropertyKeys.words, null);
    }

    /**
     * @param words
     */
    public void setWords(Map<String, Integer> words)
    {
        getStateHelper().put(PropertyKeys.words, words);
    }

    protected enum PropertyKeys
    {

        /**
         *
         */
        width,
        height,
        padding,
        font,
        words
    }
}
@@ -1451,39 +1451,123 @@
 %0A    /**%0A     * 
-@return
+Returns the width of the entire cloud.%0A     * %0A     * @return the width of the entire cloud
 %0A     */%0A    pub
@@ -1695,20 +1695,101 @@
   * 
-@param width
+Sets the width of the entire cloud.%0A     * %0A     * @param width the width of the entire cloud
 %0A   
@@ -1910,39 +1910,125 @@
 %0A    /**%0A     * 
-@return
+Returns the height of the entire cloud.%0A     * %0A     * @return the height of the entire cloud
 %0A     */%0A    pub
@@ -2158,21 +2158,104 @@
   * 
-@param height
+Sets the height of the entire cloud.%0A     * %0A     * @param height the height of the entire cloud
 %0A   
@@ -2380,39 +2380,153 @@
 %0A    /**%0A     * 
-@return
+Returns the numerical padding for each word / String.%0A     * %0A     * @return the numerical padding for each word / String
 %0A     */%0A    pub
@@ -2658,19 +2658,130 @@
   * 
-@param padd
+Sets the numerical padding for each word / String.%0A     * %0A     * @param padding the numerical padding for each word / Str
 ing%0A
@@ -2913,39 +2913,119 @@
 %0A    /**%0A     * 
-@return
+Returns the font face for each word.%0A     * %0A     * @return the font face for each word
 %0A     */%0A    pub
@@ -3149,19 +3149,96 @@
   * 
-@param font
+Sets the font face for each word.%0A     * %0A     * @param font the font face for each word
 %0A   
@@ -3366,194 +3366,721 @@
   * 
-@return%0A     */%0A    public Map%3CString, Integer%3E getWords()%0A    %7B%0A        return (Map%3CString, Integer%3E) getStateHelper().eval(PropertyKeys.words, null);%0A    %7D%0A%0A    /**%0A     * @param words
+Returns the map of words (or rather, Strings, as they can have spaces) to the %0A     * font size of that word. Typcially the size will be the number of occurences, %0A     * but that is not a requirement.%0A     * %0A     * @return the map of words to the  font size of that word%0A     */%0A    public Map%3CString, Integer%3E getWords()%0A    %7B%0A        return (Map%3CString, Integer%3E) getStateHelper().eval(PropertyKeys.words, null);%0A    %7D%0A%0A    /**%0A     * Sets the map of words (or rather, Strings, as they can have spaces) to the %0A     * font size of that word. Typcially the size will be the number of occurences, %0A     * but that is not a requirement.%0A     * %0A     * @param words the map of words to the  font size of that word
 %0A   
@@ -4364,8 +4364,9 @@
 %0A    %7D%0A%7D
+%0A

Update WordCloudComponent.java