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