本文整理匯總了Java中javafx.scene.layout.StackPane.setPrefWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java StackPane.setPrefWidth方法的具體用法?Java StackPane.setPrefWidth怎麽用?Java StackPane.setPrefWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.layout.StackPane
的用法示例。
在下文中一共展示了StackPane.setPrefWidth方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import javafx.scene.layout.StackPane; //導入方法依賴的package包/類
@Override
public void start(Stage primaryStage) {
double[] values = new double[]{50,166,200,106,94,211,172,133,132,185,152,131,158,180,172,314,262,160};
//---->Default graph using plotter<----
LineGraph graph = new LineGraph(400,200, Theme.TRAFFIC);
graph.setInterval(20);
//Populating the graph
for (double value : values) {
graph.addValue(value);
}
graph.render(LineGraph.Render.ALL);
StackPane background = new StackPane();
background.setPrefHeight(300);
background.setPrefWidth(600);
background.setStyle("-fx-background-color: radial-gradient(center 50% 50%, radius 100%, #2a367f, #1f2756)");
background.getChildren().add(graph);
StackPane.setAlignment(graph, Pos.CENTER);
StackPane axis = new StackPane();
axis.setMaxSize(500,50);
Line divider = new Line(50,0,550,0);
divider.setStroke(Color.WHITE);
divider.setOpacity(0.3);
axis.getChildren().add(divider);
StackPane.setAlignment(divider,Pos.CENTER);
Label time1 = new Label("8am");
Label time2 = new Label("5pm");
time1.setTextFill(Color.WHITE);
time2.setTextFill(Color.WHITE);
time1.setOpacity(0.5);
time2.setOpacity(0.5);
time1.setFont(Font.font("Calibri",16));
time2.setFont(Font.font("Calibri",16));
axis.getChildren().addAll(time1,time2);
StackPane.setAlignment(time1,Pos.BOTTOM_LEFT);
StackPane.setMargin(time1, new Insets(0,0,0,30));
StackPane.setAlignment(time2, Pos.BOTTOM_RIGHT);
StackPane.setMargin(time2, new Insets(0,30,0,0));
background.getChildren().add(axis);
StackPane.setAlignment(axis, Pos.BOTTOM_CENTER);
StackPane.setMargin(axis, new Insets(0,0,40,0));
primaryStage.setScene(new Scene(background));
primaryStage.setTitle("Traffic");
primaryStage.show();
}
示例2: start
import javafx.scene.layout.StackPane; //導入方法依賴的package包/類
@Override
public void start(Stage stage) throws Exception {
loadData();
tree = new J48();
tree.buildClassifier(data);
noClassificationChart = buildChart("No Classification (click to add new data)", buildSingleSeries());
clusteredChart = buildChart("Clustered", buildClusteredSeries());
realDataChart = buildChart("Real Data (+ Decision Tree classification for new data)", buildLabeledSeries());
noClassificationChart.setOnMouseClicked(e -> {
Axis<Number> xAxis = noClassificationChart.getXAxis();
Axis<Number> yAxis = noClassificationChart.getYAxis();
Point2D mouseSceneCoords = new Point2D(e.getSceneX(), e.getSceneY());
double x = xAxis.sceneToLocal(mouseSceneCoords).getX();
double y = yAxis.sceneToLocal(mouseSceneCoords).getY();
Number xValue = xAxis.getValueForDisplay(x);
Number yValue = yAxis.getValueForDisplay(y);
reloadSeries(xValue, yValue);
});
Label lblDecisionTreeTitle = new Label("Decision Tree generated for the Iris dataset:");
Text txtTree = new Text(tree.toString());
String graph = tree.graph();
SwingNode sw = new SwingNode();
SwingUtilities.invokeLater(() -> {
TreeVisualizer treeVisualizer = new TreeVisualizer(null, graph, new PlaceNode2());
treeVisualizer.setPreferredSize(new Dimension(600, 500));
sw.setContent(treeVisualizer);
});
Button btnRestore = new Button("Restore original data");
Button btnSwapColors = new Button("Swap clustered chart colors");
StackPane spTree = new StackPane(sw);
spTree.setPrefWidth(300);
spTree.setPrefHeight(350);
VBox vbDecisionTree = new VBox(5, lblDecisionTreeTitle, new Separator(), spTree,
new HBox(10, btnRestore, btnSwapColors));
btnRestore.setOnAction(e -> {
loadData();
reloadSeries();
});
btnSwapColors.setOnAction(e -> swapClusteredChartSeriesColors());
lblDecisionTreeTitle.setTextFill(Color.DARKRED);
lblDecisionTreeTitle.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD, FontPosture.ITALIC, 16));
txtTree.setTranslateX(100);
txtTree.setFont(Font.font(Font.getDefault().getFamily(), FontWeight.BOLD, FontPosture.ITALIC, 14));
txtTree.setLineSpacing(1);
txtTree.setTextAlignment(TextAlignment.LEFT);
vbDecisionTree.setTranslateY(20);
vbDecisionTree.setTranslateX(20);
GridPane gpRoot = new GridPane();
gpRoot.add(realDataChart, 0, 0);
gpRoot.add(clusteredChart, 1, 0);
gpRoot.add(noClassificationChart, 0, 1);
gpRoot.add(vbDecisionTree, 1, 1);
stage.setScene(new Scene(gpRoot));
stage.setTitle("Íris dataset clustering and visualization");
stage.show();
}