Positioning

This facility is for defining where a given object is displayed on the screen.
Each representation object has the option of carrying a position. The position data can originate from the back end (mapped automatically from an attribute of the corresponding business object, or manually from a separate source), from computation by a default layout algorithm in the network view, or from explicit end-user gestures to move or reshape nodes in the view. It is possible to retrieve the origin of the position data through the IlpPositionSource enumeration. There are three possible origins for the position of representation objects:
  • BACKEND : The position has been set by the adapter when creating the representation object.
  • LAYOUT : The position has been set in the view by an automatic layout algorithm (either the node layout or the link layout).
  • USER : The position has been set by the user through interactors.
To retrieve the position origin, you need to access the method getPositionSource in the network view.
The position implements the IlpPosition interface.The following supplied types implement IlpPosition :
The position can be attached to a representation object through the method setPosition and retrieved through the method getPosition of the network view ( IlpNetworkView).
A position converter is used to convert positions in the network model to positions in the network view or vice versa. The position converter implements the IlpPositionConverter interface.
JViews TGO provides a default position converter ( IlpDefaultPositionConverter) for the predefined business objects position data. The following predefined position types are supported:
Since the network view already supports these position types, the IlpDefaultPositionConverter does nothing else than verify that the given position is one of the predefined types.

Positioning using geographic coordinates

A more complex converter is provided for geographic coordinates ( IlpGeographicPositionConverter). It extends the default position converter to support the following types of positions:
When you use a background map, you can give the positions of objects directly in geographic coordinates (latitude/longitude). The conversion to screen coordinates is performed by using an instance of IlpGeographicPositionConverter. You can parameterize this converter through classes that are part of the Rogue Wave® JViews Maps product: an IlvProjection or an IlvMathTransform, optionally followed by an IlvTransformer. Refer to The two coordinate systems.

How to parameterize the geographic position converter

// Set the position converter. It converts the geographic coordinates
// of the objects in the XML file to planar (x,y) coordinates.
IlvProjection projection =
  new IlvEquidistantCylindricalProjection();
IlvTransformer t = new IlvTransformer(0.00001,0,0,0.00001,1,6.5);
IlpPositionConverter converter =
  new IlpGeographicPositionConverter(projection,true,t);
networkComponent.setPositionConverter(converter);
You can also parameterize the geographic position converter through CSS by using the following steps:
  1. Define a converter class with an empty constructor.
    public class MyConverter extends IlpGeographicPositionConverter {
           public MyConverter() {
             super(new IlvEquidistantCylindricalProjection(),
                   true,
                   new IlvTransformer(0.00001, 0, 0, 0.00001, 1, 6.5));
           }
         }
    
  2. Reference the converter class in a CSS file as follows.
    Positioning {
           positionClass: 'ilog.cpl.network.IlpGeographicPosition';
           converterClass: 'my.package.MyConverter';
         }
    
Important
The parameters used to configure an IlpGeographicPositionConverter should conform to the georeferencing configuration of the background map in use. For details, see Background support.
You can define your own application-specific implementation of the IlpPosition interface, for example, you could implement polar coordinates. When you define your own implementation of IlpPosition , you must also attach the corresponding implementation of the IlpPositionConverter to the view. In this particular case, you would attach a converter from polar positions to the predefined view position types.
When an object has no attached position, the view assigns a position to the corresponding graphic object. The position is assigned through the layout mechanism (node layout for positioning nodes, and link layout for shaping links).
If the position of an object changes due to user interaction, the controller requests the handler to confirm the change.