Search in sources :

Example 1 with Animatable

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

the class NetworkProfilerVisualTest method createComponentsList.

@Override
protected List<Animatable> createComponentsList() {
    long startTimeUs = myDataStore.getLatestTimeUs();
    Range timeCurrentRangeUs = new Range(startTimeUs - RangeScrollbar.DEFAULT_VIEW_LENGTH_US, startTimeUs);
    AnimatedTimeRange animatedTimeRange = new AnimatedTimeRange(timeCurrentRangeUs, 0);
    EventDispatcher<ProfilerEventListener> dummyDispatcher = EventDispatcher.create(ProfilerEventListener.class);
    mySegment = new NetworkSegment(timeCurrentRangeUs, myDataStore, dummyDispatcher);
    myDetailedView = new NetworkDetailedView();
    myDetailedView.setVisible(false);
    generateNetworkCaptureData(startTimeUs);
    myCaptureSegment = new NetworkCaptureSegment(timeCurrentRangeUs, new TestNetworkCaptureModel(), httpData -> myDetailedView.setVisible(true), dummyDispatcher);
    myRadioSegment = new NetworkRadioSegment(timeCurrentRangeUs, myDataStore, dummyDispatcher);
    List<Animatable> animatables = new ArrayList<>();
    animatables.add(animatedTimeRange);
    mySegment.createComponentsList(animatables);
    myCaptureSegment.createComponentsList(animatables);
    myRadioSegment.createComponentsList(animatables);
    animatables.add(myCaptureSegment);
    return animatables;
}
Also used : AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) NetworkCaptureModel(com.android.tools.idea.monitor.ui.network.model.NetworkCaptureModel) Range(com.android.tools.adtui.model.Range) NetworkSegment(com.android.tools.idea.monitor.ui.network.view.NetworkSegment) EventDispatcher(com.intellij.util.EventDispatcher) Animatable(com.android.tools.adtui.Animatable) AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) ProfilerEventListener(com.android.tools.idea.monitor.tool.ProfilerEventListener) RangeScrollbar(com.android.tools.adtui.RangeScrollbar) NetworkDetailedView(com.android.tools.idea.monitor.ui.network.view.NetworkDetailedView) ArrayList(java.util.ArrayList) java.awt(java.awt) VisualTest(com.android.tools.adtui.visualtests.VisualTest) HttpData(com.android.tools.idea.monitor.ui.network.model.HttpData) List(java.util.List) NonNull(com.android.annotations.NonNull) NetworkRadioSegment(com.android.tools.idea.monitor.ui.network.view.NetworkRadioSegment) NotNull(org.jetbrains.annotations.NotNull) SeriesDataStore(com.android.tools.datastore.SeriesDataStore) NetworkCaptureSegment(com.android.tools.idea.monitor.ui.network.view.NetworkCaptureSegment) javax.swing(javax.swing) ArrayList(java.util.ArrayList) NetworkCaptureSegment(com.android.tools.idea.monitor.ui.network.view.NetworkCaptureSegment) NetworkDetailedView(com.android.tools.idea.monitor.ui.network.view.NetworkDetailedView) Range(com.android.tools.adtui.model.Range) AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) Animatable(com.android.tools.adtui.Animatable) NetworkSegment(com.android.tools.idea.monitor.ui.network.view.NetworkSegment) ProfilerEventListener(com.android.tools.idea.monitor.tool.ProfilerEventListener) NetworkRadioSegment(com.android.tools.idea.monitor.ui.network.view.NetworkRadioSegment)

Example 2 with Animatable

use of com.android.tools.adtui.Animatable 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 3 with Animatable

use of com.android.tools.adtui.Animatable 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 4 with Animatable

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

the class CpuProfilerVisualTest method createComponentsList.

