next up previous contents index
Next: Mapping with Equal Sized Up: Grid Coordinate Mappers Previous: Grid Coordinate Mappers   Contents   Index


Grid Coordinate Mapper ( GridCoordinateMapper )

Baseclasses


\begin{picture}(6.5,2.5)
\thicklines
\put(0.5,1.5){\framebox (5.5,1){\bf AGDMo...
...0,-1){1}}\put(0,0){\framebox (7.5,1){\bf GridCoordinateMapper}}
\end{picture}

Definition

The class GridCoordinateMapper defines a standard interface for grid coordinate mappers and provides a generic method for their implementation.

Grid coordinate mappers are used to transform a grid layout of a graph G into a real layout ( call() function). Furthermore, they compute the initial grid size of nodes in the grid layout ( get_node_grid_size() function).

Implementation of Grid Coordinate Mappers

We refer to the input grid layout with column(v), row(v) for the position of node v, ip1(e),..., ipke(e) for the polyline of edge e, where ipi(e) = (coli(e), rowi(e)), with grid$ \_$width(v), grid$ \_$height(v) for the grid width and height of node v, and with xmin, xmax, ymin, ymax for the bounding box of the grid layout. The width and height of node v before the transformation are denoted by width(v) and height(v).

The output is given by x(v), y(v) for the position of node v, line(e), source_anchor(e) and target_anchor(e) for the polyline of edge e, and width'(v), height'(v) for the width and height of node v after the transformation. This notation will also be used in the documentation of implementations.

The input grid layout is passed to the grid coordinate mapper as a grid layout info object. An implementation of a grid coordinate mapper accesses the grid layout by using access functions provided by GridCoordinateMapper. It always works on the graph for which the final layout is produced independent of the actual type of the grid layout info object.

A grid coordinate mapper is implemented by overiding virtual methods. The computation of initial node sizes ( get_node_grid_size() function) is implemented by overriding do_get_node_grid_size(). When this method is called, grid width and height of each node are set to 0. For setting grid width or height serve the two functions grid_width(v, w) and grid_height(v, h). The default of do_get_node_grid_size() is the empty function.

The call() function does the transformation of grid coordinates into real coordinates. In most cases, the mapping is a function $ \varphi$ : $ \bf N^{2}_{}$ $ \rightarrow$ $ \bf R^{2}_{}$ with

$ \varphi(\mathit{column},\mathit{row}) = \left( \varphi_x(\mathit{column}),\varphi_y(\mathit{row})
\right). $
In this case, the mapping of x-coordinates is independent of the y-coordinates and vice versa. GridCoordinateMapper provides a basic scheme for implementing the call() function. This scheme consists of several virtual methods, which an implementation overrides if the default is not appropriate for the particular mapping. The mapping function $ \varphi$ must be defined by implementing map_x (column) and map_y (row).
  1. Initialization

    The init(A) method is called. Default is the empty function.

  2. Mapping of node coordinates

    The map_nodes(A) method is called. The default implementation computes the positions of the nodes by calling map_node(v, A) for each node v in G.

    The default of map_node(v, A) returns the center of the rectangular region of v. More exactly, if v is at grid position (x, y) and has grid width w and grid height h, it returns

    $ \frac{1}{2} \left( \varphi(x,y) + \varphi(x+w,y+h)\right). $

  3. Mapping of edge coordinates

    The map_edges(A) method is called. The default implementation determines for each edge e the grid points gsa and gta which are the source (resp. target) grid anchor point of e, and the remaining list of grid bend points ipl. Then, it calls map_edge (e, ipl, gsa, gta, dpl, s$ \_$a, t$ \_$a, A) in order to compute the polyline dpl and the source and target anchors s_a and t_a for e.

    The default of map_edge (e, ipl, gsa, gta, dpl, s$ \_$a, t$ \_$a, A) computes the edge anchors by transforming the coordinates of $ \varphi$(gsa) and $ \varphi$(gta) into [- 1..1] x [- 1, 1] coordinates which are relativ to the source (resp. target) node. The grid bend points in ipl are simply transformed using $ \varphi$ and assigned to dpl.

  4. Mapping of cluster regions

    If M is called for a cluster graph, the map_clusters(A) method is called. The default implementation uses the map_x and map_y methods to transform the corner points of the rectangular cluster regions.

  5. Cleaning-up

    Finally, the cleanup(A) method is called. Default is the empty function.

