Search in sources :

Example 1 with Point

use of org.apache.hop.core.gui.Point in project hop by apache.

the class TransformMeta 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.apache.hop.core.gui.Point) Point(org.apache.hop.core.gui.Point)

Example 2 with Point

use of org.apache.hop.core.gui.Point in project hop by apache.

the class PipelineSvgPainter method generatePipelineSvg.

public static final String generatePipelineSvg(PipelineMeta pipelineMeta, float magnification, IVariables variables) throws HopException {
    try {
        Point maximum = pipelineMeta.getMaximum();
        maximum.multiply(magnification);
        HopSvgGraphics2D graphics2D = HopSvgGraphics2D.newDocument();
        SvgGc gc = new SvgGc(graphics2D, new Point(maximum.x + 100, maximum.y + 100), 32, 0, 0);
        PipelinePainter pipelinePainter = new PipelinePainter(gc, variables, pipelineMeta, maximum, null, null, null, null, null, new ArrayList<>(), 32, 1, 0, "Arial", 10, 1.0d, false, new HashMap<>());
        pipelinePainter.setMagnification(magnification);
        pipelinePainter.drawPipelineImage();
        // 
        return graphics2D.toXml();
    } catch (Exception e) {
        throw new HopException("Unable to generate SVG for pipeline " + pipelineMeta.getName(), e);
    }
}
Also used : HopException(org.apache.hop.core.exception.HopException) SvgGc(org.apache.hop.core.gui.SvgGc) Point(org.apache.hop.core.gui.Point) HopSvgGraphics2D(org.apache.hop.core.svg.HopSvgGraphics2D) HopException(org.apache.hop.core.exception.HopException)

Example 3 with Point

use of org.apache.hop.core.gui.Point in project hop by apache.

the class PipelineMeta method getMinimum.

/**
 * Gets the minimum point on the canvas of a pipeline.
 *
 * @return Minimum coordinate of a transform in the pipeline
 */
public Point getMinimum() {
    int minx = Integer.MAX_VALUE;
    int miny = Integer.MAX_VALUE;
    for (int i = 0; i < nrTransforms(); i++) {
        TransformMeta transformMeta = getTransform(i);
        Point loc = transformMeta.getLocation();
        if (loc.x < minx) {
            minx = loc.x;
        }
        if (loc.y < miny) {
            miny = loc.y;
        }
    }
    for (int i = 0; i < nrNotes(); i++) {
        NotePadMeta notePadMeta = getNote(i);
        Point loc = notePadMeta.getLocation();
        if (loc.x < minx) {
            minx = loc.x;
        }
        if (loc.y < miny) {
            miny = loc.y;
        }
    }
    if (minx > BORDER_INDENT && minx != Integer.MAX_VALUE) {
        minx -= BORDER_INDENT;
    } else {
        minx = 0;
    }
    if (miny > BORDER_INDENT && miny != Integer.MAX_VALUE) {
        miny -= BORDER_INDENT;
    } else {
        miny = 0;
    }
    return new Point(minx, miny);
}
Also used : Point(org.apache.hop.core.gui.Point) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint) Point(org.apache.hop.core.gui.Point) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint)

Example 4 with Point

use of org.apache.hop.core.gui.Point in project hop by apache.

the class PipelineMeta method getSelectedNoteLocations.

/**
 * Get an array of all the selected note locations.
 *
 * @return The selected note locations.
 */
public Point[] getSelectedNoteLocations() {
    List<Point> points = new ArrayList<>();
    for (NotePadMeta ni : getSelectedNotes()) {
        Point p = ni.getLocation();
        // explicit copy of location
        points.add(new Point(p.x, p.y));
    }
    return points.toArray(new Point[points.size()]);
}
Also used : Point(org.apache.hop.core.gui.Point) HopExtensionPoint(org.apache.hop.core.extension.HopExtensionPoint)

Example 5 with Point

use of org.apache.hop.core.gui.Point in project hop by apache.

the class DrawGoldenDataSetOnTransformExtensionPoint method drawGoldenSetMarker.

