package project_3;

import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Paint;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class MainScene {

   /*This class  is the Main Scene of GUI*/

	private LinkedList<Country> countryList;
	private HashTable table;
	
	private Stage stage = new Stage();
	private GridPane pane =new GridPane();
	
	private RadioButton countries = new RadioButton("print Countries Information ");
	private RadioButton hash = new RadioButton("Print Hash Table Information ");
	private ToggleGroup tg = new ToggleGroup();
	private TreeNode<Country> root;
	
	Button submit =new Button("Submit"); 
	
	private Label nam = new Label("Mohammad Nabil");
	private int count;



	public MainScene(LinkedList<Country> countryList, HashTable table, TreeNode<Country> root,int count) {
		this.countryList = countryList;
		this.table = table;
		this.root=root;
		this.count=count;
	}



	public void show(){

		Text title = new Text("Choose One Of These  :");
		title.setFill(Paint.valueOf("#FF0000"));
		title.setFont(Font.font("verdana",FontWeight.BOLD,24));

		countries.setToggleGroup(tg);
		hash.setToggleGroup(tg);

		hash.setStyle("-fx-font-size:24px;");
		countries.setStyle("-fx-font-size:24px;");
		countries.setTextFill(Paint.valueOf("gold"));
		hash.setTextFill(Paint.valueOf("gold"));

		submit.setStyle("-fx-font-size:20px;");
		

		submit.setOnAction(e->{
			if(countries.isSelected()){
				new PrintCountries(countryList,root,count).show();
			}
			if(hash.isSelected()){
				new PrintHash(table).show();
			}
		});

		

		pane.setAlignment(Pos.CENTER);
		pane.setHgap(15);
		pane.setVgap(15);

		nam.setTextFill(Paint.valueOf("#c0e51b"));
		nam.setFont(Font.font("algerian",FontWeight.BOLD,15));

		pane.add(title, 0, 0);
		pane.add(countries,0, 1);
		pane.add(hash, 0, 2);
		pane.add(submit, 2, 3);
		
		pane.add(nam, 0, 5);

		Scene s = new Scene(pane,600,400);
		s.getStylesheets().addAll(this.getClass().getResource("application.css").toExternalForm());
		stage.setScene(s);
		stage.setTitle("Welcome :)");
		stage.show();

	}
}