package interfaz;
import algoritmobr.*;
import dibujo.*;
import gestion.Captura;
import java.awt.*;
import java.awt.print.PrinterJob;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import otros.Informacion;

public class Interfaz extends javax.swing.JFrame {

     public AreaDibujo areaDibujo;
     public static boolean abierto;
     public static boolean archivo;
     public static File file;
     public static PrinterJob job;
    // public static TablaAcciones Acciones;
     public static Arista listaC[]=new Arista[100];
     public static Arista listaCM[]=new Arista[100];
     
     //Declaración de Grafos a usar
     public static Grafo R = new Grafo("R");
     public static Grafo B = new Grafo("B");
     
     public static int CantidadAristasC=0;
     public static int CantidadAristasCM=0;
     public static int colorearGrafo =0;
      
    public Interfaz(){
     //    setUndecorated(true);
       Image icon;
        icon = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/iconos/core32.png"));
       setIconImage(icon);
     
    this.setExtendedState(JFrame.MAXIMIZED_BOTH);
 
  try
   {
    JFrame.setDefaultLookAndFeelDecorated(true);
    JDialog.setDefaultLookAndFeelDecorated(true);
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   }
    catch (Exception e)
     {
      e.printStackTrace();}
          
         initComponents();
         //WindowDragger bartar=new WindowDragger(this,barraMenuPrincipal);

       // x:1010 y:650
         //setExtendedState();
         setLocationRelativeTo(null);
        areaDibujo=new AreaDibujo();
        //areaDibujo.setBounds(baseDerecha.getBounds());
        frameDibujo.add(areaDibujo , java.awt.BorderLayout.CENTER);
        frameDibujo.setBackground(Color.WHITE);
        areaDibujo.setVisible(true);
        areaDibujo.setBackground(Color.WHITE);
        frameDibujo.getContentPane().setBackground(Color.WHITE);
        frameDibujo.setVisible(false);
        nodoNuevo.setEnabled(false);
        nodoNuevo1.setEnabled(false);
        aristaNueva.setEnabled(false);
        BarAgregaArista.setEnabled(false);
        cambiarEtiqueta.setEnabled(false);
        configurarPagina.setEnabled(false);
        imprimir.setEnabled(false);
        Imprimir.setEnabled(false);
       // jScrollPane1.setBounds(0, 0, 905, 625);
        Screen.setEnabled(false);
        abierto=false;
        guardarArchivo.setEnabled(false);
        Cuadricular.setEnabled(false);
        menuGuardarComo.setEnabled(false);
        menuGuardar.setEnabled(false);
        guardarimagen.setEnabled(false);
        BarAgregavertice.setEnabled(false);
        cuadri.setEnabled(false);
        AreaPunteada.setEnabled(false);
        jButton1.setEnabled(false);////////////////////////////////////////////////
        archivo=false;
        file=null;
        menuNuevo.addActionListener(nuevoDocumento.getAction());
        job=PrinterJob.getPrinterJob(); 
        jTextArea1.setEditable(abierto);
        jTextArea1.setEnabled(true);
  }

