1 |
26600
|
sandro.lab
|
package eu.dnetlib.functionality.modular.ui.workflows.sarasvati.icons;
|
2 |
|
|
|
3 |
|
|
import java.awt.BasicStroke;
|
4 |
|
|
import java.awt.Color;
|
5 |
|
|
import java.awt.Graphics2D;
|
6 |
|
|
|
7 |
|
|
import com.googlecode.sarasvati.Node;
|
8 |
|
|
import com.googlecode.sarasvati.visual.common.NodeDrawConfig;
|
9 |
|
|
import com.googlecode.sarasvati.visual.util.FontUtil;
|
10 |
|
|
|
11 |
|
|
import eu.dnetlib.msro.workflows.nodes.NodeStatus;
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
public class WorkflowIcon extends AbstractIcon {
|
15 |
|
|
|
16 |
|
|
private NodeStatus status = NodeStatus.DISABLED;
|
17 |
|
|
|
18 |
|
|
public WorkflowIcon(final Node node) {
|
19 |
|
|
super(node);
|
20 |
|
|
redrawImage();
|
21 |
|
|
}
|
22 |
|
|
|
23 |
|
|
@Override
|
24 |
|
|
public void redrawImage(final Graphics2D gfx) {
|
25 |
|
|
super.resetGfx(gfx);
|
26 |
|
|
|
27 |
|
|
switch (status) {
|
28 |
|
|
case CONFIGURED:
|
29 |
|
|
gfx.setColor(Color.decode("#336699"));
|
30 |
|
|
break;
|
31 |
|
|
case NOT_CONFIGURED:
|
32 |
|
|
gfx.setColor(Color.decode("#bb0000"));
|
33 |
|
|
break;
|
34 |
|
|
default:
|
35 |
|
|
gfx.setColor(Color.decode("#aabbcc"));
|
36 |
|
|
break;
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
gfx.fillRoundRect(0, 0, WIDTH - 1, HEIGHT - 1, ROUND_CORNER, ROUND_CORNER);
|
40 |
|
|
|
41 |
|
|
gfx.setColor(NodeDrawConfig.NODE_BORDER);
|
42 |
|
|
final BasicStroke stroke = new BasicStroke(2, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10, getDashes(), 0);
|
43 |
|
|
gfx.setStroke(stroke);
|
44 |
|
|
gfx.drawRoundRect(0, 0, WIDTH - 1, HEIGHT - 1, ROUND_CORNER, ROUND_CORNER);
|
45 |
|
|
|
46 |
|
|
gfx.setColor(Color.white);
|
47 |
|
|
final int padding = 6;
|
48 |
|
|
final int startX = padding;
|
49 |
|
|
final int maxWidth = getIconWidth() - (padding << 1);
|
50 |
|
|
FontUtil.setSizedFont(gfx, getLabel(), FONT_SIZE, maxWidth);
|
51 |
|
|
final int strWidth = (int) Math.ceil(gfx.getFontMetrics().getStringBounds(getLabel(), gfx).getWidth());
|
52 |
|
|
final int strHeight = gfx.getFontMetrics().getAscent();
|
53 |
|
|
final int left = startX + ((maxWidth - strWidth) >> 1);
|
54 |
|
|
final int top = ((getIconHeight() + strHeight) >> 1);
|
55 |
|
|
gfx.drawString(getLabel(), left, top);
|
56 |
|
|
|
57 |
|
|
super.resetGfx(gfx);
|
58 |
|
|
}
|
59 |
|
|
}
|