/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Ntice.java
 *
 * Created on 7.4.2010, 20:32:01
 */

package cz.vutbr.feec.utko.fojtoval.krypto.windows;

import cz.vutbr.feec.utko.fojtoval.krypto.funkce.DelejNtice;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;

/**
 * Tato trida slouzi k zobrazeni n-tic v danem textu. 
 * @author fojtoval
 */
public class Ntice extends javax.swing.JFrame {

    DefaultTableCellRenderer mujdtcr = new DefaultTableCellRenderer();

    /** Creates new form Ntice */
    public Ntice() {
        mujdtcr.setHorizontalAlignment(SwingConstants.CENTER);
        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() {

        jScrollPane3 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N
        setResizable(false);

        jScrollPane3.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane3.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
        jScrollPane3.setName("jScrollPane3"); // NOI18N
        jScrollPane3.setWheelScrollingEnabled(false);

        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null}
            },
            new String [] {
                "2-ce", "3-ce", "4-ce", "5-ce", "6-ce", "7-ce", "8-ce", "9-ce", "10-ce"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable2.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
        jTable2.setAutoscrolls(false);
        jTable2.setName("jTable2"); // NOI18N
        jTable2.setRowSelectionAllowed(false);
        jTable2.getTableHeader().setReorderingAllowed(false);
        jTable2.setUpdateSelectionOnSort(false);
        jScrollPane3.setViewportView(jTable2);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(cz.vutbr.feec.utko.fojtoval.krypto.NavrhApp.class).getContext().getResourceMap(Ntice.class);
        jTable2.getColumnModel().getColumn(0).setResizable(false);
        jTable2.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("jTable2.columnModel.title0")); // NOI18N
        jTable2.getColumnModel().getColumn(0).setCellRenderer(mujdtcr);
        jTable2.getColumnModel().getColumn(1).setResizable(false);
        jTable2.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("jTable2.columnModel.title1")); // NOI18N
        jTable2.getColumnModel().getColumn(1).setCellRenderer(mujdtcr);
        jTable2.getColumnModel().getColumn(2).setResizable(false);
        jTable2.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("jTable2.columnModel.title2")); // NOI18N
        jTable2.getColumnModel().getColumn(2).setCellRenderer(mujdtcr);
        jTable2.getColumnModel().getColumn(3).setResizable(false);
        jTable2.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("jTable2.columnModel.title3")); // NOI18N
        jTable2.getColumnModel().getColumn(3).setCellRenderer(mujdtcr);
        jTable2.getColumnModel().getColumn(4).setResizable(false);
        jTable2.getColumnModel().getColumn(4).setHeaderValue(resourceMap.getString("jTable2.columnModel.title4")); // NOI18N
        jTable2.getColumnModel().getColumn(4).setCellRenderer(mujdtcr);
        jTable2.getColumnModel().getColumn(5).setResizable(false);
        jTable2.getColumnModel().getColumn(5).setHeaderValue(resourceMap.getString("jTable2.columnModel.title5")); // NOI18N
        jTable2.getColumnModel().getColumn(5).setCellRenderer(mujdtcr);
        jTable2.getColumnModel().getColumn(6).setResizable(false);
        jTable2.getColumnModel().getColumn(6).setHeaderValue(resourceMap.getString("jTable2.columnModel.title6")); // NOI18N
        jTable2.getColumnModel().getColumn(6).setCellRenderer(mujdtcr);
        jTable2.getColumnModel().getColumn(7).setResizable(false);
        jTable2.getColumnModel().getColumn(7).setHeaderValue(resourceMap.getString("jTable2.columnModel.title7")); // NOI18N
        jTable2.getColumnModel().getColumn(7).setCellRenderer(mujdtcr);
        jTable2.getColumnModel().getColumn(8).setResizable(false);
        jTable2.getColumnModel().getColumn(8).setHeaderValue(resourceMap.getString("jTable2.columnModel.title8")); // NOI18N
        jTable2.getColumnModel().getColumn(8).setCellRenderer(mujdtcr);

        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()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 828, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 343, Short.MAX_VALUE)
                .addContainerGap())
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-864)/2, (screenSize.height-403)/2, 864, 403);
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {

        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Ntice().setVisible(true);
            }
      });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTable jTable2;
    // End of variables declaration//GEN-END:variables

    
    /**
     * Vytvari pole Stringu, kterymi se pak plni tabulka v gui.
     * @param text vstupni text
     * @return pole Stringu pro tabulku
     */
    @SuppressWarnings("element-type-mismatch")
    
    public static String[][] delejNtice(String text){

        String[][] outn = new String[9][20];
        for (int i = 2; i < 11; i++) {
            /* pro test nejdelsi n-tice je podminka obracene!
             * for (int i=2; i<text.length(); i++) {
             * if (!testNtic(text,i)) {
             * System.out.println("Nejdelsi n-tice je: " + (i-1));
             * i=text.length();
             */
            if (DelejNtice.testNtic(text,i)) {
                outn[i-2] = DelejNtice.poleNtic(text, i);
            }
        }
        return(outn);
    }

    
   public void delejTab(String[][] text){

      for (int i=0; i<20; i++) {
        for (int j=0; j<9; j++) {
          jTable2.setValueAt(text[j][i], i, j);
        }
      }

    }
    
}