package visualization.components;

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

import background.systemVariables.ArrayVariable;
import visualization.VisualComponent;

public class TurnedMultipleValueComponent extends VisualComponent {
	public TurnedMultipleValueComponent(ArrayVariable var) {
		super(var);				
	}	
	
	@Override
	public Area getBorder(Graphics2D g, Boolean draw) {
		Area result = new Area();
		
		Area border = dizajn.getMultipleValueDesignBorder(g, draw, x, y, dizajn.vizWidth, dizajn.vizHeight*array.size, 1, array.size);
		result.add(border);
		
		for (int i=0; i<array.size; i++) {
			
			Area part = dizajn.getDesignBorder(g, draw, array.getNth(i+array.posun).isActive(), x, y+(i*dizajn.vizHeight), dizajn.vizWidth, dizajn.vizHeight, 0, i);				
			result.add(part);		
		}				
		return result;
	}
		
	@Override
	public Area getValueShape(Graphics2D g, Boolean draw) {
        
        Area result = new Area();
		
		for (int i=0; i<array.size; i++) {			
			if (array.getNth(i+array.posun).initialized) {
				Area vA = dizajn.getDesignValueShape(g, draw, array.getNth(i+array.posun), x, y+ i*dizajn.vizHeight, 0, i);
				result.add(vA);	        
			}
		}

		return result;
	}
	
	@Override
	public Area getNameShape(Graphics2D g, Boolean draw) {		
		return dizajn.getDesignNameShape(g, draw, array.name, x, y, dizajn.vizWidth, array.size*dizajn.vizHeight, 1, array.size);
	}

}
