sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 01/03: Rename CoverageView as CoverageCanvas and make public with better separation of tasks.
Date Mon, 13 Apr 2020 21:06:04 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 7893dbdec3edf4b13c064e4e8aee747732a9c7cd
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Mon Apr 13 14:50:39 2020 +0200

    Rename CoverageView as CoverageCanvas and make public with better separation of tasks.
---
 .../java/org/apache/sis/gui/coverage/Controls.java |  2 +-
 .../{CoverageView.java => CoverageCanvas.java}     | 28 ++++++++--------------
 .../apache/sis/gui/coverage/CoverageControls.java  | 19 +++++++++++----
 .../apache/sis/gui/coverage/CoverageExplorer.java  | 12 ++++++----
 .../java/org/apache/sis/gui/coverage/GridView.java |  5 +++-
 .../java/org/apache/sis/gui/map/StatusBar.java     | 15 ++++++------
 6 files changed, 45 insertions(+), 36 deletions(-)

diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/Controls.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/Controls.java
index 9bccbfc..1db40f7 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/Controls.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/Controls.java
@@ -33,7 +33,7 @@ import org.apache.sis.util.resources.Vocabulary;
 
 
 /**
- * A {@link GridView} or {@link CoverageView} together with the controls
+ * A {@link GridView} or {@link CoverageCanvas} together with the controls
  * to show in a {@link CoverageExplorer}.
  *
  * @author  Martin Desruisseaux (Geomatys)
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageView.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageCanvas.java
similarity index 95%
rename from application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageView.java
rename to application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageCanvas.java
index ce404d5..61cc50d 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageView.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageCanvas.java
@@ -24,7 +24,6 @@ import java.awt.geom.AffineTransform;
 import java.awt.image.RenderedImage;
 import javafx.scene.paint.Color;
 import javafx.scene.layout.Region;
-import javafx.scene.layout.BorderPane;
 import javafx.scene.layout.Background;
 import javafx.scene.layout.BackgroundFill;
 import javafx.beans.value.ObservableValue;
@@ -41,18 +40,20 @@ import org.apache.sis.internal.gui.ImageRenderings;
 import org.apache.sis.referencing.operation.matrix.AffineTransforms2D;
 import org.apache.sis.referencing.operation.transform.MathTransforms;
 import org.apache.sis.gui.map.MapCanvasAWT;
-import org.apache.sis.gui.map.StatusBar;
 
 
 /**
- * A canvas for {@link RenderedImage} produced by a {@link GridCoverage}.
+ * A canvas for {@link RenderedImage} provided by a {@link GridCoverage}.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 1.1
- * @since   1.1
+ *
+ * @see CoverageExplorer
+ *
+ * @since 1.1
  * @module
  */
-final class CoverageView extends MapCanvasAWT {
+public class CoverageCanvas extends MapCanvasAWT {
     /**
      * The data shown in this canvas. Note that setting this property to a non-null value
may not
      * modify the canvas content immediately. Instead, a background process will request
the tiles.
@@ -104,25 +105,16 @@ final class CoverageView extends MapCanvasAWT {
     private AffineTransform gridToCRS;
 
     /**
-     * The image together with the status bar.
-     */
-    private final BorderPane imageAndStatus;
-
-    /**
      * Creates a new two-dimensional canvas for {@link RenderedImage}.
      */
-    public CoverageView() {
+    public CoverageCanvas() {
         super(Locale.getDefault());
         coverageProperty       = new SimpleObjectProperty<>(this, "coverage");
         sliceExtentProperty    = new SimpleObjectProperty<>(this, "sliceExtent");
         dataAlternatives       = new EnumMap<>(RangeType.class);
         currentDataAlternative = RangeType.DECLARED;
-        imageAndStatus         = new BorderPane(fixedPane);
         coverageProperty   .addListener(this::onImageSpecified);
         sliceExtentProperty.addListener(this::onImageSpecified);
-        final StatusBar statusBar = new StatusBar();
-        statusBar.setCanvas(this);
-        imageAndStatus.setBottom(statusBar.getView());
     }
 
     /**
@@ -139,8 +131,8 @@ final class CoverageView extends MapCanvasAWT {
      *
      * @return the region to show.
      */
-    public final Region getView() {
-        return imageAndStatus;
+    final Region getView() {
+        return fixedPane;
     }
 
     /**
@@ -324,7 +316,7 @@ final class CoverageView extends MapCanvasAWT {
      */
     @Override
     protected Renderer createRenderer() {
-        final RenderedImage data = this.data;       // Need to copy this reference here before
background tasks.
+        final RenderedImage data = this.data;       // Need to copy this reference here before
background task.
         if (data == null) {
             return null;
         }
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageControls.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageControls.java
index 8678e28..e824a83 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageControls.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageControls.java
@@ -21,17 +21,19 @@ import javafx.scene.control.ColorPicker;
 import javafx.scene.control.Control;
 import javafx.scene.control.Label;
 import javafx.scene.control.TitledPane;
+import javafx.scene.layout.BorderPane;
 import javafx.scene.layout.GridPane;
 import javafx.scene.layout.Region;
 import javafx.scene.layout.VBox;
 import javafx.beans.property.ObjectProperty;
 import javafx.scene.paint.Color;
+import org.apache.sis.gui.map.StatusBar;
 import org.apache.sis.coverage.grid.GridCoverage;
 import org.apache.sis.util.resources.Vocabulary;
 
 
 /**
- * A {@link CoverageView} with associated controls to show in a {@link CoverageExplorer}.
+ * A {@link CoverageCanvas} with associated controls to show in a {@link CoverageExplorer}.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 1.1
@@ -42,7 +44,7 @@ final class CoverageControls extends Controls {
     /**
      * The component for showing sample values.
      */
-    private final CoverageView view;
+    private final CoverageCanvas view;
 
     /**
      * The controls for changing {@link #view}.
@@ -50,6 +52,11 @@ final class CoverageControls extends Controls {
     private final Accordion controls;
 
     /**
+     * The image together with the status bar.
+     */
+    private final BorderPane imageAndStatus;
+
+    /**
      * Creates a new set of coverage controls.
      *
      * @param  vocabulary  localized set of words, provided in argument before often known
by the caller.
@@ -57,8 +64,12 @@ final class CoverageControls extends Controls {
      */
     CoverageControls(final Vocabulary vocabulary, final ObjectProperty<GridCoverage>
coverage) {
         final Color background = Color.BLACK;
-        view = new CoverageView();
+        view = new CoverageCanvas();
         view.setBackground(background);
+        final StatusBar statusBar = new StatusBar();
+        statusBar.setCanvas(view);
+        imageAndStatus = new BorderPane(view.getView());
+        imageAndStatus.setBottom(statusBar.getView());
         /*
          * "Display" section with the following controls:
          *    - Background color
@@ -111,7 +122,7 @@ final class CoverageControls extends Controls {
      */
     @Override
     final Region view() {
-        return view.getView();
+        return imageAndStatus;
     }
 
     /**
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageExplorer.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageExplorer.java
index 8d0bb38..f18e9c1 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageExplorer.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageExplorer.java
@@ -35,18 +35,22 @@ import org.apache.sis.gui.Widget;
 
 
 /**
- * A view of {@link GridCoverage} numerical values together with controls for band selection
- * and other operations. This class manages a {@link GridView} for showing the numerical
values.
+ * An image or tabular view of {@link GridCoverage} together with controls for band selection
and other operations.
+ * This class manages a {@link CoverageCanvas} and a {@link GridView} for showing the visual
and the numerical values.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 1.1
- * @since   1.1
+ *
+ * @see CoverageCanvas
+ * @see GridView
+ *
+ * @since 1.1
  * @module
  */
 public class CoverageExplorer extends Widget {
     /**
      * Index in the {@link #views} array for the {@link GridView} (tabular data)
-     * or the {@link CoverageView} (image).
+     * or the {@link CoverageCanvas} (image).
      */
     private static final int TABLE_VIEW = 0, IMAGE_VIEW = 1;
 
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridView.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridView.java
index fc6fc6e..125d510 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridView.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridView.java
@@ -55,7 +55,10 @@ import org.apache.sis.internal.gui.Styles;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 1.1
- * @since   1.1
+ *
+ * @see CoverageExplorer
+ *
+ * @since 1.1
  * @module
  *
  * @todo Allow users to specify a {@link NumberFormat} pattern for writing sample values.
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/map/StatusBar.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/map/StatusBar.java
index 4e7c0eb..fb794b7 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/map/StatusBar.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/map/StatusBar.java
@@ -507,18 +507,17 @@ public class StatusBar extends Widget implements EventHandler<MouseEvent>
{
      */
     @Override
     public void handle(final MouseEvent event) {
-        boolean visible = (event != null);
-        if (visible) {
+        if (event != null) {
             final EventType<? extends MouseEvent> type = event.getEventType();
-            final boolean enter = (type == MouseEvent.MOUSE_ENTERED);
-            final boolean moved = (type == MouseEvent.MOUSE_MOVED);
-            if (enter | moved) {
+            if (type == MouseEvent.MOUSE_MOVED || type == MouseEvent.MOUSE_ENTERED) {
                 setLocalCoordinates(event.getX(), event.getY());
-                if (moved) return;
+                return;
+            }
+            if (type != MouseEvent.MOUSE_EXITED) {
+                return;
             }
-            if (!enter && type != MouseEvent.MOUSE_EXITED) return;
         }
-        coordinates.setVisible(visible);
+        coordinates.setVisible(false);
     }
 
     /**


Mime
View raw message