@@ -15,6 +15,8 @@ public class CommitsInfoLayerUI extends LayerUI<JComponent> implements ImageObse
1515 boolean isThereSomthingToDisplay = false ;
1616 CommitWrapper commitToDisplay = null ;
1717
18+ boolean showJustMessage = false ;
19+
1820 final Color bgColor = new Color (33 ,33 ,33 ,230 );
1921 //final Color TITLE_COLOR = Color.LIGHT_GRAY;
2022 final Color TEXT_COLOR = Color .WHITE ;
@@ -27,6 +29,11 @@ public class CommitsInfoLayerUI extends LayerUI<JComponent> implements ImageObse
2729 Font BOLD_FONT = new Font ("Arial" , Font .BOLD , 12 );
2830 Font BOLDER_FONT = new Font ("Arial" , Font .BOLD , 20 );
2931
32+ int LEFT_MARGIN_ICON_AND_COMMIT_MESSEGE = 0 ;
33+ int LEFT_MARGIN = 0 ;
34+ int LEFT_TEXT_MARGIN = 0 ;
35+ int RIGHT_MARGIN = 0 ;
36+
3037 private BufferedImage dateImage = null , commitIDImage = null , authorImage =null ;
3138
3239 public CommitsInfoLayerUI ()
@@ -50,21 +57,69 @@ public void paint(Graphics g, JComponent c)
5057 super .paint (g , c );
5158 if (!isThereSomthingToDisplay ) return ;
5259
60+ LEFT_MARGIN_ICON_AND_COMMIT_MESSEGE = 10 ;
61+ LEFT_MARGIN = 30 ;
62+ LEFT_TEXT_MARGIN = LEFT_MARGIN +45 ;
63+ RIGHT_MARGIN = 20 ;
5364
5465 Graphics2D g2d = (Graphics2D ) g .create ();
5566
5667 int w = c .getWidth ();
5768 int h = c .getHeight ();
58- final int LEFT_MARGIN_ICON_AND_COMMIT_MESSEGE = 10 ;
59- final int LEFT_MARGIN = 30 ;
60- final int LEFT_TEXT_MARGIN = LEFT_MARGIN +45 ;
61- final int RIGHT_MARGIN = 20 ;
62-
6369
6470 // Background
6571 g2d .setColor (bgColor );
6672 g2d .fillRect (0 ,0 ,w , h -0 /*10: because the scroll-handle is not black, so if we make it black it's not pretty*/ );
6773
74+
75+ if (showJustMessage == false )
76+ draw_allCommitInfo (g , g2d , w );
77+ else
78+ draw_justCommitMessage (g2d , w );
79+
80+ g2d .dispose ();
81+ }
82+
83+ private void draw_justCommitMessage (Graphics2D g2d , int w )
84+ {
85+ ////////4
86+ String s1 ="Message: " ;
87+ String commitMessage = commitToDisplay .getCommitMessage ();
88+ int Y = 20 ;
89+
90+ g2d .setFont (NORM_FONT );
91+ g2d .setColor (BROWN );
92+ g2d .drawString (s1 ,LEFT_MARGIN_ICON_AND_COMMIT_MESSEGE , Y );
93+ int k = g2d .getFontMetrics ().stringWidth (s1 );
94+
95+ g2d .setFont (NORM_FONT );
96+ g2d .setColor (TEXT_COLOR );
97+ int maxAvailableWidth = w -k -LEFT_MARGIN -RIGHT_MARGIN ;
98+ if (maxAvailableWidth <5 /*something near 0*/ ) return ;// otherwise the below 'n-3' would be negative and cause bugs.
99+
100+ int line =0 ; //we have 5 lines
101+ final int TOTAL_AVAILABLE_LINES = 5 ;
102+ while (line <TOTAL_AVAILABLE_LINES )
103+ {
104+ int n = DrawingHelper .howManyCharFitsInWidth (g2d ,commitMessage , maxAvailableWidth );
105+ if (n <commitMessage .length () /*text doesn't fit*/ && line ==TOTAL_AVAILABLE_LINES -1 /*last line*/ )
106+ {
107+ commitMessage = commitMessage .substring (0 , n - 3 /*for "..."*/ ) + "..." ;
108+ g2d .drawString (commitMessage ,LEFT_TEXT_MARGIN ,Y );
109+ break ;
110+ }
111+ else
112+ {
113+ g2d .drawString (commitMessage .substring (0 ,n ),LEFT_TEXT_MARGIN ,Y );
114+ commitMessage = commitMessage .substring (n );
115+ Y += 20 ;
116+ line ++;
117+ }
118+ }
119+ }
120+
121+ private void draw_allCommitInfo (Graphics g , Graphics2D g2d , int w )
122+ {
68123 // Text 1-2-3-4
69124 ////////1
70125 g .drawImage (commitIDImage , LEFT_MARGIN_ICON_AND_COMMIT_MESSEGE -2 /*this icon width is longer than others*/ ,11 ,this );
@@ -114,9 +169,6 @@ public void paint(Graphics g, JComponent c)
114169 if (n <s2 .length ())
115170 s2 = s2 .substring (0 ,n -3 /*for "..."*/ )+"..." ;
116171 g2d .drawString (s2 ,LEFT_TEXT_MARGIN ,Y );
117-
118-
119- g2d .dispose ();
120172 }
121173
122174 void invisble ()
@@ -131,6 +183,10 @@ void displayInfo(CommitWrapper commit)
131183 commitToDisplay = commit ;
132184 }
133185
186+ void toggleInfoDisplayingType ()
187+ {
188+ showJustMessage = !showJustMessage ;
189+ }
134190
135191 @ Override
136192 public boolean imageUpdate (Image img , int infoflags , int x , int y , int width , int height )
0 commit comments