org.placelab.demo.mapview
Class MapView

java.lang.Object
  extended byorg.eclipse.swt.widgets.Widget
      extended byorg.eclipse.swt.widgets.Control
          extended byorg.eclipse.swt.widgets.Scrollable
              extended byorg.eclipse.swt.widgets.Composite
                  extended byorg.placelab.util.swt.SwtScrolledComposite
                      extended byorg.placelab.demo.mapview.MapView
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
Direct Known Subclasses:
TrackedMapView

public class MapView
extends SwtScrolledComposite


Field Summary
protected  org.eclipse.swt.events.MouseEvent dragBegin
           
protected  GlyphRectangle dragOutline
           
static boolean drawBorder
           
protected  GlyphHolder holder
           
protected  org.eclipse.swt.graphics.Cursor iconCursor
           
protected  org.eclipse.swt.graphics.Color iconTextBg
           
protected  MapBacking mapData
           
protected  java.util.Vector mapHistory
           
protected  org.eclipse.swt.graphics.Image mapImage
           
protected  GlyphImage mapImageGlyph
           
protected  org.eclipse.swt.graphics.Rectangle oldBounds
           
 java.util.Vector overlays
           
protected  java.util.Vector placeIcons
           
protected  java.util.Hashtable places
           
protected static int SHIFT
           
protected static double SMALL_DEVICE_SIZE
           
protected  double zoom
           
protected  double[] zoomValues
           
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
MapView(org.eclipse.swt.widgets.Composite parent, int style)
           
MapView(org.eclipse.swt.widgets.Composite parent, int style, boolean useScrollBars)
           
 
Method Summary
 void addOverlay(MapViewOverlay overlay)
          Adds an overlay to the mapview.
protected  void clearPlaceIcons()
           
 boolean containsCoordinate(TwoDCoordinate coord)
           
 void doscroll(int x, int y)
           
 void dozoom()
           
 GlyphHolder getHolder()
           
 MapBacking getMapData()
           
 org.eclipse.swt.graphics.Point getMapSize()
           
 double getOriginLat()
          Gets the origin latitude of the currently onscreen map.
 double getOriginLon()
          Gets the origin longitude of the currently onscreen map.
 org.eclipse.swt.widgets.Menu getOverlaysMenu(org.eclipse.swt.widgets.Widget parent)
          Gets an menu containing all of the overlays loaded for the mapview.
 double getPixelsPerLat()
           
 double getPixelsPerLon()
           
 org.eclipse.swt.graphics.Point getPoint(TwoDCoordinate coord)
           
protected static boolean getUseScrollBars(org.eclipse.swt.widgets.Display display)
           
 double getZoom()
           
 void handleKeyPress(org.eclipse.swt.events.KeyEvent e)
           
 boolean isInTigerMode()
           
 boolean isVisible()
           
 int latitudeToPixels(double lat)
           
 int longitudeToPixels(double lon)
           
 void onDispose()
           
 void overlayHasNewTopGlyph(MapViewOverlay overlay)
           
 double pixelsToLatitude(int pixelsY)
           
 double pixelsToLongitude(int pixelsX)
           
protected  boolean placeOnMap(PlaceBacking place)
           
 void removeOverlay(MapViewOverlay overlay)
           
 void saveMapAsImage(java.lang.String path, int imageFlags)
          Dumps the current state of the mapview to an image file at the specified path
 void setMapData(MapBacking d)
           
 void setOrigin(org.eclipse.swt.graphics.Point origin)
          Scrolls the content so that the specified point in the content is in the top left corner.
 void setPlaceSets(java.util.Hashtable placeSets)
          The placeSets are a Hashtable where place set names key to Hashtables where place names key to PlaceBackings
 void setSize(int width, int height)
           
 void setSize(org.eclipse.swt.graphics.Point size)
           
 void setZoom(double zoom)
           
protected  void shift(int x, int y)
           
 void zoomForRectangle(org.eclipse.swt.graphics.Rectangle area)
           
 void zoomIn()
           
 void zoomOut()
           
 
Methods inherited from class org.placelab.util.swt.SwtScrolledComposite
computeSize, getAlwaysShowScrollBars, getContent, getOrigin, layout, setAlwaysShowScrollBars, setContent, setExpandHorizontal, setExpandVertical, setLayout, setMinHeight, setMinSize, setMinSize, setMinWidth, setOrigin
 
Methods inherited from class org.eclipse.swt.widgets.Composite
checkSubclass, getChildren, getLayout, getTabList, layout, setFocus, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBorderWidth, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBounds, setBounds, setCapture, setCursor, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

holder

protected GlyphHolder holder

mapImageGlyph

protected GlyphImage mapImageGlyph

mapImage

protected org.eclipse.swt.graphics.Image mapImage

mapData

protected MapBacking mapData

