use of com.android.tools.adtui.model.Range 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);
}
use of com.android.tools.adtui.model.Range in project android by JetBrains.
the class DataReducerVisualTest method createComponentsList.
@Override
protected List<Animatable> createComponentsList() {
myGlobalXRange = new Range(0, 0);
myViewXRange = new AnimatedRange();
mySelectionXRange = new AnimatedRange();
myYRange = new Range(0, 0);
myLineChart = new LineChart((shape, config) -> shape);
myOptimizedLineChart = new LineChart();
myXAxis = new AxisComponent.Builder(myViewXRange, new SingleUnitAxisFormatter(1, 5, 1, ""), AxisComponent.AxisOrientation.BOTTOM).build();
mySelection = new SelectionComponent(mySelectionXRange, myViewXRange);
myData = new DefaultDataSeries<>();
mySeries = new RangedContinuousSeries("Straight", myViewXRange, myYRange, myData);
myLineChart.addLine(mySeries, new LineConfig(JBColor.BLUE));
myOptimizedLineChart.addLine(mySeries, new LineConfig(JBColor.RED));
return Arrays.asList(myViewXRange, mySelectionXRange, myLineChart, myOptimizedLineChart, myXAxis, mySelection);
}
use of com.android.tools.adtui.model.Range in project android by JetBrains.
the class SelectionVisualTest method createComponentsList.
@Override
protected List<Animatable> createComponentsList() {
myRange = new Range(0, 1000);
mySelectionRange = new Range(100, 900);
mySelection = new SelectionComponent(mySelectionRange, myRange);
// Add the scene components to the list
List<Animatable> componentsList = new ArrayList<>();
componentsList.add(mySelection);
componentsList.add(frameLength -> {
myRangeMin.setText(String.valueOf(myRange.getMin()));
myRangeMax.setText(String.valueOf(myRange.getMax()));
mySelectionMin.setText(String.valueOf(mySelectionRange.getMin()));
mySelectionMax.setText(String.valueOf(mySelectionRange.getMax()));
});
return componentsList;
}
use of com.android.tools.adtui.model.Range 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.model.Range in project android by JetBrains.
the class StateChartVisualTest method createComponentsList.
@Override
protected List<Animatable> createComponentsList() {
long nowUs = TimeUnit.NANOSECONDS.toMicros(System.nanoTime());
mTimeGlobalRangeUs = new Range(nowUs, nowUs + TimeUnit.SECONDS.toMicros(60));
mAnimatedTimeRange = new AnimatedTimeRange(mTimeGlobalRangeUs, 0);
DefaultDataSeries<MockFruitState> networkSeries = new DefaultDataSeries<>();
DefaultDataSeries<MockStrengthState> radioSeries = new DefaultDataSeries<>();
RangedSeries<MockFruitState> networkData = new RangedSeries<>(mTimeGlobalRangeUs, networkSeries);
RangedSeries<MockStrengthState> radioData = new RangedSeries<>(mTimeGlobalRangeUs, radioSeries);
mNetworkStatusChart = new StateChart<>(getFruitStateColor());
mNetworkStatusChart.addSeries(networkData);
mNetworkDataEntries.add(networkSeries);
mRadioStateChart = new StateChart<>(getStrengthColor());
mRadioStateChart.addSeries(radioData);
mRadioDataEntries.add(radioSeries);
return Arrays.asList(mAnimatedTimeRange, mNetworkStatusChart, mRadioStateChart);
}
Aggregations