use of com.android.tools.adtui.TabularLayout 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.TabularLayout in project android by JetBrains.
the class MemoryMonitorView 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);
Range leftYRange = new Range(0, 0);
final JPanel axisPanel = new JBPanel(new BorderLayout());
axisPanel.setOpaque(false);
AxisComponent.Builder builder = new AxisComponent.Builder(leftYRange, MEMORY_AXIS_FORMATTER, AxisComponent.AxisOrientation.RIGHT).showAxisLine(false).showMax(true).showUnitAtMax(true).clampToMajorTicks(true).setMarkerLengths(MARKER_LENGTH, MARKER_LENGTH).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 memSeries = new RangedContinuousSeries("Memory", viewRange, leftYRange, getMonitor().getTotalMemory());
lineChart.addLine(memSeries, new LineConfig(ProfilerColors.MEMORY_TOTAL).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(memSeries, MEMORY_AXIS_FORMATTER, 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();
}
});
}
Aggregations