Search in sources :

Example 6 with EImage

use of org.pentaho.di.core.gui.PrimitiveGCInterface.EImage in project pentaho-kettle by pentaho.

the class TransPainter method drawArrow.

@Override
protected void drawArrow(EImage arrow, int x1, int y1, int x2, int y2, double theta, int size, double factor, TransHopMeta transHop, Object startObject, Object endObject) {
    int mx, my;
    int a, b, dist;
    double angle;
    gc.drawLine(x1, y1, x2, y2);
    // in between 2 points
    mx = x1 + (x2 - x1) / 2;
    my = y1 + (y2 - y1) / 2;
    a = Math.abs(x2 - x1);
    b = Math.abs(y2 - y1);
    dist = (int) Math.sqrt(a * a + b * b);
    // 0-->100%)
    if (factor < 0) {
        if (dist >= 2 * iconsize) {
            factor = 1.3;
        } else {
            factor = 1.2;
        }
    }
    // in between 2 points
    mx = (int) (x1 + factor * (x2 - x1) / 2);
    my = (int) (y1 + factor * (y2 - y1) / 2);
    // calculate points for arrowhead
    // calculate points for arrowhead
    angle = Math.atan2(y2 - y1, x2 - x1) + (Math.PI / 2);
    boolean q1 = Math.toDegrees(angle) >= 0 && Math.toDegrees(angle) <= 90;
    boolean q2 = Math.toDegrees(angle) > 90 && Math.toDegrees(angle) <= 180;
    boolean q3 = Math.toDegrees(angle) > 180 && Math.toDegrees(angle) <= 270;
    boolean q4 = Math.toDegrees(angle) > 270 || Math.toDegrees(angle) < 0;
    if (q1 || q3) {
        gc.drawImage(arrow, mx + 1, my, magnification, angle);
    } else if (q2 || q4) {
        gc.drawImage(arrow, mx, my, magnification, angle);
    }
    if (startObject instanceof StepMeta && endObject instanceof StepMeta) {
        factor = 0.8;
        StepMeta fs = (StepMeta) startObject;
        StepMeta ts = (StepMeta) endObject;
        // in between 2 points
        mx = (int) (x1 + factor * (x2 - x1) / 2) - 8;
        my = (int) (y1 + factor * (y2 - y1) / 2) - 8;
        boolean errorHop = fs.isSendingErrorRowsToStep(ts) || (startErrorHopStep && fs.equals(startHopStep));
        boolean targetHop = Const.indexOfString(ts.getName(), fs.getStepMetaInterface().getStepIOMeta().getTargetStepnames()) >= 0;
        if (targetHop) {
            StepIOMetaInterface ioMeta = fs.getStepMetaInterface().getStepIOMeta();
            StreamInterface targetStream = ioMeta.findTargetStream(ts);
            if (targetStream != null) {
                EImage hopsIcon = BasePainter.getStreamIconImage(targetStream.getStreamIcon());
                Point bounds = gc.getImageBounds(hopsIcon);
                gc.drawImage(hopsIcon, mx, my, magnification);
                if (!shadow) {
                    areaOwners.add(new AreaOwner(AreaType.STEP_TARGET_HOP_ICON, mx, my, bounds.x, bounds.y, offset, fs, targetStream));
                }
            }
        } else if (fs.isDistributes() && fs.getRowDistribution() != null && !ts.getStepPartitioningMeta().isMethodMirror() && !errorHop) {
            // Draw the custom row distribution plugin icon
            // 
            EImage eImage = fs.getRowDistribution().getDistributionImage();
            if (eImage != null) {
                Point bounds = gc.getImageBounds(eImage);
                gc.drawImage(eImage, mx, my, magnification);
                if (!shadow) {
                    areaOwners.add(new AreaOwner(AreaType.ROW_DISTRIBUTION_ICON, mx, my, bounds.x, bounds.y, offset, fs, STRING_ROW_DISTRIBUTION));
                }
                mx += 16;
            }
        } else if (!fs.isDistributes() && !ts.getStepPartitioningMeta().isMethodMirror() && !errorHop) {
            // Draw the copy icon on the hop
            // 
            Point bounds = gc.getImageBounds(EImage.COPY_ROWS);
            gc.drawImage(EImage.COPY_ROWS, mx, my, magnification);
            if (!shadow) {
                areaOwners.add(new AreaOwner(AreaType.HOP_COPY_ICON, mx, my, bounds.x, bounds.y, offset, fs, STRING_HOP_TYPE_COPY));
            }
            mx += 16;
        }
        if (errorHop) {
            Point bounds = gc.getImageBounds(EImage.COPY_ROWS);
            gc.drawImage(EImage.FALSE, mx, my, magnification);
            if (!shadow) {
                areaOwners.add(new AreaOwner(AreaType.HOP_ERROR_ICON, mx, my, bounds.x, bounds.y, offset, fs, ts));
            }
            mx += 16;
        }
        StepIOMetaInterface ioMeta = ts.getStepMetaInterface().getStepIOMeta();
        String[] infoStepnames = ioMeta.getInfoStepnames();
        if ((candidateHopType == StreamType.INFO && ts.equals(endHopStep) && fs.equals(startHopStep)) || Const.indexOfString(fs.getName(), infoStepnames) >= 0) {
            Point bounds = gc.getImageBounds(EImage.INFO);
            gc.drawImage(EImage.INFO, mx, my, magnification);
            if (!shadow) {
                areaOwners.add(new AreaOwner(AreaType.HOP_INFO_ICON, mx, my, bounds.x, bounds.y, offset, fs, ts));
            }
            mx += 16;
        }
        // 
        if (!Utils.isEmpty(infoStepnames)) {
            // 
            for (String infoStep : infoStepnames) {
                if (fs.getName().equalsIgnoreCase(infoStep)) {
                    // 
                    if (fs.getCopies() > 1) {
                        // This is not a desirable situation, it will always end in error.
                        // As such, it's better not to give feedback on it.
                        // We do this by drawing an error icon over the hop...
                        // 
                        gc.drawImage(EImage.ERROR, mx, my, magnification);
                        if (!shadow) {
                            areaOwners.add(new AreaOwner(AreaType.HOP_INFO_STEP_COPIES_ERROR, mx, my, MINI_ICON_SIZE, MINI_ICON_SIZE, offset, fs, ts));
                        }
                        mx += 16;
                    }
                }
            }
        }
    }
    TransPainterExtension extension = new TransPainterExtension(gc, shadow, areaOwners, transMeta, null, transHop, x1, y1, x2, y2, mx, my, offset, iconsize);
    try {
        ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransPainterArrow.id, extension);
    } catch (Exception e) {
        LogChannel.GENERAL.logError("Error calling extension point(s) for the transformation painter arrow", e);
    }
}
Also used : EImage(org.pentaho.di.core.gui.PrimitiveGCInterface.EImage) StepIOMetaInterface(org.pentaho.di.trans.step.StepIOMetaInterface) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) StepMeta(org.pentaho.di.trans.step.StepMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) KettleException(org.pentaho.di.core.exception.KettleException) AreaOwner(org.pentaho.di.core.gui.AreaOwner) StreamInterface(org.pentaho.di.trans.step.errorhandling.StreamInterface)

Example 7 with EImage

use of org.pentaho.di.core.gui.PrimitiveGCInterface.EImage in project pentaho-kettle by pentaho.

the class JobPainter method drawArrow.

@Override
protected void drawArrow(EImage arrow, int x1, int y1, int x2, int y2, double theta, int size, double factor, JobHopMeta jobHop, Object startObject, Object endObject) {
    int mx, my;
    int a, b, dist;
    double angle;
    // gc.setLineWidth(1);
    // WuLine(gc, black, x1, y1, x2, y2);
    gc.drawLine(x1, y1, x2, y2);
    // What's the distance between the 2 points?
    a = Math.abs(x2 - x1);
    b = Math.abs(y2 - y1);
    dist = (int) Math.sqrt(a * a + b * b);
    // 0-->100%)
    if (factor < 0) {
        if (dist >= 2 * iconsize) {
            factor = 1.3;
        } else {
            factor = 1.2;
        }
    }
    // in between 2 points
    mx = (int) (x1 + factor * (x2 - x1) / 2);
    my = (int) (y1 + factor * (y2 - y1) / 2);
    // calculate points for arrowhead
    angle = Math.atan2(y2 - y1, x2 - x1) + (Math.PI / 2);
    boolean q1 = Math.toDegrees(angle) >= 0 && Math.toDegrees(angle) <= 90;
    boolean q2 = Math.toDegrees(angle) > 90 && Math.toDegrees(angle) <= 180;
    boolean q3 = Math.toDegrees(angle) > 180 && Math.toDegrees(angle) <= 270;
    boolean q4 = Math.toDegrees(angle) > 270 || Math.toDegrees(angle) < 0;
    if (q1 || q3) {
        gc.drawImage(arrow, mx + 1, my, magnification, angle);
    } else if (q2 || q4) {
        gc.drawImage(arrow, mx, my, magnification, angle);
    }
    // Display an icon above the hop...
    // 
    factor = 0.8;
    // in between 2 points
    mx = (int) (x1 + factor * (x2 - x1) / 2) - 8;
    my = (int) (y1 + factor * (y2 - y1) / 2) - 8;
    if (jobHop != null) {
        EImage hopsIcon;
        if (jobHop.isUnconditional()) {
            hopsIcon = EImage.UNCONDITIONAL;
        } else {
            if (jobHop.getEvaluation()) {
                hopsIcon = EImage.TRUE;
            } else {
                hopsIcon = EImage.FALSE;
            }
        }
        Point bounds = gc.getImageBounds(hopsIcon);
        gc.drawImage(hopsIcon, mx, my, magnification);
        if (!shadow) {
            areaOwners.add(new AreaOwner(AreaType.JOB_HOP_ICON, mx, my, bounds.x, bounds.y, offset, subject, jobHop));
        }
        if (jobHop.getFromEntry().isLaunchingInParallel()) {
            factor = 1;
            // in between 2 points
            mx = (int) (x1 + factor * (x2 - x1) / 2) - 8;
            my = (int) (y1 + factor * (y2 - y1) / 2) - 8;
            hopsIcon = EImage.PARALLEL;
            gc.drawImage(hopsIcon, mx, my, magnification);
            if (!shadow) {
                areaOwners.add(new AreaOwner(AreaType.JOB_HOP_PARALLEL_ICON, mx, my, bounds.x, bounds.y, offset, subject, jobHop));
            }
        }
        JobPainterExtension extension = new JobPainterExtension(gc, shadow, areaOwners, jobMeta, jobHop, x1, y1, x2, y2, mx, my, offset);
        try {
            ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.JobPainterArrow.id, extension);
        } catch (Exception e) {
            LogChannel.GENERAL.logError("Error calling extension point(s) for the job painter arrow", e);
        }
    }
}
Also used : EImage(org.pentaho.di.core.gui.PrimitiveGCInterface.EImage) AreaOwner(org.pentaho.di.core.gui.AreaOwner) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) KettleException(org.pentaho.di.core.exception.KettleException)

Example 8 with EImage

use of org.pentaho.di.core.gui.PrimitiveGCInterface.EImage in project pentaho-kettle by pentaho.

the class JobPainter method drawLine.

/**
 * Calculates line coordinates from center to center.
 */
protected void drawLine(JobHopMeta jobHop, boolean is_candidate) {
    int[] line = getLine(jobHop.getFromEntry(), jobHop.getToEntry());
    gc.setLineWidth(linewidth);
    EColor col;
    if (jobHop.getFromEntry().isLaunchingInParallel()) {
        gc.setLineStyle(ELineStyle.PARALLEL);
    } else {
        gc.setLineStyle(ELineStyle.SOLID);
    }
    EImage arrow;
    if (is_candidate) {
        col = EColor.BLUE;
        arrow = EImage.ARROW_CANDIDATE;
    } else if (jobHop.isEnabled()) {
        if (jobHop.isUnconditional()) {
            col = EColor.HOP_DEFAULT;
            arrow = EImage.ARROW_DEFAULT;
        } else {
            if (jobHop.getEvaluation()) {
                col = EColor.HOP_OK;
                arrow = EImage.ARROW_OK;
            } else {
                col = EColor.RED;
                arrow = EImage.ARROW_ERROR;
                gc.setLineStyle(ELineStyle.DASH);
            }
        }
    } else {
        col = EColor.GRAY;
        arrow = EImage.ARROW_DISABLED;
    }
    gc.setForeground(col);
    if (jobHop.isSplit()) {
        gc.setLineWidth(linewidth + 2);
    }
    drawArrow(arrow, line, jobHop);
    if (jobHop.isSplit()) {
        gc.setLineWidth(linewidth);
    }
    gc.setForeground(EColor.BLACK);
    gc.setBackground(EColor.BACKGROUND);
    gc.setLineStyle(ELineStyle.SOLID);
}
Also used : EImage(org.pentaho.di.core.gui.PrimitiveGCInterface.EImage) EColor(org.pentaho.di.core.gui.PrimitiveGCInterface.EColor)

Aggregations

EImage (org.pentaho.di.core.gui.PrimitiveGCInterface.EImage)8 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)7 Point (org.pentaho.di.core.gui.Point)7 KettleException (org.pentaho.di.core.exception.KettleException)5 AreaOwner (org.pentaho.di.core.gui.AreaOwner)4 StepIOMetaInterface (org.pentaho.di.trans.step.StepIOMetaInterface)3 StreamInterface (org.pentaho.di.trans.step.errorhandling.StreamInterface)3 NotePadMeta (org.pentaho.di.core.NotePadMeta)2 EColor (org.pentaho.di.core.gui.PrimitiveGCInterface.EColor)2 StepMeta (org.pentaho.di.trans.step.StepMeta)2 Result (org.pentaho.di.core.Result)1 ELineStyle (org.pentaho.di.core.gui.PrimitiveGCInterface.ELineStyle)1 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)1 PartitionSchema (org.pentaho.di.partition.PartitionSchema)1 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)1 StepPartitioningMeta (org.pentaho.di.trans.step.StepPartitioningMeta)1