MCPcopy Index your code
hub / github.com/arduino/Arduino / paintComponent

Method paintComponent

app/src/processing/app/EditorToolbar.java:258–337  ·  view source on GitHub ↗
(Graphics screen)

Source from the content-addressed store, hash-verified

256 }
257
258 @Override
259 public void paintComponent(Graphics screen) {
260 // this data is shared by all EditorToolbar instances
261 if (buttonImages == null) {
262 loadButtons();
263 }
264
265 // this happens once per instance of EditorToolbar
266 if (stateImage == null) {
267 state = new int[buttonCount];
268 stateImage = new Image[buttonCount];
269 for (int i = 0; i < buttonCount; i++) {
270 setState(i, INACTIVE, false);
271 }
272 y1 = 0;
273 y2 = BUTTON_HEIGHT;
274 x1 = new int[buttonCount];
275 x2 = new int[buttonCount];
276 }
277
278 Dimension size = getSize();
279 if ((offscreen == null) ||
280 (size.width != width) || (size.height != height)) {
281 offscreen = createImage(size.width, size.height);
282 width = size.width;
283 height = size.height;
284
285 int offsetX = 3;
286 for (int i = 0; i < buttonCount; i++) {
287 x1[i] = offsetX;
288 if (i == 2 || i == 6) x1[i] += BUTTON_GAP;
289 x2[i] = x1[i] + BUTTON_WIDTH;
290 offsetX = x2[i];
291 }
292
293 // Serial button must be on the right
294 x1[SERIAL] = width - BUTTON_WIDTH - 14;
295 x2[SERIAL] = width - 14;
296 }
297 Graphics2D g = Theme.setupGraphics2D(offscreen.getGraphics());
298 g.setColor(bgcolor); //getBackground());
299 g.fillRect(0, 0, width, height);
300
301 for (int i = 0; i < buttonCount; i++) {
302 g.drawImage(stateImage[i], x1[i], y1, null);
303 }
304
305 g.setColor(statusColor);
306 g.setFont(statusFont);
307
308 /*
309 // if i ever find the guy who wrote the java2d api, i will hurt him.
310 *
311 * whereas I love the Java2D API. --jdf. lol.
312 *
313 Graphics2D g2 = (Graphics2D) g;
314 FontRenderContext frc = g2.getFontRenderContext();
315 float statusW = (float) statusFont.getStringBounds(status, frc).getWidth();

Callers

nothing calls this directly

Calls 5

loadButtonsMethod · 0.95
setStateMethod · 0.95
setupGraphics2DMethod · 0.95
setColorMethod · 0.80
getSizeMethod · 0.45

Tested by

no test coverage detected