Search in sources :

Example 1 with Circle

use of javafx.scene.shape.Circle in project JFoenix by jfoenixadmin.

the class JFXRippler method getMask.

// methods that can be changed by extending the rippler class
/**
	 * generate the clipping mask
	 * @return the mask node
	 */
protected Node getMask() {
    double borderWidth = ripplerPane.getBorder() != null ? ripplerPane.getBorder().getInsets().getTop() : 0;
    Bounds bounds = control.getBoundsInParent();
    double width = control.getLayoutBounds().getWidth();
    double height = control.getLayoutBounds().getHeight();
    double diffMinX = Math.abs(control.getBoundsInLocal().getMinX() - control.getLayoutBounds().getMinX());
    double diffMinY = Math.abs(control.getBoundsInLocal().getMinY() - control.getLayoutBounds().getMinY());
    double diffMaxX = Math.abs(control.getBoundsInLocal().getMaxX() - control.getLayoutBounds().getMaxX());
    double diffMaxY = Math.abs(control.getBoundsInLocal().getMaxY() - control.getLayoutBounds().getMaxY());
    Node mask;
    switch(getMaskType()) {
        case RECT:
            // -0.1 to prevent resizing the anchor pane
            mask = new Rectangle(bounds.getMinX() + diffMinX, bounds.getMinY() + diffMinY, width - 0.1 - 2 * borderWidth, height - 0.1 - 2 * borderWidth);
            break;
        case CIRCLE:
            double radius = Math.min((width / 2) - 0.1 - 2 * borderWidth, (height / 2) - 0.1 - 2 * borderWidth);
            mask = new Circle((bounds.getMinX() + diffMinX + bounds.getMaxX() - diffMaxX) / 2, (bounds.getMinY() + diffMinY + bounds.getMaxY() - diffMaxY) / 2, radius, Color.BLUE);
            break;
        default:
            // -0.1 to prevent resizing the anchor pane
            mask = new Rectangle(bounds.getMinX() + diffMinX, bounds.getMinY() + diffMinY, width - 0.1 - 2 * borderWidth, height - 0.1 - 2 * borderWidth);
            break;
    }
    if (control instanceof Shape || (control instanceof Region && ((Region) control).getShape() != null)) {
        mask = new StackPane();
        ((Region) mask).setShape((control instanceof Shape) ? (Shape) control : ((Region) control).getShape());
        ((Region) mask).setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY)));
        mask.resize(width, height);
        mask.relocate(bounds.getMinX() + diffMinX, bounds.getMinY() + diffMinY);
    }
    return mask;
}
Also used : Circle(javafx.scene.shape.Circle) Shape(javafx.scene.shape.Shape) Bounds(javafx.geometry.Bounds) Node(javafx.scene.Node) Rectangle(javafx.scene.shape.Rectangle)

Example 2 with Circle

use of javafx.scene.shape.Circle in project JFoenix by jfoenixadmin.

the class JFXSliderSkinOLD method initialize.

private void initialize() {
    isHorizontal = getSkinnable().getOrientation() == Orientation.HORIZONTAL;
    thumb = new Circle();
    thumb.setStrokeWidth(2);
    thumb.setRadius(7);
    thumb.setFill(thumbColor);
    thumb.setStroke(thumbColor);
    thumb.getStyleClass().setAll("thumb");
    track = new Line();
    track.setStroke(trackColor);
    track.setStrokeWidth(3);
    track.getStyleClass().setAll("track");
    coloredTrack = new Line();
    coloredTrack.strokeProperty().bind(thumb.strokeProperty());
    coloredTrack.strokeWidthProperty().bind(track.strokeWidthProperty());
    sliderValue = new Text();
    sliderValue.setStroke(Color.WHITE);
    sliderValue.setFont(new Font(10));
    sliderValue.getStyleClass().setAll("sliderValue");
    animatedThumb = new StackPane();
    animatedThumb.getChildren().add(sliderValue);
    getChildren().clear();
    getChildren().addAll(track, coloredTrack, animatedThumb, thumb);
}
Also used : Line(javafx.scene.shape.Line) Circle(javafx.scene.shape.Circle) Text(javafx.scene.text.Text) Font(javafx.scene.text.Font) StackPane(javafx.scene.layout.StackPane)

Example 3 with Circle

use of javafx.scene.shape.Circle in project JFoenix by jfoenixadmin.

the class JFXTimePickerContent method createContentPane.

