use of org.apache.hop.core.gui.IGc in project hop by apache.
the class DrawTweakOnTransformExtensionPoint method drawRemovedTweak.
private void drawRemovedTweak(PipelinePainterExtension ext, TransformMeta transformMeta) {
// Now we're here, mark the transform as removed: a cross over the transform icon
//
IGc gc = ext.gc;
int iconSize = ext.iconSize;
int x = ext.x1 - 5;
int y = ext.y1 - 5;
gc.setLineWidth(transformMeta.isSelected() ? 4 : 3);
gc.setForeground(IGc.EColor.CRYSTAL);
gc.setBackground(IGc.EColor.LIGHTGRAY);
gc.setFont(IGc.EFont.GRAPH);
gc.drawLine(x, y, x + iconSize / 2, y + iconSize / 2);
gc.drawLine(x + iconSize / 2, y, x, y + iconSize / 2);
}
use of org.apache.hop.core.gui.IGc 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);
}
}
}
}
}
use of org.apache.hop.core.gui.IGc in project hop by apache.
the class DrawInputDataSetOnTransformExtensionPoint method drawInputDataSetMarker.
private void drawInputDataSetMarker(PipelinePainterExtension ext, TransformMeta transformMeta, PipelineUnitTest unitTest, List<AreaOwner> areaOwners) {
// Now we're here, draw a marker and indicate the name of the data set name
//
PipelineUnitTestSetLocation location = unitTest.findInputLocation(transformMeta.getName());
if (location == null) {
return;
}
String dataSetName = Const.NVL(location.getDataSetName(), "");
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 to the left as an arrow
//
int arrowSize = textExtent.y;
Point point = new Point(x - textExtent.x - arrowSize - 2, y + (iconSize - textExtent.y) / 2);
int[] arrow = new int[] { point.x, point.y, point.x + textExtent.x, point.y, point.x + textExtent.x + arrowSize, point.y + textExtent.y / 2, point.x + textExtent.x, point.y + textExtent.y, point.x, point.y + textExtent.y };
gc.fillPolygon(arrow);
gc.drawPolygon(arrow);
gc.drawText(dataSetName, point.x + 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_INPUT_DATA_SET, transformMeta.getName()));
}
use of org.apache.hop.core.gui.IGc in project hop by apache.
the class DrawDiffOnActionExtensionPoint method callExtensionPoint.
@Override
public void callExtensionPoint(ILogChannel log, IVariables variables, Object object) throws HopException {
if (!(object instanceof WorkflowPainter)) {
return;
}
WorkflowPainter painter = (WorkflowPainter) object;
Point offset = painter.getOffset();
IGc gc = painter.getGc();
WorkflowMeta workflowMeta = painter.getWorkflowMeta();
try {
workflowMeta.getActions().stream().filter(je -> je.getAttribute(ATTR_GIT, ATTR_STATUS) != null).forEach(je -> {
if (workflowMeta.getWorkflowVersion() == null ? false : workflowMeta.getWorkflowVersion().startsWith("git")) {
String status = je.getAttribute(ATTR_GIT, ATTR_STATUS);
Point n = je.getLocation();
String location;
if (status.equals(REMOVED)) {
location = "removed.svg";
} else if (status.equals(CHANGED)) {
location = "changed.svg";
} else if (status.equals(ADDED)) {
location = "added.svg";
} else {
// Unchanged
return;
}
int iconSize = ConstUi.ICON_SIZE;
try {
iconSize = PropsUi.getInstance().getIconSize();
} catch (Exception e) {
// Exception when accessed from Hop Server
}
int x = (n.x + iconSize + offset.x) - (iconSize / 4);
int y = n.y + offset.y - (iconSize / 4);
try {
gc.drawImage(new SvgFile(location, getClass().getClassLoader()), x, y, iconSize / 4, iconSize / 4, gc.getMagnification(), 0);
} catch (Exception e) {
throw new RuntimeException(e);
}
} else {
je.getAttributesMap().remove(ATTR_GIT);
}
});
} catch (Exception e) {
throw new HopException("Error drawing status icon on action", e);
}
}
use of org.apache.hop.core.gui.IGc in project hop by apache.
the class DrawDiffOnPipelineHopExtensionPoint method callExtensionPoint.
@Override
public void callExtensionPoint(ILogChannel log, IVariables variables, PipelinePainterExtension ext) throws HopException {
IGc gc = ext.gc;
ClassLoader classLoader = this.getClass().getClassLoader();
try {
Map<String, String> gitHops = ext.pipelineMeta.getAttributes(ATTR_GIT_HOPS);
if (gitHops == null) {
return;
}
for (String hopName : gitHops.keySet()) {
String pipelineHopName = getPipelineHopName(ext.pipelineHop);
if (ext.pipelineHop != null && pipelineHopName.equals(hopName)) {
// Draw this status...
//
SvgFile svgFile = null;
String status = gitHops.get(hopName);
if (status != null) {
switch(status) {
case ADDED:
svgFile = new SvgFile("added.svg", classLoader);
break;
case REMOVED:
svgFile = new SvgFile("removed.svg", classLoader);
break;
case CHANGED:
svgFile = new SvgFile("changed.svg", classLoader);
break;
}
if (svgFile != null) {
// Center of hop...
//
Point fr = ext.pipelineHop.getFromTransform().getLocation();
Point to = ext.pipelineHop.getToTransform().getLocation();
Point middle = new Point((fr.x + to.x) / 2, (fr.y + to.y) / 2);
int iconSize = ConstUi.ICON_SIZE;
try {
iconSize = PropsUi.getInstance().getIconSize();
} catch (Exception e) {
// Exception when accessed from Hop Server
}
gc.drawImage(svgFile, middle.x, middle.y, iconSize / 2, iconSize / 2, gc.getMagnification(), 0);
}
}
}
}
} catch (Exception e) {
throw new HopException("Error drawing status on pipeline hop", e);
}
}
Aggregations