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

The following examples show how to use javafx.scene.control.Label#setManaged() . 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: Overlay.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
protected void addHeadLine() {
    if (headLine != null) {
        ++rowIndex;

        HBox hBox = new HBox();
        hBox.setSpacing(7);
        headLineLabel = new AutoTooltipLabel(headLine);
        headlineIcon = new Label();
        headlineIcon.setManaged(false);
        headlineIcon.setVisible(false);
        headlineIcon.setPadding(new Insets(3));
        headLineLabel.setMouseTransparent(true);

        if (headlineStyle != null)
            headLineLabel.setStyle(headlineStyle);

        hBox.getChildren().addAll(headlineIcon, headLineLabel);

        GridPane.setHalignment(hBox, HPos.LEFT);
        GridPane.setRowIndex(hBox, rowIndex);
        GridPane.setColumnSpan(hBox, 2);
        gridPane.getChildren().addAll(hBox);
    }
}
 
Example 2
Source File: CalendarTileSkin.java    From OEE-Designer with MIT License 5 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

    final ZonedDateTime TIME = tile.getTime();

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

    clickHandler = e -> checkClick(e);

    labels = new ArrayList<>(56);
    for (int i = 0 ; i < 56 ; i++) {
        Label label = new Label();
        label.setManaged(false);
        label.setVisible(false);
        label.setAlignment(Pos.CENTER);
        label.addEventHandler(MouseEvent.MOUSE_PRESSED, clickHandler);
        labels.add(label);
    }

    weekBorder = new Border(new BorderStroke(Color.TRANSPARENT,
                                             Tile.GRAY,
                                             Color.TRANSPARENT,
                                             Color.TRANSPARENT,
                                             BorderStrokeStyle.NONE,
                                             BorderStrokeStyle.SOLID,
                                             BorderStrokeStyle.NONE,
                                             BorderStrokeStyle.NONE,
                                             CornerRadii.EMPTY, BorderWidths.DEFAULT,
                                             Insets.EMPTY));

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

    getPane().getChildren().addAll(titleText, text);
    getPane().getChildren().addAll(labels);
}
 
Example 3
Source File: TextUpdateRepresentation.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Control createJFXNode() throws Exception
{   // Start out 'disconnected' until first value arrives
    value_text = computeText(null);

    if (model_widget.propInteractive().getValue()  &&  !toolkit.isEditMode())
    {
        final TextArea area = new TextArea();
        area.setMinSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
        area.setEditable(false);
        area.getStyleClass().add("text_entry");
        area.setWrapText(true);
        // 'Interactive' widget needs to react to selection,
        // and as remarked in TextEntry this works best 'managed'
        area.setManaged(true);
        return area;
    }
    else
    {
        final Label label = new Label();
        label.getStyleClass().add("text_update");

        // This code manages layout,
        // because otherwise for example border changes would trigger
        // expensive Node.notifyParentOfBoundsChange() recursing up the scene graph
        label.setManaged(false);

        return label;
    }
}
 
Example 4
Source File: CalendarTileSkin.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

    final ZonedDateTime TIME = tile.getTime();

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

    clickHandler = e -> checkClick(e);

    labels = new ArrayList<>(56);
    for (int i = 0 ; i < 56 ; i++) {
        Label label = new Label();
        label.setManaged(false);
        label.setVisible(false);
        label.setAlignment(Pos.CENTER);
        label.addEventHandler(MouseEvent.MOUSE_PRESSED, clickHandler);
        labels.add(label);
    }

    weekBorder = new Border(new BorderStroke(Color.TRANSPARENT,
                                             Tile.GRAY,
                                             Color.TRANSPARENT,
                                             Color.TRANSPARENT,
                                             BorderStrokeStyle.NONE,
                                             BorderStrokeStyle.SOLID,
                                             BorderStrokeStyle.NONE,
                                             BorderStrokeStyle.NONE,
                                             CornerRadii.EMPTY, BorderWidths.DEFAULT,
                                             Insets.EMPTY));

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

    getPane().getChildren().addAll(titleText, text);
    getPane().getChildren().addAll(labels);
}
 
Example 5
Source File: MosaicPaneRefImpl.java    From Mosaic with Apache License 2.0 5 votes vote down vote up
public Label getLabel(String color, String id) {
	Label label = new Label();
	label.textProperty().set(id);
	label.textAlignmentProperty().set(TextAlignment.CENTER);
	label.alignmentProperty().set(Pos.CENTER);
	label.setOpacity(1.0);
	label.setTextFill(Color.WHITE);
	label.setFont(Font.font("Arial", FontWeight.BOLD, 16d));
	label.setStyle("-fx-background-color: " + color.toString() + 
		";-fx-alignment:center;-fx-text-alignment:center;");
	label.setManaged(false);
	
	return label;
}
 
