1 10 11 package org.enhydra.jawe.graph; 12 13 14 import java.awt.*; 15 16 import javax.swing.BorderFactory ; 17 import org.jgraph.graph.GraphConstants; 18 import org.enhydra.jawe.JaWEConfig; 19 import org.enhydra.jawe.Utils; 20 21 24 public class ProcessRenderer extends MultiLinedRenderer { 26 27 private BasicStroke borderStroke = new BasicStroke(2); 28 29 protected static final int procW=JaWEConfig.getInstance().getProcessWidth(); 30 protected static final int procH=JaWEConfig.getInstance().getProcessHeight(); 31 protected static final int rrW=54; 32 protected static final int rrH=42; 33 protected static final int innerW=ProcessRenderer.procW-rrW/3; 34 protected static final int innerH=ProcessRenderer.procH-rrH/3; 35 36 40 public void paint(Graphics g) { 41 Color fillCol=Utils.getColor(JaWEConfig.getInstance().getProcessColor()); 42 int b = borderWidth; 43 Graphics2D g2 = (Graphics2D) g; 44 Object AntiAlias = RenderingHints.VALUE_ANTIALIAS_ON; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, AntiAlias); Dimension d = getSize(); 47 boolean tmp = selected; 48 49 Color gridC=graph.getGridColor(); 50 Color highlightC=graph.getHighlightColor(); 51 Color bckgC=fillCol; Color borderC=bordercolor; 53 if (selected) { 54 bckgC=Utils.getColor(JaWEConfig.getInstance().getSelectedActivityColor()); 55 } 56 57 58 if (super.isOpaque()) { 59 g.setColor(fillCol); 60 g.fillRoundRect(b-1, b-1, d.width-b, d.height-b,rrW,rrH); 61 } 62 63 try { 64 setBorder(null); 65 setOpaque(false); 66 selected = false; 67 68 69 Graphics gl=g.create(rrW/6,rrH/6,innerW,innerH); 71 Rectangle labelRect=new Rectangle(new Dimension(innerW,innerH)); 72 super.setBounds(labelRect); 73 graph.setGridColor(bckgC); 74 graph.setHighlightColor(bckgC); 75 76 super.paint(gl); 77 78 setForeground(bordercolor); 79 graph.setGridColor(gridC); 80 graph.setHighlightColor(highlightC); 81 } finally { 82 selected = tmp; 83 } 84 if (bordercolor != null) { 85 g.setColor(bordercolor); 86 g2.setStroke(borderStroke); 87 g.drawRoundRect(b-1, b-1, d.width-b, d.height-b,rrW,rrH); 88 } 89 if (selected) { 90 g2.setStroke(GraphConstants.SELECTION_STROKE); 91 g.setColor(graph.getHighlightColor()); 92 g.drawRoundRect(b-1, b-1, d.width-b, d.height-b,rrW,rrH); 93 } 94 95 96 } 97 98 protected Color getFillColor () { 99 return Utils.getColor(JaWEConfig.getInstance().getGenericActivityColor()); 100 } 101 102 } 103 104 | Popular Tags |