All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xworker.html.GridLayout Maven / Gradle / Ivy

There is a newer version: 2.0.3
Show newest version
/*******************************************************************************
* Copyright 2007-2013 See AUTHORS file.
 * 
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 
*   http://www.apache.org/licenses/LICENSE-2.0
* 
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package xworker.html;

import java.util.ArrayList;
import java.util.List;

import org.xmeta.Thing;

public class GridLayout {
	/**
	 * Grid布局。
	 * 
	 * @param fields 需要布局的数据对象列表
	 * @param cols 布局总体所分的列
	 * 
	 * @return 布局的结果
	 */
	public static List> layout(List fields, int cols){
		//最多布局300行
        int maxRow = 300;
        List> rows = new ArrayList>();

        int[][] grids = new int[maxRow][cols];
        Object[][] gridData = new Object[maxRow][cols];

        for(int i=0; i cols ? cols : colspan;
            
            GridData gdata = new GridData();
            gdata.colspan = colspan;
            gdata.rowspan = rowspan;
            gdata.userData = obj;            
            
            //填充单元
            boolean seted = false;
            for(int m=0; m= colspan){
                            boolean ok = true;
                            for(int k=m; k row = new ArrayList();
            rows.add(row);
            for(int k=0; k




© 2015 - 2025 Weber Informatics LLC | Privacy Policy