Search in sources :

Example 11 with Range

use of com.android.tools.adtui.model.Range in project android by JetBrains.

the class CpuMonitorTest method testOtherProcessesCpuUsage.

@Test
public void testOtherProcessesCpuUsage() throws IOException {
    CpuUsageDataSeries series = myMonitor.getOtherProcessesCpuUsage();
    ImmutableList<SeriesData<Long>> seriesDataList = series.getDataForXRange(new Range());
    // Only other processes information.
    assertEquals(1, seriesDataList.size());
    SeriesData<Long> seriesData = seriesDataList.get(0);
    assertNotNull(seriesData);
    assertEquals(40, (long) seriesData.value);
}
Also used : SeriesData(com.android.tools.adtui.model.SeriesData) Range(com.android.tools.adtui.model.Range) Test(org.junit.Test)

Example 12 with Range

use of com.android.tools.adtui.model.Range in project android by JetBrains.

the class CpuMonitorTest method testThisProcessCpuUsage.

@Test
public void testThisProcessCpuUsage() throws IOException {
    CpuUsageDataSeries series = myMonitor.getThisProcessCpuUsage();
    ImmutableList<SeriesData<Long>> seriesDataList = series.getDataForXRange(new Range());
    // Only current process information.
    assertEquals(1, seriesDataList.size());
    SeriesData<Long> seriesData = seriesDataList.get(0);
    assertNotNull(seriesData);
    assertEquals(20, (long) seriesData.value);
}
Also used : SeriesData(com.android.tools.adtui.model.SeriesData) Range(com.android.tools.adtui.model.Range) Test(org.junit.Test)

Example 13 with Range

use of com.android.tools.adtui.model.Range in project android by JetBrains.

the class AnimatedTimeline method animate.

@Override
public void animate(float frameLength) {
    if (!myTimeline.isStreaming()) {
        return;
    }
    // Advances time by frameLength (up to current data max - buffer)
    float frameLengthUs = frameLength * TimeUnit.SECONDS.toMicros(1);
    Range viewRange = myTimeline.getViewRange();
    double viewMaxUs = viewRange.getMax();
    double deltaUs = myTimeline.clampToDataRange(viewMaxUs + frameLengthUs) - viewMaxUs;
    viewRange.shift(deltaUs);
}
Also used : Range(com.android.tools.adtui.model.Range)

Example 14 with Range

use of com.android.tools.adtui.model.Range in project android by JetBrains.

the class TopDownTreeModel method update.

@Override
public void update(@NotNull Range range) {
    DefaultMutableTreeNode root = (DefaultMutableTreeNode) getRoot();
    List<Range> diffs = new LinkedList<>();
    // Add all the newly added ranges.
    diffs.addAll(range.subtract(myRange));
    // Add the ranges we don't have anymore
    diffs.addAll(myRange.subtract(range));
    update(root, range, diffs);
    myRange.set(range);
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Range(com.android.tools.adtui.model.Range)

Example 15 with Range

use of com.android.tools.adtui.model.Range in project android by JetBrains.

the class LineChart method updateData.

@Override
protected void updateData() {
    Map<Range, Double> max = new HashMap<>();
    // TODO Handle stacked configs
    for (RangedContinuousSeries ranged : myLinesConfig.keySet()) {
        Range range = ranged.getYRange();
        double yMax = Double.MIN_VALUE;
        ImmutableList<SeriesData<Long>> seriesList = ranged.getSeries();
        for (int i = 0; i < seriesList.size(); i++) {
            double value = seriesList.get(i).value;
            if (yMax < value) {
                yMax = value;
            }
        }
        Double m = max.get(range);
        max.put(range, m == null ? yMax : Math.max(yMax, m));
    }
    for (Map.Entry<Range, Double> entry : max.entrySet()) {
        Range range = entry.getKey();
        // Prevent the LineChart to update the range below its current max.
        if (range.getMax() < entry.getValue()) {
            float fraction = myFirstUpdate ? 1f : DEFAULT_LERP_FRACTION;
            range.setMax(Choreographer.lerp(range.getMax(), entry.getValue(), fraction, mFrameLength, (float) (entry.getValue() * DEFAULT_LERP_THRESHOLD_PERCENTAGE)));
        }
    }
    myFirstUpdate = false;
}
Also used : SeriesData(com.android.tools.adtui.model.SeriesData) Range(com.android.tools.adtui.model.Range) RangedContinuousSeries(com.android.tools.adtui.model.RangedContinuousSeries)

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