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 2021/07/11 20:17:48 UTC
[sis] branch visual-test updated: Give a title to image window.
Display it even if the image has no "grid to CRS" transform.
This is an automated email from the ASF dual-hosted git repository.
desruisseaux pushed a commit to branch visual-test
in repository https://gitbox.apache.org/repos/asf/sis.git
The following commit(s) were added to refs/heads/visual-test by this push:
new 3b50a06 Give a title to image window. Display it even if the image has no "grid to CRS" transform.
3b50a06 is described below
commit 3b50a06dcf6583264afa3a064a6d524fd92a2400
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Sun Jul 11 20:39:42 2021 +0200
Give a title to image window. Display it even if the image has no "grid to CRS" transform.
---
src/main/java/org/apache/sis/swing/ImagePane.java | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/sis/swing/ImagePane.java b/src/main/java/org/apache/sis/swing/ImagePane.java
index 4d7c0f9..e3c3d49 100644
--- a/src/main/java/org/apache/sis/swing/ImagePane.java
+++ b/src/main/java/org/apache/sis/swing/ImagePane.java
@@ -16,6 +16,7 @@
*/
package org.apache.sis.swing;
+import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.RenderedImage;
import java.awt.geom.AffineTransform;
@@ -25,6 +26,7 @@ import org.opengis.referencing.datum.PixelInCell;
import org.apache.sis.image.PlanarImage;
import org.apache.sis.coverage.grid.GridCoverage;
import org.apache.sis.coverage.grid.GridGeometry;
+import org.apache.sis.coverage.grid.IncompleteGridGeometryException;
import org.apache.sis.referencing.operation.matrix.AffineTransforms2D;
@@ -54,11 +56,19 @@ public class ImagePane extends ZoomPane {
* only for quick testing purpose.
*
* @param coverage the coverage to show.
+ * @param title window title.
*/
- public static void show(final GridCoverage coverage) {
+ public static void show(final GridCoverage coverage, final String title) {
final RenderedImage image = coverage.render(null);
final GridGeometry gg = (GridGeometry) image.getProperty(PlanarImage.GRID_GEOMETRY_KEY);
- show(image, (AffineTransform) gg.getGridToCRS(PixelInCell.CELL_CORNER));
+ AffineTransform gridToCRS;
+ try {
+ gridToCRS = (AffineTransform) gg.getGridToCRS(PixelInCell.CELL_CORNER);
+ } catch (IncompleteGridGeometryException e) {
+ gridToCRS = new AffineTransform();
+ System.err.println(e);
+ }
+ show(image, gridToCRS, title);
}
/**
@@ -66,9 +76,10 @@ public class ImagePane extends ZoomPane {
*
* @param image the image to show.
* @param gridToCRS the transform from pixel coordinates to "real world" coordinates.
+ * @param title window title.
*/
- public static void show(final RenderedImage image, final AffineTransform gridToCRS) {
- final JFrame frame = new JFrame("RenderedImage");
+ public static void show(final RenderedImage image, final AffineTransform gridToCRS, final String title) {
+ final JFrame frame = new JFrame(title);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new ImagePane(image, gridToCRS).createScrollPane());
frame.pack();
@@ -84,6 +95,7 @@ public class ImagePane extends ZoomPane {
public ImagePane(final RenderedImage image, final AffineTransform gridToCRS) {
this.image = image;
this.gridToCRS = gridToCRS;
+ setBackground(Color.GRAY);
}
/**