(int sx, int sy)
| 903 | } |
| 904 | |
| 905 | protected void grow(int sx, int sy) { |
| 906 | if (clipboard!=null) return; |
| 907 | int xNew = ic.offScreenX2(sx); |
| 908 | int yNew = ic.offScreenY2(sy); |
| 909 | if (type==RECTANGLE) { |
| 910 | if (xNew < 0) xNew = 0; |
| 911 | if (yNew < 0) yNew = 0; |
| 912 | } |
| 913 | if (constrain) { |
| 914 | // constrain selection to be square |
| 915 | if (!center) |
| 916 | {growConstrained(xNew, yNew); return;} |
| 917 | int dx, dy, d; |
| 918 | dx = xNew - x; |
| 919 | dy = yNew - y; |
| 920 | if (dx<dy) |
| 921 | d = dx; |
| 922 | else |
| 923 | d = dy; |
| 924 | xNew = x + d; |
| 925 | yNew = y + d; |
| 926 | } |
| 927 | if (center) { |
| 928 | width = Math.abs(xNew - startX)*2; |
| 929 | height = Math.abs(yNew - startY)*2; |
| 930 | x = startX - width/2; |
| 931 | y = startY - height/2; |
| 932 | } else { |
| 933 | width = Math.abs(xNew - startX); |
| 934 | height = Math.abs(yNew - startY); |
| 935 | x = (xNew>=startX)?startX:startX - width; |
| 936 | y = (yNew>=startY)?startY:startY - height; |
| 937 | if (type==RECTANGLE) { |
| 938 | if ((x+width) > xMax) width = xMax-x; |
| 939 | if ((y+height) > yMax) height = yMax-y; |
| 940 | } |
| 941 | } |
| 942 | updateClipRect(); |
| 943 | imp.draw(clipX, clipY, clipWidth, clipHeight); |
| 944 | oldX = x; |
| 945 | oldY = y; |
| 946 | oldWidth = width; |
| 947 | oldHeight = height; |
| 948 | bounds = null; |
| 949 | } |
| 950 | |
| 951 | private void growConstrained(int xNew, int yNew) { |
| 952 | int dx = xNew - startX; |
no test coverage detected