本文整理汇总了Java中javafx.scene.layout.StackPane.setMargin方法的典型用法代码示例。如果您正苦于以下问题:Java StackPane.setMargin方法的具体用法?Java StackPane.setMargin怎么用?Java StackPane.setMargin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.layout.StackPane
的用法示例。
在下文中一共展示了StackPane.setMargin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addState
import javafx.scene.layout.StackPane; //导入方法依赖的package包/类
private void addState(State<?,?> state, HBox line, Color color, int stateIndex, String stateDescription) {
final Rectangle rectangle = new Rectangle(WIDTH, WIDTH, color);
rectangle.setArcHeight(WIDTH);
rectangle.setArcWidth(WIDTH);
rectangle.setUserData(state);
Label text = new Label(computeStateLabel(stateIndex));
text.setTextOverrun(OverrunStyle.ELLIPSIS);
text.setAlignment(Pos.CENTER);
text.setMouseTransparent(true);
text.setTextFill(Color.WHITE);
text.setFont(STATE_FONT);
text.setMaxWidth(WIDTH);
final Tooltip tooltip = new Tooltip(stateDescription);
Tooltip.install(rectangle, tooltip);
StackPane layout = new StackPane();
StackPane.setMargin(rectangle, MARGIN_INSETS);
layout.getChildren().addAll(rectangle, text);
line.getChildren().add(layout);
}
示例2: impl_updateBalloonLayoutX
import javafx.scene.layout.StackPane; //导入方法依赖的package包/类
private void impl_updateBalloonLayoutX() {
if (positionMode == PositionMode.ABSOLUTE || character == null || character.getParent() == null) return;
if (positionMode == PositionMode.RELATIVE){
try{
loadPositionFromStorage();
return;
} catch (Exception e){ }
}
double x = character.localToScreen(character.getBoundsInLocal()).getMinX();
double width = prefWidth(-1)*stackPane.getScaleX();
boolean rightAlign = x-width>0;
x += rightAlign ? (-width) : character.getWidth();
relocate(x, getPosition().getY());
bubblesGroup.setScaleX((rightAlign) ? 1 : -1);
StackPane.setMargin(content, new Insets(margin.getTop(), (rightAlign) ? margin.getRight() : margin.getLeft(),
margin.getBottom(), (!rightAlign) ? margin.getRight() : margin.getLeft()));
}
示例3: initUi
import javafx.scene.layout.StackPane; //导入方法依赖的package包/类
private void initUi() {
root.setMinSize(0, 0);
root.setPrefSize(1, 1); // Decouple from children.
root.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
root.getStyleClass().add(STYLE_CLASS);
root.getStylesheets().add(getClass().getResource(STYLESHEET).toExternalForm());
root.setAlignment(Pos.TOP_LEFT);
root.getChildren().addAll(panningComponent.getRoot(), addButton);
panningComponent.getChildren().addAll(sceneContent, resizerComponent.getRoot(), selectionBox.getRoot());
StackPane.setMargin(addButton, new Insets(15));
addButton.setGraphic(Svg.PLUS_FAT.node());
addButton.setFocusTraversable(false);
FocusHelper.requestFocusOnPress(panningComponent.getRoot());
}
示例4: 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();
}
示例5: Balloon
import javafx.scene.layout.StackPane; //导入方法依赖的package包/类
Balloon(String id, String text) {
instance=this;
bubbleShadow.setRadius(10.0);
bubbleShadow.setOffsetX(1.5);
bubbleShadow.setOffsetY(2.5);
bubbleShadow.setColor(Color.color(0, 0, 0, Main.getProperties().getFloat("balloon.shadow-opacity", 1.0f)));
Text label = new Text("");
label.setStyle("-fx-alignment: center; -fx-text-alignment: center; -fx-content-display: center;");
label.setTextAlignment(TextAlignment.CENTER);
label.setWrappingWidth(300);
if (defaultFont != null) {
label.setFont(defaultFont);
} else {
label.setFont(LocalFont.defaultFont);
}
Integer animation_delay = Main.getProperties().getInteger("balloon.text-animation-delay", 50);
if (animation_delay > 0)
symbolsAdder = new SymbolsAdder(text, animation_delay);
else
label.setText(text);
content = label;
StackPane contentPane = new StackPane();
contentPane.getChildren().add(content);
bubblesGroup = new Group(bubbleShapes);
stackPane.getChildren().add(bubblesGroup);
stackPane.getChildren().add(contentPane);
StackPane.setMargin(content, margin);
setBalloonScaleFactor(Main.getProperties().getFloat("balloon.scale_factor", 100));
getChildren().add(stackPane);
setBalloonOpacity(Main.getProperties().getFloat("balloon.opacity", 100));
setOnMousePressed(event -> {
lastClick = System.currentTimeMillis();
if ((positionMode != PositionMode.AUTO) && event.getButton().equals(MouseButton.PRIMARY)) {
startDrag(event);
}
});
setOnMouseReleased(event -> {
if(!isDragging() && event.getButton().equals(MouseButton.PRIMARY) && (System.currentTimeMillis()-lastClick)<200) {
if (character != null) {
character.say(null);
} else {
close();
}
}
});
setOnMouseEntered(event -> {
if (character != null && timeoutTimeline != null) {
timeoutTimeline.stop();
}
});
setOnMouseExited(event -> {
if (character != null && timeoutTimeline != null) {
timeoutTimeline.play();
}
});
mouseEventNotificator
.setOnClickListener()
.setOnMovedListener()
// TODO: Figure out how to write more precise check.
.setOnScrollListener(event -> true);
}