1  import javafx.application.Application;
  2  import javafx.scene.Scene;
  3  import javafx.scene.layout.Pane;
  4  import javafx.scene.shape.Line;
  5  import javafx.scene.text.Text;
  6  import javafx.scene.shape.Polyline;
  7  import javafx.stage.Stage;
  8  
  9  public class ScaleDemo extends Application {
 10    @Override // Override the start method in the Application class
 11    public void start(Stage primaryStage) {  
 12      // Create a polyline to draw a sine curve
 13      Polyline polyline = new Polyline();
 14      for (double angle = -360; angle <= 360; angle++) {
 15        polyline.getPoints().addAll(
 16          angle, Math.sin(Math.toRadians(angle)));
 17      }
 18      polyline.setTranslateY(100);
 19      polyline.setTranslateX(200);
 20      polyline.setScaleX(0.5);
 21      polyline.setScaleY(50); 
 22      polyline.setStrokeWidth(1.0 / 25);
 23      
 24      // Draw x-axis 
 25      Line line1 = new Line(10, 100, 420, 100);
 26      Line line2 = new Line(420, 100, 400, 90);
 27      Line line3 = new Line(420, 100, 400, 110);
 28  
 29      // Draw y-axis
 30      Line line4 = new Line(200, 10, 200, 200);
 31      Line line5 = new Line(200, 10, 190, 30);
 32      Line line6 = new Line(200, 10, 210, 30);
 33  
 34      // Draw x, y axis labels
 35      Text text1 = new Text(380, 70, "X");
 36      Text text2 = new Text(220, 20, "Y");    
 37      
 38      // Add nodes to a pane
 39      Pane pane = new Pane();
 40      pane.getChildren().addAll(polyline, line1, line2, line3, line4,
 41        line5, line6, text1, text2);
 42  
 43      Scene scene = new Scene(pane, 450, 200);           
 44      primaryStage.setTitle("ScaleDemo"); // Set the window title
 45      primaryStage.setScene(scene); // Place the scene in the window
 46      primaryStage.show(); // Display the window
 47    }
 48  
 49    // Lauch the program from command-line
 50    public static void main(String[] args) {
 51      launch(args);
 52    }
 53  }