package visualization.components;

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

import visualization.VisualComponent;

import background.systemVariables.ArrayVariable;

public class MultipleValueComponent extends VisualComponent {
	
	public MultipleValueComponent(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)*array.size, dizajn.vizHeight, 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+(i*dizajn.vizWidth), y, dizajn.vizWidth, dizajn.vizHeight, 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 + i*dizajn.vizWidth, y, i);
				result.add(vA);	        		    
			}
		}

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

}
