org.openjump.core.rasterimage
Class WorldFileHandler

java.lang.Object
  extended by org.openjump.core.rasterimage.WorldFileHandler
All Implemented Interfaces:
HandlerToMakeYourLifeEasier

public class WorldFileHandler
extends java.lang.Object
implements HandlerToMakeYourLifeEasier

class to create a ESRI-Worldfile for RasterImages that are exported from Jump, also for reading existent world files.

Version:
$Rev: 2509 $ modified: [sstein]: 16.Feb.2009 changed logger-entries to comments
Author:
Ole Rahn

FH Osnabrück - University of Applied Sciences Osnabrück,
Project: PIROL (2005),
Subproject: Daten- und Wissensmanagement

Field Summary
protected  java.lang.String imageFileName
           
protected  java.lang.String worldFileName
           
 
Constructor Summary
WorldFileHandler(java.lang.String imageFileName, boolean allwaysLookForTFWExtension)
           
 
Method Summary
protected  java.util.List createListOfWorldFileNamesForImage()
          creates a list of possible worldfile names for the given image file name.
 java.lang.String getImageFileName()
           
 java.lang.String getWorldFileName()
           
 boolean isAllwaysLookForTFWExtension()
           
 java.lang.String isWorldFileExistentForImage()
          Method that checks if a world file for the given image name can be found.
 com.vividsolutions.jts.geom.Envelope readWorldFile(int imgWidth, int imgHeight)
          Retrieve the real world coordinates of the image from the world file
 void setAllwaysLookForTFWExtension(boolean allwaysLookForTFWExtension)
           
 void setImageFileName(java.lang.String imageFileName)
           
 boolean writeWorldFile(com.vividsolutions.jts.geom.Envelope imageCoordinates, int imgWidth, int imgHeight)
          Method that writes a world file according to the given coordinate and image information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

worldFileName

protected java.lang.String worldFileName

imageFileName

protected java.lang.String imageFileName
Constructor Detail

WorldFileHandler

public WorldFileHandler(java.lang.String imageFileName,
                        boolean allwaysLookForTFWExtension)
Parameters:
imageFileName - name of the image file the world file is for
allwaysLookForTFWExtension - if true the worldFileHandler will look for world files with the extension .tfw even if the image file format would suggest an other extension, like .pgw - this parameter has no influence on the writing of world files!
Method Detail

writeWorldFile

public boolean writeWorldFile(com.vividsolutions.jts.geom.Envelope imageCoordinates,
                              int imgWidth,
                              int imgHeight)
Method that writes a world file according to the given coordinate and image information.

Parameters:
imageCoordinates - real world coordinates of the image
imgWidth - width (in pixel) of the image
imgHeight - height (in pixel) of the image
Returns:
true if a world file was written, else false

readWorldFile

public com.vividsolutions.jts.geom.Envelope readWorldFile(int imgWidth,
                                                          int imgHeight)
Retrieve the real world coordinates of the image from the world file

Parameters:
imgWidth - width (in pixel) of the image
imgHeight - height (in pixel) of the image
Returns:
real world coordinates of the image

createListOfWorldFileNamesForImage

protected java.util.List createListOfWorldFileNamesForImage()
creates a list of possible worldfile names for the given image file name. The first one meets the naming conventions from ESRI, the other names are variations that we got from ArcView, far away from conventions...

Returns:
a list of possible worldfile names

isWorldFileExistentForImage

public java.lang.String isWorldFileExistentForImage()
Method that checks if a world file for the given image name can be found. If so, it's name will be returned and also be stored internally.

Returns:
the name of the worldfile if existent, else null

isAllwaysLookForTFWExtension

public boolean isAllwaysLookForTFWExtension()
Returns:
Returns the allwaysLookForTFWExtension.

setAllwaysLookForTFWExtension

public void setAllwaysLookForTFWExtension(boolean allwaysLookForTFWExtension)
Parameters:
allwaysLookForTFWExtension - The allwaysLookForTFWExtension to set.

getImageFileName

public java.lang.String getImageFileName()
Returns:
Returns the imageFileName.

setImageFileName

public void setImageFileName(java.lang.String imageFileName)
Parameters:
imageFileName - The imageFileName to set.

getWorldFileName

public java.lang.String getWorldFileName()
Returns:
Returns the worldFileName.