MCPcopy Create free account
hub / github.com/BIT-DataLab/Edit-Banana / _generate_xml

Method _generate_xml

modules/basic_shape_processor.py:1487–1515  ·  view source on GitHub ↗

生成mxCell XML

(self, elem: ElementInfo, style_data: dict)

Source from the content-addressed store, hash-verified

1485 elem.processing_notes.append("BasicShapeProcessor处理完成")
1486
1487 def _generate_xml(self, elem: ElementInfo, style_data: dict) -> str:
1488 """生成mxCell XML"""
1489 elem_type = elem.element_type.lower()
1490
1491 # 获取基础样式
1492 base_style = DRAWIO_STYLES.get(elem_type, "rounded=0;whiteSpace=wrap;html=1;")
1493
1494 # 动态应用几何参数
1495 geo_params = style_data.get("geo_params", {})
1496 if elem_type == "parallelogram" and "size" in geo_params:
1497 base_style += f"size={geo_params['size']:.2f};"
1498 elif elem_type == "cylinder" and "size" in geo_params:
1499 base_style += f"size={geo_params['size']};"
1500 elif elem_type == "triangle" and "direction" in geo_params:
1501 base_style += f"direction={geo_params['direction']};"
1502
1503 # 构建完整样式
1504 fill_color = style_data["fill_color"]
1505 stroke_color = style_data["stroke_color"]
1506 stroke_width = style_data["stroke_width"]
1507
1508 style = f"{base_style}fillColor={fill_color};strokeColor={stroke_color};strokeWidth={stroke_width};"
1509
1510 # DrawIO的id必须从2开始(0和1是保留的根元素)
1511 cell_id = elem.id + 2
1512
1513 return f''&#x27;<mxCell id="{cell_id}" parent="1" vertex="1" value="" style="{style}">
1514 <mxGeometry x="{elem.bbox.x1}" y="{elem.bbox.y1}" width="{elem.bbox.width}" height="{elem.bbox.height}" as="geometry"/>
1515</mxCell>''&#x27;
1516
1517 def _run_cv_detection(self, context: ProcessingContext, cv2_image: np.ndarray) -> int:
1518 """运行CV补充检测"""

Callers 2

_process_elementMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected