Author: jsorel Date: Fri Sep 8 15:37:30 2017 New Revision: 1807778 URL: http://svn.apache.org/viewvc?rev=1807778&view=rev Log: JavaFx : new CRSChooser widget
Added: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.java - copied, changed from r1807728, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.properties - copied, changed from r1807728, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources_fr.properties - copied, changed from r1807728, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/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/gui/crs/CRSButton.java 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/crs/CRSTable.java 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/crs/FormattableObjectPane.java 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/ sis/branches/JDK8/application/sis-javafx/src/main/resources/org/ sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/ sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/ sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/ sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/ sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/CRSChooser.fxml sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_conic.png (with props) sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_geo.png (with props) sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_square.png (with props) sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_stereo.png (with props) sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_utm.png (with props) Removed: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/ClientApplication.java Modified: sis/branches/JDK8/application/pom.xml sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceTree.java sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/FontGlyphs.java Modified: sis/branches/JDK8/application/pom.xml URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/pom.xml?rev=1807778&r1=1807777&r2=1807778&view=diff ============================================================================== --- sis/branches/JDK8/application/pom.xml (original) +++ sis/branches/JDK8/application/pom.xml Fri Sep 8 15:37:30 2017 @@ -76,6 +76,7 @@ <executions> <execution> <goals> + <goal>compile-resources</goal> <goal>collect-jars</goal> </goals> </execution> Copied: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.java (from r1807728, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java) URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.java?p2=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.java&p1=sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java&r1=1807728&r2=1807778&rev=1807778&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java [UTF-8] (original) +++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.java [UTF-8] Fri Sep 8 15:37:30 2017 @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.sis.internal.storage; +package org.apache.sis.gui; import java.net.URL; import java.util.Locale; @@ -61,147 +61,29 @@ public final class Resources extends Ind } /** - * Name “{3}” is ambiguous because it can be understood as either “{1}” or “{2}” in the context - * of “{0}” data. + * Axis convention */ - public static final short AmbiguousName_4 = 15; + public static final short AxisConvention = 3; /** - * Can not read “{1}” as a file in the {0} format. + * CRS */ - public static final short CanNotReadFile_2 = 1; + public static final short CRS = 4; /** - * Can not read line {2} of “{1}” as part of a file in the {0} format. + * Code */ - public static final short CanNotReadFile_3 = 2; + public static final short Code = 1; /** - * Can not read line {2} (after column {3}) of “{1}” as part of a file in the {0} format. + * Description */ - public static final short CanNotReadFile_4 = 3; + public static final short Description = 2; /** - * This {0} reader is closed. + * Logitude first */ - public static final short ClosedReader_1 = 4; - - /** - * This {0} writer is closed. - */ - public static final short ClosedWriter_1 = 5; - - /** - * One or more read operations are in progress in the “{0}” data store. - */ - public static final short ConcurrentRead_1 = 19; - - /** - * A write operation is in progress in the “{0}” data store. - */ - public static final short ConcurrentWrite_1 = 20; - - /** - * Character string in the “{0}” file is too long. The string has {2} characters while the - * limit is {1}. - */ - public static final short ExcessiveStringSize_3 = 6; - - /** - * A feature named “{1}” is already present in the “{0}” data store. - */ - public static final short FeatureAlreadyPresent_2 = 16; - - /** - * Feature “{1}” has not been found in the “{0}” data store. - */ - public static final short FeatureNotFound_2 = 17; - - /** - * The {0} data store does not accept features of type “{1}”. - */ - public static final short IllegalFeatureType_2 = 7; - - /** - * The {0} reader does not accept inputs of type ‘{1}’. - */ - public static final short IllegalInputTypeForReader_2 = 8; - - /** - * The {0} writer does not accept outputs of type ‘{1}’. - */ - public static final short IllegalOutputTypeForWriter_2 = 9; - - /** - * Components of the “{1}” name are inconsistent with those of the name previously binded in - * “{0}” data store. - */ - public static final short InconsistentNameComponents_2 = 10; - - /** - * Missing scheme in “{0}” URI. - */ - public static final short MissingSchemeInURI_1 = 11; - - /** - * Processing executed on {0}. - */ - public static final short ProcessingExecutedOn_1 = 12; - - /** - * More than one resource have the “{1}” identifier in the “{0}” data store. - */ - public static final short ResourceIdentifierCollision_2 = 23; - - /** - * No resource found for the “{1}” identifier in the “{0}” data store. - */ - public static final short ResourceNotFound_2 = 24; - - /** - * The “{1}” element must be declared before “{0}”. - */ - public static final short ShallBeDeclaredBefore_2 = 22; - - /** - * Write operations are not supported. - */ - public static final short StoreIsReadOnly = 28; - - /** - * Can not move backward in the “{0}” stream. - */ - public static final short StreamIsForwardOnly_1 = 13; - - /** - * Stream “{0}” is not readable. - */ - public static final short StreamIsNotReadable_1 = 25; - - /** - * Stream “{0}” is not writable. - */ - public static final short StreamIsNotWritable_1 = 26; - - /** - * The “{0}” data store can be read only once. - */ - public static final short StreamIsReadOnce_1 = 18; - - /** - * Can not modify previously written data in “{0}”. - */ - public static final short StreamIsWriteOnce_1 = 21; - - /** - * Can not open {0} data store without “{1}” parameter. - */ - public static final short UndefinedParameter_2 = 27; - - /** - * Format of “{0}” is not recognized. - */ - public static final short UnknownFormatFor_1 = 14; + public static final short LongitudeFirst = 5; } /** Copied: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.properties (from r1807728, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties) URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.properties?p2=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.properties&p1=sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties&r1=1807728&r2=1807778&rev=1807778&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties [ISO-8859-1] (original) +++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources.properties [ISO-8859-1] Fri Sep 8 15:37:30 2017 @@ -16,34 +16,12 @@ # # -# Resources in this file are for "sis-netcdf" usage only and should not be used by any other module. +# Resources in this file are for "sis-javafx" usage only and should not be used by any other module. # For resources shared by all modules in the Apache SIS project, see "org.apache.sis.util.resources" package. # -AmbiguousName_4 = Name \u201c{3}\u201d is ambiguous because it can be understood as either \u201c{1}\u201d or \u201c{2}\u201d in the context of \u201c{0}\u201d data. -CanNotReadFile_2 = Can not read \u201c{1}\u201d as a file in the {0} format. -CanNotReadFile_3 = Can not read line {2} of \u201c{1}\u201d as part of a file in the {0} format. -CanNotReadFile_4 = Can not read line {2} (after column {3}) of \u201c{1}\u201d as part of a file in the {0} format. -ClosedReader_1 = This {0} reader is closed. -ClosedWriter_1 = This {0} writer is closed. -ConcurrentRead_1 = One or more read operations are in progress in the \u201c{0}\u201d data store. -ConcurrentWrite_1 = A write operation is in progress in the \u201c{0}\u201d data store. -FeatureAlreadyPresent_2 = A feature named \u201c{1}\u201d is already present in the \u201c{0}\u201d data store. -FeatureNotFound_2 = Feature \u201c{1}\u201d has not been found in the \u201c{0}\u201d data store. -ExcessiveStringSize_3 = Character string in the \u201c{0}\u201d file is too long. The string has {2} characters while the limit is {1}. -IllegalFeatureType_2 = The {0} data store does not accept features of type \u201c{1}\u201d. -IllegalInputTypeForReader_2 = The {0} reader does not accept inputs of type \u2018{1}\u2019. -IllegalOutputTypeForWriter_2 = The {0} writer does not accept outputs of type \u2018{1}\u2019. -InconsistentNameComponents_2 = Components of the \u201c{1}\u201d name are inconsistent with those of the name previously binded in \u201c{0}\u201d data store. -MissingSchemeInURI_1 = Missing scheme in \u201c{0}\u201d URI. -ProcessingExecutedOn_1 = Processing executed on {0}. -ResourceIdentifierCollision_2 = More than one resource have the \u201c{1}\u201d identifier in the \u201c{0}\u201d data store. -ResourceNotFound_2 = No resource found for the \u201c{1}\u201d identifier in the \u201c{0}\u201d data store. -ShallBeDeclaredBefore_2 = The \u201c{1}\u201d element must be declared before \u201c{0}\u201d. -StoreIsReadOnly = Write operations are not supported. -StreamIsForwardOnly_1 = Can not move backward in the \u201c{0}\u201d stream. -StreamIsNotReadable_1 = Stream \u201c{0}\u201d is not readable. -StreamIsNotWritable_1 = Stream \u201c{0}\u201d is not writable. -StreamIsReadOnce_1 = The \u201c{0}\u201d data store can be read only once. -StreamIsWriteOnce_1 = Can not modify previously written data in \u201c{0}\u201d. -UndefinedParameter_2 = Can not open {0} data store without \u201c{1}\u201d parameter. -UnknownFormatFor_1 = Format of \u201c{0}\u201d is not recognized. + +Code = Code +Description = Description +CRS = CRS +LongitudeFirst = Logitude first +AxisConvention = Axis convention Copied: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources_fr.properties (from r1807728, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties) URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources_fr.properties?p2=sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources_fr.properties&p1=sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties&r1=1807728&r2=1807778&rev=1807778&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties [ISO-8859-1] (original) +++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/Resources_fr.properties [ISO-8859-1] Fri Sep 8 15:37:30 2017 @@ -16,7 +16,7 @@ # # -# Resources in this file are for "sis-netcdf" usage only and should not be used by any other module. +# Resources in this file are for "sis-javafx" usage only and should not be used by any other module. # For resources shared by all modules in the Apache SIS project, see "org.apache.sis.util.resources" package. # # Punctuation rules in French (source: http://unicode.org/udhr/n/notes_fra.html) @@ -24,31 +24,9 @@ # U+202F NARROW NO-BREAK SPACE before ; ! and ? # U+00A0 NO-BREAK SPACE before : # -AmbiguousName_4 = Le nom \u00ab\u202f{3}\u202f\u00bb est ambigu\u00eb car il peut \u00eatre interpr\u00e9t\u00e9 aussi bien comme \u00ab\u202f{1}\u202f\u00bb ou \u00ab\u202f{2}\u202f\u00bb dans le contexte des donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb. -CanNotReadFile_2 = Ne peut pas lire \u00ab\u202f{1}\u202f\u00bb comme un fichier au format {0}. -CanNotReadFile_3 = Ne peut pas lire la ligne {2} de \u00ab\u202f{1}\u202f\u00bb comme une partie d\u2019un fichier au format {0}. -CanNotReadFile_4 = Ne peut pas lire la ligne {2} (apr\u00e8s la colonne {3}) de \u00ab\u202f{1}\u202f\u00bb comme une partie d\u2019un fichier au format {0}. -ClosedReader_1 = Ce lecteur {0} est ferm\u00e9. -ClosedWriter_1 = Cet encodeur {0} est ferm\u00e9. -ConcurrentRead_1 = Une ou plusieurs op\u00e9rations de lecture sont en cours sur les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb. -ConcurrentWrite_1 = Une op\u00e9ration d\u2019\u00e9criture est en cours sur les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb. -ExcessiveStringSize_3 = La cha\u00eene de caract\u00e8res dans le fichier \u00ab\u202f{0}\u202f\u00bb est trop longue. La cha\u00eene fait {2} caract\u00e8res alors que la limite est {1}. -FeatureAlreadyPresent_2 = Une entit\u00e9 nomm\u00e9e \u00ab\u202f{1}\u202f\u00bb est d\u00e9j\u00e0 pr\u00e9sente dans les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb. -FeatureNotFound_2 = L\u2019entit\u00e9 \u00ab\u202f{1}\u202f\u00bb n\u2019est pas \u00e9t\u00e9 trouv\u00e9e dans les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb. -IllegalFeatureType_2 = Le format {0} ne stocke pas de donn\u00e9es de type \u00ab\u202f{1}\u202f\u00bb. -IllegalInputTypeForReader_2 = Le lecteur {0} n\u2019accepte pas des entr\u00e9s de type \u2018{1}\u2019. -IllegalOutputTypeForWriter_2 = Le l\u2019encodeur {0} n\u2019accepte pas des sorties de type \u2018{1}\u2019. -InconsistentNameComponents_2 = Les \u00e9l\u00e9ments qui composent le nom \u00ab\u202f{1}\u202f\u00bb ne sont pas coh\u00e9rents avec ceux du nom qui avait \u00e9t\u00e9 pr\u00e9c\u00e9demment li\u00e9 dans les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb. -MissingSchemeInURI_1 = Il manque le sch\u00e9ma dans l\u2019URI \u00ab\u202f{0}\u202f\u00bb. -ProcessingExecutedOn_1 = Traitement ex\u00e9cut\u00e9 sur {0}. -ResourceIdentifierCollision_2 = Plusieurs ressources utilisent l\u2019identifiant \u00ab\u202f{1}\u202f\u00bb dans les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb. -ResourceNotFound_2 = Aucune ressource n\u2019a \u00e9t\u00e9 trouv\u00e9e pour l\u2019identifiant \u00ab\u202f{1}\u202f\u00bb dans les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb. -ShallBeDeclaredBefore_2 = L\u2019\u00e9l\u00e9ment \u00ab\u202f{1}\u202f\u00bb doit \u00eatre d\u00e9clar\u00e9 avant \u00ab\u202f{0}\u202f\u00bb. -StoreIsReadOnly = Les op\u00e9rations d\u2019\u00e9criture ne sont pas support\u00e9es. -StreamIsForwardOnly_1 = Ne peut pas reculer dans le flux de donn\u00e9es \u00ab\u202f{0}\u202f\u00bb. -StreamIsNotReadable_1 = Les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb ne sont pas accessibles en lecture. -StreamIsNotWritable_1 = Le flux de donn\u00e9es \u00ab\u202f{0}\u202f\u00bb ne g\u00e8re pas les \u00e9critures. -StreamIsReadOnce_1 = Les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb ne peuvent \u00eatre lues qu\u2019une seule fois. -StreamIsWriteOnce_1 = Ne peut pas revenir sur les donn\u00e9es d\u00e9j\u00e0 \u00e9crites dans \u00ab\u202f{0}\u202f\u00bb. -UndefinedParameter_2 = Ne peut pas ouvrir une source de donn\u00e9es {0} sans le param\u00e8tre \u00ab\u202f{1}\u202f\u00bb. -UnknownFormatFor_1 = Le format de \u00ab\u202f{0}\u202f\u00bb n\u2019est pas reconnu. + +Code = Code +Description = Description +CRS = CRS +LongitudeFirst = Longitude en premier +AxisConvention = Convention Added: 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/crs/CRSButton.java?rev=1807778&view=auto ============================================================================== --- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSButton.java (added) +++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSButton.java Fri Sep 8 15:37:30 2017 @@ -0,0 +1,79 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.gui.crs; + +import javafx.beans.property.ObjectProperty; +import javafx.beans.property.SimpleObjectProperty; +import javafx.beans.value.ObservableValue; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.control.Button; +import javafx.scene.image.ImageView; +import org.opengis.referencing.crs.CoordinateReferenceSystem; + +/** + * Widget button used to select a {@link CoordinateReferenceSystem}. + * + * + * @author Johann Sorel (Geomatys) + * @version 0.8 + * @since 0.8 + * @module + */ +public class CRSButton extends Button{ + + private final ObjectProperty<CoordinateReferenceSystem> crsProperty = new SimpleObjectProperty<>(); + + /** + * Create a new CRSButton with no {@link CoordinateReferenceSystem} defined. + */ + public CRSButton() { + setText("-"); + + setOnAction(new EventHandler<ActionEvent>() { + @Override + public void handle(ActionEvent event) { + final CoordinateReferenceSystem crs = CRSChooser.showDialog(CRSButton.this, crsProperty.get()); + crsProperty.set(crs); + } + }); + + //update button text when needed + crsProperty.addListener((ObservableValue<? extends CoordinateReferenceSystem> observable, + CoordinateReferenceSystem oldValue, CoordinateReferenceSystem newValue) -> { + if (newValue!=null) { + setText(newValue.getName().toString()); + setGraphic(new ImageView(CRSTable.getIcon(newValue))); + } else { + setText(" - "); + setGraphic(null); + } + }); + } + + /** + * Returns the property containing the edited {@link CoordinateReferenceSystem}. + * This property can be modified and will send events. + * It can be used with JavaFx binding operations. + * + * @return Property containing the edited {@link CoordinateReferenceSystem} + */ + public ObjectProperty<CoordinateReferenceSystem> crsProperty() { + return crsProperty; + } + +} Added: 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/crs/CRSChooser.java?rev=1807778&view=auto ============================================================================== --- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSChooser.java (added) +++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSChooser.java Fri Sep 8 15:37:30 2017 @@ -0,0 +1,155 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.gui.crs; + +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; +import javafx.scene.control.CheckBox; +import javafx.scene.control.ChoiceBox; +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.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 + * @module + */ +public class CRSChooser extends BorderPane { + + @FXML + private CheckBox uiLongFirst; + @FXML + private CheckBox uiAxisConv; + @FXML + private BorderPane uiPane; + @FXML + private TextField uiSearch; + @FXML + private ChoiceBox<AxesConvention> uiChoice; + + private CRSTable uiTable; + + private final ObjectProperty<CoordinateReferenceSystem> crsProperty = new SimpleObjectProperty<>(); + private boolean updateText; + + /** + * 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()); + } + }); + + uiTable = new CRSTable(); + uiPane.setCenter(uiTable); + + uiTable.crsProperty().bindBidirectional(crsProperty); + + crsProperty.addListener((ObservableValue<? extends CoordinateReferenceSystem> observable, + CoordinateReferenceSystem oldValue, CoordinateReferenceSystem newValue) -> { + uiTable.crsProperty().set(newValue); + if (newValue != null) { + updateText = true; + uiSearch.setText(newValue.getName().toString()); + updateText = false; + } + }); + + uiChoice.setItems(FXCollections.observableArrayList(AxesConvention.values())); + + } + + public 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); + if (uiLongFirst.isSelected()) { + crs = AbstractCRS.castOrCopy(crs).forConvention(AxesConvention.RIGHT_HANDED); + } + } + } catch (FactoryException ex) {/*no important*/} + + //fix axes convention + if (uiAxisConv.isSelected() && crs instanceof DefaultGeographicCRS && uiChoice.getValue() != null) { + crs = ((DefaultGeographicCRS) crs).forConvention(uiChoice.getValue()); + } + + return crs; + } + + /** + * Returns the property containing the edited {@link CoordinateReferenceSystem}. + * This property can be modified and will send events. + * It can be used with JavaFx binding operations. + * + * @return Property containing the edited {@link CoordinateReferenceSystem} + */ + public ObjectProperty<CoordinateReferenceSystem> crsProperty(){ + return crsProperty; + } + + /** + * Show a modal dialog to select a {@link CoordinateReferenceSystem}. + * + * @param parent parent frame of widget. + * @param crs {@link CoordinateReferenceSystem} to edit. + * @return modified {@link CoordinateReferenceSystem}. + */ + 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); + final DialogPane pane = alert.getDialogPane(); + pane.setContent(chooser); + alert.getButtonTypes().setAll(ButtonType.OK,ButtonType.CANCEL); + alert.setResizable(true); + final ButtonType res = alert.showAndWait().orElse(ButtonType.CANCEL); + return res == ButtonType.CANCEL ? null : chooser.getCorrectedCRS(); + } + +} Added: 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/crs/CRSTable.java?rev=1807778&view=auto ============================================================================== --- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSTable.java (added) +++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/CRSTable.java Fri Sep 8 15:37:30 2017 @@ -0,0 +1,340 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.gui.crs; + +import java.awt.Color; +import java.awt.Dimension; +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; +import javafx.collections.FXCollections; +import javafx.collections.ListChangeListener; +import javafx.collections.ObservableList; +import javafx.event.EventHandler; +import javafx.geometry.Insets; +import javafx.scene.control.Label; +import javafx.scene.control.ProgressIndicator; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.SelectionMode; +import javafx.scene.control.TableCell; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TablePosition; +import javafx.scene.control.TableView; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.input.MouseEvent; +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.FontGlyphs; +import org.apache.sis.internal.gui.JavaFxUtilities; +import org.apache.sis.io.wkt.FormattableObject; +import org.apache.sis.metadata.iso.citation.Citations; +import org.opengis.referencing.IdentifiedObject; +import org.opengis.referencing.crs.CRSAuthorityFactory; +import org.opengis.referencing.crs.CoordinateReferenceSystem; +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 + * @module + */ +public 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 final ObjectProperty<CoordinateReferenceSystem> crsProperty = new SimpleObjectProperty<>(); + private final TableView<Code> uiTable = new TableView<>(); + + private List<Code> allValues; + + public CRSTable(){ + uiTable.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); + setContent(uiTable); + setFitToHeight(true); + setFitToWidth(true); + + //add a loader while we load datas + final ProgressIndicator loading = new ProgressIndicator(); + loading.setMaxWidth(60); + loading.setMaxHeight(60); + loading.setBackground(new Background(new BackgroundFill(new javafx.scene.paint.Color(0, 0, 0, 0), CornerRadii.EMPTY, Insets.EMPTY))); + loading.setProgress(-1); + uiTable.setPlaceholder(loading); + uiTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); + uiTable.setTableMenuButtonVisible(false); + + uiTable.getSelectionModel().getSelectedCells().addListener(new ListChangeListener<TablePosition>() { + @Override + public void onChanged(ListChangeListener.Change<? extends TablePosition> c) { + final ObservableList<TablePosition> cells = uiTable.getSelectionModel().getSelectedCells(); + if (!cells.isEmpty()) { + final TablePosition cell = cells.get(0); + final Code code = uiTable.getItems().get(cell.getRow()); + try { + crsProperty.set((CoordinateReferenceSystem) code.createObject()); + } catch (FactoryException ex) { + JavaFxUtilities.LOGGER.log(Level.INFO,ex.getMessage(),ex); + } + } + } + }); + + uiTable.getColumns().add(new TypeColumn()); + uiTable.getColumns().add(new CodeColumn()); + uiTable.getColumns().add(new DescColumn()); + uiTable.getColumns().add(new WKTColumn()); + + + //load list + new Thread(){ + @Override + public void run() { + try { + allValues = getCodes(); + Platform.runLater(() -> { + uiTable.setItems(FXCollections.observableArrayList(allValues)); + uiTable.setPlaceholder(new Label("")); + }); + } catch (FactoryException ex) { + JavaFxUtilities.LOGGER.log(Level.WARNING,ex.getMessage(),ex); + } + } + }.start(); + + } + + public ObjectProperty<CoordinateReferenceSystem> crsProperty(){ + return crsProperty; + } + + public void searchCRS(final String searchword){ + filter(searchword); + } + + /** + * 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 + * "Search" button. + * + * @param keywords space-separated list of keywords to look for. + */ + private void filter(String keywords) { + List<Code> model = allValues; + if (keywords != null) { + final Locale locale = Locale.getDefault(); + keywords = keywords.toLowerCase(locale).trim(); + final String[] tokens = keywords.split("\\s+"); + if (tokens.length != 0) { + model = new ArrayList<>(); + scan: + for (Code code : allValues) { + final String name = code.toString().toLowerCase(locale); + for (int j=0; j<tokens.length; j++) { + if (!name.contains(tokens[j])) { + continue scan; + } + } + model.add(code); + } + } + } + uiTable.getItems().setAll(model); + } + + /** + * Returns a collection containing only the factories of the specified authority. + */ + private static Collection<CRSAuthorityFactory> filter( + final Collection<? extends CRSAuthorityFactory> factories, final String authority){ + final List<CRSAuthorityFactory> filtered = new ArrayList<>(); + for (final CRSAuthorityFactory factory : factories) { + if (Citations.identifierMatches(factory.getAuthority(), authority)) { + filtered.add(factory); + } + } + return filtered; + } + + private List<Code> getCodes() throws FactoryException{ + final CRSAuthorityFactory factory = org.apache.sis.referencing.CRS.getAuthorityFactory(null); + final Set<String> strs = factory.getAuthorityCodes(CoordinateReferenceSystem.class); + final List<Code> codes = new ArrayList<>(); + for (String str : strs) { + codes.add(new Code(factory, str)); + } + return codes; + } + + static Image getIcon(IdentifiedObject obj) { + Image icon = ICON_UNKNOWNED; + if (obj instanceof GeographicCRS) { + icon = ICON_GEO; + } else if (obj instanceof ProjectedCRS) { + final ProjectedCRS pcrs = (ProjectedCRS) obj; + final Projection proj = pcrs.getConversionFromBase(); + + if (String.valueOf(proj.getName()).toLowerCase().contains("utm")) { + icon = ICON_UTM; + } else if (proj instanceof ConicProjection) { + icon = ICON_CONIC; + } else if (proj instanceof CylindricalProjection) { + icon = ICON_SQUARE; + } else if (proj instanceof PlanarProjection) { + icon = ICON_STEREO; + } else { + icon = ICON_SQUARE; + } + } else { + icon = ICON_SQUARE; + } + return icon; + } + + private static class TypeColumn extends TableColumn<Code, Code> { + + public TypeColumn() { + setEditable(false); + setPrefWidth(30); + setMinWidth(30); + setMaxWidth(30); + setCellValueFactory((CellDataFeatures<Code, Code> param) -> new SimpleObjectProperty<>(param.getValue())); + setCellFactory(new Callback<TableColumn<Code, Code>, TableCell<Code, Code>>() { + + @Override + public TableCell<Code, Code> call(TableColumn<Code, Code> param) { + return new TableCell<Code,Code>(){ + @Override + protected void updateItem(Code item, boolean empty) { + super.updateItem(item, empty); + setGraphic(null); + if (item!=null){ + Image icon = ICON_UNKNOWNED; + try { + final IdentifiedObject obj = item.createObject(); + icon = getIcon(obj); + } catch (FactoryException ex) { + JavaFxUtilities.LOGGER.log(Level.INFO, ex.getMessage(),ex); + } + setGraphic(new ImageView(icon)); + } + } + }; + } + }); + } + + } + + private static class CodeColumn extends TableColumn<Code, String> { + + public CodeColumn() { + super(Resources.format(Resources.Keys.Code)); + setEditable(false); + setPrefWidth(150); + setCellValueFactory((TableColumn.CellDataFeatures<Code, String> param) -> new SimpleObjectProperty<>(param.getValue().code)); + } + + } + + private static class DescColumn extends TableColumn<Code, String> { + + public DescColumn() { + super(Resources.format(Resources.Keys.Description)); + setEditable(false); + setCellValueFactory((TableColumn.CellDataFeatures<Code, String> param) -> new SimpleObjectProperty<>(param.getValue().getDescription())); + } + + } + + private static class WKTColumn extends TableColumn<Code, Code> { + + private static final Image ICON = FontGlyphs.createImage("\uE873",16,COLOR); + + public WKTColumn() { + super(""); + setEditable(false); + setPrefWidth(26); + setMinWidth(26); + setMaxWidth(26); + setCellValueFactory((CellDataFeatures<Code, Code> param) -> new SimpleObjectProperty<>(param.getValue())); + setCellFactory(new Callback<TableColumn<Code, Code>, TableCell<Code, Code>>() { + + @Override + public TableCell<Code, Code> call(TableColumn<Code, Code> param) { + return new TableCell<Code,Code>(){ + + { + setOnMouseClicked(new EventHandler<MouseEvent>() { + @Override + public void handle(MouseEvent event) { + final Code item = getItem(); + if (item!=null) { + try { + final IdentifiedObject obj = getItem().createObject(); + if (obj instanceof FormattableObject) { + FormattableObjectPane.showDialog(this, (FormattableObject) obj); + } + } catch (FactoryException ex) { + JavaFxUtilities.LOGGER.log(Level.INFO,ex.getMessage(),ex); + } + } + } + }); + } + + @Override + protected void updateItem(Code item, boolean empty) { + super.updateItem(item, empty); + if (item !=null && !empty) { + setGraphic(new ImageView(ICON)); + } else { + setGraphic(null); + } + } + }; + } + }); + } + + } + +} Added: 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/crs/Code.java?rev=1807778&view=auto ============================================================================== --- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/Code.java (added) +++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/Code.java Fri Sep 8 15:37:30 2017 @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.gui.crs; + +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}. + * + * @author Martin Desruisseaux (IRD) + * @version 0.8 + * @since 0.8 + * @module + */ +final class Code { + + /** + * The authority code. + */ + public final String code; + + /** + * The CRS object description for the {@linkplain #code}. + * Will be extracted only when first needed. + */ + 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 + * to do its work if possible. + */ + private final AuthorityFactory factory; + + /** + * 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); + this.factory = factory; + this.code = code; + } + + /** + * Create the Object identified by code. + * + * @return IdentifiedObject + * @throws FactoryException + */ + public 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(); + } catch (FactoryException e) { + description = e.getLocalizedMessage(); + } + return description; + } + + /** + * Returns the name for this code. + * + * @todo Maybe we should use the widget Locale when invoking InternationalString.toString(...). + */ + @Override + public String toString() { + if (name == null) { + name = code + " - "+getDescription(); + } + return name; + } +} Added: 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/crs/FormattableObjectPane.java?rev=1807778&view=auto ============================================================================== --- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/FormattableObjectPane.java (added) +++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/crs/FormattableObjectPane.java Fri Sep 8 15:37:30 2017 @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.gui.crs; + +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.collections.FXCollections; +import javafx.scene.control.Alert; +import javafx.scene.control.ButtonType; +import javafx.scene.control.ChoiceBox; +import javafx.scene.control.DialogPane; +import javafx.scene.control.TextArea; +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 + * @module + */ +class FormattableObjectPane extends BorderPane { + + private final ChoiceBox<Convention> choice = new ChoiceBox<>(FXCollections.observableArrayList(Convention.values())); + private final TextArea text = new TextArea(); + + public FormattableObjectPane(final FormattableObject obj) { + setTop(choice); + setCenter(text); + + choice.valueProperty().addListener(new ChangeListener<Convention>() { + @Override + public void changed(ObservableValue<? extends Convention> observable, Convention oldValue, Convention newValue) { + text.setText(obj.toString(newValue)); + } + }); + choice.getSelectionModel().select(Convention.WKT1); + } + + public static void showDialog(Object parent, FormattableObject candidate){ + final FormattableObjectPane chooser = new FormattableObjectPane(candidate); + + final Alert alert = new Alert(Alert.AlertType.NONE); + final DialogPane pane = alert.getDialogPane(); + pane.setContent(chooser); + alert.getButtonTypes().setAll(ButtonType.OK); + alert.setResizable(true); + alert.showAndWait(); + } + +} Modified: sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceTree.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceTree.java?rev=1807778&r1=1807777&r2=1807778&view=diff ============================================================================== --- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceTree.java [UTF-8] (original) +++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ResourceTree.java [UTF-8] Fri Sep 8 15:37:30 2017 @@ -24,7 +24,6 @@ import java.util.List; import javafx.beans.property.SimpleObjectProperty; import javafx.beans.value.ObservableValue; import javafx.collections.ObservableList; -import javafx.embed.swing.SwingFXUtils; import javafx.geometry.Pos; import javafx.scene.control.ContentDisplay; import javafx.scene.control.TreeItem; @@ -57,10 +56,10 @@ import org.opengis.metadata.identificati */ public class ResourceTree extends TreeTableView<Resource> { - private static final Image ICON_VECTOR = SwingFXUtils.toFXImage(FontGlyphs.createImage("\uE922",18,Color.GRAY),null); - private static final Image ICON_FOLDER = SwingFXUtils.toFXImage(FontGlyphs.createImage("\uE2C8",18,Color.GRAY),null); - private static final Image ICON_STORE = SwingFXUtils.toFXImage(FontGlyphs.createImage("\uE2C7",18,Color.GRAY),null); - private static final Image ICON_OTHER = SwingFXUtils.toFXImage(FontGlyphs.createImage("\uE24D",18,Color.GRAY),null); + private static final Image ICON_VECTOR = FontGlyphs.createImage("\uE922",18,Color.GRAY); + private static final Image ICON_FOLDER = FontGlyphs.createImage("\uE2C8",18,Color.GRAY); + private static final Image ICON_STORE = FontGlyphs.createImage("\uE2C7",18,Color.GRAY); + private static final Image ICON_OTHER = FontGlyphs.createImage("\uE24D",18,Color.GRAY); public ResourceTree() { getColumns().add(new ResourceNameColumn()); 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=1807778&r1=1807777&r2=1807778&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] Fri Sep 8 15:37:30 2017 @@ -26,6 +26,8 @@ import java.awt.RenderingHints; import java.awt.geom.RoundRectangle2D; import java.awt.image.BufferedImage; import java.io.InputStream; +import javafx.embed.swing.SwingFXUtils; +import javafx.scene.image.Image; import org.apache.sis.util.ArgumentChecks; /** @@ -62,8 +64,8 @@ public final class FontGlyphs { * @param textColor glyph color * @return glyph image */ - public static BufferedImage createImage(String text, float size, Color textColor) { - return createImage(text, textColor, FONT.deriveFont(size), null, null, true, false); + public static Image createImage(String text, float size, Color textColor) { + return SwingFXUtils.toFXImage(createImage(text, textColor, FONT.deriveFont(size), null, null, true, false),null); } private static BufferedImage createImage(String text, Color textColor, Font font, Color bgColor, Insets insets, final boolean squareWanted, final boolean removeLeading) { Added: 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/JavaFxUtilities.java?rev=1807778&view=auto ============================================================================== --- sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/JavaFxUtilities.java (added) +++ sis/branches/JDK8/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/JavaFxUtilities.java Fri Sep 8 15:37:30 2017 @@ -0,0 +1,98 @@ +/* + * 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); + } + } + +} Added: sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/CRSChooser.fxml URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/CRSChooser.fxml?rev=1807778&view=auto ============================================================================== --- sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/CRSChooser.fxml (added) +++ sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/CRSChooser.fxml Fri Sep 8 15:37:30 2017 @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.*?> +<?import java.lang.*?> +<?import javafx.scene.control.*?> +<?import javafx.scene.layout.*?> + +<fx:root maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" type="BorderPane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> + <top> + <GridPane hgap="10.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" vgap="10.0" BorderPane.alignment="CENTER"> + <columnConstraints> + <ColumnConstraints hgrow="NEVER" /> + <ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" /> + <ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="10.0" prefWidth="100.0" /> + </columnConstraints> + <rowConstraints> + <RowConstraints vgrow="NEVER" /> + <RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="NEVER" /> + <RowConstraints vgrow="NEVER" /> + </rowConstraints> + <children> + <Label styleClass="property-key" text="%CRS" GridPane.rowSpan="2" /> + <CheckBox fx:id="uiLongFirst" maxWidth="1.7976931348623157E308" mnemonicParsing="false" styleClass="property-key" text="%LongitudeFirst" GridPane.columnIndex="1" GridPane.columnSpan="2" GridPane.halignment="LEFT" /> + <TextField fx:id="uiSearch" GridPane.columnSpan="3" GridPane.rowIndex="2" /> + <CheckBox fx:id="uiAxisConv" mnemonicParsing="false" text="%AxisConvention" GridPane.columnIndex="1" GridPane.rowIndex="1" /> + <ChoiceBox fx:id="uiChoice" prefWidth="150.0" GridPane.columnIndex="2" GridPane.rowIndex="1" /> + </children> + <BorderPane.margin> + <Insets bottom="10.0" left="10.0" right="10.0" /> + </BorderPane.margin> + </GridPane> + </top> + <center> + <BorderPane fx:id="uiPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" BorderPane.alignment="CENTER" /> + </center> +</fx:root> Added: sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_conic.png URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_conic.png?rev=1807778&view=auto ============================================================================== Binary file - no diff available. Propchange: sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_conic.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_geo.png URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_geo.png?rev=1807778&view=auto ============================================================================== Binary file - no diff available. Propchange: sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_geo.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_square.png URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_square.png?rev=1807778&view=auto ============================================================================== Binary file - no diff available. Propchange: sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_square.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_stereo.png URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_stereo.png?rev=1807778&view=auto ============================================================================== Binary file - no diff available. Propchange: sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_stereo.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_utm.png URL: http://svn.apache.org/viewvc/sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_utm.png?rev=1807778&view=auto ============================================================================== Binary file - no diff available. Propchange: sis/branches/JDK8/application/sis-javafx/src/main/resources/org/apache/sis/gui/crs/proj_utm.png ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream