| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,7 +27,6 @@ | |||
| 27 | 27 | import java.awt.Color; | |
| 28 | 28 | import java.awt.Cursor; | |
| 29 | 29 | import java.awt.Font; | |
| 30 | - import java.awt.FontMetrics; | ||
| 31 | 30 | import java.awt.Graphics; | |
| 32 | 31 | import java.awt.Graphics2D; | |
| 33 | 32 | import java.awt.Point; | |
@@ -60,6 +59,8 @@ | |||
| 60 | 59 | /** | |
| 61 | 60 | * Customized line painter. Adds support for background colors, | |
| 62 | 61 | * left hand gutter area with background color and text. | |
| 62 | + * TODO Most of this needs to be merged into the main TextAreaPainter, | ||
| 63 | + * since it has nothing to do with Java. [fry] | ||
| 63 | 64 | */ | |
| 64 | 65 | public class JavaTextAreaPainter extends TextAreaPainter | |
| 65 | 66 | implements MouseListener, MouseMotionListener { | |
@@ -75,14 +76,14 @@ public class JavaTextAreaPainter extends TextAreaPainter | |||
| 75 | 76 | protected Font gutterTextFont; | |
| 76 | 77 | protected Color gutterTextColor; | |
| 77 | 78 | // protected Color gutterTempColor; | |
| 78 | - | ||
| 79 | + | ||
| 79 | 80 | public static class ErrorLineCoord { | |
| 80 | 81 | public int xStart; | |
| 81 | 82 | public int xEnd; | |
| 82 | 83 | public int yStart; | |
| 83 | 84 | public int yEnd; | |
| 84 | 85 | public Problem problem; | |
| 85 | - | ||
| 86 | + | ||
| 86 | 87 | public ErrorLineCoord(int xStart, int xEnd, int yStart, int yEnd, Problem problem) { | |
| 87 | 88 | this.xStart = xStart; | |
| 88 | 89 | this.xEnd = xEnd; | |
@@ -110,7 +111,7 @@ public void mouseClicked(MouseEvent evt) { | |||
| 110 | 111 | } | |
| 111 | 112 | } | |
| 112 | 113 | }); | |
| 113 | - | ||
| 114 | + | ||
| 114 | 115 | addMouseMotionListener(new MouseMotionAdapter() { | |
| 115 | 116 | @Override | |
| 116 | 117 | public void mouseMoved(final MouseEvent evt) { | |
@@ -255,17 +256,12 @@ protected void paintLeftGutter(Graphics gfx, int line, int x) { | |||
| 255 | 256 | ||
| 256 | 257 | //gfx.setFont(getFont()); | |
| 257 | 258 | gfx.setFont(gutterTextFont); | |
| 258 | - FontMetrics gm = getFontMetrics(); | ||
| 259 | - //int tx = Editor.GUTTER_MARGIN + ; | ||
| 259 | + // Right-align the text | ||
| 260 | 260 | int tx = Editor.LEFT_GUTTER - Editor.GUTTER_MARGIN - | |
| 261 | - gm.charsWidth(txt, 0, txt.length); | ||
| 262 | - // Color textColor = getTextArea().getGutterTextColor(line); | ||
| 263 | - // if (textColor == null) { | ||
| 264 | - // gfx.setColor(getForeground()); | ||
| 265 | - // } else { | ||
| 266 | - // gfx.setColor(textColor); | ||
| 267 | - // } | ||
| 261 | + gfx.getFontMetrics().charsWidth(txt, 0, txt.length); | ||
| 268 | 262 | gfx.setColor(gutterTextColor); | |
| 263 | + // Using 'fm' here because it's relative to the editor text size, | ||
| 264 | + // not the numbers in the gutter | ||
| 269 | 265 | int ty = textArea.lineToY(line) + fm.getHeight(); | |
| 270 | 266 | Utilities.drawTabbedText(new Segment(txt, 0, text.length()), | |
| 271 | 267 | tx, ty, gfx, this, 0); | |
@@ -397,7 +393,7 @@ protected void paintErrorLine(Graphics gfx, int line, int x) { | |||
| 397 | 393 | boolean notFound = true; | |
| 398 | 394 | boolean isWarning = false; | |
| 399 | 395 | Problem problem = null; | |
| 400 | - | ||
| 396 | + | ||
| 401 | 397 | errorLineCoords.clear(); | |
| 402 | 398 | // Check if current line contains an error. If it does, find if it's an | |
| 403 | 399 | // error or warning | |
@@ -453,7 +449,7 @@ protected void paintErrorLine(Graphics gfx, int line, int x) { | |||
| 453 | 449 | // Adding offsets for the gutter | |
| 454 | 450 | x1 += Editor.LEFT_GUTTER; | |
| 455 | 451 | x2 += Editor.LEFT_GUTTER; | |
| 456 | - | ||
| 452 | + | ||
| 457 | 453 | errorLineCoords.add(new ErrorLineCoord(x1, x2, y, y1, problem)); | |
| 458 | 454 | ||
| 459 | 455 | // gfx.fillRect(x1, y, rw, height); | |
@@ -529,7 +525,7 @@ public void setECSandTheme(ErrorCheckerService ecs, JavaMode mode) { | |||
| 529 | 525 | gutterTextFont = mode.getFont("editor.gutter.text.font"); | |
| 530 | 526 | gutterTextColor = mode.getColor("editor.gutter.text.color"); | |
| 531 | 527 | } | |
| 532 | - | ||
| 528 | + | ||
| 533 | 529 | @Override | |
| 534 | 530 | public String getToolTipText(MouseEvent event) { | |
| 535 | 531 | if (!getEditor().hasJavaTabs()) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments