Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package ehospital; import edu.uci.ics.jung.algorithms.layout.FRLayout; import edu.uci.ics.jung.algorithms.layout.Layout; import edu.uci.ics.jung.algorithms.shortestpath.DijkstraShortestPath; import edu.uci.ics.jung.graph.SparseMultigraph; import edu.uci.ics.jung.graph.util.EdgeType; import edu.uci.ics.jung.visualization.BasicVisualizationServer; import edu.uci.ics.jung.visualization.decorators.ToStringLabeller; import edu.uci.ics.jung.visualization.renderers.Renderer; import java.awt.Color; import java.awt.Dimension; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; import javax.swing.DefaultComboBoxModel; import javax.swing.JFrame; import javax.swing.JOptionPane; import org.apache.commons.collections15.Transformer; /** * * @author jordi */ public class Principal extends javax.swing.JFrame { /** * Creates new form Principal */ public Principal() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jd_hospital_agregar = new javax.swing.JDialog(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); txt_hospital_nombre = new javax.swing.JTextField(); txt_hospital_direccion = new javax.swing.JTextField(); sp_hosp_param = new javax.swing.JSpinner(); sp_hosp_ambu = new javax.swing.JSpinner(); rb_hospital_a = new javax.swing.JRadioButton(); rb_hospital_b = new javax.swing.JRadioButton(); rb_hospital_c = new javax.swing.JRadioButton(); rb_hospital_d = new javax.swing.JRadioButton(); btn_hospital_agregar = new javax.swing.JButton(); jLabel6 = new javax.swing.JLabel(); rb_tipo_hosp = new javax.swing.JRadioButton(); rb_tipo_lug = new javax.swing.JRadioButton(); jLabel7 = new javax.swing.JLabel(); buttonGroup1 = new javax.swing.ButtonGroup(); jd_hospital_lugar_eliminar = new javax.swing.JDialog(); jLabel8 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); cb_hospital_eliminar = new javax.swing.JComboBox(); btn_hospital_eliminar = new javax.swing.JButton(); jd_paramedicos_agregar = new javax.swing.JDialog(); jLabel10 = new javax.swing.JLabel(); jLabel11 = new javax.swing.JLabel(); jLabel12 = new javax.swing.JLabel(); jLabel13 = new javax.swing.JLabel(); jLabel14 = new javax.swing.JLabel(); jLabel15 = new javax.swing.JLabel(); txt_param_nombre = new javax.swing.JTextField(); sp_param_edad = new javax.swing.JSpinner(); txt_param_ident = new javax.swing.JTextField(); rb_param_a = new javax.swing.JRadioButton(); rb_param_b = new javax.swing.JRadioButton(); rb_param_c = new javax.swing.JRadioButton(); rb_param_d = new javax.swing.JRadioButton(); cb_param_complejo = new javax.swing.JComboBox(); bnt_param_agregar = new javax.swing.JButton(); buttonGroup2 = new javax.swing.ButtonGroup(); jd_ambu_registrar = new javax.swing.JDialog(); jLabel16 = new javax.swing.JLabel(); jLabel17 = new javax.swing.JLabel(); jLabel18 = new javax.swing.JLabel(); jLabel19 = new javax.swing.JLabel(); jLabel20 = new javax.swing.JLabel(); txt_ambu_placa = new javax.swing.JTextField(); txt_ambu_ano = new javax.swing.JFormattedTextField(); sp_ambu_vel = new javax.swing.JSpinner(); cb_ambu_compl = new javax.swing.JComboBox(); btn_ambu_agregar = new javax.swing.JButton(); jd_ambu_eliminar = new javax.swing.JDialog(); jLabel21 = new javax.swing.JLabel(); jLabel22 = new javax.swing.JLabel(); cb_ambu_eliminar = new javax.swing.JComboBox(); btn_ambu_eliminar = new javax.swing.JButton(); jd_paramedicos_reasignar = new javax.swing.JDialog(); jLabel23 = new javax.swing.JLabel(); jLabel24 = new javax.swing.JLabel(); cb_param_reasignar_nombre = new javax.swing.JComboBox(); jLabel25 = new javax.swing.JLabel(); cb_param_reasignar_complejo = new javax.swing.JComboBox(); btn_param_reasginar_param = new javax.swing.JButton(); jd_ambu_reasignar = new javax.swing.JDialog(); jLabel26 = new javax.swing.JLabel(); jLabel27 = new javax.swing.JLabel(); cb_ambu_reasignar_placa = new javax.swing.JComboBox(); jLabel28 = new javax.swing.JLabel(); cb_ambu_reasignar_complejo = new javax.swing.JComboBox(); btn_ambu_reasignar = new javax.swing.JButton(); jd_crear_relaciones = new javax.swing.JDialog(); btn_agregar_relaciones = new javax.swing.JButton(); js_nivel = new javax.swing.JSpinner(); jLabel29 = new javax.swing.JLabel(); jLabel30 = new javax.swing.JLabel(); jLabel31 = new javax.swing.JLabel(); cb_de_relacion = new javax.swing.JComboBox(); cb_a_relacion = new javax.swing.JComboBox(); jd_archivos_guardar = new javax.swing.JDialog(); jLabel32 = new javax.swing.JLabel(); btn_guardar_complejos = new javax.swing.JButton(); btn_guardar_param = new javax.swing.JButton(); btn_guardar_ambu = new javax.swing.JButton(); jd_archivos_cargar = new javax.swing.JDialog(); jLabel33 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); btn_cargar_param = new javax.swing.JButton(); btn_cargar_ambu = new javax.swing.JButton(); jd_emergencias_crear = new javax.swing.JDialog(); jLabel34 = new javax.swing.JLabel(); jLabel35 = new javax.swing.JLabel(); cb_emergencia_de = new javax.swing.JComboBox(); jLabel36 = new javax.swing.JLabel(); rb_emer_a = new javax.swing.JRadioButton(); rb_emer_b = new javax.swing.JRadioButton(); rb_emer_c = new javax.swing.JRadioButton(); rb_emer_d = new javax.swing.JRadioButton(); btn_emergencia_buscarruta = new javax.swing.JButton(); jLabel41 = new javax.swing.JLabel(); cb_emergencia_a = new javax.swing.JComboBox(); buttonGroup3 = new javax.swing.ButtonGroup(); jd_dijsktra = new javax.swing.JDialog(); jLabel37 = new javax.swing.JLabel(); jLabel38 = new javax.swing.JLabel(); txt_recorrido_de = new javax.swing.JTextField(); txt_recorrido_a = new javax.swing.JTextField(); jLabel39 = new javax.swing.JLabel(); jScrollPane4 = new javax.swing.JScrollPane(); ta_pizarra = new javax.swing.JTextArea(); jLabel40 = new javax.swing.JLabel(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu1 = new javax.swing.JMenu(); jMenuItem_agregar_hospital = new javax.swing.JMenuItem(); jMenuItem_eliminar_hospital = new javax.swing.JMenuItem(); jMenuItem_agregar_paramedicos = new javax.swing.JMenuItem(); jMenuItem_registrar_ambulancia = new javax.swing.JMenuItem(); jMenuItem_eliminar_ambulancia = new javax.swing.JMenuItem(); jMenuItem_reasignar_paramedicos = new javax.swing.JMenuItem(); jMenuItem_reasignar_ambulancia = new javax.swing.JMenuItem(); jMenuItem_cargar_archivos = new javax.swing.JMenuItem(); jMenuItem_guardar_archivos = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu(); jMenuItem_crear_relaciones = new javax.swing.JMenuItem(); jMenuItem_ver_mapa = new javax.swing.JMenuItem(); jMenu3 = new javax.swing.JMenu(); jMenuItem_emergencia_crear = new javax.swing.JMenuItem(); jLabel1.setText("Nombre:"); jLabel2.setText("Direccion:"); jLabel3.setText("Capacidad de Paramedicos Maxima:"); jLabel4.setText("Capacidad de Ambulancias Maxima:"); jLabel5.setText("Ranking de Emergencias que se pueden atender:"); txt_hospital_nombre.setEnabled(false); txt_hospital_direccion.setEnabled(false); sp_hosp_param.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), Integer.valueOf(1), null, Integer.valueOf(1))); sp_hosp_param.setEnabled(false); sp_hosp_ambu.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(1), Integer.valueOf(1), null, Integer.valueOf(1))); sp_hosp_ambu.setEnabled(false); rb_hospital_a.setText("A"); rb_hospital_a.setEnabled(false); rb_hospital_b.setText("B"); rb_hospital_b.setEnabled(false); rb_hospital_c.setText("C"); rb_hospital_c.setEnabled(false); rb_hospital_d.setText("D"); rb_hospital_d.setEnabled(false); btn_hospital_agregar.setText("Guardar"); btn_hospital_agregar.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { btn_hospital_agregarMouseClicked(evt); } }); jLabel6.setText("Agregar Lugar o Hospital"); buttonGroup1.add(rb_tipo_hosp); rb_tipo_hosp.setText("Hospital"); rb_tipo_hosp.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { rb_tipo_hospActionPerformed(evt); } }); buttonGroup1.add(rb_tipo_lug); rb_tipo_lug.setText("Lugar"); rb_tipo_lug.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { rb_tipo_lugActionPerformed(evt); } }); jLabel7.setText("Tipo:"); javax.swing.GroupLayout jd_hospital_agregarLayout = new javax.swing.GroupLayout( jd_hospital_agregar.getContentPane()); jd_hospital_agregar.getContentPane().setLayout(jd_hospital_agregarLayout); jd_hospital_agregarLayout.setHorizontalGroup(jd_hospital_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_hospital_agregarLayout.createSequentialGroup().addGroup(jd_hospital_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_hospital_agregarLayout.createSequentialGroup().addContainerGap() .addGroup(jd_hospital_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_hospital_agregarLayout.createSequentialGroup() .addComponent(jLabel5) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(rb_hospital_a) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(rb_hospital_b) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(rb_hospital_c) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(rb_hospital_d)) .addGroup(jd_hospital_agregarLayout.createSequentialGroup() .addGroup(jd_hospital_agregarLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1).addComponent(jLabel2) .addComponent(jLabel3).addComponent(jLabel4)) .addGap(69, 69, 69) .addGroup(jd_hospital_agregarLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(sp_hosp_ambu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(sp_hosp_param, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jd_hospital_agregarLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(txt_hospital_nombre) .addComponent(txt_hospital_direccion, javax.swing.GroupLayout.DEFAULT_SIZE, 145, Short.MAX_VALUE)) .addComponent(jLabel6))))) .addGroup(jd_hospital_agregarLayout.createSequentialGroup().addGap(221, 221, 221) .addComponent(btn_hospital_agregar))) .addContainerGap(180, Short.MAX_VALUE)) .addGroup(jd_hospital_agregarLayout.createSequentialGroup().addContainerGap().addComponent(jLabel7) .addGap(62, 62, 62).addComponent(rb_tipo_hosp) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(rb_tipo_lug).addGap(126, 126, 126))); jd_hospital_agregarLayout.setVerticalGroup(jd_hospital_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jd_hospital_agregarLayout .createSequentialGroup().addContainerGap().addComponent(jLabel6).addGap(15, 15, 15) .addGroup(jd_hospital_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(rb_tipo_hosp).addComponent(rb_tipo_lug).addComponent(jLabel7)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE) .addGroup(jd_hospital_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1).addComponent(txt_hospital_nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jd_hospital_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2).addComponent(txt_hospital_direccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jd_hospital_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3).addComponent(sp_hosp_param, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jd_hospital_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4).addComponent(sp_hosp_ambu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jd_hospital_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel5).addComponent(rb_hospital_a).addComponent(rb_hospital_b) .addComponent(rb_hospital_c).addComponent(rb_hospital_d)) .addGap(31, 31, 31).addComponent(btn_hospital_agregar).addGap(20, 20, 20))); jLabel8.setText("Eliminar Hospital"); jLabel9.setText("Selecione Hospital a Eliminar "); btn_hospital_eliminar.setText("Eliminar Hospital"); btn_hospital_eliminar.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { btn_hospital_eliminarMouseClicked(evt); } }); javax.swing.GroupLayout jd_hospital_lugar_eliminarLayout = new javax.swing.GroupLayout( jd_hospital_lugar_eliminar.getContentPane()); jd_hospital_lugar_eliminar.getContentPane().setLayout(jd_hospital_lugar_eliminarLayout); jd_hospital_lugar_eliminarLayout.setHorizontalGroup( jd_hospital_lugar_eliminarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_hospital_lugar_eliminarLayout.createSequentialGroup() .addGroup(jd_hospital_lugar_eliminarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_hospital_lugar_eliminarLayout.createSequentialGroup() .addContainerGap().addComponent(jLabel9)) .addGroup(jd_hospital_lugar_eliminarLayout.createSequentialGroup() .addGap(152, 152, 152).addComponent(jLabel8)) .addGroup(jd_hospital_lugar_eliminarLayout.createSequentialGroup() .addGap(104, 104, 104).addComponent(cb_hospital_eliminar, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jd_hospital_lugar_eliminarLayout.createSequentialGroup() .addGap(133, 133, 133).addComponent(btn_hospital_eliminar))) .addContainerGap(126, Short.MAX_VALUE))); jd_hospital_lugar_eliminarLayout.setVerticalGroup(jd_hospital_lugar_eliminarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_hospital_lugar_eliminarLayout.createSequentialGroup().addContainerGap() .addComponent(jLabel8).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel9).addGap(18, 18, 18) .addComponent(cb_hospital_eliminar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(78, 78, 78).addComponent(btn_hospital_eliminar) .addContainerGap(111, Short.MAX_VALUE))); jLabel10.setText("Agregar Paramedicos"); jLabel11.setText("Nombre Completo:"); jLabel12.setText("Edad:"); jLabel13.setText("Numero de Identidad:"); jLabel14.setText("Ranking:"); jLabel15.setText("Complejo que sera Asignado:"); sp_param_edad.setModel(new javax.swing.SpinnerNumberModel(18, 18, 60, 1)); buttonGroup2.add(rb_param_a); rb_param_a.setText("A"); buttonGroup2.add(rb_param_b); rb_param_b.setText("B"); buttonGroup2.add(rb_param_c); rb_param_c.setText("C"); buttonGroup2.add(rb_param_d); rb_param_d.setText("D"); bnt_param_agregar.setText("Agregar"); bnt_param_agregar.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { bnt_param_agregarMouseClicked(evt); } }); javax.swing.GroupLayout jd_paramedicos_agregarLayout = new javax.swing.GroupLayout( jd_paramedicos_agregar.getContentPane()); jd_paramedicos_agregar.getContentPane().setLayout(jd_paramedicos_agregarLayout); jd_paramedicos_agregarLayout.setHorizontalGroup(jd_paramedicos_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_paramedicos_agregarLayout.createSequentialGroup().addGroup(jd_paramedicos_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_paramedicos_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(jd_paramedicos_agregarLayout.createSequentialGroup().addGap(126, 126, 126) .addComponent(jLabel10)) .addGroup(jd_paramedicos_agregarLayout.createSequentialGroup().addContainerGap() .addComponent(jLabel15) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(cb_param_complejo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(jd_paramedicos_agregarLayout.createSequentialGroup().addContainerGap() .addGroup(jd_paramedicos_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel11).addComponent(jLabel12) .addComponent(jLabel13).addComponent(jLabel14)) .addGap(44, 44, 44) .addGroup(jd_paramedicos_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_paramedicos_agregarLayout.createSequentialGroup() .addComponent(rb_param_a) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(rb_param_b) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(rb_param_c) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(rb_param_d)) .addGroup(jd_paramedicos_agregarLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(sp_param_edad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txt_param_nombre) .addComponent(txt_param_ident, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE))))) .addGroup(jd_paramedicos_agregarLayout.createSequentialGroup().addGap(149, 149, 149) .addComponent(bnt_param_agregar))) .addContainerGap(86, Short.MAX_VALUE))); jd_paramedicos_agregarLayout.setVerticalGroup(jd_paramedicos_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_paramedicos_agregarLayout.createSequentialGroup().addContainerGap() .addComponent(jLabel10).addGap(18, 18, 18) .addGroup(jd_paramedicos_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel11).addComponent(txt_param_nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jd_paramedicos_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel12).addComponent(sp_param_edad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jd_paramedicos_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel13).addComponent(txt_param_ident, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jd_paramedicos_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel14).addComponent(rb_param_a).addComponent(rb_param_b) .addComponent(rb_param_c).addComponent(rb_param_d)) .addGap(18, 18, 18) .addGroup(jd_paramedicos_agregarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel15).addComponent(cb_param_complejo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE) .addComponent(bnt_param_agregar).addGap(29, 29, 29))); jLabel16.setText("Registrar Ambulancia"); jLabel17.setText("Numero de placa:"); jLabel18.setText("Ao del vehiculo:"); jLabel19.setText("Velocidad maxima en kmph:"); jLabel20.setText("Complejo en el cual estara asignado:"); try { txt_ambu_ano.setFormatterFactory( new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("####"))); } catch (java.text.ParseException ex) { ex.printStackTrace(); } sp_ambu_vel.setModel(new javax.swing.SpinnerNumberModel(1, 1, 180, 10)); btn_ambu_agregar.setText("Agregar"); btn_ambu_agregar.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { btn_ambu_agregarMouseClicked(evt); } }); javax.swing.GroupLayout jd_ambu_registrarLayout = new javax.swing.GroupLayout( jd_ambu_registrar.getContentPane()); jd_ambu_registrar.getContentPane().setLayout(jd_ambu_registrarLayout); jd_ambu_registrarLayout.setHorizontalGroup(jd_ambu_registrarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_ambu_registrarLayout.createSequentialGroup().addGroup(jd_ambu_registrarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(btn_ambu_agregar) .addGroup(jd_ambu_registrarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_ambu_registrarLayout.createSequentialGroup().addContainerGap() .addComponent(jLabel17)) .addGroup(jd_ambu_registrarLayout.createSequentialGroup().addGap(143, 143, 143) .addComponent(jLabel16)) .addGroup(jd_ambu_registrarLayout.createSequentialGroup().addContainerGap() .addGroup(jd_ambu_registrarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel18).addComponent(jLabel19) .addComponent(jLabel20))))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jd_ambu_registrarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(txt_ambu_placa).addComponent(txt_ambu_ano) .addComponent(cb_ambu_compl, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(sp_ambu_vel, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)) .addGap(65, 65, 65))); jd_ambu_registrarLayout.setVerticalGroup(jd_ambu_registrarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_ambu_registrarLayout.createSequentialGroup().addContainerGap().addComponent(jLabel16) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jd_ambu_registrarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel17).addComponent(txt_ambu_placa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jd_ambu_registrarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel18).addComponent(txt_ambu_ano, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jd_ambu_registrarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel19).addComponent(sp_ambu_vel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jd_ambu_registrarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel20).addComponent(cb_ambu_compl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(52, 52, 52).addComponent(btn_ambu_agregar).addContainerGap(55, Short.MAX_VALUE))); jLabel21.setText("Eliminar"); jLabel22.setText("Seleccione ambulancia que desea eliminar:"); btn_ambu_eliminar.setText("Eliminar Ambulancia"); btn_ambu_eliminar.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { btn_ambu_eliminarMouseClicked(evt); } }); javax.swing.GroupLayout jd_ambu_eliminarLayout = new javax.swing.GroupLayout( jd_ambu_eliminar.getContentPane()); jd_ambu_eliminar.getContentPane().setLayout(jd_ambu_eliminarLayout); jd_ambu_eliminarLayout.setHorizontalGroup( jd_ambu_eliminarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_ambu_eliminarLayout.createSequentialGroup().addGroup(jd_ambu_eliminarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_ambu_eliminarLayout.createSequentialGroup().addGap(144, 144, 144) .addComponent(jLabel21)) .addGroup(jd_ambu_eliminarLayout.createSequentialGroup().addContainerGap() .addComponent(jLabel22)) .addGroup(jd_ambu_eliminarLayout.createSequentialGroup().addGap(48, 48, 48) .addComponent(cb_ambu_eliminar, javax.swing.GroupLayout.PREFERRED_SIZE, 305, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jd_ambu_eliminarLayout.createSequentialGroup().addGap(145, 145, 145) .addComponent(btn_ambu_eliminar))) .addContainerGap(47, Short.MAX_VALUE))); jd_ambu_eliminarLayout.setVerticalGroup(jd_ambu_eliminarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_ambu_eliminarLayout.createSequentialGroup().addContainerGap().addComponent(jLabel21) .addGap(18, 18, 18).addComponent(jLabel22).addGap(18, 18, 18) .addComponent(cb_ambu_eliminar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(78, 78, 78).addComponent(btn_ambu_eliminar).addContainerGap(104, Short.MAX_VALUE))); jLabel23.setText("Re-Asignar Paramedico"); jLabel24.setText("Seleccione Paramedico a re-asignar:"); jLabel25.setText("Seleccione Complejo a asignar:"); btn_param_reasginar_param.setText("Re-Asignar"); btn_param_reasginar_param.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { btn_param_reasginar_paramMouseClicked(evt); } }); javax.swing.GroupLayout jd_paramedicos_reasignarLayout = new javax.swing.GroupLayout( jd_paramedicos_reasignar.getContentPane()); jd_paramedicos_reasignar.getContentPane().setLayout(jd_paramedicos_reasignarLayout); jd_paramedicos_reasignarLayout.setHorizontalGroup(jd_paramedicos_reasignarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_paramedicos_reasignarLayout.createSequentialGroup() .addGroup(jd_paramedicos_reasignarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_paramedicos_reasignarLayout.createSequentialGroup() .addGap(164, 164, 164).addComponent(jLabel23)) .addGroup(jd_paramedicos_reasignarLayout.createSequentialGroup().addContainerGap() .addGroup(jd_paramedicos_reasignarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel24).addComponent(jLabel25)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jd_paramedicos_reasignarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(cb_param_reasignar_nombre, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(cb_param_reasignar_complejo, 0, 220, Short.MAX_VALUE))) .addGroup(jd_paramedicos_reasignarLayout.createSequentialGroup() .addGap(178, 178, 178).addComponent(btn_param_reasginar_param))) .addContainerGap(58, Short.MAX_VALUE))); jd_paramedicos_reasignarLayout.setVerticalGroup( jd_paramedicos_reasignarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_paramedicos_reasignarLayout.createSequentialGroup().addContainerGap() .addComponent(jLabel23).addGap(18, 18, 18) .addGroup(jd_paramedicos_reasignarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel24).addComponent(cb_param_reasignar_nombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(37, 37, 37) .addGroup(jd_paramedicos_reasignarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel25).addComponent(cb_param_reasignar_complejo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(91, 91, 91).addComponent(btn_param_reasginar_param) .addContainerGap(96, Short.MAX_VALUE))); jLabel26.setText("Re-Asignar Ambulancia"); jLabel27.setText("Seleccione Ambulancia que desea Re-Asignar:"); jLabel28.setText("Seleccione a que complejo desea re-asignarla:"); btn_ambu_reasignar.setText("Re-Asignar"); btn_ambu_reasignar.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { btn_ambu_reasignarMouseClicked(evt); } }); javax.swing.GroupLayout jd_ambu_reasignarLayout = new javax.swing.GroupLayout( jd_ambu_reasignar.getContentPane()); jd_ambu_reasignar.getContentPane().setLayout(jd_ambu_reasignarLayout); jd_ambu_reasignarLayout.setHorizontalGroup(jd_ambu_reasignarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jd_ambu_reasignarLayout .createSequentialGroup().addGap(0, 76, Short.MAX_VALUE) .addGroup(jd_ambu_reasignarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(cb_ambu_reasignar_placa, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cb_ambu_reasignar_complejo, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(54, 54, 54)) .addGroup(jd_ambu_reasignarLayout.createSequentialGroup() .addGroup(jd_ambu_reasignarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_ambu_reasignarLayout.createSequentialGroup().addGap(167, 167, 167) .addComponent(jLabel26)) .addGroup(jd_ambu_reasignarLayout.createSequentialGroup().addContainerGap() .addComponent(jLabel27)) .addGroup(jd_ambu_reasignarLayout.createSequentialGroup().addContainerGap() .addComponent(jLabel28)) .addGroup(jd_ambu_reasignarLayout.createSequentialGroup().addGap(150, 150, 150) .addComponent(btn_ambu_reasignar))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jd_ambu_reasignarLayout.setVerticalGroup(jd_ambu_reasignarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_ambu_reasignarLayout.createSequentialGroup().addContainerGap().addComponent(jLabel26) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel27) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(cb_ambu_reasignar_placa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(30, 30, 30).addComponent(jLabel28).addGap(18, 18, 18) .addComponent(cb_ambu_reasignar_complejo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(51, 51, 51).addComponent(btn_ambu_reasignar).addContainerGap(63, Short.MAX_VALUE))); btn_agregar_relaciones.setBackground(new java.awt.Color(204, 204, 255)); btn_agregar_relaciones.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 18)); // NOI18N btn_agregar_relaciones.setText("Add"); btn_agregar_relaciones.setOpaque(false); btn_agregar_relaciones.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btn_agregar_relacionesActionPerformed(evt); } }); js_nivel.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N js_nivel.setValue(1); jLabel29.setFont(new java.awt.Font("Arial Rounded MT Bold", 3, 18)); // NOI18N jLabel29.setText("Peso:"); jLabel30.setFont(new java.awt.Font("Arial Rounded MT Bold", 3, 18)); // NOI18N jLabel30.setText("A:"); jLabel31.setFont(new java.awt.Font("Arial Rounded MT Bold", 3, 18)); // NOI18N jLabel31.setText("De:"); cb_de_relacion.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N cb_de_relacion.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { cb_de_relacionItemStateChanged(evt); } }); cb_a_relacion.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N javax.swing.GroupLayout jd_crear_relacionesLayout = new javax.swing.GroupLayout( jd_crear_relaciones.getContentPane()); jd_crear_relaciones.getContentPane().setLayout(jd_crear_relacionesLayout); jd_crear_relacionesLayout.setHorizontalGroup(jd_crear_relacionesLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400, Short.MAX_VALUE) .addGroup(jd_crear_relacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_crear_relacionesLayout.createSequentialGroup().addGap(18, 18, 18) .addGroup(jd_crear_relacionesLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_crear_relacionesLayout.createSequentialGroup() .addGap(141, 141, 141).addComponent(btn_agregar_relaciones, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jd_crear_relacionesLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jd_crear_relacionesLayout.createSequentialGroup() .addComponent(jLabel29).addGap(29, 29, 29) .addComponent(js_nivel, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(117, 117, 117)) .addGroup(jd_crear_relacionesLayout.createSequentialGroup() .addGroup(jd_crear_relacionesLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel31).addComponent(jLabel30)) .addGap(27, 27, 27) .addGroup(jd_crear_relacionesLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(cb_a_relacion, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cb_de_relacion, javax.swing.GroupLayout.PREFERRED_SIZE, 303, javax.swing.GroupLayout.PREFERRED_SIZE))))) .addContainerGap(18, Short.MAX_VALUE)))); jd_crear_relacionesLayout.setVerticalGroup(jd_crear_relacionesLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300, Short.MAX_VALUE) .addGroup(jd_crear_relacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_crear_relacionesLayout.createSequentialGroup().addGap(60, 60, 60) .addGroup(jd_crear_relacionesLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cb_de_relacion, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel31, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(14, 14, 14) .addGroup(jd_crear_relacionesLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cb_a_relacion, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel30, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(18, 18, 18) .addGroup(jd_crear_relacionesLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel29).addComponent(js_nivel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addComponent(btn_agregar_relaciones, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(60, 60, 60)))); jLabel32.setText("Guardar en Archivos"); btn_guardar_complejos.setText("Guardar Complejos"); btn_guardar_complejos.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { btn_guardar_complejosMouseClicked(evt); } }); btn_guardar_param.setText("Guardar Paramedicos"); btn_guardar_param.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { btn_guardar_paramMouseClicked(evt); } }); btn_guardar_ambu.setText("Guardar Ambulancias"); btn_guardar_ambu.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { btn_guardar_ambuMouseClicked(evt); } }); javax.swing.GroupLayout jd_archivos_guardarLayout = new javax.swing.GroupLayout( jd_archivos_guardar.getContentPane()); jd_archivos_guardar.getContentPane().setLayout(jd_archivos_guardarLayout); jd_archivos_guardarLayout.setHorizontalGroup( jd_archivos_guardarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_archivos_guardarLayout.createSequentialGroup().addGap(138, 138, 138) .addGroup(jd_archivos_guardarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(btn_guardar_param, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btn_guardar_complejos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btn_guardar_ambu, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(127, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jd_archivos_guardarLayout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel32).addGap(148, 148, 148))); jd_archivos_guardarLayout.setVerticalGroup( jd_archivos_guardarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_archivos_guardarLayout.createSequentialGroup().addContainerGap() .addComponent(jLabel32).addGap(34, 34, 34).addComponent(btn_guardar_complejos) .addGap(18, 18, 18).addComponent(btn_guardar_param).addGap(18, 18, 18) .addComponent(btn_guardar_ambu).addContainerGap(136, Short.MAX_VALUE))); jLabel33.setText("Cargar Archivos"); jButton1.setText("Cargar Complejos"); btn_cargar_param.setText("Cargar Paramedicos"); btn_cargar_param.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { btn_cargar_paramMouseClicked(evt); } }); btn_cargar_ambu.setText("Cargar Ambulancias"); btn_cargar_ambu.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { btn_cargar_ambuMouseClicked(evt); } }); javax.swing.GroupLayout jd_archivos_cargarLayout = new javax.swing.GroupLayout( jd_archivos_cargar.getContentPane()); jd_archivos_cargar.getContentPane().setLayout(jd_archivos_cargarLayout); jd_archivos_cargarLayout.setHorizontalGroup( jd_archivos_cargarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_archivos_cargarLayout.createSequentialGroup().addGap(145, 145, 145) .addGroup(jd_archivos_cargarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btn_cargar_param, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btn_cargar_ambu, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jd_archivos_cargarLayout.createSequentialGroup() .addComponent(jLabel33).addGap(21, 21, 21))) .addContainerGap(126, Short.MAX_VALUE))); jd_archivos_cargarLayout.setVerticalGroup(jd_archivos_cargarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_archivos_cargarLayout.createSequentialGroup().addContainerGap().addComponent(jLabel33) .addGap(31, 31, 31).addComponent(jButton1).addGap(18, 18, 18).addComponent(btn_cargar_param) .addGap(18, 18, 18).addComponent(btn_cargar_ambu).addContainerGap(139, Short.MAX_VALUE))); jLabel34.setText("Crear Emergencias"); jLabel35.setText("DE:"); jLabel36.setText("Tipo de Emergencia:"); buttonGroup3.add(rb_emer_a); rb_emer_a.setText("A"); buttonGroup3.add(rb_emer_b); rb_emer_b.setText("B"); buttonGroup3.add(rb_emer_c); rb_emer_c.setText("C"); buttonGroup3.add(rb_emer_d); rb_emer_d.setText("D"); btn_emergencia_buscarruta.setText("Buscar Ruta"); btn_emergencia_buscarruta.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { btn_emergencia_buscarrutaMouseClicked(evt); } }); jLabel41.setText("A:"); javax.swing.GroupLayout jd_emergencias_crearLayout = new javax.swing.GroupLayout( jd_emergencias_crear.getContentPane()); jd_emergencias_crear.getContentPane().setLayout(jd_emergencias_crearLayout); jd_emergencias_crearLayout.setHorizontalGroup( jd_emergencias_crearLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jd_emergencias_crearLayout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE) .addComponent(btn_emergencia_buscarruta).addGap(159, 159, 159)) .addGroup( jd_emergencias_crearLayout.createSequentialGroup() .addGroup(jd_emergencias_crearLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jd_emergencias_crearLayout.createSequentialGroup() .addGroup(jd_emergencias_crearLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_emergencias_crearLayout .createSequentialGroup().addGap( 147, 147, 147) .addComponent(jLabel34)) .addGroup(jd_emergencias_crearLayout .createSequentialGroup().addContainerGap() .addComponent(jLabel36) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(rb_emer_a) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(rb_emer_b) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(rb_emer_c) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(rb_emer_d))) .addGap(86, 86, 86)) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jd_emergencias_crearLayout.createSequentialGroup() .addContainerGap() .addGroup(jd_emergencias_crearLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING) .addGroup( javax.swing.GroupLayout.Alignment.LEADING, jd_emergencias_crearLayout .createSequentialGroup() .addComponent(jLabel41) .addGap(18, 18, 18) .addComponent( cb_emergencia_de, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup( javax.swing.GroupLayout.Alignment.LEADING, jd_emergencias_crearLayout .createSequentialGroup() .addComponent(jLabel35) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent( cb_emergencia_a, javax.swing.GroupLayout.PREFERRED_SIZE, 296, javax.swing.GroupLayout.PREFERRED_SIZE))))) .addContainerGap(65, Short.MAX_VALUE))); jd_emergencias_crearLayout.setVerticalGroup(jd_emergencias_crearLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_emergencias_crearLayout.createSequentialGroup().addContainerGap() .addComponent(jLabel34).addGap(18, 18, 18) .addGroup(jd_emergencias_crearLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel35).addComponent(cb_emergencia_a, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(24, 24, 24) .addGroup(jd_emergencias_crearLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel36).addComponent(rb_emer_a).addComponent(rb_emer_b) .addComponent(rb_emer_c).addComponent(rb_emer_d)) .addGap(18, 18, 18) .addGroup(jd_emergencias_crearLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel41).addComponent(cb_emergencia_de, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 78, Short.MAX_VALUE) .addComponent(btn_emergencia_buscarruta).addGap(51, 51, 51))); jLabel37.setFont(new java.awt.Font("Arial Rounded MT Bold", 3, 24)); // NOI18N jLabel37.setText("De:"); jLabel38.setFont(new java.awt.Font("Arial Rounded MT Bold", 3, 24)); // NOI18N jLabel38.setText("A:"); txt_recorrido_de.setEditable(false); txt_recorrido_de.setFont(new java.awt.Font("Arial Rounded MT Bold", 3, 14)); // NOI18N txt_recorrido_a.setEditable(false); txt_recorrido_a.setFont(new java.awt.Font("Arial Rounded MT Bold", 3, 14)); // NOI18N jLabel39.setFont(new java.awt.Font("Arial Rounded MT Bold", 3, 24)); // NOI18N jLabel39.setText("Recorrido:"); ta_pizarra.setEditable(false); ta_pizarra.setColumns(20); ta_pizarra.setFont(new java.awt.Font("Arial Rounded MT Bold", 3, 14)); // NOI18N ta_pizarra.setRows(5); jScrollPane4.setViewportView(ta_pizarra); jLabel40.setFont(new java.awt.Font("Arial Rounded MT Bold", 3, 36)); // NOI18N jLabel40.setText("Recorrido Dijkstra"); javax.swing.GroupLayout jd_dijsktraLayout = new javax.swing.GroupLayout(jd_dijsktra.getContentPane()); jd_dijsktra.getContentPane().setLayout(jd_dijsktraLayout); jd_dijsktraLayout.setHorizontalGroup(jd_dijsktraLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jd_dijsktraLayout.createSequentialGroup().addContainerGap().addGroup(jd_dijsktraLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 552, Short.MAX_VALUE) .addGroup(jd_dijsktraLayout.createSequentialGroup().addComponent(jLabel39).addGap(0, 0, Short.MAX_VALUE)) .addGroup(jd_dijsktraLayout.createSequentialGroup() .addGroup(jd_dijsktraLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel37).addComponent(jLabel38)) .addGap(18, 18, 18) .addGroup(jd_dijsktraLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txt_recorrido_a).addComponent(txt_recorrido_de)))) .addContainerGap()) .addGroup(jd_dijsktraLayout.createSequentialGroup().addGap(90, 90, 90) .addComponent(jLabel40, javax.swing.GroupLayout.PREFERRED_SIZE, 377, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jd_dijsktraLayout.setVerticalGroup(jd_dijsktraLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jd_dijsktraLayout.createSequentialGroup() .addContainerGap().addComponent(jLabel40) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jd_dijsktraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jd_dijsktraLayout.createSequentialGroup() .addGroup(jd_dijsktraLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel37).addComponent(txt_recorrido_de, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18).addComponent(txt_recorrido_a, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel38)) .addGap(16, 16, 16).addComponent(jLabel39) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(32, Short.MAX_VALUE))); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jMenu1.setText("Administracion"); jMenuItem_agregar_hospital.setText("Agregar Complejos Hospitalarios o un Lugar"); jMenuItem_agregar_hospital.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem_agregar_hospitalActionPerformed(evt); } }); jMenu1.add(jMenuItem_agregar_hospital); jMenuItem_eliminar_hospital.setText("Eliminar Complejos Hospitalarios"); jMenuItem_eliminar_hospital.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem_eliminar_hospitalActionPerformed(evt); } }); jMenu1.add(jMenuItem_eliminar_hospital); jMenuItem_agregar_paramedicos.setText("Agregar Paramedicos"); jMenuItem_agregar_paramedicos.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem_agregar_paramedicosActionPerformed(evt); } }); jMenu1.add(jMenuItem_agregar_paramedicos); jMenuItem_registrar_ambulancia.setText("Registrar Ambulancias"); jMenuItem_registrar_ambulancia.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem_registrar_ambulanciaActionPerformed(evt); } }); jMenu1.add(jMenuItem_registrar_ambulancia); jMenuItem_eliminar_ambulancia.setText("Eliminar Ambulancias"); jMenuItem_eliminar_ambulancia.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem_eliminar_ambulanciaActionPerformed(evt); } }); jMenu1.add(jMenuItem_eliminar_ambulancia); jMenuItem_reasignar_paramedicos.setText("Re-Asignar Paramedico"); jMenuItem_reasignar_paramedicos.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem_reasignar_paramedicosActionPerformed(evt); } }); jMenu1.add(jMenuItem_reasignar_paramedicos); jMenuItem_reasignar_ambulancia.setText("Re-Asignar Ambulancia"); jMenuItem_reasignar_ambulancia.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem_reasignar_ambulanciaActionPerformed(evt); } }); jMenu1.add(jMenuItem_reasignar_ambulancia); jMenuItem_cargar_archivos.setText("Cargar Archivos"); jMenuItem_cargar_archivos.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem_cargar_archivosActionPerformed(evt); } }); jMenu1.add(jMenuItem_cargar_archivos); jMenuItem_guardar_archivos.setText("Guardar Archivo"); jMenuItem_guardar_archivos.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem_guardar_archivosActionPerformed(evt); } }); jMenu1.add(jMenuItem_guardar_archivos); jMenuBar1.add(jMenu1); jMenu2.setText("Mapeo"); jMenuItem_crear_relaciones.setText("Crear Relaciones"); jMenuItem_crear_relaciones.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem_crear_relacionesActionPerformed(evt); } }); jMenu2.add(jMenuItem_crear_relaciones); jMenuItem_ver_mapa.setText("Ver Mapa"); jMenuItem_ver_mapa.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem_ver_mapaActionPerformed(evt); } }); jMenu2.add(jMenuItem_ver_mapa); jMenuBar1.add(jMenu2); jMenu3.setText("Emergencias"); jMenu3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenu3ActionPerformed(evt); } }); jMenuItem_emergencia_crear.setText("Crear Emergencias"); jMenuItem_emergencia_crear.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem_emergencia_crearActionPerformed(evt); } }); jMenu3.add(jMenuItem_emergencia_crear); jMenuBar1.add(jMenu3); setJMenuBar(jMenuBar1); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 752, Short.MAX_VALUE)); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 476, Short.MAX_VALUE)); pack(); }// </editor-fold>//GEN-END:initComponents private void jMenuItem_agregar_paramedicosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_agregar_paramedicosActionPerformed // TODO add your handling code here: DefaultComboBoxModel modelo = new DefaultComboBoxModel(); for (int i = 0; i < lista_lugares.size(); i++) { if (lista_lugares.get(i).getTipo().contentEquals("Hospital")) { modelo.addElement(lista_lugares.get(i).getNombre()); } } cb_param_complejo.setModel(modelo); jd_paramedicos_agregar.setModal(true); jd_paramedicos_agregar.pack(); jd_paramedicos_agregar.setVisible(true); }//GEN-LAST:event_jMenuItem_agregar_paramedicosActionPerformed private void jMenuItem_agregar_hospitalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_agregar_hospitalActionPerformed // TODO add your handling code here: jd_hospital_agregar.setModal(true); jd_hospital_agregar.pack(); jd_hospital_agregar.setVisible(true); }//GEN-LAST:event_jMenuItem_agregar_hospitalActionPerformed private void rb_tipo_hospActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_tipo_hospActionPerformed // TODO add your handling code here: if (rb_tipo_hosp.isSelected()) { txt_hospital_nombre.setEnabled(true); txt_hospital_direccion.setEnabled(true); txt_hospital_direccion.setEnabled(true); sp_hosp_ambu.setEnabled(true); sp_hosp_param.setEnabled(true); rb_hospital_a.setEnabled(true); rb_hospital_b.setEnabled(true); rb_hospital_c.setEnabled(true); rb_hospital_d.setEnabled(true); } }//GEN-LAST:event_rb_tipo_hospActionPerformed private void rb_tipo_lugActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rb_tipo_lugActionPerformed // TODO add your handling code here: if (rb_tipo_lug.isSelected()) { txt_hospital_nombre.setEnabled(true); txt_hospital_direccion.setEnabled(false); sp_hosp_ambu.setEnabled(false); sp_hosp_param.setEnabled(false); rb_hospital_a.setEnabled(false); rb_hospital_b.setEnabled(false); rb_hospital_c.setEnabled(false); rb_hospital_d.setEnabled(false); } }//GEN-LAST:event_rb_tipo_lugActionPerformed private void btn_hospital_agregarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_hospital_agregarMouseClicked // TODO add your handling code here: String nombre; String direccion; String tipo; int cap_param; int cap_ambu; ArrayList ranking = new ArrayList(); if (rb_tipo_hosp.isSelected()) { nombre = "Hospital " + txt_hospital_nombre.getText(); direccion = txt_hospital_direccion.getText(); tipo = "Hospital"; cap_param = (int) sp_hosp_param.getValue(); cap_ambu = (int) sp_hosp_ambu.getValue(); if (rb_hospital_a.isSelected()) { ranking.add("A"); } if (rb_hospital_b.isSelected()) { ranking.add("B"); } if (rb_hospital_c.isSelected()) { ranking.add("C"); } if (rb_hospital_d.isSelected()) { ranking.add("D"); } lista_lugares.add(new Lugar(nombre, direccion, tipo, cap_param, cap_ambu, ranking)); JOptionPane.showMessageDialog(null, "Hospital Agregado"); } else if (rb_tipo_lug.isSelected()) { nombre = txt_hospital_nombre.getText(); tipo = "Lugar"; lista_lugares.add(new Lugar(nombre, tipo)); JOptionPane.showMessageDialog(null, "Lugar Agregado"); } txt_hospital_nombre.setText(""); txt_hospital_direccion.setText(""); sp_hosp_param.setValue(1); sp_hosp_ambu.setValue(1); rb_hospital_a.setSelected(false); rb_hospital_b.setSelected(false); rb_hospital_c.setSelected(false); rb_hospital_d.setSelected(false); rb_tipo_lug.setSelected(false); rb_tipo_hosp.setSelected(false); txt_hospital_nombre.setEnabled(false); txt_hospital_direccion.setEnabled(false); sp_hosp_ambu.setEnabled(false); sp_hosp_param.setEnabled(false); rb_hospital_a.setEnabled(false); rb_hospital_b.setEnabled(false); rb_hospital_c.setEnabled(false); rb_hospital_d.setEnabled(false); // System.out.println(lista_lugares.toString() + "./"); }//GEN-LAST:event_btn_hospital_agregarMouseClicked private void jMenuItem_eliminar_hospitalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_eliminar_hospitalActionPerformed // TODO add your handling code here: DefaultComboBoxModel modelo = new DefaultComboBoxModel(); for (int i = 0; i < lista_lugares.size(); i++) { modelo.addElement(lista_lugares.get(i).getNombre()); } cb_hospital_eliminar.setModel(modelo); jd_hospital_lugar_eliminar.setModal(true); jd_hospital_lugar_eliminar.pack(); jd_hospital_lugar_eliminar.setVisible(true); }//GEN-LAST:event_jMenuItem_eliminar_hospitalActionPerformed private void btn_hospital_eliminarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_hospital_eliminarMouseClicked // TODO add your handling code here: int elim = cb_hospital_eliminar.getSelectedIndex(); lista_lugares.remove(elim); cb_hospital_eliminar.removeItem(elim); DefaultComboBoxModel modelo = new DefaultComboBoxModel(); for (int i = 0; i < lista_lugares.size(); i++) { modelo.addElement(lista_lugares.get(i).getNombre()); } cb_hospital_eliminar.setModel(modelo); System.out.println(lista_lugares.toString()); }//GEN-LAST:event_btn_hospital_eliminarMouseClicked private void bnt_param_agregarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_bnt_param_agregarMouseClicked // TODO add your handling code here: String nombre = txt_param_nombre.getText(); int edad = (int) sp_param_edad.getValue(); int id = Integer.parseInt(txt_param_ident.getText()); String ranking = ""; if (rb_param_a.isSelected()) { ranking = "A"; } else if (rb_param_b.isSelected()) { ranking = "B"; } else if (rb_param_c.isSelected()) { ranking = "C"; } else if (rb_param_d.isSelected()) { ranking = "D"; } Lugar complejo = lista_lugares.get(cb_param_complejo.getSelectedIndex()); boolean disponible = true; Paramedicos a = new Paramedicos(nombre, edad, id, ranking, complejo, disponible); for (int i = 0; i < lista_lugares.size(); i++) { if (lista_lugares.get(i).equals(complejo)) { // System.out.println("entro primer if"); if (lista_lugares.get(i).getParamedicos_asignados().size() < lista_lugares.get(i).getCap_param()) { // System.out.println("entro segundo if"); lista_lugares.get(i).getParamedicos_asignados() .add(new Paramedicos(nombre, edad, id, ranking, complejo, disponible)); JOptionPane.showMessageDialog(null, "Paramedico Agregado"); } else { // System.out.println("entro else"); JOptionPane.showMessageDialog(this, "HA EXCEDIDO LA CAPACIDAD DE PARAMEDICOS EN DICHO HOSPITAL"); } } } lista_param.add(a); // System.out.println(lista_param.toString()); System.out.println(lista_lugares.toString()); txt_param_nombre.setText(""); txt_param_ident.setText(""); sp_param_edad.setValue(18); rb_param_a.setSelected(false); rb_param_b.setSelected(false); rb_param_c.setSelected(false); rb_param_d.setSelected(false); }//GEN-LAST:event_bnt_param_agregarMouseClicked private void jMenuItem_registrar_ambulanciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_registrar_ambulanciaActionPerformed // TODO add your handling code here: DefaultComboBoxModel modelo = new DefaultComboBoxModel(); for (int i = 0; i < lista_lugares.size(); i++) { if (lista_lugares.get(i).getTipo().contentEquals("Hospital")) { modelo.addElement(lista_lugares.get(i).getNombre()); } } cb_ambu_compl.setModel(modelo); jd_ambu_registrar.setModal(true); jd_ambu_registrar.pack(); jd_ambu_registrar.setVisible(true); }//GEN-LAST:event_jMenuItem_registrar_ambulanciaActionPerformed private void btn_ambu_agregarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_ambu_agregarMouseClicked // TODO add your handling code here: String placa = txt_ambu_placa.getText(); int ano = Integer.parseInt(txt_ambu_ano.getText()); int velo = (int) sp_ambu_vel.getValue(); Lugar complejo = lista_lugares.get(cb_ambu_compl.getSelectedIndex()); boolean disponible = true; Ambulancias a = new Ambulancias(placa, ano, velo, complejo, disponible); for (int i = 0; i < lista_lugares.size(); i++) { if (lista_lugares.get(i).equals(complejo)) { // System.out.println("entro primer if"); if (lista_lugares.get(i).getAmbulancias_asignados().size() < lista_lugares.get(i).getCap_ambu()) { // System.out.println("entro segundo if"); lista_lugares.get(i).getAmbulancias_asignados() .add(new Ambulancias(placa, ano, velo, complejo, disponible)); JOptionPane.showMessageDialog(null, "Ambulancia Agregado"); } else { // System.out.println("entro else"); JOptionPane.showMessageDialog(this, "HA EXCEDIDO LA CAPACIDAD DE AMBULANCIAS EN DICHO HOSPITAL"); } } } lista_ambu.add(a); // System.out.println(lista_lugares.toString()); txt_ambu_ano.setText(""); txt_ambu_placa.setText(""); sp_ambu_vel.setValue(1); }//GEN-LAST:event_btn_ambu_agregarMouseClicked private void jMenuItem_eliminar_ambulanciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_eliminar_ambulanciaActionPerformed // TODO add your handling code here: DefaultComboBoxModel modelo = new DefaultComboBoxModel(); for (int i = 0; i < lista_ambu.size(); i++) { modelo.addElement(lista_ambu.get(i).getPlaca()); } cb_ambu_eliminar.setModel(modelo); jd_ambu_eliminar.setModal(true); jd_ambu_eliminar.pack(); jd_ambu_eliminar.setVisible(true); }//GEN-LAST:event_jMenuItem_eliminar_ambulanciaActionPerformed private void btn_ambu_eliminarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_ambu_eliminarMouseClicked // TODO add your handling code here: int elim = cb_ambu_eliminar.getSelectedIndex(); for (int i = 0; i < lista_lugares.size(); i++) { if (lista_lugares.get(i).getAmbulancias_asignados().contains( lista_lugares.get(i).getAmbulancias_asignados().get(cb_ambu_eliminar.getSelectedIndex()))) { // System.out.println("entro a if"); lista_lugares.get(i).getAmbulancias_asignados().remove( lista_lugares.get(i).getAmbulancias_asignados().get(cb_ambu_eliminar.getSelectedIndex())); JOptionPane.showMessageDialog(this, "HA ELIMINADO LA AMBULANCIAS DEL HOSPITAL ASIGNADO"); } } lista_ambu.remove(elim); cb_ambu_eliminar.removeItem(elim); //System.out.println(lista_lugares.toString()); DefaultComboBoxModel modelo = new DefaultComboBoxModel(); for (int i = 0; i < lista_ambu.size(); i++) { modelo.addElement(lista_ambu.get(i).getPlaca()); } cb_ambu_eliminar.setModel(modelo); }//GEN-LAST:event_btn_ambu_eliminarMouseClicked private void jMenuItem_reasignar_paramedicosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_reasignar_paramedicosActionPerformed // TODO add your handling code here: DefaultComboBoxModel modelo = new DefaultComboBoxModel(); for (int i = 0; i < lista_param.size(); i++) { modelo.addElement(lista_param.get(i).getNombre()); } cb_param_reasignar_nombre.setModel(modelo); DefaultComboBoxModel modelo2 = new DefaultComboBoxModel(); for (int i = 0; i < lista_lugares.size(); i++) { if (lista_lugares.get(i).getTipo().contentEquals("Hospital")) { modelo2.addElement(lista_lugares.get(i).getNombre()); } } cb_param_reasignar_complejo.setModel(modelo2); jd_paramedicos_reasignar.setModal(true); jd_paramedicos_reasignar.pack(); jd_paramedicos_reasignar.setVisible(true); }//GEN-LAST:event_jMenuItem_reasignar_paramedicosActionPerformed private void btn_param_reasginar_paramMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_param_reasginar_paramMouseClicked // TODO add your handling code here: Lugar complejo = lista_lugares.get(cb_param_reasignar_complejo.getSelectedIndex()); Paramedicos param = lista_param.get(cb_param_reasignar_nombre.getSelectedIndex()); System.out.println("Se copiaron complejo y param"); Lugar complejoParam = param.getCompl_asignado(); System.out.println("Se continua a hacer el traslado"); System.out.println("Verificando espacio disponible en complejo destino..."); boolean disp = false; int puestoDestino = 0; for (int i = 0; i < lista_lugares.size(); i++) { System.out.println("Buscando complejo destino..."); if (lista_lugares.get(i).getNombre().contentEquals(complejo.getNombre())) { System.out.println("Complejo destino encontrado!"); if (lista_lugares.get(i).getParamedicos_asignados().size() < lista_lugares.get(i).getCap_param()) { System.out.println("Capacidad disponible, avanzando con el traslado"); disp = true; puestoDestino = i; } else { System.out.println("No hay capacidad!"); } } } if (disp) { for (int i = 0; i < lista_lugares.size(); i++) { System.out.println("Buscando complejo..."); if (lista_lugares.get(i).getNombre().contentEquals(complejoParam.getNombre())) { System.out.println("Complejo encontrado!"); for (int j = 0; j < lista_lugares.get(i).getParamedicos_asignados().size(); j++) { System.out.println("Buscando paramedico..."); if (lista_lugares.get(i).getParamedicos_asignados().get(j).getNombre() .contentEquals(param.getNombre())) { System.out.println("Paramedico encontrado!"); lista_lugares.get(i).getParamedicos_asignados().remove(j); System.out.println("Eliminado del complejo"); break; } } } } System.out.println("Iniciando transferencia..."); param.setCompl_asignado(complejo); lista_lugares.get(puestoDestino).getParamedicos_asignados().add(param); System.out.println("Paramedico transferido!"); System.out.println("El paramedico " + param.getNombre() + " esta ahora en el complejo " + param.getCompl_asignado().getNombre()); } System.out.println(lista_lugares.toString()); }//GEN-LAST:event_btn_param_reasginar_paramMouseClicked private void jMenuItem_reasignar_ambulanciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_reasignar_ambulanciaActionPerformed // TODO add your handling code here: DefaultComboBoxModel modelo = new DefaultComboBoxModel(); for (int i = 0; i < lista_ambu.size(); i++) { modelo.addElement(lista_ambu.get(i).getPlaca()); } cb_ambu_reasignar_placa.setModel(modelo); DefaultComboBoxModel modelo2 = new DefaultComboBoxModel(); for (int i = 0; i < lista_lugares.size(); i++) { if (lista_lugares.get(i).getTipo().contentEquals("Hospital")) { modelo2.addElement(lista_lugares.get(i).getNombre()); } } cb_ambu_reasignar_complejo.setModel(modelo2); jd_ambu_reasignar.setModal(true); jd_ambu_reasignar.pack(); jd_ambu_reasignar.setVisible(true); }//GEN-LAST:event_jMenuItem_reasignar_ambulanciaActionPerformed private void btn_ambu_reasignarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_ambu_reasignarMouseClicked // TODO add your handling code here: Lugar complejo = lista_lugares.get(cb_ambu_reasignar_complejo.getSelectedIndex()); Ambulancias ambu = lista_ambu.get(cb_ambu_reasignar_placa.getSelectedIndex()); System.out.println("Se copiaron complejo y param"); Lugar complejoAmbu = ambu.getCompl_asignado(); System.out.println("Se continua a hacer el traslado"); System.out.println("Verificando espacio disponible en complejo destino..."); boolean disp = false; int puestoDestino = 0; for (int i = 0; i < lista_lugares.size(); i++) { System.out.println("Buscando complejo destino..."); if (lista_lugares.get(i).getNombre().contentEquals(complejo.getNombre())) { System.out.println("Complejo destino encontrado!"); if (lista_lugares.get(i).getAmbulancias_asignados().size() < lista_lugares.get(i).getCap_ambu()) { System.out.println("Capacidad disponible, avanzando con el traslado"); disp = true; puestoDestino = i; } else { System.out.println("No hay capacidad!"); } } } if (disp) { for (int i = 0; i < lista_lugares.size(); i++) { System.out.println("Buscando complejo..."); if (lista_lugares.get(i).getNombre().contentEquals(complejoAmbu.getNombre())) { System.out.println("Complejo encontrado!"); for (int j = 0; j < lista_lugares.get(i).getAmbulancias_asignados().size(); j++) { System.out.println("Buscando ambulancia..."); if (lista_lugares.get(i).getAmbulancias_asignados().get(j).getPlaca() .contentEquals(ambu.getPlaca())) { System.out.println("Ambulancia encontrada!"); lista_lugares.get(i).getAmbulancias_asignados().remove(j); System.out.println("Eliminado del complejo"); break; } } } } System.out.println("Iniciando transferencia..."); ambu.setCompl_asignado(complejo); lista_lugares.get(puestoDestino).getAmbulancias_asignados().add(ambu); System.out.println("Ambulancia transferida!"); System.out.println("La Ambulancia " + ambu.getPlaca() + " esta ahora en el complejo " + ambu.getCompl_asignado().getNombre()); } // Lugar complejo = lista_lugares.get(cb_ambu_reasignar_complejo.getSelectedIndex()); // Ambulancias ambu = lista_ambu.get(cb_ambu_reasignar_placa.getSelectedIndex()); // for (int i = 0; i < lista_lugares.size(); i++) { // if (lista_lugares.get(i).equals(complejo)) { // System.out.println("entro segundo if"); // if (lista_lugares.get(i).getAmbulancias_asignados().size() < lista_lugares.get(i).getCap_ambu()) { // System.out.println("entro tercer if"); // lista_lugares.get(i).getAmbulancias_asignados().add(ambu); // System.out.println("ambulancia cambiado de lugar"); // } else { // System.out.println("entro else"); // JOptionPane.showMessageDialog(this, "HA EXCEDIDO LA CAPACIDAD DE PARAMEDICOS EN DICHO HOSPITAL"); // // } // } // } }//GEN-LAST:event_btn_ambu_reasignarMouseClicked private void jMenuItem_crear_relacionesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_crear_relacionesActionPerformed // TODO add your handling code here: for (int i = 0; i < lista_lugares.size(); i++) { cb_de_relacion.addItem(lista_lugares.get(i).toString()); } jd_crear_relaciones.setModal(true); jd_crear_relaciones.pack(); jd_crear_relaciones.setVisible(true); }//GEN-LAST:event_jMenuItem_crear_relacionesActionPerformed private void btn_agregar_relacionesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_agregar_relacionesActionPerformed try { Lugar de = lista_lugares.get(cb_de_relacion.getSelectedIndex()); Lugar a = lista_vecinos.get(cb_a_relacion.getSelectedIndex()); int weight = (Integer) js_nivel.getValue(); Relacion_a_vecino level = new Relacion_a_vecino(weight, a); Relacion nivel = new Relacion(weight, a); de.vecinos.add(new Vecinos(a, level)); JOptionPane.showMessageDialog(this.getFrames()[0], a.nombre + " es ahora vecino de " + de); js_nivel.setValue(1); grafo.addEdge(level, de, a, EdgeType.DIRECTED); grafo1.addEdge(nivel, de, a, EdgeType.DIRECTED); cb_a_relacion.removeAllItems(); lista_vecinos.clear(); for (int i = 0; i < lista_lugares.size(); i++) { if (cb_de_relacion.getSelectedItem().toString().equals(lista_lugares.get(i).nombre)) { } else { boolean vecinos = false; for (int j = 0; j < lista_lugares.get(cb_de_relacion.getSelectedIndex()).vecinos.size(); j++) { vecinos = false; if (lista_lugares.get(cb_de_relacion.getSelectedIndex()).vecinos.get(j).lugar.nombre .equals(lista_lugares.get(i).nombre)) { vecinos = true; break; } } if (vecinos == false) { cb_a_relacion.addItem(lista_lugares.get(i)); lista_vecinos.add(lista_lugares.get(i)); } } } } catch (Exception e) { e.printStackTrace(); } }//GEN-LAST:event_btn_agregar_relacionesActionPerformed private void cb_de_relacionItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cb_de_relacionItemStateChanged cb_a_relacion.removeAllItems(); lista_vecinos.clear(); for (int i = 0; i < lista_lugares.size(); i++) { if (cb_de_relacion.getSelectedItem().toString().equals(lista_lugares.get(i).getNombre())) { continue; } else { boolean vecinos = false; for (int j = 0; j < lista_lugares.get(cb_de_relacion.getSelectedIndex()).vecinos.size(); j++) { vecinos = false; if (lista_lugares.get(cb_de_relacion.getSelectedIndex()).vecinos.get(j).lugar.getNombre() .equals(lista_lugares.get(i).getNombre())) { vecinos = true; break; } } if (vecinos == false) { cb_a_relacion.addItem(lista_lugares.get(i)); lista_vecinos.add(lista_lugares.get(i)); } } } }//GEN-LAST:event_cb_de_relacionItemStateChanged private void jMenuItem_ver_mapaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_ver_mapaActionPerformed // TODO add your handling code here: for (int i = 0; i < lista_lugares.size(); i++) { grafo.addVertex(lista_lugares.get(i)); } for (int i = 0; i < lista_lugares.size(); i++) { for (int j = 0; j < lista_lugares.get(i).vecinos.size(); j++) { grafo.addEdge(lista_lugares.get(i).vecinos.get(j).getWeight(), lista_lugares.get(i), lista_lugares.get(i).vecinos.get(j).getLugar(), EdgeType.DIRECTED); } } for (int i = 0; i < lista_lugares.size(); i++) { grafo1.addVertex(lista_lugares.get(i)); } for (int i = 0; i < lista_lugares.size(); i++) { for (int j = 0; j < lista_lugares.get(i).vecinos.size(); j++) { grafo1.addEdge(lista_lugares.get(i).vecinos.get(j).getPeso(), lista_lugares.get(i), lista_lugares.get(i).vecinos.get(j).getLugar(), EdgeType.DIRECTED); } } this.rootPane = null; this.setLocationRelativeTo(this.rootPane); setExtendedState(java.awt.Frame.MAXIMIZED_BOTH); Layout<String, String> layout = new FRLayout(grafo); layout.setSize(new Dimension(this.getWidth(), this.getHeight())); BasicVisualizationServer<String, String> visualization = new BasicVisualizationServer<>(layout); visualization.setPreferredSize(new Dimension(this.getWidth(), this.getHeight())); visualization.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); visualization.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); visualization.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR); JFrame frame = new JFrame("Lugares de HEU"); frame.getContentPane().add(visualization).setBackground(Color.GRAY); frame.pack(); frame.setVisible(true); }//GEN-LAST:event_jMenuItem_ver_mapaActionPerformed private void btn_guardar_paramMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_guardar_paramMouseClicked // TODO add your handling code here: File archivo; FileWriter fw = null; BufferedWriter bw = null; try { archivo = new File("./Paramedicos.txt"); fw = new FileWriter(archivo, true); bw = new BufferedWriter(fw); for (int i = 0; i < lista_param.size(); i++) { bw.write(lista_param.get(i).getNombre() + ","); bw.write(lista_param.get(i).getEdad() + ","); bw.write(lista_param.get(i).getId() + ","); bw.write(lista_param.get(i).getRanking() + ","); bw.write(lista_param.get(i).getCompl_asignado() + ","); bw.write(lista_param.get(i).isDisponible() + ","); bw.flush(); } JOptionPane.showMessageDialog(this, "Datos de Paramedicos Guardados"); } catch (Exception e) { e.printStackTrace(); } finally { try { bw.close(); fw.close(); } catch (IOException ex) { } } }//GEN-LAST:event_btn_guardar_paramMouseClicked private void jMenuItem_guardar_archivosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_guardar_archivosActionPerformed // TODO add your handling code here: jd_archivos_guardar.setModal(true); jd_archivos_guardar.pack(); jd_archivos_guardar.setVisible(true); }//GEN-LAST:event_jMenuItem_guardar_archivosActionPerformed private void btn_guardar_ambuMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_guardar_ambuMouseClicked // TODO add your handling code here: File archivo; FileWriter fw = null; BufferedWriter bw = null; try { archivo = new File("./Ambulancia.txt"); fw = new FileWriter(archivo, true); bw = new BufferedWriter(fw); for (int i = 0; i < lista_ambu.size(); i++) { bw.write(lista_ambu.get(i).getPlaca() + ","); bw.write(lista_ambu.get(i).getAno() + ","); bw.write(lista_ambu.get(i).getVelocidad() + ","); bw.write(lista_ambu.get(i).getCompl_asignado() + ","); bw.write(lista_param.get(i).isDisponible() + ","); bw.flush(); } JOptionPane.showMessageDialog(this, "Datos de Ambulancias Guardados"); } catch (Exception e) { e.printStackTrace(); } finally { try { bw.close(); fw.close(); } catch (IOException ex) { } } }//GEN-LAST:event_btn_guardar_ambuMouseClicked private void btn_cargar_paramMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_cargar_paramMouseClicked // TODO add your handling code here: Scanner sc = null; File archivo2; try { archivo2 = new File("./Paramedicos.txt"); sc = new Scanner(archivo2); sc.useDelimiter(","); while (sc.hasNext()) { Paramedicos param = new Paramedicos(sc.next(), sc.nextInt(), sc.nextInt(), sc.next(), new Lugar(sc.next()), sc.nextBoolean()); lista_param.add(param); } JOptionPane.showMessageDialog(null, "Paramedicos Cargadas"); } catch (Exception e) { } finally { sc.close(); } System.out.println(lista_param.toString()); }//GEN-LAST:event_btn_cargar_paramMouseClicked private void jMenuItem_cargar_archivosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_cargar_archivosActionPerformed // TODO add your handling code here: jd_archivos_cargar.setModal(true); jd_archivos_cargar.pack(); jd_archivos_cargar.setVisible(true); }//GEN-LAST:event_jMenuItem_cargar_archivosActionPerformed private void btn_cargar_ambuMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_cargar_ambuMouseClicked // TODO add your handling code here: Scanner sc = null; File archivo2; try { archivo2 = new File("./Ambulancia.txt"); sc = new Scanner(archivo2); sc.useDelimiter(","); while (sc.hasNext()) { Ambulancias ambu = new Ambulancias(sc.next(), sc.nextInt(), sc.nextInt(), new Lugar(sc.next()), sc.nextBoolean()); lista_ambu.add(ambu); } JOptionPane.showMessageDialog(null, "Ambulancias Cargadas"); } catch (Exception e) { } finally { sc.close(); } System.out.println(lista_ambu.toString()); }//GEN-LAST:event_btn_cargar_ambuMouseClicked private void jMenuItem_emergencia_crearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem_emergencia_crearActionPerformed // TODO add your handling code here: DefaultComboBoxModel modelo = new DefaultComboBoxModel(); for (int i = 0; i < lista_lugares.size(); i++) { modelo.addElement(lista_lugares.get(i).getNombre()); } DefaultComboBoxModel modelo2 = new DefaultComboBoxModel(); for (int i = 0; i < lista_lugares.size(); i++) { modelo2.addElement(lista_lugares.get(i).getNombre()); } cb_emergencia_de.setModel(modelo); cb_emergencia_a.setModel(modelo2); jd_emergencias_crear.setModal(true); jd_emergencias_crear.pack(); jd_emergencias_crear.setVisible(true); }//GEN-LAST:event_jMenuItem_emergencia_crearActionPerformed private void jMenu3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu3ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jMenu3ActionPerformed private void btn_emergencia_buscarrutaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_emergencia_buscarrutaMouseClicked // TODO add your handling code here: txt_recorrido_de.setText(""); txt_recorrido_a.setText(""); ta_pizarra.setText(""); boolean si = false; boolean si2 = false; boolean validacion_ambuyparam = false; boolean atender = false; String tipo = ""; if (rb_emer_a.isSelected()) { tipo = "A"; } else if (rb_emer_b.isSelected()) { tipo = "B"; } else if (rb_emer_c.isSelected()) { tipo = "C"; } else if (rb_emer_d.isSelected()) { tipo = "D"; } for (int i = 0; i < lista_lugares.size(); i++) { if (lista_lugares.get(i).getNombre().equals(cb_emergencia_de.getSelectedItem())) { System.out.println("entro primer if"); if (lista_lugares.get(i).getTipo().contentEquals("Hospital")) { System.out.println("entro segundo if"); JOptionPane.showMessageDialog(null, "EMERGENCIA DESDE HOSPITAL INVALIDO"); si = false; } else { si = true; } } } for (int i = 0; i < lista_lugares.size(); i++) { if (lista_lugares.get(i).getNombre().equals(cb_emergencia_a.getSelectedItem())) { System.out.println("entro tercer if"); if (lista_lugares.get(i).getTipo().contentEquals("Lugar")) { System.out.println("entro cuarto if"); JOptionPane.showMessageDialog(null, "EMERGENCIA HACIA LUGAR INVALIDO"); si2 = false; } else { si2 = true; if ((lista_lugares.get(i).getAmbulancias_asignados().size() >= 0) && (lista_lugares.get(i).getParamedicos_asignados().size() >= 2)) { System.out.println("entro quinto if"); validacion_ambuyparam = true; } else { JOptionPane.showMessageDialog(null, "NO HAY SUFICIENTE PARAMEDICOS O AMBULANCIAS PARA ASISTIR"); validacion_ambuyparam = false; } } } } if (si == true) { if (si2 == true) { if (validacion_ambuyparam == true) { Transformer<Relacion, Integer> wtTransformer = new Transformer<Relacion, Integer>() { public Integer transform(Relacion union) { return union.getLevel(); } }; DijkstraShortestPath<Lugar, Relacion> alg = new DijkstraShortestPath(grafo1, wtTransformer); Lugar to = new Lugar(); for (int i = 0; i < lista_lugares.size(); i++) { if (cb_emergencia_a.getSelectedItem().toString().equals(lista_lugares.get(i).nombre)) { to = lista_lugares.get(i); } } List lista = alg.getPath(lista_lugares.get(cb_emergencia_de.getSelectedIndex()), to); Number distance = alg.getDistance(lista_lugares.get(cb_emergencia_a.getSelectedIndex()), to); txt_recorrido_de.setText(lista_lugares.get(cb_emergencia_de.getSelectedIndex()).toString()); txt_recorrido_a.setText(to.toString()); ta_pizarra.setText(lista.toString() + distance); for (int i = 0; i < lista_lugares.size(); i++) { grafo.addVertex(lista_lugares.get(i)); } for (int i = 0; i < lista_lugares.size(); i++) { for (int j = 0; j < lista_lugares.get(i).vecinos.size(); j++) { grafo.addEdge(lista_lugares.get(i).vecinos.get(j).getWeight(), lista_lugares.get(i), lista_lugares.get(i).vecinos.get(j).getLugar(), EdgeType.DIRECTED); } } for (int i = 0; i < lista_lugares.size(); i++) { grafo1.addVertex(lista_lugares.get(i)); } for (int i = 0; i < lista_lugares.size(); i++) { for (int j = 0; j < lista_lugares.get(i).vecinos.size(); j++) { grafo1.addEdge(lista_lugares.get(i).vecinos.get(j).getPeso(), lista_lugares.get(i), lista_lugares.get(i).vecinos.get(j).getLugar(), EdgeType.DIRECTED); } } this.rootPane = null; this.setLocationRelativeTo(this.rootPane); setExtendedState(java.awt.Frame.MAXIMIZED_BOTH); Layout<String, String> layout = new FRLayout(grafo); layout.setSize(new Dimension(this.getWidth(), this.getHeight())); BasicVisualizationServer<String, String> visualization = new BasicVisualizationServer<>(layout); visualization.setPreferredSize(new Dimension(this.getWidth(), this.getHeight())); visualization.getRenderContext().setVertexLabelTransformer(new ToStringLabeller()); visualization.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller()); visualization.getRenderer().getVertexLabelRenderer() .setPosition(Renderer.VertexLabel.Position.CNTR); JFrame frame = new JFrame("Lugares de HEU"); frame.getContentPane().add(visualization).setBackground(Color.GRAY); frame.pack(); frame.setVisible(true); jd_dijsktra.setModal(true); jd_dijsktra.pack(); jd_dijsktra.setVisible(true); } } } }//GEN-LAST:event_btn_emergencia_buscarrutaMouseClicked private void btn_guardar_complejosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_guardar_complejosMouseClicked // TODO add your handling code here: File archivo; FileWriter fw = null; BufferedWriter bw = null; try { archivo = new File("./Complejo.txt"); fw = new FileWriter(archivo, true); bw = new BufferedWriter(fw); for (int i = 0; i < lista_lugares.size(); i++) { bw.write(lista_lugares.get(i).getNombre() + ";"); bw.write(lista_lugares.get(i).getDireccion() + ";"); bw.write(lista_lugares.get(i).getTipo() + ";"); bw.write(lista_lugares.get(i).getCap_param() + ";"); bw.write(lista_lugares.get(i).getCap_ambu() + "#"); if (lista_lugares.get(i).getRanking().size() > 1) { for (int j = 0; j < lista_lugares.get(i).getRanking().size() - 1; j++) { bw.write(lista_lugares.get(i).getRanking().get(j) + ";"); } } bw.write(lista_lugares.get(i).getRanking().get(lista_lugares.get(i).getRanking().size()) + "#"); if (lista_lugares.get(i).getParamedicos_asignados().size() > 1) { for (int j = 0; j < lista_lugares.get(i).getParamedicos_asignados().size() - 1; j++) { bw.write(lista_lugares.get(i).getParamedicos_asignados().get(j).getNombre() + ";"); bw.write(lista_lugares.get(i).getParamedicos_asignados().get(j).getEdad() + ";"); bw.write(lista_lugares.get(i).getParamedicos_asignados().get(j).getId() + ";"); bw.write(lista_lugares.get(i).getParamedicos_asignados().get(j).getRanking() + ";"); bw.write(lista_lugares.get(i).getParamedicos_asignados().get(j).getCompl_asignado() + ";"); bw.write(lista_lugares.get(i).getParamedicos_asignados().get(j).isDisponible() + "&"); } } int jota = lista_lugares.get(i).getParamedicos_asignados().size(); bw.write(lista_lugares.get(i).getParamedicos_asignados().get(jota).getNombre() + ";"); bw.write(lista_lugares.get(i).getParamedicos_asignados().get(jota).getEdad() + ";"); bw.write(lista_lugares.get(i).getParamedicos_asignados().get(jota).getId() + ";"); bw.write(lista_lugares.get(i).getParamedicos_asignados().get(jota).getRanking() + ";"); bw.write(lista_lugares.get(i).getParamedicos_asignados().get(jota).getCompl_asignado() + ";"); bw.write(lista_lugares.get(i).getParamedicos_asignados().get(jota).isDisponible() + "#"); if (lista_lugares.get(i).getAmbulancias_asignados().size() > 1) { for (int j = 0; j < lista_lugares.get(i).getAmbulancias_asignados().size() - 1; j++) { bw.write(lista_lugares.get(i).getAmbulancias_asignados().get(j).getPlaca() + ";"); bw.write(lista_lugares.get(i).getAmbulancias_asignados().get(j).getAno() + ";"); bw.write(lista_lugares.get(i).getAmbulancias_asignados().get(j).getVelocidad() + ";"); bw.write(lista_lugares.get(i).getAmbulancias_asignados().get(j).getCompl_asignado() + ";"); bw.write(lista_lugares.get(i).getAmbulancias_asignados().get(j).isDisponible() + "&"); } } jota = lista_lugares.get(i).getAmbulancias_asignados().size(); bw.write(lista_lugares.get(i).getAmbulancias_asignados().get(jota).getPlaca() + ";"); bw.write(lista_lugares.get(i).getAmbulancias_asignados().get(jota).getAno() + ";"); bw.write(lista_lugares.get(i).getAmbulancias_asignados().get(jota).getVelocidad() + ";"); bw.write(lista_lugares.get(i).getAmbulancias_asignados().get(jota).getCompl_asignado() + ";"); bw.write(lista_lugares.get(i).getAmbulancias_asignados().get(jota).isDisponible() + "$"); } } catch (Exception e) { e.printStackTrace(); } finally { try { bw.close(); fw.close(); } catch (IOException ex) { } } }//GEN-LAST:event_btn_guardar_complejosMouseClicked /** * @param args the command line arguments */ 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(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Principal().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton bnt_param_agregar; private javax.swing.JButton btn_agregar_relaciones; private javax.swing.JButton btn_ambu_agregar; private javax.swing.JButton btn_ambu_eliminar; private javax.swing.JButton btn_ambu_reasignar; private javax.swing.JButton btn_cargar_ambu; private javax.swing.JButton btn_cargar_param; private javax.swing.JButton btn_emergencia_buscarruta; private javax.swing.JButton btn_guardar_ambu; private javax.swing.JButton btn_guardar_complejos; private javax.swing.JButton btn_guardar_param; private javax.swing.JButton btn_hospital_agregar; private javax.swing.JButton btn_hospital_eliminar; private javax.swing.JButton btn_param_reasginar_param; private javax.swing.ButtonGroup buttonGroup1; private javax.swing.ButtonGroup buttonGroup2; private javax.swing.ButtonGroup buttonGroup3; private javax.swing.JComboBox cb_a_relacion; private javax.swing.JComboBox cb_ambu_compl; private javax.swing.JComboBox cb_ambu_eliminar; private javax.swing.JComboBox cb_ambu_reasignar_complejo; private javax.swing.JComboBox cb_ambu_reasignar_placa; private javax.swing.JComboBox cb_de_relacion; private javax.swing.JComboBox cb_emergencia_a; private javax.swing.JComboBox cb_emergencia_de; private javax.swing.JComboBox cb_hospital_eliminar; private javax.swing.JComboBox cb_param_complejo; private javax.swing.JComboBox cb_param_reasignar_complejo; private javax.swing.JComboBox cb_param_reasignar_nombre; private javax.swing.JButton jButton1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel12; private javax.swing.JLabel jLabel13; private javax.swing.JLabel jLabel14; private javax.swing.JLabel jLabel15; private javax.swing.JLabel jLabel16; private javax.swing.JLabel jLabel17; private javax.swing.JLabel jLabel18; private javax.swing.JLabel jLabel19; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel20; private javax.swing.JLabel jLabel21; private javax.swing.JLabel jLabel22; private javax.swing.JLabel jLabel23; private javax.swing.JLabel jLabel24; private javax.swing.JLabel jLabel25; private javax.swing.JLabel jLabel26; private javax.swing.JLabel jLabel27; private javax.swing.JLabel jLabel28; private javax.swing.JLabel jLabel29; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel30; private javax.swing.JLabel jLabel31; private javax.swing.JLabel jLabel32; private javax.swing.JLabel jLabel33; private javax.swing.JLabel jLabel34; private javax.swing.JLabel jLabel35; private javax.swing.JLabel jLabel36; private javax.swing.JLabel jLabel37; private javax.swing.JLabel jLabel38; private javax.swing.JLabel jLabel39; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel40; private javax.swing.JLabel jLabel41; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JMenu jMenu1; private javax.swing.JMenu jMenu2; private javax.swing.JMenu jMenu3; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenuItem jMenuItem_agregar_hospital; private javax.swing.JMenuItem jMenuItem_agregar_paramedicos; private javax.swing.JMenuItem jMenuItem_cargar_archivos; private javax.swing.JMenuItem jMenuItem_crear_relaciones; private javax.swing.JMenuItem jMenuItem_eliminar_ambulancia; private javax.swing.JMenuItem jMenuItem_eliminar_hospital; private javax.swing.JMenuItem jMenuItem_emergencia_crear; private javax.swing.JMenuItem jMenuItem_guardar_archivos; private javax.swing.JMenuItem jMenuItem_reasignar_ambulancia; private javax.swing.JMenuItem jMenuItem_reasignar_paramedicos; private javax.swing.JMenuItem jMenuItem_registrar_ambulancia; private javax.swing.JMenuItem jMenuItem_ver_mapa; private javax.swing.JScrollPane jScrollPane4; private javax.swing.JDialog jd_ambu_eliminar; private javax.swing.JDialog jd_ambu_reasignar; private javax.swing.JDialog jd_ambu_registrar; private javax.swing.JDialog jd_archivos_cargar; private javax.swing.JDialog jd_archivos_guardar; private javax.swing.JDialog jd_crear_relaciones; private javax.swing.JDialog jd_dijsktra; private javax.swing.JDialog jd_emergencias_crear; private javax.swing.JDialog jd_hospital_agregar; private javax.swing.JDialog jd_hospital_lugar_eliminar; private javax.swing.JDialog jd_paramedicos_agregar; private javax.swing.JDialog jd_paramedicos_reasignar; private javax.swing.JSpinner js_nivel; private javax.swing.JRadioButton rb_emer_a; private javax.swing.JRadioButton rb_emer_b; private javax.swing.JRadioButton rb_emer_c; private javax.swing.JRadioButton rb_emer_d; private javax.swing.JRadioButton rb_hospital_a; private javax.swing.JRadioButton rb_hospital_b; private javax.swing.JRadioButton rb_hospital_c; private javax.swing.JRadioButton rb_hospital_d; private javax.swing.JRadioButton rb_param_a; private javax.swing.JRadioButton rb_param_b; private javax.swing.JRadioButton rb_param_c; private javax.swing.JRadioButton rb_param_d; private javax.swing.JRadioButton rb_tipo_hosp; private javax.swing.JRadioButton rb_tipo_lug; private javax.swing.JSpinner sp_ambu_vel; private javax.swing.JSpinner sp_hosp_ambu; private javax.swing.JSpinner sp_hosp_param; private javax.swing.JSpinner sp_param_edad; private javax.swing.JTextArea ta_pizarra; private javax.swing.JFormattedTextField txt_ambu_ano; private javax.swing.JTextField txt_ambu_placa; private javax.swing.JTextField txt_hospital_direccion; private javax.swing.JTextField txt_hospital_nombre; private javax.swing.JTextField txt_param_ident; private javax.swing.JTextField txt_param_nombre; private javax.swing.JTextField txt_recorrido_a; private javax.swing.JTextField txt_recorrido_de; // End of variables declaration//GEN-END:variables ArrayList<Lugar> lista_lugares = new ArrayList(); ArrayList<Paramedicos> lista_param = new ArrayList(); ArrayList<Ambulancias> lista_ambu = new ArrayList(); ArrayList<Lugar> lista_vecinos = new ArrayList(); SparseMultigraph<Lugar, Relacion_a_vecino> grafo = new SparseMultigraph<Lugar, Relacion_a_vecino>(); SparseMultigraph<Lugar, Relacion> grafo1 = new SparseMultigraph<Lugar, Relacion>(); }