Search in sources :

Example 26 with Range

use of com.android.tools.adtui.model.Range in project android by JetBrains.

the class FlameGraphVisualTest method populateUi.

@Override
protected void populateUi(@NotNull JPanel mainPanel) {
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    JBPanel controlPanel = new JBPanel();
    controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.X_AXIS));
    JBPanel buttonsPanel = new JBPanel();
    buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.Y_AXIS));
    mRecordButton = new JButton("Record");
    mRecordButton.setActionCommand(ACTION_START_RECORDING);
    mRecordButton.addActionListener(this);
    buttonsPanel.add(mRecordButton);
    mLoadButton = new JButton("Load");
    mLoadButton.setActionCommand(ACTION_LOAD_RECORDING);
    mLoadButton.addActionListener(this);
    buttonsPanel.add(mLoadButton);
    mSaveButton = new JButton("Save");
    mSaveButton.setActionCommand(ACTION_SAVE_RECORDING);
    mSaveButton.addActionListener(this);
    buttonsPanel.add(mSaveButton);
    mComboBox = new JComboBox<String>(new String[0]) {

        @Override
        public Dimension getMaximumSize() {
            Dimension max = super.getMaximumSize();
            max.height = getPreferredSize().height;
            return max;
        }
    };
    mComboBox.addActionListener(this);
    mComboBox.setActionCommand(ACTION_THREAD_SELECTED);
    JBPanel viewControlPanel = new JBPanel();
    viewControlPanel.setLayout(new BoxLayout(viewControlPanel, BoxLayout.Y_AXIS));
    JLayeredPane mockTimelinePane = createMockTimeline();
    viewControlPanel.add(mockTimelinePane);
    viewControlPanel.add(mComboBox);
    controlPanel.add(buttonsPanel);
    controlPanel.add(viewControlPanel);
    mainPanel.add(controlPanel);
    JBPanel viewPanel = new JBPanel();
    viewPanel.setLayout(new BoxLayout(viewPanel, BoxLayout.X_AXIS));
    viewPanel.add(mChart);
    mScrollBar = new JScrollBar(JScrollBar.VERTICAL);
    mScrollBar.addAdjustmentListener(new AdjustmentListener() {

        @Override
        public void adjustmentValueChanged(AdjustmentEvent e) {
            Range yRange = mChart.getYRange();
            int yOffset = mChart.getMaximumHeight() - (e.getValue() + mScrollBar.getVisibleAmount());
            yRange.setMin(yOffset);
        }
    });
    viewPanel.add(mScrollBar);
    mainPanel.add(viewPanel);
}
Also used : Range(com.android.tools.adtui.model.Range) JBPanel(com.intellij.ui.components.JBPanel)

Example 27 with Range

use of com.android.tools.adtui.model.Range in project android by JetBrains.

the class ThreadCallsVisualTest method populateUi.

@Override
protected void populateUi(@NotNull JPanel mainPanel) {
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    JBPanel controlPanel = new JBPanel();
    controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.X_AXIS));
    JBPanel buttonsPanel = new JBPanel();
    buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.Y_AXIS));
    mRecordButton = new JButton("Record");
    mRecordButton.setActionCommand(ACTION_START_RECORDING);
    mRecordButton.addActionListener(this);
    buttonsPanel.add(mRecordButton);
    mLoadButton = new JButton("Load");
    mLoadButton.setActionCommand(ACTION_LOAD_RECORDING);
    mLoadButton.addActionListener(this);
    buttonsPanel.add(mLoadButton);
    mSaveButton = new JButton("Save");
    mSaveButton.setActionCommand(ACTION_SAVE_RECORDING);
    mSaveButton.addActionListener(this);
    buttonsPanel.add(mSaveButton);
    mComboBox = new JComboBox<String>(new String[0]) {

        @Override
        public Dimension getMaximumSize() {
            Dimension max = super.getMaximumSize();
            max.height = getPreferredSize().height;
            return max;
        }
    };
    mComboBox.addActionListener(this);
    mComboBox.setActionCommand(ACTION_THREAD_SELECTED);
    JBPanel viewControlPanel = new JBPanel();
    viewControlPanel.setLayout(new BoxLayout(viewControlPanel, BoxLayout.Y_AXIS));
    JLayeredPane mockTimelinePane = createMockTimeline();
    viewControlPanel.add(mockTimelinePane);
    viewControlPanel.add(mComboBox);
    controlPanel.add(buttonsPanel);
    controlPanel.add(viewControlPanel);
    mainPanel.add(controlPanel);
    JBPanel viewPanel = new JBPanel();
    viewPanel.setLayout(new BoxLayout(viewPanel, BoxLayout.X_AXIS));
    viewPanel.add(mChart);
    mScrollBar = new JScrollBar(JScrollBar.VERTICAL);
    mScrollBar.addAdjustmentListener(e -> {
        Range yRange = mChart.getYRange();
        int yOffset = e.getValue();
        yRange.setMin(yOffset);
    });
    viewPanel.add(mScrollBar);
    mainPanel.add(viewPanel);
}
Also used : Range(com.android.tools.adtui.model.Range) JBPanel(com.intellij.ui.components.JBPanel)

