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 92dc482 Update the values shown in GridView according the band
selected in the sample dimensions table.
92dc482 is described below
commit 92dc4828a23a70bd01c9289941ada7c968a28c2b
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Tue Feb 4 13:08:22 2020 +0100
Update the values shown in GridView according the band selected in the
sample dimensions table.
---
.../sis/gui/coverage/BandSelectionListener.java | 64 ++++++++++++++++++++++
.../sis/gui/coverage/CategoryCellFactory.java | 2 +-
.../apache/sis/gui/coverage/CoverageExplorer.java | 4 +-
3 files changed, 68 insertions(+), 2 deletions(-)
diff --git
a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/BandSelectionListener.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/BandSelectionListener.java
new file mode 100644
index 0000000..6cf137c
--- /dev/null
+++
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/BandSelectionListener.java
@@ -0,0 +1,64 @@
+/*
+ * 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.property.IntegerProperty;
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.ObservableValue;
+
+
+/**
+ * Listener to selections in a table of sample dimensions. When a new row is
selected,
+ * the selection is forwarded to the {@link GridView#bandProperty}.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @version 1.1
+ * @since 1.1
+ * @module
+ */
+final class BandSelectionListener implements ChangeListener<Number> {
+ /**
+ * The {@link GridView#bandProperty} to update when a new band is selected.
+ */
+ private final IntegerProperty bandProperty;
+
+ /**
+ * Safety against recursive invocations, since a change in {@link
#bandProperty}
+ * may itself causes a change in the selected row.
+ */
+ private boolean isAdjusting;
+
+ /**
+ * Creates a new listener which will modify the given property.
+ */
+ BandSelectionListener(final IntegerProperty bandProperty) {
+ this.bandProperty = bandProperty;
+ }
+
+ /**
+ * Invoked when the user selected a new row in the table of sample
dimensions.
+ */
+ @Override
+ public void changed(ObservableValue<? extends Number> property, Number
oldValue, Number newValue) {
+ if (!isAdjusting) try {
+ isAdjusting = true;
+ bandProperty.set(newValue.intValue());
+ } finally {
+ isAdjusting = false;
+ }
+ }
+}
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 7962cce..c2d0c75 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
@@ -101,7 +101,7 @@ final class CategoryCellFactory implements
Callback<TableColumn<SampleDimension,
}
/**
- * Creates a cell for numeric values.
+ * Invoked by {@link TableColumn} for creating a cell for numeric values.
* This method is public as an implementation side-effect; do not rely on
that.
*/
@Override
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 b7ed500..89d98aa 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
@@ -104,9 +104,11 @@ public class CoverageExplorer {
* Creates an initially empty explorer.
*/
public CoverageExplorer() {
- final Vocabulary vocabulary = Vocabulary.getResources((Locale) null);
+ final Locale locale = Locale.getDefault(Locale.Category.DISPLAY);
+ final Vocabulary vocabulary = Vocabulary.getResources(locale);
gridView = new GridView();
sampleDimensions = new
CategoryCellFactory(gridView.cellFormat).createSampleDimensionTable(vocabulary);
+
sampleDimensions.getSelectionModel().selectedIndexProperty().addListener(new
BandSelectionListener(gridView.bandProperty));
/*
* "Coverage" section with the following controls:
* - Coverage domain as a list of CRS dimensions with two of them
selected (TODO).