2023-04-23 23:34:51 +02:00
|
|
|
import java.awt.Color;
|
|
|
|
import javax.swing.JComponent;
|
|
|
|
|
|
|
|
import java.awt.Graphics;
|
|
|
|
|
|
|
|
public class Cellules extends JComponent{
|
|
|
|
public static final int COULOIR=0;
|
|
|
|
public static final int MUR=1;
|
|
|
|
public static final int ENTREE=2;
|
|
|
|
public static final int SORTIE=3;
|
|
|
|
|
2023-04-27 21:19:45 +02:00
|
|
|
public static final int DESSUS=10;
|
|
|
|
public static final int VUE=11;
|
|
|
|
|
|
|
|
public static final boolean LIBRE = false;
|
|
|
|
public static final boolean OCCUPE = true;
|
|
|
|
|
2023-04-23 23:34:51 +02:00
|
|
|
private Color backgroundColor;
|
|
|
|
|
|
|
|
private int cetteLigne;
|
|
|
|
private int cetteColone;
|
|
|
|
private int ceType;
|
|
|
|
|
|
|
|
public Cellules(int uneLigne, int uneColone, int type){
|
|
|
|
super();
|
|
|
|
this.cetteLigne=uneLigne;
|
|
|
|
this.cetteColone=uneColone;
|
|
|
|
|
|
|
|
this.ceType = type;
|
|
|
|
|
|
|
|
peindre(ceType);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLigne(){
|
|
|
|
return this.cetteLigne;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getColone(){
|
|
|
|
return this.cetteColone;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getType(){
|
|
|
|
return this.ceType;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setType(int newType){
|
|
|
|
if(newType==COULOIR){
|
|
|
|
this.ceType = COULOIR;
|
|
|
|
} else if(newType==MUR){
|
|
|
|
this.ceType = MUR;
|
|
|
|
} else if(newType==ENTREE){
|
|
|
|
this.ceType = ENTREE;
|
|
|
|
} else if(newType==SORTIE){
|
|
|
|
this.ceType = SORTIE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void peindre(int peinture){
|
|
|
|
if(peinture==COULOIR){
|
|
|
|
backgroundColor = Color.WHITE;
|
|
|
|
} else if(peinture==MUR){
|
|
|
|
backgroundColor = Color.BLACK;
|
|
|
|
} else if(peinture==ENTREE){
|
|
|
|
backgroundColor = Color.BLUE;
|
|
|
|
} else if(peinture==SORTIE){
|
|
|
|
backgroundColor = Color.RED;
|
2023-04-27 21:19:45 +02:00
|
|
|
} else if(peinture==VUE){
|
|
|
|
backgroundColor = Color.YELLOW;
|
|
|
|
} else if(peinture==DESSUS){
|
|
|
|
backgroundColor = Color.ORANGE;
|
2023-04-23 23:34:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void paintComponent(Graphics g) {
|
|
|
|
super.paintComponent(g);
|
|
|
|
|
|
|
|
g.setColor(backgroundColor);
|
|
|
|
g.fillRect(0, 0, getWidth(), getHeight());
|
|
|
|
}
|
|
|
|
}
|