Java Code Examples for javafx.scene.control.Label#setPrefSize()

The following examples show how to use javafx.scene.control.Label#setPrefSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainScene.java    From mars-sim with GNU General Public License v3.0 6 votes vote down vote up
public void createLastSaveBar() {
	oldLastSaveStamp = sim.getLastSaveTimeStamp();
	oldLastSaveStamp = oldLastSaveStamp.replace("_", " ");

	lastSaveLabel = new Label();
	lastSaveLabel.setId("save-label");
	lastSaveLabel.setMaxWidth(Double.MAX_VALUE);
	if (OS.contains("linux")) {
		lastSaveLabel.setPrefWidth(LINUX_WIDTH);
		lastSaveLabel.setPrefSize(LINUX_WIDTH, 29);
	} else if (OS.contains("mac")) {
		lastSaveLabel.setPrefWidth(MACOS_WIDTH);
		lastSaveLabel.setPrefSize(MACOS_WIDTH, 28);
	} else {
		lastSaveLabel.setPrefWidth(WIN_WIDTH);
		lastSaveLabel.setPrefSize(WIN_WIDTH, 35);
	}

	lastSaveLabel.setAlignment(Pos.CENTER_RIGHT);
	lastSaveLabel.setTextAlignment(TextAlignment.RIGHT);
	lastSaveLabel.setText(LAST_SAVED + oldLastSaveStamp);

	setQuickToolTip(lastSaveLabel, "Last time the sim was saved");

}
 
Example 2
Source File: MainNode.java    From helloiot with GNU General Public License v3.0 6 votes vote down vote up
public void setToolbarButton(EventHandler<ActionEvent> backevent, Node graphic, String text) {
    
    Label l = new Label();
    l.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
    l.setAlignment(Pos.CENTER);
    l.setGraphic(graphic);
    l.setPrefSize(45.0, 40.0);             
    
    backbutton = new Button(text, l);     
    backbutton.setAlignment(Pos.BASELINE_LEFT);
    backbutton.setMaxWidth(Double.MAX_VALUE);
    backbutton.setFocusTraversable(false);
    backbutton.setMnemonicParsing(false);
    backbutton.getStyleClass().add("menubutton");
    backbutton.setOnAction(backevent);
    backbutton.setVisible(backevent != null);
}
 
Example 3
Source File: DateTileSkin.java    From OEE-Designer with MIT License 6 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

    final ZonedDateTime TIME = tile.getTime();

    titleText = new Text(DAY_FORMATTER.format(TIME));
    titleText.setFill(tile.getTitleColor());

    description = new Label(Integer.toString(TIME.getDayOfMonth()));
    description.setAlignment(Pos.CENTER);
    description.setTextAlignment(TextAlignment.CENTER);
    description.setWrapText(true);
    description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS);
    description.setTextFill(tile.getTextColor());
    description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.72);
    description.setFont(Fonts.latoLight(PREFERRED_HEIGHT * 0.65));

    text = new Text(MONTH_YEAR_FORMATTER.format(TIME));
    text.setFill(tile.getTextColor());

    getPane().getChildren().addAll(titleText, text, description);
}
 
Example 4
Source File: CharacterTileSkin.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

    titleText = new Text();
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    description = new Label(tile.getDescription());
    description.setAlignment(Pos.CENTER);
    description.setTextAlignment(TextAlignment.CENTER);
    description.setWrapText(true);
    description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS);
    description.setTextFill(tile.getTextColor());
    description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795);
    Helper.enableNode(description, tile.isTextVisible());

    text = new Text(tile.getText());
    text.setFill(tile.getUnitColor());
    Helper.enableNode(text, tile.isTextVisible());

    getPane().getChildren().addAll(titleText, text, description);
}
 
Example 5
Source File: TextTileSkin.java    From OEE-Designer with MIT License 6 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

    titleText = new Text();
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    description = new Label(tile.getDescription());
    description.setAlignment(tile.getDescriptionAlignment());
    description.setTextAlignment(TextAlignment.RIGHT);
    description.setWrapText(true);
    description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS);
    description.setTextFill(tile.getDescriptionColor());
    description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795);
    Helper.enableNode(description, tile.isTextVisible());

    text = new Text(tile.getText());
    text.setFill(tile.getUnitColor());
    Helper.enableNode(text, tile.isTextVisible());

    getPane().getChildren().addAll(titleText, text, description);
}
 
Example 6
Source File: BlackLevelGenerator.java    From testing-video with GNU General Public License v3.0 5 votes vote down vote up
private static Label text(Resolution res, ColorMatrix matrix, int col) {
    Label l = new Label(Integer.toString(getLuma(matrix, col)));
    l.setFont(font(res.height / 54));
    l.setTextFill(gray(matrix.fromLumaCode(matrix.YMIN * 4)));
    l.setTextAlignment(TextAlignment.CENTER);
    l.setAlignment(Pos.CENTER);
    l.setPrefSize(getW(res.width, col), getLabelH(res.height));
    return l;
}
 
Example 7
Source File: NotificationPanel.java    From trex-stateless-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Build component UI
 */
private void buildUI() {

    this.setSpacing(5);
    
    // add notification message
    notificationContainer = new Pane();
    notificationContainer.setPrefSize(184, 64);
    notificationContainer.getStyleClass().add("notificationContainer");
    notificationLabel = new Label();
    notificationLabel.setPrefSize(155, 60);
    notificationLabel.setWrapText(true);
    notificationLabel.getStyleClass().add("notificationMsg");
    notificationContainer.getChildren().add(notificationLabel);
    getChildren().add(notificationContainer);

    // add notification icon
    VBox iconHolder = new VBox();
    iconHolder.setPrefHeight(68);
    iconHolder.setAlignment(Pos.CENTER);
    ImageView notificationIcon = new ImageView(new Image("/icons/info_icon.png"));
    notificationIcon.getStyleClass().add("notificationIcon");
    notificationIcon.setOnMouseClicked((MouseEvent event) -> {
        notificationContainer.setVisible(!notificationContainer.isVisible());
    });
    iconHolder.getChildren().add(notificationIcon);
    getChildren().add(iconHolder);

}
 
Example 8
Source File: PopOver.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Creates a pop over with a label as the content node.
 */
public PopOver() {
    super();

    getStyleClass().add(DEFAULT_STYLE_CLASS);

    setAnchorLocation(AnchorLocation.WINDOW_TOP_LEFT);
    setOnHiding(new EventHandler<WindowEvent>() {
        @Override
        public void handle(WindowEvent evt) {
            setDetached(false);
        }
    });

    /*
     * Create some initial content.
     */
    Label label = new Label("<No Content>"); //$NON-NLS-1$
    label.setPrefSize(200, 200);
    label.setPadding(new Insets(4));
    setContentNode(label);

    ChangeListener<Object> repositionListener = new ChangeListener<Object>() {
        @Override
        public void changed(ObservableValue<? extends Object> value,
                            Object oldObject, Object newObject) {
            if (isShowing() && !isDetached()) {
                show(getOwnerNode(), targetX, targetY);
                adjustWindowLocation();
            }
        }
    };

    arrowSize.addListener(repositionListener);
    cornerRadius.addListener(repositionListener);
    arrowLocation.addListener(repositionListener);
    arrowIndent.addListener(repositionListener);
}
 
Example 9
Source File: TrainingExerciseBase.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
public DelayPane(DelayedStartListener listener) {
	getColumnConstraints().add(new ColumnConstraints(100));
	setVgap(5);

	final Label instructionsLabel = new Label("Set interval within which a beep will sound\n"
			+ "to signal the start of a round.\nDefault: A round starts after a random wait\n"
			+ "between 4 and 8 seconds in length.\n");
	instructionsLabel.setPrefSize(300, 77);

	this.add(instructionsLabel, 0, 0, 2, 3);
	addRow(3, new Label("Min (s)"));
	addRow(4, new Label("Max (s)"));

	final TextField minTextField = new TextField("4");
	this.add(minTextField, 1, 3);

	final TextField maxTextField = new TextField("8");
	this.add(maxTextField, 1, 4);

	minTextField.textProperty().addListener((observable, oldValue, newValue) -> {
		if (!newValue.matches("\\d*")) {
			minTextField.setText(oldValue);
			minTextField.positionCaret(minTextField.getLength());
		} else {
			listener.updatedDelayedStartInterval(Integer.parseInt(minTextField.getText()),
					Integer.parseInt(maxTextField.getText()));
		}
	});

	maxTextField.textProperty().addListener((observable, oldValue, newValue) -> {
		if (!newValue.matches("\\d*")) {
			maxTextField.setText(oldValue);
			maxTextField.positionCaret(maxTextField.getLength());
		} else {
			listener.updatedDelayedStartInterval(Integer.parseInt(minTextField.getText()),
					Integer.parseInt(maxTextField.getText()));
		}
	});
}
 
Example 10
Source File: CursorSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private Node createBox(Cursor cursor) {
    Label label = new Label(cursor.toString());
    label.setAlignment(Pos.CENTER);
    label.setPrefSize(85, 85);
    label.setStyle("-fx-border-color: #aaaaaa; -fx-background-color: #dddddd;");
    label.setCursor(cursor);
    return label;
}
 
Example 11
Source File: CursorSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private Node createBox(Cursor cursor) {
    Label label = new Label(cursor.toString());
    label.setAlignment(Pos.CENTER);
    label.setPrefSize(85, 85);
    label.setStyle("-fx-border-color: #aaaaaa; -fx-background-color: #dddddd;");
    label.setCursor(cursor);
    return label;
}
 
Example 12
Source File: HeadlessController.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void autocalibrationTimedOut() {
	calibrated = false;

	final Label calibrationLabel = new Label("Calibration Failed!");
	calibrationLabel.setFont(Font.font(48));
	calibrationLabel.setTextFill(Color.web("#f5a807"));
	calibrationLabel.setLayoutX(6);
	calibrationLabel.setLayoutY(6);
	calibrationLabel.setPrefSize(628, 90);
	calibrationLabel.setAlignment(Pos.CENTER);

	arenaPane.getCanvasManager().getCanvasGroup().getChildren().add(calibrationLabel);
}
 
Example 13
Source File: NetProtocolSettingFrame.java    From oim-fx with MIT License 4 votes vote down vote up
private void initComponent() {
	this.setWidth(520);
	this.setHeight(120);
	this.setResizable(false);
	this.setTitlePaneStyle(2);
	this.setRadius(5);
	this.setCenter(rootPane);
	this.setTitle("服务器地址设置");

	titleLabel.setText("服务器地址设置");
	titleLabel.setFont(Font.font("微软雅黑", 14));
	titleLabel.setStyle("-fx-text-fill:rgba(255, 255, 255, 1)");

	topBox.setStyle("-fx-background-color:#2cb1e0");
	topBox.setPrefHeight(35);
	topBox.setPadding(new Insets(5, 10, 5, 10));
	topBox.setSpacing(10);
	topBox.getChildren().add(titleLabel);

	Label addressLabel = new Label("服务器地址:");

	addressField.setPromptText("服务器地址");

	addressLabel.setPrefSize(75, 25);
	addressLabel.setLayoutX(10);
	addressLabel.setLayoutY(5);
	addressField.setPrefSize(250, 25);
	addressField.setLayoutX(addressLabel.getLayoutX() + addressLabel.getPrefWidth() + 10);
	addressField.setLayoutY(addressLabel.getLayoutY());

	portField.setPromptText("端口");
	Label partLabel = new Label("端口:");

	partLabel.setPrefSize(40, 25);
	partLabel.setLayoutX(355);
	partLabel.setLayoutY(5);
	portField.setPrefSize(80, 25);
	portField.setLayoutX(partLabel.getLayoutX() + partLabel.getPrefWidth() + 10);
	portField.setLayoutY(partLabel.getLayoutY());

	AnchorPane infoPane = new AnchorPane();
	infoPane.setStyle("-fx-background-color:#ffffff");
	infoPane.getChildren().add(addressLabel);
	infoPane.getChildren().add(addressField);

	infoPane.getChildren().add(partLabel);
	infoPane.getChildren().add(portField);

	cancelButton.setText("取消");
	cancelButton.setPrefWidth(80);

	button.setText("确定");
	button.setPrefWidth(80);

	bottomBox.setStyle("-fx-background-color:#c9e1e9");
	bottomBox.setAlignment(Pos.BASELINE_RIGHT);
	bottomBox.setPadding(new Insets(5, 10, 5, 10));
	bottomBox.setSpacing(10);
	bottomBox.getChildren().add(button);
	bottomBox.getChildren().add(cancelButton);

	rootPane.setTop(topBox);
	rootPane.setCenter(infoPane);
	rootPane.setBottom(bottomBox);
	Pattern pattern = Pattern.compile("0|(-?([1-9]\\d*)?)");
	;
	TextFormatter<Integer> formatter = new TextFormatter<Integer>(new StringConverter<Integer>() {

		@Override
		public String toString(Integer value) {
			return null != value ? value.toString() : "0";
		}

		@Override
		public Integer fromString(String text) {
			int i = 0;
			if (null != text) {
				Matcher matcher = pattern.matcher(text);
				if (matcher.matches()) {
					i = Integer.parseInt(text);
				}
			}
			return i;
		}
	});
	portField.setTextFormatter(formatter);
}
 
Example 14
Source File: StatusTileSkin.java    From tilesfx with Apache License 2.0 4 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

    titleText = new Text();
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    description = new Label(tile.getDescription());
    description.setAlignment(tile.getDescriptionAlignment());
    description.setTextAlignment(TextAlignment.RIGHT);
    description.setWrapText(true);
    description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS);
    description.setTextFill(tile.getTextColor());
    description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795);
    Helper.enableNode(description, tile.isTextVisible());

    Color foregroundColor = getSkinnable().getForegroundColor();
    Color halfTranslucent = Helper.getColorWithOpacity(foregroundColor, 0.5);

    verticalDivider = new Line(0, PREFERRED_HEIGHT * 0.35, PREFERRED_WIDTH, PREFERRED_HEIGHT * 0.35);
    verticalDivider.getStrokeDashArray().addAll(2.0, 2.0);
    verticalDivider.setStrokeDashOffset(1);
    verticalDivider.setStroke(halfTranslucent);
    verticalDivider.setStrokeWidth(1);

    horizontal1Divider = new Line(PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.45, PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.85);
    horizontal1Divider.getStrokeDashArray().addAll(2.0, 2.0);
    horizontal1Divider.setStrokeDashOffset(1);
    horizontal1Divider.setStroke(halfTranslucent);
    horizontal1Divider.setStrokeWidth(1);

    horizontal2Divider = new Line(2 * PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.45, 2 * PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.85);
    horizontal2Divider.getStrokeDashArray().addAll(2.0, 2.0);
    horizontal2Divider.setStrokeDashOffset(1);
    horizontal2Divider.setStroke(halfTranslucent);
    horizontal2Divider.setStrokeWidth(1);

    leftGraphicsPane = new StackPane();
    middleGraphicsPane = new StackPane();
    rightGraphicsPane = new StackPane();

    if (null != tile.getLeftGraphics()) { leftGraphicsPane.getChildren().setAll(tile.getLeftGraphics()); }
    if (null != tile.getMiddleGraphics()) { middleGraphicsPane.getChildren().setAll(tile.getMiddleGraphics()); }
    if (null != tile.getRightGraphics()) { rightGraphicsPane.getChildren().setAll(tile.getRightGraphics()); }

    leftValueLabel = new Label();
    leftValueLabel.setAlignment(Pos.CENTER);

    middleValueLabel = new Label();
    middleValueLabel.setAlignment(Pos.CENTER);

    rightValueLabel = new Label();
    rightValueLabel.setAlignment(Pos.CENTER);

    leftLabel = new Label();
    leftLabel.setAlignment(Pos.CENTER);

    middleLabel = new Label();
    middleLabel.setAlignment(Pos.CENTER);

    rightLabel = new Label();
    rightLabel.setAlignment(Pos.CENTER);

    text = new Text(tile.getText());
    text.setFill(tile.getUnitColor());
    Helper.enableNode(text, tile.isTextVisible());

    getPane().getChildren().addAll(titleText, description,
                                   verticalDivider, horizontal1Divider, horizontal2Divider, leftGraphicsPane, middleGraphicsPane, rightGraphicsPane,
                                   leftValueLabel, middleValueLabel, rightValueLabel,
                                   leftLabel, middleLabel, rightLabel,
                                   text);
}
 
Example 15
Source File: CalendarTileSkin.java    From tilesfx with Apache License 2.0 4 votes vote down vote up
private void drawCells() {
    List<ChartData> dataList   = tile.getChartData();
    ZonedDateTime   time       = tile.getTime();
    Locale          locale     = tile.getLocale();
    int             day        = time.getDayOfMonth();
    int             startDay   = time.withDayOfMonth(1).getDayOfWeek().getValue();
    long            lastDay    = time.range(DAY_OF_MONTH).getMaximum();
    Color           textColor  = tile.getTextColor();
    Color           bkgColor   = tile.getBackgroundColor();
    Font            regFont    = Fonts.latoRegular(size * 0.045);
    Font            bldFont    = Fonts.latoBold(size * 0.045);
    Background      bkgToday   = new Background(new BackgroundFill(tile.getBarColor(), new CornerRadii(size * 0.0125), new Insets(2)));
    Border          appmntBorder = new Border(new BorderStroke(tile.getAlarmColor(),
                                                               tile.getAlarmColor(),
                                                               tile.getAlarmColor(),
                                                               tile.getAlarmColor(),
                                                               BorderStrokeStyle.SOLID,
                                                               BorderStrokeStyle.SOLID,
                                                               BorderStrokeStyle.SOLID,
                                                               BorderStrokeStyle.SOLID,
                                                               new CornerRadii(size * 0.0125), BorderWidths.DEFAULT,
                                                               new Insets(1)));
    boolean counting = false;
    int dayCounter = 1;
    for (int y = 0 ; y < 7 ; y++) {
        for (int x = 0 ; x < 8 ; x++) {
            int index = y * 8 + x;
            Label label = labels.get(index);

            String text;
            if (x == 0 && y == 0) {
                text = "";
                label.setManaged(false);
                label.setVisible(false);
            } else if (y == 0) {
                text = DayOfWeek.of(x).getDisplayName(TextStyle.SHORT, locale);
                //label.setTextFill(x == 7 ? Tile.RED : textColor);
                label.setTextFill(textColor);
                label.setFont(bldFont);
            } else if (x == 0) {
                text = Integer.toString(time.withDayOfMonth(1).plusDays((y - 1) * 7).get(IsoFields.WEEK_OF_WEEK_BASED_YEAR));
                label.setTextFill(Tile.GRAY);
                label.setFont(regFont);
                label.setBorder(weekBorder);
            } else {
                if (index - 7 > startDay) {
                    counting = true;
                    text = Integer.toString(dayCounter);

                    LocalDate currentDay = time.toLocalDate().plusDays(dayCounter - 1);
                    long appointments    = dataList.stream().filter(data -> data.getTimestampAsLocalDate().isEqual(currentDay)).count();

                    if (x == 7) {
                        if (appointments > 0) { label.setBorder(appmntBorder); } else { label.setBorder(null); }
                        label.setTextFill(Tile.RED);
                        label.setFont(regFont);
                    } else if (dayCounter == day) {
                        if (appointments > 0) { label.setBorder(appmntBorder); } else { label.setBorder(null); }
                        label.setBackground(bkgToday);
                        label.setTextFill(bkgColor);
                        label.setFont(bldFont);
                    } else {
                        int currentDayCounter = dayCounter;
                        if (dataList.stream().filter(data -> data.getTimestampAsLocalDate().getDayOfMonth() == currentDayCounter).count() > 0) { label.setBorder(appmntBorder); } else { label.setBorder(null); }
                        label.setTextFill(textColor);
                        label.setFont(regFont);
                    }
                } else {
                    text = "";
                    label.setManaged(false);
                    label.setVisible(false);
                }
                if (dayCounter > lastDay) {
                    text = "";
                    label.setManaged(false);
                    label.setVisible(false);
                }
                if (counting) { dayCounter++; }
            }

            label.setText(text);
            label.setVisible(true);
            label.setManaged(true);
            label.setPrefSize(cellWidth, cellHeight);
            label.relocate(x * cellWidth + cellOffsetX, y * cellHeight + cellOffsetY);
        }
    }
}
 
Example 16
Source File: CalendarTileSkin.java    From OEE-Designer with MIT License 4 votes vote down vote up
private void drawCells() {
    List<ChartData> dataList   = tile.getChartData();
    ZonedDateTime   time       = tile.getTime();
    Locale          locale     = tile.getLocale();
    int             day        = time.getDayOfMonth();
    int             startDay   = time.withDayOfMonth(1).getDayOfWeek().getValue();
    long            lastDay    = time.range(DAY_OF_MONTH).getMaximum();
    Color           textColor  = tile.getTextColor();
    Color           bkgColor   = tile.getBackgroundColor();
    Font            regFont    = Fonts.latoRegular(size * 0.045);
    Font            bldFont    = Fonts.latoBold(size * 0.045);
    Background      bkgToday   = new Background(new BackgroundFill(tile.getBarColor(), new CornerRadii(size * 0.0125), new Insets(2)));
    Border          appmntBorder = new Border(new BorderStroke(tile.getAlarmColor(),
                                                               tile.getAlarmColor(),
                                                               tile.getAlarmColor(),
                                                               tile.getAlarmColor(),
                                                               BorderStrokeStyle.SOLID,
                                                               BorderStrokeStyle.SOLID,
                                                               BorderStrokeStyle.SOLID,
                                                               BorderStrokeStyle.SOLID,
                                                               new CornerRadii(size * 0.0125), BorderWidths.DEFAULT,
                                                               new Insets(1)));
    boolean counting = false;
    int dayCounter = 1;
    for (int y = 0 ; y < 7 ; y++) {
        for (int x = 0 ; x < 8 ; x++) {
            int index = y * 8 + x;
            Label label = labels.get(index);

            String text;
            if (x == 0 && y == 0) {
                text = "";
                label.setManaged(false);
                label.setVisible(false);
            } else if (y == 0) {
                text = DayOfWeek.of(x).getDisplayName(TextStyle.SHORT, locale);
                //label.setTextFill(x == 7 ? Tile.RED : textColor);
                label.setTextFill(textColor);
                label.setFont(bldFont);
            } else if (x == 0) {
                text = Integer.toString(time.withDayOfMonth(1).plusDays((y - 1) * 7).get(IsoFields.WEEK_OF_WEEK_BASED_YEAR));
                label.setTextFill(Tile.GRAY);
                label.setFont(regFont);
                label.setBorder(weekBorder);
            } else {
                if (index - 7 > startDay) {
                    counting = true;
                    text = Integer.toString(dayCounter);

                    LocalDate currentDay = time.toLocalDate().plusDays(dayCounter - 1);
                    long appointments    = dataList.stream().filter(data -> data.getTimestampAsLocalDate().isEqual(currentDay)).count();

                    if (x == 7) {
                        if (appointments > 0) { label.setBorder(appmntBorder); } else { label.setBorder(null); }
                        label.setTextFill(Tile.RED);
                        label.setFont(regFont);
                    } else if (dayCounter == day) {
                        if (appointments > 0) { label.setBorder(appmntBorder); } else { label.setBorder(null); }
                        label.setBackground(bkgToday);
                        label.setTextFill(bkgColor);
                        label.setFont(bldFont);
                    } else {
                        if (appointments > 0) { label.setBorder(appmntBorder); } else { label.setBorder(null); }
                        label.setTextFill(textColor);
                        label.setFont(regFont);
                    }
                } else {
                    text = "";
                    label.setManaged(false);
                    label.setVisible(false);
                }
                if (dayCounter > lastDay) {
                    text = "";
                    label.setManaged(false);
                    label.setVisible(false);
                }
                if (counting) { dayCounter++; }
            }

            label.setText(text);
            label.setVisible(true);
            label.setManaged(true);
            label.setPrefSize(cellWidth, cellHeight);
            label.relocate(x * cellWidth + cellOffsetX, y * cellHeight + cellOffsetY);
        }
    }
}
 
Example 17
Source File: NetSettingFrame.java    From oim-fx with MIT License 4 votes vote down vote up
private void initComponent() {
	this.setWidth(420);
	this.setHeight(120);
	this.setResizable(false);
	this.setTitlePaneStyle(2);
	this.setRadius(5);
	this.setCenter(rootPane);
	this.setTitle("服务器地址设置");

	Label nameLabel = new Label("服务器地址:");

	addressField.setPromptText("服务器地址");

	nameLabel.setPrefSize(75, 25);
	nameLabel.setLayoutX(10);
	nameLabel.setLayoutY(5);
	addressField.setPrefSize(300, 25);
	addressField.setLayoutX(nameLabel.getLayoutX() + nameLabel.getPrefWidth() + 10);
	addressField.setLayoutY(nameLabel.getLayoutY());

	AnchorPane infoPane = new AnchorPane();
	infoPane.setStyle("-fx-background-color:#ffffff");
	infoPane.getChildren().add(nameLabel);
	infoPane.getChildren().add(addressField);

	cancelButton.setText("取消");
	cancelButton.setPrefWidth(80);

	button.setText("确定");
	button.setPrefWidth(80);

	bottomBox.setStyle("-fx-background-color:#c9e1e9");
	bottomBox.setAlignment(Pos.BASELINE_RIGHT);
	bottomBox.setPadding(new Insets(5, 10, 5, 10));
	bottomBox.setSpacing(10);
	bottomBox.getChildren().add(button);
	bottomBox.getChildren().add(cancelButton);

	rootPane.setTop(topBox);
	rootPane.setCenter(infoPane);
	rootPane.setBottom(bottomBox);
}
 
Example 18
Source File: MainNode.java    From helloiot with GNU General Public License v3.0 4 votes vote down vote up
public void construct(List<UnitPage> appunitpages) {
    
    appunitpage.subscribeStatus(messagePageHandler);
    appbeeper.subscribeStatus(beeper.getMessageHandler());
    appbuzzer.subscribeStatus(buzzer.getMessageHandler());
    systime.subscribeStatus(timeindicator.getMessageHandler());

    // Add configured unitpages.
    for (UnitPage up : appunitpages) {
        this.addUnitPage(up);
    }

    //Init unit nodes
    for (Unit u : app.getUnits()) {
        Node n = u.getNode();
        if (n != null) {
            UnitPage unitpage = buildUnitPage(UnitPage.getPage(n));
            unitpage.addUnitNode(n);
        }
    }

    // Build listpages based on unitpages
    List<UnitPage> sortedunitpages = new ArrayList<>();
    sortedunitpages.addAll(unitpages.values());
    Collections.sort(sortedunitpages);
    firstmenupage = null;
    for (UnitPage value : sortedunitpages) {
        value.buildNode();
        if (!value.isSystem() && !value.isEmpty() && (value.getName() == null || !value.getName().startsWith("."))) {
            Label l = new Label();
            l.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
            l.setAlignment(Pos.CENTER);
            l.setGraphic(value.getGraphic());
            l.setPrefSize(45.0, 40.0);                
            Button buttonmenu = new Button(value.getText(), l);
            buttonmenu.getStyleClass().add("menubutton");
            buttonmenu.setAlignment(Pos.BASELINE_LEFT);
            buttonmenu.setMaxWidth(Double.MAX_VALUE);
            buttonmenu.setFocusTraversable(false);
            buttonmenu.setMnemonicParsing(false);
            buttonmenu.setOnAction(e -> {
                appunitpage.sendStatus(value.getName());              
            });
            menupages.getChildren().add(buttonmenu); // Last button is disconnect button
            if (firstmenupage == null) {
                firstmenupage = value.getName();
            }
        }
    }
    
    // Add backbutton
    if (backbutton != null && backbutton.isVisible()) {
        menupages.getChildren().add(new Separator(Orientation.HORIZONTAL));
        menupages.getChildren().add(backbutton);
    }
    
    gotoPage("start");

    // Remove menubutton if 0 or 1 visible page.
    menubutton.setVisible(!menupages.getChildren().isEmpty());
}
 
