correction de la vue de pendue

This commit is contained in:
2025-10-08 12:34:54 +02:00
parent e5f9fd7fa8
commit d07d4a7adc
3 changed files with 76 additions and 1 deletions

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

View File

@@ -0,0 +1,75 @@
package fr.iutfbleau.TD3_DEV51_Qualite_Algo.View;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.io.File;
import java.io.IOException;
public class hangedManView extends JComponent {
private int state;
public hangedManView() throws IOException {
super();
this.state = 0;
}
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
int x = 150;
int y = 200;
if(this.state > 8) {
// paint une image
g2d.drawImage(new ImageIcon(Thread.currentThread().getContextClassLoader().getResource("resources/HangedGirl.jpg")).getImage(), x, y, this);
}else{
// on paint un homme batton
// Base
if (this.state > 0) {
g2d.drawLine(x - 100, y + 100, x + 100, y + 100);
}
// Poteau vertical
if (this.state > 1) {
g2d.drawLine(x - 50, y + 100, x - 50, y - 100);
}
// Traverse horizontale
if (this.state > 2) {
g2d.drawLine(x - 50, y - 100, x + 50, y - 100);
}
// Petite corde verticale
if (this.state > 3) {
g2d.drawLine(x + 50, y - 100, x + 50, y - 70);
}
x += 50;
y -= 40;
// Tête
if (this.state > 4) {
g2d.drawOval(x - 15, y - 30, 30, 30);
}
// Corps
if (this.state > 5) {
g2d.drawLine(x, y, x, y + 40);
}
// Bras
if (this.state > 6) {
g2d.drawLine(x, y + 10, x - 20, y + 20);
g2d.drawLine(x, y + 10, x + 20, y + 20);
}
// Jambes
if (this.state > 7) {
g2d.drawLine(x, y + 40, x - 20, y + 70);
g2d.drawLine(x, y + 40, x + 20, y + 70);
}
}
}
public void setState(int state) {
this.state = state;
}
}