use of org.apache.hop.ui.hopgui.shared.SwtGc in project hop by apache.
the class HopGuiWorkflowGraph method drawWorkflowImage.
public void drawWorkflowImage(GC swtGc, int width, int height, float magnificationFactor) throws HopException {
IGc gc = new SwtGc(swtGc, width, height, iconSize);
try {
PropsUi propsUi = PropsUi.getInstance();
int gridSize = propsUi.isShowCanvasGridEnabled() ? propsUi.getCanvasGridSize() : 1;
ScrollBar horizontalScrollBar = wsCanvas.getHorizontalBar();
ScrollBar verticalScrollBar = wsCanvas.getVerticalBar();
WorkflowPainter workflowPainter = new WorkflowPainter(gc, variables, workflowMeta, new Point(width, height), horizontalScrollBar == null ? null : new SwtScrollBar(horizontalScrollBar), verticalScrollBar == null ? null : new SwtScrollBar(verticalScrollBar), hopCandidate, selectionRegion, areaOwners, propsUi.getIconSize(), propsUi.getLineWidth(), gridSize, propsUi.getNoteFont().getName(), propsUi.getNoteFont().getHeight(), propsUi.getZoomFactor(), !propsUi.useDoubleClick());
// correct the magnification with the overall zoom factor
//
float correctedMagnification = (float) (magnificationFactor * propsUi.getZoomFactor());
workflowPainter.setMagnification(correctedMagnification);
workflowPainter.setStartHopAction(startHopAction);
workflowPainter.setEndHopLocation(endHopLocation);
workflowPainter.setEndHopAction(endHopAction);
workflowPainter.setNoInputAction(noInputAction);
if (workflow != null) {
workflowPainter.setActionResults(workflow.getActionResults());
} else {
workflowPainter.setActionResults(new ArrayList<>());
}
List<ActionMeta> activeActions = new ArrayList<>();
if (workflow != null) {
activeActions.addAll(workflow.getActiveActions());
}
workflowPainter.setActiveActions(activeActions);
try {
workflowPainter.drawWorkflow();
if (workflowMeta.isEmpty() || (workflowMeta.nrNotes() == 0 && workflowMeta.nrActions() == 1 && workflowMeta.getAction(0).isStart())) {
SvgFile svgFile = new SvgFile(BasePropertyHandler.getProperty("WorkflowCanvas_image"), getClass().getClassLoader());
gc.drawImage(svgFile, 200, 200, 32, 40, gc.getMagnification(), 0);
gc.setBackground(IGc.EColor.BACKGROUND);
gc.drawText(BaseMessages.getString(PKG, "PipelineGraph.NewWorkflowBackgroundMessage"), 260, 220);
}
} catch (HopException e) {
throw new HopException("Error drawing workflow", e);
}
} finally {
gc.dispose();
}
CanvasFacade.setData(canvas, magnification, workflowMeta, HopGuiWorkflowGraph.class);
}
use of org.apache.hop.ui.hopgui.shared.SwtGc in project hop by apache.
the class HopGuiPipelineGraph method drawPipelineImage.
public void drawPipelineImage(GC swtGc, int width, int height, float magnificationFactor) {
IGc gc = new SwtGc(swtGc, width, height, iconSize);
try {
PropsUi propsUi = PropsUi.getInstance();
int gridSize = propsUi.isShowCanvasGridEnabled() ? propsUi.getCanvasGridSize() : 1;
ScrollBar horizontalScrollBar = wsCanvas.getHorizontalBar();
ScrollBar verticalScrollBar = wsCanvas.getVerticalBar();
PipelinePainter pipelinePainter = new PipelinePainter(gc, variables, pipelineMeta, new Point(width, height), horizontalScrollBar == null ? null : new SwtScrollBar(horizontalScrollBar), verticalScrollBar == null ? null : new SwtScrollBar(verticalScrollBar), candidate, selectionRegion, areaOwners, propsUi.getIconSize(), propsUi.getLineWidth(), gridSize, propsUi.getNoteFont().getName(), propsUi.getNoteFont().getHeight(), pipeline, propsUi.isIndicateSlowPipelineTransformsEnabled(), propsUi.getZoomFactor(), outputRowsMap, !propsUi.useDoubleClick(), stateMap);
// correct the magnification with the overall zoom factor
//
float correctedMagnification = (float) (magnificationFactor * propsUi.getZoomFactor());
pipelinePainter.setMagnification(correctedMagnification);
pipelinePainter.setTransformLogMap(transformLogMap);
pipelinePainter.setStartHopTransform(startHopTransform);
pipelinePainter.setEndHopLocation(endHopLocation);
pipelinePainter.setNoInputTransform(noInputTransform);
pipelinePainter.setEndHopTransform(endHopTransform);
pipelinePainter.setCandidateHopType(candidateHopType);
pipelinePainter.setStartErrorHopTransform(startErrorHopTransform);
try {
pipelinePainter.drawPipelineImage();
if (pipelineMeta.isEmpty()) {
SvgFile svgFile = new SvgFile(BasePropertyHandler.getProperty("PipelineCanvas_image"), getClass().getClassLoader());
gc.drawImage(svgFile, 200, 200, 32, 40, gc.getMagnification(), 0);
gc.setBackground(IGc.EColor.BACKGROUND);
gc.drawText(BaseMessages.getString(PKG, "PipelineGraph.NewPipelineBackgroundMessage"), 260, 220);
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), "Error", "Error drawing pipeline image", e);
}
} finally {
gc.dispose();
}
CanvasFacade.setData(canvas, magnification, pipelineMeta, HopGuiPipelineGraph.class);
}
Aggregations