    /** 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() {

        grupoPaleta = new javax.swing.ButtonGroup();
        buttonbarra = new javax.swing.ButtonGroup();
        basePrincipal = new javax.swing.JPanel();
        jLayeredPane4 = new javax.swing.JLayeredPane();
        barraHerramientas = new javax.swing.JToolBar();
        nuevoDocumento = new javax.swing.JButton();
        abrirDocumento = new javax.swing.JButton();
        guardarArchivo = new javax.swing.JButton();
        imprimir = new javax.swing.JButton();
        Screen = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JToolBar.Separator();
        jButton2 = new javax.swing.JButton();
        jSeparator9 = new javax.swing.JToolBar.Separator();
        jButton1 = new javax.swing.JButton();
        barraHerramientas2 = new javax.swing.JToolBar();
        modificar = new javax.swing.JToggleButton();
        nodoNuevo = new javax.swing.JToggleButton();
        nodoNuevo1 = new javax.swing.JToggleButton();
        aristaNueva = new javax.swing.JToggleButton();
        cambiarEtiqueta = new javax.swing.JToggleButton();
        jSeparator4 = new javax.swing.JToolBar.Separator();
        Cuadricular = new javax.swing.JToggleButton();
        frameDibujo = new javax.swing.JInternalFrame();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jPanel1 = new javax.swing.JPanel();
        jSeparator6 = new javax.swing.JToolBar.Separator();
        jLabel2 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel1 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel7 = new javax.swing.JLabel();
        jSeparator7 = new javax.swing.JSeparator();
        jLabel8 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        barraMenuPrincipal = new javax.swing.JMenuBar();
        menuArchivo = new javax.swing.JMenu();
        menuNuevo = new javax.swing.JMenuItem();
        menuAbrir = new javax.swing.JMenuItem();
        jSeparator13 = new javax.swing.JPopupMenu.Separator();
        menuGuardar = new javax.swing.JMenuItem();
        menuGuardarComo = new javax.swing.JMenuItem();
        guardarimagen = new javax.swing.JMenuItem();
        jSeparator14 = new javax.swing.JPopupMenu.Separator();
        Imprimir = new javax.swing.JMenuItem();
        configurarPagina = new javax.swing.JMenuItem();
        jSeparator15 = new javax.swing.JPopupMenu.Separator();
        menuSalir = new javax.swing.JMenuItem();
        menuEditar = new javax.swing.JMenu();
        jSeparator8 = new javax.swing.JPopupMenu.Separator();
        BarSelec = new javax.swing.JCheckBoxMenuItem();
        editVertices = new javax.swing.JMenu();
        BarAgregavertice = new javax.swing.JCheckBoxMenuItem();
        EditArista = new javax.swing.JMenu();
        BarAgregaArista = new javax.swing.JCheckBoxMenuItem();
        jSeparator16 = new javax.swing.JPopupMenu.Separator();
        jSeparator12 = new javax.swing.JPopupMenu.Separator();
        Ver = new javax.swing.JMenu();
        cuadri = new javax.swing.JCheckBoxMenuItem();
        AreaPunteada = new javax.swing.JCheckBoxMenuItem();
        jSeparator18 = new javax.swing.JPopupMenu.Separator();
        menuAyuda = new javax.swing.JMenu();
        menuItemAyuda = new javax.swing.JMenuItem();
        Acerca = new javax.swing.JMenuItem();

        setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        setTitle("Simulador para Análisis de Algoritmo BR");
        setBackground(new java.awt.Color(255, 255, 255));
        setFocusTraversalPolicyProvider(true);
        setForeground(new java.awt.Color(102, 153, 255));
        setMinimumSize(new java.awt.Dimension(1010, 650));
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
        });

        basePrincipal.setBackground(new java.awt.Color(255, 255, 255));
        basePrincipal.setLayout(new java.awt.BorderLayout());

        jLayeredPane4.setBackground(new java.awt.Color(0, 0, 0));

        barraHerramientas.setBackground(new java.awt.Color(255, 255, 255));
        barraHerramientas.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        barraHerramientas.setFloatable(false);
        barraHerramientas.setForeground(new java.awt.Color(153, 220, 255));
        barraHerramientas.setRollover(true);
        barraHerramientas.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

        nuevoDocumento.setBackground(new java.awt.Color(255, 255, 255));
        nuevoDocumento.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/linedpaper32.png"))); // NOI18N
        nuevoDocumento.setToolTipText("Nuevo Grafo");
        nuevoDocumento.setFocusable(false);
        nuevoDocumento.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        nuevoDocumento.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        nuevoDocumento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nuevoDocumentoActionPerformed(evt);
            }
        });
        barraHerramientas.add(nuevoDocumento);
        barraHerramientas.setVisible(true);

        abrirDocumento.setBackground(new java.awt.Color(255, 255, 255));
        abrirDocumento.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/folder32.png"))); // NOI18N
        abrirDocumento.setToolTipText("Abrir Grafo");
        abrirDocumento.setFocusable(false);
        abrirDocumento.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        abrirDocumento.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        abrirDocumento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                abrirDocumentoActionPerformed(evt);
            }
        });
        barraHerramientas.add(abrirDocumento);

        guardarArchivo.setBackground(new java.awt.Color(255, 255, 255));
        guardarArchivo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/filesave.png"))); // NOI18N
        guardarArchivo.setToolTipText("Guardar Grafo");
        guardarArchivo.setFocusable(false);
        guardarArchivo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        guardarArchivo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        guardarArchivo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                guardarArchivoActionPerformed(evt);
            }
        });
        barraHerramientas.add(guardarArchivo);

        imprimir.setBackground(new java.awt.Color(255, 255, 255));
        imprimir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/printer32.png"))); // NOI18N
        imprimir.setToolTipText("Imprimir");
        imprimir.setFocusable(false);
        imprimir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        imprimir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        barraHerramientas.add(imprimir);

        Screen.setBackground(new java.awt.Color(255, 255, 255));
        Screen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/camera32.png"))); // NOI18N
        Screen.setToolTipText("Obtener Imagen");
        Screen.setFocusable(false);
        Screen.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Screen.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Screen.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ScreenMouseClicked(evt);
            }
        });
        Screen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ScreenActionPerformed(evt);
            }
        });
        barraHerramientas.add(Screen);
        barraHerramientas.add(jSeparator3);

        jButton2.setBackground(new java.awt.Color(255, 255, 255));
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/aleatorio.png"))); // NOI18N
        jButton2.setText("Aleatorio");
        jButton2.setToolTipText("Genera Grafo Aleatorio");
        jButton2.setFocusable(false);
        jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        barraHerramientas.add(jButton2);
        barraHerramientas.add(jSeparator9);

        jButton1.setBackground(new java.awt.Color(255, 255, 255));
        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/boton.png"))); // NOI18N
        jButton1.setToolTipText("Ejecuta Algoritmo BR (Ctrl+ENTER)");
        buttonbarra.add(jButton1);
        jButton1.setFocusable(false);
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        barraHerramientas.add(jButton1);
        jButton1.getAccessibleContext().setAccessibleName("Algoritmo BR");
        jButton1.getAccessibleContext().setAccessibleDescription("Algoritmo BR");

        jLayeredPane4.add(barraHerramientas);
        barraHerramientas.setBounds(10, 10, 470, 50);

        barraHerramientas2.setBackground(new java.awt.Color(255, 255, 255));
        barraHerramientas2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        barraHerramientas2.setFloatable(false);
        barraHerramientas2.setForeground(new java.awt.Color(153, 220, 255));
        barraHerramientas2.setOrientation(javax.swing.SwingConstants.VERTICAL);
        barraHerramientas2.setRollover(true);
        barraHerramientas2.setToolTipText("");
        barraHerramientas2.setAlignmentX(0.5F);
        barraHerramientas2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        barraHerramientas2.setFocusCycleRoot(true);

        grupoPaleta.add(modificar);
        modificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/arrow32.png"))); // NOI18N
        modificar.setSelected(true);
        modificar.setToolTipText("Modificar");
        modificar.setFocusable(false);
        modificar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        modificar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        modificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                modificarActionPerformed(evt);
            }
        });
        barraHerramientas2.add(modificar);

        nodoNuevo.setBackground(new java.awt.Color(210, 215, 215));
        grupoPaleta.add(nodoNuevo);
        nodoNuevo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/esferaB.png"))); // NOI18N
        nodoNuevo.setToolTipText("Nuevo Nodo");
        nodoNuevo.setAutoscrolls(true);
        nodoNuevo.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        nodoNuevo.setFocusable(false);
        nodoNuevo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        nodoNuevo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        nodoNuevo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nodoNuevoActionPerformed(evt);
            }
        });
        barraHerramientas2.add(nodoNuevo);

        nodoNuevo1.setBackground(new java.awt.Color(210, 215, 215));
        grupoPaleta.add(nodoNuevo1);
        nodoNuevo1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/esferaR.png"))); // NOI18N
        nodoNuevo1.setToolTipText("Nuevo Nodo");
        nodoNuevo1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        nodoNuevo1.setFocusable(false);
        nodoNuevo1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        nodoNuevo1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        nodoNuevo1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nodoNuevo1ActionPerformed(evt);
            }
        });
        barraHerramientas2.add(nodoNuevo1);

        aristaNueva.setBackground(new java.awt.Color(210, 215, 215));
        grupoPaleta.add(aristaNueva);
        aristaNueva.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/esfera3.png"))); // NOI18N
        aristaNueva.setToolTipText("Nueva Arista No Dirigida");
        aristaNueva.setFocusable(false);
        aristaNueva.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        aristaNueva.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        aristaNueva.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aristaNuevaActionPerformed(evt);
            }
        });
        barraHerramientas2.add(aristaNueva);

        cambiarEtiqueta.setBackground(new java.awt.Color(210, 215, 215));
        grupoPaleta.add(cambiarEtiqueta);
        cambiarEtiqueta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/applix.png"))); // NOI18N
        cambiarEtiqueta.setToolTipText("Agregar/Cambiar Etiqueta");
        cambiarEtiqueta.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        cambiarEtiqueta.setFocusable(false);
        cambiarEtiqueta.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        cambiarEtiqueta.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        cambiarEtiqueta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cambiarEtiquetaActionPerformed(evt);
            }
        });
        barraHerramientas2.add(cambiarEtiqueta);
        barraHerramientas2.add(jSeparator4);

        Cuadricular.setBackground(new java.awt.Color(210, 215, 215));
        Cuadricular.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/Grid-32.png"))); // NOI18N
        Cuadricular.setToolTipText("Cuadricular Pantalla");
        Cuadricular.setFocusable(false);
        Cuadricular.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        Cuadricular.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        Cuadricular.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CuadricularActionPerformed(evt);
            }
        });
        barraHerramientas2.add(Cuadricular);

        jLayeredPane4.add(barraHerramientas2);
        barraHerramientas2.setBounds(950, 80, 40, 450);

        frameDibujo.setBackground(new java.awt.Color(255, 255, 255));
        frameDibujo.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Cuadro de Dibujo", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, new java.awt.Color(51, 153, 255)));
        frameDibujo.setClosable(true);
        frameDibujo.setMaximizable(true);
        frameDibujo.setTitle("Nuevo Grafo");
        frameDibujo.setAutoscrolls(true);
        frameDibujo.setFocusCycleRoot(false);
        frameDibujo.setFont(new java.awt.Font("Tahoma", 0, 8)); // NOI18N
        frameDibujo.setFrameIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/core32.png"))); // NOI18N
        frameDibujo.setPreferredSize(new java.awt.Dimension(900, 625));
        frameDibujo.setVisible(true);
        frameDibujo.addInternalFrameListener(new javax.swing.event.InternalFrameListener() {
            public void internalFrameActivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameClosed(javax.swing.event.InternalFrameEvent evt) {
                frameDibujoInternalFrameClosed(evt);
            }
            public void internalFrameClosing(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeactivated(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameDeiconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameIconified(javax.swing.event.InternalFrameEvent evt) {
            }
            public void internalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
            }
        });
        frameDibujo.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                frameDibujoMouseClicked(evt);
            }
        });
        jLayeredPane4.add(frameDibujo);
        frameDibujo.setBounds(290, 80, 650, 450);
        try {
            frameDibujo.setIcon(true);
        } catch (java.beans.PropertyVetoException e1) {
            e1.printStackTrace();
        }

        jScrollPane1.setBackground(new java.awt.Color(255, 255, 255));
        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        jScrollPane1.setAutoscrolls(true);

        jTextArea1.setColumns(20);
        jTextArea1.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        jTextArea1.setLineWrap(true);
        jTextArea1.setRows(5);
        jTextArea1.setWrapStyleWord(true);
        jTextArea1.setEnabled(false);
        jScrollPane1.setViewportView(jTextArea1);

        jTabbedPane1.addTab("Resultados", null, jScrollPane1, "");

        jLayeredPane4.add(jTabbedPane1);
        jTabbedPane1.setBounds(10, 80, 270, 450);

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));
        jPanel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/logoU32.png"))); // NOI18N

        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jLabel1.setText("Proyecto de Título");

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel6.setText("Ingeniería Civil en Informática");

        jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel7.setText("<html><body><CENTER>Utilización de Algoritmos de Intersecciones Bicromáticas <br> entre dos Conjuntos de Segmentos: Rojos y Azules</CENTER></body></html>");
        jLabel7.setAutoscrolls(true);

        jSeparator7.setOrientation(javax.swing.SwingConstants.VERTICAL);

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel8.setText("<html><body>Joel Sebastián Torres Carrasco <br> Cristian Manuel Vallejos Vega</body></html>");
        jLabel8.setAutoscrolls(true);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jSeparator6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel6))
                .addGap(18, 18, 18)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 350, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 350, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jLabel6))
                    .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel1)
                                .addComponent(jSeparator6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel2))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jLabel7)
                    .addComponent(jSeparator7)
                    .addComponent(jLabel8))
                .addContainerGap())
        );

        jLayeredPane4.add(jPanel1);
        jPanel1.setBounds(10, 540, 980, 50);

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/icono1.png"))); // NOI18N
        jLayeredPane4.add(jLabel3);
        jLabel3.setBounds(930, 10, 60, 50);

        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/icono1.png"))); // NOI18N
        jLayeredPane4.add(jLabel4);
        jLabel4.setBounds(930, 10, 60, 50);

        jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/icono1.png"))); // NOI18N
        jLayeredPane4.add(jLabel5);
        jLabel5.setBounds(930, 10, 60, 50);

        basePrincipal.add(jLayeredPane4, java.awt.BorderLayout.CENTER);

        getContentPane().add(basePrincipal, java.awt.BorderLayout.CENTER);

        barraMenuPrincipal.setBackground(new java.awt.Color(51, 153, 255));
        barraMenuPrincipal.setForeground(new java.awt.Color(51, 102, 255));
        barraMenuPrincipal.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        barraMenuPrincipal.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                barraMenuPrincipalMouseDragged(evt);
            }
        });

        menuArchivo.setText("Archivo");

        menuNuevo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
        menuNuevo.setText("Nuevo Grafo");
        menuNuevo.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        menuArchivo.add(menuNuevo);

        menuAbrir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        menuAbrir.setText("Abrir grafo");
        menuAbrir.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        menuArchivo.add(menuAbrir);
        menuArchivo.add(jSeparator13);

        menuGuardar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        menuGuardar.setText("Guardar");
        menuGuardar.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        menuArchivo.add(menuGuardar);

        menuGuardarComo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        menuGuardarComo.setText("Guardar Como...");
        menuGuardarComo.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        menuArchivo.add(menuGuardarComo);

        guardarimagen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.CTRL_MASK));
        guardarimagen.setText("Guardar Imagen Como...");
        guardarimagen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                guardarimagenActionPerformed(evt);
            }
        });
        menuArchivo.add(guardarimagen);
        menuArchivo.add(jSeparator14);

        Imprimir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK));
        Imprimir.setText("Imprimir...");
        Imprimir.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        menuArchivo.add(Imprimir);

        configurarPagina.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        configurarPagina.setText("Configurar Pagina...");
        configurarPagina.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        menuArchivo.add(configurarPagina);
        menuArchivo.add(jSeparator15);

        menuSalir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK));
        menuSalir.setText("Salir");
        menuSalir.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        menuSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuSalirActionPerformed(evt);
            }
        });
        menuArchivo.add(menuSalir);

        barraMenuPrincipal.add(menuArchivo);

        menuEditar.setText("Editar");
        menuEditar.add(jSeparator8);

        buttonbarra.add(BarSelec);
        BarSelec.setSelected(true);
        BarSelec.setText("Mouse Selecionador");
        BarSelec.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BarSelecActionPerformed(evt);
            }
        });
        menuEditar.add(BarSelec);

        editVertices.setText("Editar Nodos");

        buttonbarra.add(BarAgregavertice);
        BarAgregavertice.setText("Agregar Nodo");
        BarAgregavertice.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BarAgregaverticeActionPerformed(evt);
            }
        });
        editVertices.add(BarAgregavertice);

        menuEditar.add(editVertices);

        EditArista.setText("Editar Aristas");

        buttonbarra.add(BarAgregaArista);
        BarAgregaArista.setText("Agregar Arista No Dirigida");
        BarAgregaArista.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BarAgregaAristaActionPerformed(evt);
            }
        });
        EditArista.add(BarAgregaArista);

        menuEditar.add(EditArista);
        menuEditar.add(jSeparator16);
        menuEditar.add(jSeparator12);

        barraMenuPrincipal.add(menuEditar);

        Ver.setText("Ver");

        cuadri.setText("Mostrar Fondo Cuadriculado");
        cuadri.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cuadriActionPerformed(evt);
            }
        });
        Ver.add(cuadri);

        AreaPunteada.setText("Mostrar Fondo Punteado");
        AreaPunteada.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AreaPunteadaActionPerformed(evt);
            }
        });
        Ver.add(AreaPunteada);
        Ver.add(jSeparator18);

        barraMenuPrincipal.add(Ver);

        menuAyuda.setBackground(new java.awt.Color(51, 153, 255));
        menuAyuda.setText("Ayuda");

        menuItemAyuda.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0));
        menuItemAyuda.setText("Informe de Proyecto de Título");
        menuItemAyuda.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        menuItemAyuda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemAyudaActionPerformed(evt);
            }
        });
        menuAyuda.add(menuItemAyuda);

        Acerca.setText("Acerca de");
        Acerca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AcercaActionPerformed(evt);
            }
        });
        menuAyuda.add(Acerca);

        barraMenuPrincipal.add(menuAyuda);

        setJMenuBar(barraMenuPrincipal);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    
    private void menuSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuSalirActionPerformed
    
        if(abierto==true)
        { 
            if(JOptionPane.showConfirmDialog(null, "¿Esta seguro de cerrar el Programa?\n"
                                    + "cualquier dato no guardado se perdera")==JOptionPane.YES_OPTION){
                System.exit(0);
            }
           
        }
        else{
            System.exit(0);
        }
    }//GEN-LAST:event_menuSalirActionPerformed

    private void barraMenuPrincipalMouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_barraMenuPrincipalMouseDragged
 
    }//GEN-LAST:event_barraMenuPrincipalMouseDragged

    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
       
    }//GEN-LAST:event_formWindowActivated

    private void menuItemAyudaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemAyudaActionPerformed
        try{
            //File directorio = new File("temp"); //Creas un nuevo directorio a nivel de tu jar.
            //directorio.mkdirs();
            //directorio.setWritable(true);
            //copias la direccion
            String archivo = "Tesis_2013.pdf";
            //nuevo archivo en esa direccion
            File temp = new File(archivo);
            InputStream is = this.getClass().getResourceAsStream("/PDFs/Tesis_2013.pdf");
            FileOutputStream archivoDestino = new FileOutputStream(temp);
            FileWriter fw = new FileWriter(temp);
            byte[] buffer = new byte[512*1024];
            //lees el archivo hasta que se acabe...
            int nbLectura;
            while ((nbLectura = is.read(buffer)) != -1)
                archivoDestino.write(buffer, 0, nbLectura);
            //cierras el archivo,el inputS y el FileW
            fw.close();
            archivoDestino.close();
            is.close();
            //abres el archivo temporal
            Desktop.getDesktop().open(temp);
        } catch (IOException ex) {
            System.out.println("Problema abriendo el pdf");
        }
    }//GEN-LAST:event_menuItemAyudaActionPerformed

    private void AreaPunteadaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AreaPunteadaActionPerformed
        AreaDibujo.lienzo.repaint();
    }//GEN-LAST:event_AreaPunteadaActionPerformed

    private void cuadriActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cuadriActionPerformed
        
        if(cuadri.isSelected()){
            Cuadricular.setSelected(true);
        }
        else{
                Cuadricular.setSelected(false);
        }
        AreaDibujo.lienzo.repaint();
    }//GEN-LAST:event_cuadriActionPerformed

    private void AcercaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AcercaActionPerformed
        Informacion Desarrolladores = new Informacion(new javax.swing.JFrame(), true);
    }//GEN-LAST:event_AcercaActionPerformed

    private void BarAgregaverticeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BarAgregaverticeActionPerformed
        if(BarAgregavertice.isSelected()){
            nodoNuevo.setSelected(true);
            nodoNuevo1.setSelected(true);
        }
    }//GEN-LAST:event_BarAgregaverticeActionPerformed

    private void BarSelecActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BarSelecActionPerformed
        if(BarSelec.isSelected()){
            modificar.setSelected(true);
        }
    }//GEN-LAST:event_BarSelecActionPerformed

    private void BarAgregaAristaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BarAgregaAristaActionPerformed
        if(BarAgregaArista.isSelected()){
            aristaNueva.setSelected(true);
        }
    }//GEN-LAST:event_BarAgregaAristaActionPerformed

    private void guardarimagenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_guardarimagenActionPerformed
 
                  Timer t=new Timer();
		TimerTask timerTask = new TimerTask() 
	        { 
                    @Override
	            public void run()  
	            { 
                     Captura cap=new Captura(frameDibujo);
	            } 
	        }; 
 
		t.schedule(timerTask,100);

    }//GEN-LAST:event_guardarimagenActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        if(abierto==true)
        { 
            if(JOptionPane.showConfirmDialog(null, "¿Esta seguro de cerrar el Programa?\n"
                                    + "cualquier dato no guardado se perdera")==JOptionPane.YES_OPTION){
                System.exit(0);
            }
           
        }
        else{
            System.exit(0);
        }
    }//GEN-LAST:event_formWindowClosing

    private void ScreenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ScreenMouseClicked

        if(Screen.isEnabled()==true)
        {
            Timer t=new Timer();
            TimerTask timerTask = new TimerTask()
            {
                @Override
                public void run()
                {
                    Captura cap=new Captura(frameDibujo);
                }
            };

            t.schedule(timerTask,100);
        }
    }//GEN-LAST:event_ScreenMouseClicked

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

    }//GEN-LAST:event_ScreenActionPerformed

    private void modificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_modificarActionPerformed
        if(modificar.isSelected()){
            BarSelec.setSelected(true);
        }
    }//GEN-LAST:event_modificarActionPerformed

    private void nodoNuevoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nodoNuevoActionPerformed
        if(nodoNuevo.isSelected()){
            BarAgregavertice.setSelected(true);
        }
    }//GEN-LAST:event_nodoNuevoActionPerformed

    private void aristaNuevaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aristaNuevaActionPerformed
        if(aristaNueva.isSelected()){
            BarAgregaArista.setSelected(true);
        }
    }//GEN-LAST:event_aristaNuevaActionPerformed

    private void cambiarEtiquetaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cambiarEtiquetaActionPerformed
        if(cambiarEtiqueta.isSelected()){
        }
    }//GEN-LAST:event_cambiarEtiquetaActionPerformed

    private void CuadricularActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CuadricularActionPerformed
        if(Cuadricular.isSelected()){
            cuadri.setSelected(true);
        }
        else{
            cuadri.setSelected(false);
        }
        AreaDibujo.lienzo.repaint();
    }//GEN-LAST:event_CuadricularActionPerformed

    private void frameDibujoInternalFrameClosed(javax.swing.event.InternalFrameEvent evt) {//GEN-FIRST:event_frameDibujoInternalFrameClosed
        cerrarFrame();
        file=null;
        archivo=false;
    }//GEN-LAST:event_frameDibujoInternalFrameClosed

    private void frameDibujoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_frameDibujoMouseClicked

    }//GEN-LAST:event_frameDibujoMouseClicked

    private void abrirDocumentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_abrirDocumentoActionPerformed
        // TODO add your handling code here:
        Interfaz.jTextArea1.setText("");
    }//GEN-LAST:event_abrirDocumentoActionPerformed

    private void nuevoDocumentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nuevoDocumentoActionPerformed
        // TODO add your handling code here:
        Interfaz.jTextArea1.setText("");
        R = new Grafo("R");
        B = new Grafo("B");
        
    }//GEN-LAST:event_nuevoDocumentoActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        if(B.vertices.size()<=10){
            int dim=B.aristas.size();
            for(int i=0; i<dim; i++){
                for(int j=i+1; j<dim; j++){
                    if(B.aristas.get(i).equals(B.aristas.get(j)))
                    {
                        B.aristas.remove(j);
                        j--;
                        dim--;
                    }
                }
            }
        }
        if(R.vertices.size()<=10){
            int dim=R.aristas.size();
            for(int i=0; i<dim; i++){
                for(int j=i+1; j<dim; j++){
                    if(R.aristas.get(i).equals(R.aristas.get(j)))
                    {
                        R.aristas.remove(j);
                        j--;
                        dim--;
                    }
                }
            }
        }
        if(B.esVacio() || R.esVacio())
        {
            JOptionPane.showMessageDialog(null, "ERROR, los Grafos no tienen información");
        }
        else
        {
            long tiempoEjecucionRB;
            long tiempoEjecucionBR;
            AlgoritmoBR Analizador = new AlgoritmoBR();
            jTextArea1.setText("\n\nAnalizando segmentos Azules\n");
            Analizador.BR(R,B);
            tiempoEjecucionRB = Analizador.gettiempo();
            
            Analizador = new AlgoritmoBR();
            jTextArea1.append("\n\nAnalizando segmentos Rojos\n");
            Analizador.BR(B,R);
            tiempoEjecucionBR = Analizador.gettiempo();
            
            
            jTextArea1.append("\nTiempo de Ejecución Conjunto R,B: " + (float) tiempoEjecucionRB / 1000000 + "(ms)");
            jTextArea1.append("\nTiempo de Ejecución Conjunto B,R: " + (float) tiempoEjecucionBR / 1000000 + "(ms)");
            jTextArea1.append("\nTiempo de Ejecución Completo: " + (float) (tiempoEjecucionRB + tiempoEjecucionBR)/ 1000000 + "(ms)");
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void nodoNuevo1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nodoNuevo1ActionPerformed
        // TODO add your handling code here:
        if(nodoNuevo.isSelected()){
            BarAgregavertice.setSelected(true);
        }
    }//GEN-LAST:event_nodoNuevo1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        Interfaz.frameDibujo.setVisible(true);
        R = new Grafo("R");
        B = new Grafo("B");
        String m = null;
        
        try{
        do
            m=JOptionPane.showInputDialog("Ingrese Cuántos Nodos tendrá el Grafo B", null);
        while(m.contains(",") || m.contains("."));
        
        B.aletorio(Integer.parseInt(m));
        
        do
            m=JOptionPane.showInputDialog("Ingrese Cuántos Nodos tendrá el Grafo R", null);
        while(m.contains(",") || m.contains("."));
        
        R.aletorio(Integer.parseInt(m));
        
        jButton1.setEnabled(true);
        
        guardarArchivo.setEnabled(true);
        
        }catch (Exception ex) {
                JOptionPane.showMessageDialog(null,"ERROR, Intente Nuevamente");
            }
    }//GEN-LAST:event_jButton2ActionPerformed

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


    public void cerrarFrame(){
       
        if(JOptionPane.showConfirmDialog(null, "¿Esta seguro de cerrar el archivo?\n"
                                    + "cualquier dato no guardado se perdera")==JOptionPane.YES_OPTION){
            
            abierto=false;
            areaDibujo.limpiarArea();
            areaDibujo.grafo.destruirGrafo();
            jButton1.setEnabled(false);
            jTextArea1.setText("");
            
            try {
                Thread.sleep(120);
            } catch (InterruptedException ex) {
                Logger.getLogger(Interfaz.class.getName()).log(Level.SEVERE, null, ex);
            }
            areaDibujo.desactivar();
            guardarArchivo.setEnabled(false);
            guardarimagen.setEnabled(false);
            nodoNuevo.setEnabled(false);
            nodoNuevo1.setEnabled(false);
            aristaNueva.setEnabled(false);
            BarAgregaArista.setEnabled(false);
            cambiarEtiqueta.setEnabled(false);
            configurarPagina.setEnabled(false);
            imprimir.setEnabled(false);
            Imprimir.setEnabled(false);
            jButton1.setEnabled(false);//////////////////////////////////////////////////////////////
           // jScrollPane1.setBounds(0, 0, 905, 625);
            Screen.setEnabled(false);
            Cuadricular.setEnabled(false);
            menuGuardarComo.setEnabled(false);
            menuGuardar.setEnabled(false);
            BarAgregavertice.setEnabled(false);
            cuadri.setEnabled(false);
            AreaPunteada.setEnabled(false);
        } else {
            frameDibujo.setVisible(true);
        }
    }
    /**
     * @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(Interfaz.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Interfaz.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Interfaz.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Interfaz.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                
                new Interfaz().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem Acerca;
    public static javax.swing.JCheckBoxMenuItem AreaPunteada;
    public static javax.swing.JCheckBoxMenuItem BarAgregaArista;
    public static javax.swing.JCheckBoxMenuItem BarAgregavertice;
    public static javax.swing.JCheckBoxMenuItem BarSelec;
    public static javax.swing.JToggleButton Cuadricular;
    public static javax.swing.JMenu EditArista;
    public static javax.swing.JMenuItem Imprimir;
    public static javax.swing.JButton Screen;
    public static javax.swing.JMenu Ver;
    public static javax.swing.JButton abrirDocumento;
    public static javax.swing.JToggleButton aristaNueva;
    public static javax.swing.JToolBar barraHerramientas;
    public javax.swing.JToolBar barraHerramientas2;
    private javax.swing.JMenuBar barraMenuPrincipal;
    private javax.swing.JPanel basePrincipal;
    private javax.swing.ButtonGroup buttonbarra;
    public static javax.swing.JToggleButton cambiarEtiqueta;
    public static javax.swing.JMenuItem configurarPagina;
    public static javax.swing.JCheckBoxMenuItem cuadri;
    public static javax.swing.JMenu editVertices;
    public static javax.swing.JInternalFrame frameDibujo;
    private javax.swing.ButtonGroup grupoPaleta;
    public static javax.swing.JButton guardarArchivo;
    public static javax.swing.JMenuItem guardarimagen;
    public static javax.swing.JButton imprimir;
    public static javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLayeredPane jLayeredPane4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator12;
    private javax.swing.JPopupMenu.Separator jSeparator13;
    private javax.swing.JPopupMenu.Separator jSeparator14;
    private javax.swing.JPopupMenu.Separator jSeparator15;
    private javax.swing.JPopupMenu.Separator jSeparator16;
    private javax.swing.JPopupMenu.Separator jSeparator18;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JToolBar.Separator jSeparator3;
    private javax.swing.JToolBar.Separator jSeparator4;
    private javax.swing.JToolBar.Separator jSeparator6;
    private javax.swing.JSeparator jSeparator7;
    private javax.swing.JPopupMenu.Separator jSeparator8;
    private javax.swing.JToolBar.Separator jSeparator9;
    public static javax.swing.JTabbedPane jTabbedPane1;
    public static javax.swing.JTextArea jTextArea1;
    public static javax.swing.JMenuItem menuAbrir;
    private javax.swing.JMenu menuArchivo;
    private javax.swing.JMenu menuAyuda;
    private javax.swing.JMenu menuEditar;
    public static javax.swing.JMenuItem menuGuardar;
    public static javax.swing.JMenuItem menuGuardarComo;
    private javax.swing.JMenuItem menuItemAyuda;
    public static javax.swing.JMenuItem menuNuevo;
    private javax.swing.JMenuItem menuSalir;
    public static javax.swing.JToggleButton modificar;
    public static javax.swing.JToggleButton nodoNuevo;
    public static javax.swing.JToggleButton nodoNuevo1;
    public static javax.swing.JButton nuevoDocumento;
    // End of variables declaration//GEN-END:variables
}
