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