伊利适配Aris和nqms建模方法(三)
This commit is contained in:
parent
dbfd0e0b00
commit
c37c87e4b5
@ -3890,6 +3890,9 @@ var Designer = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.closePath()
|
this.closePath()
|
||||||
|
},
|
||||||
|
curveArc: function (a) {
|
||||||
|
this.arc(a.centerX, a.centerY, a.radius, a.startAngle, a.endAngle);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setLineDash: function (d, c) {
|
setLineDash: function (d, c) {
|
||||||
@ -3919,6 +3922,12 @@ var Designer = {
|
|||||||
o.lineStyle, s.lineStyle);
|
o.lineStyle, s.lineStyle);
|
||||||
var n = $.extend({},
|
var n = $.extend({},
|
||||||
o.fillStyle, s.fillStyle);
|
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++) {
|
for (var r = 0; r < s.actions.length; r++) {
|
||||||
var j = s.actions[r];
|
var j = s.actions[r];
|
||||||
this.actions[j.action].call(m, j)
|
this.actions[j.action].call(m, j)
|
||||||
@ -3955,16 +3964,22 @@ var Designer = {
|
|||||||
y: 0,
|
y: 0,
|
||||||
w: h.props.w,
|
w: h.props.w,
|
||||||
h: h.props.h,
|
h: h.props.h,
|
||||||
angle: h.props.angle
|
angle: h.props.angle,
|
||||||
|
panelProps: h.props.panelProps
|
||||||
};
|
};
|
||||||
i.clearRect(0, 0, Designer.config.panelItemWidth, Designer.config.panelItemHeight);
|
i.clearRect(0, 0, Designer.config.panelItemWidth, Designer.config.panelItemHeight);
|
||||||
if (l.w >= Designer.config.panelItemWidth || l.h >= Designer.config.panelItemWidth) {
|
if (l.w >= Designer.config.panelItemWidth || l.h >= Designer.config.panelItemWidth) {
|
||||||
if (h.props.w >= h.props.h) {
|
if (!!l.panelProps) {
|
||||||
l.w = Designer.config.panelItemWidth - h.lineStyle.lineWidth * 2;
|
l.w = h.props.w;
|
||||||
l.h = parseInt(h.props.h / h.props.w * l.w)
|
l.h = h.props.h;
|
||||||
} else {
|
} else {
|
||||||
l.h = Designer.config.panelItemHeight - h.lineStyle.lineWidth * 2;
|
if (h.props.w >= h.props.h) {
|
||||||
l.w = parseInt(h.props.w / h.props.h * l.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;
|
h.props = l;
|
||||||
@ -3973,6 +3988,14 @@ var Designer = {
|
|||||||
i.globalAlpha = h.shapeStyle.alpha;
|
i.globalAlpha = h.shapeStyle.alpha;
|
||||||
var j = (Designer.config.panelItemWidth - l.w) / 2;
|
var j = (Designer.config.panelItemWidth - l.w) / 2;
|
||||||
var k = (Designer.config.panelItemHeight - l.h) / 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(j, k);
|
||||||
i.translate(l.w / 2, l.h / 2);
|
i.translate(l.w / 2, l.h / 2);
|
||||||
i.rotate(l.angle);
|
i.rotate(l.angle);
|
||||||
@ -4217,6 +4240,7 @@ var Designer = {
|
|||||||
this.renderPath(n, q, u);
|
this.renderPath(n, q, u);
|
||||||
this.renderText(q, t);
|
this.renderText(q, t);
|
||||||
this.renderDataAttributes(q, t);
|
this.renderDataAttributes(q, t);
|
||||||
|
this.renderTitleShow(q, t);
|
||||||
Designer.painter.renderShapeLink(o, q); //节点链接
|
Designer.painter.renderShapeLink(o, q); //节点链接
|
||||||
Designer.painter.renderSahpeAttachment(o, q); //节点附件
|
Designer.painter.renderSahpeAttachment(o, q); //节点附件
|
||||||
if (q.attributesJsonArray != undefined && q.attributesJsonArray.length > 0) {
|
if (q.attributesJsonArray != undefined && q.attributesJsonArray.length > 0) {
|
||||||
@ -4263,54 +4287,83 @@ var Designer = {
|
|||||||
},
|
},
|
||||||
fillShape: function (n, i, h) {
|
fillShape: function (n, i, h) {
|
||||||
i.save();
|
i.save();
|
||||||
|
// 颜色叠加
|
||||||
|
if (typeof h.colorOverlay !== 'undefined') {
|
||||||
|
if (h.colorOverlay === 'multiplyOverlay') {
|
||||||
|
h.color = multiplyColors(h.color);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (h.type == "solid") {
|
if (h.type == "solid") {
|
||||||
i.fillStyle = "rgb(" + h.color + ")";
|
i.fillStyle = "rgb(" + h.color + ")";
|
||||||
i.fill()
|
i.fill()
|
||||||
} else {
|
} else if (h.type == "gradient") {
|
||||||
if (h.type == "gradient") {
|
var j;
|
||||||
var j;
|
if (h.gradientType == "linear") {
|
||||||
if (h.gradientType == "linear") {
|
j = GradientHelper.createLinearGradient(n, i, h)
|
||||||
j = GradientHelper.createLinearGradient(n, i, h)
|
|
||||||
} else {
|
|
||||||
j = GradientHelper.createRadialGradient(n, i, h)
|
|
||||||
}
|
|
||||||
i.fillStyle = j;
|
|
||||||
i.fill()
|
|
||||||
} else {
|
} else {
|
||||||
if (h.type == "image") {
|
j = GradientHelper.createRadialGradient(n, i, h)
|
||||||
var m = h.fileId;
|
}
|
||||||
var k = $(".shape_img[src='" + m + "']");
|
i.fillStyle = j;
|
||||||
if (k.length == 0) {
|
i.fill()
|
||||||
k = $("<img class='shape_img' loaded='0' src=''/>").appendTo("#shape_img_container");
|
} else if (h.type === "image" || h.type === "imageDef") {
|
||||||
k.bind("load.drawshape",
|
let isInvalidImage = false // 自定义图片图元 图片是否被替换标志位
|
||||||
function () {
|
let m = h.fileId
|
||||||
var b = (Designer.config.panelItemWidth - n.props.w) / 2;
|
if (h.from === 'insert') {
|
||||||
var a = (Designer.config.panelItemHeight - n.props.h) / 2;
|
m = shapeImages[h.fileId]
|
||||||
i.translate(b, a);
|
}
|
||||||
l(k);
|
if (h.type === "imageDef") {
|
||||||
i.restore();
|
if (imageDefMap[h.fileId]) {
|
||||||
$(this).attr("loaded", "1")
|
m = imageDefMap[h.fileId]
|
||||||
});
|
} else {
|
||||||
k.attr("src", m)
|
m = shapeImages[h.fileId]
|
||||||
} else {
|
isInvalidImage = true
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var k = $(".shape_img[src='" + m + "']");
|
||||||
|
if (k.length == 0) {
|
||||||
|
k = $("<img class='shape_img' loaded='0' src=''/>").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();
|
i.restore();
|
||||||
|
|
||||||
function l(r) {
|
function l(r) {
|
||||||
@ -4562,6 +4615,25 @@ var Designer = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
renderTitleShow: function (i, k) {
|
||||||
|
if (i.props.titleProps) {
|
||||||
|
var H = $("<canvas id='fixed_title" + i.id + "' class='attr_canvas'></canvas>").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) {
|
renderDataAttributes: function (i, k) {
|
||||||
$("#" + i.id).children(".attr_canvas").remove();
|
$("#" + i.id).children(".attr_canvas").remove();
|
||||||
if (!i.dataAttributes || i.dataAttributes.length == 0) {
|
if (!i.dataAttributes || i.dataAttributes.length == 0) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -278,25 +278,25 @@ var Schema = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
initShapeFunctions: function(shape) {
|
initShapeFunctions: function (shape) {
|
||||||
var pathEval = "shape.getPath = function(){var w = this.props.w; var h = this.props.h; var lineWidth = this.lineStyle.lineWidth; ";
|
var pathEval = "shape.getPath = function(){var color = [255,255,255];var fillStyle = Utils.getShapeFillStyle(this.fillStyle, false);if(fillStyle.color && fillStyle.color.length > 0){color = fillStyle.color.split(',');}var r = color[0]; var g = color[1]; var b = color[2]; var a = color[3] || 1,radial = 'radial',linear = 'linear';var w = this.props.w; var height = this.props.height; var h = this.props.h;var lineStyle = Utils.getShapeLineStyle(this.lineStyle, false); var lineWidth = lineStyle.lineWidth; ";
|
||||||
pathEval += SchemaHelper.constructPathFunBody(shape.path) + "}";
|
pathEval += SchemaHelper.constructPathFunBody(shape.path) + "}";
|
||||||
eval(pathEval);
|
eval(pathEval);
|
||||||
var block = shape.textBlock;
|
var block = shape.textBlock;
|
||||||
var textEval = "shape.getTextBlock = function(){var w = this.props.w; var h = this.props.h; return {x:";
|
var textEval = "shape.getTextBlock = function(){var w = this.props.w; var h = this.props.h; var height = this.props.height; return {x:";
|
||||||
textEval += block.x + ",y:" + block.y + ",w:" + block.w + ",h:" + block.h + "}}";
|
textEval += block.x + ",y:" + block.y + ",w:" + block.w + ",h:" + block.h + "}}";
|
||||||
eval(textEval);
|
eval(textEval);
|
||||||
var anchorsEval = "shape.getAnchors = function(){var w = this.props.w; var h = this.props.h; return [";
|
var anchorsEval = "shape.getAnchors = function(){var w = this.props.w; var h = this.props.h; return [";
|
||||||
for (var i = 0; i < shape.anchors.length; i++) {
|
for (var i = 0; i < shape.anchors.length; i++) {
|
||||||
var anchor = shape.anchors[i];
|
var anchor = shape.anchors[i];
|
||||||
anchorsEval += "{x:" + anchor.x + ", y:" + anchor.y + "}";
|
anchorsEval += "{x:" + anchor.x + ", y:" + anchor.y + "}";
|
||||||
if (i < shape.anchors.length - 1) {
|
if (i < shape.anchors.length - 1) {
|
||||||
anchorsEval += ","
|
anchorsEval += ","
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
anchorsEval += "];}";
|
anchorsEval += "];}";
|
||||||
eval(anchorsEval)
|
eval(anchorsEval)
|
||||||
},
|
},
|
||||||
initMarkers: function() {
|
initMarkers: function() {
|
||||||
for (var name in Schema.markers) {
|
for (var name in Schema.markers) {
|
||||||
var pathEval = "Schema.markers['" + name + "'] = function(size){var w = size; var h = size; var lineWidth = this.lineStyle.lineWidth; ";
|
var pathEval = "Schema.markers['" + name + "'] = function(size){var w = size; var h = size; var lineWidth = this.lineStyle.lineWidth; ";
|
||||||
@ -770,6 +770,9 @@ var SchemaHelper = {
|
|||||||
o += "{";
|
o += "{";
|
||||||
if (m.fillStyle) {
|
if (m.fillStyle) {
|
||||||
o += "fillStyle: {";
|
o += "fillStyle: {";
|
||||||
|
if (typeof m.fillStyle.colorOverlay != "undefined") {
|
||||||
|
o += "colorOverlay: '" + m.fillStyle.colorOverlay + "',"
|
||||||
|
}
|
||||||
if (typeof m.fillStyle.type != "undefined") {
|
if (typeof m.fillStyle.type != "undefined") {
|
||||||
o += "type: '" + m.fillStyle.type + "',"
|
o += "type: '" + m.fillStyle.type + "',"
|
||||||
}
|
}
|
||||||
@ -812,6 +815,27 @@ var SchemaHelper = {
|
|||||||
j += "},";
|
j += "},";
|
||||||
o += j
|
o += j
|
||||||
}
|
}
|
||||||
|
if (m.textStyle) {
|
||||||
|
var j = "textStyle: {";
|
||||||
|
if (typeof m.textStyle.text != "undefined") {
|
||||||
|
j += "text:'" + m.textStyle.text + "',"
|
||||||
|
}
|
||||||
|
if (typeof m.textStyle.size != "undefined") {
|
||||||
|
j += "size:'" + m.textStyle.size + "',"
|
||||||
|
}
|
||||||
|
if (typeof m.textStyle.color != "undefined") {
|
||||||
|
j += "color:'" + m.textStyle.color + "',"
|
||||||
|
}
|
||||||
|
if (typeof m.textStyle.x != "undefined") {
|
||||||
|
j += "x:'" + m.textStyle.x + "',"
|
||||||
|
}
|
||||||
|
if (typeof m.textStyle.y != "undefined") {
|
||||||
|
j += "y:'" + m.textStyle.y + "',"
|
||||||
|
}
|
||||||
|
j = j.substring(0, j.length - 1);
|
||||||
|
j += "},";
|
||||||
|
o += j
|
||||||
|
}
|
||||||
o += "actions:[";
|
o += "actions:[";
|
||||||
var k = m.actions;
|
var k = m.actions;
|
||||||
for (var i = 0; i < k.length; i++) {
|
for (var i = 0; i < k.length; i++) {
|
||||||
@ -825,7 +849,9 @@ var SchemaHelper = {
|
|||||||
} else {
|
} else {
|
||||||
if (n.action == "quadraticCurve") {
|
if (n.action == "quadraticCurve") {
|
||||||
o += ",x1:" + n.x1 + ",y1:" + n.y1 + ",x:" + n.x + ",y:" + n.y
|
o += ",x1:" + n.x1 + ",y1:" + n.y1 + ",x:" + n.x + ",y:" + n.y
|
||||||
}
|
} else if (n.action == "curveArc") {
|
||||||
|
o += ",centerX:" + n.centerX + ",centerY:" + n.centerY + ",radius:" + n.radius + ",startAngle:" + n.startAngle + ",endAngle:" + n.endAngle
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
o += "}";
|
o += "}";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user