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;
}
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);
}
}
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);
}
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()]);
}
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);
}
}
}
}
}
Aggregations