Skip to content
Snippets Groups Projects
Commit 2824d6fe authored by Maxence Antoine's avatar Maxence Antoine
Browse files

Merge branch 'matiasmennecart' into 'master'

Merge code de base

See merge request sae302/2024/H4_SAE3.3!1
parents 92c6317d a7293d3a
Branches
Tags
No related merge requests found
Showing
with 382 additions and 22 deletions
...@@ -41,12 +41,20 @@ ...@@ -41,12 +41,20 @@
<dependency> <dependency>
<groupId>org.openjfx</groupId> <groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId> <artifactId>javafx-controls</artifactId>
<version>14</version> <version>17</version>
<!-- Pour Mac M1+ -->
<!-- <classifier>mac-aarch64</classifier> -->
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx</artifactId>
<version>17</version>
<type>pom</type>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.openjfx</groupId> <groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId> <artifactId>javafx-swing</artifactId>
<version>14</version> <version>17</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
......
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.Scene?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.stage.Stage?>
<Stage fx:id="stage" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.univlille.sae.classification.controller.LoadDataController">
<scene>
<Scene>
<AnchorPane prefHeight="143.0" prefWidth="363.0">
<children>
<VBox layoutX="-1.0" layoutY="1.0" prefHeight="151.0" prefWidth="364.0">
<children>
<HBox alignment="CENTER" prefHeight="91.0" prefWidth="272.0">
<children>
<Label fx:id="filenamelab" prefHeight="83.0" prefWidth="157.0" text="file name" />
<Button mnemonicParsing="false" onAction="#openFileChooser" text="Parcourir" />
</children>
</HBox>
<HBox alignment="CENTER" prefHeight="76.0" prefWidth="310.0">
<children>
<Button mnemonicParsing="false" onAction="#validate" text="Valider" />
</children>
</HBox>
</children>
</VBox>
</children></AnchorPane>
</Scene>
</scene>
</Stage>
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.Scene?>
<?import javafx.scene.chart.CategoryAxis?>
<?import javafx.scene.chart.NumberAxis?>
<?import javafx.scene.chart.ScatterChart?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Region?>
<?import javafx.scene.layout.VBox?>
<?import javafx.stage.Stage?>
<Stage fx:id="stage" xmlns="http://javafx.com/javafx/21" xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.univlille.sae.classification.controller.MainStageController">
<scene>
<Scene>
<AnchorPane prefHeight="487.0" prefWidth="692.0">
<children>
<VBox prefHeight="488.0" prefWidth="691.0">
<children>
<HBox prefHeight="305.0" prefWidth="691.0">
<children>
<Region prefHeight="200.0" prefWidth="200.0" />
<ScatterChart prefHeight="213.0" prefWidth="557.0">
<xAxis>
<CategoryAxis side="BOTTOM" />
</xAxis>
<yAxis>
<NumberAxis side="LEFT" />
</yAxis>
</ScatterChart>
<Region prefHeight="200.0" prefWidth="200.0" />
</children>
</HBox>
<Region prefHeight="77.0" prefWidth="691.0" />
<HBox prefHeight="100.0" prefWidth="200.0">
<children>
<Region prefHeight="101.0" prefWidth="131.0" />
<Button mnemonicParsing="false" onAction="#openLoadData" prefHeight="27.0" prefWidth="122.0" text="Charger" />
<Region prefHeight="101.0" prefWidth="75.0" />
<Button mnemonicParsing="false" prefHeight="25.0" prefWidth="129.0" text="Classifier" />
<Region prefHeight="101.0" prefWidth="70.0" />
<Button mnemonicParsing="false" prefHeight="26.0" prefWidth="133.0" text="Reglages" />
<Region prefHeight="101.0" prefWidth="111.0" />
</children>
</HBox>
</children>
</VBox>
</children></AnchorPane>
</Scene>
</scene>
</Stage>
package fr.univlille.sae.classification;
public class ClassificationApp {
public static void main(String[] args) {
}
}
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.fxml.FXMLLoader;
import javafx.stage.Stage;
import java.io.File;
import java.io.IOException;
import java.net.URL;
public class Main extends Application {
public void start(Stage stage) throws IOException {
ClassificationModel model = new ClassificationModel();
MainStageView view = new MainStageView(model);
view.show();
}
// Ouvre l'application
public static void main(String[] args) {
Application.launch(args);
}
}
package fr.univlille.sae.classification.controller;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import java.io.File;
public class LoadDataController {
@FXML
Stage stage;
@FXML
Label filenamelab;
File file;
public void loadData() {
System.out.println("Loading data");
stage.close();
}
public void openFileChooser() {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Choisissez le fichier à importer");
this.file = fileChooser.showOpenDialog(stage);
if(file != null) {
filenamelab.setText(file.getName());
}
}
public void validate() {
if (file == null) {
stage.close();
//throw exception
}
loadData();
}
}
...@@ -27,9 +27,9 @@ public class MainStageController { ...@@ -27,9 +27,9 @@ public class MainStageController {
public void openLoadData() throws IOException { public void openLoadData() throws IOException {
/*
FXMLLoader loader = new FXMLLoader(); FXMLLoader loader = new FXMLLoader();
URL fxmlFileUrl = new File(System.getProperty("user.dir") + File.separator + "res" + File.separator + "stages" + File.separator + "main-stage.fxml").toURI().toURL(); URL fxmlFileUrl = new File(System.getProperty("user.dir") + File.separator + "res" + File.separator + "stages" + File.separator + "load-data-stage.fxml").toURI().toURL();
if (fxmlFileUrl == null) { if (fxmlFileUrl == null) {
System.out.println("Impossible de charger le fichier fxml"); System.out.println("Impossible de charger le fichier fxml");
...@@ -44,7 +44,7 @@ public class MainStageController { ...@@ -44,7 +44,7 @@ public class MainStageController {
loadStage.setTitle("Chargement des donées"); loadStage.setTitle("Chargement des donées");
loadStage.showAndWait(); loadStage.showAndWait();
*/
} }
......
package fr.univlille.sae.classification.model;
import fr.univlille.sae.classification.utils.Observable;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Set;
public class ClassificationModel extends Observable {
private List<LoadableData> datas;
private List<LoadableData> dataToClass;
public ClassificationModel() {
this.datas = new ArrayList<>();
}
/**
* TODO
* @param x
* @param y
*/
private void ajouterDonnee(double x, double y) {
}
/**
* TODO
* @param file
*/
private void loadData(File file) {
}
/**
* TODO
* @param data
*/
private void classifierDonnee(LoadableData data) {
List<String> classes = new ArrayList<>(data.getClassificationTypes());
Random rdm = new Random();
data.setClassification(classes.get(rdm.nextInt(classes.size())));
}
}
package fr.univlille.sae.classification.model;
import java.util.Set;
public class Iris extends LoadableData{
private double sepalWidth;
private double sepalLength;
private double petalWidth;
private double petalLength;
public Iris(double sepalWidth, double sepalLength, double petalWidth, double petalLength) {
this(sepalWidth, sepalLength, petalWidth, petalLength, "undefined");
}
public Iris(double sepalWidth, double sepalLength, double petalWidth, double petalLength, String classification) {
super();
this.sepalWidth = sepalWidth;
this.sepalLength = sepalLength;
this.petalWidth = petalWidth;
this.petalLength = petalLength;
}
public double getSepalWidth() {
return sepalWidth;
}
public double getSepalLength() {
return sepalLength;
}
public double getPetalWidth() {
return petalWidth;
}
public double getPetalLength() {
return petalLength;
}
}
package fr.univlille.sae.classification.model;
import java.util.Set;
public class LoadableData {
private static Set<String> classificationTypes;
private String classification;
public LoadableData() {
}
public String getClassification() {
return this.classification;
}
Set<String> getClassificationTypes() {
return classificationTypes;
}
void setClassification(String classification) {
this.classification = classification;
}
}
package fr.univlille.sae.classification.utils;
import java.util.Collection;
import java.util.HashSet;
public abstract class Observable {
protected Collection<Observer> attached = new HashSet<>();
protected Collection<Observer> toDetach = new HashSet<>();
public void attach(Observer obs) {
attached.add(obs);
}
public void detach(Observer obs) {
this.toDetach.add(obs);
}
protected void notifyObservers() {
this.updateList();
for (Observer o : attached) {
o.update(this);
}
}
protected void notifyObservers(Object data) {
this.updateList();
for (Observer o : attached) {
o.update(this, data);
}
}
private void updateList() {
this.attached.removeAll(toDetach);
this.toDetach.clear();
}
}
package fr.univlille.sae.classification.utils;
public interface Observer {
void update(Observable observable);
void update(Observable observable, Object data);
}
package fr.univlille.sae.classification.view;
public class LoadDataView {
}
package fr.univlille.sae.classification.view; package fr.univlille.sae.classification.view;
import fr.univlille.sae.classification.model.ClassificationModel;
import fr.univlille.sae.classification.utils.Observable;
import fr.univlille.sae.classification.utils.Observer;
import javafx.application.Application; import javafx.application.Application;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.stage.Stage; import javafx.stage.Stage;
...@@ -8,10 +11,18 @@ import java.io.File; ...@@ -8,10 +11,18 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
public class MainStage extends Application { public class MainStageView implements Observer {
public void start(Stage stage) throws IOException { private ClassificationModel model;
public MainStageView(ClassificationModel model) {
this.model = model;
model.attach(this);
}
public void show() throws IOException {
FXMLLoader loader = new FXMLLoader(); FXMLLoader loader = new FXMLLoader();
URL fxmlFileUrl = new File(System.getProperty("user.dir") + File.separator + "res" + File.separator + "stages" + File.separator + "main-stage.fxml").toURI().toURL(); URL fxmlFileUrl = new File(System.getProperty("user.dir") + File.separator + "res" + File.separator + "stages" + File.separator + "main-stage.fxml").toURI().toURL();
...@@ -25,15 +36,16 @@ public class MainStage extends Application { ...@@ -25,15 +36,16 @@ public class MainStage extends Application {
root.setResizable(false); root.setResizable(false);
root.setTitle("SAE3.3 - Logiciel de classification"); root.setTitle("SAE3.3 - Logiciel de classification");
root.show(); root.show();
} }
// Ouvre l'application
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void update(Observable observable) {
}
@Override
public void update(Observable observable, Object data) {
} }
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment