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