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 0b0ab2808329b57a15de7b61214658805c8a979b
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Fri May 1 18:58:26 2020 +0200

    Prepare the DataViewer window to be the main window for showing data 
without obligation to create new windows.
    Remove the "overview" parameter, which has not been implemented and become 
less relevant after above sentence.
---
 .../main/java/org/apache/sis/gui/DataViewer.java   |  7 +++-
 .../org/apache/sis/gui/coverage/ImageLoader.java   |  7 ++--
 .../org/apache/sis/gui/coverage/ImageRequest.java  | 43 ----------------------
 .../apache/sis/gui/dataset/ResourceExplorer.java   |  6 ---
 4 files changed, 8 insertions(+), 55 deletions(-)

diff --git 
a/application/sis-javafx/src/main/java/org/apache/sis/gui/DataViewer.java 
b/application/sis-javafx/src/main/java/org/apache/sis/gui/DataViewer.java
index 0188c41..bb2e579 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/DataViewer.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/DataViewer.java
@@ -24,6 +24,7 @@ import java.util.Set;
 import javafx.application.Application;
 import javafx.application.Platform;
 import javafx.event.ActionEvent;
+import javafx.geometry.Rectangle2D;
 import javafx.scene.Scene;
 import javafx.scene.control.Menu;
 import javafx.scene.control.MenuBar;
@@ -33,6 +34,7 @@ import javafx.scene.input.KeyCombination;
 import javafx.scene.layout.BorderPane;
 import javafx.stage.FileChooser;
 import javafx.scene.image.Image;
+import javafx.stage.Screen;
 import javafx.stage.Stage;
 import org.apache.sis.gui.dataset.ResourceExplorer;
 import org.apache.sis.internal.gui.BackgroundThreads;
@@ -140,12 +142,13 @@ public class DataViewer extends Application {
         final BorderPane pane = new BorderPane();
         pane.setTop(menus);
         pane.setCenter(content.getView());
+        final Rectangle2D bounds = Screen.getPrimary().getVisualBounds();
         window.setTitle("Apache Spatial Information System");
         window.getIcons().addAll(new 
Image(DataViewer.class.getResourceAsStream("SIS_64px.png")),
                                  new 
Image(DataViewer.class.getResourceAsStream("SIS_128px.png")));
         window.setScene(new Scene(pane));
-        window.setWidth(1000);
-        window.setHeight(800);
+        window.setWidth (0.75 * bounds.getWidth());
+        window.setHeight(0.75 * bounds.getHeight());
         window.show();
     }
 
