package depart.frontal.vues;

import ca.ntro.app.frontend.ViewFx;
import javafx.scene.input.KeyEvent;

public class VueRacine extends ViewFx {
	
	private final double CONST_A = 14;
	
	private double attrA = 1.1;
	private double attrB = CONST_A;

	@Override
	public void initialize() {
		rootNode().setStyle("-fx-font-size:"+CONST_A+"px;");
	}

	public void methodeA(ViewFx paramA) {
		rootNode().getChildren().clear();
		rootNode().getChildren().add(paramA.rootNode());
		
		rootNode().addEventFilter(KeyEvent.KEY_PRESSED, evtFx -> {

			switch(evtFx.getCode()) {

				case EQUALS:
					attrB *= attrA;
					rootNode().setStyle("-fx-font-size:"+attrB+"px;");
					break;

				case MINUS:
					attrB /= attrA;
					rootNode().setStyle("-fx-font-size:"+attrB+"px;");
					break;
					
					
				case DIGIT0:
					attrB = CONST_A;
					rootNode().setStyle("-fx-font-size:"+attrB+"px;");
					break;
					
				default: 
					break;
			}

		});
	}
}
