Search in sources :

Example 1 with EImage

use of org.apache.hop.core.gui.IGc.EImage in project hop by apache.

the class WorkflowPainter method drawLine.

/**
 * Calculates line coordinates from center to center.
 */
protected void drawLine(WorkflowHopMeta workflowHop, boolean isCandidate) throws HopException {
    int[] line = getLine(workflowHop.getFromAction(), workflowHop.getToAction());
    gc.setLineWidth(lineWidth);
    EColor color;
    if (workflowHop.getFromAction().isLaunchingInParallel()) {
        gc.setLineStyle(ELineStyle.PARALLEL);
    } else {
        gc.setLineStyle(ELineStyle.SOLID);
    }
    EImage arrow;
    if (isCandidate) {
        color = EColor.BLUE;
        arrow = EImage.ARROW_CANDIDATE;
    } else if (workflowHop.isEnabled()) {
        if (workflowHop.isUnconditional()) {
            color = EColor.HOP_DEFAULT;
            arrow = EImage.ARROW_DEFAULT;
        } else {
            if (workflowHop.getEvaluation()) {
                color = EColor.HOP_TRUE;
                arrow = EImage.ARROW_TRUE;
            } else {
                color = EColor.HOP_FALSE;
                arrow = EImage.ARROW_FALSE;
            }
        }
    } else {
        color = EColor.GRAY;
        arrow = EImage.ARROW_DISABLED;
    }
    gc.setForeground(color);
    if (workflowHop.isSplit()) {
        gc.setLineWidth(lineWidth + 2);
    }
    drawArrow(arrow, line, workflowHop);
    if (workflowHop.isSplit()) {
        gc.setLineWidth(lineWidth);
    }
    gc.setForeground(EColor.BLACK);
    gc.setBackground(EColor.BACKGROUND);
    gc.setLineStyle(ELineStyle.SOLID);
}
Also used : EImage(org.apache.hop.core.gui.IGc.EImage) EColor(org.apache.hop.core.gui.IGc.EColor)

Example 2 with EImage

use of org.apache.hop.core.gui.IGc.EImage in project hop by apache.

the class WorkflowPainter method drawArrow.

@Override
protected void drawArrow(EImage arrow, int x1, int y1, int x2, int y2, double theta, int size, double factor, WorkflowHopMeta workflowHop, Object startObject, Object endObject) throws HopException {
    int mx;
    int my;
    int a;
    int b;
    int dist;
    double angle;
    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, my + 1, 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) - miniIconSize / 2;
    my = (int) (y1 + factor * (y2 - y1) / 2) - miniIconSize / 2;
    if (workflowHop != null) {
        if (workflowHop.getFromAction().isLaunchingInParallel()) {
            // in between 2 points
            mx = (int) (x1 + factor * (x2 - x1) / 2);
            my = (int) (y1 + factor * (y2 - y1) / 2);
            EImage image = (workflowHop.isEnabled()) ? EImage.PARALLEL : EImage.PARALLEL_DISABLED;
            gc.drawImage(image, mx, my, magnification, angle);
            areaOwners.add(new AreaOwner(AreaType.WORKFLOW_HOP_PARALLEL_ICON, mx, my, miniIconSize, miniIconSize, offset, subject, workflowHop));
        } else {
            EImage image;
            if (workflowHop.isUnconditional()) {
                image = (workflowHop.isEnabled()) ? EImage.UNCONDITIONAL : EImage.UNCONDITIONAL_DISABLED;
            } else {
                if (workflowHop.getEvaluation()) {
                    image = (workflowHop.isEnabled()) ? EImage.TRUE : EImage.TRUE_DISABLED;
                } else {
                    image = (workflowHop.isEnabled()) ? EImage.FALSE : EImage.FALSE_DISABLED;
                }
            }
            gc.drawImage(image, mx, my, magnification);
            areaOwners.add(new AreaOwner(AreaType.WORKFLOW_HOP_ICON, mx, my, miniIconSize, miniIconSize, offset, subject, workflowHop));
        }
        WorkflowPainterExtension extension = new WorkflowPainterExtension(gc, areaOwners, workflowMeta, workflowHop, null, x1, y1, x2, y2, mx, my, offset, iconSize);
        try {
            ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, variables, HopExtensionPoint.WorkflowPainterArrow.id, extension);
        } catch (Exception e) {
            LogChannel.GENERAL.logError("Error calling extension point(s) for the workflow painter arrow", e);
        }
    }
}
Also used : EImage(org.apache.hop.core.gui.IGc.EImage) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) HopException(org.apache.hop.core.exception.HopException)

Example 3 with EImage

use of org.apache.hop.core.gui.IGc.EImage in project hop by apache.

the class WorkflowPainter method drawActions.

private void drawActions() throws HopException {
    if (gridSize > 1) {
        drawGrid();
    }
    try {
        ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, variables, HopExtensionPoint.WorkflowPainterStart.id, this);
    } catch (HopException e) {
        LogChannel.GENERAL.logError("Error in JobPainterStart extension point", e);
    }
    // First draw the notes...
    gc.setFont(EFont.NOTE);
    for (int i = 0; i < workflowMeta.nrNotes(); i++) {
        NotePadMeta ni = workflowMeta.getNote(i);
        drawNote(ni);
    }
    gc.setFont(EFont.GRAPH);
    // ... and then the rest on top of it...
    for (int i = 0; i < workflowMeta.nrWorkflowHops(); i++) {
        WorkflowHopMeta hi = workflowMeta.getWorkflowHop(i);
        drawWorkflowHop(hi, false);
    }
    EImage arrow;
    if (candidate != null) {
        drawWorkflowHop(candidate, true);
    } else {
        if (startHopAction != null && endHopLocation != null) {
            Point fr = startHopAction.getLocation();
            Point to = endHopLocation;
            if (endHopAction == null) {
                gc.setForeground(EColor.GRAY);
                arrow = EImage.ARROW_DISABLED;
            } else {
                gc.setForeground(EColor.BLUE);
                arrow = EImage.ARROW_DEFAULT;
            }
            Point start = real2screen(fr.x + iconSize / 2, fr.y + iconSize / 2);
            Point end = real2screen(to.x, to.y);
            drawArrow(arrow, start.x, start.y, end.x, end.y, theta, calcArrowLength(), 1.2, null, startHopAction, endHopAction == null ? endHopLocation : endHopAction);
        } else if (endHopAction != null && endHopLocation != null) {
            Point fr = endHopLocation;
            Point to = endHopAction.getLocation();
            if (startHopAction == null) {
                gc.setForeground(EColor.GRAY);
                arrow = EImage.ARROW_DISABLED;
            } else {
                gc.setForeground(EColor.BLUE);
                arrow = EImage.ARROW_DEFAULT;
            }
            Point start = real2screen(fr.x, fr.y);
            Point end = real2screen(to.x + iconSize / 2, to.y + iconSize / 2);
            drawArrow(arrow, start.x, start.y, end.x, end.y + iconSize / 2, theta, calcArrowLength(), 1.2, null, startHopAction == null ? endHopLocation : startHopAction, endHopAction);
        }
    }
    for (int j = 0; j < workflowMeta.nrActions(); j++) {
        ActionMeta je = workflowMeta.getAction(j);
        drawAction(je);
    }
    // 
    if (noInputAction != null) {
        gc.setLineWidth(2);
        gc.setForeground(EColor.RED);
        Point n = noInputAction.getLocation();
        gc.drawLine(offset.x + n.x - 5, offset.y + n.y - 5, offset.x + n.x + iconSize + 5, offset.y + n.y + iconSize + 5);
        gc.drawLine(offset.x + n.x - 5, offset.y + n.y + iconSize + 5, offset.x + n.x + iconSize + 5, offset.y + n.y - 5);
    }
    try {
        ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, variables, HopExtensionPoint.WorkflowPainterEnd.id, this);
    } catch (HopException e) {
        LogChannel.GENERAL.logError("Error in JobPainterEnd extension point", e);
    }
    drawRect(selectionRectangle);
}
Also used : EImage(org.apache.hop.core.gui.IGc.EImage) ActionMeta(org.apache.hop.workflow.action.ActionMeta) HopException(org.apache.hop.core.exception.HopException) NotePadMeta(org.apache.hop.core.NotePadMeta) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint)

Aggregations

EImage (org.apache.hop.core.gui.IGc.EImage)3 HopException (org.apache.hop.core.exception.HopException)2 HopExtensionPoint (org.apache.hop.core.extension.HopExtensionPoint)2 NotePadMeta (org.apache.hop.core.NotePadMeta)1 EColor (org.apache.hop.core.gui.IGc.EColor)1 ActionMeta (org.apache.hop.workflow.action.ActionMeta)1