1 26 package org.objectweb.fractal.explorer.graph; 27 28 import java.awt.Color ; 29 import java.awt.Dimension ; 30 import java.awt.Font ; 31 import java.awt.Graphics ; 32 33 import org.objectweb.util.explorer.swing.graph.CompositeVertex; 34 import org.objectweb.util.explorer.swing.graph.PrimitiveVertex; 35 import org.objectweb.util.explorer.swing.graph.VertexGraphicsInterface; 36 import org.objectweb.util.explorer.swing.graph.VertexType; 37 38 42 public class VertexGraphics 43 implements VertexGraphicsInterface 44 { 45 46 47 private void drawDottedRect(Graphics g, int x, int y, int width, int height) { 48 int currentX = x; 50 int currentY = y; 51 while (currentX < x + width - 5) { 52 g.drawLine(currentX, y, currentX + 5, y); 53 g.drawLine(currentX, y + height, currentX + 5, y + height); 54 currentX = currentX + 10; 55 } 56 while (currentY < y + height - 5) { 58 g.drawLine(x, currentY, x, currentY + 5); 59 g.drawLine(x + width, currentY, x + width, currentY + 5); 60 currentY = currentY + 10; 61 } 62 } 63 64 public Font getTextFont() { 65 return new Font ("SansSerif", Font.BOLD, 10); 66 } 67 68 69 public Dimension getDefaultSize() { 70 return new Dimension (110, 60); 71 } 72 73 74 public Dimension getSuperCompositeSize() { 75 return new Dimension (10, 10); 76 } 77 78 79 public void drawVertex(Graphics g, String vertexType, Dimension d, PrimitiveVertex vertex) { 80 g.setColor(Color.DARK_GRAY); 81 if (!vertex.isStarted()) 82 g.setColor(new Color (149, 0, 0)); 83 84 if (vertexType.equals(VertexType.PRIMITIF_VERTEX)) { 86 int size = VertexGraphicsInterface.PRIMITIVE_MEMBRANE_SIZE - 1; 87 if (vertex.isShared()) { 88 drawDottedRect(g, 0, 0, d.width - 1, d.height - 1); 89 drawDottedRect(g, size, size, d.width - 3, d.height - 3); 90 } else { 91 g.drawRect(0, 0, d.width - 1, d.height - 1); 92 g.drawRect(size, size, d.width - 3, d.height - 3); 93 } 94 } 95 96 else if (vertexType.equals(VertexType.COMPOSITE_VERTEX)) { 98 if (!((CompositeVertex) vertex).isOpen()) { 99 int size = VertexGraphicsInterface.PRIMITIVE_MEMBRANE_SIZE - 1; 101 if (vertex.isShared()) { 102 drawDottedRect(g, 0, 0, d.width - 1, d.height - 1); 103 drawDottedRect(g, size, size, d.width - size - 2, d.height 104 - size - 2); 105 } else { 106 g.drawRect(0, 0, d.width - 1, d.height - 1); 107 g.drawRect(size, size, d.width - size - 2, d.height - size 108 - 2); 109 } 110 g.setColor(Color.PINK); 111 g.fillRect(size + 1, size + 1, d.width - (size + 1) - 2, 112 d.height - (size + 1) - 2); 113 } 114 115 else { 117 int size = VertexGraphicsInterface.COMPOSITE_MEMBRANE_SIZE; 118 if (vertex.isShared()) { 119 drawDottedRect(g, 0, 0, d.width - 1, d.height - 1); 120 drawDottedRect(g, 1, 1, d.width - 3, d.height - 3); 121 drawDottedRect(g, size, size, d.width - size * 2 - 1, 122 d.height - size * 2 - 1); 123 drawDottedRect(g, size + 1, size + 1, d.width - size * 2 124 - 3, d.height - size * 2 - 3); 125 } else { 126 g.drawRect(0, 0, d.width - 1, d.height - 1); 127 g.drawRect(1, 1, d.width - 3, d.height - 3); 128 g.drawRect(size, size, d.width - size * 2 - 1, d.height 129 - size * 2 - 1); 130 g.drawRect(size + 1, size + 1, d.width - size * 2 - 3, 131 d.height - size * 2 - 3); 132 } 133 } 134 } 135 } 136 } | Popular Tags |