us.zuercher.gpx2map.source.dummy
Class DummyMapSource

java.lang.Object
  extended by us.zuercher.gpx2map.source.AbstractCachedMapSource
      extended by us.zuercher.gpx2map.source.AbstractTiledUrlMapSource
          extended by us.zuercher.gpx2map.source.dummy.DummyMapSource
All Implemented Interfaces:
MapSource

public class DummyMapSource
extends AbstractTiledUrlMapSource
implements MapSource

DummyMapSource is a dummy map source. It provides the following:

  1. An example of a minimal MapSource implementation.
  2. A means for testing map plotting without downloading map tiles.
  3. A means for testing all types of properties.
  4. A means of testing multiple built-in map sources since only one "real" implementation exists to date.
DummyMapSource can be enabled by turning on debug mode.

Author:
Stephan Zuercher

Field Summary
private  LatLon nw
          NW corner.
private static List<MapSourcePropertyDescriptor> properties
           
private  LatLon se
          SE corner.
 
Constructor Summary
DummyMapSource()
          Constructs a new DummyMapSource.
 
Method Summary
 void downloadTiles(ProgressMeter meter)
          Copies a single file via a resource URL to the cache location.
protected  int getColumnCount()
          Gets the column count.
 Dimension getImageSize()
          Returns the final size of the image.
 double getMapScale()
          Returns a guess as to the map's scale.
 List<MapSourcePropertyDescriptor> getProperties()
          Returns the property descriptors for the dummy map source.
protected  int getRowCount()
          Gets the row count.
protected  File getTile(int column, int row)
          Retrieves the one-and-only cached tile file.
 Point mapLocationToPixel(LatLon location)
          Maps the given location onto the stitched map image.
 void setBoundingBox(LatLon northWest, LatLon southEast)
          Sets the map bounding box.
 void setProperty(String name, String value)
          Simply validates that the given property name exists and, if it is a choice-based property, that a choice matching value exists.
 
Methods inherited from class us.zuercher.gpx2map.source.AbstractTiledUrlMapSource
download, download, getCompressedCacheFileExtension, stitchTiles
 
Methods inherited from class us.zuercher.gpx2map.source.AbstractCachedMapSource
getCacheDir, setCacheDir
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface us.zuercher.gpx2map.source.MapSource
setCacheDir, stitchTiles
 

Field Detail

properties

private static final List<MapSourcePropertyDescriptor> properties

nw

private LatLon nw
NW corner.


se

private LatLon se
SE corner.

Constructor Detail

DummyMapSource

DummyMapSource()
Constructs a new DummyMapSource.

Method Detail

getColumnCount

protected int getColumnCount()
Gets the column count. Each column represents 0.1 degress of longitude.

Specified by:
getColumnCount in class AbstractTiledUrlMapSource
Returns:
the column count

getRowCount

protected int getRowCount()
Gets the row count. Each column represents 0.1 degress of latitude.

Specified by:
getRowCount in class AbstractTiledUrlMapSource
Returns:
the row count

getTile

protected File getTile(int column,
                       int row)
Retrieves the one-and-only cached tile file.

Specified by:
getTile in class AbstractTiledUrlMapSource
Parameters:
column - column index, ignored
row - row index, ignored
Returns:
the one and only cache tile file.

getProperties

public List<MapSourcePropertyDescriptor> getProperties()
Returns the property descriptors for the dummy map source. Although properties are returned, they're values are not used for any real purpose. This map source should return all types of properties for testing purposes.

Specified by:
getProperties in interface MapSource
Returns:
dummy map source properties

setProperty

public void setProperty(String name,
                        String value)
Simply validates that the given property name exists and, if it is a choice-based property, that a choice matching value exists.

Specified by:
setProperty in interface MapSource
Parameters:
name - property name
value - property value
Throws:
IllegalArgumentException - if the property name is not found or if a choice property value matching the property value is not found

setBoundingBox

public void setBoundingBox(LatLon northWest,
                           LatLon southEast)
Sets the map bounding box.

Specified by:
setBoundingBox in interface MapSource
Parameters:
northWest - the northwest corner
southEast - the southeast corner

downloadTiles

public void downloadTiles(ProgressMeter meter)
                   throws IOException
Copies a single file via a resource URL to the cache location.

Specified by:
downloadTiles in interface MapSource
Parameters:
meter - a progress meter
Throws:
IOException - if there's an error copying the file

mapLocationToPixel

public Point mapLocationToPixel(LatLon location)
Maps the given location onto the stitched map image.

Specified by:
mapLocationToPixel in interface MapSource
Parameters:
location - the latitude/longitude to convert
Returns:
the x,y coordinates of that coordinate on the stitched map.

getImageSize

public Dimension getImageSize()
Returns the final size of the image.

Specified by:
getImageSize in interface MapSource
Returns:
the final size of the image.

getMapScale

public double getMapScale()
Returns a guess as to the map's scale.

Specified by:
getMapScale in interface MapSource
Returns:
a guess as to the map's scale.