my.grafos.ContactEditorUI.java Source code

Java tutorial

Introduction

Here is the source code for my.grafos.ContactEditorUI.java

Source

/*
 * 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 my.grafos;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import static my.grafos.Fabrica.xstream;
import org.apache.commons.lang.RandomStringUtils;

public class ContactEditorUI extends javax.swing.JFrame {

    /**
     * Creates new form ContactEditorUI
     */
    public ContactEditorUI() {
        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() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        isDirecionado = new java.awt.Checkbox();
        vOAresta = new javax.swing.JComboBox<>();
        vDAresta = new javax.swing.JComboBox<>();
        idAresta = new javax.swing.JTextField();
        idVertice = new javax.swing.JTextField();
        proxAresta = new javax.swing.JButton();
        antAresta = new javax.swing.JButton();
        proxVertice = new javax.swing.JButton();
        addAresta = new javax.swing.JButton();
        antVertice = new javax.swing.JButton();
        removAresta = new javax.swing.JButton();
        addVertice = new javax.swing.JButton();
        removVertice = new javax.swing.JButton();
        jLabel16 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        idArestaEx = new javax.swing.JTextField();
        idVerticeEx = new javax.swing.JTextField();
        oArestaEx = new javax.swing.JTextField();
        dArestaEx = new javax.swing.JTextField();
        isExDirecionado = new java.awt.Checkbox();
        imprimeListaA = new javax.swing.JButton();
        imprimeListaV = new javax.swing.JButton();
        algHungaro = new javax.swing.JButton();
        jLabel20 = new javax.swing.JLabel();
        subConjVertice = new javax.swing.JComboBox<>();
        jScrollPane1 = new javax.swing.JScrollPane();
        TextAreaUI = new javax.swing.JTextArea();
        MatrizAdjacencia = new javax.swing.JButton();
        ListaAdjacencia = new javax.swing.JButton();
        MatrizIncidencia = new javax.swing.JButton();
        getAdjacentes = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jMenuBar2 = new javax.swing.JMenuBar();
        jMenu3 = new javax.swing.JMenu();
        abrirGrafo = new javax.swing.JMenuItem();
        salvarGrafo = new javax.swing.JMenuItem();
        jMenu4 = new javax.swing.JMenu();

        FormListener formListener = new FormListener();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Teoria dos Grafos");

        jLabel1.setText("Id");

        jLabel2.setText("Direcionado");

        jLabel3.setText("Vrtice de Origem");

        jLabel4.setText("Vrtice de Destino");

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel8.setText("Incluir Aresta");

        jLabel9.setBackground(java.awt.Color.gray);
        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel9.setText("Incluir Vrtice");

        jLabel7.setText("Id");

        vOAresta.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] {}));
        vOAresta.addActionListener(formListener);

        vDAresta.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] {}));
        vDAresta.addActionListener(formListener);

        idAresta.addActionListener(formListener);

        idVertice.addActionListener(formListener);

        proxAresta.setText("++Aresta");
        proxAresta.addActionListener(formListener);

        antAresta.setText("- - Aresta");
        antAresta.addActionListener(formListener);

        proxVertice.setText("++Vrtice");
        proxVertice.addActionListener(formListener);

        addAresta.setText("AdicionarAresta");
        addAresta.addActionListener(formListener);

        antVertice.setText("- - Vrtice");
        antVertice.addActionListener(formListener);

        removAresta.setText("ApagarAresta");
        removAresta.addActionListener(formListener);

        addVertice.setText("AdicionarVrtice");
        addVertice.addActionListener(formListener);

        removVertice.setText("ApagarVrtice");
        removVertice.addActionListener(formListener);

        jLabel16.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel16.setText("Exibir Aresta");

        jLabel10.setText("Id");

        jLabel11.setText("Direcionado");

        jLabel12.setText("Origem");

        jLabel13.setText("Destino");

        jLabel17.setBackground(java.awt.Color.gray);
        jLabel17.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel17.setText("Exibir Vrtice");

        jLabel18.setText("Id");

        idArestaEx.setEditable(false);
        idArestaEx.addActionListener(formListener);

        idVerticeEx.setEditable(false);
        idVerticeEx.addActionListener(formListener);

        oArestaEx.setEditable(false);
        oArestaEx.addActionListener(formListener);

        dArestaEx.setEditable(false);
        dArestaEx.addActionListener(formListener);

        imprimeListaA.setText("PrintListaAresta");
        imprimeListaA.addActionListener(formListener);

        imprimeListaV.setText("PrintListaVertice");
        imprimeListaV.addActionListener(formListener);

        algHungaro.setIcon(new javax.swing.ImageIcon("D:\\GSF\\04\\Grafos\\img\\Dnes_Knig.jpg")); // NOI18N
        algHungaro.setText("Algoritmo Hngaro");
        algHungaro.addActionListener(formListener);

        jLabel20.setText("Subconjunto");

        subConjVertice.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "0", "1" }));
        subConjVertice.addActionListener(formListener);

        TextAreaUI.setColumns(20);
        TextAreaUI.setFont(new java.awt.Font("Arial", 0, 13)); // NOI18N
        TextAreaUI.setRows(5);
        jScrollPane1.setViewportView(TextAreaUI);

        MatrizAdjacencia.setText("Matriz Adjacncia");
        MatrizAdjacencia.addActionListener(formListener);

        ListaAdjacencia.setText("Lista Adjacncia");
        ListaAdjacencia.addActionListener(formListener);

        MatrizIncidencia.setText("Matriz Incidencia");
        MatrizIncidencia.addActionListener(formListener);

        getAdjacentes.setText("Listar Adjacentes");
        getAdjacentes.addActionListener(formListener);

        jButton1.setText("Vertices Incidentes");
        jButton1.addActionListener(formListener);

        jMenu3.setText("Arquivo");

        abrirGrafo.setText("Abrir grafo");
        abrirGrafo.addActionListener(formListener);
        jMenu3.add(abrirGrafo);

        salvarGrafo.setText("Salvar grafo");
        salvarGrafo.addActionListener(formListener);
        jMenu3.add(salvarGrafo);

        jMenuBar2.add(jMenu3);

        jMenu4.setText("Edit");
        jMenuBar2.add(jMenu4);

        setJMenuBar(jMenuBar2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout
                                        .createSequentialGroup().addGroup(layout.createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(addAresta).addComponent(imprimeListaA).addComponent(
                                                        jLabel9)
                                                .addGroup(layout.createSequentialGroup().addComponent(jLabel7)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addComponent(idVertice,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 95,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addGroup(layout
                                                        .createSequentialGroup().addComponent(jLabel20)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addComponent(
                                                                subConjVertice,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 123,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addGroup(layout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                        .addComponent(addVertice,
                                                                javax.swing.GroupLayout.Alignment.TRAILING)
                                                        .addComponent(
                                                                imprimeListaV,
                                                                javax.swing.GroupLayout.Alignment.TRAILING))
                                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                        layout.createSequentialGroup().addGroup(layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addComponent(jLabel2,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE)
                                                                .addComponent(jLabel4,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE)
                                                                .addComponent(jLabel3,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE)
                                                                .addComponent(
                                                                        jLabel1,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE))
                                                                .addPreferredGap(
                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                .addGroup(layout.createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                        .addComponent(idAresta,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                81,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                        .addComponent(vOAresta,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                93,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                        .addComponent(vDAresta,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                92,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                        .addComponent(isDirecionado,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                27,
                                                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                                                .addGap(16, 16, 16)))
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(layout.createSequentialGroup().addGap(26, 26,
                                                        26)
                                                        .addComponent(jScrollPane1,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 400,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addGap(0, 0, Short.MAX_VALUE))
                                                .addGroup(layout.createSequentialGroup().addGap(18, 18, 18)
                                                        .addGroup(layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                .addGroup(layout.createSequentialGroup()
                                                                        .addGroup(layout.createParallelGroup(
                                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                                .addGroup(layout
                                                                                        .createSequentialGroup()
                                                                                        .addComponent(jLabel12,
                                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                36,
                                                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                                        .addPreferredGap(
                                                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                                        .addComponent(oArestaEx,
                                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                57,
                                                                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                                                                .addGroup(layout
                                                                                        .createSequentialGroup()
                                                                                        .addComponent(jLabel13)
                                                                                        .addPreferredGap(
                                                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                                        .addComponent(dArestaEx,
                                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                57,
                                                                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                                                                .addComponent(jLabel17)
                                                                                .addGroup(layout
                                                                                        .createSequentialGroup()
                                                                                        .addComponent(jLabel18)
                                                                                        .addPreferredGap(
                                                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                                        .addComponent(idVerticeEx,
                                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                57,
                                                                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                                                                .addComponent(removAresta,
                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                        109,
                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                                .addComponent(removVertice)
                                                                                .addGroup(layout
                                                                                        .createParallelGroup(
                                                                                                javax.swing.GroupLayout.Alignment.TRAILING,
                                                                                                false)
                                                                                        .addGroup(layout
                                                                                                .createSequentialGroup()
                                                                                                .addComponent(
                                                                                                        jLabel10)
                                                                                                .addPreferredGap(
                                                                                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                                        Short.MAX_VALUE)
                                                                                                .addComponent(
                                                                                                        idArestaEx,
                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                        57,
                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                                                                        .addGroup(
                                                                                                javax.swing.GroupLayout.Alignment.LEADING,
                                                                                                layout.createSequentialGroup()
                                                                                                        .addComponent(
                                                                                                                jLabel11)
                                                                                                        .addPreferredGap(
                                                                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                                                        .addComponent(
                                                                                                                isExDirecionado,
                                                                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                                25,
                                                                                                                javax.swing.GroupLayout.PREFERRED_SIZE))))
                                                                        .addGap(6, 6, 6)
                                                                        .addGroup(layout.createParallelGroup(
                                                                                javax.swing.GroupLayout.Alignment.LEADING)
                                                                                .addGroup(layout
                                                                                        .createSequentialGroup()
                                                                                        .addGap(8, 8, 8)
                                                                                        .addGroup(layout
                                                                                                .createParallelGroup(
                                                                                                        javax.swing.GroupLayout.Alignment.LEADING)
                                                                                                .addComponent(
                                                                                                        proxVertice)
                                                                                                .addComponent(
                                                                                                        antVertice,
                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                                                        81,
                                                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                                                                                .addGroup(layout
                                                                                        .createParallelGroup(
                                                                                                javax.swing.GroupLayout.Alignment.LEADING,
                                                                                                false)
                                                                                        .addComponent(antAresta,
                                                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                                                Short.MAX_VALUE)
                                                                                        .addComponent(proxAresta))))
                                                                .addComponent(jLabel16))
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                Short.MAX_VALUE)
                                                        .addGroup(layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.LEADING,
                                                                        false)
                                                                .addComponent(MatrizAdjacencia,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE)
                                                                .addComponent(ListaAdjacencia,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE)
                                                                .addComponent(getAdjacentes,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE)
                                                                .addComponent(MatrizIncidencia,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE)
                                                                .addComponent(jButton1,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE))
                                                        .addGap(69, 69, 69))))
                                .addGroup(layout.createSequentialGroup().addComponent(algHungaro)
                                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))));

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
                new java.awt.Component[] { jLabel10, jLabel11, jLabel12, jLabel13 });

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
                new java.awt.Component[] { dArestaEx, idArestaEx, oArestaEx });

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
                new java.awt.Component[] { idAresta, vDAresta, vOAresta });

        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup().addGroup(layout
                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup().addComponent(jLabel8)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(idAresta, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(layout.createSequentialGroup()
                                                        .addComponent(isDirecionado,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addGroup(layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.BASELINE)
                                                                .addComponent(vOAresta,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addComponent(jLabel3,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE))
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                        .addGroup(layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.BASELINE)
                                                                .addComponent(vDAresta,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                .addComponent(jLabel4,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        Short.MAX_VALUE)))
                                                .addGroup(layout.createSequentialGroup()
                                                        .addComponent(jLabel2,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE, 20,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addGap(62, 62, 62)))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(addAresta)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(imprimeListaA).addGap(27, 27, 27))
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addGap(0, 0, Short.MAX_VALUE).addComponent(proxAresta)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(antAresta).addGap(109, 109, 109))
                                .addGroup(layout.createSequentialGroup().addComponent(MatrizAdjacencia)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(ListaAdjacencia)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(MatrizIncidencia)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(getAdjacentes)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jButton1)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(layout.createSequentialGroup().addComponent(jLabel9)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addGroup(layout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                                        .addComponent(jLabel7).addComponent(idVertice,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addGroup(layout
                                                        .createParallelGroup(
                                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                                        .addComponent(subConjVertice,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                                        .addComponent(jLabel20))
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(addVertice)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(imprimeListaV)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(algHungaro))
                                        .addGroup(layout.createSequentialGroup().addGroup(layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addGroup(layout.createSequentialGroup().addComponent(jLabel17)
                                                        .addGroup(layout
                                                                .createParallelGroup(
                                                                        javax.swing.GroupLayout.Alignment.BASELINE)
                                                                .addComponent(jLabel18).addComponent(idVerticeEx,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                        .addComponent(removVertice))
                                                .addGroup(layout.createSequentialGroup().addComponent(proxVertice)
                                                        .addPreferredGap(
                                                                javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                        .addComponent(antVertice)))
                                                .addGap(26, 26, 26)
                                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        130, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(0, 11, Short.MAX_VALUE))))
                        .addGroup(layout.createSequentialGroup().addComponent(jLabel16)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel10).addComponent(idArestaEx,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(
                                        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                                .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, 20,
                                                        Short.MAX_VALUE)
                                                .addComponent(isExDirecionado,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(12, 12, 12)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel12)
                                        .addComponent(oArestaEx, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel13).addComponent(dArestaEx,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(removAresta).addGap(142, 142, 142)))));

        layout.linkSize(javax.swing.SwingConstants.VERTICAL,
                new java.awt.Component[] { jLabel10, jLabel11, jLabel12, jLabel13 });

        layout.linkSize(javax.swing.SwingConstants.VERTICAL,
                new java.awt.Component[] { dArestaEx, idArestaEx, oArestaEx });

        pack();
    }

    // Code for dispatching events from components to event handlers.

    private class FormListener implements java.awt.event.ActionListener {
        FormListener() {
        }

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            if (evt.getSource() == vOAresta) {
                ContactEditorUI.this.vOArestaActionPerformed(evt);
            } else if (evt.getSource() == vDAresta) {
                ContactEditorUI.this.vDArestaActionPerformed(evt);
            } else if (evt.getSource() == idAresta) {
                ContactEditorUI.this.idArestaActionPerformed(evt);
            } else if (evt.getSource() == idVertice) {
                ContactEditorUI.this.idVerticeActionPerformed(evt);
            } else if (evt.getSource() == proxAresta) {
                ContactEditorUI.this.proxArestaActionPerformed(evt);
            } else if (evt.getSource() == antAresta) {
                ContactEditorUI.this.antArestaActionPerformed(evt);
            } else if (evt.getSource() == proxVertice) {
                ContactEditorUI.this.proxVerticeActionPerformed(evt);
            } else if (evt.getSource() == addAresta) {
                ContactEditorUI.this.addArestaActionPerformed(evt);
            } else if (evt.getSource() == antVertice) {
                ContactEditorUI.this.antVerticeActionPerformed(evt);
            } else if (evt.getSource() == removAresta) {
                ContactEditorUI.this.removArestaActionPerformed(evt);
            } else if (evt.getSource() == addVertice) {
                ContactEditorUI.this.addVerticeActionPerformed(evt);
            } else if (evt.getSource() == removVertice) {
                ContactEditorUI.this.removVerticeActionPerformed(evt);
            } else if (evt.getSource() == idArestaEx) {
                ContactEditorUI.this.idArestaExActionPerformed(evt);
            } else if (evt.getSource() == idVerticeEx) {
                ContactEditorUI.this.idVerticeExActionPerformed(evt);
            } else if (evt.getSource() == oArestaEx) {
                ContactEditorUI.this.oArestaExActionPerformed(evt);
            } else if (evt.getSource() == dArestaEx) {
                ContactEditorUI.this.dArestaExActionPerformed(evt);
            } else if (evt.getSource() == imprimeListaA) {
                ContactEditorUI.this.imprimeListaAActionPerformed(evt);
            } else if (evt.getSource() == imprimeListaV) {
                ContactEditorUI.this.imprimeListaVActionPerformed(evt);
            } else if (evt.getSource() == algHungaro) {
                ContactEditorUI.this.algHungaroActionPerformed(evt);
            } else if (evt.getSource() == subConjVertice) {
                ContactEditorUI.this.subConjVerticeActionPerformed(evt);
            } else if (evt.getSource() == abrirGrafo) {
                ContactEditorUI.this.abrirGrafoActionPerformed(evt);
            } else if (evt.getSource() == salvarGrafo) {
                ContactEditorUI.this.salvarGrafoActionPerformed(evt);
            } else if (evt.getSource() == MatrizAdjacencia) {
                ContactEditorUI.this.MatrizAdjacenciaActionPerformed(evt);
            } else if (evt.getSource() == ListaAdjacencia) {
                ContactEditorUI.this.ListaAdjacenciaActionPerformed(evt);
            } else if (evt.getSource() == MatrizIncidencia) {
                ContactEditorUI.this.MatrizIncidenciaActionPerformed(evt);
            } else if (evt.getSource() == getAdjacentes) {
                ContactEditorUI.this.getAdjacentesActionPerformed(evt);
            } else if (evt.getSource() == jButton1) {
                ContactEditorUI.this.jButton1ActionPerformed(evt);
            }
        }
    }// </editor-fold>//GEN-END:initComponents
    // author GiovanniStroppaFaquin

    String t = "";
    boolean b = false;
    int v = 0;
    int a = 0;
    Aresta aresta;
    Vertice vertice;

    private void vOArestaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vOArestaActionPerformed
        //        System.out.println("Nome do objeto: " + oAresta.getName());
        //        System.out.println("Itens em ArestaOrigem: " + oAresta.getItemCount());
        //        System.out.println(vOAresta.getItemAt(vOAresta.getSelectedIndex()));
    }//GEN-LAST:event_vOArestaActionPerformed

    private void proxArestaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_proxArestaActionPerformed

        Fabrica.xmlA = xstream.toXML(Fabrica.listaArestas);
        System.out.println(Fabrica.xmlA + " fim da lista xml");

        aresta = Maquina.correrLista(1);
        idArestaEx.setText(Integer.toString(aresta.getId()));
        isExDirecionado.setState(aresta.isDirecionado());
        oArestaEx.setText(aresta.getOrigem().getId());
        dArestaEx.setText(aresta.getDestino().getId());

    }//GEN-LAST:event_proxArestaActionPerformed

    private void addArestaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addArestaActionPerformed
        Maquina.makeSalvarArestaAction(a, isDirecionado.getState(), vOAresta.getSelectedIndex(),
                vDAresta.getSelectedIndex());
        a++;
    }//GEN-LAST:event_addArestaActionPerformed

    private void addVerticeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addVerticeActionPerformed
        Maquina.makeSalvarVerticeAction(idVertice.getText(), subConjVertice.getSelectedIndex());
        idVertice.setText(t);
        vOAresta.removeAllItems();
        vDAresta.removeAllItems();

        for (int f = 0; f < Fabrica.listaVertices.size(); f++) {
            vOAresta.addItem(
                    Fabrica.listaVertices.get(f).getId() + " " + Fabrica.listaVertices.get(f).isSubconjunto());
            vDAresta.addItem(
                    Fabrica.listaVertices.get(f).getId() + " " + Fabrica.listaVertices.get(f).isSubconjunto());

        }
    }//GEN-LAST:event_addVerticeActionPerformed

    private void idArestaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_idArestaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_idArestaActionPerformed

    private void proxVerticeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_proxVerticeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_proxVerticeActionPerformed

    private void antVerticeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_antVerticeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_antVerticeActionPerformed

    private void removVerticeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removVerticeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_removVerticeActionPerformed

    private void removArestaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removArestaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_removArestaActionPerformed

    private void antArestaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_antArestaActionPerformed
        aresta = Maquina.correrLista(0);
        idArestaEx.setText(Maquina.getIndexNaLista());
        isExDirecionado.setState(aresta.isDirecionado());
        oArestaEx.setText(aresta.getOrigem().getId());
        dArestaEx.setText(aresta.getDestino().getId());

    }//GEN-LAST:event_antArestaActionPerformed

    private void idArestaExActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_idArestaExActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_idArestaExActionPerformed

    private void idVerticeExActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_idVerticeExActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_idVerticeExActionPerformed

    private void oArestaExActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_oArestaExActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_oArestaExActionPerformed

    private void dArestaExActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dArestaExActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_dArestaExActionPerformed

    private void idVerticeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_idVerticeActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_idVerticeActionPerformed

    private void vDArestaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_vDArestaActionPerformed
        //System.out.println("Nome do objeto: " + vDAresta.getName());
        //System.out.println("Itens em ArestaDestino: " + vDAresta.getItemCount());
        //vDAresta.getSelectedItem();
    }//GEN-LAST:event_vDArestaActionPerformed

    private void salvarGrafoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_salvarGrafoActionPerformed
        try {
            Maquina.salvarGrafo();
        } catch (IOException ex) {
            Logger.getLogger(ContactEditorUI.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_salvarGrafoActionPerformed

    private void abrirGrafoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_abrirGrafoActionPerformed
        try {
            Maquina.abrirGrafo();
        } catch (IOException ex) {
            Logger.getLogger(ContactEditorUI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(ContactEditorUI.class.getName()).log(Level.SEVERE, null, ex);
        }
        idVertice.setText(t);
        vOAresta.removeAllItems();
        vDAresta.removeAllItems();

        for (int f = 0; f < Fabrica.listaVertices.size(); f++) {
            vOAresta.addItem(
                    Fabrica.listaVertices.get(f).getId() + " " + Fabrica.listaVertices.get(f).isSubconjunto());
            vDAresta.addItem(
                    Fabrica.listaVertices.get(f).getId() + " " + Fabrica.listaVertices.get(f).isSubconjunto());

        }
        System.out.println(Fabrica.listaArestas);
    }//GEN-LAST:event_abrirGrafoActionPerformed

    private void imprimeListaAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_imprimeListaAActionPerformed

        StringBuilder listaArestas = new StringBuilder();
        listaArestas.append("Lista de Arestas: {");
        for (int q = 0; q < Fabrica.getTamanhoListaArestas(); q++) {
            aresta = Fabrica.listaArestas.get(q);
            listaArestas.append(aresta.getId() + ", ");
            System.out.println(aresta + " " + aresta.getId() + " " + aresta.getOrigem().getId() + " "
                    + aresta.getDestino().getId());
        }
        listaArestas.delete(listaArestas.length() - 2, listaArestas.length());
        listaArestas.append("}");
        TextAreaUI.setText(listaArestas.toString());
    }//GEN-LAST:event_imprimeListaAActionPerformed

    private void imprimeListaVActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_imprimeListaVActionPerformed
        StringBuilder listaVertice = new StringBuilder();
        listaVertice.append("Lista de Vrtices: {");
        for (int q = 0; q < Fabrica.getTamanhoListaVertices(); q++) {
            vertice = Fabrica.listaVertices.get(q);
            listaVertice.append(vertice.getId() + ", ");
            System.out.println(vertice + vertice.getId() + vertice.isSubconjunto());
        }
        listaVertice.delete((listaVertice.length() - 2), listaVertice.length());
        listaVertice.append("}");
        TextAreaUI.setText(listaVertice.toString());

    }//GEN-LAST:event_imprimeListaVActionPerformed

    private void algHungaroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_algHungaroActionPerformed
        Algoritmos.algHungaro();
    }//GEN-LAST:event_algHungaroActionPerformed

    private void subConjVerticeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_subConjVerticeActionPerformed

    }//GEN-LAST:event_subConjVerticeActionPerformed

    private void MatrizAdjacenciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MatrizAdjacenciaActionPerformed
        TextAreaUI.setText(Maquina.makeGrafoMatrizAdjacencia());
    }//GEN-LAST:event_MatrizAdjacenciaActionPerformed

    private void ListaAdjacenciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ListaAdjacenciaActionPerformed
        TextAreaUI.setText(Maquina.makeGrafoListaAdjacencia());
    }//GEN-LAST:event_ListaAdjacenciaActionPerformed

    private void MatrizIncidenciaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MatrizIncidenciaActionPerformed
        TextAreaUI.setText(Maquina.makeGrafoMatrizIncidencia());
    }//GEN-LAST:event_MatrizIncidenciaActionPerformed

    private void getAdjacentesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_getAdjacentesActionPerformed
        TextAreaUI.setText(Maquina.getAdjacentes());
    }//GEN-LAST:event_getAdjacentesActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        TextAreaUI.setText(Maquina.getVerticesIncidentes());
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
     * @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(ContactEditorUI.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ContactEditorUI.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ContactEditorUI.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ContactEditorUI.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(() -> {
            new ContactEditorUI().setVisible(true);
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton ListaAdjacencia;
    private javax.swing.JButton MatrizAdjacencia;
    private javax.swing.JButton MatrizIncidencia;
    private javax.swing.JTextArea TextAreaUI;
    private javax.swing.JMenuItem abrirGrafo;
    private javax.swing.JButton addAresta;
    private javax.swing.JButton addVertice;
    private javax.swing.JButton algHungaro;
    private javax.swing.JButton antAresta;
    private javax.swing.JButton antVertice;
    private javax.swing.JTextField dArestaEx;
    private javax.swing.JButton getAdjacentes;
    private javax.swing.JTextField idAresta;
    private javax.swing.JTextField idArestaEx;
    private javax.swing.JTextField idVertice;
    private javax.swing.JTextField idVerticeEx;
    private javax.swing.JButton imprimeListaA;
    private javax.swing.JButton imprimeListaV;
    private java.awt.Checkbox isDirecionado;
    private java.awt.Checkbox isExDirecionado;
    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 jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenuBar jMenuBar2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField oArestaEx;
    private javax.swing.JButton proxAresta;
    private javax.swing.JButton proxVertice;
    private javax.swing.JButton removAresta;
    private javax.swing.JButton removVertice;
    private javax.swing.JMenuItem salvarGrafo;
    private javax.swing.JComboBox<String> subConjVertice;
    private javax.swing.JComboBox<String> vDAresta;
    private javax.swing.JComboBox<String> vOAresta;
    // End of variables declaration//GEN-END:variables
}