You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2018/05/26 12:59:08 UTC
svn commit: r1832308 - in /sis/branches/JDK8/application/sis-javafx/src/main:
java/org/apache/sis/gui/ java/org/apache/sis/gui/crs/
java/org/apache/sis/gui/referencing/ java/org/apache/sis/internal/gui/
resources/org/apache/sis/gui/crs/ resources/org/a...
Author: desruisseaux
Date: Sat May 26 12:59:07 2018
New Revision: 1832308
URL: http://svn.apache.org/viewvc?rev=1832308&view=rev
Log:
Move GUI resources in internal package. Rename "gui.crs" as "gui.referencing".
Deprecate the methods that introduce a dependency to AWT.
Added:
sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/
sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSButton.java
- copied, changed from r1832307, sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSButton.java
sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSChooser.java
- copied, changed from r1832307, sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSChooser.java
sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSTable.java
- copied, changed from r1832307, sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSTable.java
sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/Code.java
- copied, changed from r1832307, sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/Code.java
sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/WKTPane.java
- copied, changed from r1832307, sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/FormattableObjectPane.java
sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/FXUtilities.java
- copied, changed from r1832307, sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/JavaFxUtilities.java
sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java
- copied, changed from r1832307, sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.java
sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties
- copied, changed from r1832307, sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.properties
sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources_fr.properties
- copied unchanged from r1832307, sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources_fr.properties
sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/package-info.java (with props)
sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/referencing/
- copied from r1832307, sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/
Removed:
sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.java
sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.properties
sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources_fr.properties
sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/
sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/JavaFxUtilities.java
sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/
Modified:
sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/FontGlyphs.java
Copied: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSButton.java (from r1832307, sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSButton.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSButton.java?p2=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSButton.java&p1=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSButton.java&r1=1832307&r2=1832308&rev=1832308&view=diff
==============================================================================
--- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSButton.java [UTF-8] (original)
+++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSButton.java [UTF-8] Sat May 26 12:59:07 2018
@@ -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;
Copied: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSChooser.java (from r1832307, sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSChooser.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSChooser.java?p2=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSChooser.java&p1=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSChooser.java&r1=1832307&r2=1832308&rev=1832308&view=diff
==============================================================================
--- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSChooser.java [UTF-8] (original)
+++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSChooser.java [UTF-8] Sat May 26 12:59:07 2018
@@ -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 BorderPa
* 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 BorderPa
}
- 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 BorderPa
* @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 BorderPa
final ButtonType res = alert.showAndWait().orElse(ButtonType.CANCEL);
return res == ButtonType.CANCEL ? null : chooser.getCorrectedCRS();
}
-
}
Copied: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSTable.java (from r1832307, sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSTable.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSTable.java?p2=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSTable.java&p1=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSTable.java&r1=1832307&r2=1832308&rev=1832308&view=diff
==============================================================================
--- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSTable.java [UTF-8] (original)
+++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/CRSTable.java [UTF-8] Sat May 26 12:59:07 2018
@@ -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.Geogr
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
}
});
}
-
}
-
}
Copied: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/Code.java (from r1832307, sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/Code.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/Code.java?p2=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/Code.java&p1=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/Code.java&r1=1832307&r2=1832308&rev=1832308&view=diff
==============================================================================
--- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/Code.java [UTF-8] (original)
+++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/Code.java [UTF-8] Sat May 26 12:59:07 2018
@@ -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();
}
}
Copied: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/WKTPane.java (from r1832307, sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/FormattableObjectPane.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/WKTPane.java?p2=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/WKTPane.java&p1=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/FormattableObjectPane.java&r1=1832307&r2=1832308&rev=1832308&view=diff
==============================================================================
--- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/FormattableObjectPane.java [UTF-8] (original)
+++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/WKTPane.java [UTF-8] Sat May 26 12:59:07 2018
@@ -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 Bord
}
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 Bord
alert.setResizable(true);
alert.showAndWait();
}
-
}
Copied: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/FXUtilities.java (from r1832307, sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/JavaFxUtilities.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/FXUtilities.java?p2=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/FXUtilities.java&p1=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/JavaFxUtilities.java&r1=1832307&r2=1832308&rev=1832308&view=diff
==============================================================================
--- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/JavaFxUtilities.java [UTF-8] (original)
+++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/FXUtilities.java [UTF-8] Sat May 26 12:59:07 2018
@@ -16,83 +16,79 @@
*/
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 java.util.Locale;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javafx.embed.swing.SwingFXUtils;
+import javax.imageio.ImageIO;
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;
+import javafx.embed.swing.SwingFXUtils;
+
/**
- * Internal JavaFx utilities.
+ * JavaFX utilities for internal purpose only.
*
- * @author Johann Sorel (Geomatys)
- * @version 0.8
- * @since 0.8
+ * @author Johann Sorel (Geomatys)
+ * @version 1.0
+ * @since 1.0
* @module
*/
-public final class JavaFxUtilities {
-
- public static final Logger LOGGER = Logging.getLogger("org.apache.sis.gui");
-
- private JavaFxUtilities(){}
+public final class FXUtilities {
+ /**
+ * Do not allow instantiation of this class.
+ */
+ private FXUtilities() {
+ }
/**
- * Load an image and resize it to requested size.
+ * 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.
*
- * @param path path to image in the jar
- * @param resize null for no resize
- * @return resized image
+ * @deprecated we need a mechanism without dependency to AWT.
*/
- 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);
+ @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);
}
/**
- * Load and initialize widget from jrxml definition set this module bundle.
+ * 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 candidate widget to load JRXML in
- * @param cdtClass class as base for resource classloader
+ * @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(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);
- }
+ 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();
}
-
}
Modified: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/FontGlyphs.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/FontGlyphs.java?rev=1832308&r1=1832307&r2=1832308&view=diff
==============================================================================
--- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/FontGlyphs.java [UTF-8] (original)
+++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/FontGlyphs.java [UTF-8] Sat May 26 12:59:07 2018
@@ -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;
}
-
}
Copied: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java (from r1832307, sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java?p2=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java&p1=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.java&r1=1832307&r2=1832308&rev=1832308&view=diff
==============================================================================
--- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.java [UTF-8] (original)
+++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.java [UTF-8] Sat May 26 12:59:07 2018
@@ -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.Res
/**
- * 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 Ind
* {@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 Ind
public static final short Description = 2;
/**
- * Logitude first
+ * Longitude first
*/
public static final short LongitudeFirst = 5;
}
Copied: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties (from r1832307, sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.properties)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties?p2=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties&p1=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.properties&r1=1832307&r2=1832308&rev=1832308&view=diff
==============================================================================
--- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/Resources.properties [ISO-8859-1] Sat May 26 12:59:07 2018
@@ -23,5 +23,5 @@
Code = Code
Description = Description
CRS = CRS
-LongitudeFirst = Logitude first
+LongitudeFirst = Longitude first
AxisConvention = Axis convention
Added: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/package-info.java?rev=1832308&view=auto
==============================================================================
--- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/package-info.java (added)
+++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/package-info.java [UTF-8] Sat May 26 12:59:07 2018
@@ -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;
Propchange: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8