Search in sources :

Example 1 with StateChart

use of com.android.tools.adtui.chart.StateChart 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 StateChart

use of com.android.tools.adtui.chart.StateChart in project android by JetBrains.

the class NetworkRadioSegment method createComponentsList.

@Override
public void createComponentsList(@NotNull List<Animatable> animatables) {
    EnumMap<RadioState, Color> colorsMap = getRadioStateColor();
    EnumMap<RadioState, String> labelsMap = getRadioStateLabel();
    mRadioChart = new StateChart(colorsMap);
    mRadioChart.addSeries(new RangedSeries<>(myTimeCurrentRangeUs, new DataStoreSeries<>(mDataStore, SeriesDataType.NETWORK_RADIO)));
    mNetworkTypeChart = new StateChart<>(getNetworkTypeColor());
    mNetworkTypeChart.setRenderMode(StateChart.RenderMode.TEXT);
    mNetworkTypeChart.addSeries(new RangedSeries<>(myTimeCurrentRangeUs, new DataStoreSeries<>(mDataStore, SeriesDataType.NETWORK_TYPE)));
    List<LegendRenderData> legendRenderDataList = new ArrayList<>();
    for (RadioState state : RadioState.values()) {
        LegendRenderData renderData = new LegendRenderData(LegendRenderData.IconType.LINE, colorsMap.get(state), labelsMap.get(state));
        legendRenderDataList.add(renderData);
    }
    mLegendComponent = new LegendComponent(LegendComponent.Orientation.HORIZONTAL, 100);
    mLegendComponent.setLegendData(legendRenderDataList);
    animatables.add(mNetworkTypeChart);
    animatables.add(mRadioChart);
    animatables.add(mLegendComponent);
}
Also used : LegendRenderData(com.android.tools.adtui.LegendRenderData) JBColor(com.intellij.ui.JBColor) ArrayList(java.util.ArrayList) DataStoreSeries(com.android.tools.datastore.DataStoreSeries) LegendComponent(com.android.tools.adtui.LegendComponent) StateChart(com.android.tools.adtui.chart.StateChart)

Example 3 with StateChart

use of com.android.tools.adtui.chart.StateChart in project android by JetBrains.

the class StateChartReducerVisualTest method createComponentsList.

@Override
protected List<Animatable> createComponentsList() {
    myViewRange = new Range();
    myData = new DefaultDataSeries<>();
    RangedSeries<ColorState> series = new RangedSeries<>(myViewRange, myData);
    myColorChart = new StateChart<>(COLOR_STATE_COLORS, (rectangles, values) -> {
    });
    myColorChart.addSeries(series);
    myOptimizedColorChart = new StateChart<>(COLOR_STATE_COLORS);
    myOptimizedColorChart.addSeries(series);
    return Arrays.asList(myColorChart, myOptimizedColorChart);
}
Also used : ItemEvent(java.awt.event.ItemEvent) Range(com.android.tools.adtui.model.Range) Arrays(java.util.Arrays) DefaultDataSeries(com.android.tools.adtui.model.DefaultDataSeries) StateChart(com.android.tools.adtui.chart.StateChart) EnumMap(java.util.EnumMap) RangedSeries(com.android.tools.adtui.model.RangedSeries) Random(java.util.Random) AdtUiUtils(com.android.tools.adtui.common.AdtUiUtils) java.awt(java.awt) com.android.tools.adtui(com.android.tools.adtui) List(java.util.List) NotNull(org.jetbrains.annotations.NotNull) JBColor(com.intellij.ui.JBColor) javax.swing(javax.swing) Range(com.android.tools.adtui.model.Range) RangedSeries(com.android.tools.adtui.model.RangedSeries)

Example 4 with StateChart

use of com.android.tools.adtui.chart.StateChart in project android by JetBrains.

the class NetworkCaptureSegment method animate.

@Override
public void animate(float frameLength) {
    myDataList = myModel.getData(myTimeCurrentRangeUs);
    // TODO: currently we recreate charts from scratch, instead consider reusing charts
    myCharts.clear();
    for (HttpData data : myDataList) {
        DefaultDataSeries<NetworkState> series = new DefaultDataSeries<>();
        series.add(0, NetworkState.NONE);
        series.add(data.getStartTimeUs(), NetworkState.SENDING);
        if (data.getDownloadingTimeUs() > 0) {
            series.add(data.getDownloadingTimeUs(), NetworkState.RECEIVING);
        }
        if (data.getEndTimeUs() > 0) {
            series.add(data.getEndTimeUs(), NetworkState.NONE);
        }
        StateChart<NetworkState> chart = new StateChart<>(NETWORK_STATE_COLORS);
        chart.addSeries(new RangedSeries<>(myTimeCurrentRangeUs, series));
        chart.animate(frameLength);
        myCharts.add(chart);
    }
}
Also used : DefaultDataSeries(com.android.tools.adtui.model.DefaultDataSeries) HttpData(com.android.tools.idea.monitor.ui.network.model.HttpData) StateChart(com.android.tools.adtui.chart.StateChart)

Aggregations

StateChart (com.android.tools.adtui.chart.StateChart)4 DefaultDataSeries (com.android.tools.adtui.model.DefaultDataSeries)2 JBColor (com.intellij.ui.JBColor)2 com.android.tools.adtui (com.android.tools.adtui)1 AnimatedComponent (com.android.tools.adtui.AnimatedComponent)1 AxisComponent (com.android.tools.adtui.AxisComponent)1 LegendComponent (com.android.tools.adtui.LegendComponent)1 LegendRenderData (com.android.tools.adtui.LegendRenderData)1 AdtUiUtils (com.android.tools.adtui.common.AdtUiUtils)1 Range (com.android.tools.adtui.model.Range)1 RangedSeries (com.android.tools.adtui.model.RangedSeries)1 DataStoreSeries (com.android.tools.datastore.DataStoreSeries)1 HttpData (com.android.tools.idea.monitor.ui.network.model.HttpData)1 java.awt (java.awt)1 ComponentAdapter (java.awt.event.ComponentAdapter)1 ComponentEvent (java.awt.event.ComponentEvent)1 ItemEvent (java.awt.event.ItemEvent)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 EnumMap (java.util.EnumMap)1