Class SurfaceImageLayer

  • All Implemented Interfaces:
    AVList, Disposable, MessageListener, Layer, Restorable, WWObject, java.beans.PropertyChangeListener, java.util.EventListener

    public class SurfaceImageLayer
    extends RenderableLayer
    Displays a collection of local images on the globe.

    Note: The view input handlers detect surface images rather than the terrain as the top picked object in SelectEvents and will not respond to the user's attempts at navigation when the cursor is over the image. If this is not the desired behavior, disable picking for the layer containing the surface image.

    • Constructor Detail

      • SurfaceImageLayer

        public SurfaceImageLayer()
    • Method Detail

      • addImage

        public void addImage​(java.lang.String imagePath)
                      throws java.io.IOException
        Add an image to the collection, reprojecting it to geographic (latitude and longitude) coordinates if necessary. The image's location is determined from metadata files co-located with the image file. The number, names and contents of these files are governed by the type of the specified image. Location metadata must be available.

        If projection information is available and reprojection of the image's projection type is supported, the image will be reprojected to geographic coordinates. If projection information is not available then it's assumed that the image is already in geographic projection.

        Only reprojection from UTM is currently provided.

        Parameters:
        imagePath - the path to the image file.
        Throws:
        java.lang.IllegalArgumentException - if the image path is null.
        java.io.IOException - if an error occurs reading the image file.
        java.lang.IllegalStateException - if an error occurs while reprojecting or otherwise processing the image.
        WWRuntimeException - if the image type is unsupported.
      • getBufferedImage

        protected java.awt.image.BufferedImage getBufferedImage​(DataRaster raster)
      • addImage

        public void addImage​(java.lang.String imagePath,
                             Sector sector)
                      throws java.io.IOException,
                             WWRuntimeException
        Add an image to the collection and specify its coverage. The image is assumed to be in geographic projection (latitude and longitude).
        Parameters:
        imagePath - the path to the image file.
        sector - the geographic location of the image.
        Throws:
        java.lang.IllegalArgumentException - if the image path or sector is null.
        java.io.IOException - if an error occurs reading the image file.
        WWRuntimeException - if the image type is unsupported.
      • addImage

        public void addImage​(java.lang.String name,
                             java.awt.image.BufferedImage image,
                             Sector sector)
        Add a BufferedImage to the collection at an explicitly specified location. The image is assumed to be in geographic projection (latitude and longitude).
        Parameters:
        name - a unique name to associate with the image so that it can be subsequently referred to without having to keep a reference to the image itself. Use this name in calls to removeImage(String).
        image - the image to add.
        sector - the geographic location of the image.
        Throws:
        java.lang.IllegalArgumentException - if the image path or sector is null.
        WWRuntimeException - if the image type is unsupported.
      • addImage

        public void addImage​(java.lang.String imagePath,
                             java.util.List<? extends LatLon> corners)
                      throws java.io.IOException,
                             WWRuntimeException
        Add an image to the collection at an explicitly specified location. The image is assumed to be in geographic projection (latitude and longitude).
        Parameters:
        imagePath - the path to the image file.
        corners - the geographic location of the image's corners, specified in order of lower-left, lower-right, upper-right, upper-left.
        Throws:
        java.lang.IllegalArgumentException - if the image path or sector is null.
        java.io.IOException - if an error occurs reading the image file.
        WWRuntimeException - if the image type is unsupported.
      • addImage

        public void addImage​(java.lang.String name,
                             java.awt.image.BufferedImage image,
                             java.util.List<? extends LatLon> corners)
        Add a BufferedImage to the collection at an explicitly specified location. The image is assumed to be in geographic projection (latitude and longitude).
        Parameters:
        name - a unique name to associate with the image so that it can be subsequently referred to without having to keep a reference to the image itself. Use this name in calls to removeImage(String).
        image - the image to add.
        corners - the geographic location of the image's corners, specified in order of lower-left, lower-right, upper-right, upper-left.
        Throws:
        java.lang.IllegalArgumentException - if the image path is null, the corners list is null, contains null values or fewer than four locations.
        WWRuntimeException - if the image type is unsupported.
      • removeImage

        public void removeImage​(java.lang.String imagePath)
      • setOpacity

        public void setOpacity​(double opacity)
        Description copied from class: RenderableLayer
        Opacity is not applied to layers of this type because each renderable typically has its own opacity control.
        Specified by:
        setOpacity in interface Layer
        Overrides:
        setOpacity in class RenderableLayer
        Parameters:
        opacity - the current opacity value, which is ignored by this layer.
      • getNumImages

        public int getNumImages()
      • composeImageForSector

        public java.awt.image.BufferedImage composeImageForSector​(Sector sector,
                                                                  int canvasWidth,
                                                                  int canvasHeight,
                                                                  double aspectRatio,
                                                                  java.awt.image.BufferedImage image)
        Create an image for the portion of this layer lying within a specified sector. The image is created at a specified aspect ratio within a canvas of a specified size.
        Parameters:
        sector - the sector of interest.
        canvasWidth - the width of the canvas.
        canvasHeight - the height of the canvas.
        aspectRatio - the aspect ratio, width/height, of the window. If the aspect ratio is greater or equal to one, the full width of the canvas is used for the image; the height used is proportional to the inverse of the aspect ratio. If the aspect ratio is less than one, the full height of the canvas is used, and the width used is proportional to the aspect ratio.
        image - if non-null, a BufferedImage in which to place the image. If null, a new buffered image of type BufferedImage.TYPE_INT_RGB is created. The image must be the width and height specified in the canvasWidth and canvasHeight arguments.
        Returns:
        image the assembelled image, of size indicated by the canvasWidth and canvasHeight. If the specified aspect ratio is one, all pixels contain values. If the aspect ratio is greater than one, a full-width segment along the top of the canvas is blank. If the aspect ratio is less than one, a full-height segment along the right side of the canvase is blank. If the image argument was non-null, that buffered image is returned.
        See Also:
        ImageUtil.mergeImage(Sector, Sector, double, BufferedImage, BufferedImage)