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

The following examples show how to use javafx.scene.control.Label#setVisible() . 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: BaseAssetEditorDialog.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
/**
 * Validate the resource element.
 *
 * @param warningLabel the warning label
 * @param element      the element.
 */
@FxThread
protected void validate(@NotNull final Label warningLabel, @Nullable final T element) {

    final Function<@NotNull C, @Nullable String> validator = getValidator();
    if (validator == null) return;

    final C object = element == null ? null : getObject(element);
    final String message = object == null ? null : validator.apply(object);

    if (message == null) {
        warningLabel.setText(StringUtils.EMPTY);
        warningLabel.setVisible(false);
    } else {
        warningLabel.setText(message);
        warningLabel.setVisible(true);
    }
}
 
Example 3
Source File: BsqDashboardView.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void updateAveragePriceFields(TextField field90, TextFieldWithIcon field30, boolean isUSDField) {
    long average90 = updateAveragePriceField(field90, 90, isUSDField);
    long average30 = updateAveragePriceField(field30.getTextField(), 30, isUSDField);
    boolean trendUp = average30 > average90;
    boolean trendDown = average30 < average90;

    Label iconLabel = field30.getIconLabel();
    ObservableList<String> styleClass = iconLabel.getStyleClass();
    if (trendUp) {
        field30.setVisible(true);
        field30.setIcon(AwesomeIcon.CIRCLE_ARROW_UP);
        styleClass.remove("price-trend-down");
        styleClass.add("price-trend-up");
    } else if (trendDown) {
        field30.setVisible(true);
        field30.setIcon(AwesomeIcon.CIRCLE_ARROW_DOWN);
        styleClass.remove("price-trend-up");
        styleClass.add("price-trend-down");
    } else {
        iconLabel.setVisible(false);
    }
}
 
Example 4
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 5
Source File: TextFieldWithIcon.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public TextFieldWithIcon() {
    textField = new JFXTextField();
    textField.setEditable(false);
    textField.setMouseTransparent(true);
    textField.setFocusTraversable(false);
    setLeftAnchor(textField, 0d);
    setRightAnchor(textField, 0d);

    dummyTextField = new Label();
    dummyTextField.setWrapText(true);
    dummyTextField.setAlignment(Pos.CENTER_LEFT);
    dummyTextField.setTextAlignment(TextAlignment.LEFT);
    dummyTextField.setMouseTransparent(true);
    dummyTextField.setFocusTraversable(false);
    setLeftAnchor(dummyTextField, 0d);
    dummyTextField.setVisible(false);

    iconLabel = new Label();
    iconLabel.setLayoutX(0);
    iconLabel.setLayoutY(3);

    dummyTextField.widthProperty().addListener((observable, oldValue, newValue) -> {
        iconLabel.setLayoutX(dummyTextField.widthProperty().get() + 20);
    });

    getChildren().addAll(textField, dummyTextField, iconLabel);
}
 
Example 6
Source File: TakeOfferView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addSecondRow() {
    Tuple3<HBox, TextField, Label> priceAsPercentageTuple = getNonEditableValueBox();
    priceAsPercentageValueCurrencyBox = priceAsPercentageTuple.first;
    priceAsPercentageTextField = priceAsPercentageTuple.second;
    priceAsPercentageLabel = priceAsPercentageTuple.third;

    Tuple2<Label, VBox> priceAsPercentageInputBoxTuple = getTradeInputBox(priceAsPercentageValueCurrencyBox,
            Res.get("shared.distanceInPercent"));
    priceAsPercentageDescription = priceAsPercentageInputBoxTuple.first;

    getSmallIconForLabel(MaterialDesignIcon.CHART_LINE, priceAsPercentageDescription, "small-icon-label");

    priceAsPercentageInputBox = priceAsPercentageInputBoxTuple.second;

    priceAsPercentageLabel.setText("%");

    Tuple3<HBox, TextField, Label> amountValueCurrencyBoxTuple = getNonEditableValueBox();
    amountRangeTextField = amountValueCurrencyBoxTuple.second;

    minAmountValueCurrencyBox = amountValueCurrencyBoxTuple.first;
    Tuple2<Label, VBox> amountInputBoxTuple = getTradeInputBox(minAmountValueCurrencyBox,
            Res.get("takeOffer.amountPriceBox.amountRangeDescription"));

    amountRangeBox = amountInputBoxTuple.second;
    amountRangeBox.setVisible(false);

    fakeXLabel = new Label();
    fakeXIcon = getIconForLabel(MaterialDesignIcon.CLOSE, "2em", fakeXLabel);
    fakeXLabel.setVisible(false); // we just use it to get the same layout as the upper row
    fakeXLabel.getStyleClass().add("opaque-icon-character");

    HBox hBox = new HBox();
    hBox.setSpacing(5);
    hBox.setAlignment(Pos.CENTER_LEFT);
    hBox.getChildren().addAll(amountRangeBox, fakeXLabel, priceAsPercentageInputBox);

    GridPane.setRowIndex(hBox, ++gridRow);
    GridPane.setMargin(hBox, new Insets(0, 10, 10, 0));
    gridPane.getChildren().add(hBox);
}
 
