bibliothek.gui.dock.station.stack
Class StackDockStationFactory

java.lang.Object
  extended by bibliothek.gui.dock.station.stack.StackDockStationFactory
All Implemented Interfaces:
DockFactory<StackDockStation,StackDockStationLayout>, DockConverter<StackDockStation,StackDockStationLayout>
Direct Known Subclasses:
SecureStackDockStationFactory

public class StackDockStationFactory
extends Object
implements DockFactory<StackDockStation,StackDockStationLayout>

A DockFactory that can read and write instances of StackDockStation. This factory will create new instances of StackDockStation through the method createStation().

Author:
Benjamin Sigg

Field Summary
static String ID
          The ID which is returned by getID()
 
Constructor Summary
StackDockStationFactory()
           
 
Method Summary
protected  StackDockStation createStation()
          Called when a new StackDockStation is required.
 void estimateLocations(StackDockStationLayout layout, LocationEstimationMap children)
          Tries to estimate the DockablePropertys of the children of the station which is represented by layout.
 String getID()
          Gets the unique name of this converter.
 StackDockStationLayout getLayout(StackDockStation station, Map<Dockable,Integer> children)
          Gets the layout of element.
 StackDockStation layout(StackDockStationLayout layout)
          Creates a new DockElement and changes the layout of the new element such that is matches layout.
 StackDockStation layout(StackDockStationLayout layout, Map<Integer,Dockable> children)
          Creates a new DockElement and changes the layout of the new element such that is matches layout.
 StackDockStationLayout read(DataInputStream in, PlaceholderStrategy placeholders)
          Reads a layout from a stream.
 StackDockStationLayout read(XElement element, PlaceholderStrategy placeholders)
          Reads a layout from an xml-element.
 void setLayout(StackDockStation element, StackDockStationLayout layout)
          Reads the contents of layout and changes the layout of element accordingly.
 void setLayout(StackDockStation station, StackDockStationLayout layout, Map<Integer,Dockable> children)
          Reads the contents of layout and changes the layout of element accordingly.
 void write(StackDockStationLayout layout, DataOutputStream out)
          Writes the contents of layout into out.
 void write(StackDockStationLayout 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 ID which is returned by getID()

See Also:
Constant Field Values
Constructor Detail

StackDockStationFactory

public StackDockStationFactory()
Method Detail

getID

public String getID()
Description copied from interface: DockConverter
Gets the unique name of this converter. Please note that unique identifiers starting with "dock." should not be used by clients.

Specified by:
getID in interface DockConverter<StackDockStation,StackDockStationLayout>
Returns:
the id

getLayout

public StackDockStationLayout getLayout(StackDockStation station,
                                        Map<Dockable,Integer> children)
Description copied from interface: DockConverter
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 DockConverter<StackDockStation,StackDockStationLayout>
Parameters:
station - 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.

estimateLocations

public void estimateLocations(StackDockStationLayout layout,
                              LocationEstimationMap children)
Description copied from interface: DockFactory
Tries to estimate the DockablePropertys of the children of the station which is represented by layout.
The children of this station accessible through children.getChild( ... ), this factory may also access the leafs in the tree of Dockables through children.getSubChild(...).
Note: this method must not set the successor of any DockableProperty, it is the callers responsibility to handle chains of stations.

Specified by:
estimateLocations in interface DockFactory<StackDockStation,StackDockStationLayout>
Parameters:
layout - this station
children - the children of the station, this method should call DockLayoutInfo.setLocation(DockableProperty) or LocationEstimationMap.setLocation(int, DockableProperty) and LocationEstimationMap.setLocation(int, int, DockableProperty) for as many children as possible

setLayout

public void setLayout(StackDockStation station,
                      StackDockStationLayout layout,
                      Map<Integer,Dockable> children)
Description copied from interface: DockConverter
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 DockConverter<StackDockStation,StackDockStationLayout>
Parameters:
station - 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(StackDockStation element,
                      StackDockStationLayout layout)
Description copied from interface: DockConverter
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 DockConverter<StackDockStation,StackDockStationLayout>
Parameters:
element - the element whose properties will be changed
layout - the new set of properties

layout

public StackDockStation layout(StackDockStationLayout 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<StackDockStation,StackDockStationLayout>
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 StackDockStation layout(StackDockStationLayout 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<StackDockStation,StackDockStationLayout>
Parameters:
layout - the new layout
Returns:
a new element or null if layout can't be used

write

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

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

read

public StackDockStationLayout read(DataInputStream in,
                                   PlaceholderStrategy placeholders)
                            throws IOException
Description copied from interface: DockConverter
Reads a layout from a stream.

Specified by:
read in interface DockConverter<StackDockStation,StackDockStationLayout>
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

write

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

Specified by:
write in interface DockConverter<StackDockStation,StackDockStationLayout>
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

public StackDockStationLayout read(XElement element,
                                   PlaceholderStrategy placeholders)
Description copied from interface: DockConverter
Reads a layout from an xml-element.

Specified by:
read in interface DockConverter<StackDockStation,StackDockStationLayout>
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

createStation

protected StackDockStation createStation()
Called when a new StackDockStation is required.

Returns:
a new station