Skip to content
Snippets Groups Projects
Commit d0f18e55 authored by Matias Mennecart's avatar Matias Mennecart
Browse files

Ajouts des scripts de lancement et d'executions

parent ab2d647a
No related branches found
No related tags found
No related merge requests found
Showing
with 145 additions and 64 deletions
File added
#!/bin/bash
# Vérifie si le répertoire contient un projet Maven (pom.xml)
if [ ! -f "pom.xml" ]; then
echo "Erreur : Aucun fichier pom.xml trouvé dans le répertoire actuel."
echo "Veuillez exécuter ce script dans un répertoire Maven valide."
exit 1
fi
# Exécute mvn clean
echo "Exécution de 'mvn clean'..."
mvn clean
if [ $? -ne 0 ]; then
echo "Erreur : 'mvn clean' a échoué. Veuillez verifier que maven est bien installé"
exit 1
fi
# Exécute mvn install
echo "Exécution de 'mvn install'..."
mvn install
if [ $? -ne 0 ]; then
echo "Erreur : 'mvn install' a échoué. Veuillez verifier que maven est bien installé"
exit 1
fi
echo "Build Maven terminé avec succès."
\ No newline at end of file
......@@ -15,17 +15,11 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<version>3.8.0</version>
<configuration>
<source>11</source>
<target>11</target>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
......@@ -34,7 +28,33 @@
<mainClass>fr.univlille.sae.classification.Main</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<transformer implementation=
"org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>fr.univlille.sae.classification.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>res/</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<dependencies>
......
run.sh 0 → 100644
#!/bin/bash
# Noms des fichiers à vérifier
fichier1="ClassificationApp-1.0-shaded.jar"
fichier2="target/ClassificationApp-1.0-shaded.jar"
# Vérifie si le premier fichier existe
if [ -f "$fichier1" ]; then
echo "Execution de $fichier1 ..."
java -jar "$fichier1"
# Sinon, vérifie si le deuxième fichier existe
elif [ -f "$fichier2" ]; then
echo "Execution de $fichier1 ..."
java -jar "$fichier2"
# Si aucun des deux fichiers n'existe, affiche un message d'erreur
else
echo "Erreur : Aucun des fichiers $fichier1 ou $fichier2 n'existe. Veuillez compiler le projet avec le script fournis"
fi
\ No newline at end of file
package fr.univlille.sae.classification;
import fr.univlille.sae.classification.model.ClassificationModel;
import fr.univlille.sae.classification.view.MainStageView;
import javafx.application.Application;
import javafx.stage.Stage;
import java.io.IOException;
public class ClassificationApp extends Application {
public void start(Stage stage) throws IOException {
ClassificationModel model = ClassificationModel.getClassificationModel();
MainStageView view = new MainStageView(model);
view.show();
}
// Ouvre l'application
public static void main(String[] args) {
Application.launch(args);
}
}
......@@ -7,22 +7,8 @@ import javafx.stage.Stage;
import java.io.IOException;
public class Main extends Application {
public void start(Stage stage) throws IOException {
ClassificationModel model = ClassificationModel.getClassificationModel();
MainStageView view = new MainStageView(model);
view.show();
}
// Ouvre l'application
public class Main {
public static void main(String[] args) {
Application.launch(args);
ClassificationApp.main(args);
}
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package fr.univlille.sae.classification.controller;
import fr.univlille.sae.classification.model.ClassificationModel;
import fr.univlille.sae.classification.view.MainStageView;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.Spinner;
import javafx.scene.control.SpinnerValueFactory;
import javafx.stage.Stage;
......@@ -67,8 +68,15 @@ public class AddDataController {
System.out.println("validé");
mainStageView.getController().getClassifyData().setDisable(false);
ClassificationModel.getClassificationModel().ajouterDonnee(sepalLengthSpinner.getValue(), sepalWidthSpinner.getValue(), petalLengthSpinner.getValue(), petalWidthSpinner.getValue());
try{
ClassificationModel.getClassificationModel().ajouterDonnee(sepalLengthSpinner.getValue(), sepalWidthSpinner.getValue(), petalLengthSpinner.getValue(), petalWidthSpinner.getValue());
}catch (IllegalArgumentException e){
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Erreur");
alert.setHeaderText(null);
alert.setContentText(e.getMessage());
alert.showAndWait();
}
stage.close();
}
......
......@@ -52,8 +52,9 @@ public class ClassificationModel extends Observable {
/**
* Ajoute un point au nuage de points avec toutes les données de ce point.
* @param coords toutes les données du point.
* @throws IllegalArgumentException si le nombre de coordonnées ne correspond pas au type spécifié.
*/
public void ajouterDonnee(double... coords) {
public void ajouterDonnee(double... coords) throws IllegalArgumentException {
LoadableData newData = PointFactory.createPoint(type, coords);
this.dataToClass.add(newData);
notifyObservers(newData);
......
......@@ -12,11 +12,10 @@ public class PointFactory {
* @return instance de LoadableData correspondant aux coordonnées, ou null en cas d'erreur.
* @throws IllegalArgumentException si le nombre de coordonnées ne correspond pas au type spécifié.
*/
public static LoadableData createPoint(DataType type, double[] coords) {
public static LoadableData createPoint(DataType type, double[] coords) throws IllegalArgumentException {
int size = coords.length;
LoadableData data;
try {
switch (type) {
case IRIS:
if (size != 4) {
......@@ -27,10 +26,7 @@ public class PointFactory {
default:
throw new IllegalArgumentException("Type de données non supporté : " + type);
}
} catch (IllegalArgumentException e) {
System.err.println("Erreur lors de la création du point : " + e.getMessage());
return null;
}
return data;
}
......
......@@ -37,14 +37,9 @@ public class AddDataView {
*/
public void show() {
FXMLLoader loader = new FXMLLoader();
URL fxmlFileUrl = null;
URL fxmlFileUrl = getClass().getClassLoader().getResource("stages"+File.separator+"add-data-stage.fxml");
try {
fxmlFileUrl = new File(System.getProperty("user.dir") + File.separator + "res" + File.separator + "stages" + File.separator + "add-data-stage.fxml").toURI().toURL();
} catch (IOException e) {
System.out.println("Erreur lors de la création de l'URL du fichier FXML : " + e.getMessage());
return;
}
if (fxmlFileUrl == null) {
System.out.println("Impossible de charger le fichier fxml");
......
......@@ -38,14 +38,8 @@ public class AxesSettingsView {
*/
public void show() {
FXMLLoader loader = new FXMLLoader();
URL fxmlFileUrl = null;
URL fxmlFileUrl = getClass().getClassLoader().getResource("stages"+File.separator+"axes-settings-stage.fxml");
try {
fxmlFileUrl = new File(System.getProperty("user.dir") + File.separator + "res" + File.separator + "stages" + File.separator + "axes-settings-stage.fxml").toURI().toURL();
} catch (IOException e) {
System.out.println("Erreur lors de la création de l'URL du fichier FXML : " + e.getMessage());
return;
}
if (fxmlFileUrl == null) {
System.out.println("Impossible de charger le fichier fxml");
......
......@@ -58,7 +58,7 @@ public class DataStageView extends DataVisualizationView implements Observer {
FXMLLoader loader = new FXMLLoader();
try {
URL fxmlFileUrl = new File(System.getProperty("user.dir") + File.separator + "res" + File.separator + "stages" + File.separator + "data-view-stage.fxml").toURI().toURL();
URL fxmlFileUrl = getClass().getClassLoader().getResource("stages"+File.separator+"data-view-stage.fxml");
if (fxmlFileUrl == null) {
System.out.println("Impossible de charger le fichier fxml");
......
......@@ -32,14 +32,7 @@ public class LoadDataView {
*/
public void show() {
FXMLLoader loader = new FXMLLoader();
URL fxmlFileUrl = null;
try {
fxmlFileUrl = new File(System.getProperty("user.dir") + File.separator + "res" + File.separator + "stages" + File.separator + "load-data-stage.fxml").toURI().toURL();
} catch (IOException e) {
System.out.println("Erreur lors de la création de l'URL du fichier FXML : " + e.getMessage());
return;
}
URL fxmlFileUrl = getClass().getClassLoader().getResource("stages"+File.separator+"load-data-stage.fxml");
if (fxmlFileUrl == null) {
System.out.println("Impossible de charger le fichier fxml");
......
......@@ -58,13 +58,15 @@ public class MainStageView extends DataVisualizationView implements Observer {
FXMLLoader loader = new FXMLLoader();
try {
URL fxmlFileUrl = new File(System.getProperty("user.dir") + File.separator + "res" + File.separator + "stages" + File.separator + "main-stage.fxml").toURI().toURL();
URL fxmlFileUrl = getClass().getClassLoader().getResource("stages"+File.separator+"main-stage.fxml");
if (fxmlFileUrl == null) {
System.out.println("Impossible de charger le fichier fxml");
System.exit(-1);
}
loader.setLocation(fxmlFileUrl);
root = loader.load();
root.setResizable(false);
root.setTitle("SAE3.3 - Logiciel de classification");
......
......@@ -28,8 +28,8 @@ class ClassificationModelTest {
@Test
void testAjouterDonnee() {
double[] coords = {5.1, 3.5, 1.4, 0.2};
model.ajouterDonnee(coords);
model.ajouterDonnee(5.1, 3.5, 1.4, 0.2);
List<LoadableData> dataToClass = model.getDataToClass();
assertEquals(1, dataToClass.size());
......@@ -41,21 +41,35 @@ class ClassificationModelTest {
Exception exception = assertThrows(IllegalArgumentException.class, () -> {
model.ajouterDonnee(5.1);
});
assertEquals(null, exception.getMessage());
}
@Test
void testLoadData() throws IOException {
File csvTemp = File.createTempFile("test", ".csv");
String csvTest = "sepal_length,sepal_width,petal_length,petal_width,class\n" +
"5.1,3.5,1.4,0.2,Iris-setosa\n" +
"4.9,3.0,1.4,0.2,Iris-setosa\n";
String csvTest = "\"sepal.length\",\"sepal.width\",\"petal.length\",\"petal.width\",\"variety\"\n" +
"5.1,3.5,1.4,0.2,\"Setosa\"\n" +
"4.9,3.0,1.4,0.2,\"Setosa\"\n";
Files.write(Paths.get(csvTemp.getAbsolutePath()), csvTest.getBytes());
model.loadData(csvTemp);
List<LoadableData> datas = model.getDatas();
assertEquals(2, datas.size());
Iris i1 = (Iris) datas.get(0);
assertEquals(5.1, i1.getSepalLength());
assertEquals(3.5, i1.getSepalWidth());
assertEquals(1.4, i1.getPetalLength());
assertEquals(0.2, i1.getPetalWidth());
assertEquals("Setosa", i1.getClassification());
Iris i2 = (Iris) datas.get(1);
assertEquals(4.9, i2.getSepalLength());
assertEquals(3.0, i2.getSepalWidth());
assertEquals(1.4, i2.getPetalLength());
assertEquals(0.2, i2.getPetalWidth());
assertEquals("Setosa", i1.getClassification());
csvTemp.delete();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment