Search in sources :

Example 16 with AbstractGCEvent

use of com.tagtraum.perf.gcviewer.model.AbstractGCEvent in project GCViewer by chewiebug.

the class GCRectanglesRenderer method paintComponent.

public void paintComponent(Graphics2D g2d) {
    // make sure that we ignore the AntiAliasing flag as it does not make sense for vertical lines
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    final double scaleFactor = getModelChart().getScaleFactor();
    final double scaledHeight = (getHeight() / getModelChart().getMaxPause());
    int lastWidth = Integer.MIN_VALUE;
    int lastHeight = Integer.MIN_VALUE;
    int lastX = Integer.MIN_VALUE;
    int lastY = Integer.MIN_VALUE;
    Rectangle clip = g2d.getClipBounds();
    int leftBoundary = clip.x;
    int rightBoundary = clip.x + clip.width;
    for (Iterator<AbstractGCEvent<?>> i = getModelChart().getModel().getStopTheWorldEvents(); i.hasNext() && lastX < rightBoundary; ) {
        AbstractGCEvent<?> event = i.next();
        double pause = event.getPause();
        int width = (int) Math.max(Math.abs(scaleFactor * pause), 1.0d);
        int height = (int) (pause * scaledHeight);
        int x = (int) (scaleFactor * (event.getTimestamp() - getModelChart().getModel().getFirstPauseTimeStamp()));
        int y = getHeight() - (int) (pause * scaledHeight);
        if (lastX != x || lastY != y || lastWidth != width || lastHeight != height) {
            if ((x + width) > leftBoundary && x < rightBoundary) {
                // make sure only visible rectangles are drawn
                if (event.isFull()) {
                    g2d.setPaint(Color.BLACK);
                } else if (event.isInitialMark()) {
                    g2d.setPaint(Color.BLUE);
                } else if (event.isRemark()) {
                    g2d.setPaint(Color.ORANGE);
                } else if (event.getExtendedType().getType() == AbstractGCEvent.Type.INC_GC) {
                    g2d.setPaint(brighter);
                } else if (event instanceof VmOperationEvent) {
                    g2d.setPaint(Color.RED);
                } else {
                    g2d.setPaint(getLinePaint());
                }
                g2d.fillRect(x, y, width, height);
            }
            lastWidth = width;
            lastHeight = height;
            lastX = x;
            lastY = y;
        }
    }
}
Also used : VmOperationEvent(com.tagtraum.perf.gcviewer.model.VmOperationEvent) Rectangle(java.awt.Rectangle) AbstractGCEvent(com.tagtraum.perf.gcviewer.model.AbstractGCEvent) Paint(java.awt.Paint)

Example 17 with AbstractGCEvent

use of com.tagtraum.perf.gcviewer.model.AbstractGCEvent in project GCViewer by chewiebug.

the class TotalHeapRenderer method computePolygon.

public Polygon computePolygon(ModelChart modelChart, GCModel model) {
    ScaledPolygon polygon = createMemoryScaledPolygon();
    polygon.addPoint(0.0d, 0.0d);
    int lastTotal = 0;
    for (Iterator<AbstractGCEvent<?>> i = model.getStopTheWorldEvents(); i.hasNext(); ) {
        AbstractGCEvent<?> abstractGCEvent = i.next();
        if (abstractGCEvent instanceof GCEvent) {
            GCEvent event = (GCEvent) abstractGCEvent;
            if (event.getTotal() > 0) {
                // -> skip them
                if (polygon.npoints == 1) {
                    // first point needs to be treated different from the rest,
                    // because otherwise the polygon would not start with a vertical line at 0,
                    // but with a slanting line between 0 and after the first pause
                    polygon.addPoint(0, (double) event.getTotal());
                }
                polygon.addPoint(event.getTimestamp() - model.getFirstPauseTimeStamp() + event.getPause(), event.getTotal());
                lastTotal = event.getTotal();
            }
        }
    }
    polygon.addPointNotOptimised(model.getRunningTime(), lastTotal);
    polygon.addPointNotOptimised(model.getRunningTime(), 0.0d);
    return polygon;
}
Also used : AbstractGCEvent(com.tagtraum.perf.gcviewer.model.AbstractGCEvent) GCEvent(com.tagtraum.perf.gcviewer.model.GCEvent) AbstractGCEvent(com.tagtraum.perf.gcviewer.model.AbstractGCEvent) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint)

Example 18 with AbstractGCEvent

use of com.tagtraum.perf.gcviewer.model.AbstractGCEvent in project GCViewer by chewiebug.

the class TotalYoungRenderer method computePolygon.

public Polygon computePolygon(ModelChart modelChart, GCModel model) {
    ScaledPolygon polygon = createMemoryScaledPolygon();
    polygon.addPoint(0.0d, 0.0d);
    double lastTenured = 0;
    double lastYoung = 0;
    for (Iterator<AbstractGCEvent<?>> i = model.getStopTheWorldEvents(); i.hasNext(); ) {
        AbstractGCEvent<?> abstractGCEvent = i.next();
        if (abstractGCEvent instanceof GCEvent) {
            GCEvent event = (GCEvent) abstractGCEvent;
            double tenuredSize = 0;
            double youngSize = 0;
            GCEvent young = event.getYoung();
            GCEvent tenured = event.getTenured();
            if (hasMemoryInformation(event) && young != null && tenured != null) {
                if (modelChart.isShowTenured()) {
                    tenuredSize = tenured.getTotal();
                }
                youngSize = young.getTotal();
                if (polygon.npoints == 1) {
                    // first point needs to be treated different from the rest,
                    // because otherwise the polygon would not start with a vertical line at 0,
                    // but with a slanting line between 0 and after the first pause
                    polygon.addPoint(0, tenuredSize + youngSize);
                }
                polygon.addPoint(event.getTimestamp() - model.getFirstPauseTimeStamp() + event.getPause(), tenuredSize + youngSize);
                lastYoung = youngSize;
                lastTenured = tenuredSize;
            }
        }
    }
    polygon.addPointNotOptimised(model.getRunningTime(), lastTenured + lastYoung);
    polygon.addPointNotOptimised(model.getRunningTime(), 0.0d);
    return polygon;
}
Also used : AbstractGCEvent(com.tagtraum.perf.gcviewer.model.AbstractGCEvent) GCEvent(com.tagtraum.perf.gcviewer.model.GCEvent) AbstractGCEvent(com.tagtraum.perf.gcviewer.model.AbstractGCEvent)

Aggregations

AbstractGCEvent (com.tagtraum.perf.gcviewer.model.AbstractGCEvent)18 GCEvent (com.tagtraum.perf.gcviewer.model.GCEvent)13 GCModel (com.tagtraum.perf.gcviewer.model.GCModel)5 Paint (java.awt.Paint)3 GcResourceFile (com.tagtraum.perf.gcviewer.model.GcResourceFile)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 ZonedDateTime (java.time.ZonedDateTime)2 Test (org.junit.Test)2 VmOperationEvent (com.tagtraum.perf.gcviewer.model.VmOperationEvent)1 GradientPaint (java.awt.GradientPaint)1 Rectangle (java.awt.Rectangle)1 Locale (java.util.Locale)1 StringTokenizer (java.util.StringTokenizer)1