de.fhpotsdam.unfolding.utils
Class LargeMapImageUtils

java.lang.Object
  extended by de.fhpotsdam.unfolding.utils.LargeMapImageUtils

public class LargeMapImageUtils
extends java.lang.Object

Utility class to save large map images. Can be used to create high resolution screenshots for print. Everything currently visible on the map (tiles and markers) will be in the image. This process happens on-screen, thus the map can not be used while this tool is running. It will automatically pan to different areas of the map, stitch them together, and save them in one single image. To customize, set location, zoomLevel, and totalWidth and totalHeight. The latter two should be multiples of xStep and yStep. You can also set file name, or file prefix and file suffix of the large image to be saved. Please note the respective terms of service of the map provider!


Field Summary
protected  processing.core.PApplet p
           
protected  int totalHeight
           
protected  int totalWidth
           
protected  int xStep
           
protected  int yStep
           
 
Constructor Summary
LargeMapImageUtils(processing.core.PApplet p, UnfoldingMap map)
          Creates a new LargeMapImageUtils which stores a large image double the size of the canvas.
LargeMapImageUtils(processing.core.PApplet p, UnfoldingMap map, int stitchNumber)
           
LargeMapImageUtils(processing.core.PApplet p, UnfoldingMap map, int xStep, int yStep, int totalWidth, int totalHeight)
           
LargeMapImageUtils(processing.core.PApplet p, UnfoldingMap map, Location location, int zoomLevel)
           
LargeMapImageUtils(processing.core.PApplet p, UnfoldingMap map, Location location, int zoomLevel, int stitchNumber)
           
LargeMapImageUtils(processing.core.PApplet p, UnfoldingMap map, Location location, int zoomLevel, int xStep, int yStep, int totalWidth, int totalHeight)
           
 
Method Summary
 void init()
          Initializes a new large map image around the current map center.
 void init(Location location, int zoomLevel)
          Initializes a new large map image around the location.
 processing.core.PImage makeSnapshot()
           
protected  void renderAndMakeSnapshot(int shotX, int shotY)
          Internal method to get the current map canvas (incl markers) and stores it in an buffer image.
 void run()
          Runs the recording process.
protected  void saveLargeImage()
          Internal method to save the actual large stitched-together image in one file.
 void setImageFileName(java.lang.String imageFileName)
          The full name of the final large image.
 void setImageFilePrefix(java.lang.String imageFilePrefix)
          Sets the prefix of the final large image file.
 void setImageFileSuffix(java.lang.String imageFileSuffix)
          Sets the suffix of the final large image file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

p

protected processing.core.PApplet p

xStep

protected int xStep

yStep

protected int yStep

totalWidth

protected int totalWidth

totalHeight

protected int totalHeight
Constructor Detail

LargeMapImageUtils

public LargeMapImageUtils(processing.core.PApplet p,
                          UnfoldingMap map)
Creates a new LargeMapImageUtils which stores a large image double the size of the canvas.

Parameters:
p - The PApplet
map - The map to take screenshots from.

LargeMapImageUtils

public LargeMapImageUtils(processing.core.PApplet p,
                          UnfoldingMap map,
                          int stitchNumber)

LargeMapImageUtils

public LargeMapImageUtils(processing.core.PApplet p,
                          UnfoldingMap map,
                          Location location,
                          int zoomLevel)

LargeMapImageUtils

public LargeMapImageUtils(processing.core.PApplet p,
                          UnfoldingMap map,
                          Location location,
                          int zoomLevel,
                          int stitchNumber)

LargeMapImageUtils

public LargeMapImageUtils(processing.core.PApplet p,
                          UnfoldingMap map,
                          Location location,
                          int zoomLevel,
                          int xStep,
                          int yStep,
                          int totalWidth,
                          int totalHeight)

LargeMapImageUtils

public LargeMapImageUtils(processing.core.PApplet p,
                          UnfoldingMap map,
                          int xStep,
                          int yStep,
                          int totalWidth,
                          int totalHeight)
Method Detail

init

public void init()
Initializes a new large map image around the current map center. Pans to the upper left corner, and start the recording process.


init

public void init(Location location,
                 int zoomLevel)
Initializes a new large map image around the location. Pans to the upper left corner, and start the recording process.

Parameters:
location - The location to center around.
zoomLevel - The zoom level to use.

run

public void run()
Runs the recording process. It will automatically pan to different areas of the map, stitch them together, and save them in one single image, at the end.


saveLargeImage

protected void saveLargeImage()
Internal method to save the actual large stitched-together image in one file.


renderAndMakeSnapshot

protected void renderAndMakeSnapshot(int shotX,
                                     int shotY)
Internal method to get the current map canvas (incl markers) and stores it in an buffer image.

Parameters:
shotX - Current x position of the large image to store the current screenshot to.
shotY - Current y position of the large image to store the current screenshot to.

makeSnapshot

public processing.core.PImage makeSnapshot()

setImageFilePrefix

public void setImageFilePrefix(java.lang.String imageFilePrefix)
Sets the prefix of the final large image file. Actual file name will be prefix + number + suffix.

Parameters:
imageFilePrefix - A image file prefix (supported by Processing, i.e. '.tif', '.png', '.jpg').

setImageFileSuffix

public void setImageFileSuffix(java.lang.String imageFileSuffix)
Sets the suffix of the final large image file. Actual file name will be prefix + number + suffix.

Parameters:
imageFileSuffix - A image file suffix, e.g. 'largeImage-'.

setImageFileName

public void setImageFileName(java.lang.String imageFileName)
The full name of the final large image. If set, the LargeMapImageUtils won't automatically include a number.

Parameters:
imageFileName - A file name.