use of javafx.scene.layout.StackPane in project Smartcity-Smarthouse by TechnionYP5777.
the class RoomViewController method setImageUrl.
public RoomViewController setImageUrl(final String location) {
image_url = location;
imagePane.getChildren().addAll(new StackPane(new ImageView(new Image(getClass().getResourceAsStream(image_url))), pane));
return this;
}
use of javafx.scene.layout.StackPane in project intellij-community by JetBrains.
the class JavaFxGenerateDefaultPropertyValuesScript method start.
@Override
public void start(Stage primaryStage) throws Exception {
Button b = new Button();
b.setText("Generate");
b.setOnAction(event -> generate());
StackPane pane = new StackPane();
pane.getChildren().add(b);
primaryStage.setScene(new Scene(pane, 300, 200));
primaryStage.show();
Platform.runLater(() -> {
generate();
primaryStage.close();
});
}
use of javafx.scene.layout.StackPane in project FXyzLib by Birdasaur.
the class ClothMeshTest method start.
@Override
public void start(Stage stage) throws Exception {
camera = new PerspectiveCamera(true);
cameraTransform.setTranslate(0, 0, 0);
cameraTransform.getChildren().addAll(camera);
camera.setNearClip(0.1);
camera.setFarClip(1000000.0);
camera.setFieldOfView(42);
camera.setVerticalFieldOfView(true);
camera.setTranslateZ(-1500);
PointLight light = new PointLight(Color.LIGHTSKYBLUE);
//cameraTransform.getChildren().add(light);
light.translateXProperty().bind(camera.translateXProperty());
light.translateYProperty().bind(camera.translateYProperty());
light.translateZProperty().bind(camera.translateZProperty());
ClothMesh cloth = new ClothMesh();
cloth.setPerPointMass(10);
cloth.setBendStrength(0.5);
cloth.setStretchStrength(1.0);
cloth.setShearStrength(0.55);
cloth.setDrawMode(DrawMode.LINE);
cloth.setCullFace(CullFace.NONE);
// cloth.setDiffuseMap(new Image("https://kenai.com/attachments/wiki_images/duke/Duke3DprogressionSmall.jpg"));
cloth.setSpecularPower(5);
StackPane root = new StackPane();
root.setPickOnBounds(false);
PointLight light2 = new PointLight(Color.GAINSBORO);
light2.setTranslateZ(-1500);
PointLight light3 = new PointLight(Color.AZURE);
light3.setTranslateZ(2500);
Group g = new Group();
g.getChildren().addAll(cameraTransform, cloth, light2, light3);
root.getChildren().add(g);
Scene scene = new Scene(root, 1200, 600, true, SceneAntialiasing.BALANCED);
Stop[] stops = new Stop[] { new Stop(0, Color.BLACK), new Stop(1, Color.RED) };
LinearGradient lg = new LinearGradient(0, 0, 0, 1, true, CycleMethod.NO_CYCLE, stops);
scene.setFill(lg);
scene.setCamera(camera);
//First person shooter keyboard movement
scene.setOnKeyPressed(event -> {
double change = 10.0;
if (event.isShiftDown()) {
change = 50.0;
}
KeyCode keycode = event.getCode();
if (keycode == KeyCode.W) {
camera.setTranslateZ(camera.getTranslateZ() + change);
}
if (keycode == KeyCode.S) {
camera.setTranslateZ(camera.getTranslateZ() - change);
}
if (keycode == KeyCode.A) {
camera.setTranslateX(camera.getTranslateX() - change);
}
if (keycode == KeyCode.D) {
camera.setTranslateX(camera.getTranslateX() + change);
}
});
scene.setOnMousePressed((MouseEvent me) -> {
mousePosX = me.getSceneX();
mousePosY = me.getSceneY();
mouseOldX = me.getSceneX();
mouseOldY = me.getSceneY();
});
scene.setOnMouseDragged((MouseEvent me) -> {
if (!cloth.isHover()) {
mouseOldX = mousePosX;
mouseOldY = mousePosY;
mousePosX = me.getSceneX();
mousePosY = me.getSceneY();
mouseDeltaX = (mousePosX - mouseOldX);
mouseDeltaY = (mousePosY - mouseOldY);
double modifier = 10.0;
double modifierFactor = 0.1;
if (me.isControlDown()) {
modifier = 0.1;
}
if (me.isShiftDown()) {
modifier = 50.0;
}
if (me.isPrimaryButtonDown()) {
// +
cameraTransform.ry.setAngle(((cameraTransform.ry.getAngle() + mouseDeltaX * modifierFactor * modifier * 2.0) % 360 + 540) % 360 - 180);
// -
cameraTransform.rx.setAngle(((cameraTransform.rx.getAngle() - mouseDeltaY * modifierFactor * modifier * 2.0) % 360 + 540) % 360 - 180);
} else if (me.isSecondaryButtonDown()) {
double z = camera.getTranslateZ();
double newZ = z + mouseDeltaX * modifierFactor * modifier;
camera.setTranslateZ(newZ);
} else if (me.isMiddleButtonDown()) {
// -
cameraTransform.t.setX(cameraTransform.t.getX() + mouseDeltaX * modifierFactor * modifier * 0.3);
// -
cameraTransform.t.setY(cameraTransform.t.getY() + mouseDeltaY * modifierFactor * modifier * 0.3);
}
}
});
stage.setScene(scene);
//stage.setMaximized(true);
stage.show();
cloth.startSimulation();
}
use of javafx.scene.layout.StackPane in project FXyzLib by Birdasaur.
the class ConeTest method start.
@Override
public void start(Stage stage) {
Group coneGroup = new Group();
for (int i = 0; i < 100; i++) {
Random r = new Random();
//A lot of magic numbers in here that just artificially constrain the math
float randomRadius = (float) ((r.nextFloat() * 100) + 25);
float randomHeight = (float) ((r.nextFloat() * 300) + 75);
int randomDivisions = (int) ((r.nextFloat() * 50) + 5);
Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
Cone cone = new Cone(randomDivisions, randomRadius, randomHeight, randomColor);
cone.setEmissiveLightingColor(randomColor);
cone.setEmissiveLightingOn(r.nextBoolean());
cone.setDrawMode(r.nextBoolean() ? DrawMode.FILL : DrawMode.LINE);
double translationX = Math.random() * 1024;
if (Math.random() >= 0.5) {
translationX *= -1;
}
double translationY = Math.random() * 1024;
if (Math.random() >= 0.5) {
translationY *= -1;
}
double translationZ = Math.random() * 1024;
if (Math.random() >= 0.5) {
translationZ *= -1;
}
Translate translate = new Translate(translationX, translationY, translationZ);
Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);
cone.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
coneGroup.getChildren().add(cone);
}
root.getChildren().add(coneGroup);
camera = new AdvancedCamera();
controller = new FPSController();
camera.setNearClip(0.1);
camera.setFarClip(10000.0);
camera.setFieldOfView(42);
camera.setController(controller);
Scene scene = new Scene(new StackPane(root), 1024, 668, true, SceneAntialiasing.BALANCED);
scene.setCamera(camera);
scene.setFill(Color.BLACK);
controller.setScene(scene);
stage.setTitle("Random Cones!");
stage.setScene(scene);
stage.show();
stage.setFullScreen(false);
stage.setFullScreenExitHint("");
}
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;
}
Aggregations