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

The following examples show how to use javafx.scene.shape.Line#setStroke() . 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: EnvironmentView.java    From narjillos with MIT License 6 votes vote down vote up
private Group getVisualDebuggingSegments() {
	Group result = new Group();
	List<Segment> segments = VisualDebugger.getSegments();

	if (segments.isEmpty())
		return result;

	for (Segment segment : segments) {
		Line line = new Line(segment.getStartPoint().x, segment.getStartPoint().y, segment.getEndPoint().x, segment.getEndPoint().y);
		line.setStrokeWidth(2);
		line.setStroke(Color.RED);
		result.getChildren().add(line);
	}

	return result;
}
 
Example 4
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 5
Source File: Exercise_14_16.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
public GridPane() {
	// Create four lines and set their properties
	Line line1 = new Line(0, 200 / 3, 200, 200 / 3);
	line1.startYProperty().bind(heightProperty().divide(3));
	line1.endYProperty().bind(heightProperty().divide(3));
	line1.endXProperty().bind(widthProperty());
	line1.setStroke(Color.BLUE);

	Line line2 = new Line();
	line2.startYProperty().bind(line1.startYProperty().multiply(2));
	line2.endYProperty().bind(line1.endYProperty().multiply(2));
	line2.endXProperty().bind(widthProperty());
	line2.setStroke(Color.BLUE);

	Line line3 = new Line(200 / 3, 0, 200 / 3, 200);
	line3.startXProperty().bind(widthProperty().divide(3));
	line3.endXProperty().bind(widthProperty().divide(3));
	line3.endYProperty().bind(heightProperty());
	line3.setStroke(Color.RED);

	Line line4 = new Line();
	line4.startXProperty().bind(line3.startXProperty().multiply(2));
	line4.endXProperty().bind(line3.endXProperty().multiply(2));
	line4.endYProperty().bind(heightProperty());
	line4.setStroke(Color.RED);

	// Place lines in pane
	getChildren().addAll(line1, line2, line3, line4); 
}
 
Example 6
Source File: ParetoInfoPopup.java    From charts with Apache License 2.0 5 votes vote down vote up
private void initGraphics() {
    regularFont = Fonts.latoRegular(10);
    lightFont   = Fonts.latoLight(10);

    itemText = new Text("NAME");
    itemText.setFill(_textColor);
    itemText.setFont(regularFont);

    itemNameText = new Text("-");
    itemNameText.setFill(_textColor);
    itemNameText.setFont(regularFont);

    line = new Line(0, 0, 0, 56);
    line.setStroke(_textColor);

    vBoxTitles = new VBox(2, itemText);
    vBoxTitles.setAlignment(Pos.CENTER_LEFT);
    VBox.setMargin(itemText, new Insets(3, 0, 0, 0));

    vBoxValues = new VBox(2, itemNameText);

    vBoxValues.setAlignment(Pos.CENTER_RIGHT);
    VBox.setMargin(itemNameText, new Insets(3, 0, 0, 0));
    HBox.setHgrow(vBoxValues, Priority.ALWAYS);

    hBox = new HBox(5, vBoxTitles, line, vBoxValues);
    hBox.setPrefSize(120, 69);
    hBox.setPadding(new Insets(5));
    hBox.setBackground(new Background(new BackgroundFill(_backgroundColor, new CornerRadii(3), Insets.EMPTY)));
    hBox.setMouseTransparent(true);

    getContent().addAll(hBox);
}
 
Example 7
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 8
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 9
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 10
Source File: CountdownTimerTileSkin.java    From tilesfx with Apache License 2.0 4 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

    duration  = tile.getTimePeriod();
    minValue  = 0;
    maxValue  = duration.getSeconds();
    range     = duration.getSeconds();
    angleStep = ANGLE_RANGE / range;
    locale    = tile.getLocale();

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

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

    barBackground = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.468, PREFERRED_HEIGHT * 0.468, 90, 360);
    barBackground.setType(ArcType.OPEN);
    barBackground.setStroke(tile.getBarBackgroundColor());
    barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.1);
    barBackground.setStrokeLineCap(StrokeLineCap.BUTT);
    barBackground.setFill(null);

    bar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.468, PREFERRED_HEIGHT * 0.468, 90, 0);
    bar.setType(ArcType.OPEN);
    bar.setStroke(tile.getBarColor());
    bar.setStrokeWidth(PREFERRED_WIDTH * 0.1);
    bar.setStrokeLineCap(StrokeLineCap.BUTT);
    bar.setFill(null);

    separator = new Line(PREFERRED_WIDTH * 0.5, 1, PREFERRED_WIDTH * 0.5, 0.16667 * PREFERRED_HEIGHT);
    separator.setStroke(tile.getBackgroundColor());
    separator.setFill(Color.TRANSPARENT);

    durationText = new Text();
    durationText.setFont(Fonts.latoRegular(PREFERRED_WIDTH * 0.27333));
    durationText.setFill(tile.getValueColor());
    durationText.setTextOrigin(VPos.CENTER);

    durationFlow = new TextFlow(durationText);
    durationFlow.setTextAlignment(TextAlignment.CENTER);

    timeText = new Text(DTF.format(LocalTime.now().plus(tile.getTimePeriod().getSeconds(), ChronoUnit.SECONDS)));
    timeText.setFont(Fonts.latoRegular(PREFERRED_WIDTH * 0.27333));
    timeText.setFill(tile.getValueColor());
    timeText.setTextOrigin(VPos.CENTER);
    enableNode(timeText, tile.isValueVisible());

    timeFlow = new TextFlow(timeText);
    timeFlow.setTextAlignment(TextAlignment.CENTER);

    runningListener = (o, ov, nv) -> {
        if (nv) {
            timeText.setText(DTF.format(LocalTime.now().plus(duration.getSeconds(), ChronoUnit.SECONDS)));
        }
    };
    timeListener = e -> {
        if (TimeEventType.SECOND == e.TYPE) {
            updateBar();
        }
    };

    getPane().getChildren().addAll(barBackground, bar, separator, titleText, text, durationFlow, timeFlow);
}
 
Example 11
Source File: NodePart.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
private Node edge(Circle n, Circle m) {
	Line line = new Line(n.getCenterX(), n.getCenterY(), m.getCenterX(), m.getCenterY());
	line.setStroke(Color.BLACK);
	return line;
}
 
Example 12
Source File: ClockPane.java    From Intro-to-Java-Programming with MIT License 4 votes vote down vote up
/** Paint the clock */
protected void paintClock() {
	// Initialize clock parameters
	double clockRadius = Math.min(w, h) * 0.8 * 0.5;
	double centerX = w / 2;
	double centerY = h / 2;

	// Draw circle
	Circle circle = new Circle(centerX, centerY, clockRadius);
	circle.setFill(Color.WHITE);
	circle.setStroke(Color.BLACK);
	Text t1 = new Text(centerX - 5, centerY - clockRadius + 12, "12");
	Text t2 = new Text(centerX - clockRadius + 3, centerY + 5, "9");
	Text t3 = new Text(centerX + clockRadius - 10, centerY + 3, "3");
	Text t4 = new Text(centerX - 3, centerY + clockRadius - 3, "6");

	// Draw second hand
	double sLength = clockRadius * 0.8;
	double secondX = centerX + sLength *
		Math.sin(second * (2 * Math.PI / 60));
	double secondY = centerY - sLength *
		Math.cos(second * (2 * Math.PI / 60));
	Line sLine = new Line(centerX, centerY, secondX, secondY);
	sLine.setStroke(Color.RED);

	// Draw minute hand
	double mLength = clockRadius * 0.65;
	double xMinute = centerX + mLength *
		Math.sin(minute * (2 * Math.PI / 60));
	double minuteY = centerY - mLength *
		Math.cos(minute * (2 * Math.PI / 60));
	Line mLine = new Line(centerX, centerY, xMinute, minuteY);
	mLine.setStroke(Color.BLUE);

	// Draw hour hand 
	double hLength = clockRadius * 0.5;
	double hourX = centerX + hLength *
		Math.sin((hour % 12 + minute / 60.0) * (2 * Math.PI / 12));
	double hourY = centerY - hLength * 
		Math.cos((hour % 12 + minute / 60.0) * (2 * Math.PI / 12));
	Line hLine = new Line(centerX, centerY, hourX, hourY);
	hLine.setStroke(Color.GREEN);

	getChildren().clear();
	getChildren().addAll(circle, t1, t2, t3, t4, sLine, mLine, hLine);
}
 
