本文整理汇总了Java中javafx.geometry.VPos类的典型用法代码示例。如果您正苦于以下问题:Java VPos类的具体用法?Java VPos怎么用?Java VPos使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VPos类属于javafx.geometry包,在下文中一共展示了VPos类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLetter
import javafx.geometry.VPos; //导入依赖的package包/类
private void createLetter(String c) {
final Text letter = new Text(c);
letter.setFill(Color.BLACK);
letter.setFont(FONT_DEFAULT);
letter.setTextOrigin(VPos.TOP);
letter.setTranslateX((getWidth() - letter.getBoundsInLocal().getWidth()) / 2);
letter.setTranslateY((getHeight() - letter.getBoundsInLocal().getHeight()) / 2);
getChildren().add(letter);
// over 3 seconds move letter to random position and fade it out
final Timeline timeline = new Timeline();
timeline.getKeyFrames().add(
new KeyFrame(Duration.seconds(3), new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
// we are done remove us from scene
getChildren().remove(letter);
}
},
new KeyValue(letter.translateXProperty(), getRandom(0.0f, getWidth() - letter.getBoundsInLocal().getWidth()),INTERPOLATOR),
new KeyValue(letter.translateYProperty(), getRandom(0.0f, getHeight() - letter.getBoundsInLocal().getHeight()),INTERPOLATOR),
new KeyValue(letter.opacityProperty(), 0f)
));
timeline.play();
}
示例2: createIconContent
import javafx.geometry.VPos; //导入依赖的package包/类
public static Node createIconContent() {
Text htmlStart = new Text("<html>");
Text htmlEnd = new Text("</html>");
htmlStart.setFont(Font.font(null, FontWeight.BOLD, 20));
htmlStart.setStyle("-fx-font-size: 20px;");
htmlStart.setTextOrigin(VPos.TOP);
htmlStart.setLayoutY(11);
htmlStart.setLayoutX(20);
htmlEnd.setFont(Font.font(null, FontWeight.BOLD, 20));
htmlEnd.setStyle("-fx-font-size: 20px;");
htmlEnd.setTextOrigin(VPos.TOP);
htmlEnd.setLayoutY(31);
htmlEnd.setLayoutX(20);
return new Group(htmlStart, htmlEnd);
}
示例3: configureDigits
import javafx.geometry.VPos; //导入依赖的package包/类
private void configureDigits() {
for (int i : numbers) {
digits[i] = new Text("0");
digits[i].setFont(FONT);
digits[i].setTextOrigin(VPos.TOP);
digits[i].setLayoutX(2.3);
digits[i].setLayoutY(-1);
Rectangle background;
if (i < 6) {
background = createBackground(Color.web("#a39f91"), Color.web("#FFFFFF"));
digits[i].setFill(Color.web("#000000"));
} else {
background = createBackground(Color.web("#bdbeb3"), Color.web("#FF0000"));
digits[i].setFill(Color.web("#FFFFFF"));
}
digitsGroup[i] = new Group(background, digits[i]);
}
}
示例4: WebViewPane
import javafx.geometry.VPos; //导入依赖的package包/类
public WebViewPane() {
VBox.setVgrow(this, Priority.ALWAYS);
setMaxWidth(Double.MAX_VALUE);
setMaxHeight(Double.MAX_VALUE);
WebView view = new WebView();
view.setMinSize(500, 400);
view.setPrefSize(500, 400);
final WebEngine eng = view.getEngine();
eng.load("http://www.oracle.com/us/index.html");
final TextField locationField = new TextField("http://www.oracle.com/us/index.html");
locationField.setMaxHeight(Double.MAX_VALUE);
Button goButton = new Button("Go");
goButton.setDefaultButton(true);
EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
eng.load(locationField.getText().startsWith("http://") ? locationField.getText() :
"http://" + locationField.getText());
}
};
goButton.setOnAction(goAction);
locationField.setOnAction(goAction);
eng.locationProperty().addListener(new ChangeListener<String>() {
@Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
locationField.setText(newValue);
}
});
GridPane grid = new GridPane();
grid.setVgap(5);
grid.setHgap(5);
GridPane.setConstraints(locationField, 0, 0, 1, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.SOMETIMES);
GridPane.setConstraints(goButton,1,0);
GridPane.setConstraints(view, 0, 1, 2, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS);
grid.getColumnConstraints().addAll(
new ColumnConstraints(100, 100, Double.MAX_VALUE, Priority.ALWAYS, HPos.CENTER, true),
new ColumnConstraints(40, 40, 40, Priority.NEVER, HPos.CENTER, true)
);
grid.getChildren().addAll(locationField, goButton, view);
getChildren().add(grid);
}
示例5: layoutChildren
import javafx.geometry.VPos; //导入依赖的package包/类
@Override protected void layoutChildren() {
if (isFixedSize) {
super.layoutChildren();
} else {
List<Node> managed = getManagedChildren();
double width = getWidth();
///System.out.println("width = " + width);
double height = getHeight();
///System.out.println("height = " + height);
double top = getInsets().getTop();
double right = getInsets().getRight();
double left = getInsets().getLeft();
double bottom = getInsets().getBottom();
for (int i = 0; i < managed.size(); i++) {
Node child = managed.get(i);
layoutInArea(child, left, top,
width - left - right, height - top - bottom,
0, Insets.EMPTY, true, true, HPos.CENTER, VPos.CENTER);
}
}
}
示例6: createIconContent
import javafx.geometry.VPos; //导入依赖的package包/类
public static Node createIconContent() {
Text text = new Text("abc");
text.setTextOrigin(VPos.TOP);
text.setLayoutX(10);
text.setLayoutY(11);
text.setFill(Color.BLACK);
text.setOpacity(0.5);
text.setFont(Font.font(null, FontWeight.BOLD, 20));
text.setStyle("-fx-font-size: 20px;");
Text text2 = new Text("abc");
text2.setTextOrigin(VPos.TOP);
text2.setLayoutX(28);
text2.setLayoutY(51);
text2.setFill(Color.BLACK);
text2.setFont(javafx.scene.text.Font.font(null, FontWeight.BOLD, 20));
text2.setStyle("-fx-font-size: 20px;");
Line line = new Line(30, 32, 45, 57);
line.setStroke(Color.DARKMAGENTA);
return new javafx.scene.Group(text, line, text2);
}
示例7: addFormField
import javafx.geometry.VPos; //导入依赖的package包/类
public FormPane addFormField(String text, Node... fields) {
Label label = new Label(text);
String labelId = idText(text);
label.setId(labelId);
GridPane.setValignment(label, VPos.TOP);
int column = 0;
add(label, column++, currentRow, 1, 1);
int colspan = columns - fields.length;
int fieldIndex = 1;
for (Node field : fields) {
field.setId(labelId + "-field-" + fieldIndex);
setFormConstraints(field);
GridPane.setValignment(field, VPos.TOP);
add(field, column++, currentRow, colspan, 1);
fieldIndex++;
}
currentRow++;
column = 0;
return this;
}
示例8: resize
import javafx.geometry.VPos; //导入依赖的package包/类
private void resize() {
width = getSkinnable().getWidth();
height = getSkinnable().getHeight();
if (width > 0 && height > 0) {
size = getSkinnable().getWidth() < getSkinnable().getHeight() ? getSkinnable().getWidth() : getSkinnable().getHeight();
background.setPrefSize(width, height);
transformer.setPrefSize(width, height);
name.setText(getSkinnable().getName());
name.setFont(Font.font(size*NAME_TEXT_SIZE_FACTOR));
name.setX((size - name.getLayoutBounds().getWidth()) * 0.5);
name.setY((size - name.getLayoutBounds().getHeight()) * 0.5);
name.setTextOrigin(VPos.TOP);
updateState();
}
}
示例9: resize
import javafx.geometry.VPos; //导入依赖的package包/类
private void resize() {
width = getSkinnable().getWidth();
height = getSkinnable().getHeight();
if (width > 0 && height > 0) {
size = getSkinnable().getWidth() < getSkinnable().getHeight() ? getSkinnable().getWidth() : getSkinnable().getHeight();
background.setPrefSize(width, height);
load.setPrefSize(width, height);
name.setText(getSkinnable().getName());
name.setFont(Font.font(size*NAME_TEXT_SIZE_FACTOR));
name.setX((size - name.getLayoutBounds().getWidth()) * 0.5);
name.setY((size - name.getLayoutBounds().getHeight()) * 0.5);
name.setTextOrigin(VPos.TOP);
updateState();
}
}
示例10: GoogleEntryDetailsView
import javafx.geometry.VPos; //导入依赖的package包/类
public GoogleEntryDetailsView(GoogleEntry entry) {
super(requireNonNull(entry));
this.entry = entry;
Label notificationLabel = new Label("Notification:");
Label addButton = new Label("Add a notification");
addButton.getStyleClass().add("link");
addButton.setOnMouseClicked(evt -> createReminder());
addButton.disableProperty().bind(entry.getCalendar().readOnlyProperty());
VBox center = new VBox();
BorderPane notificationPane = new BorderPane();
notificationPane.setCenter(center);
notificationPane.setBottom(addButton);
GridPane box = (GridPane) getChildren().get(0);
box.add(notificationLabel, 0, 5);
box.add(notificationPane, 1, 5);
GridPane.setValignment(notificationLabel, VPos.TOP);
getStyleClass().add("details-view");
if (entry.isUseDefaultReminder()) {
GoogleCalendar calendar = (GoogleCalendar) entry.getCalendar();
reminders.addAll(calendar.getDefaultReminders());
}
reminders.addAll(entry.getReminders());
reminders.addListener((Observable obs) -> buildItems(center));
buildItems(center);
}
示例11: setupView
import javafx.geometry.VPos; //导入依赖的package包/类
private void setupView() {
ImageView weatherIcon = new ImageView();
weatherIcon.setImage(weatherEvent.getForecast().getWeather().getIcon());
weatherIcon.fitWidthProperty().bind(stage.widthProperty().divide(3));
weatherIcon.fitHeightProperty().bind(stage.heightProperty().multiply(1));
GridPane.setHgrow(weatherIcon, Priority.ALWAYS);
GridPane.setVgrow(weatherIcon, Priority.ALWAYS);
GridPane.setHalignment(weatherIcon, HPos.CENTER);
GridPane.setValignment(weatherIcon, VPos.CENTER);
add(weatherIcon, 0, 0);
Text txt_weather_event = new Text();
txt_weather_event.setText(controller.getWeatherEventText());
GridPane.setHgrow(txt_weather_event, Priority.ALWAYS);
GridPane.setVgrow(txt_weather_event, Priority.ALWAYS);
GridPane.setValignment(txt_weather_event, VPos.CENTER);
add(txt_weather_event, 1, 0);
}
示例12: getContentPane
import javafx.geometry.VPos; //导入依赖的package包/类
private GridPane getContentPane() {
contentPane.setHgap(10);
contentPane.setVgap(10);
// top-align all child nodes
contentPane.getChildren().addListener((ListChangeListener<Node>) c -> {
while (c.next()) {
if (c.wasAdded()) {
c.getAddedSubList().forEach(node ->
GridPane.setValignment(node, VPos.TOP));
}
}
});
ColumnConstraints titleCC = new ColumnConstraints();
titleCC.setPrefWidth(100);
ColumnConstraints valueCC = new ColumnConstraints();
valueCC.setFillWidth(true);
valueCC.setHgrow(Priority.ALWAYS);
contentPane.getColumnConstraints().addAll(titleCC, valueCC);
VBox.setVgrow(contentPane, Priority.ALWAYS);
return contentPane;
}
示例13: drawNumbers
import javafx.geometry.VPos; //导入依赖的package包/类
/**
* Draw numbers along the X axis for a previously drawn grid. Each number
* aligns with the corresponding intersection on the grid.
* @param gc Graphics context
* @param startX Start point on x axis
* @param startY Start point on y axis
* @param rows Number of rows
* @param columns Number of columns
* @param cellSize Size of each cell in the grid
* @param distance Draw distance away from the left of the grid
*/
private void drawNumbers(GraphicsContext gc, double startX, double
startY, int rows, int columns, double cellSize, double distance) {
gc.save();
gc.setFont(BOARD_FONT);
gc.setFill(Color.rgb(0,0,0, 0.75));
for(int i = 0; i < size; i++) {
double offset = i*cellSize;
gc.setTextAlign(TextAlignment.CENTER);
gc.setTextBaseline(VPos.CENTER);
gc.fillText(Integer.toString(rows + 1 - i), startX - distance,
startY + offset);
}
gc.restore();
}
示例14: resize
import javafx.geometry.VPos; //导入依赖的package包/类
private void resize() {
width = getWidth() - getInsets().getLeft() - getInsets().getRight();
height = getHeight() - getInsets().getTop() - getInsets().getBottom();
size = width < height ? width : height;
if (width > 0 && height > 0) {
canvas.setWidth(width);
canvas.setHeight(height);
canvas.relocate((getWidth() - width) * 0.5, (getHeight() - height) * 0.5);
ctx.setTextBaseline(VPos.CENTER);
ctx.setFont(Font.font(Helper.clamp(8, 24, size * 0.025)));
prepareData();
}
}
示例15: initGraphics
import javafx.geometry.VPos; //导入依赖的package包/类
private void initGraphics() {
if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 ||
Double.compare(getHeight(), 0.0) <= 0) {
if (getPrefWidth() > 0 && getPrefHeight() > 0) {
setPrefSize(getPrefWidth(), getPrefHeight());
} else {
setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
}
}
getStyleClass().add("coxcomb-chart");
popup = new InfoPopup();
canvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
ctx = canvas.getGraphicsContext2D();
ctx.setLineCap(StrokeLineCap.BUTT);
ctx.setTextBaseline(VPos.CENTER);
ctx.setTextAlign(TextAlignment.CENTER);
pane = new Pane(canvas);
getChildren().setAll(pane);
}