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 5f84c5bf4c1c69ae3c6d47c0b0728c26ff10d7a6
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Tue Nov 12 11:41:46 2019 +0100

    Fix an IndexOutOfBoundsException when showing an empty list of features.
    Avoid drawing a line on image border when rectangle cross anti-meridian.
---
 .../java/org/apache/sis/gui/dataset/ExpandableList.java |  2 +-
 .../org/apache/sis/gui/metadata/IdentificationInfo.java | 17 ++++++++++++-----
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git 
a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ExpandableList.java
 
b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ExpandableList.java
index 3d07ca8..1ecabce 100644
--- 
a/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ExpandableList.java
+++ 
b/application/sis-javafx/src/main/java/org/apache/sis/gui/dataset/ExpandableList.java
@@ -236,7 +236,7 @@ final class ExpandableList extends 
TransformationList<Feature,Feature>
     @Override
     public int size() {
         int size = getSource().size();
-        if (expansion != null) {
+        if (size != 0 && expansion != null) {
             size += expansion.length - 1;
         }
         return size;
diff --git 
a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/IdentificationInfo.java
 
b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/IdentificationInfo.java
index e70019c..eecfca6 100644
--- 
a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/IdentificationInfo.java
+++ 
b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/IdentificationInfo.java
@@ -307,6 +307,7 @@ final class IdentificationInfo extends 
Section<Identification> {
             }
             final double wi = Math.min(w, MAP_WIDTH - x);               // 
Width of part inside [-180 … +180]°.
             w -= wi;                                                    // 
Width of part not drawn by `wi`.
+            final boolean crossAntimeridian = (w > 0);
             /*
              * At this point we got the coordinates of the rectangle to draw, 
adjusted for making sure
              * that they are inside valid ranges. The `w` variable is usually 
0, unless we had to cut
@@ -325,13 +326,19 @@ final class IdentificationInfo extends 
Section<Identification> {
             gc.setStroke(Color.DARKBLUE);
             gc.setGlobalAlpha(0.1);
             gc.fillRect(x, y, wi, h);
-            if (w > 0) {
-                gc.fillRect(0, y, w, h);
+            if (crossAntimeridian) {
+                gc.fillRect(0, y, w, h);            // Second half of 
rectangle crossing anti-meridian.
             }
             gc.setGlobalAlpha(1.0);
-            gc.strokeRect(x, y, wi, h);
-            if (w > 0) {
-                gc.strokeRect(0, y, w, h);
+            if (!crossAntimeridian) {
+                gc.strokeRect(x, y, wi, h);
+            } else {
+                double xw = x + wi;
+                double yh = y + h;
+                gc.strokePolyline(new double[] {xw, x, x,  xw},
+                                  new double[] {y,  y, yh, yh}, 4);
+                gc.strokePolyline(new double[] {0, w, w,  0},
+                                  new double[] {y, y, yh, yh}, 4);
             }
         }
         return false;

Reply via email to