use of com.centurylink.mdw.designer.display.Graph in project mdw-designer by CenturyLinkCloud.
the class CanvasCommon method objectAt.
public Object objectAt(Graph process, int x, int y, Graphics g) {
Node node;
Link link;
if (selected_obj != null) {
if (selected_obj instanceof Node) {
node = (Node) selected_obj;
if (onSelectableAnchor(x, y, node.x, node.y, node.w, node.h))
return node;
else if (node.labelOnPoint(g, x, y)) {
at_anchor = -2;
delta_x = x - node.x;
delta_y = y - node.y;
return node;
}
} else if (selected_obj instanceof Link) {
link = (Link) selected_obj;
int cx, cy, n = link.getNumberOfControlPoints();
for (int i = 0; i < n; i++) {
cx = link.getControlPointX(i);
cy = link.getControlPointY(i);
if (Math.abs(cx - x) <= 3 && Math.abs(cy - y) <= 3) {
at_anchor = i;
delta_x = x - cx;
delta_y = y - cy;
return link;
}
}
if (link.labelOnPoint(g, x, y)) {
at_anchor = -2;
delta_x = x - link.lx;
delta_y = y - link.ly;
return link;
}
} else if (selected_obj instanceof SubGraph) {
SubGraph subgraph = (SubGraph) selected_obj;
if (subgraph.isSwimLane()) {
if (onSelectableAnchor(x, y, subgraph.x, subgraph.y, SubGraph.SWIMLANE_LABEL_BAR_WIDTH, subgraph.h))
return subgraph;
} else {
if (onSelectableAnchor(x, y, subgraph.x, subgraph.y, subgraph.w, subgraph.h))
return subgraph;
}
} else if (selected_obj instanceof Graph) {
if (onSelectableAnchor(x, y, process.lx, process.ly, process.lw, process.lh))
return process;
} else if (selected_obj instanceof TextNote) {
TextNote note = (TextNote) selected_obj;
if (onSelectableAnchor(x, y, note.x, note.y, note.w, note.h))
return note;
}
}
at_anchor = -1;
Object obj = process.objectAt(x, y, g);
if (obj != null) {
if (obj instanceof Node) {
delta_x = x - ((Node) obj).x;
delta_y = y - ((Node) obj).y;
} else if (obj instanceof SubGraph) {
delta_x = x - ((SubGraph) obj).x;
delta_y = y - ((SubGraph) obj).y;
} else if (obj instanceof Graph) {
delta_x = x - ((Graph) obj).lx;
delta_y = y - ((Graph) obj).ly;
} else if (obj instanceof TextNote) {
delta_x = x - ((TextNote) obj).x;
delta_y = y - ((TextNote) obj).y;
}
return obj;
}
return null;
}
use of com.centurylink.mdw.designer.display.Graph in project mdw-designer by CenturyLinkCloud.
the class CanvasCommon method mouseDragged.
protected void mouseDragged(MouseEvent arg0, Graph main_graph) {
int x = arg0.getX();
int y = arg0.getY();
if (selected_obj != null) {
if (main_graph.zoom != 100) {
x = x * 100 / main_graph.zoom;
y = y * 100 / main_graph.zoom;
}
dragging = true;
if (at_anchor >= 0) {
if (selected_obj instanceof Node) {
resizeNode(x, y, main_graph);
} else if (selected_obj instanceof Link) {
((Link) selected_obj).moveControlPoint(at_anchor, x - delta_x, y - delta_y, main_graph.arrowstyle);
if (!main_graph.isReadonly())
main_graph.setDirtyLevel(Graph.GEOCHANGE);
} else if (selected_obj instanceof SubGraph) {
resizeSubGraph(x, y);
} else if (selected_obj instanceof TextNote) {
resizeTextNote(x, y, main_graph);
}
} else {
if (drag_to_create_link) {
drag_x = x;
drag_y = y;
} else if (selected_obj instanceof Node) {
moveNode(x, y);
} else if (selected_obj instanceof Link && at_anchor == -2) {
// move link label
Link link = (Link) selected_obj;
link.lx = x - delta_x;
link.ly = y - delta_y;
} else if (selected_obj instanceof SubGraph) {
if (((SubGraph) selected_obj).isSwimLane())
moveSubgraph(0, y);
else
moveSubgraph(x, y);
} else if (selected_obj instanceof Graph) {
moveGraphLabel(x, y);
} else if (selected_obj instanceof GraphFragment) {
((GraphFragment) selected_obj).shift(main_graph, x - drag_x, y - drag_y, main_graph.arrowstyle);
drag_x = x;
drag_y = y;
if (!main_graph.isReadonly())
main_graph.setDirtyLevel(Graph.GEOCHANGE);
} else if (selected_obj instanceof TextNote) {
moveTextNote(x, y);
}
}
repaint();
} else if (marquee != null) {
if (x < 0)
x = 0;
else if (x > this.getWidth())
x = this.getWidth();
if (y < 0)
y = 0;
else if (y > this.getHeight())
y = this.getHeight();
drawRubberBand(marquee, x - marquee.x, y - marquee.y);
}
}
use of com.centurylink.mdw.designer.display.Graph in project mdw-designer by CenturyLinkCloud.
the class ExportHelper method printProcessBodyHtml.
private void printProcessBodyHtml(StringBuilder sb, GraphCommon graph) throws Exception {
String tmp = null;
if (graph instanceof SubGraph) {
SubGraph subgraph = (SubGraph) graph;
String id = subgraph.getDisplayId(nodeIdType);
if (id == null || id.length() == 0)
id = subgraph.getId().toString();
tmp = "Subprocess " + id + " - " + subgraph.getName().replace('\n', ' ');
}
if (tmp != null)
sb.append("<h2>").append(tmp).append("</h2>\n");
String summary = (graph instanceof SubGraph) ? ((SubGraph) graph).getProcessVO().getProcessDescription() : ((Graph) graph).getProcessVO().getProcessDescription();
if (summary != null && summary.length() > 0)
sb.append("<span style='font-weight:bold'>").append(summary).append("</span>");
if (options.contains(DOCUMENTATION)) {
String detail = graph.getProcessVO().getAttribute(WorkAttributeConstant.DOCUMENTATION);
if (detail != null && detail.length() > 0) {
printParagraphsHtml(sb, detail);
}
}
if (options.contains(ATTRIBUTES) && graph instanceof SubGraph) {
printAttributesHtml(sb, graph.getProcessVO().getAttributes());
}
sb.append(BR);
}
use of com.centurylink.mdw.designer.display.Graph in project mdw-designer by CenturyLinkCloud.
the class ProcessInstanceLoader method loadCompletionMap.
public Graph loadCompletionMap(ProcessVO procdef, ProcessInstanceVO processInstance, DesignerDataAccess dao) throws Exception {
ProcessInstanceVO fullInfo = dao.getProcessInstanceAll(processInstance.getId(), procdef);
processInstance.copyFrom(fullInfo);
Graph graph = new Graph(procdef, processInstance, page.getDataModel().getNodeMetaInfo(), page.frame.getIconFactory());
if (graph.subgraphs != null) {
if (procdef.isInRuleSet()) {
Map<String, String> pMap = new HashMap<String, String>();
pMap.put("owner", OwnerType.MAIN_PROCESS_INSTANCE);
pMap.put("ownerId", processInstance.getId().toString());
pMap.put("processId", procdef.getProcessId().toString());
List<ProcessInstanceVO> childProcessInstances = dao.getProcessInstanceList(pMap, 0, QueryRequest.ALL_ROWS, procdef, null).getItems();
for (ProcessInstanceVO childInst : childProcessInstances) {
ProcessInstanceVO fullChildInfo = dao.getProcessInstanceAll(childInst.getId(), procdef);
childInst.copyFrom(fullChildInfo);
Long subprocId = new Long(childInst.getComment());
for (SubGraph subgraph : graph.subgraphs) {
if (subgraph.getProcessVO().getProcessId().equals(subprocId)) {
List<ProcessInstanceVO> insts = subgraph.getInstances();
if (insts == null) {
insts = new ArrayList<ProcessInstanceVO>();
subgraph.setInstances(insts);
}
insts.add(childInst);
break;
}
}
}
} else {
for (SubGraph subgraph : graph.subgraphs) {
Map<String, String> pMap = new HashMap<String, String>();
pMap.put("owner", OwnerType.PROCESS_INSTANCE);
pMap.put("ownerId", processInstance.getId().toString());
pMap.put("processId", subgraph.getProcessVO().getProcessId().toString());
List<ProcessInstanceVO> childProcessInstances = dao.getProcessInstanceList(pMap, 0, QueryRequest.ALL_ROWS, procdef, null).getItems();
subgraph.setInstances(childProcessInstances);
for (ProcessInstanceVO childInst : childProcessInstances) {
ProcessInstanceVO fullChildInfo = dao.getProcessInstanceAll(childInst.getId(), procdef);
childInst.copyFrom(fullChildInfo);
}
}
}
}
StringBuffer errmsg_buffer = new StringBuffer();
graph.setStatus(errmsg_buffer);
if (errmsg_buffer.length() > 0) {
errmsg = "There are runtime information about activities and transitions\n" + " that are not found in process definition.\n" + "This may happen when the process definition has been modified.\n" + errmsg_buffer.toString();
}
return graph;
}
use of com.centurylink.mdw.designer.display.Graph in project mdw-designer by CenturyLinkCloud.
the class RunTimeDesignerCanvas method paintComponent.
/*
* (non-Javadoc)
*
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
*/
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graph process = page.getProcess();
if (process != null) {
if (g instanceof Graphics2D) {
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
if (process.zoom != 100) {
double scale = process.zoom / 100.0;
g2d.scale(scale, scale);
}
}
draw_graph(g, process, true);
if (page.frame != null && !page.frame.isVisible() && selected_obj != null) {
if (selected_obj instanceof Node) {
drawSelectionBox(g, (Node) selected_obj);
} else if (selected_obj instanceof Link) {
drawSelectionBox(g, (Link) selected_obj);
} else if (selected_obj instanceof SubGraph) {
drawSelectionBox(g, (SubGraph) selected_obj);
} else if (selected_obj instanceof Graph) {
drawSelectionBox(g, (Graph) selected_obj);
}
}
}
}
Aggregations