bibliothek.gui.dock.station.screen
Class ScreenDockStationFactory

java.lang.Object
  extended by bibliothek.gui.dock.station.screen.ScreenDockStationFactory
All Implemented Interfaces:
DockFactory<ScreenDockStation,ScreenDockPerspective,ScreenDockStationLayout>, DockConverter<ScreenDockStation,ScreenDockPerspective,ScreenDockStationLayout>
Direct Known Subclasses:
SecureScreenDockStationFactory

public class ScreenDockStationFactory
extends java.lang.Object
implements DockFactory<ScreenDockStation,ScreenDockPerspective,ScreenDockStationLayout>

A DockFactory which writes and reads instances of ScreenDockStation. For every station, the bounds of all dialogs are stored.

Author:
Benjamin Sigg

Field Summary
static java.lang.String ID
           
 
Constructor Summary
ScreenDockStationFactory(java.awt.Window owner)
          Constructs a factory
ScreenDockStationFactory(WindowProvider owner)
          Constructs a factory
 
Method Summary
protected  ScreenDockStation createStation()
          Creates a new ScreenDockStation.
 void estimateLocations(ScreenDockStationLayout layout, LocationEstimationMap children)
          Tries to estimate the DockablePropertys of the children of the station which is represented by layout.
 java.lang.String getID()
          Gets the unique name of this converter.
 ScreenDockStationLayout getLayout(ScreenDockStation station, java.util.Map<Dockable,java.lang.Integer> children)
          Gets the layout of element.
 java.awt.Window getOwner()
          Deprecated. replaced by getProvider()
 ScreenDockStationLayout getPerspectiveLayout(ScreenDockPerspective element, java.util.Map<PerspectiveDockable,java.lang.Integer> children)
          Gets the layout information that is associated with element.
 WindowProvider getProvider()
          Gets the provider for windows, which will be used as owner for newly created dialogs.
 ScreenDockStation layout(ScreenDockStationLayout layout, java.util.Map<java.lang.Integer,Dockable> children, PlaceholderStrategy placeholders)
          Creates a new DockElement and changes the layout of the new element such that is matches layout.
 ScreenDockStation layout(ScreenDockStationLayout layout, PlaceholderStrategy placeholders)
          Creates a new DockElement and changes the layout of the new element such that is matches layout.
 void layoutPerspective(ScreenDockPerspective perspective, ScreenDockStationLayout layout, java.util.Map<java.lang.Integer,PerspectiveDockable> children)
          Updates the contents of perspective such that it reflects the contents of layout.
 ScreenDockPerspective layoutPerspective(ScreenDockStationLayout layout, java.util.Map<java.lang.Integer,PerspectiveDockable> children)
          Creates an element that can be used by a Perspective to create a layout without creating any DockElements.
 ScreenDockStationLayout read(java.io.DataInputStream in, PlaceholderStrategy placeholders)
          Reads a layout from a stream.
 ScreenDockStationLayout read(XElement element, PlaceholderStrategy placeholders)
          Reads a layout from an xml-element.
 void setLayout(ScreenDockStation station, ScreenDockStationLayout 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(ScreenDockStation element, ScreenDockStationLayout layout, PlaceholderStrategy placeholders)
          Reads the contents of layout and changes the layout of element accordingly.
 void write(ScreenDockStationLayout layout, java.io.DataOutputStream out)
          Writes the contents of layout into out.
 void write(ScreenDockStationLayout 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 java.lang.String ID
See Also:
Constant Field Values
Constructor Detail

ScreenDockStationFactory

public ScreenDockStationFactory(java.awt.Window owner)
Constructs a factory

Parameters:
owner - the window which will be used as owner for dialogs

ScreenDockStationFactory

public ScreenDockStationFactory(WindowProvider owner)
Constructs a factory

Parameters:
owner - the window which will be used as owner for dialogs
Method Detail

getOwner

@Deprecated
public java.awt.Window getOwner()
Deprecated. replaced by getProvider()

Gets the owner of all created dialogs.

Returns:
the owner

getProvider

public WindowProvider getProvider()
Gets the provider for windows, which will be used as owner for newly created dialogs.

Returns:
the owner

getID

public java.lang.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<ScreenDockStation,ScreenDockPerspective,ScreenDockStationLayout>
Returns:
the id

estimateLocations

public void estimateLocations(ScreenDockStationLayout 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<ScreenDockStation,ScreenDockPerspective,ScreenDockStationLayout>
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

getLayout

public ScreenDockStationLayout getLayout(ScreenDockStation station,
                                         java.util.Map<Dockable,java.lang.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<ScreenDockStation,ScreenDockPerspective,ScreenDockStationLayout>
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 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.

setLayout

public void setLayout(ScreenDockStation element,
                      ScreenDockStationLayout layout,
                      PlaceholderStrategy placeholders)
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<ScreenDockStation,ScreenDockPerspective,ScreenDockStationLayout>
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.

setLayout

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

layout

public ScreenDockStation layout(ScreenDockStationLayout layout,
                                PlaceholderStrategy placeholders)
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<ScreenDockStation,ScreenDockPerspective,ScreenDockStationLayout>
Parameters:
layout - the new layout
placeholders - a strategy to detect invalid placeholders, can be null. Factories loading only Dockables but no DockStations can safely ignore this argument.
Returns:
a new element or null if layout can't be used

layout

public ScreenDockStation layout(ScreenDockStationLayout layout,
                                java.util.Map<java.lang.Integer,Dockable> children,
                                PlaceholderStrategy placeholders)
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<ScreenDockStation,ScreenDockPerspective,ScreenDockStationLayout>
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.
placeholders - a strategy to detect invalid placeholders, can be null. Factories loading only Dockables but no DockStations can safely ignore this argument.
Returns:
a new element or null if layout can't be used

getPerspectiveLayout

public ScreenDockStationLayout getPerspectiveLayout(ScreenDockPerspective element,
                                                    java.util.Map<PerspectiveDockable,java.lang.Integer> children)
Description copied from interface: DockConverter
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.

Specified by:
getPerspectiveLayout in interface DockConverter<ScreenDockStation,ScreenDockPerspective,ScreenDockStationLayout>
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 DockConverter.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

layoutPerspective

public ScreenDockPerspective layoutPerspective(ScreenDockStationLayout layout,
                                               java.util.Map<java.lang.Integer,PerspectiveDockable> children)
Description copied from interface: DockFactory
Creates an element that can be used by a Perspective to create a layout without creating any DockElements. This method may return null only if the client is guaranteed not to use a Perspective.

Specified by:
layoutPerspective in interface DockFactory<ScreenDockStation,ScreenDockPerspective,ScreenDockStationLayout>
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. Is null if the children of this station are going to be ignored.
Returns:
the new element, can be null, the return value of PerspectiveElement.getFactoryID() should be equal to DockConverter.getID()

layoutPerspective

public void layoutPerspective(ScreenDockPerspective perspective,
                              ScreenDockStationLayout layout,
                              java.util.Map<java.lang.Integer,PerspectiveDockable> children)
Description copied from interface: DockFactory
Updates the contents of perspective such that it reflects the contents of layout.

Specified by:
layoutPerspective in interface DockFactory<ScreenDockStation,ScreenDockPerspective,ScreenDockStationLayout>
Parameters:
perspective - the perspective that is to be updated
layout - the layout to apply
children - the new children of perspective, is null if the children of this station are going to be ignored.

write

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

Specified by:
write in interface DockConverter<ScreenDockStation,ScreenDockPerspective,ScreenDockStationLayout>
Parameters:
layout - the layout to store
out - the stream to write into
Throws:
java.io.IOException - if an I/O-error occurs

read

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

Specified by:
read in interface DockConverter<ScreenDockStation,ScreenDockPerspective,ScreenDockStationLayout>
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

write

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

Specified by:
write in interface DockConverter<ScreenDockStation,ScreenDockPerspective,ScreenDockStationLayout>
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 ScreenDockStationLayout read(XElement element,
                                    PlaceholderStrategy placeholders)
Description copied from interface: DockConverter
Reads a layout from an xml-element.

Specified by:
read in interface DockConverter<ScreenDockStation,ScreenDockPerspective,ScreenDockStationLayout>
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 ScreenDockStation createStation()
Creates a new ScreenDockStation.

Returns:
the new station