伊利适配Aris和nqms建模方法(三)
This commit is contained in:
parent
dbfd0e0b00
commit
c37c87e4b5
@ -3890,6 +3890,9 @@ var Designer = {
|
||||
}
|
||||
}
|
||||
this.closePath()
|
||||
},
|
||||
curveArc: function (a) {
|
||||
this.arc(a.centerX, a.centerY, a.radius, a.startAngle, a.endAngle);
|
||||
}
|
||||
},
|
||||
setLineDash: function (d, c) {
|
||||
@ -3919,6 +3922,12 @@ var Designer = {
|
||||
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)
|
||||
@ -3955,10 +3964,15 @@ var Designer = {
|
||||
y: 0,
|
||||
w: h.props.w,
|
||||
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);
|
||||
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)
|
||||
@ -3967,12 +3981,21 @@ var Designer = {
|
||||
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);
|
||||
@ -4217,6 +4240,7 @@ var Designer = {
|
||||
this.renderPath(n, q, u);
|
||||
this.renderText(q, t);
|
||||
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) {
|
||||
@ -4263,11 +4287,16 @@ var Designer = {
|
||||
},
|
||||
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") {
|
||||
} else if (h.type == "gradient") {
|
||||
var j;
|
||||
if (h.gradientType == "linear") {
|
||||
j = GradientHelper.createLinearGradient(n, i, h)
|
||||
@ -4276,24 +4305,38 @@ var Designer = {
|
||||
}
|
||||
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 {
|
||||
if (h.type == "image") {
|
||||
var m = h.fileId;
|
||||
m = shapeImages[h.fileId]
|
||||
isInvalidImage = true
|
||||
}
|
||||
}
|
||||
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 = (Designer.config.panelItemWidth - n.props.w) / 2;
|
||||
var a = (Designer.config.panelItemHeight - n.props.h) / 2;
|
||||
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") {
|
||||
} else if (k.attr("loaded") == "0") {
|
||||
k.bind("load.drawshape",
|
||||
function () {
|
||||
// var b = (Designer.config.panelItemWidth - n.props.w) / 2;
|
||||
@ -4308,9 +4351,19 @@ var Designer = {
|
||||
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) {
|
||||
@ -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) {
|
||||
$("#" + i.id).children(".attr_canvas").remove();
|
||||
if (!i.dataAttributes || i.dataAttributes.length == 0) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -279,11 +279,11 @@ var Schema = {
|
||||
}
|
||||
},
|
||||
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) + "}";
|
||||
eval(pathEval);
|
||||
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 + "}}";
|
||||
eval(textEval);
|
||||
var anchorsEval = "shape.getAnchors = function(){var w = this.props.w; var h = this.props.h; return [";
|
||||
@ -770,6 +770,9 @@ var SchemaHelper = {
|
||||
o += "{";
|
||||
if (m.fillStyle) {
|
||||
o += "fillStyle: {";
|
||||
if (typeof m.fillStyle.colorOverlay != "undefined") {
|
||||
o += "colorOverlay: '" + m.fillStyle.colorOverlay + "',"
|
||||
}
|
||||
if (typeof m.fillStyle.type != "undefined") {
|
||||
o += "type: '" + m.fillStyle.type + "',"
|
||||
}
|
||||
@ -812,6 +815,27 @@ var SchemaHelper = {
|
||||
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:[";
|
||||
var k = m.actions;
|
||||
for (var i = 0; i < k.length; i++) {
|
||||
@ -825,6 +849,8 @@ var SchemaHelper = {
|
||||
} else {
|
||||
if (n.action == "quadraticCurve") {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user