Search in sources :

Example 6 with ClassNode

use of com.google.classyshark.silverghost.methodscounter.ClassNode in project android-classyshark by google.

the class MethodsCountPanel method setup.

private void setup() {
    this.setLayout(new BorderLayout());
    treeModel = new DefaultTreeModel(new DefaultMutableTreeNode(null));
    jTree = new JTree(treeModel);
    jTree.setRootVisible(false);
    jTree.setCellRenderer(new CellRenderer());
    theme.applyTo(jTree);
    DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) jTree.getCellRenderer();
    cellRenderer.setFont(new Font("Menlo", Font.PLAIN, 18));
    jTree.setCellRenderer(cellRenderer);
    jTree.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent e) {
            Object selection = jTree.getLastSelectedPathComponent();
            DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode) selection;
            ClassNode node = (ClassNode) defaultMutableTreeNode.getUserObject();
            viewerController.onSelectedMethodCount(node);
        }
    });
    JScrollPane jScrollPane = new JScrollPane(jTree);
    this.setBorder(new EmptyBorder(0, 0, 0, 0));
    this.add(jScrollPane, BorderLayout.CENTER);
    theme.applyTo(jScrollPane);
    jTree.setDragEnabled(true);
    jTree.setTransferHandler(new FileTransferHandler(viewerController));
}
Also used : JScrollPane(javax.swing.JScrollPane) ClassNode(com.google.classyshark.silverghost.methodscounter.ClassNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CellRenderer(com.google.classyshark.gui.panel.tree.CellRenderer) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) TreeSelectionListener(javax.swing.event.TreeSelectionListener) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) FileTransferHandler(com.google.classyshark.gui.panel.FileTransferHandler) DefaultTreeCellRenderer(javax.swing.tree.DefaultTreeCellRenderer) Font(java.awt.Font) JTree(javax.swing.JTree) BorderLayout(java.awt.BorderLayout) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) EmptyBorder(javax.swing.border.EmptyBorder)

Example 7 with ClassNode

use of com.google.classyshark.silverghost.methodscounter.ClassNode in project android-classyshark by google.

the class FlatMethodCountExporter method printNode.

private void printNode(ClassNode classNode, String[] path) {
    for (String p : path) {
        pw.print(p);
        pw.print('.');
    }
    pw.println(classNode.getKey() + " - " + classNode.getMethodCount());
    Iterator<ClassNode> it = classNode.getChildNodes().values().iterator();
    String[] newPath = new String[path.length + 1];
    System.arraycopy(path, 0, newPath, 0, path.length);
    newPath[newPath.length - 1] = classNode.getKey();
    while (it.hasNext()) {
        ClassNode child = it.next();
        printNode(child, newPath);
    }
}
Also used : ClassNode(com.google.classyshark.silverghost.methodscounter.ClassNode)

Example 8 with ClassNode

use of com.google.classyshark.silverghost.methodscounter.ClassNode in project android-classyshark by google.

the class TreeMethodCountExporter method printNode.

private void printNode(ClassNode classNode, boolean[] isFinalLevel) {
    renderTreeStructure(isFinalLevel);
    pw.println(classNode.getKey() + " - " + classNode.getMethodCount());
    Iterator<ClassNode> it = classNode.getChildNodes().values().iterator();
    boolean[] isFinalLevel2 = new boolean[isFinalLevel.length + 1];
    System.arraycopy(isFinalLevel, 0, isFinalLevel2, 0, isFinalLevel.length);
    while (it.hasNext()) {
        ClassNode child = it.next();
        isFinalLevel2[isFinalLevel2.length - 1] = !it.hasNext();
        printNode(child, isFinalLevel2);
    }
}
Also used : ClassNode(com.google.classyshark.silverghost.methodscounter.ClassNode)

Aggregations

ClassNode (com.google.classyshark.silverghost.methodscounter.ClassNode)8 RootBuilder (com.google.classyshark.silverghost.methodscounter.RootBuilder)2 File (java.io.File)2 PrintWriter (java.io.PrintWriter)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 FileTransferHandler (com.google.classyshark.gui.panel.FileTransferHandler)1 CellRenderer (com.google.classyshark.gui.panel.tree.CellRenderer)1 FlatMethodCountExporter (com.google.classyshark.silverghost.exporter.FlatMethodCountExporter)1 MethodCountExporter (com.google.classyshark.silverghost.exporter.MethodCountExporter)1 TreeMethodCountExporter (com.google.classyshark.silverghost.exporter.TreeMethodCountExporter)1 BorderLayout (java.awt.BorderLayout)1 Color (java.awt.Color)1 Font (java.awt.Font)1 AffineTransform (java.awt.geom.AffineTransform)1 IOException (java.io.IOException)1 RandomAccessFile (java.io.RandomAccessFile)1 ArrayList (java.util.ArrayList)1 JScrollPane (javax.swing.JScrollPane)1 JTree (javax.swing.JTree)1 EmptyBorder (javax.swing.border.EmptyBorder)1