package edu.bloomu.ch3b;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Ellipse;
import javafx.scene.shape.Polygon;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
 * Draws a confused Java programmer (wearing a dunce cap).
 *
 * @author Drue Coles
 */
public class JavaDunce extends Application {

    @Override
    public void start(Stage stage) {
        Pane root = new Pane();
        final int width = 500;
        final int height = 450;
        Scene scene = new Scene(root, width, height, Color.THISTLE);

        Circle head = new Circle(250, 270, 110);
        head.setFill(Color.PLUM.darker());

        // color used for eyes, mouth, dunce cap, and text
        Color color = new Color(0.40, 0.2, 0.2, 1);

        Ellipse mouth = new Ellipse(250, 340, 40, 15);
        mouth.setFill(color);

        Circle leftEye = new Circle(210, 250, 12, color);
        Circle rightEye = new Circle(290, 250, 12, color);       

        // dunce cap (an isosceles triangle drawn on top of the head)
        Polygon cap = new Polygon(150, 220, 350, 220, 250, 10);
        cap.setFill(color);

        // caption at bottom of scene
        Text caption = new Text(20, 430, "public static void main");
        caption.setFill(color);
        Font textFont = Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 36);
        caption.setFont(textFont);
         
        // two large question marks on either side of the head
        Text q1 = new Text(50, 175, "?");
        Text q2 = new Text(400, 175, "?");
        Font qMarkFont = Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 100);
       
        q1.setFont(qMarkFont);
        q1.setFill(color);
        q1.setRotate(-30);
        
        q2.setFont(qMarkFont);
        q2.setFill(color);
        q2.setRotate(30);

        root.getChildren().addAll(head, cap, mouth, leftEye, rightEye, caption, q1, q2);
        stage.setTitle("Java Dunce");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}