Daniel@0: classdef Abstractlayout < handle Daniel@0: % This class represents an abstract graph layout. Subclass to create actual Daniel@0: % layouts. Daniel@0: Daniel@0: properties(Abstract = true) 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; % A 20-by-20-by-3 array specifying an image for Daniel@0: % the smartgraph button that will launch this Daniel@0: % layout. Daniel@0: name; % A unique name for instances of this class. Daniel@0: shortDescription; % A short description used for 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 dolayout(obj,adjMatrix,graphAxis,maxNodeSize) Daniel@0: % Calculate the node centers and an optimal size Daniel@0: obj.adjMatrix = adjMatrix; Daniel@0: obj.maxNodeSize = maxNodeSize; Daniel@0: xlimits = get(graphAxis,'XLim'); Daniel@0: ylimits = get(graphAxis,'YLim'); Daniel@0: obj.xmin = xlimits(1); obj.xmax = xlimits(2); Daniel@0: obj.ymin = xlimits(1); obj.ymax = ylimits(2); Daniel@0: obj.calcLayout(); Daniel@0: end Daniel@0: Daniel@0: function available = isavailable(obj) Daniel@0: % Test to see if this layout is available. Daniel@0: available = true; Daniel@0: end Daniel@0: Daniel@0: end Daniel@0: Daniel@0: methods(Access = 'protected') Daniel@0: Daniel@0: function setImage(obj,color) Daniel@0: % Sets the image to a grid with the specified color in rgb normalized Daniel@0: % units, i.e. [0.2 0.5 0.9]. Daniel@0: obj.image = cat(3,color(1)*ones(20,20),color(2)*ones(20,20),color(3)*ones(20,20)); Daniel@0: obj.image(1:4:20,:,:) = 0; Daniel@0: obj.image(:,1:4:20,:) = 0; Daniel@0: end Daniel@0: Daniel@0: Daniel@0: end Daniel@0: Daniel@0: methods(Abstract = true, Access = 'protected') Daniel@0: calcLayout(obj); % do the actual work Daniel@0: end Daniel@0: Daniel@0: end