use of io.flutter.vmService.HeapMonitor.HeapSample in project flutter-intellij by flutter.
the class HeapSamples method paintComponent.
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (heapState == null) {
return;
}
final int height = getHeight() - 1;
final int width = getWidth();
final long now = System.currentTimeMillis();
final long maxDataSize = Math.round(heapState.getCapacity() / (double) TEN_MB) * TEN_MB + TEN_MB;
final Graphics2D graphics2D = (Graphics2D) g;
graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics2D.setColor(getForegroundColor());
graphics2D.setStroke(GRAPH_STROKE);
Path2D path = null;
for (HeapSample sample : heapState.getSamples()) {
final double x = width - (((double) (now - sample.getSampleTime())) / ((double) heapState.getMaxSampleSizeMs()) * width);
final double y = (double) height * sample.getBytes() / maxDataSize;
if (path == null) {
path = new Path2D.Double();
path.moveTo(x, height - y + 1);
} else {
path.lineTo(x, height - y + 1);
}
}
graphics2D.draw(path);
}
Aggregations