Search in sources :

Example 21 with Range

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

Example 22 with Range

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);
}
Also used : ItemEvent(java.awt.event.ItemEvent) Range(com.android.tools.adtui.model.Range) Arrays(java.util.Arrays) LineConfig(com.android.tools.adtui.chart.linechart.LineConfig) DefaultDataSeries(com.android.tools.adtui.model.DefaultDataSeries) RangedContinuousSeries(com.android.tools.adtui.model.RangedContinuousSeries) LineChart(com.android.tools.adtui.chart.linechart.LineChart) ImmutableList(com.intellij.util.containers.ImmutableList) ComponentEvent(java.awt.event.ComponentEvent) AdtUiUtils(com.android.tools.adtui.common.AdtUiUtils) SingleUnitAxisFormatter(com.android.tools.adtui.common.formatter.SingleUnitAxisFormatter) java.awt(java.awt) ComponentAdapter(java.awt.event.ComponentAdapter) com.android.tools.adtui(com.android.tools.adtui) List(java.util.List) SeriesData(com.android.tools.adtui.model.SeriesData) JBLayeredPane(com.intellij.ui.components.JBLayeredPane) NotNull(org.jetbrains.annotations.NotNull) JBColor(com.intellij.ui.JBColor) javax.swing(javax.swing) SingleUnitAxisFormatter(com.android.tools.adtui.common.formatter.SingleUnitAxisFormatter) Range(com.android.tools.adtui.model.Range) LineConfig(com.android.tools.adtui.chart.linechart.LineConfig) LineChart(com.android.tools.adtui.chart.linechart.LineChart) RangedContinuousSeries(com.android.tools.adtui.model.RangedContinuousSeries)

Example 23 with Range

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;
}
Also used : SelectionComponent(com.android.tools.adtui.SelectionComponent) ArrayList(java.util.ArrayList) Animatable(com.android.tools.adtui.Animatable) Range(com.android.tools.adtui.model.Range)

Example 24 with Range

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);
}
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 25 with Range

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);
}
Also used : AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) DefaultDataSeries(com.android.tools.adtui.model.DefaultDataSeries) Range(com.android.tools.adtui.model.Range) AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) RangedSeries(com.android.tools.adtui.model.RangedSeries)

Aggregations

Range (com.android.tools.adtui.model.Range)38 RangedContinuousSeries (com.android.tools.adtui.model.RangedContinuousSeries)12 ArrayList (java.util.ArrayList)10 Test (org.junit.Test)10 JBPanel (com.intellij.ui.components.JBPanel)9 LineChart (com.android.tools.adtui.chart.linechart.LineChart)7 SeriesData (com.android.tools.adtui.model.SeriesData)7 LineConfig (com.android.tools.adtui.chart.linechart.LineConfig)6 NotNull (org.jetbrains.annotations.NotNull)6 java.awt (java.awt)5 javax.swing (javax.swing)5 Animatable (com.android.tools.adtui.Animatable)4 AnimatedTimeRange (com.android.tools.adtui.AnimatedTimeRange)4 DefaultDataSeries (com.android.tools.adtui.model.DefaultDataSeries)4 LongDataSeries (com.android.tools.adtui.model.LongDataSeries)4 List (java.util.List)4 com.android.tools.adtui (com.android.tools.adtui)3 SingleUnitAxisFormatter (com.android.tools.adtui.common.formatter.SingleUnitAxisFormatter)3 RangedSeries (com.android.tools.adtui.model.RangedSeries)3 ProfilerEventListener (com.android.tools.idea.monitor.tool.ProfilerEventListener)3