/**
* @auteur : Dominique Capet aka MG.
* @copyrights : MG For The Blatter Team. All rights reserved.
*
* @projet : utils
* @package : packutils
* @fichier : cCadreScroll.java
* @version : V1.00.18 févr. 2010
* @date : 18 févr. 2010 - 09:04:11
* @der_modif : 18 févr. 2010 - 09:04:11
*
*/
package packutils;
// Importations.
import java.awt.Graphics;
import java.util.Random;
/**
*
* @class cCadreScroll
*
*/
public class cCadreScroll extends cBaseFontePanel {
// Constantes privées.
private static final long serialVersionUID = 5439666621782555786L;
private static final int WAIT_BEFORE_ALEATOIRE = 20;
// Variables privées.
private String ligne_haute;
private String ligne_basse;
private char[] gen1, gen2;
private Random generator;
private int CptBeforeAleatoire = 0;
public cCadreScroll(String iTexte, int x, int y) {
super(iTexte, x, y);
// Préparation de l'écran.
// 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];
this.generator = new Random();
}
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 ]!="") {
if (this.CptBeforeAleatoire == 0) {
this.gen1[Ind] = (char) (228 + this.generator.nextInt(235 - 228 + 1));
this.gen2[Ind] = (char) (228 + this.generator.nextInt(235 - 228 + 1));
}
PrintLine(g, this.gen1[Ind]+" "+TabTexte[ Ind ]+" "+this.gen2[Ind], x, y);
y += HEIGHT_PIXEL_CHAR;
Ind++;
}
this.CptBeforeAleatoire++; if (this.CptBeforeAleatoire > WAIT_BEFORE_ALEATOIRE) this.CptBeforeAleatoire = 0;
PrintLine(g, (char) 224 + this.ligne_basse + (char) 225, x, y);
String Save = this.ligne_haute.substring(1);
this.ligne_haute = Save + (char) (249 + this.generator.nextInt(255 - 249));
Save = this.ligne_basse.substring(0, this.ligne_basse.length() - 1);
this.ligne_basse = (char) (242 + this.generator.nextInt(248 - 242 + 1)) + Save;
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
PrintTexteCadre(g, this.TabTexte, this.x, this.y);
}
}