use of org.pentaho.di.ui.spoon.SWTGC in project pentaho-kettle by pentaho.
the class TransGraph method getTransformationImage.
public Image getTransformationImage(Device device, int x, int y, float magnificationFactor) {
GCInterface gc = new SWTGC(device, new Point(x, y), iconsize);
int gridSize = PropsUI.getInstance().isShowCanvasGridEnabled() ? PropsUI.getInstance().getCanvasGridSize() : 1;
TransPainter transPainter = new TransPainter(gc, transMeta, new Point(x, y), new SwtScrollBar(hori), new SwtScrollBar(vert), candidate, drop_candidate, selectionRegion, areaOwners, mouseOverSteps, PropsUI.getInstance().getIconSize(), PropsUI.getInstance().getLineWidth(), gridSize, PropsUI.getInstance().getShadowSize(), PropsUI.getInstance().isAntiAliasingEnabled(), PropsUI.getInstance().getNoteFont().getName(), PropsUI.getInstance().getNoteFont().getHeight(), trans, PropsUI.getInstance().isIndicateSlowTransStepsEnabled());
transPainter.setMagnification(magnificationFactor);
transPainter.setStepLogMap(stepLogMap);
transPainter.setStartHopStep(startHopStep);
transPainter.setEndHopLocation(endHopLocation);
transPainter.setNoInputStep(noInputStep);
transPainter.setEndHopStep(endHopStep);
transPainter.setCandidateHopType(candidateHopType);
transPainter.setStartErrorHopStep(startErrorHopStep);
transPainter.setShowTargetStreamsStep(showTargetStreamsStep);
transPainter.buildTransformationImage();
Image img = (Image) gc.getImage();
gc.dispose();
return img;
}
use of org.pentaho.di.ui.spoon.SWTGC 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.ui.spoon.SWTGC in project pentaho-kettle by pentaho.
the class JobGraph method getJobImage.
public Image getJobImage(Device device, int x, int y, float magnificationFactor) {
GCInterface gc = new SWTGC(device, new Point(x, y), iconsize);
int gridSize = PropsUI.getInstance().isShowCanvasGridEnabled() ? PropsUI.getInstance().getCanvasGridSize() : 1;
JobPainter jobPainter = new JobPainter(gc, jobMeta, new Point(x, y), new SwtScrollBar(hori), new SwtScrollBar(vert), hop_candidate, drop_candidate, selectionRegion, areaOwners, mouseOverEntries, PropsUI.getInstance().getIconSize(), PropsUI.getInstance().getLineWidth(), gridSize, PropsUI.getInstance().getShadowSize(), PropsUI.getInstance().isAntiAliasingEnabled(), PropsUI.getInstance().getNoteFont().getName(), PropsUI.getInstance().getNoteFont().getHeight());
jobPainter.setMagnification(magnificationFactor);
jobPainter.setEntryLogMap(entryLogMap);
jobPainter.setStartHopEntry(startHopEntry);
jobPainter.setEndHopLocation(endHopLocation);
jobPainter.setEndHopEntry(endHopEntry);
jobPainter.setNoInputEntry(noInputEntry);
if (job != null) {
jobPainter.setJobEntryResults(job.getJobEntryResults());
} else {
jobPainter.setJobEntryResults(new ArrayList<JobEntryResult>());
}
List<JobEntryCopy> activeJobEntries = new ArrayList<>();
if (job != null) {
if (job.getActiveJobEntryJobs().size() > 0) {
activeJobEntries.addAll(job.getActiveJobEntryJobs().keySet());
}
if (job.getActiveJobEntryTransformations().size() > 0) {
activeJobEntries.addAll(job.getActiveJobEntryTransformations().keySet());
}
}
jobPainter.setActiveJobEntries(activeJobEntries);
jobPainter.drawJob();
return (Image) gc.getImage();
}
use of org.pentaho.di.ui.spoon.SWTGC 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.ui.spoon.SWTGC 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