This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit ad2649f616cbc2222fbaa9d8601d6caa42a780c6 Author: Martin Desruisseaux <[email protected]> AuthorDate: Thu May 26 18:45:05 2022 +0200 Rename `GridExtent.setRange(…)` as `withRange(…)` because it does not modify the current instance. --- .../main/java/org/apache/sis/gui/coverage/GridSliceSelector.java | 4 ++-- .../src/main/java/org/apache/sis/coverage/grid/GridExtent.java | 7 ++++--- .../test/java/org/apache/sis/coverage/grid/GridExtentTest.java | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridSliceSelector.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridSliceSelector.java index dd515ddc25..a215db2ddb 100644 --- a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridSliceSelector.java +++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridSliceSelector.java @@ -246,7 +246,7 @@ public class GridSliceSelector extends Widget { slider.setMin(min); slider.setMax(max); slider.setValue(min); - selected = selected.setRange(dim, min, min); // Initially selected slice. + selected = selected.withRange(dim, min, min); // Initially selected slice. converter.configure(gg, gridToCRS, dim, min, max, envelope, resolution); converter.setTickSpacing(slider, slider.getWidth()); label.setText(vocabulary.toLabel(converter.getAxisLabel(extent, vocabulary))); @@ -457,7 +457,7 @@ public class GridSliceSelector extends Widget { } final GridExtent extent = selectedExtent.get(); if (extent != null && position != extent.getLow(dimension)) { - selectedExtent.set(extent.setRange(dimension, position, position)); + selectedExtent.set(extent.withRange(dimension, position, position)); } } } diff --git a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridExtent.java b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridExtent.java index cf38ad7140..5ff27e6569 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridExtent.java +++ b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridExtent.java @@ -717,7 +717,7 @@ public class GridExtent implements GridEnvelope, LenientComparable, Serializable * * @see #getLow() * @see #getHigh(int) - * @see #setRange(int, long, long) + * @see #withRange(int, long, long) */ @Override public long getLow(final int index) { @@ -735,7 +735,7 @@ public class GridExtent implements GridEnvelope, LenientComparable, Serializable * * @see #getHigh() * @see #getLow(int) - * @see #setRange(int, long, long) + * @see #withRange(int, long, long) */ @Override public long getHigh(final int index) { @@ -929,6 +929,7 @@ public class GridExtent implements GridEnvelope, LenientComparable, Serializable /** * Returns a grid extent identical to this grid extent except for the coordinate values in the specified dimension. + * This grid extent is not modified. * * @param index the dimension for which to set the coordinate values. * @param low the low coordinate value at the given dimension, inclusive. @@ -941,7 +942,7 @@ public class GridExtent implements GridEnvelope, LenientComparable, Serializable * * @since 1.3 */ - public GridExtent setRange(final int index, final long low, final long high) { + public GridExtent withRange(final int index, final long low, final long high) { int ih = getDimension(); ArgumentChecks.ensureValidIndex(ih, index); ih += index; diff --git a/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridExtentTest.java b/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridExtentTest.java index 169740150b..040ecc36e3 100644 --- a/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridExtentTest.java +++ b/core/sis-feature/src/test/java/org/apache/sis/coverage/grid/GridExtentTest.java @@ -186,13 +186,13 @@ public final strictfp class GridExtentTest extends TestCase { } /** - * Tests {@link GridExtent#setRange(int, long, long)}. + * Tests {@link GridExtent#withRange(int, long, long)}. */ @Test - public void testSetRange() { + public void testWithRange() { GridExtent extent = create3D(); - assertSame(extent, extent.setRange(1, 200, 799)); - extent = extent.setRange(2, 30, 60); + assertSame(extent, extent.withRange(1, 200, 799)); + extent = extent.withRange(2, 30, 60); assertExtentEquals(extent, 0, 100, 499); assertExtentEquals(extent, 1, 200, 799); assertExtentEquals(extent, 2, 30, 60);