Example 19
Source File: GroupEditFrame.java    From oim-fx with MIT License 4 votes vote down vote up
private void initComponent() {
	this.setTitle("修改资料");
	this.setResizable(false);
	this.setTitlePaneStyle(2);
	this.setWidth(390);
	this.setHeight(520);
	this.setRadius(5);
	this.setCenter(rootPane);
	

	Label nameLabel = new Label("名 \t 称");
	Label introduceLabel = new Label("介 \t 绍");
	Label publicNoticeLabel = new Label("公 \t 告");
	
	nameField.setPromptText("名称");
	introduceTextArea.setPromptText("介 绍");
	publicNoticeTextArea.setPromptText("公 告");

	imagePanel.setHeadSize(70);
	imagePanel.setPrefSize(75, 75);
	imagePanel.setLayoutX(70);
	imagePanel.setLayoutY(20);
	
	nameLabel.setPrefSize(50, 25);
	nameLabel.setLayoutX(10);
	nameLabel.setLayoutY(120);
	nameField.setPrefSize(290, 25);
	nameField.setLayoutX(nameLabel.getLayoutX() + nameLabel.getPrefWidth() + 10);
	nameField.setLayoutY(nameLabel.getLayoutY());

	introduceLabel.setPrefSize(50, 25);
	introduceLabel.setLayoutX(10);
	introduceLabel.setLayoutY(nameField.getLayoutY() + nameField.getPrefHeight() + 15);
	introduceTextArea.setPrefSize(290, 120);
	introduceTextArea.setLayoutX(nameField.getLayoutX());
	introduceTextArea.setLayoutY(introduceLabel.getLayoutY());
	
	publicNoticeLabel.setPrefSize(50, 25);
	publicNoticeLabel.setLayoutX(10);
	publicNoticeLabel.setLayoutY(introduceTextArea.getLayoutY() + introduceTextArea.getPrefHeight() + 15);
	publicNoticeTextArea.setPrefSize(290, 120);
	publicNoticeTextArea.setLayoutX(nameField.getLayoutX());
	publicNoticeTextArea.setLayoutY(publicNoticeLabel.getLayoutY());

	AnchorPane infoPane = new AnchorPane();
	infoPane.setStyle("-fx-background-color:#ffffff");
	infoPane.getChildren().add(nameLabel);
	infoPane.getChildren().add(introduceLabel);
	infoPane.getChildren().add(publicNoticeLabel);

	infoPane.getChildren().add(nameField);
	infoPane.getChildren().add(introduceTextArea);
	infoPane.getChildren().add(publicNoticeTextArea);

	cancelButton.setText("取消");
	cancelButton.setPrefWidth(80);

	button.setText("确定");
	button.setPrefWidth(80);

	bottomBox.setStyle("-fx-background-color:#c9e1e9");
	bottomBox.setAlignment(Pos.BASELINE_RIGHT);
	bottomBox.setPadding(new Insets(5, 10, 5, 10));
	bottomBox.setSpacing(10);
	bottomBox.getChildren().add(button);
	bottomBox.getChildren().add(cancelButton);

	
	//VBox vBox=new VBox();
	
	infoPane.getChildren().add(imagePanel);
	//vBox.getChildren().add(infoPane);
	
	rootPane.setCenter(infoPane);
	rootPane.setBottom(bottomBox);
}
 
Example 20
Source File: QuestionPane.java    From oim-fx with MIT License 4 votes vote down vote up
private void initComponent() {
	this.setStyle("-fx-background-color:#ffffff");
	upButton.setText("上一步");
	button.setText("确定");

	upButton.setPrefSize(80, 25);
	button.setPrefSize(80, 25);
	
	Label passwordLabel = new Label("新密码");
	Label confirmPasswordLabel = new Label("确认密码");

	passwordField.setPromptText("新密码");
	confirmPasswordField.setPromptText("确认密码");

	passwordLabel.setPrefSize(50, 25);
	passwordLabel.setLayoutX(10);
	passwordLabel.setLayoutY(15);
	passwordField.setPrefSize(290, 25);
	passwordField.setLayoutX(passwordLabel.getLayoutX() + passwordLabel.getPrefWidth() + 10);
	passwordField.setLayoutY(passwordLabel.getLayoutY());

	confirmPasswordLabel.setPrefSize(50, 25);
	confirmPasswordLabel.setLayoutX(10);
	confirmPasswordLabel.setLayoutY(passwordField.getLayoutY() + passwordField.getPrefHeight() + 15);
	confirmPasswordField.setPrefSize(290, 25);
	confirmPasswordField.setLayoutX(confirmPasswordLabel.getLayoutX() + confirmPasswordLabel.getPrefWidth() + 10);
	confirmPasswordField.setLayoutY(confirmPasswordLabel.getLayoutY());

	AnchorPane infoPane = new AnchorPane();

	infoPane.getChildren().add(passwordLabel);
	infoPane.getChildren().add(confirmPasswordLabel);

	infoPane.getChildren().add(passwordField);
	infoPane.getChildren().add(confirmPasswordField);
	infoPane.setPrefHeight(confirmPasswordField.getLayoutY() + 50);

	topVBox.getChildren().add(infoPane);

	scrollPane.setBackground(Background.EMPTY);
	scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
	scrollPane.setContent(box);

	HBox bottomBox = new HBox();
	bottomBox.setAlignment(Pos.CENTER);
	bottomBox.setPadding(new Insets(5, 10, 5, 10));
	bottomBox.setSpacing(10);
	bottomBox.getChildren().add(upButton);
	bottomBox.getChildren().add(button);

	over.setContentNode(overLabel);
	
	baseBorderPane.setTop(topVBox);
	baseBorderPane.setCenter(scrollPane);
	baseBorderPane.setBottom(bottomBox);
	
	this.getChildren().add(baseBorderPane);
}