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