fin tp3
This commit is contained in:
46
DEV3.2/TP03/02_Chaine/JParallelogramme.java
Normal file
46
DEV3.2/TP03/02_Chaine/JParallelogramme.java
Normal file
@@ -0,0 +1,46 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.util.Random;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class JParallelogramme extends JComponent {
|
||||
|
||||
private CouleurList<Color> listeCouleurs;
|
||||
|
||||
public JParallelogramme(CouleurList<Color> listeCouleurs) {
|
||||
this.setPreferredSize(new Dimension(280, 60));
|
||||
|
||||
this.listeCouleurs = listeCouleurs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics pinceau) {
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
|
||||
if (this.isOpaque()) {
|
||||
secondPinceau.setColor(this.getBackground());
|
||||
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
}
|
||||
|
||||
int[] x = {30, 50, 20, 0};
|
||||
int[] y = {0, 0, this.getHeight(), this.getHeight()};
|
||||
|
||||
|
||||
for (Color couleur : this.listeCouleurs) {
|
||||
secondPinceau.setColor(couleur);
|
||||
secondPinceau.fillPolygon(x, y, 4);
|
||||
secondPinceau.setColor(Color.DARK_GRAY);
|
||||
secondPinceau.drawPolygon(x, y, 4);
|
||||
|
||||
for (int j = 0; j != 4; j++) {
|
||||
x[j] += 25;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public CouleurList<Color> getListeCouleurs() {
|
||||
return this.listeCouleurs;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user