use of com.android.tools.adtui.model.Range in project android by JetBrains.
the class ProfilerScrollbar method animate.
@Override
public void animate(float frameLength) {
Range dataRangeUs = myTimeline.getDataRange();
Range viewRangeUs = myTimeline.getViewRange();
int dataExtentMs = (int) ((dataRangeUs.getLength() - myTimeline.getViewBuffer()) / MS_TO_US);
int viewExtentMs = Math.min(dataExtentMs, (int) (viewRangeUs.getLength() / MS_TO_US));
int viewRelativeMinMs = Math.max(0, (int) ((viewRangeUs.getMin() - dataRangeUs.getMin()) / MS_TO_US));
if (myScrolling) {
int valueMs = getValue();
setValues(valueMs, viewExtentMs, 0, dataExtentMs);
double deltaUs = (valueMs - viewRelativeMinMs) * MS_TO_US;
viewRangeUs.shift(deltaUs);
} else {
setValues(viewRelativeMinMs, viewExtentMs, 0, dataExtentMs);
}
}
use of com.android.tools.adtui.model.Range in project android by JetBrains.
the class CpuMonitorView method populateUi.
@Override
protected void populateUi(JPanel container, Choreographer choreographer) {
container.setLayout(new TabularLayout("*", "*"));
Range viewRange = getMonitor().getTimeline().getViewRange();
Range dataRange = getMonitor().getTimeline().getDataRange();
final JLabel label = new JLabel(getMonitor().getName());
label.setBorder(MONITOR_LABEL_PADDING);
label.setVerticalAlignment(JLabel.TOP);
// Cpu usage is shown as percentages (e.g. 0 - 100) and no range animation is needed.
Range leftYRange = new Range(0, 100);
final JPanel axisPanel = new JBPanel(new BorderLayout());
axisPanel.setOpaque(false);
AxisComponent.Builder builder = new AxisComponent.Builder(leftYRange, CPU_USAGE_AXIS, AxisComponent.AxisOrientation.RIGHT).showAxisLine(false).showMax(true).showUnitAtMax(true).setMarkerLengths(MARKER_LENGTH, MARKER_LENGTH).clampToMajorTicks(true).setMargins(0, Y_AXIS_TOP_MARGIN);
final AxisComponent leftAxis = builder.build();
axisPanel.add(leftAxis, BorderLayout.WEST);
final JPanel lineChartPanel = new JBPanel(new BorderLayout());
lineChartPanel.setOpaque(false);
lineChartPanel.setBorder(BorderFactory.createEmptyBorder(Y_AXIS_TOP_MARGIN, 0, 0, 0));
final LineChart lineChart = new LineChart();
RangedContinuousSeries cpuSeries = new RangedContinuousSeries("CPU", viewRange, leftYRange, getMonitor().getThisProcessCpuUsage());
lineChart.addLine(cpuSeries, new LineConfig(ProfilerColors.CPU_USAGE).setFilled(true));
lineChartPanel.add(lineChart, BorderLayout.CENTER);
final LegendComponent legend = new LegendComponent(LegendComponent.Orientation.HORIZONTAL, LEGEND_UPDATE_FREQUENCY_MS);
legend.setLegendData(Collections.singletonList(lineChart.createLegendRenderData(cpuSeries, CPU_USAGE_AXIS, dataRange)));
final JPanel legendPanel = new JBPanel(new BorderLayout());
legendPanel.setOpaque(false);
legendPanel.add(label, BorderLayout.WEST);
legendPanel.add(legend, BorderLayout.EAST);
choreographer.register(lineChart);
choreographer.register(leftAxis);
choreographer.register(legend);
container.add(legendPanel, new TabularLayout.Constraint(0, 0));
container.add(leftAxis, new TabularLayout.Constraint(0, 0));
container.add(lineChartPanel, new TabularLayout.Constraint(0, 0));
container.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
getMonitor().expand();
}
});
}
use of com.android.tools.adtui.model.Range in project android by JetBrains.
the class CpuProfilerStageView method formatCaptureLabel.
private String formatCaptureLabel(CpuCapture capture) {
Range range = getStage().getStudioProfilers().getTimeline().getDataRange();
long min = (long) (capture.getRange().getMin() - range.getMin());
long max = (long) (capture.getRange().getMax() - range.getMin());
return formatTime(min) + " - " + formatTime(max);
}
use of com.android.tools.adtui.model.Range in project android by JetBrains.
the class ThreadCallsVisualTest method actionPerformed.
/**
* Invoked when an action occurs.
*/
@Override
public void actionPerformed(ActionEvent e) {
if (ACTION_START_RECORDING.equals(e.getActionCommand())) {
if (mSampler == null) {
mSampler = new Sampler();
}
mSampler.startSampling();
mRecordButton.setActionCommand(ACTION_STOP_RECORDING);
mRecordButton.setText("Stop Recording");
} else if (ACTION_STOP_RECORDING.equals(e.getActionCommand())) {
mSampler.stopSampling();
mRecordButton.setActionCommand(ACTION_START_RECORDING);
mRecordButton.setText("Record");
setData(mSampler.getData());
} else if (ACTION_SAVE_RECORDING.equals(e.getActionCommand())) {
} else if (ACTION_LOAD_RECORDING.equals(e.getActionCommand())) {
} else if (ACTION_THREAD_SELECTED.equals(e.getActionCommand())) {
int selected = mComboBox.getSelectedIndex();
if (selected >= 0 && selected < mComboBox.getItemCount()) {
String threadName = (String) mComboBox.getSelectedItem();
mtree = forest.get(threadName);
mChart.setHTree(mtree);
double start = mtree.getFirstChild().getStart();
double end = mtree.getLastChild().getEnd();
mTimeGlobalRangeUs.setMin(start);
mTimeGlobalRangeUs.setMax(end);
mTimeSelectionRangeUs.setMin(start);
mTimeSelectionRangeUs.setMax(end);
// Generate dummy values to simulate CPU Load.
LongDataSeries series = new LongDataSeries();
RangedContinuousSeries rangedSeries = new RangedContinuousSeries("Threads", mTimeGlobalRangeUs, new Range(0.0, 200.0), series);
Random r = new Random(System.currentTimeMillis());
for (int i = 0; i < 100; i++) {
series.add((long) (start + (end - start) / 100 * i), (long) r.nextInt(100));
}
mLineChart.addLine(rangedSeries);
mScrollBar.setValues(0, mChart.getHeight(), 0, mChart.getMaximumHeight());
}
}
}
use of com.android.tools.adtui.model.Range in project android by JetBrains.
the class NetworkProfilerVisualTest method createComponentsList.
@Override
protected List<Animatable> createComponentsList() {
long startTimeUs = myDataStore.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);
mySegment = new NetworkSegment(timeCurrentRangeUs, myDataStore, dummyDispatcher);
myDetailedView = new NetworkDetailedView();
myDetailedView.setVisible(false);
generateNetworkCaptureData(startTimeUs);
myCaptureSegment = new NetworkCaptureSegment(timeCurrentRangeUs, new TestNetworkCaptureModel(), httpData -> myDetailedView.setVisible(true), dummyDispatcher);
myRadioSegment = new NetworkRadioSegment(timeCurrentRangeUs, myDataStore, dummyDispatcher);
List<Animatable> animatables = new ArrayList<>();
animatables.add(animatedTimeRange);
mySegment.createComponentsList(animatables);
myCaptureSegment.createComponentsList(animatables);
myRadioSegment.createComponentsList(animatables);
animatables.add(myCaptureSegment);
return animatables;
}
Aggregations