www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/+cageview/+optimoutput/FreeValuesView.m
classdef FreeValuesView < mbcgui.multiview.View %cageview.optimoutput.FreeValuesView class % cageview.optimoutput.FreeValuesView extends mbcgui.multiview.View. % % cageview.optimoutput.FreeValuesView 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' % % cageview.optimoutput.FreeValuesView methods: % gettitle - Return string to use as title for view % redraw - Redraw the stats information table % Copyright 2005-2015 The MathWorks, Inc. properties (Access=protected, AbortSet) %HINFOTABLE Property is of type 'MATLAB array' hInfoTable = []; end methods % constructor block function obj = FreeValuesView(varargin) %FreeValuesView Constructor for FreeValuesView % OBJ = FreeValuesView(PROP, VALUE) constructs a class that displays % free variable values. % Call the inherited constructor obj@mbcgui.multiview.View(varargin{ : }); % converted super class constructor call obj.hInfoTable = mbcgui.table.InfoPane('Parent', obj.Parent, ... 'Position', obj.Position, ... 'SplitPosition', 0.6, ... 'UIContextMenu',obj.UIContextMenu,... 'Visible', obj.Visible); obj.ContentHandle = obj.hInfoTable; if ~isempty(obj.MessageService) obj.pPostSetMessageService; end obj.addListeners(event.listener(obj.hInfoTable, 'ButtonDown', @i_passonbtndown)); function i_passonbtndown(~, ~) % pass on ButtonDown event obj.notify('ButtonDown'); end end end % constructor block methods end % set and get functions methods % public methods %---------------------------------------- function str = gettitle(obj) %#ok<MANU> %GETTITLE Return string to use as title for view % STR = GETTITLE(OBJ) returns a string that should be used as a title for % the container the view sits in. str = 'Free Variable Values'; end % gettitle %---------------------------------------- function redraw(obj) %REDRAW Redraw the stats information table % REDRAW(OBJ) re-displays all of the output statistics for the currently % selected run. if obj.hasData && obj.MessageService.hasFocusIndex RunIdx = obj.MessageService.getFocusRun; SolIdx = obj.MessageService.getFocusSolution; out = obj.MessageService.getOptimOutput; [Vals, Names] = getSingleSolution(out, RunIdx, SolIdx, 'OutputFormat', 'cell', ... 'OutputContents', {'FreeVars'}); ValLengths = cellfun(@length, Vals); if all(ValLengths==1) inf = [Names(:), Vals(:)]; % Convert numeric data to strings for n = 1:size(inf,1) inf{n,2} = sprintf('%.12g', inf{n,2}); end else inf = cell(sum(ValLengths), 2); k = 1; for n = 1:length(Vals) if ValLengths(n)==1 inf{k,1} = Names{n}; inf{k,2} = sprintf('%.12g', Vals{n}); k = k+1; else for m = 1:ValLengths(n) inf{k,1} = sprintf('%s(%d)', Names{n}, m); inf{k,2} = sprintf('%.12g', Vals{n}(m)); k = k+1; end end end end else inf = cell(0,2); end obj.hInfoTable.ListText = inf; end % redraw end % public methods methods(Access=protected) %---------------------------------------- function pPostSetMessageService(obj) %PPOSTSETMESSAGESERVICE Method that is called when the message service is set % PPOSTSETMESSAGESERVICE(OBJ) is called in response to a new message % service being set in the object. pPostSetMessageService@mbcgui.multiview.View(obj); if ~isempty(obj.MessageService) % Add redraw events obj.addMessageServiceListener( {'ObjectChanged', ... 'SliceDirectionChanged', ... 'CurrentFocusChanged'}, ... {{@i_refresh, obj}, ... {@i_refresh, obj}, ... {@i_refresh, obj}}); end obj.redraw; end % pPostSetMessageService end end % classdef function i_refresh(~, ~, obj) % Refresh all the information obj.redraw; end % i_refresh