Updates the X and Y values when the mouse is moved and, if appropriate, shows/hides the overlay with the triangular buttons for changing the axis range limits. Overrides mouseMoved() in ImageWindow. @see ij.gui.ImageWindow#mouseMoved
(int x, int y)
| 613 | * @see ij.gui.ImageWindow#mouseMoved |
| 614 | */ |
| 615 | @AstroImageJ(reason = "Support scaled plots", modified = true) |
| 616 | public void mouseMoved(int x, int y) { |
| 617 | if (plot != null && plot.isAijPlot()) { |
| 618 | x = (int)(x * Prefs.getGuiScale()); |
| 619 | y = (int)(y * Prefs.getGuiScale()); |
| 620 | } |
| 621 | super.mouseMoved(x, y); |
| 622 | if (plot == null) |
| 623 | return; |
| 624 | String statusText = null; //coordinate readout, status or tooltip, will be shown in coordinate&status line |
| 625 | |
| 626 | //arrows and other symbols for modifying the plot range |
| 627 | var xBound = plot.frameWidth * (plot.isAijPlot() ? Prefs.getGuiScale() : 1.0); |
| 628 | var yBound = plot.frameHeight * (plot.isAijPlot() ? Prefs.getGuiScale() : 1.0); |
| 629 | if (x < xBound || y > plot.topMargin + yBound) { |
| 630 | if (!rangeArrowsVisible && !plot.isFrozen()) |
| 631 | showRangeArrows(); |
| 632 | if (activeRangeArrow < 0) //mouse is not on one of the symbols, ignore (nothing to display) |
| 633 | {} |
| 634 | else if (activeRangeArrow < 8) //mouse over an arrow: 0,3,4,7 for increase, 1,2,5,6 for decrease |
| 635 | statusText = ((activeRangeArrow+1)&0x02) != 0 ? "Decrease Range" : "Increase Range"; |
| 636 | else if (activeRangeArrow == 8) //it's the 'R' icon |
| 637 | statusText = "Reset Range"; |
| 638 | else if (activeRangeArrow == 9) //it's the 'F' icon |
| 639 | statusText = "Full Range (Fit All)"; |
| 640 | else if (activeRangeArrow >= 10 && |
| 641 | activeRangeArrow < 14) //space between arrow-pairs for single number |
| 642 | statusText = "Set limit..."; |
| 643 | else if (activeRangeArrow >= 14) |
| 644 | statusText = "Axis Range & Options..."; |
| 645 | boolean repaint = false; |
| 646 | if (activeRangeArrow >= 0 && !rangeArrowRois[activeRangeArrow].contains(x, y)) { |
| 647 | rangeArrowRois[activeRangeArrow].setFillColor( |
| 648 | activeRangeArrow < 10 ? inactiveRangeArrowColor : inactiveRangeRectColor); |
| 649 | repaint = true; //de-highlight arrow where cursor has moved out |
| 650 | activeRangeArrow = -1; |
| 651 | } |
| 652 | if (activeRangeArrow < 0) { //no currently highlighted arrow, do we have a new one? |
| 653 | int i = getRangeArrowIndex(x, y); |
| 654 | if (i >= 0) { //we have an arrow or symbol at cursor position |
| 655 | rangeArrowRois[i].setFillColor( |
| 656 | i < 14 ? activeRangeArrowColor : activeRangeRectColor); |
| 657 | activeRangeArrow = i; |
| 658 | repaint = true; |
| 659 | } |
| 660 | } |
| 661 | if (repaint) ic.repaint(); |
| 662 | } else if (rangeArrowsVisible) |
| 663 | hideRangeArrows(); |
| 664 | |
| 665 | if (statusText == null) |
| 666 | statusText = userStatusText != null ? userStatusText : plot.getCoordinates(x, y); |
| 667 | if (statusLabel != null) |
| 668 | statusLabel.setText(statusText); |
| 669 | } |
| 670 | |
| 671 | /** Called by PlotCanvas */ |
| 672 | void mouseExited(MouseEvent e) { |
nothing calls this directly
no test coverage detected