2022-04-20 00:33:31 +02:00
|
|
|
// Tom Monin et Clément Martins
|
|
|
|
// paintChoix V1
|
|
|
|
// class pour l'affichage de la selection des lignes, collonnes et nombre de mines
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
import javax.swing.*;
|
|
|
|
import javax.swing.JComponent;
|
|
|
|
|
|
|
|
public class paintChoix extends JComponent{
|
|
|
|
private boolean selectionner;
|
|
|
|
private int direction;
|
|
|
|
|
|
|
|
public paintChoix(int direction0){
|
|
|
|
|
|
|
|
this.selectionner=false;
|
|
|
|
//de base ce n'est pas selectionner
|
|
|
|
this.direction=direction0;
|
|
|
|
//initialser arbitrairement sur 0
|
2022-04-28 18:20:22 +02:00
|
|
|
|
2022-04-20 00:33:31 +02:00
|
|
|
}
|
|
|
|
public void selectionner(boolean verif){
|
|
|
|
this.selectionner=verif;
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
protected void paintComponent(Graphics pinceau) {
|
|
|
|
// obligatoire : on crée un nouveau pinceau pour pouvoir le modifier plus tard
|
|
|
|
Graphics secondPinceau = pinceau.create();
|
|
|
|
// obligatoire : si le composant n'est pas censé être transparent
|
|
|
|
if (this.isOpaque()) {
|
|
|
|
// obligatoire : on repeint toute la surface avec la couleur de fond
|
|
|
|
secondPinceau.setColor(this.getBackground());
|
|
|
|
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
|
|
|
}
|
|
|
|
if(selectionner==true){
|
|
|
|
secondPinceau.setColor(new Color(0,255,255));
|
|
|
|
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
|
|
|
}else{
|
|
|
|
secondPinceau.setColor(new Color(215,215,215));
|
|
|
|
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
|
|
|
}
|
|
|
|
if(this.direction==1){
|
|
|
|
secondPinceau.setColor(new Color(0,0,0));
|
|
|
|
secondPinceau.fillRect(this.getWidth()/5, this.getHeight()/3, this.getWidth()/5*4, this.getHeight()/3);
|
|
|
|
int[] x= new int[3];
|
|
|
|
int[] y= new int[3];
|
|
|
|
x[0]=this.getWidth()/5;
|
|
|
|
x[1]=0;
|
|
|
|
x[2]=x[0];
|
|
|
|
y[0]=0;
|
|
|
|
y[1]=this.getHeight()/2;
|
|
|
|
y[2]=this.getHeight();
|
|
|
|
secondPinceau.fillPolygon(x, y, 3);
|
|
|
|
}
|
|
|
|
if(this.direction==2){
|
|
|
|
secondPinceau.setColor(new Color(0,0,0));
|
|
|
|
secondPinceau.fillRect(0, this.getHeight()/3, this.getWidth()/5*4, this.getHeight()/3);
|
|
|
|
int[] x= new int[3];
|
|
|
|
int[] y= new int[3];
|
|
|
|
x[0]=this.getWidth()/5*4;
|
|
|
|
x[1]=this.getWidth();
|
|
|
|
x[2]=x[0];
|
|
|
|
y[0]=0;
|
|
|
|
y[1]=this.getHeight()/2;
|
|
|
|
y[2]=this.getHeight();
|
|
|
|
secondPinceau.fillPolygon(x, y, 3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|