use of com.android.tools.adtui.model.LongDataSeries in project android by JetBrains.
the class AxisLineChartVisualTest method createComponentsList.
@Override
protected List<Animatable> createComponentsList() {
mRangedData = new ArrayList<>();
mData = new ArrayList<>();
mLineChart = new LineChart();
mStartTimeUs = TimeUnit.NANOSECONDS.toMicros(System.nanoTime());
final Range timeCurrentRangeUs = new Range(0, 0);
mTimeGlobalRangeUs = new Range(0, 0);
mAnimatedTimeRange = new AnimatedTimeRange(mTimeGlobalRangeUs, mStartTimeUs);
mScrollbar = new RangeScrollbar(mTimeGlobalRangeUs, timeCurrentRangeUs);
// add horizontal time axis
AxisComponent.Builder builder = new AxisComponent.Builder(timeCurrentRangeUs, TimeAxisFormatter.DEFAULT, AxisComponent.AxisOrientation.BOTTOM).setGlobalRange(mTimeGlobalRangeUs).setMargins(AXIS_SIZE, AXIS_SIZE);
mTimeAxis = builder.build();
// left memory data + axis
Range yRange1Animatable = new Range(0, 100);
builder = new AxisComponent.Builder(yRange1Animatable, MemoryAxisFormatter.DEFAULT, AxisComponent.AxisOrientation.LEFT).setLabel(SERIES1_LABEL).showMax(true).showUnitAtMax(true).setMargins(AXIS_SIZE, AXIS_SIZE);
mMemoryAxis1 = builder.build();
LongDataSeries series1 = new LongDataSeries();
RangedContinuousSeries ranged1 = new RangedContinuousSeries(SERIES1_LABEL, timeCurrentRangeUs, yRange1Animatable, series1);
mRangedData.add(ranged1);
mData.add(series1);
// right memory data + axis
Range yRange2Animatable = new Range(0, 100);
builder = new AxisComponent.Builder(yRange2Animatable, MemoryAxisFormatter.DEFAULT, AxisComponent.AxisOrientation.RIGHT).setLabel(SERIES2_LABEL).showMax(true).showUnitAtMax(true).setMargins(AXIS_SIZE, AXIS_SIZE);
mMemoryAxis2 = builder.build();
LongDataSeries series2 = new LongDataSeries();
RangedContinuousSeries ranged2 = new RangedContinuousSeries(SERIES2_LABEL, timeCurrentRangeUs, yRange2Animatable, series2);
mRangedData.add(ranged2);
mData.add(series2);
mLineChart.addLines(mRangedData);
List<LegendRenderData> legendRenderInfo = new ArrayList<>();
//Test the populated series case
legendRenderInfo.add(mLineChart.createLegendRenderData(mRangedData.get(0), MemoryAxisFormatter.DEFAULT, mTimeGlobalRangeUs));
//Test the null series case
legendRenderInfo.add(new LegendRenderData(LegendRenderData.IconType.LINE, LineConfig.getColor(1), SERIES2_LABEL));
mLegendComponent = new LegendComponent(LegendComponent.Orientation.VERTICAL, LABEL_UPDATE_MILLIS);
mLegendComponent.setLegendData(legendRenderInfo);
mGrid = new GridComponent();
mGrid.addAxis(mTimeAxis);
mGrid.addAxis(mMemoryAxis1);
final AnimatedRange timeSelectionRangeUs = new AnimatedRange();
mSelection = new SelectionComponent(timeSelectionRangeUs, timeCurrentRangeUs);
// The comment on each line highlights why the component needs to be in that position.
return // Update global time range immediate.
Arrays.asList(// Update global time range immediate.
mAnimatedTimeRange, // Update selection range immediate.
mSelection, // Update current range immediate.
mScrollbar, // Set y's interpolation values.
mLineChart, // Clamp/interpolate ranges to major ticks if enabled.
mMemoryAxis1, // Sync with mMemoryAxis1 if enabled.
mMemoryAxis2, // Read ranges.
mTimeAxis, // No-op.
mGrid, timeSelectionRangeUs, // Reset flags.
mLegendComponent);
}
Aggregations