setCardButtons method
dynamic
setCardButtons(
- dynamic context,
- dynamic data,
- dynamic param0,
- dynamic backcolor,
Implementation
setCardButtons(context, data, param0, backcolor) {
myLogAll('setCardButtons');
List<Widget> list = [];
if (data[gType] == gProcess) {
List detail = data[gDetail];
int width = 0;
int height = 0;
double seg = 23.0;
int xSeg = 30;
int ySeg = 30;
Map map = {};
for (var element in detail) {
if ((element[gType] ?? '') == gLine) {
continue;
}
//detail.forEach((element) {
dynamic x;
dynamic y;
if (isNull(element[gX])) {
x = -1;
} else {
x = element[gX] ?? -1;
}
if (isNull(element[gY])) {
y = -1;
} else {
y = element[gY] ?? -1;
}
if (x == -1 && y == -1) {
continue;
}
dynamic id = element[gId];
dynamic source = element[gSource] ?? '';
dynamic xShow = x, yShow = y;
if (!isNull(source)) {
var elementParent = map[source];
dynamic xParent = elementParent[gXshow];
dynamic yParent = elementParent[gYshow];
if (x == 0) {
xShow = xParent;
} else {
xShow = xParent +
x * xSeg +
getInt(getCharLength(elementParent).toString());
}
if (y == 0) {
yShow = yParent;
} else {
yShow = yParent + y * ySeg;
}
}
element[gXshow] = xShow;
element[gYshow] = yShow;
map[id] = element;
int widthTmp = getInt(getCharLength(element).toString());
if (xShow + widthTmp + xSeg > width) {
width = xShow + widthTmp + xSeg + 20;
}
if (yShow + ySeg > height) {
height = yShow + ySeg;
}
}
for (var element in detail) {
if ((element[gType] ?? '') != gLine) {
continue;
}
dynamic from = element[gSource];
dynamic to = element[gTarget];
var elementFrom = map[from];
var elementTo = map[to];
int x0 = elementFrom[gXshow], y0 = elementFrom[gYshow];
double width0 = getDouble(getCharLength(elementFrom).toString()) + seg;
int x1 = elementTo[gXshow], y1 = elementTo[gYshow];
double width1 = getDouble(getCharLength(elementTo).toString()) + seg;
//起始点,如果有交集,取交集中点
dynamic direction0 =
getValue(gZzyaligntype, gLabel, element['alignsource'])[gValue];
dynamic direction1 =
getValue(gZzyaligntype, gLabel, element['aligntarget'])[gValue];
double heightI = 30.0;
Map p0 = getPointByDirection(x0, y0, width0, heightI, seg, direction0);
Map p1 = getPointByDirection(x1, y1, width1, heightI, seg, direction1);
element[gX] = 0;
element[gY] = 0;
element[gXshow] = p0[gX];
element[gYshow] = p0[gY];
if (p0[gX] > x1 && p0[gX] < x1 + width1 + seg) {
p1[gX] = p0[gX];
}
if (p0[gY] > y1 && p0[gY] < y1 + heightI) {
p1[gY] = p0[gY];
}
element['{$gXshow}0'] = p1[gX];
element['{$gYshow}0'] = p1[gY];
element['d0'] = direction0;
}
if (width > 0 && height > 0) {
data[gWidth] = width;
data[gHeight] = height;
}
}
return list;
}