www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@mbcwidgets/@Table1D/getSelectedRegions.m

    function sel = getSelectedRegions(obj)
%GETSELECTEDREGIONS Get the current selection from the table
%
%  SEL = GETSELECTEDREGIONS(OBJ) returns the current selection from the
%  table as a series of region definitions.  The output is a (N-by-2) cell
%  array with each row corresponding to a separate selection rectangle.
%  The first column contains [min max] pairs for each block's row extents
%  and the second column contains [min max] pairs for each block's column
%  extents.  The selected indices that are returned are in the view
%  coordinates.  They might not form a contiguous region in the data model
%  coordinates.

%  Copyright 2000-2009 The MathWorks, Inc. and Ford Global Technologies, Inc.


% Get the rectangles from a java method
jSel = javaMethodEDT('getSelectionBlocks',java(obj.Peer) );

sel = cell(jSel.size, 2);
for n = 1:size(sel, 1)
    data = jSel.get(n-1) + 1;
    sel{n,1} = data(1:2)';
    sel{n,2} = data(3:4)';
end