Search in sources :

Example 1 with SWTGC

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;
}
Also used : GCInterface(org.pentaho.di.core.gui.GCInterface) SwtScrollBar(org.pentaho.di.ui.spoon.SwtScrollBar) SWTGC(org.pentaho.di.ui.spoon.SWTGC) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) TransPainter(org.pentaho.di.trans.TransPainter) SwtUniversalImage(org.pentaho.di.core.SwtUniversalImage) Image(org.eclipse.swt.graphics.Image) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 2 with SWTGC

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();
}
Also used : SWTGC(org.pentaho.di.ui.spoon.SWTGC) MetricsPainter(org.pentaho.di.core.logging.MetricsPainter) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.pentaho.di.core.gui.Point) MetricsDuration(org.pentaho.di.core.metrics.MetricsDuration) Point(org.pentaho.di.core.gui.Point)

Example 3 with SWTGC

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();
}
Also used : GCInterface(org.pentaho.di.core.gui.GCInterface) SwtScrollBar(org.pentaho.di.ui.spoon.SwtScrollBar) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobPainter(org.pentaho.di.job.JobPainter) SWTGC(org.pentaho.di.ui.spoon.SWTGC) ArrayList(java.util.ArrayList) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) Image(org.eclipse.swt.graphics.Image) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) JobEntryResult(org.pentaho.di.job.JobEntryResult)

Example 4 with SWTGC

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();
}
Also used : SWTGC(org.pentaho.di.ui.spoon.SWTGC) MetricsPainter(org.pentaho.di.core.logging.MetricsPainter) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.pentaho.di.core.gui.Point) MetricsDuration(org.pentaho.di.core.metrics.MetricsDuration) Point(org.pentaho.di.core.gui.Point)

Example 5 with SWTGC

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;
}
Also used : SWTGC(org.pentaho.di.ui.spoon.SWTGC) MetricsPainter(org.pentaho.di.core.logging.MetricsPainter) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.pentaho.di.core.gui.Point) GC(org.eclipse.swt.graphics.GC) SWTGC(org.pentaho.di.ui.spoon.SWTGC) Image(org.eclipse.swt.graphics.Image) Point(org.pentaho.di.core.gui.Point) Display(org.eclipse.swt.widgets.Display)

Aggregations

Point (org.pentaho.di.core.gui.Point)5 SWTGC (org.pentaho.di.ui.spoon.SWTGC)5 Image (org.eclipse.swt.graphics.Image)3 Rectangle (org.eclipse.swt.graphics.Rectangle)3 MetricsPainter (org.pentaho.di.core.logging.MetricsPainter)3 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)2 GCInterface (org.pentaho.di.core.gui.GCInterface)2 MetricsDuration (org.pentaho.di.core.metrics.MetricsDuration)2 SwtScrollBar (org.pentaho.di.ui.spoon.SwtScrollBar)2 ArrayList (java.util.ArrayList)1 GC (org.eclipse.swt.graphics.GC)1 Display (org.eclipse.swt.widgets.Display)1 SwtUniversalImage (org.pentaho.di.core.SwtUniversalImage)1 JobEntryResult (org.pentaho.di.job.JobEntryResult)1 JobPainter (org.pentaho.di.job.JobPainter)1 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)1 TransPainter (org.pentaho.di.trans.TransPainter)1