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

The following examples show how to use javafx.scene.control.Label#relocate() . 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: DeckBuilderWindow.java    From Cardshifter with Apache License 2.0 5 votes vote down vote up
private void displayCurrentPage() {
	this.cardListBox.getChildren().clear();
	for (CardInfoMessage message : this.pageList.get(this.currentPage)) {
		CardHandDocumentController card = new CardHandDocumentController(message, null);
		Pane cardPane = card.getRootPane();			
		
		Rectangle numberOfCardsBox = new Rectangle(cardPane.getPrefWidth()/3, cardPane.getPrefHeight()/10);
		numberOfCardsBox.setFill(Color.BLUE);
		numberOfCardsBox.setStroke(Color.BLACK);
		int numChosenCards = 0;
		if (this.activeDeckConfig.getChosen().get(message.getId()) != null) {
			numChosenCards = this.activeDeckConfig.getChosen().get(message.getId());
		}
		String id = (String) message.getProperties().get("id");

		Label numberOfCardsLabel = new Label(String.format("%d / %d", numChosenCards, this.activeDeckConfig.getMaxFor(id)));
		numberOfCardsLabel.setTextFill(Color.WHITE);
		numberOfCardsBox.relocate(cardPane.getPrefWidth()/2.6, cardPane.getPrefHeight() - cardPane.getPrefHeight()/18);
		numberOfCardsLabel.relocate(cardPane.getPrefWidth()/2.3, cardPane.getPrefHeight() - cardPane.getPrefHeight()/18);
		cardPane.getChildren().add(numberOfCardsBox);
		cardPane.getChildren().add(numberOfCardsLabel);
		
		cardPane.setOnMouseClicked(e -> {this.addCardToActiveDeck(e, message);});
		cardPane.setOnDragDetected(e -> this.startDragToActiveDeck(e, cardPane, message));
		this.cardListBox.getChildren().add(cardPane);
	}
}
 
Example 2
Source File: GenericButton.java    From Cardshifter with Apache License 2.0 5 votes vote down vote up
public void setUpLabel() {
	Label buttonLabel = new Label();
	buttonLabel.setText(this.buttonString);
	buttonLabel.setTextFill(Color.WHITE);
	buttonLabel.setStyle(String.format("-fx-font-size:%f", this.sizeY - this.sizeY * 0.60));
	buttonLabel.relocate(this.sizeX/3, this.sizeY/3);
	this.getChildren().add(buttonLabel);
}
 
Example 3
Source File: LabelTest.java    From oim-fx with MIT License 4 votes vote down vote up
@Override
public void start(Stage primaryStage) {
	try {
		Group root = new Group();
		Scene scene = new Scene(root, 400, 400);
		Pane p = new Pane();
		p.setPrefSize(400, 400);
		p.setBackground(new Background(new BackgroundFill(Color.GOLD,
				null, null)));
		root.getChildren().add(p);

		primaryStage.setScene(scene);
		primaryStage.setTitle("Conversation about Bubbles with Elltz");
		primaryStage.show();
		Label bl1 = new Label();
		bl1.relocate(10, 50);
		bl1.setText("Hi Elltz -:)");
		bl1.setBackground(new Background(new BackgroundFill(Color.YELLOWGREEN,
				null, null)));

		Label bl2 = new Label();
		bl2.relocate(310, 100);
		bl2.setText("Heloooo Me");
		bl2.setBackground(new Background(new BackgroundFill(Color.GREENYELLOW,
				null, null)));

		Label bl3 = new Label();
		bl3.relocate(10, 150);
		bl3.setText("you know this would be a nice library");
		bl3.setBackground(new Background(new BackgroundFill(Color.YELLOWGREEN,
				null, null)));

		Label bl4 = new Label();
		bl4.relocate(165, 200);
		bl4.setText("uhmm yea, kinda, but yknow,im tryna \nact like im not impressed");
		bl4.setBackground(new Background(new BackgroundFill(Color.GREENYELLOW,
				null, null)));

		Label bl5 = new Label();
		bl5.relocate(10, 250);
		bl5.setText("yea! yea! i see that, lowkey.. you not gonna\n get upvotes though..lmao");
		bl5.setBackground(new Background(new BackgroundFill(Color.YELLOWGREEN,
				null, null)));

		Label bl6 = new Label();
		bl6.relocate(165, 300);
		bl6.setText("Man! shut up!!.. what you know about\n upvotes.");
		bl6.setBackground(new Background(new BackgroundFill(Color.GREENYELLOW,
				null, null)));

		p.getChildren().addAll(bl1, bl2, bl3, bl4, bl5, bl6);

	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 4
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 5
Source File: BlackLevelGenerator.java    From testing-video with GNU General Public License v3.0 4 votes vote down vote up
private static Label top(Resolution res, ColorMatrix matrix, int col) {
    Label l = text(res, matrix, col);
    l.relocate(getX(res.width, col), 0);
    return l;
}
 
Example 6
Source File: BlackLevelGenerator.java    From testing-video with GNU General Public License v3.0 4 votes vote down vote up
private static Label bottom(Resolution res, ColorMatrix matrix, int col) {
    Label l = text(res, matrix, col);
    l.relocate(getX(res.width, col), res.height - l.getPrefHeight());
    return l;
}
 
Example 7
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 8
Source File: DockUIPanel.java    From AnchorFX with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void buildNode(String title, Image iconImage) {

        Objects.requireNonNull(iconImage);
        Objects.requireNonNull(title);
        
        barPanel = new Pane();

        String titleBarStyle = (!subStationStype) ? "docknode-title-bar" : "substation-title-bar";

        barPanel.getStyleClass().add(titleBarStyle);

        barPanel.setPrefHeight(BAR_HEIGHT);
        barPanel.relocate(0, 0);
        barPanel.prefWidthProperty().bind(widthProperty());

        titleLabel = new Label(title);

        String titleTextStyle = (!subStationStype) ? "docknode-title-text" : "substation-title-text";
        
        iconView = new ImageView(iconImage);
        iconView.setFitWidth(15);
        iconView.setFitHeight(15);
        iconView.setPreserveRatio(false);
        iconView.setSmooth(true);
        iconView.relocate(1,(BAR_HEIGHT-iconView.getFitHeight()) / 2);
         
        titleLabel.getStyleClass().add(titleTextStyle);
        barPanel.getChildren().addAll(iconView,titleLabel);
        titleLabel.relocate(25, 5);

        contentPanel = new StackPane();
        contentPanel.getStyleClass().add("docknode-content-panel");
        contentPanel.relocate(0, BAR_HEIGHT);
        contentPanel.prefWidthProperty().bind(widthProperty());
        contentPanel.prefHeightProperty().bind(heightProperty().subtract(BAR_HEIGHT));
        contentPanel.getChildren().add(nodeContent);
        
        contentPanel.setCache(true);
        contentPanel.setCacheHint(CacheHint.SPEED);
        
        if (nodeContent instanceof Pane)
        {
            Pane nodeContentPane = (Pane)nodeContent;
            nodeContentPane.setMinHeight(USE_COMPUTED_SIZE);
            nodeContentPane.setMinWidth(USE_COMPUTED_SIZE);
            nodeContentPane.setMaxWidth(USE_COMPUTED_SIZE);
            nodeContentPane.setMaxHeight(USE_COMPUTED_SIZE);
        }

        getChildren().addAll(barPanel, contentPanel);
    }
 
Example 9
Source File: ActionButton.java    From Cardshifter with Apache License 2.0 4 votes vote down vote up
private void setUpLabel(String label) {
	Label actionLabel = new Label();
	actionLabel.setText(label);
	actionLabel.relocate(this.sizeX/2.5, 0);
	this.getChildren().add(actionLabel);
}