Search in sources :

Example 6 with CornerRadii

use of javafx.scene.layout.CornerRadii in project tilesfx by HanSolo.

the class CalendarTileSkin method drawCells.

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);
        }
    }
}
Also used : Locale(java.util.Locale) EventHandler(javafx.event.EventHandler) Pos(javafx.geometry.Pos) Fonts(eu.hansolo.tilesfx.fonts.Fonts) MouseEvent(javafx.scene.input.MouseEvent) ZonedDateTime(java.time.ZonedDateTime) EventType(eu.hansolo.tilesfx.events.TileEvent.EventType) ArrayList(java.util.ArrayList) ChartData(eu.hansolo.tilesfx.chart.ChartData) Insets(javafx.geometry.Insets) Helper(eu.hansolo.tilesfx.tools.Helper) BorderWidths(javafx.scene.layout.BorderWidths) BackgroundFill(javafx.scene.layout.BackgroundFill) Locale(java.util.Locale) Tile(eu.hansolo.tilesfx.Tile) Color(javafx.scene.paint.Color) Label(javafx.scene.control.Label) TextStyle(java.time.format.TextStyle) Border(javafx.scene.layout.Border) Font(javafx.scene.text.Font) Background(javafx.scene.layout.Background) DAY_OF_MONTH(java.time.temporal.ChronoField.DAY_OF_MONTH) BorderStrokeStyle(javafx.scene.layout.BorderStrokeStyle) BorderStroke(javafx.scene.layout.BorderStroke) Text(javafx.scene.text.Text) List(java.util.List) TileEvent(eu.hansolo.tilesfx.events.TileEvent) IsoFields(java.time.temporal.IsoFields) DayOfWeek(java.time.DayOfWeek) LocalDate(java.time.LocalDate) DateTimeFormatter(java.time.format.DateTimeFormatter) Optional(java.util.Optional) CornerRadii(javafx.scene.layout.CornerRadii) ChartData(eu.hansolo.tilesfx.chart.ChartData) Insets(javafx.geometry.Insets) Background(javafx.scene.layout.Background) Color(javafx.scene.paint.Color) BackgroundFill(javafx.scene.layout.BackgroundFill) Label(javafx.scene.control.Label) LocalDate(java.time.LocalDate) Font(javafx.scene.text.Font) ZonedDateTime(java.time.ZonedDateTime) BorderStroke(javafx.scene.layout.BorderStroke) CornerRadii(javafx.scene.layout.CornerRadii) Border(javafx.scene.layout.Border)

Example 7 with CornerRadii

use of javafx.scene.layout.CornerRadii in project tilesfx by HanSolo.

the class RadarChart method initGraphics.

private void initGraphics() {
    stops = new ArrayList<>(16);
    for (Stop stop : getGradientStops()) {
        if (Double.compare(stop.getOffset(), 0.0) == 0)
            stops.add(new Stop(0, stop.getColor()));
        stops.add(new Stop(stop.getOffset() * 0.69924 + 0.285, stop.getColor()));
    }
    chartCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    chartCtx = chartCanvas.getGraphicsContext2D();
    overlayCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
    overlayCtx = overlayCanvas.getGraphicsContext2D();
    unitText = new Text(getUnit());
    unitText.setTextAlignment(TextAlignment.CENTER);
    unitText.setTextOrigin(VPos.CENTER);
    unitText.setFont(Fonts.latoLight(0.045 * PREFERRED_WIDTH));
    legendStep = (getMaxValue() - getMinValue()) / 5d;
    dropShadow = new DropShadow(BlurType.TWO_PASS_BOX, Color.BLACK, 5, 0, 0, 0);
    minValueText = new Text(String.format(Locale.US, formatString, getMinValue()));
    minValueText.setTextAlignment(TextAlignment.CENTER);
    minValueText.setTextOrigin(VPos.CENTER);
    minValueText.setVisible(isLegendVisible());
    minValueText.setEffect(dropShadow);
    legend1Text = new Text(String.format(Locale.US, formatString, getMinValue() + legendStep));
    legend1Text.setTextAlignment(TextAlignment.CENTER);
    legend1Text.setTextOrigin(VPos.CENTER);
    legend1Text.setVisible(isLegendVisible());
    legend1Text.setEffect(dropShadow);
    legend2Text = new Text(String.format(Locale.US, formatString, getMinValue() + legendStep * 2));
    legend2Text.setTextAlignment(TextAlignment.CENTER);
    legend2Text.setTextOrigin(VPos.CENTER);
    legend2Text.setVisible(isLegendVisible());
    legend2Text.setEffect(dropShadow);
    legend3Text = new Text(String.format(Locale.US, formatString, getMinValue() + legendStep * 3));
    legend3Text.setTextAlignment(TextAlignment.CENTER);
    legend3Text.setTextOrigin(VPos.CENTER);
    legend3Text.setVisible(isLegendVisible());
    legend3Text.setEffect(dropShadow);
    legend4Text = new Text(String.format(Locale.US, formatString, getMinValue() + legendStep * 3));
    legend4Text.setTextAlignment(TextAlignment.CENTER);
    legend4Text.setTextOrigin(VPos.CENTER);
    legend4Text.setVisible(isLegendVisible());
    legend4Text.setEffect(dropShadow);
    maxValueText = new Text(String.format(Locale.US, formatString, getMaxValue()));
    maxValueText.setTextAlignment(TextAlignment.CENTER);
    maxValueText.setTextOrigin(VPos.CENTER);
    maxValueText.setVisible(isLegendVisible());
    maxValueText.setEffect(dropShadow);
    // Add all nodes
    pane = new Pane(chartCanvas, overlayCanvas, unitText, minValueText, legend1Text, legend2Text, legend3Text, legend4Text, maxValueText);
    pane.setBackground(new Background(new BackgroundFill(getChartBackgroundColor(), new CornerRadii(1024), Insets.EMPTY)));
    getChildren().setAll(pane);
}
Also used : Background(javafx.scene.layout.Background) Stop(javafx.scene.paint.Stop) Canvas(javafx.scene.canvas.Canvas) BackgroundFill(javafx.scene.layout.BackgroundFill) Text(javafx.scene.text.Text) CornerRadii(javafx.scene.layout.CornerRadii) Pane(javafx.scene.layout.Pane) DropShadow(javafx.scene.effect.DropShadow)

Example 8 with CornerRadii

use of javafx.scene.layout.CornerRadii in project tilesfx by HanSolo.

the class PlusMinusTileSkin method decrement.

private void decrement() {
    minusLabel.setTextFill(tile.getActiveColor());
    minusLabel.setBorder(new Border(new BorderStroke(tile.getActiveColor(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(size * 0.01))));
    double newValue = clamp(minValue, maxValue, tile.getValue() - tile.getIncrement());
    tile.setValue(newValue);
}
Also used : BorderWidths(javafx.scene.layout.BorderWidths) BorderStroke(javafx.scene.layout.BorderStroke) CornerRadii(javafx.scene.layout.CornerRadii) Border(javafx.scene.layout.Border)

Example 9 with CornerRadii

use of javafx.scene.layout.CornerRadii in project tilesfx by HanSolo.

the class PlusMinusTileSkin method resize.

@Override
protected void resize() {
    super.resize();
    description.setPrefSize(width - size * 0.1, size * 0.43);
    description.relocate(size * 0.05, titleText.isVisible() ? height * 0.42 : height * 0.32);
    double buttonSize = size * 0.18;
    minusLabel.setFont(Fonts.latoBold(size * 0.2));
    minusLabel.setPrefSize(buttonSize, buttonSize);
    minusLabel.setMinSize(buttonSize, buttonSize);
    minusLabel.setMaxSize(buttonSize, buttonSize);
    // minusLabel.setPadding(new Insets(-0.055 * size, 0, 0, 0));
    minusLabel.setPadding(new Insets(-0.0625 * size, 0, 0, 0));
    minusLabel.setBorder(new Border(new BorderStroke(tile.getForegroundColor(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(size * 0.01))));
    minusLabel.relocate(size * 0.05, height - size * 0.20 - buttonSize);
    plusLabel.setFont(Fonts.latoBold(size * 0.2));
    plusLabel.setPrefSize(buttonSize, buttonSize);
    plusLabel.setMinSize(buttonSize, buttonSize);
    plusLabel.setMaxSize(buttonSize, buttonSize);
    plusLabel.setPadding(new Insets(-0.05 * size, 0, 0, 0));
    plusLabel.setBorder(new Border(new BorderStroke(tile.getForegroundColor(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(size * 0.01))));
    plusLabel.relocate(width - size * 0.05 - buttonSize, height - size * 0.20 - buttonSize);
    valueUnitFlow.setPrefWidth(contentBounds.getWidth());
    valueUnitFlow.relocate(contentBounds.getX(), contentBounds.getY());
}
Also used : Insets(javafx.geometry.Insets) BorderWidths(javafx.scene.layout.BorderWidths) BorderStroke(javafx.scene.layout.BorderStroke) CornerRadii(javafx.scene.layout.CornerRadii) Border(javafx.scene.layout.Border)

Example 10 with CornerRadii

use of javafx.scene.layout.CornerRadii in project JFoenix by jfoenixadmin.

the class JFXSliderSkin method initListeners.

private void initListeners() {
    // delegate slider mouse events to track node 
    getSkinnable().setOnMousePressed(me -> {
        if (!me.isConsumed()) {
            me.consume();
            track.fireEvent(me);
        }
    });
    getSkinnable().setOnMouseReleased(me -> {
        if (!me.isConsumed()) {
            me.consume();
            track.fireEvent(me);
        }
    });
    getSkinnable().setOnMouseDragged(me -> {
        if (!me.isConsumed()) {
            me.consume();
            track.fireEvent(me);
        }
    });
    // animate value node
    track.addEventHandler(MouseEvent.MOUSE_PRESSED, (event) -> {
        timeline.setRate(1);
        timeline.play();
    });
    track.addEventHandler(MouseEvent.MOUSE_RELEASED, (event) -> {
        timeline.setRate(-1);
        timeline.play();
    });
    thumb.addEventHandler(MouseEvent.MOUSE_PRESSED, (event) -> {
        timeline.setRate(1);
        timeline.play();
    });
    thumb.addEventHandler(MouseEvent.MOUSE_RELEASED, (event) -> {
        timeline.setRate(-1);
        timeline.play();
    });
    track.backgroundProperty().addListener((o, oldVal, newVal) -> {
        // prevent internal color change
        if (!internalChange && newVal != null)
            trackColor = newVal.getFills().get(0).getFill();
    });
    thumb.backgroundProperty().addListener((o, oldVal, newVal) -> {
        // prevent internal color change
        if (!internalChange && newVal != null) {
            thumbColor = newVal.getFills().get(0).getFill();
            if (getSkinnable().getValue() == getSkinnable().getMin()) {
                internalChange = true;
                thumb.setBackground(new Background(new BackgroundFill(trackColor, new CornerRadii(20), Insets.EMPTY)));
                internalChange = false;
            }
        }
    });
    refreshSliderValueBinding();
    getSkinnable().valueProperty().addListener((o, oldVal, newVal) -> {
        internalChange = true;
        if (getSkinnable().getMin() == newVal.doubleValue()) {
            thumb.setBackground(new Background(new BackgroundFill(trackColor, new CornerRadii(20), Insets.EMPTY)));
            animatedThumb.pseudoClassStateChanged(PseudoClass.getPseudoClass("min"), true);
        } else if (oldVal.doubleValue() == getSkinnable().getMin()) {
            thumb.setBackground(new Background(new BackgroundFill(thumbColor, new CornerRadii(20), Insets.EMPTY)));
            animatedThumb.pseudoClassStateChanged(PseudoClass.getPseudoClass("min"), false);
        }
        internalChange = false;
    });
    getSkinnable().orientationProperty().addListener((o, oldVal, newVal) -> initAnimation(newVal));
    animatedThumb.layoutBoundsProperty().addListener((o, oldVal, newVal) -> initAnimation(getSkinnable().getOrientation()));
}
Also used : Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) CornerRadii(javafx.scene.layout.CornerRadii)

Aggregations

CornerRadii (javafx.scene.layout.CornerRadii)20 Background (javafx.scene.layout.Background)15 BackgroundFill (javafx.scene.layout.BackgroundFill)15 Border (javafx.scene.layout.Border)8 BorderStroke (javafx.scene.layout.BorderStroke)8 BorderWidths (javafx.scene.layout.BorderWidths)8 Text (javafx.scene.text.Text)5 Insets (javafx.geometry.Insets)4 Label (javafx.scene.control.Label)4 DropShadow (javafx.scene.effect.DropShadow)3 Pane (javafx.scene.layout.Pane)3 Color (javafx.scene.paint.Color)2 Rectangle (javafx.scene.shape.Rectangle)2 TextFlow (javafx.scene.text.TextFlow)2 BlackCard (com.gianlu.pyxreborn.Models.BlackCard)1 ConicalGradient (eu.hansolo.medusa.tools.ConicalGradient)1 Tile (eu.hansolo.tilesfx.Tile)1 ChartData (eu.hansolo.tilesfx.chart.ChartData)1 TileEvent (eu.hansolo.tilesfx.events.TileEvent)1 EventType (eu.hansolo.tilesfx.events.TileEvent.EventType)1