@@ -38,12 +38,12 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
38
38
39
39
/** Rollover titles for each button. */
40
40
static final String title [] = {
41
- _ ("Verify" ), _ ("Upload" ), _ ("New" ), _ ("Open" ), _ ("Save" ), _ ("Serial Monitor" )
41
+ _ ("Verify" ), _ ("Upload" ), _ ("New" ), _ ("Open" ), _ ("Save" ), _ ("Serial Monitor" ), _ ( "Serial Plotter" )
42
42
};
43
43
44
44
/** Titles for each button when the shift key is pressed. */
45
45
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" )
47
47
};
48
48
49
49
static final int BUTTON_COUNT = title .length ;
@@ -65,6 +65,7 @@ public class EditorToolbar extends JComponent implements MouseInputListener, Key
65
65
static final int SAVE = 4 ;
66
66
67
67
static final int SERIAL = 5 ;
68
+ static final int PLOTTER = 6 ;
68
69
69
70
static final int INACTIVE = 0 ;
70
71
static final int ROLLOVER = 1 ;
@@ -110,6 +111,7 @@ public EditorToolbar(Editor editor, JMenu menu) {
110
111
which [buttonCount ++] = OPEN ;
111
112
which [buttonCount ++] = SAVE ;
112
113
which [buttonCount ++] = SERIAL ;
114
+ which [buttonCount ++] = PLOTTER ;
113
115
114
116
currentRollover = -1 ;
115
117
@@ -173,8 +175,11 @@ public void paintComponent(Graphics screen) {
173
175
}
174
176
175
177
// 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 ;
178
183
}
179
184
Graphics g = offscreen .getGraphics ();
180
185
g .setColor (bgcolor ); //getBackground());
@@ -201,12 +206,15 @@ public void paintComponent(Graphics screen) {
201
206
if (currentRollover != -1 ) {
202
207
int statusY = (BUTTON_HEIGHT + g .getFontMetrics ().getAscent ()) / 2 ;
203
208
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 );
210
218
}
211
219
}
212
220
@@ -352,6 +360,10 @@ public void mousePressed(MouseEvent e) {
352
360
case SERIAL :
353
361
editor .handleSerial ();
354
362
break ;
363
+
364
+ case PLOTTER :
365
+ editor .handlePlotter ();
366
+ break ;
355
367
}
356
368
}
357
369
0 commit comments