package viewGraphique;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JPanel;
import modele.event.HeureChangedEvent;
public class Dessin extends JPanel
{
private double hauteur = -1;
private double angle = -1;
private int heure = -1;
public Dessin()
{
this.hauteur = 9;
this.setPreferredSize(new Dimension(544, 600));
}
@Override
protected void paintComponent(Graphics g)
{
// TODO Auto-generated method stub
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
if (this.heure != -1)
{
if (this.heure > 8 && this.heure < 20)
{
g2d.setColor(Color.CYAN);
g2d.fillRect(0, 0, 544, 400);
g2d.setColor(Color.YELLOW);
g2d.fillOval(30, 30, 75, 75);
} else
{
g2d.setColor(Color.DARK_GRAY);
g2d.fillRect(0, 0, 544, 400);
g2d.setColor(Color.WHITE);
g2d.fillOval(30, 30, 75, 75);
g2d.setColor(Color.DARK_GRAY);
g2d.fillOval(35, 35, 5, 5);
g2d.fillOval(38, 35, 5, 5);
g2d.fillOval(40, 40, 5, 5);
g2d.fillOval(42, 39, 5, 5);
g2d.fillOval(45, 44, 5, 5);
g2d.fillOval(42, 49, 5, 5);
g2d.fillOval(48, 42, 5, 5);
g2d.fillOval(50, 54, 5, 5);
g2d.fillOval(57, 54, 5, 5);
g2d.fillOval(35, 35, 5, 5);
g2d.fillOval(38, 35, 5, 5);
g2d.fillOval(54, 40, 5, 5);
g2d.fillOval(67, 39, 5, 5);
g2d.fillOval(63, 44, 5, 5);
g2d.fillOval(61, 49, 5, 5);
g2d.fillOval(57, 42, 5, 5);
g2d.fillOval(72, 54, 5, 5);
g2d.fillOval(76, 54, 5, 5);
g2d.fillOval(70, 60, 5, 5);
g2d.fillOval(72, 64, 5, 5);
g2d.fillOval(74, 61, 5, 5);
g2d.fillOval(71, 72, 5, 5);
g2d.fillOval(76, 80, 5, 5);
g2d.fillOval(72, 70, 5, 5);
g2d.fillOval(68, 80, 5, 5);
g2d.fillOval(78, 78, 5, 5);
g2d.fillOval(80, 80, 5, 5);
}
} else
{
g2d.setColor(Color.RED);
}
g2d.setColor(Color.BLUE);
g2d.fillRect(0, (int) (200 - (this.hauteur * 33.33) + 200), 544, 500);
g2d.setColor(Color.BLACK);
g2d.fillRect(30, 150, 5, 225);
g2d.fillRect(30, 375, 200, 5);
g2d.fillRect(225, 250, 5, 125); // Vanne
g2d.drawLine(225, 350, 500, 400);
}
public void notifyHeureChanged(HeureChangedEvent event)
{
this.hauteur = event.getNewHauteur();
this.angle = event.getNewAngleVanneOmniflot();
this.heure = event.getNewHeure();
repaint();
}
}