By default, the sizes of nodes remain unchanged. However, it is usually necessary to enlarge nodes in certain cases. An implementation must take care for this (e.g., in init()). It is also important to know that the node grid sizes computed by get_node_grid_size() are not necessarily the input grid sizes of the call() function. They are rather a proposal, but the input of call() may differ in any way.

#include < AGD/GridCoordinateMapper.h >

Initialization

GridCoordinateMapper M initializes a grid coordinate mapper.

Operations

a) Standard Interface

void M.get_node_grid_size(GridLayoutInfo& gli, const LayoutInterface& A)
    assign for each node in G a grid width and grid height via gli . Precondition: The grid layout corresponding to gli and the layout interface A are for the same graph.

void M.call(GridLayoutInfo& gli, LayoutInterface& A)
    calls M for grid layout info gli. Assigns the transformed layout to A. Precondition: The grid layout corresponding to gli and the layout interface A are for the same graph.

void M.call(CGGridLayoutInfo& gli, CGLayoutInterface& A)
    calls M for cluster graph grid layout info gli. Assigns the transformed layout to A. Precondition: The grid layout corresponding to gli and the layout interface A are for the same graph.


b) Protected Access Functions

const leda_graph& M.get_graph() returns a reference to the input graph G.

int M.column(leda_node v) returns the column of v in the grid layout.

int M.row(leda_node v) returns the row of v in the grid layout.

IPolyline M.bends(leda_edge e) returns the list of bend points of e in the grid layout.

int M.grid_width(leda_node v) returns the width of v in the grid layout.

int M.grid_height(leda_node v)
    returns the height of v in the grid layout.

bool M.in_rect(const IPoint& ip, leda_node v)
    returns true iff ip $ \in$ rect(v).

IRect M.get_gbbox() returns a tight bounding box of the grid layout.

DPoint M.map(const IPoint& ip) returns the point (map(x),map(y)), where ip = (x, y).

void M.get_anchor(DPoint& anchor, leda_node v, const DPoint& abs_anchor, const LayoutInterface& A)
    returns in anchor the relativ anchor point corresponding to the absolute point abs_anchor for edge end point v.

The following two functions may only be called for implementing do_get_node_grid_size().

void M.grid_width(leda_node v, int w)
    sets the width of v in the grid layout to w.

void M.grid_height(leda_node v, int h)
    sets the height of v in the grid layout to h.


c) Protected Overridables

void M.do_get_node_grid_size(const LayoutInterface& A)
    implements get_node_grid_size. Initially, the width and height of each node is set to 0. Default is the empty function.

void M.init(LayoutInterface& A)
    called for initialization.

void M.map_nodes(LayoutInterface& A)
    called for assigning node coordinates.

void M.map_edges(LayoutInterface& A)
    called for assigning edge polylines.

void M.map_clusters(CGLayoutInterface& A)
    called for assigning cluster regions.

void M.cleanup(LayoutInterface& A)
    called for cleaning up.

DPoint M.map_node(leda_node v, LayoutInterface& A)
    returns the position of v.

void M.map_edge(leda_edge e, IPolyline& ipl, const IPoint& gsa, const IPoint& gta, DPolyline& dpl, DPoint& s_a, DPoint& t_a, LayoutInterface& A)
    returns the polyline for edge e in dpl (bend points), s_a (source anchor point) and t_a (target anchor point). Input are the grid points gsa and gta, which are the anchor points at the source (resp. target) node, and the bend points ipl.

double M.map_x(int column) returns $ \varphi_{x}^{}$(column).

double M.map_y(int row) returns $ \varphi_{y}^{}$(row).


next up previous contents index
Next: Mapping with Equal Sized Up: Grid Coordinate Mappers Previous: Grid Coordinate Mappers   Contents   Index

© Copyright 1998-2001, Algorithmic Solutions Software GmbH. All rights reserved.
2001-08-13