Baseclasses
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
gridwidth(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
:
with
The init(A) method is called. Default is the empty function.
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
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, sa, 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, sa, t
a, A)
computes the edge anchors by transforming
the coordinates of
(gsa) and
(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
and assigned to dpl.
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.
Finally, the cleanup(A) method is called. Default is the empty function.
#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 ![]() |
||
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
![]() |
double | M.map_y(int row) | returns
![]() |
© Copyright 1998-2001, Algorithmic Solutions Software GmbH. All rights reserved.
2001-08-13