75 lines
2.9 KiB
Java
75 lines
2.9 KiB
Java
/* Copyright (c) 2017 Christopher Cromer
|
|
* Copyright (c) 2017 Carlos Faúndez
|
|
*
|
|
* This file is part of mt. It is subject to the license terms in the LICENSE file found in the top-level directory of this distribution.
|
|
* This file may not be copied, modified, propagated, or distributed except according to the terms contained in the LICENSE file.
|
|
*/
|
|
|
|
package mt;
|
|
|
|
import javafx.application.Application;
|
|
import javafx.event.EventHandler;
|
|
import javafx.scene.Group;
|
|
import javafx.scene.Scene;
|
|
import javafx.scene.control.Button;
|
|
import javafx.stage.FileChooser;
|
|
import javafx.stage.Stage;
|
|
import javafx.scene.input.MouseEvent;
|
|
|
|
import org.w3c.dom.Document;
|
|
|
|
import java.io.File;
|
|
|
|
/**
|
|
* Esta clase es la clase princial de la Maquina Turing
|
|
*/
|
|
public class MT extends Application {
|
|
|
|
/**
|
|
* Metodo de JavaFX llamada para generar el interfaz grafico.
|
|
* @param primaryStage La ventana principal
|
|
* @throws Exception La excepción
|
|
*/
|
|
@Override
|
|
public void start(final Stage primaryStage) throws Exception{
|
|
//Parent root = FXMLLoader.load(getClass().getResource("mt.fxml"));
|
|
Group root = new Group();
|
|
primaryStage.setTitle("Maquina de Turing");
|
|
primaryStage.setScene(new Scene(root, 300, 275));
|
|
Button button = new Button("Elegir archivo");
|
|
button.setDefaultButton(true);
|
|
button.setLayoutX(130);button.setLayoutY(125);
|
|
EventHandler<MouseEvent> eventHandler = new EventHandler<MouseEvent>() {
|
|
@Override
|
|
public void handle(MouseEvent event) {
|
|
FileChooser fileChooser = new FileChooser();
|
|
fileChooser.setTitle("Abrir archivo XML");
|
|
File archivo = fileChooser.showOpenDialog(primaryStage);
|
|
LeerXML xml = new LeerXML();
|
|
Document document = xml.leerArchivo(archivo);
|
|
if (document != null) {
|
|
System.out.println(document.getDocumentElement().getNodeName());
|
|
for(int i=0;i<document.getElementsByTagName("transicion").getLength();i++){
|
|
System.out.println("("+document.getElementsByTagName("qi").item(i).getTextContent()+","+
|
|
document.getElementsByTagName("si").item(i).getTextContent()+") = ("+
|
|
document.getElementsByTagName("qj").item(i).getTextContent()+","+
|
|
document.getElementsByTagName("sj").item(i).getTextContent()+","+
|
|
document.getElementsByTagName("movimiento").item(i).getTextContent()+")");
|
|
}//Ciclo base para obtener la función completa de las transiciones
|
|
}
|
|
}
|
|
};
|
|
button.addEventFilter(MouseEvent.MOUSE_CLICKED,eventHandler);
|
|
root.getChildren().add(button);
|
|
primaryStage.show();
|
|
}
|
|
|
|
/**
|
|
* El metodo principal del programa
|
|
* @param args Los argumentos pasado al programa
|
|
*/
|
|
public static void main(String[] args) {
|
|
launch(args);
|
|
}
|
|
}
|