diff --git 
a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/ImageLoader.java
 
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/ImageLoader.java
index b6faa39..0368228 100644
--- 
a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/ImageLoader.java
+++ 
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/ImageLoader.java
@@ -110,7 +110,7 @@ final class ImageLoader extends Task<RenderedImage> {
         if (cv == null) {
             GridGeometry domain = request.getDomain().orElse(null);
             final int[]  range  = request.getRange() .orElse(null);
-            if (request.getOverviewSize().isPresent()) {
+            {
                 if (domain == null) {
                     domain = request.resource.getGridGeometry();
                 }
@@ -118,9 +118,8 @@ final class ImageLoader extends Task<RenderedImage> {
                     domain = slice(domain).build();
                 }
                 /*
-                 * TODO: we should apply a subsampling here. GridDerivation 
has the API for that,
-                 * what is missing is to transmit this information to GridView 
column and row headers.
-                 * See ImageRequest.setOverviewSize(int).
+                 * TODO: We restrict loading to a two-dimensional slice for 
now.
+                 * Future version will need to give user control over slices.
                  */
             }
             cv = request.resource.read(domain, range);                      // 
May be long to execute.
diff --git 
a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/ImageRequest.java
 
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/ImageRequest.java
index 8147858..17df35b 100644
--- 
a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/ImageRequest.java
+++ 
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/ImageRequest.java
@@ -17,7 +17,6 @@
 package org.apache.sis.gui.coverage;
 
 import java.util.Optional;
-import java.util.OptionalInt;
 import javafx.concurrent.WorkerStateEvent;
 import org.apache.sis.storage.GridCoverageResource;
 import org.apache.sis.coverage.grid.GridDerivation;
@@ -49,10 +48,6 @@ public class ImageRequest {
      * The source for rendering the image, specified at construction time.
      * After class initialization, only one of {@link #resource} and {@link 
#coverage} is non-null.
      * But after task execution, this field will be set to the coverage which 
has been read.
-     *
-     * @todo If we implement subsampling using the {@link #overviewSize} 
parameter, then we need to
-     *       remember whether subsampling has been used for this {@code 
coverage} instance. This is
-     *       needed for deciding if we can reuse that instance for a view over 
the full coverage.
      */
     volatile GridCoverage coverage;
 
@@ -84,15 +79,6 @@ public class ImageRequest {
     static final double SLICE_RATIO = 0;
 
     /**
-     * Approximate width and height of desired image for overview purpose, or 
0 for the full image.
-     * If non-zero, then {@link ImageLoader} may return only a subset of 
coverage data.
-     *
-     * @see #getOverviewSize()
-     * @see #setOverviewSize(int)
-     */
-    private int overviewSize;
-
-    /**
      * For transferring a listener to {@link ImageLoader#listener} before 
background execution starts.
      * We do not provide a more generic listeners API for now, but it could be 
done in the future
      * if there is a need for that.
@@ -221,35 +207,6 @@ public class ImageRequest {
     }
 
     /**
-     * If an overview has been requested, the average width and height of the 
overview. This method returns the value
-     * given to the last call to {@link #setOverviewSize(int)} — see the 
javadoc of that method for more information.
-     * The default value is empty, meaning that the full coverage is desired.
-     *
-     * @return if this request is for an overview, the approximate overview 
width and height (averaged).
-     */
-    public OptionalInt getOverviewSize() {
-        return (overviewSize > 0) ? OptionalInt.of(overviewSize) : 
OptionalInt.empty();
-    }
-
-    /**
-     * Requests an overview of the given approximate width and height. The 
{@code size} argument is an average size;
-     * the overview will try to preserve the image height/width ratio. When an 
overview is requested, {@link GridView}
-     * may use only a subset of coverage data. The subset may consist in 
reading only the first slice, applying a
-     * subsampling at reading time, or other implementation specific settings.
-     *
-     * @param  size  approximate overview width and height (averaged).
-     *
-     * @todo The specified size is currently ignored. We only use the fact 
that an overview has been requested.
-     *       For taking the size in account, we would need to improve {@link 
GridView} for letting user know in
-     *       some way that a subsampling has been applied, for example by 
adjusting the indices shown in column
-     *       and row headers (e.g. showing "0 2 4 6 …").
-     */
-    public void setOverviewSize(final int size) {
-        ArgumentChecks.ensureStrictlyPositive("size", size);
-        overviewSize = size;
-    }
-
-    /**
      * Configures the given status bar with the geometry of the grid coverage 
we have just read.
      * This method is invoked by {@link 
GridView#onImageLoaded(WorkerStateEvent)} in JavaFX thread
      * after {@link ImageLoader} successfully loaded in background thread a 
new image.
diff --git 
a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceExplorer.java
 
b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceExplorer.java
index d8fb993..f0dd4bf 100644
--- 
a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceExplorer.java
+++ 
b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceExplorer.java
@@ -52,11 +52,6 @@ import org.apache.sis.util.resources.Vocabulary;
  */
 public class ResourceExplorer extends WindowManager {
     /**
-     * Approximate overview width and height (averaged) in number of pixels.
-     */
-    private static final int OVERVIEW_SIZE = 10000;
-
-    /**
      * The tree of resources.
      */
     private final ResourceTree resources;
@@ -222,7 +217,6 @@ public class ResourceExplorer extends WindowManager {
         ImageRequest grid  = null;
         if (resource instanceof GridCoverageResource) {
             grid = new ImageRequest((GridCoverageResource) resource, null, 0);
-            grid.setOverviewSize(OVERVIEW_SIZE);
             if (coverage == null) {
                 coverage = new CoverageExplorer();
             }

Reply via email to