bibliothek.gui.dock.station.split.SplitDividerStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of docking-frames-core Show documentation
Show all versions of docking-frames-core Show documentation
A window docking framework for Swing
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) 2011 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.station.split;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import bibliothek.gui.dock.SplitDockStation;
/**
* The {@link SplitDividerStrategy} is responsible for resizing the children of a {@link SplitDockStation}. How exactly
* a {@link SplitDividerStrategy} accomplishes that goal is not defined, but usually that involves:
* - Adding a {@link MouseListener} and a {@link MouseMotionListener} to the {@link Component} that is given during the
* {@link #install(SplitDockStation, Component) installation}.
* - If the user presses the mouse the strategy will use {@link SplitDockStation#getRoot()} and {@link SplitNode#getDividerNode(int, int)} to find the {@link Node} that
* is below the mouse.
* - By calling {@link Node#getDividerAt(int, int)} and {@link Node#setDivider(double)} the strategy can resize
* the children.
* - Through {@link SplitDockStation#getCurrentSplitLayoutManager()} and {@link SplitLayoutManager#validateDivider(SplitDockStation, double, Node)} a strategy
* can make sure that a valid value for the divider property is chosen.
*
* A strategy may offer additional services like changing the {@link Cursor}, or a strategy
* may not do anything at all.
* Implementations should (but are not enforced to) respect some properties:
*
* - {@link SplitDockStation#isResizingEnabled()}: whether the user is allowed to resize the children.
* - {@link SplitDockStation#isContinousDisplay()}: whether resizing should happen immediatelly.
*
*
* Clients usually do not need to implement this interface, and the framework offers only one default
* implementation. The interface will however remain, ready for clients with unforseen needs.
* @author Benjamin Sigg
*/
public interface SplitDividerStrategy {
/**
* Informs this strategy that station
is going to use it and that container
must
* be monitored in order to receive {@link MouseEvent}s.
* @param station the station whose children are resized by this strategy
* @param container the component to monitor
*/
public void install( SplitDockStation station, Component container );
/**
* Informs this strategy that it will no lonver be used by station
.
* @param station the station that is no longer using this
*/
public void uninstall( SplitDockStation station );
/**
* Allows this strategy to paint onto the {@link SplitDockStation}.
* @param station the station which is painted
* @param g the graphics context to use
*/
public void paint( SplitDockStation station, Graphics g );
}