Java Code Examples for javafx.scene.shape.Line#setStrokeWidth()

The following examples show how to use javafx.scene.shape.Line#setStrokeWidth() . 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: TicTacToeApp.java    From FXGLGames with MIT License 6 votes vote down vote up
private void playWinAnimation(TileCombo combo) {
    Line line = new Line();
    line.setStartX(combo.getTile1().getCenter().getX());
    line.setStartY(combo.getTile1().getCenter().getY());
    line.setEndX(combo.getTile1().getCenter().getX());
    line.setEndY(combo.getTile1().getCenter().getY());
    line.setStroke(Color.YELLOW);
    line.setStrokeWidth(3);

    getGameScene().addUINode(line);

    Timeline timeline = new Timeline();
    timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(1),
            new KeyValue(line.endXProperty(), combo.getTile3().getCenter().getX()),
            new KeyValue(line.endYProperty(), combo.getTile3().getCenter().getY())));
    timeline.setOnFinished(e -> gameOver(combo.getWinSymbol()));
    timeline.play();
}
 
Example 2
Source File: LineSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public LineSample() {
    super(180,90);
    // Create line shape
    Line line = new Line(5, 85, 175 , 5);
    line.setFill(null);
    line.setStroke(Color.RED);
    line.setStrokeWidth(2);

    // show the line shape;
    getChildren().add(line);
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Line Stroke", line.strokeProperty()),
            new SimplePropertySheet.PropDesc("Line Start X", line.startXProperty(), 0d, 170d),
            new SimplePropertySheet.PropDesc("Line Start Y", line.startYProperty(), 0d, 90d),
            new SimplePropertySheet.PropDesc("Line End X", line.endXProperty(), 10d, 180d),
            new SimplePropertySheet.PropDesc("Line End Y", line.endYProperty(), 0d, 90d)
    );
    // END REMOVE ME
}
 
Example 3
Source File: LineSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public LineSample() {
    super(180,90);
    // Create line shape
    Line line = new Line(5, 85, 175 , 5);
    line.setFill(null);
    line.setStroke(Color.RED);
    line.setStrokeWidth(2);

    // show the line shape;
    getChildren().add(line);
    // REMOVE ME
    setControls(
            new SimplePropertySheet.PropDesc("Line Stroke", line.strokeProperty()),
            new SimplePropertySheet.PropDesc("Line Start X", line.startXProperty(), 0d, 170d),
            new SimplePropertySheet.PropDesc("Line Start Y", line.startYProperty(), 0d, 90d),
            new SimplePropertySheet.PropDesc("Line End X", line.endXProperty(), 10d, 180d),
            new SimplePropertySheet.PropDesc("Line End Y", line.endYProperty(), 0d, 90d)
    );
    // END REMOVE ME
}
 
Example 4
Source File: MultipleAxesLineChart.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
private void bindMouseEvents(final LineChart<?, ?> baseChart, final Double strokeWidth) {
    getChildren().add(detailsWindow);
    detailsWindow.prefHeightProperty().bind(heightProperty());
    detailsWindow.prefWidthProperty().bind(widthProperty());
    detailsWindow.setMouseTransparent(true);

    setOnMouseMoved(null);
    setMouseTransparent(false);

    final Axis<?> xAxis = baseChart.getXAxis();
    final Axis<?> yAxis = baseChart.getYAxis();

    final Line xLine = new Line();
    final Line yLine = new Line();
    yLine.setFill(Color.GRAY);
    xLine.setFill(Color.GRAY);
    yLine.setStrokeWidth(strokeWidth / 2);
    xLine.setStrokeWidth(strokeWidth / 2);
    xLine.setVisible(false);
    yLine.setVisible(false);

    final Node chartBackground = baseChart.lookup(".chart-plot-background");
    for (final Node n : chartBackground.getParent().getChildrenUnmodifiable()) {
        if ((n != chartBackground) && (n != xAxis) && (n != yAxis)) {
            n.setMouseTransparent(true);
        }
    }
}
 
