Search in sources :

Example 1 with Choreographer

use of com.android.tools.adtui.Choreographer in project android by JetBrains.

the class LineChartTest method testSnapToDataMaxOnFirstUpdate.

@Test
public void testSnapToDataMaxOnFirstUpdate() throws Exception {
    // Test that during the first update, the LineChart will immediately snap to the current data max instead of interpolating.
    Range xRange = new Range(0, 100);
    Range yRange = new Range(0, 50);
    DefaultDataSeries<Long> testSeries = new DefaultDataSeries<>();
    for (int i = 0; i < 101; i++) {
        testSeries.add(i, (long) i);
    }
    RangedContinuousSeries rangedSeries = new RangedContinuousSeries("test", xRange, yRange, testSeries);
    Choreographer choreographer = new Choreographer(new JPanel());
    choreographer.setUpdate(false);
    LineChart lineChart = new LineChart();
    lineChart.addLine(rangedSeries);
    choreographer.register(lineChart);
    // before update.
    assertThat(yRange.getMax()).isWithin(0.0).of(50);
    choreographer.step();
    // after update.
    assertThat(yRange.getMax()).isWithin(0.0).of(100);
    choreographer.stop();
}
Also used : Choreographer(com.android.tools.adtui.Choreographer) DefaultDataSeries(com.android.tools.adtui.model.DefaultDataSeries) Range(com.android.tools.adtui.model.Range) RangedContinuousSeries(com.android.tools.adtui.model.RangedContinuousSeries) Test(org.junit.Test)

Example 2 with Choreographer

use of com.android.tools.adtui.Choreographer in project android by JetBrains.

the class VisualTest method initialize.

protected void initialize() {
    mPanel = new JBPanel();
    mChoreographer = new Choreographer(mPanel);
    mChoreographer.register(createComponentsList());
    populateUi(mPanel);
}
Also used : Choreographer(com.android.tools.adtui.Choreographer) JBPanel(com.intellij.ui.components.JBPanel)

Example 3 with Choreographer

use of com.android.tools.adtui.Choreographer in project android by JetBrains.

the class AnimatedComponentImageDiffEntry method setUpBase.

private void setUpBase() {
    // TODO: add one more level to the hierarchy and move this to a base class that can be subclassed by generators of different components
    myContentPane = new JPanel(new BorderLayout());
    myContentPane.setSize(MAIN_COMPONENT_DIMENSION);
    myContentPane.setPreferredSize(MAIN_COMPONENT_DIMENSION);
    myCurrentTimeUs = TimeUnit.NANOSECONDS.toMicros(System.nanoTime());
    myRangeStartUs = myCurrentTimeUs;
    myRangeEndUs = myRangeStartUs + TOTAL_VALUES * TIME_DELTA_US;
    myXRange = new AnimatedRange(myRangeStartUs, myRangeEndUs);
    // We don't need to set a proper FPS to the choreographer, as we're interested in the final image only, not the animation.
    myChoreographer = new Choreographer(-1, myContentPane);
    myChoreographer.setUpdate(false);
    myComponents = new ArrayList<>();
    myComponents.add(myXRange);
}
Also used : Choreographer(com.android.tools.adtui.Choreographer) AnimatedRange(com.android.tools.adtui.AnimatedRange)

Aggregations

Choreographer (com.android.tools.adtui.Choreographer)3 AnimatedRange (com.android.tools.adtui.AnimatedRange)1 DefaultDataSeries (com.android.tools.adtui.model.DefaultDataSeries)1 Range (com.android.tools.adtui.model.Range)1 RangedContinuousSeries (com.android.tools.adtui.model.RangedContinuousSeries)1 JBPanel (com.intellij.ui.components.JBPanel)1 Test (org.junit.Test)1