This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit 6289d4278ca731eb96d82d190181c7e74cb5291f Author: Martin Desruisseaux <[email protected]> AuthorDate: Sat Oct 10 23:46:05 2026 +0200 Post-release cleanup: remove some deprecated methods. --- .../org.apache.sis.feature/main/module-info.java | 2 +- .../apache/sis/coverage/grid/GridCRSBuilder.java | 10 +- .../org/apache/sis/coverage/grid/GridGeometry.java | 45 +- .../org/apache/sis/coverage/grid/package-info.java | 2 +- .../org.apache.sis.metadata/main/module-info.java | 2 +- .../org/apache/sis/metadata/AbstractMetadata.java | 11 - .../org/apache/sis/metadata/MetadataStandard.java | 22 - .../main/org/apache/sis/metadata/package-info.java | 2 +- .../main/module-info.java | 2 +- .../sis/referencing/AbstractIdentifiedObject.java | 12 - .../operation/AbstractCoordinateOperation.java | 5 +- .../referencing/operation/DefaultConversion.java | 29 +- .../sis/referencing/operation/package-info.java | 2 +- .../org/apache/sis/referencing/package-info.java | 2 +- .../org.apache.sis.storage/main/module-info.java | 2 +- .../main/org/apache/sis/storage/DataOptionKey.java | 42 -- .../apache/sis/storage/GridCoverageResource.java | 20 +- .../main/org/apache/sis/storage/package-info.java | 2 +- .../src/org.apache.sis.gui/main/module-info.java | 2 +- .../apache/sis/gui/controls/SyncWindowList.java | 250 ----------- .../apache/sis/gui/coverage/CoverageExplorer.java | 102 ----- .../org/apache/sis/gui/dataset/WindowHandler.java | 474 --------------------- .../org/apache/sis/gui/dataset/WindowManager.java | 141 ------ .../org/apache/sis/gui/dataset/package-info.java | 2 +- .../org/apache/sis/gui/internal/PrivateAccess.java | 52 --- .../org/apache/sis/gui/internal/ToolbarButton.java | 115 ----- .../main/org/apache/sis/gui/map/StatusBar.java | 16 +- .../main/org/apache/sis/gui/map/package-info.java | 2 +- 28 files changed, 18 insertions(+), 1352 deletions(-) diff --git a/endorsed/src/org.apache.sis.feature/main/module-info.java b/endorsed/src/org.apache.sis.feature/main/module-info.java index 2a7d9ef18f..9ef598684a 100644 --- a/endorsed/src/org.apache.sis.feature/main/module-info.java +++ b/endorsed/src/org.apache.sis.feature/main/module-info.java @@ -20,7 +20,7 @@ * * @author Johann Sorel (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 1.7 + * @version 1.8 * @since 0.5 */ module org.apache.sis.feature { diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCRSBuilder.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCRSBuilder.java index b123fcbb71..abbe468b42 100644 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCRSBuilder.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridCRSBuilder.java @@ -213,14 +213,6 @@ final class GridCRSBuilder extends ReferencingFactoryContainer { */ private static final Locale LOCALE = null; - /** - * Whether to force {@link DerivedCRS} instances. - * - * @deprecated to be removed after {@link GridGeometry#createImageCRS} has been removed. - */ - @Deprecated(forRemoval = true) - boolean derived; - /** * Creates a new helper class for building a grid coordinate reference system. */ @@ -260,7 +252,7 @@ final class GridCRSBuilder extends ReferencingFactoryContainer { properties.put(ObjectDomain.DOMAIN_OF_VALIDITY_KEY, new DefaultExtent(null, domain, null, null)); }); fullGrid = grid; - if (derived || grid.isDefined(GridGeometry.CRS | GridGeometry.GRID_TO_CRS)) try { + if (grid.isDefined(GridGeometry.CRS | GridGeometry.GRID_TO_CRS)) try { separator = new TransformSeparator(grid.getGridToCRS(anchor).inverse()); return forComponent(name, grid.getCoordinateReferenceSystem(), 0, 0); } catch (NoninvertibleTransformException e) { diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridGeometry.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridGeometry.java index fc71c92cba..047f91b300 100644 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridGeometry.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridGeometry.java @@ -144,7 +144,7 @@ import org.opengis.coordinate.MismatchedDimensionException; * * @author Martin Desruisseaux (IRD, Geomatys) * @author Johann Sorel (Geomatys) - * @version 1.7 + * @version 1.8 * @since 1.0 */ public class GridGeometry implements LenientComparable, Serializable { @@ -1899,49 +1899,6 @@ public class GridGeometry implements LenientComparable, Serializable { return new GridGeometry(extent, tr, tr, env, newResolution, 0); } - /** - * Creates a one-, two- or three-dimensional coordinate reference system for cell indices in the grid. - * This method returns a CRS which is derived from the "real world" CRS or a subset of it. - * If the "real world" CRS is an instance of {@link org.opengis.referencing.crs.SingleCRS}, - * then the derived CRS has the following properties: - * - * <ul> - * <li>{@link DerivedCRS#getBaseCRS()} is {@link #getCoordinateReferenceSystem()}.</li> - * <li>{@link DerivedCRS#getConversionFromBase()} is the inverse of {@link #getGridToCRS(PixelInCell)}.</li> - * </ul> - * - * Otherwise if the "real world" CRS is an instance of {@link org.opengis.referencing.crs.CompoundCRS}, - * then only the first {@link org.opengis.referencing.crs.SingleCRS} (the head) is used. - * This is usually (but not necessarily) the horizontal component of the spatial CRS. - * The result is usually two-dimensional, but 1 and 3 dimensions are also possible. - * - * <p>Because of above relationship, it is possible to use the derived CRS in a chain of operations - * with (for example) {@link org.apache.sis.referencing.CRS#findOperation CRS.findOperation(…)}.</p> - * - * @param name name of the CRS to create. - * @param anchor the cell part to map (center or corner). - * @return a derived CRS for coordinates (cell indices) associated with the grid extent. - * @throws IncompleteGridGeometryException if the CRS or "grid to CRS" transform is missing. - * - * @since 1.3 - * - * @deprecated Replaced by the more generic {@link #createGridCRS(Identifier, PixelInCell)} method. - */ - @Deprecated(since = "1.7", forRemoval = true) - public DerivedCRS createImageCRS(final String name, final PixelInCell anchor) { - ArgumentChecks.ensureNonEmpty("name", name); - final var id = new org.apache.sis.referencing.ImmutableIdentifier(null, null, name); - try { - // Note: the `true` boolean argument can be removed after the removal of this method. - var builder = new GridCRSBuilder(); - builder.derived = true; - final CoordinateReferenceSystem crs = builder.forCoverage(this, anchor, id); - return (DerivedCRS) org.apache.sis.referencing.CRS.getSingleComponents(crs).get(0); - } catch (FactoryException e) { - throw new BackingStoreException(e); - } - } - /** * Creates a coordinate reference system for cell indices in the grid. * If the cell indices can be related to the real world <abbr>CRS</abbr> diff --git a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/package-info.java b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/package-info.java index 0c0702f0f8..2338e6cf36 100644 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/package-info.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/package-info.java @@ -41,7 +41,7 @@ * @author Martin Desruisseaux (Geomatys) * @author Johann Sorel (Geomatys) * @author Alexis Manin (Geomatys) - * @version 1.7 + * @version 1.8 * @since 1.0 */ package org.apache.sis.coverage.grid; diff --git a/endorsed/src/org.apache.sis.metadata/main/module-info.java b/endorsed/src/org.apache.sis.metadata/main/module-info.java index 202fb514de..2a061a2078 100644 --- a/endorsed/src/org.apache.sis.metadata/main/module-info.java +++ b/endorsed/src/org.apache.sis.metadata/main/module-info.java @@ -23,7 +23,7 @@ * @author Martin Desruisseaux (Geomatys) * @author Cédric Briançon (Geomatys) * @author Cullen Rombach (Image Matters) - * @version 1.6 + * @version 1.8 * @since 0.3 */ module org.apache.sis.metadata { diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/AbstractMetadata.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/AbstractMetadata.java index c0a2b806f1..d5108ecf4a 100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/AbstractMetadata.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/AbstractMetadata.java @@ -154,17 +154,6 @@ public abstract class AbstractMetadata implements LenientComparable, Emptiable { return getStandard().getInterface(getClass()); } - /** - * Returns the metadata interface implemented by this class. - * - * @return the standard interface implemented by this class. - * @deprecated Renamed {@link #getStandardType()} for integration with {@link LenientComparable}. - */ - @Deprecated(since="1.7", forRemoval=true) - public final Class<?> getInterface() { - return org.apache.sis.util.Classes.getRawClass(getStandardType()); - } - /** * Returns {@code true} if this metadata contains only {@code null}, * {@linkplain org.apache.sis.xml.NilObject nil} or empty properties. diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/MetadataStandard.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/MetadataStandard.java index ceb412f4a3..0ce978e491 100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/MetadataStandard.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/MetadataStandard.java @@ -1214,28 +1214,6 @@ public class MetadataStandard implements Serializable { return new TreeTableView(this, metadata, baseType, valuePolicy); } - /** - * Compares the two specified metadata objects for equality. - * The two metadata arguments shall be implementations of a metadata interface defined by - * this {@code MetadataStandard}, otherwise an exception will be thrown. However, the two - * arguments do not need to be instances of the same implementation class - * except for {@link ComparisonMode#STRICT}. - * - * @param metadata1 the first metadata object to compare, or {@code null}. - * @param metadata2 the second metadata object to compare, or {@code null}. - * @param mode the strictness level of the comparison. - * @return {@code true} if the given metadata objects are equal or if the two arguments are {@code null}. - * - * @deprecated Replaced by {@link #equals(Object, Object, Class, ComparisonMode)} because this method - * is ambiguous when one of the given metadata instances implements more than one metadata interface. - */ - @Deprecated(since="1.7", forRemoval=true) - public boolean equals(final Object metadata1, final Object metadata2, final ComparisonMode mode) { - final Boolean equals = equals(metadata1, metadata2, null, mode); - if (equals == null) throw new ClassCastException(); - return equals; - } - /** * Compares the two specified metadata instances for equality. * The two metadata arguments should be implementations of a diff --git a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/package-info.java b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/package-info.java index fc8b17f304..af69e11a8f 100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/package-info.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/package-info.java @@ -120,7 +120,7 @@ * * @author Martin Desruisseaux (IRD, Geomatys) * @author Adrian Custer (Geomatys) - * @version 1.7 + * @version 1.8 * @since 0.3 */ @XmlAccessorType(XmlAccessType.NONE) diff --git a/endorsed/src/org.apache.sis.referencing/main/module-info.java b/endorsed/src/org.apache.sis.referencing/main/module-info.java index 537532e294..3ea3d52884 100644 --- a/endorsed/src/org.apache.sis.referencing/main/module-info.java +++ b/endorsed/src/org.apache.sis.referencing/main/module-info.java @@ -21,7 +21,7 @@ * @author Martin Desruisseaux (Geomatys) * @author Rémi Maréchal (Geomatys) * @author Maxime Gavens (Geomatys) - * @version 1.7 + * @version 1.8 * @since 0.3 */ module org.apache.sis.referencing { diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/AbstractIdentifiedObject.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/AbstractIdentifiedObject.java index e2e6111cbe..e04c584471 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/AbstractIdentifiedObject.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/AbstractIdentifiedObject.java @@ -531,18 +531,6 @@ public class AbstractIdentifiedObject extends FormattableObject implements Ident return IdentifiedObject.class; } - /** - * Returns the GeoAPI interface implemented by this class. - * - * @return the GeoAPI interface implemented by this class. - * @deprecated Renamed {@link #getStandardType()} for integration with {@link LenientComparable}. - */ - @Deprecated(since="1.7", forRemoval=true) - // TODO: make package private. - public final Class<? extends IdentifiedObject> getInterface() { - return Classes.getRawClass(getStandardType()).asSubclass(IdentifiedObject.class); - } - /** * Returns the primary name by which this object is identified. * diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java index d8968ec4d5..5b2c3a7256 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java @@ -493,11 +493,8 @@ check: for (int isTarget=0; ; isTarget++) { // 0 == source check; 1 * When this method returns {@code true}, the source and target CRS are not marshalled in XML documents. * * @return {@code true} if this coordinate operation is for the definition of a derived or projected CRS. - * - * @deprecated Replaced by the {@link DefiningConversion} class. */ - @Deprecated(since = "1.7", forRemoval = true) - public boolean isDefiningConversion() { + private boolean isDefiningConversion() { /* * Trick: we do not need to verify if (this instanceof Conversion) because: * - Only DefaultConversion constructor accepts null source and target CRS. diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java index 48bf31894b..3c9ad8e121 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/DefaultConversion.java @@ -68,7 +68,7 @@ import org.opengis.referencing.crs.DerivedCRS; * by many objects and passed between threads without synchronization. * * @author Martin Desruisseaux (IRD, Geomatys) - * @version 1.7 + * @version 1.8 * * @see DefaultTransformation * @@ -151,33 +151,6 @@ public class DefaultConversion extends AbstractSingleOperation implements Conver ArgumentChecks.ensureNonNull("targetCRS", targetCRS); } - /** - * Creates a defining conversion from the given transform and/or parameters. - * - * @param properties the properties to be given to the identified object. - * @param method the operation method. - * @param transform transform from positions in the source CRS to positions in the target CRS, or {@code null}. - * @param parameters the {@code transform} parameter values, or {@code null}. - * - * @deprecated Moved to the {@link DefiningConversion} subclass. - */ - @Deprecated(since = "1.7", forRemoval = true) - @SuppressWarnings("this-escape") // False positive. - public DefaultConversion(final Map<String,?> properties, - final OperationMethod method, - final MathTransform transform, - final ParameterValueGroup parameters) - { - super(properties, method); - this.transform = transform; - if (transform == null && parameters == null) { - throw new IllegalArgumentException(Resources.forProperties(properties) - .getString(Resources.Keys.UnspecifiedParameterValues)); - } - setParameterValues(parameters, null); - checkDimensions(properties); - } - /** * Creates a new coordinate operation initialized from the given properties. * It is caller's responsibility to set the following fields: diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/package-info.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/package-info.java index ef22720164..c2a9993182 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/package-info.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/operation/package-info.java @@ -72,7 +72,7 @@ * for example by specifying the area of interest. * * @author Martin Desruisseaux (IRD, Geomatys) - * @version 1.7 + * @version 1.8 * @since 0.6 */ @XmlSchema(location = "http://schemas.opengis.net/gml/3.2.1/coordinateOperations.xsd", diff --git a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/package-info.java b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/package-info.java index 151abcdc17..e64ead2434 100644 --- a/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/package-info.java +++ b/endorsed/src/org.apache.sis.referencing/main/org/apache/sis/referencing/package-info.java @@ -94,7 +94,7 @@ * * @author Martin Desruisseaux (IRD, Geomatys) * @author Guilhem Legal (Geomatys) - * @version 1.7 + * @version 1.8 * @since 0.4 */ @XmlSchema(location = "http://schemas.opengis.net/gml/3.2.1/referenceSystems.xsd", diff --git a/endorsed/src/org.apache.sis.storage/main/module-info.java b/endorsed/src/org.apache.sis.storage/main/module-info.java index 024b42f67a..df8b64c70d 100644 --- a/endorsed/src/org.apache.sis.storage/main/module-info.java +++ b/endorsed/src/org.apache.sis.storage/main/module-info.java @@ -20,7 +20,7 @@ * * @author Johann Sorel (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 1.7 + * @version 1.8 * @since 0.3 */ module org.apache.sis.storage { diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/DataOptionKey.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/DataOptionKey.java deleted file mode 100644 index d995be101b..0000000000 --- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/DataOptionKey.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.storage; - - -/** - * Keys in a map of options for configuring the way data are read or written to a storage. - * {@code DataOptionKey} extends {@link OptionKey} with options about features, coverages - * or other kinds of structure that are specific to some data formats. - * - * @author Martin Desruisseaux (Geomatys) - * @version 1.7 - * - * @param <T> the type of option values. - * - * @since 1.0 - * - * @deprecated Merged with {@link OptionKey}× - */ -@Deprecated(since = "1.7", forRemoval = true) -public final class DataOptionKey<T> extends OptionKey<T> { - /** - * Creates a new key of the given name. - */ - private DataOptionKey(final String name, final Class<T> type) { - super(name, type); - } -} diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/GridCoverageResource.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/GridCoverageResource.java index f2eec96621..fd8692de0a 100644 --- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/GridCoverageResource.java +++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/GridCoverageResource.java @@ -42,7 +42,7 @@ import org.apache.sis.util.ArraysExt; * * @author Martin Desruisseaux (Geomatys) * @author Johann Sorel (Geomatys) - * @version 1.7 + * @version 1.8 * @since 1.0 */ public interface GridCoverageResource extends DataSet { @@ -167,24 +167,6 @@ public interface GridCoverageResource extends DataSet { return List.of(); } - /** - * Returns the preferred resolutions ordered from finest to coarsest resolution. - * - * @return preferred resolutions for read operations in this data store, or an empty list if none. - * @throws DataStoreException if an error occurred while reading definitions from the underlying data store. - * - * @since 1.2 - * - * @deprecated Replaced by {@link #getAvailableResolutions()} but with opposite order. - * The new order is more conform to <abbr>OGC</abbr> specifications. - */ - @Deprecated(since = "1.7", forRemoval = true) - default List<double[]> getResolutions() throws DataStoreException { - final var resolutions = new java.util.ArrayList<>(getAvailableResolutions()); - java.util.Collections.reverse(resolutions); - return resolutions; - } - /** * Requests a subset of the coverage. * The filtering can be applied in two aspects: diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/package-info.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/package-info.java index 2a65abf786..1316d39a0d 100644 --- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/package-info.java +++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/package-info.java @@ -24,7 +24,7 @@ * * @author Johann Sorel (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 1.7 + * @version 1.8 * @since 0.3 */ package org.apache.sis.storage; diff --git a/optional/src/org.apache.sis.gui/main/module-info.java b/optional/src/org.apache.sis.gui/main/module-info.java index 576d9f230b..74562d9791 100644 --- a/optional/src/org.apache.sis.gui/main/module-info.java +++ b/optional/src/org.apache.sis.gui/main/module-info.java @@ -21,7 +21,7 @@ * @author Smaniotto Enzo (GSoC) * @author Johann Sorel (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 1.7 + * @version 1.8 * @since 1.1 */ module org.apache.sis.gui { diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/controls/SyncWindowList.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/controls/SyncWindowList.java deleted file mode 100644 index 124efa801f..0000000000 --- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/controls/SyncWindowList.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.gui.controls; - -import java.util.List; -import javafx.collections.ListChangeListener; -import javafx.collections.ObservableList; -import javafx.scene.control.Button; -import javafx.scene.control.TableRow; -import javafx.scene.control.TableView; -import javafx.scene.input.MouseEvent; -import javafx.scene.layout.Priority; -import javafx.scene.layout.Region; -import javafx.scene.layout.VBox; -import javafx.application.Platform; -import org.apache.sis.util.resources.Vocabulary; -import org.apache.sis.util.collection.Containers; -import org.apache.sis.gui.dataset.WindowHandler; -import org.apache.sis.gui.map.MapCanvas; -import org.apache.sis.gui.map.GestureFollower; -import org.apache.sis.gui.internal.Resources; - - -/** - * Provides a widget for listing all available windows and selecting the ones - * on which to replicate gesture events (zoom, pans, <i>etc</i>). - * - * @author Martin Desruisseaux (Geomatys) - */ -@Deprecated(since = "1.7", forRemoval = true) -public final class SyncWindowList extends TabularWidget implements ListChangeListener<WindowHandler> { - /** - * Window containing a {@link MapCanvas} on which to replicate gesture events. - * Gestures are replicated only if {@link #transformEnabled} is {@code true}. - */ - private static final class Link extends GestureFollower { - /** - * The "foreigner" view on which to replicate the gestures. - */ - public final WindowHandler view; - - /** - * Creates a new row for a window on which to replicate gestures. - * - * @param view the "foreigner" view on which to replicate the gesture events. - * @param source the canvas which is the source of zoom, pan or rotation events. - * @param target the canvas on which to apply the changes of zoom, pan or rotation. - */ - private Link(final WindowHandler view, final MapCanvas source, final MapCanvas target) { - super(source, target); - this.view = view; - } - - /** - * Converts the given list of handlers to a list of table rows. - * - * @param added list of new items to put in the table. - * @param addTo where to add the converted items. - * @param owner item to exclude (because the referenced window is itself). - * @param source the canvas for which to replicate the changes of zoom, pan or rotation. - */ - static void wrap(final List<? extends WindowHandler> added, final List<Link> addTo, - final WindowHandler owner, final MapCanvas source) - { - final Link[] items = new Link[added.size()]; - int count = 0; - try { - for (final WindowHandler view : added) { - if (view != owner) { - final MapCanvas target = view.getCanvas().orElse(null); - if (target != null) { - final Link item = new Link(view, source, target);; - items[count++] = item; // Add now for disposing if an exception is thrown. - item.initialize(); // Invoked outside constructor for allowing disposal. - item.cursorEnabled.set(true); - } - } - } - addTo.addAll(Containers.viewAsUnmodifiableList(items, 0, count)); - } catch (Throwable e) { - while (--count >= 0) { - items[--count].dispose(); // Remove listeners for avoiding memory leak. - } - throw e; - } - } - } - - /** - * The table showing values associated with colors. - */ - private final TableView<Link> table; - - /** - * The button for creating a new window. - */ - private final Button newWindow; - - /** - * The view for which to create a list of synchronized windows. - */ - private final WindowHandler owner; - - /** - * The canvas for which to replicate the changes of zoom, pan or rotation. - * Needs to be fetched only when first needed (not at construction time) - * for avoiding a stack overflow. - */ - private MapCanvas source; - - /** - * The component to be returned by {@link #getView()}. - */ - private final VBox content; - - /** - * Creates a new "synchronized windows" widget. - * - * @param owner the view for which to create a list of synchronized windows. - * @param resources localized resources, given because already known by the caller. - * @param vocabulary localized resources, given because already known by the caller - * (those arguments would be removed if this constructor was public API). - */ - @SuppressWarnings({"this-escape", "unchecked"}) - public SyncWindowList(final WindowHandler owner, final Resources resources, final Vocabulary vocabulary) { - this.owner = owner; - table = newTable(); - newWindow = new Button(resources.getString(Resources.Keys.NewWindow)); - newWindow.setMaxWidth(Double.MAX_VALUE); - /* - * The first column contains a checkbox for choosing whether the window should be followed or not. - */ - table.getColumns().setAll( - newBooleanColumn(/* 🔗 (link symbol) */ "\uD83D\uDD17", (cell) -> cell.getValue().transformEnabled), - newStringColumn (vocabulary.getString(Vocabulary.Keys.Title), (cell) -> cell.getValue().view.title)); - table.setRowFactory(SyncWindowList::newRow); - /* - * Build all other widget controls. - */ - newWindow.setOnAction((e) -> owner.duplicate().show()); - VBox.setVgrow(table, Priority.ALWAYS); - VBox.setVgrow(newWindow, Priority.NEVER); - content = new VBox(9, table, newWindow); - /* - * Add listener last when the everything else is successful (because the `this` reference escapes). - * The creation of table item list needs to be done after the caller finished its initialization, - * not now, because invoking`owner.getCanvas()` here create an infinite loop. - */ - Platform.runLater(() -> addAll(owner.manager.windows)); - owner.manager.windows.addListener(this); - } - - /** - * Invoked when `TableView` needs to create a new row for rendering purpose. - * This is the place where to configure each {@code TableRow} instances. - * - * @param table the table which needs a new row. - * @return the new row. - */ - private static TableRow<Link> newRow(final TableView<Link> table) { - final var row = new TableRow<Link>(); - row.addEventFilter(MouseEvent.MOUSE_CLICKED, SyncWindowList::onMouseClicked); - return row; - } - - /** - * Invoked when the user clicked on a cell of the row. We register this listener as a filter, - * e.g. this is invoked before the table row see the event, so we can prevent the event to be - * forwarded to the cell if desired. - */ - private static void onMouseClicked(final MouseEvent event) { - if (event.getClickCount() == 2) { - final TableRow<?> row = (TableRow<?>) event.getSource(); - final Link item = (Link) row.getItem(); - item.view.show(); - event.consume(); - /* - * If the cell was already selected, the first click caused the cell to enter in editing mode - * before the second click is detected. We want to cancel the edition since we moved focus to - * another window. The javadoc for the following method said: "Note: This method will cancel - * editing if the given row value is less than zero and the given column is null." - */ - row.getTableView().edit(-1, null); - } - } - - /** - * Returns the encapsulated JavaFX component to add in a scene graph for making the widget visible. - * The {@code Region} subclass is implementation dependent and may change in any future SIS version. - * - * @return the JavaFX component to insert in a scene graph. - */ - @Override - public Region getView() { - return content; - } - - /** - * Invoked when new items are added or removed in the list of windows. - * - * @param change a description of changes in the list of windows. - */ - @Override - public void onChanged(final Change<? extends WindowHandler> change) { - while (change.next()) { - // Ignore permutations; each table can have its own order. - if (change.wasRemoved()) { - // List of removed items usually has a single element. - final ObservableList<Link> items = table.getItems(); - for (final WindowHandler view : change.getRemoved()) { - for (int i = items.size(); --i >= 0;) { - final Link item = items.get(i); - if (item.view == view) { - items.remove(i); - item.dispose(); - break; - } - } - } - } - if (change.wasAdded()) { - addAll(change.getAddedSubList()); - } - } - } - - /** - * Adds the given window handlers and items in {@link #table}. - */ - private void addAll(final List<? extends WindowHandler> windows) { - if (source == null) { - source = owner.getCanvas().get(); - } - Link.wrap(windows, table.getItems(), owner, source); - } -} diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageExplorer.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageExplorer.java index c4a8bd1bf7..0934d4d37a 100644 --- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageExplorer.java +++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/coverage/CoverageExplorer.java @@ -23,14 +23,10 @@ import java.util.Optional; import java.awt.image.RenderedImage; import javafx.application.Platform; import javafx.beans.DefaultProperty; -import javafx.scene.control.Control; import javafx.scene.control.SplitPane; -import javafx.scene.control.Separator; -import javafx.scene.control.ToggleGroup; import javafx.scene.control.Toggle; import javafx.scene.control.TitledPane; import javafx.scene.layout.Region; -import javafx.event.ActionEvent; import javafx.beans.property.ObjectProperty; import javafx.beans.property.SimpleObjectProperty; import org.opengis.metadata.Identifier; @@ -45,13 +41,10 @@ import org.apache.sis.gui.Widget; import org.apache.sis.gui.map.StatusBar; import org.apache.sis.gui.internal.FontGIS; import org.apache.sis.gui.internal.Resources; -import org.apache.sis.gui.internal.ToolbarButton; import org.apache.sis.gui.internal.NonNullObjectProperty; -import org.apache.sis.gui.internal.PrivateAccess; import org.apache.sis.gui.internal.BackgroundThreads; import org.apache.sis.gui.referencing.RecentReferenceSystems; import static org.apache.sis.gui.internal.LogHandler.LOGGER; -import org.apache.sis.gui.dataset.WindowHandler; /** @@ -224,15 +217,6 @@ public class CoverageExplorer extends Widget { */ private SplitPane content; - /** - * Handler of the window showing this coverage view. This is used for creating new windows. - * Created when first needed for giving to subclasses a chance to complete initialization. - * - * @see #getWindowHandler() - */ - @Deprecated(since = "1.7", forRemoval = true) - private WindowHandler window; - /** * Creates an initially empty explorer with the specified view type. * @@ -256,50 +240,6 @@ public class CoverageExplorer extends Widget { coverageProperty.addListener((p,o,n) -> onPropertySet(null, n, resourceProperty)); } - /** - * Creates an explorer initialized with the same coverage or resource than the given explorer. - * - * @param source the source explorer from which to take the initial coverage or resource. - * - * @since 1.2 - */ - @SuppressWarnings("this-escape") - public CoverageExplorer(final CoverageExplorer source) { - this(source.getViewType()); - window = PrivateAccess.newWindowHandler.apply(source.window, this); - source.getImageRequest().ifPresent(this::setCoverage); - PrivateAccess.finishWindowHandler.accept(window); - if (getViewType() == View.IMAGE) { - getCoverageControls().copyStyling(source.getCoverageControls()); - } - } - - /** - * Returns the handler of the window showing this coverage view. - * Those windows are created when the user clicks on the "New window" button. - * Each window provides the area where data are shown and where the user interacts. - * The window can be a JavaFX top-level window ({@link javafx.stage.Stage}), but not necessarily. - * It may also be a tile in a mosaic of windows. - * - * @return the handler of the window showing this coverage view. - * - * @since 1.3 - * - * @deprecated Replaced by {@link org.apache.sis.gui.map.MapWindows}. - */ - @Deprecated(since = "1.7", forRemoval = true) - public final WindowHandler getWindowHandler() { - assert Platform.isFxApplicationThread(); - /* - * Created when first needed for giving to subclass constructors a chance to complete - * their initialization before `this` reference is passed to `WindowHandler` constructor. - */ - if (window == null) { - window = WindowHandler.create(this); - } - return window; - } - /** * Returns the canvas where the image is shown. * @@ -366,23 +306,6 @@ public class CoverageExplorer extends Widget { * Instead, it will invoke `getDataView(View)` or `getControls(View)` and layout those regions itself. */ if (content == null) { - /* - * Prepare buttons to add on the toolbar. Those buttons are not managed by this class; - * they are managed by org.apache.sis.gui.dataset.WindowHandler. We only declare here - * the text and action for each button. - */ - final ToggleGroup group = new ToggleGroup(); - final Control[] buttons = new Control[View.COUNT + 1]; - final Resources localized = Resources.forLocale(getLocale()); - buttons[0] = new Separator(); - for (final View type : View.values()) { - buttons[1 + type.ordinal()] = new Selector(type).createButton(group, type.icon, type.fallback, localized, type.tooltip); - } - final View type = getViewType(); - final ViewAndControls c = getViewAndControls(type, false); - group.selectToggle(group.getToggles().get(type.ordinal())); - content = new SplitPane(c.controls(), c.viewAndNavigation); - ToolbarButton.insert(content, buttons); /* * The divider position is supposed to be a fraction between 0 and 1. A value of 1 would mean * to give all the space to controls and no space to data, which is not what we want. However @@ -422,31 +345,6 @@ public class CoverageExplorer extends Widget { return getViewAndControls(Objects.requireNonNull(type), false).controlPanes.clone(); } - /** - * The action to execute when the user selects a view. - * This is used by the toolbar buttons in the widget created by {@link #getView()}. - */ - private final class Selector extends ToolbarButton { - /** The view to select when the button is pressed. */ - private final View type; - - /** Creates a new action which will show the view at the given index. */ - Selector(final View type) { - this.type = type; - } - - /** Invoked when the user selects another view to show (tabular data or the image). */ - @Override public void handle(final ActionEvent event) { - final Toggle button = (Toggle) event.getSource(); - if (button.isSelected()) { - setViewType(type); - views.get(type).selector = button; // Should never be null. - } else { - button.setSelected(true); // Prevent situation where all buttons are unselected. - } - } - } - /** * Returns the type of view (image or tabular data) shown in this explorer. * The default value is {@link View#TABLE}. diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/WindowHandler.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/WindowHandler.java deleted file mode 100644 index 040e3ba925..0000000000 --- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/WindowHandler.java +++ /dev/null @@ -1,474 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.gui.dataset; - -import java.util.Locale; -import java.util.Optional; -import javafx.application.Platform; -import javafx.stage.Stage; -import javafx.stage.Window; -import javafx.stage.WindowEvent; -import javafx.event.EventHandler; -import javafx.scene.layout.Region; -import javafx.beans.value.ChangeListener; -import javafx.beans.property.StringProperty; -import javafx.beans.property.SimpleStringProperty; -import javafx.collections.ObservableList; -import org.apache.sis.util.resources.Errors; -import org.apache.sis.storage.Resource; -import org.apache.sis.storage.DataStoreException; -import org.apache.sis.storage.event.CloseEvent; -import org.apache.sis.storage.event.StoreListener; -import org.apache.sis.gui.coverage.CoverageExplorer; -import org.apache.sis.gui.map.MapCanvas; -import org.apache.sis.gui.internal.BackgroundThreads; -import org.apache.sis.gui.internal.DataStoreOpener; -import org.apache.sis.gui.internal.GUIUtilities; -import org.apache.sis.gui.internal.PrivateAccess; -import org.apache.sis.gui.internal.Resources; -import org.apache.sis.util.logging.Logging; -import static org.apache.sis.gui.internal.LogHandler.LOGGER; - - -/** - * A separated window for visualizing a resource managed by {@link ResourceExplorer}. - * A window provides the area where the data are shown and where the user interacts. - * The window can be a JavaFX top-level window ({@link Stage}), but not necessarily. - * It may also be a tile in a mosaic of windows. - * - * @author Martin Desruisseaux (Geomatys) - * @version 1.7 - * @since 1.3 - * - * @deprecated Replaced by {@link org.apache.sis.gui.map.MapWindows}. - */ -@Deprecated(since = "1.7", forRemoval = true) -public abstract class WindowHandler { - /** - * The window manager which contains this handler. - * The manager contains the list of all windows created for the same widget. - */ - public final WindowManager manager; - - /** - * The window where the resource is visualized. This is created when first needed. - * We assume that resource views do not change their window during their lifetime. - * - * @see #show() - */ - private Stage window; - - /** - * The property for a label that identify the view. If the resource is shown - * in a top-level window, then this is typically the title of that window. - */ - public final StringProperty title; - - /** - * The listener to add and remove to/from the {@link #title} property. We use a static reference for avoiding - * to retain a direct reference to {@link #window} in listeners, which would increase the risk of memory leak. - */ - private static final ChangeListener<String> TITLE_CHANGED = (p,o,n) -> { - final var handler = (WindowHandler) ((StringProperty) p).getBean(); - handler.window.setTitle(n + " — Apache SIS"); - }; - - /** - * Creates a new handler for a window showing a resource. - * Exactly one of {@code creator} or {@code locale} arguments should be non-null. - * - * @param creator the handler which is duplicated, or {@code null} if none. - * @param locale language of texts. Used only if {@code creator} is null. - */ - WindowHandler(final WindowHandler creator, final Locale locale) { - manager = (creator != null) ? creator.manager : new WindowManager(this, locale); - title = new SimpleStringProperty(this, "title"); - } - - /** - * Methods to be invoked last by constructors, after everything else succeeded. - * Construction must be completed before invoking this method because this call will notify listeners. - * - * @return {@code this} for method call chaining. - */ - final WindowHandler finish() { - BackgroundThreads.execute(() -> { - String text; - final Locale locale = manager.locale; - if (manager.main == this) { - text = Resources.forLocale(locale).getString(Resources.Keys.MainWindow); - } else try { - text = DataStoreOpener.findLabel(getResource(), locale, true); - } catch (DataStoreException | RuntimeException e) { - text = DataStoreOpener.fallbackLabel(getResource(), locale); - Logging.recoverableException(LOGGER, WindowHandler.class, "<init>", e); - } - final String label = text; // Because lambda functions want final variable. - Platform.runLater(() -> title.set(label)); - }); - manager.modifiableWindowList.add(this); - return this; - } - - /** - * Creates a new handler for the window which is showing the given coverage viewer. - * - * @param widget the widget for which to create a handler. - * @return a handler for the window of the given widget. - */ - public static WindowHandler create(final CoverageExplorer widget) { - return new ForCoverage(null, widget.getLocale(), widget).finish(); - } - - /** - * Creates a new handler for the window which is showing the given table of features. - * - * @param widget the widget for which to create a handler. - * @return a handler for the window of the given widget. - */ - public static WindowHandler create(final FeatureTable widget) { - return new ForFeatures(null, widget.textLocale, widget).finish(); - } - - /** - * Prepares a new window with the same content as the window managed by this handler. - * This method can be used for creating many windows over the same data. - * Each window can do pans, zooms and rotations independently of other windows, - * or be synchronized with other windows, at user's choice. - * - * <p>The new view is added to the {@link WindowManager#windows} list and will be removed - * from that list if the window is closed. If the resource is closed in the window manager, - * then all windows showing that resource will be closed.</p> - * - * <p>The new window is not initially visible. - * To show the window, invoke {@link #show()} on the returned handler.</p> - * - * @return information about the new window. - */ - public abstract WindowHandler duplicate(); - - /** - * The resource shown in the {@linkplain #window}, or {@code null} if unspecified. - * This is used for identifying which handlers to remove when a resource is closed. - * This method is not yet public because a future version may need to return a full - * map context instead of a single resource. - * - * @return the resource shown in the window. - * - * @see CoverageExplorer#getResource() - * @see FeatureTable#getFeatures() - */ - abstract Resource getResource(); - - /** - * Returns the canvas (if any) where the resource is shown. - * Canvas exists for some kinds of view such as {@link CoverageExplorer}, but not for every kinds. - * For example, tabular data such as {@link FeatureTable} have no canvas. - * - * @return the canvas where the resource is shown. - * - * @see CoverageExplorer#getCanvas() - */ - public abstract Optional<MapCanvas> getCanvas(); - - /** - * Returns the JavaFX region where the resource is shown. - * This value shall be stable. - */ - abstract Region getView(); - - /** - * Returns the window which is showing the resource. - * This is used for fetching the main window. - */ - Window getWindow() { - return GUIUtilities.getWindow(getView()); - } - - /** - * Shows the window and brings it to the front. - * For handlers created by a {@code create(…)} method, this {@code show()} method can be invoked at any time. - * For handlers created by {@link #duplicate()}, this {@code show()} method can be invoked as long as the window - * has not been closed. After a duplicated window has been closed, it is not possible to show it again. - * - * @throws IllegalStateException if this handler is a {@linkplain #duplicate() duplicate} - * and the window has been closed. - */ - public void show() { - if (window == null) { - if (manager.main == this) { - if (getWindow() instanceof Stage w) { - window = w; - } else { - return; - } - } else { - final Resource resource = getResource(); - if (resource == null) { - throw new IllegalStateException(Errors.format(Errors.Keys.DisposedInstanceOf_1, getClass())); - } - final OnClose listener = new OnClose(); - resource.addListener(CloseEvent.class, listener); - window = manager.newWindow(getView()); - window.setOnHidden(listener); - title.addListener(TITLE_CHANGED); - TITLE_CHANGED.changed(title, null, title.get()); - } - } - window.show(); - window.toFront(); - } - - /** - * The action to execute when a window is closed or when the resource shown in windows is closed. - * When the event is a window closing, it impacts only that window. When the event is a resource - * closing, it impacts all windows showing that resource. - */ - private final class OnClose implements StoreListener<CloseEvent>, EventHandler<WindowEvent> { - /** - * Creates a new listener to be notified when a window or a resource is closed. - */ - OnClose() { - } - - /** - * Invoked in JavaFX thread when the window is closing. - */ - @Override public void handle(final WindowEvent event) { - manager.modifiableWindowList.remove(WindowHandler.this); - final Resource resource = getResource(); - if (resource != null) { - resource.removeListener(CloseEvent.class, this); - } - dispose(); - } - - /** - * Invoked when a resource is closing. This method can be invoked from any thread, but the actual work - * will done in the JavaFX thread. If the {@link CloseEvent} is fired from a background thread, then - * this method will block until the JavaFX thread finished to close all windows, for avoiding that - * the background thread closes the resource before we removed all usages in JavaFX thread. - */ - @Override public void eventOccurred(final CloseEvent event) { - final Resource resource = event.getSource(); - if (Platform.isFxApplicationThread()) { - close(resource); - } else BackgroundThreads.runAndWaitDialog(() -> { - close(resource); - return null; - }); - // No need to invoke `resource.removeListener(…)`, that work is done by `StoreListeners.close()`. - } - } - - /** - * Closes all windows (except the main window) which are showing the given resource. - * This is invoked when the resource has been closed in the {@link ResourceTree}. - * The handler managed by {@code this} is closed unconditionally regardless its resource. - * - * @param resource the resource which has been closed. - */ - private void close(final Resource resource) { - final WindowHandler ignore = manager.main; - final ObservableList<WindowHandler> windows = manager.modifiableWindowList; - for (int i = windows.size(); --i >= 0;) { - final WindowHandler handler = windows.get(i); - if (handler != ignore && (handler == this || handler.getResource() == resource)) { - windows.remove(i); - if (handler.window != null) { - handler.window.setOnHidden(null); // Because we will invoke `dispose()` ourselves. - handler.window.close(); - } - handler.dispose(); - } - } - } - - /** - * Makes a "best effort" for helping the garbage-collector to release memory. - * This method is for internal usage by {@code WindowHandler} and subclasses only. - * Caller shall remove this handler from the windows list before invoking this method. - */ - void dispose() { - assert manager.main != this; // Because listener is not registered for main window. - title.removeListener(TITLE_CHANGED); - if (window != null) { - window.setScene(null); - window = null; - } - } - - - - /** - * A visualization managed by a {@link CoverageExplorer} instance. - * The initial {@code CoverageExplorer} instance (before duplication) - * is itself produced by a {@link ResourceExplorer}. - */ - private static final class ForCoverage extends WindowHandler { - /** - * The widget providing the view. - */ - private final CoverageExplorer widget; - - /** - * Creates a new handler for a window showing a resource. - * - * @param creator the handler which is duplicated, or {@code null} if none. - * @param locale language of texts. Used only if {@code creator} is null. - * @param widget the widget providing the view of the resource. - */ - ForCoverage(final WindowHandler creator, final Locale locale, final CoverageExplorer widget) { - super(creator, locale); - this.widget = widget; - } - - /** - * Creates a new handler for duplicating an existing window. - * For indirect usage by {@link #duplicate()}. - * - * @param creator the handler which is duplicated. - * @param widget the widget providing the new view of the resource. - */ - private ForCoverage(final WindowHandler creator, final CoverageExplorer widget) { - this(creator, null, widget); - } - static { - PrivateAccess.newWindowHandler = ForCoverage::new; - PrivateAccess.finishWindowHandler = WindowHandler::finish; - } - - /** - * The resource shown in the {@linkplain #window window}, or {@code null} if unspecified. - */ - @Override - Resource getResource() { - return widget.getResource(); - } - - /** - * Returns the canvas where the map is shown. - */ - @Override - public Optional<MapCanvas> getCanvas() { - return Optional.of(widget.getCanvas()); - } - - /** - * Returns the JavaFX region where the resource is shown. - */ - @Override - Region getView() { - return widget.getView(); - } - - /** - * Returns the window which is showing the resource. We avoid the call to {@link #getView()} - * because in the particular case of {@link CoverageExplorer}, it causes the initialization - * of a split pane which is not the one used by the main window. - */ - @Override - Window getWindow() { - return GUIUtilities.getWindow(widget.getDataView(widget.getViewType())); - } - - /** - * Prepares (without showing) a new window with the same content as the window managed by this handler. - */ - @Override - public WindowHandler duplicate() { - return new CoverageExplorer(widget).getWindowHandler(); - } - - /** - * Makes a "best effort" for helping the garbage-collector to release resources. - */ - @Override - void dispose() { - super.dispose(); - widget.setResource(null); - } - } - - - - - /** - * A visualization managed by a {@link FeatureTable} instance. - * The initial {@code FeatureTable} instance (before duplication) - * is itself produced by a {@link ResourceExplorer}. - */ - private static final class ForFeatures extends WindowHandler { - /** - * The widget providing the view. - */ - private final FeatureTable widget; - - /** - * Creates a new handler for a window showing a resource. - * - * @param creator the handler which is duplicated, or {@code null} if none. - * @param locale language of texts. Used only if {@code creator} is null. - * @param widget the widget providing the view of the resource. - */ - ForFeatures(final WindowHandler creator, final Locale locale, final FeatureTable widget) { - super(creator, locale); - this.widget = widget; - } - - /** - * The resource shown in the {@linkplain #window window}, or {@code null} if unspecified. - */ - @Override - Resource getResource() { - return widget.getFeatures(); - } - - /** - * Returns an empty value since this window does not show map. - */ - @Override - public Optional<MapCanvas> getCanvas() { - return Optional.empty(); - } - - /** - * Returns the JavaFX region where the resource is shown. - */ - @Override - Region getView() { - return widget; - } - - /** - * Prepares (without showing) a new window with the same content as the window managed by this handler. - */ - @Override - public WindowHandler duplicate() { - return new ForFeatures(this, null, new FeatureTable(widget)).finish(); - } - - /** - * Makes a "best effort" for helping the garbage-collector to release resources. - */ - @Override - void dispose() { - super.dispose(); - widget.setFeatures(null); - } - } -} diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/WindowManager.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/WindowManager.java deleted file mode 100644 index 7159d7b818..0000000000 --- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/WindowManager.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.gui.dataset; - -import java.util.Locale; -import javafx.stage.Stage; -import javafx.stage.Screen; -import javafx.scene.Scene; -import javafx.scene.Node; -import javafx.scene.control.Button; -import javafx.scene.control.Labeled; -import javafx.scene.control.ToolBar; -import javafx.scene.control.Tooltip; -import javafx.scene.layout.BorderPane; -import javafx.scene.layout.Region; -import javafx.scene.text.Font; -import javafx.geometry.Rectangle2D; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import org.apache.sis.gui.internal.FontGIS; -import org.apache.sis.gui.internal.Resources; -import org.apache.sis.gui.internal.ToolbarButton; - - -/** - * A list of windows showing resources managed by {@link ResourceExplorer}. - * Windows are created when user clicks on the "New window" button. - * Many windows can be created for the same resource. - * Each window can apply different styles or map projections. - * Gestures such as zooms, pans and rotations can be applied independently - * or synchronized between windows, at user's choice. - * - * @author Martin Desruisseaux (Geomatys) - * @version 1.7 - * @since 1.3 - * - * @deprecated Replaced by {@link org.apache.sis.gui.map.MapWindows}. - */ -@Deprecated(since = "1.7", forRemoval = true) -public final class WindowManager { // Not designed for subclassing. - /** - * The handler of the main window. This handler shall never be disposed. - */ - final WindowHandler main; - - /** - * The language of texts to show to the user. - */ - final Locale locale; - - /** - * Read-only list of windows showing resources managed by {@link ResourceExplorer}. - * Items are added in this list when the user clicks on "New window" button and are - * removed from this list when the user closes the window. - */ - public final ObservableList<WindowHandler> windows; - - /** - * Modifiable list where to append new windows when they are created. - * This is the source of {@link #windows} list. - */ - final ObservableList<WindowHandler> modifiableWindowList; - - /** - * Creates a new window manager. - * - * @param main handler of the main window. This handler shall never be disposed. - * @param locale the language of texts to show to the user. - */ - WindowManager(final WindowHandler main, final Locale locale) { - this.main = main; - this.locale = locale; - modifiableWindowList = FXCollections.observableArrayList(); - windows = FXCollections.unmodifiableObservableList(modifiableWindowList); - } - - /** - * Creates a new window for the specified widget together with its toolbar. - * The new window will be positioned in the screen center but not yet shown. - * The window will have initially no title (title should be set by caller). - * - * @param content control that contains the data to show in a new window. - * @return window for showing the resource. Untitled and not yet visible. - */ - @Deprecated(since = "1.7", forRemoval = true) - final Stage newWindow(final Region content) { - final Stage stage = new Stage(); - final Button mainWindow = FontGIS.button((char) 0, "\uD83D\uDDD4"); // 🗔 — Desktop Window - final Button fullScreen = FontGIS.button(FontGIS.Code.FULL_SCREEN, "\u21F1\uFE0F"); // ⇱ — North West Arrow to Corner - final Resources localized = Resources.forLocale(locale); - mainWindow.setTooltip(new Tooltip(localized.getString(Resources.Keys.MainWindow))); - fullScreen.setTooltip(new Tooltip(localized.getString(Resources.Keys.FullScreen))); - mainWindow.setOnAction((e) -> main.show()); - fullScreen.setOnAction((e) -> stage.setFullScreen(true)); - /* - * Add content-specific buttons. We use the "org.apache.sis.gui.ToolbarButton" property - * as a way to transfer ToolbarButton accross packages without making this class public. - */ - final ToolBar tools = new ToolBar(mainWindow, fullScreen); - tools.getItems().addAll(ToolbarButton.remove(content)); - /* - * After we finished adding all buttons, set the font of all of them to a larger size. - */ - final Font font = Font.font(20); - for (final Node node : tools.getItems()) { - if (node instanceof Labeled) { - ((Labeled) node).setFont(font); - } - } - /* - * Main content. The tools bar will be hidden in full screen mode. - */ - final BorderPane pane = new BorderPane(); - stage.fullScreenProperty().addListener((p,o,entering) -> pane.setTop(entering ? null : tools)); - pane.setTop(tools); - pane.setCenter(content); - stage.setScene(new Scene(pane)); - /* - * We use an initial size covering a large fraction of the screen because - * this window is typically used for showing image or large tabular data. - */ - final Rectangle2D bounds = Screen.getPrimary().getVisualBounds(); - stage.setWidth (0.8 * bounds.getWidth()); - stage.setHeight(0.8 * bounds.getHeight()); - return stage; - } -} diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/package-info.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/package-info.java index 132ef13ed2..2e3c6dcdd9 100644 --- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/package-info.java +++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/dataset/package-info.java @@ -24,7 +24,7 @@ * @author Smaniotto Enzo (GSoC) * @author Johann Sorel (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 1.7 + * @version 1.8 * @since 1.1 */ package org.apache.sis.gui.dataset; diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/internal/PrivateAccess.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/internal/PrivateAccess.java deleted file mode 100644 index 505f87fd3c..0000000000 --- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/internal/PrivateAccess.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.gui.internal; - -import java.util.function.Consumer; -import java.util.function.BiFunction; -import org.apache.sis.gui.coverage.CoverageExplorer; -import org.apache.sis.gui.dataset.WindowHandler; - - -/** - * Accessor for fields that we want to keep private for now. - * This is a way to simulate the behavior of {@code friend} keyword in C++. - * Each field shall be set only once in a static block initializer and shall - * not be modified after initialization. - * - * @author Martin Desruisseaux (Geomatys) - */ -@Deprecated(since = "1.7", forRemoval = true) -public final class PrivateAccess { - /** - * Do not allow instantiation of this class. - */ - private PrivateAccess() { - } - - /** - * Accessor for {@link org.apache.sis.gui.dataset.WindowHandler.ForCoverage} constructor. - * Used for assigning {@link CoverageExplorer#window} when duplicating an existing window. - * Shall be invoked in JavaFX thread. - */ - public static volatile BiFunction<WindowHandler, CoverageExplorer, WindowHandler> newWindowHandler; - - /** - * Accessor for {@link WindowHandler#finish()} method. Shall be invoked in JavaFX thread. - */ - public static volatile Consumer<WindowHandler> finishWindowHandler; -} diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/internal/ToolbarButton.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/internal/ToolbarButton.java deleted file mode 100644 index 795a2c7fcf..0000000000 --- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/internal/ToolbarButton.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.gui.internal; - -import javafx.scene.Node; -import javafx.scene.control.Control; -import javafx.scene.control.ToggleButton; -import javafx.scene.control.ToggleGroup; -import javafx.scene.control.Tooltip; -import javafx.event.ActionEvent; -import javafx.event.EventHandler; -import org.apache.sis.util.ArraysExt; - - -/** - * Builder for a button to add in a the toolbar of a {@link org.apache.sis.gui.dataset} window. - * This class is used only for content-specific buttons; it is not used for all buttons created - * by the {@code dataset} package. A {@code ToolbarButton} can create and configure a button with its icon, - * tooltip text and action to execute when the button is pushed. - * - * <p>This class is defined in this internal package for allowing interactions between classes - * in different packages without making toolbar API public.</p> - * - * @author Martin Desruisseaux (Geomatys) - */ -public abstract class ToolbarButton implements EventHandler<ActionEvent> { - /** - * The property to use in {@link Node#getProperties()} for storing instances of this class. - * Values associated with this key shall be arrays of {@code Control[]} type. - */ - private static final String PROPERTY_KEY = "org.apache.sis.gui.ToolbarButtons"; - - /** - * Gets and removes the toolbar buttons associated with the given content pane. Those buttons - * should have been specified by a previous call to {@link #insert(Node, Control...)}. - * They will be requested by {@link org.apache.sis.gui.dataset.WindowHandler} only once, - * which is why we remove them afterward. - * - * @param content the pane for which to get the toolbar buttons. - * @return the toolbar buttons (never null, but may be empty). - * - * @deprecated following deprecation of {@code WindowHandler}. - */ - @Deprecated(since = "1.7", forRemoval = true) - public static Control[] remove(final Node content) { - final Control[] buttons = (Control[]) content.getProperties().remove(PROPERTY_KEY); - return (buttons != null) ? buttons : new Control[0]; - } - - /** - * Sets the toolbar buttons that the given pane wants to have in the data window. - * If the pane already has buttons, the new ones will be inserted before existing ones. - * - * @param content the pane for which to set the toolbar buttons. - * @param buttons the toolbar buttons to add. - */ - public static void insert(final Node content, final Control... buttons) { - content.getProperties().merge(PROPERTY_KEY, buttons, ToolbarButton::prepend); - } - - /** - * Invoked if toolbar buttons already exist for a pane, in which case the new ones - * are inserted before the existing ones. - */ - private static Object prepend(final Object oldValue, final Object newValue) { - return ArraysExt.append((ToolbarButton[]) newValue, (ToolbarButton[]) oldValue); - } - - /** - * For subclass constructors. - */ - protected ToolbarButton() { - } - - /** - * Convenience method for creating a button. - * The action handler will be {@code this}. - * - * @param group the group of the toggle button. - * @param icon the character to put in the button, as a {@link FontGIS} code. - * @param fallback the text to put in the button as a Unicode emoji if Font-GIS is not available. - * @param localized an instance of {@link Resources} for current locale. - * @param tooltip the {@link Resources.Keys} value for the tooltip. - * @return the button configured with text or icon, tooltip and action. - */ - public final ToggleButton createButton(final ToggleGroup group, final char icon, final String fallback, final Resources localized, final short tooltip) { - final ToggleButton tb = FontGIS.toggle(icon, fallback); - tb.setToggleGroup(group); - tb.setTooltip(new Tooltip(localized.getString(tooltip))); - tb.setOnAction(this); - return tb; - } - - /** - * Invoked when the user pushed the button. - * - * @param event the pushed button event. - */ - @Override - public abstract void handle(ActionEvent event); -} diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/StatusBar.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/StatusBar.java index 514183ca10..95b7da62e6 100644 --- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/StatusBar.java +++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/StatusBar.java @@ -126,7 +126,7 @@ import org.opengis.coordinate.MismatchedDimensionException; * {@link #setLocalCoordinates(double, double)} explicitly instead. * * @author Martin Desruisseaux (Geomatys) - * @version 1.7 + * @version 1.8 * @since 1.1 */ public class StatusBar extends Widget implements EventHandler<MouseEvent> { @@ -1694,20 +1694,6 @@ public class StatusBar extends Widget implements EventHandler<MouseEvent> { } } - /** - * Shows or hides an informative message on the status bar. - * The message should be temporary, for example for telling that a loading is in progress. - * - * @param text the message to show, or {@code null} if none. - * - * @since 1.3 - * @deprecated Renamed {@link #setProgressMessage(String)}. - */ - @Deprecated(since = "1.7", forRemoval = true) - public void setInfoMessage(String text) { - setProgressMessage(text); - } - /** * Shows or hides a message for an operation in progress. * The given text should be a temporary message, for example for telling that a loading is in progress. diff --git a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/package-info.java b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/package-info.java index e76f704188..93a46534e5 100644 --- a/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/package-info.java +++ b/optional/src/org.apache.sis.gui/main/org/apache/sis/gui/map/package-info.java @@ -22,7 +22,7 @@ * {@link org.apache.sis.gui.map.MapCanvasAWT} is a specialization for painting the map using Java2D. * * @author Martin Desruisseaux (Geomatys) - * @version 1.7 + * @version 1.8 * @since 1.1 */ package org.apache.sis.gui.map;
