/**
 * @auteur	: Dominique Capet aka MG.
 * @copyrights : MG For The Blatter Team. All rights reserved.
 * 
 * @projet : 		utils
 * @package :		packutils
 * @fichier :		cCadre.java
 * @version :		V1.00.18 févr. 2010
 * @date :			18 févr. 2010 - 09:02:19
 * @der_modif :     18 févr. 2010 - 09:02:19
 * 
 */
package packutils;

// Importations.
import java.awt.Graphics;
import java.util.Random;

/**
 * 
 * @class cCadre
 *
 */
public class cCadre extends cBaseFontePanel 
{
	// Constantes privées.
	private static final long serialVersionUID = -6474397514120567371L;
	// Variables privées.
	private String ligne_haute;
	private String ligne_basse;
	private char[] gen1, gen2;

	public cCadre(String iTexte, int x, int y) 
	{
		super(iTexte, x, y);
		// Génération aléatoire des lignes qui ferment le texte en haut et en bas.		
		// Length + 2, car on ajoute un espace de part et d'autres du texte.
		this.ligne_haute = RandomLigne(this.Length + 2, 255-1, 249);
		this.ligne_basse = RandomLigne(this.Length + 2, 248, 242);
		this.gen1 = new char[LIGNE_TEXTE_MAX];
		this.gen2 = new char[LIGNE_TEXTE_MAX];
		Random generator = new Random();
		for (int i = 0; i < this.nbLines; i++) {
			this.gen1[ i ] = (char) (228 + generator.nextInt(235 - 228 + 1));
			this.gen2[ i ] = (char) (228 + generator.nextInt(235 - 228 + 1));
		}
	}
	public void PrintTexteCadre(Graphics g, String[] TabTexte, int x, int y)
	{
		PrintLine(g, (char) 226 + this.ligne_haute + (char) 227, x, y);
		y += HEIGHT_PIXEL_CHAR;		 
		int Ind = 0;
		while (TabTexte[ Ind ] != "") {			
			PrintLine(g, this.gen1[ Ind ]+" "+TabTexte[ Ind ]+" "+this.gen2[ Ind ], x, y);
			y += HEIGHT_PIXEL_CHAR;
			Ind++;
		}
		PrintLine(g, (char) 224 + this.ligne_basse + (char) 225, x, y);		
	}
	public void paintComponent(Graphics g) 
	{
		super.paintComponent(g);
		PrintTexteCadre(g, this.TabTexte, this.x, this.y);
	}
}

