www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/+xregdesgui/PairwiseProj.m
classdef PairwiseProj < xregdesgui.DesignView %xregdesgui.PairwiseProj class % xregdesgui.PairwiseProj extends xregdesgui.DesignView. % % xregdesgui.PairwiseProj properties: % Parent - Property is of type 'MATLAB array' % Position - Property is of type 'rect' % Enable - Property is of type 'on/off' % Visible - Property is of type 'on/off' % UserData - Property is of type 'MATLAB array' % Tag - Property is of type 'string' % MessageService - Property is of type 'handle' % Options - Property is of type 'handle vector' % Actions - Property is of type 'handle vector' % UIContextMenu - Property is of type 'MATLAB array' % % xregdesgui.PairwiseProj methods: % gettitle - Return a suitable title for a window % printSize - Returns the preferred printing size for the component % printCopy - Create a printer-friendly copy of pairwiseproj % Copyright 2015-2016 The MathWorks, Inc. and Ford Global Technologies, Inc. properties (SetAccess=protected, AbortSet) %HTABLE Property is of type 'handle' hTable = []; %HTABLEDATA Property is of type 'handle' hTableData = []; end methods % constructor block function obj = PairwiseProj(varargin) %PAIRWISEPROJ Constructor for PairwiseProj object % OBJ = PAIRWISEPROJ(PROP, VAL, ...) creates a new PairwiseProj object. obj@xregdesgui.DesignView(varargin{ : }); % converted super class constructor call obj.hTableData = xregdesgui.PairwiseProjData; obj.hTableData.DesignPackage = obj.MessageService; nodisp = axestext(obj.Parent,'visible','off', ... 'string','2 or more factors required', ... 'horizontalalignment','center', ... 'verticalalignment','middle'); obj.hTable = mbcgui.widget.ClassicTable('Parent',obj.Parent, ... 'ShowRowHeaders', true, ... 'ShowColumnHeaders', true,... 'RowHeaderWidth', 70,... 'ColumnHeaderWidth', 60,... 'MinimumCellSize', [150 150],... 'UseVectorDrawMethod',false,... 'MainConstructor', @i_createMainObject,... 'RowConstructor', @i_createRowHeadObject,... 'ColumnConstructor', @i_createColHeadObject, ... 'MainData', obj.hTableData, ... 'RowHeaderData', obj.hTableData,... 'ColumnHeaderData', obj.hTableData,... 'RowGap', 0,... 'ColumnGap',0, ... 'ColumnHeaderPosition', 'bottom', ... 'MaximumObjectCacheSize', 15); obj.hTable.TopLeftCorner = obj.hTable.newCornerComponent('panel'); obj.hTable.BottomRightCorner = obj.hTable.newCornerComponent; obj.hTable.EmptyTableComponent = nodisp; A1 = mbcgui.actions.ToggleAction({@i_setgraphsize, obj.hTable, 0, obj.Options}, ... '&Display All Graphs'); A2 = mbcgui.actions.ToggleAction({@i_setgraphsize, obj.hTable, 100, obj.Options}, ... '&Small'); A3 = mbcgui.actions.ToggleAction({@i_setgraphsize, obj.hTable, 150, obj.Options}, ... '&Medium'); A3.Selected = true; A4 = mbcgui.actions.ToggleAction({@i_setgraphsize, obj.hTable, 200, obj.Options}, ... '&Large'); obj.Options.Actions = [A1 A2 A3 A4]; obj.ContentHandle = obj.hTable; pPostSetMessageService(obj) end % PairwiseProj end % constructor block methods % public methods %---------------------------------------- function s = gettitle(obj) %#ok<MANU> %GETTITLE Return a suitable title for a window % GETTITLE(OBJ) returns a string that can be used as the title for the % view. s = 'Pairwise Projections'; end % gettitle %---------------------------------------- function pUpdateGraph(obj, ~,~) %PUPDATEGRAPH Update the pairwise graphs % % PUPDATEGRAPH(OBJ) updates the display. % Force a table update obj.hTable.update; end % pUpdateGraph %---------------------------------------- function sz = printSize(obj) %PRINTSIZE Returns the preferred printing size for the component % SZ = PRINTSIZE(OBJ) returns a two element vector containing the % preferred width and height for printing the component. This method % scales the current screen size so that each graph maintains its aspect % ration, and adds 50 pixels for a title. % Get size of central table region sz = obj.Position(3:4) - [65 45]; % Scale size by number of missing graphs nShowing = obj.hTable.getDisplaySize; nTotal = [obj.hTableData.getRowCount, obj.hTableData.getColumnCount]; if all(nShowing>0) sz = sz.*fliplr(nTotal./nShowing); end % Add room allowed for outer axes and a title sz = sz + [45 25] + [0 50]; end % printSize %---------------------------------------- function newobj = printCopy(obj, fig) %PRINTCOPY Create a printer-friendly copy of pairwiseproj % LYT = PRINTCOPY(OBJ,FIG) % Create a copy of the design data if obj.hasData dpnew = obj.MessageService.copy; else dpnew = []; end % Create a new table NewTableData = xregdesgui.PairwiseProjData; NewTableData.DesignPackage = dpnew; nodisp = axestext(fig,'visible','off', ... 'string','2 or more factors required', ... 'horizontalalignment','center', ... 'verticalalignment','middle'); newtable = mbcgui.widget.ClassicTable('Parent',fig, ... 'ShowRowHeaders',false, ... 'ShowColumnHeaders',false,... 'MinimumCellSize', [0 0],... 'UseVectorDrawMethod',false,... 'MainConstructor',@i_createMainObjectPrintable,... 'MainData', NewTableData, ... 'RowGap', 0,'ColumnGap',0); newtable.EmptyTableComponent = nodisp; layout = xreglayerlayout(fig, ... 'border', [50 50 0 0], ... 'elements', {newtable}); newobj = obj.addPrintTitle(layout); end % printcopy end % public methods methods (Access=protected) %---------------------------------------- function pPostSetMessageService(obj) %PPOSTSETMESSAGESERVICE Respond to change of MessageService % PPOSTSETMESSAGESERVICE(OBJ) is called when the MessageService property % is changed. % Clear the listeners and add new ones obj.clearMessageServiceListeners; if ~isempty(obj.MessageService) obj.addMessageServiceListener( ... event.listener(obj.MessageService,'DesignChange',@obj.pUpdateGraph) ... ); pProp = obj.MessageService.findprop('DesignShowTestNumbers'); if ~isempty(pProp) L = event.proplistener(obj.MessageService, ... pProp, 'PostSet', @obj.pUpdateGraph); obj.addMessageServiceListener(L); end end obj.pUpdateGraph; end % pPostSetMessageService end end % classdef function h = i_createMainObject(P) h = xregdesgui.PairwiseProjGraph('Parent',P,'Visible','off'); end % i_createMainObject function h = i_createRowHeadObject(P) h = xregdesgui.PairwiseProjHeader('Parent',P,... 'Visible','off',... 'Min',-1, 'Max',1, ... 'Orientation', 'vertical', ... 'AxisEdgeOffset', 10); end % i_createRowHeadObject function h = i_createColHeadObject(P) h = xregdesgui.PairwiseProjHeader('Parent',P,... 'Visible','off',... 'Min',-1, 'Max',1, ... 'Orientation', 'horizontal', ... 'AxisEdgeOffset', 15); end % i_createColHeadObject function i_setgraphsize(src, ~, hTable, size, AG) hTable.MinimumCellSize = [size size]; set(AG.Actions, 'Selected', false); src.Selected = true; end % i_setgraphsize function h = i_createMainObjectPrintable(P) h = xregdesgui.PairwiseProjGraph('Parent',P,... 'DrawEdgeAxes', true, ... 'AxesHittest', true); end % i_createMainObjectPrintable