@@ -38,12 +38,12 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
3838
3939 /** Rollover titles for each button. */
4040 static final String title [] = {
41- _ ("Verify" ), _ ("Upload" ), _ ("New" ), _ ("Open" ), _ ("Save" ), _ ("Serial Monitor" )
41+ _ ("Verify" ), _ ("Upload" ), _ ("New" ), _ ("Open" ), _ ("Save" ), _ ("Serial Monitor" ), _ ( "Serial Plotter" )
4242 };
4343
4444 /** Titles for each button when the shift key is pressed. */
4545 static final String titleShift [] = {
46- _ ("Verify" ), _ ("Upload Using Programmer" ), _ ("New Editor Window" ), _ ("Open in Another Window" ), _ ("Save" ), _ ("Serial Monitor" )
46+ _ ("Verify" ), _ ("Upload Using Programmer" ), _ ("New Editor Window" ), _ ("Open in Another Window" ), _ ("Save" ), _ ("Serial Monitor" ), _ ( "Serial Plotter" )
4747 };
4848
4949 static final int BUTTON_COUNT = title .length ;
@@ -65,6 +65,7 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
6565 static final int SAVE = 4 ;
6666
6767 static final int SERIAL = 5 ;
68+ static final int PLOTTER = 6 ;
6869
6970 static final int INACTIVE = 0 ;
7071 static final int ROLLOVER = 1 ;
@@ -110,6 +111,7 @@ public EditorToolbar(Editor editor, JMenu menu) {
110111 which [buttonCount ++] = OPEN ;
111112 which [buttonCount ++] = SAVE ;
112113 which [buttonCount ++] = SERIAL ;
114+ which [buttonCount ++] = PLOTTER ;
113115
114116 currentRollover = -1 ;
115117
@@ -173,8 +175,11 @@ public void paintComponent(Graphics screen) {
173175 }
174176
175177 // Serial button must be on the right
176- x1 [SERIAL ] = width - BUTTON_WIDTH - 14 ;
177- x2 [SERIAL ] = width - 14 ;
178+ x1 [SERIAL ] = width - 2 * BUTTON_WIDTH - 14 ;
179+ x2 [SERIAL ] = width - BUTTON_WIDTH - 14 ;
180+ // Plotter button too
181+ x1 [PLOTTER ] = width - BUTTON_WIDTH - 14 ;
182+ x2 [PLOTTER ] = width - 14 ;
178183 }
179184 Graphics g = offscreen .getGraphics ();
180185 g .setColor (bgcolor ); //getBackground());
@@ -201,12 +206,15 @@ public void paintComponent(Graphics screen) {
201206 if (currentRollover != -1 ) {
202207 int statusY = (BUTTON_HEIGHT + g .getFontMetrics ().getAscent ()) / 2 ;
203208 String status = shiftPressed ? titleShift [currentRollover ] : title [currentRollover ];
204- if (currentRollover != SERIAL )
205- g .drawString (status , (buttonCount -1 ) * BUTTON_WIDTH + 3 * BUTTON_GAP , statusY );
206- else {
207- int statusX = x1 [SERIAL ] - BUTTON_GAP ;
208- statusX -= g .getFontMetrics ().stringWidth (status );
209- g .drawString (status , statusX , statusY );
209+ switch (currentRollover ) {
210+ case SERIAL :
211+ case PLOTTER :
212+ int statusX = x1 [SERIAL ] - BUTTON_GAP ;
213+ statusX -= g .getFontMetrics ().stringWidth (status );
214+ g .drawString (status , statusX , statusY );
215+ break ;
216+ default :
217+ g .drawString (status , (buttonCount -1 ) * BUTTON_WIDTH + 3 * BUTTON_GAP , statusY );
210218 }
211219 }
212220
@@ -352,6 +360,10 @@ public void mousePressed(MouseEvent e) {
352360 case SERIAL :
353361 editor .handleSerial ();
354362 break ;
363+
364+ case PLOTTER :
365+ editor .handlePlotter ();
366+ break ;
355367 }
356368 }
357369
0 commit comments