Sets the cursor based on the current tool and cursor location.
(int sx, int sy, int ox, int oy)
| 666 | |
| 667 | /** Sets the cursor based on the current tool and cursor location. */ |
| 668 | public void setCursor(int sx, int sy, int ox, int oy) { |
| 669 | xMouse = ox; |
| 670 | yMouse = oy; |
| 671 | mouseExited = false; |
| 672 | Roi roi = imp.getRoi(); |
| 673 | ImageWindow win = imp.getWindow(); |
| 674 | overOverlayLabel = false; |
| 675 | if (win==null) |
| 676 | return; |
| 677 | if (IJ.spaceBarDown()) { |
| 678 | setCursor(handCursor); |
| 679 | return; |
| 680 | } |
| 681 | int id = Toolbar.getToolId(); |
| 682 | switch (id) { |
| 683 | case Toolbar.MAGNIFIER: |
| 684 | setCursor(moveCursor); |
| 685 | break; |
| 686 | case Toolbar.HAND: |
| 687 | setCursor(handCursor); |
| 688 | break; |
| 689 | default: //selection tool |
| 690 | PlugInTool tool = Toolbar.getPlugInTool(); |
| 691 | boolean arrowTool = roi!=null && (roi instanceof Arrow) && tool!=null && "Arrow Tool".equals(tool.getToolName()); |
| 692 | if ((id>=Toolbar.CUSTOM1) && !arrowTool) { |
| 693 | if (Prefs.usePointerCursor) |
| 694 | setCursor(defaultCursor); |
| 695 | else |
| 696 | setCursor(crosshairCursor); |
| 697 | } else if (roi!=null && roi.getState()!=roi.CONSTRUCTING && roi.isHandle(sx, sy)>=0) { |
| 698 | setCursor(handCursor); |
| 699 | } else if ((imp.getOverlay()!=null||showAllOverlay!=null) && overOverlayLabel(sx,sy,ox,oy) && (roi==null||roi.getState()!=roi.CONSTRUCTING)) { |
| 700 | overOverlayLabel = true; |
| 701 | setCursor(handCursor); |
| 702 | } else if (Prefs.usePointerCursor || (roi!=null && roi.getState()!=roi.CONSTRUCTING && roi.contains(ox, oy))) |
| 703 | setCursor(defaultCursor); |
| 704 | else |
| 705 | setCursor(crosshairCursor); |
| 706 | } |
| 707 | } |
| 708 | |
| 709 | private boolean overOverlayLabel(int sx, int sy, int ox, int oy) { |
| 710 | Overlay o = showAllOverlay; |
no test coverage detected