本文整理汇总了Java中javafx.geometry.HPos.LEFT属性的典型用法代码示例。如果您正苦于以下问题:Java HPos.LEFT属性的具体用法?Java HPos.LEFT怎么用?Java HPos.LEFT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javafx.geometry.HPos
的用法示例。
在下文中一共展示了HPos.LEFT属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHeaderPane
public Node createHeaderPane(WeekView calView) {
final GridPane container = new GridPane();
container.setAlignment(Pos.BOTTOM_LEFT);
container.getStyleClass().add("headerpane");
final Label lblWeekday = new Label(calView.getDate().get().format(DateTimeFormatter.ofPattern("EEE")));
lblWeekday.getStyleClass().add("label-weekday");
final Label lblDate = new Label(calView.getDate().get().toString());
lblDate.getStyleClass().add("label-date");
final ContextMenu dayChooserMenu = new ContextMenu();
final CustomMenuItem item = new CustomMenuItem(new DayChooser(calView.getDate()));
dayChooserMenu.getStyleClass().add("day-chooser");
item.setHideOnClick(false);
dayChooserMenu.getItems().add(item);
lblDate.setOnMouseClicked(event ->
dayChooserMenu.show(lblDate,
lblDate.localToScreen(0, 0).getX(),
lblDate.localToScreen(0, 0).getY())
);
final Button left = new Button("<");
left.getStyleClass().add("header-button");
left.setOnAction(event -> calView.getDate().set(calView.getDate().get().minusDays(1)));
final Button right = new Button(">");
right.getStyleClass().add("header-button");
right.setOnAction(event -> calView.getDate().set(calView.getDate().get().plusDays(1)));
final ColumnConstraints columnWeekday = new ColumnConstraints(70);
final ColumnConstraints columnCenter = new ColumnConstraints(20,50,Double.POSITIVE_INFINITY, Priority.ALWAYS, HPos.LEFT,true);
final ColumnConstraints columnSwitcher = new ColumnConstraints(60);
container.getColumnConstraints().addAll(columnWeekday, columnCenter, columnSwitcher);
container.add(lblWeekday,0,0);
container.add(lblDate, 1,0);
container.add(new HBox(left, right), 2,0);
return container;
}
示例2: alignmentToHPos
/**
* Converts the given horizontal alignment to {@link HPos}.
*
* @param pHorizontalAlignment the horizontal alignment.
* @param pDefaultValue the default value to use.
* @return the appropriate {@link HPos}, or the given default value.
*/
public static HPos alignmentToHPos(int pHorizontalAlignment, HPos pDefaultValue)
{
switch (pHorizontalAlignment)
{
case IAlignmentConstants.ALIGN_LEFT:
return HPos.LEFT;
case IAlignmentConstants.ALIGN_CENTER:
return HPos.CENTER;
case IAlignmentConstants.ALIGN_RIGHT:
return HPos.RIGHT;
default:
return pDefaultValue;
}
}
示例3: whatToTest
public Step whatToTest()
{
buildPhrase();
wipe().slide().enter().head("What Could Go Wrong?");
cue(193);
letters("Thrower").withOval().at(new Centered(1200d,300d)).format(commentFormat).sketch().called("thrower");
Column column = new Column(world,new PointPair(1000,400,ViewPort.WIDTH,ViewPort.HEIGHT),HPos.LEFT,VPos.TOP);
cue(196);
column.enter();
column.head(new LettersAtom(column.groupSource(),"1. Notice the fail condition",commentFormat,Position.DEFAULT));
cue(199);
column.line(new LettersAtom(column.groupSource(),"2. Construct the exception",commentFormat,Position.DEFAULT));
cue(202);
column.line(new LettersAtom(column.groupSource(),"3. throw the exception",commentFormat,Position.DEFAULT));
return endBuild();
}
示例4: createLabels
/**
* Creates or updates the actual layout of the time axis.
* The layout can either be horizontal or vertical.
* The GridView is populated with columns/rows and labels are added accordingly.
* The labels show the time between this.timeStartProperty and this.timeEndProperty with
* this.timeStepsProperty in between.
* The time is formatted according to this.formatter.
*/
private void createLabels() {
this.getChildren().clear();
this.getRowConstraints().clear();
this.getColumnConstraints().clear();
for(LocalTime currentTime = getTimeStartProperty().get();
currentTime.isBefore(getTimeEndProperty().get()); ) {
// create a new label with the time
Label lblTime = new Label();
lblTime.setText(currentTime.format(getFormatter()));
lblTime.getStyleClass().add("time-axis-label");
// create a new row/column and add the label to it
if(horizontal) {
// center the label
lblTime.widthProperty().addListener(o -> lblTime.setTranslateX( -lblTime.widthProperty().getValue() / 2));
ColumnConstraints column = new ColumnConstraints(0, USE_COMPUTED_SIZE, Double.POSITIVE_INFINITY, Priority.SOMETIMES, HPos.LEFT, true);
this.getColumnConstraints().add(column);
this.add(lblTime, this.getColumnConstraints().size() - 1, 0);
} else {
// center the label
lblTime.heightProperty().addListener(o -> lblTime.setTranslateY( -lblTime.heightProperty().getValue() / 2));
RowConstraints row = new RowConstraints(0, USE_COMPUTED_SIZE, Double.POSITIVE_INFINITY, Priority.SOMETIMES, VPos.TOP, true);
this.getRowConstraints().add(row);
this.add(lblTime, 0, this.getRowConstraints().size() - 1);
}
// prevent overflows at midnight
LocalTime newTime = currentTime.plusMinutes(getTimeStepsProperty().get().toMinutes());
if(newTime.isAfter(currentTime)) {
currentTime = newTime;
} else {
break;
}
}
}
示例5: createColumnConstraint
private ColumnConstraints createColumnConstraint() {
ColumnConstraints constraints = new ColumnConstraints(
MIN_TILE_SIZE, getTileSize(), Region.USE_PREF_SIZE, Priority.NEVER, HPos.LEFT, true);
constraints.minWidthProperty().bind(tileSize);
constraints.prefWidthProperty().bind(tileSize);
constraints.maxWidthProperty().bind(tileSize);
return constraints;
}
示例6: FXTextArea
/**
* Creates a new instance of {@link FXTextArea}.
*
* @param pText the text.
*/
public FXTextArea(String pText)
{
super(pText);
alignment = new SimpleObjectProperty<>(HPos.LEFT);
alignment.addListener(pAlignmentObservable -> setTextAlignment());
}
示例7: alignRelativeToContent
/**
* Aligns the given node according to the given settings relative to the
* anchor node.
*
* @param pAnchorNode the node that is used for alignment.
* @param pNodeToAlign the node that is going to be aligned.
* @param pContentDisplay the content display to use.
* @param pHorizontalAlignment the horizontal alignment to use.
* @param pVerticalAlignment the vertical alignment to use.
*/
public static void alignRelativeToContent(Node pAnchorNode, Node pNodeToAlign, ContentDisplay pContentDisplay, HPos pHorizontalAlignment, VPos pVerticalAlignment)
{
if (pAnchorNode == null || pNodeToAlign == null)
{
return;
}
if (pContentDisplay == ContentDisplay.CENTER || pContentDisplay == ContentDisplay.BOTTOM || pContentDisplay == ContentDisplay.TOP)
{
if (pHorizontalAlignment == HPos.LEFT)
{
pNodeToAlign.setLayoutX(pAnchorNode.getLayoutX());
}
else if (pHorizontalAlignment == HPos.RIGHT)
{
pNodeToAlign.setLayoutX(pAnchorNode.getLayoutX() + pAnchorNode.prefWidth(-1) - pNodeToAlign.getLayoutBounds().getWidth());
}
}
if (pContentDisplay == ContentDisplay.CENTER || pContentDisplay == ContentDisplay.LEFT || pContentDisplay == ContentDisplay.RIGHT)
{
if (pVerticalAlignment == VPos.TOP)
{
pNodeToAlign.setLayoutY(pAnchorNode.getLayoutY() - pNodeToAlign.getLayoutBounds().getMinY());
}
else if (pVerticalAlignment == VPos.BOTTOM)
{
pNodeToAlign.setLayoutY(pAnchorNode.getLayoutY() - pNodeToAlign.getLayoutBounds().getMinY() + pAnchorNode.prefHeight(-1)
- pNodeToAlign.getLayoutBounds().getHeight());
}
}
}
示例8: setLayout
private void setLayout() {
// set layout for this pane
final RowConstraints headerRow = new RowConstraints(USE_PREF_SIZE, USE_COMPUTED_SIZE, USE_PREF_SIZE); // HEADER FOR FULL WEEK
final RowConstraints allDayRow = new RowConstraints(USE_PREF_SIZE, USE_COMPUTED_SIZE, USE_PREF_SIZE); // SINGLE DAY HEADER AND ALL DAY APPOINTMENTS
final RowConstraints calendarRow = new RowConstraints(
150, 500, Double.POSITIVE_INFINITY, Priority.ALWAYS, VPos.TOP, true); // CALENDAR
final ColumnConstraints columnConstraints = new ColumnConstraints(
400, 600, Double.POSITIVE_INFINITY, Priority.SOMETIMES, HPos.LEFT, true); // FULL WIDTH
this.getRowConstraints().addAll(headerRow, allDayRow, calendarRow);
this.getColumnConstraints().add(columnConstraints);
this.getStyleClass().add("weekview");
// create a container for the week header
Pane weekHeaderContainer = new StackPane();
weekHeaderContainer.getStyleClass().add("weekview-header-container");
this.weekHeaderContainer = weekHeaderContainer;
// ScrollPane that contains the DayPane and the TimeAxis
final ScrollPane scrollPane = new ScrollPane();
scrollPane.getStyleClass().add("weekview-scrollpane");
scrollPane.setStyle("-fx-background-color:transparent;"); // remove gray border
scrollPane.setFitToWidth(true);
scrollPane.setFitToHeight(true);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
// the ScrollPane holds a GridPane with two columns: one for the TimeAxis and one for the calendar
final GridPane scrollPaneContent = new GridPane();
scrollPaneContent.getStyleClass().add("weekview-scrollpane-content");
final ColumnConstraints timeColumn = new ColumnConstraints(
USE_PREF_SIZE, USE_COMPUTED_SIZE, USE_PREF_SIZE, Priority.ALWAYS, HPos.LEFT, false); // TIME COLUMN
final ColumnConstraints calendarColumn = new ColumnConstraints(
USE_PREF_SIZE, USE_COMPUTED_SIZE, Double.POSITIVE_INFINITY, Priority.ALWAYS, HPos.LEFT, true); // CALENDAR COLUMN
final RowConstraints rowConstraint = new RowConstraints(
USE_PREF_SIZE, USE_COMPUTED_SIZE, Double.POSITIVE_INFINITY, Priority.ALWAYS, VPos.TOP, true); // FULL HEIGHT
scrollPaneContent.getColumnConstraints().addAll(timeColumn, calendarColumn);
scrollPaneContent.getRowConstraints().addAll(rowConstraint);
scrollPane.setContent(scrollPaneContent);
// create a container for the TimeAxis
Pane timeAxisContainer = new StackPane();
timeAxisContainer.getStyleClass().add("weekview-timeaxis-container");
scrollPaneContent.add(timeAxisContainer, 0, 0);
this.timeAxisContainer = timeAxisContainer;
// set up a GridPane that holds all the DayPanes and a GridPane for the headers and full day appointments
final GridPane dayPaneContainer = new GridPane();
dayPaneContainer.getStyleClass().add("weekview-daypane-container");
final GridPane dayHeaderContainer = new GridPane();
dayHeaderContainer.getStyleClass().add("weekview-day-header-container");
for (int i = 0; i < numberOfDays; i++) {
final ColumnConstraints appointmentsColumn = new ColumnConstraints(
USE_PREF_SIZE, dayPaneMinWidth, Double.POSITIVE_INFINITY, Priority.ALWAYS, HPos.CENTER, true);
dayPaneContainer.getColumnConstraints().add(appointmentsColumn);
dayHeaderContainer.getColumnConstraints().add(appointmentsColumn);
}
final RowConstraints singleDayHeaderRow = new RowConstraints(USE_PREF_SIZE, USE_COMPUTED_SIZE, USE_PREF_SIZE); // PANE FOR A DAILY HEADER
final RowConstraints singleDayAppointmentsRow = new RowConstraints(USE_PREF_SIZE, USE_COMPUTED_SIZE, USE_PREF_SIZE); // PANE FOR ALL DAY APPOINTMENTS
dayHeaderContainer.getRowConstraints().addAll(singleDayHeaderRow, singleDayAppointmentsRow);
timeAxisContainer.widthProperty().addListener(observable -> {
dayHeaderContainer.setPadding(new Insets(0, 17 /*scrollbar*/, 0, timeAxisContainer.getWidth() + 1));
});
final RowConstraints dayPanesRow = new RowConstraints(
USE_PREF_SIZE, USE_COMPUTED_SIZE, Double.POSITIVE_INFINITY, Priority.ALWAYS, VPos.TOP, true); // FULL HEIGHT
dayPaneContainer.getRowConstraints().add(dayPanesRow);
this.dayPanesContainer = dayPaneContainer;
this.dayHeadersContainer = dayHeaderContainer;
scrollPaneContent.add(dayPaneContainer, 1, 0);
// ordering is important:
this.add(scrollPane, 0, 2);
this.add(dayHeaderContainer, 0, 1);
this.add(weekHeaderContainer, 0, 0);
}