use of com.android.tools.adtui.common.ColumnTreeBuilder in project android by JetBrains.
the class AppTrace method generateBottomUpTree.
private JComponent generateBottomUpTree(HNode<MethodUsage> graph) {
AppStatTreeNode top = new AppStatTreeNode();
convertGraphToTree(graph, top);
JTree tree = new JTree(top);
JComponent bottomUpColumnTree = new ColumnTreeBuilder(tree).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Method").setRenderer(new ColoredTreeCellRenderer() {
@Override
public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
AppStatTreeNode node = (AppStatTreeNode) value;
append(generateNameForColumn(node.getMethodNamespace(), node.getMethodName(), getSeparator()));
}
})).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Exclusive stats").setRenderer(new ColoredTreeCellRenderer() {
@Override
public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
AppStatTreeNode node = (AppStatTreeNode) value;
append(String.format("%2.1f%%", node.getPercentageExclusive() * 100));
}
})).build();
return bottomUpColumnTree;
}
use of com.android.tools.adtui.common.ColumnTreeBuilder in project android by JetBrains.
the class ClassHistogramView method createComponentsList.
@Override
public void createComponentsList(@NotNull List<Animatable> animatables) {
myTreeModel = new DefaultTreeModel(myRoot);
myTree = new Tree(myTreeModel);
myTree.setRootVisible(false);
myTree.setShowsRootHandles(true);
ColumnTreeBuilder builder = new ColumnTreeBuilder(myTree).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Class").setHeaderAlignment(SwingConstants.LEFT).setRenderer(new MemoryInfoColumnRenderer(0, myRoot))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Count").setHeaderAlignment(SwingConstants.LEFT).setRenderer(new MemoryInfoColumnRenderer(1, myRoot)).setInitialOrder(SortOrder.DESCENDING).setComparator((MemoryInfoTreeNode a, MemoryInfoTreeNode b) -> a.getCount() - b.getCount()));
builder.setTreeSorter((Comparator<MemoryInfoTreeNode> comparator, SortOrder sortOrder) -> {
myRoot.sort(comparator);
myTreeModel.nodeStructureChanged(myRoot);
});
myColumnTree = builder.build();
}
use of com.android.tools.adtui.common.ColumnTreeBuilder in project android by JetBrains.
the class ApkViewPanel method createUIComponents.
private void createUIComponents() {
myNameAsyncIcon = new AsyncProcessIcon("aapt xmltree manifest");
mySizeAsyncIcon = new AsyncProcessIcon("estimating apk size");
myTreeModel = new DefaultTreeModel(new LoadingNode());
myTree = new Tree(myTreeModel);
myTree.setShowsRootHandles(true);
// show root node only when showing LoadingNode
myTree.setRootVisible(true);
myTree.setPaintBusy(true);
TreeSpeedSearch treeSpeedSearch = new TreeSpeedSearch(myTree, path -> {
ApkEntry e = ApkEntry.fromNode(path.getLastPathComponent());
if (e == null) {
return null;
}
return e.getPath();
}, true);
// Provides the percentage of the node size to the total size of the APK
PercentRenderer.PercentProvider percentProvider = (jTree, value, row) -> {
ApkEntry entry = ApkEntry.fromNode(value);
ApkEntry rootEntry = ApkEntry.fromNode(jTree.getModel().getRoot());
if (entry == null || rootEntry == null) {
return 0;
} else if (!entry.isCompressedSizeKnown() || !rootEntry.isCompressedSizeKnown()) {
return 0;
} else {
return (double) entry.getCompressedSize() / rootEntry.getCompressedSize();
}
};
ColumnTreeBuilder builder = new ColumnTreeBuilder(myTree).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("File").setPreferredWidth(600).setHeaderAlignment(SwingConstants.LEADING).setRenderer(new NameRenderer(treeSpeedSearch))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Raw File Size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new SizeRenderer(false))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Download Size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new SizeRenderer(true))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("% of Total Download size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.LEADING).setRenderer(new PercentRenderer(percentProvider)));
myColumnTreePane = (JScrollPane) builder.build();
myTree.addTreeSelectionListener(this);
}
use of com.android.tools.adtui.common.ColumnTreeBuilder in project android by JetBrains.
the class MemoryDetailSegment method createComponentsList.
@Override
public void createComponentsList(@NotNull List<Animatable> animatables) {
mTreeModel = new DefaultTreeModel(mRoot);
mTree = new Tree(mTreeModel);
mTree.setRootVisible(false);
mTree.setShowsRootHandles(true);
ColumnTreeBuilder builder = new ColumnTreeBuilder(mTree).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Class").setHeaderAlignment(SwingConstants.LEFT).setRenderer(new MemoryInfoColumnRenderer(0, mRoot))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Count").setHeaderAlignment(SwingConstants.LEFT).setRenderer(new MemoryInfoColumnRenderer(1, mRoot)).setInitialOrder(SortOrder.DESCENDING).setComparator((MemoryInfoTreeNode a, MemoryInfoTreeNode b) -> a.getCount() - b.getCount()));
builder.setTreeSorter((Comparator<MemoryInfoTreeNode> comparator, SortOrder sortOrder) -> {
mRoot.sort(comparator);
mTreeModel.nodeStructureChanged(mRoot);
});
mColumnTree = builder.build();
}
use of com.android.tools.adtui.common.ColumnTreeBuilder in project android by JetBrains.
the class ApkDiffPanel method createUIComponents.
private void createUIComponents() {
myTreeModel = new DefaultTreeModel(new LoadingNode());
myTree = new Tree(myTreeModel);
myTree.setShowsRootHandles(true);
// show root node only when showing LoadingNode
myTree.setRootVisible(true);
myTree.setPaintBusy(true);
Convertor<TreePath, String> convertor = new Convertor<TreePath, String>() {
@Override
public String convert(TreePath path) {
ApkEntry e = ApkEntry.fromNode(path.getLastPathComponent());
if (e == null) {
return null;
}
return e.getPath();
}
};
TreeSpeedSearch treeSpeedSearch = new TreeSpeedSearch(myTree, convertor, true);
ColumnTreeBuilder builder = new ColumnTreeBuilder(myTree).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("File").setPreferredWidth(600).setHeaderAlignment(SwingConstants.LEADING).setRenderer(new NameRenderer(treeSpeedSearch))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Old Size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new SizeRenderer(ApkDiffEntry::getOldSize))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("New Size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new SizeRenderer(ApkDiffEntry::getNewSize))).addColumn(new ColumnTreeBuilder.ColumnBuilder().setName("Diff Size").setPreferredWidth(150).setHeaderAlignment(SwingConstants.TRAILING).setRenderer(new SizeRenderer(ApkEntry::getSize)));
myColumnTreePane = (JScrollPane) builder.build();
}
Aggregations