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 controls for cells size.
Date Sat, 01 Feb 2020 15:56:57 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 6e86c5e  Provide controls for cells size.
6e86c5e is described below

commit 6e86c5e9f35a79fca30acdf8d2552d0d6d0ddefe
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Sat Feb 1 16:56:38 2020 +0100

    Provide controls for cells size.
---
 .../sis/gui/coverage/CategoryCellFactory.java      |  3 +-
 .../apache/sis/gui/coverage/CoverageExplorer.java  | 62 +++++++++++++++++++++-
 .../org/apache/sis/gui/coverage/GridViewSkin.java  |  3 ++
 .../java/org/apache/sis/internal/gui/Styles.java   | 10 ++++
 .../org/apache/sis/util/resources/Vocabulary.java  | 20 +++++++
 .../sis/util/resources/Vocabulary.properties       |  4 ++
 .../sis/util/resources/Vocabulary_fr.properties    |  4 ++
 7 files changed, 104 insertions(+), 2 deletions(-)

diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CategoryCellFactory.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CategoryCellFactory.java
index 412495a..7962cce 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CategoryCellFactory.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CategoryCellFactory.java
@@ -29,6 +29,7 @@ import org.apache.sis.measure.NumberRange;
 import org.apache.sis.coverage.Category;
 import org.apache.sis.coverage.SampleDimension;
 import org.apache.sis.util.resources.Vocabulary;
+import org.apache.sis.internal.gui.Styles;
 
 
 /**
@@ -68,7 +69,7 @@ final class CategoryCellFactory implements Callback<TableColumn<SampleDimension,
      */
     TableView<SampleDimension> createSampleDimensionTable(final Vocabulary vocabulary)
{
         final TableView<SampleDimension> table = new TableView<>();
-        table.setPrefHeight(5 * 30);    // Show approximately 5 rows.
+        table.setPrefHeight(5 * Styles.ROW_HEIGHT);                         // Show approximately
5 rows.
         table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
         table.getColumns().setAll(
                 createStringColumn(vocabulary, Vocabulary.Keys.Name,    NAME),
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 06d6dbc..724bbfa 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
@@ -18,6 +18,7 @@ package org.apache.sis.gui.coverage;
 
 import java.util.Locale;
 import java.awt.image.RenderedImage;
+import javafx.beans.property.DoubleProperty;
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.SimpleObjectProperty;
 import javafx.beans.value.ObservableValue;
@@ -25,9 +26,16 @@ import javafx.collections.ObservableList;
 import javafx.geometry.Insets;
 import javafx.scene.control.Accordion;
 import javafx.scene.control.Label;
+import javafx.scene.control.Slider;
 import javafx.scene.control.SplitPane;
 import javafx.scene.control.TableView;
 import javafx.scene.control.TitledPane;
+import javafx.scene.layout.Border;
+import javafx.scene.layout.BorderStroke;
+import javafx.scene.layout.BorderStrokeStyle;
+import javafx.scene.layout.ColumnConstraints;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.Priority;
 import javafx.scene.layout.Region;
 import javafx.scene.layout.VBox;
 import org.apache.sis.coverage.SampleDimension;
@@ -52,6 +60,17 @@ public class CoverageExplorer {
     private static final Insets CAPTION_MARGIN = new Insets(12, 0, 9, 0);
 
     /**
+     * Space between a group of controls and the border encompassing the group.
+     */
+    private static final Insets GROUP_INSETS = new Insets(12);
+
+    /**
+     * The border to use for grouping some controls together.
+     */
+    private static final Border GROUP_BORDER = new Border(new BorderStroke(
+            Styles.BORDER, BorderStrokeStyle.SOLID, null, null));
+
+    /**
      * The data shown in this table. Note that setting this property to a non-null value
may not
      * modify the grid content immediately. Instead, a background process will request the
tiles.
      *
@@ -101,10 +120,50 @@ public class CoverageExplorer {
             coveragePane = new VBox(label, sampleDimensions);
         }
         /*
+         * "Display" section with the following controls:
+         *    - Number format as a localized pattern (TODO).
+         *    - Cell width as a slider.
+         */
+        final VBox displayPane;
+        {   // Block for making variables locale to this scope.
+            final GridPane gp = new GridPane();
+            final ColumnConstraints sliderColumn = new ColumnConstraints();
+            sliderColumn.setHgrow(Priority.ALWAYS);
+            gp.getColumnConstraints().setAll(new ColumnConstraints(), sliderColumn);
+            gp.setPadding(GROUP_INSETS);
+            gp.setBorder(GROUP_BORDER);
+            gp.setVgap(9);
+            gp.setHgap(9);
+            for (int i=0; i<3; i++) {
+                final DoubleProperty property;
+                final double min, max;
+                final short key;
+                switch (i) {
+                    case 0: key = Vocabulary.Keys.Width;   property = gridView.cellWidth;
  min = 30; max = 200; break;
+                    case 1: key = Vocabulary.Keys.Height;  property = gridView.cellHeight;
 min = 10; max =  50; break;
+                    case 2: key = Vocabulary.Keys.Spacing; property = gridView.cellSpacing;
min =  0; max =  10; break;
+                    default: throw new AssertionError(i);
+                }
+                final Label  label  = new Label(vocabulary.getLabel(key));
+                final Slider slider = new Slider(min, max, property.getValue());
+                property.bind(slider.valueProperty());
+                slider.setShowTickMarks(false);
+                label.setLabelFor(slider);
+                GridPane.setConstraints(label,  0, i);
+                GridPane.setConstraints(slider, 1, i);
+                gp.getChildren().addAll(label, slider);
+            }
+            final Label label = new Label(vocabulary.getLabel(Vocabulary.Keys.Cells));
+            label.setPadding(CAPTION_MARGIN);
+            label.setLabelFor(gp);
+            displayPane = new VBox(label, gp);
+        }
+        /*
          * Put all sections together and have the first one expanded by default.
          */
         final Accordion controls = new Accordion(
-                new TitledPane(vocabulary.getString(Vocabulary.Keys.Coverage), coveragePane)
+                new TitledPane(vocabulary.getString(Vocabulary.Keys.Coverage), coveragePane),
+                new TitledPane(vocabulary.getString(Vocabulary.Keys.Display),  displayPane)
                 // TODO: more controls to be added in a future version.
         );
         controls.setExpandedPane(controls.getPanes().get(0));
@@ -115,6 +174,7 @@ public class CoverageExplorer {
 
         coverageProperty = new SimpleObjectProperty<>(this, "coverage");
         coverageProperty.addListener(this::onCoverageSpecified);
+        gridView.bandProperty.addListener(this::onBandSpecified);
     }
 
     /**
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridViewSkin.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridViewSkin.java
index cb77f92..eac75e6 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridViewSkin.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridViewSkin.java
@@ -161,6 +161,7 @@ final class GridViewSkin extends VirtualContainerBase<GridView, GridRow>
{
         final Flow flow = (Flow) getVirtualFlow();
         final double value = newValue.doubleValue();
         flow.setFixedCellSize(value >= GridView.MIN_CELL_SIZE ? value : GridView.MIN_CELL_SIZE);
+        contentChanged(false);
     }
 
     /**
@@ -174,6 +175,8 @@ final class GridViewSkin extends VirtualContainerBase<GridView, GridRow>
{
                 ((GridRow) child).setPrefWidth(width);
             }
         }
+        layoutAll = true;
+        contentChanged(false);
     }
 
     /**
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Styles.java
b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Styles.java
index 7a52c40..524b900 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Styles.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Styles.java
@@ -42,6 +42,11 @@ public final class Styles {
     public static final double INITIAL_SPLIT = 200;
 
     /**
+     * "Standard" height of table rows. Can be approximate.
+     */
+    public static final double ROW_HEIGHT = 30;
+
+    /**
      * Usual color of text.
      */
     public static final Color NORMAL_TEXT = Color.BLACK;
@@ -72,6 +77,11 @@ public final class Styles {
     public static final Color EXPANDED_ROW = Color.GAINSBORO;
 
     /**
+     * The color for border grouping some controls together.
+     */
+    public static final Color BORDER = Color.SILVER;
+
+    /**
      * Do not allow instantiation of this class.
      */
     private Styles() {
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 43d9ed1..2f232c6 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
@@ -145,6 +145,11 @@ public final class Vocabulary extends IndexedResourceBundle {
         public static final short CellCount_1 = 16;
 
         /**
+         * Cells
+         */
+        public static final short Cells = 193;
+
+        /**
          * Character encoding
          */
         public static final short CharacterEncoding = 17;
@@ -335,6 +340,11 @@ public final class Vocabulary extends IndexedResourceBundle {
         public static final short Directory = 50;
 
         /**
+         * Display
+         */
+        public static final short Display = 196;
+
+        /**
          * ″
          */
         public static final short DittoMark = 51;
@@ -830,6 +840,11 @@ public final class Vocabulary extends IndexedResourceBundle {
         public static final short SouthBound = 139;
 
         /**
+         * Spacing
+         */
+        public static final short Spacing = 194;
+
+        /**
          * Standard deviation
          */
         public static final short StandardDeviation = 140;
@@ -1000,6 +1015,11 @@ public final class Vocabulary extends IndexedResourceBundle {
         public static final short WestBound = 171;
 
         /**
+         * Width
+         */
+        public static final short Width = 195;
+
+        /**
          * World
          */
         public static final short World = 172;
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 bf0cfdc..490af7d 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
@@ -31,6 +31,7 @@ Black                   = Black
 Blue                    = Blue
 Cardinality             = Cardinality
 CausedBy_1              = Caused by {0}
+Cells                   = Cells
 CellCount_1             = {0} cells
 CharacterEncoding       = Character encoding
 Characteristics         = Characteristics
@@ -70,6 +71,7 @@ DigitalElevationModel   = Digital elevation model
 Dimension_1             = Dimension {0}
 Dimensions              = Dimensions
 Directory               = Directory
+Display                 = Display
 DittoMark               = \u2033
 Domain                  = Domain
 DublinJulian            = Dublin Julian
@@ -169,6 +171,7 @@ Simplified              = Simplified
 SlashSeparatedList_2    = {0}/{1}
 Source                  = Source
 SouthBound              = South bound
+Spacing                 = Spacing
 StandardDeviation       = Standard deviation
 StartDate               = Start date
 StartPoint              = Start point
@@ -203,6 +206,7 @@ Versions                = Versions
 Vertical                = Vertical
 Warnings                = Warnings
 WestBound               = West bound
+Width                   = Width
 World                   = World
 Write                   = Write
 Yellow                  = Yellow
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 bd0ee7b..dad27a3 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
@@ -38,6 +38,7 @@ Black                   = Noir
 Blue                    = Bleu
 Cardinality             = Cardinalit\u00e9
 CausedBy_1              = Caus\u00e9e par {0}
+Cells                   = Cellules
 CellCount_1             = {0} cellules
 CharacterEncoding       = Encodage des caract\u00e8res
 Characteristics         = Caract\u00e9ristiques
@@ -77,6 +78,7 @@ DigitalElevationModel   = Mod\u00e8le num\u00e9rique de terrain
 Dimension_1             = Dimension {0}
 Dimensions              = Dimensions
 Directory               = R\u00e9pertoire
+Display                 = Affichage
 DittoMark               = \u2033
 Domain                  = Domaine
 DublinJulian            = Julien Dublin
@@ -176,6 +178,7 @@ Simplified              = Simplifi\u00e9
 SlashSeparatedList_2    = {0}/{1}
 Source                  = Source
 SouthBound              = Limite sud
+Spacing                 = Espacement
 StandardDeviation       = \u00c9cart type
 StartDate               = Date de d\u00e9part
 StartPoint              = Point de d\u00e9part
@@ -210,6 +213,7 @@ Versions                = Versions
 Vertical                = Vertical
 Warnings                = Avertissements
 WestBound               = Limite ouest
+Width                   = Largeur
 World                   = Monde
 Write                   = \u00c9criture
 Yellow                  = Jaune


Mime
View raw message