ressources de base

This commit is contained in:
chmantha-ets
2026-09-14 21:47:10 -04:00
commit e09ae708be
33 changed files with 370 additions and 0 deletions

Binary file not shown.

BIN
src/ressources/E0%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B

BIN
src/ressources/E100%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 852 B

BIN
src/ressources/E33%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 862 B

BIN
src/ressources/E66%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 854 B

BIN
src/ressources/UA0%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 913 B

BIN
src/ressources/UA100%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 904 B

BIN
src/ressources/UA33%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 921 B

BIN
src/ressources/UA66%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 917 B

BIN
src/ressources/UM0%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 B

BIN
src/ressources/UM100%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 779 B

BIN
src/ressources/UM33%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 799 B

BIN
src/ressources/UM66%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 786 B

BIN
src/ressources/UMP0%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 773 B

BIN
src/ressources/UMP100%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 765 B

BIN
src/ressources/UMP33%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 780 B

BIN
src/ressources/UMP66%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 768 B

BIN
src/ressources/UT0%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 B

BIN
src/ressources/UT100%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 858 B

BIN
src/ressources/UT33%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 866 B

BIN
src/ressources/UT66%.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 B

BIN
src/ressources/aile.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
src/ressources/avion.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<metadonnees>
<usine type="usine-matiere">
<icones>
<icone type="vide" path="src/ressources/UMP0%.png"/>
<icone type="un-tiers" path="src/ressources/UMP33%.png"/>
<icone type="deux-tiers" path="src/ressources/UMP66%.png"/>
<icone type="plein" path="src/ressources/UMP100%.png"/>
</icones>
<sortie type = "metal"/>
<interval-production>100</interval-production>
</usine>
<usine type="usine-aile">
<icones>
<icone type="vide" path="src/ressources/UT0%.png"/>
<icone type="un-tiers" path="src/ressources/UT33%.png"/>
<icone type="deux-tiers" path="src/ressources/UT66%.png"/>
<icone type="plein" path="src/ressources/UT100%.png"/>
</icones>
<entree type="metal" quantite="2"/>
<sortie type="aile"/>
<interval-production>50</interval-production>
</usine>
<usine type="usine-moteur">
<icones>
<icone type="vide" path="src/ressources/UM0%.png"/>
<icone type="un-tiers" path="src/ressources/UM33%.png"/>
<icone type="deux-tiers" path="src/ressources/UM66%.png"/>
<icone type="plein" path="src/ressources/UM100%.png"/>
</icones>
<entree type="metal" quantite="4"/>
<sortie type="moteur"/>
<interval-production>75</interval-production>
</usine>
<usine type="usine-assemblage">
<icones>
<icone type="vide" path="src/ressources/UA0%.png"/>
<icone type="un-tiers" path="src/ressources/UA33%.png"/>
<icone type="deux-tiers" path="src/ressources/UA66%.png"/>
<icone type="plein" path="src/ressources/UA100%.png"/>
</icones>
<entree type="aile" quantite="2"/>
<entree type="moteur" quantite="4"/>
<sortie type="avion"/>
<interval-production>110</interval-production>
</usine>
<usine type="entrepot">
<icones>
<icone type="vide" path="src/ressources/E0%.png"/>
<icone type="un-tiers" path="src/ressources/E33%.png"/>
<icone type="deux-tiers" path="src/ressources/E66%.png"/>
<icone type="plein" path="src/ressources/E100%.png"/>
</icones>
<entree type="avion" capacite="5"/>
</usine>
</metadonnees>
<simulation>
<usine type="usine-matiere" id="11" x="32" y="32"/>
<usine type="usine-aile" id="21" x="320" y="32"/>
<usine type="usine-assemblage" id="41" x="160" y="192"/>
<usine type="entrepot" id="51" x="640" y="192"/>
<usine type="usine-matiere" id="13" x="544" y="576"/>
<usine type="usine-matiere" id="12" x="96" y="352"/>
<usine type="usine-moteur" id="31" x="320" y="352"/>
<chemins>
<chemin de="11" vers="21" />
<chemin de="21" vers="41" />
<chemin de="41" vers="51" />
<chemin de="12" vers="31" />
<chemin de="13" vers="31" />
<chemin de="31" vers="41" />
</chemins>
</simulation>
</configuration>

BIN
src/ressources/metal.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
src/ressources/moteur.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,21 @@
package simulation;
import javax.swing.SwingWorker;
public class Environnement extends SwingWorker<Object, String> {
private boolean actif = true;
private static final int DELAI = 100;
@Override
protected Object doInBackground() throws Exception {
while(actif) {
Thread.sleep(DELAI);
/**
* C'est ici que vous aurez à faire la gestion de la notion de tour.
*/
firePropertyChange("TEST", null, "Ceci est un test");
}
return null;
}
}

View File

@@ -0,0 +1,40 @@
package simulation;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import javax.swing.JFrame;
public class FenetrePrincipale extends JFrame implements PropertyChangeListener {
private static final long serialVersionUID = 1L;
private static final String TITRE_FENETRE = "Laboratoire 1 : LOG121 - Simulation";
private static final Dimension DIMENSION = new Dimension(700, 700);
public FenetrePrincipale() {
PanneauPrincipal panneauPrincipal = new PanneauPrincipal();
MenuFenetre menuFenetre = new MenuFenetre();
add(panneauPrincipal);
add(menuFenetre, BorderLayout.NORTH);
// Faire en sorte que le X de la fenêtre ferme la fenêtre
setDefaultCloseOperation(EXIT_ON_CLOSE);
setTitle(TITRE_FENETRE);
setSize(DIMENSION);
// Rendre la fenêtre visible
setVisible(true);
// Mettre la fenêtre au centre de l'écran
setLocationRelativeTo(null);
// Empêcher la redimension de la fenêtre
setResizable(false);
}
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("TEST")) {
repaint();
System.out.println(evt.getNewValue());
}
}
}

View File

@@ -0,0 +1,23 @@
package simulation;
import java.awt.Dimension;
import javax.swing.JFrame;
public class FenetreStrategie extends JFrame {
private static final long serialVersionUID = 1L;
private static final String TITRE_FENETRE = "Sélectionnez votre stratégie de vente";
private static final Dimension DIMENSION = new Dimension(250, 100);
private PanneauStrategie panneauStrategie = new PanneauStrategie();
public FenetreStrategie() {
add(panneauStrategie);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setTitle(TITRE_FENETRE);
setSize(DIMENSION);
setVisible(true);
setLocationRelativeTo(null);
setResizable(false);
}
}

View File

@@ -0,0 +1,103 @@
package simulation;
import java.awt.event.ActionEvent;
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.filechooser.FileSystemView;
public class MenuFenetre extends JMenuBar {
private static final long serialVersionUID = 1L;
private static final String MENU_FICHIER_TITRE = "Fichier";
private static final String MENU_FICHIER_CHARGER = "Charger";
private static final String MENU_FICHIER_QUITTER = "Quitter";
private static final String MENU_SIMULATION_TITRE = "Simulation";
private static final String MENU_SIMULATION_CHOISIR = "Choisir";
private static final String MENU_AIDE_TITRE = "Aide";
private static final String MENU_AIDE_PROPOS = "À propos de...";
public MenuFenetre() {
ajouterMenuFichier();
ajouterMenuSimulation();
ajouterMenuAide();
}
/**
* Créer le menu de Fichier
*/
private void ajouterMenuFichier() {
JMenu menuFichier = new JMenu(MENU_FICHIER_TITRE);
JMenuItem menuCharger = new JMenuItem(MENU_FICHIER_CHARGER);
JMenuItem menuQuitter = new JMenuItem(MENU_FICHIER_QUITTER);
menuCharger.addActionListener((ActionEvent e) -> {
JFileChooser fileChooser = new JFileChooser(FileSystemView.getFileSystemView().getHomeDirectory());
fileChooser.setDialogTitle("Sélectionnez un fichier de configuration");
fileChooser.setAcceptAllFileFilterUsed(false);
// Créer un filtre
FileNameExtensionFilter filtre = new FileNameExtensionFilter(".xml", "xml");
fileChooser.addChoosableFileFilter(filtre);
int returnValue = fileChooser.showOpenDialog(null);
if (returnValue == JFileChooser.APPROVE_OPTION) {
// TODO - Parser le fichier XML sélectionné
File selectedFile = fileChooser.getSelectedFile();
System.out.println(selectedFile.getAbsolutePath());
}
});
menuQuitter.addActionListener((ActionEvent e) -> {
System.exit(0);
});
menuFichier.add(menuCharger);
menuFichier.add(menuQuitter);
add(menuFichier);
}
/**
* Créer le menu de Simulation
*/
private void ajouterMenuSimulation() {
JMenu menuSimulation = new JMenu(MENU_SIMULATION_TITRE);
JMenuItem menuChoisir = new JMenuItem(MENU_SIMULATION_CHOISIR);
menuSimulation.add(menuChoisir);
menuChoisir.addActionListener((ActionEvent e) -> {
// Ouvrir la fenêtre de sélection
// TODO - Récupérer la bonne stratégie de vente
new FenetreStrategie();
});
add(menuSimulation);
}
/**
* Créer le menu Aide
*/
private void ajouterMenuAide() {
JMenu menuAide = new JMenu(MENU_AIDE_TITRE);
JMenuItem menuPropos = new JMenuItem(MENU_AIDE_PROPOS);
menuAide.add(menuPropos);
menuPropos.addActionListener((ActionEvent e) -> {
JOptionPane.showMessageDialog(null,
"<html><p>Application simulant une chaine de production d'avions.</p>" + "<br>"
+ "<p>&copy; &nbsp; 2017 &nbsp; Ghizlane El Boussaidi</p>"
+ "<p>&copy; &nbsp; 2017 &nbsp; Dany Boisvert</p>"
+ "<p>&copy; &nbsp; 2017 &nbsp; Vincent Mattard</p>" + "<br>"
+ "<p>&Eacute;cole de technologie sup&eacute;rieure</p></html>");
});
add(menuAide);
}
}

View File

@@ -0,0 +1,25 @@
package simulation;
import java.awt.Graphics;
import java.awt.Point;
import javax.swing.JPanel;
public class PanneauPrincipal extends JPanel {
private static final long serialVersionUID = 1L;
// Variables temporaires de la demonstration:
private Point position = new Point(0,0);
private Point vitesse = new Point(1,1);
private int taille = 32;
@Override
public void paint(Graphics g) {
super.paint(g);
// On ajoute à la position le delta x et y de la vitesse
position.translate(vitesse.x, vitesse.y);
g.fillRect(position.x, position.y, taille, taille);
}
}

View File

@@ -0,0 +1,65 @@
package simulation;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.util.Enumeration;
import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.SwingUtilities;
public class PanneauStrategie extends JPanel {
private static final long serialVersionUID = 1L;
public PanneauStrategie() {
ButtonGroup groupeBoutons = new ButtonGroup();
JRadioButton strategie1 = new JRadioButton("Stratégie 1");
JRadioButton strategie2 = new JRadioButton("Stratégie 2");
JButton boutonConfirmer = new JButton("Confirmer");
boutonConfirmer.addActionListener((ActionEvent e) -> {
// TODO - Appeler la bonne stratégie
System.out.println(getSelectedButtonText(groupeBoutons));
// Fermer la fenêtre du composant
SwingUtilities.getWindowAncestor((Component) e.getSource()).dispose();
});
JButton boutonAnnuler = new JButton("Annuler");
boutonAnnuler.addActionListener((ActionEvent e) -> {
// Fermer la fenêtre du composant
SwingUtilities.getWindowAncestor((Component) e.getSource()).dispose();
});
groupeBoutons.add(strategie1);
groupeBoutons.add(strategie2);
add(strategie1);
add(strategie2);
add(boutonConfirmer);
add(boutonAnnuler);
}
/**
* Retourne le bouton sélectionné dans un groupe de boutons.
* @param groupeBoutons
* @return
*/
public String getSelectedButtonText(ButtonGroup groupeBoutons) {
for (Enumeration<AbstractButton> boutons = groupeBoutons.getElements(); boutons.hasMoreElements();) {
AbstractButton bouton = boutons.nextElement();
if (bouton.isSelected()) {
return bouton.getText();
}
}
return null;
}
}

View File

@@ -0,0 +1,16 @@
package simulation;
public class Simulation {
/**
* Cette classe représente l'application dans son ensemble.
*/
public static void main(String[] args) {
Environnement environnement = new Environnement();
FenetrePrincipale fenetre = new FenetrePrincipale();
environnement.addPropertyChangeListener(fenetre);
environnement.execute();
}
}