bibliothek.gui.dock.dockable
Class DefaultDockableFactory

java.lang.Object
  extended by bibliothek.gui.dock.dockable.DefaultDockableFactory
All Implemented Interfaces:
DockFactory<DefaultDockable,Object>

public class DefaultDockableFactory
extends Object
implements DockFactory<DefaultDockable,Object>

A factory which can read and write the properties of a DefaultDockable. Note that this factory does not store any information about the components added to the content pane of the DefaultDockable.

Author:
Benjamin Sigg

Field Summary
static String ID
          The unique id of this factory
 
Constructor Summary
DefaultDockableFactory()
           
 
Method Summary
 String getID()
          Gets the unique name of this factory.
 Object getLayout(DefaultDockable element, Map<Dockable,Integer> children)
          Gets the layout of element.
 DefaultDockable layout(Object layout)
          Creates a new DockElement and changes the layout of the new element such that is matches layout.
 DefaultDockable layout(Object layout, Map<Integer,Dockable> children)
          Creates a new DockElement and changes the layout of the new element such that is matches layout.
 Object read(DataInputStream in)
          Reads a layout from a stream.
 Object read(XElement element)
          Reads a layout from an xml-element.
 void setLayout(DefaultDockable element, Object layout)
          Reads the contents of layout and changes the layout of element accordingly.
 void setLayout(DefaultDockable element, Object layout, Map<Integer,Dockable> children)
          Reads the contents of layout and changes the layout of element accordingly.
 void write(Object layout, DataOutputStream out)
          Writes the contents of layout into out.
 void write(Object layout, XElement element)
          Writes the contents of layout into element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final String ID
The unique id of this factory

See Also:
Constant Field Values
Constructor Detail

DefaultDockableFactory

public DefaultDockableFactory()
Method Detail

getID

public String getID()
Description copied from interface: DockFactory
Gets the unique name of this factory.

Specified by:
getID in interface DockFactory<DefaultDockable,Object>
Returns:
the id

getLayout

public Object getLayout(DefaultDockable element,
                        Map<Dockable,Integer> children)
Description copied from interface: DockFactory
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.

Specified by:
getLayout in interface DockFactory<DefaultDockable,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

public void setLayout(DefaultDockable element,
                      Object layout,
                      Map<Integer,Dockable> children)
Description copied from interface: DockFactory
Reads the contents of layout and changes the layout of element accordingly. This method should remove all children from element and add new children.

Specified by:
setLayout in interface DockFactory<DefaultDockable,Object>
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

public void setLayout(DefaultDockable element,
                      Object layout)
Description copied from interface: DockFactory
Reads the contents of layout and changes the layout of element accordingly. This method should not add or remove children to or from element.

Specified by:
setLayout in interface DockFactory<DefaultDockable,Object>
Parameters:
element - the element whose properties will be changed
layout - the new set of properties

layout

public DefaultDockable layout(Object layout,
                              Map<Integer,Dockable> children)
Description copied from interface: DockFactory
Creates a new DockElement and changes the layout of the new element such that is matches layout.

Specified by:
layout in interface DockFactory<DefaultDockable,Object>
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

public DefaultDockable layout(Object layout)
Description copied from interface: DockFactory
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.

Specified by:
layout in interface DockFactory<DefaultDockable,Object>
Parameters:
layout - the new layout
Returns:
a new element or null if layout can't be used

read

public Object read(DataInputStream in)
            throws IOException
Description copied from interface: DockFactory
Reads a layout from a stream.

Specified by:
read in interface DockFactory<DefaultDockable,Object>
Parameters:
in - the stream to read from
Returns:
the new layout
Throws:
IOException - if an I/O-error occurs

read

public Object read(XElement element)
Description copied from interface: DockFactory
Reads a layout from an xml-element.

Specified by:
read in interface DockFactory<DefaultDockable,Object>
Parameters:
element - the element to read, should not be changed by this method.
Returns:
the new layout

write

public void write(Object layout,
                  DataOutputStream out)
           throws IOException
Description copied from interface: DockFactory
Writes the contents of layout into out.

Specified by:
write in interface DockFactory<DefaultDockable,Object>
Parameters:
layout - the layout to store
out - the stream to write into
Throws:
IOException - if an I/O-error occurs

write

public void write(Object layout,
                  XElement element)
Description copied from interface: DockFactory
Writes the contents of layout into element.

Specified by:
write in interface DockFactory<DefaultDockable,Object>
Parameters:
layout - the layout to store
element - an xml-element into which this method should write, the attributes of element should not be changed.