protected BorderPane createContentPane(LocalTime time) {
    Circle circle = new Circle(contentCircleRadius);
    circle.setFill(Color.rgb(224, 224, 224, 0.67));
    EventHandler<? super MouseEvent> mouseActionHandler = (event) -> {
        double dx = event.getX();
        double dy = event.getY();
        double theta = Math.atan2(dy, dx);
        int index = (int) Math.round((180 + Math.toDegrees(theta)) / angle.get());
        pointerRotate.get().setAngle(index * angle.get());
        int timeValue = (index + 9) % 12 == 0 ? 12 : (index + 9) % 12;
        if (unit.get() == TimeUnit.MINUTES)
            timeValue = (index + 45) % 60 == 0 ? 0 : (index + 45) % 60;
        timeLabel.get().setText(unit.get() == TimeUnit.MINUTES ? unitConverter.toString(timeValue) : timeValue + "");
        updateValue();
    };
    circle.setOnMousePressed(mouseActionHandler);
    circle.setOnMouseDragged(mouseActionHandler);
    hoursContent = createHoursContent(time);
    hoursContent.setMouseTransparent(true);
    minutesContent = createMinutesContent(time);
    minutesContent.setOpacity(0);
    minutesContent.setMouseTransparent(true);
    StackPane contentPane = new StackPane();
    contentPane.getChildren().addAll(circle, hoursContent, minutesContent);
    contentPane.setPadding(new Insets(12));
    BorderPane contentContainer = new BorderPane();
    contentContainer.setCenter(contentPane);
    contentContainer.setMinHeight(50);
    contentContainer.setPadding(new Insets(2, 12, 2, 12));
    return contentContainer;
}
Also used : EventHandler(javafx.event.EventHandler) FontWeight(javafx.scene.text.FontWeight) Pos(javafx.geometry.Pos) Color(javafx.scene.paint.Color) javafx.beans.property(javafx.beans.property) Label(javafx.scene.control.Label) javafx.scene.layout(javafx.scene.layout) FormatStyle(java.time.format.FormatStyle) Rotate(javafx.scene.transform.Rotate) MouseEvent(javafx.scene.input.MouseEvent) javafx.animation(javafx.animation) Font(javafx.scene.text.Font) Rectangle(javafx.scene.shape.Rectangle) Group(javafx.scene.Group) JFXTimePicker(com.jfoenix.controls.JFXTimePicker) Line(javafx.scene.shape.Line) NumberStringConverter(javafx.util.converter.NumberStringConverter) Duration(javafx.util.Duration) Insets(javafx.geometry.Insets) Paint(javafx.scene.paint.Paint) Locale(java.util.Locale) LocalTime(java.time.LocalTime) LocalTimeStringConverter(javafx.util.converter.LocalTimeStringConverter) Circle(javafx.scene.shape.Circle) Circle(javafx.scene.shape.Circle) Insets(javafx.geometry.Insets)

Example 4 with Circle

use of javafx.scene.shape.Circle in project JFoenix by jfoenixadmin.

the class JFXTimePickerContent method createHoursContent.

