wangting
2024-12-30 306a9c4fde94c54d91aee5a69d59b993c7c707a1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.vci.client.workflow.template;
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
 
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
 
import com.vci.client.workflow.delegate.ProcessCustomClientDelegate;
import com.vci.client.workflow.template.object.ProcessDefinitionObject;
 
public class ProcessDefinitionPanel extends JPanel {
 
    private static final long serialVersionUID = 4377484415817081427L;
    
    private JLabel flowChartLabel;
    
    public ProcessDefinitionPanel() {
        init();
    }
 
    private void init() {
        flowChartLabel = new JLabel();
        JPanel chartPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        chartPanel.setBackground(Color.WHITE);
        chartPanel.add(flowChartLabel);
        JScrollPane comp = new JScrollPane(chartPanel);
        
        setLayout(new BorderLayout());
        this.add(comp);
    }
 
    public void setObject(ProcessDefinitionObject processDefinitionObject) {
        updateFlowChart(processDefinitionObject);
    }
    
    /**
     * 根据processDefinition刷新流程图
     * @param processDefinition, 流程定义
     */
    private void updateFlowChart(ProcessDefinitionObject processDefinitionObject){
        if(processDefinitionObject == null){
            flowChartLabel.setIcon(null);
            return;
        }
        try {
            String deploymentId = processDefinitionObject.getJbpmDeploymentId();
            byte[] jbpmImage = new ProcessCustomClientDelegate().getProcessChart(deploymentId);
            InputStream buffin = new ByteArrayInputStream(jbpmImage, 0, jbpmImage.length);
            BufferedImage bi = ImageIO.read(buffin);
            ImageIcon icon = new ImageIcon(bi);
            flowChartLabel.setIcon(icon);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}