如何在JavaFX中用另一个形状(圆弧)剪裁形状(圆)

如何在JavaFX中用另一个形状(圆弧)剪裁形状(圆),javafx,automatic-ref-counting,geometry,shape,gauge,Javafx,Automatic Ref Counting,Geometry,Shape,Gauge,我很难尝试用圆弧来剪裁一个圆。我试图复制这个恒温器 从这里,开发者说他使用了区域s、圆s和弧来制作动画。因此,我看不出如何使用动画圆弧剪裁圆 我的代码到目前为止 //stroke is the circle without fill stroke.setClip(arc); 我得到以下错误: Caused by: java.lang.IllegalArgumentException: Node's clip set to incorrect value (node already c

我很难尝试用圆弧来剪裁一个圆。我试图复制这个恒温器

从这里,开发者说他使用了
区域
s、
s和
来制作动画。因此,我看不出如何使用动画圆弧剪裁圆

我的代码到目前为止

//stroke is the circle without fill
    stroke.setClip(arc);
我得到以下错误:

Caused by: java.lang.IllegalArgumentException: Node's clip set to incorrect value (node already connected, node  = Circle[id=stroke, centerX=0.0, centerY=0.0, radius=200.0, fill=0x1f93ff00, stroke=0x63ff26ff, strokeWidth=30.0], clip = ObjectProperty [bean: Circle[id=stroke, centerX=0.0, centerY=0.0, radius=200.0, fill=0x1f93ff00, stroke=0x63ff26ff, strokeWidth=30.0], name: clip, value: null]).
那么如何解决这个问题呢?!我非常喜欢仪表和恒温器应用程序


提前感谢

有一种更容易达到预期效果的方法:只需使用无
填充
和适当的
冲程宽度

例如:

@Override
public void start(Stage primaryStage) {
    DoubleProperty value = new SimpleDoubleProperty();
    DoubleProperty minValue = new SimpleDoubleProperty();
    DoubleProperty maxValue = new SimpleDoubleProperty();

    final double startOffset = 10;
    final double maxRange = 360 - 2 * startOffset;

    Arc arc = new Arc();
    arc.setFill(null);

    arc.setRadiusX(100);
    arc.setRadiusY(100);

    arc.setCenterX(110);
    arc.setCenterY(110);

    arc.setStrokeWidth(10);
    arc.setStroke(Color.WHITE.deriveColor(0, 0, 1, 0.5));
    arc.setStartAngle(270 - startOffset);
    arc.lengthProperty().bind(value.subtract(minValue).divide(maxValue.subtract(minValue)).multiply(-maxRange));

    Pane thermostatPane = new Pane();
    thermostatPane.setMinSize(220, 220);
    thermostatPane.getChildren().add(arc);
    thermostatPane.setStyle("-fx-background-color: orange");

    Slider minSlider = new Slider(0, 100, 0);
    Slider maxSlider = new Slider(0, 100, 100);
    Slider valueSlider = new Slider(0, 100, 20);

    valueSlider.setPrefWidth(200);
    maxSlider.setPrefWidth(200);
    minSlider.setPrefWidth(200);

    value.bind(valueSlider.valueProperty());
    minValue.bind(minSlider.valueProperty());
    maxValue.bind(maxSlider.valueProperty());

    Scene scene = new Scene(new VBox(10, thermostatPane, minSlider, valueSlider, maxSlider));

    primaryStage.setScene(scene);
    primaryStage.show();
}

你能编辑视频的链接指向合适的时间吗?这段视频长度超过1小时,当然我不会仅仅为了了解想要的行为而观看整个视频,我怀疑其他人会…@fabia抱歉,这是我的立场。谢谢你运行了你的代码,这就是我得到的:##Java运行时环境检测到一个致命错误:##异常(0xc000001d)在pc=0x00007fee7115c01,pid=8484,tid=4996##JRE版本:Java(TM)SE运行时环境(8.0(U 65-b17)(构建1.8.0 A b17)#Java虚拟机:Java热点(TM)64位服务器虚拟机(25.65-b01混合模式windows-amd64压缩oops)#有问题的框架:#C[msvcr120.dll+0x95c01]#@Hayden使用java 8u92(工作)对其进行了测试。这似乎与此缺陷有关:(至少其中一个还提到有问题的框架和msvcr120.dll)。不幸的是,我无法帮助您解决这个问题。它应该与不包含此错误的java版本一起工作,因此您可以使用其他java运行时使其工作。。。