Agregar icono y clonear la maquina

This commit is contained in:
Chris Cromer 2017-07-03 16:53:28 -04:00
parent 5ee076eb53
commit ad0ca3738a
10 changed files with 103 additions and 31 deletions

View File

@ -1,15 +0,0 @@
<component name="ArtifactManager">
<artifact type="javafx" name="JavaFXApp">
<output-path>$PROJECT_DIR$/out/artifacts/JavaFXApp</output-path>
<properties id="javafx-properties">
<options>
<option name="appClass" value="sample.Main" />
</options>
</properties>
<root id="root">
<element id="archive" name="JavaFXApp.jar">
<element id="module-output" name="Fundamentos" />
</element>
</root>
</artifact>
</component>

View File

@ -0,0 +1,22 @@
<component name="ArtifactManager">
<artifact type="javafx" name="MaquinaTuring">
<output-path>$PROJECT_DIR$/out/artifacts/MaquinaTuring</output-path>
<properties id="javafx-properties">
<options>
<option name="appClass" value="mt.MT" />
<option name="description" value="" />
<option name="height" value="480" />
<option name="htmlPlaceholderId" value="" />
<option name="title" value="Maquina Turning" />
<option name="vendor" value="" />
<option name="version" value="" />
<option name="width" value="640" />
</options>
</properties>
<root id="root">
<element id="archive" name="JavaFXApp.jar">
<element id="module-output" name="Fundamentos" />
</element>
</root>
</artifact>
</component>

View File

@ -1,25 +1,78 @@
/* 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; package mt;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class LoteController { /**
* Controlar las acciones de reconocimiento por lote
*/
public class LoteController extends VBox {
@FXML @FXML
private VBox vboxLote; private VBox vboxLote;
@FXML
private TextField cadena;
private ObservableList<TablaData> tablaData = FXCollections.observableArrayList();
/** /**
* Boton Run MT de lote * Boton de run MT
* @throws Exception La excepción
*/ */
@FXML @FXML
protected void runLote() throws Exception { protected void runLote() throws Exception {
Scene scene = vboxLote.getScene(); Scene scene = vboxLote.getScene();
Maquina maquina = (Maquina) scene.getUserData(); Maquina maquina = (Maquina) scene.getUserData();
if (maquina.comprobarCadena(new StringBuilder("000111###"), 5)) { for (TablaData fila : tablaData) {
MT.mostrarMensaje("Resultado", "Reconce"); Maquina clone = maquina.clone();
boolean exito = clone.comprobarCadena(new StringBuilder(fila.getPrimer()), new int[] {5});
if (exito) {
fila.setSegundo("Aceptada");
} }
else { else {
MT.mostrarMensaje("Resultado", " No reconce"); fila.setSegundo("Rechazada");
} }
} }
}
/**
* Boton de agregar cadena
*/
@FXML
protected void agregarCadena() {
if (!cadena.getText().trim().equals("")) {
tablaData.add(new TablaData(cadena.getText(), ""));
Scene scene = vboxLote.getScene();
@SuppressWarnings("unchecked")
TableView<TablaData> tableView = (TableView<TablaData>) scene.lookup("#tableView");
tableView.setEditable(true);
tableView.setItems(tablaData);
}
else {
MT.mostrarMensaje("Error", "Ingresa una cadena por favor!");
}
}
/**
* Boton de cerrar
*/
@FXML
protected void cerrar() {
Scene scene = vboxLote.getScene();
Stage stage = (Stage) scene.getWindow();
stage.close();
}
} }

View File

@ -14,6 +14,7 @@ import javafx.scene.Scene;
import javafx.scene.control.ButtonBar; import javafx.scene.control.ButtonBar;
import javafx.scene.control.ButtonType; import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog; import javafx.scene.control.Dialog;
import javafx.scene.image.Image;
import javafx.stage.Stage; import javafx.stage.Stage;
/** /**
@ -60,6 +61,7 @@ public class MT extends Application {
primaryStage.setScene(scene); primaryStage.setScene(scene);
primaryStage.setMinHeight(480); primaryStage.setMinHeight(480);
primaryStage.setMinWidth(640); primaryStage.setMinWidth(640);
primaryStage.getIcons().add(new Image(getClass().getResourceAsStream("/mt/images/icon.png")));
primaryStage.show(); primaryStage.show();
} }
} }

View File

@ -9,8 +9,8 @@ package mt;
import org.w3c.dom.Document; import org.w3c.dom.Document;
class Maquina { class Maquina implements Cloneable {
private final Automata maquina; private Automata maquina;
private Estado estadoactual; private Estado estadoactual;
private Enlace enlaceactual; private Enlace enlaceactual;
private String cintaanterior; private String cintaanterior;
@ -22,6 +22,21 @@ class Maquina {
cintaanterior = ""; cintaanterior = "";
} }
@Override
public Maquina clone() {
try {
final Maquina result = (Maquina) super.clone();
result.maquina = this.maquina;
result.estadoactual = this.estadoactual;
result.enlaceactual = this.enlaceactual;
result.cintaanterior = this.cintaanterior;
return result;
}
catch (final CloneNotSupportedException e) {
throw new AssertionError();
}
}
Automata getMaquina() {return maquina;} Automata getMaquina() {return maquina;}
public Estado getEstadoactual() {return estadoactual;} public Estado getEstadoactual() {return estadoactual;}

View File

@ -18,6 +18,7 @@ import javafx.scene.control.MenuItem;
import javafx.scene.control.TableColumn; import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView; import javafx.scene.control.TableView;
import javafx.scene.control.cell.TextFieldTableCell; import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.image.Image;
import javafx.scene.layout.Priority; import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
@ -102,13 +103,6 @@ public class MenuController {
tableView.getColumns().get(1).setText("(qj,sj,movimiento)"); tableView.getColumns().get(1).setText("(qj,sj,movimiento)");
contenido.getChildren().add(tableView); contenido.getChildren().add(tableView);
/*if (maquina.comprobarCadena(new StringBuilder("000111###"), 5)) {
MT.mostrarMensaje("Resultado", "Reconce");
}
else {
MT.mostrarMensaje("Resultado", " No reconce");
}*/
} }
} }
@ -141,6 +135,7 @@ public class MenuController {
stage.setMinHeight(480); stage.setMinHeight(480);
stage.setMinWidth(640); stage.setMinWidth(640);
stage.setScene(scene); stage.setScene(scene);
stage.getIcons().add(new Image(getClass().getResourceAsStream("/mt/images/icon.png")));
stage.show(); stage.show();
TableView<TablaData> tableView = FXMLLoader.load(getClass().getResource("tabla.fxml")); TableView<TablaData> tableView = FXMLLoader.load(getClass().getResource("tabla.fxml"));

BIN
src/mt/images/UBBLogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

BIN
src/mt/images/icon.icns Normal file

Binary file not shown.

BIN
src/mt/images/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

BIN
src/mt/images/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB