comparison toolboxes/graph_visualisation/graphViz4Matlab/layouts/Circlelayout.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 classdef Circlelayout < Abstractlayout
2 % A simple layout which places node onto a scaled unit circle.
3 %
4 % Matthew Dunham
5 % University of British Columbia
6 properties
7 xmin; % The left most point on the graph axis in data units
8 xmax; % The right most point on the graph axis in data units
9 ymin; % The bottom most point on the graph axis in data units
10 ymax; % The top most point on the graph axis in data units
11 adjMatrix; % The adjacency matrix
12 maxNodeSize; % The maximum diameter of a node in data units
13 image; % An image for the button that will lanuch this layout
14 name; % A unique name for instances of this class
15 shortDescription; % A description for use in the tooltips
16 nodeSize; % The calculated node size, call dolayout() before accessing
17 centers; % The calculated node centers in an n-by-2 matrix
18 end
19
20 methods
21 function obj = Circlelayout(name)
22 % constructor
23 if(nargin < 1)
24 obj.name = 'circlelayout';
25 else
26 obj.name = name;
27 end
28 load glicons;
29 obj.image = icons.circle;
30 obj.shortDescription = 'Simple Circle Layout';
31 end
32 end
33
34 methods(Access = 'protected')
35
36 function calcLayout(obj)
37 nnodes = size(obj.adjMatrix,1);
38 step = 2*pi/(nnodes);
39 t = 0:step:2*pi;
40 x = 0.4*sin(t)+0.5;
41 y = 0.4*cos(t)+0.5;
42
43 x = obj.xmin + x ./ (obj.xmax - obj.xmin);
44 y = obj.ymin + y ./ (obj.ymax - obj.ymin);
45 obj.centers = [x',y'];
46 d = sqrt((x(2)- x(1))^2 + (y(2) - y(1))^2);
47 obj.nodeSize = min(2*d/3,obj.maxNodeSize);
48 end
49
50 end
51
52
53
54 end