package meerkat.voting.gui.controllersFX;

/**
 * Created by Laura on 01/12/2017.
 */
import javafx.embed.swing.SwingFXUtils;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import meerkat.voting.gui.ui.CommandPend;
import meerkat.voting.gui.ui.uicommands.UICommand;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;

/**
 * Main controller class for the entire layout.
 */
public class PrinterController {

    /** Holder of vista. */
    @FXML
    private VBox vBox;
    @FXML
    private Text content;


    public void clean() {
        vBox.getChildren().clear();
    }

    public void addContent(String s) {
        Text txt = new Text(s);
        vBox.getChildren().add(txt);
        vBox.getScene().getWindow().sizeToScene();
    }

    public void addContent(BufferedImage i) {
        ImageView imageView = new ImageView();
        Image image = SwingFXUtils.toFXImage(i, null);
        imageView.setImage(image);
        vBox.getChildren().add(imageView);
//        String old_content = content.getText();
//        content.setText(old_content+"\n"+s);
        vBox.getScene().getWindow().sizeToScene();
    }

}