3232import java .awt .Image ;
3333import java .awt .event .MouseAdapter ;
3434import java .awt .event .MouseEvent ;
35+ import java .awt .font .FontRenderContext ;
36+ import java .awt .geom .Ellipse2D ;
3537import java .util .ArrayList ;
3638import java .util .List ;
3739
@@ -68,6 +70,7 @@ public class EditorFooter extends Box {
6870
6971 Color [] textColor = new Color [2 ];
7072 Color [] tabColor = new Color [2 ];
73+ Color updateColor ;
7174
7275 Editor editor ;
7376
@@ -86,6 +89,8 @@ public class EditorFooter extends Box {
8689 CardLayout cardLayout ;
8790 Controller controller ;
8891
92+ int updateCount ;
93+
8994
9095 public EditorFooter (Editor eddie ) {
9196 super (BoxLayout .Y_AXIS );
@@ -145,6 +150,12 @@ public void setNotification(Component comp, boolean note) {
145150 }
146151
147152
153+ public void setUpdateCount (int count ) {
154+ this .updateCount = count ;
155+ repaint ();
156+ }
157+
158+
148159 public void updateMode () {
149160 Mode mode = editor .getMode ();
150161
@@ -155,7 +166,7 @@ public void updateMode() {
155166 tabColor [SELECTED ] = mode .getColor ("footer.tab.selected.color" );
156167 tabColor [UNSELECTED ] = mode .getColor ("footer.tab.unselected.color" );
157168
158- // errorColor = mode.getColor("status.error.bgcolor ");
169+ updateColor = mode .getColor ("footer.updates.color " );
159170
160171 gradient = mode .makeGradient ("footer" , 400 , HIGH );
161172 }
@@ -233,7 +244,9 @@ public void paintComponent(Graphics screen) {
233244 }
234245
235246 // now actually draw the tabs
236- placeTabs (Editor .LEFT_GUTTER , g2 );
247+ drawTabs (Editor .LEFT_GUTTER , g2 );
248+
249+ drawUpdates (g2 );
237250
238251// // draw the two pixel line that extends left/right below the tabs
239252// g.setColor(tabColor[SELECTED]);
@@ -249,7 +262,7 @@ public void paintComponent(Graphics screen) {
249262 * @param left starting position from the left
250263 * @param g graphics context, or null if we're not drawing
251264 */
252- private void placeTabs (int left , Graphics2D g ) {
265+ private void drawTabs (int left , Graphics2D g ) {
253266 int x = left ;
254267
255268 for (Tab tab : tabs ) {
@@ -261,43 +274,30 @@ private void placeTabs(int left, Graphics2D g) {
261274 x += tab .textWidth + MARGIN ;
262275 tab .right = x ;
263276
264- // if drawing and not just placing
265- if (g != null ) {
266- tab .draw (g );
267- /*
268- int state = tab.isCurrent() ? SELECTED : UNSELECTED;
269- g.setColor(tabColor[state]);
270- if (tab.notification) {
271- g.setColor(errorColor);
272- }
273- //drawTab(g, tab.left, tab.right, tab.isFirst(), tab.isLast());
274- tab.draw(g);
275-
276- int textLeft = tab.getTextLeft();
277- if (tab.notification && state == UNSELECTED) {
278- g.setColor(Color.LIGHT_GRAY);
279- } else {
280- g.setColor(textColor[state]);
281- }
282- int tabHeight = TAB_BOTTOM - TAB_TOP;
283- int baseline = TAB_TOP + (tabHeight + fontAscent) / 2;
284- g.drawString(tab.name, textLeft, baseline);
285- */
286- }
277+ tab .draw (g );
287278 x += TAB_BETWEEN ;
288279 }
289280 }
290281
291282
292- /*
293- private void drawTab(Graphics g, int left, int right,
294- boolean leftNotch, boolean rightNotch) {
295- Graphics2D g2 = (Graphics2D) g;
296- g2.fill(Toolkit.createRoundRect(left, TAB_TOP, right, TAB_BOTTOM, 0, 0,
297- rightNotch ? CURVE_RADIUS : 0,
298- leftNotch ? CURVE_RADIUS : 0));
283+ private void drawUpdates (Graphics2D g2 ) {
284+ FontRenderContext frc = g2 .getFontRenderContext ();
285+ final int GAP = 5 ;
286+ final String updateLabel = "Updates" ;
287+ String updatesStr = "" + updateCount ;
288+ double countWidth = font .getStringBounds (updatesStr , frc ).getWidth ();
289+ float diameter = (float ) (countWidth * 1.65f );
290+ float ex = getWidth () - Editor .RIGHT_GUTTER - diameter ;
291+ float ey = (getHeight () - diameter ) / 2 ;
292+ g2 .setColor (updateColor );
293+ g2 .fill (new Ellipse2D .Float (ex , ey , diameter , diameter ));
294+ g2 .setColor (textColor [SELECTED ]);
295+ int baseline = (getHeight () + fontAscent ) / 2 ;
296+ g2 .drawString (updatesStr , (int ) (ex + (diameter - countWidth )/2 ), baseline );
297+ double updatesWidth = font .getStringBounds (updateLabel , frc ).getWidth ();
298+ g2 .setColor (textColor [UNSELECTED ]);
299+ g2 .drawString (updateLabel , (int ) (ex - updatesWidth - GAP ), baseline );
299300 }
300- */
301301
302302
303303 public Dimension getPreferredSize () {
0 commit comments