1 26 package org.objectweb.fractal.explorer.graph; 27 28 import java.awt.Color ; 29 import java.awt.Dimension ; 30 import java.awt.Graphics ; 31 32 import org.objectweb.util.explorer.swing.graph.PortGraphicsInterface; 33 import org.objectweb.util.explorer.swing.graph.PortType; 34 35 39 public class PortGraphics 40 implements PortGraphicsInterface 41 { 42 43 49 public Dimension getPortSize(String portType, boolean isInternal) { 50 if (portType.equals(PortType.SERVER_PORT)) 51 return new Dimension (11, 10); 52 else if (portType.equals(PortType.CLIENT_PORT)) 53 return new Dimension (11, 10); 54 else if (portType.equals(PortType.COLLECTION_PORT)) 55 return new Dimension (11, 10); 56 else if (portType.equals(PortType.CONTROLLER_PORT)) { 57 if (!isInternal) 58 return new Dimension (8, 10); 59 else 60 return new Dimension (8 + COMPOSITE_CONTROLLER_PORT_WIDTH, 10); 61 } else 62 return new Dimension (11, 10); 63 } 64 65 69 public void drawPort(Graphics g, String portName, String portType, 70 boolean isInternal) { 71 if (portType.equals(PortType.SERVER_PORT)) { 72 g.setColor(Color.red); 73 g.drawRect(2, 3, 8, 2); 74 g.fillRect(2, 3, 8, 2); 75 g.drawRect(0, 0, 2, 8); 76 g.fillRect(0, 0, 2, 8); 77 } else if (portType.equals(PortType.COLLECTION_PORT)) { 78 g.setColor(new Color (20, 61, 18)); 79 g.drawLine(3, 2, 6, 2); 80 g.drawLine(3, 0, 6, 4); 81 g.drawLine(3, 4, 6, 0); 82 g.drawRect(8, 1, 2, 8); 83 g.fillRect(8, 1, 2, 8); 84 g.drawRect(0, 5, 8, 2); 85 g.fillRect(0, 5, 8, 2); 86 } else if (portType.equals(PortType.CLIENT_PORT)) { 87 g.setColor(new Color (2708224)); 88 g.drawRect(8, 0, 2, 8); 89 g.fillRect(8, 0, 2, 8); 90 g.drawRect(0, 3, 8, 2); 91 g.fillRect(0, 3, 8, 2); 92 } else if (portType.equals(PortType.CONTROLLER_PORT)) { 93 g.setColor(Color.BLUE); 94 g.drawRect(0, 0, 8, 2); 95 g.fillRect(0, 0, 8, 2); 96 g.drawRect(3, 2, 2, 8); 97 g.fillRect(3, 2, 2, 8); 98 if (isInternal) { 99 g.setColor(Color.BLACK); 100 g.drawString(portName, 10, 9); 101 } 102 } 103 } 104 } | Popular Tags |