diff --git a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.core.js b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.core.js
index f688cdf1..d45ef21e 100755
--- a/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.core.js
+++ b/com.actionsoft.apps.coe.pal/web/com.actionsoft.apps.coe.pal/lib/designer/scripts/diagraming/designer.core.js
@@ -1,9697 +1 @@
-Schema.init(true);
-Schema.initMarkers();
-$(function () {
- if (role == "trial") {
- Designer.status = "demo"
- } else {
- if (role == "viewer") {
- Designer.status = "readonly"
- } else {
- if (role == "running") {
- Designer.status = "running"
- }
- }
- }
- Designer.init();
- UI.init();
- Dock.init();
- Navigator.init();
- if (Designer.status == "readonly") {
- Designer.setReadonly(true);
- $("#moreShapes").hide();
- Customize.init();
- return
- }
- if (Designer.status == "demo") {
- UI.gettingStart()
- }
-});
-var Designer = {
- config: {
- panelItemWidth: 30,
- panelItemHeight: 30,
- pageMargin: 10,
- anchorSize: 8,
- rotaterSize: 9,
- anchorColor: "#833",
- selectorColor: "#833",
- scale: 1
- },
- status: "",
- initialize: {
- initialized: false,
- initLayout: function () {
- $(window).bind("resize.designer",
- function () {
- showPainting();
- var b = $(window).height() - $("#designer_header").outerHeight() - $("#designer_footer").outerHeight();
- $(".layout").height(b);
- if ($("#demo_signup").length) {
- $("#designer_layout").height(b - $("#demo_signup").outerHeight())
- }
- });
- $(window).trigger("resize.designer")
- },
- initModel: function () {
- Model.define = {
- page: Utils.copy(Schema.pageDefaults),
- elements: {}
- };
- if (definition != undefined && definition.localAttribute != undefined) {
- Model.define.localAttribute = definition.localAttribute
- } else {
- Model.define.localAttribute = {}
- }
- if (definition != undefined && definition.commonShapeConfig != undefined) {
- Model.define.commonShapeConfig = definition.commonShapeConfig
- } else {
- Model.define.commonShapeConfig = {}
- }
- Model.persistence = {
- page: Utils.copy(Schema.pageDefaults),
- elements: {},
- localAttribute: {},
- commonShapeConfig: {}
- }
- },
- initCanvas: function () {
- if (typeof Model.define.page.width == 'string') {
- Model.define.page.width = parseFloat(Model.define.page.width);
- }
- if (typeof Model.define.page.height == 'string') {
- Model.define.page.height = parseFloat(Model.define.page.height);
- }
- var q = Model.define.page.width.toScale();
- var v = Model.define.page.height.toScale();
- var B = Model.define.page.backgroundColor;
- var s = Utils.getDarkerColor(B);
- var A = Utils.getDarkestColor(B);
- $("#designer_canvas").css({
- "background-color": "rgb(" + s + ")"
- });
- var w = $("#designer_grids");
- w.attr({
- width: q,
- height: v
- });
- var h = w[0].getContext("2d");
- h.clearRect(0, 0, q, v);
- var r = Model.define.page.padding.toScale();
- var y = q - r * 2;
- var p = v - r * 2;
- h.fillStyle = "rgb(" + B + ")";
- h.beginPath();
- h.rect(r, r, y, p);
- h.fill();
- var x = Math.round(Model.define.page.gridSize.toScale());
- if (x < 10) {
- x = 10
- }
- if (Model.define.page.showGrid) {
- h.translate(r, r);
- h.lineWidth = 1;
- h.save();
- var t = 0.5;
- var u = 0;
- while (t <= p) {
- h.restore();
- if (u % 4 == 0) {
- h.strokeStyle = "rgb(" + A + ")"
- } else {
- h.strokeStyle = "rgb(" + s + ")"
- }
- h.beginPath();
- h.moveTo(0, t);
- h.lineTo(y, t);
- t += x;
- u++;
- h.stroke()
- }
- t = 0.5;
- u = 0;
- while (t <= y) {
- h.restore();
- if (u % 4 == 0) {
- h.strokeStyle = "rgb(" + A + ")"
- } else {
- h.strokeStyle = "rgb(" + s + ")"
- }
- h.beginPath();
- h.moveTo(t, 0);
- h.lineTo(t, p);
- t += x;
- u++;
- h.stroke()
- }
- }
- $("#canvas_container").css({
- width: q,
- height: v,
- padding: Designer.config.pageMargin
- });
- if (!this.initialized) {
- $("#designer_layout").scrollTop(Designer.config.pageMargin - 10);
- $("#designer_layout").scrollLeft(Designer.config.pageMargin - 10)
- }
- var z = $("#bar_list_page").children("li[ac=set_page_showgrid]");
- z.menuitem("unselect");
- if (Model.define.page.showGrid) {
- z.menuitem("select")
- }
- },
- initShapes: function () {
- $("#shape_panel").empty();
- for (var o = 0; o < Schema.categories.length; o++) {
- var n = Schema.categories[o];
- if (n.name == "standard") {
- continue
- }
- $("#shape_panel").append("
")
- }
- $(".panel_title").unbind().bind("click",
- function () {
- $(this).parent().toggleClass("panel_collapsed")
- });
- for (var s in Schema.shapes) {
- var l = Schema.shapes[s];
- if (l.attribute.visible && l.category != "standard") {
- if ((l.category == "process_bpmn2" || l.category == "process.bpmn2" || l.category == "bpmn") && checkRunningTimeShape(l)) {
- continue;
- }
- if (!l.groupName) {
- p(l)
- } else {
- var i = SchemaGroup.getGroup(l.groupName);
- if (i[0] == s) {
- p(l, l.groupName)
- }
- }
- }
- }
-
- function p(b, d) {
- b = Utils.copy(b);
- var e = "";
- var c = $(e).appendTo("#panel_" + b.category);
- if (d) {
- c.append("")
- }
- var a = c.children()[0];
- c.bind("mouseenter",
- function () {
- if ($(this).hasClass("readonly")) {
- return
- }
- var h = $("#shape_thumb");
- var title = b.title;
- var category = b.category;
- if (b.category == "bpmn") {
- category = 'process_bpmn2';
- }
- if (category == 'lane') {
- category = methodId;
- }
- category = category.replace(/_/g, ".");
- if (methodObjectDesc[category + '-' + b.name]) {
- title += (':' + methodObjectDesc[category + '-' + b.name]);
- }
- h.children("div").text(title);
- var j = h.children("canvas")[0].getContext("2d");
- var A = {
- x: 0,
- y: 0,
- w: b.props.w,
- h: b.props.h,
- angle: b.props.angle
- };
- var y = 160;
- var k = 160;
- j.clearRect(0, 0, y, k);
- if (b.props.w >= b.props.h) {
- if (b.props.w > y) {
- A.w = y;
- A.h = parseInt(b.props.h / b.props.w * A.w)
- }
- } else {
- if (b.props.h > k) {
- A.h = k;
- A.w = parseInt(b.props.w / b.props.h * A.h)
- }
- }
- h.children("canvas").attr({
- width: y + 20,
- height: A.h + 20
- });
- h.show();
- b.props = A;
- j.save();
- if (b.name != "text" && b.name != "umlText") {
- j.globalAlpha = b.shapeStyle.alpha;
- var f = (y + 20 - A.w) / 2;
- var g = 10;
- j.translate(f, g);
- j.translate(A.w / 2, A.h / 2);
- j.rotate(A.angle);
- j.translate(-(A.w / 2), -(A.h / 2));
- Designer.painter.renderShapePath(j, b, true);
- Designer.painter.renderMarkers(j, b, true)
- } else {
- j.translate(y / 2 + 10, A.h / 2 + 10);
- j.textBaseline = "middle";
- j.textAlign = "center";
- var B = "";
- if (b.fontStyle.italic) {
- B += "italic "
- } else {
- B += "normal "
- }
- if (b.fontStyle.bold) {
- B += "bold "
- } else {
- B += "normal "
- }
- B += b.fontStyle.size + "pt ";
- B += b.fontStyle.fontFamily;
- j.font = B;
- j.fillStyle = "rgb(" + b.fontStyle.color + ")";
- j.fillText(b.text, 0, 0)
- }
- j.restore();
- var z = c.offset().top - $("#designer_header").outerHeight() + c.height() / 2 - h.outerHeight() / 2;
- if (z < 5) {
- z = 5
- } else {
- if (z + h.outerHeight() > $("#designer_viewport").height() - 5) {
- z = $("#designer_viewport").height() - 5 - h.outerHeight()
- }
- }
- h.css("top", z)
- }).bind("mouseleave",
- function () {
- $("#shape_thumb").hide()
- });
- Designer.painter.drawPanelItem(a, b.name)
- }
-
- r();
-
- function r() {
- $(".panel_box").die().live("mousedown",
- function (j) {
- var c = $(this);
- if (c.hasClass("readonly")) {
- return
- }
- var h = c.attr("shapeName");
- var a = [];
- Designer.op.changeState("creating_from_panel");
- var g = null;
- var b = null;
- var d = $("#designer_canvas");
- var f = t(h);
- $("#designer").bind("mousemove.creating",
- function (k) {
- m(f, k)
- });
- $("#canvas_container").bind("mousemove.create",
- function (B) {
- var D = Utils.getRelativePos(B.pageX, B.pageY, d);
- if (g == null) {
- g = q(h, D.x, D.y);
- b = $("#" + g.id);
- b.attr("class", "shape_box_creating")
- }
- b.css({
- left: D.x - b.width() / 2 + "px",
- top: D.y - b.height() / 2 + "px",
- "z-index": Model.orderList.length
- });
- g.props.x = D.x.restoreScale() - g.props.w / 2;
- g.props.y = D.y.restoreScale() - g.props.h / 2;
- var G = g.props;
- var H = Designer.op.snapLine(G, [g.id], true, g);
- if (H.attach) {
- g.attachTo = H.attach.id
- } else {
- delete g.attachTo
- }
- b.css({
- left: (g.props.x - 10).toScale() + "px",
- top: (g.props.y - 10).toScale() + "px",
- "z-index": Model.orderList.length
- });
- a = Utils.getShapeAnchorInLinker(g);
- Designer.op.hideLinkPoint();
- for (var C = 0; C < a.length; C++) {
- var E = a[C];
- for (var F = 0; F < E.anchors.length; F++) {
- var k = E.anchors[F];
- Designer.op.showLinkPoint(Utils.toScale(k))
- }
- }
- });
- var e = false;
- $("#canvas_container").bind("mouseup.create",
- function (k) {
- e = true
- });
- $(document).bind("mouseup.create",
- function () {
- $(this).unbind("mouseup.create");
- $("#designer").unbind("mousemove.creating");
- $("#creating_shape_container").hide();
- Designer.op.hideLinkPoint();
- Designer.op.hideSnapLine();
- $("#canvas_container").unbind("mouseup.create").unbind("mousemove.create");
- if (g != null) {
- if (e == false) {
- b.remove()
- } else {
- MessageSource.beginBatch();
- if (g.onCreated) {
- var P = g.onCreated();
- if (P == false) {
- b.remove();
- MessageSource.commit();
- return
- }
- }
- b.attr("class", "shape_box");
- if (g.category == 'lane') {
- b.addClass("lane_box");
- }
- Designer.events.push("created", g);
- Model.add(g);
- var S = Utils.getShapeContext(g.id);
- var Q = b.position();
- var K = 7;
- for (var N = 0; N < a.length; N++) {
- var W = a[N];
- var M = W.linker;
- if (W.type == "line") {
- var Y = Utils.copy(M);
- var Z = Utils.copy(M);
- Z.id = Utils.newId();
- if (W.anchors.length == 1) {
- var O = W.anchors[0];
- var U = Utils.getPointAngle(g.id, O.x, O.y, K);
- M.to = {
- id: g.id,
- x: O.x,
- y: O.y,
- angle: U
- };
- Z.from = {
- id: g.id,
- x: O.x,
- y: O.y,
- angle: U
- }
- } else {
- if (W.anchors.length == 2) {
- var R = W.anchors[0];
- var T = W.anchors[1];
- var k = Utils.measureDistance(M.from, R);
- var L = Utils.measureDistance(M.from, T);
- var X, V;
- if (k < L) {
- X = R;
- V = T
- } else {
- X = T;
- V = R
- }
- var U = Utils.getPointAngle(g.id, X.x, X.y, K);
- M.to = {
- id: g.id,
- x: X.x,
- y: X.y,
- angle: U
- };
- U = Utils.getPointAngle(g.id, V.x, V.y, K);
- Z.from = {
- id: g.id,
- x: V.x,
- y: V.y,
- angle: U
- }
- }
- }
- if (W.anchors.length <= 2) {
- Designer.painter.renderLinker(M, true);
- Model.update(M);
- Designer.painter.renderLinker(Z, true);
- Z.props.zindex = Model.maxZIndex + 1;
- Model.add(Z);
- Designer.events.push("linkerCreated", Z)
- }
- } else {
- var O = W.anchors[0];
- var U = Utils.getPointAngle(g.id, O.x, O.y, K);
- if (W.type == "from") {
- M.from = {
- id: g.id,
- x: O.x,
- y: O.y,
- angle: U
- }
- } else {
- M.to = {
- id: g.id,
- x: O.x,
- y: O.y,
- angle: U
- }
- }
- Designer.painter.renderLinker(M, true);
- Model.update(M)
- }
- }
- // 如果当前拖拽到画布的图形是子流程 则渲染节点展开图标
- if (g.name == 'subProcess') {
- window.subProcess.shapeOpenIconRender(g);
- }
- Utils.unselect();
- Utils.selectShape(g.id);
- MessageSource.commit();
- if (g.attribute.editable) {
- Designer.op.editShapeText(g)
- }
- }
- }
- c.css({
- left: "0px",
- top: "0px"
- });
- Designer.op.resetState()
- })
- })
- }
-
- function t(a) {
- var b = $("#creating_shape_canvas");
- var c = $("#creating_shape_container");
- if (b.length == 0) {
- c = $("").appendTo("#designer");
- b = $("").appendTo(c)
- }
- c.css({
- left: "0px",
- top: "0px",
- width: $(".panel_container").width(),
- height: $("#shape_panel").outerHeight()
- });
- Designer.painter.drawPanelItem(b[0], a);
- return b
- }
-
- function m(b, a) {
- $("#creating_shape_container").show();
- var c = Utils.getRelativePos(a.pageX, a.pageY, $("#creating_shape_container"));
- b.css({
- left: c.x - Designer.config.panelItemWidth / 2,
- top: c.y - Designer.config.panelItemHeight / 2
- })
- }
-
- function q(g, e, f) {
- var h = Utils.newId();
- var b = Schema.shapes[g];
- var c = e.restoreScale() - b.props.w / 2;
- var d = f.restoreScale() - b.props.h / 2;
- var a = Model.create(g, c, d);
- Designer.painter.renderShape(a);
- return a
- }
- }
- },
- hotkey: {
- init: function () {
- var b = null;
- $(document).unbind("keydown.hotkey").bind("keydown.hotkey",
- function (n) {
- if (n.ctrlKey && n.keyCode == 65) {
- Designer.selectAll();
- n.preventDefault()
- } else {
- if (n.keyCode == 46 || n.keyCode == 8) {
- Designer.op.removeShape();
- n.preventDefault()
- } else {
- if (n.ctrlKey && n.keyCode == 90) {
- MessageSource.undo();
- n.preventDefault()
- } else {
- if (n.ctrlKey && n.keyCode == 89) {
- MessageSource.redo();
- n.preventDefault()
- } else {
- if (n.ctrlKey && !n.shiftKey && n.keyCode == 67) {
- Designer.clipboard.copy();
- n.preventDefault()
- } else {
- if (n.ctrlKey && n.keyCode == 88) {
- Designer.clipboard.cut();
- n.preventDefault()
- } else {
- if (n.ctrlKey && n.keyCode == 86) {
- Designer.clipboard.paste();
- n.preventDefault()
- } else {
- if (n.ctrlKey && n.keyCode == 68) {
- Designer.clipboard.duplicate();
- n.preventDefault()
- } else {
- if (n.ctrlKey && n.shiftKey && n.keyCode == 66) {
- Designer.clipboard.brush();
- n.preventDefault()
- } else {
- if (n.ctrlKey && n.keyCode == 190) {
- Designer.zoomIn();
- n.preventDefault()
- } else {
- if (n.ctrlKey && n.keyCode == 188) {
- Designer.zoomOut();
- n.preventDefault()
- } else {
- if (n.keyCode >= 37 && n.keyCode <= 40) {
- if (b == null) {
- var s = Utils.getSelected();
- var m = Utils.getFamilyShapes(s);
- s = s.concat(m);
- var q = Utils.getContainedShapes(s);
- s = s.concat(q);
- var r = Utils.getAttachedShapes(s);
- s = s.concat(r);
- var a = Utils.getOutlinkers(s);
- b = s.concat(a)
- }
- if (b.length > 0) {
- n.preventDefault();
- var t = 10;
- if (n.ctrlKey) {
- t = 1
- }
- Utils.hideLinkerCursor();
- if (n.keyCode == 37) {
- Designer.op.moveShape(b, {
- x: -t,
- y: 0
- })
- } else {
- if (n.keyCode == 38) {
- Designer.op.moveShape(b, {
- x: 0,
- y: -t
- })
- } else {
- if (n.keyCode == 39) {
- Designer.op.moveShape(b, {
- x: t,
- y: 0
- })
- } else {
- if (n.keyCode == 40) {
- Designer.op.moveShape(b, {
- x: 0,
- y: t
- })
- }
- }
- }
- }
- $(document).unbind("keyup.moveshape").bind("keyup.moveshape",
- function () {
- Model.updateMulti(b);
- b = null;
- $(document).unbind("keyup.moveshape");
- Designer.op.hideTip();
- Utils.showLinkerCursor()
- })
- }
- } else {
- if (n.keyCode == 221 && n.ctrlKey) {
- var e = "front";
- if (n.shiftKey) {
- e = "forward"
- }
- Designer.layerShapes(e)
- } else {
- if (n.keyCode == 219 && n.ctrlKey) {
- var e = "back";
- if (n.shiftKey) {
- e = "backward"
- }
- Designer.layerShapes(e)
- } else {
- if (n.keyCode == 71 && n.ctrlKey) {
- n.preventDefault();
- if (n.shiftKey) {
- Designer.ungroup()
- } else {
- Designer.group()
- }
- } else {
- if (n.keyCode == 76 && n.ctrlKey) {
- n.preventDefault();
- if (n.shiftKey) {
- Designer.unlockShapes()
- } else {
- Designer.lockShapes()
- }
- } else {
- if (n.keyCode == 18) {
- Designer.op.changeState("drag_canvas")
- } else {
- if (n.keyCode == 27) {
- if (!Designer.op.state) {
- Utils.unselect();
- $(".menu.list").hide();
- $(".menu").hide();
- $(".color_picker").hide()
- } else {
- if (Designer.op.state == "creating_free_text" || Designer.op.state == "creating_free_linker") {
- Designer.op.resetState()
- }
- }
- } else {
- if (n.keyCode == 84 && !n.ctrlKey) {
- $(".menu.list").hide();
- Designer.op.changeState("creating_free_text")
- } else {
- if (n.keyCode == 73 && !n.ctrlKey) {
- $(".menu.list").hide();
- UI.showImageSelect(function (c, d, f) {
- UI.insertImage(c, d, f)
- });
- $("#designer_contextmenu").hide()
- } else {
- if (n.keyCode == 76 && !n.ctrlKey) {
- $(".menu.list").hide();
- Designer.op.changeState("creating_free_linker");
- $("#designer_contextmenu").hide()
- } else {
- if (n.keyCode == 66 && n.ctrlKey) {
- var o = Utils.getSelectedIds();
- if (o.length > 0) {
- var p = Model.getShapeById(o[0]);
- Designer.setFontStyle({
- bold: !p.fontStyle.bold
- });
- UI.update()
- }
- } else {
- if (n.keyCode == 73 && n.ctrlKey) {
- var o = Utils.getSelectedIds();
- if (o.length > 0) {
- var p = Model.getShapeById(o[0]);
- Designer.setFontStyle({
- italic: !p.fontStyle.italic
- });
- UI.update()
- }
- } else {
- if (n.keyCode == 85 && n.ctrlKey) {
- var o = Utils.getSelectedIds();
- if (o.length > 0) {
- var p = Model.getShapeById(o[0]);
- Designer.setFontStyle({
- underline: !p.fontStyle.underline
- });
- UI.update()
- }
- n.preventDefault()
- } else {
- if (n.keyCode == 32 && !n.ctrlKey) {
- var o = Utils.getSelectedIds();
- if (o.length == 1) {
- var p = Model.getShapeById(o[0]);
- Designer.op.editShapeText(p)
- }
- n.preventDefault()
- } else {
- if (n.keyCode == 121) {
- n.preventDefault();
- Dock.enterPresentation()
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- });
- $("input,textarea,select").die().live("keydown.hotkey",
- function (a) {
- a.stopPropagation()
- })
- },
- cancel: function () {
- $(document).unbind("keydown.hotkey")
- }
- },
- contextMenu: {
- init: function () {
- $("#designer_contextmenu").unbind("mousedown").bind("mousedown",
- function (b) {
- b.stopPropagation()
- });
- $("#designer_contextmenu").find("li:not(.devider)").unbind("click").bind("click",
- function () {
- var b = $(this);
- if (!b.menuitem("isDisabled") && b.children(".extend_menu").length == 0) {
- Designer.contextMenu.execAction(b);
- Designer.contextMenu.hide()
- }
- });
- $("#canvas_container").unbind("contextmenu").bind("contextmenu",
- function (d) {
- d.preventDefault();
- var e = $("#designer_canvas");
- var f = Utils.getRelativePos(d.pageX, d.pageY, e);
- Designer.contextMenu.show(f.x, f.y)
- })
- },
- destroy: function () {
- $("#canvas_container").unbind("contextmenu");
- this.hide()
- },
- menuPos: {
- x: 0,
- y: 0,
- shape: null
- },
- show: function (k, l) {
- this.menuPos.x = k;
- this.menuPos.y = l;
- var p = $("#designer_contextmenu");
- var r = Utils.getShapeByPosition(k, l, false);
- p.children().hide();
- p.children("li[ac=selectall]").show();
- p.children(".devi_selectall").show();
- p.children("li[ac=drawline]").show();
- var q = Designer.clipboard.elements.length;
- if (r == null) {
- if (q > 0) {
- p.children("li[ac=paste]").show();
- p.children(".devi_clip").show()
- }
- } else {
- var n = r.shape;
- this.menuPos.shape = n;
- if (n.locked) {
- if (q > 0) {
- p.children("li[ac=paste]").show();
- p.children(".devi_clip").show()
- }
- p.children("li[ac=unlock]").show();
- p.children(".devi_shape").show()
- } else {
- p.children("li[ac=cut]").show();
- p.children("li[ac=copy]").show();
- p.children("li[ac=duplicate]").show();
- if (q > 0) {
- p.children("li[ac=paste]").show()
- }
- p.children(".devi_clip").show();
- p.children("li[ac=front]").show();
- p.children("li[ac=back]").show();
- p.children("li[ac=lock]").show();
- var m = Utils.getSelectedIds();
- var o = m.length;
- if (o >= 2) {
- p.children("li[ac=group]").show();
- $("#ctxmenu_align").show()
- }
- var j = Utils.getSelectedGroups().length;
- if (j >= 1) {
- p.children("li[ac=ungroup]").show()
- }
- p.children(".devi_shape").show();
- if (o == 1 && n.name != "linker" && n.link) {
- p.children("li[ac=changelink]").show()
- }
- if (n.name == "linker" || n.attribute.editable) {
- p.children("li[ac=edit]").show()
- }
- p.children("li[ac=delete]").show();
- p.children(".devi_del").show()
- }
- }
- p.css({
- display: "block",
- "z-index": Model.orderList.length + 3,
- left: k,
- top: l
- });
- $(document).bind("mousedown.ctxmenu",
- function () {
- Designer.contextMenu.hide()
- })
- },
- hide: function () {
- $("#designer_contextmenu").hide();
- $(document).unbind("mousedown.ctxmenu")
- },
- execAction: function (e) {
- var d = e.attr("ac");
- if (d == "cut") {
- Designer.clipboard.cut()
- } else {
- if (d == "copy") {
- Designer.clipboard.copy()
- } else {
- if (d == "paste") {
- Designer.clipboard.paste(this.menuPos.x, this.menuPos.y)
- } else {
- if (d == "duplicate") {
- Designer.clipboard.duplicate()
- } else {
- if (d == "front") {
- Designer.layerShapes("front")
- } else {
- if (d == "back") {
- Designer.layerShapes("back")
- } else {
- if (d == "lock") {
- Designer.lockShapes()
- } else {
- if (d == "unlock") {
- Designer.unlockShapes()
- } else {
- if (d == "group") {
- Designer.group()
- } else {
- if (d == "ungroup") {
- Designer.ungroup()
- } else {
- if (d == "align_shape") {
- var f = e.attr("al");
- Designer.alignShapes(f)
- } else {
- if (d == "edit") {
- Designer.op.editShapeText(this.menuPos.shape)
- } else {
- if (d == "delete") {
- Designer.op.removeShape()
- } else {
- if (d == "selectall") {
- Designer.selectAll()
- } else {
- if (d == "drawline") {
- Designer.op.changeState("creating_free_linker")
- } else {
- if (d == "changelink") {
- UI.showInsertLink()
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- },
- init: function () {
- this.initialize.initLayout();
- this.initialize.initModel();
- this.initialize.initCanvas();
- this.initialize.initShapes();
- this.hotkey.init();
- this.contextMenu.init();
- Designer.op.init();
- this.initialize.initialized = true;
- Designer.events.push("initialized");
- $("#designer_layout").on("scroll",
- function () {
- $(document).trigger("mouseup.multiselect")
- })
- },
- op: {
- init: function () {
- var c = $("#designer_canvas");
- var d = $("#canvas_container");
- d.unbind("mousemove.operate").bind("mousemove.operate",
- function (a) {
- if (Designer.op.state != null) {
- return
- }
- Designer.op.destroy();
- var b = Utils.getRelativePos(a.pageX, a.pageY, c);
- var j = Utils.getShapeByPosition(b.x, b.y);
- if (j != null) {
- if (j.type == "dataAttribute") {
- } else {
- if (j.type == "linker") {
- d.css("cursor", "pointer");
- Designer.op.shapeSelectable(j.shape);
- var h = j.shape;
- var i = j.pointIndex;
- if (h.linkerType == "broken" && i > 1 && i <= h.points.length) {
- Designer.op.brokenLinkerChangable(h, i - 1)
- } else {
- if (h.from.id == null && h.to.id == null) {
- d.css("cursor", "move");
- Designer.op.shapeDraggable()
- }
- }
- Designer.op.linkerEditable(h)
- } else {
- if (j.type == "linker_point") {
- d.css("cursor", "move");
- Designer.op.shapeSelectable(j.shape);
- Designer.op.linkerDraggable(j.shape, j.point);
- Designer.op.linkerEditable(j.shape)
- } else {
- if (j.type == "linker_text") {
- d.css("cursor", "text");
- Designer.op.shapeSelectable(j.shape);
- Designer.op.linkerEditable(j.shape)
- } else {
- if (j.type == "shape") {
- if (j.shape.locked) {
- d.css("cursor", "default");
- Designer.op.shapeSelectable(j.shape)
- } else {
- d.css("cursor", "move");
- Designer.op.shapeSelectable(j.shape);
- Designer.op.shapeEditable(j.shape);
- Designer.op.shapeDraggable();
- if (j.shape.link) {
- }
- }
- } else {
- d.css("cursor", "crosshair");
- Designer.op.shapeSelectable(j.shape);
- Designer.op.shapeLinkable(j.shape, j.linkPoint)
- }
- if (j.shape.parent) {
- Utils.showAnchors(Model.getShapeById(j.shape.parent))
- } else {
- Utils.showAnchors(j.shape)
- }
- }
- }
- }
- }
- } else {
- d.css("cursor", "default");
- Designer.op.shapeMultiSelectable()
- }
- })
- },
- cancel: function () {
- $("#canvas_container").unbind("mousemove.operate").css("cursor", "default");
- this.destroy()
- },
- destroy: function () {
- $("#designer_canvas").unbind("mousedown.drag").unbind("dblclick.edit").unbind("mousedown.draglinker").unbind("mousedown.select").unbind("mousedown.brokenLinker").unbind("dblclick.edit_linker");
- $("#canvas_container").unbind("mousedown.link").unbind("mousedown.create_text").unbind("mousedown.drag_canvas");
- $("#designer_layout").unbind("mousedown.multiselect");
- Utils.hideAnchors();
- $("#link_spot").hide()
- },
- state: null,
- changeState: function (b) {
- this.state = b;
- if (b == "creating_free_text") {
- this.destroy();
- $("#canvas_container").css("cursor", "crosshair");
- this.textCreatable()
- } else {
- if (b == "creating_free_linker") {
- this.destroy();
- $("#canvas_container").css("cursor", "crosshair");
- this.shapeLinkable()
- } else {
- if (b == "drag_canvas") {
- this.destroy();
- this.canvasDraggable()
- } else {
- if (b == "changing_curve") {
- this.destroy()
- }
- }
- }
- }
- },
- resetState: function () {
- this.state = null;
- $("#canvas_container").css("cursor", "default")
- },
- shapeSelectable: function (d) {
- var c = $("#designer_canvas");
- c.bind("mousedown.select",
- function (b) {
- Designer.op.changeState("seelcting_shapes");
- var a = d.id;
- var f = [];
- if (b.ctrlKey) {
- var f = Utils.getSelectedIds();
- if (Utils.isSelected(a)) {
- Utils.removeFromArray(f, a)
- } else {
- f.push(a)
- }
- Utils.unselect();
- if (f.length > 0) {
- Utils.selectShape(f)
- }
- } else {
- if (Utils.selectIds.indexOf(a) < 0) {
- Utils.unselect();
- Utils.selectShape(a)
- }
- }
- $(document).bind("mouseup.select",
- function () {
- Designer.op.resetState();
- c.unbind("mousedown.select");
- $(document).unbind("mouseup.select")
- })
- })
- },
- shapeDraggable: function () {
- var c = $("#designer_canvas");
- var d = $("#canvas_container");
- c.bind("mousedown.drag",
- function (b) {
- Utils.hideLinkerCursor();
- Utils.hideLinkerControls();
- Designer.op.changeState("dragging");
- var x = Utils.getRelativePos(b.pageX, b.pageY, c);
- var u = Utils.getSelected();
- var w = true;
- if (u.length == 1 && u[0].name == "linker") {
- w = false
- }
- var z = null;
- if (w) {
- z = Utils.getShapesBounding(u)
- }
- var i = Utils.getFamilyShapes(u);
- u = u.concat(i);
- var r = Utils.getContainedShapes(u);
- u = u.concat(r);
- var s = Utils.getAttachedShapes(u);
- u = u.concat(s);
- var y = [];
- if (w) {
- for (var t = 0; t < u.length; t++) {
- var q = u[t];
- if (q == undefined) {
- continue
- }
- if (q.name == "linker") {
- if (q.from.id && y.indexOf(q.from.id) < 0) {
- y.push(q.from.id)
- }
- if (q.to.id && y.indexOf(q.to.id) < 0) {
- y.push(q.to.id)
- }
- }
- if (y.indexOf(q.id) < 0) {
- y.push(q.id)
- }
- }
- }
- var v = u;
- var a = Utils.getOutlinkers(u);
- u = u.concat(a);
- d.bind("mousemove.drag",
- function (j) {
- $("#link_spot").hide();
- var f = Utils.getRelativePos(j.pageX, j.pageY, c);
- var g = {
- x: f.x - x.x,
- y: f.y - x.y
- };
- if (w) {
- var e = Utils.copy(z);
- e.x += g.x;
- e.y += g.y;
- var h = Designer.op.snapLine(e, y);
- g = {
- x: e.x - z.x,
- y: e.y - z.y
- };
- f = {
- x: x.x + g.x,
- y: x.y + g.y
- };
- z.x += g.x;
- z.y += g.y;
- if (v.length == 1 && v[0].groupName == "boundaryEvent") {
- if (h.attach) {
- v[0].attachTo = h.attach.id
- } else {
- delete u[0].attachTo
- }
- }
- }
- if (g.x == 0 && g.y == 0) {
- return
- }
- if (methodId == 'process.subprocess') { // 如果当前打开的模型不是端到端总图 那么整个js也没有执行的必要
- // 端到端功能 如果移动的元素是子流程节点展开后 范围框中的元素 则进行移动范围限制校验
- let rang = window.subProcess.scopeRang;
- let movingEle = window.subProcess.movingEle;
- if (movingEle != null && rang != null) {
- let flag = false;
- for (let k = 0; k < u.length; k++) {
- if (u[k].name == "linker") continue;
- if (u[k].id == movingEle.id) flag = true;
- }
- if (flag) {
- let movingEleBound = {
- x: movingEle.props.x,
- y: movingEle.props.y,
- w: movingEle.props.w,
- h: movingEle.props.h
- }
- if (movingEleBound.x + g.x <= rang.x1 || movingEleBound.x + movingEleBound.w + g.x >= rang.x2 || movingEleBound.y + g.y <= rang.y1 || movingEleBound.y + movingEleBound.h + g.y >= rang.y2) {
- $.simpleAlert("子流程内部节点只能在范围标识框内部移动", "warning");
- d.unbind("mousemove.drag");
- c.unbind("mousedown.drag");
- return;
- }
- }
- }
- }
- Designer.op.moveShape(u, g);
- x = f;
- $(document).unbind("mouseup.drop").bind("mouseup.drop",
- function () {
- Model.updateMulti(u);
- $(document).unbind("mouseup.drop")
- })
- });
- $(document).bind("mouseup.drag",
- function () {
- Designer.op.resetState();
- d.unbind("mousemove.drag");
- c.unbind("mousedown.drag");
- $(document).unbind("mouseup.drag");
- Designer.op.hideTip();
- Designer.op.hideSnapLine();
- Utils.showLinkerCursor();
- Utils.showLinkerControls();
- var selectedShape = Utils.getSelected()[0];
- if (selectedShape) {
- var shapePosition = selectedShape.props;
- var pageSize = Model.define.page;
- if (shapePosition.x + shapePosition.w > pageSize.width - pageSize.padding) {
- Designer.setPageStyle({
- width: shapePosition.x + shapePosition.w + pageSize.padding + 30
- });
- $("#page_size_w").spinner('value', shapePosition.x + shapePosition.w + pageSize.padding + 30);
- }
- if (shapePosition.y + shapePosition.h > pageSize.height - pageSize.padding) {
- Designer.setPageStyle({
- height: shapePosition.y + shapePosition.h + pageSize.padding + 30
- });
- $("#page_size_h").spinner('value', shapePosition.x + shapePosition.w + pageSize.padding + 30)
- }
- }
- if (isAutoSave == "0") {
- $("#saving_tip").css("color", "rgb(255, 0, 0)");
- $("#saving_tip").text("文件已修改,未保存");
- }
- })
- })
- },
- shapeResizable: function () {
- $(".shape_controller").bind("mousedown",
- function (ab) {
- if (!isAdmin && isCustomDefine == "1") {
- var ae = Utils.getSelected();
- var P = true;
- for (var p = 0; p < ae.length; p++) {
- var V = ae[p].name;
- var i = Schema.shapes[V];
- if (i.resizeable == "0") {
- return
- }
- }
- }
- Utils.hideLinkerCursor();
- if ($("#shape_text_edit").length) {
- $("#shape_text_edit").trigger("blur")
- }
- var S = $("#canvas_container");
- var Y = $("#designer_canvas");
- ab.stopPropagation();
- var D = Utils.getRelativePos(ab.pageX, ab.pageY, Y);
- var Q = $(this);
- Designer.op.changeState("resizing");
- var U = Utils.getSelectedIds();
- var K = Utils.getSelected();
- var M;
- if (U.length == 1) {
- var aa = Model.getShapeById(U[0]);
- M = Utils.copy(aa.props)
- } else {
- M = Utils.getControlBox(U);
- M.angle = 0
- }
- var C = {
- x: M.x + M.w / 2,
- y: M.y + M.h / 2
- };
- var N = Q.attr("resizeDir");
- var E = {};
- if (N.indexOf("l") >= 0) {
- E.x = M.x + M.w
- } else {
- if (N.indexOf("r") >= 0) {
- E.x = M.x
- } else {
- E.x = M.x + M.w / 2
- }
- }
- if (N.indexOf("t") >= 0) {
- E.y = M.y + M.h
- } else {
- if (N.indexOf("b") >= 0) {
- E.y = M.y
- } else {
- E.y = M.y + M.h / 2
- }
- }
- E = Utils.getRotated(C, E, M.angle);
-
- function G(a, b) {
- if (a.id == null) {
- if (b) {
- return {
- type: "box",
- x: (a.x - M.x) / M.w,
- y: (a.y - M.y) / M.h
- }
- } else {
- return {
- type: "fixed"
- }
- }
- } else {
- if (Utils.isSelected(a.id)) {
- var e = Model.getShapeById(a.id);
- var d = {
- x: e.props.x + e.props.w / 2,
- y: e.props.y + e.props.h / 2
- };
- var c = Utils.getRotated(d, a, -e.props.angle);
- return {
- type: "shape",
- x: (c.x - e.props.x) / e.props.w,
- y: (c.y - e.props.y) / e.props.h
- }
- } else {
- return {
- type: "fixed"
- }
- }
- }
- }
-
- var W = [];
- var ac = {};
- var Z = [];
- var L = Utils.getAttachedShapes(K);
- K = K.concat(L);
- var J = [];
- for (var H = 0; H < K.length; H++) {
- var aa = K[H];
- J.push(aa.id);
- if (aa.parent) {
- J.push(aa.parent)
- }
- if (aa.name == "linker") {
- if (Z.indexOf(aa.id) == -1) {
- Z.push(aa.id)
- }
- } else {
- W.push(aa);
- if (aa.attachTo && !Utils.isSelected(aa.id)) {
- ac[aa.id] = {
- type: "attached",
- x: (aa.props.x + aa.props.w / 2 - M.x) / M.w,
- y: (aa.props.y + aa.props.h / 2 - M.y) / M.h
- }
- } else {
- ac[aa.id] = {
- x: (aa.props.x - M.x) / M.w,
- y: (aa.props.y - M.y) / M.h,
- w: aa.props.w / M.w,
- h: aa.props.h / M.h
- }
- }
- var I = Model.getShapeLinkers(aa.id);
- if (I && I.length > 0) {
- for (var T = 0; T < I.length; T++) {
- var O = I[T];
- if (Z.indexOf(O) == -1) {
- Z.push(O)
- }
- }
- }
- }
- }
- for (var H = 0; H < Z.length; H++) {
- var O = Z[H];
- var R = Model.getShapeById(O);
- W.push(R);
- var K = Utils.isSelected(O);
- ac[R.id] = {
- from: G(R.from, K),
- to: G(R.to, K)
- }
- }
- var X = Q.css("cursor");
- S.css("cursor", X);
- var F = [];
- var ad = {
- w: 20,
- h: 20
- };
- Designer.events.push("beforeResize", {
- minSize: ad,
- shapes: W,
- dir: N
- });
- S.bind("mousemove.resize",
- function (a) {
- F = [];
- var t = Utils.getRelativePos(a.pageX, a.pageY, Y);
- t = Utils.restoreScale(t);
- var k = Utils.getRotated(E, t, -M.angle);
- var w = Utils.copy(M);
- if (N.indexOf("r") >= 0) {
- w.w = k.x - E.x
- } else {
- if (N.indexOf("l") >= 0) {
- w.w = E.x - k.x
- }
- }
- if (N.indexOf("b") >= 0) {
- w.h = k.y - E.y
- } else {
- if (N.indexOf("t") >= 0) {
- w.h = E.y - k.y
- }
- }
- if (a.ctrlKey && N.length == 2) {
- if (M.w >= M.h) {
- w.h = M.h / M.w * w.w;
- if (w.h < ad.h) {
- w.h = ad.h;
- w.w = M.w / M.h * w.h
- }
- } else {
- w.w = M.w / M.h * w.h;
- if (w.w < ad.w) {
- w.w = ad.w;
- w.h = M.h / M.w * w.w
- }
- }
- } else {
- if (w.w < ad.w) {
- w.w = ad.w
- }
- if (w.h < ad.h) {
- w.h = ad.h
- }
- }
- var d = {};
- if (N.indexOf("r") >= 0) {
- d.x = E.x + w.w
- } else {
- if (N.indexOf("l") >= 0) {
- d.x = E.x - w.w
- } else {
- d.x = E.x
- }
- }
- if (N.indexOf("b") >= 0) {
- d.y = E.y + w.h
- } else {
- if (N.indexOf("t") >= 0) {
- d.y = E.y - w.h
- } else {
- d.y = E.y
- }
- }
- var o = Utils.getRotated(E, d, M.angle);
- var m = {
- x: 0.5 * E.x + 0.5 * o.x,
- y: 0.5 * E.y + 0.5 * o.y
- };
- var f = Utils.getRotated(m, E, -M.angle);
- if (N.indexOf("r") >= 0) {
- w.x = f.x
- } else {
- if (N.indexOf("l") >= 0) {
- w.x = f.x - w.w
- } else {
- w.x = f.x - w.w / 2
- }
- }
- if (N.indexOf("b") >= 0) {
- w.y = f.y
- } else {
- if (N.indexOf("t") >= 0) {
- w.y = f.y - w.h
- } else {
- w.y = f.y - w.h / 2
- }
- }
- if (w.angle == 0) {
- var y = W[0];
- var h = Designer.op.snapResizeLine(w, J, N)
- }
- Utils.removeAnchors();
- for (var e = 0; e < W.length; e++) {
- var u = W[e];
- var j = ac[u.id];
- if (u.name == "linker") {
- if (j.from.type == "box") {
- u.from.x = w.x + w.w * j.from.x;
- u.from.y = w.y + w.h * j.from.y
- } else {
- if (j.from.type == "shape") {
- var c = Model.getShapeById(u.from.id);
- var g = {
- x: c.props.x + c.props.w * j.from.x,
- y: c.props.y + c.props.h * j.from.y
- };
- var b = {
- x: c.props.x + c.props.w / 2,
- y: c.props.y + c.props.h / 2
- };
- var s = Utils.getRotated(b, g, c.props.angle);
- u.from.x = s.x;
- u.from.y = s.y
- }
- }
- if (j.to.type == "box") {
- u.to.x = w.x + w.w * j.to.x;
- u.to.y = w.y + w.h * j.to.y
- } else {
- if (j.to.type == "shape") {
- var c = Model.getShapeById(u.to.id);
- var g = {
- x: c.props.x + c.props.w * j.to.x,
- y: c.props.y + c.props.h * j.to.y
- };
- var b = {
- x: c.props.x + c.props.w / 2,
- y: c.props.y + c.props.h / 2
- };
- var s = Utils.getRotated(b, g, c.props.angle);
- u.to.x = s.x;
- u.to.y = s.y
- }
- }
- Designer.painter.renderLinker(u, true)
- } else {
- if (j.type == "attached") {
- u.props.x = w.x + w.w * j.x - u.props.w / 2;
- u.props.y = w.y + w.h * j.y - u.props.h / 2
- } else {
- var x = Utils.copy(u.props);
- u.props.x = w.x + w.w * j.x;
- u.props.y = w.y + w.h * j.y;
- u.props.w = w.w * j.w;
- u.props.h = w.h * j.h;
- var v = Model.getShapeById(u.id).props;
- v.x = w.x + w.w * j.x;
- v.y = w.y + w.h * j.y;
- v.w = w.w * j.w;
- v.h = w.h * j.h;
- var q = {
- x: u.props.x - x.x,
- y: u.props.y - x.y,
- w: u.props.w - x.w,
- h: u.props.h - x.h
- };
- var l = {
- shape: u,
- offset: q,
- dir: N
- };
- var n = Designer.events.push("resizing", l);
- if (n) {
- F = F.concat(n)
- }
- }
- Designer.painter.renderShape(u);
- Utils.showAnchors(u)
- }
- }
- Designer.painter.drawControls(U);
- var r = "W: " + Math.round(w.w) + " H: " + Math.round(w.h);
- if (w.x != M.x) {
- r = "X: " + Math.round(w.x) + " Y: " + Math.round(w.y) + "
" + r
- }
- Designer.op.showTip(r);
- $(document).unbind("mouseup.resize_ok").bind("mouseup.resize_ok",
- function () {
- if (F.length > 0) {
- W = W.concat(F)
- }
- Model.updateMulti(W);
- $(document).unbind("mouseup.resize_ok")
- })
- });
- $(document).bind("mouseup.resize",
- function () {
- S.css("cursor", "default");
- Designer.op.resetState();
- S.unbind("mousemove.resize");
- $(document).unbind("mouseup.resize");
- var selectedShape = Utils.getSelected()[0];
- if (selectedShape) {
- var shapePosition = selectedShape.props;
- var pageSize = Model.define.page;
- if (shapePosition.x + shapePosition.w > pageSize.width - pageSize.padding) {
- Designer.setPageStyle({
- width: shapePosition.x + shapePosition.w + pageSize.padding + 10
- });
- }
- if (shapePosition.y + shapePosition.h > pageSize.height - pageSize.padding) {
- Designer.setPageStyle({
- height: shapePosition.y + shapePosition.h + pageSize.padding + 10
- });
- }
- }
- Designer.op.hideTip();
- Utils.showLinkerCursor();
- Designer.op.hideSnapLine()
- })
- })
- },
- shapeRotatable: function () {
- $(".shape_rotater").bind("mousemove",
- function (i) {
- var j = $(this);
- var g = i.pageX - j.offset().left;
- var h = i.pageY - j.offset().top;
- var e = j[0].getContext("2d");
- j.unbind("mousedown");
- j.removeClass("rotate_enable");
- if (e.isPointInPath(g, h)) {
- j.addClass("rotate_enable");
- j.bind("mousedown",
- function (b) {
- Utils.hideLinkerCursor();
- if ($("#shape_text_edit").length) {
- $("#shape_text_edit").trigger("blur")
- }
- b.stopPropagation();
- Designer.op.changeState("rotating");
- var r = Utils.getSelectedIds();
- var c;
- var s;
- if (r.length == 1) {
- var f = Model.getShapeById(r[0]);
- c = f.props;
- s = f.props.angle
- } else {
- c = Utils.getControlBox(r);
- s = 0
- }
- var x = {
- x: c.x + c.w / 2,
- y: c.y + c.h / 2
- };
- var d = Utils.toScale(x);
- var w = $("#designer_canvas");
- var u = Utils.getSelected();
- var t = Utils.getAttachedShapes(u);
- u = u.concat(t);
- var a = Utils.getOutlinkers(u);
- u = u.concat(a);
- var v = s;
- $(document).bind("mousemove.rotate",
- function (l) {
- var m = Utils.getRelativePos(l.pageX, l.pageY, w);
- var H = Math.atan(Math.abs(m.x - d.x) / Math.abs(d.y - m.y));
- if (m.x >= d.x && m.y >= d.y) {
- H = Math.PI - H
- } else {
- if (m.x <= d.x && m.y >= d.y) {
- H = Math.PI + H
- } else {
- if (m.x <= d.x && m.y <= d.y) {
- H = Math.PI * 2 - H
- }
- }
- }
- H = H % (Math.PI * 2);
- var k = Math.PI / 36;
- var o = Math.round(H / k);
- H = k * o;
- if (H == v) {
- return
- }
- v = H;
- Designer.op.showTip(o * 5 % 360 + "°");
- Designer.painter.rotateControls(c, H);
- Utils.removeAnchors();
- var L = H - s;
- for (var G = 0; G < u.length; G++) {
- var q = u[G];
- var I = Model.getPersistenceById(q.id);
- if (q.name != "linker") {
- q.props.angle = Math.abs((L + I.props.angle) % (Math.PI * 2));
- var F = {
- x: I.props.x + I.props.w / 2,
- y: I.props.y + I.props.h / 2
- };
- var n = Utils.getRotated(x, F, L);
- q.props.x = n.x - q.props.w / 2;
- q.props.y = n.y - q.props.h / 2;
- Designer.painter.renderShape(q);
- Utils.showAnchors(q)
- } else {
- var p = false;
- if ((Utils.isSelected(q.id) && q.from.id == null) || Utils.isSelected(q.from.id)) {
- var K = Utils.getRotated(x, I.from, L);
- q.from.x = K.x;
- q.from.y = K.y;
- if (q.from.angle != null) {
- q.from.angle = Math.abs((I.from.angle + L) % (Math.PI * 2))
- }
- p = true
- }
- var J = false;
- if ((Utils.isSelected(q.id) && q.to.id == null) || Utils.isSelected(q.to.id)) {
- var K = Utils.getRotated(x, I.to, L);
- q.to.x = K.x;
- q.to.y = K.y;
- if (q.to.angle != null) {
- q.to.angle = Math.abs((I.to.angle + L) % (Math.PI * 2))
- }
- J = true
- }
- if (p || J) {
- Designer.painter.renderLinker(q, true)
- }
- }
- }
- }).bind("mouseup.rotate",
- function () {
- $(document).unbind("mousemove.rotate").unbind("mouseup.rotate");
- Designer.op.resetState();
- Model.updateMulti(u);
- Designer.painter.drawControls(r);
- Designer.op.hideTip();
- Utils.showLinkerCursor()
- })
- })
- } else {
- j.removeClass("rotate_enable");
- j.unbind("mousedown")
- }
- })
- },
- groupShapeChangable: function () {
- $(".change_shape_icon").bind("mousedown",
- function (l) {
- l.stopPropagation();
- var i = Utils.getSelected()[0];
- var j = i.groupName;
- var m = $(this).parent();
- var k = m.position();
- var n = k.left + m.width();
- var e = k.top + m.height() + 10;
- Designer.op.groupDashboard(j, n, e,
- function (c) {
- if (i.name != c) {
- var b = Designer.events.push("shapeChanged", {
- shape: i,
- name: c
- });
- var b1 = Utils.copy(i); //保留源节点信息(AttributesJsonArray)
- var b2 = Utils.copy(i); //重新保留源节点信息(AttributesJsonArray)
- Model.changeShape(i, c); //重画节点后会把节点信息抹去
- //将源节点b2内的AttributesJsonArray加入默认属性,并且替换源节点有值并且为目标节点默认属性的属性。
- for (var x = 0; x < b2.dataAttributes.length; x++) {
- var b2x = b2.dataAttributes[x];
- if (b2x.attributesJsonArray) {
- var attributesJsonArray = b2x.attributesJsonArray.splice(0); //源节点的属性
- //加入默认属性
- if (Model.define.localAttribute != undefined && Model.define.localAttribute[c] != undefined && Model.define.localAttribute[c] != null && Model.define.localAttribute[c].length > 0) {
- for (var b2xi in Model.define.localAttribute[c]) {
- b2x.attributesJsonArray.push(Utils.copy(Model.define.localAttribute[c][b2xi]));
- }
- }
- //替换源节点有值的属性
- for (var pj = 0; pj < attributesJsonArray.length; pj++) {
- var hasValue = (attributesJsonArray[pj].value || attributesJsonArray[pj].value === false) && attributesJsonArray[pj].value !== [];
- if (attributesJsonArray[pj] && attributesJsonArray[pj].id && hasValue) {
- var flag = false;
- for (var b2xj = 0; b2xj < b2x.attributesJsonArray.length; b2xj++) {
- if (b2x.attributesJsonArray[b2xj] && b2x.attributesJsonArray[b2xj].id == attributesJsonArray[pj].id) {
- b2x.attributesJsonArray[b2xj] = attributesJsonArray[pj];
- flag = true;
- break;
- }
- }
- }
- }
- }
- }
- i.dataAttributes = b2.dataAttributes; //重新加入默认属性并且加入源节点带值的属性
- var a = [i];
- if (b && b.length > 0) {
- a = a.concat(b)
- }
- Model.updateMulti(a)
- }
- })
- })
- },
- shapeMultiSelectable: function () {
- var d = $("#designer_canvas");
- var c = $("#designer_layout");
- c.unbind("mousedown.multiselect").bind("mousedown.multiselect",
- function (a) {
- var b = null;
- if (!a.ctrlKey) {
- Utils.unselect()
- }
- var f = Utils.getRelativePos(a.pageX, a.pageY, d);
- Designer.op.changeState("multi_selecting");
- c.bind("mousemove.multiselect",
- function (i) {
- if (b == null) {
- b = $("").appendTo(d)
- }
- var j = Utils.getRelativePos(i.pageX, i.pageY, d);
- var e = {
- "z-index": Model.orderList.length,
- left: j.x,
- top: j.y
- };
- if (j.x > f.x) {
- e.left = f.x
- }
- if (j.y > f.y) {
- e.top = f.y
- }
- e.width = Math.abs(j.x - f.x);
- e.height = Math.abs(j.y - f.y);
- b.css(e)
- });
- $(document).unbind("mouseup.multiselect").bind("mouseup.multiselect",
- function (j) {
- if (b != null) {
- var l = {
- x: b.position().left.restoreScale(),
- y: b.position().top.restoreScale(),
- w: b.width().restoreScale(),
- h: b.height().restoreScale()
- };
- var e = Utils.getShapesByRange(l);
- if (j.ctrlKey) {
- var k = Utils.getSelectedIds();
- Utils.mergeArray(e, k)
- }
- Utils.unselect();
- Utils.selectShape(e);
- b.remove()
- }
- Designer.op.resetState();
- $(document).unbind("mouseup.multiselect");
- c.unbind("mousemove.multiselect")
- });
- c.unbind("mousedown.multiselect")
- })
- },
- shapeEditable: function (d) {
- var c = $("#designer_canvas");
- if (d.attribute.editable == false) {
- return
- }
- c.unbind("dblclick.edit").bind("dblclick.edit",
- function () {
- Designer.op.editShapeText(d);
- c.unbind("dblclick.edit")
- })
- },
- editShapeText: function (o) {
- if (o.name == "linker") {
- this.editLinkerText(o);
- return
- }
- var j = $("#shape_text_edit");
- if (j.length == 0) {
- j = $("").appendTo("#designer_canvas")
- }
- var k = $("#shape_text_ruler");
- if (k.length == 0) {
- k = $("").appendTo("#designer_canvas")
- }
- $(".text_canvas[forshape=" + o.id + "]").hide();
- var l = o.fontStyle;
- var p = o.getTextBlock();
- if (l.orientation == "horizontal") {
- var m = {
- x: p.x + p.w / 2,
- y: p.y + p.h / 2
- };
- p = {
- x: m.x - p.h / 2,
- y: m.y - p.w / 2,
- w: p.h,
- h: p.w
- }
- }
- var n = {
- width: p.w + "px",
- "z-index": Model.orderList.length + 2,
- "line-height": Math.round(l.size * 1.25) + "px",
- "font-size": l.size + "px",
- "font-family": l.fontFamily,
- "font-weight": l.bold ? "bold" : "normal",
- "font-style": l.italic ? "italic" : "normal",
- "text-align": l.textAlign,
- color: "rgb(" + l.color + ")",
- "text-decoration": l.underline ? "underline" : "none"
- };
- j.css(n);
- k.css(n);
- j.show();
- p.x += o.props.x;
- p.y += o.props.y;
- j.val(o.text);
- $("#shape_text_edit").unbind().bind("keyup",
- function () {
- var a = $(this).val();
- k.val(a);
- k.scrollTop(99999);
- var h = k.scrollTop();
- j.css({
- height: h
- });
- var g = {
- x: p.x + p.w / 2,
- y: p.y + p.h / 2
- };
- var f = 0;
- var d = 0;
- var w = p.h;
- if (o.fontStyle.vAlign == "middle") {
- if (h > w) {
- w = h;
- f = (g.y - w / 2);
- d = 0
- } else {
- f = (g.y - p.h / 2);
- d = (p.h - h) / 2;
- w = p.h - d
- }
- } else {
- if (o.fontStyle.vAlign == "bottom") {
- if (h > w) {
- w = h;
- f = (g.y + p.h / 2 - w);
- d = 0
- } else {
- f = (g.y - p.h / 2);
- d = p.h - h;
- w = p.h - d
- }
- } else {
- f = (g.y - p.h / 2);
- d = 0;
- if (h > w) {
- w = h
- } else {
- w = p.h
- }
- }
- }
- var x = d + w;
- var b = {
- x: p.x + p.w / 2,
- y: f + x / 2
- };
- var c = o.props.angle;
- if (c != 0) {
- var v = {
- x: o.props.x + o.props.w / 2,
- y: o.props.y + o.props.h / 2
- };
- b = Utils.getRotated(v, b, c)
- }
- if (l.orientation == "horizontal") {
- c = (Math.PI * 1.5 + c) % (Math.PI * 2)
- }
- var u = Math.round(c / (Math.PI * 2) * 360);
- var e = "rotate(" + u + "deg) scale(" + Designer.config.scale + ")";
- j.css({
- width: p.w,
- height: w,
- "padding-top": d,
- left: b.x.toScale() - p.w / 2 - 2,
- top: b.y.toScale() - x / 2 - 2,
- "-webkit-transform": e,
- "-ms-transform": e,
- "-o-transform": e,
- "-moz-transform": e,
- transform: e
- })
- }).bind("keydown",
- function (a) {
- var d = $(this);
- if (a.keyCode == 13 && a.ctrlKey) {
- i();
- return false
- } else {
- if (a.keyCode == 27) {
- d.unbind().remove();
- $(".text_canvas[forshape=" + o.id + "]").show()
- } else {
- if (a.keyCode == 66 && a.ctrlKey) {
- var c = !o.fontStyle.bold;
- o.fontStyle.bold = c;
- Model.update(o);
- var b = c ? "bold" : "normal";
- $(this).css("font-weight", b);
- k.css("font-weight", b);
- UI.update()
- } else {
- if (a.keyCode == 73 && a.ctrlKey) {
- var c = !o.fontStyle.italic;
- o.fontStyle.italic = c;
- Model.update(o);
- var b = c ? "italic" : "normal";
- $(this).css("font-style", b);
- k.css("font-style", b);
- UI.update()
- } else {
- if (a.keyCode == 85 && a.ctrlKey) {
- var c = !o.fontStyle.underline;
- o.fontStyle.underline = c;
- Model.update(o);
- var b = c ? "underline" : "none";
- $(this).css("text-decoration", b);
- k.css("text-decoration", b);
- a.preventDefault();
- UI.update()
- }
- }
- }
- }
- }
- }).bind("blur",
- function (a) {
- i()
- }).bind("mousemove",
- function (a) {
- a.stopPropagation()
- }).bind("mousedown",
- function (a) {
- a.stopPropagation()
- }).bind("mouseenter",
- function (a) {
- Designer.op.destroy()
- });
- $("#shape_text_edit").trigger("keyup");
- j.select();
-
- function i() {
- var a = $("#shape_text_edit").val();
- if ($("#shape_text_edit").length && $("#shape_text_edit").is(":visible")) {
- if (a != o.text) {
- o.text = a;
- Model.update(o)
- }
- Designer.painter.renderShape(o);
- $("#shape_text_edit").remove()
- }
- }
- },
- shapeLinkable: function (j, g) {
- var i = $("#designer_canvas");
- var f = $("#canvas_container");
- f.unbind("mousedown.link").bind("mousedown.link",
- function (c) {
- Designer.op.changeState("linking_from_shape");
- var e = null;
- var d = null;
- var a;
- if (!j) {
- var b = Utils.getRelativePos(c.pageX, c.pageY, i);
- a = {
- x: b.x.restoreScale(),
- y: b.y.restoreScale(),
- id: null,
- angle: null
- }
- } else {
- a = g;
- a.id = j.id
- }
- f.bind("mousemove.link",
- function (m) {
- f.css("cursor", "default");
- var n = Utils.getRelativePos(m.pageX, m.pageY, i);
- if (d == null) {
- d = h(a, n);
- Designer.events.push("linkerCreating", d)
- }
- Designer.op.moveLinker(d, "to", n.x, n.y);
- $(document).unbind("mouseup.droplinker").bind("mouseup.droplinker",
- function () {
- if (Math.abs(n.x - a.x) > 20 || Math.abs(n.y - a.y) > 20) {
- Model.add(d);
- Designer.events.push("linkerCreated", d);
- if (d.to.id == null && d.from.id != null) {
- Designer.op.linkDashboard(d)
- }
- Utils.showLinkerCursor()
- } else {
- $("#" + d.id).remove()
- }
- $(document).unbind("mouseup.droplinker")
- })
- });
- $(document).bind("mouseup.link",
- function () {
- Designer.op.hideLinkPoint();
- Designer.op.resetState();
- if (methodId == 'process.subprocess') { // 如果建模为端到端 连线样式调整 防止因层级原因 子流程展开或者关闭按钮 点击不到
- window.subProcess.linkerBoxPointerEvent();
- }
- f.unbind("mousedown.link");
- f.unbind("mousemove.link");
- $(document).unbind("mouseup.link")
- })
- });
-
- function h(a, b) {
- var d = Utils.newId();
- var c = Utils.copy(Schema.linkerDefaults);
- c.from = a;
- c.to = {
- id: null,
- x: b.x,
- y: b.y,
- angle: null
- };
- c.props = {
- zindex: Model.maxZIndex + 1
- };
- c.id = d;
- return c
- }
- },
- linkerEditable: function (c) {
- var d = $("#designer_canvas");
- d.unbind("dblclick.edit_linker").bind("dblclick.edit_linker",
- function () {
- Designer.op.editLinkerText(c);
- d.unbind("dblclick.edit_linker")
- })
- },
- editLinkerText: function (n) {
- Designer.contextMenu.hide();
- var o = Designer.painter.getLinkerMidpoint(n);
- var k = $("#" + n.id).find(".text_canvas");
- var i = $("#linker_text_edit");
- if (i.length == 0) {
- i = $("").appendTo("#designer_canvas")
- }
- $("#" + n.id).find(".text_canvas").hide();
- var l = n.fontStyle;
- var m = "scale(" + Designer.config.scale + ")";
- var j = Math.round(l.size * 1.25);
- i.css({
- "z-index": Model.orderList.length,
- "line-height": j + "px",
- "font-size": l.size + "px",
- "font-family": l.fontFamily,
- "font-weight": l.bold ? "bold" : "normal",
- "font-style": l.italic ? "italic" : "normal",
- "text-align": l.textAlign,
- color: "rgb(" + l.color + ")",
- "text-decoration": l.underline ? "underline" : "none",
- "-webkit-transform": m,
- "-ms-transform": m,
- "-o-transform": m,
- "-moz-transform": m,
- transform: m
- });
- i.val(n.text).show().select();
- i.unbind().bind("keyup",
- function () {
- var b = $(this).val();
- var a = b.replace(//g, ">").replace(/\n/g, "
");
- k.html(a + "
");
- var d = k.width();
- if (d < 50) {
- d = 50
- }
- var c = k.height();
- if (c < j) {
- c = j
- }
- i.css({
- left: o.x.toScale() - d / 2 - 2,
- top: o.y.toScale() - c / 2 - 2,
- width: d,
- height: c
- })
- }).bind("mousedown",
- function (a) {
- a.stopPropagation()
- }).bind("keydown",
- function (a) {
- if (a.keyCode == 13 && a.ctrlKey) {
- p();
- return false
- } else {
- if (a.keyCode == 27) {
- i.unbind().remove();
- Designer.painter.renderLinkerText(n)
- } else {
- if (a.keyCode == 66 && a.ctrlKey) {
- var c = !n.fontStyle.bold;
- n.fontStyle.bold = c;
- Model.update(n);
- var b = c ? "bold" : "normal";
- $(this).css("font-weight", b);
- k.css("font-weight", b);
- UI.update()
- } else {
- if (a.keyCode == 73 && a.ctrlKey) {
- var c = !n.fontStyle.italic;
- n.fontStyle.italic = c;
- Model.update(n);
- var b = c ? "italic" : "normal";
- $(this).css("font-style", b);
- k.css("font-style", b);
- UI.update()
- } else {
- if (a.keyCode == 85 && a.ctrlKey) {
- var c = !n.fontStyle.underline;
- n.fontStyle.underline = c;
- Model.update(n);
- var b = c ? "underline" : "none";
- $(this).css("text-decoration", b);
- k.css("text-decoration", b);
- a.preventDefault();
- UI.update()
- }
- }
- }
- }
- }
- }).bind("blur",
- function () {
- p()
- });
- i.trigger("keyup");
-
- function p() {
- var b = $("#linker_text_edit");
- if (b.length && b.is(":visible")) {
- var a = b.val();
- if (a != n.text) {
- n.text = a;
- Model.update(n)
- }
- Designer.painter.renderLinker(n);
- b.remove()
- }
- }
- },
- linkerDraggable: function (g, f) {
- var h = $("#designer_canvas");
- var e = $("#canvas_container");
- h.bind("mousedown.draglinker",
- function (b) {
- Utils.hideLinkerControls();
- Designer.op.changeState("dragging_linker");
- var c = Utils.getSelectedIds();
- var a = false;
- if (c.length > 1) {
- a = true
- }
- e.bind("mousemove.draglinker",
- function (d) {
- e.css("cursor", "default");
- var j = Utils.getRelativePos(d.pageX, d.pageY, h);
- Designer.op.moveLinker(g, f, j.x, j.y);
- if (a) {
- Designer.painter.drawControls(c)
- }
- $(document).unbind("mouseup.droplinker").bind("mouseup.droplinker",
- function () {
- $(document).unbind("mouseup.droplinker");
- Model.update(g);
- Utils.showLinkerControls()
- })
- });
- $(document).bind("mouseup.draglinker",
- function () {
- Designer.op.hideLinkPoint();
- Designer.op.resetState();
- h.unbind("mousedown.draglinker");
- e.unbind("mousemove.draglinker");
- $(document).unbind("mouseup.draglinker");
- Utils.showLinkerControls()
- })
- })
- },
- linkClickable: function (e, f) {
- var d = $("#link_spot");
- if (d.length == 0) {
- d = $("").appendTo("#designer_canvas")
- }
- if (e.trim().toLowerCase().indexOf("http") == -1) {
- e = "http://" + e
- }
- d.show().css({
- left: f.x - 50,
- top: f.y - 50,
- "z-index": Model.orderList.length + 1
- })
- },
- textCreatable: function () {
- var c = $("#designer_canvas");
- var d = $("#canvas_container");
- d.unbind("mousedown.create_text").bind("mousedown.create_text",
- function (a) {
- var g = null;
- if (!a.ctrlKey) {
- Utils.unselect()
- }
- var h = Utils.getRelativePos(a.pageX, a.pageY, c);
- var b = null;
- d.bind("mousemove.create_text",
- function (f) {
- if (g == null) {
- g = $("").appendTo(c)
- }
- var e = Utils.getRelativePos(f.pageX, f.pageY, c);
- b = {
- "z-index": Model.orderList.length,
- left: e.x - 1,
- top: e.y - 1
- };
- if (e.x > h.x) {
- b.left = h.x - 1
- }
- if (e.y > h.y) {
- b.top = h.y - 1
- }
- b.width = Math.abs(e.x - h.x - 2);
- b.height = Math.abs(e.y - h.y - 2);
- g.css(b)
- });
- $(document).unbind("mouseup.create_text").bind("mouseup.create_text",
- function (e) {
- if (b != null && b.width >= 20 && b.height >= 20) {
- var f = Model.create("standardText", b.left.restoreScale(), b.top.restoreScale());
- f.props.w = b.width.restoreScale();
- f.props.h = b.height.restoreScale();
- Model.add(f);
- Designer.painter.renderShape(f);
- Designer.op.editShapeText(f);
- Utils.unselect();
- Utils.selectShape(f.id)
- }
- g.remove();
- Designer.op.resetState();
- $(document).unbind("mouseup.create_text");
- d.unbind("mousemove.create_text")
- });
- d.unbind("mousedown.create_text")
- })
- },
- canvasDragTimeout: null,
- canvasDraggable: function () {
- var b = $("#canvas_container");
- b.css("cursor", "url(../apps/_bpm.platform/js/designer/themes/default/images/diagraming/cursor_hand.png) 8 8, auto");
- if (this.canvasDragTimeout) {
- clearTimeout(this.canvasDragTimeout)
- }
- this.canvasDragTimeout = setTimeout(function () {
- b.unbind("mousedown.drag_canvas");
- Designer.op.resetState();
- b.unbind("mousemove.drag_canvas");
- $(document).unbind("mouseup.drag_canvas")
- },
- 500);
- b.unbind("mousedown.drag_canvas").bind("mousedown.drag_canvas",
- function (e) {
- var f = $("#designer_layout").scrollTop();
- var a = $("#designer_layout").scrollLeft();
- b.bind("mousemove.drag_canvas",
- function (d) {
- var h = d.pageX - e.pageX;
- var c = d.pageY - e.pageY;
- $("#designer_layout").scrollLeft(a - h);
- $("#designer_layout").scrollTop(f - c)
- });
- $(document).unbind("mouseup.drag_canvas").bind("mouseup.drag_canvas",
- function (c) {
- b.unbind("mousemove.drag_canvas");
- $(document).unbind("mouseup.drag_canvas")
- })
- });
- $(document).unbind("keyup.drag_canvas").bind("keyup.drag_canvas",
- function (a) {
- b.unbind("mousedown.drag_canvas");
- Designer.op.resetState();
- $(document).unbind("mouseup.drag_canvas");
- a.preventDefault();
- clearTimeout(this.canvasDragTimeout);
- b.unbind("mousemove.drag_canvas")
- })
- },
- canvasFreeDraggable: function () {
- var b = $("#canvas_container");
- b.css("cursor", "url(../apps/_bpm.platform/js/designer/themes/default/images/diagraming/cursor_hand.png) 8 8, auto");
- b.unbind("mousedown.drag_canvas").bind("mousedown.drag_canvas",
- function (e) {
- var f = $("#designer_layout").scrollTop();
- var a = $("#designer_layout").scrollLeft();
- b.bind("mousemove.drag_canvas",
- function (d) {
- var h = d.pageX - e.pageX;
- var c = d.pageY - e.pageY;
- $("#designer_layout").scrollLeft(a - h);
- $("#designer_layout").scrollTop(f - c)
- });
- $(document).unbind("mouseup.drag_canvas").bind("mouseup.drag_canvas",
- function (c) {
- b.unbind("mousemove.drag_canvas");
- $(document).unbind("mouseup.drag_canvas")
- })
- })
- },
- moveShape: function (A, H) {
- var z = [];
- for (var x = 0; x < A.length; x++) {
- var M = A[x];
- z.push(M.id)
- }
- var i = Utils.restoreScale(H);
- for (var x = 0; x < A.length; x++) {
- var M = A[x];
- if (M.name == "linker") {
- var D = M;
- var y = D.from;
- var L = D.to;
- var G = false;
- var C = false;
- if (!Utils.isSelected(D.id)) {
- if (y.id != null && z.indexOf(y.id) >= 0) {
- D.from.x += i.x;
- D.from.y += i.y;
- G = true
- }
- if (L.id != null && z.indexOf(L.id) >= 0) {
- D.to.x += i.x;
- D.to.y += i.y;
- C = true
- }
- } else {
- if (y.id == null || z.indexOf(y.id) >= 0) {
- D.from.x += i.x;
- D.from.y += i.y;
- G = true
- }
- if (L.id == null || z.indexOf(L.id) >= 0) {
- D.to.x += i.x;
- D.to.y += i.y;
- C = true
- }
- }
- if (G && C) {
- for (var w = 0; w < D.points.length; w++) {
- var B = D.points[w];
- B.x += i.x;
- B.y += i.y
- }
- var p = $("#" + M.id);
- var J = p.position();
- p.css({
- left: J.left += H.x,
- top: J.top += H.y
- })
- } else {
- if (G || C) {
- Designer.painter.renderLinker(D, true)
- }
- }
- } else {
- N(M);
- $(".shape_contour[forshape=" + M.id + "]").css({
- left: M.props.x.toScale(),
- top: M.props.y.toScale()
- })
- }
- }
- var K = Utils.getSelectedLinkerIds();
- if (A.length == 1 && K.length == 1) {
- return
- }
- if (K.length > 0) {
- var I = Utils.getSelectedIds();
- Designer.painter.drawControls(I)
- } else {
- var E = $("#shape_controls");
- E.css({
- left: parseFloat(E.css("left")) + H.x,
- top: parseFloat(E.css("top")) + H.y
- })
- }
- var F = $("#shape_controls").position();
- if (F && Utils.getSelected().length > 0) {
- Designer.op.showTip("X: " + Math.round(F.left.restoreScale()) + " Y: " + Math.round(F.top.restoreScale()));
- }
-
- function N(a) {
- a.props.x += i.x;
- a.props.y += i.y;
- var b = $("#" + a.id);
- b.css({
- left: parseFloat(b.css("left")) + H.x,
- top: parseFloat(b.css("top")) + H.y
- })
- }
- },
- moveLinker: function (D, w, G, H) {
- var K = null;
- var C = null;
- var z = Utils.getShapeByPosition(G, H, true);
- Designer.op.hideLinkPoint();
- if (z != null) {
- var L = z.shape;
- Utils.showAnchors(L);
- C = L.id;
- if (z.type == "bounding") {
- K = z.linkPoint;
- Designer.op.showLinkPoint(Utils.toScale(K))
- } else {
- if (z.type == "shape") {
- var u;
- var I;
- if (w == "from") {
- u = {
- x: D.to.x,
- y: D.to.y
- };
- I = D.to.id
- } else {
- u = {
- x: D.from.x,
- y: D.from.y
- };
- I = D.from.id
- }
- if (L.id == I) {
- Designer.op.hideLinkPoint();
- K = {
- x: G.restoreScale(),
- y: H.restoreScale()
- };
- K.angle = null;
- C = null
- } else {
- var B = L.getAnchors();
- var E = -1;
- var A;
- var t = {
- x: L.props.x + L.props.w / 2,
- y: L.props.y + L.props.h / 2
- };
- for (var v = 0; v < B.length; v++) {
- var y = B[v];
- var F = Utils.getRotated(t, {
- x: L.props.x + y.x,
- y: L.props.y + y.y
- },
- L.props.angle);
- var x = Utils.measureDistance(F, u);
- if (E == -1 || x < E) {
- E = x;
- A = F
- }
- }
- var J = Utils.getPointAngle(L.id, A.x, A.y, 7);
- K = {
- x: A.x,
- y: A.y,
- angle: J
- };
- Designer.op.showLinkPoint(Utils.toScale(K))
- }
- }
- }
- } else {
- Designer.op.hideLinkPoint();
- Utils.hideAnchors();
- K = {
- x: G.restoreScale(),
- y: H.restoreScale()
- };
- K.angle = null;
- C = null
- }
- if (w == "from") {
- D.from.id = C;
- D.from.x = K.x;
- D.from.y = K.y;
- D.from.angle = K.angle;
- if (C == null) {
- if (K.x >= D.to.x - 6 && K.x <= D.to.x + 6) {
- D.from.x = D.to.x
- }
- if (K.y >= D.to.y - 6 && K.y <= D.to.y + 6) {
- D.from.y = D.to.y
- }
- }
- } else {
- D.to.x = K.x;
- D.to.y = K.y;
- D.to.id = C;
- D.to.angle = K.angle;
- if (C == null) {
- if (K.x >= D.from.x - 6 && K.x <= D.from.x + 6) {
- D.to.x = D.from.x
- }
- if (K.y >= D.from.y - 6 && K.y <= D.from.y + 6) {
- D.to.y = D.from.y
- }
- }
- }
- Designer.painter.renderLinker(D, true)
- },
- showLinkPoint: function (e) {
- var f = $("").appendTo($("#designer_canvas"));
- var d = f[0].getContext("2d");
- d.translate(1, 1);
- d.lineWidth = 1;
- d.globalAlpha = 0.3;
- d.strokeStyle = Designer.config.anchorColor;
- d.fillStyle = Designer.config.anchorColor;
- d.beginPath();
- d.moveTo(0, 15);
- d.bezierCurveTo(0, -5, 30, -5, 30, 15);
- d.bezierCurveTo(30, 35, 0, 35, 0, 15);
- d.closePath();
- d.fill();
- d.stroke();
- f.css({
- left: e.x - 16,
- top: e.y - 16,
- "z-index": Model.orderList.length
- }).show()
- },
- hideLinkPoint: function () {
- $(".link_point_canvas").hide()
- },
- brokenLinkerChangable: function (k, l) {
- var h = $("#canvas_container");
- var g = $("#designer_canvas");
- var i = k.points[l - 1];
- var j = k.points[l];
- if (i.x == j.x) {
- h.css("cursor", "e-resize")
- } else {
- h.css("cursor", "n-resize")
- }
- g.bind("mousedown.brokenLinker",
- function (a) {
- Designer.op.changeState("changing_broken_linker");
- var b = Utils.getRelativePos(a.pageX, a.pageY, g);
- var c = Utils.getSelectedIds();
- h.bind("mousemove.brokenLinker",
- function (e) {
- var f = Utils.getRelativePos(e.pageX, e.pageY, g);
- var d = {
- x: f.x - b.x,
- y: f.y - b.y
- };
- d = Utils.restoreScale(d);
- if (i.x == j.x) {
- i.x += d.x;
- j.x += d.x
- } else {
- i.y += d.y;
- j.y += d.y
- }
- Designer.painter.renderLinker(k);
- if (c.length > 1) {
- Designer.painter.drawControls(c)
- }
- b = f;
- $(document).unbind("mouseup.changed").bind("mouseup.changed",
- function () {
- Model.update(k);
- $(document).unbind("mouseup.changed")
- })
- });
- $(document).bind("mouseup.brokenLinker",
- function () {
- Designer.op.resetState();
- h.unbind("mousemove.brokenLinker");
- g.unbind("mousedown.brokenLinker");
- $(document).unbind("mouseup.brokenLinker")
- })
- })
- },
- removeShape: function () {// 在designer.extend.core.js重写
- var d = Utils.getSelected();
- if (d.length > 0) {
- Utils.unselect();
- var e = Utils.getAttachedShapes(d);
- d = d.concat(e);
- var c = [];
- for (var b = 0; b < d.length; b++) {
- var a = Utils.getChildrenShapes(d[b]);
- c = c.concat(a)
- }
- d = d.concat(c);
- if (d.length > 0) {
- var shapeIds = [];
- for (var index = 0; index < d.length; index++) {
- if (d[index].name != "linker") {
- shapeIds.push(d[index].id)
- }
- }
- if (shapeIds.length > 0) {
- $.ajax({
- url: "./jd?sid=" + $("#sid").val() + "&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_relation_search",
- data: {
- shapeIds: shapeIds.join(","),
- fileId: ruuid
- },
- success: function (msg) {
- if (typeof (msg) == "string") {
- msg = eval("(" + msg + ")")
- }
- var relationShapes = msg.data.relationShapes;
- if (relationShapes.length > 0) {
- var options = {
- title: "提示",
- content: "图形[" + relationShapes + "]被关联,确定删除吗?",
- onConfirm: function () {
- Model.remove(d)
- }
- };
- $.confirm(options)
- } else {
- Model.remove(d)
- }
- }
- })
- } else {
- Model.remove(d)
- }
- }
- }
- },
- showTip: function (h) {
- var f = $("#designer_op_tip");
- if (f.length == 0) {
- f = $("").appendTo("#designer_canvas")
- }
- f.stop().html(h);
- var e = $("#shape_controls");
- var g = e.position();
- f.css({
- top: g.top + e.height() + 5,
- left: g.left + e.width() / 2 - f.outerWidth() / 2,
- "z-index": Model.orderList.length
- }).show()
- },
- hideTip: function () {
- $("#designer_op_tip").fadeOut(100)
- },
- snapLine: function (R, Q, S, ae) {
- var U = R.y;
- var J = R.y + R.h / 2;
- var ad = R.y + R.h;
- var af = R.x;
- var T = R.x + R.w / 2;
- var X = R.x + R.w;
- var ag = 2;
- var ab = {
- v: null,
- h: null,
- attach: null
- };
- var W = null;
- if (S) {
- W = ae
- } else {
- W = Model.getShapeById(Q[0])
- }
- if (Q.length == 1 && W.groupName == "boundaryEvent") {
- for (var K = Model.orderList.length - 1; K >= 0; K--) {
- var P = Model.orderList[K].id;
- var ai = Model.getShapeById(P);
- if (ai.name != "linker" && ai.id != W.id) {
- var O = ai.props;
- if (ab.attach == null && O.angle == 0 && (ai.groupName == "task" || ai.groupName == "callActivity" || ai.groupName == "subProcess")) {
- var p = {
- x: O.x - ag,
- y: O.y - ag,
- w: O.w + ag * 2,
- h: O.h + ag * 2
- };
- if (Utils.pointInRect(T, J, p)) {
- var aj = O.y;
- var ac = O.y + O.h;
- var M = O.x;
- var L = O.x + O.w;
- var V = false;
- var aa = false;
- if (aj >= J - ag && aj <= J + ag) {
- R.y = aj - R.h / 2;
- aa = true
- } else {
- if (ac >= J - ag && ac <= J + ag) {
- R.y = ac - R.h / 2;
- aa = true
- }
- }
- if (M >= T - ag && M <= T + ag) {
- R.x = M - R.w / 2;
- V = true
- } else {
- if (L >= T - ag && L <= T + ag) {
- R.x = L - R.w / 2;
- V = true
- }
- }
- if (V || aa) {
- ab.attach = ai
- }
- }
- }
- }
- }
- }
- if (ab.attach == null) {
- for (var K = Model.orderList.length - 1; K >= 0; K--) {
- var P = Model.orderList[K].id;
- var ai = Model.getShapeById(P);
- if (ai.name == "linker" || Q.indexOf(P) >= 0 || ai.parent) {
- continue
- }
- var O = ai.props;
- if (ab.h == null) {
- var aj = O.y;
- var ak = O.y + O.h / 2;
- var ac = O.y + O.h;
- if (ak >= J - ag && ak <= J + ag) {
- ab.h = {
- type: "middle",
- y: ak
- };
- R.y = ak - R.h / 2
- } else {
- if (aj >= U - ag && aj <= U + ag) {
- ab.h = {
- type: "top",
- y: aj
- };
- R.y = aj
- } else {
- if (ac >= ad - ag && ac <= ad + ag) {
- ab.h = {
- type: "bottom",
- y: ac
- };
- R.y = ac - R.h
- } else {
- if (ac >= U - ag && ac <= U + ag) {
- ab.h = {
- type: "top",
- y: ac
- };
- R.y = ac
- } else {
- if (aj >= ad - ag && aj <= ad + ag) {
- ab.h = {
- type: "bottom",
- y: aj
- };
- R.y = aj - R.h
- }
- }
- }
- }
- }
- }
- if (ab.v == null) {
- var M = O.x;
- var N = O.x + O.w / 2;
- var L = O.x + O.w;
- if (N >= T - ag && N <= T + ag) {
- ab.v = {
- type: "center",
- x: N
- };
- R.x = N - R.w / 2
- } else {
- if (M >= af - ag && M <= af + ag) {
- ab.v = {
- type: "left",
- x: M
- };
- R.x = M
- } else {
- if (L >= X - ag && L <= X + ag) {
- ab.v = {
- type: "right",
- x: L
- };
- R.x = L - R.w
- } else {
- if (L >= af - ag && L <= af + ag) {
- ab.v = {
- type: "left",
- x: L
- };
- R.x = L
- } else {
- if (M >= X - ag && M <= X + ag) {
- ab.v = {
- type: "right",
- x: M
- };
- R.x = M - R.w
- }
- }
- }
- }
- }
- }
- if (ab.h != null && ab.v != null) {
- break
- }
- }
- }
- this.hideSnapLine();
- var ah = $("#designer_canvas");
- if (ab.attach != null) {
- var Y = $("#designer_op_snapline_attach");
- if (Y.length == 0) {
- Y = $("").appendTo(ah)
- }
- var I = ab.attach;
- var al = I.lineStyle.lineWidth;
- Y.css({
- width: (I.props.w + al).toScale(),
- height: (I.props.h + al).toScale(),
- left: (I.props.x - al / 2).toScale() - 2,
- top: (I.props.y - al / 2).toScale() - 2,
- "z-index": $("#" + I.id).css("z-index")
- }).show()
- }
- if (ab.h != null) {
- var i = $("#designer_op_snapline_h");
- if (i.length == 0) {
- i = $("").appendTo(ah)
- }
- i.css({
- width: ah.width() + Designer.config.pageMargin * 2,
- left: -Designer.config.pageMargin,
- top: Math.round(ab.h.y.toScale()),
- "z-index": Model.orderList.length + 1
- }).show()
- }
- if (ab.v != null) {
- var Z = $("#designer_op_snapline_v");
- if (Z.length == 0) {
- Z = $("").appendTo(ah)
- }
- Z.css({
- height: ah.height() + Designer.config.pageMargin * 2,
- top: -Designer.config.pageMargin,
- left: Math.round(ab.v.x.toScale()),
- "z-index": Model.orderList.length + 1
- }).show()
- }
- return ab
- },
- snapResizeLine: function (K, I, J) {
- var L = K.y;
- var i = K.y + K.h / 2;
- var P = K.y + K.h;
- var Q = K.x;
- var C = K.x + K.w / 2;
- var D = K.x + K.w;
- var R = 2;
- var N = {
- v: null,
- h: null
- };
- for (var F = Model.orderList.length - 1; F >= 0; F--) {
- var B = Model.orderList[F].id;
- var U = Model.getShapeById(B);
- if (U.name == "linker" || I.indexOf(B) >= 0 || U.parent) {
- continue
- }
- var H = U.props;
- if (N.h == null && (J.indexOf("t") >= 0 || J.indexOf("b") >= 0)) {
- var T = H.y;
- var V = H.y + H.h / 2;
- var O = H.y + H.h;
- if (V >= i - R && V <= i + R) {
- N.h = {
- type: "middle",
- y: V
- };
- if (J.indexOf("t") >= 0) {
- K.h = (P - V) * 2;
- K.y = P - K.h
- } else {
- K.h = (V - K.y) * 2
- }
- } else {
- if (J.indexOf("t") >= 0 && T >= L - R && T <= L + R) {
- N.h = {
- type: "top",
- y: T
- };
- K.y = T;
- K.h = P - T
- } else {
- if (J.indexOf("b") >= 0 && O >= P - R && O <= P + R) {
- N.h = {
- type: "bottom",
- y: O
- };
- K.h = O - L
- } else {
- if (J.indexOf("t") >= 0 && O >= L - R && O <= L + R) {
- N.h = {
- type: "top",
- y: O
- };
- K.y = O;
- K.h = P - O
- } else {
- if (J.indexOf("b") >= 0 && T >= P - R && T <= P + R) {
- N.h = {
- type: "bottom",
- y: T
- };
- K.h = T - K.y
- }
- }
- }
- }
- }
- }
- if (N.v == null && (J.indexOf("l") >= 0 || J.indexOf("r") >= 0)) {
- var p = H.x;
- var A = H.x + H.w / 2;
- var G = H.x + H.w;
- if (A >= C - R && A <= C + R) {
- N.v = {
- type: "center",
- x: A
- };
- if (J.indexOf("l") >= 0) {
- K.w = (D - A) * 2;
- K.x = D - K.w
- } else {
- K.w = (A - K.x) * 2
- }
- } else {
- if (J.indexOf("l") >= 0 && p >= Q - R && p <= Q + R) {
- N.v = {
- type: "left",
- x: p
- };
- K.x = p;
- K.w = D - p
- } else {
- if (J.indexOf("r") >= 0 && G >= D - R && G <= D + R) {
- N.v = {
- type: "right",
- x: G
- };
- K.w = G - K.x
- } else {
- if (J.indexOf("l") >= 0 && G >= Q - R && G <= Q + R) {
- N.v = {
- type: "left",
- x: G
- };
- K.x = G;
- K.w = D - G
- } else {
- if (J.indexOf("r") >= 0 && p >= D - R && p <= D + R) {
- N.v = {
- type: "right",
- x: p
- };
- K.w = p - K.x
- }
- }
- }
- }
- }
- }
- if (N.h != null && N.v != null) {
- break
- }
- }
- this.hideSnapLine();
- var S = $("#designer_canvas");
- if (N.h != null) {
- var E = $("#designer_op_snapline_h");
- if (E.length == 0) {
- E = $("").appendTo(S)
- }
- E.css({
- width: S.width() + Designer.config.pageMargin * 2,
- left: -Designer.config.pageMargin,
- top: Math.round(N.h.y.toScale()),
- "z-index": Model.orderList.length + 1
- }).show()
- }
- if (N.v != null) {
- var M = $("#designer_op_snapline_v");
- if (M.length == 0) {
- M = $("").appendTo(S)
- }
- M.css({
- height: S.height() + Designer.config.pageMargin * 2,
- top: -Designer.config.pageMargin,
- left: Math.round(N.v.x.toScale()),
- "z-index": Model.orderList.length + 1
- }).show()
- }
- return N
- },
- hideSnapLine: function () {
- $("#designer_op_snapline_h").hide();
- $("#designer_op_snapline_v").hide();
- $("#designer_op_snapline_attach").hide()
- },
- linkDashboard: function (q) {
- var m = Model.getShapeById(q.from.id);
- var t = m.category;
- if ($("#panel_" + t).length != 0) {
- var p = $("#shape_dashboard_" + t);
- if (p.length == 0) {
- p = $("").appendTo("#designer_canvas");
-
- function r(b, d) {
- var e = "";
- var c = $(e).appendTo(p);
- if (d) {
- c.append("")
- }
- var a = c.children()[0];
- Designer.painter.drawPanelItem(a, b.name)
- }
-
- for (var l in Schema.shapes) {
- var o = Schema.shapes[l];
- if ((o.category == "process_bpmn2" || o.category == "process.bpmn2" || o.category == "bpmn") && checkRunningTimeShape(o)) {
- continue;
- }
- if (o.category == t) {
- var s = o.attribute;
- if (s.visible && s.linkable) {
- if (!o.groupName) {
- r(o)
- } else {
- var k = SchemaGroup.getGroup(o.groupName);
- if (k[0] == o.name) {
- r(o, o.groupName)
- }
- }
- }
- }
- }
- p.bind("mousemove",
- function (a) {
- a.stopPropagation()
- }).bind("mousedown",
- function (a) {
- a.stopPropagation()
- })
- }
- p.css({
- left: q.to.x.toScale(),
- top: q.to.y.toScale(),
- "z-index": Model.orderList.length
- }).show();
- p.find(".link_shape_icon").unbind().bind("mousedown",
- function (f) {
- f.stopPropagation();
- var a = $(this).attr("group");
- var d = $(this).parent().position();
- var e = p.position();
- var b = d.left + e.left + $(this).parent().outerWidth() - 10;
- var c = d.top + e.top + $(this).parent().outerHeight();
- Designer.op.groupDashboard(a, b, c,
- function (g) {
- n(g);
- p.hide();
- $(document).unbind("mousedown.dashboard")
- })
- }).bind("click",
- function (a) {
- a.stopPropagation()
- });
- p.children(".dashboard_box").unbind().bind("click",
- function () {
- p.hide();
- $(document).unbind("mousedown.dashboard");
- var a = $(this);
- var b = a.attr("shapeName");
- n(b)
- });
- initRunningDashboard(p);
- $(document).bind("mousedown.dashboard",
- function () {
- p.hide();
- $(document).unbind("mousedown.dashboard")
- });
-
- function n(e) {
- var y = Schema.shapes[e];
- var d = Utils.getEndpointAngle(q, "to");
- var b = Utils.getAngleDir(d);
- var f = y.getAnchors();
- var A;
- if (b == 1) {
- var c = null;
- for (var j = 0; j < f.length; j++) {
- var z = f[j];
- if (c == null || z.y < c) {
- c = z.y;
- A = z
- }
- }
- } else {
- if (b == 2) {
- var g = null;
- for (var j = 0; j < f.length; j++) {
- var z = f[j];
- if (g == null || z.x > g) {
- g = z.x;
- A = z
- }
- }
- } else {
- if (b == 3) {
- var h = null;
- for (var j = 0; j < f.length; j++) {
- var z = f[j];
- if (h == null || z.y > h) {
- h = z.y;
- A = z
- }
- }
- } else {
- if (b == 4) {
- var B = null;
- for (var j = 0; j < f.length; j++) {
- var z = f[j];
- if (B == null || z.x < B) {
- B = z.x;
- A = z
- }
- }
- }
- }
- }
- }
- var i = Model.create(e, q.to.x - A.x, q.to.y - A.y);
- Designer.painter.renderShape(i);
- MessageSource.beginBatch();
- if (i.onCreated) {
- i.onCreated()
- }
- Designer.events.push("created", i);
- Model.add(i);
- var a = Utils.getPointAngle(i.id, q.to.x, q.to.y, 7);
- q.to.id = i.id;
- q.to.angle = a;
- Designer.painter.renderLinker(q, true);
- Model.update(q);
- MessageSource.commit();
- Utils.unselect();
- Utils.selectShape(i.id);
- Designer.op.editShapeText(i)
- }
- }
- },
- groupDashboard: function (m, s, n, t) {
- $(".group_dashboard").hide();
- var o = $("#shape_group_dashboard_" + m);
- if (o.length == 0) {
- o = $("").appendTo("#designer_canvas");
- var i = SchemaGroup.getGroup(m);
- for (var r = 0; r < i.length; r++) {
- var v = i[r];
- var p = Schema.shapes[v];
- if ((p.category == "process_bpmn2" || p.category == "process.bpmn2" || p.category == "bpmn") && checkRunningTimeShape(p)) {
- continue;
- }
- if (p.attribute.visible) {
- var q = $("").appendTo(o);
- var u = q.children("canvas")[0];
- Designer.painter.drawPanelItem(u, p.name)
- }
- }
- o.bind("mousedown",
- function (a) {
- a.stopPropagation()
- })
- }
- o.css({
- left: s,
- top: n,
- "z-index": Model.orderList.length + 1
- }).show();
- $(".dashboard_box").unbind().bind("click",
- function () {
- var a = $(this).attr("shapeName");
- t(a);
- o.hide();
- $(document).unbind("mousedown.group_dashboard")
- });
- $(document).bind("mousedown.group_dashboard",
- function () {
- o.hide();
- $(document).unbind("mousedown.group_dashboard")
- });
- return o
- },
- showPanelGroup: function (o, z, t) {
- z.stopPropagation();
- var s = $("#group_dashboard_" + o);
- $(".group_dashboard").hide();
- if (s.length == 0) {
- s = $("").appendTo("#designer");
- var i = SchemaGroup.getGroup(o);
- for (var v = 0; v < i.length; v++) {
- var y = i[v];
- var r = Schema.shapes[y];
- if ((r.category == "process_bpmn2" || r.category == "process.bpmn2" || r.category == "bpmn") && checkRunningTimeShape(r)) {
- continue;
- }
- if (r.attribute.visible) {
- var title = r.title;
- var category = r.category;
- if (r.category == "bpmn") {
- category = 'process_bpmn2';
- }
- category = category.replace(/_/g, ".");
- if (category == 'lane') {
- category = methodId;
- }
- if (methodObjectDesc[category + '-' + r.name]) {
- title += (':' + methodObjectDesc[category + '-' + r.name]);
- }
- var u = $("").appendTo(s);
- var x = u.children("canvas")[0];
- Designer.painter.drawPanelItem(x, r.name)
- }
- }
- s.css("position", "fixed")
- }
- var p = $(t).parent();
- var w = p.offset();
- s.show();
- var q = w.top + p.height();
- if (q + s.outerHeight() > $(window).height()) {
- q = $(window).height() - s.outerHeight()
- }
- s.css({
- left: w.left - 7,
- top: q
- });
- $(document).bind("mousedown.group_board",
- function () {
- s.hide();
- $(document).unbind("mousedown.group_board")
- })
- },
- changeShapeProps: function (j, o) {
- function p(e) {
- if (typeof o.x != "undefined") {
- e.x += (o.x - j.props.x)
- }
- if (typeof o.y != "undefined") {
- e.y += (o.y - j.props.y)
- }
- if (typeof o.w != "undefined" || typeof o.h != "undefined" || typeof o.angle != "undefined") {
- var f = $.extend({},
- j.props, o);
- var g = {
- x: j.props.x + j.props.w / 2,
- y: j.props.y + j.props.h / 2
- };
- var b = Utils.getRotated(g, e, -j.props.angle);
- var c = j.props.w;
- var h = j.props.h;
- if (typeof o.w != "undefined") {
- e.x = j.props.x + (b.x - j.props.x) / j.props.w * o.w;
- c = o.w
- } else {
- e.x = b.x
- }
- if (typeof o.h != "undefined") {
- e.y = j.props.y + (b.y - j.props.y) / j.props.h * o.h;
- h = o.h
- } else {
- e.y = b.y
- }
- var d = {
- x: j.props.x + c / 2,
- y: j.props.y + h / 2
- };
- var a = Utils.getRotated(d, e, f.angle);
- e.x = a.x;
- e.y = a.y
- }
- if (typeof o.angle != "undefined") {
- e.angle += o.angle - j.props.angle
- }
- }
-
- var m = [];
- var l = Model.getShapeLinkers(j.id);
- if (l && l.length > 0) {
- for (var i = 0; i < l.length; i++) {
- var k = l[i];
- var n = Model.getShapeById(k);
- if (j.id == n.from.id) {
- p(n.from)
- }
- if (j.id == n.to.id) {
- p(n.to)
- }
- }
- m = l
- }
- $.extend(j.props, o);
- Designer.painter.renderShape(j);
- Utils.showLinkerCursor();
- return m
- }
- },
- events: {
- push: function (f, e) {
- var d = this.listeners[f];
- if (d) {
- return d(e)
- }
- return null
- },
- listeners: {},
- addEventListener: function (c, d) {
- this.listeners[c] = d
- }
- },
- clipboard: {
- elements: [],
- presetedIds: {},
- presetIds: function () {
- this.presetedIds = {};
- for (var c = 0; c < this.elements.length; c++) {
- var d = this.elements[c];
- this.presetedIds[d.id] = Utils.newId();
- if (d.group && !this.presetedIds[d.group]) {
- this.presetedIds[d.group] = Utils.newId()
- }
- }
- },
- plus: true,
- copy: function (g) {
- this.elements = [];
- var j;
- var k;
- if (g) {
- j = g
- } else {
- j = Utils.getSelected();
- k = Utils.getFamilyShapes(j);
- j = j.concat(k)
- }
- j.sort(function i(a, b) {
- return a.props.zindex - b.props.zindex
- });
- for (var f = 0; f < j.length; f++) {
- var h = Utils.copy(j[f]);
- if (h.name == "linker") {
- if (h.from.id != null) {
- if (!Utils.isSelected(h.from.id) && g == undefined) {
- h.from.id = null;
- h.from.angle = null
- }
- }
- if (h.to.id != null) {
- if (!Utils.isSelected(h.to.id) && g == undefined) {
- h.to.id = null;
- h.to.angle = null
- }
- }
- }
- this.elements.push(h)
- }
- this.elements.sort(function i(a, b) {
- return a.props.zindex - b.props.zindex
- });
- this.presetIds();
- this.plus = true;
- Designer.events.push("clipboardChanged", this.elements.length)
- },
- cut: function () {
- this.copy();
- // Designer.op.removeShape();// 重复删除,造成异常
- this.plus = true;
- },
- paste: function (F, G) {
- if (this.elements.length == 0) {
- return
- }
- var w = 20;
- var x = 20;
- if (typeof F != "undefined") {
- var I = Utils.getShapesBounding(this.elements);
- w = F - I.x - I.w / 2;
- x = G - I.y - I.h / 2
- }
- var H = [];
- var K = [];
- var j = [];
- for (var y = 0; y < this.elements.length; y++) {
- var L = this.elements[y];
- if (L.name != "linker") {
- var v;
- var L = this.elements[y];
- L.props.zindex = Model.maxZIndex + (y + 1);
- var D = this.presetedIds[L.id];
- if (this.plus || typeof F != "undefined") {
- L.props.x += w;
- L.props.y += x
- }
- v = Utils.copy(L);
- for (var A = 0; A < v.dataAttributes.length; A++) {
- var B = v.dataAttributes[A];
- B.id = Utils.newId()
- }
- v.id = D;
- if (v.children) {
- for (var E = 0; E < v.children.length; E++) {
- var z = v.children[E];
- v.children[E] = this.presetedIds[z]
- }
- }
- if (v.parent) {
- v.parent = this.presetedIds[v.parent]
- }
- H.push(v);
- K.push(D);
- if (L.group) {
- var J = this.presetedIds[L.group];
- v.group = J
- }
- var i = {};
- i.copyShapeId = L.id;
- i.pasteShapeId = v.id;
- i.pasteFileId = ruuid;
- j.push(i)
- }
- }
- for (var y = 0; y < this.elements.length; y++) {
- var L = this.elements[y];
- if (L.name == "linker") {
- var v;
- L.props.zindex = Model.maxZIndex + (y + 1);
- var D = this.presetedIds[L.id];
- if (this.plus || typeof F != "undefined") {
- L.from.x += w;
- L.from.y += x;
- L.to.x += w;
- L.to.y += x;
- for (var p = 0; p < L.points.length; p++) {
- var C = L.points[p];
- C.x += w;
- C.y += x
- }
- }
- v = Utils.copy(L);
- if (!v.dataAttributes) {
- v.dataAttributes = []
- }
- for (var A = 0; A < v.dataAttributes.length; A++) {
- var B = v.dataAttributes[A];
- B.id = Utils.newId()
- }
- if (L.from.id != null) {
- v.from.id = this.presetedIds[L.from.id]
- }
- if (L.to.id != null) {
- v.to.id = this.presetedIds[L.to.id]
- }
- v.id = D;
- H.push(v);
- K.push(D);
- if (L.group) {
- var J = this.presetedIds[L.group];
- v.group = J
- }
- }
- }
- Model.addMulti(H);
- for (var y = 0; y < H.length; y++) {
- var L = H[y];
- Designer.painter.renderShape(L)
- }
- Model.build();
- this.presetIds();
- Utils.unselect();
- Utils.selectShape(K);
- this.plus = true;
- return j
- },
- duplicate: function () {
- this.copy();
- this.paste()
- },
- brush: function () {
- var h = Utils.getSelected();
- if (h.length == 0) {
- return
- }
- var g = {
- fontStyle: {},
- lineStyle: {},
- fillStyle: null,
- shapeStyle: null
- };
- for (var i = 0; i < h.length; i++) {
- var f = h[i];
- if (f.name == "linker") {
- $.extend(g.lineStyle, f.lineStyle);
- $.extend(g.fontStyle, f.fontStyle)
- } else {
- if (g.fillStyle == null) {
- g.fillStyle = {}
- }
- if (g.shapeStyle == null) {
- g.shapeStyle = {}
- }
- $.extend(g.lineStyle, f.lineStyle);
- $.extend(g.fontStyle, f.fontStyle);
- $.extend(g.shapeStyle, f.shapeStyle);
- $.extend(g.fillStyle, f.fillStyle)
- }
- }
- $("#bar_brush").button("select");
- var j = $("#designer_op_help");
- if (j.length == 0) {
- j = $("").appendTo("#designer_viewport")
- }
- j.html("选择目标图形并使用格式刷样式
Esc取消").show();
- $(document).unbind("keydown.cancelbrush").bind("keydown.cancelbrush",
- function (a) {
- if (a.keyCode == 27) {
- $("#bar_brush").button("unselect");
- j.hide();
- $(document).unbind("keydown.cancelbrush");
- Utils.selectCallback = null;
- $("#bar_brush").button("disable")
- }
- });
- Utils.selectCallback = function () {
- var b = Utils.getSelected();
- for (var a = 0; a < b.length; a++) {
- var c = b[a];
- var d = c.fontStyle.orientation;
- $.extend(c.lineStyle, g.lineStyle);
- $.extend(c.fontStyle, g.fontStyle);
- if (c.name != "linker") {
- c.lineStyle = g.lineStyle;
- delete c.lineStyle.beginArrowStyle;
- delete c.lineStyle.endArrowStyle;
- c.fontStyle.orientation = d;
- if (g.fillStyle != null) {
- c.fillStyle = g.fillStyle
- }
- if (g.shapeStyle != null) {
- c.shapeStyle = g.shapeStyle
- }
- } else {
- delete c.fontStyle.orientation;
- delete c.fontStyle.vAlign
- }
- Designer.painter.renderShape(c)
- }
- Model.updateMulti(b)
- }
- }
- },
- addFunction: function (c, d) {
- if (Designer[c]) {
- throw "Duplicate function name!"
- } else {
- this[c] = d
- }
- },
- painter: {
- actions: {
- move: function (b) {
- this.moveTo(b.x, b.y);
- this.prePoint = b;
- if (this.beginPoint == null) {
- this.beginPoint = b
- }
- },
- line: function (d) {
- if (typeof this.webkitLineDash != "undefined" && typeof this.lineDashOffset == "undefined" && this.lineWidth != 0) {
- var f = this.webkitLineDash;
- var c = this.prePoint;
- var h = Utils.measureDistance(c, d);
- var k = 0;
- var b = 1 / h;
- var j = c;
- var e = 0;
- var g = true;
- while (k < 1) {
- k += b;
- if (k > 1) {
- k = 1
- }
- var i = {
- x: (1 - k) * c.x + k * d.x,
- y: (1 - k) * c.y + k * d.y
- };
- var a = Utils.measureDistance(j, i);
- if (a >= f[e] || k >= 1) {
- if (g) {
- this.lineTo(i.x, i.y)
- } else {
- this.moveTo(i.x, i.y)
- }
- g = !g;
- j = i;
- e++;
- if (e >= f.length) {
- e = 0
- }
- }
- }
- this.moveTo(d.x, d.y)
- } else {
- this.lineTo(d.x, d.y)
- }
- this.prePoint = d;
- if (this.beginPoint == null) {
- this.beginPoint = d
- }
- },
- curve: function (e) {
- if (typeof this.webkitLineDash != "undefined" && typeof this.lineDashOffset == "undefined" && this.lineWidth != 0) {
- var g = this.webkitLineDash;
- var d = this.prePoint;
- var i = Utils.measureDistance(d, e);
- var n = 0;
- var b = 1 / i;
- var l = d;
- var f = 0;
- var h = true;
- var c = 0;
- while (n < 1) {
- n += b;
- if (n > 1) {
- n = 1
- }
- var k = {
- x: d.x * Math.pow((1 - n), 3) + e.x1 * n * Math.pow((1 - n), 2) * 3 + e.x2 * Math.pow(n, 2) * (1 - n) * 3 + e.x * Math.pow(n, 3),
- y: d.y * Math.pow((1 - n), 3) + e.y1 * n * Math.pow((1 - n), 2) * 3 + e.y2 * Math.pow(n, 2) * (1 - n) * 3 + e.y * Math.pow(n, 3)
- };
- var a = Utils.measureDistance(l, k);
- if (a >= g[f] || n >= 1) {
- if (h) {
- var m = c + (n - c) / 2;
- var j = {
- x: d.x * Math.pow((1 - m), 3) + e.x1 * m * Math.pow((1 - m), 2) * 3 + e.x2 * Math.pow(m, 2) * (1 - m) * 3 + e.x * Math.pow(m, 3),
- y: d.y * Math.pow((1 - m), 3) + e.y1 * m * Math.pow((1 - m), 2) * 3 + e.y2 * Math.pow(m, 2) * (1 - m) * 3 + e.y * Math.pow(m, 3)
- };
- this.lineTo(j.x, j.y);
- this.lineTo(k.x, k.y)
- } else {
- this.moveTo(k.x, k.y)
- }
- h = !h;
- l = k;
- c = n;
- f++;
- if (f >= g.length) {
- f = 0
- }
- }
- }
- this.moveTo(e.x, e.y)
- } else {
- this.bezierCurveTo(e.x1, e.y1, e.x2, e.y2, e.x, e.y)
- }
- this.prePoint = e;
- if (this.beginPoint == null) {
- this.beginPoint = e
- }
- },
- quadraticCurve: function (e) {
- if (typeof this.webkitLineDash != "undefined" && typeof this.lineDashOffset == "undefined" && this.lineWidth != 0) {
- var g = this.webkitLineDash;
- var d = this.prePoint;
- var i = Utils.measureDistance(d, e);
- var n = 0;
- var b = 1 / i;
- var l = d;
- var f = 0;
- var h = true;
- var c = 0;
- while (n < 1) {
- n += b;
- if (n > 1) {
- n = 1
- }
- var k = {
- x: d.x * Math.pow((1 - n), 2) + e.x1 * n * (1 - n) * 2 + e.x * Math.pow(n, 2),
- y: d.y * Math.pow((1 - n), 2) + e.y1 * n * (1 - n) * 2 + e.y * Math.pow(n, 2)
- };
- var a = Utils.measureDistance(l, k);
- if (a >= g[f] || n >= 1) {
- if (h) {
- var m = c + (n - c) / 2;
- var j = {
- x: d.x * Math.pow((1 - m), 2) + e.x1 * m * (1 - m) * 2 + e.x * Math.pow(m, 2),
- y: d.y * Math.pow((1 - m), 2) + e.y1 * m * (1 - m) * 2 + e.y * Math.pow(m, 2)
- };
- this.lineTo(j.x, j.y);
- this.lineTo(k.x, k.y)
- } else {
- this.moveTo(k.x, k.y)
- }
- h = !h;
- l = k;
- c = n;
- f++;
- if (f >= g.length) {
- f = 0
- }
- }
- }
- this.moveTo(e.x, e.y)
- } else {
- this.quadraticCurveTo(e.x1, e.y1, e.x, e.y)
- }
- this.prePoint = e;
- if (this.beginPoint == null) {
- this.beginPoint = e
- }
- },
- close: function () {
- if (typeof this.webkitLineDash != "undefined" && typeof this.lineDashOffset == "undefined" && this.lineWidth != 0) {
- var f = this.webkitLineDash;
- var c = this.prePoint;
- var d = this.beginPoint;
- var h = Utils.measureDistance(c, d);
- var k = 0;
- var b = 1 / h;
- var j = c;
- var e = 0;
- var g = true;
- while (k < 1) {
- k += b;
- if (k > 1) {
- k = 1
- }
- var i = {
- x: (1 - k) * c.x + k * d.x,
- y: (1 - k) * c.y + k * d.y
- };
- var a = Utils.measureDistance(j, i);
- if (a >= f[e] || k >= 1) {
- if (g) {
- this.lineTo(i.x, i.y)
- } else {
- this.moveTo(i.x, i.y)
- }
- g = !g;
- j = i;
- e++;
- if (e >= f.length) {
- e = 0
- }
- }
- }
- }
- this.closePath()
- },
- curveArc: function (a) {
- this.arc(a.centerX, a.centerY, a.radius, a.startAngle, a.endAngle);
- }
- },
- setLineDash: function (d, c) {
- if (!d.setLineDash) {
- d.setLineDash = function () {
- }
- }
- d.setLineDash(c);
- d.mozDash = c;
- d.webkitLineDash = c
- },
- renderShapePath: function (f, e, h) {
- var g;
- if (h && e.drawIcon) {
- g = e.drawIcon(e.props.w, e.props.h)
- } else {
- g = e.getPath()
- }
- this.renderPath(f, e, g, h)
- },
- renderPath: function (m, o, i, t) {
- for (var q = 0; q < i.length; q++) {
- var s = i[q];
- m.save();
- m.beginPath();
- var p = $.extend({},
- o.lineStyle, s.lineStyle);
- var n = $.extend({},
- o.fillStyle, s.fillStyle);
- if (s.textStyle) {
- // path 中文字处理
- m.font = s.textStyle.size + " " + o.fontStyle.fontFamily;
- m.fillStyle = "rgb(" + s.textStyle.color + ")";
- m.fillText(s.textStyle.text, s.textStyle.x, s.textStyle.y);
- }
- for (var r = 0; r < s.actions.length; r++) {
- var j = s.actions[r];
- this.actions[j.action].call(m, j)
- }
- this.fillShape(o, m, n);
- if (p.lineWidth) {
- m.lineWidth = p.lineWidth;
- m.strokeStyle = "rgb(" + p.lineColor + ")";
- if (p.lineStyle == "dashed") {
- if (t) {
- this.setLineDash(m, [p.lineWidth * 4, p.lineWidth * 2])
- } else {
- this.setLineDash(m, [p.lineWidth * 6, p.lineWidth * 3])
- }
- } else {
- if (p.lineStyle == "dot") {
- this.setLineDash(m, [p.lineWidth, p.lineWidth * 2])
- } else {
- if (p.lineStyle == "dashdot") {
- this.setLineDash(m, [p.lineWidth * 6, p.lineWidth * 2, p.lineWidth, p.lineWidth * 2])
- }
- }
- }
- m.stroke()
- }
- m.restore()
- }
- },
- drawPanelItem: function (n, m) {
- var i = n.getContext("2d");
- var h = Utils.copy(Schema.shapes[m]);
- var l = {
- x: 0,
- y: 0,
- w: h.props.w,
- h: h.props.h,
- angle: h.props.angle,
- panelProps: h.props.panelProps
- };
- i.clearRect(0, 0, Designer.config.panelItemWidth, Designer.config.panelItemHeight);
- if (l.w >= Designer.config.panelItemWidth || l.h >= Designer.config.panelItemWidth) {
- if (!!l.panelProps) {
- l.w = h.props.w;
- l.h = h.props.h;
- } else {
- if (h.props.w >= h.props.h) {
- l.w = Designer.config.panelItemWidth - h.lineStyle.lineWidth * 2;
- l.h = parseInt(h.props.h / h.props.w * l.w)
- } else {
- l.h = Designer.config.panelItemHeight - h.lineStyle.lineWidth * 2;
- l.w = parseInt(h.props.w / h.props.h * l.h)
- }
- }
- }
- h.props = l;
- i.save();
- i.lineJoin = "round";
- i.globalAlpha = h.shapeStyle.alpha;
- var j = (Designer.config.panelItemWidth - l.w) / 2;
- var k = (Designer.config.panelItemHeight - l.h) / 2;
- if (!!l.panelProps) {
- if (!!l.panelProps.x) {
- j = -l.panelProps.x;
- }
- if (!!l.panelProps.y) {
- k = -l.panelProps.y;
- }
- }
- i.translate(j, k);
- i.translate(l.w / 2, l.h / 2);
- i.rotate(l.angle);
- i.translate(-(l.w / 2), -(l.h / 2));
- this.renderShapePath(i, h, true,
- function () {
- Designer.painter.drawPanelItem(n, m)
- });
- this.renderMarkers(i, h, true);
- i.restore()
- },
- handleShapeConfigData: function (dataArray, q, attributesJsonArray) {
- //先去除重复的配置--在拼装数据前,先删除数据
- var temp1;
- for (var i = q.dataAttributes.length - 1; i >= 0; i--) {
- temp1 = q.dataAttributes[i];
- var hor = temp1.horizontal;
- var ver = temp1.vertical;
- if (temp1.hasOwnProperty("attributesJsonArray")) {
- var temp2 = temp1.dataShowConfig;
- if (temp2 != undefined) {
- temp2.value = [];
- }
- break
- }
- }
- var key = q.name;
- for (var i = 0; i < dataArray.length; i++) {
- var temp = dataArray[i];
- var showType = temp.showType;
- var horizontal = temp.horizontal;
- horizontal = horizontal.toLowerCase();
- var verity = temp.verity;
- verity = verity.toLowerCase();
- if (verity == "center") {
- verity = "middle";
- }
- if (showType == "text" || showType == "attribute") {
- var cfgContent = temp.cfgContent;
- var params = {
- "w": 30,
- "h": 30,
- "textw": 20,
- "texth": 17,
- "imgT": 0,
- "category": "custom",
- "icon": "",
- "name": key,
- "showName": false,
- "showType": "text", //text icon
- "type": "string",
- "value": cfgContent,
- "horizontal": horizontal,
- "vertical": verity,
- "radius": 5,
- "title": ""
- };
- if (showType == "attribute") {
- var attrId = temp.key;
- var attrType = "string";
- if (attributesJsonArray.length > 0) {
- for (var j = 0; j < attributesJsonArray.length; j++) {
- var attr = attributesJsonArray[j];
- if (attr.key == attrId) {
- attrType = attr.type;
- cfgContent = attr.value;
- break;
- }
- }
- }
- var attrTypeArray = ['string', 'select', 'select_m', 'textarea'];
- if (temp.isShowAttrName && attrTypeArray.indexOf(attrType) >= 0 && (cfgContent + '').trim().length > 0) {
- cfgContent = "(" + temp.attrName + ")" + cfgContent;
- }
- if (attrType == 'relation' || attrType == 'awsorg') {
- var shapeIdAttrId = q.id + "_" + attrId;
- var relationData = relationShapeModelObject;
- var relationValue = "";
- if (relationData[shapeIdAttrId]) {
- cfgContent = relationData[shapeIdAttrId].join(",");
- } else {
- cfgContent = "";
- }
- if (temp.isShowAttrName) {
- cfgContent = "(" + temp.attrName + ")" + cfgContent;
- }
- }
- params.showType = "attr";
- params.value = cfgContent;
- }
- if (!q.dataAttributes) {
- q.dataAttributes = [];
- }
- params.id = Utils.newId();
- params.category = "custom";
- if (!temp1.dataShowConfig) {
- temp1.dataShowConfig = {};
- if (!temp1.dataShowConfig.value) {
- temp1.dataShowConfig.value = [];
- }
- }
- temp1.dataShowConfig.value.push(params);
- //Model.updateMulti([q]);
- } else {
- var iconContent = temp.iconContent;
- var params = {
- "w": 16,
- "h": 16,
- "textw": 20,
- "texth": 17,
- "imgT": 0,
- "category": "custom",
- "icon": iconContent,
- "name": key,
- "showName": false,
- "showType": "icon", //text icon
- "type": "string",
- "value": "",
- "horizontal": horizontal,
- "vertical": verity
- };
- if (!q.dataAttributes) {
- q.dataAttributes = [];
- }
- params.id = Utils.newId();
- params.category = "custom";
- if (!temp1.dataShowConfig) {
- temp1.dataShowConfig = {};
- if (!temp1.dataShowConfig.value) {
- temp1.dataShowConfig.value = [];
- }
- }
- temp1.dataShowConfig.value.push(params);
- //Model.updateMulti([q]);
- }
- }
- },
- renderShape: function (q) {
- if (q.name == "linker") {
- this.renderLinker(q);
- return
- }
- var commonShapeConfig = Utils.copy(Model.define.commonShapeConfig);
- var specialShapeConfig;
- var attributesJsonArray;
- var dataAttributes = q.dataAttributes;
- for (var i = 0; i < dataAttributes.length; i++) {
- var temp = dataAttributes[i];
- if (temp.hasOwnProperty("attributesJsonArray")) {
- if (temp.dataShowConfig) {
- specialShapeConfig = temp.dataShowConfig.config;
- }
- attributesJsonArray = temp.attributesJsonArray;
- break;
- }
- }
- var key = q.name;
- if (specialShapeConfig == undefined) {
- if (commonShapeConfig != undefined && commonShapeConfig[key] != undefined) {
- commonShapeConfig = commonShapeConfig[key];
- this.handleShapeConfigData(commonShapeConfig, q, attributesJsonArray);
- }
- } else {
- if (commonShapeConfig == undefined) {
- this.handleShapeConfigData(Utils.copy(specialShapeConfig), q, attributesJsonArray);
- } else {
- commonShapeConfig = commonShapeConfig[key];
- var tempCommonShapeConfig = [];
- if (commonShapeConfig != undefined) {
- var dataArray = [];
- var tempArray = [];
- for (i = 0; i < commonShapeConfig.length; i++) {
- var temp1 = commonShapeConfig[i];
- for (j = 0; j < specialShapeConfig.length; j++) {
- var temp2 = specialShapeConfig[j];
- if (temp1.horizontal == temp2.horizontal && temp1.verity == temp2.verity) {
- tempArray.push(i);
- break;
- }
- }
- }
- if (tempArray.length > 0) {
- for (i = 0; i < commonShapeConfig.length; i++) {
- if (!(tempArray.indexOf(i) >= 0)) {
- tempCommonShapeConfig.push(commonShapeConfig[i]);
- }
- }
- }
- }
- if (tempCommonShapeConfig.length > 0) {
- dataArray = specialShapeConfig.concat(tempCommonShapeConfig);
- } else {
- dataArray = specialShapeConfig;
- }
- this.handleShapeConfigData(dataArray, q, attributesJsonArray);
- }
- }
- var o = $("#" + q.id);
- if (o.length == 0) {
- var v = $("#designer_canvas");
- if (q.category == 'lane') {
- o = $("").appendTo(v)
- } else {
- o = $("").appendTo(v)
- }
- }
- var t = Utils.getShapeBox(q);
- var w = (t.w + 20).toScale();
- var s = (t.h + 20).toScale();
- o.find(".shape_canvas").attr({
- width: w,
- height: s
- });
- o.css({
- left: (t.x - 10).toScale() + "px",
- top: (t.y - 10).toScale() + "px",
- width: w,
- height: s
- });
- var n = o.find(".shape_canvas")[0].getContext("2d");
- n.clearRect(0, 0, q.props.w + 20, q.props.h + 20);
- n.scale(Designer.config.scale, Designer.config.scale);
- n.translate(10, 10);
- n.translate(q.props.x - t.x, q.props.y - t.y);
- n.translate(q.props.w / 2, q.props.h / 2);
- n.rotate(q.props.angle);
- n.translate(-(q.props.w / 2), -(q.props.h / 2));
- var x = q.lineStyle;
- n.globalAlpha = q.shapeStyle.alpha;
- n.lineJoin = "round";
- this.renderShapePath(n, q);
- this.renderMarkers(n, q);
- var m = q.getPath();
- var p = Utils.copy(m[m.length - 1]);
- p.fillStyle = {
- type: "none"
- };
- p.lineStyle = {
- lineWidth: 0
- };
- var u = [p];
- this.renderPath(n, q, u);
- this.renderText(q, t);
- let tmpCommonShapeConfig = Utils.copy(Model.define.commonShapeConfig);
- if (specialShapeConfig !== undefined || tmpCommonShapeConfig[key] !== undefined){ // 如果特殊与全局都没有配置,则不显示
- this.renderDataAttributes(q, t);
- }
- this.renderTitleShow(q, t);
- Designer.painter.renderShapeLink(o, q); //节点链接
- Designer.painter.renderSahpeAttachment(o, q); //节点附件
- if (q.attributesJsonArray != undefined && q.attributesJsonArray.length > 0) {
- o.find(".shape_danger").remove();
- o.find(".shape_regulate").remove();
- var A = false;
- var z = false;
- for (var r in q.attributesJsonArray) {
- var l = q.attributesJsonArray[r];
- if (l != undefined && l.key == "danger" && l.value != undefined && l.value != "" && relationShapesObject != undefined) {
- if (typeof l.value == 'object' && l.value.constructor == Array) {
- for (var m = 0; m < l.value.length; m++) {
- if (relationShapesObject[l.value[m]] != undefined) {
- A = true;
- break;
- }
- }
- } else if (relationShapesObject[l.value] != undefined) {
- A = true;
- }
- } else {
- if (l != undefined && l.key == "regulate" && l.value != undefined && l.value != "" && relationShapesObject != undefined) {
- if (typeof l.value == 'object' && l.value.constructor == Array) {
- for (var m = 0; m < l.value.length; m++) {
- if (relationShapesObject[l.value[m]] != undefined) {
- z = true;
- break;
- }
- }
- } else if (relationShapesObject[l.value] != undefined) {
- z = true;
- }
- }
- }
- }
- if (A) {
- var y = $("").appendTo(o)
- }
- // 伊利项目需求 控制角标不显示
- // if (z) {
- // var y = $("").appendTo(o)
- // }
- }
- },
- fillShape: function (n, i, h) {
- i.save();
- // 颜色叠加
- if (typeof h.colorOverlay !== 'undefined') {
- if (h.colorOverlay === 'multiplyOverlay') {
- h.color = multiplyColors(h.color);
- }
- }
- if (h.type == "solid") {
- i.fillStyle = "rgb(" + h.color + ")";
- i.fill()
- } else if (h.type == "gradient") {
- var j;
- if (h.gradientType == "linear") {
- j = GradientHelper.createLinearGradient(n, i, h)
- } else {
- j = GradientHelper.createRadialGradient(n, i, h)
- }
- i.fillStyle = j;
- i.fill()
- } else if (h.type === "image" || h.type === "imageDef") {
- let isInvalidImage = false // 自定义图片图元 图片是否被替换标志位
- let m = h.fileId
- if (h.from === 'insert') {
- m = shapeImages[h.fileId]
- }
- if (h.type === "imageDef") {
- if (imageDefMap[h.fileId]) {
- m = imageDefMap[h.fileId]
- } else {
- m = shapeImages[h.fileId]
- isInvalidImage = true
- }
- }
- var k = $(".shape_img[src='" + m + "']");
- if (k.length == 0) {
- k = $("
").appendTo("#shape_img_container");
- k.bind("load.drawshape",
- function () {
- var b = h.from === 'insert' ? 0 : (Designer.config.panelItemWidth - n.props.w) / 2;
- var a = h.from === 'insert' ? 0 : (Designer.config.panelItemHeight - n.props.h) / 2;
- if (isInvalidImage) {
- a = 0
- b = 0
- }
- i.translate(b, a);
- l(k);
- i.restore();
- $(this).attr("loaded", "1")
- });
- k.attr("src", m)
- } else if (k.attr("loaded") == "0") {
- k.bind("load.drawshape",
- function () {
- // var b = (Designer.config.panelItemWidth - n.props.w) / 2;
- // var a = (Designer.config.panelItemHeight - n.props.h) / 2;
- var b = 0;// by sunlh 20200716 svg shape
- var a = 0;
- i.translate(b, a);
- l(k);
- i.restore()
- })
- } else {
- l(k)
- }
- }
-
- // 颜色叠加 乘法处理
- function multiplyColors(color1) {
- // 将颜色转换为RGB数组格式
- let [r1, g1, b1] = color1.split(',').map(Number);
- let [r2, g2, b2] = color1.split(',').map(Number);
- let r = (r1 / 255) * (r2 / 255) * 255;
- let g = (g1 / 255) * (g2 / 255) * 255;
- let b = (b1 / 255) * (b2 / 255) * 255;
- // 返回新的RGB颜色字符串
- return `${Math.round(r)}, ${Math.round(g)}, ${Math.round(b)}`;
- }
-
- i.restore();
-
- function l(r) {
- i.save();
- i.clip();
- if (h.display == "fit") {
- var d = r.width();
- var q = r.height();
- var a = d / q;
- var e = n.props.w / n.props.h;
- if (a > e) {
- var g = n.props.w;
- var b = 0;
- var s = g / a;
- var c = n.props.h / 2 - s / 2;
- i.drawImage(r[0], b, c, g, s)
- } else {
- var s = n.props.h;
- var c = 0;
- var g = s * a;
- var b = n.props.w / 2 - g / 2;
- i.drawImage(r[0], b, c, g, s)
- }
- } else {
- if (h.display == "stretch") {
- i.drawImage(r[0], 0, 0, n.props.w, n.props.h)
- } else {
- if (h.display == "original") {
- var d = r.width();
- var q = r.height();
- var b = n.props.w / 2 - d / 2;
- var c = n.props.h / 2 - q / 2;
- i.drawImage(r[0], b, c, d, q)
- } else {
- if (h.display == "tile") {
- var b = 0;
- var d = r.width();
- var q = r.height();
- while (b < n.props.w) {
- var c = 0;
- while (c < n.props.h) {
- i.drawImage(r[0], b, c, d, q);
- c += q
- }
- b += d
- }
- } else {
- if (h.display == "static") {
- var u = 0;
- var t = r.width();
- var f = r.height();
- i.drawImage(r[0], h.imageX, h.imageY, t, f)
- } else {
- if (h.display == "zoom") {
- var u = 0;
- var t = r.width();
- var f = r.height();
- i.drawImage(r[0], h.imageX, h.imageY, t, f, h.canvasX, h.canvasY, h.canvasW, h.canvasH)
- } else {
- var d = r.width();
- var q = r.height();
- var a = d / q;
- var e = n.props.w / n.props.h;
- if (a > e) {
- var s = n.props.h;
- var c = 0;
- var g = s * a;
- var b = n.props.w / 2 - g / 2;
- i.drawImage(r[0], b, c, g, s)
- } else {
- var g = n.props.w;
- var b = 0;
- var s = g / a;
- var c = n.props.h / 2 - s / 2;
- i.drawImage(r[0], b, c, g, s)
- }
- }
- }
- }
- }
- }
- }
- i.restore()
- }
- },
- renderText: function (z, r) {
- var B = $("#" + z.id);
- var v = B.find(".text_canvas[forshape=" + z.id + "]");
- if (v.length == 0) {
- v = $("").appendTo(B);
- v.bind("focus",
- function () {
- $(this).blur()
- })
- }
- v.attr("readonly", "readonly");
- if (z.text == null || z.text.trim() == "") {
- v.css({
- height: "0px",
- width: "0px"
- }).hide();
- return
- }
- var C = z.fontStyle;
- var G = {
- "line-height": Math.round(C.size * 1.25) + "px",
- "font-size": C.size + "px",
- "font-family": C.fontFamily,
- "font-weight": C.bold ? "bold" : "normal",
- "font-style": C.italic ? "italic" : "normal",
- "text-align": C.textAlign,
- color: "rgb(" + C.color + ")",
- "text-decoration": C.underline ? "underline" : "none",
- opacity: z.shapeStyle.alpha
- };
- v.css(G);
- v.show();
- var s = z.getTextBlock();
- if (z.fontStyle.orientation == "horizontal") {
- var D = {
- x: s.x + s.w / 2,
- y: s.y + s.h / 2
- };
- s = {
- x: D.x - s.h / 2,
- y: D.y - s.w / 2,
- w: s.h,
- h: s.w
- }
- }
- v.css({
- width: s.w
- });
- v.height(0);
- v.val(z.text);
- v.scrollTop(99999);
- var E = v.scrollTop();
- var y = 0;
- if (C.vAlign == "middle") {
- y = (s.y + s.h / 2 - E / 2)
- } else {
- if (z.fontStyle.vAlign == "bottom") {
- y = (s.y + s.h - E)
- } else {
- y = s.y
- }
- }
- var t = {
- x: s.x + s.w / 2,
- y: y + E / 2
- };
- var w = z.props.angle;
- if (w != 0) {
- var H = {
- x: z.props.w / 2,
- y: z.props.h / 2
- };
- t = Utils.getRotated(H, t, w)
- }
- if (C.orientation == "horizontal") {
- w = (Math.PI * 1.5 + w) % (Math.PI * 2)
- }
- var F = Math.round(w / (Math.PI * 2) * 360);
- var x = "rotate(" + F + "deg) scale(" + Designer.config.scale + ")";
- var A = s.w;
- var u = E;
- v.css({
- width: A,
- height: u,
- left: (t.x + (z.props.x - r.x) + 10).toScale() - s.w / 2,
- top: (t.y + (z.props.y - r.y) + 10).toScale() - E / 2,
- "-webkit-transform": x,
- "-ms-transform": x,
- "-o-transform": x,
- "-moz-transform": x,
- transform: x
- })
- },
- calculateTextLines: function (D, i, z) {
- var E = i.w;
- var w = i.h;
- var J = [];
- var H = D.split(/\n/);
- for (var x = 0; x < H.length; x++) {
- var B = H[x];
- var A = z.measureText(B);
- if (A.width <= E) {
- J.push(B)
- } else {
- var C = B.split(/\s/);
- var F = "";
- for (var y = 0; y < C.length; y++) {
- var j = C[y];
- if (y != C.length - 1) {
- j += " "
- }
- var h = z.measureText(j).width;
- if (h > E) {
- for (var I = 0; I < j.length; I++) {
- var p = F + j[I];
- var G = z.measureText(p).width;
- if (G > E) {
- J.push(F);
- F = j[I]
- } else {
- F = p
- }
- }
- } else {
- var p = F + j;
- var G = z.measureText(p).width;
- if (G > E) {
- J.push(F);
- F = j
- } else {
- F = p
- }
- }
- }
- if (F != "") {
- J.push(F)
- }
- }
- }
- return J
- },
- renderMarkers: function (n, r, v) {
- if (r.attribute && r.attribute.markers && r.attribute.markers.length > 0) {
- var u = r.attribute.markers;
- var i = Schema.config.markerSize;
- var q = 4;
- if (v) {
- i = 10
- }
- var t = r.attribute.markerOffset;
- if (v) {
- t = 5
- }
- var w = u.length * i + (u.length - 1) * q;
- var p = r.props.w / 2 - w / 2;
- for (var s = 0; s < u.length; s++) {
- var o = u[s];
- n.save();
- n.translate(p, r.props.h - i - t);
- var x = Schema.markers[o].call(r, i);
- this.renderPath(n, r, x);
- n.restore();
- p += i + q
- }
- }
- },
- renderTitleShow: function (i, k) {
- if (i.props.titleProps) {
- var H = $("").appendTo($("#" + i.id));
- H.css({
- left: (10 + i.props.titleProps.x) * Designer.config.scale + 'px',
- top: (17 + i.props.titleProps.y) * Designer.config.scale + 'px',
- });
- var b = H[0].getContext("2d");
- var w = "13px ";
- w += i.fontStyle.fontFamily;
- b.font = w;
- b.fillStyle = "#696969";
- if (i.titleStyle && i.titleStyle.titleColor) {
- b.fillStyle = i.titleStyle.titleColor;
- }
- b.scale(Designer.config.scale, Designer.config.scale);
- b.fillText(i.title, 0, 12);
- }
- },
- renderDataAttributes: function (i, k) {
- $("#" + i.id).children(".attr_canvas").remove();
- if (!i.dataAttributes || i.dataAttributes.length == 0) {
- return
- }
- var n = {
- x: i.props.w / 2,
- y: i.props.h / 2
- };
- for (var p = 0; p < i.dataAttributes.length; p++) {
- var j = i.dataAttributes[p];
- if (j.hasOwnProperty("attributesJsonArray")) {
- if (!j.dataShowConfig) {
- continue
- }
- var jj = j.dataShowConfig.value;
- if (jj && jj.length > 0) {
- for (var n = 0; n < jj.length; n++) {
- var jjj = jj[n];
- var l = "";
- var o = "";
- if (jjj.showName) {
- l = j.name + ": "
- }
- if (jjj.showType == "text" || jjj.showType == "attr") {
- l += jjj.value;
- //判断如果岗位多个数据,...显示 by zhaolei
- /* if (jjj.value != "") {
- debugger;
- var lenth = jjj.value.match(/,/g).length;
- if (lenth >= 2) {
- var index1 = jjj.value.indexOf(",");
- var index2 = jjj.value.indexOf(",", index1 + 1);
- l += jjj.value.substr(0, index2) + "...";
- } else {
- l += jjj.value;
- }
-
- }else{
- l += jjj.value;
- }*/
- } else {
- if (jjj.showType == "icon") {
- o = jjj.icon
- }
- }
- if (l == "" && o == "") {
- continue
- }
- m(jjj, l, o)
- }
- }
- }
- /*if (j.showType == "none") {
- continue
- }
- var l = "";
- var o = "";
- if (j.showName) {
- l = j.name + ": "
- }
- if (j.showType == "text" || j.showType == "attr") {
- l += j.value
- } else {
- if (j.showType == "icon") {
- o = j.icon
- }
- }
- if (l == "" && o == "") {
- continue
- }
- m(j, l, o)*/
- }
-
- function m(c, y, x) {
- if (1 + 1 == 3) {
- // if (c.showType == 'icon' && x.indexOf("") >= 0) {// 图标重构
- var h = c.horizontal;
- var I = c.vertical;
- var icon = x.split("|")[0];
- var iconColor = x.split("|")[1];
- var H = $("" + icon + "
").appendTo($("#" + i.id));
- // 图标大小处理
- // $('#attr_canvas_' + c.id).css('font-size', Designer.config.scale * 20 + 'px');
- $('#attr_canvas_icon_' + c.id).css('font-size', Designer.config.scale + 'em');
- debugger;
- var D = 0;
- var a = 20;
- if (x != "") {
- D += 20
- }
- var E, F;
- if (h == "mostleft") {// 左外边
- E = -D - 2
- } else if (h == "leftedge") {// 左线上
- E = -D / 2
- } else if (h == "left") {// 左内边
- E = 2
- } else if (h == "center") {// 中间
- E = (i.props.w - D) / 2;
- } else if (h == "right") {// 右内边
- E = i.props.w - D - 2;
- } else if (h == "rightedge") {// 右线上
- E = i.props.w - D / 2
- } else if (h == "mostright") {// 右外边
- E = i.props.w + 2
- }
- if (I == "mosttop") {// 上外边
- F = -a
- } else if (I == "topedge") {// 上线上
- F = -a / 2
- } else if (I == "top") {// 上内边
- F = 0
- } else if (I == "middle") {// 中间
- F = (i.props.h - a) / 2
- } else if (I == "bottom") {// 下内边
- F = i.props.h - a
- } else if (I == "bottomedge") {// 下线上
- F = i.props.h - a / 2
- } else if (I == "mostbottom") {// 下外边
- F = i.props.h
- }
- var g = {
- x: E,
- y: F,
- w: D,
- h: a
- };
- var G = Utils.getRotatedBox(g, i.props.angle, n);
- H.attr({
- width: G.w.toScale(),
- height: G.h.toScale()
- });
- var d = (G.x + (i.props.x - k.x) + 10).toScale();
- var e = (G.y + (i.props.y - k.y) + 10).toScale();
- if (h != "mostleft" || h == "left" || h != "right") {
- H.css({
- left: d,
- top: e
- });
- }
- if (D > i.props.w) {
- var tempShapeWidth = i.props.w;
- if (tempShapeWidth < 100) {
- tempShapeWidth = 100;
- }
- H[0].width = tempShapeWidth + 10;
- H[0].height = Math.ceil(D / tempShapeWidth) * 10 + 15;
- if (h == "mostleft") {
- d = -tempShapeWidth + tempShapeWidth * 0.2;
- H.css({
- left: d,
- top: e
- });
- }
- if (h == "left") {
- H.css({
- left: d,
- top: e - 5
- });
- }
- if (h == "left" && I != "bottom") {
- H.css({
- left: d,
- top: e
- });
- }
- if (h == "right") {
- d = tempShapeWidth / 4;
- H.css({
- left: d,
- top: e - 5
- });
- }
- if (I == "mosttop" || I == "bottom") {
- e = e - Math.ceil(D / tempShapeWidth) * 5;
- H.css({
- left: d,
- top: e
- });
- }
- if (h == "center" && Math.ceil(D / tempShapeWidth) > 1) {
- H.css({
- left: 15,
- top: e
- });
- }
- if (h == "right" && I != "mosttop" && I != "bottom") {
- d = tempShapeWidth / 4;
- H.css({
- left: d,
- top: e
- });
- }
- } else {
- if (h == "mostleft") {
- d = -D;
- H.css({
- left: d,
- top: e
- });
- }
- if (h == "right") {
- d = i.props.w - D;
- H.css({
- left: d,
- top: e
- });
- }
- }
- return;
- }
- var h = c.horizontal;
- var I = c.vertical;
- var H = $("").appendTo($("#" + i.id));
- var b = H[0].getContext("2d");
- var w = "12px ";
- w += i.fontStyle.fontFamily;
- b.font = w;
- var D = b.measureText(y).width;
- var a = 20;
- if (x != "") {
- D += 20
- }
- var E, F;
- if (h == "mostleft") {
- E = -D - 2
- } else {
- if (h == "leftedge") {
- E = -D / 2
- } else {
- if (h == "left") {
- E = 2
- } else {
- if (h == "center") {
- E = (i.props.w - D) / 2;
- } else {
- if (h == "right") {
- E = i.props.w - D - 2;
- }else {
- if (h == "rightedge") {
- E = i.props.w - D / 2
- } else {
- E = i.props.w + 2
- }
- }
- }
- }
- }
- }
- if (I == "mosttop") {
- F = -a
- } else {
- if (I == "topedge") {
- F = -a / 2
- } else {
- if (I == "top") {
- F = 0
- } else {
- if (I == "middle") {
- F = (i.props.h - a) / 2
- } else {
- if (I == "bottom") {
- F = i.props.h - a
- } else {
- if (I == "bottomedge") {
- F = i.props.h - a / 2
- } else {
- F = i.props.h
- }
- }
- }
- }
- }
- }
- var g = {
- x: E,
- y: F,
- w: D,
- h: a
- };
- var G = Utils.getRotatedBox(g, i.props.angle, n);
- H.attr({
- width: G.w.toScale(),
- height: G.h.toScale()
- });
- b.font = w;
- var d = (G.x + (i.props.x - k.x) + 10).toScale();
- var e = (G.y + (i.props.y - k.y) + 10).toScale();
- if (h != "mostleft" || h == "left" || h != "right") {
- H.css({
- left: d,
- top: e
- });
- }
- b.scale(Designer.config.scale, Designer.config.scale);
- b.translate(G.w / 2, G.h / 2);
- b.rotate(i.props.angle);
- b.translate(-G.w / 2, -G.h / 2);
- b.translate((G.w - g.w) / 2, (G.h - g.h) / 2);
- b.globalAlpha = i.shapeStyle.alpha;
- if (c.type == "link") {
- b.fillStyle = "#4183C4"
- } else {
- b.fillStyle = "#333"
- }
- if (c.showType == "text") {
- b.fillStyle = "#696969";
- }
- if (c.showType == "attr") {
- b.fillStyle = "#191970";
- }
- b.textBaseline = "middle";
- if (D > i.props.w) {
- var tempShapeWidth = i.props.w;
- if (tempShapeWidth < 100) {
- tempShapeWidth = 100;
- }
- H[0].width = tempShapeWidth + 10;
- H[0].height = Math.ceil(D / tempShapeWidth) * 10 + 15;
- for (var v = 0; v < Math.ceil(D / tempShapeWidth); v++) {
- var tempL = (v + 1) * tempShapeWidth;
- var tempX = 0;
- if (c.showType == "text") {
- b.fillStyle = "#696969";
- }
- if (c.showType == "attr") {
- b.fillStyle = "#191970";
- }
- var tempY = a / 2 + v * 12;
- if (tempL < D) {
- b.fillText(y.substring(v * tempShapeWidth / (D / y.length), tempL / (D / y.length)), tempX, tempY);
- } else {
- b.fillText(y.substring(v * tempShapeWidth / (D / y.length), D / (D / y.length)), tempX, tempY);
- }
- }
- if (h == "mostleft") {
- d = -tempShapeWidth + tempShapeWidth * 0.2;
- H.css({
- left: d,
- top: e
- });
- }
- if (h == "left") {
- H.css({
- left: d,
- top: e - 5
- });
- }
- if (h == "left" && I != "bottom") {
- H.css({
- left: d,
- top: e
- });
- }
- if (h == "right") {
- d = tempShapeWidth / 4;
- H.css({
- left: d,
- top: e - 5
- });
- }
- if (I == "mosttop" || I == "bottom") {
- e = e - Math.ceil(D / tempShapeWidth) * 5;
- H.css({
- left: d,
- top: e
- });
- }
- if (h == "center" && Math.ceil(D / tempShapeWidth) > 1) {
- H.css({
- left: 15,
- top: e
- });
- }
- if (h == "right" && I != "mosttop" && I != "bottom") {
- d = tempShapeWidth / 4;
- H.css({
- left: d,
- top: e
- });
- }
- } else {
- if (h == "mostleft") {
- d = -D;
- H.css({
- left: d,
- top: e
- });
- }
- if (h == "right") {
- // d = i.props.w - D;
- H.css({
- left: d,
- top: e
- });
- }
- b.fillText(y, 0, a / 2);
- }
- if (x != "") {
- if (x.indexOf("") >= 0) {
- var icon = x.split("|")[0];
- var iconColor = x.split("|")[1];
- icon = eval("('" + icon.replace('', '\\u').replace(';', '') + "')");
- // 创建 FontFace 对象, 使用与CSS `@import` 相同的字体文件路径 目的是保证字体文件加载完成后 才渲染图标
- const font = new FontFace('awsui-iconfont', 'url(../commons/css/font/iconfont.woff');
- font.load().then(function (loadedFont) {
- // 使用字体
- document.fonts.add(loadedFont);
- // 现在字体已加载,可以进行绘制操作
- console.debug('Font loaded successfully');
- b.font = "19px awsui-iconfont";
- b.fillStyle = iconColor;
- b.fillText(icon, 0, a / 2);
- });
- iconCavCode = H[0].toDataURL("image/png");
- c.iconCavCode = iconCavCode;
- } else {
- var J = "/images/data-attr/" + x + ".png";
- var f = $(".shape_img[src='" + J + "']");
- if (f.length == 0) {
- f = $("
").appendTo("#shape_img_container")
- }
- if (f.attr("loaded") == "true") {
- b.drawImage(f[0], g.w - 20, 0, 20, 20)
- } else {
- f.bind("load.drawshape",
- function () {
- $(this).attr("loaded", "true");
- b.drawImage(f[0], g.w - 20, 0, 20, 20)
- })
- }
- }
- }
- b.beginPath();
- b.rect(0, 0, D, a);
- b.closePath()
- }
- },
- renderLinker: function (h, k) {
- if (k) {
- h.points = Utils.getLinkerPoints(h)
- }
- if (h.linkerType == "curve" || h.linkerType == "broken") {
- if (!h.points || h.points.length == 0) {
- h.points = Utils.getLinkerPoints(h)
- }
- }
- var q = h.points;
- var o = Utils.copy(h.from);
- var a = Utils.copy(h.to);
- if (h.attribute && h.attribute.collapseBy) {
- $("#" + h.id).hide();
- return
- } else {
- $("#" + h.id).show()
- }
- var p = Utils.getEndpointAngle(h, "from");
- var d = Utils.getEndpointAngle(h, "to");
- var b = Utils.getLinkerLineStyle(h.lineStyle);
- l(o, h, b.beginArrowStyle, p);
- l(a, h, b.endArrowStyle, d);
- var B = a.x;
- var x = a.y;
- var y = o.x;
- var w = o.y;
- if (a.x < o.x) {
- B = a.x;
- y = o.x
- } else {
- B = o.x;
- y = a.x
- }
- if (a.y < o.y) {
- x = a.y;
- w = o.y
- } else {
- x = o.y;
- w = a.y
- }
- for (var r = 0; r < q.length; r++) {
- var n = q[r];
- if (n.x < B) {
- B = n.x
- } else {
- if (n.x > y) {
- y = n.x
- }
- }
- if (n.y < x) {
- x = n.y
- } else {
- if (n.y > w) {
- w = n.y
- }
- }
- }
- var f = {
- x: B,
- y: x,
- w: y - B,
- h: w - x
- };
- var C = $("#" + h.id);
- if (C.length == 0) {
- var g = $("#designer_canvas");
- C = $("").appendTo(g)
- }
- if (!Model.getShapeById(h.id)) {
- C.css("z-index", Model.orderList.length + 1)
- C.css({'pointer-events': 'none'})
- }
- var A = C.find(".shape_canvas");
- A.attr({
- width: (f.w + 20).toScale(),
- height: (f.h + 20).toScale()
- });
- C.css({
- left: (f.x - 10).toScale(),
- top: (f.y - 10).toScale(),
- width: (f.w + 20).toScale(),
- height: (f.h + 20).toScale()
- });
- var m = A[0].getContext("2d");
- m.scale(Designer.config.scale, Designer.config.scale);
- m.translate(10, 10);
- var s = Utils.getLinkerLineStyle(h.lineStyle);
- m.lineWidth = s.lineWidth;
- m.strokeStyle = "rgb(" + s.lineColor + ")";
- m.fillStyle = "rgb(" + s.lineColor + ")";
- m.save();
- var z = {
- x: o.x - f.x,
- y: o.y - f.y
- };
- var c = {
- x: a.x - f.x,
- y: a.y - f.y
- };
- m.save();
- if (s.lineStyle == "dashed") {
- this.setLineDash(m, [s.lineWidth * 5, s.lineWidth * 2])
- } else {
- if (s.lineStyle == "dot") {
- this.setLineDash(m, [s.lineWidth, s.lineWidth * 1.5])
- } else {
- if (s.lineStyle == "dashdot") {
- this.setLineDash(m, [s.lineWidth * 5, s.lineWidth * 2, s.lineWidth, s.lineWidth * 2])
- }
- }
- }
- m.lineJoin = "round";
- m.beginPath();
- this.actions.move.call(m, z);
- if (h.linkerType == "curve") {
- var v = q[0];
- var u = q[1];
- var t = {
- x1: v.x - f.x,
- y1: v.y - f.y,
- x2: u.x - f.x,
- y2: u.y - f.y,
- x: c.x,
- y: c.y
- };
- this.actions.curve.call(m, t)
- } else {
- for (var r = 0; r < q.length; r++) {
- var D = q[r];
- this.actions.line.call(m, {
- x: D.x - f.x,
- y: D.y - f.y
- })
- }
- this.actions.line.call(m, c)
- }
- var j = Utils.isSelected(h.id);
- if (j) {
- m.shadowBlur = 4;
- m.shadowColor = "#833";
- if (h.linkerType == "curve" && Utils.getSelectedIds().length == 1) {
- }
- }
- m.stroke();
- m.restore();
- delete m.webkitLineDash;
- e(z, p, o.id, s.beginArrowStyle, h, o.angle);
- e(c, d, a.id, s.endArrowStyle, h, a.angle);
- m.restore();
- this.renderLinkerText(h);
-
- function l(M, H, i, J) {
- if (M.id) {
- var E = Model.getShapeById(M.id);
- if (E) {
- var G = {
- x: 0,
- y: 0
- };
- var I = Utils.getShapeLineStyle(E.lineStyle);
- var L = Utils.getLinkerLineStyle(H.lineStyle);
- if (i == "none" || i == "cross") {
- G.x = -I.lineWidth / 2
- } else {
- if (i == "solidArrow" || i == "dashedArrow") {
- G.x = -I.lineWidth / 2 - L.lineWidth * 1.3
- } else {
- if (i == "solidDiamond" || i == "dashedDiamond") {
- G.x = -I.lineWidth / 2 - L.lineWidth
- } else {
- G.x = -I.lineWidth / 2 - L.lineWidth / 2
- }
- }
- }
- var K = {
- x: 0,
- y: 0
- };
- var F = Utils.getRotated(K, G, J);
- M.x += F.x;
- M.y += F.y
- }
- }
- }
-
- function e(W, M, Q, Y, R, E) {
- if (Y == "normal") {
- var S = 12;
- var ac = Math.PI / 5;
- var V = S / Math.cos(ac);
- var L = W.x - V * Math.cos(M - ac);
- var K = W.y - V * Math.sin(M - ac);
- var O = W.x - V * Math.sin(Math.PI / 2 - M - ac);
- var N = W.y - V * Math.cos(Math.PI / 2 - M - ac);
- m.beginPath();
- m.moveTo(L, K);
- m.lineTo(W.x, W.y);
- m.lineTo(O, N);
- m.stroke()
- } else {
- if (Y == "solidArrow") {
- var S = 12;
- var ac = Math.PI / 10;
- var V = S / Math.cos(ac);
- var L = W.x - V * Math.cos(M - ac);
- var K = W.y - V * Math.sin(M - ac);
- var O = W.x - V * Math.sin(Math.PI / 2 - M - ac);
- var N = W.y - V * Math.cos(Math.PI / 2 - M - ac);
- m.beginPath();
- m.moveTo(W.x, W.y);
- m.lineTo(L, K);
- m.lineTo(O, N);
- m.lineTo(W.x, W.y);
- m.closePath();
- m.fill();
- m.stroke()
- } else {
- if (Y == "dashedArrow") {
- m.save();
- var S = 12;
- var ac = Math.PI / 10;
- var V = S / Math.cos(ac);
- var L = W.x - V * Math.cos(M - ac);
- var K = W.y - V * Math.sin(M - ac);
- var O = W.x - V * Math.sin(Math.PI / 2 - M - ac);
- var N = W.y - V * Math.cos(Math.PI / 2 - M - ac);
- m.beginPath();
- m.moveTo(W.x, W.y);
- m.lineTo(L, K);
- m.lineTo(O, N);
- m.lineTo(W.x, W.y);
- m.closePath();
- m.fillStyle = "white";
- m.fill();
- m.stroke();
- m.restore()
- } else {
- if (Y == "solidCircle") {
- m.save();
- var i = 4;
- var J = W.x - i * Math.cos(M);
- var I = W.y - i * Math.sin(M);
- m.beginPath();
- m.arc(J, I, i, 0, Math.PI * 2, false);
- m.closePath();
- m.fill();
- m.stroke();
- m.restore()
- } else {
- if (Y == "dashedCircle") {
- m.save();
- var i = 4;
- var J = W.x - i * Math.cos(M);
- var I = W.y - i * Math.sin(M);
- m.beginPath();
- m.arc(J, I, i, 0, Math.PI * 2, false);
- m.closePath();
- m.fillStyle = "white";
- m.fill();
- m.stroke();
- m.restore()
- } else {
- if (Y == "solidDiamond") {
- m.save();
- var S = 8;
- var ac = Math.PI / 7;
- var V = S / Math.cos(ac);
- var L = W.x - V * Math.cos(M - ac);
- var K = W.y - V * Math.sin(M - ac);
- var O = W.x - V * Math.sin(Math.PI / 2 - M - ac);
- var N = W.y - V * Math.cos(Math.PI / 2 - M - ac);
- var U = W.x - S * 2 * Math.cos(M);
- var T = W.y - S * 2 * Math.sin(M);
- m.beginPath();
- m.moveTo(W.x, W.y);
- m.lineTo(L, K);
- m.lineTo(U, T);
- m.lineTo(O, N);
- m.lineTo(W.x, W.y);
- m.closePath();
- m.fill();
- m.stroke();
- m.restore()
- } else {
- if (Y == "dashedDiamond") {
- m.save();
- var S = 8;
- var ac = Math.PI / 7;
- var V = S / Math.cos(ac);
- var L = W.x - V * Math.cos(M - ac);
- var K = W.y - V * Math.sin(M - ac);
- var O = W.x - V * Math.sin(Math.PI / 2 - M - ac);
- var N = W.y - V * Math.cos(Math.PI / 2 - M - ac);
- var U = W.x - S * 2 * Math.cos(M);
- var T = W.y - S * 2 * Math.sin(M);
- m.beginPath();
- m.moveTo(W.x, W.y);
- m.lineTo(L, K);
- m.lineTo(U, T);
- m.lineTo(O, N);
- m.lineTo(W.x, W.y);
- m.closePath();
- m.fillStyle = "white";
- m.fill();
- m.stroke();
- m.restore()
- } else {
- if (Y == "cross") {
- var H = 6;
- var P = 14;
- var ab = H * Math.cos(Math.PI / 2 - M);
- var aa = H * Math.sin(Math.PI / 2 - M);
- var Z = W.x + ab;
- var G = W.y - aa;
- var U = W.x - P * Math.cos(M);
- var T = W.y - P * Math.sin(M);
- var X = U - ab;
- var F = T + aa;
- m.beginPath();
- m.moveTo(Z, G);
- m.lineTo(X, F);
- m.stroke()
- }
- }
- }
- }
- }
- }
- }
- }
- }
- },
- renderLinkerText: function (l) {
- var m = $("#" + l.id);
- var q = m.find(".text_canvas");
- if (q.length == 0) {
- q = $("").appendTo(m)
- }
- var n = l.fontStyle;
- var p = "scale(" + Designer.config.scale + ")";
- var r = {
- "line-height": Math.round(n.size * 1.25) + "px",
- "font-size": n.size + "px",
- "font-family": n.fontFamily,
- "font-weight": n.bold ? "bold" : "normal",
- "font-style": n.italic ? "italic" : "normal",
- "text-align": n.textAlign,
- color: "rgb(" + n.color + ")",
- "text-decoration": n.underline ? "underline" : "none",
- "-webkit-transform": p,
- "-ms-transform": p,
- "-o-transform": p,
- "-moz-transform": p,
- transform: p
- };
- q.css(r);
- if (l.text == null || l.text == "") {
- q.hide();
- return
- }
- q.show();
- var k = l.text.replace(//g, ">").replace(/\n/g, "
");
- q.html(k + "
");
- var j = this.getLinkerMidpoint(l);
- var o = m.position();
- q.css({
- left: j.x.toScale() - o.left - q.width() / 2,
- top: j.y.toScale() - o.top - q.height() / 2
- })
- },
- getLinkerMidpoint: function (z) {
- var w = {};
- if (z.linkerType == "normal") {
- w = {
- x: 0.5 * z.from.x + 0.5 * z.to.x,
- y: 0.5 * z.from.y + 0.5 * z.to.y
- }
- } else {
- if (z.linkerType == "curve") {
- var d = z.from;
- var q = z.points[0];
- var v = z.points[1];
- var x = z.to;
- w = {
- x: d.x * 0.125 + q.x * 0.375 + v.x * 0.375 + x.x * 0.125,
- y: d.y * 0.125 + q.y * 0.375 + v.y * 0.375 + x.y * 0.125
- }
- } else {
- var u = [];
- u.push(z.from);
- u = u.concat(z.points);
- u.push(z.to);
- var r = 0;
- for (var A = 1; A < u.length; A++) {
- var q = u[A - 1];
- var v = u[A];
- var y = Utils.measureDistance(q, v);
- r += y
- }
- var s = r / 2;
- var B = 0;
- for (var A = 1; A < u.length; A++) {
- var q = u[A - 1];
- var v = u[A];
- var y = Utils.measureDistance(q, v);
- var t = B + y;
- if (t > s) {
- var p = (s - B) / y;
- w = {
- x: (1 - p) * q.x + p * v.x,
- y: (1 - p) * q.y + p * v.y
- };
- break
- }
- B = t
- }
- }
- }
- return w
- },
- controlStatus: {
- resizeDir: [],
- rotatable: true
- },
- drawControls: function (m) {
- var n = $("#shape_controls");
- if (n.length == 0) {
- var r = $("#designer_canvas");
- n = $("").appendTo(r);
- n.append("");
- n.append("");
- n.append("");
- n.append("");
- n.append("");
- n.append("");
- n.append("");
- n.append("");
- n.append("");
- Designer.op.shapeResizable();
- n.append("");
- Designer.op.shapeRotatable();
- n.append("");
- Designer.op.groupShapeChangable();
- $(".shape_controller").css({
- "border-color": Designer.config.anchorColor,
- width: Designer.config.anchorSize - 2,
- height: Designer.config.anchorSize - 2
- })
- }
- $(".shape_controller").css({
- "z-index": Model.orderList.length
- });
- $(".change_shape_icon").hide();
- n.show();
- var p = 0;
- var i;
- var q;
- if (m.length == 1) {
- var l = Model.getShapeById(m[0]);
- i = l.props;
- p = l.props.angle;
- q = l.resizeDir;
- if (l.groupName && SchemaGroup.groupExists(l.groupName)) {
- $(".change_shape_icon").show()
- }
- } else {
- i = Utils.getControlBox(m);
- q = ["tl", "tr", "br", "bl"]
- }
- var t = true;
- for (var o = 0; o < m.length; o++) {
- var s = m[o];
- var l = Model.getShapeById(s);
- if (l.attribute && l.attribute.rotatable == false) {
- t = false
- }
- if ((l.resizeDir && l.resizeDir.length == 0) || (l.parent && m.length > 1)) {
- q = []
- }
- }
- this.controlStatus.rotatable = t;
- this.controlStatus.resizeDir = q;
- this.rotateControls(i, p);
- return n
- },
- rotateControls: function (R, E) {
- var O = $("#shape_controls");
- var N = Utils.getRotatedBox(R, E);
- var i = N.w.toScale();
- var Q = N.h.toScale();
- O.css({
- left: N.x.toScale(),
- top: N.y.toScale(),
- width: i,
- height: Q,
- "z-index": Model.orderList.length
- });
- var P = i + 20;
- var K = Q + 20;
- var S = $("#controls_bounding");
- S.attr({
- width: P,
- height: K
- });
- var J = S[0].getContext("2d");
- J.lineJoin = "round";
- if (this.controlStatus.resizeDir.length == 0) {
- J.lineWidth = 2;
- J.strokeStyle = Designer.config.selectorColor;
- J.globalAlpha = 0.8
- } else {
- J.lineWidth = 1;
- J.strokeStyle = Designer.config.selectorColor;
- J.globalAlpha = 0.5
- }
- J.save();
- J.clearRect(0, 0, P, K);
- J.translate(P / 2, K / 2);
- J.rotate(E);
- J.translate(-P / 2, -K / 2);
- J.translate(9.5, 9.5);
- var W = {
- x: Math.round((R.x - N.x).toScale()),
- y: Math.round((R.y - N.y).toScale()),
- w: Math.floor(R.w.toScale() + 1),
- h: Math.floor(R.h.toScale() + 1)
- };
- J.strokeRect(W.x, W.y, W.w, W.h);
- J.restore();
- var A = 0 - Designer.config.anchorSize / 2;
- var G = {};
- R = Utils.toScale(R);
- N = Utils.toScale(N);
- var D = {
- x: (R.x + R.w / 2),
- y: R.y + R.h / 2
- };
- O.children(".shape_controller").hide();
- for (var H = 0; H < this.controlStatus.resizeDir.length; H++) {
- var L = this.controlStatus.resizeDir[H];
- var X = $(".shape_controller[resizeDir=" + L + "]");
- X.show();
- var U, V;
- if (L.indexOf("l") >= 0) {
- U = R.x
- } else {
- if (L.indexOf("r") >= 0) {
- U = R.x + R.w
- } else {
- U = R.x + R.w / 2
- }
- }
- if (L.indexOf("t") >= 0) {
- V = R.y
- } else {
- if (L.indexOf("b") >= 0) {
- V = R.y + R.h
- } else {
- V = R.y + R.h / 2
- }
- }
- var T = Utils.getRotated(D, {
- x: U,
- y: V
- },
- E);
- X.css({
- left: T.x - N.x + A,
- top: T.y - N.y + A
- })
- }
- var M = Math.PI / 8;
- O.children(".shape_controller").removeClass("s n e w");
- if (E > M && E <= M * 3) {
- O.children("div[resizeDir=tl]").addClass("n");
- O.children("div[resizeDir=tr]").addClass("e");
- O.children("div[resizeDir=br]").addClass("s");
- O.children("div[resizeDir=bl]").addClass("w");
- O.children("div[resizeDir=l]").addClass("n w");
- O.children("div[resizeDir=r]").addClass("s e");
- O.children("div[resizeDir=b]").addClass("s w");
- O.children("div[resizeDir=t]").addClass("n e")
- } else {
- if (E > M * 3 && E <= M * 5) {
- O.children("div[resizeDir=tl]").addClass("n e");
- O.children("div[resizeDir=tr]").addClass("s e");
- O.children("div[resizeDir=br]").addClass("s w");
- O.children("div[resizeDir=bl]").addClass("n w");
- O.children("div[resizeDir=l]").addClass("n");
- O.children("div[resizeDir=r]").addClass("s");
- O.children("div[resizeDir=b]").addClass("w");
- O.children("div[resizeDir=t]").addClass("e")
- } else {
- if (E > M * 5 && E <= M * 7) {
- O.children("div[resizeDir=tl]").addClass("e");
- O.children("div[resizeDir=tr]").addClass("s");
- O.children("div[resizeDir=br]").addClass("w");
- O.children("div[resizeDir=bl]").addClass("n");
- O.children("div[resizeDir=l]").addClass("n e");
- O.children("div[resizeDir=r]").addClass("s w");
- O.children("div[resizeDir=b]").addClass("n w");
- O.children("div[resizeDir=t]").addClass("s e")
- } else {
- if (E > M * 7 && E <= M * 9) {
- O.children("div[resizeDir=tl]").addClass("s e");
- O.children("div[resizeDir=tr]").addClass("s w");
- O.children("div[resizeDir=br]").addClass("n w");
- O.children("div[resizeDir=bl]").addClass("n e");
- O.children("div[resizeDir=l]").addClass("e");
- O.children("div[resizeDir=r]").addClass("w");
- O.children("div[resizeDir=b]").addClass("n");
- O.children("div[resizeDir=t]").addClass("s")
- } else {
- if (E > M * 9 && E <= M * 11) {
- O.children("div[resizeDir=tl]").addClass("s");
- O.children("div[resizeDir=tr]").addClass("w");
- O.children("div[resizeDir=br]").addClass("n");
- O.children("div[resizeDir=bl]").addClass("e");
- O.children("div[resizeDir=l]").addClass("s e");
- O.children("div[resizeDir=r]").addClass("n w");
- O.children("div[resizeDir=b]").addClass("n e");
- O.children("div[resizeDir=t]").addClass("s w")
- } else {
- if (E > M * 11 && E <= M * 13) {
- O.children("div[resizeDir=tl]").addClass("s w");
- O.children("div[resizeDir=tr]").addClass("n w");
- O.children("div[resizeDir=br]").addClass("n e");
- O.children("div[resizeDir=bl]").addClass("s e");
- O.children("div[resizeDir=l]").addClass("s");
- O.children("div[resizeDir=r]").addClass("n");
- O.children("div[resizeDir=b]").addClass("e");
- O.children("div[resizeDir=t]").addClass("w")
- } else {
- if (E > M * 13 && E <= M * 15) {
- O.children("div[resizeDir=tl]").addClass("w");
- O.children("div[resizeDir=tr]").addClass("n");
- O.children("div[resizeDir=br]").addClass("e");
- O.children("div[resizeDir=bl]").addClass("s");
- O.children("div[resizeDir=l]").addClass("s w");
- O.children("div[resizeDir=r]").addClass("n e");
- O.children("div[resizeDir=b]").addClass("s e");
- O.children("div[resizeDir=t]").addClass("n w")
- } else {
- O.children("div[resizeDir=tl]").addClass("n w");
- O.children("div[resizeDir=tr]").addClass("n e");
- O.children("div[resizeDir=br]").addClass("s e");
- O.children("div[resizeDir=bl]").addClass("s w");
- O.children("div[resizeDir=l]").addClass("w");
- O.children("div[resizeDir=r]").addClass("e");
- O.children("div[resizeDir=b]").addClass("s");
- O.children("div[resizeDir=t]").addClass("n")
- }
- }
- }
- }
- }
- }
- }
- if (this.controlStatus.rotatable) {
- var B = O.find(".shape_rotater");
- B.show();
- var C = {
- x: R.x + R.w / 2,
- y: R.y - 20
- };
- var F = Utils.getRotated(D, C, E);
- B.css({
- top: F.y - 20 - N.y,
- left: F.x - 20.5 - N.x
- });
- var I = B[0].getContext("2d");
- I.lineWidth = 1;
- I.strokeStyle = Designer.config.selectorColor;
- I.fillStyle = "white";
- I.save();
- I.clearRect(0, 0, 41, 40);
- I.translate(20.5, 20);
- I.rotate(E);
- I.translate(-20.5, -20);
- I.beginPath();
- I.moveTo(20.5, 20);
- I.lineTo(20.5, 40);
- I.stroke();
- I.beginPath();
- I.arc(20.5, 20, Designer.config.rotaterSize / 2, 0, Math.PI * 2);
- I.closePath();
- I.fill();
- I.stroke();
- I.restore()
- } else {
- O.find(".shape_rotater").hide()
- }
- },
- renderShapeLink: function (o, q) {
- //图形的链接
- o.find(".shape_link_point").remove();
- if (q.link) {
- var y = $("" +
- "" +
- "
").appendTo(o);
- y.on("mousedown.link",
- function (I) {
- I.stopPropagation();
- var c = Model.getShapeById($(this).parent().attr("id"));
- myshapeLink = c;
- if (c != undefined) {
- var k = c.props.x;
- var j = c.props.y;
- var B = c.props.w;
- var H = c.props.h;
- var b = $("#link-dialog-normal_contextmenu");
- b.empty();
- var D = [];
- for (var G = 0; G < c.dataAttributes.length; G++) {
- var E = c.dataAttributes[G];
- if (E.linksArray) {
- D = E.linksArray;
- break
- }
- }
- var d = "";
- for (var f = 0; f < D.length; f++) {
- if (D[f].type == "file") {
- d += D[f].uuid + ","
- }
- }
- if (D.length > 0 && window.opener) {
- var a = parent.window.$("#appId").val();
- var K = {
- sid: $("#sid").val(),
- cmd: "com.actionsoft.apps.coe.pal_pl_repository_designer_viewer_link_perm",
- uuids: d,
- filePerms: filePerms
- };
- if (window.opener) {
- K.modelType = "used"
- } else {
- if (a != undefined && a != "com.actionsoft.apps.coe.pal" && a != "") {
- K.modelType = "published"
- }
- }
- awsui.ajax.request({
- url: "./jd",
- method: "POST",
- data: K,
- async: false,
- ok: function (L) {
- var N = [];
- var M = L.data.uuids;
- // M = M.split(",");
- for (var e = 0; e < D.length; e++) {
- var h = false;
- var i = D[e].uuid;
- if (D[e].type == "file") {
- for (var O = 0; O < M.length; O++) {
- if (M[O].linkUUID == D[e].uuid) {
- h = true;
- break
- }
- }
- } else {
- h = true
- }
- if (h) {
- D[e].uuid = i;
- N.push(D[e])
- }
- }
- D = N
- }
- })
- }
- if (D.length == 0) {
- b.hide();
- $.simpleAlert("没有链接权限", "error");
- return
- } else {
- if (D.length == 1) {
- b.hide();
- openLinkUrlRewrite(D[0].type, D[0].url, D[0].target, D[0].uuid, "", D[0].name, true);
- return
- } else {
- for (var f = 0; f < D.length; f++) {
- linkIndex++;
- var C = D[f];
- var F = '" + C.name + "";
- if (role == "owner") {
- F += '"
- }
- F += "";
- b.append(F)
- }
- }
- }
- var g = Utils.getShapeByPosition(k, j, false);
- var J = Designer.clipboard.elements.length;
- if (g == null) {
- if (J > 0) {
- b.children("li[ac=paste]").show();
- b.children(".devi_clip").show()
- }
- } else {
- var c = g.shape;
- b.children("li[ac=cut]").show()
- }
- b.css({
- display: "block",
- "z-index": Model.orderList.length + 3,
- left: k + B + 10,
- top: j + H
- });
- $(document).on("mousedown.link", ":not(#link-dialog-normal_contextmenu li):not(#link-dialog-normal_contextmenu ul):not(#link-dialog-normal_contextmenu a):not(#link-dialog-normal_contextmenu div)",
- function (h) {
- if (this.id == "link-dialog-normal_contextmenu") {
- return false
- }
- b.hide()
- })
- }
- I.stopPropagation()
- })
- }
- },
- renderSahpeAttachment: function (o, q) {
- // 图形的附件
- o.find(".shape_attachment_point").remove();
- var selflist = []; //自身附件
- var relatelist = []; //关联附件
- var reqComplete = false; //是否请求完成
- // 封装请求后台方法.参数控制是否异步请求
- var reqMethod_renderSahpeAttachment = function (isAsync) {
- // 请求后台的自身附件
- $.ajax({
- method: "POST",
- async: isAsync,
- url: "./jd?sid=" + encodeURIComponent(sid) + "&cmd=com.actionsoft.apps.coe.pal_processlevel_upfile_load",
- data: {pl_uuid: ruuid, uuids: q.id},
- success: function (msg) {
- selflist = msg.data.list;
- // 请求后台的关联附件
- $.ajax({
- method: "POST",
- async: isAsync,
- url: "./jd?sid=" + encodeURIComponent(sid) + "&cmd=com.actionsoft.apps.coe.pal_processlevel_relation_upfile_load",
- data: {pl_uuid: ruuid, shape_uuid: q.id},
- success: function (msg) {
- relatelist = msg.data.list;
- reqComplete = true;
- }
- });
- }
- });
- };
- // 使用请求
- reqMethod_renderSahpeAttachment(true);
- // 使用定时器,异步控制节点的附件角标的出现
- var startTime = new Date().getTime();
- var intervalClr = window.setInterval(function () {
- // 5秒内请求完毕则处理,5秒内请求不完则不再处理
- var endTime = new Date().getTime();
- if (endTime - startTime > 5000 || reqComplete == true) {
- // 取消此定时器
- window.clearInterval(intervalClr);
- // 图形有附件,增加右下角图标 --begin
- if ((selflist && selflist.length > 0) || (relatelist && relatelist.length > 0)) {
- var y = $("" +
- "" +
- "
").appendTo(o);
- y.on("mousedown.attachment",
- function (I) {
- I.stopPropagation();
- // 每次点击节点附件下标再次请求后台,使用最新附件列表
- reqMethod_renderSahpeAttachment(false);
- var c = Model.getShapeById($(this).parent().attr("id")); //设计器上的图形
- myshapeLink = c;
- if (c != undefined) {
- var k = c.props.x;
- var j = c.props.y;
- var B = c.props.w;
- var H = c.props.h;
- var b = $("#attachment-dialog-normal_contextmenu");
- b.empty();
- b.append(''); //用于提供下载窗口
- for (var s = 0; s < 2; s++) { //循环附件和关联附件
- var attalist = selflist; //统一处理附件或者关联附件
- var attaTypeName = "附件"; //附件or关联附件
- if (s == 0) { //自身附件
- //
- } else { //关联附件
- attalist = relatelist;
- attaTypeName = "关联附件";
- }
- if (attalist.length > 0) {
- b.append('' + attaTypeName + '');
- for (var f = 0; f < attalist.length; f++) {
- var atta = attalist[f];
- // 是否允许下载的逻辑判断 1.支持下载 or 2.当前用户为上传用户 or admin用户
- var createUser = atta.createUser;
- var download = atta.download;
- var downloadPerm = false;
- if (s == 0) {
- // 附件 可以下载的条件: 1.支持下载 2.当前用户为上传用户
- if (download == 1 || user == createUser) {
- downloadPerm = true;
- }
- } else {
- // 关联附件 可以下载的条件: 1.支持下载
- if (download == 1) {
- downloadPerm = true;
- }
- }
- // 拼接展示框
- var F = '' + atta.fileName + '';
- if (downloadPerm) {
- F += '';
- }
- F += "";
- b.append(F)
- }
- }
- }
- // 如果其他人操作致使没有附件可展示,则给出无附件的展示
- if (selflist.length == 0 && relatelist.length == 0) {
- b.append('' + '无附件' + '');
- }
- // 控制展示与否
- var g = Utils.getShapeByPosition(k, j, false);
- var J = Designer.clipboard.elements.length;
- if (g == null) {
- if (J > 0) {
- b.children("li[ac=paste]").show();
- b.children(".devi_clip").show()
- }
- } else {
- var c = g.shape;
- b.children("li[ac=cut]").show()
- }
- b.css({
- display: "block",
- "z-index": Model.orderList.length + 3,
- left: k + B + 10,
- top: j + H
- });
- $(document).on("mousedown.attachment", ":not(#attachment-dialog-normal_contextmenu span):not(#attachment-dialog-normal_contextmenu li):not(#attachment-dialog-normal_contextmenu ul):not(#attachment-dialog-normal_contextmenu a):not(#attachment-dialog-normal_contextmenu div)",
- function (h) {
- if (this.id == "attachment-dialog-normal_contextmenu") {
- return false;
- }
- b.hide();
- });
- }
- I.stopPropagation()
- });
- }
- // 图形有附件,增加右下角图标 --end
- }
- }, 100); // end setInterval
- }, // end renderSahpeAttachment
- }
-};
-var Model = {
- define: {},
- persistence: {},
- orderList: [],
- maxZIndex: 0,
- linkerMap: {
- map: {},
- add: function (c, d) {
- if (!this.map[c]) {
- this.map[c] = []
- }
- if (this.map[c].indexOf(d) < 0) {
- this.map[c].push(d)
- }
- },
- remove: function (c, d) {
- if (this.map[c]) {
- Utils.removeFromArray(this.map[c], d)
- }
- },
- empty: function () {
- this.map = {}
- }
- },
- groupMap: {
- map: {},
- add: function (d, c) {
- this.map[d] = c
- },
- push: function (d, c) {
- if (!this.map[d]) {
- this.map[d] = []
- }
- this.map[d].push(c)
- },
- remove: function (b) {
- delete this.map[b]
- },
- empty: function () {
- this.map = {}
- }
- },
- create: function (l, h, j) {// designer.extend.core.js重写
- var m = Utils.newId();
- var o = Utils.copy(Schema.shapes[l]);
- o.id = m;
- o.props.x = h;
- o.props.y = j;
- o.props.zindex = Model.maxZIndex + 1;
- o.props = $.extend(true, {},
- Schema.shapeDefaults.props, o.props);
- for (var k = 0; k < o.dataAttributes.length; k++) {
- var i = o.dataAttributes[k];
- i.id = Utils.newId();
- if (i.attributesJsonArray) {
- if (Model.define.localAttribute != undefined && Model.define.localAttribute[o.name] != undefined && Model.define.localAttribute[o.name] != null && Model.define.localAttribute[o.name].length > 0) {
- for (var n in Model.define.localAttribute[o.name]) {
- i.attributesJsonArray.push(Utils.copy(Model.define.localAttribute[o.name][n]));
- }
- }
- }
- }
- Designer.events.push("create", o);
- return o
- },
- add: function (d, c) {
- this.addMulti([d], c)
- },
- addMulti: function (f, h) {
- if (typeof h == "undefined") {
- h = true
- }
- var g = [];
- for (var i = 0; i < f.length; i++) {
- var j = f[i];
- g.push(Utils.copy(j));
- this.define.elements[j.id] = Utils.copy(j);
- this.persistence.elements[j.id] = Utils.copy(j)
- }
- this.build();
- if (h) {
- MessageSource.send("create", g)
- }
- },
- update: function (b) {
- this.updateMulti([b]);
- Designer.painter.renderShape(b)
- },
- updateMulti: function (l) {
- var h = [];
- var g = [];
- for (var j = 0; j < l.length; j++) {
- var k = l[j];
- if (this.define.elements[k.id]) {
- this.define.elements[k.id] = Utils.copy(k);
- g.push(Utils.copy(this.getPersistenceById(k.id)));
- h.push(Utils.copy(k));
- this.persistence.elements[k.id] = Utils.copy(k)
- }
- }
- this.build();
- var i = {
- shapes: g,
- updates: h
- };
- MessageSource.send("update", i)
- },
- remove: function (C, u) {
- if (typeof u == "undefined") {
- u = true
- }
- if (u) {
- C = Designer.events.push("beforeRemove", C)
- }
- var w = [];
- var r = [];
- var z = [];
- var q = [];
- var A = [];
- if (C.length == 0) {
- return false
- }
- for (var y = 0; y < C.length; y++) {
- var v = C[y];
- if (v.name == "linker") {
- A.push(v.id)
- } else {
- q.push(v.id)
- }
- }
- for (var y = 0; y < C.length; y++) {
- var v = C[y];
- w.push(Utils.copy(v));
- $("#" + v.id).remove();
- delete this.define.elements[v.id];
- delete this.persistence.elements[v.id];
- this.groupMap.remove(v.group);
- if (v.name == "linker") {
- if (v.from.id != null) {
- this.linkerMap.remove(v.from.id, v.id)
- }
- if (v.to.id != null) {
- this.linkerMap.remove(v.to.id, v.id)
- }
- } else {
- if (v.parent && q.indexOf(v.parent) < 0) {
- var t = Model.getShapeById(v.parent);
- if (t) {
- Utils.removeFromArray(t.children, v.id);
- if (r.indexOf(v.parent) < 0) {
- r.push(v.parent);
- z.push(t)
- }
- }
- }
- var i = this.getShapeLinkers(v.id);
- if (i && i.length > 0) {
- for (var x = 0; x < i.length; x++) {
- var D = i[x];
- if (A.indexOf(D) < 0) {
- var B = this.getShapeById(D);
- if (B.from.id != null && B.from.id == v.id) {
- B.from.id = null;
- B.from.angle = null
- }
- if (B.to.id != null && B.to.id == v.id) {
- B.to.id = null;
- B.to.angle = null
- }
- if (r.indexOf(D) < 0) {
- r.push(D);
- z.push(B)
- }
- }
- }
- }
- delete this.linkerMap.map[v.id]
- }
- }
- this.build();
- MessageSource.beginBatch();
- MessageSource.send("remove", w);
- if (u) {
- var s = Designer.events.push("removed", {
- shapes: C,
- changedIds: r,
- range: q
- });
- if (s && s.length) {
- z = z.concat(s)
- }
- }
- if (z.length > 0) {
- this.updateMulti(z)
- }
- MessageSource.commit();
- return true
- },
- updatePage: function (f, h) {
- var e = $.extend(Model.define.page, f);
- var g = {
- page: Utils.copy(Model.persistence.page),
- update: Utils.copy(e)
- };
- Model.persistence.page = Utils.copy(e);
- MessageSource.send("updatePage", g);
- Designer.initialize.initCanvas()
- },
- updateLocalAttribute: function (e) {
- var c = $.extend(Model.define.localAttribute, e);
- var f = {
- localAttribute: Utils.copy(Model.persistence.localAttribute),
- update: Utils.copy(c)
- };
- Model.persistence.localAttribute = Utils.copy(c);
- MessageSource.send("updateLocalAttribute", f)
- },
- getShapeById: function (b) {
- return this.define.elements[b]
- },
- getPersistenceById: function (b) {
- return this.persistence.elements[b]
- },
- build: function () {
- this.orderList = [];
- this.linkerMap.empty();
- for (var h in Model.define.elements) {
- var g = Model.getShapeById(h);
- this.orderList.push({
- id: g.id,
- zindex: g.props.zindex
- });
- if (g.name == "linker") {
- if (g.from.id != null) {
- this.linkerMap.add(g.from.id, g.id)
- }
- if (g.to.id != null) {
- this.linkerMap.add(g.to.id, g.id)
- }
- }
- if (g.group) {
- this.groupMap.push(g.group, g.id)
- }
- }
- this.orderList.sort(function i(a, b) {
- return a.zindex - b.zindex;
- });
- for (var j = 0; j < Model.orderList.length; j++) {
- var h = Model.orderList[j].id;
- var g = Model.getShapeById(h);
- $("#" + h).css("z-index", j);
- }
- var f = 0;
- if (this.orderList.length > 0) {
- f = this.orderList[this.orderList.length - 1].zindex
- }
- this.maxZIndex = f
- },
- getShapeLinkers: function (b) {
- return this.linkerMap.map[b]
- },
- getGroupShapes: function (b) {
- return this.groupMap.map[b]
- },
- changeShape: function (e, f) {
- var d = Schema.shapes[f];
- e.name = f;
- e.title = d.shapeName;
- e.attribute = d.attribute;
- e.dataAttributes = d.dataAttributes;
- e.path = d.path;
- e.textBlock = d.textBlock;
- e.anchors = d.anchors;
- Schema.initShapeFunctions(e);
- Designer.painter.renderShape(e)
- }
-};
-var Utils = {
- getDomById: function (b) {
- return document.getElementById(b)
- },
- newId: function () {
- var c = Math.random();
- var d = (c + new Date().getTime());
- return d.toString(16).replace(".", "")
- },
- getShapeByPosition: function (V, W, ab) {
- var at = [];
- for (var x = Model.orderList.length - 1; x >= 0; x--) {
- var S = Model.orderList[x].id;
- var i = $("#" + S);
- var am = Model.getShapeById(S);
- var ak = i.position();
- var ac = V - ak.left;
- var ad = W - ak.top;
- var R = {
- x: ak.left,
- y: ak.top,
- w: i.width(),
- h: i.height()
- };
- var y = i.find(".shape_canvas")[0];
- var av = y.getContext("2d");
- var aB = this.pointInRect(V, W, R);
- if (am.name == "linker") {
- if (!aB) {
- continue
- }
- if (ab) {
- continue
- }
- var U = 10;
- U = U.toScale();
- var ae = {
- x: V - U,
- y: W - U,
- w: U * 2,
- h: U * 2
- };
- if (this.pointInRect(am.to.x.toScale(), am.to.y.toScale(), ae)) {
- var al = {
- type: "linker_point",
- point: "end",
- shape: am
- };
- at.push(al);
- } else {
- if (this.pointInRect(am.from.x.toScale(), am.from.y.toScale(), ae)) {
- var al = {
- type: "linker_point",
- point: "from",
- shape: am
- };
- at.push(al);
- } else {
- var aj = i.find(".text_canvas");
- var ah = aj.position();
- var ae = {
- x: ah.left,
- y: ah.top,
- w: aj.width(),
- h: aj.height()
- };
- if (this.pointInRect(ac, ad, ae)) {
- var al = {
- type: "linker_text",
- shape: am
- };
- at.push(al);
- continue
- }
- U = 7;
- U = U.toScale();
- var ag = this.pointInLinker({
- x: V.restoreScale(),
- y: W.restoreScale()
- },
- am, U);
- if (ag > -1) {
- var al = {
- type: "linker",
- shape: am,
- pointIndex: ag
- };
- at.push(al);
- }
- }
- }
- } else {
- if (aB && am.locked && !ab) {
- if (av.isPointInPath(ac, ad)) {
- var al = {
- type: "shape",
- shape: am
- };
- at.push(al)
- }
- continue
- }
- var U = 7;
- if (aB) {
- U = U.toScale();
- var ae = {
- x: V - U,
- y: W - U,
- w: U * 2,
- h: U * 2
- };
- var Z = {
- x: am.props.x + am.props.w / 2,
- y: am.props.y + am.props.h / 2
- };
- var ao = am.getAnchors();
- var al = null;
- for (var aw = 0; aw < ao.length; aw++) {
- var ay = ao[aw];
- ay = this.getRotated(Z, {
- x: am.props.x + ay.x,
- y: am.props.y + ay.y
- },
- am.props.angle);
- if (Utils.pointInRect(ay.x.toScale(), ay.y.toScale(), ae)) {
- var an = Utils.getPointAngle(S, ay.x, ay.y, U);
- ay.angle = an;
- al = {
- type: "bounding",
- shape: am,
- linkPoint: ay
- };
- if (av.isPointInPath(ac, ad)) {
- al.inPath = true
- }
- break
- }
- }
- if (al != null) {
- at.push(al);
- continue
- }
- }
- if (am.dataAttributes) {
- var al = null;
- for (var au = 0; au < am.dataAttributes.length; au++) {
- var ap = am.dataAttributes[au];
- if (ap.type == "link" && ap.showType && ap.showType != "none") {
- var af = i.children("#attr_canvas_" + ap.id);
- if (af.length > 0) {
- var ai = af.position();
- var X = ac - ai.left;
- var Y = ad - ai.top;
- var ar = af[0].getContext("2d");
- if (ar.isPointInPath(X, Y)) {
- al = {
- type: "dataAttribute",
- shape: am,
- attribute: ap
- };
- break
- }
- }
- }
- }
- if (al != null) {
- at.push(al);
- continue
- }
- }
- if (!aB) {
- continue
- }
- if (av.isPointInPath(ac, ad)) {
- if (ab) {
- var ao = am.getAnchors();
- if (ao && ao.length) {
- var al = {
- type: "shape",
- shape: am
- };
- at.push(al);
- } else {
- }
- } else {
- var al = {
- type: "shape",
- shape: am
- };
- at.push(al);
- }
- } else {
- if (!am.attribute || typeof am.attribute.linkable == "undefined" || am.attribute.linkable) {
- var an = Utils.getPointAngle(S, V.restoreScale(), W.restoreScale(), U);
- if (an != null) {
- var al = null;
- var aC = {
- angle: an
- };
- for (var aa = 1; aa <= U; aa++) {
- if (an == 0) {
- aC.x = ac + aa;
- aC.y = ad
- } else {
- if (an < Math.PI / 2) {
- aC.x = ac + aa * Math.cos(an);
- aC.y = ad + aa * Math.sin(an)
- } else {
- if (an == Math.PI / 2) {
- aC.x = ac;
- aC.y = ad + aa
- } else {
- if (an < Math.PI) {
- aC.x = ac - aa * Math.sin(an - Math.PI / 2);
- aC.y = ad + aa * Math.cos(an - Math.PI / 2)
- } else {
- if (an == Math.PI / 2) {
- aC.x = ac - aa;
- aC.y = ad
- } else {
- if (an < Math.PI / 2 * 3) {
- aC.x = ac - aa * Math.cos(an - Math.PI);
- aC.y = ad - aa * Math.sin(an - Math.PI)
- } else {
- if (an == Math.PI / 2 * 3) {
- aC.x = ac;
- aC.y = ad - aa
- } else {
- aC.x = ac + aa * Math.sin(an - Math.PI / 2 * 3);
- aC.y = ad - aa * Math.cos(an - Math.PI / 2 * 3)
- }
- }
- }
- }
- }
- }
- }
- if (av.isPointInPath(aC.x, aC.y)) {
- aC.x += ak.left;
- aC.y += ak.top;
- aC.x = aC.x.restoreScale();
- aC.y = aC.y.restoreScale();
- al = {
- type: "bounding",
- shape: am,
- linkPoint: aC
- };
- break
- }
- }
- if (al != null) {
- at.push(al);
- }
- }
- }
- }
- }
- }
- var al = null;
- if (at.length == 1) {
- al = at[0]
- }
- if (at.length > 1 && ab) {
- al = at[0]
- } else {
- if (at.length > 1) {
- var ax = at[0];
- if (ax.type == "bounding" && ax.type != "linker_point" && ax.type != "linker") {
- return ax
- }
- var ag = [];
- var aA = [];
- var aq = [];
- for (var x = 0; x < at.length; x++) {
- var T = at[x];
- if (T.type == "bounding") {
- aq.push(T)
- } else {
- if (T.type == "linker") {
- ag.push(T)
- } else {
- if (T.type == "linker_point") {
- aA.push(T)
- }
- }
- }
- }
- if (aq.length > 0 && aA.length > 0) {
- for (var x = 0; x < aq.length; x++) {
- var T = aq[x];
- if (T.inPath) {
- al = T;
- break
- }
- }
- }
- if (al == null && aA.length > 0) {
- aA.sort(function az(a, b) {
- if (Utils.isSelected(a.shape.id) && !Utils.isSelected(b.shape.id)) {
- return -1
- } else {
- if (!Utils.isSelected(a.shape.id) && Utils.isSelected(b.shape.id)) {
- return 1
- } else {
- return b.shape.props.zindex - a.shape.props.zindex
- }
- }
- });
- al = aA[0]
- }
- if (al == null && ag.length > 0) {
- ag.sort(function az(a, b) {
- if (Utils.isSelected(a.shape.id) && !Utils.isSelected(b.shape.id)) {
- return -1
- } else {
- if (!Utils.isSelected(a.shape.id) && Utils.isSelected(b.shape.id)) {
- return 1
- } else {
- return b.shape.props.zindex - a.shape.props.zindex
- }
- }
- });
- al = ag[0]
- }
- if (al == null) {
- al = at[0]
- }
- }
- }
- return al
- },
- checkCross: function (k, m, n, o) {
- var j = false;
- var l = (m.x - k.x) * (o.y - n.y) - (m.y - k.y) * (o.x - n.x);
- if (l != 0) {
- var p = ((k.y - n.y) * (o.x - n.x) - (k.x - n.x) * (o.y - n.y)) / l;
- var d = ((k.y - n.y) * (m.x - k.x) - (k.x - n.x) * (m.y - k.y)) / l;
- if ((p >= 0) && (p <= 1) && (d >= 0) && (d <= 1)) {
- j = true
- }
- }
- return j
- },
- rectCross: function (m, n) {
- var q = m.x;
- var o = m.x + m.w;
- var k = m.y;
- var s = m.y + m.h;
- var r = n.x;
- var p = n.x + n.w;
- var l = n.y;
- var t = n.y + n.h;
- if (((q < p) && (r < o)) && ((k < t) && (l < s))) {
- return true
- } else {
- return false
- }
- },
- rectInRect: function (l, h) {
- var i = {
- x: l.x,
- y: l.y
- };
- var j = {
- x: l.x + l.w,
- y: l.y
- };
- var k = {
- x: l.x + l.w,
- y: l.y + l.h
- };
- var g = {
- x: l.x,
- y: l.y + l.h
- };
- if (this.pointInRect(i.x, i.y, h) && this.pointInRect(j.x, j.y, h) && this.pointInRect(k.x, k.y, h) && this.pointInRect(g.x, g.y, h)) {
- return true
- } else {
- return false
- }
- },
- pointInPolygon: function (j, p) {
- var k, l, m, n;
- k = j;
- l = {
- x: -1000000,
- y: j.y
- };
- var o = 0;
- for (var i = 0; i < p.length - 1; i++) {
- m = p[i];
- n = p[i + 1];
- if (Utils.checkCross(k, l, m, n) == true) {
- o++
- }
- }
- m = p[p.length - 1];
- n = p[0];
- if (Utils.checkCross(k, l, m, n) == true) {
- o++
- }
- return (o % 2 == 0) ? false : true
- },
- pointInRect: function (d, e, f) {
- if (d >= f.x && d <= f.x + f.w && e >= f.y && e <= f.y + f.h) {
- return true
- }
- return false
- },
- pointInLinker: function (q, t, s) {
- var o = this.getLinkerLinePoints(t);
- var v = {
- x: q.x - s,
- y: q.y
- };
- var w = {
- x: q.x + s,
- y: q.y
- };
- var x = {
- x: q.x,
- y: q.y - s
- };
- var m = {
- x: q.x,
- y: q.y + s
- };
- for (var u = 1; u < o.length; u++) {
- var n = o[u - 1];
- var p = o[u];
- var r = this.checkCross(v, w, n, p);
- if (r) {
- return u
- }
- r = this.checkCross(x, m, n, p);
- if (r) {
- return u
- }
- }
- return -1
- },
- getLinkerLength: function (n) {
- var d = this.getLinkerLinePoints(n);
- var i = 0;
- for (var l = 1; l < d.length; l++) {
- var j = d[l - 1];
- var m = d[l];
- var k = Utils.measureDistance(j, m);
- i += k
- }
- return i
- },
- getShapesByRange: function (j) {
- var g = [];
- for (var h in Model.define.elements) {
- var f = Model.getShapeById(h);
- var i = f.props;
- if (f.name == "linker") {
- i = this.getLinkerBox(f)
- } else {
- i = this.getShapeBox(f)
- }
- if (this.pointInRect(i.x, i.y, j) && this.pointInRect(i.x + i.w, i.y, j) && this.pointInRect(i.x + i.w, i.y + i.h, j) && this.pointInRect(i.x, i.y + i.h, j)) {
- g.push(f.id)
- }
- }
- return g
- },
- getControlBox: function (l) {
- var j = {
- x1: null,
- y1: null,
- x2: null,
- y2: null
- };
- for (var h = 0; h < l.length; h++) {
- var k = l[h];
- var i = Model.getShapeById(k);
- var m;
- if (i.name == "linker") {
- m = this.getLinkerBox(i)
- } else {
- m = this.getShapeBox(i)
- }
- if (j.x1 == null || m.x < j.x1) {
- j.x1 = m.x
- }
- if (j.y1 == null || m.y < j.y1) {
- j.y1 = m.y
- }
- if (j.x2 == null || m.x + m.w > j.x2) {
- j.x2 = m.x + m.w
- }
- if (j.y2 == null || m.y + m.h > j.y2) {
- j.y2 = m.y + m.h
- }
- }
- var n = {
- x: j.x1,
- y: j.y1,
- w: j.x2 - j.x1,
- h: j.y2 - j.y1
- };
- return n
- },
- getShapesBounding: function (h) {
- var i = {
- x1: null,
- y1: null,
- x2: null,
- y2: null
- };
- for (var l = 0; l < h.length; l++) {
- var g = h[l];
- var k;
- if (g.name == "linker") {
- k = this.getLinkerBox(g)
- } else {
- k = g.props
- }
- if (i.x1 == null || k.x < i.x1) {
- i.x1 = k.x
- }
- if (i.y1 == null || k.y < i.y1) {
- i.y1 = k.y
- }
- if (i.x2 == null || k.x + k.w > i.x2) {
- i.x2 = k.x + k.w
- }
- if (i.y2 == null || k.y + k.h > i.y2) {
- i.y2 = k.y + k.h
- }
- }
- var j = {
- x: i.x1,
- y: i.y1,
- w: i.x2 - i.x1,
- h: i.y2 - i.y1
- };
- return j
- },
- getShapeContext: function (c) {
- var d = Utils.getDomById(c);
- return d.getElementsByTagName("canvas")[0].getContext("2d")
- },
- selectIds: [],
- selectShape: function (s, w) {
- if (typeof s == "string") {
- var o = s;
- s = [];
- s.push(o)
- }
- if (s.length <= 0) {
- return
- }
- var r = Utils.mergeArray([], s);
- for (var u = 0; u < s.length; u++) {
- var p = Model.getShapeById(s[u]);
- if (p && p.group) {
- var x = Model.getGroupShapes(p.group);
- Utils.mergeArray(r, x)
- }
- }
- var z = [];
- for (var u = 0; u < r.length; u++) {
- var y = r[u];
- var p = Model.getShapeById(y);
- if (p && p.parent && p.resizeDir.length == 0 && z.indexOf(p.parent) < 0) {
- z.push(p.parent)
- } else {
- if (z.indexOf(y) < 0) {
- z.push(y)
- }
- }
- }
- s = z;
- Utils.removeAnchors();
- Utils.selectIds = [];
- for (var q = 0; q < s.length; q++) {
- var o = s[q];
- var p = Model.getShapeById(o);
- Utils.selectIds.push(o);
- if (p && p.name == "linker") {
- if (this.isLocked(p.id)) {
- Utils.showLockers(p)
- } else {
- Designer.painter.renderLinker(p)
- }
- } else {
- if (p && this.isLocked(p.id)) {
- Utils.showLockers(p)
- } else {
- //by bzp 处理富文本显示的按钮
- if (p.name == "regulation" && methodId == 'control.policy') {
- parent.$("#dock_btn_richtext").show();
- }
- //by bzp end
- Utils.showAnchors(p)
- }
- }
- }
- var z = Utils.getSelectedIds();
- var i = false;
- if (z.length == 1) {
- var t = Model.getShapeById(z[0]);
- if (t.name == "linker") {
- i = true;
- Utils.showLinkerControls()
- }
- }
- if (z.length > 0 && !i) {
- var v = Designer.painter.drawControls(z)
- }
- if (typeof w == "undefined") {
- w = true
- }
- if (this.selectCallback && w) {
- this.selectCallback()
- }
- Designer.events.push("selectChanged");
- this.showLinkerCursor()
- },
- selectCallback: null,
- unselect: function () {
- var h = this.selectIds;
- this.selectIds = [];
- for (var e = 0; e < h.length; e++) {
- var g = h[e];
- var f = Model.getShapeById(g);
- if (f.name == "linker") {
- Designer.painter.renderLinker(f)
- }
- }
- $("#shape_controls").hide();
- Utils.removeLockers();
- Utils.removeAnchors();
- if ($("#dock_content_attribute").is(":visible")) {
- $("#tagContent1 :focus").blur()
- }
- Designer.events.push("selectChanged");
- this.hideLinkerCursor();
- this.hideLinkerControls()
- },
- getSelected: function () {
- var f = [];
- for (var e = 0; e < this.selectIds.length; e++) {
- var g = this.selectIds[e];
- if (!Utils.isLocked(g)) {
- var h = Model.getShapeById(g);
- f.push(h)
- }
- }
- return f
- },
- getSelectedIds: function () {
- var e = [];
- for (var d = 0; d < this.selectIds.length; d++) {
- var f = this.selectIds[d];
- if (!Utils.isLocked(f)) {
- e.push(f)
- }
- }
- return e
- },
- getSelectedLinkers: function () {
- var f = [];
- for (var e = 0; e < this.selectIds.length; e++) {
- var g = this.selectIds[e];
- if (!Utils.isLocked(g)) {
- var h = Model.getShapeById(g);
- if (h.name == "linker") {
- f.push(h)
- }
- }
- }
- return f
- },
- getSelectedLinkerIds: function () {
- var f = [];
- for (var e = 0; e < this.selectIds.length; e++) {
- var g = this.selectIds[e];
- if (!Utils.isLocked(g)) {
- var h = Model.getShapeById(g);
- if (h.name == "linker") {
- f.push(g)
- }
- }
- }
- return f
- },
- getSelectedShapeIds: function () {
- var f = [];
- for (var e = 0; e < this.selectIds.length; e++) {
- var g = this.selectIds[e];
- if (!Utils.isLocked(g)) {
- var h = Model.getShapeById(g);
- if (h.name != "linker") {
- f.push(g)
- }
- }
- }
- return f
- },
- getSelectedLockedIds: function () {
- var e = [];
- for (var d = 0; d < this.selectIds.length; d++) {
- var f = this.selectIds[d];
- if (Utils.isLocked(f)) {
- e.push(f)
- }
- }
- return e
- },
- getSelectedGroups: function () {
- var f = [];
- for (var h = 0; h < this.selectIds.length; h++) {
- var g = this.selectIds[h];
- var e = Model.getShapeById(g);
- if (e.group && f.indexOf(e.group) < 0) {
- f.push(e.group)
- }
- }
- return f
- },
- isSelected: function (b) {
- if (this.selectIds.indexOf(b) >= 0 && !this.isLocked(b)) {
- return true
- }
- return false
- },
- isLocked: function (b) {
- if (Model.getShapeById(b).locked) {
- return true
- } else {
- return false
- }
- },
- linkerCursorTimer: null,
- showLinkerCursor: function () {
- this.hideLinkerCursor();
- var C = Utils.getSelectedIds();
- if (C.length == 1) {
- var J = Model.getShapeById(C[0]);
- if (J.name != "linker") {
- var H = Model.linkerMap.map[J.id];
- if (H && H.length) {
- var B = [];
- for (var z = 0; z < H.length; z++) {
- var d = H[z];
- var E = Model.getShapeById(d);
- if (J.id != E.from.id || !E.to.id) {
- continue
- }
- var y = this.getLinkerLength(E).toScale();
- var A = [];
- if (E.linkerType == "broken") {
- A.push({
- x: E.from.x.toScale(),
- y: E.from.y.toScale(),
- t: 0
- });
- for (var p = 0; p < E.points.length; p++) {
- var D = E.points[p];
- A.push({
- x: D.x.toScale(),
- y: D.y.toScale()
- })
- }
- A.push({
- x: E.to.x.toScale(),
- y: E.to.y.toScale()
- });
- var w = 0;
- for (var p = 1; p < A.length; p++) {
- var K = A[p - 1];
- var L = A[p];
- w += Utils.measureDistance(K, L);
- L.t = w / y
- }
- }
- var F = Math.floor(y / 120) + 1;
- var I = 3 / y;
- var i = (Math.ceil(y / 120) * 120) / y;
- var x = 0;
- while (x < y) {
- var G = {
- t: x / y,
- step: I,
- linker: E,
- points: A,
- maxT: i
- };
- B.push(G);
- x += 120
- }
- }
- this.playLinkerCursor(B)
- }
- }
- }
- },
- playLinkerCursor: function (l) {
- for (var h = 0; h < l.length; h++) {
- var j = l[h];
- var k = $("").appendTo("#designer_canvas");
- var m = j.linker;
- var i = (m.lineStyle.lineWidth + 2).toScale();
- if (i < 5) {
- i = 5
- }
- var n = i / 2;
- j.half = n;
- j.dom = k;
- k.css({
- width: i,
- height: i,
- "-webkit-border-radius": n,
- "-moz-border-radius": n,
- "-ms-border-radius": n,
- "-o-border-radius": n,
- "border-radius": n,
- "z-index": $("#" + m.id).css("z-index")
- })
- }
- this.linkerCursorTimer = setInterval(function () {
- for (var w = 0; w < l.length; w++) {
- var c = l[w];
- var t = c.linker;
- if (c.t >= c.maxT) {
- c.t = 0;
- c.dom.show()
- }
- var y = c.t;
- if (t.linkerType == "broken") {
- for (var v = 1; v < c.points.length; v++) {
- var b = c.points[v - 1];
- var d = c.points[v];
- if (y >= b.t && y < d.t) {
- var x = (y - b.t) / (d.t - b.t);
- var f = (1 - x) * b.x + x * d.x;
- var g = (1 - x) * b.y + x * d.y;
- c.dom.css({
- left: f - c.half,
- top: g - c.half
- });
- break
- }
- }
- } else {
- if (t.linkerType == "curve") {
- var a = t.from;
- var b = t.points[0];
- var d = t.points[1];
- var e = t.to;
- var f = a.x.toScale() * Math.pow((1 - y), 3) + b.x.toScale() * y * Math.pow((1 - y), 2) * 3 + d.x.toScale() * Math.pow(y, 2) * (1 - y) * 3 + e.x.toScale() * Math.pow(y, 3);
- var g = a.y.toScale() * Math.pow((1 - y), 3) + b.y.toScale() * y * Math.pow((1 - y), 2) * 3 + d.y.toScale() * Math.pow(y, 2) * (1 - y) * 3 + e.y.toScale() * Math.pow(y, 3);
- c.dom.css({
- left: f - c.half,
- top: g - c.half
- })
- } else {
- var f = (1 - y) * t.from.x.toScale() + y * t.to.x.toScale();
- var g = (1 - y) * t.from.y.toScale() + y * t.to.y.toScale();
- c.dom.css({
- left: f - c.half,
- top: g - c.half
- })
- }
- }
- c.t += c.step;
- if (c.t >= 1) {
- c.dom.hide()
- }
- }
- },
- 30)
- },
- hideLinkerCursor: function () {
- if (this.linkerCursorTimer) {
- clearInterval(this.linkerCursorTimer)
- }
- $(".linker_cursor").remove()
- },
- showLinkerControls: function () {
- this.hideLinkerControls();
- var e = Utils.getSelectedIds();
- var h = null;
- if (e.length == 1) {
- var f = Model.getShapeById(e[0]);
- if (f.name == "linker" && f.linkerType == "curve") {
- h = f
- }
- }
- if (h == null) {
- return
- }
-
- function g(r, s) {
- var t = null;
- var b = null;
- if (s == "from") {
- t = r.from;
- b = r.points[0]
- } else {
- t = r.to;
- b = r.points[1]
- }
- var q = Utils.measureDistance(t, b).toScale() - 6;
- var c = {
- x: (0.5 * t.x + 0.5 * b.x).toScale(),
- y: (0.5 * t.y + 0.5 * b.y).toScale()
- };
- var u = Utils.getAngle(t, b) + Math.PI / 2;
- var a = $("").appendTo("#designer_canvas");
- var d = $("").appendTo("#designer_canvas");
- var v = Math.round(u / (Math.PI * 2) * 360);
- var p = "rotate(" + v + "deg)";
- a.css({
- left: c.x,
- top: c.y - q / 2,
- height: q,
- "z-index": Model.orderList.length,
- "-webkit-transform": p,
- "-ms-transform": p,
- "-o-transform": p,
- "-moz-transform": p,
- transform: p
- });
- d.css({
- left: b.x.toScale() - 4,
- top: b.y.toScale() - 4,
- "z-index": Model.orderList.length
- });
- d.attr("ty", s);
- d.unbind().bind("mousedown",
- function (j) {
- r = Model.getShapeById(r.id);
- var i = null;
- if (s == "from") {
- i = r.points[0]
- } else {
- i = r.points[1]
- }
- j.stopPropagation();
- d.addClass("moving");
- Designer.op.changeState("changing_curve");
- $(document).bind("mousemove.change_curve",
- function (l) {
- var k = Utils.getRelativePos(l.pageX, l.pageY, $("#designer_canvas"));
- i.x = k.x;
- i.y = k.y;
- Designer.painter.renderLinker(r);
- Model.define.elements[r.id] = r;
- Utils.showLinkerControls();
- $(".linker_control_point[ty=" + d.attr("ty") + "]").addClass("moving");
- $(document).unbind("mouseup.changed_curve").bind("mouseup.changed_curve",
- function (m) {
- Model.update(r);
- $(document).unbind("mouseup.changed_curve")
- })
- });
- $(document).unbind("mouseup.change_curve").bind("mouseup.change_curve",
- function (k) {
- $(document).unbind("mouseup.change_curve");
- $(document).unbind("mousemove.change_curve");
- $(".linker_control_point").removeClass("moving");
- Designer.op.resetState()
- })
- });
- return d
- }
-
- g(h, "from");
- g(h, "to")
- },
- hideLinkerControls: function () {
- $(".linker_control_line").remove();
- $(".linker_control_point").remove()
- },
- showAnchors: function (n) {
- if ($(".shape_contour[forshape=" + n.id + "]").length > 0) {
- return
- }
- var q = $("").appendTo($("#designer_canvas"));
- q.css({
- left: n.props.x.toScale(),
- top: n.props.y.toScale(),
- "z-index": Model.orderList.length + 1
- });
- if (!Utils.isSelected(n.id)) {
- q.addClass("hovered_contour")
- }
- var t = Designer.config.anchorSize - 2;
- var u = {
- "border-color": Designer.config.anchorColor,
- "border-radius": Designer.config.anchorSize / 2,
- width: t,
- height: t
- };
- var v = n.getAnchors();
- var o = {
- x: n.props.w / 2,
- y: n.props.h / 2
- };
- var r = n.props.angle;
- for (var m = 0; m < v.length; m++) {
- var p = v[m];
- var l = $("").appendTo(q);
- var s = this.getRotated(o, p, r);
- u.left = s.x.toScale() - Designer.config.anchorSize / 2;
- u.top = s.y.toScale() - Designer.config.anchorSize / 2;
- l.css(u)
- }
- },
- hideAnchors: function () {
- $(".hovered_contour").remove()
- },
- removeAnchors: function () {
- //by bzp
- $("#dock_btn_richtext").hide();
- $(".shape_contour").remove()
- },
- showLockers: function (s) {
- var m = $("#" + s.id);
- var q = m.position();
-
- function t() {
- var c = $("").appendTo(m);
- var a = c[0].getContext("2d");
- a.strokeStyle = "#777";
- a.lineWidth = 1;
- var b = 9;
- a.beginPath();
- a.moveTo(2, 2);
- a.lineTo(b, b);
- a.moveTo(2, b);
- a.lineTo(b, 2);
- a.stroke();
- return c
- }
-
- function r(b) {
- var a = t();
- a.css({
- left: b.x.toScale() - q.left - 5,
- top: b.y.toScale() - q.top - 5
- })
- }
-
- if (s.name != "linker") {
- var u = s.props;
- var v = {
- x: u.x + u.w / 2,
- y: u.y + u.h / 2
- };
- var l = this.getRotated(v, {
- x: u.x,
- y: u.y
- },
- s.props.angle);
- r(l);
- var n = this.getRotated(v, {
- x: u.x + u.w,
- y: u.y
- },
- s.props.angle);
- r(n);
- var o = this.getRotated(v, {
- x: u.x + u.w,
- y: u.y + u.h
- },
- s.props.angle);
- r(o);
- var p = this.getRotated(v, {
- x: u.x,
- y: u.y + u.h
- },
- s.props.angle);
- r(p)
- } else {
- r(s.from);
- r(s.to)
- }
- },
- removeLockers: function () {
- $(".shape_locker").remove()
- },
- measureDistance: function (g, h) {
- var e = h.y - g.y;
- var f = h.x - g.x;
- return Math.sqrt(Math.pow(e, 2) + Math.pow(f, 2))
- },
- removeFromArray: function (f, d) {
- var e = f.indexOf(d);
- if (e >= 0) {
- f.splice(e, 1)
- }
- return f
- },
- addToArray: function (f, d) {
- var e = f.indexOf(d);
- if (e < 0) {
- f.push(d)
- }
- return f
- },
- mergeArray: function (e, f) {
- for (var h = 0; h < f.length; h++) {
- var g = f[h];
- if (e.indexOf(g) < 0) {
- e.push(g)
- }
- }
- return e
- },
- getCirclePoints: function (j, k, n) {
- var l = Math.PI / 18;
- var o = [];
- for (var p = 0; p < 36; p++) {
- var i = l * p;
- var m = {
- x: j - Math.cos(i) * n,
- y: k - Math.sin(i) * n,
- angle: i
- };
- o.push(m)
- }
- return o
- },
- getPointAngle: function (r, i, p, F) {
- var x = $("#" + r).position();
- var y = Utils.getShapeContext(r);
- i = i.toScale() - x.left;
- p = p.toScale() - x.top;
- var E = this.getCirclePoints(i, p, F);
- var u = E.length;
- var G = false;
- for (var w = 0; w < u; w++) {
- var D = E[w];
- if (y.isPointInPath(D.x, D.y)) {
- D.inPath = true;
- G = true
- } else {
- D.inPath = false
- }
- }
- if (G == false) {
- return null
- }
- var C = null;
- var z = null;
- for (var w = 0; w < u; w++) {
- var D = E[w];
- if (!D.inPath) {
- if (C == null) {
- var A = E[(w - 1 + u) % u];
- if (A.inPath) {
- C = D.angle
- }
- }
- if (z == null) {
- var v = E[(w + 1 + u) % u];
- if (v.inPath) {
- z = D.angle
- }
- }
- if (C != null && z != null) {
- break
- }
- }
- }
- var H = (Math.PI * 2 + z - C) % (Math.PI * 2) / 2;
- var B = (C + H) % (Math.PI * 2);
- return B
- },
- getAngleDir: function (c) {
- var d = Math.PI;
- if (c >= d / 4 && c < d / 4 * 3) {
- return 1
- } else {
- if (c >= d / 4 * 3 && c < d / 4 * 5) {
- return 2
- } else {
- if (c >= d / 4 * 5 && c < d / 4 * 7) {
- return 3
- } else {
- return 4
- }
- }
- }
- },
- getLinkerPoints: function (G) {
- var O = [];
- if (G.linkerType == "broken") {
- var J = Math.PI;
- var y = G.from;
- var aa = G.to;
- var R = Math.abs(aa.x - y.x);
- var I = Math.abs(aa.y - y.y);
- var K = 30;
- if (y.id != null && aa.id != null) {
- var ab = this.getAngleDir(y.angle);
- var ac = this.getAngleDir(aa.angle);
- var X, V, S;
- if (ab == 1 && ac == 1) {
- if (y.y < aa.y) {
- X = y;
- V = aa;
- S = false
- } else {
- X = aa;
- V = y;
- S = true
- }
- var W = Model.getShapeById(X.id).props;
- var E = Model.getShapeById(V.id).props;
- if (V.x >= W.x - K && V.x <= W.x + W.w + K) {
- var P;
- if (V.x < W.x + W.w / 2) {
- P = W.x - K
- } else {
- P = W.x + W.w + K
- }
- var Q = X.y - K;
- O.push({
- x: X.x,
- y: Q
- });
- O.push({
- x: P,
- y: Q
- });
- Q = V.y - K;
- O.push({
- x: P,
- y: Q
- });
- O.push({
- x: V.x,
- y: Q
- })
- } else {
- var Q = X.y - K;
- O.push({
- x: X.x,
- y: Q
- });
- O.push({
- x: V.x,
- y: Q
- })
- }
- } else {
- if (ab == 3 && ac == 3) {
- if (y.y > aa.y) {
- X = y;
- V = aa;
- S = false
- } else {
- X = aa;
- V = y;
- S = true
- }
- var W = Model.getShapeById(X.id).props;
- var E = Model.getShapeById(V.id).props;
- if (V.x >= W.x - K && V.x <= W.x + W.w + K) {
- var Q = X.y + K;
- var P;
- if (V.x < W.x + W.w / 2) {
- P = W.x - K
- } else {
- P = W.x + W.w + K
- }
- O.push({
- x: X.x,
- y: Q
- });
- O.push({
- x: P,
- y: Q
- });
- Q = V.y + K;
- O.push({
- x: P,
- y: Q
- });
- O.push({
- x: V.x,
- y: Q
- })
- } else {
- var Q = X.y + K;
- O.push({
- x: X.x,
- y: Q
- });
- O.push({
- x: V.x,
- y: Q
- })
- }
- } else {
- if (ab == 2 && ac == 2) {
- if (y.x > aa.x) {
- X = y;
- V = aa;
- S = false
- } else {
- X = aa;
- V = y;
- S = true
- }
- var W = Model.getShapeById(X.id).props;
- var E = Model.getShapeById(V.id).props;
- if (V.y >= W.y - K && V.y <= W.y + W.h + K) {
- var P = X.x + K;
- var Q;
- if (V.y < W.y + W.h / 2) {
- Q = W.y - K
- } else {
- Q = W.y + W.h + K
- }
- O.push({
- x: P,
- y: X.y
- });
- O.push({
- x: P,
- y: Q
- });
- P = V.x + K;
- O.push({
- x: P,
- y: Q
- });
- O.push({
- x: P,
- y: V.y
- })
- } else {
- var P = X.x + K;
- O.push({
- x: P,
- y: X.y
- });
- O.push({
- x: P,
- y: V.y
- })
- }
- } else {
- if (ab == 4 && ac == 4) {
- if (y.x < aa.x) {
- X = y;
- V = aa;
- S = false
- } else {
- X = aa;
- V = y;
- S = true
- }
- var W = Model.getShapeById(X.id).props;
- var E = Model.getShapeById(V.id).props;
- if (V.y >= W.y - K && V.y <= W.y + W.h + K) {
- var P = X.x - K;
- var Q;
- if (V.y < W.y + W.h / 2) {
- Q = W.y - K
- } else {
- Q = W.y + W.h + K
- }
- O.push({
- x: P,
- y: X.y
- });
- O.push({
- x: P,
- y: Q
- });
- P = V.x - K;
- O.push({
- x: P,
- y: Q
- });
- O.push({
- x: P,
- y: V.y
- })
- } else {
- var P = X.x - K;
- O.push({
- x: P,
- y: X.y
- });
- O.push({
- x: P,
- y: V.y
- })
- }
- } else {
- if ((ab == 1 && ac == 3) || (ab == 3 && ac == 1)) {
- if (ab == 1) {
- X = y;
- V = aa;
- S = false
- } else {
- X = aa;
- V = y;
- S = true
- }
- var W = Model.getShapeById(X.id).props;
- var E = Model.getShapeById(V.id).props;
- if (V.y <= X.y) {
- var Q = X.y - I / 2;
- O.push({
- x: X.x,
- y: Q
- });
- O.push({
- x: V.x,
- y: Q
- })
- } else {
- var ad = W.x + W.w;
- var U = E.x + E.w;
- var Q = X.y - K;
- var P;
- if (U >= W.x && E.x <= ad) {
- var x = W.x + W.w / 2;
- if (V.x < x) {
- P = W.x < E.x ? W.x - K : E.x - K
- } else {
- P = ad > U ? ad + K : U + K
- }
- if (E.y < X.y) {
- Q = E.y - K
- }
- } else {
- if (V.x < X.x) {
- P = U + (W.x - U) / 2
- } else {
- P = ad + (E.x - ad) / 2
- }
- }
- O.push({
- x: X.x,
- y: Q
- });
- O.push({
- x: P,
- y: Q
- });
- Q = V.y + K;
- O.push({
- x: P,
- y: Q
- });
- O.push({
- x: V.x,
- y: Q
- })
- }
- } else {
- if ((ab == 2 && ac == 4) || (ab == 4 && ac == 2)) {
- if (ab == 2) {
- X = y;
- V = aa;
- S = false
- } else {
- X = aa;
- V = y;
- S = true
- }
- var W = Model.getShapeById(X.id).props;
- var E = Model.getShapeById(V.id).props;
- if (V.x > X.x) {
- var P = X.x + R / 2;
- O.push({
- x: P,
- y: X.y
- });
- O.push({
- x: P,
- y: V.y
- })
- } else {
- var F = W.y + W.h;
- var N = E.y + E.h;
- var P = X.x + K;
- var Q;
- if (N >= W.y && E.y <= F) {
- var x = W.y + W.h / 2;
- if (V.y < x) {
- Q = W.y < E.y ? W.y - K : E.y - K
- } else {
- Q = F > N ? F + K : N + K
- }
- if (E.x + E.w > X.x) {
- P = E.x + E.w + K
- }
- } else {
- if (V.y < X.y) {
- Q = N + (W.y - N) / 2
- } else {
- Q = F + (E.y - F) / 2
- }
- }
- O.push({
- x: P,
- y: X.y
- });
- O.push({
- x: P,
- y: Q
- });
- P = V.x - K;
- O.push({
- x: P,
- y: Q
- });
- O.push({
- x: P,
- y: V.y
- })
- }
- } else {
- if ((ab == 1 && ac == 2) || (ab == 2 && ac == 1)) {
- if (ab == 2) {
- X = y;
- V = aa;
- S = false
- } else {
- X = aa;
- V = y;
- S = true
- }
- var W = Model.getShapeById(X.id).props;
- var E = Model.getShapeById(V.id).props;
- if (V.x > X.x && V.y > X.y) {
- O.push({
- x: V.x,
- y: X.y
- })
- } else {
- if (V.x > X.x && E.x > X.x) {
- var P;
- if (E.x - X.x < K * 2) {
- P = X.x + (E.x - X.x) / 2
- } else {
- P = X.x + K
- }
- var Q = V.y - K;
- O.push({
- x: P,
- y: X.y
- });
- O.push({
- x: P,
- y: Q
- });
- O.push({
- x: V.x,
- y: Q
- })
- } else {
- if (V.x <= X.x && V.y > W.y + W.h) {
- var F = W.y + W.h;
- var P = X.x + K;
- var Q;
- if (V.y - F < K * 2) {
- Q = F + (V.y - F) / 2
- } else {
- Q = V.y - K
- }
- O.push({
- x: P,
- y: X.y
- });
- O.push({
- x: P,
- y: Q
- });
- O.push({
- x: V.x,
- y: Q
- })
- } else {
- var P;
- var U = E.x + E.w;
- if (U > X.x) {
- P = U + K
- } else {
- P = X.x + K
- }
- var Q;
- if (V.y < W.y) {
- Q = V.y - K
- } else {
- Q = W.y - K
- }
- O.push({
- x: P,
- y: X.y
- });
- O.push({
- x: P,
- y: Q
- });
- O.push({
- x: V.x,
- y: Q
- })
- }
- }
- }
- } else {
- if ((ab == 1 && ac == 4) || (ab == 4 && ac == 1)) {
- if (ab == 4) {
- X = y;
- V = aa;
- S = false
- } else {
- X = aa;
- V = y;
- S = true
- }
- var W = Model.getShapeById(X.id).props;
- var E = Model.getShapeById(V.id).props;
- var U = E.x + E.w;
- if (V.x < X.x && V.y > X.y) {
- O.push({
- x: V.x,
- y: X.y
- })
- } else {
- if (V.x < X.x && U < X.x) {
- var P;
- if (X.x - U < K * 2) {
- P = U + (X.x - U) / 2
- } else {
- P = X.x - K
- }
- var Q = V.y - K;
- O.push({
- x: P,
- y: X.y
- });
- O.push({
- x: P,
- y: Q
- });
- O.push({
- x: V.x,
- y: Q
- })
- } else {
- if (V.x >= X.x && V.y > W.y + W.h) {
- var F = W.y + W.h;
- var P = X.x - K;
- var Q;
- if (V.y - F < K * 2) {
- Q = F + (V.y - F) / 2
- } else {
- Q = V.y - K
- }
- O.push({
- x: P,
- y: X.y
- });
- O.push({
- x: P,
- y: Q
- });
- O.push({
- x: V.x,
- y: Q
- })
- } else {
- var P;
- if (E.x < X.x) {
- P = E.x - K
- } else {
- P = X.x - K
- }
- var Q;
- if (V.y < W.y) {
- Q = V.y - K
- } else {
- Q = W.y - K
- }
- O.push({
- x: P,
- y: X.y
- });
- O.push({
- x: P,
- y: Q
- });
- O.push({
- x: V.x,
- y: Q
- })
- }
- }
- }
- } else {
- if ((ab == 2 && ac == 3) || (ab == 3 && ac == 2)) {
- if (ab == 2) {
- X = y;
- V = aa;
- S = false
- } else {
- X = aa;
- V = y;
- S = true
- }
- var W = Model.getShapeById(X.id).props;
- var E = Model.getShapeById(V.id).props;
- if (V.x > X.x && V.y < X.y) {
- O.push({
- x: V.x,
- y: X.y
- })
- } else {
- if (V.x > X.x && E.x > X.x) {
- var P;
- if (E.x - X.x < K * 2) {
- P = X.x + (E.x - X.x) / 2
- } else {
- P = X.x + K
- }
- var Q = V.y + K;
- O.push({
- x: P,
- y: X.y
- });
- O.push({
- x: P,
- y: Q
- });
- O.push({
- x: V.x,
- y: Q
- })
- } else {
- if (V.x <= X.x && V.y < W.y) {
- var P = X.x + K;
- var Q;
- if (W.y - V.y < K * 2) {
- Q = V.y + (W.y - V.y) / 2
- } else {
- Q = V.y + K
- }
- O.push({
- x: P,
- y: X.y
- });
- O.push({
- x: P,
- y: Q
- });
- O.push({
- x: V.x,
- y: Q
- })
- } else {
- var P;
- var U = E.x + E.w;
- if (U > X.x) {
- P = U + K
- } else {
- P = X.x + K
- }
- var Q;
- if (V.y > W.y + W.h) {
- Q = V.y + K
- } else {
- Q = W.y + W.h + K
- }
- O.push({
- x: P,
- y: X.y
- });
- O.push({
- x: P,
- y: Q
- });
- O.push({
- x: V.x,
- y: Q
- })
- }
- }
- }
- } else {
- if ((ab == 3 && ac == 4) || (ab == 4 && ac == 3)) {
- if (ab == 4) {
- X = y;
- V = aa;
- S = false
- } else {
- X = aa;
- V = y;
- S = true
- }
- var W = Model.getShapeById(X.id).props;
- var E = Model.getShapeById(V.id).props;
- var U = E.x + E.w;
- if (V.x < X.x && V.y < X.y) {
- O.push({
- x: V.x,
- y: X.y
- })
- } else {
- if (V.x < X.x && U < X.x) {
- var P;
- if (X.x - U < K * 2) {
- P = U + (X.x - U) / 2
- } else {
- P = X.x - K
- }
- var Q = V.y + K;
- O.push({
- x: P,
- y: X.y
- });
- O.push({
- x: P,
- y: Q
- });
- O.push({
- x: V.x,
- y: Q
- })
- } else {
- if (V.x >= X.x && V.y < W.y) {
- var P = X.x - K;
- var Q;
- if (W.y - V.y < K * 2) {
- Q = V.y + (W.y - V.y) / 2
- } else {
- Q = V.y + K
- }
- O.push({
- x: P,
- y: X.y
- });
- O.push({
- x: P,
- y: Q
- });
- O.push({
- x: V.x,
- y: Q
- })
- } else {
- var P;
- if (E.x < X.x) {
- P = E.x - K
- } else {
- P = X.x - K
- }
- var Q;
- if (V.y > W.y + W.h) {
- Q = V.y + K
- } else {
- Q = W.y + W.h + K
- }
- O.push({
- x: P,
- y: X.y
- });
- O.push({
- x: P,
- y: Q
- });
- O.push({
- x: V.x,
- y: Q
- })
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- if (S) {
- O.reverse()
- }
- } else {
- if (y.id != null || aa.id != null) {
- var X, V, S, M;
- if (y.id != null) {
- X = y;
- V = aa;
- S = false;
- M = y.angle
- } else {
- X = aa;
- V = y;
- S = true;
- M = aa.angle
- }
- var Z = Model.getShapeById(X.id).props;
- if (M >= J / 4 && M < J / 4 * 3) {
- if (V.y < X.y) {
- if (R >= I) {
- O.push({
- x: X.x,
- y: V.y
- })
- } else {
- var x = I / 2;
- O.push({
- x: X.x,
- y: X.y - x
- });
- O.push({
- x: V.x,
- y: X.y - x
- })
- }
- } else {
- O.push({
- x: X.x,
- y: X.y - K
- });
- if (R >= I) {
- if (V.x >= Z.x - K && V.x <= Z.x + Z.w + K) {
- var L = Z.x + Z.w / 2;
- if (V.x < L) {
- O.push({
- x: Z.x - K,
- y: X.y - K
- });
- O.push({
- x: Z.x - K,
- y: V.y
- })
- } else {
- O.push({
- x: Z.x + Z.w + K,
- y: X.y - K
- });
- O.push({
- x: Z.x + Z.w + K,
- y: V.y
- })
- }
- } else {
- if (V.x < Z.x) {
- O.push({
- x: V.x + K,
- y: X.y - K
- });
- O.push({
- x: V.x + K,
- y: V.y
- })
- } else {
- O.push({
- x: V.x - K,
- y: X.y - K
- });
- O.push({
- x: V.x - K,
- y: V.y
- })
- }
- }
- } else {
- if (V.x >= Z.x - K && V.x <= Z.x + Z.w + K) {
- var L = Z.x + Z.w / 2;
- if (V.x < L) {
- O.push({
- x: Z.x - K,
- y: X.y - K
- });
- O.push({
- x: Z.x - K,
- y: V.y - K
- });
- O.push({
- x: V.x,
- y: V.y - K
- })
- } else {
- O.push({
- x: Z.x + Z.w + K,
- y: X.y - K
- });
- O.push({
- x: Z.x + Z.w + K,
- y: V.y - K
- });
- O.push({
- x: V.x,
- y: V.y - K
- })
- }
- } else {
- O.push({
- x: V.x,
- y: X.y - K
- })
- }
- }
- }
- } else {
- if (M >= J / 4 * 3 && M < J / 4 * 5) {
- if (V.x > X.x) {
- if (R >= I) {
- var x = R / 2;
- O.push({
- x: X.x + x,
- y: X.y
- });
- O.push({
- x: X.x + x,
- y: V.y
- })
- } else {
- O.push({
- x: V.x,
- y: X.y
- })
- }
- } else {
- O.push({
- x: X.x + K,
- y: X.y
- });
- if (R >= I) {
- if (V.y >= Z.y - K && V.y <= Z.y + Z.h + K) {
- var L = Z.y + Z.h / 2;
- if (V.y < L) {
- O.push({
- x: X.x + K,
- y: Z.y - K
- });
- O.push({
- x: V.x + K,
- y: Z.y - K
- });
- O.push({
- x: V.x + K,
- y: V.y
- })
- } else {
- O.push({
- x: X.x + K,
- y: Z.y + Z.h + K
- });
- O.push({
- x: V.x + K,
- y: Z.y + Z.h + K
- });
- O.push({
- x: V.x + K,
- y: V.y
- })
- }
- } else {
- O.push({
- x: X.x + K,
- y: V.y
- })
- }
- } else {
- if (V.y >= Z.y - K && V.y <= Z.y + Z.h + K) {
- var L = Z.y + Z.h / 2;
- if (V.y < L) {
- O.push({
- x: X.x + K,
- y: Z.y - K
- });
- O.push({
- x: V.x,
- y: Z.y - K
- })
- } else {
- O.push({
- x: X.x + K,
- y: Z.y + Z.h + K
- });
- O.push({
- x: V.x,
- y: Z.y + Z.h + K
- })
- }
- } else {
- if (V.y < X.y) {
- O.push({
- x: X.x + K,
- y: V.y + K
- });
- O.push({
- x: V.x,
- y: V.y + K
- })
- } else {
- O.push({
- x: X.x + K,
- y: V.y - K
- });
- O.push({
- x: V.x,
- y: V.y - K
- })
- }
- }
- }
- }
- } else {
- if (M >= J / 4 * 5 && M < J / 4 * 7) {
- if (V.y > X.y) {
- if (R >= I) {
- O.push({
- x: X.x,
- y: V.y
- })
- } else {
- var x = I / 2;
- O.push({
- x: X.x,
- y: X.y + x
- });
- O.push({
- x: V.x,
- y: X.y + x
- })
- }
- } else {
- O.push({
- x: X.x,
- y: X.y + K
- });
- if (R >= I) {
- if (V.x >= Z.x - K && V.x <= Z.x + Z.w + K) {
- var L = Z.x + Z.w / 2;
- if (V.x < L) {
- O.push({
- x: Z.x - K,
- y: X.y + K
- });
- O.push({
- x: Z.x - K,
- y: V.y
- })
- } else {
- O.push({
- x: Z.x + Z.w + K,
- y: X.y + K
- });
- O.push({
- x: Z.x + Z.w + K,
- y: V.y
- })
- }
- } else {
- if (V.x < Z.x) {
- O.push({
- x: V.x + K,
- y: X.y + K
- });
- O.push({
- x: V.x + K,
- y: V.y
- })
- } else {
- O.push({
- x: V.x - K,
- y: X.y + K
- });
- O.push({
- x: V.x - K,
- y: V.y
- })
- }
- }
- } else {
- if (V.x >= Z.x - K && V.x <= Z.x + Z.w + K) {
- var L = Z.x + Z.w / 2;
- if (V.x < L) {
- O.push({
- x: Z.x - K,
- y: X.y + K
- });
- O.push({
- x: Z.x - K,
- y: V.y + K
- });
- O.push({
- x: V.x,
- y: V.y + K
- })
- } else {
- O.push({
- x: Z.x + Z.w + K,
- y: X.y + K
- });
- O.push({
- x: Z.x + Z.w + K,
- y: V.y + K
- });
- O.push({
- x: V.x,
- y: V.y + K
- })
- }
- } else {
- O.push({
- x: V.x,
- y: X.y + K
- })
- }
- }
- }
- } else {
- if (V.x < X.x) {
- if (R >= I) {
- var x = R / 2;
- O.push({
- x: X.x - x,
- y: X.y
- });
- O.push({
- x: X.x - x,
- y: V.y
- })
- } else {
- O.push({
- x: V.x,
- y: X.y
- })
- }
- } else {
- O.push({
- x: X.x - K,
- y: X.y
- });
- if (R >= I) {
- if (V.y >= Z.y - K && V.y <= Z.y + Z.h + K) {
- var L = Z.y + Z.h / 2;
- if (V.y < L) {
- O.push({
- x: X.x - K,
- y: Z.y - K
- });
- O.push({
- x: V.x - K,
- y: Z.y - K
- });
- O.push({
- x: V.x - K,
- y: V.y
- })
- } else {
- O.push({
- x: X.x - K,
- y: Z.y + Z.h + K
- });
- O.push({
- x: V.x - K,
- y: Z.y + Z.h + K
- });
- O.push({
- x: V.x - K,
- y: V.y
- })
- }
- } else {
- O.push({
- x: X.x - K,
- y: V.y
- })
- }
- } else {
- if (V.y >= Z.y - K && V.y <= Z.y + Z.h + K) {
- var L = Z.y + Z.h / 2;
- if (V.y < L) {
- O.push({
- x: X.x - K,
- y: Z.y - K
- });
- O.push({
- x: V.x,
- y: Z.y - K
- })
- } else {
- O.push({
- x: X.x - K,
- y: Z.y + Z.h + K
- });
- O.push({
- x: V.x,
- y: Z.y + Z.h + K
- })
- }
- } else {
- if (V.y < X.y) {
- O.push({
- x: X.x - K,
- y: V.y + K
- });
- O.push({
- x: V.x,
- y: V.y + K
- })
- } else {
- O.push({
- x: X.x - K,
- y: V.y - K
- });
- O.push({
- x: V.x,
- y: V.y - K
- })
- }
- }
- }
- }
- }
- }
- }
- if (S) {
- O.reverse()
- }
- } else {
- if (R >= I) {
- var x = (aa.x - y.x) / 2;
- O.push({
- x: y.x + x,
- y: y.y
- });
- O.push({
- x: y.x + x,
- y: aa.y
- })
- } else {
- var x = (aa.y - y.y) / 2;
- O.push({
- x: y.x,
- y: y.y + x
- });
- O.push({
- x: aa.x,
- y: y.y + x
- })
- }
- }
- }
- } else {
- if (G.linkerType == "curve") {
- var y = G.from;
- var aa = G.to;
- var Y = this.measureDistance(y, aa);
- var T = Y * 0.4;
-
- function H(e, d) {
- if (e.id != null) {
- return {
- x: e.x - T * Math.cos(e.angle),
- y: e.y - T * Math.sin(e.angle)
- }
- } else {
- var c = Math.abs(e.y - d.y);
- var f = Math.abs(e.x - d.x);
- var b = Math.atan(c / f);
- var a = {};
- if (e.x <= d.x) {
- a.x = e.x + T * Math.cos(b)
- } else {
- a.x = e.x - T * Math.cos(b)
- }
- if (e.y <= d.y) {
- a.y = e.y + T * Math.sin(b)
- } else {
- a.y = e.y - T * Math.sin(b)
- }
- return a
- }
- }
-
- O.push(H(y, aa));
- O.push(H(aa, y))
- }
- }
- return O
- },
- getLinkerLinePoints: function (i) {
- var f = [];
- if (i.linkerType != "curve") {
- f.push(i.from);
- f = f.concat(i.points)
- } else {
- var j = 0.05;
- var g = 0;
- while (g <= 1) {
- var h = {
- x: (1 - g) * (1 - g) * (1 - g) * i.from.x + 3 * (1 - g) * (1 - g) * g * i.points[0].x + 3 * (1 - g) * g * g * i.points[1].x + g * g * g * i.to.x,
- y: (1 - g) * (1 - g) * (1 - g) * i.from.y + 3 * (1 - g) * (1 - g) * g * i.points[0].y + 3 * (1 - g) * g * g * i.points[1].y + g * g * g * i.to.y
- };
- f.push(h);
- g += j
- }
- }
- f.push(i.to);
- return f
- },
- getLinkerBox: function (l) {
- var i = this.getLinkerLinePoints(l);
- var o = i[0].x;
- var p = i[0].y;
- var q = i[0].x;
- var r = i[0].y;
- for (var n = 0; n < i.length; n++) {
- var k = i[n];
- if (k.x < o) {
- o = k.x
- } else {
- if (k.x > q) {
- q = k.x
- }
- }
- if (k.y < p) {
- p = k.y
- } else {
- if (k.y > r) {
- r = k.y
- }
- }
- }
- var m = {
- x: o,
- y: p,
- w: q - o,
- h: r - p
- };
- return m
- },
- getShapeBox: function (e) {
- var d = e.props;
- var f = e.props.angle;
- return this.getRotatedBox(d, f)
- },
- getRotatedBox: function (p, r, u) {
- if (r == 0) {
- return p
- } else {
- if (!u) {
- u = {
- x: p.x + p.w / 2,
- y: p.y + p.h / 2
- }
- }
- var l = this.getRotated(u, {
- x: p.x,
- y: p.y
- },
- r);
- var m = this.getRotated(u, {
- x: p.x + p.w,
- y: p.y
- },
- r);
- var n = this.getRotated(u, {
- x: p.x + p.w,
- y: p.y + p.h
- },
- r);
- var o = this.getRotated(u, {
- x: p.x,
- y: p.y + p.h
- },
- r);
- var q = Math.min(l.x, m.x, n.x, o.x);
- var t = Math.max(l.x, m.x, n.x, o.x);
- var s = Math.min(l.y, m.y, n.y, o.y);
- var v = Math.max(l.y, m.y, n.y, o.y);
- return {
- x: q,
- y: s,
- w: t - q,
- h: v - s
- }
- }
- },
- getRotated: function (n, h, j) {
- var k = this.measureDistance(n, h);
- if (k == 0 || j == 0) {
- return h
- }
- var m = Math.atan(Math.abs(h.x - n.x) / Math.abs(n.y - h.y));
- if (h.x >= n.x && h.y >= n.y) {
- m = Math.PI - m
- } else {
- if (h.x <= n.x && h.y >= n.y) {
- m = Math.PI + m
- } else {
- if (h.x <= n.x && h.y <= n.y) {
- m = Math.PI * 2 - m
- }
- }
- }
- m = m % (Math.PI * 2);
- var l = (m + j) % (Math.PI * 2);
- var i = {
- x: n.x + Math.sin(l) * k,
- y: n.y - Math.cos(l) * k
- };
- return i
- },
- getShapeAnchorInLinker: function (H) {
- var A = H.getAnchors();
- var G = [];
- var t = {
- x: H.props.x + H.props.w / 2,
- y: H.props.y + H.props.h / 2
- };
- for (var v = 0; v < A.length; v++) {
- var y = A[v];
- var x = {
- x: y.x + H.props.x,
- y: y.y + H.props.y
- };
- var E = this.getRotated(t, x, H.props.angle);
- G.push(E)
- }
- var C = [];
- var F = 2;
- for (var w = Model.orderList.length - 1; w >= 0; w--) {
- var z = Model.orderList[w].id;
- var i = Model.getShapeById(z);
- if (i.name != "linker") {
- continue
- }
- var B = i;
- var u = null;
- F = 3;
- for (var v = 0; v < G.length; v++) {
- var J = G[v];
- var I = {
- x: J.x - F,
- y: J.y - F,
- w: F * 2,
- h: F * 2
- };
- if (B.from.id == null && this.pointInRect(B.from.x, B.from.y, I)) {
- u = {
- linker: B,
- anchors: [J],
- type: "from"
- };
- break
- }
- if (B.to.id == null && this.pointInRect(B.to.x, B.to.y, I)) {
- u = {
- linker: B,
- anchors: [J],
- type: "to"
- };
- break
- }
- }
- F = 2;
- if (u == null) {
- for (var v = 0; v < G.length; v++) {
- var J = G[v];
- var D = Utils.pointInLinker(J, B, F);
- if (D > -1) {
- if (u == null) {
- u = {
- linker: B,
- anchors: [],
- type: "line"
- }
- }
- u.anchors.push(J)
- }
- }
- }
- if (u != null) {
- C.push(u)
- }
- }
- return C
- },
- getEndpointAngle: function (m, k) {
- var i;
- if (k == "from") {
- i = m.from
- } else {
- i = m.to
- }
- var n;
- if (m.linkerType == "normal") {
- if (k == "from") {
- n = m.to
- } else {
- n = m.from
- }
- } else {
- if (m.linkerType == "broken") {
- if (k == "from") {
- n = m.points[0]
- } else {
- n = m.points[m.points.length - 1]
- }
- } else {
- var l = 12;
- var h;
- var j = Utils.measureDistance(m.from, m.to);
- if (k == "from") {
- h = l / j
- } else {
- h = 1 - l / j
- }
- n = {
- x: (1 - h) * (1 - h) * (1 - h) * m.from.x + 3 * (1 - h) * (1 - h) * h * m.points[0].x + 3 * (1 - h) * h * h * m.points[1].x + h * h * h * m.to.x,
- y: (1 - h) * (1 - h) * (1 - h) * m.from.y + 3 * (1 - h) * (1 - h) * h * m.points[0].y + 3 * (1 - h) * h * h * m.points[1].y + h * h * h * m.to.y
- }
- }
- }
- return this.getAngle(n, i)
- },
- getAngle: function (f, e) {
- var d = Math.atan(Math.abs(f.y - e.y) / Math.abs(f.x - e.x));
- if (e.x <= f.x && e.y > f.y) {
- d = Math.PI - d
- } else {
- if (e.x < f.x && e.y <= f.y) {
- d = Math.PI + d
- } else {
- if (e.x >= f.x && e.y < f.y) {
- d = Math.PI * 2 - d
- }
- }
- }
- return d
- },
- getDarkerColor: function (q, m) {
- if (!m) {
- m = 13
- }
- var n = q.split(",");
- var r = parseInt(n[0]);
- var o = parseInt(n[1]);
- var l = parseInt(n[2]);
- var p = Math.round(r - r / 255 * m);
- if (p < 0) {
- p = 0
- }
- var g = Math.round(o - o / 255 * m);
- if (g < 0) {
- g = 0
- }
- var b = Math.round(l - l / 255 * m);
- if (b < 0) {
- b = 0
- }
- return p + "," + g + "," + b
- },
- getDarkestColor: function (b) {
- return this.getDarkerColor(b, 26)
- },
- toScale: function (f) {
- var e = {};
- for (var d in f) {
- e[d] = f[d];
- if (typeof f[d] == "number") {
- e[d] = e[d].toScale()
- }
- }
- return e
- },
- restoreScale: function (f) {
- var e = {};
- for (var d in f) {
- e[d] = f[d];
- if (typeof f[d] == "number") {
- e[d] = e[d].restoreScale()
- }
- }
- return e
- },
- getOutlinkers: function (i) {
- var l = [];
- var j = [];
- for (var n = 0; n < i.length; n++) {
- var p = i[n];
- if (p != undefined && p.name != "linker") {
- var m = Model.getShapeLinkers(p.id);
- if (m && m.length > 0) {
- for (var o = 0; o < m.length; o++) {
- var k = m[o];
- if (!this.isSelected(k) && j.indexOf(k) < 0) {
- l.push(Model.getShapeById(k));
- j.push(k)
- }
- }
- }
- }
- }
- return l
- },
- getFamilyShapes: function (i) {
- var j = [];
- for (var m = 0; m < i.length; m++) {
- var h = i[m];
- if (h.name != "linker") {
- if (h.parent) {
- var k = Model.getShapeById(h.parent);
- if (!Utils.isSelected(h.parent)) {
- j.push(k)
- }
- var l = this.getChildrenShapes(k);
- j = j.concat(l)
- }
- var n = this.getChildrenShapes(h);
- j = j.concat(n)
- }
- }
- return j
- },
- getChildrenShapes: function (f) {
- var h = [];
- if (f.children && f.children.length > 0) {
- for (var e = 0; e < f.children.length; e++) {
- var g = f.children[e];
- if (!Utils.isSelected(g)) {
- h.push(Model.getShapeById(g))
- }
- }
- }
- return h
- },
- isFamilyShape: function (c, d) {
- if (c.parent == d.id) {
- return true
- } else {
- if (c.id == d.parent) {
- return true
- } else {
- if (c.parent && c.parent == d.parent) {
- return true
- }
- }
- }
- return false
- },
- getContainedShapes: function (n) {
- var h = [];
- var l = [];
- for (var k = 0; k < n.length; k++) {
- var m = n[k];
- if (m.name != "linker" && m.attribute && m.attribute.container) {
- var j = i(m);
- h = h.concat(j)
- }
- }
-
- function i(e) {
- var b = [];
- for (var c = Model.orderList.length - 1; c >= 0; c--) {
- var f = Model.orderList[c].id;
- if (e.id != f && !Utils.isSelected(f) && l.indexOf(f) < 0) {
- var d = Model.getShapeById(f);
- if (!d.attribute || typeof d.attribute.container == "undefined" || d.attribute.container == false) {
- if (!Utils.isFamilyShape(d, e)) {
- var a = Utils.getShapeBox(d);
- if (Utils.rectInRect(a, e.props)) {
- b.push(d);
- l.push(f)
- }
- }
- }
- }
- }
- return b
- }
-
- return h
- },
- getAttachedShapes: function (p) {
- var r = [];
- for (var m = 0; m < p.length; m++) {
- if (p[m] != undefined) {
- r.push(p[m].id)
- }
- }
- var l = [];
- for (var m = 0; m < p.length; m++) {
- var j = p[m];
- if (j != undefined && (j.groupName == "task" || j.groupName == "callActivity" || j.groupName == "subProcess")) {
- var q = [];
- for (var o = Model.orderList.length - 1; o >= 0; o--) {
- var i = Model.orderList[o].id;
- var n = Model.getShapeById(i);
- if (n.attachTo == j.id && !Utils.isSelected(i) && r.indexOf(i) < 0) {
- q.push(n)
- }
- }
- l = l.concat(q)
- }
- }
- return l
- },
- copy: function (b) {
- return $.extend(true, {},
- b)
- },
- rangeChildren: function (s) {
- var v = [];
- if (s.children && s.children.length > 0) {
- if (s.name == "verticalPool") {
- var h = [];
- var y = [];
- for (var u = 0; u < s.children.length; u++) {
- var w = s.children[u];
- var x = Model.getShapeById(w);
- if (x.name == "horizontalSeparator") {
- y.push(x)
- } else {
- h.push(x)
- }
- }
- h.sort(function (a, b) {
- return a.props.x - b.props.x
- });
- var q = s.props.x;
- for (var u = 0; u < h.length; u++) {
- var x = h[u];
- if (x.name == 'verticalLane' && x.props.x != q) {
- var m = Utils.getContainedShapes([x]);
- var p = Utils.getOutlinkers(m);
- m = m.concat(p);
- Designer.op.moveShape(m, {
- x: (q - x.props.x) * Designer.config.scale,
- y: 0
- });
- var linkers = [];
- for (var i = 0; i < v.length; i++) {
- if (v[i].name == 'linker') {
- linkers.push(v[i].id);
- }
- }
- for (var i = 0; i < m.length; i++) {
- if (linkers.indexOf(m[i].id) > -1) {
- continue;
- }
- v.push(m[i]);
- }
- }
- x.props.x = q;
- Designer.painter.renderShape(x);
- v.push(x);
- q += x.props.w;
- }
- y.sort(function (a, b) {
- return a.props.y - b.props.y
- });
- var r = s.props.y + 40;
- for (var u = 0; u < y.length; u++) {
- var x = y[u];
- var z = x.props.y + x.props.h;
- x.props.w = s.props.w;
- x.props.y = r;
- var t = z - r;
- x.props.h = t;
- Designer.painter.renderShape(x);
- v.push(x);
- r += t
- }
- } else {
- if (s.name == "horizontalPool") {
- var h = [];
- var y = [];
- for (var u = 0; u < s.children.length; u++) {
- var w = s.children[u];
- var x = Model.getShapeById(w);
- if (x.name == "verticalSeparator") {
- y.push(x)
- } else {
- h.push(x)
- }
- }
- h.sort(function (a, b) {
- return a.props.y - b.props.y
- });
- var r = s.props.y;
- for (var u = 0; u < h.length; u++) {
- var x = h[u];
- if (x.name == 'horizontalLane' && x.props.y != r) {
- var m = Utils.getContainedShapes([x]);
- var p = Utils.getOutlinkers(m);
- m = m.concat(p);
- Designer.op.moveShape(m, {
- x: 0,
- y: (r - x.props.y) * Designer.config.scale
- });
- var linkers = [];
- for (var i = 0; i < v.length; i++) {
- if (v[i].name == 'linker') {
- linkers.push(v[i].id);
- }
- }
- for (var i = 0; i < m.length; i++) {
- if (linkers.indexOf(m[i].id) > -1) {
- continue;
- }
- v.push(m[i]);
- }
- }
- x.props.y = r;
- Designer.painter.renderShape(x);
- v.push(x);
- r += x.props.h
- }
- y.sort(function (a, b) {
- return a.props.x - b.props.x
- });
- var q = s.props.x + 40;
- for (var u = 0; u < y.length; u++) {
- var x = y[u];
- var i = x.props.x + x.props.w;
- x.props.h = s.props.h;
- x.props.x = q;
- var p = i - q;
- x.props.w = p;
- Designer.painter.renderShape(x);
- v.push(x);
- q += p
- }
- }
- }
- }
- return v
- },
- getRelativePos: function (h, e, g) {
- var f = g.offset();
- if (f == null) {
- f = {
- left: 0,
- top: 0
- }
- }
- return {
- x: h - f.left + g.scrollLeft(),
- y: e - f.top + g.scrollTop()
- }
- },
- getCollapsedShapes: function (b) {
- var k = [];
- var a = [];
- for (var e = 0; e < b.length; e++) {
- var f = b[e];
- if (f.attribute && f.attribute.collapsed) {
- var h = [];
- for (var c = Model.orderList.length - 1; c >= 0; c--) {
- var g = Model.orderList[c].id;
- var d = Model.getShapeById(g);
- if (d.attribute && d.attribute.collapseBy == f.id && a.indexOf(g) < 0) {
- h.push(d)
- }
- }
- k = k.concat(h)
- }
- }
- return k
- },
- getCollapsedShapesById: function (e) {
- var a = [];
- for (var c = Model.orderList.length - 1; c >= 0; c--) {
- var d = Model.orderList[c].id;
- var b = Model.getShapeById(d);
- if (b.attribute && b.attribute.collapseBy == e) {
- a.push(b)
- }
- }
- return a
- },
- getShapeLineStyle: function (a, b) {
- if (b == false || !Model.define.theme || !Model.define.theme.shape) {
- return $.extend({}, Schema.shapeDefaults.lineStyle, a)
- } else {
- return $.extend({}, Schema.shapeDefaults.lineStyle, Model.define.theme.shape.lineStyle, a)
- }
- },
- getLinkerLineStyle: function (a, b) {
- if (b == false || !Model.define.theme || !Model.define.theme.linker) {
- return $.extend({}, Schema.linkerDefaults.lineStyle, a)
- } else {
- return $.extend({}, Schema.linkerDefaults.lineStyle, Model.define.theme.linker.lineStyle, a)
- }
- },
- getShapeFontStyle: function (b, a) {
- if (a == false || !Model.define.theme || !Model.define.theme.shape) {
- return $.extend({}, Schema.shapeDefaults.fontStyle, b)
- } else {
- return $.extend({}, Schema.shapeDefaults.fontStyle, Model.define.theme.shape.fontStyle, b)
- }
- },
- getLinkerFontStyle: function (b, a) {
- if (a == false || !Model.define.theme || !Model.define.theme.linker) {
- return $.extend({}, Schema.linkerDefaults.fontStyle, b)
- } else {
- return $.extend({}, Schema.linkerDefaults.fontStyle, Model.define.theme.linker.fontStyle, b)
- }
- },
- getShapeFillStyle: function (a, b) {
- if (b == false || !Model.define.theme || !Model.define.theme.shape) {
- return $.extend({}, Schema.shapeDefaults.fillStyle, a)
- } else {
- return $.extend({}, Schema.shapeDefaults.fillStyle, Model.define.theme.shape.fillStyle, a)
- }
- },
- containsChinese: function (a) {
- if (escape(a).indexOf("%u") >= 0) {
- return true
- } else {
- return false
- }
- },
- filterXss: function (a) {
- a = a.toString();
- a = a.replace(//g, ">");
- a = a.replace(/%3E/g, ">");
- a = a.replace(/'/g, "'");
- a = a.replace(/"/g, """);
- return a
- }
-};
-var GradientHelper = {
- createLinearGradient: function (m, j, k) {
- var q = m.props;
- var p;
- var n;
- var o;
- if (q.w > q.h) {
- p = {
- x: 0,
- y: q.h / 2
- };
- n = {
- x: q.w,
- y: q.h / 2
- };
- o = (k.angle + Math.PI / 2) % (Math.PI * 2)
- } else {
- p = {
- x: q.w / 2,
- y: 0
- };
- n = {
- x: q.w / 2,
- y: q.h
- };
- o = k.angle
- }
- if (o != 0) {
- var r = {
- x: q.w / 2,
- y: q.h / 2
- };
- p = Utils.getRotated(r, p, o);
- n = Utils.getRotated(r, n, o);
- if (p.x < 0) {
- p.x = 0
- }
- if (p.x > m.props.w) {
- p.x = m.props.w
- }
- if (p.y < 0) {
- p.y = 0
- }
- if (p.y > m.props.h) {
- p.y = m.props.h
- }
- if (n.x < 0) {
- n.x = 0
- }
- if (n.x > m.props.w) {
- n.x = m.props.w
- }
- if (n.y < 0) {
- n.y = 0
- }
- if (n.y > m.props.h) {
- n.y = m.props.h
- }
- }
- var l = j.createLinearGradient(p.x, p.y, n.x, n.y);
- l.addColorStop(0, "rgb(" + k.beginColor + ")");
- l.addColorStop(1, "rgb(" + k.endColor + ")");
- return l
- },
- createRadialGradient: function (l, h, g) {
- var i = l.props;
- var k = i.h;
- if (i.w < i.h) {
- k = i.w
- }
- var j = h.createRadialGradient(i.w / 2, i.h / 2, 10, i.w / 2, i.h / 2, k * g.radius);
- j.addColorStop(0, "rgb(" + g.beginColor + ")");
- j.addColorStop(1, "rgb(" + g.endColor + ")");
- return j
- },
- getLighterColor: function (q) {
- var m = 60;
- var n = q.split(",");
- var r = parseInt(n[0]);
- var o = parseInt(n[1]);
- var l = parseInt(n[2]);
- var p = Math.round(r + (255 - r) / 255 * m);
- if (p > 255) {
- p = 255
- }
- var g = Math.round(o + (255 - o) / 255 * m);
- if (g > 255) {
- g = 255
- }
- var b = Math.round(l + (255 - l) / 255 * m);
- if (b > 255) {
- b = 255
- }
- return p + "," + g + "," + b
- },
- getDarkerColor: function (q) {
- var m = 60;
- var n = q.split(",");
- var r = parseInt(n[0]);
- var o = parseInt(n[1]);
- var l = parseInt(n[2]);
- var p = Math.round(r - r / 255 * m);
- if (p < 0) {
- p = 0
- }
- var g = Math.round(o - o / 255 * m);
- if (g < 0) {
- g = 0
- }
- var b = Math.round(l - l / 255 * m);
- if (b < 0) {
- b = 0
- }
- return p + "," + g + "," + b
- }
-};
-var MessageSource = {
- batchSize: 0,
- messages: [],
- withUndo: true,
- withMessage: true,
- withDock: true,
- undoStack: {
- stack: [],
- push: function (c, d) {
- this.stack.push(c);
- if (typeof d == "undefined") {
- d = true
- }
- if (d) {
- MessageSource.redoStack.stack = []
- }
- Designer.events.push("undoStackChanged", this.stack.length)
- },
- pop: function () {
- var c = this.stack.length;
- if (c == 0) {
- return null
- }
- var d = this.stack[c - 1];
- this.stack.splice(c - 1, 1);
- MessageSource.redoStack.push(d);
- Designer.events.push("undoStackChanged", this.stack.length);
- return d
- }
- },
- redoStack: {
- stack: [],
- push: function (b) {
- this.stack.push(b);
- Designer.events.push("redoStackChanged", this.stack.length)
- },
- pop: function () {
- var c = this.stack.length;
- if (c == 0) {
- return null
- }
- var d = this.stack[c - 1];
- this.stack.splice(c - 1, 1);
- MessageSource.undoStack.push(d, false);
- Designer.events.push("redoStackChanged", this.stack.length);
- return d
- }
- },
- beginBatch: function () {
- this.batchSize++
- },
- commit: function () {
- this.batchSize--;
- this.submit()
- },
- submit: function () {
- if (this.batchSize == 0 && this.messages.length != 0) {
- if (this.withDock) {
- Dock.update(true)
- }
- if (this.withMessage == false) {
- this.messages = [];
- return
- }
- if (this.withUndo) {
- this.undoStack.push(this.messages)
- }
- if (chartId != "") {
- var c = JSON.stringify(this.messages);
- if (role != "trial") {
- $("#saving_tip").text("<@i18n resource='diagraming.saving'/>")
- }
- var d = {
- action: "command",
- messages: c,
- ignore: "messages",
- name: userName
- };
- CLB.send(d,
- function () {
- if (role != "trial") {
- $("#saving_tip").text("<@i18n resource='diagraming.saved'/>")
- }
- })
- }
- this.messages = []
- }
- },
- send: function (c, d) {
- this.messages.push({
- action: c,
- content: d
- });
- this.submit()
- },
- receive: function (b) {
- this.doWithoutMessage(function () {
- MessageSource.executeMessages(b, true);
- Utils.showLinkerControls();
- Utils.showLinkerCursor()
- })
- },
- undo: function () {
- var b = this.undoStack.pop();
- if (b == null) {
- return
- }
- this.doWithoutUndo(function () {
- MessageSource.beginBatch();
- for (var k = 0; k < b.length; k++) {
- var h = b[k];
- if (h.action == "create") {
- Utils.unselect();
- Model.remove(h.content, false)
- } else {
- if (h.action == "update") {
- var a = h.content.shapes;
- Model.updateMulti(a);
- for (var l = 0; l < a.length; l++) {
- var i = a[l];
- Designer.painter.renderShape(i)
- }
- var j = Utils.getSelectedIds();
- Utils.unselect();
- Utils.selectShape(j, false)
- } else {
- if (h.action == "remove") {
- var a = h.content;
- Model.addMulti(a);
- for (var l = 0; l < a.length; l++) {
- var i = a[l];
- Designer.painter.renderShape(i)
- }
- } else {
- if (h.action == "updatePage") {
- Model.updatePage(h.content.page)
- }
- }
- }
- }
- }
- MessageSource.commit()
- })
- },
- redo: function () {
- var b = this.redoStack.pop();
- if (b == null) {
- return
- }
- this.doWithoutUndo(function () {
- MessageSource.executeMessages(b, false)
- })
- },
- executeMessages: function (p, l) {
- MessageSource.beginBatch();
- for (var o = 0; o < p.length; o++) {
- var r = p[o];
- if (r.action == "create") {
- var s = r.content;
- if (l) {
- for (var m = 0; m < s.length; m++) {
- var n = s[m];
- if (n.name != "linker") {
- Schema.initShapeFunctions(n)
- }
- }
- }
- Model.addMulti(s);
- for (var m = 0; m < s.length; m++) {
- var n = s[m];
- Designer.painter.renderShape(n)
- }
- Model.build()
- } else {
- if (r.action == "update") {
- var i = r.content.updates;
- for (var m = 0; m < i.length; m++) {
- var q = i[m];
- if (l && q.name != "linker") {
- Schema.initShapeFunctions(q)
- }
- Designer.painter.renderShape(q)
- }
- Model.updateMulti(i);
- var t = Utils.getSelectedIds();
- Utils.unselect();
- Utils.selectShape(t)
- } else {
- if (r.action == "remove") {
- Utils.unselect();
- Model.remove(r.content)
- } else {
- if (r.action == "updatePage") {
- Model.updatePage(r.content.update)
- }
- }
- }
- }
- }
- MessageSource.commit()
- },
- doWithoutUndo: function (b) {
- this.withUndo = false;
- b();
- this.withUndo = true
- },
- doWithoutMessage: function (b) {
- this.withMessage = false;
- b();
- this.withMessage = true
- },
- doWithoutUpdateDock: function (b) {
- this.withDock = false;
- b();
- this.withDock = true
- }
-};
-Number.prototype.toScale = function () {
- return this * Designer.config.scale
-};
-Number.prototype.restoreScale = function () {
- return this / Designer.config.scale
-};
\ No newline at end of file
+Schema.init(!0),Schema.initMarkers(),$(function(){if("trial"==role?Designer.status="demo":"viewer"==role?Designer.status="readonly":"running"==role&&(Designer.status="running"),Designer.init(),UI.init(),Dock.init(),Navigator.init(),"readonly"==Designer.status)return Designer.setReadonly(!0),$("#moreShapes").hide(),void Customize.init();"demo"==Designer.status&&UI.gettingStart()});var Designer={config:{panelItemWidth:30,panelItemHeight:30,pageMargin:10,anchorSize:8,rotaterSize:9,anchorColor:"#833",selectorColor:"#833",scale:1},status:"",initialize:{initialized:!1,initLayout:function(){$(window).bind("resize.designer",function(){showPainting();var e=$(window).height()-$("#designer_header").outerHeight()-$("#designer_footer").outerHeight();$(".layout").height(e),$("#demo_signup").length&&$("#designer_layout").height(e-$("#demo_signup").outerHeight())}),$(window).trigger("resize.designer")},initModel:function(){Model.define={page:Utils.copy(Schema.pageDefaults),elements:{}},null!=definition&&null!=definition.localAttribute?Model.define.localAttribute=definition.localAttribute:Model.define.localAttribute={},null!=definition&&null!=definition.commonShapeConfig?Model.define.commonShapeConfig=definition.commonShapeConfig:Model.define.commonShapeConfig={},Model.persistence={page:Utils.copy(Schema.pageDefaults),elements:{},localAttribute:{},commonShapeConfig:{}}},initCanvas:function(){"string"==typeof Model.define.page.width&&(Model.define.page.width=parseFloat(Model.define.page.width)),"string"==typeof Model.define.page.height&&(Model.define.page.height=parseFloat(Model.define.page.height));var e=Model.define.page.width.toScale(),t=Model.define.page.height.toScale(),i=Model.define.page.backgroundColor,n=Utils.getDarkerColor(i),r=Utils.getDarkestColor(i);$("#designer_canvas").css({"background-color":"rgb("+n+")"});var s=$("#designer_grids");s.attr({width:e,height:t});var a=s[0].getContext("2d");a.clearRect(0,0,e,t);var o=Model.define.page.padding.toScale(),l=e-2*o,d=t-2*o;a.fillStyle="rgb("+i+")",a.beginPath(),a.rect(o,o,l,d),a.fill();var h=Math.round(Model.define.page.gridSize.toScale());if(h<10&&(h=10),Model.define.page.showGrid){a.translate(o,o),a.lineWidth=1,a.save();for(var p=.5,c=0;p<=d;)a.restore(),a.strokeStyle=c%4==0?"rgb("+r+")":"rgb("+n+")",a.beginPath(),a.moveTo(0,p),a.lineTo(l,p),p+=h,c++,a.stroke();for(p=.5,c=0;p<=l;)a.restore(),a.strokeStyle=c%4==0?"rgb("+r+")":"rgb("+n+")",a.beginPath(),a.moveTo(p,0),a.lineTo(p,d),p+=h,c++,a.stroke()}$("#canvas_container").css({width:e,height:t,padding:Designer.config.pageMargin}),this.initialized||($("#designer_layout").scrollTop(Designer.config.pageMargin-10),$("#designer_layout").scrollLeft(Designer.config.pageMargin-10));var u=$("#bar_list_page").children("li[ac=set_page_showgrid]");u.menuitem("unselect"),Model.define.page.showGrid&&u.menuitem("select")},initShapes:function(){$("#shape_panel").empty();for(var e=0;e"+t.text+"")}for(var i in $(".panel_title").unbind().bind("click",function(){$(this).parent().toggleClass("panel_collapsed")}),Schema.shapes){var n=Schema.shapes[i];if(n.attribute.visible&&"standard"!=n.category){if(("process_bpmn2"==n.category||"process.bpmn2"==n.category||"bpmn"==n.category)&&checkRunningTimeShape(n))continue;if(n.groupName)SchemaGroup.getGroup(n.groupName)[0]==i&&r(n,n.groupName);else r(n)}}function r(e,t){var i="",n=$(i).appendTo("#panel_"+e.category);t&&n.append("");var r=n.children()[0];n.bind("mouseenter",function(){if(!$(this).hasClass("readonly")){var t=$("#shape_thumb"),i=e.title,r=e.category;"bpmn"==e.category&&(r="process_bpmn2"),"lane"==r&&(r=methodId),r=r.replace(/_/g,"."),methodObjectDesc[r+"-"+e.name]&&(i+=":"+methodObjectDesc[r+"-"+e.name]),t.children("div").text(i);var s=t.children("canvas")[0].getContext("2d"),a={x:0,y:0,w:e.props.w,h:e.props.h,angle:e.props.angle},o=160;if(s.clearRect(0,0,o,160),e.props.w>=e.props.h?e.props.w>o&&(a.w=o,a.h=parseInt(e.props.h/e.props.w*a.w)):e.props.h>160&&(a.h=160,a.w=parseInt(e.props.w/e.props.h*a.h)),t.children("canvas").attr({width:180,height:a.h+20}),t.show(),e.props=a,s.save(),"text"!=e.name&&"umlText"!=e.name){s.globalAlpha=e.shapeStyle.alpha;var l=(180-a.w)/2;s.translate(l,10),s.translate(a.w/2,a.h/2),s.rotate(a.angle),s.translate(-a.w/2,-a.h/2),Designer.painter.renderShapePath(s,e,!0),Designer.painter.renderMarkers(s,e,!0)}else{s.translate(90,a.h/2+10),s.textBaseline="middle",s.textAlign="center";var d="";e.fontStyle.italic?d+="italic ":d+="normal ",e.fontStyle.bold?d+="bold ":d+="normal ",d+=e.fontStyle.size+"pt ",d+=e.fontStyle.fontFamily,s.font=d,s.fillStyle="rgb("+e.fontStyle.color+")",s.fillText(e.text,0,0)}s.restore();var h=n.offset().top-$("#designer_header").outerHeight()+n.height()/2-t.outerHeight()/2;h<5?h=5:h+t.outerHeight()>$("#designer_viewport").height()-5&&(h=$("#designer_viewport").height()-5-t.outerHeight()),t.css("top",h)}}).bind("mouseleave",function(){$("#shape_thumb").hide()}),Designer.painter.drawPanelItem(r,e.name)}$(".panel_box").die().live("mousedown",function(e){var t=$(this);if(!t.hasClass("readonly")){var i=t.attr("shapeName"),n=[];Designer.op.changeState("creating_from_panel");var r=null,s=null,a=$("#designer_canvas"),o=function(e){var t=$("#creating_shape_canvas"),i=$("#creating_shape_container");return 0==t.length&&(i=$("").appendTo("#designer"),t=$("").appendTo(i)),i.css({left:"0px",top:"0px",width:$(".panel_container").width(),height:$("#shape_panel").outerHeight()}),Designer.painter.drawPanelItem(t[0],e),t}(i);$("#designer").bind("mousemove.creating",function(e){!function(e,t){$("#creating_shape_container").show();var i=Utils.getRelativePos(t.pageX,t.pageY,$("#creating_shape_container"));e.css({left:i.x-Designer.config.panelItemWidth/2,top:i.y-Designer.config.panelItemHeight/2})}(o,e)}),$("#canvas_container").bind("mousemove.create",function(e){var t=Utils.getRelativePos(e.pageX,e.pageY,a);null==r&&(r=function(e,t,i){Utils.newId();var n=Schema.shapes[e],r=t.restoreScale()-n.props.w/2,s=i.restoreScale()-n.props.h/2,a=Model.create(e,r,s);return Designer.painter.renderShape(a),a}(i,t.x,t.y),(s=$("#"+r.id)).attr("class","shape_box_creating")),s.css({left:t.x-s.width()/2+"px",top:t.y-s.height()/2+"px","z-index":Model.orderList.length}),r.props.x=t.x.restoreScale()-r.props.w/2,r.props.y=t.y.restoreScale()-r.props.h/2;var o=r.props,l=Designer.op.snapLine(o,[r.id],!0,r);l.attach?r.attachTo=l.attach.id:delete r.attachTo,s.css({left:(r.props.x-10).toScale()+"px",top:(r.props.y-10).toScale()+"px","z-index":Model.orderList.length}),n=Utils.getShapeAnchorInLinker(r),Designer.op.hideLinkPoint();for(var d=0;d=37&&t.keyCode<=40){if(null==e){var i=Utils.getSelected(),n=Utils.getFamilyShapes(i);i=i.concat(n);var r=Utils.getContainedShapes(i);i=i.concat(r);var s=Utils.getAttachedShapes(i);i=i.concat(s);var a=Utils.getOutlinkers(i);e=i.concat(a)}if(e.length>0){t.preventDefault();var o=10;t.ctrlKey&&(o=1),Utils.hideLinkerCursor(),37==t.keyCode?Designer.op.moveShape(e,{x:-o,y:0}):38==t.keyCode?Designer.op.moveShape(e,{x:0,y:-o}):39==t.keyCode?Designer.op.moveShape(e,{x:o,y:0}):40==t.keyCode&&Designer.op.moveShape(e,{x:0,y:o}),$(document).unbind("keyup.moveshape").bind("keyup.moveshape",function(){Model.updateMulti(e),e=null,$(document).unbind("keyup.moveshape"),Designer.op.hideTip(),Utils.showLinkerCursor()})}}else if(221==t.keyCode&&t.ctrlKey){var l="front";t.shiftKey&&(l="forward"),Designer.layerShapes(l)}else if(219==t.keyCode&&t.ctrlKey){l="back";t.shiftKey&&(l="backward"),Designer.layerShapes(l)}else{if(71==t.keyCode&&t.ctrlKey)t.preventDefault(),t.shiftKey?Designer.ungroup():Designer.group();else if(76==t.keyCode&&t.ctrlKey)t.preventDefault(),t.shiftKey?Designer.unlockShapes():Designer.lockShapes();else if(18==t.keyCode)Designer.op.changeState("drag_canvas");else if(27==t.keyCode)Designer.op.state?"creating_free_text"!=Designer.op.state&&"creating_free_linker"!=Designer.op.state||Designer.op.resetState():(Utils.unselect(),$(".menu.list").hide(),$(".menu").hide(),$(".color_picker").hide());else if(84!=t.keyCode||t.ctrlKey)if(73!=t.keyCode||t.ctrlKey)if(76!=t.keyCode||t.ctrlKey)if(66==t.keyCode&&t.ctrlKey){if((h=Utils.getSelectedIds()).length>0){var d=Model.getShapeById(h[0]);Designer.setFontStyle({bold:!d.fontStyle.bold}),UI.update()}}else if(73==t.keyCode&&t.ctrlKey){if((h=Utils.getSelectedIds()).length>0){d=Model.getShapeById(h[0]);Designer.setFontStyle({italic:!d.fontStyle.italic}),UI.update()}}else if(85==t.keyCode&&t.ctrlKey){if((h=Utils.getSelectedIds()).length>0){d=Model.getShapeById(h[0]);Designer.setFontStyle({underline:!d.fontStyle.underline}),UI.update()}t.preventDefault()}else if(32!=t.keyCode||t.ctrlKey)121==t.keyCode&&(t.preventDefault(),Dock.enterPresentation());else{var h;if(1==(h=Utils.getSelectedIds()).length){d=Model.getShapeById(h[0]);Designer.op.editShapeText(d)}t.preventDefault()}else $(".menu.list").hide(),Designer.op.changeState("creating_free_linker"),$("#designer_contextmenu").hide();else $(".menu.list").hide(),UI.showImageSelect(function(e,t,i){UI.insertImage(e,t,i)}),$("#designer_contextmenu").hide();else $(".menu.list").hide(),Designer.op.changeState("creating_free_text")}}),$("input,textarea,select").die().live("keydown.hotkey",function(e){e.stopPropagation()})},cancel:function(){$(document).unbind("keydown.hotkey")}},contextMenu:{init:function(){$("#designer_contextmenu").unbind("mousedown").bind("mousedown",function(e){e.stopPropagation()}),$("#designer_contextmenu").find("li:not(.devider)").unbind("click").bind("click",function(){var e=$(this);e.menuitem("isDisabled")||0!=e.children(".extend_menu").length||(Designer.contextMenu.execAction(e),Designer.contextMenu.hide())}),$("#canvas_container").unbind("contextmenu").bind("contextmenu",function(e){e.preventDefault();var t=$("#designer_canvas"),i=Utils.getRelativePos(e.pageX,e.pageY,t);Designer.contextMenu.show(i.x,i.y)})},destroy:function(){$("#canvas_container").unbind("contextmenu"),this.hide()},menuPos:{x:0,y:0,shape:null},show:function(e,t){this.menuPos.x=e,this.menuPos.y=t;var i=$("#designer_contextmenu"),n=Utils.getShapeByPosition(e,t,!1);i.children().hide(),i.children("li[ac=selectall]").show(),i.children(".devi_selectall").show(),i.children("li[ac=drawline]").show();var r=Designer.clipboard.elements.length;if(null==n)r>0&&(i.children("li[ac=paste]").show(),i.children(".devi_clip").show());else{var s=n.shape;if(this.menuPos.shape=s,s.locked)r>0&&(i.children("li[ac=paste]").show(),i.children(".devi_clip").show()),i.children("li[ac=unlock]").show(),i.children(".devi_shape").show();else{i.children("li[ac=cut]").show(),i.children("li[ac=copy]").show(),i.children("li[ac=duplicate]").show(),r>0&&i.children("li[ac=paste]").show(),i.children(".devi_clip").show(),i.children("li[ac=front]").show(),i.children("li[ac=back]").show(),i.children("li[ac=lock]").show();var a=Utils.getSelectedIds().length;a>=2&&(i.children("li[ac=group]").show(),$("#ctxmenu_align").show()),Utils.getSelectedGroups().length>=1&&i.children("li[ac=ungroup]").show(),i.children(".devi_shape").show(),1==a&&"linker"!=s.name&&s.link&&i.children("li[ac=changelink]").show(),("linker"==s.name||s.attribute.editable)&&i.children("li[ac=edit]").show(),i.children("li[ac=delete]").show(),i.children(".devi_del").show()}}i.css({display:"block","z-index":Model.orderList.length+3,left:e,top:t}),$(document).bind("mousedown.ctxmenu",function(){Designer.contextMenu.hide()})},hide:function(){$("#designer_contextmenu").hide(),$(document).unbind("mousedown.ctxmenu")},execAction:function(e){var t=e.attr("ac");if("cut"==t)Designer.clipboard.cut();else if("copy"==t)Designer.clipboard.copy();else if("paste"==t)Designer.clipboard.paste(this.menuPos.x,this.menuPos.y);else if("duplicate"==t)Designer.clipboard.duplicate();else if("front"==t)Designer.layerShapes("front");else if("back"==t)Designer.layerShapes("back");else if("lock"==t)Designer.lockShapes();else if("unlock"==t)Designer.unlockShapes();else if("group"==t)Designer.group();else if("ungroup"==t)Designer.ungroup();else if("align_shape"==t){var i=e.attr("al");Designer.alignShapes(i)}else"edit"==t?Designer.op.editShapeText(this.menuPos.shape):"delete"==t?Designer.op.removeShape():"selectall"==t?Designer.selectAll():"drawline"==t?Designer.op.changeState("creating_free_linker"):"changelink"==t&&UI.showInsertLink()}},init:function(){this.initialize.initLayout(),this.initialize.initModel(),this.initialize.initCanvas(),this.initialize.initShapes(),this.hotkey.init(),this.contextMenu.init(),Designer.op.init(),this.initialize.initialized=!0,Designer.events.push("initialized"),$("#designer_layout").on("scroll",function(){$(document).trigger("mouseup.multiselect")})},op:{init:function(){var e=$("#designer_canvas"),t=$("#canvas_container");t.unbind("mousemove.operate").bind("mousemove.operate",function(i){if(null==Designer.op.state){Designer.op.destroy();var n=Utils.getRelativePos(i.pageX,i.pageY,e),r=Utils.getShapeByPosition(n.x,n.y);if(null!=r)if("dataAttribute"==r.type);else if("linker"==r.type){t.css("cursor","pointer"),Designer.op.shapeSelectable(r.shape);var s=r.shape,a=r.pointIndex;"broken"==s.linkerType&&a>1&&a<=s.points.length?Designer.op.brokenLinkerChangable(s,a-1):null==s.from.id&&null==s.to.id&&(t.css("cursor","move"),Designer.op.shapeDraggable()),Designer.op.linkerEditable(s)}else"linker_point"==r.type?(t.css("cursor","move"),Designer.op.shapeSelectable(r.shape),Designer.op.linkerDraggable(r.shape,r.point),Designer.op.linkerEditable(r.shape)):"linker_text"==r.type?(t.css("cursor","text"),Designer.op.shapeSelectable(r.shape),Designer.op.linkerEditable(r.shape)):("shape"==r.type?r.shape.locked?(t.css("cursor","default"),Designer.op.shapeSelectable(r.shape)):(t.css("cursor","move"),Designer.op.shapeSelectable(r.shape),Designer.op.shapeEditable(r.shape),Designer.op.shapeDraggable(),r.shape.link):(t.css("cursor","crosshair"),Designer.op.shapeSelectable(r.shape),Designer.op.shapeLinkable(r.shape,r.linkPoint)),r.shape.parent?Utils.showAnchors(Model.getShapeById(r.shape.parent)):Utils.showAnchors(r.shape));else t.css("cursor","default"),Designer.op.shapeMultiSelectable()}})},cancel:function(){$("#canvas_container").unbind("mousemove.operate").css("cursor","default"),this.destroy()},destroy:function(){$("#designer_canvas").unbind("mousedown.drag").unbind("dblclick.edit").unbind("mousedown.draglinker").unbind("mousedown.select").unbind("mousedown.brokenLinker").unbind("dblclick.edit_linker"),$("#canvas_container").unbind("mousedown.link").unbind("mousedown.create_text").unbind("mousedown.drag_canvas"),$("#designer_layout").unbind("mousedown.multiselect"),Utils.hideAnchors(),$("#link_spot").hide()},state:null,changeState:function(e){this.state=e,"creating_free_text"==e?(this.destroy(),$("#canvas_container").css("cursor","crosshair"),this.textCreatable()):"creating_free_linker"==e?(this.destroy(),$("#canvas_container").css("cursor","crosshair"),this.shapeLinkable()):"drag_canvas"==e?(this.destroy(),this.canvasDraggable()):"changing_curve"==e&&this.destroy()},resetState:function(){this.state=null,$("#canvas_container").css("cursor","default")},shapeSelectable:function(e){var t=$("#designer_canvas");t.bind("mousedown.select",function(i){Designer.op.changeState("seelcting_shapes");var n=e.id,r=[];if(i.ctrlKey){r=Utils.getSelectedIds();Utils.isSelected(n)?Utils.removeFromArray(r,n):r.push(n),Utils.unselect(),r.length>0&&Utils.selectShape(r)}else Utils.selectIds.indexOf(n)<0&&(Utils.unselect(),Utils.selectShape(n));$(document).bind("mouseup.select",function(){Designer.op.resetState(),t.unbind("mousedown.select"),$(document).unbind("mouseup.select")})})},shapeDraggable:function(){var e=$("#designer_canvas"),t=$("#canvas_container");e.bind("mousedown.drag",function(i){Utils.hideLinkerCursor(),Utils.hideLinkerControls(),Designer.op.changeState("dragging");var n=Utils.getRelativePos(i.pageX,i.pageY,e),r=Utils.getSelected(),s=!0;1==r.length&&"linker"==r[0].name&&(s=!1);var a=null;s&&(a=Utils.getShapesBounding(r));var o=Utils.getFamilyShapes(r);r=r.concat(o);var l=Utils.getContainedShapes(r);r=r.concat(l);var d=Utils.getAttachedShapes(r);r=r.concat(d);var h=[];if(s)for(var p=0;p=i.x2||r.y+l.y<=i.y1||r.y+r.h+l.y>=i.y2)return $.simpleAlert("子流程内部节点只能在范围标识框内部移动","warning"),t.unbind("mousemove.drag"),void e.unbind("mousedown.drag")}}}Designer.op.moveShape(r,l),n=o,$(document).unbind("mouseup.drop").bind("mouseup.drop",function(){Model.updateMulti(r),$(document).unbind("mouseup.drop")})}}),$(document).bind("mouseup.drag",function(){Designer.op.resetState(),t.unbind("mousemove.drag"),e.unbind("mousedown.drag"),$(document).unbind("mouseup.drag"),Designer.op.hideTip(),Designer.op.hideSnapLine(),Utils.showLinkerCursor(),Utils.showLinkerControls();var i=Utils.getSelected()[0];if(i){var n=i.props,r=Model.define.page;n.x+n.w>r.width-r.padding&&(Designer.setPageStyle({width:n.x+n.w+r.padding+30}),$("#page_size_w").spinner("value",n.x+n.w+r.padding+30)),n.y+n.h>r.height-r.padding&&(Designer.setPageStyle({height:n.y+n.h+r.padding+30}),$("#page_size_h").spinner("value",n.x+n.w+r.padding+30))}"0"==isAutoSave&&($("#saving_tip").css("color","rgb(255, 0, 0)"),$("#saving_tip").text("文件已修改,未保存"))})})},shapeResizable:function(){$(".shape_controller").bind("mousedown",function(e){if(!isAdmin&&"1"==isCustomDefine)for(var t=Utils.getSelected(),i=0;i=0?u.x=o.x+o.w:c.indexOf("r")>=0?u.x=o.x:u.x=o.x+o.w/2,c.indexOf("t")>=0?u.y=o.y+o.h:c.indexOf("b")>=0?u.y=o.y:u.y=o.y+o.h/2,u=Utils.getRotated(p,u,o.angle);var y=[],f={},x=[],v=Utils.getAttachedShapes(d);d=d.concat(v);for(var m=[],b=0;b0)for(var w=0;w=0?n.w=i.x-u.x:c.indexOf("l")>=0&&(n.w=u.x-i.x),c.indexOf("b")>=0?n.h=i.y-u.y:c.indexOf("t")>=0&&(n.h=u.y-i.y),e.ctrlKey&&2==c.length?o.w>=o.h?(n.h=o.h/o.w*n.w,n.h=0?r.x=u.x+n.w:c.indexOf("l")>=0?r.x=u.x-n.w:r.x=u.x,c.indexOf("b")>=0?r.y=u.y+n.h:c.indexOf("t")>=0?r.y=u.y-n.h:r.y=u.y;var a=Utils.getRotated(u,r,o.angle),d={x:.5*u.x+.5*a.x,y:.5*u.y+.5*a.y},h=Utils.getRotated(d,u,-o.angle);if(c.indexOf("r")>=0?n.x=h.x:c.indexOf("l")>=0?n.x=h.x-n.w:n.x=h.x-n.w/2,c.indexOf("b")>=0?n.y=h.y:c.indexOf("t")>=0?n.y=h.y-n.h:n.y=h.y-n.h/2,0==n.angle)y[0],Designer.op.snapResizeLine(n,m,c);Utils.removeAnchors();for(var p=0;p"+C),Designer.op.showTip(C),$(document).unbind("mouseup.resize_ok").bind("mouseup.resize_ok",function(){_.length>0&&(y=y.concat(_)),Model.updateMulti(y),$(document).unbind("mouseup.resize_ok")})}),$(document).bind("mouseup.resize",function(){r.css("cursor","default"),Designer.op.resetState(),r.unbind("mousemove.resize"),$(document).unbind("mouseup.resize");var e=Utils.getSelected()[0];if(e){var t=e.props,i=Model.define.page;t.x+t.w>i.width-i.padding&&Designer.setPageStyle({width:t.x+t.w+i.padding+10}),t.y+t.h>i.height-i.padding&&Designer.setPageStyle({height:t.y+t.h+i.padding+10})}Designer.op.hideTip(),Utils.showLinkerCursor(),Designer.op.hideSnapLine()})})},shapeRotatable:function(){$(".shape_rotater").bind("mousemove",function(e){var t=$(this),i=e.pageX-t.offset().left,n=e.pageY-t.offset().top,r=t[0].getContext("2d");t.unbind("mousedown"),t.removeClass("rotate_enable"),r.isPointInPath(i,n)?(t.addClass("rotate_enable"),t.bind("mousedown",function(e){Utils.hideLinkerCursor(),$("#shape_text_edit").length&&$("#shape_text_edit").trigger("blur"),e.stopPropagation(),Designer.op.changeState("rotating");var t,i,n=Utils.getSelectedIds();if(1==n.length){var r=Model.getShapeById(n[0]);t=r.props,i=r.props.angle}else t=Utils.getControlBox(n),i=0;var s={x:t.x+t.w/2,y:t.y+t.h/2},a=Utils.toScale(s),o=$("#designer_canvas"),l=Utils.getSelected(),d=Utils.getAttachedShapes(l);l=l.concat(d);var h=Utils.getOutlinkers(l);l=l.concat(h);var p=i;$(document).bind("mousemove.rotate",function(e){var n=Utils.getRelativePos(e.pageX,e.pageY,o),r=Math.atan(Math.abs(n.x-a.x)/Math.abs(a.y-n.y));n.x>=a.x&&n.y>=a.y?r=Math.PI-r:n.x<=a.x&&n.y>=a.y?r=Math.PI+r:n.x<=a.x&&n.y<=a.y&&(r=2*Math.PI-r),r%=2*Math.PI;var d=Math.PI/36,h=Math.round(r/d);if((r=d*h)!=p){p=r,Designer.op.showTip(5*h%360+"°"),Designer.painter.rotateControls(t,r),Utils.removeAnchors();for(var c=r-i,u=0;u0)for(var o in Model.define.localAttribute[e])s.attributesJsonArray.push(Utils.copy(Model.define.localAttribute[e][o]));for(var l=0;l0&&(p=p.concat(i)),Model.updateMulti(p)}})})},shapeMultiSelectable:function(){var e=$("#designer_canvas"),t=$("#designer_layout");t.unbind("mousedown.multiselect").bind("mousedown.multiselect",function(i){var n=null;i.ctrlKey||Utils.unselect();var r=Utils.getRelativePos(i.pageX,i.pageY,e);Designer.op.changeState("multi_selecting"),t.bind("mousemove.multiselect",function(t){null==n&&(n=$("").appendTo(e));var i=Utils.getRelativePos(t.pageX,t.pageY,e),s={"z-index":Model.orderList.length,left:i.x,top:i.y};i.x>r.x&&(s.left=r.x),i.y>r.y&&(s.top=r.y),s.width=Math.abs(i.x-r.x),s.height=Math.abs(i.y-r.y),n.css(s)}),$(document).unbind("mouseup.multiselect").bind("mouseup.multiselect",function(e){if(null!=n){var i={x:n.position().left.restoreScale(),y:n.position().top.restoreScale(),w:n.width().restoreScale(),h:n.height().restoreScale()},r=Utils.getShapesByRange(i);if(e.ctrlKey){var s=Utils.getSelectedIds();Utils.mergeArray(r,s)}Utils.unselect(),Utils.selectShape(r),n.remove()}Designer.op.resetState(),$(document).unbind("mouseup.multiselect"),t.unbind("mousemove.multiselect")}),t.unbind("mousedown.multiselect")})},shapeEditable:function(e){var t=$("#designer_canvas");0!=e.attribute.editable&&t.unbind("dblclick.edit").bind("dblclick.edit",function(){Designer.op.editShapeText(e),t.unbind("dblclick.edit")})},editShapeText:function(e){if("linker"!=e.name){var t=$("#shape_text_edit");0==t.length&&(t=$("").appendTo("#designer_canvas"));var i=$("#shape_text_ruler");0==i.length&&(i=$("").appendTo("#designer_canvas")),$(".text_canvas[forshape="+e.id+"]").hide();var n=e.fontStyle,r=e.getTextBlock();if("horizontal"==n.orientation){var s={x:r.x+r.w/2,y:r.y+r.h/2};r={x:s.x-r.h/2,y:s.y-r.w/2,w:r.h,h:r.w}}var a={width:r.w+"px","z-index":Model.orderList.length+2,"line-height":Math.round(1.25*n.size)+"px","font-size":n.size+"px","font-family":n.fontFamily,"font-weight":n.bold?"bold":"normal","font-style":n.italic?"italic":"normal","text-align":n.textAlign,color:"rgb("+n.color+")","text-decoration":n.underline?"underline":"none"};t.css(a),i.css(a),t.show(),r.x+=e.props.x,r.y+=e.props.y,t.val(e.text),$("#shape_text_edit").unbind().bind("keyup",function(){var s=$(this).val();i.val(s),i.scrollTop(99999);var a=i.scrollTop();t.css({height:a});r.x,r.w;var o=r.y+r.h/2,l=0,d=0,h=r.h;"middle"==e.fontStyle.vAlign?a>h?(l=o-(h=a)/2,d=0):(l=o-r.h/2,d=(r.h-a)/2,h=r.h-d):"bottom"==e.fontStyle.vAlign?a>h?(h=a,l=o+r.h/2-h,d=0):(l=o-r.h/2,d=r.h-a,h=r.h-d):(l=o-r.h/2,d=0,h=a>h?a:r.h);var p=d+h,c={x:r.x+r.w/2,y:l+p/2},u=e.props.angle;if(0!=u){var g={x:e.props.x+e.props.w/2,y:e.props.y+e.props.h/2};c=Utils.getRotated(g,c,u)}"horizontal"==n.orientation&&(u=(1.5*Math.PI+u)%(2*Math.PI));var y="rotate("+Math.round(u/(2*Math.PI)*360)+"deg) scale("+Designer.config.scale+")";t.css({width:r.w,height:h,"padding-top":d,left:c.x.toScale()-r.w/2-2,top:c.y.toScale()-p/2-2,"-webkit-transform":y,"-ms-transform":y,"-o-transform":y,"-moz-transform":y,transform:y})}).bind("keydown",function(t){var n=$(this);if(13==t.keyCode&&t.ctrlKey)return o(),!1;if(27==t.keyCode)n.unbind().remove(),$(".text_canvas[forshape="+e.id+"]").show();else if(66==t.keyCode&&t.ctrlKey){var r=!e.fontStyle.bold;e.fontStyle.bold=r,Model.update(e);var s=r?"bold":"normal";$(this).css("font-weight",s),i.css("font-weight",s),UI.update()}else if(73==t.keyCode&&t.ctrlKey){r=!e.fontStyle.italic;e.fontStyle.italic=r,Model.update(e);s=r?"italic":"normal";$(this).css("font-style",s),i.css("font-style",s),UI.update()}else if(85==t.keyCode&&t.ctrlKey){r=!e.fontStyle.underline;e.fontStyle.underline=r,Model.update(e);s=r?"underline":"none";$(this).css("text-decoration",s),i.css("text-decoration",s),t.preventDefault(),UI.update()}}).bind("blur",function(e){o()}).bind("mousemove",function(e){e.stopPropagation()}).bind("mousedown",function(e){e.stopPropagation()}).bind("mouseenter",function(e){Designer.op.destroy()}),$("#shape_text_edit").trigger("keyup"),t.select()}else this.editLinkerText(e);function o(){var t=$("#shape_text_edit").val();$("#shape_text_edit").length&&$("#shape_text_edit").is(":visible")&&(t!=e.text&&(e.text=t,Model.update(e)),Designer.painter.renderShape(e),$("#shape_text_edit").remove())}},shapeLinkable:function(e,t){var i=$("#designer_canvas"),n=$("#canvas_container");n.unbind("mousedown.link").bind("mousedown.link",function(r){Designer.op.changeState("linking_from_shape");var s,a=null;if(e)(s=t).id=e.id;else{var o=Utils.getRelativePos(r.pageX,r.pageY,i);s={x:o.x.restoreScale(),y:o.y.restoreScale(),id:null,angle:null}}n.bind("mousemove.link",function(e){n.css("cursor","default");var t=Utils.getRelativePos(e.pageX,e.pageY,i);null==a&&(a=function(e,t){var i=Utils.newId(),n=Utils.copy(Schema.linkerDefaults);return n.from=e,n.to={id:null,x:t.x,y:t.y,angle:null},n.props={zindex:Model.maxZIndex+1},n.id=i,n}(s,t),Designer.events.push("linkerCreating",a)),Designer.op.moveLinker(a,"to",t.x,t.y),$(document).unbind("mouseup.droplinker").bind("mouseup.droplinker",function(){Math.abs(t.x-s.x)>20||Math.abs(t.y-s.y)>20?(Model.add(a),Designer.events.push("linkerCreated",a),null==a.to.id&&null!=a.from.id&&Designer.op.linkDashboard(a),Utils.showLinkerCursor()):$("#"+a.id).remove(),$(document).unbind("mouseup.droplinker")})}),$(document).bind("mouseup.link",function(){Designer.op.hideLinkPoint(),Designer.op.resetState(),"process.subprocess"==methodId&&window.subProcess.linkerBoxPointerEvent(),n.unbind("mousedown.link"),n.unbind("mousemove.link"),$(document).unbind("mouseup.link")})})},linkerEditable:function(e){var t=$("#designer_canvas");t.unbind("dblclick.edit_linker").bind("dblclick.edit_linker",function(){Designer.op.editLinkerText(e),t.unbind("dblclick.edit_linker")})},editLinkerText:function(e){Designer.contextMenu.hide();var t=Designer.painter.getLinkerMidpoint(e),i=$("#"+e.id).find(".text_canvas"),n=$("#linker_text_edit");0==n.length&&(n=$("").appendTo("#designer_canvas")),$("#"+e.id).find(".text_canvas").hide();var r=e.fontStyle,s="scale("+Designer.config.scale+")",a=Math.round(1.25*r.size);function o(){var t=$("#linker_text_edit");if(t.length&&t.is(":visible")){var i=t.val();i!=e.text&&(e.text=i,Model.update(e)),Designer.painter.renderLinker(e),t.remove()}}n.css({"z-index":Model.orderList.length,"line-height":a+"px","font-size":r.size+"px","font-family":r.fontFamily,"font-weight":r.bold?"bold":"normal","font-style":r.italic?"italic":"normal","text-align":r.textAlign,color:"rgb("+r.color+")","text-decoration":r.underline?"underline":"none","-webkit-transform":s,"-ms-transform":s,"-o-transform":s,"-moz-transform":s,transform:s}),n.val(e.text).show().select(),n.unbind().bind("keyup",function(){var e=$(this).val().replace(//g,">").replace(/\n/g,"
");i.html(e+"
");var r=i.width();r<50&&(r=50);var s=i.height();s1&&(a=!0),n.bind("mousemove.draglinker",function(r){n.css("cursor","default");var o=Utils.getRelativePos(r.pageX,r.pageY,i);Designer.op.moveLinker(e,t,o.x,o.y),a&&Designer.painter.drawControls(s),$(document).unbind("mouseup.droplinker").bind("mouseup.droplinker",function(){$(document).unbind("mouseup.droplinker"),Model.update(e),Utils.showLinkerControls()})}),$(document).bind("mouseup.draglinker",function(){Designer.op.hideLinkPoint(),Designer.op.resetState(),i.unbind("mousedown.draglinker"),n.unbind("mousemove.draglinker"),$(document).unbind("mouseup.draglinker"),Utils.showLinkerControls()})})},linkClickable:function(e,t){var i=$("#link_spot");0==i.length&&(i=$("").appendTo("#designer_canvas")),-1==e.trim().toLowerCase().indexOf("http")&&(e="http://"+e),i.show().css({left:t.x-50,top:t.y-50,"z-index":Model.orderList.length+1})},textCreatable:function(){var e=$("#designer_canvas"),t=$("#canvas_container");t.unbind("mousedown.create_text").bind("mousedown.create_text",function(i){var n=null;i.ctrlKey||Utils.unselect();var r=Utils.getRelativePos(i.pageX,i.pageY,e),s=null;t.bind("mousemove.create_text",function(t){null==n&&(n=$("").appendTo(e));var i=Utils.getRelativePos(t.pageX,t.pageY,e);s={"z-index":Model.orderList.length,left:i.x-1,top:i.y-1},i.x>r.x&&(s.left=r.x-1),i.y>r.y&&(s.top=r.y-1),s.width=Math.abs(i.x-r.x-2),s.height=Math.abs(i.y-r.y-2),n.css(s)}),$(document).unbind("mouseup.create_text").bind("mouseup.create_text",function(e){if(null!=s&&s.width>=20&&s.height>=20){var i=Model.create("standardText",s.left.restoreScale(),s.top.restoreScale());i.props.w=s.width.restoreScale(),i.props.h=s.height.restoreScale(),Model.add(i),Designer.painter.renderShape(i),Designer.op.editShapeText(i),Utils.unselect(),Utils.selectShape(i.id)}n.remove(),Designer.op.resetState(),$(document).unbind("mouseup.create_text"),t.unbind("mousemove.create_text")}),t.unbind("mousedown.create_text")})},canvasDragTimeout:null,canvasDraggable:function(){var e=$("#canvas_container");e.css("cursor","url(../apps/_bpm.platform/js/designer/themes/default/images/diagraming/cursor_hand.png) 8 8, auto"),this.canvasDragTimeout&&clearTimeout(this.canvasDragTimeout),this.canvasDragTimeout=setTimeout(function(){e.unbind("mousedown.drag_canvas"),Designer.op.resetState(),e.unbind("mousemove.drag_canvas"),$(document).unbind("mouseup.drag_canvas")},500),e.unbind("mousedown.drag_canvas").bind("mousedown.drag_canvas",function(t){var i=$("#designer_layout").scrollTop(),n=$("#designer_layout").scrollLeft();e.bind("mousemove.drag_canvas",function(e){var r=e.pageX-t.pageX,s=e.pageY-t.pageY;$("#designer_layout").scrollLeft(n-r),$("#designer_layout").scrollTop(i-s)}),$(document).unbind("mouseup.drag_canvas").bind("mouseup.drag_canvas",function(t){e.unbind("mousemove.drag_canvas"),$(document).unbind("mouseup.drag_canvas")})}),$(document).unbind("keyup.drag_canvas").bind("keyup.drag_canvas",function(t){e.unbind("mousedown.drag_canvas"),Designer.op.resetState(),$(document).unbind("mouseup.drag_canvas"),t.preventDefault(),clearTimeout(this.canvasDragTimeout),e.unbind("mousemove.drag_canvas")})},canvasFreeDraggable:function(){var e=$("#canvas_container");e.css("cursor","url(../apps/_bpm.platform/js/designer/themes/default/images/diagraming/cursor_hand.png) 8 8, auto"),e.unbind("mousedown.drag_canvas").bind("mousedown.drag_canvas",function(t){var i=$("#designer_layout").scrollTop(),n=$("#designer_layout").scrollLeft();e.bind("mousemove.drag_canvas",function(e){var r=e.pageX-t.pageX,s=e.pageY-t.pageY;$("#designer_layout").scrollLeft(n-r),$("#designer_layout").scrollTop(i-s)}),$(document).unbind("mouseup.drag_canvas").bind("mouseup.drag_canvas",function(t){e.unbind("mousemove.drag_canvas"),$(document).unbind("mouseup.drag_canvas")})})},moveShape:function(e,t){for(var i=[],n=0;n=0)&&(a.from.x+=s.x,a.from.y+=s.y,d=!0),(null==l.id||i.indexOf(l.id)>=0)&&(a.to.x+=s.x,a.to.y+=s.y,h=!0)):(null!=o.id&&i.indexOf(o.id)>=0&&(a.from.x+=s.x,a.from.y+=s.y,d=!0),null!=l.id&&i.indexOf(l.id)>=0&&(a.to.x+=s.x,a.to.y+=s.y,h=!0)),d&&h){for(var p=0;p0){var f=Utils.getSelectedIds();Designer.painter.drawControls(f)}else{var x=$("#shape_controls");x.css({left:parseFloat(x.css("left"))+t.x,top:parseFloat(x.css("top"))+t.y})}var v=$("#shape_controls").position();v&&Utils.getSelected().length>0&&Designer.op.showTip("X: "+Math.round(v.left.restoreScale())+" Y: "+Math.round(v.top.restoreScale()))}function m(e){e.props.x+=s.x,e.props.y+=s.y;var i=$("#"+e.id);i.css({left:parseFloat(i.css("left"))+t.x,top:parseFloat(i.css("top"))+t.y})}},moveLinker:function(e,t,i,n){var r=null,s=null,a=Utils.getShapeByPosition(i,n,!0);if(Designer.op.hideLinkPoint(),null!=a){var o,l,d=a.shape;if(Utils.showAnchors(d),s=d.id,"bounding"==a.type)r=a.linkPoint,Designer.op.showLinkPoint(Utils.toScale(r));else if("shape"==a.type)if("from"==t?(o={x:e.to.x,y:e.to.y},l=e.to.id):(o={x:e.from.x,y:e.from.y},l=e.from.id),d.id==l)Designer.op.hideLinkPoint(),(r={x:i.restoreScale(),y:n.restoreScale()}).angle=null,s=null;else{for(var h,p=d.getAnchors(),c=-1,u={x:d.props.x+d.props.w/2,y:d.props.y+d.props.h/2},g=0;g=e.to.x-6&&r.x<=e.to.x+6&&(e.from.x=e.to.x),r.y>=e.to.y-6&&r.y<=e.to.y+6&&(e.from.y=e.to.y))):(e.to.x=r.x,e.to.y=r.y,e.to.id=s,e.to.angle=r.angle,null==s&&(r.x>=e.from.x-6&&r.x<=e.from.x+6&&(e.to.x=e.from.x),r.y>=e.from.y-6&&r.y<=e.from.y+6&&(e.to.y=e.from.y))),Designer.painter.renderLinker(e,!0)},showLinkPoint:function(e){var t=$("").appendTo($("#designer_canvas")),i=t[0].getContext("2d");i.translate(1,1),i.lineWidth=1,i.globalAlpha=.3,i.strokeStyle=Designer.config.anchorColor,i.fillStyle=Designer.config.anchorColor,i.beginPath(),i.moveTo(0,15),i.bezierCurveTo(0,-5,30,-5,30,15),i.bezierCurveTo(30,35,0,35,0,15),i.closePath(),i.fill(),i.stroke(),t.css({left:e.x-16,top:e.y-16,"z-index":Model.orderList.length}).show()},hideLinkPoint:function(){$(".link_point_canvas").hide()},brokenLinkerChangable:function(e,t){var i=$("#canvas_container"),n=$("#designer_canvas"),r=e.points[t-1],s=e.points[t];r.x==s.x?i.css("cursor","e-resize"):i.css("cursor","n-resize"),n.bind("mousedown.brokenLinker",function(t){Designer.op.changeState("changing_broken_linker");var a=Utils.getRelativePos(t.pageX,t.pageY,n),o=Utils.getSelectedIds();i.bind("mousemove.brokenLinker",function(t){var i=Utils.getRelativePos(t.pageX,t.pageY,n),l={x:i.x-a.x,y:i.y-a.y};l=Utils.restoreScale(l),r.x==s.x?(r.x+=l.x,s.x+=l.x):(r.y+=l.y,s.y+=l.y),Designer.painter.renderLinker(e),o.length>1&&Designer.painter.drawControls(o),a=i,$(document).unbind("mouseup.changed").bind("mouseup.changed",function(){Model.update(e),$(document).unbind("mouseup.changed")})}),$(document).bind("mouseup.brokenLinker",function(){Designer.op.resetState(),i.unbind("mousemove.brokenLinker"),n.unbind("mousedown.brokenLinker"),$(document).unbind("mouseup.brokenLinker")})})},removeShape:function(){var d=Utils.getSelected();if(d.length>0){Utils.unselect();var e=Utils.getAttachedShapes(d);d=d.concat(e);for(var c=[],b=0;b0){for(var shapeIds=[],index=0;index0?$.ajax({url:"./jd?sid="+$("#sid").val()+"&cmd=com.actionsoft.apps.coe.pal_pl_repository_designer_relation_search",data:{shapeIds:shapeIds.join(","),fileId:ruuid},success:function(msg){"string"==typeof msg&&(msg=eval("("+msg+")"));var relationShapes=msg.data.relationShapes;if(relationShapes.length>0){var options={title:"提示",content:"图形["+relationShapes+"]被关联,确定删除吗?",onConfirm:function(){Model.remove(d)}};$.confirm(options)}else Model.remove(d)}}):Model.remove(d)}}},showTip:function(e){var t=$("#designer_op_tip");0==t.length&&(t=$("").appendTo("#designer_canvas")),t.stop().html(e);var i=$("#shape_controls"),n=i.position();t.css({top:n.top+i.height()+5,left:n.left+i.width()/2-t.outerWidth()/2,"z-index":Model.orderList.length}).show()},hideTip:function(){$("#designer_op_tip").fadeOut(100)},snapLine:function(e,t,i,n){var r=e.y,s=e.y+e.h/2,a=e.y+e.h,o=e.x,l=e.x+e.w/2,d=e.x+e.w,h={v:null,h:null,attach:null},p=null;if(p=i?n:Model.getShapeById(t[0]),1==t.length&&"boundaryEvent"==p.groupName)for(var c=Model.orderList.length-1;c>=0;c--){var u=Model.orderList[c].id;if("linker"!=(w=Model.getShapeById(u)).name&&w.id!=p.id){var g=w.props;if(null==h.attach&&0==g.angle&&("task"==w.groupName||"callActivity"==w.groupName||"subProcess"==w.groupName)){var y={x:g.x-2,y:g.y-2,w:g.w+4,h:g.h+4};if(Utils.pointInRect(l,s,y)){var f=g.y,x=g.y+g.h,v=g.x,m=g.x+g.w,b=!1,S=!1;f>=s-2&&f<=s+2?(e.y=f-e.h/2,S=!0):x>=s-2&&x<=s+2&&(e.y=x-e.h/2,S=!0),v>=l-2&&v<=l+2?(e.x=v-e.w/2,b=!0):m>=l-2&&m<=l+2&&(e.x=m-e.w/2,b=!0),(b||S)&&(h.attach=w)}}}}if(null==h.attach)for(c=Model.orderList.length-1;c>=0;c--){var w;u=Model.orderList[c].id;if(!("linker"==(w=Model.getShapeById(u)).name||t.indexOf(u)>=0||w.parent)){g=w.props;if(null==h.h){f=g.y;var k=g.y+g.h/2;x=g.y+g.h;k>=s-2&&k<=s+2?(h.h={type:"middle",y:k},e.y=k-e.h/2):f>=r-2&&f<=r+2?(h.h={type:"top",y:f},e.y=f):x>=a-2&&x<=a+2?(h.h={type:"bottom",y:x},e.y=x-e.h):x>=r-2&&x<=r+2?(h.h={type:"top",y:x},e.y=x):f>=a-2&&f<=a+2&&(h.h={type:"bottom",y:f},e.y=f-e.h)}if(null==h.v){v=g.x;var M=g.x+g.w/2;m=g.x+g.w;M>=l-2&&M<=l+2?(h.v={type:"center",x:M},e.x=M-e.w/2):v>=o-2&&v<=o+2?(h.v={type:"left",x:v},e.x=v):m>=d-2&&m<=d+2?(h.v={type:"right",x:m},e.x=m-e.w):m>=o-2&&m<=o+2?(h.v={type:"left",x:m},e.x=m):v>=d-2&&v<=d+2&&(h.v={type:"right",x:v},e.x=v-e.w)}if(null!=h.h&&null!=h.v)break}}this.hideSnapLine();var D=$("#designer_canvas");if(null!=h.attach){var _=$("#designer_op_snapline_attach");0==_.length&&(_=$("").appendTo(D));var I=h.attach,U=I.lineStyle.lineWidth;_.css({width:(I.props.w+U).toScale(),height:(I.props.h+U).toScale(),left:(I.props.x-U/2).toScale()-2,top:(I.props.y-U/2).toScale()-2,"z-index":$("#"+I.id).css("z-index")}).show()}if(null!=h.h){var C=$("#designer_op_snapline_h");0==C.length&&(C=$("").appendTo(D)),C.css({width:D.width()+2*Designer.config.pageMargin,left:-Designer.config.pageMargin,top:Math.round(h.h.y.toScale()),"z-index":Model.orderList.length+1}).show()}if(null!=h.v){var P=$("#designer_op_snapline_v");0==P.length&&(P=$("").appendTo(D)),P.css({height:D.height()+2*Designer.config.pageMargin,top:-Designer.config.pageMargin,left:Math.round(h.v.x.toScale()),"z-index":Model.orderList.length+1}).show()}return h},snapResizeLine:function(e,t,i){for(var n=e.y,r=e.y+e.h/2,s=e.y+e.h,a=e.x,o=e.x+e.w/2,l=e.x+e.w,d={v:null,h:null},h=Model.orderList.length-1;h>=0;h--){var p=Model.orderList[h].id,c=Model.getShapeById(p);if(!("linker"==c.name||t.indexOf(p)>=0||c.parent)){var u=c.props;if(null==d.h&&(i.indexOf("t")>=0||i.indexOf("b")>=0)){var g=u.y,y=u.y+u.h/2,f=u.y+u.h;y>=r-2&&y<=r+2?(d.h={type:"middle",y:y},i.indexOf("t")>=0?(e.h=2*(s-y),e.y=s-e.h):e.h=2*(y-e.y)):i.indexOf("t")>=0&&g>=n-2&&g<=n+2?(d.h={type:"top",y:g},e.y=g,e.h=s-g):i.indexOf("b")>=0&&f>=s-2&&f<=s+2?(d.h={type:"bottom",y:f},e.h=f-n):i.indexOf("t")>=0&&f>=n-2&&f<=n+2?(d.h={type:"top",y:f},e.y=f,e.h=s-f):i.indexOf("b")>=0&&g>=s-2&&g<=s+2&&(d.h={type:"bottom",y:g},e.h=g-e.y)}if(null==d.v&&(i.indexOf("l")>=0||i.indexOf("r")>=0)){var x=u.x,v=u.x+u.w/2,m=u.x+u.w;v>=o-2&&v<=o+2?(d.v={type:"center",x:v},i.indexOf("l")>=0?(e.w=2*(l-v),e.x=l-e.w):e.w=2*(v-e.x)):i.indexOf("l")>=0&&x>=a-2&&x<=a+2?(d.v={type:"left",x:x},e.x=x,e.w=l-x):i.indexOf("r")>=0&&m>=l-2&&m<=l+2?(d.v={type:"right",x:m},e.w=m-e.x):i.indexOf("l")>=0&&m>=a-2&&m<=a+2?(d.v={type:"left",x:m},e.x=m,e.w=l-m):i.indexOf("r")>=0&&x>=l-2&&x<=l+2&&(d.v={type:"right",x:x},e.w=x-e.x)}if(null!=d.h&&null!=d.v)break}}this.hideSnapLine();var b=$("#designer_canvas");if(null!=d.h){var S=$("#designer_op_snapline_h");0==S.length&&(S=$("").appendTo(b)),S.css({width:b.width()+2*Designer.config.pageMargin,left:-Designer.config.pageMargin,top:Math.round(d.h.y.toScale()),"z-index":Model.orderList.length+1}).show()}if(null!=d.v){var w=$("#designer_op_snapline_v");0==w.length&&(w=$("").appendTo(b)),w.css({height:b.height()+2*Designer.config.pageMargin,top:-Designer.config.pageMargin,left:Math.round(d.v.x.toScale()),"z-index":Model.orderList.length+1}).show()}return d},hideSnapLine:function(){$("#designer_op_snapline_h").hide(),$("#designer_op_snapline_v").hide(),$("#designer_op_snapline_attach").hide()},linkDashboard:function(e){var t=Model.getShapeById(e.from.id).category;if(0!=$("#panel_"+t).length){var i=$("#shape_dashboard_"+t);if(0==i.length){function n(e,t){var n="",r=$(n).appendTo(i);t&&r.append("");var s=r.children()[0];Designer.painter.drawPanelItem(s,e.name)}for(var r in i=$("").appendTo("#designer_canvas"),Schema.shapes){var s=Schema.shapes[r];if(("process_bpmn2"!=s.category&&"process.bpmn2"!=s.category&&"bpmn"!=s.category||!checkRunningTimeShape(s))&&s.category==t){var a=s.attribute;if(a.visible&&a.linkable)if(s.groupName)SchemaGroup.getGroup(s.groupName)[0]==s.name&&n(s,s.groupName);else n(s)}}i.bind("mousemove",function(e){e.stopPropagation()}).bind("mousedown",function(e){e.stopPropagation()})}function o(t){var i,n=Schema.shapes[t],r=Utils.getEndpointAngle(e,"to"),s=Utils.getAngleDir(r),a=n.getAnchors();if(1==s)for(var o=null,l=0;lh)&&(h=d.x,i=d)}}else if(3==s){var p=null;for(l=0;lp)&&(p=d.y,i=d)}}else if(4==s){var c=null;for(l=0;l