annotate toolboxes/graph_visualisation/graphViz4Matlab/layouts/Abstractlayout.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 classdef Abstractlayout < handle
wolffd@0 2 % This class represents an abstract graph layout. Subclass to create actual
wolffd@0 3 % layouts.
wolffd@0 4
wolffd@0 5 properties(Abstract = true)
wolffd@0 6 xmin; % The left most point on the graph axis in data units
wolffd@0 7 xmax; % The right most point on the graph axis in data units
wolffd@0 8 ymin; % The bottom most point on the graph axis in data units
wolffd@0 9 ymax; % The top most point on the graph axis in data units
wolffd@0 10 adjMatrix; % The adjacency matrix
wolffd@0 11 maxNodeSize; % The maximum diameter of a node in data units
wolffd@0 12 image; % A 20-by-20-by-3 array specifying an image for
wolffd@0 13 % the smartgraph button that will launch this
wolffd@0 14 % layout.
wolffd@0 15 name; % A unique name for instances of this class.
wolffd@0 16 shortDescription; % A short description used for tooltips.
wolffd@0 17 nodeSize; % The calculated node size, call dolayout() before accessing
wolffd@0 18 centers; % The calculated node centers in an n-by-2 matrix
wolffd@0 19 end
wolffd@0 20
wolffd@0 21 methods
wolffd@0 22 function dolayout(obj,adjMatrix,graphAxis,maxNodeSize)
wolffd@0 23 % Calculate the node centers and an optimal size
wolffd@0 24 obj.adjMatrix = adjMatrix;
wolffd@0 25 obj.maxNodeSize = maxNodeSize;
wolffd@0 26 xlimits = get(graphAxis,'XLim');
wolffd@0 27 ylimits = get(graphAxis,'YLim');
wolffd@0 28 obj.xmin = xlimits(1); obj.xmax = xlimits(2);
wolffd@0 29 obj.ymin = xlimits(1); obj.ymax = ylimits(2);
wolffd@0 30 obj.calcLayout();
wolffd@0 31 end
wolffd@0 32
wolffd@0 33 function available = isavailable(obj)
wolffd@0 34 % Test to see if this layout is available.
wolffd@0 35 available = true;
wolffd@0 36 end
wolffd@0 37
wolffd@0 38 end
wolffd@0 39
wolffd@0 40 methods(Access = 'protected')
wolffd@0 41
wolffd@0 42 function setImage(obj,color)
wolffd@0 43 % Sets the image to a grid with the specified color in rgb normalized
wolffd@0 44 % units, i.e. [0.2 0.5 0.9].
wolffd@0 45 obj.image = cat(3,color(1)*ones(20,20),color(2)*ones(20,20),color(3)*ones(20,20));
wolffd@0 46 obj.image(1:4:20,:,:) = 0;
wolffd@0 47 obj.image(:,1:4:20,:) = 0;
wolffd@0 48 end
wolffd@0 49
wolffd@0 50
wolffd@0 51 end
wolffd@0 52
wolffd@0 53 methods(Abstract = true, Access = 'protected')
wolffd@0 54 calcLayout(obj); % do the actual work
wolffd@0 55 end
wolffd@0 56
wolffd@0 57 end