Search in sources :

Example 36 with Point

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

the class TransPainter method drawTrans.

private void drawTrans(Point thumb) {
    if (!shadow && gridSize > 1) {
        drawGrid();
    }
    if (hori != null && vert != null) {
        hori.setThumb(thumb.x);
        vert.setThumb(thumb.y);
    }
    try {
        ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransPainterStart.id, this);
    } catch (KettleException e) {
        LogChannel.GENERAL.logError("Error in TransPainterStart extension point", e);
    }
    gc.setFont(EFont.NOTE);
    // First the notes
    for (int i = 0; i < transMeta.nrNotes(); i++) {
        NotePadMeta ni = transMeta.getNote(i);
        drawNote(ni);
    }
    gc.setFont(EFont.GRAPH);
    gc.setBackground(EColor.BACKGROUND);
    for (int i = 0; i < transMeta.nrTransHops(); i++) {
        TransHopMeta hi = transMeta.getTransHop(i);
        drawHop(hi);
    }
    EImage arrow;
    if (candidate != null) {
        drawHop(candidate, true);
    } else {
        if (startHopStep != null && endHopLocation != null) {
            Point fr = startHopStep.getLocation();
            Point to = endHopLocation;
            if (endHopStep == 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, startHopStep, endHopStep == null ? endHopLocation : endHopStep);
        } else if (endHopStep != null && endHopLocation != null) {
            Point fr = endHopLocation;
            Point to = endHopStep.getLocation();
            if (startHopStep == 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, theta, calcArrowLength(), 1.2, null, startHopStep == null ? endHopLocation : startHopStep, endHopStep);
        }
    }
    // Draw regular step appearance
    for (int i = 0; i < transMeta.nrSteps(); i++) {
        StepMeta stepMeta = transMeta.getStep(i);
        if (stepMeta.isDrawn()) {
            drawStep(stepMeta);
        }
    }
    if (slowStepIndicatorEnabled) {
        // Highlight possible bottlenecks
        for (int i = 0; i < transMeta.nrSteps(); i++) {
            StepMeta stepMeta = transMeta.getStep(i);
            if (stepMeta.isDrawn()) {
                checkDrawSlowStepIndicator(stepMeta);
            }
        }
    }
    // Draw step status indicators (running vs. done)
    for (int i = 0; i < transMeta.nrSteps(); i++) {
        StepMeta stepMeta = transMeta.getStep(i);
        if (stepMeta.isDrawn()) {
            drawStepStatusIndicator(stepMeta);
        }
    }
    // Draw performance table for selected step(s)
    for (int i = 0; i < transMeta.nrSteps(); i++) {
        StepMeta stepMeta = transMeta.getStep(i);
        if (stepMeta.isDrawn()) {
            drawStepPerformanceTable(stepMeta);
        }
    }
    int selectedStepsCount = 0;
    for (int i = transMeta.nrSteps() - 1; i >= 0; i--) {
        StepMeta stepMeta = transMeta.getStep(i);
        if (stepMeta.isSelected()) {
            selectedStepsCount++;
        }
    }
    TransPainterFlyoutExtension extension = null;
    for (int i = transMeta.nrSteps() - 1; i >= 0; i--) {
        StepMeta stepMeta = transMeta.getStep(i);
        if (stepMeta.isSelected() && stepMeta.isDrawn() && selectedStepsCount == 1) {
            extension = new TransPainterFlyoutExtension(gc, areaOwners, transMeta, stepMeta, translationX, translationY, magnification, area, offset);
            break;
        }
    }
    if (extension == null) {
        // pass null to notify extension that nothing is selected
        extension = new TransPainterFlyoutExtension(gc, areaOwners, transMeta, null, translationX, translationY, magnification, area, offset);
    }
    try {
        ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransPainterFlyout.id, extension);
    } catch (Exception e) {
        LogChannel.GENERAL.logError("Error calling extension point(s) for the transformation painter step", e);
    }
    // 
    if (noInputStep != null) {
        gc.setLineWidth(2);
        gc.setForeground(EColor.RED);
        Point n = noInputStep.getLocation();
        gc.drawLine(n.x - 5, n.y - 5, n.x + iconsize + 10, n.y + iconsize + 10);
        gc.drawLine(n.x - 5, n.y + iconsize + 5, n.x + iconsize + 5, n.y - 5);
    }
    if (drop_candidate != null) {
        gc.setLineStyle(ELineStyle.SOLID);
        gc.setForeground(EColor.BLACK);
        Point screen = real2screen(drop_candidate.x, drop_candidate.y);
        gc.drawRectangle(screen.x, screen.y, iconsize, iconsize);
    }
    try {
        ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransPainterEnd.id, this);
    } catch (KettleException e) {
        LogChannel.GENERAL.logError("Error in TransPainterEnd extension point", e);
    }
    if (!shadow) {
        drawRect(selrect);
    }
}
Also used : EImage(org.pentaho.di.core.gui.PrimitiveGCInterface.EImage) KettleException(org.pentaho.di.core.exception.KettleException) NotePadMeta(org.pentaho.di.core.NotePadMeta) 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)

Example 37 with Point

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

the class TransPainter method buildTransformationImage.

public void buildTransformationImage() {
    Point max = transMeta.getMaximum();
    Point thumb = getThumb(area, max);
    offset = getOffset(thumb, area);
    // First clear the image in the background color
    gc.setBackground(EColor.BACKGROUND);
    gc.fillRectangle(0, 0, area.x, area.y);
    // 
    if (shadowSize > 0) {
        shadow = true;
        gc.setTransform(translationX, translationY, shadowSize, magnification);
        gc.setAlpha(20);
        drawTrans(thumb);
    }
    // Draw the transformation onto the image
    // 
    shadow = false;
    gc.setTransform(translationX, translationY, 0, magnification);
    gc.setAlpha(255);
    drawTrans(thumb);
    gc.dispose();
}
Also used : Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 38 with Point

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

the class TransPainter method getNamePosition.

public Point getNamePosition(String string, Point screen, int iconsize) {
    Point textsize = gc.textExtent(string);
    int xpos = screen.x + (iconsize / 2) - (textsize.x / 2);
    int ypos = screen.y + iconsize + 5;
    return new Point(xpos, ypos);
}
Also used : 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)

Example 39 with Point

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

the class StepMeta method setLocation.

@Override
public void setLocation(int x, int y) {
    int nx = (x >= 0 ? x : 0);
    int ny = (y >= 0 ? y : 0);
    Point loc = new Point(nx, ny);
    if (!loc.equals(location)) {
        setChanged();
    }
    location = loc;
}
Also used : Point(org.pentaho.di.core.gui.Point) Point(org.pentaho.di.core.gui.Point)

Example 40 with Point

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

the class StepMeta method replaceMeta.

public void replaceMeta(StepMeta stepMeta) {
    // --> StepPlugin.id
    this.stepid = stepMeta.stepid;
    this.name = stepMeta.name;
    if (stepMeta.stepMetaInterface != null) {
        setStepMetaInterface((StepMetaInterface) stepMeta.stepMetaInterface.clone());
    } else {
        this.stepMetaInterface = null;
    }
    this.selected = stepMeta.selected;
    this.distributes = stepMeta.distributes;
    this.setRowDistribution(stepMeta.getRowDistribution());
    this.copiesString = stepMeta.copiesString;
    // force re-calculation
    this.copiesCache = null;
    if (stepMeta.location != null) {
        this.location = new Point(stepMeta.location.x, stepMeta.location.y);
    } else {
        this.location = null;
    }
    this.drawstep = stepMeta.drawstep;
    this.description = stepMeta.description;
    this.terminator = stepMeta.terminator;
    if (stepMeta.stepPartitioningMeta != null) {
        this.stepPartitioningMeta = stepMeta.stepPartitioningMeta.clone();
    } else {
        this.stepPartitioningMeta = null;
    }
    if (stepMeta.clusterSchema != null) {
        this.clusterSchema = stepMeta.clusterSchema.clone();
    } else {
        this.clusterSchema = null;
    }
    // temporary to resolve later.
    this.clusterSchemaName = stepMeta.clusterSchemaName;
    // Also replace the remote steps with cloned versions...
    // 
    this.remoteInputSteps = new ArrayList<RemoteStep>();
    for (RemoteStep remoteStep : stepMeta.remoteInputSteps) {
        this.remoteInputSteps.add((RemoteStep) remoteStep.clone());
    }
    this.remoteOutputSteps = new ArrayList<RemoteStep>();
    for (RemoteStep remoteStep : stepMeta.remoteOutputSteps) {
        this.remoteOutputSteps.add((RemoteStep) remoteStep.clone());
    }
    // 
    if (stepMeta.stepErrorMeta != null) {
        this.stepErrorMeta = stepMeta.stepErrorMeta.clone();
    }
    this.attributesMap = copyStringMap(stepMeta.attributesMap);
    // this.setShared(stepMeta.isShared());
    this.id = stepMeta.getObjectId();
    this.setChanged(true);
}
Also used : Point(org.pentaho.di.core.gui.Point)

Aggregations

Point (org.pentaho.di.core.gui.Point)141 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)72 Test (org.junit.Test)37 StepMeta (org.pentaho.di.trans.step.StepMeta)34 NotePadMeta (org.pentaho.di.core.NotePadMeta)29 KettleException (org.pentaho.di.core.exception.KettleException)28 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)28 PrintWriter (java.io.PrintWriter)26 HttpServletRequest (javax.servlet.http.HttpServletRequest)26 HttpServletResponse (javax.servlet.http.HttpServletResponse)26 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)26 TransMeta (org.pentaho.di.trans.TransMeta)25 StringWriter (java.io.StringWriter)24 AreaOwner (org.pentaho.di.core.gui.AreaOwner)22 Trans (org.pentaho.di.trans.Trans)18 JobMeta (org.pentaho.di.job.JobMeta)17 ArrayList (java.util.ArrayList)16 TransHopMeta (org.pentaho.di.trans.TransHopMeta)14 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)14 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)12