From d30e385951ce03335a5023f0775fd144da3c0b88 Mon Sep 17 00:00:00 2001 From: jinlin <jinlin> Date: 星期二, 18 三月 2025 11:18:31 +0800 Subject: [PATCH] 修改 --- src/main/java/com/example/client/service/Level2ViewService.java | 48 ++++++++++++++++++++++++++++++++---------------- 1 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/example/client/service/Level2ViewService.java b/src/main/java/com/example/client/service/Level2ViewService.java index e70c7a0..73e5165 100644 --- a/src/main/java/com/example/client/service/Level2ViewService.java +++ b/src/main/java/com/example/client/service/Level2ViewService.java @@ -2,6 +2,7 @@ import com.example.client.dto.ColumnDto; import com.example.client.utils.CommonTable; +import com.example.client.utils.Compute; import com.example.server.progressTrack.Dto.NetworkNodeStatusDto; import com.example.server.progressTrack.model.DjJdgzNetworkLevel1; import com.example.server.progressTrack.model.DjJdgzNetworkLevel2; @@ -15,10 +16,7 @@ import javax.swing.*; import java.awt.*; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseWheelEvent; -import java.awt.event.MouseWheelListener; +import java.awt.event.*; import java.util.ArrayList; import java.util.List; @@ -30,12 +28,12 @@ @Autowired private NetWorkDiagramService netWorkDiagramService; - public JPanel createTable(Integer width, Integer height) { - height = height - 100; - JPanel panel = new JPanel(); + public JPanel createTable(Integer width, Integer height, JFrame frame) { + JPanel panel = new JPanel(new BorderLayout()); + panel.setPreferredSize(new Dimension(width, height)); - JPanel jLeft = new JPanel(new BorderLayout()); - jLeft.setPreferredSize(new Dimension(width / 4 - 20, height)); + JPanel jLeft = new JPanel(); + jLeft.setPreferredSize(new Dimension(width / 4 - 20, Compute.ComputeHeight(0, frame))); JPanel diagram = new JPanel(new BorderLayout()); diagram.setPreferredSize(new Dimension(width - width / 4, height)); @@ -47,16 +45,29 @@ //columnDto.add(new ColumnDto("ID", "id", -1, null,false)); - columnDto.add(new ColumnDto("搴忓彿", "", width / 10 - 10, "autoCreate", false, null,null)); - columnDto.add(new ColumnDto("宸ョ▼", "ProjectName", width / 8, null, false, null,null)); - columnDto.add(new ColumnDto("涓�绾ц妭鐐�", "processName", width / 8, null, false, null,null)); + columnDto.add(new ColumnDto("搴忓彿", "", 120, "autoCreate", false, null, null)); + columnDto.add(new ColumnDto("宸ョ▼", "ProjectName", 145, null, false, null, null)); + columnDto.add(new ColumnDto("涓�绾ц妭鐐�", "processName", 125, null, false, null, null)); JTable subTable = CommonTable.createCommonTable(list, columnDto); subTable.setRowHeight(25); - subTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); + subTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); JScrollPane scrollTable = new JScrollPane(subTable); - jLeft.add(scrollTable, BorderLayout.CENTER); + scrollTable.setPreferredSize(new Dimension(width / 4 - 20, Compute.ComputeHeightWithScroll(0, frame))); + jLeft.add(scrollTable); + frame.addComponentListener(new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + + jLeft.setPreferredSize(new Dimension(width / 4 - 20, Compute.ComputeHeight(0, frame))); + scrollTable.setPreferredSize(new Dimension(width / 4 - 20, Compute.ComputeHeightWithScroll(0, frame))); + jLeft.revalidate(); + jLeft.repaint(); + scrollTable.revalidate(); + scrollTable.repaint(); + } + }); // 鍒涘缓姘村钩鍒嗗壊闈㈡澘 JSplitPane hSplitPane = new JSplitPane( @@ -80,7 +91,7 @@ mxGraphComponent graphComponent = new mxGraphComponent(graph); graphComponent.setConnectable(false); graphComponent.setDragEnabled(false); - graphComponent.zoomTo(2, true); + graphComponent.zoomTo(1, true); diagram.add(graphComponent); mxGraph finalGraph = graph; @@ -104,7 +115,12 @@ int r = subTable.getSelectedRow(); DjJdgzNetworkLevel2 data = list.get(r); List<NetworkNodeStatusDto> nodeStatusList = level2Service.getNodeStatusData(data.getId()); - graph2[0] = netWorkDiagramService.getCsDiagram(graph2[0], data.getContent(), nodeStatusList, diagram.getPreferredSize().width, diagram.getPreferredSize().height); + mxGraph csDiagram = netWorkDiagramService.getCsDiagram(graph2[0], data.getContent(), nodeStatusList, diagram.getPreferredSize().width, diagram.getPreferredSize().height); + if (nodeStatusList != null && nodeStatusList.size() > 0) { + graph2[0] = csDiagram; + } else { + graph2[0].removeCells(graph2[0].getChildVertices(graph2[0].getDefaultParent())); + } } } }); -- Gitblit v1.9.1