You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2020/06/17 17:39:25 UTC
[sis] branch geoapi-4.0 updated (bba7e3c -> f2c4c23)
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a change to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git.
from bba7e3c Fix an shift observed during change of map projection. The fix require an anchor point to be specified in call to `setObjectiveCRS(…)`.
new 45d82aa Do not allow the use of display CRS in the definition of Point Of Interest.
new 00162ea Resolve a duplication in the offered CRS items.
new f2c4c23 Fix image transparency.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../java/org/apache/sis/gui/map/MapCanvasAWT.java | 6 ++--
.../org/apache/sis/gui/referencing/MenuSync.java | 3 +-
.../gui/referencing/RecentReferenceSystems.java | 34 +++++++++++++---------
.../main/java/org/apache/sis/portrayal/Canvas.java | 29 ++++++++++--------
4 files changed, 43 insertions(+), 29 deletions(-)
[sis] 02/03: Resolve a duplication in the offered CRS items.
Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
commit 00162eace60e4d4ad6f42797d2c236218a8c522b
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Wed Jun 17 11:44:46 2020 +0200
Resolve a duplication in the offered CRS items.
---
.../org/apache/sis/gui/referencing/MenuSync.java | 3 +-
.../gui/referencing/RecentReferenceSystems.java | 34 +++++++++++++---------
2 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/MenuSync.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/MenuSync.java
index 1127282..297cb8d 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/MenuSync.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/MenuSync.java
@@ -164,7 +164,8 @@ final class MenuSync extends SimpleObjectProperty<ReferenceSystem> implements Ev
}
final MenuItem[] items = new MenuItem[systems.size()];
for (int i=0; i<items.length; i++) {
- items[i] = mapping.remove(systems.get(i));
+ final Object key = systems.get(i);
+ items[i] = mapping.remove(key == RecentReferenceSystems.OTHER ? CHOOSER : key);
}
/*
* Previous loop copied all items that could be reused as-is. Now search for all items that are new.
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/RecentReferenceSystems.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/RecentReferenceSystems.java
index 3264899..82329c2 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/RecentReferenceSystems.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/RecentReferenceSystems.java
@@ -358,7 +358,7 @@ public class RecentReferenceSystems {
* Authority codes are resolved if possible or removed if they can not be resolved. Unverified CRSs are compared
* with authoritative definitions and replaced when a match is found. Duplications are removed.
*
- * <p>This method can be invoked from any thread.</p>
+ * <p>This method can be invoked from any thread. In practice, it is invoked from a background thread.</p>
*
* @param domain the {@link #areaOfInterest} value read from JavaFX thread, or {@code null} if none.
* @param mode the {@link #duplicationCriterion} value read from JavaFX thread.
@@ -487,6 +487,7 @@ public class RecentReferenceSystems {
synchronized (systemsOrCodes) {
isModified = true;
if (referenceSystems != null) {
+ // ChoiceBox or Menu already created. They will observe the changes in item list.
updateItems();
}
}
@@ -558,7 +559,8 @@ public class RecentReferenceSystems {
* {@code systems} list has been computed.
*/
private void setReferenceSystems(final List<ReferenceSystem> systems, final ComparisonMode mode) {
- if (systems != null) try {
+ // Nested calls to this method should never happen, but check !isAdjusting anyway as safety.
+ if (systems != null && !isAdjusting) try {
isAdjusting = true;
/*
* The call to `copyAsDiff(…)` may cause some ChoiceBox values to be lost if the corresponding
@@ -621,6 +623,7 @@ public class RecentReferenceSystems {
action.changed(property, oldValue, newValue);
return;
}
+ final ComparisonMode mode = duplicationCriterion.get();
if (newValue == OTHER) {
final CRSChooser chooser = new CRSChooser(factory, geographicAOI, locale);
newValue = chooser.showDialog(GUIUtilities.getWindow(property)).orElse(null);
@@ -635,7 +638,6 @@ public class RecentReferenceSystems {
* given by CRSChooser, which is more conform to authoritative definition.
*/
final ObservableList<ReferenceSystem> items = referenceSystems;
- final ComparisonMode mode = duplicationCriterion.get();
int count = items.size() - NUM_OTHER_ITEMS;
boolean found = false;
for (int i=0; i<count; i++) {
@@ -675,20 +677,16 @@ public class RecentReferenceSystems {
}
if (oldValue != newValue) {
/*
- * Notify the user-specified listener first. It will typically starts a background process.
- * If an exception occurs in that user code, the list of CRS choices will be left unchanged.
- */
- action.changed(property, oldValue, newValue);
- RecentChoices.useReferenceSystem(IdentifiedObjects.toString(IdentifiedObjects.getIdentifier(newValue, null)));
- /*
* If the selected CRS is already at the beginning of the list, do nothing. The beginning is
* either one of the core items (specified by `setPreferred(…)`) or the first item after the
* core items.
*/
final ObservableList<ReferenceSystem> items = referenceSystems;
final int count = items.size() - NUM_OTHER_ITEMS;
- for (int i=Math.min(count, NUM_CORE_ITEMS + 1); --i >= 0;) {
- if (items.get(i) == newValue) {
+ for (int i = Math.min(count, NUM_CORE_ITEMS + 1); --i >= 0;) {
+ final ReferenceSystem current = items.get(i);
+ if (Utilities.deepEquals(current, newValue, mode)) {
+ action.changed(property, oldValue, current);
return;
}
}
@@ -697,14 +695,22 @@ public class RecentReferenceSystems {
* We need to remove the old value before to add the new one, otherwise it seems
* to confuse the list.
*/
- for (int i=count; --i >= NUM_CORE_ITEMS;) {
- if (items.get(i) == newValue) {
- items.remove(i);
+ for (int i = count; --i >= NUM_CORE_ITEMS;) {
+ if (Utilities.deepEquals(items.get(i), newValue, mode)) {
+ newValue = items.remove(i);
break;
}
}
items.add(Math.min(items.size(), NUM_CORE_ITEMS), newValue);
+ /*
+ * Notify the user-specified listeners. It will typically starts a background process.
+ * We test (oldValue != newValue) again because `newValue` may have been replaced.
+ */
notifyChanges();
+ if (oldValue != newValue) {
+ action.changed(property, oldValue, newValue); // Typically starts a background process.
+ }
+ RecentChoices.useReferenceSystem(IdentifiedObjects.toString(IdentifiedObjects.getIdentifier(newValue, null)));
}
}
}
[sis] 01/03: Do not allow the use of display CRS in the definition
of Point Of Interest.
Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
commit 45d82aa039de556cdee94b9c3358a10b66dfc7e2
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Wed Jun 17 10:47:24 2020 +0200
Do not allow the use of display CRS in the definition of Point Of Interest.
---
.../main/java/org/apache/sis/portrayal/Canvas.java | 29 +++++++++++++---------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/core/sis-portrayal/src/main/java/org/apache/sis/portrayal/Canvas.java b/core/sis-portrayal/src/main/java/org/apache/sis/portrayal/Canvas.java
index 9f1c03f..1ab6399 100644
--- a/core/sis-portrayal/src/main/java/org/apache/sis/portrayal/Canvas.java
+++ b/core/sis-portrayal/src/main/java/org/apache/sis/portrayal/Canvas.java
@@ -300,8 +300,8 @@ public class Canvas extends Observable implements Localized {
*
* <p>In current implementation, this transform may depend on the zoom level and viewed geographic
* area at the time this transform has been computed. The transform could be slightly different if
- * it has been computed at the time a different geographic area was viewed. Those variations may
- * exist because {@link #findTransform(CoordinateReferenceSystem, CoordinateReferenceSystem)} takes
+ * it has been computed at the time a different geographic area was viewed. Those variations may exist
+ * because {@link #findTransform(CoordinateReferenceSystem, CoordinateReferenceSystem, boolean)} takes
* in account the current viewing conditions. We may need to revisit this behavior in the future if
* it appears to be a problem.</p>
*
@@ -365,7 +365,7 @@ public class Canvas extends Observable implements Localized {
*
* @see #getGeographicArea()
* @see #getSpatialResolution()
- * @see #findTransform(CoordinateReferenceSystem, CoordinateReferenceSystem)
+ * @see #findTransform(CoordinateReferenceSystem, CoordinateReferenceSystem, boolean)
*/
private final CanvasContext operationContext;
@@ -373,7 +373,7 @@ public class Canvas extends Observable implements Localized {
* The factory to use for creating coordinate operations. This factory allow us to specify the area
* of interest (the geographic region shown by this {@code Canvas}) and the desired resolution.
*
- * @see #findTransform(CoordinateReferenceSystem, CoordinateReferenceSystem)
+ * @see #findTransform(CoordinateReferenceSystem, CoordinateReferenceSystem, boolean)
*/
private final DefaultCoordinateOperationFactory coordinateOperationFactory;
@@ -529,10 +529,10 @@ public class Canvas extends Observable implements Localized {
* to view the same area after the CRS change. Those information only need to be approximate
* anyway, and in many cases will be totally ignored by `findTransform(…)`.
*/
- final MathTransform newToOld = findTransform(newValue, oldValue);
+ final MathTransform newToOld = findTransform(newValue, oldValue, false);
if (pointOfInterest != null && !newToOld.isIdentity()) {
final CoordinateReferenceSystem poiCRS = pointOfInterest.getCoordinateReferenceSystem();
- final MathTransform poiToNew = findTransform(poiCRS, newValue);
+ final MathTransform poiToNew = findTransform(poiCRS, newValue, false);
final DirectPosition poiInNew = poiToNew.transform(pointOfInterest, allocatePosition());
/*
* We need anchor in new CRS. If no anchor was specified, `poiInNew` is already what we need.
@@ -547,7 +547,7 @@ public class Canvas extends Observable implements Localized {
if (!Utilities.equalsIgnoreMetadata(crs, newValue)) {
MathTransform anchorToNew = poiToNew;
if (!Utilities.equalsIgnoreMetadata(crs, poiCRS)) {
- anchorToNew = findTransform(crs, newValue);
+ anchorToNew = findTransform(crs, newValue, true);
}
anchor = anchorToNew.transform(anchor, allocatePosition());
}
@@ -879,7 +879,7 @@ public class Canvas extends Observable implements Localized {
*/
MathTransform mt = multidimToObjective;
if (mt == null || !Utilities.equalsIgnoreMetadata(crs, oldValue.getCoordinateReferenceSystem())) {
- mt = findTransform(crs, objectiveCRS);
+ mt = findTransform(crs, objectiveCRS, false);
}
objectivePOI = mt.transform(copy, allocatePosition());
pointOfInterest = copy; // Set only after transform succeeded.
@@ -1174,18 +1174,23 @@ public class Canvas extends Observable implements Localized {
* CRS may differ depending on which area is currently visible in the canvas. All requests for a coordinate
* operation should invoke this method instead than {@link CRS#findOperation(CoordinateReferenceSystem,
* CoordinateReferenceSystem, GeographicBoundingBox)}.
+ *
+ * @param allowDisplayCRS whether the {@code sourceCRS} can be {@link #getDisplayCRS()}.
*/
private MathTransform findTransform(CoordinateReferenceSystem source,
- final CoordinateReferenceSystem target)
+ final CoordinateReferenceSystem target,
+ boolean allowDisplayCRS)
throws FactoryException, TransformException, RenderException
{
- final boolean fromDisplay = Utilities.equalsIgnoreMetadata(source, displayBounds.getCoordinateReferenceSystem());
- if (fromDisplay) {
+ if (allowDisplayCRS) {
+ allowDisplayCRS = Utilities.equalsIgnoreMetadata(source, displayBounds.getCoordinateReferenceSystem());
+ }
+ if (allowDisplayCRS) {
source = objectiveCRS;
}
operationContext.refresh(this);
MathTransform tr = coordinateOperationFactory.createOperation(source, target, operationContext).getMathTransform();
- if (fromDisplay) {
+ if (allowDisplayCRS) {
tr = MathTransforms.concatenate(getObjectiveToDisplay().inverse(), tr);
}
return tr;
[sis] 03/03: Fix image transparency.
Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git
commit f2c4c2308f30e4b07b6698c73329c9e6162c8f60
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Wed Jun 17 16:13:20 2020 +0200
Fix image transparency.
---
.../src/main/java/org/apache/sis/gui/map/MapCanvasAWT.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/map/MapCanvasAWT.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/map/MapCanvasAWT.java
index 57cd3c9..6816258 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/map/MapCanvasAWT.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/map/MapCanvasAWT.java
@@ -18,6 +18,7 @@ package org.apache.sis.gui.map;
import java.util.Locale;
import java.nio.IntBuffer;
+import java.awt.AlphaComposite;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.awt.GraphicsConfiguration;
@@ -388,13 +389,13 @@ public abstract class MapCanvasAWT extends MapCanvas {
VolatileImage drawTo = previousBuffer;
previousBuffer = null; // For letting GC do its work.
if (drawTo == null) {
- drawTo = configuration.createCompatibleVolatileImage(width, height);
+ drawTo = configuration.createCompatibleVolatileImage(width, height, VolatileImage.TRANSLUCENT);
}
boolean invalid = true;
try {
do {
if (drawTo.validate(configuration) == VolatileImage.IMAGE_INCOMPATIBLE) {
- drawTo = configuration.createCompatibleVolatileImage(width, height);
+ drawTo = configuration.createCompatibleVolatileImage(width, height, VolatileImage.TRANSLUCENT);
}
final Graphics2D gr = drawTo.createGraphics();
try {
@@ -422,6 +423,7 @@ public abstract class MapCanvasAWT extends MapCanvas {
final VolatileImage drawTo = doubleBuffer;
final Graphics2D gr = buffer.createGraphics();
try {
+ gr.setComposite(AlphaComposite.Src); // Copy source (previous destination is discarded).
gr.drawImage(drawTo, 0, 0, null);
contentsLost = drawTo.contentsLost();
} finally {