mapHistory

protected java.util.Vector mapHistory

places

protected java.util.Hashtable places

placeIcons

protected java.util.Vector placeIcons

overlays

public java.util.Vector overlays

iconCursor

protected org.eclipse.swt.graphics.Cursor iconCursor

iconTextBg

protected org.eclipse.swt.graphics.Color iconTextBg

dragBegin

protected org.eclipse.swt.events.MouseEvent dragBegin

dragOutline

protected GlyphRectangle dragOutline

oldBounds

protected org.eclipse.swt.graphics.Rectangle oldBounds

zoomValues

protected double[] zoomValues

zoom

protected double zoom

SHIFT

protected static final int SHIFT
See Also:
Constant Field Values

SMALL_DEVICE_SIZE

protected static final double SMALL_DEVICE_SIZE
See Also:
Constant Field Values

drawBorder

public static boolean drawBorder
Constructor Detail

MapView

public MapView(org.eclipse.swt.widgets.Composite parent,
               int style)

MapView

public MapView(org.eclipse.swt.widgets.Composite parent,
               int style,
               boolean useScrollBars)
Method Detail

isVisible

public boolean isVisible()

getUseScrollBars

protected static boolean getUseScrollBars(org.eclipse.swt.widgets.Display display)

zoomForRectangle

public void zoomForRectangle(org.eclipse.swt.graphics.Rectangle area)

addOverlay

public void addOverlay(MapViewOverlay overlay)
Adds an overlay to the mapview. MapViewOverlays call this themselves when they are created, so you should never have to call it yourself


removeOverlay

public void removeOverlay(MapViewOverlay overlay)

overlayHasNewTopGlyph

public void overlayHasNewTopGlyph(MapViewOverlay overlay)

getOverlaysMenu

public org.eclipse.swt.widgets.Menu getOverlaysMenu(org.eclipse.swt.widgets.Widget parent)
Gets an menu containing all of the overlays loaded for the mapview. The menu items toggle the visibility of the overlays.


zoomIn

public void zoomIn()

zoomOut

public void zoomOut()

getZoom

public double getZoom()

setZoom

public void setZoom(double zoom)

handleKeyPress

public void handleKeyPress(org.eclipse.swt.events.KeyEvent e)

shift

protected void shift(int x,
                     int y)

setOrigin

public void setOrigin(org.eclipse.swt.graphics.Point origin)
Description copied from class: SwtScrolledComposite
Scrolls the content so that the specified point in the content is in the top left corner. If no content has been set, nothing will occur. Negative values will be ignored. Values greater than the maximum scroll distance will result in scrolling to the end of the scrollbar.

Overrides:
setOrigin in class SwtScrolledComposite
Parameters:
origin - the point on the content to appear in the top left corner

onDispose

public void onDispose()

clearPlaceIcons

protected void clearPlaceIcons()

getHolder

public GlyphHolder getHolder()

getMapSize

public org.eclipse.swt.graphics.Point getMapSize()

setMapData

public void setMapData(MapBacking d)

isInTigerMode

public boolean isInTigerMode()

setPlaceSets

public void setPlaceSets(java.util.Hashtable placeSets)
The placeSets are a Hashtable where place set names key to Hashtables where place names key to PlaceBackings


placeOnMap

protected boolean placeOnMap(PlaceBacking place)

getMapData

public MapBacking getMapData()

getOriginLat

public double getOriginLat()
Gets the origin latitude of the currently onscreen map. Note the origin is defined to be the lower left corner


getOriginLon

public double getOriginLon()
Gets the origin longitude of the currently onscreen map. Note the origin is defined to be the lower left corner


getPixelsPerLat

public double getPixelsPerLat()

getPixelsPerLon

public double getPixelsPerLon()

pixelsToLatitude

public double pixelsToLatitude(int pixelsY)

pixelsToLongitude

public double pixelsToLongitude(int pixelsX)

latitudeToPixels

public int latitudeToPixels(double lat)

longitudeToPixels

public int longitudeToPixels(double lon)

getPoint

public org.eclipse.swt.graphics.Point getPoint(TwoDCoordinate coord)

containsCoordinate

public boolean containsCoordinate(TwoDCoordinate coord)

doscroll

public void doscroll(int x,
                     int y)

dozoom

public void dozoom()

setSize

public void setSize(int width,
                    int height)

setSize

public void setSize(org.eclipse.swt.graphics.Point size)

saveMapAsImage

public void saveMapAsImage(java.lang.String path,
                           int imageFlags)
                    throws org.eclipse.swt.SWTException
Dumps the current state of the mapview to an image file at the specified path

Parameters:
path - the path to save the image to
imageFlags - the image type to save as (see org.eclipse.swt.graphics.ImageLoader)
Throws:
org.eclipse.swt.SWTException