@Override
protected List<Animatable> createComponentsList() {
    long startTimeUs = mDataStore.getLatestTimeUs();
    Range timeCurrentRangeUs = new Range(startTimeUs - RangeScrollbar.DEFAULT_VIEW_LENGTH_US, startTimeUs);
    AnimatedTimeRange animatedTimeRange = new AnimatedTimeRange(timeCurrentRangeUs, 0);
    //TODO Update test data for CpuUsageSegment to be exactly what it was.
    EventDispatcher<ProfilerEventListener> dummyDispatcher = EventDispatcher.create(ProfilerEventListener.class);
    mCPULevel2Segment = new CpuUsageSegment(timeCurrentRangeUs, mDataStore, dummyDispatcher);
    mThreadsSegment = new ThreadsSegment(timeCurrentRangeUs, mDataStore, dummyDispatcher, (threads) -> {
    // TODO: show L3 segment with the charts corresponding to threads selected.
    // Hide any charts corresponding to unselected threads and hide L3 segment in case no threads are selected
    });
    List<Animatable> animatables = new ArrayList<>();
    animatables.add(animatedTimeRange);
    animatables.add(mThreadsSegment);
    mCPULevel2Segment.createComponentsList(animatables);
    mThreadsSegment.createComponentsList(animatables);
    return animatables;
}
Also used : AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) ThreadsSegment(com.android.tools.idea.monitor.ui.cpu.view.ThreadsSegment) ThreadStateDataSeries(com.android.tools.profilers.cpu.ThreadStateDataSeries) Range(com.android.tools.adtui.model.Range) CpuUsageSegment(com.android.tools.idea.monitor.ui.cpu.view.CpuUsageSegment) EventDispatcher(com.intellij.util.EventDispatcher) Animatable(com.android.tools.adtui.Animatable) AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) ProfilerEventListener(com.android.tools.idea.monitor.tool.ProfilerEventListener) RangeScrollbar(com.android.tools.adtui.RangeScrollbar) ArrayList(java.util.ArrayList) java.awt(java.awt) TimeUnit(java.util.concurrent.TimeUnit) VisualTest(com.android.tools.adtui.visualtests.VisualTest) List(java.util.List) SeriesData(com.android.tools.adtui.model.SeriesData) ThreadsSegment(com.android.tools.idea.monitor.ui.cpu.view.ThreadsSegment) TestDataGenerator(com.android.tools.idea.monitor.ui.visual.data.TestDataGenerator) CpuProfiler(com.android.tools.profiler.proto.CpuProfiler) SeriesDataType(com.android.tools.datastore.SeriesDataType) NotNull(org.jetbrains.annotations.NotNull) SeriesDataStore(com.android.tools.datastore.SeriesDataStore) javax.swing(javax.swing) CpuUsageSegment(com.android.tools.idea.monitor.ui.cpu.view.CpuUsageSegment) ArrayList(java.util.ArrayList) Animatable(com.android.tools.adtui.Animatable) ProfilerEventListener(com.android.tools.idea.monitor.tool.ProfilerEventListener) Range(com.android.tools.adtui.model.Range) AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange)

Example 5 with Animatable

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

the class MemoryProfilerVisualTest method createComponentsList.

@Override
protected List<Animatable> createComponentsList() {
    long startTimeUs = mDataStore.getLatestTimeUs();
    Range timeCurrentRangeUs = new Range(startTimeUs - RangeScrollbar.DEFAULT_VIEW_LENGTH_US, startTimeUs);
    AnimatedTimeRange animatedTimeRange = new AnimatedTimeRange(timeCurrentRangeUs, 0);
    EventDispatcher<ProfilerEventListener> dummyDispatcher = EventDispatcher.create(ProfilerEventListener.class);
    mSegment = new MemorySegment(timeCurrentRangeUs, mDataStore, dummyDispatcher);
    mRoot = new MemoryInfoTreeNode("Root");
    mDetailSegment = new MemoryDetailSegment(timeCurrentRangeUs, mRoot, dummyDispatcher);
    List<Animatable> animatables = new ArrayList<>();
    animatables.add(animatedTimeRange);
    mSegment.createComponentsList(animatables);
    mDetailSegment.createComponentsList(animatables);
    // Simulate allocation data with stack frames.
    mUpdateDataThread = new Thread() {

        @Override
        public void run() {
            try {
                while (true) {
                    updateTree(mRoot);
                    Thread.sleep(10);
                }
            } catch (InterruptedException e) {
            }
        }
    };
    mUpdateDataThread.start();
    return animatables;
}
Also used : AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) MemoryInfoTreeNode(com.android.tools.idea.monitor.ui.memory.model.MemoryInfoTreeNode) ArrayList(java.util.ArrayList) Range(com.android.tools.adtui.model.Range) AnimatedTimeRange(com.android.tools.adtui.AnimatedTimeRange) MemorySegment(com.android.tools.idea.monitor.ui.memory.view.MemorySegment) MemoryDetailSegment(com.android.tools.idea.monitor.ui.memory.view.MemoryDetailSegment) Animatable(com.android.tools.adtui.Animatable) ProfilerEventListener(com.android.tools.idea.monitor.tool.ProfilerEventListener)

Aggregations

Animatable (com.android.tools.adtui.Animatable)5 ArrayList (java.util.ArrayList)5 AnimatedTimeRange (com.android.tools.adtui.AnimatedTimeRange)4 Range (com.android.tools.adtui.model.Range)4 ProfilerEventListener (com.android.tools.idea.monitor.tool.ProfilerEventListener)3 java.awt (java.awt)3 List (java.util.List)3 javax.swing (javax.swing)3 NotNull (org.jetbrains.annotations.NotNull)3 RangeScrollbar (com.android.tools.adtui.RangeScrollbar)2 SelectionComponent (com.android.tools.adtui.SelectionComponent)2 VisualTest (com.android.tools.adtui.visualtests.VisualTest)2 SeriesDataStore (com.android.tools.datastore.SeriesDataStore)2 EventDispatcher (com.intellij.util.EventDispatcher)2 TimeUnit (java.util.concurrent.TimeUnit)2 NonNull (com.android.annotations.NonNull)1 AnimatedComponent (com.android.tools.adtui.AnimatedComponent)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