Added a more robust hightlight functionality.
Added Hash Tables. Updated docs.
This commit is contained in:
@@ -227,7 +227,8 @@ public class ArrayController implements Initializable {
|
||||
if (encontrado != -1) {
|
||||
generarGrafico();
|
||||
grafico = new Grafico(scene);
|
||||
grafico.destacar(encontrado, Grafico.RECTANGULO);
|
||||
grafico.destacar("#caja_" + encontrado, Grafico.RECTANGULO);
|
||||
grafico.destacar("#texto_" + encontrado, Grafico.TEXTO);
|
||||
}
|
||||
else {
|
||||
errorNoEsta();
|
||||
@@ -289,7 +290,7 @@ public class ArrayController implements Initializable {
|
||||
private void generarGrafico() {
|
||||
grafico.removerDestacar();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Text text = (Text) scene.lookup("#caja_" + String.valueOf(i));
|
||||
Text text = (Text) scene.lookup("#texto_" + String.valueOf(i));
|
||||
text.setText(array.getIndice(i));
|
||||
}
|
||||
}
|
||||
|
@@ -172,7 +172,7 @@ public class BurbujaController implements Initializable {
|
||||
*/
|
||||
private void generarGrafico() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Text text = (Text) scene.lookup("#caja_" + String.valueOf(i));
|
||||
Text text = (Text) scene.lookup("#texto_" + String.valueOf(i));
|
||||
text.setText(array.getIndice(i));
|
||||
}
|
||||
}
|
||||
|
@@ -203,7 +203,8 @@ public class ColaController implements Initializable {
|
||||
int encontrado = cola.peek();
|
||||
if (encontrado != Integer.MIN_VALUE) {
|
||||
generarGrafico();
|
||||
grafico.destacar(0, Grafico.RECTANGULO);
|
||||
grafico.destacar("#caja_" + 0, Grafico.RECTANGULO);
|
||||
grafico.destacar("#texto_" + 0, Grafico.TEXTO);
|
||||
}
|
||||
else {
|
||||
errorVacia();
|
||||
@@ -242,7 +243,7 @@ public class ColaController implements Initializable {
|
||||
private void generarGrafico() {
|
||||
grafico.removerDestacar();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Text text = (Text) scene.lookup("#caja_" + String.valueOf(i));
|
||||
Text text = (Text) scene.lookup("#texto_" + String.valueOf(i));
|
||||
text.setText(cola.getIndice(i));
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,9 @@ package cl.cromer.estructuras;
|
||||
import javafx.animation.Animation;
|
||||
import javafx.animation.PauseTransition;
|
||||
import javafx.animation.SequentialTransition;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.paint.Color;
|
||||
@@ -14,45 +16,39 @@ import javafx.scene.shape.Rectangle;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.util.Duration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Esta clase es para trabajar con graficos.
|
||||
*
|
||||
* @author Chris Cromer
|
||||
*/
|
||||
public class Grafico {
|
||||
/**
|
||||
* Duración de la animación.
|
||||
*/
|
||||
static final public int DURACION = 150;
|
||||
/**
|
||||
* Tipo de dibujo rectuangular.
|
||||
*/
|
||||
static final public int RECTANGULO = 0;
|
||||
|
||||
/**
|
||||
* Tipo de dibujo circular.
|
||||
*/
|
||||
static final public int CIRCULO = 1;
|
||||
/**
|
||||
* Tipo de dibjuo texto
|
||||
*/
|
||||
static final public int TEXTO = 2;
|
||||
/**
|
||||
* La escena donde está cosas graficas.
|
||||
*/
|
||||
final private Scene scene;
|
||||
/**
|
||||
* Contiene la animación de destacar.
|
||||
* Los elementos destacados.
|
||||
*/
|
||||
private SequentialTransition blinkTransition;
|
||||
/**
|
||||
* El valor de cual caja está destacado actualmente
|
||||
*/
|
||||
private int destacado;
|
||||
/**
|
||||
* El tipo de objeto que está destacado.
|
||||
*/
|
||||
private int tipo;
|
||||
/**
|
||||
* El color original de fondo para volver cuando no es destacado.
|
||||
*/
|
||||
private Color destacadoBG;
|
||||
/**
|
||||
* El color original de text para volver cuando no es destacado.
|
||||
*/
|
||||
private Color destacadoFG;
|
||||
private List<Destacados> destacados;
|
||||
|
||||
/**
|
||||
* Graficar una escena.
|
||||
@@ -61,7 +57,7 @@ public class Grafico {
|
||||
*/
|
||||
public Grafico(Scene scene) {
|
||||
this.scene = scene;
|
||||
destacado = -1;
|
||||
destacados = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,7 +154,7 @@ public class Grafico {
|
||||
}
|
||||
|
||||
/**
|
||||
* Crear un rectangulo con texto adentro.
|
||||
* Crear un rectangulo.
|
||||
*
|
||||
* @param colores Colores: Los colores para dar color al rectangulo.
|
||||
* @param label String: El texto por el ID de fxml.
|
||||
@@ -170,9 +166,9 @@ public class Grafico {
|
||||
rectangle.setWidth(40);
|
||||
rectangle.setFill(colores.getFondo());
|
||||
rectangle.setStroke(Color.BLACK);
|
||||
rectangle.setId("border_" + label);
|
||||
rectangle.setId("caja_" + label);
|
||||
Text text = new Text();
|
||||
text.setId("caja_" + label);
|
||||
text.setId("texto_" + label);
|
||||
text.setStroke(colores.getTexto());
|
||||
|
||||
StackPane stackPane = new StackPane();
|
||||
@@ -194,9 +190,9 @@ public class Grafico {
|
||||
rectangle.setWidth(40);
|
||||
rectangle.setFill(colores.getFondo());
|
||||
rectangle.setStroke(Color.BLACK);
|
||||
rectangle.setId("border_" + label);
|
||||
rectangle.setId("caja_" + label);
|
||||
Text text = new Text();
|
||||
text.setId("caja_" + label);
|
||||
text.setId("texto_" + label);
|
||||
text.setStroke(colores.getTexto());
|
||||
text.setText(texto);
|
||||
|
||||
@@ -205,21 +201,72 @@ public class Grafico {
|
||||
return stackPane;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crear 3 rectangulos.
|
||||
*
|
||||
* @param colores Colores: Los colores para dar color a los rectangulos.
|
||||
* @param label String: El texto por el ID de fxml.
|
||||
* @return StackPane: Devolver el stackpane que contiene los rectangulos y textos.
|
||||
*/
|
||||
public static StackPane crearHashCajas(Colores colores, String label) {
|
||||
Rectangle rectangle = new Rectangle();
|
||||
rectangle.setHeight(40);
|
||||
rectangle.setWidth(40);
|
||||
rectangle.setFill(colores.getFondo());
|
||||
rectangle.setStroke(Color.BLACK);
|
||||
rectangle.setId("indice_caja_" + label);
|
||||
Text text = new Text();
|
||||
text.setId("indice_texto_" + label);
|
||||
text.setStroke(colores.getTexto());
|
||||
|
||||
StackPane stackPane1 = new StackPane();
|
||||
stackPane1.getChildren().addAll(rectangle, text);
|
||||
|
||||
rectangle = new Rectangle();
|
||||
rectangle.setHeight(40);
|
||||
rectangle.setWidth(120);
|
||||
rectangle.setFill(colores.getFondo());
|
||||
rectangle.setStroke(Color.BLACK);
|
||||
rectangle.setId("llave_caja_" + label);
|
||||
text = new Text();
|
||||
text.setId("llave_texto_" + label);
|
||||
text.setStroke(colores.getTexto());
|
||||
|
||||
StackPane stackPane2 = new StackPane();
|
||||
stackPane2.getChildren().addAll(rectangle, text);
|
||||
|
||||
rectangle = new Rectangle();
|
||||
rectangle.setHeight(40);
|
||||
rectangle.setWidth(40);
|
||||
rectangle.setFill(colores.getFondo());
|
||||
rectangle.setStroke(Color.BLACK);
|
||||
rectangle.setId("valor_caja_" + label);
|
||||
text = new Text();
|
||||
text.setId("valor_texto_" + label);
|
||||
text.setStroke(colores.getTexto());
|
||||
|
||||
StackPane stackPane3 = new StackPane();
|
||||
stackPane3.getChildren().addAll(rectangle, text);
|
||||
|
||||
HBox hBox = new HBox();
|
||||
hBox.getChildren().addAll(stackPane1, stackPane2, stackPane3);
|
||||
hBox.setAlignment(Pos.TOP_CENTER);
|
||||
|
||||
StackPane stackPane = new StackPane();
|
||||
stackPane.getChildren().addAll(hBox);
|
||||
return stackPane;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crear un animacion de transicion usando colores que cambian.
|
||||
*
|
||||
* @param rectangle Rectangle: El objeto que desea animar.
|
||||
* @param text Text: El texto que desea animar.
|
||||
* @param colorBackground Color: Color del fondo de destacar.
|
||||
* @param colorText Color: Color del texto.
|
||||
* @return PauseTransition: La transition creado con los elementos y colores.
|
||||
*/
|
||||
private static PauseTransition createPauseTransition(Rectangle rectangle, Text text, Color colorBackground, Color colorText) {
|
||||
PauseTransition changeColor = new PauseTransition(new Duration(100));
|
||||
changeColor.setOnFinished(actionEvent -> {
|
||||
rectangle.setFill(colorBackground);
|
||||
text.setStroke(colorText);
|
||||
});
|
||||
private static PauseTransition createPauseTransition(Rectangle rectangle, Color colorBackground) {
|
||||
PauseTransition changeColor = new PauseTransition(new Duration(DURACION));
|
||||
changeColor.setOnFinished(actionEvent -> rectangle.setFill(colorBackground));
|
||||
return changeColor;
|
||||
}
|
||||
|
||||
@@ -227,80 +274,157 @@ public class Grafico {
|
||||
* Crear un animacion de transicion usando colores que cambian.
|
||||
*
|
||||
* @param circle Circle: El objeto que desea animar.
|
||||
* @param text Text: El texto que desea animar.
|
||||
* @param colorBackground Color: Color del fondo de destacar.
|
||||
* @return PauseTransition: La transition creado con los elementos y colores.
|
||||
*/
|
||||
private static PauseTransition createPauseTransition(Circle circle, Color colorBackground) {
|
||||
PauseTransition changeColor = new PauseTransition(new Duration(DURACION));
|
||||
changeColor.setOnFinished(actionEvent -> circle.setFill(colorBackground));
|
||||
return changeColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Crear un animacion de transicion usando colores que cambian.
|
||||
*
|
||||
* @param text Text: El texto que desea animar.
|
||||
* @param colorText Color: Color del texto.
|
||||
* @return PauseTransition: La transition creado con los elementos y colores.
|
||||
*/
|
||||
private static PauseTransition createPauseTransition(Circle circle, Text text, Color colorBackground, Color colorText) {
|
||||
PauseTransition changeColor = new PauseTransition(new Duration(100));
|
||||
changeColor.setOnFinished(actionEvent -> {
|
||||
circle.setFill(colorBackground);
|
||||
text.setStroke(colorText);
|
||||
});
|
||||
private static PauseTransition createPauseTransition(Text text, Color colorText) {
|
||||
PauseTransition changeColor = new PauseTransition(new Duration(DURACION));
|
||||
changeColor.setOnFinished(actionEvent -> text.setStroke(colorText));
|
||||
return changeColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destacar un elemento
|
||||
*
|
||||
* @param valor int: El indice a destacar.
|
||||
* @param tipo int: El tipo de objeto a destacar, {@value #RECTANGULO} o {@value #CIRCULO}
|
||||
* @param id int: El indice a destacar.
|
||||
* @param tipo int: El tipo de objeto a destacar, {@value #RECTANGULO}, {@value #CIRCULO} o {@value #TEXTO}
|
||||
*/
|
||||
public void destacar(int valor, int tipo) {
|
||||
if (tipo != RECTANGULO && tipo != CIRCULO) {
|
||||
public void destacar(String id, int tipo) {
|
||||
if (tipo != RECTANGULO && tipo != CIRCULO && tipo != TEXTO) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
this.tipo = tipo;
|
||||
}
|
||||
|
||||
destacado = valor;
|
||||
Colores colores = new Colores();
|
||||
Rectangle rectangle = null;
|
||||
Circle circle = null;
|
||||
if (this.tipo == RECTANGULO) {
|
||||
rectangle = (Rectangle) scene.lookup("#border_" + String.valueOf(valor));
|
||||
destacadoBG = (Color) rectangle.getFill();
|
||||
Text text = null;
|
||||
if (tipo == RECTANGULO) {
|
||||
rectangle = (Rectangle) scene.lookup(id);
|
||||
}
|
||||
else if (this.tipo == CIRCULO) {
|
||||
circle = (Circle) scene.lookup("#border_" + String.valueOf(valor));
|
||||
destacadoBG = (Color) circle.getFill();
|
||||
else if (tipo == CIRCULO) {
|
||||
circle = (Circle) scene.lookup(id);
|
||||
}
|
||||
else {
|
||||
text = (Text) scene.lookup(id);
|
||||
}
|
||||
Text text = (Text) scene.lookup("#caja_" + String.valueOf(valor));
|
||||
destacadoFG = (Color) text.getStroke();
|
||||
PauseTransition changeColor[] = new PauseTransition[Colores.MAX_COLORS];
|
||||
for (int i = 0; i < Colores.MAX_COLORS; i++) {
|
||||
if (this.tipo == RECTANGULO) {
|
||||
changeColor[i] = createPauseTransition(rectangle, text, colores.getFondo(), colores.getTexto());
|
||||
if (tipo == RECTANGULO) {
|
||||
changeColor[i] = createPauseTransition(rectangle, colores.getFondo());
|
||||
}
|
||||
else if (this.tipo == CIRCULO) {
|
||||
changeColor[i] = createPauseTransition(circle, text, colores.getFondo(), colores.getTexto());
|
||||
else if (tipo == CIRCULO) {
|
||||
changeColor[i] = createPauseTransition(circle, colores.getFondo());
|
||||
}
|
||||
else {
|
||||
changeColor[i] = createPauseTransition(text, colores.getTexto());
|
||||
}
|
||||
colores.siguinteColor();
|
||||
}
|
||||
blinkTransition = new SequentialTransition(changeColor);
|
||||
blinkTransition.setCycleCount(Animation.INDEFINITE);
|
||||
blinkTransition.play();
|
||||
|
||||
if (tipo == RECTANGULO) {
|
||||
destacados.add(new Destacados(tipo, id, (Color) rectangle.getFill(), new SequentialTransition(changeColor)));
|
||||
}
|
||||
else if (tipo == CIRCULO) {
|
||||
destacados.add(new Destacados(tipo, id, (Color) circle.getFill(), new SequentialTransition(changeColor)));
|
||||
}
|
||||
else {
|
||||
destacados.add(new Destacados(tipo, id, (Color) text.getStroke(), new SequentialTransition(changeColor)));
|
||||
}
|
||||
|
||||
destacados.get(destacados.size() - 1).getSequentialTransition().setCycleCount(Animation.INDEFINITE);
|
||||
destacados.get(destacados.size() - 1).getSequentialTransition().play();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remover el efecto de destacar.
|
||||
* Remover todos los elementos destacados.
|
||||
*/
|
||||
public void removerDestacar() {
|
||||
if (destacado != -1) {
|
||||
blinkTransition.stop();
|
||||
if (tipo == RECTANGULO) {
|
||||
Rectangle rectangle = (Rectangle) scene.lookup("#border_" + String.valueOf(destacado));
|
||||
rectangle.setFill(destacadoBG);
|
||||
if (destacados.size() != 0) {
|
||||
for (int i = 0; i < destacados.size(); i++) {
|
||||
destacados.get(i).getSequentialTransition().stop();
|
||||
|
||||
if (destacados.get(i).getTipo() == RECTANGULO) {
|
||||
Rectangle rectangle = (Rectangle) scene.lookup(destacados.get(i).getId());
|
||||
rectangle.setFill(destacados.get(i).getColor());
|
||||
}
|
||||
else if (destacados.get(i).getTipo() == CIRCULO) {
|
||||
Circle circle = (Circle) scene.lookup(destacados.get(i).getId());
|
||||
circle.setFill(destacados.get(i).getColor());
|
||||
}
|
||||
else {
|
||||
Text text = (Text) scene.lookup(destacados.get(i).getId());
|
||||
text.setStroke(destacados.get(i).getColor());
|
||||
}
|
||||
|
||||
destacados.remove(i);
|
||||
}
|
||||
else if (tipo == CIRCULO) {
|
||||
Circle circle = (Circle) scene.lookup("#border_" + String.valueOf(destacado));
|
||||
circle.setFill(destacadoBG);
|
||||
}
|
||||
Text text = (Text) scene.lookup("#caja_" + String.valueOf(destacado));
|
||||
text.setStroke(destacadoFG);
|
||||
destacado = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clase de elemento destacado.
|
||||
*
|
||||
* @author Chris Cromer
|
||||
*/
|
||||
final static private class Destacados {
|
||||
/**
|
||||
* El tipo de objeto que está destacado.
|
||||
*/
|
||||
private int tipo;
|
||||
/**
|
||||
* El id del elemento destacado.
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* El color anterior del elemento destacado.
|
||||
*/
|
||||
private Color color;
|
||||
/**
|
||||
* La animación del elemento destacado.
|
||||
*/
|
||||
private SequentialTransition sequentialTransition;
|
||||
|
||||
/**
|
||||
* Inicilizar.
|
||||
* @param tipo int: El tipo de elemento destacado, {@value #RECTANGULO}, {@value #CIRCULO} o {@value #TEXTO}.
|
||||
* @param id String: El id para identificar el elemento.
|
||||
* @param color Color: El color anterior para cambiarlo cuando {@link #removerDestacar()} es usado.
|
||||
* @param sequentialTransition SequentialTransition: La animación a usar.
|
||||
*/
|
||||
public Destacados(int tipo, String id, Color color, SequentialTransition sequentialTransition) {
|
||||
this.tipo = tipo;
|
||||
this.id = id;
|
||||
this.color = color;
|
||||
this.sequentialTransition = sequentialTransition;
|
||||
}
|
||||
|
||||
public int getTipo() {
|
||||
return tipo;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public SequentialTransition getSequentialTransition() {
|
||||
return sequentialTransition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
28
src/cl/cromer/estructuras/HashItem.java
Normal file
28
src/cl/cromer/estructuras/HashItem.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package cl.cromer.estructuras;
|
||||
|
||||
public class HashItem {
|
||||
private int indice;
|
||||
private String llave;
|
||||
private int valor;
|
||||
|
||||
public HashItem(String llave, int valor) {
|
||||
this.llave = llave;
|
||||
this.valor = valor;
|
||||
}
|
||||
|
||||
public String getLlave() {
|
||||
return llave;
|
||||
}
|
||||
|
||||
public int getValor() {
|
||||
return valor;
|
||||
}
|
||||
|
||||
public int getIndice() {
|
||||
return indice;
|
||||
}
|
||||
|
||||
public void setIndice(int indice) {
|
||||
this.indice = indice;
|
||||
}
|
||||
}
|
112
src/cl/cromer/estructuras/HashTable.java
Normal file
112
src/cl/cromer/estructuras/HashTable.java
Normal file
@@ -0,0 +1,112 @@
|
||||
package cl.cromer.estructuras;
|
||||
|
||||
public class HashTable {
|
||||
private HashItem hashArray[];
|
||||
private int tamano;
|
||||
private int size;
|
||||
|
||||
public HashTable(int tamano) {
|
||||
this.tamano = tamano;
|
||||
hashArray = new HashItem[tamano];
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public int hashMejor(String string) {
|
||||
int intLength = string.length() / 4;
|
||||
int sum = 0;
|
||||
for (int j = 0; j < intLength; j++) {
|
||||
char c[] = string.substring(j * 4, (j * 4) + 4).toCharArray();
|
||||
int mult = 1;
|
||||
for (char aC : c) {
|
||||
sum = sum + aC * mult;
|
||||
mult = mult * 256;
|
||||
}
|
||||
}
|
||||
|
||||
char c[] = string.substring(intLength * 4).toCharArray();
|
||||
int mult = 1;
|
||||
for (char aC : c) {
|
||||
sum = sum + aC * mult;
|
||||
mult = mult * 256;
|
||||
}
|
||||
|
||||
return (Math.abs(sum) % tamano);
|
||||
}
|
||||
|
||||
public int hash(String string) {
|
||||
int hash = 31;
|
||||
for (int i = 0; i < string.length(); i++) {
|
||||
hash = hash * 31 + string.charAt(i);
|
||||
}
|
||||
if (hash < 0) {
|
||||
hash = hash * -1;
|
||||
}
|
||||
return hash % tamano;
|
||||
}
|
||||
|
||||
public boolean insertar(String llave, int valor) {
|
||||
HashItem hashItem = new HashItem(llave, valor);
|
||||
int hashIndice = hash(hashItem.getLlave());
|
||||
int i = 0;
|
||||
while (hashArray[hashIndice] != null && hashArray[hashIndice].getLlave() != null && i < tamano) {
|
||||
if (hashArray[hashIndice].getLlave().equals(llave)) {
|
||||
return false;
|
||||
}
|
||||
hashIndice++;
|
||||
hashIndice = hashIndice % tamano;
|
||||
i++;
|
||||
}
|
||||
if (i == 10) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
hashItem.setIndice(hashIndice);
|
||||
hashArray[hashIndice] = hashItem;
|
||||
size++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean eliminar(String llave) {
|
||||
HashItem hashItem = new HashItem(llave, 0);
|
||||
int hashIndice = hash(hashItem.getLlave());
|
||||
int i = 0;
|
||||
while (hashArray[hashIndice] != null && hashArray[hashIndice].getLlave() != null && i < tamano) {
|
||||
if (hashArray[hashIndice].getLlave().equals(llave)) {
|
||||
hashArray[hashIndice] = null;
|
||||
return true;
|
||||
}
|
||||
hashIndice++;
|
||||
hashIndice = hashIndice % tamano;
|
||||
i++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public HashItem buscar(String llave) {
|
||||
for (int i = 0; i < tamano; i++) {
|
||||
if (hashArray[i] != null && hashArray[i].getLlave().equals(llave)) {
|
||||
return hashArray[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devolver el valor que está guardado en cada indice. Se usa para construir la grafica.
|
||||
*
|
||||
* @param indice int: El indice que desea ver.
|
||||
* @return String: El valor que está en dicho indice.
|
||||
*/
|
||||
public HashItem getIndice(int indice) {
|
||||
if (indice >= 0 && indice < hashArray.length) {
|
||||
return hashArray[indice];
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
314
src/cl/cromer/estructuras/HashTableController.java
Normal file
314
src/cl/cromer/estructuras/HashTableController.java
Normal file
@@ -0,0 +1,314 @@
|
||||
package cl.cromer.estructuras;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.ButtonBar;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.control.Dialog;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.text.Text;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Random;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Esta clase es para controlar todos la interfaz de HashTable.
|
||||
*
|
||||
* @author Chris Cromer
|
||||
*/
|
||||
public class HashTableController implements Initializable {
|
||||
/**
|
||||
* La caja para ingresar la llave.
|
||||
*/
|
||||
@FXML
|
||||
private TextFieldLimited llaveHashTable;
|
||||
|
||||
/**
|
||||
* La caja para ingresar el valor.
|
||||
*/
|
||||
@FXML
|
||||
private TextFieldLimited valorHashTable;
|
||||
|
||||
/**
|
||||
* Donde poner el contenido de hashTable.
|
||||
*/
|
||||
@FXML
|
||||
private VBox contenidoHashTable;
|
||||
|
||||
/**
|
||||
* Donde va el codigo a mostrar a la pantalla.
|
||||
*/
|
||||
@FXML
|
||||
private Text codigoHashTable;
|
||||
|
||||
/**
|
||||
* La escena donde está cosas graficas.
|
||||
*/
|
||||
private Scene scene;
|
||||
|
||||
/**
|
||||
* Donde está guardado los idiomas.
|
||||
*/
|
||||
private ResourceBundle resourceBundle;
|
||||
|
||||
/**
|
||||
* El hashTable usado en la aplicación.
|
||||
*/
|
||||
private HashTable hashTable;
|
||||
|
||||
/**
|
||||
* Grafico rectangulos.
|
||||
*/
|
||||
private Grafico grafico;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
scene = null;
|
||||
Colores colores = new Colores();
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
contenidoHashTable.getChildren().addAll(Grafico.crearHashCajas(colores, String.valueOf(i)));
|
||||
colores.siguinteColor();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Llenar el hashTable con numeros al azar.
|
||||
*/
|
||||
@FXML
|
||||
protected void botonLlenar() {
|
||||
if (scene == null) {
|
||||
initializeHashTable();
|
||||
}
|
||||
|
||||
Palabras palabras = new Palabras();
|
||||
|
||||
Random random = new Random();
|
||||
int maximo = 99;
|
||||
int minimo = 0;
|
||||
int rango = maximo - minimo + 1;
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
int numero = random.nextInt(rango) + minimo;
|
||||
while (!hashTable.insertar(palabras.getPalabra(), numero)) {
|
||||
if (hashTable.size() == 10) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
generarGrafico();
|
||||
}
|
||||
|
||||
/**
|
||||
* Vaciar el hashTable de todos los valores.
|
||||
*/
|
||||
@FXML
|
||||
protected void botonVaciar() {
|
||||
if (scene == null) {
|
||||
initializeHashTable();
|
||||
}
|
||||
|
||||
hashTable = new HashTable(10);
|
||||
generarGrafico();
|
||||
}
|
||||
|
||||
/**
|
||||
* Insertar un valor al hashTable y mostrar el codigo en la pantalla.
|
||||
*/
|
||||
@FXML
|
||||
protected void botonInsertar() {
|
||||
if (scene == null) {
|
||||
initializeHashTable();
|
||||
}
|
||||
|
||||
// Mostrar el codigo
|
||||
/*String tipo = (hashTable.isOrdered()) ? "Ordenado" : "Simple";
|
||||
String codigoTexto = new Scanner(getClass().getResourceAsStream("/cl/cromer/estructuras/code/hashTable" + tipo + "/insertar")).useDelimiter("\\Z").next();
|
||||
codigoHashTable.setText(codigoTexto);*/
|
||||
|
||||
if (llaveHashTable.getText() != null && !llaveHashTable.getText().trim().equals("") && valorHashTable.getText() != null && !valorHashTable.getText().trim().equals("")) {
|
||||
try {
|
||||
boolean exito = hashTable.insertar(llaveHashTable.getText().trim(), Integer.valueOf(valorHashTable.getText()));
|
||||
if (exito) {
|
||||
llaveHashTable.setText("");
|
||||
valorHashTable.setText("");
|
||||
generarGrafico();
|
||||
}
|
||||
else {
|
||||
ButtonType botonCerrar = new ButtonType(resourceBundle.getString("cerrar"), ButtonBar.ButtonData.OK_DONE);
|
||||
Dialog<String> dialog = new Dialog<>();
|
||||
dialog.setTitle(resourceBundle.getString("error"));
|
||||
if (hashTable.size() == 10) {
|
||||
dialog.setContentText(resourceBundle.getString("tablaHashLleno"));
|
||||
}
|
||||
else {
|
||||
dialog.setContentText(resourceBundle.getString("tablaHashLlaveExiste"));
|
||||
}
|
||||
dialog.getDialogPane().getButtonTypes().add(botonCerrar);
|
||||
Main.setIcon(dialog, getClass());
|
||||
dialog.show();
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException exception) {
|
||||
// El error no es fatal, sigue
|
||||
Logs.log(Level.WARNING, "No es tipo int.");
|
||||
errorNoLlave();
|
||||
}
|
||||
}
|
||||
else {
|
||||
Main.error(resourceBundle.getString("tablaHashNoLlave"), resourceBundle);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Eliminar un valor del hashTable si existe y mostrar el codigo en la pantalla.
|
||||
*/
|
||||
@FXML
|
||||
protected void botonEliminar() {
|
||||
if (scene == null) {
|
||||
initializeHashTable();
|
||||
}
|
||||
|
||||
// Mostrar el codigo
|
||||
/*String tipo = (hashTable.isOrdered()) ? "Ordenado" : "Simple";
|
||||
String codigoTexto = new Scanner(getClass().getResourceAsStream("/cl/cromer/estructuras/code/hashTable" + tipo + "/eliminar")).useDelimiter("\\Z").next();
|
||||
codigoHashTable.setText(codigoTexto);*/
|
||||
|
||||
try {
|
||||
if (llaveHashTable.getText() != null && !llaveHashTable.getText().trim().equals("")) {
|
||||
boolean exito = hashTable.eliminar(llaveHashTable.getText());
|
||||
if (exito) {
|
||||
llaveHashTable.setText("");
|
||||
valorHashTable.setText("");
|
||||
generarGrafico();
|
||||
}
|
||||
else {
|
||||
errorNoEsta();
|
||||
}
|
||||
}
|
||||
else {
|
||||
errorNoLlave();
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException exception) {
|
||||
// El error no es fatal, sigue
|
||||
Logs.log(Level.WARNING, "No es tipo int.");
|
||||
errorNoLlave();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Buscar si existe un elemento en el hashTable y mostrar el codigo en la pantalla
|
||||
* Si existe el valor destacarlo.
|
||||
*/
|
||||
@FXML
|
||||
protected void botonBuscar() {
|
||||
if (scene == null) {
|
||||
initializeHashTable();
|
||||
}
|
||||
|
||||
// Mostrar el codigo
|
||||
/*String tipo = (hashTable.isOrdered()) ? "Ordenado" : "Simple";
|
||||
String codigoTexto = new Scanner(getClass().getResourceAsStream("/cl/cromer/estructuras/code/hashTable" + tipo + "/buscar")).useDelimiter("\\Z").next();
|
||||
codigoHashTable.setText(codigoTexto);*/
|
||||
|
||||
try {
|
||||
if (llaveHashTable.getText() != null && !llaveHashTable.getText().trim().equals("")) {
|
||||
HashItem hashItem = hashTable.buscar(llaveHashTable.getText());
|
||||
if (hashItem != null) {
|
||||
generarGrafico();
|
||||
grafico = new Grafico(scene);
|
||||
grafico.destacar("#indice_caja_" + hashItem.getIndice(), Grafico.RECTANGULO);
|
||||
grafico.destacar("#indice_texto_" + hashItem.getIndice(), Grafico.TEXTO);
|
||||
grafico.destacar("#llave_caja_" + hashItem.getIndice(), Grafico.RECTANGULO);
|
||||
grafico.destacar("#llave_texto_" + hashItem.getIndice(), Grafico.TEXTO);
|
||||
grafico.destacar("#valor_caja_" + hashItem.getIndice(), Grafico.RECTANGULO);
|
||||
grafico.destacar("#valor_texto_" + hashItem.getIndice(), Grafico.TEXTO);
|
||||
}
|
||||
else {
|
||||
errorNoEsta();
|
||||
}
|
||||
}
|
||||
else {
|
||||
errorNoLlave();
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException exception) {
|
||||
// El error no es fatal, sigue
|
||||
Logs.log(Level.WARNING, "No es tipo int.");
|
||||
errorNoLlave();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Se muestra un error si la persona no ingresa un valor en el TextField.
|
||||
*/
|
||||
private void errorNoLlave() {
|
||||
|
||||
/*ButtonType botonCerrar = new ButtonType(resourceBundle.getString("cerrar"), ButtonBar.ButtonData.OK_DONE);
|
||||
Dialog<String> dialog = new Dialog<>();
|
||||
dialog.setTitle(resourceBundle.getString("error"));
|
||||
dialog.setContentText(resourceBundle.getString("tablaHashNoLlave"));
|
||||
dialog.getDialogPane().getButtonTypes().add(botonCerrar);
|
||||
Main.setIcon(dialog, getClass());
|
||||
dialog.show();*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Error cuando el valor no está en el hashTable.
|
||||
*/
|
||||
private void errorNoEsta() {
|
||||
ButtonType botonCerrar = new ButtonType(resourceBundle.getString("cerrar"), ButtonBar.ButtonData.OK_DONE);
|
||||
Dialog<String> dialog = new Dialog<>();
|
||||
dialog.setTitle(resourceBundle.getString("error"));
|
||||
dialog.setContentText(resourceBundle.getString("tablaHashNoEsta"));
|
||||
dialog.getDialogPane().getButtonTypes().add(botonCerrar);
|
||||
Main.setIcon(dialog, getClass());
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Crear el hashTable de tamaño 10.
|
||||
*/
|
||||
private void initializeHashTable() {
|
||||
scene = contenidoHashTable.getScene();
|
||||
grafico = new Grafico(scene);
|
||||
this.hashTable = new HashTable(10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Poner los valores en el grafico.
|
||||
*/
|
||||
private void generarGrafico() {
|
||||
grafico.removerDestacar();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
if (hashTable.getIndice(i) != null) {
|
||||
Text text = (Text) scene.lookup("#indice_texto_" + String.valueOf(i));
|
||||
text.setText(String.valueOf(i));
|
||||
text = (Text) scene.lookup("#llave_texto_" + String.valueOf(i));
|
||||
text.setText(hashTable.getIndice(i).getLlave());
|
||||
text = (Text) scene.lookup("#valor_texto_" + String.valueOf(i));
|
||||
text.setText(String.valueOf(hashTable.getIndice(i).getValor()));
|
||||
}
|
||||
else {
|
||||
Text text = (Text) scene.lookup("#indice_texto_" + String.valueOf(i));
|
||||
text.setText("");
|
||||
text = (Text) scene.lookup("#llave_texto_" + String.valueOf(i));
|
||||
text.setText("");
|
||||
text = (Text) scene.lookup("#valor_texto_" + String.valueOf(i));
|
||||
text.setText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -172,7 +172,7 @@ public class InsercionController implements Initializable {
|
||||
*/
|
||||
private void generarGrafico() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Text text = (Text) scene.lookup("#caja_" + String.valueOf(i));
|
||||
Text text = (Text) scene.lookup("#texto_" + String.valueOf(i));
|
||||
text.setText(array.getIndice(i));
|
||||
}
|
||||
}
|
||||
|
@@ -307,7 +307,8 @@ public class ListaEnlazdaController implements Initializable {
|
||||
if (enlace != null) {
|
||||
generarGrafico();
|
||||
grafico = new Grafico(scene);
|
||||
grafico.destacar(enlace.getLlave(), Grafico.RECTANGULO);
|
||||
grafico.destacar("#caja_" + enlace.getLlave(), Grafico.RECTANGULO);
|
||||
grafico.destacar("#texto_" + enlace.getLlave(), Grafico.TEXTO);
|
||||
}
|
||||
else {
|
||||
errorNoEsta();
|
||||
@@ -408,7 +409,8 @@ public class ListaEnlazdaController implements Initializable {
|
||||
/**
|
||||
* Dibujarlo con una flecha.
|
||||
*
|
||||
* @param enlace Object: El enlace que tiene la llave y valor.
|
||||
* @param enlace Enlace: El enlace que tiene la llave y valor.
|
||||
* @param sinFlecha boolean: Verdad si necesita dibujar una flecha.
|
||||
*/
|
||||
private void dibujarSimple(Enlace enlace, boolean sinFlecha) {
|
||||
contenidoLista.getChildren().addAll(
|
||||
@@ -425,7 +427,8 @@ public class ListaEnlazdaController implements Initializable {
|
||||
/**
|
||||
* Dibujarlo con dos flechas.
|
||||
*
|
||||
* @param enlace El enlace que tiene la llave y valor.
|
||||
* @param enlace Enlace: El enlace que tiene la llave y valor.
|
||||
* @param primer boolean: Verdad si es el primer elemento de la lista.
|
||||
*/
|
||||
private void dibujarDoble(Enlace enlace, boolean primer) {
|
||||
if (primer) {
|
||||
|
@@ -4,6 +4,8 @@ import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.ButtonBar;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.control.Dialog;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.stage.Stage;
|
||||
@@ -46,6 +48,16 @@ public class Main extends Application {
|
||||
stage.getIcons().add(new Image(classe.getResourceAsStream("/cl/cromer/estructuras/images/icon.png")));
|
||||
}
|
||||
|
||||
static public void error(String mensaje, ResourceBundle resourceBundle) {
|
||||
ButtonType botonCerrar = new ButtonType(resourceBundle.getString("cerrar"), ButtonBar.ButtonData.OK_DONE);
|
||||
Dialog<String> dialog = new Dialog<>();
|
||||
dialog.setTitle(resourceBundle.getString("error"));
|
||||
dialog.setContentText(mensaje);
|
||||
dialog.getDialogPane().getButtonTypes().add(botonCerrar);
|
||||
Main.setIcon(dialog, Main.class);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Crear el stage y la scene para la aplicación grafica.
|
||||
*
|
||||
|
@@ -213,6 +213,18 @@ public class MenuController extends VBox implements Initializable {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Click en Hash Table.
|
||||
*/
|
||||
@FXML
|
||||
protected void menuHashTable() {
|
||||
loadStage(
|
||||
resourceBundle.getString("tituloTablaHash"),
|
||||
"/cl/cromer/estructuras/fxml/hashTable.fxml",
|
||||
"/cl/cromer/estructuras/css/style.css"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Click en Ingles.
|
||||
*/
|
||||
|
@@ -172,7 +172,7 @@ public class MergeController implements Initializable {
|
||||
*/
|
||||
private void generarGrafico() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Text text = (Text) scene.lookup("#caja_" + String.valueOf(i));
|
||||
Text text = (Text) scene.lookup("#texto_" + String.valueOf(i));
|
||||
text.setText(array.getIndice(i));
|
||||
}
|
||||
}
|
||||
|
65
src/cl/cromer/estructuras/Palabras.java
Normal file
65
src/cl/cromer/estructuras/Palabras.java
Normal file
@@ -0,0 +1,65 @@
|
||||
package cl.cromer.estructuras;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class Palabras {
|
||||
List<String> palabras;
|
||||
|
||||
public Palabras() {
|
||||
palabras = new ArrayList<>();
|
||||
palabras.add("hola");
|
||||
palabras.add("mundo");
|
||||
palabras.add("cruel");
|
||||
palabras.add("mi");
|
||||
palabras.add("tiempo");
|
||||
palabras.add("es");
|
||||
palabras.add("limitado");
|
||||
palabras.add("pero");
|
||||
palabras.add("puedo");
|
||||
palabras.add("lograr");
|
||||
palabras.add("el");
|
||||
palabras.add("proyecto");
|
||||
palabras.add("si");
|
||||
palabras.add("trabajo");
|
||||
palabras.add("bien");
|
||||
palabras.add("computador");
|
||||
palabras.add("test");
|
||||
palabras.add("mouse");
|
||||
palabras.add("clase");
|
||||
palabras.add("software");
|
||||
palabras.add("hardware");
|
||||
palabras.add("vaso");
|
||||
palabras.add("mesa");
|
||||
palabras.add("tabla");
|
||||
palabras.add("color");
|
||||
palabras.add("calor");
|
||||
palabras.add("edad");
|
||||
palabras.add("olor");
|
||||
palabras.add("ganar");
|
||||
palabras.add("dormir");
|
||||
palabras.add("tomar");
|
||||
palabras.add("comer");
|
||||
palabras.add("pensar");
|
||||
palabras.add("programar");
|
||||
palabras.add("hablar");
|
||||
palabras.add("sentir");
|
||||
palabras.add("perder");
|
||||
palabras.add("abrir");
|
||||
palabras.add("cerrar");
|
||||
palabras.add("mirar");
|
||||
palabras.add("agua");
|
||||
palabras.add("me");
|
||||
palabras.add("llaman");
|
||||
palabras.add("gringo");
|
||||
palabras.add("loco");
|
||||
palabras.add("no");
|
||||
}
|
||||
|
||||
public String getPalabra() {
|
||||
Random random = new Random();
|
||||
int numero = random.nextInt(palabras.size());
|
||||
return palabras.get(numero);
|
||||
}
|
||||
}
|
@@ -203,7 +203,8 @@ public class PilaController implements Initializable {
|
||||
int encontrado = pila.peek();
|
||||
if (encontrado != Integer.MIN_VALUE) {
|
||||
generarGrafico();
|
||||
grafico.destacar(pila.size() - 1, Grafico.RECTANGULO);
|
||||
grafico.destacar("#caja_" + (pila.size() - 1), Grafico.RECTANGULO);
|
||||
grafico.destacar("#texto_" + (pila.size() - 1), Grafico.TEXTO);
|
||||
}
|
||||
else {
|
||||
errorVacia();
|
||||
@@ -242,7 +243,7 @@ public class PilaController implements Initializable {
|
||||
private void generarGrafico() {
|
||||
grafico.removerDestacar();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Text text = (Text) scene.lookup("#caja_" + String.valueOf(i));
|
||||
Text text = (Text) scene.lookup("#texto_" + String.valueOf(i));
|
||||
text.setText(pila.getIndice(i));
|
||||
}
|
||||
}
|
||||
|
@@ -172,7 +172,7 @@ public class QuickController implements Initializable {
|
||||
*/
|
||||
private void generarGrafico() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Text text = (Text) scene.lookup("#caja_" + String.valueOf(i));
|
||||
Text text = (Text) scene.lookup("#texto_" + String.valueOf(i));
|
||||
text.setText(array.getIndice(i));
|
||||
}
|
||||
}
|
||||
|
@@ -172,7 +172,7 @@ public class SeleccionController implements Initializable {
|
||||
*/
|
||||
private void generarGrafico() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Text text = (Text) scene.lookup("#caja_" + String.valueOf(i));
|
||||
Text text = (Text) scene.lookup("#texto_" + String.valueOf(i));
|
||||
text.setText(array.getIndice(i));
|
||||
}
|
||||
}
|
||||
|
@@ -172,7 +172,7 @@ public class ShellController implements Initializable {
|
||||
*/
|
||||
private void generarGrafico() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Text text = (Text) scene.lookup("#caja_" + String.valueOf(i));
|
||||
Text text = (Text) scene.lookup("#texto_" + String.valueOf(i));
|
||||
text.setText(array.getIndice(i));
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,8 @@ tituloMerge=Merge
|
||||
tituloListaEnlazadaSimple=Simple Linked List
|
||||
tituloListaEnlazadaCircular=Circular Linked List
|
||||
tituloListaEnlazadaDoble=Double Linked List
|
||||
tituloTablaHash=Hash Table
|
||||
|
||||
estructuras=Structures
|
||||
array=Array
|
||||
arraySimple=Simple
|
||||
@@ -63,6 +65,8 @@ peek=Peek
|
||||
nuevo=New
|
||||
paso=Step
|
||||
correr=Run
|
||||
llave=Key:
|
||||
valor=Value:
|
||||
arrayLleno=Value not inserted because array is full.
|
||||
arrayValorExiste=Value already exists.
|
||||
arrayNoEsta=Value does not exist.
|
||||
@@ -81,4 +85,8 @@ pilaVacia=The stack is empty.
|
||||
pilaNoValor=Please input a numeric value.
|
||||
colaLlena=Value not inserted because the queue is full.
|
||||
colaVacia=The queue is empty.
|
||||
colaNoValor=Please input a numeric value.
|
||||
colaNoValor=Please input a numeric value.
|
||||
tablaHashLleno=Key not inserted because hash table is full.
|
||||
tablaHashLlaveExiste=Key already exists.
|
||||
tablaHashNoEsta=Key does not exist.
|
||||
tablaHashNoLlave=Please input a key and a numeric value.
|
@@ -12,6 +12,7 @@ tituloMerge=Merge
|
||||
tituloListaEnlazadaSimple=Lista Enlazada Simple
|
||||
tituloListaEnlazadaCircular=Lista Enlazada Circular
|
||||
tituloListaEnlazadaDoble=Lista Enlazada Doble
|
||||
tituloTablaHash=Tabla Hash
|
||||
estructuras=Estructuras
|
||||
array=Array
|
||||
arraySimple=Simple
|
||||
@@ -63,7 +64,9 @@ peek=Peek
|
||||
nuevo=Nuevo
|
||||
paso=Paso
|
||||
correr=Correr
|
||||
arrayLleno=Valor no fue insertado porque el array est\u00E1 lleno.
|
||||
llave=Llave:
|
||||
valor=Valor:
|
||||
arrayLleno=El valor no fue insertado porque el array est\u00E1 lleno.
|
||||
arrayValorExiste=El valor ya existe.
|
||||
arrayNoEsta=El valor no existe.
|
||||
arrayNoValor=Ingresar un valor num\u00E9rico por favor.
|
||||
@@ -76,9 +79,13 @@ mergeYaOrdenado=El array ya est\u00E1 ordenado.
|
||||
listaLlaveExiste=La llave ya existe.
|
||||
listaNoEsta=La llave no existe.
|
||||
listaNoValor=Ingresar una llave y valor num\u00E9ricos por favor.
|
||||
pilaLlena=Valor no fue insertado porque la pila est\u00E1 llena.
|
||||
pilaLlena=El valor no fue insertado porque la pila est\u00E1 llena.
|
||||
pilaVacia=La pila est\u00E1 vac\u00EDa.
|
||||
pilaNoValor=Ingresar un valor num\u00E9rico por favor.
|
||||
colaLlena=Valor no fue insertado porque la cola est\u00E1 llena.
|
||||
colaLlena=El valor no fue insertado porque la cola est\u00E1 llena.
|
||||
colaVacia=La cola est\u00E1 vac\u00EDa.
|
||||
colaNoValor=Ingresar un valor num\u00E9rico por favor.
|
||||
colaNoValor=Ingresar un valor 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.
|
33
src/cl/cromer/estructuras/fxml/hashTable.fxml
Normal file
33
src/cl/cromer/estructuras/fxml/hashTable.fxml
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import cl.cromer.estructuras.TextFieldLimited?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
<VBox xmlns:fx="http://javafx.com/fxml/1" prefHeight="768.0" prefWidth="1024.0" spacing="10"
|
||||
xmlns="http://javafx.com/javafx/8.0.92" fx:controller="cl.cromer.estructuras.HashTableController">
|
||||
<fx:include source="menu.fxml"/>
|
||||
<ScrollPane fitToHeight="true" fitToWidth="true" VBox.vgrow="ALWAYS">
|
||||
<HBox alignment="TOP_CENTER" VBox.vgrow="ALWAYS" spacing="50">
|
||||
<VBox spacing="10">
|
||||
<HBox alignment="CENTER" spacing="10">
|
||||
<Button text="%llenar" onAction="#botonLlenar"/>
|
||||
<Button text="%vaciar" onAction="#botonVaciar"/>
|
||||
</HBox>
|
||||
<HBox alignment="CENTER" spacing="10">
|
||||
<Button text="%insertar" onAction="#botonInsertar"/>
|
||||
<Button text="%eliminar" onAction="#botonEliminar"/>
|
||||
<Button text="%buscar" onAction="#botonBuscar"/>
|
||||
<Text text="%llave"/>
|
||||
<TextFieldLimited fx:id="llaveHashTable" maxLength="10" prefWidth="100"/>
|
||||
<Text text="%valor"/>
|
||||
<TextFieldLimited fx:id="valorHashTable" maxLength="3" prefWidth="50"/>
|
||||
</HBox>
|
||||
<VBox fx:id="contenidoHashTable" alignment="CENTER"/>
|
||||
</VBox>
|
||||
<StackPane alignment="TOP_LEFT" minWidth="450">
|
||||
<Text fx:id="codigoHashTable"/>
|
||||
</StackPane>
|
||||
</HBox>
|
||||
</ScrollPane>
|
||||
</VBox>
|
@@ -35,7 +35,7 @@
|
||||
<MenuItem text="%dirigidos"/>
|
||||
<MenuItem text="%noDirigidos"/>
|
||||
</Menu>
|
||||
<MenuItem text="%tablaHash"/>
|
||||
<MenuItem text="%tablaHash" onAction="#menuHashTable"/>
|
||||
</Menu>
|
||||
<Menu text="%idioma">
|
||||
<MenuItem onAction="#menuIngles" text="%ingles"/>
|
||||
|
Reference in New Issue
Block a user