Example 28 with Range

use of com.android.tools.adtui.model.Range in project android by JetBrains.

the class LineChartLegendRenderData method getFormattedData.

@Override
public String getFormattedData() {
    double time = myRange.getMax();
    ImmutableList<SeriesData<Long>> data = mySeries.getDataSeries().getDataForXRange(new Range(time, time));
    if (data.isEmpty()) {
        return null;
    }
    SeriesData<Long> key = new SeriesData<>(TimeUnit.MICROSECONDS.toNanos((long) time), 0L);
    int index = Collections.binarySearch(data, key, (left, right) -> {
        long diff = left.x - right.x;
        return (diff == 0) ? 0 : (diff < 0) ? -1 : 1;
    });
    // This returns the data to the right given no exact match.
    index = index >= 0 ? index : -(index + 1);
    index = Math.max(0, Math.min(data.size() - 1, index));
    return myFormatter.getFormattedString(mySeries.getYRange().getLength(), data.get(index).value, true);
}
Also used : SeriesData(com.android.tools.adtui.model.SeriesData) Range(com.android.tools.adtui.model.Range)

Example 29 with Range

use of com.android.tools.adtui.model.Range in project android by JetBrains.

the class CpuProfilerVisualTest method createComponentsList.

@Override
protected List<Animatable> createComponentsList() {
    long startTimeUs = mDataStore.getLatestTimeUs();
    Range timeCurrentRangeUs = new Range(startTimeUs - RangeScrollbar.DEFAULT_VIEW_LENGTH_US, startTimeUs);
    AnimatedTimeRange animatedTimeRange = new AnimatedTimeRange(timeCurrentRangeUs, 0);
    //TODO Update test data for CpuUsageSegment to be exactly what it was.
    EventDispatcher<ProfilerEventListener> dummyDispatcher = EventDispatcher.create(ProfilerEventListener.class);
    mCPULevel2Segment = new CpuUsageSegment(timeCurrentRangeUs, mDataStore, dummyDispatcher);
    mThreadsSegment = new ThreadsSegment(timeCurrentRangeUs, mDataStore, dummyDispatcher, (threads) -> {
    // TODO: show L3 segment with the charts corresponding to threads selected.
    // Hide any charts corresponding to unselected threads and hide L3 segment in case no threads are selected
    });
    List<Animatable> animatables = new ArrayList<>();
    animatables.add(animatedTimeRange);
    animatables.add(mThreadsSegment);
    mCPULevel2Segment.createComponentsList(animatables);
    mThreadsSegment.createComponentsList(animatables);
    return animatables;
}
Also used : AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) ThreadsSegment(com.android.tools.idea.monitor.ui.cpu.view.ThreadsSegment) ThreadStateDataSeries(com.android.tools.profilers.cpu.ThreadStateDataSeries) Range(com.android.tools.adtui.model.Range) CpuUsageSegment(com.android.tools.idea.monitor.ui.cpu.view.CpuUsageSegment) EventDispatcher(com.intellij.util.EventDispatcher) Animatable(com.android.tools.adtui.Animatable) AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) ProfilerEventListener(com.android.tools.idea.monitor.tool.ProfilerEventListener) RangeScrollbar(com.android.tools.adtui.RangeScrollbar) ArrayList(java.util.ArrayList) java.awt(java.awt) TimeUnit(java.util.concurrent.TimeUnit) VisualTest(com.android.tools.adtui.visualtests.VisualTest) List(java.util.List) SeriesData(com.android.tools.adtui.model.SeriesData) ThreadsSegment(com.android.tools.idea.monitor.ui.cpu.view.ThreadsSegment) TestDataGenerator(com.android.tools.idea.monitor.ui.visual.data.TestDataGenerator) CpuProfiler(com.android.tools.profiler.proto.CpuProfiler) SeriesDataType(com.android.tools.datastore.SeriesDataType) NotNull(org.jetbrains.annotations.NotNull) SeriesDataStore(com.android.tools.datastore.SeriesDataStore) javax.swing(javax.swing) CpuUsageSegment(com.android.tools.idea.monitor.ui.cpu.view.CpuUsageSegment) ArrayList(java.util.ArrayList) Animatable(com.android.tools.adtui.Animatable) ProfilerEventListener(com.android.tools.idea.monitor.tool.ProfilerEventListener) Range(com.android.tools.adtui.model.Range) AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange)

