Search in sources :

Example 1 with AxisComponent

use of com.android.tools.adtui.AxisComponent in project android by JetBrains.

the class StateChartVisualTest method createMockTimeline.

private JLayeredPane createMockTimeline() {
    JLayeredPane timelinePane = new JLayeredPane();
    timelinePane.add(mNetworkStatusChart);
    timelinePane.add(mRadioStateChart);
    timelinePane.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            JLayeredPane host = (JLayeredPane) e.getComponent();
            if (host != null) {
                Dimension dim = host.getSize();
                int numChart = 0;
                for (Component c : host.getComponents()) {
                    if (c instanceof AxisComponent) {
                        AxisComponent axis = (AxisComponent) c;
                        switch(axis.getOrientation()) {
                            case LEFT:
                                axis.setBounds(0, 0, AXIS_SIZE, dim.height);
                                break;
                            case BOTTOM:
                                axis.setBounds(0, dim.height - AXIS_SIZE, dim.width, AXIS_SIZE);
                                break;
                            case RIGHT:
                                axis.setBounds(dim.width - AXIS_SIZE, 0, AXIS_SIZE, dim.height);
                                break;
                            case TOP:
                                axis.setBounds(0, 0, dim.width, AXIS_SIZE);
                                break;
                        }
                    } else if (c instanceof StateChart) {
                        int y = numChart % 2 == 0 ? AXIS_SIZE : dim.height - AXIS_SIZE * 2;
                        c.setBounds(AXIS_SIZE, y, dim.width - AXIS_SIZE * 2, AXIS_SIZE);
                        numChart++;
                    }
                }
            }
        }
    });
    return timelinePane;
}
Also used : AxisComponent(com.android.tools.adtui.AxisComponent) ComponentEvent(java.awt.event.ComponentEvent) AxisComponent(com.android.tools.adtui.AxisComponent) AnimatedComponent(com.android.tools.adtui.AnimatedComponent) StateChart(com.android.tools.adtui.chart.StateChart) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 2 with AxisComponent

use of com.android.tools.adtui.AxisComponent in project android by JetBrains.

the class StageView method buildTimeAxis.

@NotNull
protected AxisComponent buildTimeAxis(StudioProfilers profilers) {
    AxisComponent.Builder builder = new AxisComponent.Builder(profilers.getTimeline().getViewRange(), TimeAxisFormatter.DEFAULT, AxisComponent.AxisOrientation.BOTTOM);
    builder.setGlobalRange(profilers.getDataRange()).showAxisLine(false).setOffset(profilers.getDeviceStartUs());
    AxisComponent timeAxis = builder.build();
    timeAxis.setMinimumSize(new Dimension(0, ProfilerLayout.TIME_AXIS_HEIGHT));
    timeAxis.setPreferredSize(new Dimension(Integer.MAX_VALUE, ProfilerLayout.TIME_AXIS_HEIGHT));
    return timeAxis;
}
Also used : AxisComponent(com.android.tools.adtui.AxisComponent) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with AxisComponent

use of com.android.tools.adtui.AxisComponent 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();
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) TabularLayout(com.android.tools.adtui.TabularLayout) MouseAdapter(java.awt.event.MouseAdapter) AxisComponent(com.android.tools.adtui.AxisComponent) Range(com.android.tools.adtui.model.Range) LineConfig(com.android.tools.adtui.chart.linechart.LineConfig) JBPanel(com.intellij.ui.components.JBPanel) RangedContinuousSeries(com.android.tools.adtui.model.RangedContinuousSeries) LegendComponent(com.android.tools.adtui.LegendComponent) LineChart(com.android.tools.adtui.chart.linechart.LineChart)

Example 4 with AxisComponent

use of com.android.tools.adtui.AxisComponent 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();
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) TabularLayout(com.android.tools.adtui.TabularLayout) MouseAdapter(java.awt.event.MouseAdapter) AxisComponent(com.android.tools.adtui.AxisComponent) Range(com.android.tools.adtui.model.Range) LineConfig(com.android.tools.adtui.chart.linechart.LineConfig) JBPanel(com.intellij.ui.components.JBPanel) RangedContinuousSeries(com.android.tools.adtui.model.RangedContinuousSeries) LegendComponent(com.android.tools.adtui.LegendComponent) LineChart(com.android.tools.adtui.chart.linechart.LineChart)

Aggregations

AxisComponent (com.android.tools.adtui.AxisComponent)4 LegendComponent (com.android.tools.adtui.LegendComponent)2 TabularLayout (com.android.tools.adtui.TabularLayout)2 LineChart (com.android.tools.adtui.chart.linechart.LineChart)2 LineConfig (com.android.tools.adtui.chart.linechart.LineConfig)2 Range (com.android.tools.adtui.model.Range)2 RangedContinuousSeries (com.android.tools.adtui.model.RangedContinuousSeries)2 JBPanel (com.intellij.ui.components.JBPanel)2 MouseAdapter (java.awt.event.MouseAdapter)2 MouseEvent (java.awt.event.MouseEvent)2 AnimatedComponent (com.android.tools.adtui.AnimatedComponent)1 StateChart (com.android.tools.adtui.chart.StateChart)1 ComponentAdapter (java.awt.event.ComponentAdapter)1 ComponentEvent (java.awt.event.ComponentEvent)1 NotNull (org.jetbrains.annotations.NotNull)1