sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 02/02: Reduce the number of Locale object we carry. They are not needed at this time since the application is shown in default locale only, and the information is tedious to transfer between various objects.
Date Sun, 23 Feb 2020 16:47:17 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

commit 3195e47572da31c3bcaf034b1e349080efb12a0f
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Sun Feb 23 17:35:54 2020 +0100

    Reduce the number of Locale object we carry. They are not needed at this time since the
application is shown in default locale only, and the information is tedious to transfer between
various objects.
---
 .../java/org/apache/sis/gui/coverage/CoverageExplorer.java |  7 +++----
 .../java/org/apache/sis/gui/coverage/CoverageView.java     |  6 ++----
 .../main/java/org/apache/sis/gui/coverage/GridView.java    |  2 +-
 .../main/java/org/apache/sis/gui/coverage/StatusBar.java   |  3 +--
 .../main/java/org/apache/sis/gui/dataset/DataWindow.java   | 11 ++---------
 .../main/java/org/apache/sis/gui/dataset/FeatureTable.java | 11 ++---------
 .../main/java/org/apache/sis/gui/dataset/ResourceTree.java |  2 +-
 .../java/org/apache/sis/gui/metadata/MetadataSummary.java  | 14 +++-----------
 .../java/org/apache/sis/gui/metadata/MetadataTree.java     | 11 ++---------
 .../java/org/apache/sis/internal/gui/ToolbarButton.java    |  4 +---
 .../src/main/java/org/apache/sis/internal/map/Canvas.java  |  2 +-
 11 files changed, 19 insertions(+), 54 deletions(-)

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 158c106..9a31c49 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
@@ -114,8 +114,7 @@ public class CoverageExplorer {
      * Creates an initially empty explorer.
      */
     public CoverageExplorer() {
-        final Locale locale = Locale.getDefault(Locale.Category.DISPLAY);
-        final Vocabulary vocabulary = Vocabulary.getResources(locale);
+        final Vocabulary vocabulary = Vocabulary.getResources((Locale) null);
         gridView         = new GridView();
         sampleDimensions = new CategoryCellFactory(gridView.cellFormat).createSampleDimensionTable(vocabulary);
         sampleDimensions.getSelectionModel().selectedIndexProperty().addListener(new BandSelectionListener(gridView.bandProperty));
@@ -203,8 +202,8 @@ addRows:    for (int row = 0;; row++) {
             }
 
             /** Creates a visualization of the coverage. */
-            @Override public Region createView(final Locale locale) {
-                final CoverageView view = new CoverageView(locale);
+            @Override public Region createView() {
+                final CoverageView view = new CoverageView();
                 view.coverageProperty.bind(coverageProperty);
                 return view.getView();
             }
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 2bcfb14..62a448c 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
@@ -125,11 +125,9 @@ final class CoverageView extends PlanarCanvas {
 
     /**
      * Creates a new two-dimensional canvas for {@link RenderedImage}.
-     *
-     * @param  locale  the locale to use for labels and some messages, or {@code null} for
default.
      */
-    public CoverageView(final Locale locale) {
-        super(locale);
+    public CoverageView() {
+        super(Locale.getDefault());
         coverageProperty    = new SimpleObjectProperty<>(this, "coverage");
         sliceExtentProperty = new SimpleObjectProperty<>(this, "sliceExtent");
         dataToImage = new AffineTransform();
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridView.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridView.java
index b4b171d..2ac1464 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridView.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/GridView.java
@@ -186,7 +186,7 @@ public class GridView extends Control {
     private final NumberFormat headerFormat;
 
     /**
-     * The formatter to use for writing sample values. This is also the the property for
the localized format pattern.
+     * The formatter to use for writing sample values. This is also the property for the
localized format pattern.
      * Note that this pattern depends on current locale. It is provided for user interactions
(i.e. in a GUI control)
      * instead than programmatic action.
      *
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/StatusBar.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/StatusBar.java
index 72f0b14..70c76cf 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/StatusBar.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/StatusBar.java
@@ -17,7 +17,6 @@
 package org.apache.sis.gui.coverage;
 
 import java.util.Locale;
-import java.util.TimeZone;
 import javax.measure.Unit;
 import javafx.geometry.Insets;
 import javafx.geometry.Pos;
@@ -86,7 +85,7 @@ final class StatusBar extends HBox {
      */
     StatusBar(final GridView view) {
         this.view = view;
-        format = new CoordinateFormat(Locale.getDefault(Locale.Category.FORMAT), TimeZone.getDefault());
+        format = new CoordinateFormat();
         coordinates = new Label();
         setAlignment(Pos.CENTER_RIGHT);
         getChildren().setAll(coordinates);
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/DataWindow.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/DataWindow.java
index 59ca2cc..4a7ac4a 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/DataWindow.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/DataWindow.java
@@ -16,7 +16,6 @@
  */
 package org.apache.sis.gui.dataset;
 
-import java.util.Locale;
 import javafx.geometry.Rectangle2D;
 import javafx.stage.Screen;
 import javafx.stage.Stage;
@@ -46,11 +45,6 @@ import org.apache.sis.internal.gui.ToolbarButton;
  */
 final class DataWindow extends Stage {
     /**
-     * The locale for texts and tooltips in this window.
-     */
-    private final Locale locale;
-
-    /**
      * The tools bar. Removed from the pane when going in full screen mode, and reinserted
      * when exiting full screen mode. The first button in this toolbar shall be the "home"
      * button (for showing the main window on front) — if a different position is desired,
@@ -96,7 +90,6 @@ final class DataWindow extends Stage {
      * @param  localized  {@link Resources} instance, provided because often known by the
caller.
      */
     private DataWindow(final Region content, final Resources localized) {
-        locale = localized.getLocale();
         /*
          * Build the tools bar. This bar will be hidden in full screen mode. Note that above
          * method assumes that the "home" button created below is the first one in the toolbar.
@@ -185,8 +178,8 @@ final class DataWindow extends Stage {
         public void handle(final ActionEvent event) {
             if (creator != null) {
                 final DataWindow originator = window;
-                final Resources  localized  = Resources.forLocale(originator.locale);
-                final Region     content    = creator.createView(originator.locale);
+                final Resources  localized  = Resources.forLocale(null);
+                final Region     content    = creator.createView();
                 final Button     backButton = creator.createBackButton(localized);
                 backButton.setOnAction((e) -> {originator.show(); originator.toFront();});
                 ToolbarButton.insert(content, new ToolbarButton() {
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/FeatureTable.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/FeatureTable.java
index 94c4a90..548fe79 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/FeatureTable.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/FeatureTable.java
@@ -83,17 +83,12 @@ import org.apache.sis.internal.gui.ExceptionReporter;
 @DefaultProperty("features")
 public class FeatureTable extends TableView<Feature> {
     /**
-     * The locale to use for texts.
+     * The locale to use for texts. This is usually {@link Locale#getDefault()}.
+     * This value is given to {@link InternationalString#toString(Locale)} calls.
      */
     final Locale textLocale;
 
     /**
-     * The locale to use for dates/numbers.
-     * This is often the same than {@link #textLocale}.
-     */
-    private final Locale dataLocale;
-
-    /**
      * The type of features, or {@code null} if not yet determined.
      * This type determines the columns that will be shown.
      *
@@ -124,7 +119,6 @@ public class FeatureTable extends TableView<Feature> {
     public FeatureTable() {
         super(new FeatureList());
         textLocale = Locale.getDefault(Locale.Category.DISPLAY);
-        dataLocale = Locale.getDefault(Locale.Category.FORMAT);
         initialize();
     }
 
@@ -140,7 +134,6 @@ public class FeatureTable extends TableView<Feature> {
         other.isSharingList = true;
         isSharingList = true;
         textLocale    = other.textLocale;
-        dataLocale    = other.dataLocale;
         featureType   = other.featureType;
         setFeatures(other.getFeatures());           // Shall be invoked before to install
the listener.
         initialize();                               // Install listener.
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceTree.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceTree.java
index 97657f8..7a73429 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceTree.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceTree.java
@@ -100,7 +100,7 @@ public class ResourceTree extends TreeView<Resource> {
      * For showing a resource, invoke {@link #setResource(Resource)} after construction.
      */
     public ResourceTree() {
-        localized = Resources.forLocale(Locale.getDefault(Locale.Category.DISPLAY));
+        localized = Resources.forLocale(null);
         setCellFactory(ResourceTree::newCell);
         setOnDragOver(ResourceTree::onDragOver);
         setOnDragDropped(this::load);
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataSummary.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataSummary.java
index f4f3f42..920fcb5 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataSummary.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataSummary.java
@@ -20,7 +20,6 @@ import java.text.DateFormat;
 import java.text.NumberFormat;
 import java.util.Collection;
 import java.util.ArrayList;
-import java.util.Locale;
 import java.util.StringJoiner;
 import javafx.application.Platform;
 import javafx.beans.DefaultProperty;
@@ -76,12 +75,6 @@ public class MetadataSummary {
     final Resources localized;
 
     /**
-     * The locale to use for date/number formatters.
-     * This is often the same than {@link #localized}.
-     */
-    final Locale dataLocale;
-
-    /**
      * The format to use for writing numbers, created when first needed.
      *
      * @see #getNumberFormat()
@@ -147,8 +140,7 @@ public class MetadataSummary {
      * Creates an initially empty metadata overview.
      */
     public MetadataSummary() {
-        localized   = Resources.forLocale(Locale.getDefault(Locale.Category.DISPLAY));
-        dataLocale  = Locale.getDefault(Locale.Category.FORMAT);
+        localized   = Resources.forLocale(null);
         information = new TitledPane[] {
             new TitledPane(localized.getString(Resources.Keys.ResourceIdentification), new
IdentificationInfo(this)),
             new TitledPane(localized.getString(Resources.Keys.SpatialRepresentation),  new
RepresentationInfo(this))
@@ -182,7 +174,7 @@ public class MetadataSummary {
      */
     final NumberFormat getNumberFormat() {
         if (numberFormat == null) {
-            numberFormat = NumberFormat.getInstance(dataLocale);
+            numberFormat = NumberFormat.getInstance();
         }
         return numberFormat;
     }
@@ -192,7 +184,7 @@ public class MetadataSummary {
      */
     final DateFormat getDateFormat() {
         if (dateFormat == null) {
-            dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.MEDIUM,
dataLocale);
+            dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.MEDIUM);
         }
         return dateFormat;
     }
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataTree.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataTree.java
index 9b964b2..5b7c3c7 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataTree.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/MetadataTree.java
@@ -113,17 +113,12 @@ public class MetadataTree extends TreeTableView<TreeTable.Node>
{
     }
 
     /**
-     * The locale to use for texts.
+     * The locale to use for texts. This is usually {@link Locale#getDefault()}.
+     * This value is given to {@link InternationalString#toString(Locale)} calls.
      */
     final Locale textLocale;
 
     /**
-     * The locale to use for dates/numbers.
-     * This is often the same than {@link #textLocale}.
-     */
-    private final Locale dataLocale;
-
-    /**
      * Creates a new initially empty metadata tree.
      */
     public MetadataTree() {
@@ -150,10 +145,8 @@ public class MetadataTree extends TreeTableView<TreeTable.Node>
{
     MetadataTree(final MetadataSummary controller, final boolean standard) {
         if (controller != null) {
             textLocale = controller.localized.getLocale();
-            dataLocale = controller.dataLocale;
         } else {
             textLocale = Locale.getDefault(Locale.Category.DISPLAY);
-            dataLocale = Locale.getDefault(Locale.Category.FORMAT);
         }
         contentProperty = new ContentProperty(this);
         nameColumn      = new TreeTableColumn<>(TableColumn.NAME .getHeader().toString(textLocale));
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/ToolbarButton.java
b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/ToolbarButton.java
index d3f2109..06e588f 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/ToolbarButton.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/ToolbarButton.java
@@ -16,7 +16,6 @@
  */
 package org.apache.sis.internal.gui;
 
-import java.util.Locale;
 import javafx.scene.Node;
 import javafx.scene.control.Button;
 import javafx.scene.control.Tooltip;
@@ -148,9 +147,8 @@ public abstract class ToolbarButton {
          * This method is invoked only on the first click. For all subsequent clicks,
          * the existing window will be shown again.
          *
-         * @param  locale  locale of the window creating a new window.
          * @return content of the window to show.
          */
-        public abstract Region createView(Locale locale);
+        public abstract Region createView();
     }
 }
diff --git a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/Canvas.java b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/Canvas.java
index d70de30..1fa4edc 100644
--- a/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/Canvas.java
+++ b/core/sis-portrayal/src/main/java/org/apache/sis/internal/map/Canvas.java
@@ -375,7 +375,7 @@ public class Canvas extends Observable implements Localized {
     private final DefaultCoordinateOperationFactory coordinateOperationFactory;
 
     /**
-     * The locale for labels or error messages.
+     * The locale for labels or error messages, or {@code null} for the default.
      */
     private final Locale locale;
 


Mime
View raw message