de.fhpotsdam.unfolding.mapdisplay
Class Java2DMapDisplay

java.lang.Object
  extended by de.fhpotsdam.unfolding.mapdisplay.AbstractMapDisplay
      extended by de.fhpotsdam.unfolding.mapdisplay.Java2DMapDisplay
All Implemented Interfaces:
TileLoaderListener, processing.core.PConstants
Direct Known Subclasses:
OpenGLMapDisplay

public class Java2DMapDisplay
extends AbstractMapDisplay
implements processing.core.PConstants

The internal MapDisplay to handle the map display in Processing 2D (and used as super class for 3D)


Nested Class Summary
 
Nested classes/interfaces inherited from class de.fhpotsdam.unfolding.mapdisplay.AbstractMapDisplay
AbstractMapDisplay.QueueSorter, AbstractMapDisplay.ZoomComparator
 
Field Summary
protected  java.lang.Integer bgColor
           
protected  processing.core.PMatrix3D innerMatrix
          The inner transformation matrix.
static org.apache.log4j.Logger log
           
protected  processing.core.PMatrix3D matrix
          The outer transformation matrix.
 processing.core.PApplet papplet
           
 
Fields inherited from class de.fhpotsdam.unfolding.mapdisplay.AbstractMapDisplay
allTilesLoaded, angle, grid_padding, height, images, innerAngle, innerOffsetX, innerOffsetY, innerScale, innerTransformationCenter, markerManagerList, max_images_to_keep, max_pending, offsetX, offsetY, pending, provider, queue, queueSorter, recent_images, scale, TILE_HEIGHT, TILE_WIDTH, transformationCenter, width, zoomComparator
 
Fields inherited from interface processing.core.PConstants
ADD, ALPHA, ALT, AMBIENT, ARC, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BEZIER_VERTEX, BLEND, BLUR, BOTTOM, BOX, BREAK, BURN, CENTER, CHATTER, CHORD, CLAMP, CLOSE, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CURVE_VERTEX, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_DEPTH_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_ERRORS, DISABLE_OPTIMIZED_STROKE, DISABLE_RETINA_PIXELS, DISABLE_STROKE_PERSPECTIVE, DISABLE_STROKE_PURE, DISABLE_TEXTURE_MIPMAPS, DODGE, DOWN, DXF, ELLIPSE, ENABLE_DEPTH_MASK, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_ERRORS, ENABLE_OPTIMIZED_STROKE, ENABLE_RETINA_PIXELS, ENABLE_STROKE_PERSPECTIVE, ENABLE_STROKE_PURE, ENABLE_TEXTURE_MIPMAPS, ENTER, EPSILON, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, GIF, GRAY, GROUP, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LANDSCAPE, LEFT, LIGHTEST, LINE, LINE_LOOP, LINE_STRIP, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NORMAL, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, PIE, platformNames, POINT, POINTS, POLYGON, PORTRAIT, POSTERIZE, PROBLEM, PROJECT, PROJECTION, QUAD, QUAD_BEZIER_VERTEX, QUAD_STRIP, QUADRATIC_VERTEX, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RECT, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPHERE, SPOT, SQUARE, SUBTRACT, TAB, TARGA, TAU, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, VERTEX, WAIT, WHITESPACE, WINDOWS, X, Y, Z
 
Constructor Summary
Java2DMapDisplay(processing.core.PApplet papplet, AbstractMapProvider provider)
          Creates a new MapDisplay with full canvas size, and given provider
Java2DMapDisplay(processing.core.PApplet papplet, AbstractMapProvider provider, float offsetX, float offsetY, float width, float height)
          Creates a new MapDisplay.
 
Method Summary
 void calculateInnerMatrix()
           
 void calculateMatrix()
          Updates the matrix to transform the map with.
