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);
}
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);
}
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);
}
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;
}
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;
}
Aggregations