Commit 12c5e504 authored by Matthew Dawson's avatar Matthew Dawson
Browse files

Add in converter functions to convert from Matlab 2d grids to Java.

Add in a converter function that converts Matlab 2d grids to the java representaion.
Do to the ugliness of the Matlab system, there a ton of resizes going on. Also,
the code is completely untested, but works in theory.
parent 7be0b274
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
%% convert_hierarchical_grid_to_java
% generates a java version fo the hiearchcial grid
%
% inputs:
%   grid:Grid - grid to convert
%   java_grid:List<HierarchicalCell> - place to put changed cells.
%
% outputs;
%   none
% Author: Matthew Dawson matthew@mjdsystems.ca
% Organization: McMaster Centre for Software Certification

function convert_twodimensional_grid_to_java(grid, java_grid)

% Pre-set the x size.
java_grid.setSize(size(grid.Grid1.cells, 2), 1)

TableBlock.convert_twodimensional_grid_to_java_real(grid, grid.Grid2.cells, grid.Grid1.cells, java_grid, 0)

end
+29 −0
Original line number Diff line number Diff line
%% convert_hierarchical_grid_to_java
% generates a java version fo the hiearchcial grid
%
% inputs:
%   grid:Grid - grid to convert
%   java_grid:List<HierarchicalCell> - place to put changed cells.
%
% outputs;
%   none
% Author: Matthew Dawson matthew@mjdsystems.ca
% Organization: McMaster Centre for Software Certification

function current_index = convert_twodimensional_grid_to_java_real(grid, left_grid, top_gird, java_grid, current_index)

for i=1:size(left_grid,2)
    % If we are not a leaf node on the left, descend:
    if ~isempty(old_cell.subgrid)
        current_index = TableBlock.convert_twodimensional_grid_to_java_real(grid, left_grid(i).subgrid.cells, top_grid, java_grid, current_index)
    else % Otherwise, we are the reference cell for the 2d grid.  So pull results out.
        java_grid.resize(java_grid.sizeX(), current_index + 1)
        for j=1:size(top_grid, 2)
            java_grid.get(j, current_index).setContents(grid.search_return(top_grid(j), left_grid(i)).result_text);
        end
        current_index=current_index+1;
    end
end

end