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

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