1 10 11 package org.enhydra.jawe.graph; 12 13 import org.enhydra.jawe.*; 14 import org.enhydra.jawe.xml.*; 15 16 import org.jgraph.graph.*; 17 18 import java.awt.*; 19 import javax.swing.*; 20 21 24 public class ActivityRenderer extends MultiLinedRenderer { 26 27 private BasicStroke borderStroke = new BasicStroke(2); 28 29 protected static final int actW=JaWEConfig.getInstance().getActivityWidth(); 30 protected static final int actH=JaWEConfig.getInstance().getActivityHeight(); 31 protected static final int innerW=JaWEConfig.getInstance().getInnerActivityWidth(); 32 protected static final int innerH=JaWEConfig.getInstance().getInnerActivityHeight(); 33 protected static final int xOff=(int)((actW-innerW)/2); 34 protected static final int yOff=(int)((actH-innerH)/2); 35 36 40 public void paint(Graphics g) { 41 Activity act=(Activity)view.getCell(); 42 Color fillColor=getFillColor(); 46 47 Color gridC=graph.getGridColor(); 48 Color highlightC=graph.getHighlightColor(); 49 Color bckgC=fillColor; Color borderC=bordercolor; 51 if (selected) { 52 bckgC=Utils.getColor(JaWEConfig.getInstance().getSelectedActivityColor()); 53 } 54 55 super.setBackground(bckgC); 56 57 int xo[]=new int[]{0,actW-1,actW-1,actW-1,0,0}; 58 int yo[]=new int[]{0,0,actH/2,actH-1,actH-1,actH/2}; 59 int xi[]=new int[]{1,actW-2,actW-2,actW-2,1,1}; 60 int yi[]=new int[]{1,1,actH/2,actH-2,actH-2,actH/2}; 61 if (XMLUtil.isANDTypeSplitOrJoin((org.enhydra.jawe.xml.elements.Activity)act.getPropertyObject(),1)) { 62 xo[5]=xOff-3; 63 xi[5]=xOff-2; 64 } 65 if (XMLUtil.isANDTypeSplitOrJoin((org.enhydra.jawe.xml.elements.Activity)act.getPropertyObject(),0)) { 66 xo[1]=actW-xOff+3; 67 xo[3]=actW-xOff+3; 68 xi[1]=actW-xOff+2; 69 xi[3]=actW-xOff+2; 70 } 71 72 int points=6; 73 74 g.setColor(bckgC); 76 g.fillPolygon(xo,yo,points); 78 g.setColor(bordercolor); 79 ((Graphics2D) g).setStroke(borderStroke); 80 g.drawPolygon(xi,yi,points); 82 83 if (selected || hasFocus) { 85 ((Graphics2D) g).setStroke(GraphConstants.SELECTION_STROKE); 86 if (hasFocus) 87 g.setColor(graph.getGridColor()); 88 else if (selected) 89 g.setColor(graph.getHighlightColor()); 90 g.drawPolygon(xo,yo,points); 93 } 94 95 Graphics gl=g.create(xOff,yOff,innerW,innerH); 97 Rectangle labelRect=new Rectangle(new Dimension(innerW,innerH)); 98 super.setBounds(labelRect); 99 graph.setGridColor(bckgC); 100 graph.setHighlightColor(bckgC); 101 setBorder(BorderFactory.createLineBorder(bckgC,borderWidth)); 102 super.paint(gl); 103 setBorder(BorderFactory.createLineBorder(bordercolor,borderWidth)); 104 setForeground(bordercolor); 105 graph.setGridColor(gridC); 106 graph.setHighlightColor(highlightC); 107 108 109 120 } 121 122 protected Color getFillColor () { 123 Color c=Utils.getColor(JaWEConfig.getInstance().getGenericActivityColor()); 124 return ActivityRenderer.getFillColor(c,(Activity)view.getCell()); 125 } 126 127 protected static Color getFillColor (Color defaultColor,Activity act) { 128 if (!JaWEConfig.getInstance().getUseBubblesStatus()) { 129 boolean isStartingAct=Utils.isStartingActivity(act); 130 boolean isEndingAct=Utils.isEndingActivity(act); 131 if (isStartingAct && isEndingAct) { 132 return Utils.getColor(JaWEConfig.getInstance().getStartEndColor()); 133 } else if (isStartingAct) { 134 return Utils.getColor(JaWEConfig.getInstance().getStartColor()); 135 } else if (isEndingAct) { 136 return Utils.getColor(JaWEConfig.getInstance().getEndColor()); 137 } 138 } 139 return defaultColor; 140 } 141 142 } 143 | Popular Tags |