Example 7
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 8
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 9
Source File: FileAssetEditorDialog.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected void validate(@NotNull final Label warningLabel, @Nullable final ResourceElement element) {
    super.validate(warningLabel, element);

    final Function<@NotNull Path, @Nullable String> validator = getValidator();
    final boolean visible = warningLabel.isVisible();

    if (!visible && element instanceof FolderResourceElement) {
        warningLabel.setText(Messages.ASSET_EDITOR_DIALOG_WARNING_SELECT_FILE);
        warningLabel.setVisible(true);
    } else if (validator == null) {
        warningLabel.setVisible(false);
    }
}
 
Example 10
Source File: BaseAssetEditorDialog.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected void createBeforeActions(@NotNull final HBox container) {
    super.createBeforeActions(container);

    warningLabel = new Label();
    warningLabel.setGraphic(new ImageView(Icons.WARNING_24));
    warningLabel.setVisible(false);

    FXUtils.addClassTo(warningLabel, CssClasses.DIALOG_LABEL_WARNING);
    FXUtils.addToPane(warningLabel, container);
}
 
Example 11
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 12
Source File: CustomPlainAmpSkin.java    From medusademo with Apache License 2.0 4 votes vote down vote up
private void initGraphics() {
    // Set initial size
    if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) {
        if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) {
            gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight());
        } else {
            gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    ticksAndSectionsCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ticksAndSections       = ticksAndSectionsCanvas.getGraphicsContext2D();

    ledCanvas = new Canvas();
    led       = ledCanvas.getGraphicsContext2D();

    thresholdTooltip = new Tooltip("Threshold\n(" + String.format(locale, formatString, gauge.getThreshold()) + ")");
    thresholdTooltip.setTextAlignment(TextAlignment.CENTER);

    threshold = new Path();
    Helper.enableNode(threshold, gauge.isThresholdVisible());
    Tooltip.install(threshold, thresholdTooltip);

    average = new Path();
    Helper.enableNode(average, gauge.isAverageVisible());

    markerPane = new Pane();

    needleRotate = new Rotate(180 - START_ANGLE);
    needleRotate.setAngle(needleRotate.getAngle() + (gauge.getValue() - oldValue - gauge.getMinValue()) * angleStep);

    needleMoveTo1       = new MoveTo();
    needleCubicCurveTo2 = new CubicCurveTo();
    needleCubicCurveTo3 = new CubicCurveTo();
    needleCubicCurveTo4 = new CubicCurveTo();
    needleLineTo5       = new LineTo();
    needleCubicCurveTo6 = new CubicCurveTo();
    needleClosePath7    = new ClosePath();
    needle              = new Path(needleMoveTo1, needleCubicCurveTo2, needleCubicCurveTo3, needleCubicCurveTo4, needleLineTo5, needleCubicCurveTo6, needleClosePath7);
    needle.setFillRule(FillRule.EVEN_ODD);
    needle.getTransforms().setAll(needleRotate);
    needle.getStyleClass().add("needle");

    dropShadow = new DropShadow();
    dropShadow.setColor(Color.rgb(0, 0, 0, 0.25));
    dropShadow.setBlurType(BlurType.TWO_PASS_BOX);
    dropShadow.setRadius(0.015 * PREFERRED_WIDTH);
    dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH);

    shadowGroup = new Group(needle);
    shadowGroup.setEffect(gauge.isShadowsEnabled() ? dropShadow : null);
    shadowGroup.getStyleClass().add("shadow-group");

    unitText = new Text(gauge.getUnit());
    unitText.setMouseTransparent(true);
    unitText.setTextOrigin(VPos.CENTER);
    unitText.getStyleClass().add("unit");

    lcd = new Rectangle(0.3 * PREFERRED_WIDTH, 0.1 * PREFERRED_HEIGHT);
    lcd.setArcWidth(0.0125 * PREFERRED_HEIGHT);
    lcd.setArcHeight(0.0125 * PREFERRED_HEIGHT);
    lcd.relocate((PREFERRED_WIDTH - lcd.getWidth()) * 0.5, 0.66 * PREFERRED_HEIGHT);
    lcd.getStyleClass().add("lcd");
    Helper.enableNode(lcd, gauge.isLcdVisible() && gauge.isValueVisible());

    lcdText = new Label(String.format(locale, "%." + gauge.getDecimals() + "f", gauge.getValue()));
    lcdText.setAlignment(Pos.CENTER_RIGHT);
    lcdText.setVisible(gauge.isValueVisible());
    lcdText.getStyleClass().add("lcd-foreground");

    // Set initial value
    angleStep          = ANGLE_RANGE / gauge.getRange();
    double targetAngle = 180 - START_ANGLE + (gauge.getValue() - gauge.getMinValue()) * angleStep;
    targetAngle        = clamp(180 - START_ANGLE, 180 - START_ANGLE + ANGLE_RANGE, targetAngle);
    needleRotate.setAngle(targetAngle);

    // Add all nodes
    pane = new Pane();
    pane.getChildren().setAll(ticksAndSectionsCanvas,
                              markerPane,
                              ledCanvas,
                              unitText,
                              lcd,
                              lcdText,
                              shadowGroup);
    pane.getStyleClass().add("background-pane");

    getChildren().setAll(pane);
}
 
