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: Provide more control on the image shown. Control on background color make easier to distinguish the missing values. Control on range to use for scaling gray tone will in in place but the actual action will be the purpose of the next commit.
Date Mon, 24 Feb 2020 18:48:25 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 cffed6a  Provide more control on the image shown. Control on background color make
easier to distinguish the missing values. Control on range to use for scaling gray tone will
in in place but the actual action will be the purpose of the next commit.
cffed6a is described below

commit cffed6ab80cb6e4a3610c09de31a36f3d4921e2c
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Mon Feb 24 15:05:18 2020 +0100

    Provide more control on the image shown. Control on background color make easier to distinguish
the missing values. Control on range to use for scaling gray tone will in in place but the
actual action will be the purpose of the next commit.
---
 .../apache/sis/gui/coverage/CoverageControls.java  | 14 +++--
 .../apache/sis/gui/coverage/CoverageExplorer.java  |  5 +-
 .../org/apache/sis/gui/coverage/CoverageView.java  | 18 ++++++
 .../org/apache/sis/gui/coverage/RangeType.java     | 70 ++++++++++++++++++++++
 .../org/apache/sis/internal/gui/Resources.java     |  5 ++
 .../apache/sis/internal/gui/Resources.properties   |  1 +
 .../sis/internal/gui/Resources_fr.properties       |  1 +
 .../org/apache/sis/util/resources/Vocabulary.java  | 10 ++++
 .../sis/util/resources/Vocabulary.properties       |  2 +
 .../sis/util/resources/Vocabulary_fr.properties    |  2 +
 10 files changed, 121 insertions(+), 7 deletions(-)

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 cac0eb4..c6aea60 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
@@ -24,8 +24,8 @@ import javafx.scene.control.TitledPane;
 import javafx.scene.layout.GridPane;
 import javafx.scene.layout.Region;
 import javafx.scene.layout.VBox;
-import javafx.scene.paint.Color;
 import javafx.beans.property.ObjectProperty;
+import javafx.scene.paint.Color;
 import org.apache.sis.coverage.grid.GridCoverage;
 import org.apache.sis.util.resources.Vocabulary;
 
@@ -56,7 +56,9 @@ final class CoverageControls extends Controls {
      * @param  coverage    property containing the coverage to show.
      */
     CoverageControls(final Vocabulary vocabulary, final ObjectProperty<GridCoverage>
coverage) {
+        final Color background = Color.BLACK;
         view = new CoverageView();
+        view.setBackground(background);
         /*
          * "Display" section with the following controls:
          *    - Background color
@@ -64,7 +66,8 @@ final class CoverageControls extends Controls {
         final VBox displayPane;
         {   // Block for making variables locale to this scope.
             final GridPane gp = createControlGrid(
-                label(vocabulary, Vocabulary.Keys.Background, createBackgroundButton())
+                label(vocabulary, Vocabulary.Keys.Background, createBackgroundButton(background)),
+                label(vocabulary, Vocabulary.Keys.ValueRange, RangeType.createButton(view::onRangeTypeChanged))
             );
             final Label label = new Label(vocabulary.getLabel(Vocabulary.Keys.Image));
             label.setPadding(CAPTION_MARGIN);
@@ -85,11 +88,10 @@ final class CoverageControls extends Controls {
     /**
      * Creates the button for selecting a background color.
      */
-    private static ColorPicker createBackgroundButton() {
-        final ColorPicker b = new ColorPicker();
+    private ColorPicker createBackgroundButton(final Color background) {
+        final ColorPicker b = new ColorPicker(background);
         b.setOnAction((e) -> {
-            final Color color = ((ColorPicker) e.getSource()).getValue();
-            // TODO
+            view.setBackground(((ColorPicker) e.getSource()).getValue());
         });
         return b;
     }
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 153967d..588a9ff 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
@@ -20,8 +20,9 @@ import javafx.scene.control.SplitPane;
 import javafx.scene.control.Separator;
 import javafx.scene.control.ToggleGroup;
 import javafx.scene.control.Toggle;
-import javafx.event.ActionEvent;
 import javafx.scene.layout.Region;
+import javafx.event.ActionEvent;
+import javafx.collections.ObservableList;
 import javafx.beans.value.ObservableValue;
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.SimpleObjectProperty;
@@ -113,6 +114,8 @@ public class CoverageExplorer {
             new Selector(IMAGE_VIEW).createButton(group, "\uD83D\uDDFA\uFE0F", localized,
Resources.Keys.Visualize),    // 🗺 — World map.
             new Selector(TABLE_VIEW).createButton(group, "\uD83D\uDD22\uFE0F", localized,
Resources.Keys.TabularData)   // 🔢 — Input symbol for numbers.
         );
+        final ObservableList<Toggle> toggles = group.getToggles();
+        group.selectToggle(toggles.get(toggles.size() - 1));
     }
 
     /**
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/CoverageView.java
index 7d1bca3..77381a9 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/CoverageView.java
@@ -29,8 +29,11 @@ import javafx.scene.image.ImageView;
 import javafx.scene.image.PixelBuffer;
 import javafx.scene.image.PixelFormat;
 import javafx.scene.image.WritableImage;
+import javafx.scene.paint.Color;
 import javafx.scene.layout.Pane;
 import javafx.scene.layout.Region;
+import javafx.scene.layout.Background;
+import javafx.scene.layout.BackgroundFill;
 import javafx.beans.value.ObservableValue;
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.SimpleObjectProperty;
@@ -229,6 +232,21 @@ final class CoverageView extends PlanarCanvas {
     }
 
     /**
+     * Sets the background, as a color for now but more patterns my be allowed in a future
version.
+     */
+    final void setBackground(final Color color) {
+        view.setBackground(new Background(new BackgroundFill(color, null, null)));
+    }
+
+    /**
+     * Invoked when the user selected a new range of values to scale.
+     */
+    final void onRangeTypeChanged(final ObservableValue<? extends RangeType> property,
+                                  final RangeType previous, final RangeType value)
+    {
+    }
+
+    /**
      * Invoked when the {@link #data} content needs to be rendered again into {@link #image}.
      * It may be because a new image has been specified, or because the viewed region moved
      * or have been zoomed.
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/RangeType.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/RangeType.java
new file mode 100644
index 0000000..7339bd5
--- /dev/null
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/RangeType.java
@@ -0,0 +1,70 @@
+/*
+ * 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.gui.coverage;
+
+import javafx.beans.value.ChangeListener;
+import javafx.scene.control.ChoiceBox;
+import javafx.scene.control.SingleSelectionModel;
+import org.apache.sis.util.resources.Vocabulary;
+import org.apache.sis.internal.gui.Resources;
+
+
+/**
+ * The kind of range to use for scaling the color palette of an image.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 1.1
+ * @since   1.1
+ * @module
+ */
+enum RangeType {
+    /**
+     * As declared in the data store.
+     * This is the default value.
+     */
+    DECLARED,
+
+    /**
+     * Computed from statistics (minimum and maximum values).
+     */
+    AUTOMATIC;
+
+    /**
+     * Creates the button for selecting a type of range.
+     * The initial value is {@link #DECLARED}.
+     */
+    static ChoiceBox<RangeType> createButton(final ChangeListener<RangeType>
listener) {
+        final ChoiceBox<RangeType> button = new ChoiceBox<>();
+        button.getItems().addAll(values());
+        final SingleSelectionModel<RangeType> select = button.getSelectionModel();
+        select.select(0);
+        select.selectedItemProperty().addListener(listener);
+        return button;
+    }
+
+    /**
+     * Returns the string representation for this enumeration value.
+     */
+    @Override
+    public String toString() {
+        switch (this) {
+            case DECLARED:  return Resources .format(Resources.Keys.FromMetadata);
+            case AUTOMATIC: return Vocabulary.format(Vocabulary.Keys.Automatic);
+            default:        return super.toString();
+        }
+    }
+}
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java
b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java
index 162ffad..4060265 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java
@@ -196,6 +196,11 @@ public final class Resources extends IndexedResourceBundle {
         public static final short Format = 38;
 
         /**
+         * From metadata
+         */
+        public static final short FromMetadata = 53;
+
+        /**
          * Full screen
          */
         public static final short FullScreen = 42;
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties
b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties
index e0dd468..7af6c69 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties
@@ -48,6 +48,7 @@ Extent                 = Extent:
 File                   = File
 Filter                 = Filter:
 Format                 = Format:
+FromMetadata           = From metadata
 FullScreen             = Full screen
 GeospatialFiles        = Geospatial data files
 Loading                = Loading\u2026
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources_fr.properties
b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources_fr.properties
index ef7cf2a..48bb9b3 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources_fr.properties
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources_fr.properties
@@ -53,6 +53,7 @@ Extent                 = \u00c9tendue\u00a0:
 File                   = Fichier
 Filter                 = Filtre\u00a0:
 Format                 = Format\u00a0:
+FromMetadata           = Des m\u00e9ta-donn\u00e9es
 FullScreen             = Plein \u00e9cran
 GeospatialFiles        = Fichiers de donn\u00e9es g\u00e9ospatiales
 Loading                = Chargement\u2026
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
index 5bbae82..e91fcb2 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.java
@@ -100,6 +100,11 @@ public final class Vocabulary extends IndexedResourceBundle {
         public static final short Attributes = 9;
 
         /**
+         * Automatic
+         */
+        public static final short Automatic = 201;
+
+        /**
          * Axis changes
          */
         public static final short AxisChanges = 10;
@@ -995,6 +1000,11 @@ public final class Vocabulary extends IndexedResourceBundle {
         public static final short ValueDomain = 164;
 
         /**
+         * Value range
+         */
+        public static final short ValueRange = 200;
+
+        /**
          * Values
          */
         public static final short Values = 165;
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
index 8ff62af..8f5c86e 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary.properties
@@ -22,6 +22,7 @@ Angle                   = Angle
 AngularDegrees          = Degrees
 AngularMinutes          = Minutes
 AngularSeconds          = Seconds
+Automatic               = Automatic
 Attributes              = Attributes
 AxisChanges             = Axis changes
 Azimuth                 = Azimuth
@@ -203,6 +204,7 @@ UpperBound              = Upper bound
 Value                   = Value
 Values                  = Values
 ValueDomain             = Value domain
+ValueRange              = Value range
 Variables               = Variables
 Version_2               = {0} version {1}
 Versions                = Versions
diff --git a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
index c6f1946..93d9fa9 100644
--- a/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
+++ b/core/sis-utility/src/main/java/org/apache/sis/util/resources/Vocabulary_fr.properties
@@ -29,6 +29,7 @@ Angle                   = Angle
 AngularDegrees          = Degr\u00e9s
 AngularMinutes          = Minutes
 AngularSeconds          = Secondes
+Automatic               = Automatique
 Attributes              = Attributs
 AxisChanges             = Changements d\u2019axes
 Azimuth                 = Azimut
@@ -210,6 +211,7 @@ UpperBound              = Limite haute
 Value                   = Valeur
 Values                  = Valeurs
 ValueDomain             = Domaine des valeurs
+ValueRange              = Plage des valeurs
 Variables               = Variables
 Version_2               = {0} version {1}
 Versions                = Versions


Mime
View raw message