import java.awt.Color;
import java.awt.Point;
import java.util.ArrayList;
import java.util.Random;

public class ChartObj 
{
	// COMMON 
	private String	              	id;
	private String 					obj_type;
	private Point					location;
	private int						xcentre = 0;
	private int						ycentre = 0;
	private boolean             	selected;
	private Color					obj_color;
	private Color					text_color;
	
	// Activity
	private int						w_activity;
	private int						h_activity;
	private int						x1;
	private int						y1;
	 
	// Decision
	private Point             		p1;
	private Point             		p2;
	private Point             		p3;
	private Point             		p4;
	private int						w_decision;
	private	int						h_decision;	
	
	public ChartObj() 
	{
	    
	}

	public ChartObj(String obj_type, Point location) 
	{
		// commun
		//incidentEdges = new ArrayList<Edge_transition>();
		this.obj_type = obj_type;
		this.location = location;
		this.xcentre = (int) location.getX();
		this.ycentre = (int) location.getY();
		this.selected = false;
		this.obj_color = Color.BLACK;
		this.text_color = Color.BLACK;
		
		if(obj_type.equals(""))
		{
	     
			this.w_activity = 240;
			this.h_activity = 60;
		
			this.x1 = xcentre - (w_activity /2);
			this.y1 = ycentre - (h_activity /2);
	     
			this.selected = false;
			this.obj_color = Color.BLACK;
			this.text_color = Color.BLACK;
			id = generate_id("A");
		}	
		else
		{
	    	
			this.w_decision = 100;
			this.h_decision = 100;
	    	
	    	p1 = new Point();
	    	p2 = new Point();
	    	p3 = new Point();
	    	p4 = new Point();
	    	
	    	p1.setLocation( (int) (location.getX() - (w_decision/2))  , (int)location.getY());
	    	p2.setLocation( (int) (location.getX() )  ,  (int) (location.getY() - (h_decision/2)) );
	    	p3.setLocation( (int) (location.getX() + (w_decision/2))  , (int)location.getY());
	    	p4.setLocation( (int) (location.getX() )  ,  (int) (location.getY() + (h_decision/2)) );
			
			id = generate_id("D");
		}
		
	}
	
	public String generate_id(String type)
	{
		  int max = 100;
		  int min = 1;
		  Random randomNum = new Random();
		  int id = min + randomNum.nextInt(max);
		  //System.out.println("Random id " + id );
		  String tmp = type + Integer.toString(id);
		  return tmp;
	}
	    
	public String getID()
	{
		  return id;
	}

	//public boolean isSelected() { return selected; }
	    
	//public void setSelected(boolean state) { selected = state; }
	    
	//public void setUnSelected(boolean state) { selected = state; }
	    
	//public void toggleSelected() { selected = !selected; }
	    
}
