bibliothek.gui.dock
Interface DockFactory<D extends DockElement,L>

Type Parameters:
D - the type of element which can be written and read by this factory
L - the type of object that stores the contents of a D
All Known Implementing Classes:
DefaultDockableFactory, FlapDockStationFactory, ScreenDockStationFactory, SecureFlapDockStationFactory, SecureScreenDockStationFactory, SecureSplitDockStationFactory, SecureStackDockStationFactory, SplitDockStationFactory, StackDockStationFactory

public interface DockFactory<D extends DockElement,L>

A DockFactory can convert the contents of a DockElement in a persistent form.
Some kind of DockElement will be converted into a Object, this layout can then be written into a stream.

Author:
Benjamin Sigg

Method Summary
 String getID()
          Gets the unique name of this factory.
 L getLayout(D element, Map<Dockable,Integer> children)
          Gets the layout of element.
 D layout(L layout)
          Creates a new DockElement and changes the layout of the new element such that is matches layout.
 D layout(L layout, Map<Integer,Dockable> children)
          Creates a new DockElement and changes the layout of the new element such that is matches layout.
 L read(DataInputStream in)
          Reads a layout from a stream.
 L read(XElement element)
          Reads a layout from an xml-element.
 void setLayout(D element, L layout)
          Reads the contents of layout and changes the layout of element accordingly.
 void setLayout(D element, L layout, Map<Integer,Dockable> children)
          Reads the contents of layout and changes the layout of element accordingly.
 void write(L layout, DataOutputStream out)
          Writes the contents of layout into out.
 void write(L layout, XElement element)
          Writes the contents of layout into element.
 

Method Detail

getID

String getID()
Gets the unique name of this factory.

Returns:
the id

getLayout

L getLayout(D element,
            Map<Dockable,Integer> children)
Gets the layout of element. This method should create a new instance of the layout object, that new object should not be tied to element in any way. A layout can be living for a long period of time and might be used on another dockable object.

Parameters:
element - the element for which a new layout should be created
children - a map containing unique identifiers for the children of the element. Children which are not in this map should not be stored in the layout.
Returns:
the newly created, independent layout object.

setLayout

void setLayout(D element,
               L layout,
               Map<Integer,Dockable> children)
Reads the contents of layout and changes the layout of element accordingly. This method should remove all children from element and add new children.

Parameters:
element - the element whose content and children will be rearranged.
layout - the new layout of element
children - some children, note that the map may not contain all elements which were present when the layout was created.

setLayout

void setLayout(D element,
               L layout)
Reads the contents of layout and changes the layout of element accordingly. This method should not add or remove children to or from element.

Parameters:
element - the element whose properties will be changed
layout - the new set of properties

layout

D layout(L layout,
         Map<Integer,Dockable> children)
Creates a new DockElement and changes the layout of the new element such that is matches layout.

Parameters:
layout - the new layout
children - some children, note that the map may not contain all elements which were present when the layout was created.
Returns:
a new element or null if layout can't be used

layout

D layout(L layout)
Creates a new DockElement and changes the layout of the new element such that is matches layout. This method should not add any children to the element.

Parameters:
layout - the new layout
Returns:
a new element or null if layout can't be used

write

void write(L layout,
           DataOutputStream out)
           throws IOException
Writes the contents of layout into out.

Parameters:
layout - the layout to store
out - the stream to write into
Throws:
IOException - if an I/O-error occurs

write

void write(L layout,
           XElement element)
Writes the contents of layout into element.

Parameters:
layout - the layout to store
element - an xml-element into which this method should write, the attributes of element should not be changed.

read

L read(DataInputStream in)
       throws IOException
Reads a layout from a stream.

Parameters:
in - the stream to read from
Returns:
the new layout
Throws:
IOException - if an I/O-error occurs

read

L read(XElement element)
Reads a layout from an xml-element.

Parameters:
element - the element to read, should not be changed by this method.
Returns:
the new layout