Skip to content
Snippets Groups Projects
Commit e9dc8b6d authored by BrunoDatoMeneses's avatar BrunoDatoMeneses
Browse files

ENH: minor changes for multiUI mode

parent ca71d0e3
No related branches found
No related tags found
1 merge request!4Exp rein
...@@ -164,10 +164,12 @@ public class Amas<E extends Environment> implements Schedulable { ...@@ -164,10 +164,12 @@ public class Amas<E extends Environment> implements Schedulable {
public Amas(AmasMultiUIWindow window, VUIMulti vui, E environment, Scheduling scheduling, Object... params) { public Amas(AmasMultiUIWindow window, VUIMulti vui, E environment, Scheduling scheduling, Object... params) {
amasMultiUIWindow = window; if(!Configuration.commandLineMode) {
vuiMulti = vui; amasMultiUIWindow = window;
amasMultiUIWindow.addTabbedPanel(vuiMulti.title, vuiMulti.getPanel()); vuiMulti = vui;
//vuiMulti.addTabbedDefaultPanel(amasMultiUIWindow); amasMultiUIWindow.addTabbedPanel(vuiMulti.title, vuiMulti.getPanel());
}
executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(Configuration.allowedSimultaneousAgentsExecution); executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(Configuration.allowedSimultaneousAgentsExecution);
......
...@@ -5,7 +5,13 @@ import fr.irit.smac.amak.ui.AmasMultiUIWindow; ...@@ -5,7 +5,13 @@ import fr.irit.smac.amak.ui.AmasMultiUIWindow;
import fr.irit.smac.amak.ui.MainWindow; import fr.irit.smac.amak.ui.MainWindow;
import fr.irit.smac.amak.ui.VUIMulti; import fr.irit.smac.amak.ui.VUIMulti;
import javafx.application.Application; import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Button;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.Slider;
import javafx.scene.layout.Pane; import javafx.scene.layout.Pane;
import javafx.stage.Stage; import javafx.stage.Stage;
...@@ -24,6 +30,7 @@ public class AntsLaunchExampleMultiUI extends Application{ ...@@ -24,6 +30,7 @@ public class AntsLaunchExampleMultiUI extends Application{
public void start(Stage primaryStage) throws Exception { public void start(Stage primaryStage) throws Exception {
Configuration.multiUI=true; Configuration.multiUI=true;
Configuration.commandLineMode =false;
AmasMultiUIWindow window = new AmasMultiUIWindow("Random Ants Multi UI 1"); AmasMultiUIWindow window = new AmasMultiUIWindow("Random Ants Multi UI 1");
...@@ -34,11 +41,31 @@ public class AntsLaunchExampleMultiUI extends Application{ ...@@ -34,11 +41,31 @@ public class AntsLaunchExampleMultiUI extends Application{
//WorldExampleMultiUI env2 = new WorldExampleMultiUI(window2); //WorldExampleMultiUI env2 = new WorldExampleMultiUI(window2);
AntHillExampleMultiUI ants = new AntHillExampleMultiUI(window, VUIMulti.get("Ants VUI 1"), env); AntHillExampleMultiUI ants = new AntHillExampleMultiUI(window, new VUIMulti("Ants VUI 1"), env);
//new AntHillExampleMultiUI(window2, VUIMulti.get("Ants VUI 2"), env2); //new AntHillExampleMultiUI(window2, VUIMulti.get("Ants VUI 2"), env2);
for(int i=0;i<1000;i++) Button btn = new Button();
ants.cycle(); btn.setText("GO");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
for(int i=0;i<10000;i++) {
System.out.println(i);
ants.cycle();
}
}
});
window.addToolbar(btn);
for(int i=0;i<10000;i++) {
System.out.println(i);
ants.getScheduler().step();
}
} }
@Override @Override
......
...@@ -65,7 +65,6 @@ public class AmasMultiUIWindow extends Stage{ ...@@ -65,7 +65,6 @@ public class AmasMultiUIWindow extends Stage{
public TabPane tabbedPanel; public TabPane tabbedPanel;
protected static Object startEnded = new Object();
/** /**
* Create the frame. * Create the frame.
...@@ -75,55 +74,57 @@ public class AmasMultiUIWindow extends Stage{ ...@@ -75,55 +74,57 @@ public class AmasMultiUIWindow extends Stage{
* should be used by the Application of JavaFX only. * should be used by the Application of JavaFX only.
*/ */
public AmasMultiUIWindow(String title) { public AmasMultiUIWindow(String title) {
synchronized (startEnded) {
VBox root = new VBox();
// Creation of the menu bar (Top)
menuBar = new MenuBar();
root.getChildren().add(menuBar);
// Border organization
organizationPane = new BorderPane();
organizationPane.setMinSize(200, 200); //that way we avoid 0 size, which can cause problems
root.getChildren().add(organizationPane);
VBox.setVgrow(organizationPane, Priority.ALWAYS);
// Creation of scene VBox root = new VBox();
this.setTitle(title);
Scene scene = new Scene(root, 450, 300); // Creation of the menu bar (Top)
//stage = primaryStage; menuBar = new MenuBar();
this.setScene(scene); root.getChildren().add(menuBar);
this.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override // Border organization
public void handle(WindowEvent event) { organizationPane = new BorderPane();
Platform.exit(); organizationPane.setMinSize(200, 200); //that way we avoid 0 size, which can cause problems
} root.getChildren().add(organizationPane);
}); VBox.setVgrow(organizationPane, Priority.ALWAYS);
// Creation of the toolbar (Bottom) // Creation of scene
toolbarPanel = new ToolBar(); this.setTitle(title);
organizationPane.setBottom(toolbarPanel); Scene scene = new Scene(root, 450, 300);
//stage = primaryStage;
// Creation of the right part of the split pane (Center Right) this.setScene(scene);
tabbedPanel = new TabPane(); this.setOnCloseRequest(new EventHandler<WindowEvent>() {
organizationPane.setCenter(tabbedPanel); @Override
public void handle(WindowEvent event) {
// Creation of the close menu item Platform.exit();
MenuItem menuItem = new MenuItem("Close"); }
menuItem.setOnAction(new EventHandler<ActionEvent>() { });
@Override
public void handle(ActionEvent event) { // Creation of the toolbar (Bottom)
System.exit(0); toolbarPanel = new ToolBar();
} organizationPane.setBottom(toolbarPanel);
});
addToMenu("Options", menuItem); // Creation of the right part of the split pane (Center Right)
tabbedPanel = new TabPane();
menuBar.getMenus().add(new Menu("AMAKFX v" + Information.VERSION)); organizationPane.setCenter(tabbedPanel);
this.show(); // Creation of the close menu item
MenuItem menuItem = new MenuItem("Close");
menuItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.exit(0);
}
});
addToMenu("Options", menuItem);
menuBar.getMenus().add(new Menu("AMAKFX v" + Information.VERSION));
this.show();
startEnded.notify();
}
} }
// @Override // @Override
...@@ -231,7 +232,8 @@ public class AmasMultiUIWindow extends Stage{ ...@@ -231,7 +232,8 @@ public class AmasMultiUIWindow extends Stage{
*/ */
public void addTabbedPanel(String title, Node panel) { public void addTabbedPanel(String title, Node panel) {
Tab t = new DraggableTab(title, panel); Tab t = new DraggableTab(title, panel);
RunLaterHelper.runLater(() -> tabbedPanel.getTabs().add(t)); tabbedPanel.getTabs().add(t);
//RunLaterHelper.runLater(() -> tabbedPanel.getTabs().add(t));
} }
/** /**
......
...@@ -48,7 +48,7 @@ public class F_XY_System implements StudiedSystem { ...@@ -48,7 +48,7 @@ public class F_XY_System implements StudiedSystem {
out.put("px0", x); out.put("px0", x);
out.put("px1", y); out.put("px1", y);
out.put("oracle", 0.0); out.put("oracle", result);
return out; return out;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment