com.tensegrity.skeleton.swing
Class SwingFrameLayoutController

java.lang.Object
  extended bycom.tensegrity.skeleton.swing.SwingFrameLayoutController

public class SwingFrameLayoutController
extends java.lang.Object

The SwingFrameLayoutController gathers all the logic behind the ApplicationFrame layout of toolboxes and graphDocuments. Methods within this class ensure that the global layout of the application and the application itself (i.e. menu and toolbars) are kept in a valid state when the ToggleLeftColumnCommand,ToggleRightColumnCommand commands, and the menu items used in order to hide or show toolboxes are used. Note that this controller also manages the application state when the user closes the toolboxes using the top-right cross on their respective panels. It is recommanded to subclass this class in order to provide application specific initial containers size values as well as specific resize weights for the application's JSplitPanes. In order to do so the following methods are provided:

Please refer to these methods documentation for more information. It is also important to note that each container is initialized with a default minimum size (DEFAULT_MINIMUM_SIZE). However, subclasses can override these values by means of the setupContainersMinimumSizes() method. It is also recommended to go through the JSplitPane's class documentation for a better understanding of the resize weights.

Version:
$Id: SwingFrameLayoutController.java,v 1.56 2005/08/16 10:20:22 BurkhardWick Exp $
Author:
S�bastien Guyon

Field Summary
static java.awt.Dimension DEFAULT_MINIMUM_SIZE
          This is the default minimum size for each container.
static int SLIDE_PANEL_EAST
          Public constants for layout positions/constraints.
static int SLIDE_PANEL_NORTH_EAST
          Public constants for layout positions/constraints.
static int SLIDE_PANEL_NORTH_WEST
          Public constants for layout positions/constraints.
static int SLIDE_PANEL_SOUTH
          Public constants for layout positions/constraints.
static int SLIDE_PANEL_SOUTH_EAST
          Public constants for layout positions/constraints.
static int SLIDE_PANEL_SOUTH_WEST
          Public constants for layout positions/constraints.
static int SLIDE_PANEL_WEST
          Public constants for layout positions/constraints.
static double SPLITPANE_DEFAULT_RESIZE_WEIGHT
          Constant defining the default resize weight for split panes
static java.lang.String SPLITPANE_HORIZONTAL_BOTTOM_LEFT
          Constant to be used by subclasses in setupSplitPanesResizeWeights().
static java.lang.String SPLITPANE_HORIZONTAL_BOTTOM_RIGHT
          Constant to be used by subclasses in setupSplitPanesResizeWeights().
static java.lang.String SPLITPANE_HORIZONTAL_MIDDLE
          Constant to be used by subclasses in setupSplitPanesResizeWeights().
static java.lang.String SPLITPANE_HORIZONTAL_TOP_LEFT
          Constant to be used by subclasses in setupSplitPanesResizeWeights().
static java.lang.String SPLITPANE_HORIZONTAL_TOP_RIGHT
          Constant to be used by subclasses in setupSplitPanesResizeWeights().
static java.lang.String SPLITPANE_VERTICAL_LEFT
          Constant to be used by subclasses in setupSplitPanesResizeWeights().
static java.lang.String SPLITPANE_VERTICAL_RIGHT
          Constant to be used by subclasses in setupSplitPanesResizeWeights().
 
Constructor Summary
SwingFrameLayoutController(SwingApplicationFrame applicationFrame)
          Creates a new SwingFrameLayoutController.
 
Method Summary
protected  SwingApplicationFrame getApplicationFrame()
          Returns the local SwingApplicationFrame instance.
protected  int getDefaultDividerSize()
          Returns the split panes divider sizes depending on the current L&F.
protected  Container getEastContainer()
           Returns the application specific East Container
 FrameLayoutSnapshot getFameLayoutSnapshot()
           This method returns an instance of FrameLayoutSnapshot which contains all the information required in order to re-build the application frame layout the next time the application is started.
protected  Container getNorthEastContainer()
           Returns the application specific North East Container
protected  Container getNorthWestContainer()
           Returns the application specific North West Container
protected  Container getSouthContainer()
           Returns the application specific South Container
protected  Container getSouthEastContainer()
           Returns the application specific South East Container
protected  Container getSouthWestContainer()
           Returns the application specific South West Container
protected  Container getWestContainer()
           Returns the application specific West Container
 boolean isLeftColumnVisible()
          Returns true if the left column is visible, false otherwise
 boolean isRightColumnVisible()
          Returns true if the right column is visible, false otherwise
 void restorePreferencesFrameLayout(FrameLayoutSnapshot snapshot)
           This method sets up this SwingFrameLayoutController instance in such a way that the application frame will be layouted with all the information contained into the passed FrameLayoutSnapshot.
protected  void setDefaultEastContainer(Container defaultEastContainer)
          Use this method in order to set the Container which should act as a default container for the right column.
protected  void setDefaultWestContainer(Container defaultWestContainer)
          Use this method in order to set the Container which should act as a default container for the left column.
protected  void setupContainerInitialSize(Container container, java.awt.Dimension size)
           Method used in order to set a container's initial size.
protected  void setupContainerMinimumSize(Container container, java.awt.Dimension size)
           Method used in order to set a container's initial size.
protected  void setupContainersInitialSizes()
           Method used in order to set containers initial sizes.
protected  void setupContainersMinimumSizes()
           Method used in order to set containers minimum sizes.
protected  java.util.HashMap setupSplitPanesResizeWeights()
           Method used in order to set up JSplitPane s resize weights.
protected  void showColumnSlidePanel(Container slidePanel, boolean isLeftColumn)
           Shows or hide the passed container depending on its current state.
 boolean showSlidePanel(Container containerInstance)
           This method can be used in order to show or hide the passed Container, depending on its visible state.
 void showSlidePanel(int slidePanelIndex)
          This method can be used in order to show or hide the Container corresponding to the passed slidePanelIndex, depending on its visible state.
protected  void showSouthSlidePanel(Container slidePanel)
           Shows or hides the south container.
 void toggleLeftColumn()
          Method called by the perform method of ToggleLeftColumnCommand
 void toggleRightColumn()
          Method called by the perform method of ToggleLeftColumnCommand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SLIDE_PANEL_NORTH_WEST

public static final int SLIDE_PANEL_NORTH_WEST
Public constants for layout positions/constraints.

See Also:
Constant Field Values

SLIDE_PANEL_WEST

public static final int SLIDE_PANEL_WEST
Public constants for layout positions/constraints.

See Also:
Constant Field Values

SLIDE_PANEL_SOUTH_WEST

public static final int SLIDE_PANEL_SOUTH_WEST
Public constants for layout positions/constraints.

See Also:
Constant Field Values

SLIDE_PANEL_EAST

public static final int SLIDE_PANEL_EAST
Public constants for layout positions/constraints.

See Also:
Constant Field Values

SLIDE_PANEL_SOUTH_EAST

public static final int SLIDE_PANEL_SOUTH_EAST
Public constants for layout positions/constraints.

See Also:
Constant Field Values

SLIDE_PANEL_NORTH_EAST

public static final int SLIDE_PANEL_NORTH_EAST
Public constants for layout positions/constraints.

See Also:
Constant Field Values

SLIDE_PANEL_SOUTH

public static final int SLIDE_PANEL_SOUTH
Public constants for layout positions/constraints.

See Also:
Constant Field Values

DEFAULT_MINIMUM_SIZE

public static final java.awt.Dimension DEFAULT_MINIMUM_SIZE
This is the default minimum size for each container. See setupContainersMinimumSizes() for more information.


SPLITPANE_DEFAULT_RESIZE_WEIGHT

public static final double SPLITPANE_DEFAULT_RESIZE_WEIGHT
Constant defining the default resize weight for split panes

See Also:
Constant Field Values

SPLITPANE_VERTICAL_LEFT

public static final java.lang.String SPLITPANE_VERTICAL_LEFT
Constant to be used by subclasses in setupSplitPanesResizeWeights(). Refer to this method's documentation for more information.

See Also:
Constant Field Values

SPLITPANE_VERTICAL_RIGHT

public static final java.lang.String SPLITPANE_VERTICAL_RIGHT
Constant to be used by subclasses in setupSplitPanesResizeWeights(). Refer to this method's documentation for more information.

See Also:
Constant Field Values

SPLITPANE_HORIZONTAL_TOP_LEFT

public static final java.lang.String SPLITPANE_HORIZONTAL_TOP_LEFT
Constant to be used by subclasses in setupSplitPanesResizeWeights(). Refer to this method's documentation for more information.

See Also:
Constant Field Values

SPLITPANE_HORIZONTAL_BOTTOM_LEFT

public static final java.lang.String SPLITPANE_HORIZONTAL_BOTTOM_LEFT
Constant to be used by subclasses in setupSplitPanesResizeWeights(). Refer to this method's documentation for more information.

See Also:
Constant Field Values

SPLITPANE_HORIZONTAL_TOP_RIGHT

public static final java.lang.String SPLITPANE_HORIZONTAL_TOP_RIGHT
Constant to be used by subclasses in setupSplitPanesResizeWeights(). Refer to this method's documentation for more information.

See Also:
Constant Field Values

SPLITPANE_HORIZONTAL_BOTTOM_RIGHT

public static final java.lang.String SPLITPANE_HORIZONTAL_BOTTOM_RIGHT
Constant to be used by subclasses in setupSplitPanesResizeWeights(). Refer to this method's documentation for more information.

See Also:
Constant Field Values

SPLITPANE_HORIZONTAL_MIDDLE

public static final java.lang.String SPLITPANE_HORIZONTAL_MIDDLE
Constant to be used by subclasses in setupSplitPanesResizeWeights(). Refer to this method's documentation for more information.

See Also:
Constant Field Values
Constructor Detail

SwingFrameLayoutController

public SwingFrameLayoutController(SwingApplicationFrame applicationFrame)
Creates a new SwingFrameLayoutController.

Parameters:
applicationFrame - Application context for this controller.
Method Detail

isLeftColumnVisible

public final boolean isLeftColumnVisible()
Returns true if the left column is visible, false otherwise

Returns:
true if the left column is visible, false otherwise

isRightColumnVisible

public final boolean isRightColumnVisible()
Returns true if the right column is visible, false otherwise

Returns:
true if the right column is visible, false otherwise

showSlidePanel

public final boolean showSlidePanel(Container containerInstance)

This method can be used in order to show or hide the passed Container, depending on its visible state. It delegates its call to showSlidePanel(int). This method returns false if the passed container is not registered as being on the left or on the right column.

Parameters:
containerInstance - the Container to show or hide.
Returns:
false if the passed container is not registered as being on the left or on the right column.

showSlidePanel

public void showSlidePanel(int slidePanelIndex)
This method can be used in order to show or hide the Container corresponding to the passed slidePanelIndex, depending on its visible state. It is called when the ShowSlidePanelAction action is performed. The parameter must be one of:

Parameters:
slidePanelIndex - represents the panel to show or hide. Must be one of:

setupSplitPanesResizeWeights

protected java.util.HashMap setupSplitPanesResizeWeights()

Method used in order to set up JSplitPane s resize weights. Override this method in order to configure application specific resize weights for each split panes. It is important when overriding this method to return a HashMap for which items are Double s and the keys are:

This default implementation sets the following values:

Returns:
HashMap of Double s for which the keys are:
  • SPLITPANE_VERTICAL_LEFT
  • SPLITPANE_VERTICAL_RIGHT
  • SPLITPANE_HORIZONTAL_TOP_LEFT
  • SPLITPANE_HORIZONTAL_BOTTOM_LEFT
  • SPLITPANE_HORIZONTAL_TOP_RIGHT
  • SPLITPANE_HORIZONTAL_BOTTOM_RIGHT
  • SPLITPANE_HORIZONTAL_MIDDLE

setupContainersInitialSizes

protected void setupContainersInitialSizes()

Method used in order to set containers initial sizes. By default this method does nothing and is intended to be overriden by subclasses. Important
When overriding this method, subclasses should exclusively use the method setupContainerInitialSize(Container, Dimension) in order to set up containers initial sizes. Also, in order to avoid unexpected results, one should ensure that containers of a same column are herein set up to have the same width.


setupContainersMinimumSizes

protected void setupContainersMinimumSizes()

Method used in order to set containers minimum sizes. By default this method does nothing and is intended to be overriden by subclasses. All containers' minimum sizes are by default set to DEFAULT_MINIMUM_SIZE. This method can therefore be used to override this setting. Important
When overriding this method, subclasses should exclusively use the method setupContainerMinimumSize(Container, Dimension) in order to set up containers initial sizes. Also, in order to avoid unexpected results, one should ensure that containers of a same column are herein set up to have the same minimum size.


setupContainerMinimumSize

protected final void setupContainerMinimumSize(Container container,
                                               java.awt.Dimension size)

Method used in order to set a container's initial size. This method should be used by subclasses in setupContainersMinimumSizes()

Parameters:
container - the container
size - the container's desired initial size

setupContainerInitialSize

protected final void setupContainerInitialSize(Container container,
                                               java.awt.Dimension size)

Method used in order to set a container's initial size. This method should be used by subclasses in setupContainersInitialSizes()

Parameters:
container - the container
size - the container's desired initial size

toggleLeftColumn

public final void toggleLeftColumn()
Method called by the perform method of ToggleLeftColumnCommand

See Also:
com.tensegrity.component.orgchart.launch.commands.ToggleLeftColumnCommand

getDefaultDividerSize

protected int getDefaultDividerSize()
Returns the split panes divider sizes depending on the current L&F.

Returns:
the split panes divider sizes depending on the current L&F.

toggleRightColumn

public final void toggleRightColumn()
Method called by the perform method of ToggleLeftColumnCommand

See Also:
com.tensegrity.component.orgchart.launch.commands.ToggleLeftColumnCommand

showColumnSlidePanel

protected final void showColumnSlidePanel(Container slidePanel,
                                          boolean isLeftColumn)

Shows or hide the passed container depending on its current state.

Parameters:
slidePanel - the container to hide or show
isLeftColumn - if true then the container is one the left column, otherwise it is on the right column

getNorthEastContainer

protected final Container getNorthEastContainer()

Returns the application specific North East Container

Returns:
application specific North East Container

getSouthContainer

protected final Container getSouthContainer()

Returns the application specific South Container

Returns:
application specific South Container

getSouthEastContainer

protected final Container getSouthEastContainer()

Returns the application specific South East Container

Returns:
application specific South East Container

getEastContainer

protected final Container getEastContainer()

Returns the application specific East Container

Returns:
application specific East Container

getNorthWestContainer

protected final Container getNorthWestContainer()

Returns the application specific North West Container

Returns:
application specific North West Container

getWestContainer

protected final Container getWestContainer()

Returns the application specific West Container

Returns:
application specific West Container

getSouthWestContainer

protected final Container getSouthWestContainer()

Returns the application specific South West Container

Returns:
application specific South West Container

getApplicationFrame

protected final SwingApplicationFrame getApplicationFrame()
Returns the local SwingApplicationFrame instance.

Returns:
Returns the applicationFrame.

setDefaultEastContainer

protected void setDefaultEastContainer(Container defaultEastContainer)
Use this method in order to set the Container which should act as a default container for the right column.

Parameters:
defaultEastContainer - The defaultEastContainer to set.

setDefaultWestContainer

protected void setDefaultWestContainer(Container defaultWestContainer)
Use this method in order to set the Container which should act as a default container for the left column.

Parameters:
defaultWestContainer - The defaultWestContainer to set.

getFameLayoutSnapshot

public final FrameLayoutSnapshot getFameLayoutSnapshot()

This method returns an instance of FrameLayoutSnapshot which contains all the information required in order to re-build the application frame layout the next time the application is started.

Returns:
an instance of FrameLayoutSnapshot which contains all the information required in order to re-build the application frame layout the next time the application is started.

restorePreferencesFrameLayout

public final void restorePreferencesFrameLayout(FrameLayoutSnapshot snapshot)

This method sets up this SwingFrameLayoutController instance in such a way that the application frame will be layouted with all the information contained into the passed FrameLayoutSnapshot.

Parameters:
snapshot - FrameLayoutSnapshot instance containing the information required to layout the application frame as it was the last time the application was closed.

showSouthSlidePanel

protected final void showSouthSlidePanel(Container slidePanel)

Shows or hides the south container.

Parameters:
slidePanel - the south container to show or hide.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.