Example 13
Source File: PlainAmpSkin.java    From Medusa with Apache License 2.0 4 votes vote down vote up
private void initGraphics() {
    // Set initial size
    if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) {
        if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) {
            gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight());
        } else {
            gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    ticksAndSectionsCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ticksAndSections       = ticksAndSectionsCanvas.getGraphicsContext2D();

    ledCanvas = new Canvas();
    led       = ledCanvas.getGraphicsContext2D();

    thresholdTooltip = new Tooltip("Threshold\n(" + String.format(locale, formatString, gauge.getThreshold()) + ")");
    thresholdTooltip.setTextAlignment(TextAlignment.CENTER);

    threshold = new Path();
    Helper.enableNode(threshold, gauge.isThresholdVisible());
    Tooltip.install(threshold, thresholdTooltip);

    average = new Path();
    Helper.enableNode(average, gauge.isAverageVisible());

    markerPane = new Pane();

    needleRotate = new Rotate(180 - START_ANGLE);
    needleRotate.setAngle(needleRotate.getAngle() + (gauge.getValue() - oldValue - gauge.getMinValue()) * angleStep);

    needleMoveTo1       = new MoveTo();
    needleCubicCurveTo2 = new CubicCurveTo();
    needleCubicCurveTo3 = new CubicCurveTo();
    needleCubicCurveTo4 = new CubicCurveTo();
    needleLineTo5       = new LineTo();
    needleCubicCurveTo6 = new CubicCurveTo();
    needleClosePath7    = new ClosePath();
    needle              = new Path(needleMoveTo1, needleCubicCurveTo2, needleCubicCurveTo3, needleCubicCurveTo4, needleLineTo5, needleCubicCurveTo6, needleClosePath7);
    needle.setFillRule(FillRule.EVEN_ODD);
    needle.getTransforms().setAll(needleRotate);

    dropShadow = new DropShadow();
    dropShadow.setColor(Color.rgb(0, 0, 0, 0.25));
    dropShadow.setBlurType(BlurType.TWO_PASS_BOX);
    dropShadow.setRadius(0.015 * PREFERRED_WIDTH);
    dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH);

    shadowGroup = new Group(needle);
    shadowGroup.setEffect(gauge.isShadowsEnabled() ? dropShadow : null);

    unitText = new Text(gauge.getUnit());
    unitText.setMouseTransparent(true);
    unitText.setTextOrigin(VPos.CENTER);

    lcd = new Rectangle(0.3 * PREFERRED_WIDTH, 0.1 * PREFERRED_HEIGHT);
    lcd.setArcWidth(0.0125 * PREFERRED_HEIGHT);
    lcd.setArcHeight(0.0125 * PREFERRED_HEIGHT);
    lcd.relocate((PREFERRED_WIDTH - lcd.getWidth()) * 0.5, 0.66 * PREFERRED_HEIGHT);
    Helper.enableNode(lcd, gauge.isLcdVisible() && gauge.isValueVisible());

    lcdText = new Label(String.format(locale, "%." + gauge.getDecimals() + "f", gauge.getValue()));
    lcdText.setAlignment(Pos.CENTER_RIGHT);
    lcdText.setVisible(gauge.isValueVisible());

    // Set initial value
    angleStep          = ANGLE_RANGE / gauge.getRange();
    double targetAngle = 180 - START_ANGLE + (gauge.getValue() - gauge.getMinValue()) * angleStep;
    targetAngle        = clamp(180 - START_ANGLE, 180 - START_ANGLE + ANGLE_RANGE, targetAngle);
    needleRotate.setAngle(targetAngle);

    // Add all nodes
    pane = new Pane();
    pane.getChildren().setAll(ticksAndSectionsCanvas,
                              markerPane,
                              ledCanvas,
                              unitText,
                              lcd,
                              lcdText,
                              shadowGroup);

    getChildren().setAll(pane);
}
 
Example 14
Source File: AmpSkin.java    From Medusa with Apache License 2.0 4 votes vote down vote up
private void initGraphics() {
    // Set initial size
    if (Double.compare(gauge.getPrefWidth(), 0.0) <= 0 || Double.compare(gauge.getPrefHeight(), 0.0) <= 0 ||
        Double.compare(gauge.getWidth(), 0.0) <= 0 || Double.compare(gauge.getHeight(), 0.0) <= 0) {
        if (gauge.getPrefWidth() > 0 && gauge.getPrefHeight() > 0) {
            gauge.setPrefSize(gauge.getPrefWidth(), gauge.getPrefHeight());
        } else {
            gauge.setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    ticksAndSectionsCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    ticksAndSections       = ticksAndSectionsCanvas.getGraphicsContext2D();

    ledCanvas = new Canvas();
    led       = ledCanvas.getGraphicsContext2D();

    thresholdTooltip = new Tooltip("Threshold\n(" + String.format(locale, formatString, gauge.getThreshold()) + ")");
    thresholdTooltip.setTextAlignment(TextAlignment.CENTER);

    threshold = new Path();
    Helper.enableNode(threshold, gauge.isThresholdVisible());
    Tooltip.install(threshold, thresholdTooltip);

    average = new Path();
    Helper.enableNode(average, gauge.isAverageVisible());

    markerPane = new Pane();

    needleRotate = new Rotate(180 - START_ANGLE);
    needleRotate.setAngle(needleRotate.getAngle() + (gauge.getValue() - oldValue - gauge.getMinValue()) * angleStep);

    needleMoveTo1       = new MoveTo();
    needleCubicCurveTo2 = new CubicCurveTo();
    needleCubicCurveTo3 = new CubicCurveTo();
    needleCubicCurveTo4 = new CubicCurveTo();
    needleLineTo5       = new LineTo();
    needleCubicCurveTo6 = new CubicCurveTo();
    needleClosePath7    = new ClosePath();
    needle              = new Path(needleMoveTo1, needleCubicCurveTo2, needleCubicCurveTo3, needleCubicCurveTo4, needleLineTo5, needleCubicCurveTo6, needleClosePath7);
    needle.setFillRule(FillRule.EVEN_ODD);
    needle.getTransforms().setAll(needleRotate);

    dropShadow = new DropShadow();
    dropShadow.setColor(Color.rgb(0, 0, 0, 0.25));
    dropShadow.setBlurType(BlurType.TWO_PASS_BOX);
    dropShadow.setRadius(0.015 * PREFERRED_WIDTH);
    dropShadow.setOffsetY(0.015 * PREFERRED_WIDTH);

    shadowGroup = new Group(needle);
    shadowGroup.setEffect(gauge.isShadowsEnabled() ? dropShadow : null);

    titleText = new Text(gauge.getTitle());
    titleText.setTextOrigin(VPos.CENTER);
    titleText.setFill(gauge.getTitleColor());
    Helper.enableNode(titleText, !gauge.getTitle().isEmpty());

    unitText = new Text(gauge.getUnit());
    unitText.setMouseTransparent(true);
    unitText.setTextOrigin(VPos.CENTER);

    lcd = new Rectangle(0.3 * PREFERRED_WIDTH, 0.1 * PREFERRED_HEIGHT);
    lcd.setArcWidth(0.0125 * PREFERRED_HEIGHT);
    lcd.setArcHeight(0.0125 * PREFERRED_HEIGHT);
    lcd.relocate((PREFERRED_WIDTH - lcd.getWidth()) * 0.5, 0.44 * PREFERRED_HEIGHT);
    Helper.enableNode(lcd, gauge.isLcdVisible() && gauge.isValueVisible());

    lcdText = new Label(String.format(locale, "%." + gauge.getDecimals() + "f", gauge.getValue()));
    lcdText.setAlignment(Pos.CENTER_RIGHT);
    lcdText.setVisible(gauge.isValueVisible());

    // Set initial value
    angleStep          = ANGLE_RANGE / gauge.getRange();
    double targetAngle = 180 - START_ANGLE + (gauge.getValue() - gauge.getMinValue()) * angleStep;
    targetAngle        = clamp(180 - START_ANGLE, 180 - START_ANGLE + ANGLE_RANGE, targetAngle);
    needleRotate.setAngle(targetAngle);

    lightEffect = new InnerShadow(BlurType.TWO_PASS_BOX, Color.rgb(255, 255, 255, 0.65), 2, 0.0, 0.0, 2.0);

    foreground = new SVGPath();
    foreground.setContent("M 26 26.5 C 26 20.2432 26.2432 20 32.5 20 L 277.5 20 C 283.7568 20 284 20.2432 284 26.5 L 284 143.5 C 284 149.7568 283.7568 150 277.5 150 L 32.5 150 C 26.2432 150 26 149.7568 26 143.5 L 26 26.5 ZM 0 6.7241 L 0 253.2758 C 0 260 0 260 6.75 260 L 303.25 260 C 310 260 310 260 310 253.2758 L 310 6.7241 C 310 0 310 0 303.25 0 L 6.75 0 C 0 0 0 0 0 6.7241 Z");
    foreground.setEffect(lightEffect);

    // Add all nodes
    pane = new Pane();
    pane.getChildren().setAll(ticksAndSectionsCanvas,
                              markerPane,
                              ledCanvas,
                              unitText,
                              lcd,
                              lcdText,
                              shadowGroup,
                              foreground,
                              titleText);

    getChildren().setAll(pane);
}
 
Example 15
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 16
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 17
Source File: MutableOfferView.java    From bisq with GNU Affero General Public License v3.0 4 votes vote down vote up
private void addSecondRow() {
    // price as fiat
    Tuple3<HBox, InputTextField, Label> priceValueCurrencyBoxTuple = getEditableValueBox(
            Res.get("createOffer.price.prompt"));
    priceValueCurrencyBox = priceValueCurrencyBoxTuple.first;
    fixedPriceTextField = priceValueCurrencyBoxTuple.second;
    editOfferElements.add(fixedPriceTextField);
    priceCurrencyLabel = priceValueCurrencyBoxTuple.third;
    editOfferElements.add(priceCurrencyLabel);
    Tuple2<Label, VBox> priceInputBoxTuple = getTradeInputBox(priceValueCurrencyBox, "");
    priceDescriptionLabel = priceInputBoxTuple.first;

    getSmallIconForLabel(MaterialDesignIcon.LOCK, priceDescriptionLabel, "small-icon-label");

    editOfferElements.add(priceDescriptionLabel);
    fixedPriceBox = priceInputBoxTuple.second;

    marketBasedPriceTextField.setPromptText(Res.get("shared.enterPercentageValue"));
    marketBasedPriceLabel.setText("%");

    Tuple3<HBox, InputTextField, Label> amountValueCurrencyBoxTuple = getEditableValueBox(Res.get("createOffer.amount.prompt"));
    minAmountValueCurrencyBox = amountValueCurrencyBoxTuple.first;
    minAmountTextField = amountValueCurrencyBoxTuple.second;
    editOfferElements.add(minAmountTextField);
    minAmountBtcLabel = amountValueCurrencyBoxTuple.third;
    editOfferElements.add(minAmountBtcLabel);

    Tuple2<Label, VBox> amountInputBoxTuple = getTradeInputBox(minAmountValueCurrencyBox, Res.get("createOffer.amountPriceBox.minAmountDescription"));


    fakeXLabel = new Label();
    fakeXIcon = getIconForLabel(MaterialDesignIcon.CLOSE, "2em", fakeXLabel);
    fakeXLabel.getStyleClass().add("opaque-icon-character");
    fakeXLabel.setVisible(false); // we just use it to get the same layout as the upper row

    // Fixed/Percentage toggle
    priceTypeToggleButton = getIconButton(MaterialDesignIcon.SWAP_VERTICAL);
    editOfferElements.add(priceTypeToggleButton);
    HBox.setMargin(priceTypeToggleButton, new Insets(16, 0, 0, 0));

    priceTypeToggleButton.setOnAction((actionEvent) ->
            updatePriceToggleButtons(model.getDataModel().getUseMarketBasedPrice().getValue()));

    secondRowHBox = new HBox();

    secondRowHBox.setSpacing(5);
    secondRowHBox.setAlignment(Pos.CENTER_LEFT);
    secondRowHBox.getChildren().addAll(amountInputBoxTuple.second, fakeXLabel, fixedPriceBox, priceTypeToggleButton);
    GridPane.setRowIndex(secondRowHBox, ++gridRow);
    GridPane.setColumnIndex(secondRowHBox, 0);
    GridPane.setMargin(secondRowHBox, new Insets(0, 10, 10, 0));
    gridPane.getChildren().add(secondRowHBox);
}
 
Example 18
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 19
Source File: WorkbenchTest.java    From WorkbenchFX with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {
  MockitoAnnotations.initMocks(this);

  robot = new FxRobot();

  for (int i = 0; i < moduleNodes.length; i++) {
    moduleNodes[i] = new Label("Module Content");
  }

  for (int i = 0; i < mockModules.length; i++) {
    mockModules[i] = createMockModule(
        moduleNodes[i], null, true, "Module " + i, workbench,
        FXCollections.observableArrayList(), FXCollections.observableArrayList()
    );
  }

  FontAwesomeIconView fontAwesomeIconView = new FontAwesomeIconView(FontAwesomeIcon.QUESTION);
  fontAwesomeIconView.getStyleClass().add("icon");
  menuItem = new MenuItem("Item 1.1", fontAwesomeIconView);

  // Initialization of items for ToolbarItem testing
  toolbarItemText = "ToolbarItem Text";
  toolbarItemIconView = new FontAwesomeIconView(FontAwesomeIcon.QUESTION);
  toolbarItemMenuItem = new MenuItem("Menu Item");

  toolbarItemLeft = new ToolbarItem(toolbarItemText, toolbarItemIconView, toolbarItemMenuItem);
  toolbarItemRight = new ToolbarItem(toolbarItemText, toolbarItemIconView, toolbarItemMenuItem);

  // Setup WorkbenchDialog Mock
  blocking = new SimpleBooleanProperty();
  when(mockDialog.getButtonTypes()).thenReturn(buttonTypes);
  when(mockDialog.getOnResult()).thenReturn(mockOnResult);
  when(mockDialog.blockingProperty()).thenReturn(blocking);

  navigationDrawer = new MockNavigationDrawer();
  dialogControl = new MockDialogControl();
  when(mockDialog.getDialogControl()).thenReturn(dialogControl);
  dialogControl.setDialog(mockDialog);

  workbench = Workbench.builder(
      mockModules[FIRST_INDEX],
      mockModules[SECOND_INDEX],
      mockModules[LAST_INDEX])
      .tabFactory(MockTab::new)
      .tileFactory(MockTile::new)
      .pageFactory(MockPage::new)
      .navigationDrawer(navigationDrawer)
      .navigationDrawerItems(menuItem)
      .toolbarLeft(toolbarItemLeft)
      .toolbarRight(toolbarItemRight)
      .build();

  first = mockModules[FIRST_INDEX];
  when(first.getWorkbench()).thenReturn(workbench);
  second = mockModules[SECOND_INDEX];
  when(second.getWorkbench()).thenReturn(workbench);
  last = mockModules[LAST_INDEX];
  when(last.getWorkbench()).thenReturn(workbench);

  overlays = workbench.getOverlays();
  blockingOverlaysShown = workbench.getBlockingOverlaysShown();
  overlaysShown = workbench.getNonBlockingOverlaysShown();
  overlay1 = new Label();
  overlay1.setVisible(false);
  overlay2 = new Label();
  overlay2.setVisible(false);
  overlay3 = new Label();
  overlay3.setVisible(false);

  navigationDrawerItems = workbench.getNavigationDrawerItems();

  Scene scene = new Scene(workbench, 100, 100);
  stage.setScene(scene);
  stage.show();
}