diff --git a/TSVizzEvolution.jar b/TSVizzEvolution.jar index 6e338b5..bc9e170 100644 Binary files a/TSVizzEvolution.jar and b/TSVizzEvolution.jar differ diff --git a/TSVizzEvolution/.classpath b/TSVizzEvolution/.classpath index fcda42d..dfb55e9 100644 --- a/TSVizzEvolution/.classpath +++ b/TSVizzEvolution/.classpath @@ -1,7 +1,6 @@ - diff --git a/TSVizzEvolution/classes_testes/tsvizzevolution/TesteJTable.java b/TSVizzEvolution/classes_testes/tsvizzevolution/TesteJTable.java deleted file mode 100644 index cb136f7..0000000 --- a/TSVizzEvolution/classes_testes/tsvizzevolution/TesteJTable.java +++ /dev/null @@ -1,44 +0,0 @@ -package tsvizzevolution; -import java.awt.BorderLayout; -import javax.swing.JFrame; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.SwingUtilities; -import javax.swing.table.DefaultTableModel; - -public class TesteJTable extends JFrame{ - public TesteJTable() { - } -/** - * - */ - private static final long serialVersionUID = 1L; - -private static void criaFrame() { -JFrame frame = new JFrame("Teste JTable"); -frame.setSize(600, 600); -frame.setLocation(50, 50); -frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); -frame.getContentPane().setLayout(new BorderLayout()); - -DefaultTableModel tableModel = new DefaultTableModel( - new Object[] { "Coluna 1", "Coluna 2" }, 0); -tableModel.addRow(new Object[] { "Linha 1, Coluna 1", "Linha 1, Coluna 2" }); -tableModel.addRow(new Object[] { "Linha 2, Coluna 1", "Linha 2, Coluna 2" }); -JTable tabela = new JTable(tableModel); - -JScrollPane scrollPane = new JScrollPane(); -scrollPane.setViewportView(tabela); - -frame.getContentPane().add(scrollPane, BorderLayout.CENTER); - -frame.setVisible(true); -} - -public static void main(String[] args) { -SwingUtilities.invokeLater(new Runnable() { -@Override public void run() { -criaFrame(); -}}); -} -} \ No newline at end of file diff --git a/TSVizzEvolution/classes_testes/tsvizzevolution/duasversoes.java b/TSVizzEvolution/classes_testes/tsvizzevolution/duasversoes.java deleted file mode 100644 index b31ba53..0000000 --- a/TSVizzEvolution/classes_testes/tsvizzevolution/duasversoes.java +++ /dev/null @@ -1,2349 +0,0 @@ -package tsvizzevolution; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.io.*; -import java.util.*; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.swing.BorderFactory; -import javax.swing.DefaultComboBoxModel; -import javax.swing.GroupLayout; -import javax.swing.GroupLayout.Alignment; -import javax.swing.JDialog; -import javax.swing.JOptionPane; -import javax.swing.LayoutStyle.ComponentPlacement; -import javax.swing.border.EmptyBorder; -import javax.swing.table.DefaultTableModel; -import javax.swing.table.JTableHeader; -import javax.swing.table.TableColumn; -import javax.swing.JButton; -import javax.swing.JComboBox; -import javax.swing.JFileChooser; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JProgressBar; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.JTextField; -import javax.swing.LayoutStyle; -import javax.swing.ToolTipManager; -import javax.swing.UIManager; -import javax.swing.UnsupportedLookAndFeelException; -import javax.swing.WindowConstants; - -import org.graphstream.graph.Edge; -import org.graphstream.graph.Graph; -import org.graphstream.graph.Node; -import org.graphstream.graph.implementations.MultiGraph; -import org.graphstream.ui.spriteManager.Sprite; -import org.graphstream.ui.spriteManager.SpriteManager; -import org.graphstream.ui.view.Viewer; - -import static org.graphstream.algorithm.Toolkit.randomNode; -import static org.graphstream.ui.graphicGraph.GraphPosLengthUtils.nodePosition; - -public class duasversoes extends JFrame { - private JButton btnChooseFileSearch1; - private JButton btnChooseFileSearch2; - private JButton btnVisualizeGraph; - private JButton btnVisualizeTimeline; - private JButton btnSearchMethod; - private JButton btnSearchMethod2; - - private JComboBox cbLevel; - private JComboBox cbClass; - private JComboBox cbTestSmells; - private JComboBox cbAuthor; - private JComboBox cbVisualization; - private JComboBox cbTimeline; - private JComboBox cbSelectMethod; - - private JLabel lblTimeline; - private JLabel lblCsv1; - private JLabel lblCsv2; - private JLabel lblLevel; - private JLabel lblClass; - private JLabel lblTestSmells; - private JLabel lblAuthor; - private JLabel lblVisualization; - private JLabel lblSelectTheCsvMethod; - private JLabel lblSelectTheSecond; - private JLabel lblVisualizeGraph; - private JLabel lblVisualizeTimeline; - private JLabel lblSelectMethod; - - private JPanel pnlClass; - private JPanel pnlTestSmells; - private JPanel pnlAuthor; - private JPanel pnlGraph; - private JPanel pnlLevel; - private JPanel pnlTimeline; - private JPanel pnlVisualization ; - private JPanel pnlMethod; - private JPanel pnlProgress; - private JPanel pnlSelectMethod; - public JProgressBar progress; - public JPanel classe; - public JPanel metodo; - public JPanel contentPane; - - public JFrame frame; - - private JTextField txtFilePathDefault1; - private JTextField txtFilePathDefault2; - private JTextField txtFilePathMethod; - private JTextField txtFilePathMethod2; - - private static final String VIRGULA = ","; - private static String nomeDoArquivo; - - - - public Thread progressoT = new Thread() { - @Override - public void run(){ - progress.setValue(0); - for (int i = 0; i <= 50; i++) { - progress.setValue(i); - try { - Thread.sleep(20); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - }; - }; - - public static int converteInteiro(String valor) { - try { - return Integer.parseInt(valor); - } catch (NumberFormatException e) { - return 0; - } - } - - public duasversoes() throws IOException { - - setTitle("TSVizzEvolution"); - setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - setBounds(100, 100, 710, 584); - contentPane = new JPanel(); - contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); - setContentPane(contentPane); - setResizable(false); - - // Para abrir no centro da Tela - Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2); - - initComponents(); - pnlClass.setVisible(false); - pnlTestSmells.setVisible(false); - pnlAuthor.setVisible(false); - pnlVisualization.setVisible(true); - pnlLevel.setVisible(true); - pnlTimeline.setVisible(false); - btnVisualizeGraph.setVisible(true); - btnVisualizeTimeline.setVisible(false); - pnlMethod.setVisible(false); - lblVisualizeGraph.setVisible(true); - lblVisualizeTimeline.setVisible(false); - pnlSelectMethod.setVisible(false); - - btnVisualizeGraph.setEnabled(false); - btnVisualizeTimeline.setEnabled(false); - - GroupLayout gl_pnlSelectMethod = new GroupLayout(pnlSelectMethod); - gl_pnlSelectMethod.setHorizontalGroup( - gl_pnlSelectMethod.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlSelectMethod.createSequentialGroup() - .addComponent(lblSelectMethod, GroupLayout.PREFERRED_SIZE, 146, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(cbSelectMethod, GroupLayout.PREFERRED_SIZE, 247, GroupLayout.PREFERRED_SIZE) - .addGap(71)) - ); - gl_pnlSelectMethod.setVerticalGroup( - gl_pnlSelectMethod.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlSelectMethod.createSequentialGroup() - .addGap(3) - .addGroup(gl_pnlSelectMethod.createParallelGroup(Alignment.BASELINE) - .addComponent(lblSelectMethod) - .addComponent(cbSelectMethod, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) - ); - pnlSelectMethod.setLayout(gl_pnlSelectMethod); - GroupLayout gl_contentPane = new GroupLayout(contentPane); - gl_contentPane.setHorizontalGroup( - gl_contentPane.createParallelGroup(Alignment.LEADING) - .addComponent(pnlGraph, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - ); - gl_contentPane.setVerticalGroup( - gl_contentPane.createParallelGroup(Alignment.LEADING) - .addComponent(pnlGraph, GroupLayout.PREFERRED_SIZE, 625, GroupLayout.PREFERRED_SIZE) - ); - GroupLayout gl_pnlGraph = new GroupLayout(pnlGraph); - gl_pnlGraph.setHorizontalGroup( - gl_pnlGraph.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlGraph.createSequentialGroup() - .addGap(10) - .addGroup(gl_pnlGraph.createParallelGroup(Alignment.LEADING) - .addComponent(lblCsv1) - .addGroup(gl_pnlGraph.createSequentialGroup() - .addComponent(txtFilePathDefault1, GroupLayout.PREFERRED_SIZE, 536, GroupLayout.PREFERRED_SIZE) - .addGap(6) - .addComponent(btnChooseFileSearch1)) - .addComponent(lblCsv2) - .addGroup(gl_pnlGraph.createSequentialGroup() - .addComponent(txtFilePathDefault2, GroupLayout.PREFERRED_SIZE, 536, GroupLayout.PREFERRED_SIZE) - .addGap(6) - .addComponent(btnChooseFileSearch2)) - .addComponent(pnlVisualization, GroupLayout.PREFERRED_SIZE, 355, GroupLayout.PREFERRED_SIZE) - .addComponent(pnlLevel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addComponent(pnlTimeline, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addComponent(pnlMethod, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addComponent(pnlClass, GroupLayout.PREFERRED_SIZE, 481, GroupLayout.PREFERRED_SIZE) - .addComponent(pnlAuthor, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addComponent(pnlTestSmells, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addComponent(pnlSelectMethod, GroupLayout.PREFERRED_SIZE, 468, GroupLayout.PREFERRED_SIZE) - .addGroup(gl_pnlGraph.createSequentialGroup() - .addComponent(lblVisualizeGraph, GroupLayout.PREFERRED_SIZE, 299, GroupLayout.PREFERRED_SIZE) - .addGap(4) - .addComponent(btnVisualizeGraph, GroupLayout.PREFERRED_SIZE, 234, GroupLayout.PREFERRED_SIZE)) - .addGroup(gl_pnlGraph.createSequentialGroup() - .addComponent(lblVisualizeTimeline, GroupLayout.PREFERRED_SIZE, 299, GroupLayout.PREFERRED_SIZE) - .addGap(4) - .addComponent(btnVisualizeTimeline, GroupLayout.PREFERRED_SIZE, 234, GroupLayout.PREFERRED_SIZE)) - .addComponent(pnlProgress, GroupLayout.PREFERRED_SIZE, 129, GroupLayout.PREFERRED_SIZE))) - ); - gl_pnlGraph.setVerticalGroup( - gl_pnlGraph.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlGraph.createSequentialGroup() - .addComponent(lblCsv1) - .addGap(6) - .addGroup(gl_pnlGraph.createParallelGroup(Alignment.LEADING) - .addComponent(txtFilePathDefault1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addComponent(btnChooseFileSearch1)) - .addGap(13) - .addComponent(lblCsv2) - .addGroup(gl_pnlGraph.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlGraph.createSequentialGroup() - .addGap(6) - .addComponent(txtFilePathDefault2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addComponent(btnChooseFileSearch2)) - .addGap(6) - .addComponent(pnlVisualization, GroupLayout.PREFERRED_SIZE, 38, GroupLayout.PREFERRED_SIZE) - .addGap(6) - .addComponent(pnlLevel, GroupLayout.PREFERRED_SIZE, 49, GroupLayout.PREFERRED_SIZE) - .addGap(6) - .addComponent(pnlTimeline, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE) - .addGap(6) - .addComponent(pnlMethod, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addGap(6) - .addComponent(pnlClass, GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE) - .addGap(6) - .addComponent(pnlAuthor, GroupLayout.PREFERRED_SIZE, 49, GroupLayout.PREFERRED_SIZE) - .addGap(6) - .addComponent(pnlTestSmells, GroupLayout.PREFERRED_SIZE, 41, GroupLayout.PREFERRED_SIZE) - .addGap(6) - .addComponent(pnlSelectMethod, GroupLayout.PREFERRED_SIZE, 38, GroupLayout.PREFERRED_SIZE) - .addGap(6) - .addGroup(gl_pnlGraph.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlGraph.createSequentialGroup() - .addGap(4) - .addComponent(lblVisualizeGraph)) - .addComponent(btnVisualizeGraph)) - .addGap(11) - .addGroup(gl_pnlGraph.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlGraph.createSequentialGroup() - .addGap(4) - .addComponent(lblVisualizeTimeline)) - .addComponent(btnVisualizeTimeline)) - .addGap(6) - .addComponent(pnlProgress, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - ); - pnlGraph.setLayout(gl_pnlGraph); - contentPane.setLayout(gl_contentPane); - - cbLevel.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent event) { - if (event.getItem().equals("A Specific Test Smells")) { - pnlTestSmells.setVisible(true); - pnlClass.setVisible(false); - pnlAuthor.setVisible(false); - pnlMethod.setVisible(false); - pnlSelectMethod.setVisible(false); - } else if (event.getItem().equals("A Specific Test Class")) { - pnlClass.setVisible(true); - pnlTestSmells.setVisible(false); - pnlAuthor.setVisible(false); - pnlMethod.setVisible(false); - pnlSelectMethod.setVisible(false); - } else if (event.getItem().equals("Author")) { - pnlClass.setVisible(false); - pnlTestSmells.setVisible(true); - pnlAuthor.setVisible(true); - pnlMethod.setVisible(false); - pnlSelectMethod.setVisible(false); - } else if (event.getItem().equals("Methods")) { - pnlClass.setVisible(true); - pnlTestSmells.setVisible(false); - pnlAuthor.setVisible(false); - pnlMethod.setVisible(true); - pnlSelectMethod.setVisible(true); - } else { - pnlClass.setVisible(false); - pnlTestSmells.setVisible(false); - pnlAuthor.setVisible(false); - pnlMethod.setVisible(false); - pnlSelectMethod.setVisible(false); - - } - } - }); - - cbLevel.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent event) { - if (event.getItem().equals("Methods")) { - pnlClass.setVisible(true); - pnlTestSmells.setVisible(false); - pnlAuthor.setVisible(false); - pnlMethod.setVisible(true); - pnlSelectMethod.setVisible(true); - } else { - pnlClass.setVisible(false); - pnlTestSmells.setVisible(false); - pnlAuthor.setVisible(false); - pnlMethod.setVisible(false); - pnlSelectMethod.setVisible(false); - } - } - }); - } - - private void btnChooseFileSearch1ActionPerformed(ActionEvent evt) { - final JFileChooser fc = new JFileChooser(); - int returnVal = fc.showOpenDialog(duasversoes.this); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - txtFilePathDefault1.setText(file.getPath()); - // txtFilePathDefault1.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\commons-io_testsmesll_2_1.csv"); - nomeDoArquivo = file.getName(); - } - } - - private void btnChooseFileSearch2ActionPerformed(ActionEvent evt) throws IOException { - final JFileChooser fc = new JFileChooser(); - int returnVal = fc.showOpenDialog(duasversoes.this); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - txtFilePathDefault2.setText(file.getPath()); - // txtFilePathDefault2.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\commons-io_testsmesll_2_5.csv"); - nomeDoArquivo = file.getName(); - btnGerarUploadActionPerformed(evt); - } - } - - private void btnSearchMethodActionPerformed(ActionEvent evt) { - final JFileChooser fc = new JFileChooser(); - int returnVal = fc.showOpenDialog(duasversoes.this); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - txtFilePathMethod.setText(file.getPath()); - txtFilePathMethod.setText("C:\\Users\\Adriana\\Desktop\\mestrado\\software\\all_report_by_testsmells.csv"); - nomeDoArquivo = file.getName(); - } - } - - private void btnSearchMethod2ActionPerformed(ActionEvent evt) throws IOException { - final JFileChooser fc = new JFileChooser(); - int returnVal = fc.showOpenDialog(duasversoes.this); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - txtFilePathMethod2.setText(file.getPath()); - txtFilePathMethod2.setText("C:\\Users\\Adriana\\Desktop\\mestrado\\softwar\\eall_report_by_testsmells.csv"); - nomeDoArquivo = file.getName(); - btnGerarUploadActionPerformed(evt); - } - } - - - private void btnGerarTimelineActionPerformed(ActionEvent evt) { - frame = new JFrame(); - frame.setLocationRelativeTo(null); - frame.setVisible(true); - frame.setPreferredSize(new Dimension( 1000 + Configurations.adicionalBorda, Configurations.alturaPainel )); - frame.setMaximumSize(frame.getPreferredSize()); - frame.setMinimumSize(frame.getPreferredSize()); - frame.setTitle("TSVizzEvolution"); - frame.setLocationRelativeTo(null); - frame.setResizable(false); - - - JPanel painel = new JPanel(); - painel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - painel.setBackground(Configurations.corPainel); //seta a cor de fundo - painel.setBorder(BorderFactory.createLineBorder((Color) Configurations.bordaPainel, Configurations.larguraBorda)); // seta a borda - painel.setPreferredSize(new Dimension( 1000, Configurations.alturaPainel )); - painel.setMaximumSize(painel.getPreferredSize()); - painel.setMinimumSize(painel.getPreferredSize()); - frame.getContentPane().add(painel); - - - int tamanho = 0; - try { - String selecionado = (String) cbTimeline.getSelectedItem(); - tamanho = criaRetangulos(painel, selecionado, txtFilePathDefault1.getText(), txtFilePathDefault2.getText(), tamanho); - - } catch (Exception e){ - e.printStackTrace(); - } - painel.setPreferredSize(new Dimension(tamanho*204, Configurations.alturaPainel )); - - JScrollPane jScrollPane = new JScrollPane(painel); - //jScrollPane.setHorizontalScrollBarPolicy(jScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - jScrollPane.setVerticalScrollBarPolicy(jScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); - frame.getContentPane().add(jScrollPane); - } - - private int criaRetangulos(JPanel painel, String filtro, String fileName1, String fileName2, int tam){ - - JLabel versao1 = new JLabel ("V1"); - versao1.setFont(new Font("Tahoma", Font.PLAIN, 22)); - painel.add(versao1); - - JPanel pacote = new JPanel(); - pacote.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - pacote.setBackground(Configurations.corPacote); //seta a cor de fundo - pacote.setBorder(BorderFactory.createLineBorder((Color) Configurations.bordaPacote, Configurations.larguraBorda)); // seta a borda - ToolTipManager.sharedInstance().setInitialDelay(500);//aparecerá logo que passe 0,5 segundos - painel.add(pacote); - - JLabel versao2 = new JLabel ("V2"); - versao2.setFont(new Font("Tahoma", Font.PLAIN, 22)); - painel.add(versao2); - - JPanel pacote2 = new JPanel(); - pacote2.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - pacote2.setBackground(Configurations.corPacote); //seta a cor de fundo - pacote2.setBorder(BorderFactory.createLineBorder((Color) Configurations.bordaPacote, Configurations.larguraBorda)); // seta a borda - ToolTipManager.sharedInstance().setInitialDelay(500);//aparecerá logo que passe 0,5 segundos - - painel.add(pacote2); - - - String [] colunas = {"Category","V1","V2","V2 Ocurrences ","Color V1", "Color V2"}; - - Object [][] dados = { - {"New", "False", "True","Not apply ", "Gray", "Green"}, - {"Removed", "True", "False", "Not apply ", "Green", "Gray"}, - {"Propagated", "True", "True", "Equal", "Green", "Yellow"}, - {"Increased", "True", "True", "Increase", "Green", "Red"}, - {"Decreased", "True", "True", "Decrease", "Green", "Blue"}, - }; - JTable tabelaLegenda = new JTable(dados, colunas); - tabelaLegenda.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // Configura a largura para 100 pixels - int vColIndex = 0; - TableColumn col = tabelaLegenda.getColumnModel().getColumn(vColIndex); - - JTableHeader header = tabelaLegenda.getTableHeader(); - header.setFont(new Font("Tahoma", Font.BOLD, 12)); - - painel.add(new JScrollPane(tabelaLegenda)); - txtFilePathMethod.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\all_report_by_testsmells.csv"); - List l1 = CriaListaDeMetodos(txtFilePathMethod.getText()); - List l2 = CriaListaDeMetodos(txtFilePathMethod.getText()); - List dados1 = retornaDados(fileName1, filtro); - List dados2 = retornaDados(fileName2, filtro); - arrumaDados(dados1, dados2); - int tamanho = constroiBlocos(dados1, filtro, pacote, l1); - tamanho = constroiBlocos(dados2, filtro, pacote2, l2); - return tamanho; - } - - private int constroiBlocos(List dados, String filtro, JPanel pacote, List l){ - List analisados = new ArrayList<>(); - if (filtro.equals("Project")){ - for (int i = 0; i < dados.size(); i++){ - String projeto = dados.get(i).projeto; - if (!foiAnalisado(analisados, projeto)){ - classe = new JPanel(); - classe.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - classe.setBackground(Configurations.corClasse); //seta a cor de fundo - classe.setBorder(BorderFactory.createLineBorder((Color) Configurations.bordaClasse, Configurations.larguraBorda)); // seta a borda - classe.setPreferredSize(new Dimension(204, Configurations.alturaClasse)); - String novo_nome_segundo_vertice = projeto.substring(0, projeto.length()-2); - String html_classe = "

"+ filtro+": " + novo_nome_segundo_vertice +"

"; - classe.setToolTipText(html_classe); - pacote.add(classe); - JPanel espaco3 = new JPanel(); - espaco3.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - espaco3.setBackground(Color.WHITE); //seta a cor de fundo - espaco3.setBorder(BorderFactory.createLineBorder((Color) Configurations.bordaPainel, Configurations.larguraBorda)); // seta a borda - ToolTipManager.sharedInstance().setInitialDelay(500);//aparecerá logo que passe 0,5 segundos - espaco3.setPreferredSize(new Dimension(800, 10 )); - - pacote.add(espaco3); - for (int j = i; j < dados.size(); j++){ - if (dados.get(j).projeto.equals(projeto)){ - JPanel metodo = new JPanel(); - metodo.setBackground(dados.get(j).cor); - metodo.setBorder(BorderFactory.createLineBorder((Color) Configurations.bordaMetodo, Configurations.larguraBorda)); // seta a borda - metodo.setPreferredSize(new Dimension (Configurations.larguraMetodo, Configurations.alturaMetodo)); // seta o tamanho - metodo.setMaximumSize(metodo.getPreferredSize()); - metodo.setMinimumSize(metodo.getPreferredSize()); - String novo_nome_primeiro_vertice = dados.get(j).nome.substring(0, dados.get(j).nome.length()-2); - String html_metodo = "

Test Smells: " + novo_nome_primeiro_vertice + "
"+ "Occurrence: " + dados.get(j).valor + "

"; - metodo.setToolTipText(html_metodo); - classe.add(metodo); - } - } - analisados.add(projeto); - } - } - }else{ - for (int i = 0; i < dados.size(); i++){ - String classe_analisada = dados.get(i).classe; - if (!foiAnalisado(analisados, classe_analisada)){ - classe = new JPanel(); - classe.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - classe.setBackground(Configurations.corClasse); //seta a cor de fundo - classe.setBorder(BorderFactory.createLineBorder((Color) Configurations.bordaClasse, Configurations.larguraBorda)); // seta a borda - classe.setPreferredSize(new Dimension(204, Configurations.alturaClasse)); - String novo_nome_segundo_vertice = classe_analisada.substring(0, classe_analisada.length()-2); - // String html_classe = "

Test Class: " + novo_nome_segundo_vertice +"

"; - // classe.setToolTipText(html_classe); - pacote.add(classe); - for (int j = i; j < dados.size(); j++){ - if (dados.get(j).classe.equals(classe_analisada)){ - JPanel metodo = new JPanel(); - metodo.setBackground(dados.get(j).cor); - metodo.setBorder(BorderFactory.createLineBorder((Color) Configurations.bordaMetodo, Configurations.larguraBorda)); // seta a borda - metodo.setPreferredSize(new Dimension (Configurations.larguraMetodo, Configurations.alturaMetodo)); // seta o tamanho - metodo.setMaximumSize(metodo.getPreferredSize()); - metodo.setMinimumSize(metodo.getPreferredSize()); - String novo_nome_primeiro_vertice = dados.get(j).nome.substring(0, dados.get(j).nome.length()-2); - String html_metodo = "

Test Smells: " + novo_nome_primeiro_vertice + "
"+ "Occurrence: " + dados.get(j).valor +"
"+ "Test Class: " + novo_nome_segundo_vertice + "

"; - if(filtro.equals("Methods")){ - for(ClassMethod obj: l){ - if(obj.testSmell.equals(novo_nome_primeiro_vertice) && obj.classe.equals(novo_nome_segundo_vertice)){ - html_metodo = "

Test Smells: " + novo_nome_primeiro_vertice + "
"+ "Occurrence: " + dados.get(j).valor +"
" + "Test Class: " + novo_nome_segundo_vertice + "
Metodos: " + obj.metodos +"

"; - } - } - } - metodo.setToolTipText(html_metodo); - classe.add(metodo); - } - } - analisados.add(classe_analisada); - } - } - } - return analisados.size(); - } - - private boolean foiAnalisado(List analisados, String classe){ - for (String analisado : analisados) { - if (analisado.equals(classe)) { - return true; - } - } - return false; - } - - - private List CriaListaDeMetodos(String path){ - List listaMetodosClasse1 = new ArrayList<>(); - try { - List listaMetodos = new ArrayList(); - String linha = null; - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(path))); - while ((linha = reader.readLine()) != null) { - String[] dados = linha.split(VIRGULA); - listaMetodos.add(dados); - } - - for (int i = 0; i < listaMetodos.size(); i++) { - boolean tem = false; - String[] dado_linha = (String[]) listaMetodos.get(i); - for (ClassMethod obj : listaMetodosClasse1) { - if (dado_linha[1].equals(obj.classe) && dado_linha[7].equals(obj.testSmell)) { - tem = true; - } - } - if (tem == false) { - listaMetodosClasse1.add(new ClassMethod(dado_linha[1], dado_linha[7])); - } - } - for (ClassMethod obj : listaMetodosClasse1) { - for (int i = 0; i < listaMetodos.size(); i++) { - String[] dado_linha = (String[]) listaMetodos.get(i); - if (obj.classe.equals(dado_linha[1]) && obj.testSmell.equals(dado_linha[7])) { - int begin; - int end; - try { - begin = Integer.valueOf(dado_linha[10]); - }catch (Exception e){ - begin = 0; - } - try { - end = Integer.valueOf(dado_linha[11]); - }catch (Exception e){ - end = 0; - } - obj.addMethods(new MethodData(dado_linha[8], begin, end)); - } - } - } - return listaMetodosClasse1; - } catch (Exception e) { - - } - return listaMetodosClasse1; - } - private void btnGerarGrafoActionPerformed(ActionEvent evt) { - pnlProgress.setVisible(true); - - iniciaProcessamento(); - } - - private void iniciaProcessamento() { - progress.setValue(0); - pnlProgress.add(progress); - - new Thread() { - - @Override - public void run(){ - progress.setValue(0); - progressoT.run(); - try { - System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer"); - Graph graph1 = new MultiGraph("TSVizzEvolution"); - //setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(txtFilePathDefault1.getText()))); - String linha = null; - - List listaDeLinhasInt = new ArrayList(); - List listaDeLinhas = new ArrayList(); - List listaMetodos = new ArrayList(); - String cabecalho; - - cabecalho = reader.readLine(); - - String[] cabecalhoLista = cabecalho.split(VIRGULA); - for (int i = 10; i < cabecalhoLista.length; i++) { - graph1.addNode(cabecalhoLista[i] + "_1"); - Node n = graph1.getNode(cabecalhoLista[i] + "_1"); - n.setAttribute("ui.label", cabecalhoLista[i] + "_1"); - n.addAttribute("ui.class", "quadradoTS"); - double x = (Math.random() * ((1000000) + 1)); - double y = (Math.random() * ((1000000) + 1)); - n.setAttribute("x", x); - n.setAttribute("y", y); - - } - progress.setValue(55); - if (cabecalho != null) { - while ((linha = reader.readLine()) != null) { - String[] dados = linha.split(VIRGULA); - listaDeLinhas.add(dados); - int[] valorInteiros = new int[dados.length]; - - for (int i = 0; i < dados.length; i++) { - valorInteiros[i] = converteInteiro(String.valueOf(dados[i])); - } - listaDeLinhasInt.add(valorInteiros); - } - - } - - BufferedReader reader2 = new BufferedReader(new InputStreamReader(new FileInputStream(txtFilePathDefault2.getText()))); - String linha2 = null; - - List listaDeLinhasInt2 = new ArrayList(); - List listaDeLinhas2 = new ArrayList(); - String cabecalho2; - - cabecalho2 = reader2.readLine(); - - String[] cabecalhoLista2 = cabecalho2.split(VIRGULA); - for (int i = 10; i < cabecalhoLista2.length; i++) { - graph1.addNode(cabecalhoLista2[i] + "_2"); - Node n = graph1.getNode(cabecalhoLista2[i] + "_2"); - n.setAttribute("ui.label", cabecalhoLista2[i] + "_2"); - n.addAttribute("ui.class", "quadradoTS"); - double x = (Math.random() * ((1000000) + 1)); - double y = (Math.random() * ((1000000) + 1)); - n.setAttribute("x", x); - n.setAttribute("y", y); - - } - if (cabecalho2 != null) { - while ((linha2 = reader2.readLine()) != null) { - String[] dados = linha2.split(VIRGULA); - listaDeLinhas2.add(dados); - int[] valorInteiros = new int[dados.length]; - - for (int i = 0; i < dados.length; i++) { - valorInteiros[i] = converteInteiro(String.valueOf(dados[i])); - } - listaDeLinhasInt2.add(valorInteiros); - } - - } - - //---------------------------------------------------------------------------------------------------------- - progress.setValue(75); - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - String f = "All Test Classes"; - String selecionado = (String) cbLevel.getSelectedItem(); - int coluna = 0; - if (selecionado.equals("Project")) { - coluna = 5; - f = "Project"; - }else { - coluna = 6; - } - List listaMetodosClasse1 = CriaListaDeMetodos(txtFilePathMethod.getText()); - txtFilePathMethod2.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\all_report_by_testsmells.csv"); //depois tirar essa linha - List listaMetodosClasse2 = CriaListaDeMetodos(txtFilePathMethod2.getText()); - List l1 = retornaDados(txtFilePathDefault1.getText(), f); - List l2 = retornaDados(txtFilePathDefault2.getText(), f); - String filtro = ""; - progress.setValue(78); - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - try { - if (selecionado.equals("Project") || selecionado.equals("All Test Classes")) { - CriaGrafoCompleto(listaDeLinhasInt, listaDeLinhas, cabecalhoLista, graph1, coluna, 1, txtFilePathDefault1.getText(), selecionado, l1); - CriaGrafoCompleto(listaDeLinhasInt2, listaDeLinhas2, cabecalhoLista2, graph1, coluna, 2, txtFilePathDefault2.getText(), selecionado, l2); - } else { - if (selecionado.equals("A Specific Test Class")) { - filtro = (String) cbClass.getSelectedItem(); - CriaGrafoParcial(listaDeLinhasInt, listaDeLinhas, cabecalhoLista, graph1, filtro, coluna, 1, txtFilePathDefault1.getText(), l1); - CriaGrafoParcial(listaDeLinhasInt2, listaDeLinhas2, cabecalhoLista2, graph1, filtro, coluna, 2, txtFilePathDefault2.getText(), l2); - graph1 = criaNosInexistentes(graph1, concatenaLista(listaDeLinhas, listaDeLinhas2)); - - }else if (selecionado.equals("Author")){ - filtro = (String) cbTestSmells.getSelectedItem(); - String filtroAutor = (String) cbAuthor.getSelectedItem(); - CriaGrafoParcialAutor(listaDeLinhasInt, listaDeLinhas, cabecalhoLista, graph1, filtro, filtroAutor, coluna, 1, txtFilePathDefault1.getText(), l1); - CriaGrafoParcialAutor(listaDeLinhasInt2, listaDeLinhas2, cabecalhoLista2, graph1, filtro, filtroAutor, coluna, 2, txtFilePathDefault2.getText(), l2); - - }else if (true){ - String testSmell = (String) cbTestSmells.getSelectedItem(); - String classe = (String) cbClass.getSelectedItem(); - CriaGrafoMetodos(listaDeLinhasInt, listaDeLinhas, cabecalhoLista, graph1, testSmell, classe, coluna, 1, txtFilePathDefault1.getText(), l1, listaMetodosClasse1); - CriaGrafoMetodos(listaDeLinhasInt2, listaDeLinhas2, cabecalhoLista2, graph1, testSmell, classe, coluna, 2, txtFilePathDefault1.getText(), l2, listaMetodosClasse2); - }else{ - filtro = (String) cbTestSmells.getSelectedItem(); - CriaGrafoParcial(listaDeLinhasInt, listaDeLinhas, cabecalhoLista, graph1, filtro, coluna, 1, txtFilePathDefault1.getText(), l1); - CriaGrafoParcial(listaDeLinhasInt2, listaDeLinhas2, cabecalhoLista2, graph1, filtro, coluna, 1, txtFilePathDefault2.getText(), l2); - graph1 = removeVertices(graph1, filtro); - } - } - graph1 = removeVerticesDoisLados(graph1); - graph1 = CriaLegenda(graph1); - } catch (Exception e) { - e.printStackTrace(); - } - // String path = System.getProperty("user.dir").replace('\\', '/'); - - graph1.addAttribute("ui.stylesheet", "url('tsvizzevolution/Config.css')"); - progress.setValue(99); - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - progress.setValue(100); - progressoT.interrupt(); - if (graph1.getNodeCount() == 1){ - String msg = ""; - if (selecionado.equals("Author")) { - msg = "The combination Test Smells x Author does not exist!"; - } - if (selecionado.equals("A Specific Test Smells")) { - msg = "The selected Test Smells has no occurrences in the selected csv file!"; - } - if (selecionado.equals("Methods")) { - msg = "The combination Test Class x Test Smells does not exist!"; - } - JOptionPane optionPane = new JOptionPane(); - optionPane.setMessage(msg); - optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); - JDialog dialog = optionPane.createDialog(null, "Warning"); - dialog.setVisible(true); - - }else { - Viewer v = graph1.display(); - v.disableAutoLayout(); - } - } catch (IOException ex) { - Logger.getLogger(duasversoes.class.getName()).log(Level.SEVERE, null, ex); - } - } -}.start(); -} - private static Graph CriaLegenda(Graph graph1){ - graph1.addNode("-"); - Node n = graph1.getNode("-"); - n.addAttribute("ui.class", "legenda"); - float maior_x = 0; - for (int i = 0; i < graph1.getNodeCount(); i++) { - Node n1 = graph1.getNode(i); - String value_x = "0"; - try{ - value_x = n1.getAttribute("x").toString(); - }catch (Exception e){ - - } - if (Float.parseFloat(value_x) > maior_x){ - maior_x = Float.parseFloat(value_x); - } - } - n.setAttribute("x", maior_x + 1000); - n.setAttribute("y", 0); - return graph1; - } - - private static void CriaGrafoCompleto(List listaDeLinhasInt, List listaDeLinhas, String[] cabecalho, Graph graph1, int coluna, int flag, String file, String filtro, List l) throws IOException { - String complemento = ""; - if (flag == 1){ - complemento = "_1"; - }else{ - complemento = "_2"; - } - for (int i = 0; i < listaDeLinhasInt.size(); i++) { - int[] linhaInt = (int[]) listaDeLinhasInt.get(i); - String[] linha = (String[]) listaDeLinhas.get(i); - try { - graph1.addNode(linha[coluna] + complemento); - } catch (Exception e) { - } - String busca = linha[coluna] + complemento; - Node n1 = graph1.getNode(linha[coluna] + complemento); - n1.setAttribute("ui.label", linha[coluna] + complemento); - if (filtro.equals("Project")) - n1.addAttribute("ui.class", "projeto"); - double x = (Math.random() * ((1000000) + 1)) + 700000; - double y = (Math.random() * ((1000000) + 1)) + 700000; - if (complemento.equals("_1")){ - x = (Math.random() * ((500000) + 1)); - y = (Math.random() * ((500000) + 1)); - } - n1.setAttribute("x", x); - n1.setAttribute("y", y); - for (int j = 10; j < linhaInt.length; j++) { - if (linhaInt[j] != 0) { - try { - graph1.addEdge(cabecalho[j] + complemento + " " + linha[coluna] + complemento, cabecalho[j] + complemento, linha[coluna] + complemento); - Edge e = graph1.getEdge(cabecalho[j] + complemento + " " + linha[coluna] + complemento); - int valor = retornaDadosDoisNos(cabecalho[j], linha[coluna], filtro, l); - e.setAttribute("ui.label", valor); - } catch (Exception e) { - } - } - } - } - } - - private static void CriaGrafoParcialAutor(List listaDeLinhasInt, List listaDeLinhas, String[] cabecalho, Graph graph1, String nome, String nomeAutor, int coluna, int flag, String file, List l) throws IOException { - String complemento = ""; - if (flag == 1){ - complemento = "_1"; - }else{ - complemento = "_2"; - } - String filtro_autor = nomeAutor; - int colunaAutor = 1; - List l1 = retornaDadosAutores(file); - if (nomeAutor.equals("All")){ - ArrayList nomeAutores = new ArrayList<>(); - for (int i = 0; i < listaDeLinhas.size(); i++){ - String[] linha = (String[]) listaDeLinhas.get(i); - if (!nomeAutores.contains(linha[1])){ - nomeAutores.add(linha[1]); - } - } - for (int x = 0; x < nomeAutores.size(); x++){ - nomeAutor = nomeAutores.get(x); - graph1.addNode(nomeAutor + complemento); - Node autor = graph1.getNode(nomeAutor + complemento); - autor.setAttribute("ui.label", nomeAutor + complemento); - autor.addAttribute("ui.class", "boneco"); - double x1 = (Math.random() * ((1000000) + 1)) + 700000; - double y = (Math.random() * ((1000000) + 1)) + 700000; - if (complemento.equals("_1")){ - x1 = (Math.random() * ((500000) + 1)); - y = (Math.random() * ((500000) + 1)); - } - autor.setAttribute("x", x1); - autor.setAttribute("y", y); - - for (int i = 0; i < listaDeLinhasInt.size(); i++) { - int[] linhaInt = (int[]) listaDeLinhasInt.get(i); - String[] linha = (String[]) listaDeLinhas.get(i); - try { - graph1.addNode(linha[coluna] + complemento); - } catch (Exception e) { - } - Node n1 = graph1.getNode(linha[coluna] + complemento); - n1.setAttribute("ui.label", linha[coluna] + complemento); - x1 = (Math.random() * ((1000000) + 1)) + 700000; - y = (Math.random() * ((1000000) + 1)) + 700000; - if (complemento.equals("_1")){ - x1 = (Math.random() * ((500000) + 1)); - y = (Math.random() * ((500000) + 1)); - } - n1.setAttribute("x", x1); - n1.setAttribute("y", y); - for (int j = 10; j < linhaInt.length; j++) { - if (linhaInt[j] != 0) { - if (nomeAutor.equals(linha[colunaAutor]) || nome.equals(cabecalho[j])) { - if (nome.equals(cabecalho[j])) { - try { - graph1.addEdge(cabecalho[j] + complemento + " " + linha[colunaAutor] + complemento, cabecalho[j] + complemento, linha[colunaAutor] + complemento); - Edge e = graph1.getEdge(cabecalho[j] + complemento + " " + linha[colunaAutor] + complemento); - int valor = retornaDadosAutorMetodo(linha[colunaAutor], cabecalho[j], file, l1); - e.setAttribute("ui.label", valor); - } catch (Exception e) { - } - } - } - } - } - - } - if (complemento.equals("_2")) { - boolean stop = false; - while (!stop) { - boolean Flag = false; - for (int i = 0; i < graph1.getNodeCount(); i++) { - Node n1 = graph1.getNode(i); - if (n1.getDegree() == 0) { - if (!(n1.getId().equals(nome + "_1") || n1.getId().equals(nome + "_2"))) { - Flag = true; - graph1.removeNode(n1); - break; - } - } - } - if (!Flag) { - stop = true; - } - } - } - } - }else { - graph1.addNode(nomeAutor + complemento); - Node autor = graph1.getNode(nomeAutor + complemento); - autor.setAttribute("ui.label", nomeAutor + complemento); - autor.addAttribute("ui.class", "boneco"); - double x = (Math.random() * ((1000000) + 1)) + 700000; - double y = (Math.random() * ((1000000) + 1)) + 700000; - if (complemento.equals("_1")){ - x = (Math.random() * ((500000) + 1)); - y = (Math.random() * ((500000) + 1)); - } - autor.setAttribute("x", x); - autor.setAttribute("y", y); - int soma_valor = 0; - for (int i = 0; i < listaDeLinhasInt.size(); i++) { - int[] linhaInt = (int[]) listaDeLinhasInt.get(i); - String[] linha = (String[]) listaDeLinhas.get(i); - try { - graph1.addNode(linha[coluna] + complemento); - } catch (Exception e) { - } - Node n1 = graph1.getNode(linha[coluna] + complemento); - n1.setAttribute("ui.label", linha[coluna] + complemento); - - double x1 = (Math.random() * ((1000000) + 1)) + 700000; - y = (Math.random() * ((1000000) + 1)) + 700000; - if (complemento.equals("_1")){ - x = (Math.random() * ((500000) + 1)); - y = (Math.random() * ((500000) + 1)); - } - n1.setAttribute("x", x1); - n1.setAttribute("y", y); - for (int j = 10; j < linhaInt.length; j++) { - if (linhaInt[j] != 0) { - if (nome.equals(linha[coluna]) || nome.equals(cabecalho[j]) && linha[colunaAutor].equals(nomeAutor)) { - try { - graph1.addEdge(cabecalho[j] + complemento + " " + linha[coluna] + complemento, cabecalho[j] + complemento, linha[coluna] + complemento); - Edge e = graph1.getEdge(cabecalho[j] + complemento + " " + linha[coluna] + complemento); - int valor = retornaDadosDoisNos(cabecalho[j], linha[coluna], "All Test Classes", l); - e.setAttribute("ui.label", valor); - soma_valor += valor; - } catch (Exception e) { - } - } - } - } - for (int j = 10; j < linhaInt.length; j++) { - if (linhaInt[j] != 0) { - if (nomeAutor.equals(linha[colunaAutor]) || nome.equals(cabecalho[j])) { - if (nome.equals(cabecalho[j])) { - try { - graph1.addEdge(cabecalho[j] + complemento + " " + linha[colunaAutor] + complemento, cabecalho[j] + complemento, linha[colunaAutor] + complemento); - Edge e = graph1.getEdge(cabecalho[j] + complemento + " " + linha[colunaAutor] + complemento); - e.setAttribute("ui.label", soma_valor); - } catch (Exception e) { - } - } - } - } - } - - } - if (complemento.equals("_2")) { - boolean stop = false; - while (!stop) { - boolean Flag = false; - for (int i = 0; i < graph1.getNodeCount(); i++) { - Node n1 = graph1.getNode(i); - if (n1.getDegree() == 0) { - if (!(n1.getId().equals(nome + "_1") || n1.getId().equals(nome + "_2"))) { - Flag = true; - graph1.removeNode(n1); - break; - } - } - } - if (!Flag) { - stop = true; - } - } - } - } - } - - private static void CriaGrafoParcial(List listaDeLinhasInt, List listaDeLinhas, String[] cabecalho, Graph graph1, String nome, int coluna, int flag, String file, List l) throws IOException { - String complemento = ""; - if (flag == 1){ - complemento = "_1"; - }else{ - complemento = "_2"; - } - for (int i = 0; i < listaDeLinhasInt.size(); i++) { - int[] linhaInt = (int[]) listaDeLinhasInt.get(i); - String[] linha = (String[]) listaDeLinhas.get(i); - try { - graph1.addNode(linha[coluna] + complemento); - } catch (Exception e) { - } - Node n1 = graph1.getNode(linha[coluna] + complemento); - n1.setAttribute("ui.label", linha[coluna] + complemento); - double x = (Math.random() * ((1000000) + 1)) + 700000; - double y = (Math.random() * ((1000000) + 1)) + 700000; - if (complemento.equals("_1")){ - x = (Math.random() * ((500000) + 1)); - y = (Math.random() * ((500000) + 1)); - } - n1.setAttribute("x", x); - n1.setAttribute("y", y); - for (int j = 10; j < linhaInt.length; j++) { - if (linhaInt[j] != 0) { - if (nome.equals(linha[coluna]) || nome.equals(cabecalho[j])) { - try { - graph1.addEdge(cabecalho[j] + complemento + " " + linha[coluna] + complemento, cabecalho[j] + complemento, linha[coluna] + complemento); - Edge e = graph1.getEdge(cabecalho[j] + complemento + " " + linha[coluna] + complemento); - int valor = retornaDadosDoisNos(cabecalho[j], linha[coluna], "All Test Classes", l); - e.setAttribute("ui.label", valor); - } catch (Exception e) { - } - } - } - } - } - - if (complemento.equals("_2")) { - boolean stop = false; - while (!stop) { - boolean Flag = false; - for (int i = 0; i < graph1.getNodeCount(); i++) { - Node n1 = graph1.getNode(i); - if (n1.getDegree() == 0) { - if (!(n1.getId().equals(nome + "_1") || n1.getId().equals(nome + "_2"))) { - Flag = true; - graph1.removeNode(n1); - break; - } - } - } - if (!Flag) { - stop = true; - } - } - } - } - - private static void CriaGrafoMetodos(List listaClassesInt, List listaClasses, String[] cabecalho, Graph graph1, String nome, String classe, int coluna, int flag, String file, List l, List listaMetodosClasse) throws IOException { - String complemento = ""; - if (flag == 1){ - complemento = "_1"; - }else{ - complemento = "_2"; - } - for (int i = 0; i < listaClassesInt.size(); i++) { - int[] linhaInt = (int[]) listaClassesInt.get(i); - String[] linha = (String[]) listaClasses.get(i); - try { - graph1.addNode(linha[coluna] + complemento); - } catch (Exception e) { - } - Node n1 = graph1.getNode(linha[coluna] + complemento); - n1.setAttribute("ui.label", linha[coluna] + complemento); - double x = (Math.random() * ((1000000) + 1)); - double y = (Math.random() * ((1000000) + 1)); - n1.setAttribute("x", x); - n1.setAttribute("y", y); - // n1.setAttribute("layout.weight", 10); - n1.setAttribute("edges","layout.weight:4"); - for (int j = 10; j < linhaInt.length; j++) { - if (linhaInt[j] != 0) { - if (classe.equals(linha[coluna]) && nome.equals(cabecalho[j])) { - try{ - graph1.addEdge(cabecalho[j] + complemento + " " + linha[coluna] + complemento, cabecalho[j] + complemento, linha[coluna] + complemento); - Edge e = graph1.getEdge(cabecalho[j] + complemento + " " + linha[coluna] + complemento); - int valor = retornaDadosDoisNos(cabecalho[j], linha[coluna], "All Test Classes", l); - e.setAttribute("ui.label", valor); - } catch (Exception e) { - } - } - } - } - } - if (graph1.getEdgeCount() > 0) { - for (ClassMethod obj : listaMetodosClasse) { - for (MethodData metodo : obj.metodos) { - try { - graph1.addNode(metodo.metodo + complemento); - Node n1 = graph1.getNode(metodo.metodo + complemento); - n1.setAttribute("ui.label", metodo.metodo+ complemento + "," + metodo.begin + "-" + metodo.end); - n1.addAttribute("ui.class", "metodo"); - double x = (Math.random() * ((1000000) + 1) + 1000000); - double y = (Math.random() * ((1000000) + 1) + 1000000); - n1.setAttribute("x", x); - n1.setAttribute("y", y); - if (obj.classe.equals(classe)){ - graph1.addEdge(metodo.metodo + complemento, obj.classe + complemento, metodo.metodo + complemento); - } - } catch (Exception e) { - } - } - } - } - if (complemento.equals("_2")) { - boolean stop = false; - while (!stop) { - boolean Flag = false; - for (int i = 0; i < graph1.getNodeCount(); i++) { - Node n1 = graph1.getNode(i); - if (n1.getDegree() == 0) { - if (!(n1.getId().equals(nome + "_1") || n1.getId().equals(nome + "_2"))) { - Flag = true; - graph1.removeNode(n1); - break; - } - } - } - if (!Flag) { - stop = true; - } - } - } - } - - private void cbLevelActionPerformed(ActionEvent evt) { - } - private void cbVisualizationActionPerformed(ActionEvent evt) { - } - - private void cbTimelineActionPerformed(ActionEvent evt) { - } - - private void btnGerarUploadActionPerformed(ActionEvent evt) throws IOException { - String[] a = null; - String[] b = null; - String[] c = null; - String[] a2 = null; - String[] b2 = null; - String[] c2 = null; - // txtFilePathDefault1.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\commons-io_testsmesll_2_1.csv"); - // txtFilePathMethod.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\all_report_by_testsmells.csv"); - a2 = carrega_lista_linhas(txtFilePathDefault1.getText()); - b2 = carrega_lista_cabecalho(txtFilePathDefault1.getText()); - c2 = carrega_lista_autor(txtFilePathDefault1.getText()); - - // txtFilePathDefault2.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\commons-io_testsmesll_2_6.csv"); - // txtFilePathMethod2.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\all_report_by_testsmells.csv"); - a = carrega_lista_linhas(txtFilePathDefault2.getText()); - b = carrega_lista_cabecalho(txtFilePathDefault2.getText()); - c = carrega_lista_autor(txtFilePathDefault2.getText()); - - a = concatena(a, a2); - b = concatena(b, b2); - c = concatena_autor(c, c2); - - cbAuthor.setModel(new DefaultComboBoxModel<>(c)); - - cbClass.setModel(new DefaultComboBoxModel<>(a)); - - cbTestSmells.setModel(new DefaultComboBoxModel<>(b)); - - btnVisualizeGraph.setEnabled(true); - btnVisualizeTimeline.setEnabled(true); - - } - public static int retornaDadosDoisNos(String a, String b, String filtro, List l){ - if (filtro.equals("Project")) { - for (int i = 0; i < l.size(); i++) { - Data d = l.get(i); - if (d.nome.equals(a) && d.projeto.equals(b)) { - return d.valor; - } - } - return 0; - }else{ - for (int i = 0; i < l.size(); i++) { - Data d = l.get(i); - if (d.nome.equals(a) && d.classe.equals(b)) { - return d.valor; - } - } - return 0; - } - } - - public static int retornaDadosAutorMetodo(String autor, String metodo, String file, List l){ - for (int i = 0; i < l.size(); i++) { - Data d = l.get(i); - if (d.autor.equals(autor) && d.nome.equals(metodo)) { - return d.valor; - } - } - return 0; - } - - public static List retornaDadosAutores(String file){ - try { - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); - String linha = null; - - List listaDeLinhasInt = new ArrayList(); - List listaDeLinhas = new ArrayList(); - String cabecalho; - - cabecalho = reader.readLine(); - String[] cabecalhoLista = cabecalho.split(VIRGULA); - if (cabecalho != null) { - while ((linha = reader.readLine()) != null) { - String[] dados = linha.split(VIRGULA); - listaDeLinhas.add(dados); - int[] valorInteiros = new int[dados.length]; - - for (int i = 0; i < dados.length; i++) { - valorInteiros[i] = converteInteiro(String.valueOf(dados[i])); - } - listaDeLinhasInt.add(valorInteiros); - } - - } - List resultado = new ArrayList<>(); - List autores = new ArrayList<>(); - int coluna = 1; - for (int i = 0; i < listaDeLinhas.size(); i++){ - String[] linha_analisada = (String[]) listaDeLinhas.get(i); - String autor = linha_analisada[coluna]; - boolean flag = false; - for (int j = 0; j < autores.size(); j++){ - if (autores.get(j).equals(autor)){ - flag = true; - } - } - if (!flag){ - autores.add(autor); - } - } - for (int i = 0; i < autores.size(); i ++){ - String autor = autores.get(i); - coluna = 10; - for (int j = 10; j < cabecalhoLista.length; j++) { - int soma = 0; - for (int k = 0; k < listaDeLinhas.size(); k++) { - String[] linha_analisada = (String[]) listaDeLinhas.get(k); - int[] linha_int = (int[]) listaDeLinhasInt.get(k); - if (linha_analisada[1].equals(autor)){ - soma += linha_int[coluna]; - } - } - resultado.add(new Data(cabecalhoLista[j], soma, autor)); - coluna += 1; - } - } - return resultado; - }catch (Exception e){ - e.printStackTrace(); - return null; - } - } - - public static Graph removeVertices(Graph graph1, String filtro){ - boolean stop = false; - while (!stop) { - boolean Flag = false; - for (int i = 0; i < graph1.getNodeCount(); i++) { - Node n1 = graph1.getNode(i); - if (n1.getDegree() == 0) { - if (!(n1.getId().equals(filtro + "_1") || n1.getId().equals(filtro + "_2"))) { - Flag = true; - graph1.removeNode(n1); - break; - } - } - } - if (!Flag) { - stop = true; - } - } - return graph1; - } - - public static Graph removeVerticesDoisLados(Graph graph1){ - for (int i = 0; i < graph1.getNodeCount(); i++) { - Node n1 = graph1.getNode(i); - String complemento = n1.getId().substring(n1.getId().length()-2, n1.getId().length()); - if (complemento.equals("_1")){ - Node n2 = graph1.getNode(n1.getId().substring(0, n1.getId().length()-2) + "_2"); - if (n2 != null){ - if(n2.getDegree() == 0 && n1.getDegree() == 0){ - graph1.removeNode(n2); - graph1.removeNode(n1); - i --; - } - } - }else{ - Node n2 = graph1.getNode(n1.getId().substring(0, n1.getId().length()-2) + "_1"); - if (n2 != null){ - if(n2.getDegree() == 0 && n1.getDegree() == 0){ - graph1.removeNode(n2); - graph1.removeNode(n1); - i --; - } - } - } - } - return graph1; - } - - - public static Graph criaNosInexistentes(Graph graph, List listaDeLinhas){ - List todasClasses = retornaTodasClasses(listaDeLinhas); - for (int i = 0; i < graph.getNodeCount(); i++) { - Node n1 = graph.getNode(i); - if (in(n1.getId().substring(0, n1.getId().length()-2), todasClasses)) { - char complemento = n1.getId().charAt(n1.getId().length() - 1); - char adicional = ' '; - if (complemento == '1') { - adicional = '2'; - } else { - adicional = '1'; - } - String nomeAlterado = n1.getId(); - nomeAlterado = nomeAlterado.substring(0, nomeAlterado.length() - 1) + adicional; - boolean achou = false; - for (int j = 0; j < graph.getNodeCount(); j++) { - Node no = graph.getNode(j); - if (no.getId().equals(nomeAlterado)) { - achou = true; - } - } - if (!achou) { - graph.addNode(nomeAlterado); - Node n = graph.getNode(nomeAlterado); - n.setAttribute("ui.label", nomeAlterado); - n.addAttribute("ui.class", "x"); - n.setAttribute("x", -1000); - n.setAttribute("y", 0); - } - } - } - - return graph; - } - - public static List OrdenaPeloNumeroOcorrencias(List l){ - Data[] v = new Data[l.size()]; - for (int i = 0; i < v.length; i++){ - v[i] = l.get(i); - } - - for(int i = 0; i < v.length - 1; i++) { - for(int j = 0; j < v.length - 1 - i; j++) { - if(v[j].valor < v[j + 1].valor) { - Data aux = v[j]; - v[j] = v[j + 1]; - v[j + 1] = aux; - } - } - } - l = new ArrayList(); - for (int i = 0; i < v.length; i++){ - l.add(v[i]); - } - return l; - } - - public static void arrumaDados(List dados1, List dados2){ - for (int i = 0; i < dados1.size(); i++){ - if (dados1.get(i).valor == 0){ - boolean achou = false; - int j_achado = -1; - for (int j = 0; j < dados2.size(); j++){ - if (dados2.get(j).nome.equals(dados1.get(i).nome) && dados2.get(j).classe.equals(dados1.get(i).classe)){ - achou = true; - j_achado = j; - break; - } - } - if (achou){ - if (dados2.get(j_achado).valor == 0){ - dados2.remove(dados2.get(j_achado)); - dados1.remove(dados1.get(i)); - i--; - } - }else{ - dados1.remove(dados1.get(i)); - i--; - } - } - } - for (int i = 0; i < dados2.size(); i++){ - if (dados2.get(i).valor == 0){ - boolean achou = false; - int j_achado = -1; - for (int j = 0; j < dados1.size(); j++){ - if (dados1.get(j).nome.equals(dados2.get(i).nome) && dados1.get(j).classe.equals(dados2.get(i).classe)){ - achou = true; - j_achado = j; - break; - } - } - if (achou){ - if (dados1.get(j_achado).valor == 0){ - dados1.remove(dados1.get(j_achado)); - dados2.remove(dados2.get(i)); - i--; - } - }else{ - dados2.remove(dados2.get(i)); - i--; - } - } - } - for (int i =0; i < dados1.size(); i++){ - boolean tem = false; - for (int j = 0; j < dados2.size(); j++){ - if (dados1.get(i).nome.equals(dados2.get(j).nome) && dados1.get(i).classe.equals(dados2.get(j).classe)){ - tem = true; - if (dados1.get(i).valor > 0){ - dados1.get(i).cor = Color.green; - }else{ - dados1.get(i).cor = Color.gray; - } - if (dados1.get(i).valor > 0) { - dados2.get(j).cor = Color.YELLOW; - if (dados1.get(i).valor > dados2.get(j).valor) { - if(dados2.get(j).valor > 0){ - dados2.get(j).cor = Color.BLUE; - }else{ - dados2.get(j).cor = Color.gray; - } - } - if (dados1.get(i).valor < dados2.get(j).valor) { - if(dados2.get(j).valor > 0){ - dados2.get(j).cor = Color.red; - }else{ - dados2.get(j).cor = Color.gray; - } - } - }else{ - dados2.get(j).cor = Color.GREEN; - } - } - } - if (!tem){ - dados2.add(new Data(dados1.get(i).nome, 0, dados1.get(i).classe, dados1.get(i).projeto, Color.GRAY)); - dados1.get(i).cor = Color.green; - } - } - for (int i =0; i < dados2.size(); i++){ - boolean tem = false; - for (int j = 0; j < dados1.size(); j++){ - if (dados2.get(i).nome.equals(dados1.get(j).nome) && dados2.get(i).classe.equals(dados1.get(j).classe)){ - tem = true; - } - } - if (!tem){ - dados1.add(new Data(dados2.get(i).nome, 0, dados2.get(i).classe, dados1.get(i).projeto, Color.GRAY)); - dados2.get(i).cor = Color.green; - } - } - for (int i = 0; i < dados1.size(); i++){ - dados1.get(i).nome = dados1.get(i).nome + "_1"; - if (dados1.get(i).classe != null){ - dados1.get(i).classe = dados1.get(i).classe + "_1"; - } - } - for (int i = 0; i < dados2.size(); i++){ - dados2.get(i).nome = dados2.get(i).nome + "_2"; - if (dados2.get(i).classe != null) { - dados2.get(i).classe = dados2.get(i).classe + "_2"; - } - } - Collections.sort(dados1); - Collections.sort(dados2); - } - - public static List retornaDados(String file, String filtro){ - try { - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); - String linha = null; - - List listaDeLinhasInt = new ArrayList(); - List listaDeLinhas = new ArrayList(); - String cabecalho; - - cabecalho = reader.readLine(); - String[] cabecalhoLista = cabecalho.split(VIRGULA); - if (cabecalho != null) { - while ((linha = reader.readLine()) != null) { - String[] dados = linha.split(VIRGULA); - listaDeLinhas.add(dados); - int[] valorInteiros = new int[dados.length]; - - for (int i = 0; i < dados.length; i++) { - valorInteiros[i] = converteInteiro(String.valueOf(dados[i])); - } - listaDeLinhasInt.add(valorInteiros); - } - - } - List resultado_final = new ArrayList<>(); - if (filtro.equals("Project")) { - - int coluna = 10; - - for (int i = 10; i < cabecalhoLista.length; i++) { - int soma = 0; - String nome_projeto = ""; - for (int j = 0; j < listaDeLinhas.size(); j++) { - int[] linha_int = (int[]) listaDeLinhasInt.get(j); - String[] linha_analisada = (String[]) listaDeLinhas.get(j); - soma += linha_int[coluna]; - nome_projeto = linha_analisada[5]; - } - resultado_final.add(new Data(cabecalhoLista[i], soma, "", nome_projeto)); - coluna += 1; - - } - } - if (filtro.equals("All Test Classes") || filtro.equals("Methods")){ - List classes = new ArrayList<>(); - int coluna = 6; - for (int i = 0; i < listaDeLinhas.size(); i++){ - String[] linha_analisada = (String[]) listaDeLinhas.get(i); - String classe = linha_analisada[coluna]; - boolean flag = false; - for (int j = 0; j < classes.size(); j++){ - if (classes.get(j).equals(classe)){ - flag = true; - } - } - if (!flag){ - classes.add(classe); - } - } - for (int i = 0; i < classes.size(); i ++){ - String classe_analisada = classes.get(i); - coluna = 10; - for (int j = 10; j < cabecalhoLista.length; j++) { - int soma = 0; - String nome_projeto = ""; - for (int k = 0; k < listaDeLinhas.size(); k++) { - String[] linha_analisada = (String[]) listaDeLinhas.get(k); - int[] linha_int = (int[]) listaDeLinhasInt.get(k); - if (linha_analisada[6].equals(classe_analisada)){ - soma += linha_int[coluna]; - nome_projeto = linha_analisada[5]; - } - } - resultado_final.add(new Data(cabecalhoLista[j], soma, classe_analisada, nome_projeto)); - coluna += 1; - } - } - } - return resultado_final; - }catch (Exception e){ - return null; - } - } - - public static void main(String args[]) throws IOException { - try { - for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - UIManager.setLookAndFeel(info.getClassName()); - break; - } - } - - } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(duasversoes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(duasversoes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(duasversoes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(duasversoes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - try { - new duasversoes().setVisible(true); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }); - } - - public static String[] carrega_lista_linhas(String path) throws IOException{ - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(path))); - String linha = null; - List resposta = new ArrayList(); - while ((linha = reader.readLine()) != null) { - String[] dados = linha.split(VIRGULA); - String classe = dados[6]; - boolean flag = false; - for(int i = 0; i < resposta.size(); i++){ - if(resposta.get(i).equals(classe)){ - flag = true; - } - } - if (flag == false){ - resposta.add(classe); - } - } - String[] resposta_final = new String[resposta.size() - 1]; - for(int i = 0; i < resposta.size() - 1; i++){ - resposta_final[i] = (String) resposta.get(i+1); - } - return resposta_final; - } - - public static String[] carrega_lista_cabecalho(String path) throws IOException{ - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(path))); - String cabecalho_combo; - cabecalho_combo = reader.readLine(); - String[] cabecalhoTest = cabecalho_combo.split(VIRGULA); - String[] resultado = new String[cabecalhoTest.length - 10]; - for (int i = 10; i < cabecalhoTest.length; i++){ - resultado[i - 10] = cabecalhoTest[i]; - } - return resultado; - } - - public static String[] carrega_lista_autor(String path) throws IOException{ - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(path))); - String linha = null; - List resposta = new ArrayList(); - while ((linha = reader.readLine()) != null) { - String[] dados = linha.split(VIRGULA); - String classe = dados[1]; - boolean flag = false; - for(int i = 0; i < resposta.size(); i++){ - if(resposta.get(i).equals(classe)){ - flag = true; - } - } - if (flag == false){ - resposta.add(classe); - } - } - resposta.remove(0); - Collections.sort(resposta); - resposta.remove(1); - String[] resposta_final = new String[resposta.size()]; - for (int i = 0; i < resposta.size(); i++) { - resposta_final[i] = (String) resposta.get(i); - } - return resposta_final; - } - @SuppressWarnings("unchecked") - - private String[] concatena_autor(String[] lista1, String[] lista2){ - List lista = new ArrayList<>(); - for (int i = 0; i < lista1.length; i++){ - lista.add(lista1[i]); - } - for (int i = 0; i < lista2.length; i++){ - boolean achou = false; - for (int j = 0; j < lista.size(); j++){ - if (lista.get(j).equals(lista2[i])){ - achou = true; - } - } - if (!achou){ - lista.add(lista2[i]); - } - } - Collections.sort(lista); - lista.add(0, "All"); - String[] resultado = new String[lista.size()]; - for (int i = 0; i < lista.size(); i++){ - resultado[i] = lista.get(i); - } - return resultado; - } - - private String[] concatena(String[] lista1, String[] lista2){ - List lista = new ArrayList<>(); - for (int i = 0; i < lista1.length; i++){ - lista.add(lista1[i]); - } - for (int i = 0; i < lista2.length; i++){ - boolean achou = false; - for (int j = 0; j < lista.size(); j++){ - if (lista.get(j).equals(lista2[i])){ - achou = true; - } - } - if (!achou){ - lista.add(lista2[i]); - } - } - Collections.sort(lista); - String[] resultado = new String[lista.size()]; - for (int i = 0; i < lista.size(); i++){ - resultado[i] = lista.get(i); - } - return resultado; - } - - public void carregaComponentes(){ - try { - String[] a = null; - String[] b = null; - String[] c = null; - String[] a2 = null; - String[] b2 = null; - String[] c2 = null; - - a2 = carrega_lista_linhas(txtFilePathDefault1.getText()); - b2 = carrega_lista_cabecalho(txtFilePathDefault1.getText()); - c2 = carrega_lista_autor(txtFilePathDefault1.getText()); - - a = carrega_lista_linhas(txtFilePathDefault2.getText()); - b = carrega_lista_cabecalho(txtFilePathDefault2.getText()); - c = carrega_lista_autor(txtFilePathDefault2.getText()); - - a = concatena(a, a2); - b = concatena(b, b2); - c = concatena_autor(c, c2); - cbAuthor.setModel(new DefaultComboBoxModel<>(c)); - cbClass.setModel(new DefaultComboBoxModel<>(a)); - cbTestSmells.setModel(new DefaultComboBoxModel<>(b)); - - }catch (Exception e){ - e.printStackTrace(); - } - } - - private List concatenaLista(List lista1, List lista2){ - List lista = new ArrayList<>(); - for (int i = 0; i < lista1.size(); i++){ - lista.add(lista1.get(i)); - } - for (int i = 0; i < lista2.size(); i++){ - boolean achou = false; - for (int j = 0; j < lista.size(); j++){ - if (lista.get(j).equals(lista2.get(i))){ - achou = true; - } - } - if (!achou){ - lista.add(lista2.get(i)); - } - } - return lista; - } - - public static List retornaTodasClasses(List listaDeLinhas){ - List listaClasses = new ArrayList<>(); - for (int i = 0; i < listaDeLinhas.size(); i++){ - String[] linha = (String[]) listaDeLinhas.get(i); - Boolean encontrou = false; - for (int j = 0; j < listaClasses.size(); j++){ - if (listaClasses.get(j).equals(linha[6])){ - encontrou = true; - } - } - if (!encontrou){ - listaClasses.add(linha[6]); - } - } - return listaClasses; - } - - public static boolean in(String x, List l){ - for (int i = 0; i < l.size(); i++){ - if (x.equals(l.get(i))){ - return true; - } - } - return false; - } - - public static String[] carrega_lista_autor_test(String path, String autor) throws IOException { - List resposta_final_array = new ArrayList(); - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(path))); - String[] cabecalho = reader.readLine().split(VIRGULA); - String linha = null; - while ((linha = reader.readLine()) != null) { - String[] dados = linha.split(VIRGULA); - if(autor.equals(dados[1])){ - for(int i=10; i retorna_lista_classe_metodo() throws IOException { - List listaMetodosClasse = new ArrayList<>(); - List listaMetodos = new ArrayList(); - String linha = null; - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(txtFilePathMethod.getText()))); - while ((linha = reader.readLine()) != null) { - String[] dados = linha.split(VIRGULA); - listaMetodos.add(dados); - } - - for (int i = 0; i < listaMetodos.size(); i++) { - boolean tem = false; - String[] dado_linha = (String[]) listaMetodos.get(i); - for (ClassMethod obj : listaMetodosClasse) { - if (dado_linha[1].equals(obj.classe)) { - tem = true; - } - } - if (tem == false) { - listaMetodosClasse.add(new ClassMethod(dado_linha[1])); - } - } - for (ClassMethod obj : listaMetodosClasse) { - for (int i = 0; i < listaMetodos.size(); i++) { - String[] dado_linha = (String[]) listaMetodos.get(i); - if (obj.classe.equals(dado_linha[1])) { - int begin; - int end; - try { - begin = Integer.valueOf(dado_linha[10]); - }catch (Exception e){ - begin = 0; - } - try { - end = Integer.valueOf(dado_linha[11]); - }catch (Exception e){ - end = 0; - } - obj.addMethods(new MethodData(dado_linha[8], begin, end)); - } - } - } - return listaMetodosClasse; - } - - private void initComponents() throws IOException { - pnlGraph = new JPanel(); - pnlLevel = new JPanel(); - pnlTimeline = new JPanel(); - pnlMethod = new JPanel(); - txtFilePathDefault1 = new JTextField(); - txtFilePathDefault2 = new JTextField(); - btnSearchMethod = new JButton(); - lblVisualizeGraph = new JLabel(); - lblVisualizeTimeline = new JLabel(); - progress = new JProgressBar(0, 100); - pnlProgress = new JPanel(); - pnlSelectMethod = new JPanel(); - - pnlSelectMethod.setVisible(false); - pnlProgress.setVisible(false); - - progress.setStringPainted(true); - progress.setValue(0); - progress.setSize(new Dimension(100, 23)); - - lblVisualizeTimeline.setVisible(false); - - btnVisualizeGraph = new JButton(); - btnVisualizeGraph.setText("Generate Graph View"); - btnVisualizeGraph.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - btnGerarGrafoActionPerformed(evt); - } - }); - - btnVisualizeTimeline = new JButton(); - btnVisualizeTimeline.setText("Generate Timeline View"); - btnVisualizeTimeline.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - btnGerarTimelineActionPerformed(evt); - } - - - }); - - cbVisualization = new JComboBox<>(); - cbVisualization.setModel(new DefaultComboBoxModel<>(new String[] {"Graph View", "Timeline View" })); - cbVisualization.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - cbVisualizationActionPerformed(evt); - } - }); - - pnlLevel.setVisible(true); - pnlTimeline.setVisible(false); - btnVisualizeGraph.setVisible(true); - btnVisualizeTimeline.setVisible(false); - pnlMethod.setVisible(false); - - - - String selecionado2 = (String) cbVisualization.getSelectedItem(); - if (selecionado2.equals("Graph View")) { - cbVisualization.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent event) { - if (event.getItem().equals("Graph View")) { - pnlMethod.setVisible(false); - pnlSelectMethod.setVisible(false); - pnlLevel.setVisible(true); - pnlTimeline.setVisible(false); - btnVisualizeGraph.setVisible(true); - btnVisualizeTimeline.setVisible(false); - lblVisualizeGraph.setVisible(true); - lblVisualizeTimeline.setVisible(false); - } else if (event.getItem().equals("Timeline View")) { - pnlClass.setVisible(false); - pnlTestSmells.setVisible(false); - pnlAuthor.setVisible(false); - pnlTimeline.setVisible(true); - pnlLevel.setVisible(false); - btnVisualizeTimeline.setVisible(true); - btnVisualizeGraph.setVisible(false); - pnlMethod.setVisible(false); - lblVisualizeGraph.setVisible(false); - lblVisualizeTimeline.setVisible(true); - pnlSelectMethod.setVisible(false); - } - - } - }); - - } - cbTimeline = new JComboBox<>(); - cbTimeline.setModel(new DefaultComboBoxModel<>(new String[] { "Project", "All Test Classes", "Methods" })); - cbTimeline.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - cbTimelineActionPerformed(evt); - } - }); - - cbLevel = new JComboBox<>(); - cbLevel.setModel(new DefaultComboBoxModel<>(new String[] { "Project", "All Test Classes", "A Specific Test Class", "A Specific Test Smells", "Author", "Methods"})); - cbLevel.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - cbLevelActionPerformed(evt); - } - }); - - btnChooseFileSearch2 = new JButton(); - btnChooseFileSearch2.setText("Search ..."); - btnChooseFileSearch2.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - try { - btnChooseFileSearch2ActionPerformed(evt); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }); - - btnChooseFileSearch1 = new JButton(); - btnChooseFileSearch1.setText("Search ..."); - btnChooseFileSearch1.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - btnChooseFileSearch1ActionPerformed(evt); - } - }); - - btnSearchMethod.setText("Search ..."); - btnSearchMethod.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnSearchMethodActionPerformed(evt); - } - }); - - lblTimeline = new JLabel(); - lblTimeline.setText("Select the level of granularity:"); - - lblVisualization = new JLabel(); - lblVisualization.setText("Select a view type:"); - - lblLevel = new JLabel(); - lblLevel.setText("Select the level of granularity:"); - - pnlAuthor = new JPanel(); - - lblAuthor = new JLabel(); - lblAuthor.setText("Select A Specific Author or All:"); - - cbAuthor = new JComboBox<>(); - - cbAuthor.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (!String.valueOf(cbAuthor.getSelectedItem()).equals("All")) { - try { - if (e.getStateChange() == ItemEvent.SELECTED) { - String[] result = carrega_lista_autor_test(txtFilePathDefault1.getText(), String.valueOf(cbAuthor.getSelectedItem())); - cbTestSmells.setModel(new DefaultComboBoxModel<>(result)); - cbTestSmells.removeAllItems(); - for (String test : result) { - cbTestSmells.addItem(test); - } - } else { - } - } catch (Exception exception) { - exception.printStackTrace(); - } - }else{ - try { - String[] result = carrega_lista_cabecalho(txtFilePathDefault1.getText()); - Arrays.sort(result); - cbTestSmells.removeAllItems(); - for (String test : result) { - cbTestSmells.addItem(test); - } - } catch (IOException ioException) { - ioException.printStackTrace(); - } - - } - } - }); - - - lblClass = new JLabel(); - lblClass.setText("Select a Test Class:"); - - pnlClass = new JPanel(); - - cbClass = new JComboBox<>(); - - lblCsv2 = new JLabel(); - lblCsv2.setText("Select the second .csv File :"); - lblCsv1 = new JLabel(); - - lblCsv1.setText("Select the first .csv File :"); - lblCsv1.setFont(new Font("Tahoma", Font.PLAIN, 16)); - - lblTestSmells = new JLabel(); - pnlTestSmells = new JPanel(); - - lblTestSmells.setText("Select a Test Smells:"); - cbTestSmells = new JComboBox<>(); - pnlVisualization = new JPanel(); - - lblSelectTheCsvMethod = new JLabel(); - lblSelectTheCsvMethod.setText("Select the first .csv File (By Test Smells JNose) :"); - - txtFilePathMethod = new JTextField(); - // txtFilePathMethod.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\commons-io_testsmesll_2_6.csv"); - - lblSelectTheSecond = new JLabel(); - lblSelectTheSecond.setText("Select the second .csv File (By Test Smells JNose) :"); - - txtFilePathMethod2 = new JTextField(); - - btnSearchMethod2 = new JButton(); - btnSearchMethod2.setText("Search ..."); - btnSearchMethod2.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - try { - btnSearchMethod2ActionPerformed(evt); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }); - - lblVisualizeGraph.setText("Click here to generate the visualization :"); - lblVisualizeTimeline.setText("Click here to generate the visualization :"); - - lblSelectMethod = new JLabel(); - lblSelectMethod.setText("Select a Method:"); - - cbSelectMethod = new JComboBox(); - - pnlSelectMethod.setVisible(false); - - lblSelectMethod.setFont(new Font("Tahoma", Font.PLAIN, 16)); - cbSelectMethod.setFont(new Font("Tahoma", Font.PLAIN, 16)); - lblVisualizeGraph.setFont(new Font("Tahoma", Font.PLAIN, 16)); - lblVisualizeTimeline.setFont(new Font("Tahoma", Font.PLAIN, 16)); - btnSearchMethod2.setFont(new Font("Tahoma", Font.PLAIN, 16)); - btnChooseFileSearch1.setFont(new Font("Tahoma", Font.PLAIN, 16)); - btnChooseFileSearch2.setFont(new Font("Tahoma", Font.PLAIN, 16)); - btnVisualizeGraph.setFont(new Font("Tahoma", Font.PLAIN, 16)); - btnVisualizeTimeline.setFont(new Font("Tahoma", Font.PLAIN, 16)); - cbLevel.setFont(new Font("Tahoma", Font.PLAIN, 16)); - cbClass.setFont(new Font("Tahoma", Font.PLAIN, 16)); - cbTestSmells.setFont(new Font("Tahoma", Font.PLAIN, 16)); - cbAuthor.setFont(new Font("Tahoma", Font.PLAIN, 16)); - cbVisualization.setFont(new Font("Tahoma", Font.PLAIN, 16)); - cbTimeline.setFont(new Font("Tahoma", Font.PLAIN, 16)); - lblTimeline.setFont(new Font("Tahoma", Font.PLAIN, 16)); - lblCsv1.setFont(new Font("Tahoma", Font.PLAIN, 16)); - lblCsv2.setFont(new Font("Tahoma", Font.PLAIN, 16)); - lblLevel.setFont(new Font("Tahoma", Font.PLAIN, 16)); - lblClass.setFont(new Font("Tahoma", Font.PLAIN, 16)); - lblTestSmells.setFont(new Font("Tahoma", Font.PLAIN, 16)); - lblAuthor.setFont(new Font("Tahoma", Font.PLAIN, 16)); - lblVisualization.setFont(new Font("Tahoma", Font.PLAIN, 16)); - txtFilePathDefault1.setFont(new Font("Tahoma", Font.PLAIN, 14)); - txtFilePathDefault2.setFont(new Font("Tahoma", Font.PLAIN, 14)); - txtFilePathMethod.setFont(new Font("Tahoma", Font.PLAIN, 14)); - lblSelectTheCsvMethod.setFont(new Font("Tahoma", Font.PLAIN, 16)); - btnSearchMethod.setFont(new Font("Tahoma", Font.PLAIN, 16)); - lblSelectTheSecond.setFont(new Font("Tahoma", Font.PLAIN, 16)); - txtFilePathMethod2.setFont(new Font("Tahoma", Font.PLAIN, 14)); - - - cbClass.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - try { - List l = retorna_lista_classe_metodo(); - cbSelectMethod.removeAllItems(); - for(ClassMethod obj: l){ - if(obj.classe.equals(String.valueOf(cbClass.getSelectedItem()))) - for(MethodData Metodos: obj.metodos){ - cbSelectMethod.addItem(Metodos.metodo); - } - } - } catch (IOException ioException) { - ioException.printStackTrace(); - } - - } - }); - - GroupLayout gl_pnlClass = new GroupLayout(pnlClass); - gl_pnlClass.setHorizontalGroup( - gl_pnlClass.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlClass.createSequentialGroup() - .addComponent(lblClass) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cbClass, GroupLayout.PREFERRED_SIZE, 267, GroupLayout.PREFERRED_SIZE) - .addContainerGap(50, Short.MAX_VALUE)) - ); - gl_pnlClass.setVerticalGroup( - gl_pnlClass.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlClass.createSequentialGroup() - .addGroup(gl_pnlClass.createParallelGroup(Alignment.BASELINE) - .addComponent(lblClass) - .addComponent(cbClass, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addContainerGap(67, Short.MAX_VALUE)) - ); - pnlClass.setLayout(gl_pnlClass); - - GroupLayout gl_pnlLevel = new GroupLayout(pnlLevel); - gl_pnlLevel.setHorizontalGroup( - gl_pnlLevel.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlLevel.createSequentialGroup() - .addComponent(lblLevel) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(cbLevel, GroupLayout.PREFERRED_SIZE, 190, GroupLayout.PREFERRED_SIZE) - .addContainerGap(59, Short.MAX_VALUE)) - ); - gl_pnlLevel.setVerticalGroup( - gl_pnlLevel.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlLevel.createSequentialGroup() - .addContainerGap() - .addGroup(gl_pnlLevel.createParallelGroup(Alignment.BASELINE) - .addComponent(lblLevel) - .addComponent(cbLevel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addContainerGap(48, Short.MAX_VALUE)) - ); - pnlLevel.setLayout(gl_pnlLevel); - - GroupLayout gl_pnlTimeline = new GroupLayout(pnlTimeline); - gl_pnlTimeline.setHorizontalGroup( - gl_pnlTimeline.createParallelGroup(Alignment.LEADING) - .addGroup(Alignment.TRAILING, gl_pnlTimeline.createSequentialGroup() - .addComponent(lblTimeline, GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(cbTimeline, GroupLayout.PREFERRED_SIZE, 215, GroupLayout.PREFERRED_SIZE) - .addGap(32)) - ); - gl_pnlTimeline.setVerticalGroup( - gl_pnlTimeline.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlTimeline.createSequentialGroup() - .addGroup(gl_pnlTimeline.createParallelGroup(Alignment.BASELINE) - .addComponent(lblTimeline) - .addComponent(cbTimeline, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addContainerGap(23, Short.MAX_VALUE)) - ); - pnlTimeline.setLayout(gl_pnlTimeline); - - GroupLayout gl_pnlAuthor = new GroupLayout(pnlAuthor); - gl_pnlAuthor.setHorizontalGroup( - gl_pnlAuthor.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlAuthor.createSequentialGroup() - .addComponent(lblAuthor) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(cbAuthor, GroupLayout.PREFERRED_SIZE, 180, GroupLayout.PREFERRED_SIZE) - .addContainerGap(33, Short.MAX_VALUE)) - ); - gl_pnlAuthor.setVerticalGroup( - gl_pnlAuthor.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlAuthor.createSequentialGroup() - .addContainerGap() - .addGroup(gl_pnlAuthor.createParallelGroup(Alignment.BASELINE) - .addComponent(lblAuthor) - .addComponent(cbAuthor, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addContainerGap(35, Short.MAX_VALUE)) - ); - pnlAuthor.setLayout(gl_pnlAuthor); - - - GroupLayout gl_pnlTestSmells = new GroupLayout(pnlTestSmells); - gl_pnlTestSmells.setHorizontalGroup( - gl_pnlTestSmells.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlTestSmells.createSequentialGroup() - .addComponent(lblTestSmells) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(cbTestSmells, GroupLayout.PREFERRED_SIZE, 200, GroupLayout.PREFERRED_SIZE) - .addContainerGap(66, Short.MAX_VALUE)) - ); - gl_pnlTestSmells.setVerticalGroup( - gl_pnlTestSmells.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlTestSmells.createSequentialGroup() - .addContainerGap() - .addGroup(gl_pnlTestSmells.createParallelGroup(Alignment.BASELINE) - .addComponent(lblTestSmells) - .addComponent(cbTestSmells, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addContainerGap(16, Short.MAX_VALUE)) - ); - pnlTestSmells.setLayout(gl_pnlTestSmells); - - GroupLayout gl_pnlMethod = new GroupLayout(pnlMethod); - gl_pnlMethod.setHorizontalGroup( - gl_pnlMethod.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlMethod.createSequentialGroup() - .addGroup(gl_pnlMethod.createParallelGroup(Alignment.LEADING) - .addComponent(lblSelectTheCsvMethod) - .addGroup(gl_pnlMethod.createSequentialGroup() - .addGap(2) - .addComponent(txtFilePathMethod, GroupLayout.PREFERRED_SIZE, 534, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(btnSearchMethod, GroupLayout.PREFERRED_SIZE, 99, GroupLayout.PREFERRED_SIZE)) - .addComponent(lblSelectTheSecond, GroupLayout.PREFERRED_SIZE, 456, GroupLayout.PREFERRED_SIZE) - .addGroup(gl_pnlMethod.createSequentialGroup() - .addGap(2) - .addComponent(txtFilePathMethod2, GroupLayout.PREFERRED_SIZE, 534, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(btnSearchMethod2, GroupLayout.PREFERRED_SIZE, 99, GroupLayout.PREFERRED_SIZE))) - .addContainerGap(29, Short.MAX_VALUE)) - ); - gl_pnlMethod.setVerticalGroup( - gl_pnlMethod.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlMethod.createSequentialGroup() - .addGap(9) - .addComponent(lblSelectTheCsvMethod) - .addPreferredGap(ComponentPlacement.RELATED) - .addGroup(gl_pnlMethod.createParallelGroup(Alignment.BASELINE) - .addComponent(btnSearchMethod, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE) - .addComponent(txtFilePathMethod, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(lblSelectTheSecond, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.RELATED) - .addGroup(gl_pnlMethod.createParallelGroup(Alignment.BASELINE) - .addComponent(btnSearchMethod2, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE) - .addComponent(txtFilePathMethod2, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)) - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - pnlMethod.setLayout(gl_pnlMethod); - - GroupLayout gl_pnlVisualization = new GroupLayout(pnlVisualization); - gl_pnlVisualization.setHorizontalGroup( - gl_pnlVisualization.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlVisualization.createSequentialGroup() - .addComponent(lblVisualization) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(cbVisualization, GroupLayout.PREFERRED_SIZE, 140, GroupLayout.PREFERRED_SIZE) - .addContainerGap(70, Short.MAX_VALUE)) - ); - gl_pnlVisualization.setVerticalGroup( - gl_pnlVisualization.createParallelGroup(Alignment.LEADING) - .addGroup(Alignment.TRAILING, gl_pnlVisualization.createSequentialGroup() - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(gl_pnlVisualization.createParallelGroup(Alignment.BASELINE) - .addComponent(lblVisualization) - .addComponent(cbVisualization, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addContainerGap()) - ); - pnlVisualization.setLayout(gl_pnlVisualization); - } -} diff --git a/TSVizzEvolution/classes_testes/tsvizzevolution/umaversao.java b/TSVizzEvolution/classes_testes/tsvizzevolution/umaversao.java deleted file mode 100644 index 637a26c..0000000 --- a/TSVizzEvolution/classes_testes/tsvizzevolution/umaversao.java +++ /dev/null @@ -1,1689 +0,0 @@ -package tsvizzevolution; - -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.io.*; -import java.util.*; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.swing.*; -import javax.swing.GroupLayout.Alignment; -import javax.swing.LayoutStyle.ComponentPlacement; -import javax.swing.border.EmptyBorder; - -import org.graphstream.graph.Edge; -import org.graphstream.graph.Graph; -import org.graphstream.graph.Node; -import org.graphstream.graph.implementations.MultiGraph; -import org.graphstream.ui.view.Viewer; - -public class umaversao extends javax.swing.JFrame { - private JButton btnChooseFileSearch; - private JButton btnVisualizeGraph; - private JButton btnSearchMethod; - private JButton btnVisualizeTreemap; - - private JComboBox cbLevel; - private JComboBox cbClass; - private JComboBox cbTestSmells; - private JComboBox cbAuthor; - private JComboBox cbVisualization; - private JComboBox cbSelectMethod; - - private JLabel lblSelectCsv; - private JLabel lblLevel; - private JLabel lblSelectClass; - private JLabel lblSelectTestSmells; - private JLabel lblAuthor; - private JLabel lblSelectTheCsvMethod; - private JLabel lblVisualization; - private JLabel lblLoad; - private JLabel lblVisualizeGraph; - private JLabel lblVisualizeTreemap; - private JLabel lblSelectMethod; - private JLabel lblSelect; - - private JPanel pnlClass; - private JPanel pnlTestSmells; - private JPanel pnlAuthor; - private JPanel pnlGraph; - private JPanel pnlUpload; - private JPanel pnlMethod; - private JPanel pnlbutton; - private JPanel pnlVisualization; - private JPanel pnlProgress; - private JPanel pnlSelectMethod; - - public JFrame frame; - public JPanel classe; - public JPanel contentPane; - public JProgressBar progress; - - private JTextField txtFilePathDefault1; - private JTextField txtFilePathMethod; - - private static final String VIRGULA = ","; - private static String nomeDoArquivo; - private JPanel pnlLevel; - - - public Thread progressoT = new Thread() { - - @Override - public void run(){ - - progress.setValue(0); - -// System.out.println("Entrou na Thread"); - - for (int i = 0; i <= 50; i++) { - progress.setValue(i); - try { - Thread.sleep(20); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - }; - }; - - public static int converteInteiro(String valor) { - try { - return Integer.parseInt(valor); - } catch (NumberFormatException e) { - return 0; - } - } - - public void onchange_combo(){ - - } - - public umaversao() throws IOException { - setTitle("TSVizzEvolution"); - setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - setBounds(100, 100, 733, 655); - contentPane = new JPanel(); - contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); - setContentPane(contentPane); - setResizable(false); - - // Para abrir no centro da Tela - Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); - this.setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2); - - initComponents(); - pnlClass.setVisible(false); - pnlTestSmells.setVisible(false); - pnlAuthor.setVisible(false); - pnlUpload.setVisible(true); - pnlMethod.setVisible(false); - pnlVisualization.setVisible(true); - btnVisualizeTreemap.setVisible(false); - btnVisualizeGraph.setVisible(true); - lblVisualizeGraph.setVisible(true); - lblVisualizeTreemap.setVisible(false); - pnlSelectMethod.setVisible(false); - - cbLevel.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent event) { - if (event.getItem().equals("A Specific Test Smells")) { - pnlTestSmells.setVisible(true); - pnlClass.setVisible(false); - pnlAuthor.setVisible(false); - pnlMethod.setVisible(false); - pnlSelectMethod.setVisible(false); - } else if (event.getItem().equals("A Specific Test Class")) { - pnlClass.setVisible(true); - pnlTestSmells.setVisible(false); - pnlAuthor.setVisible(false); - pnlMethod.setVisible(false); - pnlSelectMethod.setVisible(false); - } else if (event.getItem().equals("Author")) { - pnlClass.setVisible(false); - pnlTestSmells.setVisible(true); - pnlAuthor.setVisible(true); - pnlMethod.setVisible(false); - pnlSelectMethod.setVisible(false); - } else if (event.getItem().equals("Methods")) { - pnlClass.setVisible(true); - pnlTestSmells.setVisible(false); - pnlAuthor.setVisible(false); - pnlMethod.setVisible(true); - pnlSelectMethod.setVisible(true); - } else { - pnlClass.setVisible(false); - pnlTestSmells.setVisible(false); - pnlAuthor.setVisible(false); - pnlMethod.setVisible(false); - pnlSelectMethod.setVisible(false); - } - } - }); - - } - - private void btnChooseFileSearchActionPerformed(java.awt.event.ActionEvent evt) throws IOException { - final JFileChooser fc = new JFileChooser(); - int returnVal = fc.showOpenDialog(umaversao.this); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - txtFilePathDefault1.setText(file.getPath()); - //txtFilePathDefault1.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\commons-io_testsmesll_2_1.csv"); - nomeDoArquivo = file.getName(); - btnGerarUploadActionPerformed(evt); - - } - } - - private void btnSearchMethodActionPerformed(java.awt.event.ActionEvent evt) throws IOException { - final JFileChooser fc = new JFileChooser(); - int returnVal = fc.showOpenDialog(umaversao.this); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - txtFilePathMethod.setText(file.getPath()); - //txtFilePathMethod.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\all_report_by_testsmells.csv"); - nomeDoArquivo = file.getName(); - btnGerarUploadActionPerformed(evt); - - } - } - - private void btnGerarTreemapActionPerformed() { - frame = new JFrame(); - frame.setVisible(true); - frame.setPreferredSize(new Dimension(1200, 900)); - frame.setMaximumSize(frame.getPreferredSize()); - frame.setMinimumSize(frame.getPreferredSize()); - frame.setTitle("TSVizzEvolution"); - frame.setLocationRelativeTo(null); - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - - JPanel painel = new JPanel(); - painel.setLayout(new BorderLayout()); - painel.setBackground(Configurations.corPainel); // seta a cor de fundo - painel.setBorder( - BorderFactory.createLineBorder((Color) Configurations.bordaPainel, Configurations.larguraBorda)); // seta - // a - // borda - painel.setPreferredSize(new Dimension(1200, 900)); - painel.setMaximumSize(painel.getPreferredSize()); - painel.setMinimumSize(painel.getPreferredSize()); - frame.getContentPane().add(painel); - try { - CriaTreeMapView(txtFilePathDefault1.getText(), "Project", painel); - - } catch (Exception e) { - e.printStackTrace(); - } - JScrollPane jScrollPane = new JScrollPane(painel); - jScrollPane.setHorizontalScrollBarPolicy(jScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - jScrollPane.setVerticalScrollBarPolicy(jScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - frame.getContentPane().add(jScrollPane); - } - - private void CriaTreeMapView(String fileName1, String filtro, JPanel painel) { - - JPanel pacote = new JPanel(); - pacote.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - pacote.setBackground(Configurations.corPacote); // seta a cor de fundo - pacote.setBorder( - BorderFactory.createLineBorder((Color) Configurations.bordaPacote, Configurations.larguraBorda)); // seta - // a - // borda - pacote.setPreferredSize(new Dimension(1000, 500)); - ToolTipManager.sharedInstance().setInitialDelay(500);// aparecer� logo que passe 0,5 segundos - painel.add(pacote); - - List dados1 = retornaDados(fileName1, filtro); - dados1 = OrdenaPeloNumeroOcorrencias(dados1); - int maior_valor = dados1.get(0).valor; - Random rand = new Random(); - for (Data d : dados1) { - float r = rand.nextFloat(); - float g = rand.nextFloat(); - float b = rand.nextFloat(); - classe = new JPanel(); - classe.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - Color c = new Color(r, g, b); - classe.setBackground(c); // seta a cor de fundo - classe.setBorder(BorderFactory.createLineBorder(Configurations.bordaPacote, 1)); // seta a borda - classe.setPreferredSize(new Dimension((d.valor * 500) / maior_valor, (d.valor * 500) / maior_valor)); - - String html_classe = "

"+ d.nome+": " + d.valor +"

"; - classe.setToolTipText(html_classe); - pacote.add(classe); - } - - } - - public static List OrdenaPeloNumeroOcorrencias(List l) { - Data[] v = new Data[l.size()]; - for (int i = 0; i < v.length; i++) { - v[i] = l.get(i); - } - - for (int i = 0; i < v.length - 1; i++) { - for (int j = 0; j < v.length - 1 - i; j++) { - if (v[j].valor < v[j + 1].valor) { - Data aux = v[j]; - v[j] = v[j + 1]; - v[j + 1] = aux; - } - } - } - l = new ArrayList(); - for (int i = 0; i < v.length; i++) { - l.add(v[i]); - } - return l; - } - - private void btnGerarGrafoActionPerformed(java.awt.event.ActionEvent evt) { - pnlProgress.setVisible(true); - iniciaProcessamento(); - } - - private void iniciaProcessamento() { - progress.setValue(0); - pnlProgress.add(progress); - - new Thread() { - - @Override - public void run(){ - progress.setValue(0); - progressoT.run(); - try { - System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer"); - Graph graph1 = new MultiGraph("TSVizzEvolution"); - //setDefaultCloseOperation(graph1.DISPOSE_ON_CLOSE); - - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(txtFilePathDefault1.getText()))); - String linha = null; - - List listaClassesInt = new ArrayList(); - List listaClasses = new ArrayList(); - List listaMetodos = new ArrayList(); - - String cabecalho; - - cabecalho = reader.readLine(); - - String[] listaTestSmells = cabecalho.split(VIRGULA); - for (int i = 10; i < listaTestSmells.length; i++) { - graph1.addNode(listaTestSmells[i]); - Node n = graph1.getNode(listaTestSmells[i]); - n.setAttribute("ui.label", listaTestSmells[i]); - n.addAttribute("ui.class", "quadradoTS"); - n.addAttribute("ui.", "quadradoTS"); - - double x = (Math.random() * ((1000000) + 1)); - double y = (Math.random() * ((1000000) + 1)); - n.setAttribute("x", x); - n.setAttribute("y", y); - // n.setAttribute("layout.weight", 10); - n.setAttribute("edges", "layout.weight:4"); - - } - progress.setValue(55); - if (cabecalho != null) { - while ((linha = reader.readLine()) != null) { - String[] dados = linha.split(VIRGULA); - listaClasses.add(dados); - int[] valorInteiros = new int[dados.length]; - - for (int i = 0; i < dados.length; i++) { - valorInteiros[i] = converteInteiro(String.valueOf(dados[i])); - } - listaClassesInt.add(valorInteiros); - } - - } - String selecionado = (String) cbLevel.getSelectedItem(); - int coluna = 0; - if (selecionado.equals("Project")) { - coluna = 5; - } else { - coluna = 6; - } - List listaMetodosClasse = new ArrayList<>(); - if (selecionado.equals("Methods")) { - reader = new BufferedReader(new InputStreamReader(new FileInputStream(txtFilePathMethod.getText()))); - while ((linha = reader.readLine()) != null) { - String[] dados = linha.split(VIRGULA); - listaMetodos.add(dados); - } - - for (int i = 0; i < listaMetodos.size(); i++) { - boolean tem = false; - String[] dado_linha = (String[]) listaMetodos.get(i); - for (ClassMethod obj : listaMetodosClasse) { - if (dado_linha[1].equals(obj.classe)) { - tem = true; - } - } - if (tem == false) { - listaMetodosClasse.add(new ClassMethod(dado_linha[1])); - } - } - progress.setValue(75); - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - for (ClassMethod obj : listaMetodosClasse) { - for (int i = 0; i < listaMetodos.size(); i++) { - String[] dado_linha = (String[]) listaMetodos.get(i); - if (obj.classe.equals(dado_linha[1])) { - int begin; - int end; - try { - begin = Integer.valueOf(dado_linha[10]); - }catch (Exception e){ - begin = 0; - } - try { - end = Integer.valueOf(dado_linha[11]); - }catch (Exception e){ - end = 0; - } - obj.addMethods(new MethodData(dado_linha[8], begin, end)); - } - } - } - progress.setValue(78); - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - try { - if (selecionado.equals("Project") || selecionado.equals("All Test Classes")) { - CriaGrafoCompleto(listaClassesInt, listaClasses, listaTestSmells, graph1, coluna, 1, - txtFilePathDefault1.getText(), selecionado); - } else { - String filtro = ""; - if (selecionado.equals("A Specific Test Class")) { - filtro = (String) cbClass.getSelectedItem(); - CriaGrafoParcial(listaClassesInt, listaClasses, listaTestSmells, graph1, filtro, coluna, - txtFilePathDefault1.getText()); - } else if (selecionado.equals("Author")) { - filtro = (String) cbTestSmells.getSelectedItem(); - String filtroAutor = (String) cbAuthor.getSelectedItem(); - CriaGrafoParcialAutor(listaClassesInt, listaClasses, listaTestSmells, graph1, filtro, - filtroAutor, coluna, txtFilePathDefault1.getText()); - } else if (selecionado.equals("Methods")) { - String testSmell = (String) cbTestSmells.getSelectedItem(); - String classe = (String) cbClass.getSelectedItem(); - CriaGrafoMetodos(listaClassesInt, listaClasses, listaTestSmells, graph1, testSmell, classe, - coluna, txtFilePathDefault1.getText(), listaMetodosClasse); - } else { - filtro = (String) cbTestSmells.getSelectedItem(); - CriaGrafoParcial(listaClassesInt, listaClasses, listaTestSmells, graph1, filtro, coluna, - txtFilePathDefault1.getText()); - } - } - - } catch (Exception e) { - e.printStackTrace(); - } - // String path = System.getProperty("user.dir").replace('\\', '/'); - // graph1.addAttribute("ui.stylesheet", "url('" + path + - // "/src/tsvizzevolution/Config.css')"); - graph1.addAttribute("ui.stylesheet", "url('tsvizzevolution/Config.css')"); - graph1 = CriaLegenda(graph1); - progress.setValue(99); - try { - Thread.sleep(100); - } catch (InterruptedException e) { - e.printStackTrace(); - } - progress.setValue(100); - progressoT.interrupt(); - if (graph1.getNodeCount() == 1) { - String msg = ""; - if (selecionado.equals("Author")) { - msg = "The combination Test Smells x Author does not exist!"; - } - if (selecionado.equals("A Specific Test Smells")) { - msg = "The selected Test Smells has no occurrences in the selected csv file!"; - } - if (selecionado.equals("Methods")) { - msg = "The combination Test Class x Test Smells does not exist!"; - } - JOptionPane optionPane = new JOptionPane(); - optionPane.setMessage(msg); - optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE); - JDialog dialog = optionPane.createDialog(null, "Warning"); - dialog.setVisible(true); - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - - } else { - Viewer v = graph1.display(); - v.disableAutoLayout(); - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - } - } catch (IOException ex) { - Logger.getLogger(umaversao.class.getName()).log(Level.SEVERE, null, ex); - } - } - }.start(); - } - private static void CriaGrafoCompleto(List listaClassesInt, List listaClasses, String[] cabecalho, Graph graph1, - int coluna, int flag, String file, String filtro) throws IOException { - List l = retornaDados(file, filtro); - for (int i = 0; i < listaClassesInt.size(); i++) { - int[] linhaInt = (int[]) listaClassesInt.get(i); - String[] linha = (String[]) listaClasses.get(i); - try { - graph1.addNode(linha[coluna]); - } catch (Exception e) { - } - Node n1 = graph1.getNode(linha[coluna]); - n1.setAttribute("ui.label", linha[coluna]); - // n1.addAttribute("ui.style", "shape:circle;"); - if (filtro.equals("Project")) - n1.addAttribute("ui.class", "projeto"); - double x = (Math.random() * ((1000000) + 1) - 1000000); - double y = (Math.random() * ((1000000) + 1) - 1000000); - n1.setAttribute("x", x); - n1.setAttribute("y", y); - // n1.setAttribute("layout.weight", 10); - n1.setAttribute("edges", "layout.weight:4"); - for (int j = 10; j < linhaInt.length; j++) { - if (linhaInt[j] != 0) { - try { - graph1.addEdge(cabecalho[j] + " " + linha[coluna], cabecalho[j], linha[coluna]); - Edge e = graph1.getEdge(cabecalho[j] + " " + linha[coluna]); - int valor = retornaDadosDoisNos(cabecalho[j], linha[coluna], file, filtro, l); - e.setAttribute("ui.label", valor); - } catch (Exception e) { - } - } - } - } - - boolean stop = false; - while (!stop) { - boolean Flag = false; - for (int i = 0; i < graph1.getNodeCount(); i++) { - Node n1 = graph1.getNode(i); - if (n1.getDegree() == 0) { - Flag = true; - graph1.removeNode(n1); - break; - } - } - if (!Flag) { - stop = true; - } - } - } - - private static void CriaGrafoParcial(List listaClassesInt, List listaClasses, String[] cabecalho, Graph graph1, - String nome, int coluna, String file) throws IOException { - List l = retornaDados(file, "All Test Classes"); - for (int i = 0; i < listaClassesInt.size(); i++) { - int[] linhaInt = (int[]) listaClassesInt.get(i); - String[] linha = (String[]) listaClasses.get(i); - try { - graph1.addNode(linha[coluna]); - } catch (Exception e) { - } - Node n1 = graph1.getNode(linha[coluna]); - n1.setAttribute("ui.label", linha[coluna]); - double x = (Math.random() * ((1000000) + 1)); - double y = (Math.random() * ((1000000) + 1)); - n1.setAttribute("x", x); - n1.setAttribute("y", y); - // n1.setAttribute("layout.weight", 10); - n1.setAttribute("edges", "layout.weight:4"); - - for (int j = 10; j < linhaInt.length; j++) { - if (linhaInt[j] != 0) { - if (nome.equals(linha[coluna]) || nome.equals(cabecalho[j])) { - try { - graph1.addEdge(cabecalho[j] + " " + linha[coluna], cabecalho[j], linha[coluna]); - Edge e = graph1.getEdge(cabecalho[j] + " " + linha[coluna]); - int valor = retornaDadosDoisNos(cabecalho[j], linha[coluna], file, "All Test Classes", l); - e.setAttribute("ui.label", valor); - } catch (Exception e) { - } - } - } - } - } - - boolean stop = false; - while (!stop) { - boolean Flag = false; - for (int i = 0; i < graph1.getNodeCount(); i++) { - Node n1 = graph1.getNode(i); - if (n1.getDegree() == 0) { - Flag = true; - graph1.removeNode(n1); - break; - } - } - if (!Flag) { - stop = true; - } - } - } - - private static void CriaGrafoMetodos(List listaClassesInt, List listaClasses, String[] cabecalho, Graph graph1, - String nome, String classe, int coluna, String file, List listaMetodosClasse) - throws IOException { - List l = retornaDados(file, "All Test Classes"); - for (int i = 0; i < listaClassesInt.size(); i++) { - int[] linhaInt = (int[]) listaClassesInt.get(i); - String[] linha = (String[]) listaClasses.get(i); - try { - graph1.addNode(linha[coluna]); - } catch (Exception e) { - } - Node n1 = graph1.getNode(linha[coluna]); - n1.setAttribute("ui.label", linha[coluna]); - double x = (Math.random() * ((1000000) + 1)); - double y = (Math.random() * ((1000000) + 1)); - n1.setAttribute("x", x); - n1.setAttribute("y", y); - // n1.setAttribute("layout.weight", 10); - n1.setAttribute("edges", "layout.weight:4"); - - for (int j = 10; j < linhaInt.length; j++) { - if (linhaInt[j] != 0) { - if (classe.equals(linha[coluna]) && nome.equals(cabecalho[j])) { - try { - graph1.addEdge(cabecalho[j] + " " + linha[coluna], cabecalho[j], linha[coluna]); - Edge e = graph1.getEdge(cabecalho[j] + " " + linha[coluna]); - int valor = retornaDadosDoisNos(cabecalho[j], linha[coluna], file, "All Test Classes", l); - e.setAttribute("ui.label", valor); - } catch (Exception e) { - } - } - } - } - } - if (graph1.getEdgeCount() > 0) { - for (ClassMethod obj : listaMetodosClasse) { - for (MethodData metodo : obj.metodos) { - try { - graph1.addNode(metodo.metodo); - Node n1 = graph1.getNode(metodo.metodo); - n1.setAttribute("ui.label", metodo.metodo + "," + metodo.begin + "-" + metodo.end); - n1.addAttribute("ui.class", "metodo"); - double x = (Math.random() * ((1000000) + 1) + 1000000); - double y = (Math.random() * ((1000000) + 1) + 1000000); - n1.setAttribute("x", x); - n1.setAttribute("y", y); - if (obj.classe.equals(classe)) - graph1.addEdge(metodo.metodo, obj.classe, metodo.metodo); - } catch (Exception e) { - } - } - } - } - - boolean stop = false; - while (!stop) { - boolean Flag = false; - for (int i = 0; i < graph1.getNodeCount(); i++) { - Node n1 = graph1.getNode(i); - if (n1.getDegree() == 0) { - Flag = true; - graph1.removeNode(n1); - break; - } - } - if (!Flag) { - stop = true; - } - } - } - - private static void CriaGrafoParcialAutor(List listaClassesInt, List listaClasses, String[] cabecalho, Graph graph1, - String nome, String nomeAutor, int coluna, String file) throws IOException { - int colunaAutor = 1; - List l = retornaDados(file, "All Test Classes"); - List l2 = retornaDadosAutores(file); - if (nomeAutor.equals("All")) { - ArrayList nomeAutores = new ArrayList<>(); - for (int i = 0; i < listaClasses.size(); i++) { - String[] linha = (String[]) listaClasses.get(i); - if (!nomeAutores.contains(linha[1])) { - nomeAutores.add(linha[1]); - } - } - for (int x = 0; x < nomeAutores.size(); x++) { - nomeAutor = nomeAutores.get(x); - graph1.addNode(nomeAutor); - Node autor = graph1.getNode(nomeAutor); - double x1 = (Math.random() * ((1000000) + 1)); - double y = (Math.random() * ((1000000) + 1)); - autor.setAttribute("ui.label", nomeAutor); - autor.addAttribute("ui.class", "boneco"); - autor.setAttribute("x", x1); - autor.setAttribute("y", y); - - for (int i = 0; i < listaClassesInt.size(); i++) { - int[] linhaInt = (int[]) listaClassesInt.get(i); - String[] linha = (String[]) listaClasses.get(i); - try { - graph1.addNode(linha[coluna]); - } catch (Exception e) { - } - Node n1 = graph1.getNode(linha[coluna]); - n1.setAttribute("ui.label", linha[coluna]); - - x1 = (Math.random() * ((1000000) + 1)); - y = (Math.random() * ((1000000) + 1)); - n1.setAttribute("x", x1); - n1.setAttribute("y", y); - n1.setAttribute("layout.weight", 10); - n1.setAttribute("edges", "layout.weight:4"); - - for (int j = 10; j < linhaInt.length; j++) { - if (linhaInt[j] != 0) { - if (nomeAutor.equals(linha[colunaAutor]) || nome.equals(cabecalho[j])) { - if (nome.equals(cabecalho[j])) { - try { - graph1.addEdge(cabecalho[j] + " " + linha[colunaAutor], cabecalho[j], - linha[colunaAutor]); - Edge e = graph1.getEdge(cabecalho[j] + " " + linha[colunaAutor]); - int valor = retornaDadosAutorMetodo(linha[colunaAutor], cabecalho[j], file, l2); - e.setAttribute("ui.label", valor); - } catch (Exception e) { - } - } - } - } - } - - } - - boolean stop = false; - while (!stop) { - boolean Flag = false; - for (int i = 0; i < graph1.getNodeCount(); i++) { - Node n1 = graph1.getNode(i); - if (n1.getDegree() == 0) { - Flag = true; - graph1.removeNode(n1); - break; - } - } - if (!Flag) { - stop = true; - } - } - } - } else { - graph1.addNode(nomeAutor); - Node autor = graph1.getNode(nomeAutor); - autor.setAttribute("ui.label", nomeAutor); - autor.addAttribute("ui.class", "boneco"); - autor.setAttribute("x", -1000); - autor.setAttribute("y", 0); - - for (int i = 0; i < listaClassesInt.size(); i++) { - int[] linhaInt = (int[]) listaClassesInt.get(i); - String[] linha = (String[]) listaClasses.get(i); - try { - graph1.addNode(linha[coluna]); - } catch (Exception e) { - } - Node n1 = graph1.getNode(linha[coluna]); - n1.setAttribute("ui.label", linha[coluna]); - double x1 = (Math.random() * ((1000000) + 1)); - double y = (Math.random() * ((1000000) + 1)); - n1.setAttribute("x", x1); - n1.setAttribute("y", y); - for (int j = 10; j < linhaInt.length; j++) { - if (linhaInt[j] != 0) { - if (nome.equals(linha[coluna]) - || nome.equals(cabecalho[j]) && linha[colunaAutor].equals(nomeAutor)) { - try { - graph1.addEdge(cabecalho[j] + " " + linha[coluna], cabecalho[j], linha[coluna]); - Edge e = graph1.getEdge(cabecalho[j] + " " + linha[coluna]); - int valor = retornaDadosDoisNos(cabecalho[j], linha[coluna], file, "All Test Classes", - l); - e.setAttribute("ui.label", valor); - } catch (Exception e) { - } - } - } - } - for (int j = 10; j < linhaInt.length; j++) { - if (linhaInt[j] != 0) { - if (nomeAutor.equals(linha[colunaAutor]) || nome.equals(cabecalho[j])) { - if (nome.equals(cabecalho[j])) { - try { - graph1.addEdge(cabecalho[j] + " " + linha[colunaAutor], cabecalho[j], - linha[colunaAutor]); - Edge e = graph1.getEdge(cabecalho[j] + " " + linha[colunaAutor]); - int valor = retornaDadosAutorMetodo(linha[colunaAutor], cabecalho[j], file, l2); - e.setAttribute("ui.label", valor); - } catch (Exception e) { - } - } - } - } - } - - } - - boolean stop = false; - while (!stop) { - boolean Flag = false; - for (int i = 0; i < graph1.getNodeCount(); i++) { - Node n1 = graph1.getNode(i); - if (n1.getDegree() == 0) { - Flag = true; - graph1.removeNode(n1); - break; - } - } - if (!Flag) { - stop = true; - } - } - } - } - - public static int retornaDadosAutorMetodo(String autor, String metodo, String file, List l) { - for (int i = 0; i < l.size(); i++) { - Data d = l.get(i); - if (d.autor.equals(autor) && d.nome.equals(metodo)) { - return d.valor; - } - } - return 0; - } - - public static List retornaDadosAutores(String file) { - try { - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); - String linha = null; - - List listaDeLinhasInt = new ArrayList(); - List listaDeLinhas = new ArrayList(); - String cabecalho; - - cabecalho = reader.readLine(); - String[] cabecalhoLista = cabecalho.split(VIRGULA); - if (cabecalho != null) { - while ((linha = reader.readLine()) != null) { - String[] dados = linha.split(VIRGULA); - listaDeLinhas.add(dados); - int[] valorInteiros = new int[dados.length]; - - for (int i = 0; i < dados.length; i++) { - valorInteiros[i] = converteInteiro(String.valueOf(dados[i])); - } - listaDeLinhasInt.add(valorInteiros); - } - - } - List resultado = new ArrayList<>(); - List autores = new ArrayList<>(); - int coluna = 1; - for (int i = 0; i < listaDeLinhas.size(); i++) { - String[] linha_analisada = (String[]) listaDeLinhas.get(i); - String autor = linha_analisada[coluna]; - boolean flag = false; - for (int j = 0; j < autores.size(); j++) { - if (autores.get(j).equals(autor)) { - flag = true; - } - } - if (!flag) { - autores.add(autor); - } - } - for (int i = 0; i < autores.size(); i++) { - String autor = autores.get(i); - coluna = 10; - for (int j = 10; j < cabecalhoLista.length; j++) { - int soma = 0; - for (int k = 0; k < listaDeLinhas.size(); k++) { - String[] linha_analisada = (String[]) listaDeLinhas.get(k); - int[] linha_int = (int[]) listaDeLinhasInt.get(k); - if (linha_analisada[1].equals(autor)) { - soma += linha_int[coluna]; - } - } - resultado.add(new Data(cabecalhoLista[j], soma, autor)); - coluna += 1; - } - } - return resultado; - } catch (Exception e) { - e.printStackTrace(); - return null; - } - } - - public static int retornaDadosDoisNos(String a, String b, String file, String filtro, List l) { - if (filtro.equals("Project")) { - for (int i = 0; i < l.size(); i++) { - Data d = l.get(i); - if (d.nome.equals(a) && d.projeto.equals(b)) { - return d.valor; - } - } - return 0; - } else { - for (int i = 0; i < l.size(); i++) { - Data d = l.get(i); - if (d.nome.equals(a) && d.classe.equals(b)) { - return d.valor; - } - } - return 0; - } - } - - public static List retornaDados(String file, String filtro) { - try { - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); - String linha = null; - - List listaClassesInt = new ArrayList(); - List listaClasses = new ArrayList(); - String cabecalho; - - cabecalho = reader.readLine(); - String[] listaTestSmells = cabecalho.split(VIRGULA); - if (cabecalho != null) { - while ((linha = reader.readLine()) != null) { - String[] dados = linha.split(VIRGULA); - listaClasses.add(dados); - int[] valorInteiros = new int[dados.length]; - - for (int i = 0; i < dados.length; i++) { - valorInteiros[i] = converteInteiro(String.valueOf(dados[i])); - } - listaClassesInt.add(valorInteiros); - } - - } - List resultado_final = new ArrayList<>(); - if (filtro.equals("Project")) { - - int coluna = 10; - - for (int i = 10; i < listaTestSmells.length; i++) { - int soma = 0; - String nome_projeto = ""; - for (int j = 0; j < listaClasses.size(); j++) { - int[] linha_int = (int[]) listaClassesInt.get(j); - String[] linha_analisada = (String[]) listaClasses.get(j); - soma += linha_int[coluna]; - nome_projeto = linha_analisada[5]; - } - resultado_final.add(new Data(listaTestSmells[i], soma, "", nome_projeto)); - coluna += 1; - - } - } - if (filtro.equals("All Test Classes")) { - List classes = new ArrayList<>(); - int coluna = 6; - for (int i = 0; i < listaClasses.size(); i++) { - String[] linha_analisada = (String[]) listaClasses.get(i); - String classe = linha_analisada[coluna]; - boolean flag = false; - for (int j = 0; j < classes.size(); j++) { - if (classes.get(j).equals(classe)) { - flag = true; - } - } - if (!flag) { - classes.add(classe); - } - } - for (int i = 0; i < classes.size(); i++) { - String classe_analisada = classes.get(i); - coluna = 10; - for (int j = 10; j < listaTestSmells.length; j++) { - int soma = 0; - String nome_projeto = ""; - for (int k = 0; k < listaClasses.size(); k++) { - String[] linha_analisada = (String[]) listaClasses.get(k); - int[] linha_int = (int[]) listaClassesInt.get(k); - if (linha_analisada[6].equals(classe_analisada)) { - soma += linha_int[coluna]; - nome_projeto = linha_analisada[5]; - } - } - resultado_final.add(new Data(listaTestSmells[j], soma, classe_analisada, nome_projeto)); - coluna += 1; - } - } - } - return resultado_final; - } catch (Exception e) { - return null; - } - } - - private void cbLevelActionPerformed(java.awt.event.ActionEvent evt) { - } - - public static void main(String args[]) throws IOException { - 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(umaversao.class.getName()).log(java.util.logging.Level.SEVERE, - null, ex); - } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(umaversao.class.getName()).log(java.util.logging.Level.SEVERE, - null, ex); - } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(umaversao.class.getName()).log(java.util.logging.Level.SEVERE, - null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(umaversao.class.getName()).log(java.util.logging.Level.SEVERE, - null, ex); - } - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - try { - new umaversao().setVisible(true); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }); - } - - public static String[] carrega_lista_linhas(String path) throws IOException { - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(path))); - String linha = null; - List resposta = new ArrayList(); - while ((linha = reader.readLine()) != null) { - String[] dados = linha.split(VIRGULA); - String classe = dados[6]; - boolean flag = false; - for (int i = 0; i < resposta.size(); i++) { - if (resposta.get(i).equals(classe)) { - flag = true; - } - } - if (flag == false) { - resposta.add(classe); - } - } - Collections.sort(resposta); - String[] resposta_final = new String[resposta.size() - 1]; - for (int i = 0; i < resposta.size() - 1; i++) { - resposta_final[i] = (String) resposta.get(i + 1); - } - return resposta_final; - } - - private static Graph CriaLegenda(Graph graph1) { - graph1.addNode("-"); - Node n = graph1.getNode("-"); - n.addAttribute("ui.class", "legenda"); - float maior_x = 0; - for (int i = 0; i < graph1.getNodeCount(); i++) { - Node n1 = graph1.getNode(i); - String value_x = "0"; - try { - value_x = n1.getAttribute("x").toString(); - } catch (Exception e) { - - } - if (Float.parseFloat(value_x) > maior_x) { - maior_x = Float.parseFloat(value_x); - } - } - n.setAttribute("x", maior_x + 1000); - n.setAttribute("y", 0); - return graph1; - } - - public static String[] carrega_lista_cabecalho(String path) throws IOException { - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(path))); - String cabecalho_combo; - cabecalho_combo = reader.readLine(); - String[] cabecalhoTest = cabecalho_combo.split(VIRGULA); - String[] resultado = new String[cabecalhoTest.length - 10]; - for (int i = 10; i < cabecalhoTest.length; i++) { - resultado[i - 10] = cabecalhoTest[i]; - } - List aux = new ArrayList<>(); - for (int i = 0; i < resultado.length; i++) { - aux.add(resultado[i]); - } - Collections.sort(aux); - for (int i = 0; i < resultado.length; i++) { - resultado[i] = aux.get(i); - } - return resultado; - - } - - public static String[] ordenaVetorString(String[] vetor) { - String[] resultado = new String[vetor.length]; - List l = new ArrayList<>(); - for (int i = 0; i < vetor.length; i++) { - l.add(vetor[i]); - } - Collections.sort(l); - for (int i = 0; i < vetor.length; i++) { - resultado[i] = l.get(i); - } - return resultado; - } - - public static String[] carrega_lista_autor(String path) throws IOException { - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(path))); - String linha = null; - List resposta = new ArrayList(); - while ((linha = reader.readLine()) != null) { - String[] dados = linha.split(VIRGULA); - String classe = dados[1]; - boolean flag = false; - for (int i = 0; i < resposta.size(); i++) { - if (resposta.get(i).equals(classe)) { - flag = true; - } - } - if (flag == false) { - resposta.add(classe); - } - } - resposta.remove(0); - Collections.sort(resposta); - resposta.add(0, "All"); - String[] resposta_final = new String[resposta.size()]; - for (int i = 0; i < resposta.size(); i++) { - resposta_final[i] = (String) resposta.get(i); - } - return resposta_final; - } - - public static String[] carrega_lista_autor_test(String path, String autor) throws IOException { - List resposta_final_array = new ArrayList(); - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(path))); - String[] cabecalho = reader.readLine().split(VIRGULA); - String linha = null; - while ((linha = reader.readLine()) != null) { - String[] dados = linha.split(VIRGULA); - if(autor.equals(dados[1])){ - for(int i=10; i retorna_lista_classe_metodo() throws IOException { - List listaMetodosClasse = new ArrayList<>(); - List listaMetodos = new ArrayList(); - String linha = null; - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(txtFilePathMethod.getText()))); - while ((linha = reader.readLine()) != null) { - String[] dados = linha.split(VIRGULA); - listaMetodos.add(dados); - } - - for (int i = 0; i < listaMetodos.size(); i++) { - boolean tem = false; - String[] dado_linha = (String[]) listaMetodos.get(i); - for (ClassMethod obj : listaMetodosClasse) { - if (dado_linha[1].equals(obj.classe)) { - tem = true; - } - } - if (tem == false) { - listaMetodosClasse.add(new ClassMethod(dado_linha[1])); - } - } - for (ClassMethod obj : listaMetodosClasse) { - for (int i = 0; i < listaMetodos.size(); i++) { - String[] dado_linha = (String[]) listaMetodos.get(i); - if (obj.classe.equals(dado_linha[1])) { - int begin; - int end; - try { - begin = Integer.valueOf(dado_linha[10]); - }catch (Exception e){ - begin = 0; - } - try { - end = Integer.valueOf(dado_linha[11]); - }catch (Exception e){ - end = 0; - } - obj.addMethods(new MethodData(dado_linha[8], begin, end)); - } - } - } - return listaMetodosClasse; - } - - private void cbVisualizationActionPerformed(ActionEvent evt) { - } - - private void btnGerarUploadActionPerformed(ActionEvent evt) throws IOException { - String[] a = null; - String[] b = null; - String[] c = null; - String[] metodos = null; - - a = carrega_lista_linhas(txtFilePathDefault1.getText()); - b = carrega_lista_cabecalho(txtFilePathDefault1.getText()); - c = carrega_lista_autor(txtFilePathDefault1.getText()); - - cbAuthor.setModel(new DefaultComboBoxModel<>(c)); - cbClass.setModel(new DefaultComboBoxModel<>(a)); - cbTestSmells.setModel(new DefaultComboBoxModel<>(b)); - - btnVisualizeGraph.setEnabled(true); - btnVisualizeTreemap.setEnabled(true); - - - } - - private void initComponents() throws IOException { - btnChooseFileSearch = new JButton(); - btnSearchMethod = new JButton(); - - progress = new JProgressBar(0, 100); - - lblSelectCsv = new JLabel(); - lblSelectClass = new JLabel(); - lblSelectTestSmells = new JLabel(); - lblAuthor = new JLabel(); - lblSelectTheCsvMethod = new JLabel(); - - pnlClass = new JPanel(); - pnlTestSmells = new JPanel(); - pnlAuthor = new JPanel(); - pnlGraph = new JPanel(); - pnlUpload = new JPanel(); - pnlMethod = new JPanel(); - pnlbutton = new JPanel(); - pnlVisualization = new JPanel(); - pnlLevel = new JPanel(); - pnlProgress = new JPanel(); - pnlSelectMethod = new JPanel(); - - cbTestSmells = new JComboBox<>(); - cbClass = new JComboBox<>(); - cbAuthor = new JComboBox<>(); - - pnlSelectMethod.setVisible(false); - pnlProgress.setVisible(false); - - progress.setStringPainted(true); - progress.setValue(0); - progress.setSize(new Dimension(100, 23)); - - pnlbutton.setVisible(false); - - lblSelectTheCsvMethod.setText("Select the .csv File (By Test Smells JNose) :"); - - txtFilePathMethod = new JTextField(); -// txtFilePathMethod.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\commons-io_testsmesll_2_6.csv"); - txtFilePathDefault1 = new JTextField(); - - pnlUpload.setVisible(true); - pnlMethod.setVisible(false); - pnlSelectMethod.setVisible(false); - - setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - - lblSelectCsv.setText("Select the .csv File :"); - - btnChooseFileSearch.setText("Search ..."); - btnChooseFileSearch.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - try { - btnChooseFileSearchActionPerformed(evt); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }); - - cbAuthor.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - if (!String.valueOf(cbAuthor.getSelectedItem()).equals("All")) { - try { - if (e.getStateChange() == ItemEvent.SELECTED) { - String[] result = carrega_lista_autor_test(txtFilePathDefault1.getText(), String.valueOf(cbAuthor.getSelectedItem())); - cbTestSmells.setModel(new DefaultComboBoxModel<>(result)); - cbTestSmells.removeAllItems(); - for (String test : result) { - cbTestSmells.addItem(test); - } - } else { - } - } catch (Exception exception) { - exception.printStackTrace(); - } - }else{ - try { - String[] result = carrega_lista_cabecalho(txtFilePathDefault1.getText()); - Arrays.sort(result); - cbTestSmells.removeAllItems(); - for (String test : result) { - cbTestSmells.addItem(test); - } - } catch (IOException ioException) { - ioException.printStackTrace(); - } - - } - } - }); - - cbSelectMethod = new JComboBox(); - cbClass.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - try { - List l = retorna_lista_classe_metodo(); - cbSelectMethod.removeAllItems(); - for(ClassMethod obj: l){ - if(obj.classe.equals(String.valueOf(cbClass.getSelectedItem()))) - for(MethodData Metodos: obj.metodos){ - cbSelectMethod.addItem(Metodos.metodo); - } - } - } catch (IOException ioException) { - ioException.printStackTrace(); - } - - } - }); - - - btnSearchMethod.setText("Search ..."); - btnSearchMethod.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - try { - btnSearchMethodActionPerformed(evt); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - }); - lblSelectClass.setText("Select a Test Class:"); - lblSelectTestSmells.setText("Select a Test Smells:"); - lblAuthor.setText("Select A Specific Author or All:"); - - cbVisualization = new JComboBox<>(); - cbVisualization.setModel(new DefaultComboBoxModel<>(new String[] { "Graph View", "Treemap View" })); - cbVisualization.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - cbVisualizationActionPerformed(evt); - } - }); - - String selecionado2 = (String) cbVisualization.getSelectedItem(); - if (selecionado2.equals("Graph View")) { - cbVisualization.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent event) { - if (event.getItem().equals("Graph View")) { - pnlUpload.setVisible(true); - pnlMethod.setVisible(false); - pnlSelectMethod.setVisible(false); - pnlLevel.setVisible(true); - btnVisualizeGraph.setVisible(true); - lblVisualizeGraph.setVisible(true); - btnVisualizeTreemap.setVisible(false); - lblVisualizeTreemap.setVisible(false); - } else if (event.getItem().equals("Treemap View")) { - pnlClass.setVisible(false); - pnlTestSmells.setVisible(false); - pnlAuthor.setVisible(false); - pnlLevel.setVisible(false); - pnlUpload.setVisible(true); - pnlMethod.setVisible(false); - pnlSelectMethod.setVisible(false); - btnVisualizeGraph.setVisible(false); - lblVisualizeGraph.setVisible(false); - btnVisualizeTreemap.setVisible(true); - lblVisualizeTreemap.setVisible(true); - } - - } - }); - - } - pnlSelectMethod.setVisible(false); - - btnChooseFileSearch.setFont(new Font("Tahoma", Font.PLAIN, 16)); - cbClass.setFont(new Font("Tahoma", Font.PLAIN, 16)); - cbTestSmells.setFont(new Font("Tahoma", Font.PLAIN, 16)); - cbAuthor.setFont(new Font("Tahoma", Font.PLAIN, 16)); - lblSelectCsv.setFont(new Font("Tahoma", Font.PLAIN, 16)); - lblSelectClass.setFont(new Font("Tahoma", Font.PLAIN, 16)); - lblSelectTestSmells.setFont(new Font("Tahoma", Font.PLAIN, 16)); - lblAuthor.setFont(new Font("Tahoma", Font.PLAIN, 16)); - txtFilePathDefault1.setFont(new Font("Tahoma", Font.PLAIN, 14)); - txtFilePathMethod.setFont(new Font("Tahoma", Font.PLAIN, 14)); - lblSelectTheCsvMethod.setFont(new Font("Tahoma", Font.PLAIN, 16)); - btnSearchMethod.setFont(new Font("Tahoma", Font.PLAIN, 16)); - cbVisualization.setFont(new Font("Tahoma", Font.PLAIN, 16)); - - // }); - - lblSelect = new JLabel("Select a view type:"); - lblSelect.setFont(new Font("Tahoma", Font.PLAIN, 16)); - - lblLevel = new JLabel(); - lblLevel.setFont(new Font("Tahoma", Font.PLAIN, 16)); - - lblLevel.setText("Select the level of granularity:"); - cbLevel = new JComboBox<>(); - cbLevel.setFont(new Font("Tahoma", Font.PLAIN, 16)); - cbLevel.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Project", "All Test Classes", - "A Specific Test Class", "A Specific Test Smells", "Author", "Methods" })); - cbLevel.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - cbLevelActionPerformed(evt); - } - }); - btnVisualizeGraph = new JButton(); - - btnVisualizeGraph.setText("Generate Graph View"); - btnVisualizeGraph.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnGerarGrafoActionPerformed(evt); - } - }); - btnVisualizeGraph.setFont(new Font("Tahoma", Font.PLAIN, 16)); - - btnVisualizeTreemap = new JButton("Generate Treemap View"); - btnVisualizeTreemap.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent evt) { - btnGerarTreemapActionPerformed(); - } - }); - - btnVisualizeTreemap.setVisible(false); - - lblVisualizeGraph = new JLabel("Click here to generate the visualization :"); - - lblVisualizeTreemap= new JLabel("Click here to generate the visualization :"); - - btnVisualizeGraph.setEnabled(false); - btnVisualizeTreemap.setEnabled(false); - - - lblSelectMethod = new JLabel(); - lblSelectMethod.setText("Select a Method:"); - - btnVisualizeTreemap.setFont(new Font("Tahoma", Font.PLAIN, 16)); - lblVisualizeGraph.setFont(new Font("Tahoma", Font.PLAIN, 16)); - lblVisualizeTreemap.setFont(new Font("Tahoma", Font.PLAIN, 16)); - lblSelectMethod.setFont(new Font("Tahoma", Font.PLAIN, 16)); - cbSelectMethod.setFont(new Font("Tahoma", Font.PLAIN, 16)); - - - - GroupLayout gl_pnlMethod = new GroupLayout(pnlMethod); - gl_pnlMethod.setHorizontalGroup( - gl_pnlMethod.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlMethod.createSequentialGroup() - .addGroup(gl_pnlMethod.createParallelGroup(Alignment.LEADING) - .addComponent(lblSelectTheCsvMethod) - .addGroup(gl_pnlMethod.createSequentialGroup() - .addGap(2) - .addComponent(txtFilePathMethod, GroupLayout.PREFERRED_SIZE, 534, GroupLayout.PREFERRED_SIZE) - .addGap(6) - .addComponent(btnSearchMethod, GroupLayout.PREFERRED_SIZE, 99, GroupLayout.PREFERRED_SIZE))) - .addContainerGap(23, Short.MAX_VALUE)) - ); - gl_pnlMethod.setVerticalGroup( - gl_pnlMethod.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlMethod.createSequentialGroup() - .addGap(9) - .addComponent(lblSelectTheCsvMethod) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addGroup(gl_pnlMethod.createParallelGroup(Alignment.BASELINE) - .addComponent(txtFilePathMethod, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addComponent(btnSearchMethod, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)) - .addContainerGap(19, Short.MAX_VALUE)) - ); - pnlMethod.setLayout(gl_pnlMethod); - - GroupLayout gl_pnlVisualization = new GroupLayout(pnlVisualization); - gl_pnlVisualization - .setHorizontalGroup( - gl_pnlVisualization.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlVisualization.createSequentialGroup().addGap(2).addComponent(lblSelect) - .addPreferredGap(ComponentPlacement.RELATED).addComponent(cbVisualization, - GroupLayout.PREFERRED_SIZE, 207, GroupLayout.PREFERRED_SIZE) - .addGap(176))); - gl_pnlVisualization.setVerticalGroup(gl_pnlVisualization.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlVisualization.createSequentialGroup().addGap(5) - .addGroup(gl_pnlVisualization - .createParallelGroup(Alignment.BASELINE).addComponent(cbVisualization, - GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE) - .addComponent(lblSelect)))); - pnlVisualization.setLayout(gl_pnlVisualization); - - GroupLayout gl_pnlLevel = new GroupLayout(pnlLevel); - gl_pnlLevel.setHorizontalGroup( - gl_pnlLevel.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlLevel.createSequentialGroup() - .addGap(4) - .addComponent(lblLevel) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cbLevel, GroupLayout.PREFERRED_SIZE, 190, GroupLayout.PREFERRED_SIZE) - .addContainerGap(584, Short.MAX_VALUE)) - ); - gl_pnlLevel.setVerticalGroup( - gl_pnlLevel.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlLevel.createSequentialGroup() - .addGroup(gl_pnlLevel.createParallelGroup(Alignment.BASELINE) - .addComponent(cbLevel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addComponent(lblLevel)) - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - pnlLevel.setLayout(gl_pnlLevel); - - GroupLayout gl_pnlAuthor = new GroupLayout(pnlAuthor); - gl_pnlAuthor.setHorizontalGroup(gl_pnlAuthor.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlAuthor.createSequentialGroup() - .addComponent(lblAuthor, GroupLayout.PREFERRED_SIZE, 219, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(cbAuthor, GroupLayout.PREFERRED_SIZE, 180, GroupLayout.PREFERRED_SIZE) - .addContainerGap(111, Short.MAX_VALUE))); - gl_pnlAuthor.setVerticalGroup(gl_pnlAuthor.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlAuthor.createSequentialGroup().addContainerGap() - .addGroup(gl_pnlAuthor.createParallelGroup(Alignment.BASELINE) - .addComponent(lblAuthor, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE) - .addComponent(cbAuthor, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)) - .addContainerGap(51, Short.MAX_VALUE))); - pnlAuthor.setLayout(gl_pnlAuthor); - - GroupLayout gl_pnlTestSmells = new GroupLayout(pnlTestSmells); - gl_pnlTestSmells.setHorizontalGroup(gl_pnlTestSmells.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlTestSmells.createSequentialGroup() - .addComponent(lblSelectTestSmells, GroupLayout.PREFERRED_SIZE, 146, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(cbTestSmells, GroupLayout.PREFERRED_SIZE, 200, GroupLayout.PREFERRED_SIZE) - .addContainerGap(191, Short.MAX_VALUE))); - gl_pnlTestSmells - .setVerticalGroup(gl_pnlTestSmells.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlTestSmells.createSequentialGroup().addContainerGap() - .addGroup(gl_pnlTestSmells.createParallelGroup(Alignment.TRAILING) - .addComponent(cbTestSmells, GroupLayout.PREFERRED_SIZE, 26, - GroupLayout.PREFERRED_SIZE) - .addComponent(lblSelectTestSmells, GroupLayout.PREFERRED_SIZE, 20, - GroupLayout.PREFERRED_SIZE)) - .addContainerGap(37, Short.MAX_VALUE))); - pnlTestSmells.setLayout(gl_pnlTestSmells); - - GroupLayout gl_pnlClass = new GroupLayout(pnlClass); - gl_pnlClass.setHorizontalGroup(gl_pnlClass.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlClass.createSequentialGroup() - .addComponent(lblSelectClass, GroupLayout.PREFERRED_SIZE, 136, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(cbClass, GroupLayout.PREFERRED_SIZE, 267, GroupLayout.PREFERRED_SIZE) - .addContainerGap(128, Short.MAX_VALUE))); - gl_pnlClass.setVerticalGroup(gl_pnlClass.createParallelGroup(Alignment.LEADING).addGroup(gl_pnlClass - .createSequentialGroup().addContainerGap() - .addGroup(gl_pnlClass.createParallelGroup(Alignment.BASELINE) - .addComponent(lblSelectClass, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE) - .addComponent(cbClass, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)) - .addContainerGap(37, Short.MAX_VALUE))); - pnlClass.setLayout(gl_pnlClass); - - GroupLayout gl_pnlGraph = new GroupLayout(pnlGraph); - gl_pnlGraph.setHorizontalGroup( - gl_pnlGraph.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlGraph.createSequentialGroup() - .addGap(10) - .addGroup(gl_pnlGraph.createParallelGroup(Alignment.LEADING) - .addComponent(pnlClass, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addComponent(lblSelectCsv) - .addGroup(gl_pnlGraph.createSequentialGroup() - .addComponent(txtFilePathDefault1, GroupLayout.PREFERRED_SIZE, 535, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(btnChooseFileSearch)) - .addComponent(pnlVisualization, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addComponent(pnlLevel, GroupLayout.PREFERRED_SIZE, 999, GroupLayout.PREFERRED_SIZE) - .addComponent(pnlMethod, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addGroup(gl_pnlGraph.createSequentialGroup() - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(lblVisualizeGraph, GroupLayout.PREFERRED_SIZE, 303, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addComponent(btnVisualizeGraph, GroupLayout.PREFERRED_SIZE, 285, GroupLayout.PREFERRED_SIZE)) - .addGroup(gl_pnlGraph.createSequentialGroup() - .addComponent(lblVisualizeTreemap, GroupLayout.PREFERRED_SIZE, 303, GroupLayout.PREFERRED_SIZE) - .addGap(4) - .addComponent(btnVisualizeTreemap, GroupLayout.PREFERRED_SIZE, 285, GroupLayout.PREFERRED_SIZE)) - .addComponent(pnlProgress, GroupLayout.PREFERRED_SIZE, 144, GroupLayout.PREFERRED_SIZE))) - .addGroup(gl_pnlGraph.createSequentialGroup() - .addContainerGap() - .addComponent(pnlAuthor, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - .addGroup(gl_pnlGraph.createSequentialGroup() - .addContainerGap() - .addComponent(pnlTestSmells, GroupLayout.PREFERRED_SIZE, 360, GroupLayout.PREFERRED_SIZE)) - .addGroup(gl_pnlGraph.createSequentialGroup() - .addContainerGap() - .addComponent(pnlSelectMethod, GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE) - .addGap(639)) - ); - gl_pnlGraph.setVerticalGroup( - gl_pnlGraph.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlGraph.createSequentialGroup() - .addGap(6) - .addComponent(lblSelectCsv) - .addGap(6) - .addGroup(gl_pnlGraph.createParallelGroup(Alignment.BASELINE) - .addComponent(txtFilePathDefault1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) - .addComponent(btnChooseFileSearch)) - .addGap(12) - .addComponent(pnlVisualization, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE) - .addGap(6) - .addComponent(pnlLevel, GroupLayout.PREFERRED_SIZE, 37, GroupLayout.PREFERRED_SIZE) - .addGap(6) - .addComponent(pnlMethod, GroupLayout.PREFERRED_SIZE, 79, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(pnlClass, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(pnlAuthor, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(pnlTestSmells, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(pnlSelectMethod, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE) - .addPreferredGap(ComponentPlacement.UNRELATED) - .addGroup(gl_pnlGraph.createParallelGroup(Alignment.BASELINE) - .addComponent(btnVisualizeGraph) - .addComponent(lblVisualizeGraph)) - .addGap(6) - .addGroup(gl_pnlGraph.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlGraph.createSequentialGroup() - .addGap(4) - .addComponent(lblVisualizeTreemap)) - .addComponent(btnVisualizeTreemap)) - .addGap(1) - .addComponent(pnlProgress, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) - ); - - GroupLayout gl_pnlSelectMethod = new GroupLayout(pnlSelectMethod); - gl_pnlSelectMethod.setHorizontalGroup( - gl_pnlSelectMethod.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlSelectMethod.createSequentialGroup() - .addContainerGap() - .addComponent(lblSelectMethod) - .addPreferredGap(ComponentPlacement.RELATED) - .addComponent(cbSelectMethod, GroupLayout.PREFERRED_SIZE, 200, GroupLayout.PREFERRED_SIZE) - .addContainerGap(39, Short.MAX_VALUE)) - ); - gl_pnlSelectMethod.setVerticalGroup( - gl_pnlSelectMethod.createParallelGroup(Alignment.LEADING) - .addGroup(gl_pnlSelectMethod.createSequentialGroup() - .addGroup(gl_pnlSelectMethod.createParallelGroup(Alignment.BASELINE) - .addComponent(cbSelectMethod, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE) - .addComponent(lblSelectMethod)) - .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - pnlSelectMethod.setLayout(gl_pnlSelectMethod); - pnlGraph.setLayout(gl_pnlGraph); - GroupLayout gl_contentPane = new GroupLayout(contentPane); - gl_contentPane.setHorizontalGroup( - gl_contentPane.createParallelGroup(Alignment.LEADING) - .addGroup(gl_contentPane.createSequentialGroup() - .addGap(10) - .addComponent(pnlGraph, GroupLayout.PREFERRED_SIZE, 689, GroupLayout.PREFERRED_SIZE)) - ); - gl_contentPane.setVerticalGroup( - gl_contentPane.createParallelGroup(Alignment.LEADING) - .addGroup(gl_contentPane.createSequentialGroup() - .addGap(11) - .addComponent(pnlGraph, GroupLayout.PREFERRED_SIZE, 474, GroupLayout.PREFERRED_SIZE)) - ); - contentPane.setLayout(gl_contentPane); - - pack(); - - } -} diff --git a/TSVizzEvolution/src/Thumbs.db b/TSVizzEvolution/src/Thumbs.db index c558a10..2ca06c1 100644 Binary files a/TSVizzEvolution/src/Thumbs.db and b/TSVizzEvolution/src/Thumbs.db differ diff --git a/TSVizzEvolution/src/tsvizzevolution/GraphOneVersion.java b/TSVizzEvolution/src/tsvizzevolution/GraphOneVersion.java index de1f82b..b660970 100644 --- a/TSVizzEvolution/src/tsvizzevolution/GraphOneVersion.java +++ b/TSVizzEvolution/src/tsvizzevolution/GraphOneVersion.java @@ -38,7 +38,7 @@ public class GraphOneVersion extends javax.swing.JFrame { private JComboBox cbAuthor; private JComboBox cbVisualization; private JComboBox cbSelectMethod; - + private JLabel lblSelectCsv; private JLabel lblLevel; private JLabel lblSelectClass; @@ -218,7 +218,7 @@ private void btnChooseFileSearchActionPerformed(java.awt.event.ActionEvent evt) if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); txtFilePathDefault1.setText(file.getPath()); - txtFilePathDefault1.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\resultado_evolution1.csv"); + //txtFilePathDefault1.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\resultado_evolution1.csv"); nomeDoArquivo = file.getName(); btnGerarUploadActionPerformed(evt); @@ -231,8 +231,8 @@ private void btnSearchMethodActionPerformed(java.awt.event.ActionEvent evt) thro if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); txtFilePathMethod.setText(file.getPath()); - txtFilePathMethod.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\commons-io_result_byclasstest_testsmells.csv"); - nomeDoArquivo = file.getName(); + //txtFilePathMethod.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\commons-io_result_byclasstest_testsmells.csv"); + //nomeDoArquivo = file.getName(); List l = retorna_lista_classe_metodo(); List list = new ArrayList<>(); for(ClassMethod obj: l){ @@ -476,7 +476,7 @@ public void run(){ String testSmell = (String) cbTestSmells.getSelectedItem(); String classe = (String) cbClass.getSelectedItem(); CriaGrafoMetodos(listaClassesInt, listaClasses, listaTestSmells, graph1, testSmell, classe, - coluna, txtFilePathDefault1.getText(), listaMetodosClasse); + coluna, txtFilePathDefault1.getText(), listaMetodosClasse, (String) cbSelectMethod.getSelectedItem()); } else { filtro = (String) cbTestSmells.getSelectedItem(); CriaGrafoParcial(listaClassesInt, listaClasses, listaTestSmells, graph1, filtro, coluna, @@ -631,8 +631,8 @@ private static void CriaGrafoParcial(List listaClassesInt, List listaClasses, St } private static void CriaGrafoMetodos(List listaClassesInt, List listaClasses, String[] cabecalho, Graph graph1, - String nome, String classe, int coluna, String file, List listaMetodosClasse) - throws IOException { + String nome, String classe, int coluna, String file, List listaMetodosClasse, String metodoFiltro) throws IOException { + System.out.println(metodoFiltro); List l = retornaDados(file, "All Test Classes"); for (int i = 0; i < listaClassesInt.size(); i++) { int[] linhaInt = (int[]) listaClassesInt.get(i); @@ -650,7 +650,7 @@ private static void CriaGrafoMetodos(List listaClassesInt, List listaClasses, St // n1.setAttribute("layout.weight", 10); n1.setAttribute("edges", "layout.weight:4"); - for (int j = 10; j < linhaInt.length; j++) { + for (int j = 9; j < linhaInt.length; j++) { if (linhaInt[j] != 0) { if (classe.equals(linha[coluna]) && nome.equals(cabecalho[j])) { try { @@ -667,18 +667,20 @@ private static void CriaGrafoMetodos(List listaClassesInt, List listaClasses, St if (graph1.getEdgeCount() > 0) { for (ClassMethod obj : listaMetodosClasse) { for (MethodData metodo : obj.metodos) { - try { - graph1.addNode(metodo.metodo); - Node n1 = graph1.getNode(metodo.metodo); - n1.setAttribute("ui.label", metodo.metodo + "," + metodo.begin + "-" + metodo.end); - n1.addAttribute("ui.class", "metodo"); - double x = (Math.random() * ((1000000) + 1) + 1000000); - double y = (Math.random() * ((1000000) + 1) + 1000000); - n1.setAttribute("x", x); - n1.setAttribute("y", y); - if (obj.classe.equals(classe)) - graph1.addEdge(metodo.metodo, obj.classe, metodo.metodo); - } catch (Exception e) { + if (obj.classe.equals(classe)) { + try { + graph1.addNode(metodo.metodo); + Node n1 = graph1.getNode(metodo.metodo); + n1.setAttribute("ui.label", metodo.metodo + "," + metodo.begin + "-" + metodo.end); + n1.addAttribute("ui.class", "metodo"); + double x = (Math.random() * ((1000000) + 1) + 1000000); + double y = (Math.random() * ((1000000) + 1) + 1000000); + n1.setAttribute("x", x); + n1.setAttribute("y", y); + if (metodo.metodo.equals(metodoFiltro)) + graph1.addEdge(metodo.metodo, obj.classe, metodo.metodo); + } catch (Exception e) { + } } } } diff --git a/TSVizzEvolution/src/tsvizzevolution/GraphTwoVersions.java b/TSVizzEvolution/src/tsvizzevolution/GraphTwoVersions.java index ab29687..0a69139 100644 --- a/TSVizzEvolution/src/tsvizzevolution/GraphTwoVersions.java +++ b/TSVizzEvolution/src/tsvizzevolution/GraphTwoVersions.java @@ -376,7 +376,7 @@ private void btnChooseFileSearch1ActionPerformed(ActionEvent evt) { if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); txtFilePathDefault1.setText(file.getPath()); - txtFilePathDefault1.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\resultado_evolution1.csv"); + //txtFilePathDefault1.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\resultado_evolution1.csv"); nomeDoArquivo = file.getName(); } } @@ -387,7 +387,7 @@ private void btnChooseFileSearch2ActionPerformed(ActionEvent evt) throws IOExcep if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); txtFilePathDefault2.setText(file.getPath()); - txtFilePathDefault2.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\resultado_evolution1.csv"); + //txtFilePathDefault2.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\resultado_evolution1.csv"); nomeDoArquivo = file.getName(); btnGerarUploadActionPerformed(evt); } @@ -399,7 +399,7 @@ private void btnSearchMethodActionPerformed(ActionEvent evt) { if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); txtFilePathMethod.setText(file.getPath()); - txtFilePathMethod.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\commons-io_result_byclasstest_testsmells.csv"); + //txtFilePathMethod.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\commons-io_result_byclasstest_testsmells.csv"); nomeDoArquivo = file.getName(); } } @@ -410,7 +410,7 @@ private void btnSearchMethod2ActionPerformed(ActionEvent evt) throws IOException if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); txtFilePathMethod2.setText(file.getPath()); - txtFilePathMethod2.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\commons-io_result_byclasstest_testsmells.csv"); + //txtFilePathMethod2.setText("C:\\Users\\T-GAMER\\IdeaProjects\\teste\\src\\tsvizzevolution\\commons-io_result_byclasstest_testsmells.csv"); nomeDoArquivo = file.getName(); List l = retorna_lista_classe_metodo(); List list = new ArrayList<>(); @@ -800,8 +800,8 @@ public void run(){ }else if (true){ String testSmell = (String) cbTestSmells.getSelectedItem(); String classe = (String) cbClass.getSelectedItem(); - CriaGrafoMetodos(listaDeLinhasInt, listaDeLinhas, cabecalhoLista, graph1, testSmell, classe, coluna, 1, txtFilePathDefault1.getText(), l1, listaMetodosClasse1); - CriaGrafoMetodos(listaDeLinhasInt2, listaDeLinhas2, cabecalhoLista2, graph1, testSmell, classe, coluna, 2, txtFilePathDefault1.getText(), l2, listaMetodosClasse2); + CriaGrafoMetodos(listaDeLinhasInt, listaDeLinhas, cabecalhoLista, graph1, testSmell, classe, coluna, 1, txtFilePathDefault1.getText(), l1, listaMetodosClasse1, (String) cbSelectMethod.getSelectedItem()); + CriaGrafoMetodos(listaDeLinhasInt2, listaDeLinhas2, cabecalhoLista2, graph1, testSmell, classe, coluna, 2, txtFilePathDefault1.getText(), l2, listaMetodosClasse2, (String) cbSelectMethod.getSelectedItem()); }else{ filtro = (String) cbTestSmells.getSelectedItem(); CriaGrafoParcial(listaDeLinhasInt, listaDeLinhas, cabecalhoLista, graph1, filtro, coluna, 1, txtFilePathDefault1.getText(), l1); @@ -1141,7 +1141,7 @@ private static void CriaGrafoParcial(List listaDeLinhasInt, List listaDeLinhas, } } - private static void CriaGrafoMetodos(List listaClassesInt, List listaClasses, String[] cabecalho, Graph graph1, String nome, String classe, int coluna, int flag, String file, List l, List listaMetodosClasse) throws IOException { + private static void CriaGrafoMetodos(List listaClassesInt, List listaClasses, String[] cabecalho, Graph graph1, String nome, String classe, int coluna, int flag, String file, List l, List listaMetodosClasse, String metodoFiltro) throws IOException { String complemento = ""; if (flag == 1){ complemento = "_1"; @@ -1180,19 +1180,20 @@ private static void CriaGrafoMetodos(List listaClassesInt, List listaClasses, St if (graph1.getEdgeCount() > 0) { for (ClassMethod obj : listaMetodosClasse) { for (MethodData metodo : obj.metodos) { - try { - graph1.addNode(metodo.metodo + complemento); - Node n1 = graph1.getNode(metodo.metodo + complemento); - n1.setAttribute("ui.label", metodo.metodo+ complemento + "," + metodo.begin + "-" + metodo.end); - n1.addAttribute("ui.class", "metodo"); - double x = (Math.random() * ((1000000) + 1) + 1000000); - double y = (Math.random() * ((1000000) + 1) + 1000000); - n1.setAttribute("x", x); - n1.setAttribute("y", y); - if (obj.classe.equals(classe)){ - graph1.addEdge(metodo.metodo + complemento, obj.classe + complemento, metodo.metodo + complemento); + if (obj.classe.equals(classe)) { + try { + graph1.addNode(metodo.metodo + complemento); + Node n1 = graph1.getNode(metodo.metodo + complemento); + n1.setAttribute("ui.label", metodo.metodo+ complemento + "," + metodo.begin + "-" + metodo.end); + n1.addAttribute("ui.class", "metodo"); + double x = (Math.random() * ((1000000) + 1) + 1000000); + double y = (Math.random() * ((1000000) + 1) + 1000000); + n1.setAttribute("x", x); + n1.setAttribute("y", y); + if (metodo.metodo.equals(metodoFiltro)) + graph1.addEdge(metodo.metodo + complemento, obj.classe + complemento, metodo.metodo + complemento); + } catch (Exception e) { } - } catch (Exception e) { } } }