Example 5
Source File: Main.java    From FXTutorials with MIT License 5 votes vote down vote up
public Arrow() {
    Line line = new Line(10, -5, 20, 0);
    Line line2 = new Line(10, 7, 20, 2);
    line.setStrokeWidth(3);
    line2.setStrokeWidth(3);
    line.setStroke(Color.RED);
    line2.setStroke(Color.BLUE);

    getChildren().addAll(new Rectangle(20, 2), line, line2);
}
 
Example 6
Source File: JFXTimePickerContent.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
private StackPane createMinutesContent(LocalTime time) {
    // create minutes content
    StackPane minsPointer = new StackPane();
    Circle selectionCircle = new Circle(contentCircleRadius / 6);
    selectionCircle.fillProperty().bind(timePicker.defaultColorProperty());

    Circle minCircle = new Circle(selectionCircle.getRadius() / 8);
    minCircle.setFill(Color.rgb(255, 255, 255, 0.87));
    minCircle.setTranslateX(selectionCircle.getRadius() - minCircle.getRadius());
    minCircle.setVisible(time.getMinute() % 5 != 0);
    selectedMinLabel.textProperty().addListener((o, oldVal, newVal) -> {
        if (Integer.parseInt(newVal) % 5 == 0) {
            minCircle.setVisible(false);
        } else {
            minCircle.setVisible(true);
        }
    });


    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);
    minsPointer.getChildren().addAll(line, selectionCircle, minCircle);
    StackPane.setAlignment(selectionCircle, Pos.CENTER_LEFT);
    StackPane.setAlignment(minCircle, Pos.CENTER_LEFT);


    Group pointerGroup = new Group();
    pointerGroup.getChildren().add(minsPointer);
    pointerGroup.setTranslateX((-contentCircleRadius + shift) / 2);
    minsPointerRotate = new Rotate(0, contentCircleRadius - shift, selectionCircle.getRadius());
    pointerGroup.getTransforms().add(minsPointerRotate);

    Pane clockLabelsContainer = new Pane();
    // inner circle radius
    double radius = contentCircleRadius - shift - selectionCircle.getRadius();
    for (int i = 0; i < 12; i++) {
        StackPane labelContainer = new StackPane();
        int val = ((i + 3) * 5) % 60;
        Label label = new Label(String.valueOf(unitConverter.toString(val)));
        label.setFont(Font.font(ROBOTO, FontWeight.BOLD, 12));
        // init label color
        label.setTextFill(val == time.getMinute() ?
            Color.rgb(255, 255, 255, 0.87) : Color.rgb(0, 0, 0, 0.87));
        selectedMinLabel.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));
            }
        });

        labelContainer.getChildren().add(label);
        double labelSize = (selectionCircle.getRadius() / Math.sqrt(2)) * 2;
        labelContainer.setMinSize(labelSize, labelSize);

        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);
    }

    minsPointerRotate.setAngle(180 + (time.getMinute() + 45) % 60 * Math.toDegrees(2 * Math.PI / 60));

    return new StackPane(pointerGroup, clockLabelsContainer);
}
 
Example 7
Source File: ClearingTextField.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
public CustomSkin(TextField text)
{
    super(text);

    // Circle with central 'x' as clear button
    final Circle circle = new Circle();
    circle.setFill(Color.GRAY);
    circle.radiusProperty().bind(text.heightProperty().multiply(0.325));
    circle.setFocusTraversable(false);

    final Line line1 = new Line();
    line1.setStroke(Color.WHITE);
    line1.setStrokeWidth(1.7);
    line1.startXProperty().bind(text.heightProperty().multiply(-0.1));
    line1.startYProperty().bind(text.heightProperty().multiply(-0.1));
    line1.endXProperty().bind(text.heightProperty().multiply(0.1));
    line1.endYProperty().bind(text.heightProperty().multiply(0.1));

    final Line line2 = new Line();
    line2.setStroke(Color.WHITE);
    line2.setStrokeWidth(1.7);
    line2.startXProperty().bind(text.heightProperty().multiply(0.1));
    line2.startYProperty().bind(text.heightProperty().multiply(-0.1));
    line2.endXProperty().bind(text.heightProperty().multiply(-0.1));
    line2.endYProperty().bind(text.heightProperty().multiply(0.1));

    final Group clear_button = new Group(circle, line1, line2);
    // Move clear button from center of text field to right edge
    clear_button.translateXProperty().bind(text.widthProperty().subtract(text.heightProperty()).divide(2.0));

    // Appear as soon as text is entered
    clear_button.visibleProperty().bind(text.textProperty().greaterThan(""));
    getChildren().add(clear_button);

    // Clicking the button clears text
    clear_button.setOnMouseClicked(event -> text.setText(""));
}
 
