use of org.pentaho.di.core.logging.MetricsPainter in project pentaho-kettle by pentaho.
the class TransMetricsDelegate method refreshImage.
private void refreshImage(GC canvasGc) {
List<MetricsDuration> durations = MetricsUtil.getAllDurations(transGraph.trans.getLogChannelId());
if (Utils.isEmpty(durations)) {
// In case of an empty durations or null there is nothing to draw
return;
}
// Sort the metrics.
Collections.sort(durations, new Comparator<MetricsDuration>() {
@Override
public int compare(MetricsDuration o1, MetricsDuration o2) {
return o1.getDate().compareTo(o2.getDate());
}
});
Rectangle bounds = canvas.getBounds();
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
if (transGraph.trans == null) {
image = null;
return;
}
//
if (image != null && (System.currentTimeMillis() - lastRefreshTime) < 5000) {
return;
}
lastRefreshTime = System.currentTimeMillis();
if (image != null) {
// prevent out of memory...
image.dispose();
image = null;
}
// Correct size of canvas.
org.eclipse.swt.graphics.Point textExtent = canvasGc.textExtent("AagKkiw");
int height = textExtent.y + 8;
// Make the height larger if needed for clarify
//
bounds.height = Math.max(durations.size() * height, bounds.height);
canvas.setSize(bounds.width, bounds.height);
SWTGC gc = new SWTGC(Display.getCurrent(), new Point(bounds.width, bounds.height), PropsUI.getInstance().getIconSize());
MetricsPainter painter = new MetricsPainter(gc, height);
drawAreas = painter.paint(durations);
image = (Image) gc.getImage();
// refresh the scrolled composite
//
sMetricsComposite.setMinHeight(bounds.height);
sMetricsComposite.setMinWidth(bounds.width);
sMetricsComposite.layout(true, true);
// Draw the image on the canvas...
//
canvas.redraw();
// close shop on the SWT GC side.
//
gc.dispose();
}
use of org.pentaho.di.core.logging.MetricsPainter in project pentaho-kettle by pentaho.
the class JobMetricsDelegate method refreshImage.
private void refreshImage(GC canvasGc) {
List<MetricsDuration> durations = MetricsUtil.getAllDurations(jobGraph.job.getLogChannelId());
if (Utils.isEmpty(durations)) {
// In case of an empty durations or null there is nothing to draw
return;
}
// Sort the metrics.
Collections.sort(durations, new Comparator<MetricsDuration>() {
@Override
public int compare(MetricsDuration o1, MetricsDuration o2) {
return o1.getDate().compareTo(o2.getDate());
}
});
Rectangle bounds = canvas.getBounds();
if (bounds.width <= 0 || bounds.height <= 0) {
return;
}
if (jobGraph.job == null) {
image = null;
return;
}
//
if (image != null && (System.currentTimeMillis() - lastRefreshTime) < 5000) {
return;
}
lastRefreshTime = System.currentTimeMillis();
if (image != null) {
// prevent out of memory...
image.dispose();
image = null;
}
// Correct size of canvas.
//
org.eclipse.swt.graphics.Point textExtent = canvasGc.textExtent("AagKkiw");
int barHeight = textExtent.y + 8;
// Make the height larger if needed for clarify
//
bounds.height = Math.max(durations.size() * barHeight, bounds.height);
canvas.setSize(bounds.width, bounds.height);
SWTGC gc = new SWTGC(Display.getCurrent(), new Point(bounds.width, bounds.height), PropsUI.getInstance().getIconSize());
MetricsPainter painter = new MetricsPainter(gc, barHeight);
// checking according to method's contract
drawAreas = painter.paint(durations);
image = (Image) gc.getImage();
// refresh the scrolled composite
//
// sMetricsComposite.setMinHeight(bounds.height);
// sMetricsComposite.setMinWidth(bounds.width);
sMetricsComposite.layout(true, true);
// close shop on the SWT GC side.
//
gc.dispose();
// Draw the image on the canvas...
//
canvas.redraw();
}
use of org.pentaho.di.core.logging.MetricsPainter in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceTestMetrics method refreshImage.
private synchronized Image refreshImage() {
Display device = metricsComposite.getDisplay();
Rectangle bounds = metricsComposite.getBounds();
if (image != null) {
Rectangle imageBounds = image.getBounds();
// Check if image in cache fits
if (imageBounds.width == bounds.width && imageBounds.height >= bounds.height) {
return image;
} else {
// Need to regenerate
image.dispose();
image = null;
}
}
String metricsMessage = BaseMessages.getString(DataServiceTestController.PKG, "DataServiceTest.MetricsPlaceholder");
org.eclipse.swt.graphics.Point textExtent = new GC(canvas).textExtent(metricsMessage);
if (durations.isEmpty()) {
bounds.height = textExtent.y * 2;
image = new Image(device, bounds.width, bounds.height);
GC gc = new GC(image);
gc.drawText(metricsMessage, (bounds.width - textExtent.x) / 2, textExtent.y / 2);
} else {
// Adjust height to fit all bars
int barHeight = textExtent.y + 5;
bounds.height = Math.max(20 + durations.size() * (barHeight + 5), bounds.height);
SWTGC gc = new SWTGC(device, new Point(bounds.width, bounds.height), PropsUI.getInstance().getIconSize());
MetricsPainter painter = new MetricsPainter(gc, barHeight);
painter.paint(durations);
image = (Image) gc.getImage();
gc.dispose();
}
metricsComposite.setMinHeight(bounds.height);
metricsComposite.layout();
return image;
}
Aggregations