Connected views to models. Added photos.
@@ -12,6 +12,8 @@ import org.example.views.MainUI;
|
|||||||
*/
|
*/
|
||||||
public class App extends Application {
|
public class App extends Application {
|
||||||
|
|
||||||
|
public static final double MULTIPLIER = 1.5;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage stage) {
|
public void start(Stage stage) {
|
||||||
MainUI.start(stage);
|
MainUI.start(stage);
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
package org.example.controller;
|
package org.example.controller;
|
||||||
|
|
||||||
|
import org.example.models.MainLogic;
|
||||||
|
import org.example.models.Path;
|
||||||
|
|
||||||
public class Controller {
|
public class Controller {
|
||||||
|
|
||||||
|
public static Path logic(int k, double multiplier) {
|
||||||
|
return MainLogic.logic(k, multiplier);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,20 @@ import java.util.Set;
|
|||||||
public class MainLogic {
|
public class MainLogic {
|
||||||
|
|
||||||
private static final HashMap<Set<Node>, List<Path>> cache = new HashMap<>();
|
private static final HashMap<Set<Node>, List<Path>> cache = new HashMap<>();
|
||||||
public static final double MULTIPLIER = 1.5;
|
public static double MULTIPLIER = 1.5;
|
||||||
public static final int K = 4;
|
public static int K = 4;
|
||||||
public static double LENGHT;
|
public static double LENGHT;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
System.out.println(logic(K, MULTIPLIER));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Path logic(int k, double multiplier) {
|
||||||
|
|
||||||
|
// Parsing args
|
||||||
|
K = k; MULTIPLIER = multiplier;
|
||||||
|
|
||||||
|
// Login
|
||||||
ArrayList<Node> nl = importData();
|
ArrayList<Node> nl = importData();
|
||||||
Node moncalieri = nl.getLast();
|
Node moncalieri = nl.getLast();
|
||||||
nl.remove(moncalieri);
|
nl.remove(moncalieri);
|
||||||
@@ -34,7 +42,7 @@ public class MainLogic {
|
|||||||
bestPath = p;
|
bestPath = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println(bestPath);
|
return bestPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<Node> importData() {
|
public static ArrayList<Node> importData() {
|
||||||
|
|||||||
@@ -1,17 +1,54 @@
|
|||||||
package org.example.views;
|
package org.example.views;
|
||||||
|
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.scene.control.TextFormatter;
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import org.example.App;
|
||||||
|
import org.example.controller.Controller;
|
||||||
|
import org.example.models.Path;
|
||||||
|
|
||||||
|
import java.util.function.UnaryOperator;
|
||||||
|
|
||||||
public class MainUI {
|
public class MainUI {
|
||||||
public static void start(Stage stage) {
|
public static void start(Stage stage) {
|
||||||
|
//Controller.logic()
|
||||||
|
|
||||||
|
VBox root = new VBox();
|
||||||
|
TextField numericField = new TextField();
|
||||||
|
|
||||||
|
// Filter to allow only integer numbers
|
||||||
|
UnaryOperator<TextFormatter.Change> filter = change -> {
|
||||||
|
String text = change.getControlNewText();
|
||||||
|
// Regex: allows empty field (for deletion) or digits only
|
||||||
|
if (text.matches("\\d*")) {
|
||||||
|
return change;
|
||||||
|
}
|
||||||
|
return null; // Reject the change
|
||||||
|
};
|
||||||
|
Button submit = new Button("Submit");
|
||||||
|
HBox hBox = new HBox(numericField,submit);
|
||||||
|
root.getChildren().add(hBox);
|
||||||
|
var scene = new Scene(root, 640, 480);
|
||||||
|
|
||||||
|
submit.setOnAction(event -> {
|
||||||
|
int k = Integer.parseInt(numericField.getText());
|
||||||
|
double multiplier = App.MULTIPLIER;
|
||||||
|
Path bestPath = Controller.logic(k, multiplier);
|
||||||
|
slideShowStart();
|
||||||
|
});
|
||||||
|
|
||||||
var label = new Label("Hello, JavaFX " + "javafxVersion" + ", running on Java " + "javaVersion" + ".");
|
|
||||||
var scene = new Scene(new StackPane(label), 640, 480);
|
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
stage.show();
|
stage.show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void slideShowStart() {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
src/main/resources/images/Belvedere della Silvana.jpg
Normal file
|
After Width: | Height: | Size: 83 KiB |
BIN
src/main/resources/images/Belvedere di Castelmola.jpg
Normal file
|
After Width: | Height: | Size: 8.9 MiB |
BIN
src/main/resources/images/Belvedere di San Vigilio.jpg
Normal file
|
After Width: | Height: | Size: 478 KiB |
BIN
src/main/resources/images/Belvedere di Villa d'Este.jpg
Normal file
|
After Width: | Height: | Size: 6.2 MiB |
BIN
src/main/resources/images/Castello di Miramare.jpg
Normal file
|
After Width: | Height: | Size: 2.8 MiB |
BIN
src/main/resources/images/Castello di Moncalieri.jpg
Normal file
|
After Width: | Height: | Size: 2.2 MiB |
BIN
src/main/resources/images/Castello di Racconigi.jpg
Normal file
|
After Width: | Height: | Size: 826 KiB |
BIN
src/main/resources/images/Palazzo Ducale di Urbino.jpg
Normal file
|
After Width: | Height: | Size: 35 MiB |
BIN
src/main/resources/images/Palazzo Madama.jpg
Normal file
|
After Width: | Height: | Size: 22 MiB |
BIN
src/main/resources/images/Palazzo Pitti.jpg
Normal file
|
After Width: | Height: | Size: 5.8 MiB |
BIN
src/main/resources/images/Palazzo Reale di Torino.jpg
Normal file
|
After Width: | Height: | Size: 7.9 MiB |
BIN
src/main/resources/images/Piazzale Michelangelo.jpg
Normal file
|
After Width: | Height: | Size: 2.9 MiB |
BIN
src/main/resources/images/Punto Panoramico del Monte Baldo.jpg
Normal file
|
After Width: | Height: | Size: 260 KiB |
BIN
src/main/resources/images/Reggia di Caserta.jpg
Normal file
|
After Width: | Height: | Size: 1.8 MiB |
BIN
src/main/resources/images/Rocca di Calascio.jpg
Normal file
|
After Width: | Height: | Size: 20 MiB |