Example 8
Source File: LineSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static Node createIconContent() {
    Line line = new Line(0, 0, 70, 70);
    line.setStroke(Color.web("#b9c0c5"));
    line.setStrokeWidth(5);
    line.getStrokeDashArray().addAll(15d,15d);
    line.setFill(null);
    javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
    effect.setOffsetX(1);
    effect.setOffsetY(1);
    effect.setRadius(3);
    effect.setColor(Color.rgb(0,0,0,0.6));
    line.setEffect(effect);
    return line;
}
 
Example 9
Source File: LineSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static Node createIconContent() {
    Line line = new Line(0, 0, 70, 70);
    line.setStroke(Color.web("#b9c0c5"));
    line.setStrokeWidth(5);
    line.getStrokeDashArray().addAll(15d,15d);
    line.setFill(null);
    javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
    effect.setOffsetX(1);
    effect.setOffsetY(1);
    effect.setRadius(3);
    effect.setColor(Color.rgb(0,0,0,0.6));
    line.setEffect(effect);
    return line;
}
 
Example 10
Source File: Civ6MenuApp.java    From FXTutorials with MIT License 5 votes vote down vote up
private void addLine(double x, double y) {
    line = new Line(x, y, x, y + 300);
    line.setStrokeWidth(3);
    line.setStroke(Color.color(1, 1, 1, 0.75));
    line.setEffect(new DropShadow(5, Color.BLACK));
    line.setScaleY(0);

    root.getChildren().add(line);
}
 
Example 11
Source File: FillPatternStyleHelper.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
private static Image createDefaultHatch(final Paint color, final double strokeWidth) {
    WeakHashMap<Double, Image> checkCache = FillPatternStyleHelper.defaultHatchCacheWithStrokeWidth.get(color);
    if (checkCache != null) {
        final Image val = checkCache.get(Double.valueOf(strokeWidth));
        if (val != null) {
            // found existing Image with given parameter
            return val;
        }
    }
    // need to recompute hatch pattern image

    final Pane pane = new Pane();
    pane.setPrefSize(10, 10);
    final Line fw = new Line(-5, -5, 25, 25);
    final Line bw = new Line(-5, 25, 25, -5);
    fw.setSmooth(false);
    bw.setSmooth(false);
    fw.setStroke(color);
    bw.setStroke(color);
    fw.setStrokeWidth(strokeWidth);
    bw.setStrokeWidth(strokeWidth);
    pane.getChildren().addAll(fw, bw);

    pane.setStyle("-fx-background-color: rgba(0, 0, 0, 0.0)");
    final Scene scene = new Scene(pane);
    scene.setFill(Color.TRANSPARENT);
    final Image retVal = pane.snapshot(null, null);
    // add retVal to cache
    if (checkCache == null) {
        final WeakHashMap<Double, Image> temp = new WeakHashMap<>();
        temp.put(Double.valueOf(strokeWidth), retVal);
        FillPatternStyleHelper.defaultHatchCacheWithStrokeWidth.put(color, temp);
        // checkCache = new WeakHashMap<>();
    } else {
        checkCache.put(Double.valueOf(strokeWidth), retVal);
    }

    return retVal;
}
 
