Search in sources :

Example 1 with SelectionComponent

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

the class LineChartVisualTest method createComponentsList.

@Override
protected List<Animatable> createComponentsList() {
    mRangedData = new ArrayList<>();
    mData = new ArrayList<>();
    long nowUs = TimeUnit.NANOSECONDS.toMicros(System.nanoTime());
    Range timeGlobalRangeUs = new Range(nowUs, nowUs + TimeUnit.SECONDS.toMicros(60));
    mLineChart = new LineChart();
    mAnimatedTimeRange = new AnimatedTimeRange(timeGlobalRangeUs, 0);
    List<Animatable> componentsList = new ArrayList<>();
    mySelectionComponent = new SelectionComponent(new Range(0, 0), timeGlobalRangeUs);
    myOverlayComponent = new OverlayComponent(mySelectionComponent);
    // Add the scene components to the list
    componentsList.add(mAnimatedTimeRange);
    componentsList.add(mLineChart);
    componentsList.add(mySelectionComponent);
    Range yRange = new Range(0.0, 100.0);
    for (int i = 0; i < 4; i++) {
        if (i % 2 == 0) {
            yRange = new Range(0.0, 100.0);
        }
        DefaultDataSeries<Long> series = new DefaultDataSeries<>();
        RangedContinuousSeries ranged = new RangedContinuousSeries("Widgets", timeGlobalRangeUs, yRange, series);
        mRangedData.add(ranged);
        mData.add(series);
    }
    mLineChart.addLines(mRangedData);
    mDurationData1 = new DefaultDataSeries<>();
    mDurationData2 = new DefaultDataSeries<>();
    RangedSeries<DefaultDurationData> series1 = new RangedSeries<>(timeGlobalRangeUs, mDurationData1);
    RangedSeries<DefaultDurationData> series2 = new RangedSeries<>(timeGlobalRangeUs, mDurationData2);
    mDurationRendererBlocking = new DurationDataRenderer.Builder(series1, Color.WHITE).setLabelColors(Color.DARK_GRAY, Color.GRAY, Color.lightGray, Color.WHITE).setIsBlocking(true).setIcon(UIManager.getIcon("Tree.leafIcon")).setLabelProvider(durationdata -> "Blocking").setClickHander(durationData -> mClickDisplayLabel.setText(durationData.toString())).build();
    mDurationRendererAttached = new DurationDataRenderer.Builder(series2, Color.WHITE).setLabelColors(Color.DARK_GRAY, Color.GRAY, Color.lightGray, Color.WHITE).setIcon(UIManager.getIcon("Tree.leafIcon")).setLabelProvider(durationdata -> "Attached").setAttachLineSeries(mRangedData.get(0)).setClickHander(durationData -> mClickDisplayLabel.setText(durationData.toString())).build();
    mLineChart.addCustomRenderer(mDurationRendererBlocking);
    mLineChart.addCustomRenderer(mDurationRendererAttached);
    myOverlayComponent.addDurationDataRenderer(mDurationRendererBlocking);
    myOverlayComponent.addDurationDataRenderer(mDurationRendererAttached);
    componentsList.add(mDurationRendererBlocking);
    componentsList.add(mDurationRendererAttached);
    componentsList.add(myOverlayComponent);
    return componentsList;
}
Also used : AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) ItemEvent(java.awt.event.ItemEvent) LineConfig(com.android.tools.adtui.chart.linechart.LineConfig) LineChart(com.android.tools.adtui.chart.linechart.LineChart) Animatable(com.android.tools.adtui.Animatable) AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) ImmutableList(com.intellij.util.containers.ImmutableList) SelectionComponent(com.android.tools.adtui.SelectionComponent) GBC_FULL(com.android.tools.adtui.common.AdtUiUtils.GBC_FULL) AdtUiUtils(com.android.tools.adtui.common.AdtUiUtils) MouseEvent(java.awt.event.MouseEvent) UNSPECIFIED_DURATION(com.android.tools.adtui.model.DurationData.UNSPECIFIED_DURATION) com.android.tools.adtui.model(com.android.tools.adtui.model) ArrayList(java.util.ArrayList) java.awt(java.awt) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) AnimatedComponent(com.android.tools.adtui.AnimatedComponent) DurationDataRenderer(com.android.tools.adtui.chart.linechart.DurationDataRenderer) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MouseAdapter(java.awt.event.MouseAdapter) OverlayComponent(com.android.tools.adtui.chart.linechart.OverlayComponent) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) javax.swing(javax.swing) DurationDataRenderer(com.android.tools.adtui.chart.linechart.DurationDataRenderer) ArrayList(java.util.ArrayList) AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) SelectionComponent(com.android.tools.adtui.SelectionComponent) Animatable(com.android.tools.adtui.Animatable) OverlayComponent(com.android.tools.adtui.chart.linechart.OverlayComponent) LineChart(com.android.tools.adtui.chart.linechart.LineChart)

Example 2 with SelectionComponent

use of com.android.tools.adtui.SelectionComponent 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)

Aggregations

Animatable (com.android.tools.adtui.Animatable)2 SelectionComponent (com.android.tools.adtui.SelectionComponent)2 ArrayList (java.util.ArrayList)2 AnimatedComponent (com.android.tools.adtui.AnimatedComponent)1 AnimatedTimeRange (com.android.tools.adtui.AnimatedTimeRange)1 DurationDataRenderer (com.android.tools.adtui.chart.linechart.DurationDataRenderer)1 LineChart (com.android.tools.adtui.chart.linechart.LineChart)1 LineConfig (com.android.tools.adtui.chart.linechart.LineConfig)1 OverlayComponent (com.android.tools.adtui.chart.linechart.OverlayComponent)1 AdtUiUtils (com.android.tools.adtui.common.AdtUiUtils)1 GBC_FULL (com.android.tools.adtui.common.AdtUiUtils.GBC_FULL)1 com.android.tools.adtui.model (com.android.tools.adtui.model)1 UNSPECIFIED_DURATION (com.android.tools.adtui.model.DurationData.UNSPECIFIED_DURATION)1 Range (com.android.tools.adtui.model.Range)1 ImmutableList (com.intellij.util.containers.ImmutableList)1 java.awt (java.awt)1 ItemEvent (java.awt.event.ItemEvent)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 Collections (java.util.Collections)1