package visualization.designs;

import java.awt.Graphics2D;
import java.awt.geom.Area;
import java.awt.geom.RoundRectangle2D;

import visualization.Design;
import visualization.designs.colors.Blue;


import background.systemVariables.SimpleVariable;

public class SimpleDesign extends Design {
			
	public SimpleDesign(String c) {		
		super(c);		
		vizArc = 10;
		multipleValueOffset = 4;
		defHeight = 40;
		defWidth = 40;		
		if (colors==null) colors = new Blue();
		recalculateMultiplicator(1);
	}

	@Override	
	public Area getDesignBorder(Graphics2D g, Boolean draw, Boolean active, int x, int y, int width, int height) {
		Area part = new Area(new RoundRectangle2D.Double(x, y, width-1, height-1, vizArc, vizArc));
		if (draw) drawIt(g, part, colors.standardBorderColor, active, colors.activeBorderColor, true, colors.standardFillColor, colors.activeFillColor);		
		return part;
	}

	@Override	
	public Area getDesignBorder(Graphics2D g, Boolean draw, Boolean active, int x, int y, int width, int height, int valueNumberX) {
		return getDesignBorder(g, draw, active, x, y, width, height, valueNumberX, 0);
	}
	
	@Override 
	public Area getDesignBorder(Graphics2D g, Boolean draw, Boolean active, int x, int y, int width, int height, int valueNumberX, int valueNumberY) {
		Area part = new Area(new RoundRectangle2D.Double(x+(multipleValueOffset*(valueNumberX+1)), y+(multipleValueOffset*(valueNumberY+1)), width-1, height-1, vizArc, vizArc));
		if (draw) drawIt(g, part, colors.standardBorderColor, active, colors.activeBorderColor, true, colors.standardFillColor, colors.activeFillColor);		
		return part;
	}
	
	@Override
	public Area getMultipleValueDesignBorder(Graphics2D g, Boolean draw, int x, int y, int width, int height, int valuesX, int valuesY) {		
		Area part = new Area(new RoundRectangle2D.Double(x, y, width+multipleValueOffset*(valuesX+1), height+multipleValueOffset*(valuesY+1), vizArc, vizArc));
		if (draw) drawIt(g, part, colors.outerBorderColor);		
		return part;
	}

	@Override
	public Area getDesignValueShape(Graphics2D g,Boolean draw, SimpleVariable var, int x, int y) {       					
		return getDesignValueShape(g, draw, var, x, y, -1, -1);
	}
	
	@Override
	public Area getDesignValueShape(Graphics2D g,Boolean draw, SimpleVariable var, int x, int y, int valueNumber) {       					
		return getDesignValueShape(g, draw, var, x, y, valueNumber, 0);
	}
	
	@Override
	public Area getDesignValueShape(Graphics2D g,Boolean draw, SimpleVariable var, int x, int y, int valueNumberX, int valueNumberY) {       					
		String val = var.getValue("string");			
	    Area vA = getAreaFromString(g,val,valueFont);                        	    	    
	    
	    int	w = x + multipleValueOffset*(valueNumberX+1) + Math.round(vizWidth / 2) - Math.round(vA.getBounds().width / 2);
	    int h = y + multipleValueOffset*(valueNumberY+1) + Math.round(vizHeight / 2) + Math.round(vA.getBounds().height / 2);	    	

	    moveAreaTo(vA, w, h);	    
	    if (draw) drawIt(g, val, valueFont, colors.standardValueColor, var.isActive(), colors.activeValueColor, w, h);

		return vA;
	}

	@Override
	public Area getDesignNameShape(Graphics2D g, Boolean draw, String name, int x, int y, int width, int height) {
		Area vA = getAreaFromString(g, name, nameFont);		                
        
        int w = x + Math.round(width / 2) - Math.round(vA.getBounds().width / 2); 
        int h = y + height + vA.getBounds().height + 5;        

	    moveAreaTo(vA, w, h);	    
	    if (draw) drawIt(g, name, nameFont, colors.standardTextColor, false, null, w, h);
        
        return vA;
	}

	
	@Override
	public Area getDesignNameShape(Graphics2D g, Boolean draw, String name, int x, int y, int width, int height, int valuesX, int valuesY) {
		Area vA = getAreaFromString(g, name, nameFont);		                
        
        int w = x + Math.round((width + multipleValueOffset*(valuesX+1)) / 2) - Math.round(vA.getBounds().width / 2); 
        int h = y + height + vA.getBounds().height + multipleValueOffset*(valuesY+1) + 5;        

	    moveAreaTo(vA, w, h);	    
	    if (draw) drawIt(g, name, nameFont, colors.standardTextColor, false, null, w, h);
        
        return vA;
	}

}
