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

org.jclarion.clarion.swing.TabLayout Maven / Gradle / Ivy

There is a newer version: 1.86
Show newest version
/**
 * Copyright 2010, by Andrew Barnham
 *
 * The contents of this file are subject to
 * GNU Lesser General Public License (LGPL), v.3
 * http://www.gnu.org/licenses/lgpl.txt
 * 
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied.
 */
package org.jclarion.clarion.swing;

import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager2;

public class TabLayout implements LayoutManager2
{
    private boolean spread;
    
    private int y;
    
    public TabLayout(boolean spread)
    {
        this.spread=spread;
    }

    @Override
    public void addLayoutComponent(String name, Component comp) {
    }

    private void layoutRow(Component[] kids, int first, int last, int spread,int y) 
    {
        if (last==first) return;
        int avgSpread=spread/(last-first);
        
        int x = 0;
        
        for (int scan=first;scan0 && x+current.width>width) {
                layoutRow(kids,first,scan,width-x,y);
                y+=maxy;
                maxy=0;
                x=0;
                first=scan;
            }
            
            x+=current.width;
            if (maxy0) {
            layoutRow(kids,first,kids.length,spread?width-x:0,y);
            y+=maxy;
        }    
        
        
        this.y=y;
        
    }


    public int getY()
    {
        return y;
    }
    
    @Override
    public Dimension minimumLayoutSize(Container parent) {
        return new Dimension(20,20);
    }

    @Override
    public Dimension preferredLayoutSize(Container parent) 
    {
        return new Dimension(20,20);
    }

    @Override
    public void removeLayoutComponent(Component comp) {
    }

    @Override
    public void addLayoutComponent(Component comp, Object constraints) {
        // TODO Auto-generated method stub
        
    }

    @Override
    public float getLayoutAlignmentX(Container target) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public float getLayoutAlignmentY(Container target) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public void invalidateLayout(Container target) {
        target.validate();
    }

    @Override
    public Dimension maximumLayoutSize(Container target) {
        // TODO Auto-generated method stub
        return null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy