use of com.centurylink.mdw.designer.display.Link 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.Link in project mdw-designer by CenturyLinkCloud.
the class CanvasCommon method mousePressed.
protected void mousePressed(MouseEvent arg0, Graph main_graph) {
closeLabelEditor();
int x = arg0.getX();
int y = arg0.getY();
if (main_graph.zoom != 100) {
x = x * 100 / main_graph.zoom;
y = y * 100 / main_graph.zoom;
}
Object obj = objectAt(main_graph, x, y, getGraphics());
if (selected_obj != null && selected_obj instanceof GraphFragment && obj != null && ((GraphFragment) selected_obj).contains(obj)) {
// dragging to move
drag_x = x;
drag_y = y;
} else if (selected_obj != null && obj != null && obj instanceof Node && arg0.isControlDown()) {
GraphFragment frag;
if (selected_obj instanceof Node) {
frag = new GraphFragment(main_graph.getId());
frag.nodes.add((Node) selected_obj);
selected_obj = frag;
} else if (selected_obj instanceof SubGraph) {
frag = new GraphFragment(main_graph.getId());
frag.subgraphs.add((SubGraph) selected_obj);
selected_obj = frag;
} else if (selected_obj instanceof Link) {
frag = new GraphFragment(main_graph.getId());
frag.links.add((Link) selected_obj);
selected_obj = frag;
} else if (selected_obj instanceof GraphFragment) {
frag = (GraphFragment) selected_obj;
} else
frag = null;
if (frag != null)
frag.nodes.add((Node) obj);
repaint();
} else if (obj != null) {
selected_obj = obj;
if (obj instanceof Node) {
if (arg0.isShiftDown() && !main_graph.isReadonly()) {
drag_to_create_link = true;
}
}
// closeLabelEditor(true);
repaint();
} else if (selected_obj != null) {
selected_obj = null;
// closeLabelEditor(true);
repaint();
marquee = new Rectangle(arg0.getX(), arg0.getY(), 0, 0);
} else {
marquee = new Rectangle(arg0.getX(), arg0.getY(), 0, 0);
}
this.requestFocus();
}
use of com.centurylink.mdw.designer.display.Link in project mdw-designer by CenturyLinkCloud.
the class CanvasCommon method draw_subgraph.
private void draw_subgraph(Graphics g, Graph process, SubGraph subgraph, boolean drawStatus) {
if (drawStatus && subgraph.getStatus() != null)
drawNodeOrSubgraphStatus(subgraph.getStatus(), g, subgraph.x, subgraph.y, subgraph.w, subgraph.h, process.nodestyle.equals(Node.NODE_STYLE_ICON));
if (subgraph.isNew())
g.setColor(NEW_COLOR);
else if (subgraph.isDeleted())
g.setColor(Color.LIGHT_GRAY);
else
g.setColor(LIGHT_BLUE);
g.drawRoundRect(subgraph.x, subgraph.y, subgraph.w, subgraph.h, 12, 12);
// String subtype = subgraph.getAttribute(WorkAttributeConstant.EMBEDDED_PROCESS_TYPE);
// if (subtype==null || subtype.equals(ProcessVisibilityConstant.EMBEDDED_ERROR_PROCESS))
// g.setColor(Color..red);
// else
g.setColor(Color.BLACK);
subgraph.lx = subgraph.x + 10;
subgraph.ly = subgraph.y + 4;
g.drawString(subgraph.getName(), subgraph.lx, subgraph.ly);
if (Node.ID_DATABASE.equals(process.getNodeIdType())) {
g.setColor(Color.GRAY);
g.drawString("[" + subgraph.getProcessVO().getProcessId().toString() + "]", subgraph.x + 10, subgraph.y + subgraph.h + 4);
} else if (Node.ID_LOGICAL.equals(process.getNodeIdType())) {
g.setColor(Color.GRAY);
g.drawString("[" + subgraph.getLogicalId() + "]", subgraph.x + 10, subgraph.y + subgraph.h + 4);
} else if (Node.ID_REFERENCE.equals(process.getNodeIdType())) {
g.setColor(Color.GRAY);
g.drawString("[" + subgraph.getReferenceId() + "]", subgraph.x + 10, subgraph.y + subgraph.h + 4);
} else if (Node.ID_SEQUENCE.equals(process.getNodeIdType())) {
g.setColor(Color.GRAY);
g.drawString("[" + String.valueOf(subgraph.getSequenceId()) + "]", subgraph.x + 10, subgraph.y + subgraph.h + 4);
}
for (Node node : subgraph.nodes) {
drawNode(node, g, drawStatus, process.nodestyle);
}
if (drawStatus) {
for (Link conn : subgraph.links) {
if (!conn.isHidden() && conn.getColor() == Color.LIGHT_GRAY)
drawConnector(g, process, conn);
}
for (Link conn : subgraph.links) {
if (!conn.isHidden() && conn.getColor() != Color.LIGHT_GRAY)
drawConnector(g, process, conn);
}
} else {
for (Link link : subgraph.links) {
if (!link.isHidden())
this.drawConnector(g, process, link);
}
}
}
use of com.centurylink.mdw.designer.display.Link in project mdw-designer by CenturyLinkCloud.
the class CanvasCommon method draw_graph.
protected void draw_graph(Graphics g, Graph process, boolean drawStatus) {
if (g instanceof Graphics2D && normal_stroke == null) {
normal_stroke = ((Graphics2D) g).getStroke();
line_stroke = new BasicStroke(3.0f);
float[] dash = { 10.0f, 10.0f };
dash_stroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 10.0f, dash, 0.0f);
grid_stroke = new BasicStroke(0.2f);
}
if (editable) {
Dimension canvas_size = this.getSize();
g.setColor(Color.GRAY);
((Graphics2D) g).setStroke(grid_stroke);
for (int x = grid_size; x < canvas_size.width; x += grid_size) {
g.drawLine(x, 0, x, canvas_size.height);
}
for (int y = grid_size; y < canvas_size.height; y += grid_size) {
g.drawLine(0, y, canvas_size.width, y);
}
}
g.setFont(normal_font);
if (drawStatus) {
for (Link conn : process.links) {
if (!conn.isHidden() && conn.getColor() == Color.LIGHT_GRAY)
drawConnector(g, process, conn);
}
for (Link conn : process.links) {
if (!conn.isHidden() && conn.getColor() != Color.LIGHT_GRAY)
drawConnector(g, process, conn);
}
} else {
for (Link conn : process.links) {
if (!conn.isHidden())
drawConnector(g, process, conn);
}
}
drawMainProcess(g, process);
for (Node node : process.nodes) {
drawNode(node, g, drawStatus, process.nodestyle);
}
for (SubGraph subgraph : process.subgraphs) {
draw_subgraph(g, process, subgraph, drawStatus);
}
if (process.notes != null) {
for (TextNote note : process.notes) {
draw_textnote(g, note);
}
}
}
use of com.centurylink.mdw.designer.display.Link 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);
}
}
Aggregations