private StackPane createHoursContent(LocalTime time) {
    // create hours content
    StackPane hoursPointer = new StackPane();
    Circle selectionCircle = new Circle(contentCircleRadius / 6);
    selectionCircle.fillProperty().bind(timePicker.defaultColorProperty());
    double shift = 9;
    Line line = new Line(shift, 0, contentCircleRadius, 0);
    line.fillProperty().bind(timePicker.defaultColorProperty());
    line.strokeProperty().bind(line.fillProperty());
    line.setStrokeWidth(1.5);
    hoursPointer.getChildren().addAll(line, selectionCircle);
    StackPane.setAlignment(selectionCircle, Pos.CENTER_LEFT);
    Group pointerGroup = new Group();
    pointerGroup.getChildren().add(hoursPointer);
    pointerGroup.setTranslateX((-contentCircleRadius + shift) / 2);
    hoursPointerRotate = new Rotate(0, contentCircleRadius - shift, selectionCircle.getRadius());
    pointerRotate.set(hoursPointerRotate);
    pointerGroup.getTransforms().add(hoursPointerRotate);
    Pane clockLabelsContainer = new Pane();
    // inner circle radius
    double radius = contentCircleRadius - shift - selectionCircle.getRadius();
    for (int i = 0; i < 12; i++) {
        // create the label and its container
        int val = (i + 3) % 12 == 0 ? 12 : (i + 3) % 12;
        Label label = new Label(val + "");
        label.setFont(Font.font("Roboto", FontWeight.BOLD, 12));
        // init color 
        if (val == time.getHour() % 12 || (val == 12 && time.getHour() % 12 == 0))
            label.setTextFill(Color.rgb(255, 255, 255, 0.87));
        else
            label.setTextFill(Color.rgb(0, 0, 0, 0.87));
        selectedHourLabel.textProperty().addListener((o, oldVal, newVal) -> {
            if (Integer.parseInt(newVal) == Integer.parseInt(label.getText())) {
                label.setTextFill(Color.rgb(255, 255, 255, 0.87));
            } else {
                label.setTextFill(Color.rgb(0, 0, 0, 0.87));
            }
        });
        // create label container 
        StackPane labelContainer = new StackPane();
        labelContainer.getChildren().add(label);
        double labelSize = (selectionCircle.getRadius() / Math.sqrt(2)) * 2;
        labelContainer.setMinSize(labelSize, labelSize);
        // position the label on the circle
        double angle = 2 * i * Math.PI / 12;
        double xOffset = radius * Math.cos(angle);
        double yOffset = radius * Math.sin(angle);
        final double startx = contentCircleRadius + xOffset;
        final double starty = contentCircleRadius + yOffset;
        labelContainer.setLayoutX(startx - labelContainer.getMinWidth() / 2);
        labelContainer.setLayoutY(starty - labelContainer.getMinHeight() / 2);
        // add label to the parent node
        clockLabelsContainer.getChildren().add(labelContainer);
        // init pointer angle
        if (val == time.getHour() % 12 || (val == 12 && time.getHour() % 12 == 0))
            hoursPointerRotate.setAngle(180 + Math.toDegrees(angle));
    }
    return new StackPane(pointerGroup, clockLabelsContainer);
}
Also used : Line(javafx.scene.shape.Line) Circle(javafx.scene.shape.Circle) Group(javafx.scene.Group) Rotate(javafx.scene.transform.Rotate) Label(javafx.scene.control.Label) Paint(javafx.scene.paint.Paint)

Example 5 with Circle

use of javafx.scene.shape.Circle in project JFoenix by jfoenixadmin.

the class JFXColorPickerSkin method updateColor.

private void updateColor() {
    final ColorPicker colorPicker = (ColorPicker) getSkinnable();
    // update picker box color
    Circle ColorCircle = new Circle();
    ColorCircle.setFill(colorPicker.getValue());
    ColorCircle.setLayoutX(pickerColorBox.getWidth() / 4);
    ColorCircle.setLayoutY(pickerColorBox.getHeight() / 2);
    pickerColorBox.getChildren().add(ColorCircle);
    Timeline animateColor = new Timeline(new KeyFrame(Duration.millis(240), new KeyValue(ColorCircle.radiusProperty(), 200, Interpolator.EASE_BOTH)));
    animateColor.setOnFinished((finish) -> {
        pickerColorBox.setBackground(new Background(new BackgroundFill(ColorCircle.getFill(), pickerColorBox.getBackground().getFills().get(0).getRadii(), pickerColorBox.getBackground().getFills().get(0).getInsets())));
        pickerColorBox.getChildren().remove(ColorCircle);
    });
    animateColor.play();
    // update label color
    displayNode.setTextFill(colorPicker.getValue().grayscale().getRed() < 0.5 ? Color.valueOf("rgba(255, 255, 255, 0.87)") : Color.valueOf("rgba(0, 0, 0, 0.87)"));
    if (colorLabelVisible.get())
        displayNode.setText(colorDisplayName(colorPicker.getValue()));
    else
        displayNode.setText("");
}
Also used : Circle(javafx.scene.shape.Circle) Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) ColorPicker(javafx.scene.control.ColorPicker) KeyFrame(javafx.animation.KeyFrame)

Aggregations

Circle (javafx.scene.shape.Circle)13 Label (javafx.scene.control.Label)5 Line (javafx.scene.shape.Line)5 Text (javafx.scene.text.Text)5 Group (javafx.scene.Group)4 Paint (javafx.scene.paint.Paint)3 Rectangle (javafx.scene.shape.Rectangle)3 Shape (javafx.scene.shape.Shape)3 Font (javafx.scene.text.Font)3 Rotate (javafx.scene.transform.Rotate)3 Point2D (aima.core.util.math.geom.shapes.Point2D)2 Insets (javafx.geometry.Insets)2 Node (javafx.scene.Node)2 StackPane (javafx.scene.layout.StackPane)2 Color (javafx.scene.paint.Color)2 Agent (aima.core.agent.Agent)1 Map (aima.core.environment.map.Map)1 JFXTimePicker (com.jfoenix.controls.JFXTimePicker)1 URL (java.net.URL)1 LocalDate (java.time.LocalDate)1