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

Method fillShape

ij/src/main/java/ij/gui/Plot.java:3816–3855  ·  view source on GitHub ↗

Fill the area of the symbols for data points (except for shape=DOT) Note that ip.fill, ip.fillOval etc. can't be used here: they do not care about the clip rectangle

(int shape, int x0, int y0, int size)

Source from the content-addressed store, hash-verified

3814 /** Fill the area of the symbols for data points (except for shape=DOT)
3815 * Note that ip.fill, ip.fillOval etc. can't be used here: they do not care about the clip rectangle */
3816 void fillShape(int shape, int x0, int y0, int size) {
3817 if (shape == DIAMOND) size = (int)(size*1.21);
3818 int r = sc(size/2)-1;
3819 switch(shape) {
3820 case BOX:
3821 for (int dy=-r; dy<=r; dy++)
3822 for (int dx=-r; dx<=r; dx++)
3823 ip.drawDot(x0+dx, y0+dy);
3824 break;
3825 case TRIANGLE:
3826 int ybase = y0 - r - sc(1);
3827 int yend = y0 + r;
3828 double halfWidth = sc(size/2)+sc(1)-1;
3829 double hwStep = halfWidth/(yend-ybase+1);
3830 for (int y=yend; y>=ybase; y--, halfWidth -= hwStep) {
3831 int dx = (int)(Math.round(halfWidth));
3832 for (int x=x0-dx; x<=x0+dx; x++)
3833 ip.drawDot(x,y);
3834 }
3835 break;
3836 case DIAMOND:
3837 ybase = y0 - r - sc(1);
3838 yend = y0 + r;
3839 halfWidth = sc(size/2)+sc(1)-1;
3840 hwStep = halfWidth/(yend-ybase+1);
3841 for (int y=yend; y>=ybase; y--) {
3842 int dx = (int)(Math.round(halfWidth-(hwStep+1)*Math.abs(y-y0)));
3843 for (int x=x0-dx; x<=x0+dx; x++)
3844 ip.drawDot(x,y);
3845 }
3846 break;
3847 case CIRCLE: case CONNECTED_CIRCLES:
3848 int rsquare = (r+1)*(r+1);
3849 for (int dy=-r; dy<=r; dy++)
3850 for (int dx=-r; dx<=r; dx++)
3851 if (dx*dx + dy*dy <= rsquare)
3852 ip.drawDot(x0+dx, y0+dy);
3853 break;
3854 }
3855 }
3856
3857 /** Adds an arrow from position 1 to 2 given in pixels; 'size' is the length of the arrowhead
3858 * @deprecated Use as a public method is not supported any more because it is incompatible with rescaling */

Callers 2

drawPlotObjectMethod · 0.95
drawLegendMethod · 0.95

Calls 4

scMethod · 0.95
drawDotMethod · 0.45
roundMethod · 0.45
absMethod · 0.45

Tested by

no test coverage detected