Example 12
Source File: WidgetTreeCell.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void updateItem(final WidgetOrTab item, final boolean empty)
{
    super.updateItem(item, empty);
    if (empty || item == null)
    {
        setText(null);
        setGraphic(null);
    }
    else if (item.isWidget())
    {
        final Widget widget = item.getWidget();
        final String type = widget.getType();
        setText(widget.getName());
        final Image icon = WidgetIcons.getIcon(type);
        if (icon != null)
        {
            if (widget instanceof VisibleWidget)
            {
                final boolean visible = ((VisibleWidget)widget).propVisible().getValue();
                if (!visible)
                {
                    final double w = icon.getWidth();
                    final double h = icon.getHeight();
                    final Line l1 = new Line(0, 0, w, h);
                    final Line l2 = new Line(0, h, w, 0);
                    l1.setStroke(Color.RED);
                    l2.setStroke(Color.RED);
                    l1.setStrokeWidth(2);
                    l2.setStrokeWidth(2);
                    final StackPane pane = new StackPane(new ImageView(icon), l1, l2);
                    setGraphic(pane);
                }
                else
                    setGraphic(new ImageView(icon));
            }
            else
                setGraphic(new ImageView(icon));
        }
        else
            setGraphic(null);
    }
    else
    {
        setText(item.getTab().name().getValue());
        if (tab_icon != null)
            setGraphic(new ImageView(tab_icon));
        else
            setGraphic(null);
    }
}
 
Example 13
Source File: ImageMaskController.java    From MyBox with Apache License 2.0 4 votes vote down vote up
public boolean drawMaskMosaicLines(double strokeWidth) {
    for (List<Line> penline : maskPenLines) {
        maskPane.getChildren().removeAll(penline);
    }
    maskPenLines.clear();
    polygonP1.setOpacity(0);
    int size = maskPenData.getPointsSize();
    if (size == 0) {
        return true;
    }
    double xRatio = imageView.getBoundsInParent().getWidth() / getImageWidth();
    double yRatio = imageView.getBoundsInParent().getHeight() / getImageHeight();
    if (size == 1) {
        polygonP1.setOpacity(1);
        DoublePoint p1 = maskPenData.getPoint(0);
        int anchorHW = AppVariables.getUserConfigInt("AnchorWidth", 10) / 2;
        polygonP1.setLayoutX(imageView.getLayoutX() + p1.getX() * xRatio - anchorHW);
        polygonP1.setLayoutY(imageView.getLayoutY() + p1.getY() * yRatio - anchorHW);
    } else if (size > 1) {
        double lastx, lasty = -1, thisx, thisy;
        for (List<DoublePoint> lineData : maskPenData.getLines()) {
            List<Line> penLine = new ArrayList<>();
            lastx = -1;
            for (DoublePoint p : lineData) {
                thisx = p.getX() * xRatio;
                thisy = p.getY() * yRatio;
                if (lastx >= 0) {
                    Line line = new Line(lastx, lasty, thisx, thisy);
                    line.setStrokeWidth(strokeWidth);
                    penLine.add(line);
                    maskPane.getChildren().add(line);
                    line.setLayoutX(imageView.getLayoutX());
                    line.setLayoutY(imageView.getLayoutY());
                }
                lastx = thisx;
                lasty = thisy;
            }
            maskPenLines.add(penLine);
        }

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

    titleText = new Text();
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    description = new Label(tile.getDescription());
    description.setAlignment(tile.getDescriptionAlignment());
    description.setTextAlignment(TextAlignment.RIGHT);
    description.setWrapText(true);
    description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS);
    description.setTextFill(tile.getTextColor());
    description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795);
    Helper.enableNode(description, tile.isTextVisible());

    Color foregroundColor = getSkinnable().getForegroundColor();
    Color halfTranslucent = Helper.getColorWithOpacity(foregroundColor, 0.5);

    verticalDivider = new Line(0, PREFERRED_HEIGHT * 0.35, PREFERRED_WIDTH, PREFERRED_HEIGHT * 0.35);
    verticalDivider.getStrokeDashArray().addAll(2.0, 2.0);
    verticalDivider.setStrokeDashOffset(1);
    verticalDivider.setStroke(halfTranslucent);
    verticalDivider.setStrokeWidth(1);

    horizontal1Divider = new Line(PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.45, PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.85);
    horizontal1Divider.getStrokeDashArray().addAll(2.0, 2.0);
    horizontal1Divider.setStrokeDashOffset(1);
    horizontal1Divider.setStroke(halfTranslucent);
    horizontal1Divider.setStrokeWidth(1);

    horizontal2Divider = new Line(2 * PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.45, 2 * PREFERRED_WIDTH / 3, PREFERRED_HEIGHT * 0.85);
    horizontal2Divider.getStrokeDashArray().addAll(2.0, 2.0);
    horizontal2Divider.setStrokeDashOffset(1);
    horizontal2Divider.setStroke(halfTranslucent);
    horizontal2Divider.setStrokeWidth(1);

    leftGraphicsPane = new StackPane();
    middleGraphicsPane = new StackPane();
    rightGraphicsPane = new StackPane();

    if (null != tile.getLeftGraphics()) { leftGraphicsPane.getChildren().setAll(tile.getLeftGraphics()); }
    if (null != tile.getMiddleGraphics()) { middleGraphicsPane.getChildren().setAll(tile.getMiddleGraphics()); }
    if (null != tile.getRightGraphics()) { rightGraphicsPane.getChildren().setAll(tile.getRightGraphics()); }

    leftValueLabel = new Label();
    leftValueLabel.setAlignment(Pos.CENTER);

    middleValueLabel = new Label();
    middleValueLabel.setAlignment(Pos.CENTER);

    rightValueLabel = new Label();
    rightValueLabel.setAlignment(Pos.CENTER);

    leftLabel = new Label();
    leftLabel.setAlignment(Pos.CENTER);

    middleLabel = new Label();
    middleLabel.setAlignment(Pos.CENTER);

    rightLabel = new Label();
    rightLabel.setAlignment(Pos.CENTER);

    text = new Text(tile.getText());
    text.setFill(tile.getUnitColor());
    Helper.enableNode(text, tile.isTextVisible());

    getPane().getChildren().addAll(titleText, description,
                                   verticalDivider, horizontal1Divider, horizontal2Divider, leftGraphicsPane, middleGraphicsPane, rightGraphicsPane,
                                   leftValueLabel, middleValueLabel, rightValueLabel,
                                   leftLabel, middleLabel, rightLabel,
                                   text);
}
 
