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

Method setLimitsNoUpdate

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

Sets the x-axis and y-axis range. Accepts NaN values to indicate auto range. Does not update the image and leaves the default limits (for reset via the 'R' field) untouched.

(double xMin, double xMax, double yMin, double yMax)

Source from the content-addressed store, hash-verified

452 /** Sets the x-axis and y-axis range. Accepts NaN values to indicate auto range.
453 * Does not update the image and leaves the default limits (for reset via the 'R' field) untouched. */
454 void setLimitsNoUpdate(double xMin, double xMax, double yMin, double yMax) {
455 boolean containsNaN = (Double.isNaN(xMin + xMax + yMin + yMax));
456 if (containsNaN && getNumPlotObjects(PlotObject.XY_DATA|PlotObject.ARROWS, false)==0)//can't apply auto-range without data
457 return;
458 double[] range = {xMin, xMax, yMin, yMax};
459 if (containsNaN) { //auto range for at least one limit
460 double[] extrema = getMinAndMax(true, ALL_AXES_RANGE);
461 boolean[] auto = new boolean[range.length];
462 for (int i = 0; i < range.length; i++)
463 if (Double.isNaN(range[i])) {
464 auto[i] = true;
465 range[i] = extrema[i];
466 }
467 for (int a = 0; a<range.length; a+=2) { //for all axes (0 for x, 2 for y): would semi-auto reverse the axis?
468 if (auto[a] == auto[a+1]) continue; //ignore if not semi-auto
469 boolean currentAxisReverse = defaultMinMax[a+1] < defaultMinMax[a];
470 if ((!currentAxisReverse && range[a+1] <= range[a]) || (currentAxisReverse && range[a] <= range[a+1])) {
471 auto[a] = true; //semi-auto to full-auto
472 auto[a+1] = true;
473 range[a] = extrema[a];
474 range[a+1] = extrema[a+1];
475 }
476 }
477 for (int i = 0; i < range.length; i++)
478 if (!auto[i]) // don't modify for limits that were set manually
479 enlargeRange[i] = 0;
480 enlargeRange(range); // for automatic limits, avoid points exactly at the border
481 }
482 System.arraycopy(range, 0, currentMinMax, 0, Math.min(range.length, currentMinMax.length));
483 ignoreForce2Grid = true;
484 }
485
486 /** Takes over the current limits as the default ones (i.e., the limits set by clicking at the 'R' field in the bottom-left corner) */
487 void makeLimitsDefault() {

Callers 2

setLimitsMethod · 0.95
dialogItemChangedMethod · 0.80

Calls 5

getNumPlotObjectsMethod · 0.95
getMinAndMaxMethod · 0.95
enlargeRangeMethod · 0.95
arraycopyMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected