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

Method zoom

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

Zooms in or out active plots while keeping focus on cursor position Above or below frame: zoom x only Left or right of frame: zoom y only Corners: focus is in center N. Vischer

(int x, int y, double zoomFactor)

Source from the content-addressed store, hash-verified

2623 * N. Vischer
2624 */
2625 void zoom(int x, int y, double zoomFactor) {
2626 boolean wasLogX = logXAxis;
2627 boolean wasLogY = logYAxis;
2628 double plotX = descaleX(x);
2629 double plotY = descaleY(y);
2630 IJ.showStatus ("" + plotX);
2631 boolean insideX = x > frame.x && x < frame.x + frame.width;
2632 boolean insideY = y > frame.y && y < frame.y + frame.height;
2633 if (!insideX && !insideY) {
2634 insideX = true;
2635 insideY = true;
2636 x = frame.x + frame.width / 2;
2637 y = frame.y + frame.height / 2;
2638 }
2639 int leftPart = x - frame.x;
2640 int rightPart = frame.x + frame.width - x;
2641 int highPart = y - frame.y;
2642 int lowPart = frame.y + frame.height - y;
2643
2644 if (insideX) {
2645 currentMinMax[0] = descaleX((int) (x - leftPart / zoomFactor));
2646 currentMinMax[1] = descaleX((int) (x + rightPart / zoomFactor));
2647 }
2648 if (insideY) {
2649 currentMinMax[2] = descaleY((int) (y + lowPart / zoomFactor));
2650 currentMinMax[3] = descaleY((int) (y - highPart / zoomFactor));
2651 }
2652 updateImage();
2653 if (wasLogX != logXAxis ){//log-lin was automatically changed
2654 int changedX = (int) scaleXtoPxl(plotX);
2655 int left = changedX - leftPart;
2656 int right = changedX + rightPart;
2657 currentMinMax[0] = descaleX(left);
2658 currentMinMax[1] = descaleX(right);
2659 updateImage();
2660 }
2661 if (wasLogY != logYAxis){//log-lin was automatically changed
2662 int changedY = (int) scaleYtoPxl(plotY);
2663 int bottom = changedY + lowPart;
2664 int top = changedY + highPart;
2665 currentMinMax[2] = descaleY(bottom);
2666 currentMinMax[3] = descaleY(top);
2667 updateImage();
2668 }
2669 }
2670
2671 /** Moves the plot range by a given number of pixels and updates the image */
2672 void scroll(int dx, int dy) {

Callers

nothing calls this directly

Calls 6

descaleXMethod · 0.95
descaleYMethod · 0.95
showStatusMethod · 0.95
updateImageMethod · 0.95
scaleXtoPxlMethod · 0.95
scaleYtoPxlMethod · 0.95

Tested by

no test coverage detected