summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/gui/BoxHighlightPainter.java
diff options
context:
space:
mode:
authorGravatar jeff2015-01-13 23:25:04 -0500
committerGravatar jeff2015-01-13 23:25:04 -0500
commit959cb5fd4f9586ec3bd265b452fe25fe1db82e3f (patch)
treebdd8a2c52c2fe053ba3460614bde8542e5378dbe /src/cuchaz/enigma/gui/BoxHighlightPainter.java
parentgot rid of gradle in favor of ivy+ssjb (diff)
downloadenigma-fork-959cb5fd4f9586ec3bd265b452fe25fe1db82e3f.tar.gz
enigma-fork-959cb5fd4f9586ec3bd265b452fe25fe1db82e3f.tar.xz
enigma-fork-959cb5fd4f9586ec3bd265b452fe25fe1db82e3f.zip
source format change
don't hate me too much if you were planning a big merge. =P
Diffstat (limited to 'src/cuchaz/enigma/gui/BoxHighlightPainter.java')
-rw-r--r--src/cuchaz/enigma/gui/BoxHighlightPainter.java37
1 files changed, 15 insertions, 22 deletions
diff --git a/src/cuchaz/enigma/gui/BoxHighlightPainter.java b/src/cuchaz/enigma/gui/BoxHighlightPainter.java
index df63f5a..db7c85b 100644
--- a/src/cuchaz/enigma/gui/BoxHighlightPainter.java
+++ b/src/cuchaz/enigma/gui/BoxHighlightPainter.java
@@ -19,40 +19,35 @@ import javax.swing.text.BadLocationException;
19import javax.swing.text.Highlighter; 19import javax.swing.text.Highlighter;
20import javax.swing.text.JTextComponent; 20import javax.swing.text.JTextComponent;
21 21
22public abstract class BoxHighlightPainter implements Highlighter.HighlightPainter 22public abstract class BoxHighlightPainter implements Highlighter.HighlightPainter {
23{ 23
24 private Color m_fillColor; 24 private Color m_fillColor;
25 private Color m_borderColor; 25 private Color m_borderColor;
26 26
27 protected BoxHighlightPainter( Color fillColor, Color borderColor ) 27 protected BoxHighlightPainter(Color fillColor, Color borderColor) {
28 {
29 m_fillColor = fillColor; 28 m_fillColor = fillColor;
30 m_borderColor = borderColor; 29 m_borderColor = borderColor;
31 } 30 }
32 31
33 @Override 32 @Override
34 public void paint( Graphics g, int start, int end, Shape shape, JTextComponent text ) 33 public void paint(Graphics g, int start, int end, Shape shape, JTextComponent text) {
35 { 34 Rectangle bounds = getBounds(text, start, end);
36 Rectangle bounds = getBounds( text, start, end );
37 35
38 // fill the area 36 // fill the area
39 if( m_fillColor != null ) 37 if (m_fillColor != null) {
40 { 38 g.setColor(m_fillColor);
41 g.setColor( m_fillColor ); 39 g.fillRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, 4, 4);
42 g.fillRoundRect( bounds.x, bounds.y, bounds.width, bounds.height, 4, 4 );
43 } 40 }
44 41
45 // draw a box around the area 42 // draw a box around the area
46 g.setColor( m_borderColor ); 43 g.setColor(m_borderColor);
47 g.drawRoundRect( bounds.x, bounds.y, bounds.width, bounds.height, 4, 4 ); 44 g.drawRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, 4, 4);
48 } 45 }
49 46
50 protected static Rectangle getBounds( JTextComponent text, int start, int end ) 47 protected static Rectangle getBounds(JTextComponent text, int start, int end) {
51 { 48 try {
52 try
53 {
54 // determine the bounds of the text 49 // determine the bounds of the text
55 Rectangle bounds = text.modelToView( start ).union( text.modelToView( end ) ); 50 Rectangle bounds = text.modelToView(start).union(text.modelToView(end));
56 51
57 // adjust the box so it looks nice 52 // adjust the box so it looks nice
58 bounds.x -= 2; 53 bounds.x -= 2;
@@ -61,11 +56,9 @@ public abstract class BoxHighlightPainter implements Highlighter.HighlightPainte
61 bounds.height -= 2; 56 bounds.height -= 2;
62 57
63 return bounds; 58 return bounds;
64 } 59 } catch (BadLocationException ex) {
65 catch( BadLocationException ex )
66 {
67 // don't care... just return something 60 // don't care... just return something
68 return new Rectangle( 0, 0, 0, 0 ); 61 return new Rectangle(0, 0, 0, 0);
69 } 62 }
70 } 63 }
71} 64}