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

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

public interface DockConverter<D extends DockElement,P extends PerspectiveElement,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
 java.lang.String getID()
          Gets the unique name of this converter.
 L getLayout(D element, java.util.Map<Dockable,java.lang.Integer> children)
          Gets the layout of element.
 L getPerspectiveLayout(P element, java.util.Map<PerspectiveDockable,java.lang.Integer> children)
          Gets the layout information that is associated with element.
 L read(java.io.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, java.util.Map<java.lang.Integer,Dockable> children, PlaceholderStrategy placeholders)
          Reads the contents of layout and changes the layout of element accordingly.
 void setLayout(D element, L layout, PlaceholderStrategy placeholders)
          Reads the contents of layout and changes the layout of element accordingly.
 void write(L layout, java.io.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

java.lang.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,
            java.util.Map<Dockable,java.lang.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 from 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.

getPerspectiveLayout

L getPerspectiveLayout(P element,
                       java.util.Map<PerspectiveDockable,java.lang.Integer> children)
Gets the layout information that is associated with element. The layout information can be any Object. The only restriction of the object is, that the associated DockFactory understands how to read that object.

Parameters:
element - the element whose layout information is asked.
children - a map providing identifiers for the children of this element. The identifiers are in the range from 0 (incl.) to children.size() (excl.), the exact same identifiers would be given to getLayout(bibliothek.gui.dock.DockElement, Map). Is null if the children of this station should be ignored.
Returns:
the layout information, may be null if this converter does not support perspectives

setLayout

void setLayout(D element,
               L layout,
               java.util.Map<java.lang.Integer,Dockable> children,
               PlaceholderStrategy placeholders)
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.
placeholders - a strategy to detect invalid placeholders, can be null. Factories loading only Dockables but no DockStations can safely ignore this argument.

setLayout

void setLayout(D element,
               L layout,
               PlaceholderStrategy placeholders)
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
placeholders - a strategy to detect invalid placeholders, can be null. Factories loading only Dockables but no DockStations can safely ignore this argument.

write

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

Parameters:
layout - the layout to store
out - the stream to write into
Throws:
java.io.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(java.io.DataInputStream in,
       PlaceholderStrategy placeholders)
       throws java.io.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:
java.io.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