import javafx.application.Application; import javafx.scene.*; import javafx.scene.paint.Color; import javafx.scene.shape.*; import javafx.stage.Stage; public class SemiCircleSample extends Application { @Override public void start(Stage stage) { Arc arc = new Arc(50, 50, 25, 25, 0, 180); arc.setType(ArcType.OPEN); arc.setStrokeWidth(10); arc.setStroke(Color.CORAL); arc.setStrokeType(StrokeType.INSIDE); arc.setFill(null); stage.setScene(new Scene(new Group(arc), 100, 80)); stage.show(); } public static void main(String[] args) { launch(args); } }
private static Arc createArc(double radius, double centerX, double centerY, double fromAngle, double toAngle, Paint stroke, double strokeWidth) { Arc arc = new Arc(centerX, centerY, radius, radius, fromAngle, toAngle - fromAngle); arc.setFill(null); arc.setStroke(stroke); arc.setStrokeWidth(strokeWidth); return arc; } @Override public void start(Stage primaryStage) { Pane pane = new Pane( createArc(50, 60, 60, 90, 315, Color.BLUE, 10), // part of the blue ring containing part covered by yellow createArc(50, 110, 110, 0, 360, Color.YELLOW, 10), createArc(50, 60, 60, -45, 90, Color.BLUE, 10) // part covering the yellow ring ); Scene scene = new Scene(pane); primaryStage.setScene(scene); primaryStage.show(); }
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));