Example 6
Source File: NewTradeProtocolLaunchWindow.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void addHeadLine() {

    Label versionNumber = new AutoTooltipLabel(BisqAppMain.DEFAULT_APP_NAME + " v1.2");
    versionNumber.getStyleClass().add("news-version");
    HBox.setHgrow(versionNumber, Priority.ALWAYS);
    versionNumber.setMaxWidth(Double.MAX_VALUE);

    Button closeButton = FormBuilder.getIconButton(MaterialDesignIcon.CLOSE,
            "close-icon", "1.231em");
    closeButton.setOnAction(event -> hide());
    HBox.setHgrow(closeButton, Priority.NEVER);

    HBox header = new HBox(versionNumber, closeButton);

    GridPane.setRowIndex(header, ++rowIndex);
    GridPane.setColumnSpan(header, 2);
    gridPane.getChildren().add(header);

    headLineLabel = addLabel(gridPane, ++rowIndex, headLine);
    headLineLabel.getStyleClass().add("popup-headline-information");
    headlineIcon = new Label();
    headlineIcon.getStyleClass().add("popup-icon-information");
    headlineIcon.setManaged(true);
    headlineIcon.setVisible(true);
    FormBuilder.getIconForLabel(AwesomeIcon.INFO_SIGN, headlineIcon, "1em");

    headLineLabel.setGraphic(headlineIcon);
    GridPane.setHalignment(headLineLabel, HPos.LEFT);
    GridPane.setColumnSpan(headLineLabel, 2);
}
 
Example 7
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 8
Source File: HeatTabController.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
private void createStateLabels() {
    Group overlay = map.getOverlayGroup();
    for(String state: Region.ALL_STATES) {
        Node stateNode = map.lookup("#"+state);
        if (stateNode != null) {
            Label label = new Label("+10");
            label.getStyleClass().add("heatmap-label");
            label.setTextAlignment(TextAlignment.CENTER);
            label.setAlignment(Pos.CENTER);
            label.setManaged(false);
            label.setOpacity(0);
            label.setVisible(false);
            Bounds stateBounds = stateNode.getBoundsInParent();
            if ("DE".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()-25, stateBounds.getMinY(), 
                        stateBounds.getWidth()+50, stateBounds.getHeight());
            } else if ("VT".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()-25, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("NH".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()+30, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("MA".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()-20, stateBounds.getMinY()-18, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("RI".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY(), 
                        stateBounds.getWidth()+40, stateBounds.getHeight());
            } else if ("ID".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()+60, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("MI".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()+60, stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("FL".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()+95, stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("LA".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()-50, stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            }
            stateLabelMap.put(state, label);
            overlay.getChildren().add(label);
        }
    }
}
 
Example 9
Source File: HeatTabController.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
private void createStateLabels() {
    Group overlay = map.getOverlayGroup();
    for(String state: Region.ALL_STATES) {
        Node stateNode = map.lookup("#"+state);
        if (stateNode != null) {
            Label label = new Label("+10");
            label.getStyleClass().add("heatmap-label");
            label.setTextAlignment(TextAlignment.CENTER);
            label.setAlignment(Pos.CENTER);
            label.setManaged(false);
            label.setOpacity(0);
            label.setVisible(false);
            Bounds stateBounds = stateNode.getBoundsInParent();
            if ("DE".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()-25, stateBounds.getMinY(), 
                        stateBounds.getWidth()+50, stateBounds.getHeight());
            } else if ("VT".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()-25, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("NH".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()+30, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("MA".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()-20, stateBounds.getMinY()-18, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("RI".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY(), 
                        stateBounds.getWidth()+40, stateBounds.getHeight());
            } else if ("ID".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY()+60, 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("MI".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()+60, stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("FL".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()+95, stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else if ("LA".equals(state)) {
                label.resizeRelocate(stateBounds.getMinX()-50, stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            } else {
                label.resizeRelocate(stateBounds.getMinX(), stateBounds.getMinY(), 
                        stateBounds.getWidth(), stateBounds.getHeight());
            }
            stateLabelMap.put(state, label);
            overlay.getChildren().add(label);
        }
    }
}
 
Example 10
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);
        }
    }
}