From 8af689363a255b339475d3432f8f5e7e8f8c3731 Mon Sep 17 00:00:00 2001 From: roche Date: Tue, 12 Nov 2019 13:58:07 +0100 Subject: [PATCH] Iniciando funcionalidad estadisticas --- .classpath | 2 + bin/.gitignore | 2 - bin/Logica/Gestion.class | Bin 0 -> 1401 bytes bin/Logica/Transaccion.class | Bin 0 -> 1157 bytes ...java => ControladorAniadirVisualizar.java} | 18 ++++---- .../ControladorPanelLateral.java | 29 ++++++++++++ src/VistaControlador/Menu.java | 39 +++++++++++----- ...Vista.java => VistaAniadirVisualizar.java} | 16 ++++--- src/VistaControlador/VistaPanelLateral.java | 42 ++++++++++++++++++ 9 files changed, 118 insertions(+), 30 deletions(-) create mode 100644 bin/Logica/Gestion.class create mode 100644 bin/Logica/Transaccion.class rename src/VistaControlador/{Controlador.java => ControladorAniadirVisualizar.java} (79%) create mode 100644 src/VistaControlador/ControladorPanelLateral.java rename src/VistaControlador/{Vista.java => VistaAniadirVisualizar.java} (79%) create mode 100644 src/VistaControlador/VistaPanelLateral.java diff --git a/.classpath b/.classpath index 51a8bba..79207fa 100644 --- a/.classpath +++ b/.classpath @@ -2,5 +2,7 @@ + + diff --git a/bin/.gitignore b/bin/.gitignore index f9897f2..a1bbed7 100644 --- a/bin/.gitignore +++ b/bin/.gitignore @@ -1,3 +1 @@ /VistaControlador/ -/PedirDatos/ -/Logica/ diff --git a/bin/Logica/Gestion.class b/bin/Logica/Gestion.class new file mode 100644 index 0000000000000000000000000000000000000000..b2e20509f060b14ff313e02afbe5ffad9d125aa1 GIT binary patch literal 1401 zcmZ`&+fEZv6kVqmO3MJH)XGIs?rl-3h}Qy=cp)TJA4*E#$mpM~fwcM-no?dYUqP5n&-VjI>y!)nWn7I;fZ70uyqEWM?+jMk+^o4?zf={#M zNUI?$6;kEb_$<_D)}?^h6bQSvD@}o(6~i*zHGyC{Q)0yvyQ;?!L|lW0{sflC^~=uy#S4N=5YG^(KwF@eE?Vd*cM^|J14$+AhIiGp2`W=T4R%KgK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); + this.add(this.panel); } + + } diff --git a/src/VistaControlador/Vista.java b/src/VistaControlador/VistaAniadirVisualizar.java similarity index 79% rename from src/VistaControlador/Vista.java rename to src/VistaControlador/VistaAniadirVisualizar.java index fc2fcb2..b3b54c3 100644 --- a/src/VistaControlador/Vista.java +++ b/src/VistaControlador/VistaAniadirVisualizar.java @@ -11,21 +11,23 @@ import javax.swing.JScrollPane; import Logica.*; -public class Vista extends JPanel{ +public class VistaAniadirVisualizar extends JPanel{ private int x,y; - private static final int altocheck=28; + private static final int altoCheck=28; protected Gestion gestiones; protected JButton boton; protected LinkedList transacciones; JPanel cuadro; JScrollPane panel; Menu menu; - public Vista(Menu menu) { + + public VistaAniadirVisualizar(Menu menu, Gestion gestion) { + this.gestiones=gestion; this.transacciones=new LinkedList(); this.menu=menu; this.x=100; this.boton=new JButton("aniadir"); - this.gestiones=new Gestion(); + //this.gestiones=new Gestion(); this.add(boton); this.cuadro=new JPanel(); this.panel=new JScrollPane(cuadro); @@ -37,16 +39,16 @@ public class Vista extends JPanel{ this.add(panel); } - public void aniadirElemento(String nombre, int dinero, Controlador controlador) { + public void aniadirElemento(String nombre, int dinero, ControladorAniadirVisualizar controlador) { Transaccion transaccion=new Transaccion(nombre, dinero); this.gestiones.aniadirGasto(transaccion); JCheckBox check=new JCheckBox(transaccion.toString()); check.setSelected(true); - check.setSize(new Dimension(x,Vista.altocheck)); + check.setSize(new Dimension(x,VistaAniadirVisualizar.altoCheck)); check.addActionListener(controlador); this.transacciones.add(check); this.cuadro.add(check); - this.y+=Vista.altocheck; + this.y+=VistaAniadirVisualizar.altoCheck; cuadro.setPreferredSize(new Dimension(x, y)); this.revalidate(); this.repaint(); diff --git a/src/VistaControlador/VistaPanelLateral.java b/src/VistaControlador/VistaPanelLateral.java new file mode 100644 index 0000000..da35911 --- /dev/null +++ b/src/VistaControlador/VistaPanelLateral.java @@ -0,0 +1,42 @@ +package VistaControlador; + +import java.awt.GridBagConstraints; + +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JTextArea; + +import Logica.Gestion; + +public class VistaPanelLateral extends JPanel{ + protected JTextArea total; + protected JTextArea gastoEnvio; + protected JButton elegirMes; + protected JButton mostrarEstadisticas; + + VistaPanelLateral(GridBagConstraints constrain){ + this.total=new JTextArea(); + this.gastoEnvio=new JTextArea(); + this.elegirMes=new JButton("Elegir mes"); + this.mostrarEstadisticas=new JButton("Mostrar grafico del mes"); + this.add(this.mostrarEstadisticas); + constrain.gridx=1; + constrain.gridy=0; + constrain.weightx=2; + this.add(this.elegirMes); + constrain.gridx=1; + constrain.gridy=1; + constrain.weightx=2; + this.add(this.total); + constrain.gridx=1; + constrain.gridy=2; + constrain.weightx=2; + this.add(this.gastoEnvio); + } + + void actualizarDatos(Gestion gestion) { + this.total.setText("Total: "+String.valueOf(Gestion.getTotal())+"€"); + this.gastoEnvio.setText("Suma: "+String.valueOf(gestion.getSuma())+"€"); + } + +}