bibliothek.gui.dock.facile.station.split.ResizeElement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of docking-frames-common Show documentation
Show all versions of docking-frames-common Show documentation
DockingFrames is an open source Java Swing docking framework, licenced under LGPL 2.1.
This is the same distribution as the original distribution (http://www.docking-frames.org/), only reinstalled in maven
/*
* 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.facile.station.split;
import bibliothek.gui.dock.SplitDockStation;
/**
* Represents one node of the tree which represents the split-tree of
* a {@link SplitDockStation}.
* @author Benjamin Sigg
*/
public abstract class ResizeElement{
/** the last request that was issued */
private ResizeRequest request;
/** the parent of this node */
private ResizeElement parent;
/** the origin of this element */
private LockedResizeLayoutManager layout;
/**
* Creates a new element.
* @param parent the parent of this
* @param layout the origin of this element
*/
public ResizeElement( ResizeElement parent, LockedResizeLayoutManager layout ){
this.parent = parent;
this.layout = layout;
}
/**
* Gets the parent of this node
* @return the parent or null
if this is a root
*/
public ResizeElement getParent() {
return parent;
}
/**
* Gets the layout that created this element.
* @return the origin of this element
*/
public LockedResizeLayoutManager getLayout() {
return layout;
}
/**
* Creates the initial request of changed sizes.
* @return the initial request or null
*/
protected abstract ResizeRequest createRequest();
/**
* Gets the initial request for the size change.
* @return the initial request or null
*/
public ResizeRequest getRequest(){
return request;
}
/**
* Gets the children of this element.
* @return the children or null
*/
protected abstract ResizeElement[] getChildren();
/**
* Called before the bounds of a tree are updated, can be used
* to store some properties that are later needed to create
* the {@link ResizeRequest}.
*/
public void prepareResize(){
ResizeElement[] children = getChildren();
if( children != null ){
for( ResizeElement child : children ){
child.prepareResize();
}
}
}
/**
* Calls {@link #createRequest()} on this
and recursively
* on all children. Stores the result for later analysis.
*/
public void prepareRequests(){
ResizeElement[] children = getChildren();
if( children != null ){
for( ResizeElement child : children ){
child.prepareRequests();
}
}
request = createRequest();
}
/**
* Checks whether this {@link ResizeElement} is valid. A valid {@link ResizeElement} has no children
* that are null
.
* @return true
if this element can actually be used
*/
public boolean isValid(){
ResizeElement[] children = getChildren();
if( children != null ){
for( ResizeElement child : children ){
if( child == null ){
return false;
}
}
}
return true;
}
/**
* Adapts the size of the children of this element given the size change
* the parent could provide.
* @param deltaWidth the change of this elements width
* @param deltaHeight the change of this elements height
*/
public abstract void adapt( double deltaWidth, double deltaHeight );
/**
* Gets the root of this tree.
* @return the root
*/
public ResizeRoot getResizeRoot(){
return parent.getResizeRoot();
}
}