From e60f16bf68ba01585024f5523bbb0eec46ddf934 Mon Sep 17 00:00:00 2001 From: sebastiancc27 Date: Wed, 28 Feb 2024 08:10:24 -0600 Subject: [PATCH] Hala Madrid!! 14 Champions Proyecto ASCII --- ASCII/build.xml | 73 + ASCII/manifest.mf | 3 + ASCII/nbproject/build-impl.xml | 1771 ++++++++++++++++++ ASCII/nbproject/genfiles.properties | 8 + ASCII/nbproject/project.properties | 103 + ASCII/nbproject/project.xml | 15 + ASCII/src/Controlador/GestionSize1.java | 136 ++ ASCII/src/Controlador/GestionTextFields.java | 41 + ASCII/src/Modelo/Caballo.java | 61 + ASCII/src/Modelo/Hada.java | 135 ++ ASCII/src/Modelo/ImprimirAscii.java | 25 + ASCII/src/Modelo/Lienzo.java | 43 + ASCII/src/Modelo/Main.java | 303 +++ ASCII/src/Modelo/Tren.java | 126 ++ ASCII/src/Modelo/WS.java | 45 + ASCII/src/Vista/Principal1.form | 35 + ASCII/src/Vista/Principal1.java | 159 ++ ASCII/src/images/boton-agregar.png | Bin 0 -> 706 bytes ASCII/src/images/deshacer.png | Bin 0 -> 477 bytes ASCII/src/images/disquete.png | Bin 0 -> 492 bytes 20 files changed, 3082 insertions(+) create mode 100644 ASCII/build.xml create mode 100644 ASCII/manifest.mf create mode 100644 ASCII/nbproject/build-impl.xml create mode 100644 ASCII/nbproject/genfiles.properties create mode 100644 ASCII/nbproject/project.properties create mode 100644 ASCII/nbproject/project.xml create mode 100644 ASCII/src/Controlador/GestionSize1.java create mode 100644 ASCII/src/Controlador/GestionTextFields.java create mode 100644 ASCII/src/Modelo/Caballo.java create mode 100644 ASCII/src/Modelo/Hada.java create mode 100644 ASCII/src/Modelo/ImprimirAscii.java create mode 100644 ASCII/src/Modelo/Lienzo.java create mode 100644 ASCII/src/Modelo/Main.java create mode 100644 ASCII/src/Modelo/Tren.java create mode 100644 ASCII/src/Modelo/WS.java create mode 100644 ASCII/src/Vista/Principal1.form create mode 100644 ASCII/src/Vista/Principal1.java create mode 100644 ASCII/src/images/boton-agregar.png create mode 100644 ASCII/src/images/deshacer.png create mode 100644 ASCII/src/images/disquete.png diff --git a/ASCII/build.xml b/ASCII/build.xml new file mode 100644 index 0000000..45b203a --- /dev/null +++ b/ASCII/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project ASCII. + + + diff --git a/ASCII/manifest.mf b/ASCII/manifest.mf new file mode 100644 index 0000000..328e8e5 --- /dev/null +++ b/ASCII/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/ASCII/nbproject/build-impl.xml b/ASCII/nbproject/build-impl.xml new file mode 100644 index 0000000..242bc50 --- /dev/null +++ b/ASCII/nbproject/build-impl.xml @@ -0,0 +1,1771 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ASCII/nbproject/genfiles.properties b/ASCII/nbproject/genfiles.properties new file mode 100644 index 0000000..874d1eb --- /dev/null +++ b/ASCII/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=5be6c28b +build.xml.script.CRC32=b4da1c6d +build.xml.stylesheet.CRC32=f85dc8f2@1.104.0.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=5be6c28b +nbproject/build-impl.xml.script.CRC32=60e9fb8b +nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.104.0.48 diff --git a/ASCII/nbproject/project.properties b/ASCII/nbproject/project.properties new file mode 100644 index 0000000..107395a --- /dev/null +++ b/ASCII/nbproject/project.properties @@ -0,0 +1,103 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.modulepath=\ + ${run.modulepath} +debug.test.classpath=\ + ${run.test.classpath} +debug.test.modulepath=\ + ${run.test.modulepath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/ASCII.jar +dist.javadoc.dir=${dist.dir}/javadoc +dist.jlink.dir=${dist.dir}/jlink +dist.jlink.output=${dist.jlink.dir}/ASCII +excludes= +file.reference.itextpdf-5.5.13.jar=C:\\Users\\Hp\\OneDrive\\Escritorio\\JAR\\itextpdf-5.5.13.jar +file.reference.okhttp-3.9.1.jar=C:\\Users\\Hp\\OneDrive\\Escritorio\\JAR\\okhttp-3.9.1.jar +file.reference.okio-1.8.0.jar=C:\\Users\\Hp\\OneDrive\\Escritorio\\JAR\\okio-1.8.0.jar +file.reference.org.apache.commons.io.jar=C:\\Users\\Hp\\OneDrive\\Escritorio\\JAR\\org.apache.commons.io.jar +includes=** +jar.compress=false +javac.classpath=\ + ${file.reference.itextpdf-5.5.13.jar}:\ + ${file.reference.okhttp-3.9.1.jar}:\ + ${file.reference.okio-1.8.0.jar}:\ + ${file.reference.org.apache.commons.io.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.modulepath= +javac.processormodulepath= +javac.processorpath=\ + ${javac.classpath} +javac.source=19 +javac.target=19 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.modulepath=\ + ${javac.modulepath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.html5=false +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +# The jlink additional root modules to resolve +jlink.additionalmodules= +# The jlink additional command line parameters +jlink.additionalparam= +jlink.launcher=true +jlink.launcher.name=ASCII +main.class= +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.modulepath=\ + ${javac.modulepath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +run.test.modulepath=\ + ${javac.test.modulepath} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/ASCII/nbproject/project.xml b/ASCII/nbproject/project.xml new file mode 100644 index 0000000..58b3f1d --- /dev/null +++ b/ASCII/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + ASCII + + + + + + + + + diff --git a/ASCII/src/Controlador/GestionSize1.java b/ASCII/src/Controlador/GestionSize1.java new file mode 100644 index 0000000..8112e7b --- /dev/null +++ b/ASCII/src/Controlador/GestionSize1.java @@ -0,0 +1,136 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package Controlador; + + +import Modelo.WS; +import Vista.Principal1; +import java.awt.Color; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.itextpdf.text.Document; +import com.itextpdf.text.DocumentException; +import com.itextpdf.text.PageSize; +import com.itextpdf.text.Phrase; +import com.itextpdf.text.pdf.PdfPTable; +import com.itextpdf.text.pdf.PdfWriter; +import java.io.FileNotFoundException; + +import java.io.FileOutputStream; +import java.io.IOException; +import javax.swing.JOptionPane; + +/** + * + * @author Hp + */ +public class GestionSize1 implements ActionListener{ + Principal1 v; + WS ws=new WS(); + public String numeroTelefonico; + public GestionSize1(Principal1 v){ + this.v=v; + } + //Para la matriz de JTextFields +public void generarPDF(JTextField[][] matrix, String filePath) throws DocumentException, FileNotFoundException{ + Document document = new Document(PageSize.A4); + PdfWriter.getInstance(document, new FileOutputStream(filePath)); + document.open(); + for (int i = 0; i < matrix.length; i++) { + for (int j = 0; j < matrix[i].length; j++) { + String text = matrix[i][j].getText(); + document.add(new Phrase(text)); + } + document.add(new Phrase("\n")); // Agrega una nueva línea después de cada fila + } + document.close(); + + } + + @Override + public void actionPerformed(ActionEvent e) { + + if(e.getSource()==v.incrementSize){ + Font fuente=new Font("Dialog", Font.BOLD, 20); + int nCol=v.col+1; + int nFilas=v.filas+1; + System.out.println("NUEVA FILA : "+nFilas+" NUEVA COL: "+nCol); + JTextField[][] matriz=new JTextField[nFilas][nCol]; + v.panelP.removeAll(); + v.panelP.setLayout(new GridLayout(nFilas, nCol,1,1)); + + for(int i=0;i1) e.consume(); + //System.out.println(cont); + } + + @Override + public void keyPressed(KeyEvent e) { + // throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + + } + + @Override + public void keyReleased(KeyEvent e) { + // throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + +} diff --git a/ASCII/src/Modelo/Caballo.java b/ASCII/src/Modelo/Caballo.java new file mode 100644 index 0000000..2205891 --- /dev/null +++ b/ASCII/src/Modelo/Caballo.java @@ -0,0 +1,61 @@ +package Modelo; + +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ + +/** + * + * @author reyes + */ +public class Caballo extends Lienzo{ + public int x; + public int y; + + public Caballo(int ancho, int alto, char lienzo [][]) { + super(ancho, alto, lienzo); + } + + public void pintarCaballlo(char[][] lienzo){ + this.setPen(1, 16, ','); + this.setPen(1, 17, '-'); + this.setPen(1, 18, '-'); + this.setPen(1, 19, '-'); + this.setPen(2, 15, '/'); + this.setPen(2, 20, '|'); + this.setPen(3, 20, '|'); + this.setPen(3, 18, '^'); + this.setPen(4, 16, '/'); + this.setPen(3, 13, '-'); + this.setPen(3, 12, '-'); + this.setPen(3, 11, '-'); + this.setPen(3, 10, '-'); + this.setPen(3, 9, '-'); + this.setPen(3, 8, '-'); + this.setPen(3, 7, '*'); + this.setPen(4, 6, ';'); + this.setPen(4, 5, ','); + this.setPen(5, 4, '/'); + this.setPen(5, 5, '/'); + this.setPen(6, 3, ','); + this.setPen(4, 7, '('); + this.setPen(4, 10, ')'); + this.setPen(5, 7, '/'); + this.setPen(5, 9, '/'); + this.setPen(6, 7, '|'); + this.setPen(6, 8, '|'); + this.setPen(7, 8, '^'); + this.setPen(4, 11, '-'); + this.setPen(4, 12, '-'); + this.setPen(4, 13, '-'); + this.setPen(4, 14, ','); + this.setPen(5, 14, '|'); + this.setPen(5, 15, '-'); + this.setPen(5, 16, '-'); + this.setPen(5, 17, ';'); + this.setPen(6, 17, '^'); + this.setPen(6, 15, '|'); + this.setPen(7, 15, '^'); + } +} \ No newline at end of file diff --git a/ASCII/src/Modelo/Hada.java b/ASCII/src/Modelo/Hada.java new file mode 100644 index 0000000..82918ef --- /dev/null +++ b/ASCII/src/Modelo/Hada.java @@ -0,0 +1,135 @@ +package Modelo; + +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ + +/** + * + * @author reyes + */ +public class Hada extends Lienzo{ + + Hada(int ancho, int alto, char[][] lienzo){ + super(ancho, alto, lienzo); + } + + //Función que llena la matriz con los simbolos para crear el hada + public void pintarHada(char[][] lienzo){ + //Inicia ASCCI del hada + + //ASCCI necesario para el hada del lazo izquierdo + this.setPen(4, 2, '('); + this.setPen(4, 3, '^'); + this.setPen(4, 4, '\\'); + this.setPen(4, 5, '('); + this.setPen(4, 6, ')'); + this.setPen(4, 7, '_'); + this.setPen(5, 3, '>'); + this.setPen(5, 4, '/'); + this.setPen(5, 5, '('); + this.setPen(5, 6, '_'); + this.setPen(6, 2, '('); + this.setPen(6, 3, '/'); + this.setPen(6, 4, '\\'); + this.setPen(6, 5, '\\'); + this.setPen(7, 4, '/'); + this.setPen(7, 5, '|'); + this.setPen(8, 4, '`'); + this.setPen(8, 5, '`'); + + //Empiezan los caracteres para la flor + this.setPen(5, 11, '_'); + this.setPen(5, 12, '.'); + this.setPen(5, 13, '-'); + this.setPen(5, 14, '.'); + this.setPen(5, 15, '-'); + this.setPen(5, 16, '.'); + this.setPen(6, 10, '('); + this.setPen(6, 11, '_'); + this.setPen(6, 12, '\\'); + this.setPen(6, 13, '_'); + this.setPen(6, 14, '|'); + this.setPen(6, 15, '_'); + this.setPen(6, 16, '/'); + this.setPen(6, 17, '_'); + this.setPen(6, 18, ')'); + this.setPen(7, 9, '('); + this.setPen(7, 10, '_'); + this.setPen(7, 11, '_'); + this.setPen(7, 12, '>'); + this.setPen(7, 13, '('); + this.setPen(7, 14, '@'); + this.setPen(7, 15, ')'); + this.setPen(7, 16, '<'); + this.setPen(7, 17, '_'); + this.setPen(7, 18, '_'); + this.setPen(7, 19, ')'); + this.setPen(8, 10, '('); + this.setPen(8, 11, '_'); + this.setPen(8, 12, '/'); + this.setPen(8, 13, '^'); + this.setPen(8, 14, '|'); + this.setPen(8, 15, '^'); + this.setPen(8, 16, '\\'); + this.setPen(8, 17, '_'); + this.setPen(8, 18, ')'); + this.setPen(9, 12, '\''); + this.setPen(9, 13, '-'); + this.setPen(9, 14, '\''); + this.setPen(9, 15, '-'); + this.setPen(9, 16, '\''); + this.setPen(9, 17, '#'); + this.setPen(9, 18, ','); + this.setPen(9, 21, '_'); + this.setPen(9, 22, '/'); + this.setPen(9, 23, '\\'); + this.setPen(10, 17, '`'); + this.setPen(10, 18, '#'); + this.setPen(10, 20, '/'); + this.setPen(10, 22, '_'); + this.setPen(10, 23, '\\'); + this.setPen(11, 13, '|'); + this.setPen(11, 14, '\\'); + this.setPen(11, 15, '_'); + this.setPen(11, 17, ','); + this.setPen(11, 18, '#'); + this.setPen(11, 19, '|'); + this.setPen(11, 20, '/'); + this.setPen(11, 21, '_'); + this.setPen(11, 22, '/'); + this.setPen(12, 13, '\\'); + this.setPen(12, 15, '\\'); + this.setPen(12, 16, '|'); + this.setPen(12, 17, '#'); + this.setPen(12, 18, '\''); + this.setPen(13, 14, '`'); + this.setPen(13, 15, '-'); + this.setPen(13, 16, '#'); + this.setPen(13, 17, '\''); + this.setPen(13, 19, '/'); + this.setPen(13, 20, '|'); + this.setPen(14, 13, '/'); + this.setPen(14, 14, '\\'); + this.setPen(14, 15, '_'); + this.setPen(14, 16, '#'); + this.setPen(14, 18, '|'); + this.setPen(14, 20, '/'); + this.setPen(14, 21, '_'); + this.setPen(15, 13, '\\'); + this.setPen(15, 14, '_'); + this.setPen(15, 15, '.'); + this.setPen(15, 16, '|'); + this.setPen(15, 17, '#'); + this.setPen(15, 18, ','); + this.setPen(15, 19, '_'); + this.setPen(15, 20, '_'); + this.setPen(15, 21, '/'); + + //Bucle para rellenar todo la parte inferior simulando pasto + for(int i = 0; i < 33; i++) + this.setPen(16, i, '^'); + } + +} diff --git a/ASCII/src/Modelo/ImprimirAscii.java b/ASCII/src/Modelo/ImprimirAscii.java new file mode 100644 index 0000000..f3400e0 --- /dev/null +++ b/ASCII/src/Modelo/ImprimirAscii.java @@ -0,0 +1,25 @@ +package Modelo; + + + +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ + +/** + * + * @author Hp + */ +public class ImprimirAscii extends Thread { + + public void run(char[][] lienzo, int ancho, int alto) throws InterruptedException { + for (int i = 0; i < alto; i++) { + for (int j = 0; j < ancho; j++) { + System.out.print(lienzo[i][j]); + } + Thread.sleep(1000); + System.out.println(""); + } + } +} diff --git a/ASCII/src/Modelo/Lienzo.java b/ASCII/src/Modelo/Lienzo.java new file mode 100644 index 0000000..9e6fa68 --- /dev/null +++ b/ASCII/src/Modelo/Lienzo.java @@ -0,0 +1,43 @@ +package Modelo; + +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ + +/** + * + * @author reyes + */ +public abstract class Lienzo { + private int acho; + private int alto; + int x; + int y; + public char lienzo [][]; + + public Lienzo(int ancho, int alto, char lienzo[][]){ + this.acho=ancho; + this.alto=alto; + this.lienzo=lienzo; + } + public void limpiarMatriz(char[][] lienzo, int filas, int col){ + for(int i=0;i array){ + for(int i=0;i array){ + int anchoMax=array.get(0); + for(int i=0;i xS=new ArrayList<>(); + ArrayList yS=new ArrayList<>(); + char[] puntosManual; + char[][] auxLienzo; + + int ancho; + int alto; + int nAncho,nAlto; + + //CABALLO + char[][] lienzo=new char[14][22]; //Se inicializa el lienzo para el caballo + ImprimirAscii hilo1=new ImprimirAscii();//HILO PARA IMPRIMIR EL CABALLO LINEA POR LINEA + Caballo caballo=new Caballo(14,22,lienzo);//se instancia un objeto caballo que herada de lienzo + caballo.limpiarMatriz(lienzo,14,22);//Se limpia la matriz o lienzo + caballo.pintarCaballlo(lienzo);//se establecen cada uno de los pintos en la matriz del caballo + + char[][] lienzotren=new char[10][27]; + Tren tren = new Tren(10, 22, lienzotren); + ImprimirAscii hiloTren=new ImprimirAscii(); + tren.limpiarMatriz(lienzotren, 10, 22); + tren.pintarTren(lienzotren); + + + char[][] lienzoHada = new char[20][33]; + //Instancia de nuestro objeto hada + Hada hada = new Hada(20,33, lienzoHada); + ImprimirAscii hiloHada=new ImprimirAscii(); + //Funcion que llena la matriz de espacios en blanco + hada.limpiarMatriz(lienzoHada, 20, 33); + //Funcion que tiene los simbolos para dibujar el hada + hada.pintarHada(lienzoHada); + + + Scanner entrada=new Scanner(System.in); + do{ + System.out.println("-------------MENU---------------"); + System.out.println("1.- MOSTRAR CABALLO"); + System.out.println("2.- MOSTRAR TREN"); + System.out.println("3.- MOSTRAR HADA"); + System.out.println("4.- REALIZAR FIGURA MANUALMENTE"); + System.out.println("5.- MOSTRAR IMAGEN EN CARACTERES ASCII"); + System.out.println("6.- SALIR"); + System.out.println("--- Seleccione una opcion:"); + + + while (!entrada.hasNextInt()) { + System.out.println("Por favor, ingrese una opcion de las mencionadas."); + entrada.next(); + } + + opcionFigura=entrada.nextInt(); + + try{ + + switch (opcionFigura) { + case 1: + + hilo1.run(lienzo, 22, 14); + //caballo.paint(14,22,lienzo); + + do{ + System.out.println("Desea exportar el dibujo a un archivo.txt? S/N"); + opcionExportar = entrada.next().charAt(0); + + if (opcionExportar != 'S' && opcionExportar != 'N' && opcionExportar !='s' && opcionExportar !='n') { + System.out.println("Opcion invalida. Por favor, ingrese S o N."); + } + }while(opcionExportar != 'S' && opcionExportar != 'N'&& opcionExportar !='s' && opcionExportar !='n'); + + if (opcionExportar == 'S' || opcionExportar == 's') { + System.out.println("Ingrese el nombre que desea asignarle al archivo (sin extension): "); + nombre = entrada.next(); + var = nombre + ".txt"; + exportar(lienzo, var); + } + break; + case 2: + hiloTren.run(lienzotren, 22, 10); + /// tren.paint(10, 22, lienzotren); + + do{ + System.out.println("Desea exportar el dibujo a un archivo.txt? S/N"); + opcionExportar = entrada.next().charAt(0); + + if (opcionExportar != 'S' && opcionExportar != 'N' && opcionExportar !='s' && opcionExportar !='n') { + System.out.println("Opcion invalida. Por favor, ingrese S o N."); + } + }while(opcionExportar != 'S' && opcionExportar != 'N'&& opcionExportar !='s' && opcionExportar !='n'); + + if (opcionExportar == 'S' || opcionExportar == 's') { + System.out.println("Ingrese el nombre que desea asignarle al archivo (sin extension): "); + nombre = entrada.next(); + var = nombre + ".txt"; + exportar(lienzotren, var); + } + break; + case 3: + hiloHada.run(lienzoHada, 33, 20); + //hada.paint(20, 33, lienzoHada); + do{ + System.out.println("Desea exportar el dibujo a un archivo.txt? S/N"); + opcionExportar = entrada.next().charAt(0); + + if (opcionExportar != 'S' && opcionExportar != 'N' && opcionExportar !='s' && opcionExportar !='n') { + System.out.println("Opcion invalida. Por favor, ingrese S o N."); + } + }while(opcionExportar != 'S' && opcionExportar != 'N'&& opcionExportar !='s' && opcionExportar !='n'); + + + if (opcionExportar == 'S' || opcionExportar == 's') { + System.out.println("Ingrese el nombre que desea asignarle al archivo (sin extension): "); + nombre = entrada.next(); + var = nombre + ".txt"; + exportar(lienzoHada, var); + } + break; + case 4: + ventana=new Principal1(); + ventana.setVisible(true); + break; + case 5: + System.out.println("Ingrese el nombre de la imagen (incluyendo la extension):"); + nombreImagen = entrada.next(); + BufferedImage image = null; + + try { + image = ImageIO.read(new File(nombreImagen)); + } catch (IOException er) { + System.out.println("La imagen '" + nombreImagen + "' no se encuentra en el directorio."); + } + + int originalWidth = image.getWidth(); + int originalHeight = image.getHeight(); + + // Calcular la proporción de escalado para mantener la relación de aspecto + double scaleRatio = (double) targetWidth / originalWidth; + int targetHeight = (int) (originalHeight * scaleRatio); + + BufferedImage scaledImage = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_RGB); + Graphics2D g = scaledImage.createGraphics(); + g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + g.drawImage(image, 0, 0, targetWidth, targetHeight, null); + g.dispose(); + + final char[] ASCII_CHARS = {'@', '#', '8', '&', 'o', ':', '*', '.', ' '}; + + StringBuilder asciiImage = new StringBuilder(); + for (int h = 0; h < targetHeight; h++) { + for (int m = 0; m < targetWidth; m++) { + // Obtener el color del píxel + int color = scaledImage.getRGB(m, h); + int red = (color >> 16) & 0xff; + int green = (color >> 8) & 0xff; + int blue = color & 0xff; + + int gray = (red + green + blue) / 3; + + int index = gray * (ASCII_CHARS.length - 1) / 255; + asciiImage.append(ASCII_CHARS[index]); + } + asciiImage.append("\n"); + } + System.out.println(asciiImage.toString()); + break; + case 6: + System.out.println("Saliendo del programa..."); + return; + default: + System.out.println("Opcion no valida. Por favor, ingrese una de las opciones del menu."); + break; + } + } catch (Exception ex) { + + } + + do { + System.out.println("Desea realizar otra accion? S/N"); + opcionImpresion = entrada.next().charAt(0); + + if (opcionImpresion != 'S' && opcionImpresion != 'N' && opcionImpresion !='s' && opcionImpresion != 'n') { + System.out.println("Opcion invalida. Por favor, ingrese S o N."); + } + } while (opcionImpresion != 'S' && opcionImpresion != 'N' && opcionImpresion !='s' && opcionImpresion != 'n'); + + System.out.println("Opcion ingresada: " + opcionImpresion); + + } while (opcionImpresion == 'S' || opcionImpresion == 's'); + } + +} + + diff --git a/ASCII/src/Modelo/Tren.java b/ASCII/src/Modelo/Tren.java new file mode 100644 index 0000000..57a1058 --- /dev/null +++ b/ASCII/src/Modelo/Tren.java @@ -0,0 +1,126 @@ +package Modelo; + +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ + +/** + * + * @author reyes + */ +public class Tren extends Lienzo{ + public int x; + public int y; + + public Tren(int ancho, int alto, char lienzo [][]) { + super(ancho, alto, lienzo); + } + + public void pintarTren(char[][] lienzo){ + this.setPen(6,1,'/'); + this.setPen(6,2,'o'); + this.setPen(6,3,'O'); + this.setPen(6,4,'-'); + this.setPen(6,5,'-'); + this.setPen(6,6,'0'); + this.setPen(6,7,'0'); + this.setPen(6,8,'0'); + this.setPen(6,9,'`'); + this.setPen(6,10,'"'); + this.setPen(6,11,'`'); + this.setPen(6,12,'-'); + this.setPen(6,13,'O'); + this.setPen(6,14,'O'); + this.setPen(6,15,'-'); + this.setPen(6,16,'-'); + this.setPen(6,17,'-'); + this.setPen(6,18,'O'); + this.setPen(6,19,'O'); + this.setPen(6,20,'-'); + this.setPen(6,21,'`'); + this.setPen(5,2,'{'); + this.setPen(5,3,'='); + this.setPen(5,4,'='); + this.setPen(5,5,'='); + this.setPen(5,6,'='); + this.setPen(5,7,'='); + this.setPen(5,8,'='); + this.setPen(5,9,'|'); + this.setPen(5,10,'_'); + this.setPen(5,11,'|'); + this.setPen(5,12,'~'); + this.setPen(5,13,'~'); + this.setPen(5,14,'~'); + this.setPen(5,15,'~'); + this.setPen(5,16,'~'); + this.setPen(5,17,'~'); + this.setPen(5,18,'~'); + this.setPen(5,19,'~'); + this.setPen(5,20,'~'); + this.setPen(5,21,'|'); + this.setPen(4,3,'I'); + this.setPen(4,4,'I'); + this.setPen(4,5,'_'); + this.setPen(4,6,'_'); + this.setPen(4,7,'['); + this.setPen(4,8,'W'); + this.setPen(4,9,']'); + this.setPen(4,11,'|'); + this.setPen(4,13,'['); + this.setPen(4,14,'i'); + this.setPen(4,15,']'); + this.setPen(4,17,'['); + this.setPen(4,18,'z'); + this.setPen(4,19,']'); + this.setPen(4,21,'|'); + this.setPen(3,4,'@'); + this.setPen(3,5,'"'); + this.setPen(3,7,'_'); + this.setPen(3,8,'_'); + this.setPen(3,9,'_'); + this.setPen(3,11,'_'); + this.setPen(3,12,'_'); + this.setPen(3,13,'_'); + this.setPen(3,14,'_'); + this.setPen(3,15,'_'); + this.setPen(3,16,'_'); + this.setPen(3,17,'_'); + this.setPen(3,18,'_'); + this.setPen(3,19,'_'); + this.setPen(3,20,'_'); + this.setPen(3,21,'_'); + + this.setPen(2,5,'@'); + this.setPen(2,6,'@'); + this.setPen(2,7,'@'); + this.setPen(2,8,'"'); + this.setPen(2,9,'"'); + this.setPen(2,10,'"'); + this.setPen(2,11,'"'); + this.setPen(2,12,'"'); + this.setPen(2,13,'"'); + this.setPen(2,14,'"'); + this.setPen(2,15,'"'); + this.setPen(2,16,'"'); + this.setPen(2,17,'"'); + + this.setPen(1,6,'e'); + this.setPen(1,7,'@'); + this.setPen(1,8,'@'); + this.setPen(1,9,'@'); + this.setPen(1,10,'@'); + this.setPen(1,11,'@'); + this.setPen(1,12,'@'); + this.setPen(1,13,'@'); + this.setPen(1,14,'@'); + this.setPen(1,15,'@'); + this.setPen(1,16,'@'); + this.setPen(1,17,'@'); + this.setPen(1,18,'@'); + this.setPen(1,19,'@'); + this.setPen(1,20,'@'); + this.setPen(1,21,'@'); + } + +} \ No newline at end of file diff --git a/ASCII/src/Modelo/WS.java b/ASCII/src/Modelo/WS.java new file mode 100644 index 0000000..ad69979 --- /dev/null +++ b/ASCII/src/Modelo/WS.java @@ -0,0 +1,45 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package Modelo; +import java.io.File; +import java.io.IOException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import okhttp3.FormBody; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okio.BufferedSource; +import okio.ByteString; +import org.apache.commons.io.FileUtils; +/** + * + * @author Hp + */ +public class WS { + public int filas=5; + public int col=5; + +public void enviarMsj(String numeroTelefonico) throws IOException { + OkHttpClient client = new OkHttpClient(); + MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); + byte[] fileContent = FileUtils.readFileToByteArray(new File("matriz.pdf")); + String pdf = Base64.getEncoder().encodeToString(fileContent); + pdf=URLEncoder.encode(pdf, StandardCharsets.UTF_8.toString()); + RequestBody body = RequestBody.create(mediaType, "token=1ll1iyc008r882c9&to="+numeroTelefonico+"&document=" + pdf+"&filename=ultramsg.pdf"); + Request request = new Request.Builder() + .url("https://api.ultramsg.com/instance68828/messages/document") + .post(body) + .addHeader("content-type", "application/x-www-form-urlencoded") + .build(); + +Response response = client.newCall(request).execute(); + +} + +} diff --git a/ASCII/src/Vista/Principal1.form b/ASCII/src/Vista/Principal1.form new file mode 100644 index 0000000..769eecd --- /dev/null +++ b/ASCII/src/Vista/Principal1.form @@ -0,0 +1,35 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/ASCII/src/Vista/Principal1.java b/ASCII/src/Vista/Principal1.java new file mode 100644 index 0000000..50b994f --- /dev/null +++ b/ASCII/src/Vista/Principal1.java @@ -0,0 +1,159 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template + */ +package Vista; + +import Controlador.GestionSize1; +import Controlador.GestionTextFields; +import java.awt.Color; +import java.awt.Font; +import java.awt.GridLayout; +import java.awt.TextField; +import java.util.ArrayList; +import javax.swing.*; +import javax.swing.border.Border; +import javax.swing.border.EtchedBorder; +import javax.swing.border.TitledBorder; + +/** + * + * @author Hp + */ +public class Principal1 extends javax.swing.JFrame { + + + public JPanel panelP=new JPanel(); + public int filas; + public int col; + public JTextField panel; + public JButton incrementSize=new JButton(" Aumentar"); + public JTextField[][]matriz; + public JTextField[][] matrizGuardar; + public JButton guardar=new JButton("Guardar"); + public JButton regresar=new JButton("Regresar"); + + + ImageIcon iconIncrement = new ImageIcon("src/images/boton-agregar.png"); + ImageIcon iconSave = new ImageIcon("src/images/disquete.png"); + ImageIcon iconBack = new ImageIcon("src/images/deshacer.png"); + + Border bordejpanel = new TitledBorder(new EtchedBorder(), ""); + + public Principal1() { + Font fuente=new Font("Dialog", Font.BOLD, 30); + filas=5; + col=5; + matriz=new JTextField[filas][col]; + this.panelP.setLayout(new GridLayout(filas, col,3,3)); + for(int i=0;i//GEN-BEGIN:initComponents + private void initComponents() { + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 400, Short.MAX_VALUE) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 300, Short.MAX_VALUE) + ); + + pack(); + }// //GEN-END:initComponents + + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(Principal1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(Principal1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(Principal1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(Principal1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new Principal1().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables +} diff --git a/ASCII/src/images/boton-agregar.png b/ASCII/src/images/boton-agregar.png new file mode 100644 index 0000000000000000000000000000000000000000..1c9e610f1f7ddeed541646dd6ca946fcc444d0a0 GIT binary patch literal 706 zcmV;z0zLhSP)m-{oX{_gl#`Gw(JX3l)ixpU6U znPI)7B~iB@gXlvyHsLR3@Bz1Q6;D>v$r?^$5_1*XB#ue@!BX_#VFU4NoWntMp^mor zK7{k3lk4Bd*5w)>#FrqN!7y4Y%&TJrQ!)1=_M{p=fZstdhW1nfbjI8{{7G@52j64j z1uKhV3q}-BxF6C*y)rKpOQe=A- zoDAI;iz)05g(=mtJ=K9$ybb-Gd1tLb;Yi4F%vK~#!7MJv_u(=Jc7?pL2F7#b`7%&8 z_+GX=T?vFKArRd8QM~{^VsJyr*o5*kf2nr6gr_aWzU3W_A;=T2Uh!|5p=@R9|H*ln ziAh@$jiiL2H}t3Tj>Z*u6>>)cVJfzTd|Bqeosj$2(1D?lcgqF`6g9tU9;6;bd6@ea zQ+gT-BWvKmSxt^&va45q9CubAy&0_;I`A&IPb{TaljXu{mg5?(1?Ph*oW1xQ6Gm6) zL=6{%>yu&^G{rvIHEK>)oR)JX>%jHk_-PrtYoB5zre*cK%I;{z8AZ&$VsEPP9KDL1 zn8O>{wR}icSlX}=+hw=tONylYq=g#xox%ZxXxaWVTSz_!GIykP#OD>ji zgCGAwd=-OOOqBJ6_{0n}u$dx05d%$Z4-qeIVB9Ha;VoW`$T`RSpKqNBo3j$y_+a?V z)8adNcqS}cVP^3ur+6~H;As)@$Jj3^9>t~6%l8*^_*Rj46xVr7e63hK{wEgG1g8?u zb)DIbC!$3q= zxFw_flQIS<){=FFYB&&X%+eHTN?!{1!q522>4FB{2s^)@V@wYh>MQs6+);i5{c8$a TJ`^9x00000NkvXXu0mjfQ8LW| literal 0 HcmV?d00001 diff --git a/ASCII/src/images/disquete.png b/ASCII/src/images/disquete.png new file mode 100644 index 0000000000000000000000000000000000000000..a35cd158106f6f0a54eac979d2469811c172ad18 GIT binary patch literal 492 zcmVP_;R6KJ7f|28 zdk8BFvCvL1jpc!bT`c@~0kyR=T|~y>X7QA}nB+cUaeo+?U6%d-c5hg2P*s2ch=6xM zON>WgUR817%m*bKXF`abd>!}z&Vd&oB-V|^xM~82mUn@BU=7%^xhG&lRo~$I+D{YL z;%LLxc-%t(j9>M2>QrwOwM5QVZzVR1d0ePF)Ou ifQs95HIE1gRFyBA>GW$yLt6y^0000