/*
 *
 * Copyright (C)   20 dec. 2003 Jean-Yves Beaujean 
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,  59
 * Temple Place - Suite 330, Boston, MA 02111-1307, USA.

 */
package jxtray.diag;


import java.util.Vector;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GradientPaint;
import java.awt.Rectangle;
import java.awt.Color;


public class DiTable extends DiElement
{
	private String name;
	private String tableType;
	private Vector vField;


	
	public DiTable( String name)
	{
		super();
		this.name = name;
		vField = new Vector();
	}
	
	public void addField( DiField field)
	{
		vField.add(field);
	}
	
	public int countElement()
	{
		return vField.size();
	}
	/**
	 * @return String
	 */
	public String getName() {
		return name;
	}

	/**
	 * @return String
	 */
	public String getTableType() {
		return tableType;
	}

	/**
	 * @param string
	 */
	public void setName(String string) 
	{
		name = string;
	}

	/**
	 * @param string
	 */
	public void setTableType(String string)
	{
		tableType = string;
	}
	
	public void paint(Graphics g)
	{
		g.setFont(font);
				
		Color color1 = Color.WHITE;
		Color color2 = Color.DARK_GRAY;

		painter = new GradientPaint(x, y,color1,x, y + height, color2);
		g2 = (Graphics2D) g;
		g2.setPaint(painter);
		g2.fill(new Rectangle(x,y,width,height));
		g.draw3DRect(x,y,width,height,true);
		
		g.setColor(color2); // ton vert
		g.drawString(name,x+10,y+10);			
						
	}
	

}
