1 10 11 package org.enhydra.jawe.graph; 12 13 import org.enhydra.jawe.*; 14 import org.enhydra.jawe.xml.elements.Condition; 15 16 import org.jgraph.graph.*; 17 import org.jgraph.JGraph; 18 19 import java.util.*; 20 import java.awt.*; 21 import java.awt.geom.*; 22 import java.awt.event.*; 23 import javax.swing.undo.UndoableEdit ; 24 25 28 public class TransitionRenderer extends EdgeRenderer { 29 30 31 public TransitionRenderer () { 32 super(); 33 } 34 35 public void paint(Graphics g) { 36 Transition tr=(Transition)view.getCell(); 37 if (tr.hasCondition()) { 38 lineWidth=3; 39 } else { 40 lineWidth=1; 41 } 42 Color clr=Utils.getColor(JaWEConfig.getInstance().getTransitionColor()); 43 String ttype=tr.getType(); 44 if (ttype.equals(Condition.CONDITION_TYPE_DEFAULTEXCEPTION)) { 45 clr=Utils.getColor(JaWEConfig.getInstance().getDefaultExceptionTransitionColor()); 46 } else if (ttype.equals(Condition.CONDITION_TYPE_EXCEPTION)) { 47 clr=Utils.getColor(JaWEConfig.getInstance().getExceptionTransitionColor()); 48 } else if (ttype.equals(Condition.CONDITION_TYPE_OTHERWISE)) { 49 clr=Utils.getColor(JaWEConfig.getInstance().getOtherwiseTransitionColor()); 50 } 51 52 54 Shape edgeShape = view.getShape(); 55 if (edgeShape != null) { 57 Graphics2D g2 = (Graphics2D) g; 58 int c = BasicStroke.CAP_BUTT; 59 int j = BasicStroke.JOIN_MITER; 60 g2.setStroke(new BasicStroke(lineWidth, c, j)); 61 translateGraphics(g); 62 g.setColor(clr); 64 if (view.beginShape != null) { 65 if (beginFill) 66 g2.fill(view.beginShape); 67 g2.draw(view.beginShape); 68 } 69 if (view.endShape != null) { 70 if (endFill) 71 g2.fill(view.endShape); 72 g2.draw(view.endShape); 73 } 74 if (lineDash != null) g2.setStroke( 76 new BasicStroke(lineWidth, c, j, 10.0f, lineDash, 0.0f)); 77 if (view.lineShape != null) 78 g2.draw(view.lineShape); 79 80 if (selected) { g2.setStroke(GraphConstants.SELECTION_STROKE); 82 g2.setColor(graph.getHighlightColor()); 83 if (view.beginShape != null) 84 g2.draw(view.beginShape); 85 if (view.lineShape != null) 86 g2.draw(view.lineShape); 87 if (view.endShape != null) 88 g2.draw(view.endShape); 89 } 90 if (graph.getEditingCell() != view.getCell()) { 91 Object label = graph.convertValueToString(view); 92 if (label != null) { 93 g2.setStroke(new BasicStroke(1)); 94 g.setFont(getFont()); 95 paintLabel(g, label.toString()); 96 } 97 } 98 } 99 } 100 } 101 102 103 | Popular Tags |