MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / drawButton

Method drawButton

ij/src/main/java/ij/gui/Toolbar.java:356–506  ·  view source on GitHub ↗
(Graphics g, int tool)

Source from the content-addressed store, hash-verified

354 }
355
356 private void drawButton(Graphics g, int tool) {
357 if (g==null) return;
358 if (legacyMode) {
359 if (tool==UNUSED)
360 tool = CUSTOM1;
361 else if (tool>=CUSTOM1)
362 tool++;
363 if ((tool==POLYLINE && lineType!=POLYLINE) || (tool==FREELINE && lineType!=FREELINE))
364 return;
365 }
366 int index = toolIndex(tool);
367 int x = index*buttonWidth + 1*scale;
368 if (tool>=CUSTOM1)
369 x -= buttonWidth-gapSize;
370 if (tool!=UNUSED)
371 fill3DRect(g, x, 1, buttonWidth, buttonHeight-1, !down[tool]);
372 g.setColor(toolColor);
373 x = index*buttonWidth + offset;
374 if (tool>=CUSTOM1)
375 x -= buttonWidth-gapSize;
376 int y = offset;
377 if (dscale==1.3) {x++; y++;}
378 if (dscale==1.4) {x+=2; y+=2;}
379 if (down[tool]) { x++; y++;}
380 this.g = g;
381 if (tool>=CUSTOM1 && tool<=getNumTools() && icons[tool]!=null) {
382 drawIcon(g, tool, x+1*scale, y+1*scale);
383 return;
384 }
385 switch (tool) {
386 case RECTANGLE:
387 xOffset = x; yOffset = y;
388 if (rectType==ROUNDED_RECT_ROI)
389 g.drawRoundRect(x-1*scale, y+1*scale, 17*scale, 13*scale, 8*scale, 8*scale);
390 else if (rectType==ROTATED_RECT_ROI)
391 polyline(0,10,7,0,15,6,8,16,0,10);
392 else
393 g.drawRect(x-1*scale, y+1*scale, 17*scale, 13*scale);
394 drawTriangle(16,16);
395 return;
396 case OVAL:
397 xOffset = x; yOffset = y;
398 if (ovalType==BRUSH_ROI) {
399 yOffset = y - 1;
400 polyline(6,4,8,2,12,1,15,2,16,4,15,7,12,8,9,11,9,14,6,16,2,16,0,13,1,10,4,9,6,7,6,4);
401 } else if (ovalType==ELLIPSE_ROI) {
402 xOffset = x - 1;
403 yOffset = y + 1;
404 polyline(11,0,13,0,14,1,15,1,16,2,17,3,17,7,12,12,11,12,10,13,8,13,7,14,4,14,3,13,2,13,1,12,1,11,0,10,0,9,1,8,1,7,6,2,7,2,8,1,10,1,11,0);
405 } else
406 g.drawOval(x, y+1*scale, 17*scale, 13*scale);
407 drawTriangle(16,16);
408 return;
409 case POLYGON:
410 xOffset = x+1; yOffset = y+2;
411 polyline(4,0,15,0,15,1,11,5,11,6,14,11,14,12,0,12,0,4,4,0);
412 return;
413 case FREEROI:

Callers 6

drawButtonsMethod · 0.95
setTool2Method · 0.95
setColorMethod · 0.95
repaintToolMethod · 0.95
drawToolMethod · 0.95
setIconMethod · 0.80

Calls 15

toolIndexMethod · 0.95
fill3DRectMethod · 0.95
getNumToolsMethod · 0.95
drawIconMethod · 0.95
polylineMethod · 0.95
drawTriangleMethod · 0.95
mMethod · 0.95
dMethod · 0.95
drawDotMethod · 0.95
drawPointMethod · 0.95
getColorMethod · 0.95
dotMethod · 0.95

Tested by

no test coverage detected