Clasificacion por fecha y posibilidad de aniadir mas gestiones por mes

This commit is contained in:
Guillermo Roche 2019-11-13 22:51:49 +01:00
parent 7d6a253033
commit 7b52f06a51
6 changed files with 66 additions and 3 deletions

Binary file not shown.

Binary file not shown.

View File

@ -9,6 +9,7 @@ public class Gestion{
private static float total; private static float total;
private static Month mes; private static Month mes;
private static Year anio; private static Year anio;
private static String nombre;
public Gestion() { public Gestion() {
this.gestiones=new Vector<Transaccion>(); this.gestiones=new Vector<Transaccion>();
@ -16,6 +17,17 @@ public class Gestion{
Gestion.total=0; Gestion.total=0;
} }
public Gestion(String nombre) {
this.gestiones=new Vector<Transaccion>();
this.suma=0;
Gestion.total=0;
this.nombre=nombre;
}
public String getNombre() {
return this.nombre;
}
public void aniadirGasto(Transaccion transaccion) { public void aniadirGasto(Transaccion transaccion) {
this.gestiones.add(transaccion); this.gestiones.add(transaccion);
this.suma+=transaccion.getDinero(); this.suma+=transaccion.getDinero();

27
src/Logica/Meses.java Normal file
View File

@ -0,0 +1,27 @@
package Logica;
import java.time.Month;
import java.util.ArrayList;
public class Meses {
private ArrayList<Mes> meses;
public Meses() {
this.meses=new ArrayList<Mes>();
}
public void aniadirTransaccion() {
}
}
class Mes{
private int anio;
private Month mes;
int total;
ArrayList<Gestion> gestiones;
Mes(ArrayList<Gestion> gestiones){
this.gestiones=gestiones;
}
}

View File

@ -50,4 +50,8 @@ public class Transaccion {
public boolean isPositivo() { public boolean isPositivo() {
return this.positivo; return this.positivo;
} }
public LocalDate getDia() {
return this.dia;
}
} }

View File

@ -4,19 +4,26 @@ import java.awt.Frame;
import java.awt.GridBagConstraints; import java.awt.GridBagConstraints;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.time.Year;
import javax.swing.JFrame; import javax.swing.JFrame;
import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame; import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart; import org.jfree.chart.JFreeChart;
import org.jfree.data.time.Month;
import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection; import org.jfree.data.xy.XYSeriesCollection;
import com.github.lgooddatepicker.components.DatePicker; import com.github.lgooddatepicker.components.DatePicker;
import com.github.lgooddatepicker.optionalusertools.DateChangeListener;
import com.github.lgooddatepicker.zinternaltools.DateChangeEvent;
import com.github.lgooddatepicker.zinternaltools.DemoPanel; import com.github.lgooddatepicker.zinternaltools.DemoPanel;
public class ControladorPanelLateral implements ActionListener{ public class ControladorPanelLateral implements ActionListener, DateChangeListener{
private VistaPanelLateral vista; private VistaPanelLateral vista;
private java.time.Month mes;
private int anio;
public ControladorPanelLateral(VistaPanelLateral vista) { public ControladorPanelLateral(VistaPanelLateral vista) {
this.vista=vista; this.vista=vista;
@ -45,8 +52,21 @@ public class ControladorPanelLateral implements ActionListener{
private void aniadirElementos() { private void aniadirElementos() {
this.vista.mostrarEstadisticas.addActionListener(this); this.vista.mostrarEstadisticas.addActionListener(this);
this.vista.mostrarEstadisticas.setActionCommand("Mostrar estadisticas"); this.vista.mostrarEstadisticas.setActionCommand("Mostrar estadisticas");
//this.vista.elegirMes.addActionListener(this); if(VistaPanelLateral.elegirMes.getDateChangeListeners().size()==0) {
//this.vista.elegirMes.setActionCommand("Elegir mes"); VistaPanelLateral.elegirMes.addDateChangeListener(this);
this.mes=VistaPanelLateral.elegirMes.getDate().getMonth();
this.anio=VistaPanelLateral.elegirMes.getDate().getYear();
}
}
public void dateChanged(DateChangeEvent arg0) {
if(this.mes!=VistaPanelLateral.elegirMes.getDate().getMonth() ||
this.anio!=VistaPanelLateral.elegirMes.getDate().getYear()) {
System.out.println("Cambia mes");
this.mes=VistaPanelLateral.elegirMes.getDate().getMonth();
this.anio=VistaPanelLateral.elegirMes.getDate().getYear();
}
} }
} }