1 9 package bluej.editor.moe; 10 11 16 17 import javax.swing.text.*; 18 19 import java.awt.*; 20 import bluej.Config; 21 import bluej.prefmgr.PrefMgr; 22 import org.syntax.jedit.*; 23 import org.syntax.jedit.tokenmarker.*; 24 25 38 39 public class MoeSyntaxView extends BlueJSyntaxView 40 { 41 public static final String BREAKPOINT = "break"; 43 public static final String STEPMARK = "step"; 44 45 static final Image breakImage = 46 Config.getImageAsIcon("image.editor.breakmark").getImage(); 47 static final Image stepImage = 48 Config.getImageAsIcon("image.editor.stepmark").getImage(); 49 static final Image breakStepImage = 50 Config.getImageAsIcon("image.editor.breakstepmark").getImage(); 51 52 56 public MoeSyntaxView(Element elem) 57 { 58 super(elem); 59 } 60 61 64 public void paintTaggedLine(Segment lineText, int lineIndex, Graphics g, int x, int y, 65 SyntaxDocument document, TokenMarker tokenMarker, Color def, Element line) 66 { 67 if(PrefMgr.getFlag(PrefMgr.LINENUMBERS)) 68 drawLineNumber(g, lineIndex+1, x, y); 69 70 72 if(hasTag(line, BREAKPOINT)) { 73 if(hasTag(line, STEPMARK)) { 74 g.drawImage(breakStepImage, x-1, y+3-breakStepImage.getHeight(null), 75 null); 76 } 77 else { g.drawImage(breakImage, x-1, y+3-breakImage.getHeight(null), null); 79 } 80 } 81 else if(hasTag(line, STEPMARK)) { 82 g.drawImage(stepImage, x-1, y+3-stepImage.getHeight(null), null); 83 } 84 85 if(tokenMarker == null) { 86 Utilities.drawTabbedText(lineText, x+BREAKPOINT_OFFSET, y, g, this, 0); 87 } 88 else { 89 paintSyntaxLine(lineText, lineIndex, x+BREAKPOINT_OFFSET, y, g, 90 document, tokenMarker, def); 91 } 92 } 93 94 98 public void paint(Graphics g, Shape allocation) 99 { 100 Rectangle bounds = allocation.getBounds(); 102 if(Boolean.FALSE.equals(getDocument().getProperty(MoeEditor.COMPILED))) { 103 g.setColor(Color.lightGray); 104 g.fillRect(0, 0, bounds.x + TAG_WIDTH, 105 bounds.y + bounds.height); 106 } 107 108 super.paint(g, allocation); 110 111 g.setColor(Color.black); 113 g.drawLine(bounds.x + TAG_WIDTH, 0, 114 bounds.x + TAG_WIDTH, bounds.y + bounds.height); 115 } 116 117 } 118 | Popular Tags |