Class RasterImageLayer

All Implemented Interfaces:
Disposable, Layerable, LayerManagerProxy, ObjectContainingMetaInformation

public final class RasterImageLayer extends GeoReferencedLayerable implements ObjectContainingMetaInformation, Disposable
Layer representing a georeferenced raster image (e.g. an areal photography) in OpenJump.
Version:
$Rev: 2509 $ modified: [sstein]: 16.Feb.2009 changed logger-entries to comments, used frame.warnUser
Author:
Ole Rahn

FH Osnabrück - University of Applied Sciences Osnabrück,
Project: PIROL (2006),
Subproject: Daten- und Wissensmanagement
  • Field Details

    • lastImgProcessingMode

      protected int lastImgProcessingMode
    • MODE_NONE

      protected static final int MODE_NONE
      See Also:
    • MODE_SCALINGFIRST

      protected static final int MODE_SCALINGFIRST
      See Also:
    • MODE_CLIPPINGFIRST

      protected static final int MODE_CLIPPINGFIRST
      See Also:
    • MODE_FASTDISPLAY

      protected static final int MODE_FASTDISPLAY
      See Also:
    • imagePart

      protected Rectangle imagePart
    • visibleRect

      protected Rectangle visibleRect
    • oldScaleXImg2Canvas

      protected double oldScaleXImg2Canvas
    • xOffset

      protected int xOffset
    • yOffset

      protected int yOffset
    • transparencyLevel

      protected double transparencyLevel
    • availRAM

      protected static long availRAM
    • freeRamFactor

      protected static double freeRamFactor
    • minRamToKeepFree

      protected static double minRamToKeepFree
    • maxPixelsForFastDisplayMode

      protected static int maxPixelsForFastDisplayMode
    • imageFileName

      protected String imageFileName
    • origImageWidth

      protected int origImageWidth
    • origImageHeight

      protected int origImageHeight
    • imageSet

      protected boolean imageSet
    • image

      protected BufferedImage image
    • numBands

      protected int numBands
    • rasterDataChanged

      protected boolean rasterDataChanged
    • scaledBufferedImage

      protected BufferedImage scaledBufferedImage
    • actualImageEnvelope

      protected org.locationtech.jts.geom.Envelope actualImageEnvelope
    • visibleEnv

      protected org.locationtech.jts.geom.Envelope visibleEnv
    • oldVisibleEnv

      protected org.locationtech.jts.geom.Envelope oldVisibleEnv
    • firingAppearanceEvents

      protected boolean firingAppearanceEvents
      Flag to decide, if events are fired automatically, if the appearance (imageEnvelope, etc.) changes.
      default: true
    • needToKeepImage

      protected boolean needToKeepImage
      Flag to control if the image should be deleted from RAM as soon as possible to save RAM or if it should be kept e.g. because it was generated dynamically and can not be loaded from a file again, once it was deleted.
    • transparentColor

      protected Color transparentColor
    • transparencyColorNeedsToBeApplied

      protected boolean transparencyColorNeedsToBeApplied
    • noDataValue

      protected double noDataValue
    • originalCellSize

      protected double originalCellSize
    • actualCellSize

      protected double actualCellSize
    • metaInformation

      protected MetaDataMap metaInformation
  • Constructor Details

    • RasterImageLayer

      public RasterImageLayer()
      for java2xml
    • RasterImageLayer

      public RasterImageLayer(String name, LayerManager layerManager, String imageFileName, BufferedImage imageToDisplay, org.locationtech.jts.geom.Envelope wholeImageEnvelope)
      Parameters:
      name - name of the layer
      layerManager - the LayerManager
      imageFileName - the name of the image file
      imageToDisplay - the image (if already loaded) or null
      wholeImageEnvelope - the image envelope in model (real world) coordinates
    • RasterImageLayer

      public RasterImageLayer(String name, LayerManager layerManager, BufferedImage imageToDisplay, Raster newRaster, org.locationtech.jts.geom.Envelope wholeImageEnvelope)
      Constructor to be used in case the image was not loaded from a file, so there is no file name, but an image
      Parameters:
      name - name of the layer
      layerManager - the LayerManager
      imageToDisplay - the image (if already loaded) or null
      newRaster - the raster (if already loaded) or null
      wholeImageEnvelope - the image envelope in model (real world) coordinates
  • Method Details

    • getXmlEnvelope

      public String getXmlEnvelope()
      for java2xml
      Returns:
      the Envelope as string
    • setXmlEnvelope

      public void setXmlEnvelope(String envStr)
      for java2xml
      Parameters:
      envStr - the Envelope as string
    • clone

      public Object clone() throws CloneNotSupportedException
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException
    • scaleImage

      protected BufferedImage scaleImage(BufferedImage im, float xScale, float yScale)
      apply a scale operation to the image and return the new image.
    • createOneColorImage

      protected BufferedImage createOneColorImage(Color color)
      Create a single color image in the case where a single image pixel is visible
      Parameters:
      color - color of the pixel
      Returns:
      a single color BufferedImage
    • createImage

      public BufferedImage createImage(LayerViewPanel layerViewPanel)
      Creates the image to draw
      Parameters:
      layerViewPanel - the LayerViewPanel where the image will be drawn
      Returns:
      the BufferedImage to be drawn
    • getCommittedMemory

      protected long getCommittedMemory()
    • clearImageAndRaster

      public boolean clearImageAndRaster(boolean garbageCollect)
      Deletes image from RAM (if it is not to be kept and if the RAM consumption is high) and calls the garbage collector, if garbageCollect is true.
      Parameters:
      garbageCollect - if true the garbage collector will be called (this parameter may be overridden, if there is not enough RAM available...)
    • flushImages

      public void flushImages(boolean garbageCollect)
      flushes all images from the RAM.
      Parameters:
      garbageCollect - if true the garbage collector will be called (this parameter may be overridden, if there is not enough RAM available...)
    • reLoadImage

      public void reLoadImage(LayerViewPanel layerViewPanel) throws Exception
      Throws:
      Exception
    • stretchImageValuesForDisplay

      protected BufferedImage stretchImageValuesForDisplay() throws NoninvertibleTransformException
      **
      Throws:
      NoninvertibleTransformException
    • getWholeImageEnvelope

      public org.locationtech.jts.geom.Envelope getWholeImageEnvelope()
      Returns:
      Envelope with the real world coordinates of the image
    • getActualImageEnvelope

      public org.locationtech.jts.geom.Envelope getActualImageEnvelope()
    • getXmlWholeImageEnvelope

      public String getXmlWholeImageEnvelope()
      for java2xml
      Returns:
      the Envelope as string
    • getXmlActualImageEnvelope

      public String getXmlActualImageEnvelope()
    • setXmlWholeImageEnvelope

      public void setXmlWholeImageEnvelope(String envStr)
      for java2xml
      Parameters:
      envStr - the Envelope as string
    • setXmlActualImageEnvelope

      public void setXmlActualImageEnvelope(String envStr)
    • getWholeImageEnvelopeAsGeometry

      public org.locationtech.jts.geom.Geometry getWholeImageEnvelopeAsGeometry()
      Method to change the coordinates of the image and later apply the changes to the RasterImageLayer by using setGeometryAsWholeImageEnvelope(Geometry).
      Returns:
      return the imageEnvelope (= bounding box) as a geometry,
    • getActualImageEnvelopeAsGeometry

      public org.locationtech.jts.geom.Geometry getActualImageEnvelopeAsGeometry()
    • setGeometryAsWholeImageEnvelope

      public void setGeometryAsWholeImageEnvelope(org.locationtech.jts.geom.Geometry geometry)
      Method to set the coordinates of the image, e.g. after changing them after using getWholeImageEnvelopeAsGeometry().
    • setGeometryAsActualImageEnvelope

      public void setGeometryAsActualImageEnvelope(org.locationtech.jts.geom.Geometry geometry)
    • makeBufferedImage

      public static BufferedImage makeBufferedImage(Image im)
      creates a BufferedImage out of an Image
      Parameters:
      im - the Image
      Returns:
      the BufferedImage
    • getScaledImageMatchingVisible

      protected BufferedImage getScaledImageMatchingVisible(BufferedImage toBeScaled, double XscaleImg2Canvas, double YscaleImg2Canvas)
    • getDrawingRectangle

      public Rectangle getDrawingRectangle(double imgWidth, double imgHeight, org.locationtech.jts.geom.Envelope imageEnv, Viewport viewport) throws NoninvertibleTransformException
      Throws:
      NoninvertibleTransformException
    • getVisibleImageCoordinatesOfImage

      protected Rectangle getVisibleImageCoordinatesOfImage(double imgWidth, double imgHeight, org.locationtech.jts.geom.Envelope viewportEnv, org.locationtech.jts.geom.Envelope imageEnv)
      Returns the visible part of the image in image coordinate
      Parameters:
      imgWidth - original image width
      imgHeight - original image height
      viewportEnv - viewport in model coordinates
      imageEnv - image envelope in model coordinates
      Returns:
      visible part of the image in image coordinates
    • getVisibleImageCoordinatesOfImage

      protected Rectangle getVisibleImageCoordinatesOfImage(BufferedImage img, org.locationtech.jts.geom.Envelope visible, org.locationtech.jts.geom.Envelope imageEnv)
    • getVisiblePartOfTheImage

      protected BufferedImage getVisiblePartOfTheImage(BufferedImage img, Rectangle desiredImageArea)
    • getImage

      public BufferedImage getImage()
    • setImage

      public void setImage(BufferedImage image)
      Sets the image that will be shown in the map (also sets some interally used flags)
      Parameters:
      image - image that will be shown in the map
    • setImageSet

      public void setImageSet(boolean imageSet)
    • isImageNull

      public boolean isImageNull()
    • getImageForDisplay

      public BufferedImage getImageForDisplay(LayerViewPanel layerViewPanel) throws Exception
      returns the image, this can be modified - i.e. is just a representation.
      Returns:
      the image
      Throws:
      Exception
    • isImageSet

      public boolean isImageSet()
      Returns:
      true, if the image object was set at least once, else false
    • getTransparencyLevel

      public double getTransparencyLevel()
      Returns the transparency level of the image. The transparencyLevel controlls the transparency level of the whole image (all pixels). It is independent of the transparency color, that replaces a certain color in the image. The transparencyLevel is expressed as a float within a range from 0.0 (no transparency) to 1.0 (full transparency).
      Returns:
      the transparency level of the image
    • setTransparencyLevel

      public void setTransparencyLevel(double transparencyLevel)
      Sets the transparency level of the image. This controlls the transparency level of the whole image (all pixels). It is independent of the transparency color, that replaces a certain color in the image. The transparencyLevel is expressed as a float within a range from 0.0 (no transparency) to 1.0 (full transparency).
      Parameters:
      transparencyLevel - the transparency level of the image
    • setTransparencyLevelInPercent

      public void setTransparencyLevelInPercent(int transparencyInPercent)
      Sets the transparency level of the image. This controlls the transparency level of the whole image (all pixels). It is independent of the transparency color, that replaces a certain color in the image. The transparencyLevel is expressed as a percentage within a range from 0 (no transparency) to 100 (full transparency).
      Parameters:
      transparencyInPercent - the transparency level of the image
    • getTransparentColor

      public Color getTransparentColor()
      Gets the color which will be drawn with a zero opacity in the Jump map
      Returns:
      color that will be replaced with transparent pixels
    • getTransparentColorAsString

      public String getTransparentColorAsString()
      for java2xml
    • setTransparentColorAsString

      public void setTransparentColorAsString(String hexColorString)
      for java2xml
    • setTransparentColor

      public void setTransparentColor(Color transparentColor)
      Sets the color which will be drawn with a zero opacity in the Jump map
      Parameters:
      transparentColor - the color for transparency
    • forceTotalRepaint

      protected void forceTotalRepaint()
      After this method was invoked, the image will be completely re-rendered (not using caches) the next time.
    • getXOffset

      public int getXOffset()
      Returns:
      the current offset (to the viewport's (0,0)) in x direction
    • getYOffset

      public int getYOffset()
      Returns:
      the current offset (to the viewport's (0,0)) in y direction
    • getFreeRamFactor

      public static double getFreeRamFactor()
    • setFreeRamFactor

      public static void setFreeRamFactor(double freeRamFactor)
    • getAvailRAM

      public static long getAvailRAM()
    • getMaxPixelsForFastDisplayMode

      public static int getMaxPixelsForFastDisplayMode()
    • getMinRamToKeepFree

      public static double getMinRamToKeepFree()
    • setImageFileName

      public void setImageFileName(String imageFileName)
      Sets the image's files name (if image is not to be kept) - this needs to be set!
      Parameters:
      imageFileName - the file name of the image
    • getImageFileName

      public String getImageFileName()
      Returns:
      the file name of the image represented by this instance of the RasterImageLayer
    • isNeedToKeepImage

      public boolean isNeedToKeepImage()
      check, if image will be kept in RAM or if it will be reloaded from a file if needed
      Returns:
      true if image will be kept in RAM, else false
    • setNeedToKeepImage

      public void setNeedToKeepImage(boolean needToKeepImage)
      toogle, if image will be kept in RAM or if it will be reloaded from a file if needed
      Parameters:
      needToKeepImage - true if image is supposed be kept in RAM, else false
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • getOrigImageHeight

      public int getOrigImageHeight()
      Returns:
      the height of the source image
    • getOrigImageWidth

      public int getOrigImageWidth()
      Returns:
      the width of the source image
    • setOrigImageHeight

      public void setOrigImageHeight(int origImageHeight)
      for java2xml
      Parameters:
      origImageHeight - height of original image
    • setOrigImageWidth

      public void setOrigImageWidth(int origImageWidth)
      for java2xml
      Parameters:
      origImageWidth - width of original image
    • setVisible

      public void setVisible(boolean visible)
      shows or hides the image in the Jump map
      Specified by:
      setVisible in interface Layerable
      Overrides:
      setVisible in class AbstractLayerable
      Parameters:
      visible - set true if image must be visible
    • isFiringAppearanceEvents

      public boolean isFiringAppearanceEvents()
      Returns:
      true if appearance events are fired automatically, false if not
      See Also:
    • setFiringAppearanceEvents

      public void setFiringAppearanceEvents(boolean firingAppearanceEvents)
      Parameters:
      firingAppearanceEvents - true if appearance events are to be fired automatically, false if not
      See Also:
    • getMetaInformation

      public MetaDataMap getMetaInformation()
      Specified by:
      getMetaInformation in interface ObjectContainingMetaInformation
    • setMetaInformation

      public void setMetaInformation(MetaDataMap metaInformation)
      Specified by:
      setMetaInformation in interface ObjectContainingMetaInformation
    • getRasterData

      public Raster getRasterData(Rectangle subset) throws IOException
      Throws:
      IOException
    • getRectangleFromEnvelope

      public Rectangle getRectangleFromEnvelope(org.locationtech.jts.geom.Envelope envelope)
    • isRasterDataChanged

      public boolean isRasterDataChanged()
      Returns:
      the rasterDataChanged
    • setRasterDataChanged

      public void setRasterDataChanged(boolean rasterDataChanged)
      Parameters:
      rasterDataChanged - the rasterDataChanged to set
    • getNoDataValue

      public double getNoDataValue()
      Default value is NaN. The value can be different when data have been read, for example, from (ESRI) ASCII grid images
      Returns:
      value that is written when a cell does not contain data
    • getNumBands

      public int getNumBands()
      TODO: sstein test - 25.Sept.2013
      Returns:
      number of bands
    • dispose

      public void dispose()
      Specified by:
      dispose in interface Disposable
    • getCellValue

      public Double getCellValue(org.locationtech.jts.geom.Coordinate coordinate, int band) throws IOException
      Throws:
      IOException
    • getCellValue

      public Double getCellValue(int col, int row, int band) throws IOException
      Throws:
      IOException
    • getCellValue

      public Double getCellValue(double coordX, double coordY, int band) throws IOException
      Throws:
      IOException
    • isNoData

      public boolean isNoData(double value)
    • getMetadata

      public Metadata getMetadata()
    • getViewportRectangle

      public static Rectangle getViewportRectangle(WorkbenchContext workbenchContext)
    • getSymbology

      public RasterSymbology getSymbology()
    • setSymbology

      public void setSymbology(RasterSymbology symbology) throws NoninvertibleTransformException
      Throws:
      NoninvertibleTransformException
    • getActualRasterData

      public Raster getActualRasterData()
    • getUUID

      public UUID getUUID()
    • isTemporaryLayer

      public boolean isTemporaryLayer()
      Check if selected sextante raster layer is Temporary layer Both layers in memory and layes stored into TEMP folder are considered as "Temporary layers"
    • getFilePath

      public String getFilePath()
      Returns:
      the file path of a RasterImageLayer.class eg. C/File/imagename.tif. If the file path is a TEMP folder it returns that the layer has no datasource
    • isSpatiallyConsistentWith

      public boolean isSpatiallyConsistentWith(RasterImageLayer rasterImageLayer)
      Check if the RasteImageLayer is spatially consistent with another:
    • both have the same cell size
    • both have the same dimension (same width and height)
    • both overlap to each other into the geographic space
    • Parameters:
      rasterImageLayer - another RasterImageLayer
      Returns:
      true if they are spatially consistent, false if they are not