/**
 * Licensed under the MICE s.r.l.
 * End User License Agreement
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.micegroup.it/voila/license.html
 */
package it.mice.voila.runtime.displaytag.basedec;

import javax.servlet.jsp.PageContext;

import it.mice.voila.runtime.entity.AwesomeIndicatorBean;

/**
 * Display Column Decorator per la trasformazione dei campi valori con 2 cifre decimali. 
 */
public class AwesomeIndicatorDecorator extends ValueDecorator {
	private int zoom = 1;
	
	public AwesomeIndicatorDecorator() {
        super();
    }
	
	public AwesomeIndicatorDecorator(int zoom) {
        super();
        this.zoom = zoom;
    }

    public String decorate(Object value) {
    	if (value == null || !(value instanceof AwesomeIndicatorBean)) {
    		return "";
    	}
    	AwesomeIndicatorBean aib = (AwesomeIndicatorBean)value;
    	
    	StringBuffer output = new StringBuffer();
    	output.append("<i class=\"fa " + aib.getSymbolName() + " " + aib.getColor() + (zoom > 1 ? (" fa-" + zoom + "x") : "") + "\">" + aib.getText() + "</i>");
   	
        return output.toString();
    }

	@Override
	public void setPageContext(PageContext pageContext) {
		super.setPageContext(getPageContext());
	}

}