Example 13
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 14
Source File: FlatSkin.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);
        }
    }

    colorRing = new Circle(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.5);
    colorRing.setFill(Color.TRANSPARENT);
    colorRing.setStrokeWidth(PREFERRED_WIDTH * 0.0075);
    colorRing.setStroke(gauge.getBarColor());

    bar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.468, PREFERRED_HEIGHT * 0.468, 90, 0);
    bar.setType(ArcType.OPEN);
    bar.setStroke(gauge.getBarColor());
    bar.setStrokeWidth(PREFERRED_WIDTH * 0.15);
    bar.setStrokeLineCap(StrokeLineCap.BUTT);
    bar.setFill(null);

    separator = new Line(PREFERRED_WIDTH * 0.5, 1, PREFERRED_WIDTH * 0.5, 0.16667 * PREFERRED_HEIGHT);
    separator.setStroke(gauge.getBorderPaint());
    separator.setFill(Color.TRANSPARENT);

    titleText = new Text(gauge.getTitle());
    titleText.setFont(Fonts.robotoLight(PREFERRED_WIDTH * 0.08));
    titleText.setFill(gauge.getTitleColor());
    Helper.enableNode(titleText, !gauge.getTitle().isEmpty());

    valueText = new Text(formatNumber(gauge.getLocale(), gauge.getFormatString(), gauge.getDecimals(), gauge.getCurrentValue()));
    valueText.setFont(Fonts.robotoRegular(PREFERRED_WIDTH * 0.27333));
    valueText.setFill(gauge.getValueColor());
    Helper.enableNode(valueText, gauge.isValueVisible());

    unitText = new Text(gauge.getUnit());
    unitText.setFont(Fonts.robotoLight(PREFERRED_WIDTH * 0.08));
    unitText.setFill(gauge.getUnitColor());
    Helper.enableNode(unitText, !gauge.getUnit().isEmpty());

    pane = new Pane(colorRing, bar, separator, titleText, valueText, unitText);
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), new CornerRadii(1024), Insets.EMPTY)));
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(1024), new BorderWidths(gauge.getBorderWidth()))));

    getChildren().setAll(pane);
}
 
Example 15
Source File: TileSparklineSkin.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);
        }
    }

    graphBounds = new Rectangle(PREFERRED_WIDTH * 0.05, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.45);

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

    valueText = new Text(String.format(locale, formatString, gauge.getValue()));
    valueText.setFill(gauge.getValueColor());
    Helper.enableNode(valueText, gauge.isValueVisible());

    unitText = new Text(gauge.getUnit());
    unitText.setFill(gauge.getUnitColor());
    Helper.enableNode(unitText, !gauge.getUnit().isEmpty());

    averageText = new Text(String.format(locale, formatString, gauge.getAverage()));
    averageText.setFill(gauge.getAverageColor());
    Helper.enableNode(averageText, gauge.isAverageVisible());

    highText = new Text();
    highText.setTextOrigin(VPos.BOTTOM);
    highText.setFill(gauge.getValueColor());

    lowText = new Text();
    lowText.setTextOrigin(VPos.TOP);
    lowText.setFill(gauge.getValueColor());

    subTitleText = new Text(gauge.getSubTitle());
    subTitleText.setTextOrigin(VPos.TOP);
    subTitleText.setFill(gauge.getSubTitleColor());

    stdDeviationArea = new Rectangle();
    Helper.enableNode(stdDeviationArea, gauge.isAverageVisible());

    averageLine = new Line();
    averageLine.setStroke(gauge.getAverageColor());
    averageLine.getStrokeDashArray().addAll(PREFERRED_WIDTH * 0.005, PREFERRED_WIDTH * 0.005);
    Helper.enableNode(averageLine, gauge.isAverageVisible());

    pathElements = new ArrayList<>(noOfDatapoints);
    pathElements.add(0, new MoveTo());
    for (int i = 1 ; i < noOfDatapoints ; i++) { pathElements.add(i, new LineTo()); }

    sparkLine = new Path();
    sparkLine.getElements().addAll(pathElements);
    sparkLine.setFill(null);
    sparkLine.setStroke(gauge.getBarColor());
    sparkLine.setStrokeWidth(PREFERRED_WIDTH * 0.0075);
    sparkLine.setStrokeLineCap(StrokeLineCap.ROUND);
    sparkLine.setStrokeLineJoin(StrokeLineJoin.ROUND);

    dot = new Circle();
    dot.setFill(gauge.getBarColor());

    pane = new Pane(titleText, valueText, unitText, stdDeviationArea, averageLine, sparkLine, dot, averageText, highText, lowText, subTitleText);
    pane.setBorder(new Border(new BorderStroke(gauge.getBorderPaint(), BorderStrokeStyle.SOLID, new CornerRadii(PREFERRED_WIDTH * 0.025), new BorderWidths(gauge.getBorderWidth()))));
    pane.setBackground(new Background(new BackgroundFill(gauge.getBackgroundPaint(), new CornerRadii(PREFERRED_WIDTH * 0.025), Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example 16
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 17
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 18
Source File: FxmlImageManufacture.java    From MyBox with Apache License 2.0 4 votes vote down vote up
public static Image indicateSplitFx(Image image,
            List<Integer> rows, List<Integer> cols,
            Color lineColor, int lineWidth, boolean showSize) {
        try {
            if (rows == null || cols == null) {
                return image;
            }
            Group group = new Group();
            int width = (int) image.getWidth();
            int height = (int) image.getHeight();
            int row;
            for (int i = 0; i < rows.size(); ++i) {
                row = rows.get(i);
                if (row <= 0 || row >= height - 1) {
                    continue;
                }
                Line rowLine = new Line(0, row, width, row);
                rowLine.setStroke(lineColor);
                rowLine.setStrokeWidth(lineWidth);
                group.getChildren().add(rowLine);
            }
            int col;
            for (int i = 0; i < cols.size(); ++i) {
                col = cols.get(i);
                if (col <= 0 || col >= width - 1) {
                    continue;
                }
                Line colLine = new Line(col, 0, col, height);
                colLine.setStroke(lineColor);
                colLine.setStrokeWidth(lineWidth);
                group.getChildren().add(colLine);
            }

            if (showSize) {
                for (int i = 0; i < rows.size() - 1; ++i) {
                    int h = rows.get(i + 1) - rows.get(i) + 1;
                    for (int j = 0; j < cols.size() - 1; ++j) {
                        int w = cols.get(j + 1) - cols.get(j) + 1;
                        Text text = new Text();
                        text.setX(cols.get(j) + w / 3);
                        text.setY(rows.get(i) + h / 3);
                        text.setFill(lineColor);
                        text.setText(w + "x" + h);
                        text.setFont(new javafx.scene.text.Font(lineWidth * 3.0));
                        group.getChildren().add(text);
                    }
                }
            }

            Blend blend = new Blend(BlendMode.SRC_OVER);
            blend.setBottomInput(new ImageInput(image));
            group.setEffect(blend);

            SnapshotParameters parameters = new SnapshotParameters();
            parameters.setFill(Color.TRANSPARENT);
            WritableImage newImage = group.snapshot(parameters, null);

            return newImage;
        } catch (Exception e) {
//            logger.error(e.toString());
            return null;
        }
    }
 
Example 19
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 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;
}