sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 01/31: Move GUI resources in internal package. Rename "gui.crs" as "gui.referencing". Deprecate the methods that introduce a dependency to AWT.
Date Mon, 18 Jun 2018 09:44:12 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 3b520e651c25922bc62b3b324f5fbb4041a8af59
Author: Martin Desruisseaux <desruisseaux@apache.org>
AuthorDate: Sat May 26 12:59:07 2018 +0000

    Move GUI resources in internal package. Rename "gui.crs" as "gui.referencing".
    Deprecate the methods that introduce a dependency to AWT.
    
    
    git-svn-id: https://svn.apache.org/repos/asf/sis/branches/JDK8@1832308 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sis/gui/{crs => referencing}/CRSButton.java    |   2 +-
 .../sis/gui/{crs => referencing}/CRSChooser.java   |  51 ++++++-----
 .../sis/gui/{crs => referencing}/CRSTable.java     |  65 ++++++++------
 .../apache/sis/gui/{crs => referencing}/Code.java  |  54 ++++--------
 .../WKTPane.java}                                  |  16 ++--
 .../org/apache/sis/internal/gui/FXUtilities.java   |  94 ++++++++++++++++++++
 .../org/apache/sis/internal/gui/FontGlyphs.java    |  13 +--
 .../apache/sis/internal/gui/JavaFxUtilities.java   |  98 ---------------------
 .../apache/sis/{ => internal}/gui/Resources.java   |  16 ++--
 .../sis/{ => internal}/gui/Resources.properties    |   2 +-
 .../sis/{ => internal}/gui/Resources_fr.properties |   0
 .../org/apache/sis/internal/gui/package-info.java  |  31 +++++++
 .../sis/gui/{crs => referencing}/CRSChooser.fxml   |   0
 .../sis/gui/{crs => referencing}/proj_conic.png    | Bin
 .../sis/gui/{crs => referencing}/proj_geo.png      | Bin
 .../sis/gui/{crs => referencing}/proj_square.png   | Bin
 .../sis/gui/{crs => referencing}/proj_stereo.png   | Bin
 .../sis/gui/{crs => referencing}/proj_utm.png      | Bin
 18 files changed, 229 insertions(+), 213 deletions(-)

diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSButton.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSButton.java
similarity index 98%
rename from application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSButton.java
rename to application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSButton.java
index 2ddd516..b953613 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSButton.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSButton.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.gui.crs;
+package org.apache.sis.gui.referencing;
 
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.SimpleObjectProperty;
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSChooser.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSChooser.java
similarity index 85%
rename from application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSChooser.java
rename to application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSChooser.java
index 649743d..3aeede0 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSChooser.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSChooser.java
@@ -14,13 +14,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.gui.crs;
+package org.apache.sis.gui.referencing;
 
+import java.util.Locale;
+import java.io.IOException;
+import java.io.UncheckedIOException;
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.SimpleObjectProperty;
 import javafx.beans.value.ObservableValue;
 import javafx.collections.FXCollections;
-import javafx.event.EventHandler;
 import javafx.fxml.FXML;
 import javafx.scene.control.Alert;
 import javafx.scene.control.ButtonType;
@@ -30,21 +32,22 @@ import javafx.scene.control.DialogPane;
 import javafx.scene.control.TextField;
 import javafx.scene.input.KeyEvent;
 import javafx.scene.layout.BorderPane;
-import org.apache.sis.internal.gui.JavaFxUtilities;
+import org.opengis.util.FactoryException;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.apache.sis.internal.gui.FXUtilities;
 import org.apache.sis.referencing.crs.DefaultGeographicCRS;
 import org.apache.sis.referencing.cs.AxesConvention;
 import org.apache.sis.referencing.CRS;
 import org.apache.sis.referencing.IdentifiedObjects;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.util.FactoryException;
 import org.apache.sis.referencing.crs.AbstractCRS;
 
+
 /**
  * Widget configuration panel used to select a {@link CoordinateReferenceSystem}.
  *
- * @author Johann Sorel (Geomatys)
- * @version 0.8
- * @since   0.8
+ * @author  Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since   1.0
  * @module
  */
 public class CRSChooser extends BorderPane {
@@ -69,15 +72,14 @@ public class CRSChooser extends BorderPane {
      * Create a new CRSChooser with no {@link CoordinateReferenceSystem} defined.
      */
     public CRSChooser() {
-        JavaFxUtilities.loadJRXML(this,CRSChooser.class);
-
-        uiSearch.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>()
{
-
-            @Override
-            public void handle(KeyEvent event) {
-                if (updateText) return;
-                uiTable.searchCRS(uiSearch.getText());
-            }
+        try {
+            FXUtilities.loadJRXML(this, CRSChooser.class, Locale.getDefault());
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+        uiSearch.addEventHandler(KeyEvent.KEY_PRESSED, (KeyEvent event) -> {
+            if (updateText) return;
+            uiTable.searchCRS(uiSearch.getText());
         });
 
         uiTable = new CRSTable();
@@ -99,26 +101,24 @@ public class CRSChooser extends BorderPane {
 
     }
 
-    public CoordinateReferenceSystem getCorrectedCRS(){
+    private CoordinateReferenceSystem getCorrectedCRS(){
         CoordinateReferenceSystem crs = crsProperty.get();
         if (crs == null) return null;
 
-        //fix longitude first
         try {
             Integer epsg = IdentifiedObjects.lookupEPSG(crs);
             if (epsg != null) {
-                crs = CRS.forCode("EPSG:"+epsg);
+                crs = CRS.forCode("EPSG:" + epsg);
                 if (uiLongFirst.isSelected()) {
                     crs = AbstractCRS.castOrCopy(crs).forConvention(AxesConvention.RIGHT_HANDED);
                 }
             }
-        } catch (FactoryException ex) {/*no important*/}
-
-        //fix axes convention
+        } catch (FactoryException ex) {
+            // TODO
+        }
         if (uiAxisConv.isSelected() && crs instanceof DefaultGeographicCRS &&
uiChoice.getValue() != null) {
             crs = ((DefaultGeographicCRS) crs).forConvention(uiChoice.getValue());
         }
-
         return crs;
     }
 
@@ -140,7 +140,7 @@ public class CRSChooser extends BorderPane {
      * @param crs {@link CoordinateReferenceSystem} to edit.
      * @return modified {@link CoordinateReferenceSystem}.
      */
-    public static CoordinateReferenceSystem showDialog(Object parent, CoordinateReferenceSystem
crs){
+    public static CoordinateReferenceSystem showDialog(Object parent, CoordinateReferenceSystem
crs) {
         final CRSChooser chooser = new CRSChooser();
         chooser.crsProperty.set(crs);
         final Alert alert = new Alert(Alert.AlertType.NONE);
@@ -151,5 +151,4 @@ public class CRSChooser extends BorderPane {
         final ButtonType res = alert.showAndWait().orElse(ButtonType.CANCEL);
         return res == ButtonType.CANCEL ? null : chooser.getCorrectedCRS();
     }
-
 }
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSTable.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSTable.java
similarity index 87%
rename from application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSTable.java
rename to application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSTable.java
index 77530ac..66448c5 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSTable.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSTable.java
@@ -14,16 +14,16 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.gui.crs;
+package org.apache.sis.gui.referencing;
 
 import java.awt.Color;
 import java.awt.Dimension;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Locale;
 import java.util.Set;
-import java.util.logging.Level;
 import javafx.application.Platform;
 import javafx.beans.property.ObjectProperty;
 import javafx.beans.property.SimpleObjectProperty;
@@ -47,9 +47,9 @@ import javafx.scene.layout.Background;
 import javafx.scene.layout.BackgroundFill;
 import javafx.scene.layout.CornerRadii;
 import javafx.util.Callback;
-import org.apache.sis.gui.Resources;
+import org.apache.sis.internal.gui.Resources;
 import org.apache.sis.internal.gui.FontGlyphs;
-import org.apache.sis.internal.gui.JavaFxUtilities;
+import org.apache.sis.internal.gui.FXUtilities;
 import org.apache.sis.io.wkt.FormattableObject;
 import org.apache.sis.metadata.iso.citation.Citations;
 import org.opengis.referencing.IdentifiedObject;
@@ -59,27 +59,35 @@ import org.opengis.referencing.crs.GeographicCRS;
 import org.opengis.referencing.crs.ProjectedCRS;
 import org.opengis.referencing.operation.ConicProjection;
 import org.opengis.referencing.operation.CylindricalProjection;
-import org.opengis.referencing.operation.OperationMethod;
 import org.opengis.referencing.operation.PlanarProjection;
 import org.opengis.referencing.operation.Projection;
 import org.opengis.util.FactoryException;
 
 /**
  *
- * @author Johann Sorel (Geomatys)
- * @version 0.8
- * @since   0.8
+ * @author  Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since   1.0
  * @module
  */
-public class CRSTable extends ScrollPane{
+final class CRSTable extends ScrollPane {
 
     private static final Color COLOR = new Color(30, 150, 250);
-    private static final Image ICON_GEO = JavaFxUtilities.getImage("/org/apache/sis/gui/crs/proj_geo.png",
new Dimension(16, 16));
-    private static final Image ICON_SQUARE = JavaFxUtilities.getImage("/org/apache/sis/gui/crs/proj_square.png",
new Dimension(16, 16));
-    private static final Image ICON_STEREO = JavaFxUtilities.getImage("/org/apache/sis/gui/crs/proj_stereo.png",
new Dimension(16, 16));
-    private static final Image ICON_UTM = JavaFxUtilities.getImage("/org/apache/sis/gui/crs/proj_utm.png",
new Dimension(16, 16));
-    private static final Image ICON_CONIC = JavaFxUtilities.getImage("/org/apache/sis/gui/crs/proj_conic.png",
new Dimension(16, 16));
-    private static final Image ICON_UNKNOWNED = FontGlyphs.createImage("\uE22F",16,COLOR);
+    private static final Image ICON_GEO, ICON_SQUARE, ICON_STEREO, ICON_UTM, ICON_CONIC;
+    private static final Image ICON_UNKNOWN = FontGlyphs.createImage("\uE22F",16,COLOR);
+    static {
+        final Class<?> c = CRSTable.class;
+        final Dimension dim = new Dimension(16, 16);
+        try {
+            ICON_GEO    = FXUtilities.getImage(c, "proj_geo.png",    dim);
+            ICON_SQUARE = FXUtilities.getImage(c, "proj_square.png", dim);
+            ICON_STEREO = FXUtilities.getImage(c, "proj_stereo.png", dim);
+            ICON_UTM    = FXUtilities.getImage(c, "proj_utm.png",    dim);
+            ICON_CONIC  = FXUtilities.getImage(c, "proj_conic.png",  dim);
+        } catch (IOException e) {
+            throw new ExceptionInInitializerError(e);
+        }
+    }
 
     private final ObjectProperty<CoordinateReferenceSystem> crsProperty = new SimpleObjectProperty<>();
     private final TableView<Code> uiTable = new TableView<>();
@@ -112,7 +120,7 @@ public class CRSTable extends ScrollPane{
                     try {
                         crsProperty.set((CoordinateReferenceSystem) code.createObject());
                     } catch (FactoryException ex) {
-                        JavaFxUtilities.LOGGER.log(Level.INFO,ex.getMessage(),ex);
+                        error(ex);
                     }
                 }
             }
@@ -135,11 +143,10 @@ public class CRSTable extends ScrollPane{
                         uiTable.setPlaceholder(new Label(""));
                     });
                 } catch (FactoryException ex) {
-                    JavaFxUtilities.LOGGER.log(Level.WARNING,ex.getMessage(),ex);
+                    error(ex);
                 }
             }
         }.start();
-
     }
 
     public ObjectProperty<CoordinateReferenceSystem> crsProperty(){
@@ -150,6 +157,10 @@ public class CRSTable extends ScrollPane{
         filter(searchword);
     }
 
+    private static void error(final Exception e) {
+        // TODO
+    }
+
     /**
      * Display only the CRS name that contains the specified keywords. The {@code keywords}
      * argument is a space-separated list, usually provided by the user after he pressed
the
@@ -205,7 +216,7 @@ public class CRSTable extends ScrollPane{
     }
 
     static Image getIcon(IdentifiedObject obj) {
-        Image icon = ICON_UNKNOWNED;
+        Image icon = ICON_UNKNOWN;
         if (obj instanceof GeographicCRS) {
             icon = ICON_GEO;
         } else if (obj instanceof ProjectedCRS) {
@@ -247,12 +258,12 @@ public class CRSTable extends ScrollPane{
                             super.updateItem(item, empty);
                             setGraphic(null);
                             if (item!=null){
-                                Image icon = ICON_UNKNOWNED;
+                                Image icon = ICON_UNKNOWN;
                                 try {
                                     final IdentifiedObject obj = item.createObject();
                                     icon = getIcon(obj);
                                 } catch (FactoryException ex) {
-                                    JavaFxUtilities.LOGGER.log(Level.INFO, ex.getMessage(),ex);
+                                    error(ex);
                                 }
                                 setGraphic(new ImageView(icon));
                             }
@@ -280,7 +291,8 @@ public class CRSTable extends ScrollPane{
         public DescColumn() {
             super(Resources.format(Resources.Keys.Description));
             setEditable(false);
-            setCellValueFactory((TableColumn.CellDataFeatures<Code, String> param)
-> new SimpleObjectProperty<>(param.getValue().getDescription()));
+            setCellValueFactory((TableColumn.CellDataFeatures<Code, String> param)
->
+                    new SimpleObjectProperty<>(param.getValue().getDescription()));
         }
 
     }
@@ -300,8 +312,7 @@ public class CRSTable extends ScrollPane{
 
                 @Override
                 public TableCell<Code, Code> call(TableColumn<Code, Code> param)
{
-                    return new TableCell<Code,Code>(){
-
+                    return new TableCell<Code,Code>() {
                         {
                             setOnMouseClicked(new EventHandler<MouseEvent>() {
                                 @Override
@@ -311,10 +322,10 @@ public class CRSTable extends ScrollPane{
                                         try {
                                             final IdentifiedObject obj = getItem().createObject();
                                             if (obj instanceof FormattableObject) {
-                                                FormattableObjectPane.showDialog(this, (FormattableObject)
obj);
+                                                WKTPane.showDialog(this, (FormattableObject)
obj);
                                             }
                                         } catch (FactoryException ex) {
-                                            JavaFxUtilities.LOGGER.log(Level.INFO,ex.getMessage(),ex);
+                                            error(ex);
                                         }
                                     }
                                 }
@@ -334,7 +345,5 @@ public class CRSTable extends ScrollPane{
                 }
             });
         }
-
     }
-
 }
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/Code.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/Code.java
similarity index 60%
rename from application/sis-javafx/src/main/java/org/apache/sis/gui/crs/Code.java
rename to application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/Code.java
index f47a97c..59676d3 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/Code.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/Code.java
@@ -14,38 +14,35 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.gui.crs;
+package org.apache.sis.gui.referencing;
 
-import org.apache.sis.util.ArgumentChecks;
 import org.opengis.referencing.AuthorityFactory;
 import org.opengis.referencing.IdentifiedObject;
 import org.opengis.util.FactoryException;
 
 
 /**
- * This element stores the {@linkplain #code code value}.
- * The description name will be fetched when first needed and returned by {@link #toString}.
+ * Stores the code of a coordinate reference system (CRS) together with its description.
+ * The description will be fetched when first needed and returned by {@link #toString()}.
  *
- * @author Martin Desruisseaux (IRD)
- * @version 0.8
- * @since   0.8
+ * @author  Martin Desruisseaux (Geomatys)
+ * @author  Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since   1.0
  * @module
  */
 final class Code {
-
     /**
-     * The authority code.
+     * The CRS code. Usually defined by EPSG, but other authorities are allowed.
      */
-    public final String code;
+    final String code;
 
     /**
-     * The CRS object description for the {@linkplain #code}.
-     * Will be extracted only when first needed.
+     * The CRS object description for the {@linkplain #code}, fetched when first needed.
+     * In Apache SIS implementation of EPSG factory, this is the CRS name.
      */
     private String name;
 
-    private String description;
-
     /**
      * The authority factory to use for fetching the name. Will be set to {@code null} after
      * {@linkplain #name} has been made available, in order to allow the garbage collector
@@ -55,39 +52,29 @@ final class Code {
 
     /**
      * Creates a code from the specified value.
-     *
-     * @param factory The authority factory.
-     * @param code The authority code.
      */
-    public Code(final AuthorityFactory factory, final String code) {
-        ArgumentChecks.ensureNonNull("factory", factory);
-        ArgumentChecks.ensureNonNull("code", code);
+    Code(final AuthorityFactory factory, final String code) {
         this.factory = factory;
         this.code    = code;
     }
 
     /**
      * Create the Object identified by code.
-     *
-     * @return IdentifiedObject
-     * @throws FactoryException
      */
-    public IdentifiedObject createObject() throws FactoryException{
+    IdentifiedObject createObject() throws FactoryException{
         return factory.createObject(code);
     }
 
     /**
      * Returns a description of the object.
-     *
-     * @return
      */
-    public String getDescription(){
-        if (description == null) try {
-            description = factory.getDescriptionText(code).toString();
+    public String getDescription() {
+        if (name == null) try {
+            name = factory.getDescriptionText(code).toString();
         } catch (FactoryException e) {
-            description = e.getLocalizedMessage();
+            name = e.getLocalizedMessage();
         }
-        return description;
+        return name;
     }
 
     /**
@@ -97,9 +84,6 @@ final class Code {
      */
     @Override
     public String toString() {
-        if (name == null) {
-            name = code + " - "+getDescription();
-        }
-        return name;
+        return code + " - " + getDescription();
     }
 }
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/FormattableObjectPane.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/WKTPane.java
similarity index 88%
rename from application/sis-javafx/src/main/java/org/apache/sis/gui/crs/FormattableObjectPane.java
rename to application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/WKTPane.java
index 9909695..b984d4c 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/FormattableObjectPane.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/WKTPane.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.gui.crs;
+package org.apache.sis.gui.referencing;
 
 import javafx.beans.value.ChangeListener;
 import javafx.beans.value.ObservableValue;
@@ -28,20 +28,21 @@ import javafx.scene.layout.BorderPane;
 import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.io.wkt.FormattableObject;
 
+
 /**
  * Small panel to display an object as WKT in various conventions.
  *
- * @author Johann Sorel (Geomatys)
- * @version 0.8
- * @since   0.8
+ * @author  Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since   1.0
  * @module
  */
-class FormattableObjectPane extends BorderPane {
+final class WKTPane extends BorderPane {
 
     private final ChoiceBox<Convention> choice = new ChoiceBox<>(FXCollections.observableArrayList(Convention.values()));
     private final TextArea text = new TextArea();
 
-    public FormattableObjectPane(final FormattableObject obj) {
+    public WKTPane(final FormattableObject obj) {
         setTop(choice);
         setCenter(text);
 
@@ -55,7 +56,7 @@ class FormattableObjectPane extends BorderPane {
     }
 
     public static void showDialog(Object parent, FormattableObject candidate){
-        final FormattableObjectPane chooser = new FormattableObjectPane(candidate);
+        final WKTPane chooser = new WKTPane(candidate);
 
         final Alert alert = new Alert(Alert.AlertType.NONE);
         final DialogPane pane = alert.getDialogPane();
@@ -64,5 +65,4 @@ class FormattableObjectPane extends BorderPane {
         alert.setResizable(true);
         alert.showAndWait();
     }
-
 }
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/FXUtilities.java
b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/FXUtilities.java
new file mode 100644
index 0000000..73c8bc8
--- /dev/null
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/FXUtilities.java
@@ -0,0 +1,94 @@
+/*
+ * 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.internal.gui;
+
+import java.util.Locale;
+import java.awt.Dimension;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import javax.imageio.ImageIO;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Parent;
+import javafx.scene.image.Image;
+import javafx.embed.swing.SwingFXUtils;
+
+
+/**
+ * JavaFX utilities for internal purpose only.
+ *
+ * @author  Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since   1.0
+ * @module
+ */
+public final class FXUtilities {
+    /**
+     * Do not allow instantiation of this class.
+     */
+    private FXUtilities() {
+    }
+
+    /**
+     * Loads an image and resizes it to requested size.
+     *
+     * @param  loader  the class to use for loading the image.
+     * @param  path    path to image in the jar, relative to the {@code loader} class.
+     * @param  resize  the desired size, or {@code null} for no resizing.
+     * @return image resized to the given dimension.
+     * @throws IOException if the image can not be loaded.
+     *
+     * @deprecated we need a mechanism without dependency to AWT.
+     */
+    @Deprecated
+    public static Image getImage(final Class<?> loader, final String path, final Dimension
resize) throws IOException {
+        BufferedImage img = ImageIO.read(loader.getResourceAsStream(path));
+        if (resize != null) {
+            final BufferedImage resized = new BufferedImage(resize.width, resize.height,
BufferedImage.TYPE_INT_ARGB);
+            final Graphics2D g = resized.createGraphics();
+            g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+            g.drawImage(img, 0, 0, resize.width, resize.height, null);
+            g.dispose();
+            img = resized;
+        }
+        return SwingFXUtils.toFXImage(img, null);
+    }
+
+    /**
+     * Loads and initializes widget from JRXML definition provided in this module.
+     * The JRXML file shall be in the same package than the given {@code loader} class
+     * and have the same simple name followed by the {@code ".fxml"} extension.
+     *
+     * @param  target  the widget for which to load the JRXML file.
+     * @param  loader  the class to use for loading the file.
+     * @param  locale  the locale for the resources.
+     * @throws IOException if an error occurred while loading the JRXML file.
+     */
+    public static void loadJRXML(final Parent target, final Class<?> loader, final
Locale locale) throws IOException {
+        final FXMLLoader fxl = new FXMLLoader(loader.getResource(loader.getSimpleName() +
".fxml"),
+                                              Resources.forLocale(locale));
+        fxl.setRoot(target);
+        fxl.setController(target);
+        /*
+         * In some environements like OSGi, we must use the class loader of the widget
+         * (not the class loader of FXMLLoader).
+         */
+        fxl.setClassLoader(loader.getClassLoader());
+        fxl.load();
+    }
+}
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/FontGlyphs.java
b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/FontGlyphs.java
index 9675057..154e572 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/FontGlyphs.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/FontGlyphs.java
@@ -30,14 +30,18 @@ import javafx.embed.swing.SwingFXUtils;
 import javafx.scene.image.Image;
 import org.apache.sis.util.ArgumentChecks;
 
+
 /**
  * Internal image tool to generate icons for javafx widgets.
  *
- * @author Johann Sorel (Geomatys)
- * @version 0.8
- * @since   0.8
+ * @author  Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since   1.0
  * @module
+ *
+ * @deprecated This introduces a dependency to AWT, which we wish to avoid at this early
stage.
  */
+@Deprecated
 public final class FontGlyphs {
 
     private static Font FONT;
@@ -120,7 +124,6 @@ public final class FontGlyphs {
             g.setPaint(gradiant);
             g.fill(rect);
         }
-
         int x = border + insets.left + additionalLeftInset;
 
         //draw text
@@ -135,8 +138,6 @@ public final class FontGlyphs {
             g.setColor(Color.BLACK);
             g.draw(rect);
         }
-
         return img;
     }
-
 }
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/JavaFxUtilities.java
b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/JavaFxUtilities.java
deleted file mode 100644
index 69acf9e..0000000
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/JavaFxUtilities.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.internal.gui;
-
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.util.Locale;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javafx.embed.swing.SwingFXUtils;
-import javafx.fxml.FXMLLoader;
-import javafx.scene.Parent;
-import javafx.scene.image.Image;
-import javax.imageio.ImageIO;
-import org.apache.sis.gui.Resources;
-import org.apache.sis.util.logging.Logging;
-
-/**
- * Internal JavaFx utilities.
- *
- * @author Johann Sorel (Geomatys)
- * @version 0.8
- * @since   0.8
- * @module
- */
-public final class JavaFxUtilities {
-
-    public static final Logger LOGGER = Logging.getLogger("org.apache.sis.gui");
-
-    private JavaFxUtilities(){}
-
-    /**
-     * Load an image and resize it to requested size.
-     *
-     * @param path path to image in the jar
-     * @param resize null for no resize
-     * @return resized image
-     */
-    public static Image getImage(final String path, Dimension resize) {
-        BufferedImage img = null;
-        try {
-            img = ImageIO.read(JavaFxUtilities.class.getResourceAsStream(path));
-
-            if (resize!=null) {
-                final BufferedImage resized = new BufferedImage(resize.width, resize.height,
BufferedImage.TYPE_INT_ARGB);
-                final Graphics2D g = resized.createGraphics();
-                g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
-                g.drawImage(img, 0, 0, resize.width, resize.height, null);
-                g.dispose();
-                img = resized;
-            }
-
-        } catch (IOException ex) {
-            LOGGER.log(Level.WARNING, ex.getMessage(), ex);
-        }
-        return SwingFXUtils.toFXImage(img, null);
-    }
-
-    /**
-     * Load and initialize widget from jrxml definition set this module bundle.
-     *
-     * @param candidate widget to load JRXML in
-     * @param cdtClass class as base for resource classloader
-     */
-    public static void loadJRXML(Parent candidate, Class cdtClass) {
-        final String fxmlpath = "/"+cdtClass.getName().replace('.', '/')+".fxml";
-        final FXMLLoader loader = new FXMLLoader(cdtClass.getResource(fxmlpath));
-        loader.setResources(Resources.forLocale(Locale.getDefault()));
-        loader.setController(candidate);
-        loader.setRoot(candidate);
-        //in special environement like osgi or other, we must use the proper class loaders
-        //not necessarly the one who loaded the FXMLLoader class
-        loader.setClassLoader(cdtClass.getClassLoader());
-        try {
-            loader.load();
-        } catch (IOException ex) {
-            throw new IllegalArgumentException(ex.getMessage(), ex);
-        }
-    }
-
-}
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.java b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java
similarity index 96%
rename from application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.java
rename to application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java
index 9b56e14..8eda591 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.gui;
+package org.apache.sis.internal.gui;
 
 import java.net.URL;
 import java.util.Locale;
@@ -27,13 +27,13 @@ import org.apache.sis.util.resources.ResourceInternationalString;
 
 
 /**
- * Warning and error messages that are specific to the {@code sis-storage} module.
+ * Messages that are specific to the {@code sis-javafx} module.
  * Resources in this file should not be used by any other module. For resources shared by
  * all modules in the Apache SIS project, see {@link org.apache.sis.util.resources} package.
  *
- * @author  Martin Desruisseaux (IRD, Geomatys)
- * @version 0.8
- * @since   0.8
+ * @author  Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since   1.0
  * @module
  */
 public final class Resources extends IndexedResourceBundle {
@@ -42,10 +42,6 @@ public final class Resources extends IndexedResourceBundle {
      * {@code Keys} should appear in any resulting class files. Since the Java compiler
      * inlines final integer values, using long identifiers will not bloat the constant
      * pools of compiled classes.
-     *
-     * @author  Martin Desruisseaux (IRD, Geomatys)
-     * @since   0.3
-     * @module
      */
     @Generated("org.apache.sis.util.resources.IndexedResourceCompiler")
     public static final class Keys extends KeyConstants {
@@ -81,7 +77,7 @@ public final class Resources extends IndexedResourceBundle {
         public static final short Description = 2;
 
         /**
-         * Logitude first
+         * Longitude first
          */
         public static final short LongitudeFirst = 5;
     }
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.properties
b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties
similarity index 97%
rename from application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.properties
rename to application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties
index 06bad7b..6ce5fb7 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.properties
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties
@@ -23,5 +23,5 @@
 Code            = Code
 Description     = Description
 CRS             = CRS
-LongitudeFirst  = Logitude first
+LongitudeFirst  = Longitude first
 AxisConvention  = Axis convention
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources_fr.properties
b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources_fr.properties
similarity index 100%
rename from application/sis-javafx/src/main/java/org/apache/sis/gui/Resources_fr.properties
rename to application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources_fr.properties
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/package-info.java
b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/package-info.java
new file mode 100644
index 0000000..673060f
--- /dev/null
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/package-info.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+/**
+ * A set of helper classes for the SIS implementation.
+ *
+ * <STRONG>Do not use!</STRONG>
+ *
+ * This package is for internal use by SIS only. Classes in this package
+ * may change in incompatible ways in any future version without notice.
+ *
+ * @author  Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since   1.0
+ * @module
+ */
+package org.apache.sis.internal.gui;
diff --git a/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/CRSChooser.fxml
b/application/sis-javafx/src/main/resources/org/apache/sis/gui/referencing/CRSChooser.fxml
similarity index 100%
rename from application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/CRSChooser.fxml
rename to application/sis-javafx/src/main/resources/org/apache/sis/gui/referencing/CRSChooser.fxml
diff --git a/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_conic.png
b/application/sis-javafx/src/main/resources/org/apache/sis/gui/referencing/proj_conic.png
similarity index 100%
rename from application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_conic.png
rename to application/sis-javafx/src/main/resources/org/apache/sis/gui/referencing/proj_conic.png
diff --git a/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_geo.png
b/application/sis-javafx/src/main/resources/org/apache/sis/gui/referencing/proj_geo.png
similarity index 100%
rename from application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_geo.png
rename to application/sis-javafx/src/main/resources/org/apache/sis/gui/referencing/proj_geo.png
diff --git a/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_square.png
b/application/sis-javafx/src/main/resources/org/apache/sis/gui/referencing/proj_square.png
similarity index 100%
rename from application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_square.png
rename to application/sis-javafx/src/main/resources/org/apache/sis/gui/referencing/proj_square.png
diff --git a/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_stereo.png
b/application/sis-javafx/src/main/resources/org/apache/sis/gui/referencing/proj_stereo.png
similarity index 100%
rename from application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_stereo.png
rename to application/sis-javafx/src/main/resources/org/apache/sis/gui/referencing/proj_stereo.png
diff --git a/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_utm.png
b/application/sis-javafx/src/main/resources/org/apache/sis/gui/referencing/proj_utm.png
similarity index 100%
rename from application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_utm.png
rename to application/sis-javafx/src/main/resources/org/apache/sis/gui/referencing/proj_utm.png

-- 
To stop receiving notification emails like this one, please contact
desruisseaux@apache.org.

Mime
View raw message