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

bibliothek.gui.dock.layout.DockLayoutComposition Maven / Gradle / Ivy

The newest version!
/*
 * Bibliothek - DockingFrames
 * Library built on Java/Swing, allows the user to "drag and drop"
 * panels containing any Swing-Component the developer likes to add.
 * 
 * Copyright (C) 2007 Benjamin Sigg
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 * Benjamin Sigg
 * [email protected]
 * CH - Switzerland
 */
package bibliothek.gui.dock.layout;

import java.util.List;

import bibliothek.gui.dock.DockElement;

/**
 * A {@link DockLayoutComposition} describes all relations and positions of a
 * set of {@link DockElement}s. The DockLayoutComposition does not
 * have any references to DockElements, but with the help of a
 * {@link DockSituation} new trees of DockElements can be created.
 * @author Benjamin Sigg
 */
public class DockLayoutComposition {
    /** a description of the {@link DockElement} that is represented by this composition */
    private DockLayoutInfo layout;
    /** additional information about the element */
    private List> adjacent;
    /** the list of known children of this element */
    private List children;
    /** tells that the children of this station should be ignored */
    private boolean ignoreChildren;
    
    /**
     * Creates a new composition.
     * @param layout the content of the element that is represented by this composition,
     * can be null
     * @param adjacent additional information about the element, can be null
     * @param children the children of the station represented by this composition
     * @param ignoreChildren whether the children should be ignored or not
     */
    public DockLayoutComposition( DockLayoutInfo layout, List> adjacent, List children, boolean ignoreChildren ){
        if( children == null )
            throw new IllegalArgumentException( "children must not be null" );
        
        this.layout = layout;
        this.adjacent = adjacent;
        this.children = children;
        this.ignoreChildren = ignoreChildren;
    }
    
    /**
     * Gets the layout which describes the element of this composition.
     * @return the layout, can be null to indicate that this composition
     * was not loaded properly
     */
    public DockLayoutInfo getLayout() {
        return layout;
    }
    
    /**
     * Gets the additional information about the element.
     * @return the additional information or null
     */
    public List> getAdjacent() {
        return adjacent;
    }
    
    /**
     * Searches for the {@link DockLayout} whose factory is set to factoryId.
     * @param factoryId the name of some {@link AdjacentDockFactory}.
     * @return the matching layout or null if not found
     */
    public DockLayout getAdjacent( String factoryId ){
    	if( adjacent != null ){
	    	for( DockLayout layout : adjacent ){
	    		if( layout.getFactoryID().equals( factoryId )){
	    			return layout;
	    		}
	    	}
    	}
    	return null;
    }
    
    /**
     * Gets the list of all known children of this composition.
     * @return the list of children
     */
    public List getChildren() {
        return children;
    }
    
    /**
     * Tells that the children of this composition were ignored.
     * @return true if the children are to be ignored
     */
    public boolean isIgnoreChildren() {
        return ignoreChildren;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy