Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
In JMap, map elements are objects (points, lines, polygons, text, etc.) that make up the map. The classes of these elements are all derived from the abstract class K2DElement. Map elements are organized into layers that are displayed in a JMap application within a view (View class). Each map element is associated with a geometry (Geometry interface) and has a digital identifier as well as a certain number of attributes. The map element does not directly contain any geometry information. Instead, it is the associated geometry that contains all of the geometry coordinates. Element identifiers found within the same layer must be unique. The GeneratedUniqueId() utility method of the K2DElement abstract class allows you to generate a sequence of unique identifiers for the elements.
The following example demonstrates how to create map elements:
// Create a point geometry Point
pointGeometry = new Point.Double(100., 100.);
// Create the element using the geometry, null attributes and auto generated id
K2DPoint point = new K2DPoint(pointGeometry, null, K2DElement.generateUniqueId());
// Create a line geometry Point
pointGeometry1 = new Point.Double(100., 100.);
Point pointGeometry2 = new Point.Double(200., 200.);
Line lineGeometry = new Line(pointGeometry1, pointGeometry2);
// Create some attributes
String attrib1 = "some value";
Integer attrib2 = new Integer(999);
// Create the element using the geometry, 2 attributes and auto generated id
K2DPolyline line = new K2DPolyline(lineGeometry, new Object[] {attrib1, attrib2}, K2DElement.generateUniqueId());
Map elements normally have values for their attributes. These values are the descriptive data of the map elements. All elements within the same layer possess the same list of attributes (same names, same types). Note that the elements contain only the values of the attributes (table or chart of objects) and not their definition. The definition of these attributes is managed at the layer level, using the Attribute class.
The list of attributes for the elements of a layer is determined by the JMap administrator when the layer (linked attributes) is created. The types of attributes are defined using Java constants for the SQL types (java.sql.Types class).
Element attributes are used for many functions such as tooltips, labels, thematics, and filtering.
The following example demonstrates how to access the values of element attributes:
K2DElement element = ... Object[] attributeValues = element.getAttributes();
for (int i = 0; i < attributeValues.lenght; i++)
{
System.out.println(i + " : " + attributeValues[i]);
}
The following example demonstrates how to access the definition of a layer’s attributes.
VectorLayer layer= ...
Attribute[] attributes = layer.getAttributeMetaData();
for (int i = 0; i < attributes .lenght; i++)
{
System.out.println(i + " name : " + attributes[i].getName());
System.out.println(i + " title : " + attributes[i].getTitle());
System.out.println(i + " type: " + attributes[i].getType());
}
When elements are drawn on the map, a style object is used to determine the visual aspects of the elements. Instances of the Style class have properties such as line color, fill color, letter font, transparency, etc. Each layer will have one or more styles. The style used for displaying the elements is based on the scale of the map and whether or not it contains thematics. Thematics dictate the style of the displayed elements based on the attribute values of these elements.
The following example demonstrates how to obtain the style used for a layer according to a particular scale. Here the presence of thematics on the layer is not taken into account.
K2DElement element = ...
VectorLayer layer = ...
Style style = layer.getStyle(view.getScaleFactor());
The following example demonstrates how to obtain the style used to display a specific element at a given scale. The resulting style does not take into account the presence of thematics on the layer.
K2DElement element = ...
VectorLayer layer = ...
Style style = layer.getStyle(element, view.getScaleFactor());
Style properties can be modified by calling the methods of the Style class. The following example demonstrates how to modify the style parameters of a layer of polygons at the current map scale.
VectorLayer layerOfPolygons = ...
Style style = layerOfPolygons.getStyle(view.getScaleFactor());
style.setBorderColor(Color.BLACK);
style.setFillColor(Color.BLUE);
style.setTransparency(.5f); // 50% transparent
The bounding rectangle of a displayed map element is the smallest rectangle in device coordinates (DC) that completely contains the element, taking its style into account. The style of an element influences the bounding rectangle displayed. For example, a thick polygon border will increase the size of the bounding rectangle, and the size of a point symbol will determine the size of the bounding rectangle on display, and so forth.
The following code example shows how to obtain the bounding rectangle of a displayed map element:
K2DElement element = ...
View view = ...
VectorLayer layer = ...
Rectangle displayBounds = element.getDisplayBounds(view.getTransform(), layer.getStyle(element, view.getScaleFactor()));
Note that the getDisplayBounds method takes the transformation of the view (refer to Coordinate Systems) and element style as parameters.
The map elements of vector layers can be selected. A variety of tools allow the user to select elements in the vector layers of a JMap project.
The K2DElement class has a property called selected that indicates whether or not an element is selected. Selected elements are displayed using a different style, which is the selection style of the vector layer.
Vector layers manage the list of their selected elements. The API of the VectorLayer class offers several methods related to selecting elements. See Layers and Layer Manager for more information on this topic.
The following source code example shows how to select and unselect elements.
K2DElement element = ...
VectorLayer layer = ...
// add the element to the current selection
layer.addToSelection(element);
// test if element is selected, useless, just to demonstrate boolean
isSelected = element.isSelected();
// cycle through selection
Collection selection = layer.getSelection();
for (K2DElement element : selection)
System.out.println(element));
// unselect element
layer.unselectElement(element);
// clear layer selection
layer.clearSelection();
Styled elements (K2DStyledElement class) are special map elements. They have their own style and they ignore the style of the layer that contains them when they are displayed. They are useful when programmatically adding elements to the map that have their own style. Aside from this difference, styled elements behave exactly like any other map elements.
The following coding example shows how to create styled elements.
K2DElement element = ...
Style style = ...
K2DStyledElement styledElem = new K2DStyledElement(element, style);
// element will use this style to draw itself
The following class diagram shows a simplified version of JMap Pro’s architecture.
Two coordinate systems are used in JMap Pro programming: the WC or World Coordinates system and the DC or Device Coordinates system. The WC system is the system used for the original data and the DC system is used for the screen that will display the map.
All the geometry coordinates in JMap are in WC. For example, if your data uses the MTM zone 8 projection, the values of the coordinates will be similar to (300 000, 5 000 000). If your data is not projected, it will be in longitude and latitude and its range will be from -180 to 180 degrees east-west and from -90 to 90 degrees north-south
The computer screen used to display the map is divided into pixels with the coordinates (0,0) showing on the top left part of the screen. This is the DC system. When you are working with mouse-clicked events (i.e., MouseClicked) in a JMap application, you are working with DC coordinates contained in the event and expressed in pixels.
In JMap programming, WC coordinates must frequently be transformed into DC and vice-versa. When the map elements of a layer are drawn on the screen, their coordinates are converted from WC to DC on the fly in order to light up the appropriate pixels on the screen. However, when a mouse click occurs on the map, the DC coordinates of the mouse cursor are transformed into WC coordinates in order to select the appropriate element on the map.
The K2DTransform class contains an affine transformation matrix used to convert data between the DC and WC systems. It provides methods to transform the coordinates in both directions. Each map in JMap (View class) has its own transformation instance.
The following source code example demonstrates how to transform WC coordinates into DC.
K2DTransform transform = ...
Point pointWC;
Point pointDC;
// Transform a point from WC to DC
pointWC = new Point.Double(100., 100.);
pointDC = transform.transform(pointWC);
// Transform a point from DC to WC
pointDC = new Point.Double(100., 100.);
pointWC = transform.transformInv(pointDC);
The following source code example demonstrates how to transform DC coordinates resulting from a mouse click event to WC. The transformation is obtained from the view.
View view = ...
K2DTransform transform = view.getTransform();
MouseEvent e = ...
Point pointWC = transform.transformInv(new Point.Double(e.getX(), e.getY()));
The following source code example demonstrates how to transform DC coordinates using a mouse click event. This simple method is only available from a tool class derived from the Tool class.
Point pointWC = Tool.toWCPoint(e);
Rectangle transformations (normal or inverted) must be performed with caution: if a rotation is applied to a view, the rectangle that is returned could be overwritten. To prevent this problem, it is preferable to make calculations on an oriented rectangle initialized from the rectangle to be transformed.
View view = ...
final ViewState viewState = view.getViewState();
// Computes the display bounding box of the selection
final Rectangle displaySelectBounds = view.getLayerManager().getDisplaySelectedBounds(viewState, true);
if (displaySelectBounds != null)
{
// Transforms the display bounding box into a WC extent.
final OrientedRectangle selectBounds = viewState.getTransform().transformInv(
new OrientedRectangle.Double(displaySelectBounds)
);
view.zoom(selectBounds);
view.refresh()
}
In JMap, the class is the main GUI component responsible for displaying the map. The methods of this class allow you to control the map (zoom, pan, etc.), to refresh it, to get information on the scale, etc.
The table below shows the main methods of the class.
In JMap, a view generates events in several situations. To get these events, you must register a listener to the view. To get events generated by all open views, it is recommended to register a listener on the View Manager. Read below for more information on this subject.
View view = ...
view.addViewEventListener(new ViewEventListener()
{
@Override
public void viewToolChangedOccurred(ViewToolChangedEvent e)
{
}
...
});
View view = ...
ViewManager viewManager = view.getLayerManager();
viewManager.addViewManagerEventListener(new ViewManagerEventListener()
{
@Override
public void viewAdded(ViewAddedEvent e)
{
}
...
});
Layers ( class and its related classes) are highly important in JMap programming. They contain and manage the map data displayed on the map ( class). There are two main types of layers: vector layers ( class), which contain vector data, and raster layers ( class), which contain raster data (images).
When a project is loaded, the client application gets the layer configuration from the server and creates the related instances in the . Initially, a layer does not contain any data. Its data will only be loaded, in full or in part, after the view has been refreshed, based on the loading mode and display restrictions (visibility state and display thresholds).
In JMap, there are two different modes to load layers: by tile and by region. Vector layers support both modes, but raster layers can only be loaded by region.
Tiled layers divide the region of the layer into rows and columns; each cell is a data tile ( and classes). Since the layers are initially empty at application startup, data tiles will be loaded by the application when they are initially displayed in a view. Once it is loaded in a layer, a tile will be kept in memory for the duration of the session, unless the session expires prematurely or the memory manager decides to delete the tile.
When a data tile request is sent to JMap Server, all geometries ( interface) intersecting the region of the tile will be transferred to the client. Once the tile is received, the geometries will be transformed into elements ( class), which will then be loaded in the of the layer. To avoid duplicating an element in several data tiles, elements that are not completely included in a tile will eventually be moved to the layer’s universe tile.
Layers loaded by region are based on the same structure ( and classes), but they only have a single tile with a variable region. When a change is applied to the transformation matrix of the view and the view is refreshed, layers loaded by region will reload their single tile with the data intersecting the extent of the view.
The Layer class is abstract and therefore cannot be instantiated. However, it provides the basic methods for all layers.
Vector layers have a set of attributes that are common to all elements of the layer. These attributes provide the descriptive data of the layer’s elements.
The layers in JMap generate events in several situations. To get the events generated by a layer, you must register a listener on the layer. To get the events generated by all the layers of the project, it is recommended to register a listener on the layer manager. See below for more information on this subject.
Layer layer = ...
layer.addLayerEventListener(new LayerEventListener()
{
@Override
public void layerSelChangedEventOccurred(LayerSelChangedEvent e)
{
// TODO
}
...
});
The layer manager in JMap generates events. To receive the events generated by a layer manager, you must register a listener on the appropriate layer manager. Note that a listener registered on the layer manager will get the events generated by all the layers handled by the layer manager.
JMap Pro extensions are modules developed in Java that can be added to JMap Pro to enhance its features. Extensions are specified as parameters for applications and are initialized when said applications are launched. Typically, extensions are integrated to the GUI of a JMap Pro application by inserting the buttons and menus that activate the functions provided by the extension.
To develop an extension and make it available to users, you must perform the following two steps:
Develop your extension by creating a Java class derived from the class;
Deploy your extension in JMap Server so it may be accessed by the JMap Pro applications.
See the following sections for more information.
To program JMap Pro extensions, it is important to follow a set of simple rules. This section describes these programming rules.
The first step towards developing a JMap Pro extension consists of programming a class derived from the abstract class . This class contains the following 3 methods, which are called at different moments in the life cycle of the extension:
Parameters are passed to the extension with the init() method, using a Map<String, String> collection. In JMap, there are two predefined parameters that match constants defined in the class:
EXTENSION_PARAMETER_GUI_VISIBLE: Indicates whether the extension’s GUI components (other than toolbars) must be visible when the application is launched.
EXTENSION_PARAMETER_TOOLBAR_VISIBLE: Indicates whether the extension’s toolbars must be visible when the application is launched.
These parameters contain true or false values and they are set by the JMap Administrator when a JMap Pro application is deployed. Your extension must comply with these parameters. An extension can also receive its own settings, which would be set by the JMap Administrator.
The following code example shows how to access the settings from the init() method.
public void init(JMapApplicationContext appContext, Map<String, String> mapExtensionParameters)
{
String param = mapExtensionParameters.get(JMapClientExtension.EXTENSION_PARAMETER_TOOLBAR_VISIBLE);
boolean toolbarVisible = Boolean.parseBoolean(param);
...
}
Most commonly used methods of the JMapApplication class:
As a developer of JMap Pro extensions, you will probably be developing applications that need to communicate between the client side and JMap Server. Whether you need to communicate with your own extension on the server side or to make general requests to JMap Server, the programming principle is the same.
To create your request class, you must observe the two following rules:
All of the class’s properties must be serializable.
You are free to add all the properties and methods that are useful to executing your request. These properties and methods can be used by your extension on the server side.
The following source code example demonstrates how to program a simple request.
// This request is used to save a new citizen complaint
public class SaveComplaintExtensionRequest extends JMapExtensionRequest
{
private String citizenName;
private int requestType;
public void setCitizenName(String citizenName)
{
this.citizenName = citizenName;
}
public String getCitizenName()
{
return this.citizenName;
}
public void setRequestType(int requestType)
{
this.requestType = requestType;
}
public int getRequestType()
{
return this.requestType;
}
}
To create your response class, you must observe the two following rules:
All of the class’ properties should be serializable.
You are free to add all properties and methods that are useful to returning the information regarding the request’s execution to the client. These properties and methods can operate from the client side by your extension after the request is executed on the server.
The following source code example demonstrates how to program a simple response.
// This response is returned to client after a citizen complaint save request was executed
public class SaveComplaintExtensionResponse extends JMapExtensionResponse
{
private long uniqueId;
public void setUniqueId(long uniqueId)
{
this.uniqueId = uniqueId;
}
public long getUniqueId()
{
return this.uniqueId;
}
}
Your extension should always check the status of a response before using it. If the status is not equal to JMapSRV_STS_SUCCESS, a special process must occur in order to manage the error. In this case, the getMessage() method allows you to generate a message explaining the cause of the error.
Some client extensions can be completely invisible to the user but the majority of extensions are integrated into the JMap Pro GUI. This integration can take many forms. The initGui() method must be used to initialize the graphical interface of an extension.
The main methods of the JMapGuiService class are listed below:
// This button will be in a group thus only onebutton can be pressed among this group.
AbstractButton button = guiFactory.createToggleButton(new ButtonAction(),
appContext.getApplication().getGuiService().getMainButtonGroup());
// Add the button on the Zoom and Pan toolbar.
appContext.getApplication().getGuiService().getToolBar("ZOOM_PAN").add(button);
The following code example shows how to create a toolbar using the JMapGuiFactory class. In this example, the JMapApplicationActionManager class is used to access the buttons’ actions. This class can manage single instances of actions. Afterwards, two buttons are created and added to the bar. Finally, the toolbar is added vertically, on the right side of the application. Notice the HashMap of properties that is used to place the toolbar. This principle is used with all components to specify their characteristics.
// Create the new toolbar final ToolBar
toolBar = guiFactory.createToolBar("SHOWCASE", "JMap example showcase");
// Create and add buttons on toolbar
toolBar.add( guiFactory.createToggleButton(applicationActionManager.getAction(CreatePolygonAction.class), jmapGuiService.getMainButtonGroup())
);
toolBar.add( guiFactory.createButton(applicationActionManager.getAction(ShowDockingPanelAction.class))
);
// Adds the new toolbar vectically to the right side of the application frame.
HashMap<String, Object> properties = new HashMap<String, Object>();
properties.put("CONTEXT_INIT_SIDE", new Integer(SwingConstants.EAST)); // Dock to the east
jmapGuiService.addToolBar(toolBar, properties);
// Create a panel with the needed components
final JPanel panel = new JPanel();
...
// Set the properties of the dockable panel.
HashMap<String, Object> properties = new HashMap<String, Object>();
properties.put("KEY", COMPONENT_KEY); // Will be used to reference the panel
properties.put("TITLE", "JMap 7 SDK showcase."); // Will be displayed on the title bar
properties.put("CONTEXT_INIT_SIDE", SwingConstants.EAST); // Tells JMap to dock the panel to the east of the frame
appContext.getApplication().getGuiService().addDockableComponent(panel, properties);
The following code example shows how to create and add a menu to the interface.
// Create menu and add items to it
JMenu menu = new JMenu("SDK");
JMenuItem item1 = new JMenuItem("Item 1");
JMenuItem item2 = new JMenuItem("Item 2");
this.menu.add(item1); this.menu.add(item2);
// Add menu to menu bar at position 4
appContext.getApplication().getGuiService().getMenuBar().add(menu, 4);
// Add 2 menu items to existing menus TOOLS and HELP
JMenuItem item3 = new JMenuItem("Item 3");
JMenuItem item4 = new JMenuItem("Item 4");
appContext.getApplication().getGuiService().addMenuItem("TOOLS", item3, false);
appContext.getApplication().getGuiService().addMenuItem("HELP", item4, false);
The following code shows how to add a section of items to the map’s pop-up menu. This menu appears when the user right-clicks on the map. In addition, the menu item is only active if the user has clicked on at least one element of a map layer. Otherwise, the menu item will be disabled.
final ViewMenuAction menuAction = new ViewMenuAction();
// Obtain the currently active view
View view = JMapApplicationContext.getInstance().getViewManager().getActiveView();
if (view != null)
{
// Add a separatr and a menu item
view.addPopupMenuSeparator();
view.addPopupMenuAction(menuAction);
}
// Register an event listener with the View Manager so that we are notified when the view popup menu is about to be displayed
JMapApplicationContext.getInstance().getViewManager().addViewEventListener(new ViewAdapter()
{
@Override
public void viewPopupMenuShowing(ViewPopupMenuShowingEvent e)
{
// Enable map menu item only if the user clicked on some element
K2DElement[] elements = e.getView().getLayerManager().getElementsAtPoint(e.getWcCoord(), e.getView().getViewState(), false);
menuAction.setEnabled(elements.length > 0);
}
});
Abstract methods of the AbstractLayerSettingsCustomPage class:
// Obtain a reference to the ShowLayerSettingsAction
instance ShowLayerSettingsAction showLayerSettingsAction = (ShowLayerSettingsAction)appContext.getApplicationActionManager()
.getAction(ShowLayerSettingsAction.class);
// Add the custom panel for the Cities layer
showLayerSettingsAction.addLayerSettingsCustomPage(SDKLayerSettingsPanel.class.getName(), layerCities.getId());
You can add buttons associated with a layer in the layer manager. These buttons can be used to trigger custom actions that are specific to a layer. The buttons are added in different ways in the hierarchical section and list section.
The following source code example shows how to add a button to the Cities layer.
// Obtain layer instance from layer manager
Layer layerCities = appContext.getViewManager().getLayerManager().getLayer("Cities");
JMapGuiService guiService = appContext.getApplication().getGuiService();
JMapGuiFactory guiFactory = guiService.getGuiFactory();
AbstractButton abstractButton = guiFactory.createButton(new ButtonAction());
// Add the button to the 'More options' of the LayerTreeBar (hierarchy) for the layer Cities
guiService.getLayerTreeBar().addCustomButton(abstractButton, layerCities.getId());
// Add the button to the LayerPanel of the LayerBar (list) for the layer Cities
LayerPanel layerPanel = guiService.getLayerBar().getLayerPanel(layerCities.getId());
Button button = new Button(new ButtonAction(), false, new Dimension(18, 18));
layerPanel.addCustomButton(button);
To be deployed within JMap Pro applications, client extensions must follow certain rules. If these rules are met, the extension appears in the deployment section of JMap Admin.
Group extension classes in an archive (JAR)
All classes and resources (images, etc.) of the extension must be contained in a single JAR archive file. Use a meaningful and unique name, as this name will be used in the following steps.
Include a manifest file
The extension archive must include a manifest.mf file with the following entries:
Here is an example of a manifest file's content:
extension_class: jmap.extensions.edition.EditionExtension
extension_name: Edition
extension_version: 1.0.0049
Provide a JNLP file
The JNLP file is required. It describes the deployed library. The file must have the same name as the extension's JAR file (except for the .jnlp extension). The following example shows the parts that must be changed in bold.
<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for Extension libraries -->
<jnlp
spec="1.0+" codebase="http://$JMAPSERVER_HOST$:$JMAPSERVER_WEBPORT$$PATH$/edition_client"
href="edition_client.jnlp">
<information>
<title>Edition Extension</title>
<vendor>K2 Geospatial</vendor>
<description>Edition Extension</description>
<description kind="short">Edition Extension</description>
</information>
<security> <all-permissions/> </security>
<resources> <jar href="edition_client.jar"/> </resources>
<component-desc/>
</jnlp>
Place the files in the correct directory.
All files that make up the extension (JAR, JNLP, and other files) must be placed in a directory created specifically for the extension and located within the directory for Client Extensions (JMap_HOME/extensions/client). The name of the extension's directory must be identical to the name of the extension's JAR. The following image shows how files and directories are organized in Windows for K2 Geospatial's Edition extension.
The signature of a Java library certifies that the library comes from an identifiable source and that its content has not been altered. The user who executes the library’s code can trust the authenticity of the library. This is even more important when the library requires system access that can cause security issues such as data access, network access, etc.
The following tables present the keys of JMap Pro’s GUI components. These keys are used to control these components through programming, notably in the methods of the JMapGuiService class.
A JMap tool provides interaction between the user and the map using the mouse. For example, when the user activates the selection tool and clicks on the map to select an item, it is the selection tool class that performs the work. This tool is programmed to make a selection at the location that is clicked on the map. Similarly, when the distance measurement tool is used, the tool class calculates and displays the distance between the 2 points clicked by the user. Thus, developing a JMap tool allows you to implement custom actions.
In general, only one tool at a time can be enabled. In order to be enabled, a tool must be the active tool in a JMap view. To do so, you must use the method of the or class. Note that the method used to activate the tool, such as a button or a menu item, has no connection with the operation of the tool itself.
When the user changes the active the tool (e.g. by pressing a button), the code will essentially be as follows:
JMapApplicationContext.getInstance().getViewManager().setCurrentTool(new MyTool());
When a tool is active, it receives all the mouse events that are generated by the active view. The Tool class is responsible for processing these events and taking the appropriate actions.
To develop a new tool, you must program a class derived from the abstract class and implement only the methods needed to perform the tool’s function. For example, if the tool must perform an action when the user clicks the mouse, you must implement the method.
Tool class methods:
The following code example shows a simple tool that displays the properties of the first element found at the coordinates of the mouse cursor when the user presses and releases the left mouse button on the map. Only vector layers are considered and the search is performed from the highest layer to the lowest layer, in the layer display order. Other methods of the Tool class are not implemented because they are not required for the operation of this tool.
public class ElementInfoTool extends Tool
{
public void onToolReleased(MouseEvent e)
{
super.onToolReleased(e);
System.out.println("ElementInfoTool.onToolReleased");
// Obtain array of layers to cycle them in reverse order
final Layer aLayers[] = this.view.getLayerManager().getAllLayers();
// Get the layer visibility status from the layer manager (also includes the hierarchy visibility)
final LayerVisibilitySet layersVisibility = this.view.getLayerManager().getLayerTreeVisibility();
// Transform mouse x,y coordinate to WC coordinate
// Point wcCoord = view.getTransform().transformInv(new Point.Double(e.getX(), e.getY())); final Point wcCoord = toWCPoint(e); // method inherited from class Tool
final ViewState viewState = this.view.getViewState();
// Cycle through every layer in reverse order (from top position to bottom position) looking for an element under the x,y position.
for (int i = aLayers.length - 1; i >= 0; i--)
{
// Consider only vector layers
if (!(aLayers[i] instanceof VectorLayer))
continue;
final VectorLayer vectorLayer = (VectorLayer) aLayers[i];
// Layer must be visible, selectable and displayed at the current scale
if (layersVisibility.isVisible(vectorLayer.getId()) && vectorLayer.isSelectable() && vectorLayer.isDrawable(viewState.getScale()))
{
final K2DElement elem = vectorLayer.getElementAtPoint(wcCoord, viewState, true);
if (elem != null)
{
String message = "Selected element on layer " + vectorLayer.getName() + ":\n\n"
+ "Class:" + elem.getClass().getName() + '\n'
+ "Id: " + elem.getId() + '\n'
+ "Geometry: " + elem.getGeometry().getClass() + '\n'
+ "Display bounds: " + elem.getDisplayBounds(viewState, vectorLayer.getStyle(elem, viewState.getScale())) + '\n'
+ "Attributes:\n";
final Object[] attribs = elem.getAttributes();
final Attribute[] attribDefinitions = vectorLayer.getAttributeMetaData();
for (int j = 0; j < attribs.length; j++)
{
message += " " + attribDefinitions[j].getName() + " : " + attribs[j] + '\n';
}
JOptionPane.showMessageDialog(this.view, message);
break;
}
}
}
}
}
You can implement tools to draw on the map simply by deriving them from existing JMap classes for drawing tools.
By deriving from these classes, all the basic operations are inherited. The following options are available:
Persistent and volatile modes (determines whether items are created);
Select the layer that will receive the items drawn;
Style parameters of drawn elements (colors, line types, etc.);
Display dimensions on the map while drawing.
public class CreatePolygonTool extends ToolDrawPolygon
{ private final static String LAYER_NAME = "Zones";
private VectorLayer targetLayer; // The layer that will hold the polygons
public void init(View view)
{
super.init(view);
// Make sure the layer exists. If not create it and register it in the layer manager of the view.
final LayerManager layerMgr = view.getLayerManager();
this.targetLayer = (VectorLayer)layerMgr.getLayer(LAYER_NAME);
if (this.targetLayer == null)
{
// The layer does not exist, create it
this.targetLayer = new VectorLayer(Layer.getNextUserLayerId(), // avoid id conflict with other layers
LAYER_NAME,
ElementTypes.TYPE_POLYGON);
// Tell JMap that information on this layer does not come from the server
this.targetLayer.setLocal(true);
// Set the mouse-over text for the layer. It will be displayed when the user stops the mouse pointer over an element.
this.targetLayer.setMouseOverConfiguration(new MouseOverConfiguration("This is a zone."));
// Add the layer to the layer manager list. All layers need to be registered in the layer manager in order to be displayed in the view. The layer is added to the top.
layerMgr.addLayer(this.targetLayer);
}
// Tell the superclass that the resulting elements should be persisted when completed. That means that they will be placed on a layer. Otherwise, they would be deleted as soon as they are completed.
setPersistent(true);
// Tell the superclass to place the resulting elements on the target layer. Otherwise, they would be placed on the default drawing layer
// (id = LayerManager.LAYER_ID_USER_DRAWINGS).
setDrawLayer(this.targetLayer);
// Modify the style of the surface elements (polygons).
final Style surfaceStyle = getStyleContainer().getSurfaceStyle();
surfaceStyle.setFillColor(Color.GREEN);
surfaceStyle.setTransparency(.50f);
// To have the valid drawing style displayed in the layer bar, make the layer default style identical to the drawing style.
this.targetLayer.setStyle(surfaceStyle, 0.);
}
}
There are several ways to allow communication between a JMap Pro application and another client application, also called an external application.The external application is an application running locally on the same computer as JMap Pro. We are not talking here of web applications (HTML, javascript), but rather client applications. The JMap Socket extension provides this communication in a simple and effective way.
The Socket extension is a generic extension that allows a bidirectional socket communication between external applications and JMap Pro extensions. This extension does not directly process the messages. Its role is limited to providing communication. Here is a typical scenario describing the use of this extension:
An external application sends the identifier of an element to JMap and it is automatically located and selected on the map. Conversely, the user clicks on a map element, and JMap sends the ID of the element to the external application, which displays a form with the properties of the element.
To communicate, external applications and JMap extensions send messages that are in fact byte arrays. The contents of these byte arrays is interpreted on either side. The Socket extension does not interpret their content.
The external application always connects to JMap first. It does so by opening a socket to the port configured in the Socket extension. Thereafter, the external application will once again initiate communication. This first contact is a special communication called a handshake. During the handshake, the external application indicates its unique identifier (a character string identifying the application).
As for the JMap extension that wants to communicate with the external application, it must register with the Socket extension. It must provide the same identifier as the external application. This is the identifier that links the two.
Subsequently, the external application and JMap extension can send each other messages in any direction. Each party (the external application or extension) is responsible for interpreting the messages and taking the appropriate actions.
Optionally, the Socket extension can launch the external application if it does not respond. Once it is launched, the external application may initiate communication as described above.
The code examples that follow are written in Java . An external application programmed in another language should implement the same logic, in that application’s language.
Opening a socket using IP address 127.0.0.1 and port 12351):
Socket socket = new Socket(“127.0.0.1”, 12351);
Sending a handshake message
The handshake message is received and interpreted by the Socket extension only. Note that the number of bytes of the message must precede the contents of the message. The message is sent as a byte array. The character encoding (charset) of this message is defined in the configuration of the Socket (socket.properties file) extension.
DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
String handshake = "handshake:MyIdentifier";
dos.writeInt(handshake.getBytes().length);
dos.write(handshake.getBytes());
dos.flush();
Sending other messages
Subsequent messages are sent the same way as the handshake message, however, they will be received and interpreted by the extensions registered with the same identifier. Extensions that receive messages must therefore be able to understand the content of messages and perform the corresponding actions. The character encoding of the message is free and must be agreed to by the extension and the external application.
DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
String message = "locate :id=333";
dos.writeInt(message.getBytes().length);
dos.write(message.getBytes());
dos.flush();
Receiving messages from JMap
Receiving messages is done using the same socket as for sending. The length of the message is read first, followed by the byte array of the message. Message reception should be done asynchronously, in a separate thread.
DataInputStream dis = new DataInputStream(socket.getInputStream());
int length = dis.readInt();
if (length > 0)
{
byte[] messageBytes = new byte[length];
dis.readFully(messageBytes);
}
The following example shows how to register a JMap extension with the socket extension to be notified when a connection or disconnection occurs and when messages from the external application are received. This code could be placed in the init() method of the JMap extension.
SocketClientExtension.register(new SocketClient()
{
@Override
public void socketMessageReceived(byte[] bytes)
{
String data = new String(bytes /*, Charset.forName("ISO-8859-5")*/);
// Interpret content of data…
}
@Override
public void socketConnectionOpened()
{
}
@Override
public void socketConnectionClosed()
{
}
@Override
public String getIdentifier()
{
return "MyIdentifier";
}
@Override
public String getExecutable()
{
// Optional - return null if not needed return "c:/external_app.exe";
}
});
The following example shows how to send a message to the external application from the JMap extension.
String message = "openform: id =99";
byte[] bytes = message.getBytes();
SocketClientManager.getInstance().sendMessage("MyIdentifier" , bytes);
Java applets are executed in the environment of a web browser. Therefore, they can interact, in both directions, with the javascript code in the web page that contains the applet. This communication allows you to create HTML interfaces to control the map and perform simple integrations with other applications running in the environment of the web browser. This does not apply to JMap Pro applications deployed with the JavaWebStart method (not in a web browser) because no web page is involved in these cases.
The following sample web page is a normal startup page for a JMap Pro applet to which javascript functions have been added (pan and zoom). Hyperlinks are also used to call these functions. When triggered, the functions call the JMap API to control the map.
The JMap Pro application has a getApplicationContext() method that is used to access all the components of the application.
<%@page contentType="text/html;charset=ISO-8859-1"%>
<%
String username = request.getParameter("username");
String password = request.getParameter("password");
String parameters = null;
if (username != null && username.length() != 0)
{
parameters = "?username=" + username;
if (password != null)
parameters += "&password=" + password;
}
%>
<html>
<head>
<title>
aa
</title>
<script src="library/deployJava.js"></script>
<script src="library/jmap.js"></script>
</head>
<BODY BGCOLOR="#ffffff" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">
<script>
function zoom(factor)
{
document.jmap.getApplicationContext().getViewManager().getActiveView().zoom(factor);
document.jmap.getApplicationContext().getViewManager().getActiveView().refresh();
}
function pan(x, y)
{
document.jmap.getApplicationContext().getViewManager().getActiveView().pan(x, y);
document.jmap.getApplicationContext().getViewManager().getActiveView().refresh();
}
</script>
<a href="javascript:zoom(2.);">Zoom in</a>
<a href="javascript:zoom(0.5);">Zoom out</a>
<a href="javascript:pan(0, 200);">Pan north</a>
<a href="javascript:pan(0, -200);">Pan south</a>
<a href="javascript:pan(200, 0);">Pan west</a>
<a href="javascript:pan(-200, 0);">Pan east</a>
<script>
var attributes =
{
name: "jmap",
codebase: "http://127.0.0.1:8080/aa",
code: "com.kheops.jmap.client.application.JMapApplicationLauncher",
archive: "dockingClient.jar,jmap_application.jar,jmap_client.jar,jmap_client_images.jar,jmap_projections.jar,jmap_symbols.jar,custom_symbols.jar,jmap_metadata.jar,jmap_net.jar,jmap_spatial.jar,kheops_ui.jar,kheops_util.jar,gif4j_pro_2.0.jar,jide-action.jar,jide-common.jar,jide-components.jar,jide-dock.jar,jide-grids.jar",
width: "100%",
height: "100%",
mayscript: true,
separate_jvm: true,
parameters: "-appclassname jmap.viewers.docking.AppDocking -project "The World" -directport 7003 -httpport 8080 <%= username != null ? username : "" %> <%= password != null ? password : "" %> -proxypath /aa/servlet/jmapproxy -serverid "aa" -maxmemory 33554432 -connection direct -donotlistusers false -showconnectionmoredetails false true "
};
var parameters = {fontSize:16, jnlp_href:'dockingClient.jnlp'} ;
deployJava.runApplet(attributes, parameters, '1.6.0_10');
</script>
</body>
</html>
From a JMap Pro applet, it is possible to call javascript functions that are in the web page containing the applet. This allows for interaction between the JMap Pro application and its HTML environment. For example, it would be possible to select an item on the map and display its information in an HTML page.
To enable this java-javascript communication, the mayscript: true parameter must be specified in the attributes used to start the applet, as shown in the following example.
<script>
var attributes =
{
name: "jmap",
codebase: "http://127.0.0.1:8080/aa",
code: "com.kheops.jmap.client.application.JMapApplicationLauncher",
archive: "dockingClient.jar,jmap_application.jar,jmap_client.jar,jmap_client_images.jar,jmap_projections.jar,jmap_symbols.jar,custom_symbols.jar,jmap_metadata.jar,jmap_net.jar,jmap_spatial.jar,kheops_ui.jar,kheops_util.jar,gif4j_pro_2.0.jar,jide-action.jar,jide-common.jar,jide-components.jar,jide-dock.jar,jide-grids.jar",
width: "100%",
height: "100%",
mayscript: true,
separate_jvm: true,
parameters: "-appclassname jmap.viewers.docking.AppDocking -project "The World" -directport 7003 -httpport 8080 <%= username != null ? username : "" %> <%= password != null ? password : "" %> -proxypath /aa/servlet/jmapproxy -serverid "aa" -maxmemory 33554432 -connection direct -donotlistusers false -showconnectionmoredetails false true "
};
var parameters = {fontSize:16, jnlp_href:'dockingClient.jnlp'} ;
deployJava.runApplet(attributes, parameters, '1.6.0_10');
</script>
To call a javascript function from your Java code (possibly your JMap extension), you must use the JSObject API, as shown in the following example.
JSObject w = JSObject.getWindow((Applet)appContext.getRootPaneContainer());
w.eval("show_form(" + id + ");");
In this example, the getWindow method receives the instance of the applet as a parameter. The getRootPaneContainer method of the JMapApplicationContext class returns the top level container of the application, the latter being the instance of the Applet when the application is running inside the web browser.
The javascript function to be called and its parameters are taken as parameters by the eval method. In this example, an ID is passed to the javascript function.
When JMap Pro opens, a connection to the associated JMap Server is established. This connection is used to direct the various system requests, including requests to load the project configuration and data as well as .
Communication between a JMap Pro (desktop) application and JMap Server is done by exchanging requests and responses. The requests and the responses are in fact serialized objects that must normally be programmed, and these objects will contain the properties required to execute the request and return the information to the client. For example, an application managing citizen requests might have a request and response with the following properties:
Your extension should always check the status of a response before using it. If the status is not equal to JMapSRV_STS_SUCCESS, a special treatment should be done in order to manage the error situation. In this case, the getMessage() method allows you to generate a message explaining the cause of the error.
JMapSrvConnection jmapConn = JMapApplicationContext.getInstance().getConnection();
The following code example shows how to use the executeRequest method.
MyRequest request = new MyRequest("This is a test", 555);
JMapSrvConnection jmapConn = JMapApplicationContext.getInstance().getConnection();
MyResponse response = (MyResponse)jmapConn.executeRequest(request); // Execution WILL block here
if (response.getStatus() == MyResponse.JMAPSRV_STS_SUCCESS)
{
// Do something useful with the response
}
else
{
// Handle error here
}
The following code example shows how to use the pushRequest method.
MyRequest request = new MyRequest("This is a test", 555);
request.setClient(new JMapRequestClient()
{
// Will be called when the response is received from JMapServer
@Override
public void callback(JMapRequest request, JMapResponse response)
{
if (response.getStatus() == MyResponse.JMAPSRV_STS_SUCCESS)
{
// Do something useful with the response
}
else
{
// Handle error here
}
}
});
JMapSrvConnection jmapConn = JMapApplicationContext.getInstance().getConnection(); jmapConn.pushRequest(request); // Execution WILL NOT block here
JMap Pro applications are developed on a modular basis to simplify the addition of new features. Applications can be broken down into three levels, two of which are scalable to allow for programming additional features.
The first level is the entry point of the application ( class), which covers the type of application (applet, Java Web Start or standalone Java) and instantiates the application class (instance of the class) to be used. The second level is the JMap Pro application; it is driven by its abstract class, , which provides all the services required to ensure its proper operation. Since the class does not provide the application’s graphical interface, it is necessary to instantiate a class that inherits the JMapApplication class and that will instantiate the application’s graphical components, including the layer hierarchy and button toolbars. The DockingClient class, included in this SDK, is a good example of a JMap Pro application. The third level is for JMap extensions. JMap Pro applications allow you to develop and use extension classes ( class) to add new features to applications. JMap Pro extension development is explained in the following .
When the application is initialized, a connection with JMap Server is established based on the application parameters that have been specified. Communication with the server is unidirectional and allows for exchanging messages using requests and responses. The details of this communication are explained in this .
The JMap Pro application takes certain parameters when it is started up. These parameters specify the address of the JMap Server, the communication ports, the project to open, and many other options.
Parameters are passed to the application in various ways, depending on its starting mode. Java and JavaWebStart applet parameters are passed in the application’s JNLP file. Application parameters are passed to the command line or can be specified in an Ant script.
The following example shows the parameters passed to the command line to start a JMap Pro application that opens the project The World and loads the extension Showcase.
-appclassname jmap.viewers.docking.AppDocking -server jmap3.k2geospatial.com -directport 7003
-project "The world" -extensions jmap.examples.showcase.extension.ShowCaseClientExtension
The following table describes the various parameters:
To receive a view’s events, you must implement the interface and register it with the view using the method, as shown in the example below.
Note that the adapter can also be used to simplify the development of a listener.
The table below shows the events triggered by the class.
For more information on events in Java, see the .
The class contains some view properties that define its state at a given time (scale, scope, transformation, etc.). Several methods in the JMap API take an instance of ViewState as a parameter. It is possible to get the state of a view by calling the method of the class.
The view manager ( class) is responsible for managing one or more views that are present in the application. This class has methods that allow you to perform operations on all the views of the application and to know at any time which view is active (i.e. in focus).
The table below shows the main methods of the class.
The View Manager triggers events associated with the state of its views. To get these events, you must implement the interface and register it with the view manager using the method, as shown in the following example.
Note that the adapter can also be used to simplify the development of a listener.
The table below shows the events triggered by the class.
It is also possible to register a listener to the View Manager to get the events generated by all the views associated with the layer manager. This may be more convenient than registering a listener on each view separately. To do so, use the method of the class.
The class provides useful methods to work with the view.
The table below shows the mains methods of the class.
The class is derived from the Layer class and contains only vector data. It has several specialized methods for vector data to generate element selections, perform spatial analysis, etc.
The class is derived from the Layer class and contains only raster data. Its methods are rarely used by JMap application developers.
To receive the events of a layer, you must implement the interface and register it with the layer using the method, as shown in the following example:
There is also an adapter () that simplifies the development of the listener. The superclass has a getLayer() method and a getLayerManager() method allowing you to access the layer or layer manager that generated the event
The following table shows the events triggered by the class.
In JMap, each map ( class) has a layer manager ( class). The latter is responsible for managing all of the layers to be shown on the map, as well as their order and hierarchical organization. In addition, the layer manager can listen for events on all layers and perform certain operations on them.
To receive the layer manager’s events, you must implement the interface and register it with the layer manager using the method.
The class is very useful for extension development because it provides access to a set of general application resources. This class is a singleton. Therefore, the instance can easily be accessed from anywhere using the static method.
The class represents the JMap application. It offers methods that provide access to application resources (GUI, event logs, etc.). It also provides methods to perform tasks in a simple way (create a new map, close the project, etc.).
For more information on client-server communication in JMap, refer to the section.
The class should be derived from the class;
The class should be derived from the class;
Being derived from the class, your response class will inherit some useful properties, including the response status and an explanatory message in case of a problem.
Each response has a status that indicates if the request was executed successfully or if a problem occurred. The getStatus() method of the class allows you to get the status of the response. For the list of possible statuses and their description, refer to the documentation of the class.
The class is used to access the components of the graphical user interface (menus, toolbars, etc.) and to add or remove components. To simplify access to the graphical components, each component has a unique key. This key must be provided when a component is added or removed. For a complete list of available keys, see the section components. The JMapGuiFactory class described below provides methods for creating GUI components.
The class is used to create buttons, menus and toolbars that are compatible with JMap applications. Methods such as createButton (), createMenu (), createToolBar (), etc. are called to create the appropriate components.
The following code shows how to add a button to an existing toolbar. The toolbar is retrieved using its key. For a complete list of available keys, see section . Note that the action associated with the button is not shown in the example.
The method adds components such as windows to the interface. It takes a HashMap of key-value pairs as a parameter to define the display settings of the new window. All keys and possible values are defined in the method’s documentation.
The following code example shows how to add items to existing application menus. Note that a key is used to retrieve existing menus. For a complete list of available keys, see the section .
It is possible to add sections to the settings window of a layer, as shown in the image below. To do this, you must implement your own class derived from the abstract class and implement that class’s 3 abstract methods. You must provide a title and icon for your section by passing them to the constructor of the superclass; they will be displayed in the settings window.
The getLayer() method of the class lets you know to which layer the parameters apply. To save your settings section, you must use the method addLayerSettingsCustomPage of the ShowLayerSettingsAction class, as shown in the following source code example.
Signing Java libraries is done using the jarsigner tool included with the Java JDK. To do this, you must have a Java signing certificate issued for your organization. These certificates can be purchased from a reputable security company such as Thawte () or Verisign (). Once you have your certificate, you must import it in a keystore using the keytool, which is also included with the Java JDK. Note that the keytool can also produce development certificates. These certificates are not deemed to be from reliable sources and they will generate warning messages. However, they are helpful for development and in-house testing purposes. For more information on this topic, refer to the documentation on the Java JDK’s security tools ().
The libraries of JMap Pro extensions must be signed in order to be properly deployed in a JMap Pro application. If you use the provided with the JMap SDK, the Ant scripts generated handle the signing of your extension. Thus, when you run these scripts to compile and build the library for your extension, it is signed automatically. This signature is done using the development certificate provided with the SDK. If you want to use your own certificate, you must replace the JDK_HOME/tools/extensionbuilder/RES/keystore.jks file by your own keystore, in which you will have imported your certificate.
The following table lists the classes for drawing tools available in JMap. All these classes are derived from the class.
The following table lists the most commonly used methods of the class.
The following code example shows a tool derived from that inherits all of its drawing capabilities.
The Socket extension provides a standard means of communication allowing JMap extensions to communicate with external applications. External applications are applications running locally on the same computer as JMap Pro. These applications can be written in any programming language (Java, C + +, Windev, C #, VB.NET, etc.). Note that web applications (HTML, javascript, etc.) are not supported by this integration method. Other methods are better suited to web applications (see ).
For more information, refer to the section.
Every response has a status that indicates if the request was executed successfully or if a problem occurred. The getStatus() method of the class allows you to get the status of the response. For the list of possible statuses and their description, refer to the documentation of the class.
The class is responsible for all communication between JMap client and JMap Server. The connection instance can be accessed using the JMap application context, as shown in the following example.
The following methods (inherited from the class) are used to send requests to JMap Server and to receive the responses.
When initializing the application, all useful instances that define the application’s execution context are stored in a singleton of the class.
Main methods of the K2DTransform class
Creates a new oriented rectangle from the specified WC point and transforms it into a DC point.
Creates a new point from a WC point and transforms it into a DC point.
Creates a new rectangle from a specific WC rectangle and transforms it into DC.
Creates a new oriented rectangle from the specified DC point and transforms it into a WC point.
Creates a new point from a specific DC point and transforms it into a WC point.
Creates a new rectangle from a specific DC rectangle and transforms it into WC.
Variable | Description |
extension_class | Identifies the main class of the extension, derived from the abstract class JMapClientExtension. |
extension_name | Specifies the name of the extension. This name appears in JMapAdmin when deploying applications. |
extension_version | Specifies the version number of the extension. This information appears in JMapAdmin when deploying applications. The version number is used only to simplify the management of extensions. |
Toolbars |
|
ZOOM_PAN | Toolbar containing buttons for zooming and panning. |
SELECTION | Toolbar containing buttons for selection/deselection. |
ROTATION | Toolbar containing buttons for rotation and cancellation of the rotation. |
MEASURE_LABEL | Toolbar containing buttons for measuring, clearing measurements, labelling and clearing labels. |
INFOS_SEARCH | Toolbar containing buttons for reporting and search tools. |
PRINT_MAIL | Toolbar containing buttons for printing and emailing. |
Menus |
|
PROJECT | Projects menu containing items for loading projects, context management, personal layers management, etc. |
VIEW | View menu containing items for controlling the display of the various components of the GUI such as the layer manager, overview, etc. |
TOOLS | Tools menu containing the items of various tools and extensions. |
MAP | Maps menu containing map window management items. |
HELP | Help menu containing help topic items. |
Windows |
|
LAYERS | Map layer manager. |
CONTEXTS | Contexts management window. |
ELEMENTS_EXPLORER | Window containing the elements explorers of the layers. |
SELECTION_EXPLORER | Window containing the selection explorer. |
MESSAGES_VIEWER | JMap messages management window. |
PERSONAL_LAYERS | Personal layers management window. |
QUERIES | Spatial and attribute queries window. |
GO_TO_COORDINATE | Window for entering coordinates to be reached on the map. |
GEOMETRY_INFO_PANEL | Window to display geometric properties of map elements. |
OVERVIEW | Map overview window. |
Parameters (* = mandatory) |
|
-appclassname * | Main class of the application to run. Currently, the only possible value is jmap.viewers.docking.AppDocking. |
-server * | The name or IP address of the JMap server to which the application must connect. |
-directport | IP communication port for direct connections with JMap Server. |
-httpport | IP communication port for connections through HTTP proxy with JMap Server. |
-project | The project that will open by default. Must be enclosed in quotes if the name contains spaces. |
-language | Language of the application’s GUIs. Supported values are fr, en, es, pt, and default. The default value means that the language used will be the default language of the user’s operating system. |
-country | The country, used with the language, to determine the display formats of dates and numbers. |
-username | The username to log on to the application. |
-password | The password to log on to the application. |
-sessionid | Specifies the session number in order to connect to a session that is already open on the JMap server. |
-autozoom | Instructs the JMap application to locate a position or element automatically upon startup. The syntax is: |
-connection | Type of connection to use between the application and the JMap Server. Possible values are: - direct: Opens a direct connection to JMap Server using the direct port. - proxy: Opens a proxy HTTP connection to JMap Server using the HTTP port. - any: Attempts to open a direct connection. In case of failure, switches to connection through HTTP proxy. |
-proxypath | If the connection type is HTTP-proxy, specifies a relative path to the HTTP proxy. |
-serverid | If the connection type is HTTP-proxy, specifies on which JMap Server instance the connection must open when multiple instances of JMapServer are available. This way, the HTTP proxy can be used to direct the queries. Server IDs are configured in the jmsconnections.xml files. |
-showconnectionmoredetails | Determines whether the login window should show the list of available projects on JMap Server. Possible values: true, false |
-usediskcache | Determines whether the disk cache is enabled or not. Possible values: true, false |
-diskcachepath | If the disk cache is enabled, determines the folder where the cached data will be saved. |
-diskcachesize | If the disk cache is enabled, determines the maximum size of the total data cache. Data will automatically be deleted when the cache reaches the size limit. The value is expressed in bytes. A value of -1 indicates an unlimited size. |
-usememorycache | Determines whether the memory cache is enabled or not. If the cache is enabled, the data in memory is handled in the following way: when the space becomes full, i.e. the cache reaches the size limit (-maxmemory parameter), data is automatically removed from the memory. The amount of data removed depends on the specified percentage (percentreleasememory parameter). Possible values: true, false |
-maxmemory | If the in-memory cache is enabled, determines the maximum size of the data in memory.The value is expressed in bytes. The default value is 33554432 (32MB). |
-percentreleasememory | Determines the percentage of memory to free when the cache becomes full. The percentage is based on the total size of the cache. The value is an integer between 1 and 100. |
-logos | List of logos to show on the map as well as their position and transparency. Example -logos “? Jmaplogo.gif x = 5 & y = 5 & transparency = 30.0 & relativeTo = NE” |
-northarrow | Display settings for a north arrow on the map, including the model, position, size, etc. Example -northarrow Simple3D, 0,50,5,5 |
-displayscalebar | Determines whether the scale bar must be displayed on the map. Possible values: true, false |
-extensions | The list of extensions to initialize at application startup, separated by commas. Example -extensions jmap.extensions.googlemap.client.GoogleMapsExtension, jmap.examples.showcase.extension.ShowCaseClientExtension |
Navigation |
|
Performs a zoom at the map centre using the specified magnifying factor. For example, a factor of 2 will display a map that is two times closer. A value of 0.5 will produce a map that is two times farther. The map must be refreshed afterwards. |
Pans and zooms the map around the specified rectangle. The map must be refreshed afterwards. |
Pans and zooms the map to show the entire area covered by the data. The map must be refreshed afterwards. |
Makes the specified coordinates the new centre of the map view. The scale is not affected.The map must be refreshed afterwards. |
Makes the specified coordinates the new centre of the map view. The scale is not affected. The map must be refreshed afterwards. |
Moves the map based on the x and y values specified in screen coordinates (DC). The map must be refreshed afterwards. |
Modifies the map scale based on the specified value. The map must be refreshed afterwards. |
Display |
|
Refreshes the map. After any method modifying the state of the map is called, the map must be refreshed in order to display the changes. |
Adds a marker (symbol indicating a location) at the specified coordinates with the specified message and style. |
Removes the specified marker from the map. |
Removes all markers from the map. |
Returns the view bounds to screen coordinates (DC). |
Returns the view bounds to world coordinates (WC). |
Returns the view transformation. This is the transformation used to convert Screen Cooordinates (DC) to World Coordinates (WC) and vice-versa. |
Returns the view overlay. The overlay is a special layer designed to display volatile data. It is often used to create smooth animations (moving objects, drawing, etc.). |
Returns the current scale factor of the view as the denominator (1: denominator). |
Returns the current horizontal distance of the view in world coordinates (WC). |
Other |
|
Removes an action from the view’s pop-up menu. |
Removes an item from the view’s pop-up menu. |
Adds an action to the view’s pop-up menu. |
Adds an item to the view’s pop-up menu. |
Registers a listener to the events generated by the view. |
Removes a listener from the events generated by the view. |
Replaces the active tool of the view with the tool specified as a parameter. |
View events |
Launched after the view's state changes following a navigation operation (zoom, pan, etc.). |
Launched when the active tool of the view is replaced by another tool. |
Launched when the view is redrawn, in whole or in part. The elements of the layers are redrawn. |
Launched when the view is repainted, in whole or in part. The image of the map is simply refreshed; the elements of the layers are not redrawn. |
Launched when static elements (north arrow, scale bar, etc.) are added to or removed from the view. |
Launched just before the pop-up menu of the view is displayed. Allows you to change the contents of the menu before it is presented to the user. |
Launched when the view becomes ready for use, i.e. after the first time it is displayed. |
Most commonly used methods of the ViewManager class |
Registers a listener to the events triggered by the active view. |
Registers a listener to the events triggered by the view manager (see below). |
Returns the active view (i.e. the view that is in focus). |
Return the layer manager of the active view. |
Returns the view with the name specified as a parameter. |
Returns a list of all existing views in the view manager. |
Performs a refresh action on all existing views in the view manager. |
Removes a listener from the events triggered by the active view of the view manager. |
Removes a listener from the events triggered by the view manager. |
Replaces the active tool of the active view with the tool specified as a parameter. |
View manager events |
Launched when a view is added to the View Manager. |
Launched when a view is activated (i.e. comes into focus). |
Launched when a view has been deactivated (i.e. it has lost focus in favour of another view). |
Launched when a view is removed from the View Manager. |
Most commonly used methods of the ViewUtil class |
Produces and returns an image of the map as displayed in the view. The width (in pixels) of the image to be created is passed as a parameter. |
Saves an image of the map on the hard drive. A window displays, allowing the user to select the location of the file. |
Most commonly used methods of the Layer class |
|
Adds a listener to the events generated by the layer. |
Returns the unique numerical ID of the layer. |
Returns the layer name. |
Static method that generates a new unique identifier for a user layer. |
Invalidates the cache of a layer loaded by region. This allows the layer to be refreshed when no changes have been made to the view transformation matrix. |
Indicates if the layer is displayed at the specified scale according to the defined display thresholds. |
Indicates whether or not the layer objects are selectable. |
Indicates whether or not the layer is visible. |
Returns a serializable data structure containing all of the layer’s information. |
Most commonly used methods of the VectorLayer class |
Adds the specified element on the layer. |
Adds all specified elements on the layer. |
Adds the specified element to the list of selected elements. |
Adds a collection of elements to the list of selected elements. |
Clears the list of selected objects on this layer. |
Returns a collection containing all of the layer's elements. |
Returns the total extent of the layer data as a rectangle. |
Returns an array containing all the elements selected on the layer. |
Most commonly used methods of the RasterLayer class |
|
Returns the total extent of layer data as a rectangle. |
Most commonly used events of the Layer class |
Launched after new elements are added to the layer. The added elements are accessible in the instance of the event. |
Launched after changing elements on the layer. Changed items are available in the instance of the event. |
Launched after removing elements from the layer. The removed elements are available in the instance of the event. |
Launched after changing the selection on the layer; this can include selected or unselected events. The elements in question are available in the instance of the event. |
Launched after changing the style of the layer. |
Most commonly used methods of the LayerManager class |
|
Adds the specified layer to the highest position. |
Adds a listener to events generated by the layer manager. The layer manager also relays all the events generated by the layers it manages. |
Clears the list of selected elements on each layer. |
Returns the ordered set of layers (user layers and normal layers). The layer at the zero position is the bottom layer. |
Returns the layer having the specified unique identifier. |
Returns the layer having the specified unique name. |
Returns the position of the specified layer. |
Returns all the selected elements on all layers. |
Returns the extent of all selected elements on all layers. |
Removes the layer located at the specified position. |
Events of the layer manager |
Launched after changing the position of a layer in the list of layers handled by the layer manager. |
Launched after removing a layer from the list of layers handled by the layer manager. |
Launched after adding a layer to the list of layers handled by the layer manager. |
This method is called by the JMap application just before it exits. In this method, you must put the code required to terminate your extension. This could include the code to release resources, save settings, etc. |
Returns the instance of the main application window. |
Returns the path to the main JMap folder on the user's computer. This is where JMap writes its data. |
Creates a new map view that automatically appears in the application. |
Adds an item to an existing menu by specifying the menu key. |
Retrieves a menu using its key. The returned object can then be used to modify the menu. |
Adds a toolbar to a specific position in the application interface. |
Retrieves a toolbar using its key. The returned object can then be used to modify the toolbar. |
Adds a dockable window at a specific position in the application interface. |
Allows you to remove a dockable window using its key. |
Returns the JMapGuiFactory instance. This class allows you to create GUI components such as buttons and toolbars. |
In this method, you must create and return the the instance of JPanel that displays the GUI of the settings in your section. This is the graphical interface that will be displayed. |
This method is called when the user clicks on the OK button to confirm the changes and close the window. Your method should return true only if the parameters entered are valid. Otherwise, the window will refuse to close. |
This method is called when the user clicks on the OK button to confirm the changes and close the window, and after calling the validateSetting() method. You must apply the parameter changes on the layer. |
This method is called when the tool becomes the active tool of a view. The code for this method should be used as necessary to prepare the work of the tool. The view is passed as a parameter to this method. |
This method is called by the view when the tool becomes active to allow your tool to provide its own mouse cursor. The cursor will be visible on the view as long as your tool remains the active tool. |
This method is called when the user presses on one of the mouse buttons within the view. |
This method is called when the user releases a mouse button within the view. |
This method is called after the user has completed a mouse click within the view. |
This method is called repeatedly when the user moves the mouse inside the view. |
This method is called repeatedly when the user moves the mouse inside the view while keeping a button pressed. |
This method is called when the tool becomes inactive, i.e. when another tool is activated on the screen. The code for this method could be used, as needed, to perform a termination action or to free up resources. |
Sends the request passed as a parameter to JMap Server and returns the response generated by JMap Server or by a server extension. This is a blocking method. It is well suited to situations where one must wait for the server’s response before continuing. |
Most commonly used methods of the JMapApplication class |
Adds a project listener in the application's list of listeners. |
Removes a project listener from the application's list of listeners. |
Returns an instance of java.util.Logger to perform logging in the application. |
Defines a user parameter to be saved. |
Request | Response |
Name of requesterType of requestDescriptionx and y coordinates of the request’s location | Status of the saved request in the database Unique identifier generated upon save |
Returns the instance of the class associated with this view. See below for more information on this topic.
Returns the instance associated with the view.
Returns the map projection () of the data on the map.
Returns the unit () of the data on the map.
Sends an image of the map by email to the recipients defined in the type object passed as a parameter.
Returns the type of elements contained in the layer. Types are defined by the constants of the class.
Returns the instance of the Style Manager ( class) used by the layer. It manages all of the layer styles, which define the graphical appearance of elements on the map.
Returns the list of attributes ( class) of the layer.
Adds a new display filter ( interface) to the layer. This filter allows you to define what will be displayed and what won't.
Provides the first element of the layer detected at the specified coordinates in WC in the specified map ( class). The last parameter determines if the elements that are invisible (due to a display filter, for example) should be considered or not.
Returns all of the layer's elements identified at the specified WC coordinates in the specified map ( class). The last parameter determines if the elements that are invisible (due to a display filter, for example) should be considered or not.
Returns all of the layer's elements that intersect the surface specified in WC coordinates in the specified map ( class). The last parameter determines if the elements that are invisible (due to a display filter, for example) should be considered or not.
Returns the raster parameters ( class) used by the raster layer (e.g. the size of the image, transparency, etc.).
Returns an array of attributes for the various bands ( class) contained in the image.
Returns a data structure ( class) containing the visibility state of a layer. This state considers the state of the selection of groups in the layer hierarchy as well as the configuration of their visibility.
This method is called when the extension is loaded by the JMap Pro application. At this point, the graphical interfaces have not yet been initialized. In this method, you can put any code that will prepare the operation of your extension. This could include loading a settings file, verifying dependencies, etc. The method receives an instance of as a parameter. This class provides access to all the resources of the JMap application. The method also receives a collection (map) of parameters. These parameters provide useful information for the extension. See below for more information.
This method is called by the JMap application when its graphical interface has been initialized. In this method, you should put the code that initializes the GUI of your extension. This could include adding buttons or toolbars, menus, windows, etc. See the section for more information. This GUI will allow users to access the functions offered by your extension.
Returns the instance of the connection ( class) to JMap Server.
Returns the instance of the View Manager ( class) of the application.
Returns the instance of the JMap application ( class).
Returns the instance of the project ( class) opened in the application.
Returns the instance of the application’s class. See the section for more information.
Returns the instance of the application’s class. Used to record messages from your extension in the JMap application’s logs.
Returns the object that contains the styles of the various types of elements (polygons, lines, etc.) that can be drawn. This method is called to change the style of the elements that will be drawn by the tool.
Specifies the layer that will receive the items drawn by the tool, if the elements are persistent (see method below). If no layer is specified, a system layer is used by default.
Determines whether the items will be stored on a layer or not (see method above). If they are not stored, the elements disappear immediately after the drawing operation is completed.
Sends the request passed as a parameter to JMap Server. This method is non-blocking. When the response is received, the method of the client of the request is called. This method is well suited to situations where one must quickly give back control to the user and when one can process the response in an asynchronous manner.
Creates a new view ( class) initialized with the current project in the application.
Returns the active project ( class) in the application.
Returns the instance to be used in order to access and manipulate the components of the application's GUI.
Returns the extension loaded ( class) for the specified class name.
Returns the messaging controller ( class) of the application.
Returns the edition transaction manager ( class) of the application.
Returns the user parameter controller ( class).
Returns the user parameter ( class) saved for the specified key.