Search in sources :

Example 1 with HprofBitmapProvider

use of com.android.tools.perflib.heap.memoryanalyzer.HprofBitmapProvider in project android by JetBrains.

the class ViewBitmapAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    ClassInstance selectedClassInstance = e.getData(InstancesTreeView.SELECTED_CLASS_INSTANCE);
    if (selectedClassInstance == null) {
        return;
    }
    try {
        BufferedImage img = BitmapDecoder.getBitmap(new HprofBitmapProvider(selectedClassInstance));
        final JComponent comp;
        if (img != null) {
            comp = ImageEditorManagerImpl.createImageEditorUI(img);
        } else {
            String errorMessage = AndroidBundle.message("android.profiler.hprof.actions.view.bitmap.fail");
            comp = new JLabel(errorMessage, Messages.getErrorIcon(), SwingConstants.CENTER);
        }
        Project project = e.getData(CommonDataKeys.PROJECT);
        JBPopup popup = DebuggerUIUtil.createValuePopup(project, comp, null);
        JFrame frame = WindowManager.getInstance().getFrame(project);
        Dimension frameSize = frame.getSize();
        Dimension size = new Dimension(frameSize.width / 2, frameSize.height / 2);
        popup.setSize(size);
        popup.show(new RelativePoint(frame, new Point(size.width / 2, size.height / 2)));
    } catch (Exception ignored) {
    }
}
Also used : RelativePoint(com.intellij.ui.awt.RelativePoint) RelativePoint(com.intellij.ui.awt.RelativePoint) BufferedImage(java.awt.image.BufferedImage) Project(com.intellij.openapi.project.Project) JBPopup(com.intellij.openapi.ui.popup.JBPopup) ClassInstance(com.android.tools.perflib.heap.ClassInstance) HprofBitmapProvider(com.android.tools.perflib.heap.memoryanalyzer.HprofBitmapProvider)

Aggregations

ClassInstance (com.android.tools.perflib.heap.ClassInstance)1 HprofBitmapProvider (com.android.tools.perflib.heap.memoryanalyzer.HprofBitmapProvider)1 Project (com.intellij.openapi.project.Project)1 JBPopup (com.intellij.openapi.ui.popup.JBPopup)1 RelativePoint (com.intellij.ui.awt.RelativePoint)1 BufferedImage (java.awt.image.BufferedImage)1