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 CategoryCellFactory as BandRangeTable.
Date Sat, 08 Aug 2020 22:18:33 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 8d5386a  Rename CategoryCellFactory as BandRangeTable.
8d5386a is described below

commit 8d5386ada4ef4d70e609ac092abc08e13744df94
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Sat Aug 8 14:15:20 2020 +0200

    Rename CategoryCellFactory as BandRangeTable.
---
 ...ategoryCellFactory.java => BandRangeTable.java} | 31 ++++++++++++----------
 .../org/apache/sis/gui/coverage/GridControls.java  |  2 +-
 2 files changed, 18 insertions(+), 15 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/BandRangeTable.java
similarity index 82%
rename from application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CategoryCellFactory.java
rename to application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/BandRangeTable.java
index c2d0c75..5e4111f 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/BandRangeTable.java
@@ -26,39 +26,42 @@ import javafx.beans.property.ReadOnlyObjectWrapper;
 import javafx.beans.value.ObservableValue;
 import javafx.geometry.Pos;
 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;
 
 
 /**
- * Factory methods for cell values to shown in the sample dimension or category table.
- *
- * <p>Current implementation handles only {@link SampleDimension} instances, but it
- * can be extended for handling also {@link Category} objects in a future version.
- * The class name is in anticipation for such extension.</p>
+ * Builder for a table of {@link SampleDimension} instances with their value ranges.
+ * The columns are: band name, minimum value, maximum value, unit of measurement.
+ * The {@link TableView} is provided indirectly by the {@link #create create(…)} method;
+ * the interfaces implemented by this class are implementation convenience that may change
in any future version.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 1.1
  * @since   1.1
  * @module
  */
-final class CategoryCellFactory implements Callback<TableColumn<SampleDimension,Number>,
TableCell<SampleDimension,Number>> {
+final class BandRangeTable implements Callback<TableColumn<SampleDimension,Number>,
TableCell<SampleDimension,Number>> {
     /**
-     * Identifier of columns shown in the sample dimension or category table.
+     * Identifier of columns shown in the sample dimension table.
      */
     private static final String NAME = "name", MINIMUM = "minimum", MAXIMUM = "maximum",
UNITS = "units";
 
     /**
+     * Approximate amount of rows to make visible.
+     */
+    private static final int NUM_VISIBLE_ROW = 5;
+
+    /**
      * The format to use for formatting minimum and maximum values.
      */
     private final CellFormat cellFormat;
 
     /**
-     * Creates a cell value factory.
+     * Creates a new instance which will format numbers using the given object.
      */
-    CategoryCellFactory(final CellFormat format) {
+    BandRangeTable(final CellFormat format) {
         cellFormat = format;
     }
 
@@ -67,9 +70,9 @@ final class CategoryCellFactory implements Callback<TableColumn<SampleDimension,
      *
      * @param  vocabulary  resources for the locale in use.
      */
-    TableView<SampleDimension> createSampleDimensionTable(final Vocabulary vocabulary)
{
+    TableView<SampleDimension> create(final Vocabulary vocabulary) {
         final TableView<SampleDimension> table = new TableView<>();
-        table.setPrefHeight(5 * Styles.ROW_HEIGHT);                         // Show approximately
5 rows.
+        table.setPrefHeight(NUM_VISIBLE_ROW * Styles.ROW_HEIGHT);
         table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
         table.getColumns().setAll(
                 createStringColumn(vocabulary, Vocabulary.Keys.Name,    NAME),
@@ -82,9 +85,9 @@ final class CategoryCellFactory implements Callback<TableColumn<SampleDimension,
     /**
      * Creates a new column with a title identified by the given key.
      */
-    private TableColumn<SampleDimension,String> createStringColumn(final Vocabulary
vocabulary, final short key, final String id) {
+    private static TableColumn<SampleDimension,String> createStringColumn(final Vocabulary
vocabulary, final short key, final String id) {
         final TableColumn<SampleDimension,String> column = new TableColumn<>(vocabulary.getString(key));
-        column.setCellValueFactory(CategoryCellFactory::getStringValue);
+        column.setCellValueFactory(BandRangeTable::getStringValue);
         column.setId(id);
         return column;
     }
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridControls.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridControls.java
index f3e2cfc..da11e50 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridControls.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridControls.java
@@ -68,7 +68,7 @@ final class GridControls extends Controls {
      */
     GridControls(final RecentReferenceSystems referenceSystems, final Vocabulary vocabulary)
{
         view = new GridView(referenceSystems);
-        sampleDimensions = new CategoryCellFactory(view.cellFormat).createSampleDimensionTable(vocabulary);
+        sampleDimensions = new BandRangeTable(view.cellFormat).create(vocabulary);
         sampleDimensions.getSelectionModel().selectedIndexProperty().addListener(new BandSelectionListener(view.bandProperty));
         view.bandProperty.addListener((p,o,n) -> onBandSpecified(n));
         /*


Mime
View raw message