annotate toolboxes/graph_visualisation/graphViz4Matlab/layouts/Circlelayout.m @ 0:cc4b1211e677 tip

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