1 31 32 package org.antlr.works.visualization.skin.nfa; 33 34 import org.antlr.works.visualization.graphics.GContext; 35 import org.antlr.works.visualization.graphics.GObject; 36 import org.antlr.works.visualization.graphics.shape.GLink; 37 import org.antlr.works.visualization.graphics.shape.GNode; 38 import org.antlr.works.visualization.skin.Skin; 39 40 import java.awt.*; 41 42 public class NFASkin extends Skin { 43 44 public NFASkin() { 45 value_epsilon_width = 10; 46 value_epsilon_up = 0; 47 value_epsilon_down = 0; 48 49 value_box_width = 20; 50 value_box_up = 0; 51 value_box_down = 0; 52 53 value_node_width = 10; 54 value_node_up = 5; 55 value_node_down = 5; 56 57 value_char_width = 3.5f; 58 value_line_space = 2; 59 } 60 61 public boolean isLinkVisible() { 62 return true; 63 } 64 65 public boolean isNodeVisible() { 66 return true; 67 } 68 69 public float getStartOffset(GContext context) { 70 return context.getPixelNodeWidth()/2; 71 } 72 73 public float getEndOffset(GContext context) { 74 return context.getPixelNodeWidth()/2; 75 } 76 77 public boolean objectContainsPoint(GObject object, Point p) { 78 if(object instanceof GNode) 79 return NFANode.nodeContainsPoint((GNode)object, p); 80 return false; 81 } 82 83 public void drawNode(GNode node) { 84 NFANode.draw(node); 85 } 86 87 public void drawLink(GLink link) { 88 NFALink.draw(link); 89 } 90 91 92 } 93 | Popular Tags |