Search in sources :

Example 31 with Point

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

the class StarModelPainter method getCirclePoints.

private List<TablePoint> getCirclePoints(Point center, int width, int heigth, List<LogicalTable> tableList) {
    List<TablePoint> points = new ArrayList<TablePoint>();
    int nrPoints = tableList.size();
    double alpha = Math.PI * 2 / nrPoints;
    for (int i = 0; i < nrPoints; i++) {
        double tetha = alpha * i;
        Point point = new Point(center.x, center.y);
        point.x += (int) Math.round(Math.cos(tetha) * width);
        point.y += (int) Math.round(Math.sin(tetha) * (heigth - 5));
        points.add(new TablePoint(tableList.get(i), point));
    }
    return points;
}
Also used : ArrayList(java.util.ArrayList) Point(org.pentaho.di.core.gui.Point) Point(org.pentaho.di.core.gui.Point)

Example 32 with Point

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

the class JobGenerator method generateDimensionTransformation.

/**
 * Generates a template
 * @param databaseMeta
 * @param logicalModel
 * @return
 */
public TransMeta generateDimensionTransformation(DatabaseMeta databaseMeta, LogicalTable logicalTable) {
    TransMeta transMeta = new TransMeta();
    String tableName = ConceptUtil.getName(logicalTable, locale);
    String tableDescription = ConceptUtil.getDescription(logicalTable, locale);
    DimensionType dimensionType = ConceptUtil.getDimensionType(logicalTable);
    transMeta.setName("Update dimension '" + tableName + "'");
    transMeta.setDescription(tableDescription);
    // Let's not forget to add the target database
    // 
    transMeta.addDatabase(databaseMeta);
    Point location = new Point(GRAPH_LEFT, GRAPH_TOP);
    // Find all the source columns and source tables and put them into a table input step...
    // 
    StepMeta inputStep = generateTableInputStepFromLogicalTable(logicalTable);
    DatabaseMeta sourceDatabaseMeta = ((TableInputMeta) inputStep.getStepMetaInterface()).getDatabaseMeta();
    if (sourceDatabaseMeta != null)
        transMeta.addOrReplaceDatabase(sourceDatabaseMeta);
    inputStep.setLocation(location.x, location.y);
    nextLocation(location);
    transMeta.addStep(inputStep);
    StepMeta lastStep = inputStep;
    // Generate an dimension lookup/update step for each table
    // 
    StepMeta dimensionStep;
    if (dimensionType == DimensionType.SLOWLY_CHANGING_DIMENSION) {
        dimensionStep = generateDimensionLookupStepFromLogicalTable(databaseMeta, logicalTable);
    } else {
        dimensionStep = generateCombinationLookupStepFromLogicalTable(databaseMeta, logicalTable);
    }
    dimensionStep.setLocation(location.x, location.y);
    nextLocation(location);
    transMeta.addStep(dimensionStep);
    TransHopMeta transHop = new TransHopMeta(lastStep, dimensionStep);
    transMeta.addTransHop(transHop);
    return transMeta;
}
Also used : DimensionType(org.pentaho.di.starmodeler.DimensionType) TransMeta(org.pentaho.di.trans.TransMeta) Point(org.pentaho.di.core.gui.Point) TransHopMeta(org.pentaho.di.trans.TransHopMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) TableInputMeta(org.pentaho.di.trans.steps.tableinput.TableInputMeta)

Example 33 with Point

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

the class TransMeta method getMaximum.

/**
 * Gets the maximum size of the canvas by calculating the maximum location of a step.
 *
 * @return Maximum coordinate of a step in the transformation + (100,100) for safety.
 */
public Point getMaximum() {
    int maxx = 0, maxy = 0;
    for (int i = 0; i < nrSteps(); i++) {
        StepMeta stepMeta = getStep(i);
        Point loc = stepMeta.getLocation();
        if (loc.x > maxx) {
            maxx = loc.x;
        }
        if (loc.y > maxy) {
            maxy = loc.y;
        }
    }
    for (int i = 0; i < nrNotes(); i++) {
        NotePadMeta notePadMeta = getNote(i);
        Point loc = notePadMeta.getLocation();
        if (loc.x + notePadMeta.width > maxx) {
            maxx = loc.x + notePadMeta.width;
        }
        if (loc.y + notePadMeta.height > maxy) {
            maxy = loc.y + notePadMeta.height;
        }
    }
    return new Point(maxx + 100, maxy + 100);
}
Also used : Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) NotePadMeta(org.pentaho.di.core.NotePadMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 34 with Point

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

the class TransMeta method getStep.

/**
 * Find the step that is located on a certain point on the canvas, taking into account the icon size.
 *
 * @param x
 *          the x-coordinate of the point queried
 * @param y
 *          the y-coordinate of the point queried
 * @param iconsize
 *          the iconsize
 * @return The step information if a step is located at the point. Otherwise, if no step was found: null.
 */
public StepMeta getStep(int x, int y, int iconsize) {
    int i, s;
    s = steps.size();
    for (i = s - 1; i >= 0; i--) {
        // Back to front because drawing goes from start to end
        StepMeta stepMeta = steps.get(i);
        if (partOfTransHop(stepMeta) || stepMeta.isDrawn()) {
            // Only consider steps from active or inactive hops!
            Point p = stepMeta.getLocation();
            if (p != null) {
                if (x >= p.x && x <= p.x + iconsize && y >= p.y && y <= p.y + iconsize + 20) {
                    return stepMeta;
                }
            }
        }
    }
    return null;
}
Also used : 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)

Example 35 with Point

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

the class TransPainter method drawStepPerformanceTable.

private void drawStepPerformanceTable(StepMeta stepMeta) {
    if (stepMeta == null) {
        return;
    }
    // draw optional performance indicator
    if (trans != null) {
        Point pt = stepMeta.getLocation();
        if (pt == null) {
            pt = new Point(50, 50);
        }
        Point screen = real2screen(pt.x, pt.y);
        int x = screen.x;
        int y = screen.y;
        List<StepInterface> steps = trans.findBaseSteps(stepMeta.getName());
        // draw mouse over performance indicator
        if (trans.isRunning()) {
            if (stepMeta.isSelected()) {
                // determine popup dimensions up front
                int popupX = x;
                int popupY = y;
                int popupWidth = 0;
                int popupHeight = 1;
                gc.setFont(EFont.SMALL);
                Point p = gc.textExtent("0000000000");
                int colWidth = p.x + MINI_ICON_MARGIN;
                int rowHeight = p.y + MINI_ICON_MARGIN;
                int titleWidth = 0;
                // calculate max title width to get the colum with
                String[] titles = TransPainter.getPeekTitles();
                for (String title : titles) {
                    Point titleExtent = gc.textExtent(title);
                    titleWidth = Math.max(titleExtent.x + MINI_ICON_MARGIN, titleWidth);
                    popupHeight += titleExtent.y + MINI_ICON_MARGIN;
                }
                popupWidth = titleWidth + 2 * MINI_ICON_MARGIN;
                // determine total popup width
                popupWidth += steps.size() * colWidth;
                // determine popup position
                popupX = popupX + (iconsize - popupWidth) / 2;
                popupY = popupY - popupHeight - MINI_ICON_MARGIN;
                // draw the frame
                gc.setForeground(EColor.DARKGRAY);
                gc.setBackground(EColor.LIGHTGRAY);
                gc.setLineWidth(1);
                gc.fillRoundRectangle(popupX, popupY, popupWidth, popupHeight, 7, 7);
                // draw the title columns
                // gc.setBackground(EColor.BACKGROUND);
                // gc.fillRoundRectangle(popupX, popupY, titleWidth+MINI_ICON_MARGIN, popupHeight, 7, 7);
                gc.setBackground(EColor.LIGHTGRAY);
                gc.drawRoundRectangle(popupX, popupY, popupWidth, popupHeight, 7, 7);
                for (int i = 0, barY = popupY; i < titles.length; i++) {
                    if (i % 2 == 1) {
                        gc.setBackground(EColor.BACKGROUND);
                    } else {
                        gc.setBackground(EColor.LIGHTGRAY);
                    }
                    gc.fillRoundRectangle(popupX + 1, barY + 1, popupWidth - 2, rowHeight, 7, 7);
                    barY += rowHeight;
                }
                // draw the header column
                int rowY = popupY + MINI_ICON_MARGIN;
                int rowX = popupX + MINI_ICON_MARGIN;
                gc.setForeground(EColor.BLACK);
                gc.setBackground(EColor.BACKGROUND);
                for (int i = 0; i < titles.length; i++) {
                    if (i % 2 == 1) {
                        gc.setBackground(EColor.BACKGROUND);
                    } else {
                        gc.setBackground(EColor.LIGHTGRAY);
                    }
                    gc.drawText(titles[i], rowX, rowY);
                    rowY += rowHeight;
                }
                // draw the values for each copy of the step
                gc.setBackground(EColor.LIGHTGRAY);
                rowX += titleWidth;
                for (StepInterface step : steps) {
                    rowX += colWidth;
                    rowY = popupY + MINI_ICON_MARGIN;
                    StepStatus stepStatus = new StepStatus(step);
                    String[] fields = stepStatus.getPeekFields();
                    for (int i = 0; i < fields.length; i++) {
                        if (i % 2 == 1) {
                            gc.setBackground(EColor.BACKGROUND);
                        } else {
                            gc.setBackground(EColor.LIGHTGRAY);
                        }
                        drawTextRightAligned(fields[i], rowX, rowY);
                        rowY += rowHeight;
                    }
                }
            }
        }
    }
}
Also used : StepInterface(org.pentaho.di.trans.step.StepInterface) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) StepStatus(org.pentaho.di.trans.step.StepStatus) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

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