protected  TileLoader createTileLoader(Coordinate coord)
           
 void draw()
          Draws the on the PGraphics canvas.
 float[] getInnerObject(ScreenPosition screenPosition)
           
 float[] getInnerObjectFromLocation(Location location)
           
 float[] getInnerObjectFromObjectPosition(float x, float y)
           
 float[] getInnerObjectFromScreenPosition(float x, float y)
          Deprecated. 
 processing.core.PGraphics getInnerPG()
           
 Location getLocation(float x, float y)
           
 Location getLocation(ScreenPosition screenPosition)
           
 Location getLocationFromInnerObjectPosition(float x, float y)
           
 Location getLocationFromObjectPosition(float x, float y)
           
 Location getLocationFromScreenPosition(float x, float y)
          Deprecated. 
 float[] getObjectFromInnerObjectPosition(float x, float y)
           
 float[] getObjectFromLocation(Location location)
           
 float[] getObjectFromScreenPosition(float x, float y)
           
 processing.core.PGraphics getOuterPG()
           
 float[] getScreenFromInnerObjectPosition(float x, float y)
           
 float[] getScreenFromObjectPosition(float x, float y)
           
 ScreenPosition getScreenPosition(Location location)
           
 float[] getScreenPositionFromLocation(Location location)
          Deprecated. 
protected  float[] getTransformedPosition(float x, float y, boolean inverse)
          Calculates offset and rotation for screen canvas position, to be used with the internal transformation matrix.
protected  java.util.Vector getVisibleKeys(processing.core.PGraphics pg)
           
protected  void postDraw()
          Is called last in draw().
 void setBackgroundColor(java.lang.Integer color)
          Sets background color of map.
 void tilesLoaded()
          Gets called if all tiles have been loaded.
 
Methods inherited from class de.fhpotsdam.unfolding.mapdisplay.AbstractMapDisplay
addMarker, addMarkerManager, addMarkers, allTilesLoaded, cleanupImageBuffer, cleanupImageBuffer, createDefaultMarkerManager, getDefaultMarkerManager, getHeight, getInnerTransformationCenter, getLastMarkerManager, getMapProvider, getMarkerManager, getMarkerManager, getMarkerManagerList, getMask, getTransformationCenter, getWidth, grabTile, processQueue, removeMarkerManager, removeMarkerManager, resize, setInnerTransformationCenter, setMapProvider, setProvider, setTransformationCenter, tileLoaded
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static org.apache.log4j.Logger log

papplet

public processing.core.PApplet papplet

innerMatrix

protected processing.core.PMatrix3D innerMatrix
The inner transformation matrix. Scales and rotates the map.


matrix

protected processing.core.PMatrix3D matrix
The outer transformation matrix. Rotates the map pane.


bgColor

protected java.lang.Integer bgColor
Constructor Detail

Java2DMapDisplay

public Java2DMapDisplay(processing.core.PApplet papplet,
                        AbstractMapProvider provider)
Creates a new MapDisplay with full canvas size, and given provider


Java2DMapDisplay

public Java2DMapDisplay(processing.core.PApplet papplet,
                        AbstractMapProvider provider,
                        float offsetX,
                        float offsetY,
                        float width,
                        float height)
Creates a new MapDisplay.

Method Detail

tilesLoaded

public void tilesLoaded()
Gets called if all tiles have been loaded. Invokes the tilesLoaded method in the client application if existing. TODO Pass the ID of this map to the method to enable handling multiple maps.

Specified by:
tilesLoaded in class AbstractMapDisplay

calculateMatrix

public void calculateMatrix()
Updates the matrix to transform the map with. For the rotation the matrix has to be temporarily translated to the transformation center. Thus, it has to be reset with the original position, afterwards. Original position is calculated by inverting the current matrix. (As the matrix incorporates that position, it stores every transformation, even though the matrix is created anew.)

Specified by:
calculateMatrix in class AbstractMapDisplay

calculateInnerMatrix

public void calculateInnerMatrix()
Specified by:
calculateInnerMatrix in class AbstractMapDisplay

getObjectFromScreenPosition

public float[] getObjectFromScreenPosition(float x,
                                           float y)
Specified by:
getObjectFromScreenPosition in class AbstractMapDisplay

getScreenFromObjectPosition

public float[] getScreenFromObjectPosition(float x,
                                           float y)
Specified by:
getScreenFromObjectPosition in class AbstractMapDisplay

getTransformedPosition

protected float[] getTransformedPosition(float x,
                                         float y,
                                         boolean inverse)
Description copied from class: AbstractMapDisplay
Calculates offset and rotation for screen canvas position, to be used with the internal transformation matrix.

Specified by:
getTransformedPosition in class AbstractMapDisplay
Parameters:
x - Cartesian x coordinate.
y - Cartesian y coordinate.
inverse - Indicates back and forward matrix calculation. Inverse is used for point2location, non-inverse for location2point.
Returns:
An 1d-2elements-array with x and y.

getObjectFromInnerObjectPosition

public float[] getObjectFromInnerObjectPosition(float x,
                                                float y)
Specified by:
getObjectFromInnerObjectPosition in class AbstractMapDisplay

getInnerObjectFromObjectPosition

public float[] getInnerObjectFromObjectPosition(float x,
                                                float y)
Specified by:
getInnerObjectFromObjectPosition in class AbstractMapDisplay

getScreenFromInnerObjectPosition

public float[] getScreenFromInnerObjectPosition(float x,
                                                float y)
Specified by:
getScreenFromInnerObjectPosition in class AbstractMapDisplay

getInnerObjectFromScreenPosition

@Deprecated
public float[] getInnerObjectFromScreenPosition(float x,
                                                           float y)
Deprecated. 

Specified by:
getInnerObjectFromScreenPosition in class AbstractMapDisplay

getInnerObject

public float[] getInnerObject(ScreenPosition screenPosition)
Specified by:
getInnerObject in class AbstractMapDisplay

getObjectFromLocation

public float[] getObjectFromLocation(Location location)
Specified by:
getObjectFromLocation in class AbstractMapDisplay

getLocationFromInnerObjectPosition

public Location getLocationFromInnerObjectPosition(float x,
                                                   float y)
Specified by:
getLocationFromInnerObjectPosition in class AbstractMapDisplay

getLocationFromScreenPosition

@Deprecated
public Location getLocationFromScreenPosition(float x,
                                                         float y)
Deprecated. 

Specified by:
getLocationFromScreenPosition in class AbstractMapDisplay

getLocation

public Location getLocation(float x,
                            float y)
Specified by:
getLocation in class AbstractMapDisplay

getLocation

public Location getLocation(ScreenPosition screenPosition)
Specified by:
getLocation in class AbstractMapDisplay

getLocationFromObjectPosition

public Location getLocationFromObjectPosition(float x,
                                              float y)
Specified by:
getLocationFromObjectPosition in class AbstractMapDisplay

getInnerObjectFromLocation

public float[] getInnerObjectFromLocation(Location location)
Specified by:
getInnerObjectFromLocation in class AbstractMapDisplay

getScreenPosition

public ScreenPosition getScreenPosition(Location location)
Specified by:
getScreenPosition in class AbstractMapDisplay

getScreenPositionFromLocation

@Deprecated
public float[] getScreenPositionFromLocation(Location location)
Deprecated. 

Specified by:
getScreenPositionFromLocation in class AbstractMapDisplay

getInnerPG

public processing.core.PGraphics getInnerPG()
Specified by:
getInnerPG in class AbstractMapDisplay

getOuterPG

public processing.core.PGraphics getOuterPG()
Specified by:
getOuterPG in class AbstractMapDisplay

postDraw

protected void postDraw()
Is called last in draw(). May be implemented in sub-classes to handle drawing on outerPG.


draw

public void draw()
Draws the on the PGraphics canvas.

Specified by:
draw in class AbstractMapDisplay

setBackgroundColor

public void setBackgroundColor(java.lang.Integer color)
Sets background color of map.

Specified by:
setBackgroundColor in class AbstractMapDisplay
Parameters:
color - Color for the background canvas. Can be semi-transparent. If null it is not used.

getVisibleKeys

protected java.util.Vector getVisibleKeys(processing.core.PGraphics pg)

createTileLoader

protected TileLoader createTileLoader(Coordinate coord)
Specified by:
createTileLoader in class AbstractMapDisplay