2022-05-05 22:45:26 +02:00
|
|
|
|
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;
|
2022-05-05 22:45:26 +02:00
|
|
|
private paintChoix pinceau;
|
|
|
|
private boolean clique;
|
|
|
|
private int x;
|
|
|
|
private int fonction;
|
|
|
|
public paintChoix(int x0, int fonction0){
|
|
|
|
this.clique=false;
|
|
|
|
this.pinceau=null;
|
2022-04-20 00:33:31 +02:00
|
|
|
this.selectionner=false;
|
2022-05-05 22:45:26 +02:00
|
|
|
this.x=30-x0;
|
|
|
|
this.fonction=fonction0;
|
2022-04-20 00:33:31 +02:00
|
|
|
//de base ce n'est pas selectionner
|
|
|
|
}
|
|
|
|
public void selectionner(boolean verif){
|
|
|
|
this.selectionner=verif;
|
2022-05-05 22:45:26 +02:00
|
|
|
if(this.pinceau!=null){
|
|
|
|
this.pinceau.selectionner(verif);
|
|
|
|
}
|
|
|
|
this.repaint();
|
|
|
|
}
|
|
|
|
public void setPaintChoix(paintChoix pinceau0){
|
|
|
|
this.pinceau=pinceau0;
|
|
|
|
}
|
|
|
|
public void setClique(boolean verif){
|
|
|
|
this.clique=verif;
|
|
|
|
if(this.pinceau!=null){
|
|
|
|
this.pinceau.setClique(verif);
|
|
|
|
}
|
|
|
|
this.repaint();
|
|
|
|
}
|
|
|
|
public int getFonction(){
|
|
|
|
return this.fonction;
|
|
|
|
}
|
|
|
|
public int getN(){
|
|
|
|
return this.x;
|
2022-04-20 00:33:31 +02:00
|
|
|
}
|
|
|
|
@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());
|
|
|
|
}
|
2022-05-05 22:45:26 +02:00
|
|
|
if(this.clique==true){
|
|
|
|
secondPinceau.setColor(new Color(0, 127, 255));
|
2022-04-20 00:33:31 +02:00
|
|
|
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
|
|
|
}
|
2022-05-05 22:45:26 +02:00
|
|
|
if(selectionner==true){
|
|
|
|
secondPinceau.setColor(new Color(255, 127, 0));
|
|
|
|
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
2022-04-20 00:33:31 +02:00
|
|
|
}
|
2022-05-05 22:45:26 +02:00
|
|
|
secondPinceau.setColor(new Color(0,0,0));
|
|
|
|
secondPinceau.drawRect(0, 0, this.getWidth(), this.getHeight());
|
2022-05-20 13:39:53 +02:00
|
|
|
if(this.fonction==8){
|
|
|
|
secondPinceau.setColor(new Color(255, 255, 255));
|
|
|
|
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
|
|
|
Image nouveau=Toolkit.getDefaultToolkit().getImage("./IMAGE/nouveau.jpg");
|
|
|
|
if(this.selectionner==true){
|
|
|
|
secondPinceau.drawImage(nouveau, 0, 0, this.getWidth(), this.getHeight(), this);
|
|
|
|
}else{
|
|
|
|
secondPinceau.drawImage(nouveau, this.getWidth()/20, this.getHeight()/20, this.getWidth()/20*18, this.getHeight()/20*18, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(this.fonction==9){
|
|
|
|
secondPinceau.setColor(new Color(255, 255, 255));
|
|
|
|
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
|
|
|
Image quitter=Toolkit.getDefaultToolkit().getImage("./IMAGE/quitter.jpg");
|
|
|
|
if(this.selectionner==true){
|
|
|
|
secondPinceau.drawImage(quitter, 0, 0, this.getWidth(), this.getHeight(), this);
|
|
|
|
}else{
|
|
|
|
secondPinceau.drawImage(quitter, this.getWidth()/20, this.getHeight()/20, this.getWidth()/20*18, this.getHeight()/20*18, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(this.fonction==10){
|
|
|
|
secondPinceau.setColor(new Color(255, 255, 255));
|
|
|
|
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
|
|
|
Image reprendre=Toolkit.getDefaultToolkit().getImage("./IMAGE/reprendre.png");
|
|
|
|
if(this.selectionner==true){
|
|
|
|
secondPinceau.drawImage(reprendre, 0, 0, this.getWidth(), this.getHeight(), this);
|
|
|
|
}else{
|
|
|
|
secondPinceau.drawImage(reprendre, this.getWidth()/20, this.getHeight()/20, this.getWidth()/20*18, this.getHeight()/20*18, this);
|
|
|
|
}
|
|
|
|
}
|
2022-04-20 00:33:31 +02:00
|
|
|
}
|
|
|
|
}
|