bibliothek.gui.dock.perspective
Class Perspective

java.lang.Object
  extended by bibliothek.gui.dock.perspective.Perspective
Direct Known Subclasses:
PredefinedPerspective

public abstract class Perspective
extends Object

A Perspective is a helper class that allows clients to create a layout without the need to create DockStations or Dockables.
Perspectives cannot be created directly, clients must first set up the DockSituation that would load the layout and then call the method DockSituation.createPerspective() to create a Perspective which in return is able to write a file that matches the need of its owner DockSituation.

Author:
Benjamin Sigg

Constructor Summary
Perspective(DockSituation situation)
          Creates a new Perspective using situation to read and write items.
 
Method Summary
 PerspectiveElement convert(DockLayoutComposition composition)
          Converts composition using the DockFactorys that are registered at this perspective.
 DockLayoutComposition convert(PerspectiveElement element)
          Converts element using the DockFactorys that are registered at this perspective.
protected abstract  DockFactory<?,?,?> getFactory(String id)
          Gets the factory which is responsible to store an element whose id is id.
protected abstract  String getID(PerspectiveElement element)
          Gets the identifier of the factory that is responsible for element.
 DockSituation getSituation()
          Gets the DockSituation which is used to convert PerspectiveElements and DockLayoutCompositions.
 Map<String,PerspectiveStation> read(DataInputStream in)
          Reads the contents of in and returns them in a map.
 Map<String,PerspectiveStation> readXML(XElement root)
          Reads the contents of root and returns them in a map.
 void write(Map<String,PerspectiveStation> stations, DataOutputStream out)
          Writes the layout created by stations to out.
 void writeXML(Map<String,PerspectiveStation> stations, XElement element)
          Converts the content of stations to XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Perspective

public Perspective(DockSituation situation)
Creates a new Perspective using situation to read and write items.

Parameters:
situation - the set of factories to use
Method Detail

readXML

public Map<String,PerspectiveStation> readXML(XElement root)
Reads the contents of root and returns them in a map.

Parameters:
root - the data to read
Returns:
the content of root

writeXML

public void writeXML(Map<String,PerspectiveStation> stations,
                     XElement element)
Converts the content of stations to XML.

Parameters:
stations - the items to write
element - the element to write into

read

public Map<String,PerspectiveStation> read(DataInputStream in)
                                    throws IOException
Reads the contents of in and returns them in a map.

Parameters:
in - the stream to read from
Returns:
the content of in
Throws:
IOException - if an I/O-error ocurrs

write

public void write(Map<String,PerspectiveStation> stations,
                  DataOutputStream out)
           throws IOException
Writes the layout created by stations to out. The data written by this method can be read by DockSituation.read(DataInputStream)

Parameters:
stations - the root-stations to store
out - the stream to write into
Throws:
IOException - if an I/O-error occurred

convert

public DockLayoutComposition convert(PerspectiveElement element)
Converts element using the DockFactorys that are registered at this perspective.

Parameters:
element - the element to convert, not null
Returns:
the converted element
Throws:
IllegalArgumentException - if a factory is missing

convert

public PerspectiveElement convert(DockLayoutComposition composition)
Converts composition using the DockFactorys that are registered at this perspective.

Parameters:
composition - the element to convert, not null
Returns:
the converted element

getSituation

public DockSituation getSituation()
Gets the DockSituation which is used to convert PerspectiveElements and DockLayoutCompositions.

Returns:
the situation, not null

getID

protected abstract String getID(PerspectiveElement element)
Gets the identifier of the factory that is responsible for element.

Parameters:
element - the element to store
Returns:
the factory that is responsible for element

getFactory

protected abstract DockFactory<?,?,?> getFactory(String id)
Gets the factory which is responsible to store an element whose id is id.

Parameters:
id - the identifier of the element to store or read
Returns:
the factory, can be null