sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] branch geoapi-4.0 updated: Rename Canvas2D as PlanarCanvas because the constraint is not only to be two-dimensional, but also to use a Cartesian coordinate system (as opposed to the coordinate system of planetarium dome for example).
Date Thu, 06 Feb 2020 21:48:17 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


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 32546a8  Rename Canvas2D as PlanarCanvas because the constraint is not only to be
two-dimensional, but also to use a Cartesian coordinate system (as opposed to the coordinate
system of planetarium dome for example).
32546a8 is described below

commit 32546a87153ec700fc9bc0db3e041224181c2e52
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Thu Feb 6 22:46:49 2020 +0100

    Rename Canvas2D as PlanarCanvas because the constraint is not only to be two-dimensional,
but also to use a Cartesian coordinate system (as opposed to the coordinate system of planetarium
dome for example).
---
 .../org/apache/sis/internal/map/GridCanvas.java    |  2 +-
 .../map/{Canvas2D.java => PlanarCanvas.java}       | 35 ++++++++++++++++++----
 2 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/GridCanvas.java
b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/GridCanvas.java
index ace0fe3..66c1e4a 100644
--- a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/GridCanvas.java
+++ b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/GridCanvas.java
@@ -55,7 +55,7 @@ import org.opengis.util.FactoryException;
  * @since   1.1
  * @module
  */
-public abstract class GridCanvas extends Canvas2D {
+public abstract class GridCanvas extends PlanarCanvas {
     /**
      * @deprecated
      * This is a temporary constant, as we will probably need to replace the creation
diff --git a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/Canvas2D.java b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/PlanarCanvas.java
similarity index 60%
rename from core/sis-portrayal/src/main/java/org/apache/sis/internal/map/Canvas2D.java
rename to core/sis-portrayal/src/main/java/org/apache/sis/internal/map/PlanarCanvas.java
index 54aa379..54a3b83 100644
--- a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/Canvas2D.java
+++ b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/PlanarCanvas.java
@@ -16,14 +16,24 @@
  */
 package org.apache.sis.internal.map;
 
+import java.util.Map;
 import java.awt.geom.AffineTransform;
-import org.apache.sis.internal.referencing.j2d.AffineTransform2D;
+import org.opengis.referencing.cs.AxisDirection;
+import org.apache.sis.measure.Units;
+import org.apache.sis.referencing.cs.DefaultCartesianCS;
+import org.apache.sis.referencing.cs.DefaultCoordinateSystemAxis;
+import org.apache.sis.referencing.datum.DefaultEngineeringDatum;
+import org.apache.sis.referencing.crs.DefaultEngineeringCRS;
 import org.apache.sis.referencing.operation.transform.LinearTransform;
+import org.apache.sis.internal.referencing.j2d.AffineTransform2D;
+
+import static java.util.Collections.singletonMap;
+import static org.opengis.referencing.IdentifiedObject.NAME_KEY;
 
 
 /**
- * A canvas in which data are reduced to a two-dimensional slice before to be displayed.
- * This canvas assumes that the display device uses a Cartesian coordinate system
+ * A canvas for two-dimensional display device using a Cartesian coordinate system.
+ * Data are reduced to a two-dimensional slice before to be displayed.
  *
  * @author  Johann Sorel (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
@@ -31,7 +41,20 @@ import org.apache.sis.referencing.operation.transform.LinearTransform;
  * @since   1.1
  * @module
  */
-public abstract class Canvas2D extends Canvas {
+public abstract class PlanarCanvas extends Canvas {
+    /**
+     * The display Coordinate Reference System used by all {@code PlanarCanvas} instances.
+     */
+    private static final DefaultEngineeringCRS DISPLAY_CRS;
+    static {
+        Map<String,?> property = singletonMap(NAME_KEY, "Display on two-dimensional
Cartesian coordinate system");
+        DefaultCartesianCS cs = new DefaultCartesianCS(property,
+                new DefaultCoordinateSystemAxis(singletonMap(NAME_KEY, "Column"), "x", AxisDirection.DISPLAY_RIGHT,
Units.PIXEL),
+                new DefaultCoordinateSystemAxis(singletonMap(NAME_KEY, "Row"),    "y", AxisDirection.DISPLAY_DOWN,
 Units.PIXEL));
+        property = singletonMap(NAME_KEY, cs.getName());        // Reuse the same Identifier
instance.
+        DISPLAY_CRS = new DefaultEngineeringCRS(property, new DefaultEngineeringDatum(property),
cs);
+    }
+
     /**
      * The conversion from {@linkplain #getObjectiveCRS() objective CRS} to the display coordinate
system.
      * This transform will be modified in-place when user applies zoom, translation or rotation
on the view area.
@@ -49,8 +72,8 @@ public abstract class Canvas2D extends Canvas {
     /**
      * Creates a new two-dimensional canvas.
      */
-    protected Canvas2D() {
-        super(null);    // TODO
+    protected PlanarCanvas() {
+        super(DISPLAY_CRS);
         objectiveToDisplay = new AffineTransform();
     }
 


Mime
View raw message