use of com.tagtraum.perf.gcviewer.model.VmOperationEvent in project GCViewer by chewiebug.
the class ModelMetricsPanelTest method testVmOpModel.
@Test
public void testVmOpModel() {
GCEvent event = new GCEvent();
event.setTimestamp(0.5);
event.setType(Type.G1_YOUNG_INITIAL_MARK);
event.setPause(0.245);
event.setPreUsed(900);
event.setPostUsed(400);
event.setTotal(1024);
GCModel model = new GCModel();
model.add(event);
VmOperationEvent vmOpEvent = new VmOperationEvent();
vmOpEvent.setTimestamp(0.7);
vmOpEvent.setType(Type.APPLICATION_STOPPED_TIME);
vmOpEvent.setPause(0.26);
model.add(vmOpEvent);
ModelMetricsPanel panel = new ModelMetricsPanel();
// first add empty model; is done when opened
panel.setModel(new GCModel());
// only later a model with entries is set
panel.setModel(model);
}
use of com.tagtraum.perf.gcviewer.model.VmOperationEvent 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;
}
}
}
Aggregations