net.refractions.udig.project.ui.viewers
Class MapViewer

java.lang.Object
  extended by net.refractions.udig.project.ui.viewers.MapViewer

public class MapViewer
extends java.lang.Object

A concrete viewer based on a ViewportPane widget.

In order to facilitate experimentation with a range of GIS widgets we have created a JFace "viewer" for working with a Map.

Since:
1.1.0
Author:
Jody Garnett

Field Summary
protected  Map map
          This is the current map.
protected  ViewportPane viewport
          This viewer's ViewportPane control.
 
Constructor Summary
MapViewer(Composite parent)
          Creates a map viewer on a newly-created viewport pane under the given parent.
MapViewer(Composite parent, int style)
          Creates a table viewer on a newly-created table control under the given parent.
 
Method Summary
 void dispose()
           
 Control getControl()
          Access to the control (often this is the same as getViewport().
 Map getMap()
          This is the Map; you can send addLayer commands and so forth to this.
 Menu getMenu()
           
 RenderManager getRenderManager()
          The render manager responsible for rendering items in this view.
protected  ToolContext getToolContext()
           
 ViewportPane getViewport()
          Access to the ViewportPane
 void init(WorkbenchPart part)
          Used to internal "MapPart" to the provided WorkbenchPart (any status messages etc..
 void openContextMenu()
          Will open the menu provided by getMenu().
 void setFont(Control control)
           
 void setMap(Map map)
          Used to ask the widget to display the provided map.
 void setMenu(Menu contextMenu)
          Context menu to be made visible as needed by tools.
 void setModalTool(ModalTool tool)
          Accept the provided tool; call setContext; and activate the tool.
 void setResolutions(double[] resolutions)
          For resolutions consider:
 void setSelectionProvider(IMapEditorSelectionProvider selectionProvider)
           
 void zoomTo(int level)
          Will zoom to the appropriate level (if a zoom model has been provided by setResolutions call).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

viewport

protected ViewportPane viewport
This viewer's ViewportPane control.


map

protected Map map
This is the current map.

Constructor Detail

MapViewer

public MapViewer(Composite parent)
Creates a map viewer on a newly-created viewport pane under the given parent.

The viewport pane is created using the SWT style bits MULTI, H_SCROLL, V_SCROLL, and BORDER. The viewer has no input, no content provider, a default label provider, no sorter, and no filters. The table has no columns.

Parameters:
parent - the parent control

MapViewer

public MapViewer(Composite parent,
                 int style)
Creates a table viewer on a newly-created table control under the given parent. The table control is created using the given style bits. The viewer has no input, no content provider, a default label provider, no sorter, and no filters. The table has no columns.

Parameters:
parent - the parent control
style - Use SWT.SINGLE or SWT.MULTI to control the use of tiles, SWT.DOUBLE_BUFFERED and SWT.NO_BACKGROUND can be used to configure the canvas.
Method Detail

init

public void init(WorkbenchPart part)
Used to internal "MapPart" to the provided WorkbenchPart (any status messages etc.. would be sent to the view or editor provided).

This is an *optional* step; if you can call this method setSelectionProvider will work.

Parameters:
part - Editor or View workbench part

getViewport

public ViewportPane getViewport()
Access to the ViewportPane

The Viewport is usually an SWT widget; to be sure check getControl().

Returns:
viewport used to display the map

getControl

public Control getControl()
Access to the control (often this is the same as getViewport().

You use this to work with DnD or context menu integration tasks.

Returns:
control May be null if SWT not used, the viewport does not extend Control, or if disposed.

getRenderManager

public RenderManager getRenderManager()
The render manager responsible for rendering items in this view.

Returns:

getMap

public Map getMap()
This is the Map; you can send addLayer commands and so forth to this.


setMap

public void setMap(Map map)
Used to ask the widget to display the provided map.

This method will register a listener on the provided map and the viewer will refresh as the map state changes.

Parameters:
map - to display; or null for none.

setMenu

public void setMenu(Menu contextMenu)
Context menu to be made visible as needed by tools.

Parameters:
contextMenu -

getMenu

public Menu getMenu()

openContextMenu

public void openContextMenu()
Will open the menu provided by getMenu().

This method is called by tools to open the context menu


setModalTool

public void setModalTool(ModalTool tool)
Accept the provided tool; call setContext; and activate the tool.

The tool is responsible for registering any mouse listeners it requires when setActive( true ) is called. When the tool is replaced setActive( false ) will be called allowing you to clean up your listeners.

Parameters:
tool -

getToolContext

protected ToolContext getToolContext()
Returns:
tool context (used to teach tools about our MapViewer facilities.

setFont

public void setFont(Control control)

setSelectionProvider

public void setSelectionProvider(IMapEditorSelectionProvider selectionProvider)

dispose

public void dispose()

setResolutions

public void setResolutions(double[] resolutions)
For resolutions consider:

 WMSTileSet tileSet = (res.resolve( WMSTileSet.class, null ));
 theResolutions = tileSet.getResolutions();
 


zoomTo

public void zoomTo(int level)
Will zoom to the appropriate level (if a zoom model has been provided by setResolutions call).

Parameters:
level -