Class RasterImageLayer
java.lang.Object
com.vividsolutions.jump.workbench.model.AbstractLayerable
com.vividsolutions.jump.workbench.model.GeoReferencedLayerable
org.openjump.core.rasterimage.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
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected doubleprotected org.locationtech.jts.geom.Envelopeprotected static longprotected booleanFlag to decide, if events are fired automatically, if the appearance (imageEnvelope, etc.) changes.
default: trueprotected static doubleprotected BufferedImageprotected Stringprotected Rectangleprotected booleanprotected intprotected static intprotected MetaDataMapprotected static doubleprotected static final intprotected static final intprotected static final intprotected static final intprotected booleanFlag 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.protected doubleprotected intprotected doubleprotected org.locationtech.jts.geom.Envelopeprotected intprotected intprotected doubleprotected booleanprotected BufferedImageprotected booleanprotected doubleprotected Colorprotected org.locationtech.jts.geom.Envelopeprotected Rectangleprotected intprotected int -
Constructor Summary
ConstructorsConstructorDescriptionfor java2xmlRasterImageLayer(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 imageRasterImageLayer(String name, LayerManager layerManager, String imageFileName, BufferedImage imageToDisplay, org.locationtech.jts.geom.Envelope wholeImageEnvelope) -
Method Summary
Modifier and TypeMethodDescriptionbooleanclearImageAndRaster(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, ifgarbageCollectis true.clone()createImage(LayerViewPanel layerViewPanel) Creates the image to drawprotected BufferedImagecreateOneColorImage(Color color) Create a single color image in the case where a single image pixel is visiblevoiddispose()protected voidfinalize()voidflushImages(boolean garbageCollect) flushes all images from the RAM.protected voidAfter this method was invoked, the image will be completely re-rendered (not using caches) the next time.org.locationtech.jts.geom.Envelopeorg.locationtech.jts.geom.Geometrystatic longgetCellValue(double coordX, double coordY, int band) getCellValue(int col, int row, int band) getCellValue(org.locationtech.jts.geom.Coordinate coordinate, int band) protected longgetDrawingRectangle(double imgWidth, double imgHeight, org.locationtech.jts.geom.Envelope imageEnv, Viewport viewport) static doublegetImage()getImageForDisplay(LayerViewPanel layerViewPanel) returns the image, this can be modified - i.e. is just a representation.static intstatic doubledoubleDefault value is NaN.intTODO: sstein test - 25.Sept.2013intintgetRasterData(Rectangle subset) getRectangleFromEnvelope(org.locationtech.jts.geom.Envelope envelope) protected BufferedImagegetScaledImageMatchingVisible(BufferedImage toBeScaled, double XscaleImg2Canvas, double YscaleImg2Canvas) doubleReturns the transparency level of the image.Gets the color which will be drawn with a zero opacity in the Jump mapfor java2xmlgetUUID()static RectanglegetViewportRectangle(WorkbenchContext workbenchContext) protected RectanglegetVisibleImageCoordinatesOfImage(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 coordinateprotected RectanglegetVisibleImageCoordinatesOfImage(BufferedImage img, org.locationtech.jts.geom.Envelope visible, org.locationtech.jts.geom.Envelope imageEnv) protected BufferedImagegetVisiblePartOfTheImage(BufferedImage img, Rectangle desiredImageArea) org.locationtech.jts.geom.Envelopeorg.locationtech.jts.geom.GeometryMethod to change the coordinates of the image and later apply the changes to the RasterImageLayer by usingsetGeometryAsWholeImageEnvelope(Geometry).for java2xmlfor java2xmlintintbooleanbooleanbooleanbooleancheck, if image will be kept in RAM or if it will be reloaded from a file if neededbooleanisNoData(double value) booleanbooleanisSpatiallyConsistentWith(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 spacebooleanCheck if selected sextante raster layer is Temporary layer Both layers in memory and layes stored into TEMP folder are considered as "Temporary layers"static BufferedImagecreates a BufferedImage out of an ImagevoidreLoadImage(LayerViewPanel layerViewPanel) protected BufferedImagescaleImage(BufferedImage im, float xScale, float yScale) apply a scale operation to the image and return the new image.voidsetFiringAppearanceEvents(boolean firingAppearanceEvents) static voidsetFreeRamFactor(double freeRamFactor) voidsetGeometryAsActualImageEnvelope(org.locationtech.jts.geom.Geometry geometry) voidsetGeometryAsWholeImageEnvelope(org.locationtech.jts.geom.Geometry geometry) Method to set the coordinates of the image, e.g. after changing them after usinggetWholeImageEnvelopeAsGeometry().voidsetImage(BufferedImage image) Sets the image that will be shown in the map (also sets some interally used flags)voidsetImageFileName(String imageFileName) Sets the image's files name (if image is not to be kept) - this needs to be set!voidsetImageSet(boolean imageSet) voidsetMetaInformation(MetaDataMap metaInformation) voidsetNeedToKeepImage(boolean needToKeepImage) toogle, if image will be kept in RAM or if it will be reloaded from a file if neededvoidsetOrigImageHeight(int origImageHeight) for java2xmlvoidsetOrigImageWidth(int origImageWidth) for java2xmlvoidsetRasterDataChanged(boolean rasterDataChanged) voidsetSymbology(RasterSymbology symbology) voidsetTransparencyLevel(double transparencyLevel) Sets the transparency level of the image.voidsetTransparencyLevelInPercent(int transparencyInPercent) Sets the transparency level of the image.voidsetTransparentColor(Color transparentColor) Sets the color which will be drawn with a zero opacity in the Jump mapvoidsetTransparentColorAsString(String hexColorString) for java2xmlvoidsetVisible(boolean visible) shows or hides the image in the Jump mapvoidsetXmlActualImageEnvelope(String envStr) voidsetXmlEnvelope(String envStr) for java2xmlvoidsetXmlWholeImageEnvelope(String envStr) for java2xmlprotected BufferedImage**Methods inherited from class GeoReferencedLayerable
getBlackboard, getEnvelope, getSrsInfo, setEnvelope, setSrsInfoMethods inherited from class AbstractLayerable
fireAppearanceChanged, fireLayerChanged, getLayerManager, getMaxScale, getMinScale, getName, getTask, isEditable, isReadonly, isScaleDependentRenderingEnabled, isSelectable, isVisible, setEditable, setLayerManager, setMaxScale, setMinScale, setName, setReadonly, setScaleDependentRenderingEnabled, setSelectable, toString
-
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
-
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
-
origImageWidth
protected int origImageWidth -
origImageHeight
protected int origImageHeight -
imageSet
protected boolean imageSet -
image
-
numBands
protected int numBands -
rasterDataChanged
protected boolean rasterDataChanged -
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 firingAppearanceEventsFlag to decide, if events are fired automatically, if the appearance (imageEnvelope, etc.) changes.
default: true -
needToKeepImage
protected boolean needToKeepImageFlag 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
-
transparencyColorNeedsToBeApplied
protected boolean transparencyColorNeedsToBeApplied -
noDataValue
protected double noDataValue -
originalCellSize
protected double originalCellSize -
actualCellSize
protected double actualCellSize -
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 layerlayerManager- the LayerManagerimageFileName- the name of the image fileimageToDisplay- the image (if already loaded) or nullwholeImageEnvelope- 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 layerlayerManager- the LayerManagerimageToDisplay- the image (if already loaded) or nullnewRaster- the raster (if already loaded) or nullwholeImageEnvelope- the image envelope in model (real world) coordinates
-
-
Method Details
-
getXmlEnvelope
-
setXmlEnvelope
-
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
scaleImage
apply a scale operation to the image and return the new image. -
createOneColorImage
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
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, ifgarbageCollectis 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
- Throws:
Exception
-
stretchImageValuesForDisplay
**- 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
-
getXmlActualImageEnvelope
-
setXmlWholeImageEnvelope
for java2xml- Parameters:
envStr- the Envelope as string
-
setXmlActualImageEnvelope
-
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 usingsetGeometryAsWholeImageEnvelope(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 usinggetWholeImageEnvelopeAsGeometry(). -
setGeometryAsActualImageEnvelope
public void setGeometryAsActualImageEnvelope(org.locationtech.jts.geom.Geometry geometry) -
makeBufferedImage
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 widthimgHeight- original image heightviewportEnv- viewport in model coordinatesimageEnv- 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
-
getImage
-
setImage
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
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
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
for java2xml -
setTransparentColorAsString
for java2xml -
setTransparentColor
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
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
- 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
-
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:
setVisiblein interfaceLayerable- Overrides:
setVisiblein classAbstractLayerable- 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
- Specified by:
getMetaInformationin interfaceObjectContainingMetaInformation
-
setMetaInformation
- Specified by:
setMetaInformationin interfaceObjectContainingMetaInformation
-
getRasterData
- Throws:
IOException
-
getRectangleFromEnvelope
-
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:
disposein interfaceDisposable
-
getCellValue
public Double getCellValue(org.locationtech.jts.geom.Coordinate coordinate, int band) throws IOException - Throws:
IOException
-
getCellValue
- Throws:
IOException
-
getCellValue
- Throws:
IOException
-
isNoData
public boolean isNoData(double value) -
getMetadata
-
getViewportRectangle
-
getSymbology
-
setSymbology
- Throws:
NoninvertibleTransformException
-
getActualRasterData
-
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
- 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
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
-