Search in sources :

Example 6 with LongDataSeries

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);
}
Also used : LongDataSeries(com.android.tools.adtui.model.LongDataSeries) ArrayList(java.util.ArrayList) Range(com.android.tools.adtui.model.Range) RangedContinuousSeries(com.android.tools.adtui.model.RangedContinuousSeries) LineChart(com.android.tools.adtui.chart.linechart.LineChart)

Aggregations

LongDataSeries (com.android.tools.adtui.model.LongDataSeries)6 Range (com.android.tools.adtui.model.Range)6 RangedContinuousSeries (com.android.tools.adtui.model.RangedContinuousSeries)6 ArrayList (java.util.ArrayList)4 LineChart (com.android.tools.adtui.chart.linechart.LineChart)3 JBPanel (com.intellij.ui.components.JBPanel)3 com.android.tools.adtui (com.android.tools.adtui)2 SeriesData (com.android.tools.adtui.model.SeriesData)2 ImmutableList (com.intellij.util.containers.ImmutableList)2 java.awt (java.awt)2 List (java.util.List)2 TimeUnit (java.util.concurrent.TimeUnit)2 javax.swing (javax.swing)2 NotNull (org.jetbrains.annotations.NotNull)2 LineConfig (com.android.tools.adtui.chart.linechart.LineConfig)1 AdtUiUtils (com.android.tools.adtui.common.AdtUiUtils)1 MemoryAxisFormatter (com.android.tools.adtui.common.formatter.MemoryAxisFormatter)1 TimeAxisFormatter (com.android.tools.adtui.common.formatter.TimeAxisFormatter)1 JBLayeredPane (com.intellij.ui.components.JBLayeredPane)1 ComponentAdapter (java.awt.event.ComponentAdapter)1