sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 01/04: Move TileTranslation as an inner class for keeping it close to the only code where it is used.
Date Tue, 18 Feb 2020 20:03:43 GMT
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 8f4d5c351c09ea8a8d66dd62bc3a0d730c0a0ee4
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Mon Feb 17 16:10:05 2020 +0100

    Move TileTranslation as an inner class for keeping it close to the only code where it
is used.
---
 .../internal/referencing/j2d/TileOrganizer.java    | 56 +++++++++++++++-
 .../internal/referencing/j2d/TileTranslation.java  | 75 ----------------------
 2 files changed, 53 insertions(+), 78 deletions(-)

diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/TileOrganizer.java
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/TileOrganizer.java
index 8be2c96..7d114ea 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/TileOrganizer.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/TileOrganizer.java
@@ -254,12 +254,12 @@ public class TileOrganizer {
                     groupBounds.translate(dx, dy);
                 }
                 reference = new AffineTransform2D(reference);               // Make immutable.
-                final Map<Dimension,TileTranslation> pool = new HashMap<>();
+                final Map<Dimension,Translation> pool = new HashMap<>();
                 for (final Tile tile : tilesArray) {
                     final Dimension subsampling = tile.getSubsampling();
-                    TileTranslation translated = pool.get(subsampling);
+                    Translation translated = pool.get(subsampling);
                     if (translated == null) {
-                        translated = new TileTranslation(subsampling, reference, dx, dy);
+                        translated = new Translation(subsampling, reference, dx, dy);
                         pool.put(subsampling, translated);
                     }
                     translated.applyTo(tile);
@@ -270,6 +270,56 @@ public class TileOrganizer {
         return results;
     }
 
+
+    /**
+     * An affine transform which is translated relative to an original transform.
+     * The translation terms are stored separately without modifying the transform.
+     * This class if for internal use by {@link TileOrganizer} only.
+     */
+    private static final class Translation {
+        /**
+         * The translated "grid to real world" transform, as an immutable instance.
+         */
+        private final AffineTransform gridToCRS;
+
+        /**
+         * The translation in "absolute units". This is the same units than for tiles at
subsampling (1,1).
+         */
+        private final int dx, dy;
+
+        /**
+         * Creates a new translated transform. The translation is specified in "absolute
units",
+         * i.e. in the same units than for tiles at subsampling (1,1).
+         *
+         * @param  subsampling  the {@linkplain Tile#getSubsampling() tile subsampling}.
+         * @param  reference    the "grid to real world" transform at subsampling (1,1).
+         * @param  dx           the translation along <var>x</var> axis in "absolute
units".
+         * @param  dy           the translation along <var>y</var> axis in "absolute
units".
+         */
+        Translation(final Dimension subsampling, AffineTransform reference, int dx, int dy)
{
+            this.dx = dx / subsampling.width;                           // It is okay to
round toward zero.
+            this.dy = dy / subsampling.height;
+            dx %= subsampling.width;
+            dy %= subsampling.height;
+            reference = new AffineTransform(reference);
+            reference.scale(subsampling.width, subsampling.height);
+            reference.translate(dx, dy);                                // Correction for
non-integer division of (dx,dy).
+            gridToCRS = new ImmutableAffineTransform(reference);
+        }
+
+        /**
+         * Applies the translation and the new "grid to CRS" transform on the given tile.
+         *
+         * @param  tile  the tile on which to apply the translation.
+         */
+        final void applyTo(final Tile tile) {
+            synchronized (tile) {
+                tile.translate(dx, dy);
+                tile.setGridToCRS(gridToCRS);
+            }
+        }
+    }
+
     /**
      * Sorts affine transform by increasing X scales in absolute value.
      * For {@link #computePyramidLevels(Collection)} internal working only.
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/TileTranslation.java
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/TileTranslation.java
deleted file mode 100644
index 095ad78..0000000
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/TileTranslation.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.sis.internal.referencing.j2d;
-
-import java.awt.Dimension;
-import java.awt.geom.AffineTransform;
-
-
-/**
- * An affine transform which is translated relative to an original transform.
- * The translation terms are stored separately without modifying the transform.
- * This class if for internal use by {@link TileOrganizer} only.
- *
- * @author  Martin Desruisseaux (Geomatys)
- * @version 1.1
- * @since   1.1
- * @module
- */
-final class TileTranslation {
-    /**
-     * The translated "grid to real world" transform, as an immutable instance.
-     */
-    private final AffineTransform gridToCRS;
-
-    /**
-     * The translation in "absolute units". This is the same units than for tiles at subsampling
(1,1).
-     */
-    private final int dx, dy;
-
-    /**
-     * Creates a new translated transform. The translation is specified in "absolute units",
-     * i.e. in the same units than for tiles at subsampling (1,1).
-     *
-     * @param  subsampling  the {@linkplain Tile#getSubsampling() tile subsampling}.
-     * @param  reference    the "grid to real world" transform at subsampling (1,1).
-     * @param  dx           the translation along <var>x</var> axis in "absolute
units".
-     * @param  dy           the translation along <var>y</var> axis in "absolute
units".
-     */
-    TileTranslation(final Dimension subsampling, AffineTransform reference, int dx, int dy)
{
-        this.dx = dx / subsampling.width;                           // It is okay to round
toward zero.
-        this.dy = dy / subsampling.height;
-        dx %= subsampling.width;
-        dy %= subsampling.height;
-        reference = new AffineTransform(reference);
-        reference.scale(subsampling.width, subsampling.height);
-        reference.translate(dx, dy);                                // Correction for non-integer
division of (dx,dy).
-        gridToCRS = new ImmutableAffineTransform(reference);
-    }
-
-    /**
-     * Applies the translation and the new "grid to CRS" transform on the given tile.
-     *
-     * @param  tile  the tile on which to apply the translation.
-     */
-    final void applyTo(final Tile tile) {
-        synchronized (tile) {
-            tile.translate(dx, dy);
-            tile.setGridToCRS(gridToCRS);
-        }
-    }
-}


Mime
View raw message