Example 30 with Range

use of com.android.tools.adtui.model.Range in project android by JetBrains.

the class MemoryProfilerVisualTest method createComponentsList.

@Override
protected List<Animatable> createComponentsList() {
    long startTimeUs = mDataStore.getLatestTimeUs();
    Range timeCurrentRangeUs = new Range(startTimeUs - RangeScrollbar.DEFAULT_VIEW_LENGTH_US, startTimeUs);
    AnimatedTimeRange animatedTimeRange = new AnimatedTimeRange(timeCurrentRangeUs, 0);
    EventDispatcher<ProfilerEventListener> dummyDispatcher = EventDispatcher.create(ProfilerEventListener.class);
    mSegment = new MemorySegment(timeCurrentRangeUs, mDataStore, dummyDispatcher);
    mRoot = new MemoryInfoTreeNode("Root");
    mDetailSegment = new MemoryDetailSegment(timeCurrentRangeUs, mRoot, dummyDispatcher);
    List<Animatable> animatables = new ArrayList<>();
    animatables.add(animatedTimeRange);
    mSegment.createComponentsList(animatables);
    mDetailSegment.createComponentsList(animatables);
    // Simulate allocation data with stack frames.
    mUpdateDataThread = new Thread() {

        @Override
        public void run() {
            try {
                while (true) {
                    updateTree(mRoot);
                    Thread.sleep(10);
                }
            } catch (InterruptedException e) {
            }
        }
    };
    mUpdateDataThread.start();
    return animatables;
}
Also used : AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) MemoryInfoTreeNode(com.android.tools.idea.monitor.ui.memory.model.MemoryInfoTreeNode) ArrayList(java.util.ArrayList) Range(com.android.tools.adtui.model.Range) AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) MemorySegment(com.android.tools.idea.monitor.ui.memory.view.MemorySegment) MemoryDetailSegment(com.android.tools.idea.monitor.ui.memory.view.MemoryDetailSegment) Animatable(com.android.tools.adtui.Animatable) ProfilerEventListener(com.android.tools.idea.monitor.tool.ProfilerEventListener)

Aggregations

Range (com.android.tools.adtui.model.Range)38 RangedContinuousSeries (com.android.tools.adtui.model.RangedContinuousSeries)12 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)10 JBPanel (com.intellij.ui.components.JBPanel)9 LineChart (com.android.tools.adtui.chart.linechart.LineChart)7 SeriesData (com.android.tools.adtui.model.SeriesData)7 LineConfig (com.android.tools.adtui.chart.linechart.LineConfig)6 NotNull (org.jetbrains.annotations.NotNull)6 java.awt (java.awt)5 javax.swing (javax.swing)5 Animatable (com.android.tools.adtui.Animatable)4 AnimatedTimeRange (com.android.tools.adtui.AnimatedTimeRange)4 DefaultDataSeries (com.android.tools.adtui.model.DefaultDataSeries)4 LongDataSeries (com.android.tools.adtui.model.LongDataSeries)4 List (java.util.List)4 com.android.tools.adtui (com.android.tools.adtui)3 SingleUnitAxisFormatter (com.android.tools.adtui.common.formatter.SingleUnitAxisFormatter)3 RangedSeries (com.android.tools.adtui.model.RangedSeries)3 ProfilerEventListener (com.android.tools.idea.monitor.tool.ProfilerEventListener)3