showCustomDiagram static method
List<Widget>
showCustomDiagram(
- PresentationCustomDiagram presentationCustomDiagram,
- Map<
String, String> clearMap, - List<
PresentationColorSchemes> colorSchemes, - double divisionFactor,
- Map<
String, double> maxWidthHeight,
Implementation
static List<Widget> showCustomDiagram(PresentationCustomDiagram presentationCustomDiagram, Map<String, String> clearMap,
List<PresentationColorSchemes> colorSchemes, double divisionFactor, Map<String, double> maxWidthHeight) {
List<Widget> tempShapes = [];
if (presentationCustomDiagram.x / divisionFactor + presentationCustomDiagram.width / divisionFactor > maxWidthHeight["maxWidth"]!) {
maxWidthHeight["maxWidth"] = presentationCustomDiagram.x / divisionFactor + presentationCustomDiagram.width / divisionFactor;
}
if (presentationCustomDiagram.y / divisionFactor + presentationCustomDiagram.height / divisionFactor > maxWidthHeight["maxHeight"]!) {
maxWidthHeight["maxHeight"] = presentationCustomDiagram.y / divisionFactor + presentationCustomDiagram.height / divisionFactor;
}
String clrSchemeVal = presentationCustomDiagram.clrScheme ?? "";
String color = "";
if (presentationCustomDiagram.srgbClr!.isNotEmpty) {
color = "0xff${presentationCustomDiagram.srgbClr}";
} else {
if (clearMap[clrSchemeVal] != null) {
clrSchemeVal = clearMap[clrSchemeVal]!;
}
var clrScheme = colorSchemes.firstWhereOrNull((clrSch) {
//print(clrSch.name);
return clrSch.name == clrSchemeVal;
});
if (clrScheme != null) {
if (clrScheme.sysClrLast.isNotEmpty) {
color = "0xff${clrScheme.sysClrLast}";
} else if (clrScheme.srgbClr.isNotEmpty) {
color = "0xff${clrScheme.srgbClr}";
}
}
}
Color adjustedColor = Colors.transparent;
if (color.isNotEmpty) {
adjustedColor = Color(int.parse(color));
if (presentationCustomDiagram.lumMod != null || presentationCustomDiagram.lumOff != null) {
adjustedColor = modifyColor(adjustedColor, presentationCustomDiagram.lumMod, presentationCustomDiagram.lumOff);
}
}
double rotate = 0;
bool flipH = false;
bool flipV = false;
if (presentationCustomDiagram.rotate != null) {
rotate = presentationCustomDiagram.rotate! * pi / 180;
}
if (presentationCustomDiagram.flipH != null && presentationCustomDiagram.flipH == "1") {
//flipH=true;
}
if (presentationCustomDiagram.flipV != null && presentationCustomDiagram.flipV == "1") {
flipV = true;
}
tempShapes.add(Positioned(
top: presentationCustomDiagram.y != 0 ? presentationCustomDiagram.y / divisionFactor : 0,
left: presentationCustomDiagram.x != 0 ? presentationCustomDiagram.x / divisionFactor : 0,
child: Container(
//color: Colors.grey,
width: presentationCustomDiagram.width.toDouble() / divisionFactor,
height: presentationCustomDiagram.height.toDouble() / divisionFactor,
child: Transform.rotate(
angle: rotate,
child: Transform.flip(
flipX: flipH,
flipY: flipV,
child: CustomPaint(
child: Container(), painter: CustomDiagram(presentationCustomDiagram, divisionFactor.toDouble(), adjustedColor)))))));
return tempShapes;
}