/*
 *  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.chart.axis;

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

/**
 * @author Joe Hendrix
 */
public abstract class Axis
{
    private String axis;
    private boolean localTime;
    private Map<String, Object> map = new HashMap<>();
    private Type type;

    /**
     * @param axis
     */
    protected Axis(String axis)
    {
        this.axis = axis;
    }

    /**
     * @return
     */
    public int getHeight()
    {
        return (int) map.get("height:");
    }

    /**
     * @param height
     */
    public void setHeight(int height)
    {
        map.put("height:", height);
    }

    /**
     * @return
     */
    public boolean isLocalTime()
    {
        return localTime;
    }

    /**
     * @param localTime
     */
    public void setLocalTime(boolean localTime)
    {
        this.localTime = localTime;
    }

    /**
     * Returns the maximum value of the axis range.
     * 
     * @return the maximum value of the axis range
     */
    public int getMax()
    {
        return (int) map.get("max:");
    }

    /**
     * Sets the maximum value of the axis range.
     * 
     * @param max the maximum value of the axis range
     */
    public void setMax(int max)
    {
        map.put("max:", max);
    }

    /**
     * Returns the minimum value of the axis range.
     * 
     * @return the minimum value of the axis range
     */ 
    public int getMin()
    {
        return (int) map.get("min:");
    }

    /**
     * Sets the minimum value of the axis range.
     * 
     * @param min the minimum value of the axis range
     */
    public void setMin(int min)
    {
        map.put("min:", min);
    }

    /**
     * Returns whether to show or hide the axis.
     * 
     * @return whether to show or hide the axis
     */
    public boolean isShow()
    {
        return (boolean) map.get("show:");
    }

    /**
     * Sets whether to show or hide the axis.
     * 
     * @param show whether to show or hide the axis
     */
    public void setShow(boolean show)
    {
        map.put("show:", show);
    }

    /**
     * Returns the type of the axis. Uses the nested Type enum. Values are:
     * <ul>
     * <li>timeseries</li>
     * <li>category</li>
     * <li>indexed</li>
     * </ul>
     * 
     * @return the type of the axis
     */
    public Type getType()
    {
        return type;
    }

    /**
     * Sets the type of the axis. Uses the nested Type enum. Values are:
     * <ul>
     * <li>timeseries</li>
     * <li>category</li>
     * <li>indexed</li>
     * </ul>
     * 
     * @param type the type of the axis
     */
    public void setType(Type type)
    {
        this.type = type;
    }

    /**
     * @return
     */
    public Padding getPadding()
    {
        return (Padding) map.get("padding:");
    }

    /**
     * @param padding
     */
    public void setPadding(Padding padding)
    {
        map.put("padding:", padding);
    }

    /**
     * @return
     */
    protected Label getLabel()
    {
        return (Label) map.get("label:");
    }
    
    /**
     * Sets the text for the axis label
     * 
     * @param label the text for the axis label
     */
    public abstract void setLabel(String label)
    {
        getLabel().setText(label);
    }

    /**
     * @param label
     */
    protected void setLabel(Label label)
    {
        map.put("label:", label);
    }

    @Override
    public String toString()
    {
        StringJoiner sj = new StringJoiner(",");

        for ( String field : map.keySet() )
        {
            StringBuilder sb = new StringBuilder(field);
            sb.append(map.get(field));

            sj.add(sb);
        }

        if ( type != null )
        {
            sj.add("type:'" + type + "'");
        }

        StringBuilder returnValue = new StringBuilder(axis);
        returnValue.append(":{");
        returnValue.append(sj);
        returnValue.append("}");

        return returnValue.toString();
    }

    /**
     *
     */
    public enum Type
    {

        /**
         *
         */
        timeseries,

        /**
         *
         */
        category,

        /**
         *
         */
        indexed
    }

    /**
     *
     */
    public enum Side
    {

        /**
         *
         */
        left,

        /**
         *
         */
        right
    }

    /**
     *
     */
    public class Padding
    {
        int left;
        int right;

        /**
         * @param left
         * @param right
         */
        public Padding(int left, int right)
        {
            this.left = left;
            this.right = right;
        }

        @Override
        public String toString()
        {
            return "{left:" + left + ",right:" + right + "}";
        }
    }
}

@@ -3475,25 +3475,16 @@
  public 
-abstract 
 void set
@@ -4637,437 +4637,7 @@
    %7D
-%0A%0A    /**%0A     *%0A     */%0A    public class Padding%0A    %7B%0A        int left;%0A        int right;%0A%0A        /**%0A         * @param left%0A         * @param right%0A         */%0A        public Padding(int left, int right)%0A        %7B%0A            this.left = left;%0A            this.right = right;%0A        %7D%0A%0A        @Override%0A        public String toString()%0A        %7B%0A            return %22%7Bleft:%22 + left + %22,right:%22 + right + %22%7D%22;%0A        %7D%0A    %7D
 %0A%7D%0A

Update Axis.java