Daniel@0: classdef Circlelayout < Abstractlayout Daniel@0: % A simple layout which places node onto a scaled unit circle. Daniel@0: % Daniel@0: % Matthew Dunham Daniel@0: % University of British Columbia Daniel@0: properties Daniel@0: xmin; % The left most point on the graph axis in data units Daniel@0: xmax; % The right most point on the graph axis in data units Daniel@0: ymin; % The bottom most point on the graph axis in data units Daniel@0: ymax; % The top most point on the graph axis in data units Daniel@0: adjMatrix; % The adjacency matrix Daniel@0: maxNodeSize; % The maximum diameter of a node in data units Daniel@0: image; % An image for the button that will lanuch this layout Daniel@0: name; % A unique name for instances of this class Daniel@0: shortDescription; % A description for use in the tooltips Daniel@0: nodeSize; % The calculated node size, call dolayout() before accessing Daniel@0: centers; % The calculated node centers in an n-by-2 matrix Daniel@0: end Daniel@0: Daniel@0: methods Daniel@0: function obj = Circlelayout(name) Daniel@0: % constructor Daniel@0: if(nargin < 1) Daniel@0: obj.name = 'circlelayout'; Daniel@0: else Daniel@0: obj.name = name; Daniel@0: end Daniel@0: load glicons; Daniel@0: obj.image = icons.circle; Daniel@0: obj.shortDescription = 'Simple Circle Layout'; Daniel@0: end Daniel@0: end Daniel@0: Daniel@0: methods(Access = 'protected') Daniel@0: Daniel@0: function calcLayout(obj) Daniel@0: nnodes = size(obj.adjMatrix,1); Daniel@0: step = 2*pi/(nnodes); Daniel@0: t = 0:step:2*pi; Daniel@0: x = 0.4*sin(t)+0.5; Daniel@0: y = 0.4*cos(t)+0.5; Daniel@0: Daniel@0: x = obj.xmin + x ./ (obj.xmax - obj.xmin); Daniel@0: y = obj.ymin + y ./ (obj.ymax - obj.ymin); Daniel@0: obj.centers = [x',y']; Daniel@0: d = sqrt((x(2)- x(1))^2 + (y(2) - y(1))^2); Daniel@0: obj.nodeSize = min(2*d/3,obj.maxNodeSize); Daniel@0: end Daniel@0: Daniel@0: end Daniel@0: Daniel@0: Daniel@0: Daniel@0: end