kTrade method
dynamic
kTrade(
- dynamic x,
- dynamic y,
- dynamic w,
- dynamic h,
Implementation
kTrade(x, y, w, h) {
var pathData = {};
var linePath = [];
// var txtPath = [];
dynamic obj = {};
double oy = 0;
int i = 0;
double doublePadding = 8;
var gdt1Size = {};
double gdt1w = 0; //第一段文案宽度
var gdt2Size = {};
double gdt2w = 0; //第二段文案宽度
double gdt3w = 0;// //第三段文案宽度
var zyzstxtSize = {}; //止盈止损按钮文字尺寸
double infoBgH = 28; //信息背景矩形块高度
double infoBgLeft = x + 30; //信息背景矩形块距离左边距离
num zIndex = 0;
num zyzsIndex = 0;
double txtOffy = 1;
var allPathList = {};
var wObj = {};
double yPriceBgw = initYW-20+doublePadding;
double yPriceBgx = x + w - yPriceBgw-10+doublePadding/2;
//挂单 外部传进来最好是排序的,因为顺序会决定当两条数据重叠时,优先检测哪一条,检测到就不在检测
if (chartData.orderData.isNotEmpty) {
var styleProperty = style['orderLineStyle']['property'];
var reactRound = styleProperty['reactRound'];
// var lineColor = styleProperty['lineColor']; //线颜色
// var lineStrokeWidth = styleProperty['lineStrokeWidth']; //线宽
// var lineDotted = styleProperty['lineDotted']; //挂单线是否绘制虚线
// var infoBorderColor = styleProperty['infoBorderColor']; //信息边线色
var infoFullColor = styleProperty['infoFullColor']; //信息填充色
var infoStrokeWidth = styleProperty['infoStrokeWidth']; //信息边线宽
var infoFontColor = styleProperty['infoFontColor']; //信息字体颜色
// var amountBorderColor = styleProperty['amountBorderColor']; //数量边线色
var amountFullColor = styleProperty['amountFullColor']; //数量填充色
var amountStrokeWidth = styleProperty['amountStrokeWidth']; //数量边线宽
// var amountFontColor = styleProperty['amountFontColor']; //数量字体颜色
// var zyzsBtnBorderColor = styleProperty['zyzsBtnBorderColor']; //止盈止损边线色
var zyzsBtnFullColor = styleProperty['zyzsBtnFullColor']; //止盈止损填充色
var zyzsBtnStrokeWidth = styleProperty['zyzsBtnStrokeWidth']; //止盈止损边线宽
// var zyzsBtnFontColor = styleProperty['zyzsBtnFontColor']; //止盈止损字体颜色
// var closeBorderColor = styleProperty['closeBorderColor']; //关闭边线色
var closeFullColor = styleProperty['closeFullColor']; //关闭填充色
var closeStrokeWidth = styleProperty['closeStrokeWidth']; //关闭边线宽
var closeFontColor = styleProperty['closeFontColor']; //关闭字体颜色
// var yPriceBorderColor = styleProperty['yPriceBorderColor']; //y轴价格边线色
var yPriceFullColor = styleProperty['yPriceFullColor']; //y轴价格填充色
var yPriceStrokeWidth = styleProperty['yPriceStrokeWidth']; //y轴价格边线宽
// var yPriceFontColor = styleProperty['yPriceFontColor']; //y轴价格字体颜色
var zyzsDotted = styleProperty['zyzsDotted']; //止盈止损线是否绘制虚线
// var zyzsInfoFontColor =
// styleProperty['zyzsInfoFontColor']; //这里是止盈止损线的信息内容字体颜色
for (i = 0; i < chartData.orderData.length; i++) {
obj = chartData.orderData[i];
var objList = [];
allPathList[obj['tr_id']] = objList;
if (obj['codeId'] != klineState.widget.propertys['codeId'] ||
obj['tr_price'] > kMax ||
obj['tr_price'] < kMin) {
continue;
}
obj['projectType'] = klineState
.widget.propertys['projectType']; // spot现货 swap合约
obj['type'] = "gd"; //数据类型挂单
zyzsIndex = zIndex; //止盈止损线,底线-=1; 边框+=1;文字+=2;
zIndex += 4; //挂单线,底线-=1;边框+=1;文字+=2;
if (widthMap[obj['tr_id']] != null) {
wObj = widthMap[obj['tr_id']];
} else {
wObj = {
'gdt1w': 0.0,
'gdt1wzy': 0.0,
'gdt1wzs': 0.0,
'gdt2w': 0.0,
'gdt2wzy': 0.0,
'gdt2wzs': 0.0
};
widthMap[obj['tr_id']] = wObj;
}
oy = Tools.priceToY(h, obj['tr_price'], kYMin, kScale);
var fullColor = style[ColorType['upColor']];
if (obj.containsKey('tr_side')) {
switch (obj['tr_side']) {
case 1: //现货买入 上涨色
fullColor = style[ColorType['upColor']];
break;
case 2: //现货卖出 下跌色
fullColor = style[ColorType['downColor']];
break;
case 3: //合约开多 上涨色
fullColor = style[ColorType['upColor']];
break;
case 4: //合约开空
fullColor = style[ColorType['downColor']];
break;
case 5: //合约平多 上涨色
fullColor = style[ColorType['upColor']];
break;
case 6: //合约平空
fullColor = style[ColorType['downColor']];
break;
}
}
//测量
gdt1Size = Tools.getStrW(obj['info'], style['orderLineStyle']['font']);
gdt1w = gdt1Size['width'];
//取最大值
gdt1w = Tools.max(wObj['gdt1w'], gdt1w);
wObj['gdt1w'] = gdt1w;
//测量
gdt2Size =
Tools.getStrW(obj['tr_amount'], style['orderLineStyle']['font']);
gdt2w = gdt2Size['width'];
//取最大值
gdt2w = Tools.max(wObj['gdt2w'], gdt2w);
wObj['gdt2w'] = gdt2w;
//挂单信息背景y坐标
infoBgH = gdt1Size['height'] + doublePadding;
gdt3w = infoBgH;
var bg1 = [], bg2 = [], bg3 = [], bg4 = [], bg5 = [];
//=========================委托线==========================
if (obj['tr_order_show']) {
bg1 = [
infoBgLeft,
y + oy - infoBgH / 2,
gdt1w + doublePadding,
infoBgH,
[reactRound,0.0,0.0,reactRound]
];
//信息背景
callTradeLineReactPath(
linePath, objList, 'gd', zIndex, fullColor, bg1, true, infoStrokeWidth, fullColor);
//信息
callTradeLineTxtPath(linePath, objList, 'gd', zIndex, infoFontColor, [
obj['info'],
bg1[0] + bg1[2] / 2,
y + oy,
{'xlayout': 'center', 'ylayout': 'center'}
]);
bg2 = [
bg1[0] + bg1[2],
bg1[1],
gdt2w + doublePadding,
bg1[3],
];
//数量背景
callTradeLineReactPath(linePath, objList, 'gd', zIndex,
amountFullColor, bg2, true, amountStrokeWidth, fullColor);
//数量
callTradeLineTxtPath(
linePath, objList, 'gd', zIndex, fullColor, [
obj['tr_amount'],
bg2[0] + bg2[2] / 2,
y + oy + txtOffy,
{'xlayout': 'center', 'ylayout': 'center'}
]);
bg3 = [
bg2[0] + bg2[2],
bg2[1],
gdt3w,
bg2[3],
[0.0,reactRound,reactRound,0.0]
];
//关闭背景
callTradeLineReactPath(linePath, objList, 'gd', zIndex,
closeFullColor, bg3, true, closeStrokeWidth, fullColor);
//关闭按钮
callTradeLineXPath(linePath, objList, 'gd', zIndex, closeFontColor, bg3);
//关闭按钮尺寸
obj['xSize'] = {'x': bg3[0], 'y': bg3[1], 'w': bg3[2], 'h': bg3[3]};
//左侧全部尺寸
obj['leftSize'] = {
'x': bg1[0],
'y': bg1[1],
'w': bg3[0] + bg3[2] - bg1[0],
'h': bg1[3]
};
obj['oy'] = oy;
obj['zyzsSize'] = {};
if (obj['tr_order_zyzsbtn_show']) {
zyzstxtSize = Tools.getStrW(obj['zyzsTxt'], style['orderLineStyle']['font']);
bg4 = [
bg3[0] + bg3[2] + 20,
bg3[1],
zyzstxtSize['width'] + doublePadding,
bg3[3],
reactRound
];
//信息背景
callTradeLineReactPath(
linePath,
objList,
'gd',
zIndex,
zyzsBtnFullColor,
bg4,
true,
zyzsBtnStrokeWidth,
fullColor);
//信息
callTradeLineTxtPath(
linePath, objList, 'gd', zIndex, fullColor, [
obj['zyzsTxt'],
bg4[0] + bg4[2] / 2,
y + oy,
{'xlayout': 'center', 'ylayout': 'center'}
]);
//止盈止损文案尺寸
obj['zyzsSize'] = {
'x': bg4[0],
'y': bg4[1],
'w': bg4[2],
'h': bg4[3]
};
//左侧全部尺寸
obj['leftSize'] = {
'x': bg1[0],
'y': bg1[1],
'w': bg4[0] + bg4[2] - bg1[0],
'h': bg1[3]
};
}
//挂单线
var lineData2 = {
'drawType': 'linePath',
'type': 'gd',
'zIndex': zIndex - 1,
'stroke': {
'color': fullColor,
'style': PaintingStyle.stroke,
},
'linePath': [
[
"moveTo",
[x, y + oy]
],
[
"lineTo",
[yPriceBgx, y + oy]
]
],
};
linePath.insert(0, lineData2);
objList.insert(0, lineData2);
bg5 = [yPriceBgx, bg1[1], yPriceBgw, bg1[3], reactRound];
//y轴价格背景
callTradeLineReactPath(
linePath,
objList,
'gd',
zIndex,
yPriceFullColor,
bg5,
true,
yPriceStrokeWidth,
fullColor);
//y轴价格信息
callTradeLineTxtPath(
linePath, objList, 'gd', zIndex, fullColor, [
obj['tr_price'],
bg5[0] + bg5[2] / 2,
y + oy,
{'xlayout': 'center', 'ylayout': 'center'}
]);
}
//=========================委托止盈线========================
obj['zyxSize'] = {};
obj['zyoy'] = 0;
obj['leftZySize'] = {};
if (obj['tr_order_zyzs_show'] &&
obj.containsKey('tr_zy_price') &&
obj['tr_zy_price'] < kMax &&
obj['tr_zy_price'] > kMin) {
//绘制止盈线
oy = Tools.priceToY(h, obj['tr_zy_price'], kYMin, kScale);
bg1 = [];
bg2 = [];
bg3 = [];
bg4 = [];
bg5 = [];
var trzytxt = obj.containsKey('tr_zy_order_price') &&
obj['tr_zy_order_price'] > 0
? obj['tr_zy_limitstr']
: obj['tr_zy_marketstr'];
//测量
gdt1Size = Tools.getStrW(trzytxt, style['orderLineStyle']['font']);
gdt1w = gdt1Size['width'];
//取最大值
gdt1w = Tools.max(wObj['gdt1wzy'], gdt1w);
wObj['gdt1wzy'] = gdt1w;
//测量
gdt2Size = Tools.getStrW(
obj['tr_amount'], style['orderLineStyle']['font']);
gdt2w = gdt2Size['width'];
//取最大值
gdt2w = Tools.max(wObj['gdt2wzy'], gdt2w);
wObj['gdt2wzy'] = gdt2w;
bg1 = [
infoBgLeft,
y + oy - infoBgH / 2,
gdt1w + doublePadding,
infoBgH,
[reactRound,0.0,0.0,reactRound]
];
//止盈背景
callTradeLineReactPath(linePath, objList, 'gdzy', zyzsIndex,
infoFullColor, bg1, true, infoStrokeWidth, style[ColorType['upColor']]);
//止盈信息
callTradeLineTxtPath(
linePath, objList, 'gdzy', zyzsIndex, style[ColorType['upColor']], [
trzytxt,
bg1[0] + bg1[2] / 2,
y + oy,
{'xlayout': 'center', 'ylayout': 'center'}
]);
bg2 = [bg1[0] + bg1[2], bg1[1], gdt2w + doublePadding, bg1[3]];
//数量背景
callTradeLineReactPath(
linePath,
objList,
'gdzy',
zyzsIndex,
amountFullColor,
bg2,
true,
amountStrokeWidth,
style[ColorType['upColor']]);
//数量信息
callTradeLineTxtPath(
linePath, objList, 'gdzy', zyzsIndex, style[ColorType['upColor']], [
obj['tr_amount'],
bg2[0] + bg2[2] / 2,
y + oy + txtOffy,
{'xlayout': 'center', 'ylayout': 'center'}
]);
bg3 = [
bg2[0] + bg2[2],
bg2[1],
gdt3w,
bg2[3],
[0.0,reactRound,reactRound,0.0]
];
//关闭背景
callTradeLineReactPath(linePath, objList, 'gdzy', zyzsIndex,
closeFullColor, bg3, true, closeStrokeWidth, style[ColorType['upColor']]);
//关闭按钮
callTradeLineXPath(linePath, objList, 'gdzy', zyzsIndex, closeFontColor, bg3);
//止盈关闭按钮尺寸
obj['zyxSize'] = {
'x': bg3[0],
'y': bg3[1],
'w': bg3[2],
'h': bg3[3]
};
obj['zyoy'] = oy;
//止盈线
var lineData4 = {
'drawType': 'linePath',
'type': 'gdzy',
'zIndex': zyzsIndex - 1,
'stroke': {
'color': style[ColorType['upColor']],
'style': PaintingStyle.stroke,
},
'property': {'dottedLine': zyzsDotted},
'linePath': [
[
"moveTo",
[x, y + oy]
],
[
"lineTo",
[yPriceBgx, y + oy]
]
],
};
linePath.insert(0, lineData4);
objList.insert(0, lineData4);
bg4 = [yPriceBgx, bg3[1], yPriceBgw, bg3[3], reactRound];
//y轴价格背景
callTradeLineReactPath(linePath, objList, 'gdzy', zyzsIndex,
yPriceFullColor, bg4, true, yPriceStrokeWidth, style[ColorType['upColor']]);
//y轴价格信息
callTradeLineTxtPath(
linePath, objList, 'gdzy', zyzsIndex, style[ColorType['upColor']], [
obj['tr_zy_price'],
bg4[0] + bg4[2] / 2,
y + oy,
{'xlayout': 'center', 'ylayout': 'center'}
]);
//左侧全部尺寸
obj['leftZySize'] = {
'x': bg1[0],
'y': bg1[1],
'w': bg3[0] + bg3[2] - bg1[0],
'h': bg1[3]
};
}
//=========================委托止损线========================
obj['zsxSize'] = {};
obj['zsoy'] = 0;
obj['leftZsSize'] = {};
if (obj['tr_order_zyzs_show'] &&
obj.containsKey('tr_zs_price') &&
obj['tr_zs_price'] < kMax &&
obj['tr_zs_price'] > kMin) {
//绘制止损线
oy = Tools.priceToY(h, obj['tr_zs_price'], kYMin, kScale);
var trzstxt = obj.containsKey('tr_zs_order_price') &&
obj['tr_zs_order_price'] > 0
? obj['tr_zs_limitstr']
: obj['tr_zs_marketstr'];
//测量
gdt1Size = Tools.getStrW(trzstxt, style['orderLineStyle']['font']);
gdt1w = gdt1Size['width'];
//取最大值
gdt1w = Tools.max(wObj['gdt1wzs'], gdt1w);
wObj['gdt1wzs'] = gdt1w;
//测量
gdt2Size = Tools.getStrW(
obj['tr_amount'], style['orderLineStyle']['font']);
gdt2w = gdt2Size['width'];
//取最大值
gdt2w = Tools.max(wObj['gdt2wzs'], gdt2w);
wObj['gdt2wzs'] = gdt2w;
bg1 = [
infoBgLeft,
y + oy - infoBgH / 2,
gdt1w + doublePadding,
infoBgH,
[reactRound,0.0,0.0,reactRound]
];
//止盈背景
callTradeLineReactPath(linePath, objList, 'gdzs', zyzsIndex,
infoFullColor, bg1, true, infoStrokeWidth, style[ColorType['downColor']]);
//止盈信息
callTradeLineTxtPath(
linePath, objList, 'gdzs', zyzsIndex, style[ColorType['downColor']], [
trzstxt,
bg1[0] + bg1[2] / 2,
y + oy,
{'xlayout': 'center', 'ylayout': 'center'}
]);
bg2 = [
bg1[0] + bg1[2],
bg1[1],
gdt2w + doublePadding,
bg1[3],
];
//数量背景
callTradeLineReactPath(
linePath,
objList,
'gdzs',
zyzsIndex,
amountFullColor,
bg2,
true,
amountStrokeWidth,
style[ColorType['downColor']]);
//数量信息
callTradeLineTxtPath(
linePath, objList, 'gdzs', zyzsIndex, style[ColorType['downColor']], [
obj['tr_amount'],
bg2[0] + bg2[2] / 2,
y + oy + txtOffy,
{'xlayout': 'center', 'ylayout': 'center'}
]);
bg3 = [
bg2[0] + bg2[2],
bg2[1],
gdt3w,
bg2[3],
[0.0,reactRound,reactRound,0.0]
];
//关闭背景
callTradeLineReactPath(linePath, objList, 'gdzs', zyzsIndex,
closeFullColor, bg3, true, closeStrokeWidth, style[ColorType['downColor']]);
//关闭按钮
callTradeLineXPath(linePath, objList, 'gdzs', zyzsIndex, closeFontColor, bg3);
//止损关闭按钮尺寸
obj['zsxSize'] = {
'x': bg3[0],
'y': bg3[1],
'w': bg3[2],
'h': bg3[3]
};
obj['zsoy'] = oy;
//止损线
var lineData4 = {
'drawType': 'linePath',
'type': 'gdzs',
'zIndex': zyzsIndex - 1,
'stroke': {
'color': style[ColorType['downColor']],
'style': PaintingStyle.stroke,
},
'property': {'dottedLine': zyzsDotted},
'linePath': [
[
"moveTo",
[x, y + oy]
],
[
"lineTo",
[yPriceBgx, y + oy]
]
],
};
linePath.insert(0, lineData4);
objList.insert(0, lineData4);
bg4 = [yPriceBgx, bg3[1], yPriceBgw, bg3[3], reactRound];
//y轴价格背景
callTradeLineReactPath(linePath, objList, 'gdzs', zyzsIndex,
yPriceFullColor, bg4, true, yPriceStrokeWidth, style[ColorType['downColor']]);
//y轴价格信息
callTradeLineTxtPath(
linePath, objList, 'gdzs', zyzsIndex, style[ColorType['downColor']], [
obj['tr_zs_price'],
bg4[0] + bg4[2] / 2,
y + oy,
{'xlayout': 'center', 'ylayout': 'center'}
]);
//左侧全部尺寸
obj['leftZsSize'] = {
'x': bg1[0],
'y': bg1[1],
'w': bg3[0] + bg3[2] - bg1[0],
'h': bg3[3]
};
}
zIndex += 4;
}
}
//持仓 posData 外部传进来最好是排序的,因为顺序会决定当两条数据重叠时,优先检测哪一条,检测到就不在检测
if (chartData.positionData.isNotEmpty) {
var styleProperty = style['posLineStyle']['property'];
var reactRound = styleProperty['reactRound'];
// var lineColor = styleProperty['lineColor']; //线颜色
// var lineStrokeWidth = styleProperty['lineStrokeWidth']; //线宽
// var lineDotted = styleProperty['lineDotted']; //挂单线是否绘制虚线
// var infoBorderColor = styleProperty['infoBorderColor']; //信息边线色
var infoFullColor = styleProperty['infoFullColor']; //信息填充色
var infoStrokeWidth = styleProperty['infoStrokeWidth']; //信息边线宽
var infoFontColor = styleProperty['infoFontColor']; //信息字体颜色
// var amountBorderColor = styleProperty['amountBorderColor']; //数量边线色
var amountFullColor = styleProperty['amountFullColor']; //数量填充色
var amountStrokeWidth = styleProperty['amountStrokeWidth']; //数量边线宽
// var amountFontColor = styleProperty['amountFontColor']; //数量字体颜色
// var zyzsBtnBorderColor = styleProperty['zyzsBtnBorderColor']; //止盈止损边线色
var zyzsBtnFullColor = styleProperty['zyzsBtnFullColor']; //止盈止损填充色
var zyzsBtnStrokeWidth = styleProperty['zyzsBtnStrokeWidth']; //止盈止损边线宽
// var zyzsBtnFontColor = styleProperty['zyzsBtnFontColor']; //止盈止损字体颜色
// var closeBorderColor = styleProperty['closeBorderColor']; //关闭边线色
var closeFullColor = styleProperty['closeFullColor']; //关闭填充色
var closeStrokeWidth = styleProperty['closeStrokeWidth']; //关闭边线宽
var closeFontColor = styleProperty['closeFontColor']; //关闭字体颜色
// var yPriceBorderColor = styleProperty['yPriceBorderColor']; //y轴价格边线色
var yPriceFullColor = styleProperty['yPriceFullColor']; //y轴价格填充色
var yPriceStrokeWidth = styleProperty['yPriceStrokeWidth']; //y轴价格边线宽
// var yPriceFontColor = styleProperty['yPriceFontColor']; //y轴价格字体颜色
var zyzsDotted = styleProperty['zyzsDotted']; //止盈止损线是否绘制虚线
// var zyzsInfoFontColor =
// styleProperty['zyzsInfoFontColor']; //这里是止盈止损线的信息内容字体颜色
for (i = 0; i < chartData.positionData.length; i++) {
obj = chartData.positionData[i];
var objList = [];
allPathList[obj['tr_id']] = objList;
if (obj['codeId'] != klineState.widget.propertys['codeId'] ||
obj['tr_price'] > kMax ||
obj['tr_price'] < kMin) {
continue;
}
obj['projectType'] = klineState
.widget.propertys['projectType']; // spot现货 swap合约
obj['type'] = "cc"; //持仓
zyzsIndex = zIndex; //止盈止损线,底线-=1; 边框+=1;文字+=2;
zIndex += 4; //挂单线,底线-=1;边框+=1;文字+=2;
if (widthMap[obj['tr_id']] != null) {
wObj = widthMap[obj['tr_id']];
} else {
wObj = {
'gdt1w': 0.0,
'gdt1wzy': 0.0,
'gdt1wzs': 0.0,
'gdt2w': 0.0,
'gdt2wzy': 0.0,
'gdt2wzs': 0.0
};
widthMap[obj['tr_id']] = wObj;
}
oy = Tools.priceToY(h, obj['tr_price'], kYMin, kScale);
var fullColor = style[ColorType['downColor']];
if (obj.containsKey('tr_side')) {
switch (obj['tr_side']) {
case 3: //合约开多
fullColor = style[ColorType['upColor']];
break;
case 4: //合约开空
fullColor = style[ColorType['downColor']];
break;
case 5: //合约平多
fullColor = style[ColorType['upColor']];
break;
case 6: //合约平空
fullColor = style[ColorType['downColor']];
break;
}
}
var yk = (obj['tr_yk']) > 0 ? "+${obj['tr_yk']}" : obj['tr_yk'];
yk = "${obj['info']} $yk";
var ykColor = obj['tr_yk'] > 0
? style[ColorType['upColor']]
: style[ColorType['downColor']];
//测量
gdt1Size = Tools.getStrW(yk, style['posLineStyle']['font']);
gdt1w = gdt1Size['width'];
//取最大值
gdt1w = Tools.max(wObj['gdt1w'], gdt1w);
wObj['gdt1w'] = gdt1w;
//测量
gdt2Size =
Tools.getStrW(obj['tr_amount'], style['posLineStyle']['font']);
gdt2w = gdt2Size['width'];
//取最大值
gdt2w = Tools.max(wObj['gdt2w'], gdt2w);
wObj['gdt2w'] = gdt2w;
infoBgH = gdt1Size['height'] + doublePadding;
gdt3w = infoBgH;
//持仓信息背景y坐标
var bg1 = [], bg2 = [], bg3 = [], bg4 = [], bg5 = [];
//=========================持仓线========================
if (obj['tr_position_show']) {
//止盈止损展示
var zyzstxt = obj['zyzsTxt']; //"止盈/止损"
zyzstxtSize =
Tools.getStrW(obj['zyzsTxt'], style['posLineStyle']['font']);
var zyzstxtw = zyzstxtSize['width'];
bg1 = [
x +
Tools.round((w -
(gdt1w +
doublePadding +
gdt2w +
doublePadding +
gdt3w +
doublePadding +
20 +
zyzstxtw +
doublePadding)) /
2),
y + oy - infoBgH / 2,
gdt1w + doublePadding,
infoBgH,
[reactRound,0.0,0.0,reactRound]
];
//信息背景
callTradeLineReactPath(
linePath, objList, 'cc', zIndex, ykColor, bg1, true, infoStrokeWidth, ykColor);
//信息
callTradeLineTxtPath(linePath, objList, 'cc', zIndex, infoFontColor, [
yk,
bg1[0] + bg1[2] / 2,
y + oy,
{'ylayout': 'center', 'xlayout': 'center'}
]);
bg2 = [
bg1[0] + bg1[2],
bg1[1],
gdt2w + doublePadding,
bg1[3],
];
//数量背景
callTradeLineReactPath(linePath, objList, 'cc', zIndex,
amountFullColor, bg2, true, amountStrokeWidth, ykColor);
//数量
callTradeLineTxtPath(
linePath, objList, 'cc', zIndex, ykColor, [
obj['tr_amount'],
bg2[0] + bg2[2] / 2,
y + oy + txtOffy,
{'ylayout': 'center', 'xlayout': 'center'}
]);
bg3 = [
bg2[0] + bg2[2],
bg2[1],
gdt3w,
bg2[3],
[0.0,reactRound,reactRound,0.0]
];
//关闭背景
callTradeLineReactPath(linePath, objList, 'cc', zIndex,
closeFullColor, bg3, true, closeStrokeWidth, ykColor);
//关闭按钮
callTradeLineXPath(linePath, objList, 'cc', zIndex, closeFontColor, bg3);
//持仓信息关闭按钮尺寸
obj['xSize'] = {'x': bg3[0], 'y': bg3[1], 'w': bg3[2], 'h': bg3[3]};
obj['oy'] = oy;
//左侧全部尺寸
obj['leftSize'] = {
'x': bg1[0],
'y': bg1[1],
'w': bg3[0] + bg3[2] - bg1[0],
'h': bg1[3]
};
//持仓线
var lineData4 = {
'drawType': 'linePath',
'type': 'cc',
'zIndex': zIndex - 1,
'stroke': {
'color': fullColor,
'style': PaintingStyle.stroke,
},
'linePath': [
[
"moveTo",
[x, y + oy]
],
[
"lineTo",
[yPriceBgx, y + oy]
]
],
};
linePath.insert(0, lineData4);
objList.insert(0, lineData4);
obj['zyzsSize'] = {};
if(obj['tr_position_zyzsbtn_show']){
bg4 = [
bg3[0] + bg3[2] + 20,
bg3[1],
zyzstxtSize['width'] + doublePadding,
bg3[3],
reactRound
];
//止盈止损背景
callTradeLineReactPath(
linePath,
objList,
'cc',
zIndex,
zyzsBtnFullColor,
bg4,
true,
zyzsBtnStrokeWidth,
ykColor);
//信息
callTradeLineTxtPath(
linePath, objList, 'cc', zIndex, ykColor, [
zyzstxt,
bg4[0] + bg4[2] / 2,
y + oy,
{'ylayout': 'center', 'xlayout': 'center'}
]);
//止盈止损尺寸
obj['zyzsSize'] = {
'x': bg4[0],
'y': bg4[1],
'w': bg4[2],
'h': bg4[3]
};
//左侧全部尺寸
obj['leftSize'] = {
'x': bg1[0],
'y': bg1[1],
'w': bg4[0] + bg4[2] - bg1[0],
'h': bg1[3]
};
}
bg5 = [yPriceBgx, bg4[1], yPriceBgw, bg4[3], reactRound];
//y轴价格背景
callTradeLineReactPath(
linePath, objList, 'cc', zIndex, yPriceFullColor, bg5, true, yPriceStrokeWidth, ykColor);
//y轴价格信息
callTradeLineTxtPath(
linePath, objList, 'cc', zIndex, ykColor, [
obj['tr_price'],
bg5[0] + bg5[2] / 2,
y + oy,
{'ylayout': 'center', 'xlayout': 'center'}
]);
}
//=========================持仓止盈线========================
obj['zyxSize'] = {};
obj['zyoy'] = 0;
obj['leftZySize'] = {};
if (obj['tr_position_zyzs_show'] &&
obj.containsKey('tr_zy_price') &&
obj['tr_zy_price'] < kMax &&
obj['tr_zy_price'] > kMin) {
//绘制止盈线
oy = Tools.priceToY(h, obj['tr_zy_price'], kYMin, kScale);
var trzytxt = obj.containsKey('tr_zy_order_price') &&
obj['tr_zy_order_price'] > 0
? obj['tr_zy_limitstr']
: obj['tr_zy_marketstr'];
//测量
gdt1Size = Tools.getStrW(trzytxt, style['posLineStyle']['font']);
gdt1w = gdt1Size['width'];
//取最大值
gdt1w = Tools.max(wObj['gdt1wzy'], gdt1w);
wObj['gdt1wzy'] = gdt1w;
//测量
gdt2Size =
Tools.getStrW(obj['tr_amount'], style['posLineStyle']['font']);
gdt2w = gdt2Size['width'];
//取最大值
gdt2w = Tools.max(wObj['gdt2wzy'], gdt2w);
wObj['gdt2wzy'] = gdt2w;
bg1 = [];
bg2 = [];
bg3 = [];
bg4 = [];
bg1 = [
infoBgLeft,
y + oy - infoBgH / 2,
gdt1w + doublePadding,
infoBgH,
[reactRound,0.0,0.0,reactRound]
];
//止盈背景
callTradeLineReactPath(linePath, objList, 'cczy', zyzsIndex,
infoFullColor, bg1, true, infoStrokeWidth, style[ColorType['upColor']]);
//止盈信息
callTradeLineTxtPath(
linePath, objList, 'cczy', zyzsIndex, style[ColorType['upColor']], [
trzytxt,
bg1[0] + bg1[2] / 2,
y + oy,
{'ylayout': 'center', 'xlayout': 'center'}
]);
bg2 = [
bg1[0] + bg1[2],
bg1[1],
gdt2w + doublePadding,
bg1[3],
];
//数量背景
callTradeLineReactPath(linePath, objList, 'cczy', zyzsIndex,
amountFullColor, bg2, true, amountStrokeWidth, style[ColorType['upColor']]);
//数量信息
callTradeLineTxtPath(
linePath, objList, 'cczy', zyzsIndex, style[ColorType['upColor']], [
obj['tr_amount'],
bg2[0] + bg2[2] / 2,
y + oy + txtOffy,
{'ylayout': 'center', 'xlayout': 'center'}
]);
bg3 = [
bg2[0] + bg2[2],
bg2[1],
gdt3w ,
bg2[3],
[0.0,reactRound,reactRound,0.0]
];
//关闭背景
callTradeLineReactPath(linePath, objList, 'cczy', zyzsIndex,
closeFullColor, bg3, true, closeStrokeWidth, style[ColorType['upColor']]);
//关闭按钮
callTradeLineXPath(linePath, objList, 'cczy', zyzsIndex, closeFontColor, bg3);
//止盈关闭按钮尺寸
obj['zyxSize'] = {'x': bg3[0], 'y': bg3[1], 'w': bg3[2], 'h': bg3[3]};
obj['zyoy'] = oy;
//止盈文案
//止盈线
var lineData4 = {
'drawType': 'linePath',
'type': 'cczy',
'zIndex': zyzsIndex - 1,
'stroke': {
'color': style[ColorType['upColor']],
'style': PaintingStyle.stroke,
},
'property': {'dottedLine': zyzsDotted},
'linePath': [
[
"moveTo",
[x, y + oy]
],
[
"lineTo",
[yPriceBgx, y + oy]
]
],
};
linePath.insert(0, lineData4);
objList.insert(0, lineData4);
bg4 = [yPriceBgx, bg3[1], yPriceBgw, bg3[3], reactRound];
//y轴价格背景
callTradeLineReactPath(linePath, objList, 'cczy', zyzsIndex,
yPriceFullColor, bg4, true, yPriceStrokeWidth, style[ColorType['upColor']]);
//y轴价格信息
callTradeLineTxtPath(
linePath, objList, 'cczy', zyzsIndex, style[ColorType['upColor']], [
obj['tr_zy_price'],
bg4[0] + bg4[2] / 2,
y + oy,
{'ylayout': 'center', 'xlayout': 'center'}
]);
//左侧全部尺寸
obj['leftZySize'] = {
'x': bg1[0],
'y': bg1[1],
'w': bg3[0] + bg3[2] - bg1[0],
'h': bg1[3]
};
}
obj['zsxSize'] = {};
obj['zsoy'] = 0;
obj['leftZsSize'] = {};
//=========================持仓止损线========================
if (obj['tr_position_zyzs_show'] &&
obj.containsKey('tr_zs_price') &&
obj['tr_zs_price'] < kMax &&
obj['tr_zs_price'] > kMin) {
//绘制止损线
oy = Tools.priceToY(h, obj['tr_zs_price'], kYMin, kScale);
var trzstxt = obj.containsKey('tr_zs_order_price') &&
obj['tr_zs_order_price'] > 0
? obj['tr_zs_limitstr']
: obj['tr_zs_marketstr'];
//测量
gdt1Size = Tools.getStrW(trzstxt, style['posLineStyle']['font']);
gdt1w = gdt1Size['width'];
//取最大值
gdt1w = Tools.max(wObj['gdt1wzs'], gdt1w);
wObj['gdt1wzs'] = gdt1w;
//测量
gdt2Size =
Tools.getStrW(obj['tr_amount'], style['posLineStyle']['font']);
gdt2w = gdt2Size['width'];
//取最大值
gdt2w = Tools.max(wObj['gdt2wzs'], gdt2w);
wObj['gdt2wzs'] = gdt2w;
bg1 = [];
bg2 = [];
bg3 = [];
bg4 = [];
bg1 = [
infoBgLeft,
y + oy - infoBgH / 2,
gdt1w + doublePadding,
infoBgH,
[reactRound,0.0,0.0,reactRound]
];
//止盈背景
callTradeLineReactPath(linePath, objList, 'cczs', zyzsIndex,
infoFullColor , bg1, true, infoStrokeWidth, style[ColorType['downColor']]);
//止盈信息
callTradeLineTxtPath(
linePath, objList, 'cczs', zyzsIndex, style[ColorType['downColor']], [
trzstxt,
bg1[0] + bg1[2] / 2,
y + oy,
{'ylayout': 'center', 'xlayout': 'center'}
]);
bg2 = [
bg1[0] + bg1[2],
bg1[1],
gdt2w + doublePadding,
bg1[3],
];
//数量背景
callTradeLineReactPath(linePath, objList, 'cczs', zyzsIndex,
amountFullColor, bg2, true, amountStrokeWidth, style[ColorType['downColor']]);
//数量信息
callTradeLineTxtPath(
linePath, objList, 'cczs', zyzsIndex, style[ColorType['downColor']], [
obj['tr_amount'],
bg2[0] + bg2[2] / 2,
y + oy + txtOffy,
{'ylayout': 'center', 'xlayout': 'center'}
]);
bg3 = [
bg2[0] + bg2[2],
bg2[1],
gdt3w,
bg2[3],
[0.0,reactRound,reactRound,0.0]
];
//关闭背景
callTradeLineReactPath(linePath, objList, 'cczs', zyzsIndex,
closeFullColor, bg3, true, closeStrokeWidth, style[ColorType['downColor']]);
//关闭按钮
callTradeLineXPath(linePath, objList, 'cczs', zyzsIndex, closeFontColor, bg3);
//止损关闭按钮尺寸
obj['zsxSize'] = {'x': bg3[0], 'y': bg3[1], 'w': bg3[2], 'h': bg3[3]};
obj['zsoy'] = oy;
//止损线
var lineData4 = {
'drawType': 'linePath',
'type': 'cczs',
'zIndex': zyzsIndex - 1,
'stroke': {
'color': style[ColorType['downColor']],
'style': PaintingStyle.stroke,
},
'property': {'dottedLine': zyzsDotted},
'linePath': [
[
"moveTo",
[x, y + oy]
],
[
"lineTo",
[yPriceBgx, y + oy]
]
],
};
linePath.insert(0, lineData4);
objList.insert(0, lineData4);
bg4 = [yPriceBgx, bg3[1], yPriceBgw, bg3[3], reactRound];
//y轴价格背景
callTradeLineReactPath(linePath, objList, 'cczs', zyzsIndex,
yPriceFullColor, bg4, true, yPriceStrokeWidth, style[ColorType['downColor']]);
//y轴价格信息
callTradeLineTxtPath(
linePath, objList, 'cczs', zyzsIndex, style[ColorType['downColor']], [
obj['tr_zs_price'],
bg4[0] + bg4[2] / 2,
y + oy,
{'ylayout': 'center', 'xlayout': 'center'}
]);
//左侧全部尺寸
obj['leftZsSize'] = {
'x': bg1[0],
'y': bg1[1],
'w': bg3[0] + bg3[2] - bg1[0],
'h': bg1[3]
};
}
zIndex += 4;
}
}
//从层级最高的到最低的,先画委托,再画持仓,所以持仓层级最高,检测选中从最高层级持仓开始
var isSel = false;
//先检测持仓线,因为是最后绘制的持仓线
for (int posi = chartData.positionData.length - 1; posi >= 0; posi--) {
var obj = chartData.positionData[posi];
//如果没有选中线,则继续判断是否选中
if (!isSel && callTradeLineInMouse(obj, false)) {
var pathObj = allPathList[obj['tr_id']];
//标记选中,只能选中一根线
isSel = true;
for (int pi = 0, pil = pathObj.length; pi < pil; pi++) {
var v = pathObj[pi];
v["zIndex"] += 999;
if ((obj['isShowHoverX'] || obj['isShowHoverZyZs']) &&
v['type'] == "cc") {
v["zIndex"] += 3;
} else if ((obj['isShowHoverZyX'] || obj['isShowHoverZy']) &&
v['type'] == "cczy") {
v["zIndex"] += 3;
} else if ((obj['isShowHoverZsX'] || obj['isShowHoverZs']) &&
v['type'] == "cczs") {
v["zIndex"] += 3;
}
}
} else {
callTradeLineInMouse(obj, true);
}
}
//在检测委托线,因为是先绘制的委托线
for (int orderi = chartData.orderData.length - 1; orderi >= 0; orderi--) {
var obj = chartData.orderData[orderi];
//如果没有选中线,则继续判断是否选中
if (!isSel && callTradeLineInMouse(obj, false)) {
var pathObj = allPathList[obj['tr_id']];
//标记选中,只能选中一根线
isSel = true;
for (int pi = 0, pil = pathObj.length; pi < pil; pi++) {
var v = pathObj[pi];
v["zIndex"] = v['zIndex'] + 999;
if ((obj['isShowHoverX'] || obj['isShowHoverZyZs']) &&
v['type'] == "gd") {
v["zIndex"] += 3;
} else if ((obj['isShowHoverZyX'] || obj['isShowHoverZy']) &&
v['type'] == "gdzy") {
v["zIndex"] += 3;
} else if ((obj['isShowHoverZsX'] || obj['isShowHoverZs']) &&
v['type'] == "gdzs") {
v["zIndex"] += 3;
}
}
} else {
callTradeLineInMouse(obj, true);
}
}
//按照zIndex排序
linePath.sort((a, b) {
return a['zIndex'].compareTo(b['zIndex']);
});
pathData = {
'linePath': linePath,
};
return pathData;
}