1 10 11 package org.enhydra.jawe.graph; 12 13 import org.enhydra.jawe.*; 14 15 import org.jgraph.graph.*; 16 17 import java.awt.*; 18 import javax.swing.*; 19 20 25 public class ParticipantRenderer extends VertexRenderer { 26 27 protected static final int participantNameWidth=JaWEConfig.getInstance().getParticipantNameWidth(); 28 29 38 public void paint(Graphics g) { 39 String label = graph.convertValueToString(view.getCell()); 40 Graphics2D g2 = (Graphics2D) g; 41 Dimension d = view.getBounds().getBounds().getSize(); 43 g2.setStroke(JaWEConstants.DEPARTMENT_STROKE); 44 45 Color bordCol=Utils.getColor(JaWEConfig.getInstance().getParticipantBorderColor()); 46 g.setColor(bordCol); 47 48 g.drawRect(0,0,d.width-1,d.height-1); 50 51 Participant p=(Participant)view.getCell(); 53 if (p.getUserObject()==org.enhydra.jawe.xml.elements.Participant. 54 getFreeTextExpressionParticipant()) { 55 g.setColor(Utils.getColor(JaWEConfig.getInstance().getFreeTextExpressionParticipantColor())); 56 g.fillRect(1,1,d.width-3,d.height-3); 57 g.setColor(bordCol); 58 } else { 59 Color pc; 60 String pt=p.get("ParticipantType").toValue().toString(); 61 if (pt.equals("RESOURCE_SET")) { 62 pc=Utils.getColor(JaWEConfig.getInstance().getResourceSetParticipantColor()); 63 } else if (pt.equals("RESOURCE")) { 64 pc=Utils.getColor(JaWEConfig.getInstance().getResourceParticipantColor()); 65 } else if (pt.equals("ROLE")) { 66 pc=Utils.getColor(JaWEConfig.getInstance().getRoleParticipantColor()); 67 } else if (pt.equals("ORGANIZATIONAL_UNIT")) { 68 pc=Utils.getColor(JaWEConfig.getInstance().getOrganizationalUnitParticipantColor()); 69 } else if (pt.equals("HUMAN")) { 70 pc=Utils.getColor(JaWEConfig.getInstance().getHumanParticipantColor()); 71 } else { pc=Utils.getColor(JaWEConfig.getInstance().getSystemParticipantColor()); 73 } 74 75 g.setColor(pc); 76 g.fillRect(1,1,participantNameWidth-2,d.height-3); 77 g.setColor(bordCol); 78 } 79 80 g.drawLine(participantNameWidth,0,participantNameWidth,d.height-1); 82 83 84 if (selected) { g2.setStroke(GraphConstants.SELECTION_STROKE); 89 g.setColor(graph.getHighlightColor()); 92 g.drawRect(0, 0, d.width-1, d.height-1); 93 94 g.drawLine(participantNameWidth,0,participantNameWidth,d.height-1); 95 96 } 97 98 if (label != null) { 104 if (!selected) { 105 g2.setStroke(JaWEConstants.DEPARTMENT_STROKE); 106 g.setColor(Utils.getColor(JaWEConfig.getInstance().getParticipantTextColor())); 107 } 108 Font f=GraphConstants.getFont(view.getAllAttributes()); 109 g2.setFont(f); 110 int h = getFontMetrics(f).stringWidth(label); 111 112 h = d.height / 2 + h / 2; 113 g2.translate(participantNameWidth/2, h); 114 g2.rotate(Math.toRadians(-90)); 115 g2.drawString(label,0,0); 116 } 117 } 118 119 } 120 | Popular Tags |