Estructuras de Datos
-
+
+
+ Estructuras de Datos 1.0.2 (14/08/2016) The webstart and embedded verions require java 8 to run! It is also necessary to add cromer.cl to your trusted sites in java settings because the java applet is unsigned.
- Windows:click to download windows binary
- Linux:click to download linux binary
+ Windows:click to download windows binary
+ Linux:click to download linux binary Webstart:click to launch this app as webstart Embedded:click to launch this app as embedded app Source code:github
diff --git a/src/cl/cromer/estructuras/Colores.java b/src/cl/cromer/estructuras/Colores.java
index 16b5abd..3adfde6 100644
--- a/src/cl/cromer/estructuras/Colores.java
+++ b/src/cl/cromer/estructuras/Colores.java
@@ -3,6 +3,7 @@ package cl.cromer.estructuras;
import javafx.scene.paint.Color;
import java.util.Random;
+import java.util.prefs.Preferences;
/**
* Rotación y generación de colores.
@@ -46,6 +47,19 @@ public class Colores {
* Cambiar el color al siguinte. Si no hay, voler al primer.
*/
public void siguinteColor() {
+
+ int colorsToUse;
+ Preferences preferences = (Preferences) Main.stage.getUserData();
+ if (preferences != null) {
+ colorsToUse = preferences.getInt("colors", MAX_COLORS);
+ }
+ else {
+ colorsToUse = MAX_COLORS;
+ }
+ if (colorsToUse <= color) {
+ color = 0;
+ }
+
switch (color) {
case 1:
color = 2;
diff --git a/src/cl/cromer/estructuras/ConfigController.java b/src/cl/cromer/estructuras/ConfigController.java
new file mode 100644
index 0000000..b8246c2
--- /dev/null
+++ b/src/cl/cromer/estructuras/ConfigController.java
@@ -0,0 +1,79 @@
+package cl.cromer.estructuras;
+
+import javafx.fxml.FXML;
+import javafx.fxml.Initializable;
+import javafx.scene.control.ComboBox;
+import javafx.stage.Stage;
+
+import java.net.URL;
+import java.util.ResourceBundle;
+import java.util.prefs.Preferences;
+
+/**
+ * Esta clase es para controlar la configuración.
+ *
+ * @author Chris Cromer
+ */
+public class ConfigController implements Initializable {
+ /**
+ * El color ComboBox.
+ */
+ @FXML
+ private ComboBox colors;
+
+ /**
+ * Donde está guardado los idiomas.
+ */
+ private ResourceBundle resourceBundle;
+
+ /**
+ * Inicializar todos los datos y dibujar las graficas.
+ *
+ * @param location URL: El URL de fxml en uso.
+ * @param resourceBundle ResourceBundle: Tiene datos de idioma.
+ */
+ @Override
+ public void initialize(URL location, ResourceBundle resourceBundle) {
+ this.resourceBundle = resourceBundle;
+ }
+
+ /**
+ * Guardar los colores maximo a usar.
+ */
+ @FXML
+ protected void changeColor() {
+ Stage stage = (Stage) colors.getScene().getWindow();
+ Preferences preferences = (Preferences) stage.getScene().getUserData();
+ if (preferences != null) {
+ preferences.putInt("colors", colors.getValue());
+ }
+ }
+
+ /**
+ * Cerrar la venta de configuración.
+ */
+ @FXML
+ protected void closeConfig() {
+ Stage stage = (Stage) colors.getScene().getWindow();
+ stage.close();
+ }
+
+ /**
+ * Este metodo es para el evento de windowshown.
+ */
+ public void handleWindowShownEvent() {
+ Stage stage = (Stage) colors.getScene().getWindow();
+ Preferences preferences = (Preferences) stage.getScene().getUserData();
+
+ for (int i = 2; i <= Colores.MAX_COLORS; i++) {
+ colors.getItems().add(i);
+ }
+
+ if (preferences != null) {
+ colors.setValue(preferences.getInt("colors", Colores.MAX_COLORS));
+ }
+ else {
+ colors.setValue(Colores.MAX_COLORS);
+ }
+ }
+}
diff --git a/src/cl/cromer/estructuras/Grafo.java b/src/cl/cromer/estructuras/Grafo.java
index 7b0dd66..3c6e909 100644
--- a/src/cl/cromer/estructuras/Grafo.java
+++ b/src/cl/cromer/estructuras/Grafo.java
@@ -241,7 +241,7 @@ public class Grafo {
}
}
- /*
+ /**
* JBoss, Home of Professional Open Source Copyright 2006, Red Hat Middleware
* LLC, and individual contributors by the @authors tag. See the copyright.txt
* in the distribution for a full listing of individual contributors.
diff --git a/src/cl/cromer/estructuras/Main.java b/src/cl/cromer/estructuras/Main.java
index 0880a3b..dcdf506 100644
--- a/src/cl/cromer/estructuras/Main.java
+++ b/src/cl/cromer/estructuras/Main.java
@@ -27,6 +27,12 @@ import java.util.prefs.Preferences;
* @version 1.0.2
*/
public class Main extends Application {
+ static public String VERSION = "1.0.2";
+
+ /**
+ * El stage pricipal
+ */
+ static public Stage stage;
/**
* El logger.
*/
@@ -35,10 +41,11 @@ public class Main extends Application {
/**
* Crear el stage y la scene para la aplicación grafica.
*
- * @param stage Stage: El primer stage donde va todas las cosas visuales.
+ * @param startStage Stage: El primer stage donde va todas las cosas visuales.
*/
@Override
- public void start(Stage stage) {
+ public void start(Stage startStage) {
+ stage = startStage;
String idioma;
String idioma2;
Preferences preferences;
diff --git a/src/cl/cromer/estructuras/MenuController.java b/src/cl/cromer/estructuras/MenuController.java
index 4408264..60cbfce 100644
--- a/src/cl/cromer/estructuras/MenuController.java
+++ b/src/cl/cromer/estructuras/MenuController.java
@@ -9,8 +9,11 @@ import javafx.scene.control.ButtonBar;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.MenuBar;
+import javafx.scene.image.Image;
import javafx.scene.layout.VBox;
+import javafx.stage.Modality;
import javafx.stage.Stage;
+import javafx.stage.WindowEvent;
import java.io.IOException;
import java.net.URL;
@@ -348,6 +351,47 @@ public class MenuController extends VBox implements Initializable {
}
}
+ /**
+ * Click en Configuración
+ */
+ @FXML
+ protected void menuConfig() {
+ Preferences preferences = (Preferences) Main.stage.getUserData();
+ if (preferences != null) {
+ Stage configStage = new Stage();
+ configStage.initModality(Modality.WINDOW_MODAL);
+ // Main is the daddy
+ configStage.initOwner(Main.stage);
+
+ try {
+ FXMLLoader fxmlLoader = new FXMLLoader();
+ fxmlLoader.setLocation(getClass().getResource("/cl/cromer/estructuras/fxml/config.fxml"));
+ fxmlLoader.setResources(this.resourceBundle);
+ Parent parent = fxmlLoader.load();
+
+ Scene scene = new Scene(parent);
+ scene.setUserData(preferences);
+ scene.getStylesheets().add("/cl/cromer/estructuras/css/main.css");
+ configStage.setScene(scene);
+
+ configStage.setTitle(this.resourceBundle.getString("config"));
+
+ configStage.getIcons().add(new Image(getClass().getResourceAsStream("/cl/cromer/estructuras/images/icon.png")));
+ final ConfigController configController = fxmlLoader.getController();
+ configStage.addEventHandler(WindowEvent.WINDOW_SHOWN, window -> configController.handleWindowShownEvent());
+ configStage.show();
+ }
+ catch (IOException exception) {
+ // Este error es fatal, hay que cerrar la aplicación.
+ Logs.log(Level.SEVERE, exception);
+ configStage.close();
+ }
+ }
+ else {
+ Main.mostrarError(resourceBundle.getString("configNotAvailable"), resourceBundle);
+ }
+ }
+
/**
* Click en Acerca.
*/
@@ -356,7 +400,7 @@ public class MenuController extends VBox implements Initializable {
ButtonType botonCerrar = new ButtonType(resourceBundle.getString("cerrar"), ButtonBar.ButtonData.OK_DONE);
Dialog dialog = new Dialog<>();
dialog.setTitle(resourceBundle.getString("acerca"));
- dialog.setContentText(resourceBundle.getString("credito"));
+ dialog.setContentText(resourceBundle.getString("titulo") + " " + Main.VERSION + "\n\n" +resourceBundle.getString("credito"));
dialog.getDialogPane().getButtonTypes().add(botonCerrar);
dialog.getDialogPane().getScene().getWindow().sizeToScene();
Main.setIcon(dialog, getClass());
diff --git a/src/cl/cromer/estructuras/Palabras.java b/src/cl/cromer/estructuras/Palabras.java
index e8b24b8..aa1292e 100644
--- a/src/cl/cromer/estructuras/Palabras.java
+++ b/src/cl/cromer/estructuras/Palabras.java
@@ -4,9 +4,17 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
+/**
+ * Esta clase es una colleción de palabaras que se puede mostrar al azar.
+ *
+ * @author Chris Cromer
+ */
public class Palabras {
final private List palabras;
+ /**
+ * Inicilizar la lista de palabras.
+ */
public Palabras() {
palabras = new ArrayList<>();
palabras.add("hola");
@@ -57,6 +65,11 @@ public class Palabras {
palabras.add("no");
}
+ /**
+ * Devolver una palabra al azar.
+ *
+ * @return String: La palabra.
+ */
public String getPalabra() {
Random random = new Random();
int numero = random.nextInt(palabras.size());
diff --git a/src/cl/cromer/estructuras/bundles/Idioma_en.properties b/src/cl/cromer/estructuras/bundles/Idioma_en.properties
index 66727d3..102948a 100644
--- a/src/cl/cromer/estructuras/bundles/Idioma_en.properties
+++ b/src/cl/cromer/estructuras/bundles/Idioma_en.properties
@@ -51,6 +51,7 @@ ingles=English
espanol=Spanish
cambiarIdioma=Change Language
cambiarIdiomaMensaje=To change the language the program must be restarted.\n\nAre you sure you wish the restart?
+config=Settings
ayuda=Help
acerca=About
credito=Made by Christopher Cromer(chris@cromer.cl)\nCivil Engineering in Computer Science\nUniversity of the B\u00EDo B\u00EDo
@@ -112,4 +113,8 @@ grafoNoNumero=Please input a numeric node number.
tablaHashLleno=Key not inserted because the hash table is full.
tablaHashLlaveExiste=Key already exists.
tablaHashNoEsta=Key does not exist.
-tablaHashNoLlave=Please input a key and a numeric value.
\ No newline at end of file
+tablaHashNoLlave=Please input a key and a numeric value.
+
+configNotAvailable=Settings is not avilable in the web version.
+configColores=Colors:
+configGuardar=Save
\ No newline at end of file
diff --git a/src/cl/cromer/estructuras/bundles/Idioma_es.properties b/src/cl/cromer/estructuras/bundles/Idioma_es.properties
index 00e5af4..7f1a4d4 100644
--- a/src/cl/cromer/estructuras/bundles/Idioma_es.properties
+++ b/src/cl/cromer/estructuras/bundles/Idioma_es.properties
@@ -51,6 +51,7 @@ espanol=Espa\u00F1ol
cambiarIdioma=Cambiar Idioma
cambiarIdiomaMensaje=Para cambiar el idioma el programa debe reiniciarse.\n\nUsted est\u00E1 seguro que desea reiniciar?
ayuda=Ayuda
+config=Configuraci\u00F3n
acerca=Acerca
credito=Construido por Christopher Cromer\nIngenier\u00EDa Civil en Inform\u00E1tica\nUniversidad del B\u00EDo B\u00EDo
cambiar=Cambiar
@@ -111,4 +112,8 @@ grafoNoNumero=Ingresar un nodo num\u00E9rico por favor.
tablaHashLleno=La llave no fue insertado porque la tabla hash est\u00E1 lleno.
tablaHashLlaveExiste=La llave ya existe.
tablaHashNoEsta=La llave no existe.
-tablaHashNoLlave=Ingresar una llave y un valor num\u00E9rico por favor.
\ No newline at end of file
+tablaHashNoLlave=Ingresar una llave y un valor num\u00E9rico por favor.
+
+configNotAvailable=Configuraci\u00F3n no está disponible en la versi\u00F3n web.
+configColores=Colores:
+configGuardar=Guardar
\ No newline at end of file
diff --git a/src/cl/cromer/estructuras/fxml/config.fxml b/src/cl/cromer/estructuras/fxml/config.fxml
new file mode 100644
index 0000000..65c5c6d
--- /dev/null
+++ b/src/cl/cromer/estructuras/fxml/config.fxml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/cl/cromer/estructuras/fxml/menu.fxml b/src/cl/cromer/estructuras/fxml/menu.fxml
index ddb38e3..eb71e2a 100644
--- a/src/cl/cromer/estructuras/fxml/menu.fxml
+++ b/src/cl/cromer/estructuras/fxml/menu.fxml
@@ -43,6 +43,7 @@
\ No newline at end of file