parent
db1f986314
commit
d959a4d2f0
@ -0,0 +1,37 @@
|
||||
package view.cellules;
|
||||
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ListCell;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
import view_modele.CouleurVM;
|
||||
|
||||
|
||||
public class CelluleCouleur extends ListCell<CouleurVM> {
|
||||
|
||||
private BorderPane layout = new BorderPane();
|
||||
|
||||
private Rectangle rectangleCouleur;
|
||||
|
||||
private Label couleur = new Label();
|
||||
|
||||
@Override
|
||||
protected void updateItem(CouleurVM item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if(!empty){
|
||||
rectangleCouleur = new Rectangle(30,10, Color.rgb(item.getRouge(), item.getVert(), item.getBleue()));
|
||||
couleur.textProperty().bind(Bindings.concat(item.rougeProperty(), ", ", item.vertProperty(), ", ", item.bleueProperty()));
|
||||
layout.setLeft(rectangleCouleur);
|
||||
layout.setCenter(couleur);
|
||||
setGraphic(layout);
|
||||
}
|
||||
else{
|
||||
rectangleCouleur = null;
|
||||
couleur.textProperty().unbind();
|
||||
setGraphic(null);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package view.cellules;
|
||||
|
||||
import javafx.scene.control.ListCell;
|
||||
import view_modele.TailleVM;
|
||||
|
||||
public class CelluleTaille extends ListCell<TailleVM> {
|
||||
|
||||
@Override
|
||||
protected void updateItem(TailleVM item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if(!empty){
|
||||
setText(item.toString());
|
||||
}
|
||||
else{
|
||||
setText("");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package view_modele;
|
||||
|
||||
import Modele.metier.Couleur;
|
||||
import javafx.beans.property.IntegerProperty;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
|
||||
import javax.swing.plaf.IconUIResource;
|
||||
|
||||
public class CouleurVM {
|
||||
|
||||
private Couleur modele;
|
||||
|
||||
private IntegerProperty vert = new SimpleIntegerProperty();
|
||||
public int getVert() { return vert.get(); }
|
||||
public IntegerProperty vertProperty() { return vert; }
|
||||
public void setVert(int vert) { this.vert.set(vert); }
|
||||
|
||||
private IntegerProperty rouge = new SimpleIntegerProperty();
|
||||
public int getRouge() { return rouge.get(); }
|
||||
public IntegerProperty rougeProperty() { return rouge; }
|
||||
public void setRouge(int rouge) { this.rouge.set(rouge); }
|
||||
|
||||
private IntegerProperty bleue = new SimpleIntegerProperty();
|
||||
public int getBleue() { return bleue.get(); }
|
||||
public IntegerProperty bleueProperty() { return bleue; }
|
||||
public void setBleue(int bleue) { this.bleue.set(bleue); }
|
||||
|
||||
public CouleurVM(Couleur modele) {
|
||||
this.modele = modele;
|
||||
setVert(modele.getVert());
|
||||
setRouge(modele.getRouge());
|
||||
setBleue(modele.getBleue());
|
||||
}
|
||||
|
||||
public CouleurVM(int vert, int rouge, int bleue){
|
||||
this(new Couleur(vert, rouge, bleue));
|
||||
}
|
||||
|
||||
public Couleur getModele() {
|
||||
return modele;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj){
|
||||
if(obj == null) return false;
|
||||
if(this == obj) return true;
|
||||
if(getClass() != obj.getClass()) return false;
|
||||
|
||||
CouleurVM other = (CouleurVM)obj;
|
||||
return modele.equals(other.modele);
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package view_modele;
|
||||
|
||||
public enum TailleVM {
|
||||
|
||||
XS,
|
||||
S,
|
||||
M,
|
||||
L,
|
||||
XL
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package view_modele;
|
||||
|
||||
import Modele.metier.Taille;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TailleVMTailleConverter {
|
||||
|
||||
public static Taille toTaille(TailleVM taille){
|
||||
Taille ans = null;
|
||||
switch (taille){
|
||||
case XS -> ans = Taille.XS;
|
||||
case S -> ans = Taille.S;
|
||||
case M -> ans = Taille.M;
|
||||
case L -> ans = Taille.L;
|
||||
case XL -> ans = Taille.XL;
|
||||
}
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
||||
public static List<Taille> toTailles(List<TailleVM> tailles){
|
||||
List<Taille> ans = new ArrayList<>();
|
||||
for(var taille : tailles){
|
||||
ans.add(toTaille(taille));
|
||||
}
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
||||
public static TailleVM toTailleVM(Taille taille){
|
||||
TailleVM ans = null;
|
||||
switch (taille){
|
||||
case XS -> ans = TailleVM.XS;
|
||||
case S -> ans = TailleVM.S;
|
||||
case M -> ans = TailleVM.M;
|
||||
case L -> ans = TailleVM.L;
|
||||
case XL -> ans = TailleVM.XL;
|
||||
}
|
||||
|
||||
return ans;
|
||||
}
|
||||
|
||||
public static List<TailleVM> toTaillesVM(List<Taille> tailles){
|
||||
List<TailleVM> ans = new ArrayList<>();
|
||||
for(var taille : tailles){
|
||||
ans.add(toTailleVM(taille));
|
||||
}
|
||||
|
||||
return ans;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue