Hala Madrid!! 14 Champions Proyecto ASCII

This commit is contained in:
sebastiancc27 2024-02-28 08:10:24 -06:00
parent ea0c9622cf
commit e60f16bf68
20 changed files with 3082 additions and 0 deletions

73
ASCII/build.xml Normal file
View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="ASCII" default="default" basedir=".">
<description>Builds, tests, and runs the project ASCII.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar: JAR building
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="ASCII-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>

3
ASCII/manifest.mf Normal file
View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>ASCII</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots>
<root id="test.src.dir"/>
</test-roots>
</data>
</configuration>
</project>

View File

@ -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;i<nFilas;i++){
for(int j=0;j<nCol;j++){
JTextField panel=new JTextField();
panel.setFont(fuente);
panel.setText(" ");
panel.addKeyListener(new GestionTextFields(v, panel));
matriz[i][j]=panel;
}
}
for(int i=0;i<nFilas;i++){
for(int j=0;j<nCol;j++){
v.panelP.add(matriz[i][j]);
}
}
v.panelP.revalidate();
v.panelP.repaint();
v.col=nCol;
v.filas=nFilas;
v.setMatriz(matriz);
}
if (e.getSource() == v.guardar) {
int filas = v.filas;
int col = v.col;
int opcionCompartir;
String filePath = "matriz.pdf";
System.out.println("FILAS: " + v.filas + " COL: " + v.col);
char[][] matriz = new char[filas][col];
JTextField[][] matriz2 = new JTextField[filas][col];
matriz2 = v.getMatriz();
for (int i = 0; i < filas; i++) {
for (int j = 0; j < col; j++) {
//matriz[i][j]=matriz2[i][j].toString().charAt(0);
System.out.print(matriz2[i][j].getText());
}
System.out.println("");
}
try {
generarPDF(matriz2, filePath);
System.out.println("PDF creado exitosamente en: " + filePath);
opcionCompartir=JOptionPane.showConfirmDialog(null, "Desea enviar el documento a su WhatsApp?: ");
if(opcionCompartir==0){
numeroTelefonico=JOptionPane.showInputDialog("Ingrese su número telefónico");
System.out.println("Numero "+numeroTelefonico);
ws.enviarMsj(numeroTelefonico);
}else{
return;
}
} catch (Exception em) {
//em.printStackTrace();
System.out.println("Alguo salio mal al guardar o enviar msj: "+em.toString());
}
}
if(e.getSource()==v.regresar){
v.dispose();
return;
}
}
}

View File

@ -0,0 +1,41 @@
/*
* 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 Vista.Principal1;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JTextField;
/**
*
* @author Hp
*/
public class GestionTextFields implements KeyListener{
private Principal1 p;
JTextField panel;
int cont=0;
public GestionTextFields(Principal1 p, JTextField panel){
this.p=p;
this.panel=panel;
}
@Override
public void keyTyped(KeyEvent e) {
cont++;
if(cont>1) 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
}
}

View File

@ -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, '^');
}
}

135
ASCII/src/Modelo/Hada.java Normal file
View File

@ -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, '^');
}
}

View File

@ -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("");
}
}
}

View File

@ -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<filas;i++){
for(int j=0;j<col;j++){
lienzo[i][j]=' ';
}
System.out.println("");
}
}
public void setPen(int x, int y, char c){
lienzo[x][y]=c;
}
public void paint(int filas, int col, char[][] lienzo){
for(int i=0;i<filas;i++){
for(int j=0;j<col;j++){
System.out.print(lienzo[i][j]);
}
System.out.println("");
}
}
}

303
ASCII/src/Modelo/Main.java Normal file
View File