Example 15
Source File: ImageMaskController.java    From MyBox with Apache License 2.0 4 votes vote down vote up
public boolean drawMaskPenLines(double strokeWidth, Color strokeColor, boolean dotted, float opacity) {
    for (List<Line> penline : maskPenLines) {
        maskPane.getChildren().removeAll(penline);
    }
    maskPenLines.clear();
    polygonP1.setOpacity(0);
    int size = maskPenData.getPointsSize();
    if (size == 0) {
        return true;
    }
    double xRatio = imageView.getBoundsInParent().getWidth() / getImageWidth();
    double yRatio = imageView.getBoundsInParent().getHeight() / getImageHeight();
    double drawStrokeWidth = strokeWidth * xRatio;
    if (size == 1) {
        polygonP1.setOpacity(1);
        DoublePoint p1 = maskPenData.getPoint(0);
        int anchorHW = AppVariables.getUserConfigInt("AnchorWidth", 10) / 2;
        polygonP1.setLayoutX(imageView.getLayoutX() + p1.getX() * xRatio - anchorHW);
        polygonP1.setLayoutY(imageView.getLayoutY() + p1.getY() * yRatio - anchorHW);
    } else if (size > 1) {
        double lastx, lasty = -1, thisx, thisy;
        for (List<DoublePoint> lineData : maskPenData.getLines()) {
            List<Line> penLine = new ArrayList<>();
            lastx = -1;
            for (DoublePoint p : lineData) {
                thisx = p.getX() * xRatio;
                thisy = p.getY() * yRatio;
                if (lastx >= 0) {
                    Line line = new Line(lastx, lasty, thisx, thisy);
                    if (strokeColor.equals(Color.TRANSPARENT)) {
                        // Have not found how to make line as transparent. For display only.
                        line.setStroke(Color.WHITE);
                    } else {
                        line.setStroke(strokeColor);
                    }
                    line.setStrokeWidth(drawStrokeWidth);
                    line.getStrokeDashArray().clear();
                    if (dotted) {
                        line.getStrokeDashArray().addAll(drawStrokeWidth * 1d, drawStrokeWidth * 3d);
                    }
                    line.setOpacity(opacity);
                    penLine.add(line);
                    maskPane.getChildren().add(line);
                    line.setLayoutX(imageView.getLayoutX());
                    line.setLayoutY(imageView.getLayoutY());
                }
                lastx = thisx;
                lasty = thisy;
            }
            maskPenLines.add(penLine);
        }

    }
    return true;
}
 
