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

Type Parameters:
D - the kind of DockElement this converter handles
L - the kind of data this converter uses as intermediate format
All Known Subinterfaces:
AdjacentDockFactory<L>, DockFactory<D,L>
All Known Implementing Classes:
CommonMultipleDockableFactory, CommonSingleDockableFactory, DefaultDockableFactory, FlapDockStationFactory, RegisteringDockFactory, ReplacementDockFactory, ScreenDockStationFactory, SecureFlapDockStationFactory, SecureScreenDockStationFactory, SecureSplitDockStationFactory, SecureStackDockStationFactory, SplitDockStationFactory, StackDockStationFactory

public interface DockConverter<D extends DockElement,L>

A DockConverter can store or load content which is related to a certain kind of DockElement.
The content of an element is first converted in a special intermediate form represented by some object of type L. This intermediate object can then be written as byte-stream or in xml.

Author:
Benjamin Sigg

Method Summary
 String getID()
          Gets the unique name of this converter.
 L getLayout(D element, Map<Dockable,Integer> children)
          Gets the layout of element.
 L read(DataInputStream in, PlaceholderStrategy placeholders)
          Reads a layout from a stream.
 L read(XElement element, PlaceholderStrategy placeholders)
          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 converter. Please note that unique identifiers starting with "dock." should not be used by clients.

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.
The identifiers are in the range 0 (incl.) to children.size() (excl.). The same identifiers will be used as indices by a LocationEstimationMap. See also DockFactory.estimateLocations(Object, LocationEstimationMap).
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

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,
       PlaceholderStrategy placeholders)
       throws IOException
Reads a layout from a stream.

Parameters:
in - the stream to read from
placeholders - a strategy to detect invalid placeholders, can be null. Factories loading only Dockables but no DockStations can safely ignore this argument.
Returns:
the new layout, can be null if the layout should be discarded
Throws:
IOException - if an I/O-error occurs

read

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

Parameters:
element - the element to read, should not be changed by this method.
placeholders - a strategy to detect invalid placeholders, can be null. Factories loading only Dockables but no DockStations can safely ignore this argument.
Returns:
the new layout, can be null if the layout should be discarded