Source of ShowArc.java


  1: 
  2: import javafx.application.Application;
  3: import javafx.scene.Scene;
  4: import javafx.scene.Group;
  5: import javafx.scene.layout.BorderPane;
  6: import javafx.scene.paint.Color;
  7: import javafx.stage.Stage;
  8: import javafx.scene.shape.Arc;
  9: import javafx.scene.shape.ArcType;
 10: import javafx.scene.text.Text;
 11: 
 12: public class ShowArc extends Application {
 13:   @Override // Override the start method in the Application class
 14:   public void start(Stage primaryStage) {
 15:     Arc arc1 = new Arc(150, 100, 80, 80, 30, 35); // Create an arc
 16:     arc1.setFill(Color.RED); // Set fill color
 17:     arc1.setType(ArcType.ROUND); // Set arc type
 18: 
 19:     Arc arc2 = new Arc(150, 100, 80, 80, 30 + 90, 35);
 20:     arc2.setFill(Color.WHITE);
 21:     arc2.setType(ArcType.OPEN);
 22:     arc2.setStroke(Color.BLACK);
 23: 
 24:     Arc arc3 = new Arc(150, 100, 80, 80, 30 + 180, 35);
 25:     arc3.setFill(Color.WHITE);
 26:     arc3.setType(ArcType.CHORD);
 27:     arc3.setStroke(Color.BLACK);
 28: 
 29:     Arc arc4 = new Arc(150, 100, 80, 80, 30 + 270, 35);
 30:     arc4.setFill(Color.GREEN);
 31:     arc4.setType(ArcType.CHORD);
 32:     arc4.setStroke(Color.BLACK);
 33: 
 34:     // Create a group and add nodes to the group
 35:     Group group = new Group();
 36:     group.getChildren().addAll(new Text(210, 40, "arc1: round"),
 37:       arc1, new Text(20, 40, "arc2: open"), arc2,
 38:       new Text(20, 170, "arc3: chord"), arc3,
 39:       new Text(210, 170, "arc4: chord"), arc4);
 40: 
 41:     // Create a scene and place it in the stage
 42:     Scene scene = new Scene(new BorderPane(group), 300, 200);
 43:     primaryStage.setTitle("ShowArc"); // Set the stage title
 44:     primaryStage.setScene(scene); // Place the scene in the stage
 45:     primaryStage.show(); // Display the stage
 46:   }
 47: 
 48:   /**
 49:    * The main method is only needed for the IDE with limited
 50:    * JavaFX support. Not needed for running from the command line.
 51:    */
 52:   public static void main(String[] args) {
 53:     launch(args);
 54:   }
 55: }