src/tokenclustering/view/MainFrame.java
/**
     * Redesenha a arvore de tokens da tela.
     * @param tokens A nova lista de tokens.
     */
Redesenha a arvore de tokens da tela.
@param tokens A nova lista de tokens.
Redesenha a arvore de tokens da tela . @param tokens A nova lista de tokens .
public void refreshTokenTree(ArrayList<Token> tokens) {
        DefaultMutableTreeNode root = new DefaultMutableTreeNode("Tokens");
        TreeMap<String, TreeSet<Token>> clasifiedTokens = new TreeMap<String, TreeSet<Token>>();
        for (Token token : tokens) {
            String folder = token.getWidth() + "x" + token.getHeight();
            if (!clasifiedTokens.containsKey(folder)) {
                clasifiedTokens.put(folder, new TreeSet<Token>());
            }
            clasifiedTokens.get(folder).add(token);
        }
        for (String folder : clasifiedTokens.keySet()) {
            DefaultMutableTreeNode folderNode = new DefaultMutableTreeNode(folder);
            for (Token token : clasifiedTokens.get(folder)) {
                folderNode.add(new DefaultMutableTreeNode(token));
            }
            root.add(folderNode);
        }
        this.TokenTree.setModel(new DefaultTreeModel(root));
        for (int i = 0; i < this.TokenTree.getRowCount(); i++) {
            this.TokenTree.expandRow(i);
        }
    }
public void refreshTokenTree ( ArrayList < Token > tokens ) { DefaultMutableTreeNode root = new DefaultMutableTreeNode ( "Tokens" ) ; TreeMap < String , TreeSet < Token > > clasifiedTokens = new TreeMap < String , TreeSet < Token > > ( ) ; for ( Token token : tokens ) { String folder = token . getWidth ( ) + "x" + token . getHeight ( ) ; if ( ! clasifiedTokens . containsKey ( folder ) ) { clasifiedTokens . put ( folder , new TreeSet < Token > ( ) ) ; } clasifiedTokens . get ( folder ) . add ( token ) ; } for ( String folder : clasifiedTokens . keySet ( ) ) { DefaultMutableTreeNode folderNode = new DefaultMutableTreeNode ( folder ) ; for ( Token token : clasifiedTokens . get ( folder ) ) { folderNode . add ( new DefaultMutableTreeNode ( token ) ) ; } root . add ( folderNode ) ; } this . TokenTree . setModel ( new DefaultTreeModel ( root ) ) ; for ( int i = 0 ; i < this . TokenTree . getRowCount ( ) ; i ++ ) { this . TokenTree . expandRow ( i ) ; } }
Redesenha a arvore de tokens da tela.
Redesenha a arvore de tokens da tela .