Example 16
Source File: GridViewBase.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
private Line createLine(final double x1, final double y1, final double x2, final double y2) {
	final Line line = new Line(x1, y1, x2, y2);
	line.setStroke(lineCol);
	line.setStrokeWidth(strokeWidth);
	return line;
}
 
Example 17
Source File: Callout.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void build() {
    // Create head
    Circle head = new Circle(getHeadPoint().getX(), getHeadPoint().getY(), 5);
    head.setFill(Color.WHITE);

    // First leader line
    Line firstLeaderLine = new Line(headPoint.getX(), headPoint.getY(),
            headPoint.getX(), headPoint.getY());
    firstLeaderLine.setStroke(Color.WHITE);
    firstLeaderLine.setStrokeWidth(3);

    // Second part of the leader line
    Line secondLeaderLine = new Line(getLeaderLineToPoint().getX(),
            getLeaderLineToPoint().getY(),
            getLeaderLineToPoint().getX(),
            getLeaderLineToPoint().getY());

    secondLeaderLine.setStroke(Color.WHITE);
    secondLeaderLine.setStrokeWidth(3);

    // Main title Rectangle
    HBox mainTitle = new HBox();
    mainTitle.setBackground(
            new Background(
                    new BackgroundFill(Color.WHITE,
                            new CornerRadii(2),
                            new Insets(0)))
    );

    // Main title text
    Text mainTitleText = new Text(getMainTitleText());
    HBox.setMargin(mainTitleText, new Insets(8, 8, 8, 8));
    mainTitleText.setFont(Font.font(20));
    mainTitle.getChildren().add(mainTitleText);

    // Position sub tile rectangle under main title
    Rectangle subTitleRect = new Rectangle(2, 20);
    subTitleRect.setFill(Color.WHITE);

    // Create the sub title
    HBox subTitle = new HBox();
    subTitle.setBackground(
            new Background(
                    new BackgroundFill(Color.color(0, 0, 0, .20),
                            new CornerRadii(0),
                            new Insets(0)))
    );
    Text subTitleText = new Text(getSubTitleText());
    subTitleText.setVisible(true);
    subTitleText.setFill(Color.WHITE);
    subTitleText.setFont(Font.font(14));
    subTitle.getChildren().add(subTitleText);

    // Build the animation code.
    buildAnimation(head,
            firstLeaderLine,
            secondLeaderLine,
            mainTitle,
            subTitleRect,
            subTitle);

    // Must add nodes after buildAnimation.
    // Positioning calculations are done
    // outside of this Group.
    getChildren().addAll(head,
            firstLeaderLine,
            secondLeaderLine,
            mainTitle,
            subTitleRect,
            subTitle);
    getChildren().forEach(node -> node.setVisible(false));

}
 
Example 18
Source File: MouthView.java    From narjillos with MIT License 4 votes vote down vote up
private Line createLine() {
	Line result = new Line(0, 0, LINE_LENGTH, 2);
	result.setStrokeWidth(2);
	return result;
}
 
