www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@mbcwidgets/@VariableEditorTable/pSetNewValueAt.m
function pSetNewValueAt(obj, rows, cols, values) %PSETNEWVALUEAT set a new value at a specified row % % PSETNEWVALUEAT(OBJ, ROW, COL, JVAL) updates the value at the specified % row and column from the java value object jval. A VariableChanged event % is then sent. % Copyright 2000-2008 The MathWorks, Inc. and Ford Global Technologies, Inc. SWITCH_RC = false; if obj.ValueColumnCount==1 && any(rows>size(obj.VariableTypes,1)) % Switch row and column indices for a 1D row of values SWITCH_RC = true; tmp = cols; cols = rows; rows = tmp; end for n = 1:length(rows) for m = 1:length(cols) row = rows(n); col = cols(m); jval = values(n, m); obj.disableListeners; switch class(jval); case 'com.mathworks.toolbox.mbc.gui.value.ScalarValue' obj.VariableTypes(row, col) = 1; obj.VariableValues{row, col} = jval.getScalar; case 'com.mathworks.toolbox.mbc.gui.value.RangeValue' obj.VariableTypes(row, col) = 2; obj.VariableValues{row, col} = ... [jval.getRangeMin jval.getRangeMax jval.getNumPoints]; case 'com.mathworks.toolbox.mbc.gui.value.FreeformValue' obj.VariableTypes(row, col) = 3; obj.VariableValues{row, col} = jval.getVector.'; case 'com.mathworks.toolbox.mbc.gui.value.LinkedValue' obj.VariableTypes(row, col) = 4; obj.VariableValues{row, col} = jval.LinkedVar; case 'com.mathworks.toolbox.mbc.gui.value.LogicalValue' obj.VariableTypes(row, col) = 5; obj.VariableValues{row, col} = jval.Value; end obj.enableListeners; if SWITCH_RC tmp = col; col = row; row = tmp; end obj.pSendVariableChanged(row, col, jval.getValue); end end