田源
2024-03-07 4b4083fd73dc27ece42f4835483565eef0e4f608
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
package com.vci.client.workflow.editor.shape;
 
import java.awt.Rectangle;
import java.util.Map;
 
import com.mxgraph.canvas.mxGraphics2DCanvas;
import com.mxgraph.shape.mxBasicShape;
import com.mxgraph.swing.util.mxSwingConstants;
import com.mxgraph.util.mxConstants;
import com.mxgraph.view.mxCellState;
 
public class mxTaskShape extends mxBasicShape {
 
    public void paintShape(mxGraphics2DCanvas canvas, mxCellState state)
    {
        Map<String, Object> style = state.getStyle();
 
        Rectangle tmp = state.getRectangle();
        int pad = 0;
        int radius = 0;
        try {
            pad = Integer.parseInt((String) style.get("padding"));
            radius = Integer.parseInt((String) style.get("radius"));
        } catch (Exception e) {
            e.printStackTrace();
        }
        int x = tmp.x + pad;
        int y = tmp.y + pad;
        int w = tmp.width - pad * 2;
        int h = tmp.height - pad * 2;
        boolean shadow = hasShadow(canvas, state);
        int shadowOffsetX = shadow ? mxConstants.SHADOW_OFFSETX : 0;
        int shadowOffsetY = shadow ? mxConstants.SHADOW_OFFSETY : 0;
        if(canvas.getGraphics().hitClip(x, y, w + shadowOffsetX, h + shadowOffsetY))
        {
            if(shadow)
            {
                canvas.getGraphics().setColor(mxSwingConstants.SHADOW_COLOR);
                canvas.getGraphics().fillRoundRect(x + mxConstants.SHADOW_OFFSETX, y + mxConstants.SHADOW_OFFSETY, w, h, radius, radius);
            }
            if(configureGraphics(canvas, state, true))
                canvas.getGraphics().fillRoundRect(x, y, w, h, radius, radius);
            if(configureGraphics(canvas, state, false))
                canvas.getGraphics().drawRoundRect(x, y, w, h, radius, radius);
        }
    }
 
}