Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.crosswire.common.swing.desktop
Class ViewLayout

    java.lang.Object
      org.crosswire.common.swing.desktop.ViewLayout

All Implemented Interfaces:
  Viewable

Direct Known Subclasses:
  MDIViewLayout, TDIViewLayout

    public abstract class ViewLayout

extends Object
implements Viewable

Abstract manager of how we layout views.

Distribution Licence: JSword is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation. This program 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 General Public License for more details. The License is available on the internet here, or by writing to: Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA The copyright to this program is held by it's authors.

Version:
  $Id: ViewLayout.java,v 1.2 2004/09/21 17:45:47 dmsmith Exp $
Author:
  Joe Walker [joe at eireneh dot com], DM Smith [dmsmith555 at yahoo dot com]
See Also:
  `Licence`

Field Summary
`private static int` | `base` A shared counter for creating unknown titles.
`private GridBagConstraints` | `gbc` A shared, reusable constraint that makes its contents grow to fill the area.
`private EventListenerList` | `listenerList` The listeners for handling ViewEvent Listeners
`private static int` | `MAX_TITLE_LEN` The maximum length of a title before it is abbreviated
`private JPanel` | `panel` The panel into which all components are placed.
`private List` | `views` The list of views.

Constructor Summary
`protected` | `ViewLayout()` This constructor is protected because it only needs to be seen by the sub classes

Method Summary
`void` | `addView(Component component)` Add a view to the set.
`void` | `addViewEventListener(ViewEventListener listener)` Adds a view event listener for notification of any changes to the view.
`void` | `closeAll()` Close all the views.
`void` | `closeOthers(Component component)` Close all the views but the one provided.
`void` | `fireViewRemoved(ViewEvent e)` Notify the listeners that the view has been removed.
`protected void` | `forceRemoveView(Component component)` Unconditionally remove a view from the set.
`private String` | `generateTitle()` Generates a generic title
`protected Object` | `getConstraint()` A constraint that allows the panel to be filled up, stretching horizonally and vertically.
`protected JPanel` | `getPanel()` All parts are put into a panel.
`abstract Component` | `getSelected()` Returns the top view.
`protected String` | `getTitle(Component component)` Get the title from the component, truncating it if necessary.
`Component` | `getView(int i)` Get the view by position.
`int` | `getViewCount()` The number of views held by this layout.
`Collection` | `getViews()` Get a snapshot of the views as a collection.
`Iterator` | `iterator()` Get an iterator of a snapshot of views.
`void` | `moveTo(ViewLayout other)` Copies all the views from the one layout to the other
`void` | `removeView(Component component)` Remove a view from the set.
`void` | `removeViewEventListener(ViewEventListener listener)` Removes a view event listener.
`abstract void` | `select(Component component)` Find the view and select it.
`abstract void` | `updateTitle(Component component)` Update the title of the view.
`void` | `visit(ViewVisitor visitor)` Visit every view in the order that they were added.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### views

    private List views

  The list of views.

### listenerList

    private EventListenerList listenerList

  The listeners for handling ViewEvent Listeners

### MAX_TITLE_LEN

    private static final int MAX_TITLE_LEN

  The maximum length of a title before it is abbreviated

  See Also:
    Constant Field Values

### base

    private static int base

  A shared counter for creating unknown titles.

### panel

    private JPanel panel

  The panel into which all components are placed.

### gbc

    private GridBagConstraints gbc

  A shared, reusable constraint that makes its contents grow to fill the area.

Constructor Detail

### ViewLayout

    protected ViewLayout()

  This constructor is protected because it only needs to be seen by the sub classes

Method Detail

### addView

    public void addView(Component component)

  Add a view to the set.

  Specified by:
    `addView` in interface `Viewable`

### removeView

    public void removeView(Component component)

  Remove a view from the set.

  Specified by:
    `removeView` in interface `Viewable`

### forceRemoveView

    protected void forceRemoveView(Component component)

  Unconditionally remove a view from the set.

### getViews

    public Collection getViews()

  Get a snapshot of the views as a collection.

  Specified by:
    `getViews` in interface `Viewable`
  Returns:
    the views

### iterator

    public Iterator iterator()

  Get an iterator of a snapshot of views.

  Specified by:
    `iterator` in interface `Viewable`
  Returns:
    an iterator over the views.

### moveTo

    public void moveTo(ViewLayout other)

  Copies all the views from the one layout to the other

  Specified by:
    `moveTo` in interface `Viewable`
  Parameters:
    `other` - the other layout

### closeAll

    public void closeAll()

  Close all the views. Note the policy is enforced that one view is kept. This will keep the last one added.

  Specified by:
    `closeAll` in interface `Viewable`

### closeOthers

    public void closeOthers(Component component)

  Close all the views but the one provided.

  Specified by:
    `closeOthers` in interface `Viewable`
  Parameters:
    `component` - the view that is to remain open.

### visit

    public void visit(ViewVisitor visitor)

  Visit every view in the order that they were added.

  Specified by:
    `visit` in interface `Viewable`
  Parameters:
    `visitor` - The visitor for the view

### updateTitle

    public abstract void updateTitle(Component component)

  Update the title of the view. If the component does not implement Titleable, then a generated title will be used.

  Specified by:
    `updateTitle` in interface `Viewable`
  Parameters:
    `component` - the component whose title is to be used

### getSelected

    public abstract Component getSelected()

  Returns the top view. If no view is the top, it returns the first one added.

  Specified by:
    `getSelected` in interface `Viewable`

### select

    public abstract void select(Component component)

  Find the view and select it.

  Specified by:
    `select` in interface `Viewable`
  Parameters:
    `component` -

### getViewCount

    public int getViewCount()

  The number of views held by this layout.

  Specified by:
    `getViewCount` in interface `Viewable`
  Returns:
    the number of views held by this layout

### getView

    public Component getView(int i)

  Get the view by position. Note that adding and removing views changes the indexes of the views. Do not use this for iteration as it is not thread safe.

  Specified by:
    `getView` in interface `Viewable`
  Parameters:
    `i` - the index of the view
  Returns:
    the requested view.

### getTitle

    protected String getTitle(Component component)

  Get the title from the component, truncating it if necessary. If the component does not implement Titleable of if the title is empty, then titles are generated.

  Parameters:
    `component` - from whom the title is gotten
  Returns:
    the title, possibly truncated or generated

### generateTitle

    private String generateTitle()

  Generates a generic title

  Returns:
    the generated title

### getPanel

    protected JPanel getPanel()

  All parts are put into a panel. This prevents the programmer from having to change containers.

  Returns:
    Returns the panel.

### getConstraint

    protected Object getConstraint()

  A constraint that allows the panel to be filled up, stretching horizonally and vertically.

  Returns:
    the constraint

### addViewEventListener

    public void addViewEventListener(ViewEventListener listener)

  Adds a view event listener for notification of any changes to the view.

  Specified by:
    `addViewEventListener` in interface `Viewable`
  Parameters:
    `listener` - the listener

### removeViewEventListener

    public void removeViewEventListener(ViewEventListener listener)

  Removes a view event listener.

  Specified by:
    `removeViewEventListener` in interface `Viewable`
  Parameters:
    `listener` - the listener

### fireViewRemoved

    public void fireViewRemoved(ViewEvent e)

  Notify the listeners that the view has been removed.

  Parameters:
    `e` - the event
  See Also:
    `EventListenerList`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Copyright ? 2003-2004
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD