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

The following examples show how to use javafx.scene.shape.Line#setFill() . 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: 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 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: 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 4
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 5
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 6
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 7
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);
}