protected void drawGoldenSetMarker(PipelinePainterExtension ext, TransformMeta transformMeta, PipelineUnitTest unitTest, List<AreaOwner> areaOwners) {
    PipelineUnitTestSetLocation location = unitTest.findGoldenLocation(transformMeta.getName());
    if (location == null) {
        return;
    }
    String dataSetName = Const.NVL(location.getDataSetName(), "");
    // Now we're here, draw a marker and indicate the name of the unit test
    // 
    IGc gc = ext.gc;
    int iconSize = ext.iconSize;
    int x = ext.x1;
    int y = ext.y1;
    gc.setLineWidth(transformMeta.isSelected() ? 2 : 1);
    gc.setForeground(IGc.EColor.CRYSTAL);
    gc.setBackground(IGc.EColor.LIGHTGRAY);
    gc.setFont(IGc.EFont.GRAPH);
    Point textExtent = gc.textExtent(dataSetName);
    // add a tiny bit of a margin
    textExtent.x += 6;
    textExtent.y += 6;
    // Draw it at the right hand side
    // 
    int arrowSize = textExtent.y;
    Point point = new Point(x + iconSize, y + (iconSize - textExtent.y) / 2);
    int[] arrow = new int[] { point.x, point.y + textExtent.y / 2, point.x + arrowSize, point.y, point.x + textExtent.x + arrowSize, point.y, point.x + textExtent.x + arrowSize, point.y + textExtent.y, point.x + arrowSize, point.y + textExtent.y };
    gc.fillPolygon(arrow);
    gc.drawPolygon(arrow);
    gc.drawText(dataSetName, point.x + arrowSize + 3, point.y + 3);
    // Leave a trace of what we drew, for memory reasons, just the name of the data set here.
    // 
    areaOwners.add(new AreaOwner(AreaOwner.AreaType.CUSTOM, point.x, point.y, textExtent.x, textExtent.y, new Point(0, 0), DataSetConst.AREA_DRAWN_GOLDEN_DATA_SET, transformMeta.getName()));
    // 
    if (ext.stateMap != null) {
        Map<String, Boolean> results = (Map<String, Boolean>) ext.stateMap.get(DataSetConst.STATE_KEY_GOLDEN_DATASET_RESULTS);
        if (results != null) {
            Boolean result = results.get(dataSetName);
            if (result != null) {
                try {
                    int iconX = point.x + arrowSize + textExtent.x - 5;
                    int iconY = point.y - 5;
                    if (result) {
                        gc.drawImage(IGc.EImage.SUCCESS, iconX, iconY, gc.getMagnification());
                    } else {
                        gc.drawImage(IGc.EImage.FAILURE, iconX, iconY, gc.getMagnification());
                    }
                    areaOwners.add(new AreaOwner(AreaOwner.AreaType.CUSTOM, iconX + ConstUi.SMALL_ICON_SIZE, iconY + 5, ConstUi.SMALL_ICON_SIZE, ConstUi.SMALL_ICON_SIZE, new Point(0, 0), DataSetConst.AREA_DRAWN_GOLDEN_DATA_RESULT, transformMeta.getName()));
                } catch (Exception e) {
                    LogChannel.UI.logError("Error drawing golden data set result on pipeline", e);
                }
            }
        }
    }
}
Also used : PipelineUnitTestSetLocation(org.apache.hop.testing.PipelineUnitTestSetLocation) IGc(org.apache.hop.core.gui.IGc) AreaOwner(org.apache.hop.core.gui.AreaOwner) ExtensionPoint(org.apache.hop.core.extension.ExtensionPoint) IExtensionPoint(org.apache.hop.core.extension.IExtensionPoint) Point(org.apache.hop.core.gui.Point) Map(java.util.Map) ExtensionPoint(org.apache.hop.core.extension.ExtensionPoint) IExtensionPoint(org.apache.hop.core.extension.IExtensionPoint) Point(org.apache.hop.core.gui.Point) HopException(org.apache.hop.core.exception.HopException)

Aggregations

Point (org.apache.hop.core.gui.Point)67 Test (org.junit.Test)17 ILogChannel (org.apache.hop.core.logging.ILogChannel)15 PrintWriter (java.io.PrintWriter)14 HopException (org.apache.hop.core.exception.HopException)14 HttpServletRequest (javax.servlet.http.HttpServletRequest)13 HttpServletResponse (javax.servlet.http.HttpServletResponse)13 ActionMeta (org.apache.hop.workflow.action.ActionMeta)13 StringWriter (java.io.StringWriter)12 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)12 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)12 HopExtensionPoint (org.apache.hop.core.extension.HopExtensionPoint)11 NotePadMeta (org.apache.hop.core.NotePadMeta)10 ExtensionPoint (org.apache.hop.core.extension.ExtensionPoint)9 IExtensionPoint (org.apache.hop.core.extension.IExtensionPoint)9 WorkflowMeta (org.apache.hop.workflow.WorkflowMeta)9 Pipeline (org.apache.hop.pipeline.Pipeline)8 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)7 IGc (org.apache.hop.core.gui.IGc)6 AreaOwner (org.apache.hop.core.gui.AreaOwner)4