@ -0,0 +1,303 @@
package Modelo;
import Vista.Principal1;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
/*
* 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
*/
import java.util.ArrayList;
import javax.imageio.ImageIO;
public class Main {
/**
* @param args the command line arguments
*/
public static void imprimirArray(ArrayList<Integer> array){
for(int i=0;i<array.size();i++){
System.out.println(array.get(i));
}
}
public static void imprimeCaracteres(char[] array, int tam){
System.out.println("IMPRIMIENDO LOS CARACTERES");
for(int i=0;i<tam;i++){
System.out.println(array[i]);
}
}
public static int obtenerMaximo(ArrayList<Integer> array){
int anchoMax=array.get(0);
for(int i=0;i<array.size();i++){
if(anchoMax<array.get(i)){
anchoMax=array.get(i);
}
}
return (anchoMax+2);
}
public static void pintarMatrizManual(int filas, int col, char[][] lienzo){
for(int i=0;i<filas;i++){
for(int j=0;j<col;j++){
System.out.print(lienzo[i][j]);
}
System.out.println("");
}
}
public static void limpiarMatriz(char[][] lienzo, int filas, int col){
for(int i=0;i<filas;i++){
for(int j=0;j<col;j++){
lienzo[i][j]='#';
}
System.out.println("");
}
}
public static void llenarMatrizManuel(char[][] matriz,char caracter, int x, int y ){
matriz[x][y]=caracter;
}
public static void exportar(char[][] matriz, String filename) {
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(filename));
for (int i = 0; i < matriz.length; i++) {
for (int j = 0; j < matriz[i].length; j++) {
writer.write(matriz[i][j]);
if (j < matriz[i].length - 1) {
writer.write(""); // Tabular para separar columnas
}
}
writer.newLine(); // Nueva línea para cada fila
}
writer.close();
System.out.println("Matriz exportada exitosamente al archivo: " + filename);
} catch (IOException e) {
System.err.println("Error al exportar la matriz al archivo: " + e.getMessage());
}
}
public static void main(String[] args) {
int opcionFigura;
char opcionImpresion;
int puntosLienzo=0;
char opcionModificacion;
char opcionExportar;
String nombre;
String var;
Boolean ciclo = true;
String nombreImagen;
int targetWidth = 100;
char[][] lienzoManuel;
char[][] lienzoR;
int x,y;
char caracter;
Principal1 ventana;
ArrayList<Integer> xS=new ArrayList<>();
ArrayList<Integer> 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');
}
}

126
ASCII/src/Modelo/Tren.java Normal file
View File

@ -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,'@');
}
}

45
ASCII/src/Modelo/WS.java Normal file
View File

@ -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();
}
}

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="400" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="300" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Form>

View File

@ -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<filas;i++){
for(int j=0;j<col;j++){
this.panel=new JTextField();
//panel.setBackground(Color.GREEN);
panel.setFont(fuente);
panel.setText(" ");
panel.addKeyListener(new GestionTextFields(this, panel));
panel.setBorder( BorderFactory.createLoweredBevelBorder());
matriz[i][j]=panel;
}
}
this.setLayout(null);
for(int i=0;i<filas;i++){
for(int j=0;j<col;j++){
this.panelP.add(matriz[i][j]);
}
}
//BOTONES
incrementSize.setIcon(iconIncrement);
incrementSize.setBounds(20,420,130,50);
guardar.setIcon(iconSave);
guardar.setBounds(210, 420, 150, 50);
regresar.setIcon(iconBack);
regresar.setBounds(400,420,150,50);
panelP.setBackground(Color.red);
this.panelP.setBounds(15,10,550,400);
incrementSize.addActionListener(new GestionSize1(this));
guardar.addActionListener(new GestionSize1(this));
regresar.addActionListener(new GestionSize1(this));
this.add(panelP);
this.add(incrementSize);
this.add(guardar);
this.add(regresar);
this.setSize(600,550);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
this.setLocationRelativeTo(null);
this.setResizable(false);
}
public void setMatriz(JTextField[][] matriz){
this.matriz=matriz;
}
public JTextField[][] getMatriz(){
return this.matriz;
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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();
}// </editor-fold>//GEN-END:initComponents
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* 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);
}
//</editor-fold>
//</editor-fold>
/* 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
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 B