use of javafx.scene.layout.StackPane in project aima-java by aimacode.
the class MapColoringCspApp method createRootPane.
/**
* Defines state view, parameters, and call-back functions and calls the
* simulation pane builder to create layout and controller objects.
*/
@Override
public Pane createRootPane() {
BorderPane root = new BorderPane();
StackPane stateView = new StackPane();
stateViewCtrl = new CspViewCtrl<>(stateView);
List<Parameter> params = createParameters();
SimulationPaneBuilder builder = new SimulationPaneBuilder();
builder.defineParameters(params);
builder.defineStateView(stateView);
builder.defineInitMethod(this::initialize);
builder.defineSimMethod(this::simulate);
simPaneCtrl = builder.getResultFor(root);
return root;
}
use of javafx.scene.layout.StackPane in project aima-java by aimacode.
the class NQueensCspApp method createRootPane.
/**
* Defines state view, parameters, and call-back functions and calls the
* simulation pane builder to create layout and controller objects.
*/
@Override
public Pane createRootPane() {
BorderPane root = new BorderPane();
StackPane stateView = new StackPane();
stateViewCtrl = new NQueensViewCtrl(stateView);
List<Parameter> params = createParameters();
SimulationPaneBuilder builder = new SimulationPaneBuilder();
builder.defineParameters(params);
builder.defineStateView(stateView);
builder.defineInitMethod(this::initialize);
builder.defineSimMethod(this::simulate);
simPaneCtrl = builder.getResultFor(root);
simPaneCtrl.setParam(SimulationPaneCtrl.PARAM_SIM_SPEED, 0);
return root;
}
use of javafx.scene.layout.StackPane in project aima-java by aimacode.
the class NQueensViewCtrl method update.
/** Updates the view. */
public void update(NQueensBoard board) {
int size = board.getSize();
if (queens.length != size * size) {
gridPane.getChildren().clear();
gridPane.getColumnConstraints().clear();
gridPane.getRowConstraints().clear();
queens = new Polygon[size * size];
RowConstraints c1 = new RowConstraints();
c1.setPercentHeight(100.0 / size);
ColumnConstraints c2 = new ColumnConstraints();
c2.setPercentWidth(100.0 / size);
for (int i = 0; i < board.getSize(); i++) {
gridPane.getRowConstraints().add(c1);
gridPane.getColumnConstraints().add(c2);
}
for (int i = 0; i < queens.length; i++) {
StackPane field = new StackPane();
queens[i] = createQueen();
field.getChildren().add(queens[i]);
int col = i % size;
int row = i / size;
field.setBackground(new Background(new BackgroundFill((col % 2 == row % 2) ? Color.WHITE : Color.LIGHTGRAY, null, null)));
gridPane.add(field, col, row);
}
}
double scale = 0.2 * gridPane.getWidth() / gridPane.getColumnConstraints().size();
for (int i = 0; i < queens.length; i++) {
Polygon queen = queens[i];
queen.setScaleX(scale);
queen.setScaleY(scale);
XYLocation loc = new XYLocation(i % size, i / size);
if (board.queenExistsAt(loc)) {
queen.setVisible(true);
queen.setFill(board.isSquareUnderAttack(loc) ? Color.RED : Color.BLACK);
} else {
queen.setVisible(false);
}
}
}
use of javafx.scene.layout.StackPane in project aima-java by aimacode.
the class OsmRoutePlannerApp method createRootPane.
/**
* Simple pane to control the game.
*/
@Override
public Pane createRootPane() {
routeCalculator = createRouteCalculator();
BorderPane root = new BorderPane();
ToolBar toolBar = new ToolBar();
clearBtn = new Button("Clear");
clearBtn.setOnAction(ev -> initialize());
taskCombo = new ComboBox<>();
taskCombo.getItems().addAll(routeCalculator.getTaskSelectionOptions());
taskCombo.getSelectionModel().select(0);
calcBtn = new Button("Calculate Route");
calcBtn.setOnAction(ev -> calculateRoute());
toolBar.getItems().addAll(clearBtn, new Separator(), taskCombo, calcBtn);
root.setTop(toolBar);
StackPane mapPane = new StackPane();
mapPaneCtrl = new MapPaneCtrl(mapPane);
mapPaneCtrl.getMap().addMapDataEventListener(ev -> updateEnabledState());
mapPaneCtrl.loadMap(DataResource.getULMFileResource());
root.setCenter(mapPane);
statusLabel = new Label();
statusLabel.setMaxWidth(Double.MAX_VALUE);
statusLabel.setMaxWidth(Double.MAX_VALUE);
statusLabel.setAlignment(Pos.CENTER);
statusLabel.setFont(Font.font(16));
root.setBottom(statusLabel);
return root;
}
use of javafx.scene.layout.StackPane in project aima-java by aimacode.
the class OsmLRTAStarAgentApp method createRootPane.
/**
* Defines state view, parameters, and call-back functions and calls the
* simulation pane builder to create layout and controller objects.
*/
@Override
public Pane createRootPane() {
BorderPane root = new BorderPane();
List<Parameter> params = createParameters();
StackPane mapPane = new StackPane();
mapPaneCtrl = new MapPaneCtrl(mapPane);
loadMap();
SimulationPaneBuilder builder = new SimulationPaneBuilder();
builder.defineParameters(params);
builder.defineStateView(mapPane);
builder.defineInitMethod(this::initialize);
builder.defineSimMethod(this::simulate);
simPaneCtrl = builder.getResultFor(root);
simPaneCtrl.setParam(SimulationPaneCtrl.PARAM_SIM_SPEED, 0);
return root;
}
Aggregations