Example 19
Source File: JFXCheckBoxOldSkin.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
public JFXCheckBoxOldSkin(JFXCheckBox control) {
    super(control);

    box.setMinSize(20, 20);
    box.setPrefSize(20, 20);
    box.setMaxSize(20, 20);
    box.setBorder(new Border(new BorderStroke(control.getUnCheckedColor(),
        BorderStrokeStyle.SOLID,
        new CornerRadii(0),
        new BorderWidths(lineThick))));
    //
    StackPane boxContainer = new StackPane();
    boxContainer.getChildren().add(box);
    boxContainer.setPadding(new Insets(padding));
    rippler = new JFXRippler(boxContainer, RipplerMask.CIRCLE);
    rippler.setRipplerFill(getSkinnable().isSelected() ? control.getUnCheckedColor() : control.getCheckedColor());

    rightLine = new Line();
    leftLine = new Line();
    rightLine.setStroke(control.getCheckedColor());
    rightLine.setStrokeWidth(lineThick);
    leftLine.setStroke(control.getCheckedColor());
    leftLine.setStrokeWidth(lineThick);
    rightLine.setVisible(false);
    leftLine.setVisible(false);

    container.getChildren().add(rightLine);
    container.getChildren().add(leftLine);
    container.getChildren().add(rippler);
    AnchorPane.setRightAnchor(rippler, labelOffset);

    // add listeners
    getSkinnable().selectedProperty().addListener((o, oldVal, newVal) -> {
        rippler.setRipplerFill(newVal ? control.getUnCheckedColor() : control.getCheckedColor());
        transition.setRate(newVal ? 1 : -1);
        transition.play();
    });

    updateChildren();

}
 
Example 20
Source File: ImageMaskController.java    From MyBox with Apache License 2.0 4 votes vote down vote up
public boolean drawMaskLine(double strokeWidth, Color strokeColor, boolean dotted, float opacity) {
    maskPane.getChildren().removeAll(maskLineLines);
    maskLineLines.clear();
    polygonP1.setOpacity(0);
    int size = maskLineData.getSize();
    if (size == 0) {
        return true;
    }

    double xRatio = imageView.getBoundsInParent().getWidth() / getImageWidth();
    double yRatio = imageView.getBoundsInParent().getHeight() / getImageHeight();
    double drawStrokeWidth = strokeWidth * xRatio;
    if (size == 1) {
        polygonP1.setOpacity(1);
        DoublePoint p1 = maskLineData.get(0);
        int anchorHW = AppVariables.getUserConfigInt("AnchorWidth", 10) / 2;
        polygonP1.setLayoutX(imageView.getLayoutX() + p1.getX() * xRatio - anchorHW);
        polygonP1.setLayoutY(imageView.getLayoutY() + p1.getY() * yRatio - anchorHW);
    } else if (size > 1) {
        double lastx = -1, lasty = -1, thisx, thisy;
        for (DoublePoint p : maskLineData.getPoints()) {
            thisx = p.getX() * xRatio;
            thisy = p.getY() * yRatio;
            if (lastx >= 0) {
                Line line = new Line(lastx, lasty, thisx, thisy);
                if (strokeColor.equals(Color.TRANSPARENT)) {
                    // Have not found how to make line as transparent. For display only.
                    line.setStroke(Color.WHITE);
                } else {
                    line.setStroke(strokeColor);
                }
                line.setStrokeWidth(drawStrokeWidth);
                line.getStrokeDashArray().clear();
                if (dotted) {
                    line.getStrokeDashArray().addAll(drawStrokeWidth * 1d, drawStrokeWidth * 3d);
                }
                line.setOpacity(opacity);
                maskLineLines.add(line);
                maskPane.getChildren().add(line);
                line.setLayoutX(imageView.getLayoutX());
                line.setLayoutY(imageView.getLayoutY());
            }
            lastx = thisx;
            lasty = thisy;
        }
    }
    return true;
}