|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbibliothek.gui.dock.layout.DockSituation
public class DockSituation
A DockSituation is a converter: the relationship of
DockStations
and Dockables
,
the position of Dockables and other information are converted into a
stream of bytes. The other direction, read a stream
and create Dockables and DockStations, is also possible.
Constructor Summary | |
---|---|
DockSituation()
Constructs a new DockSituation. |
|
DockSituation(DockFactory<?,?>... factories)
Constructs a new DockSituation and sets some factories which are used to create new DockElements |
Method Summary | |
---|---|
void |
add(DockFactory<?,?> factory)
Adds a factory |
DockLayoutComposition |
convert(DockElement element)
Converts the layout of element and all its children into a
DockLayoutComposition . |
DockElement |
convert(DockLayoutComposition composition)
Reads the contents of composition and creates a DockElement
that matches the composition. |
protected DockFactory<? extends DockElement,?> |
getFactory(String id)
Gets the factory which has the given id . |
protected String |
getID(DockElement dockable)
Gets the id of the factory which is needed to write (and later read) the element dockable . |
protected String |
getID(DockFactory<?,?> factory)
Gets the id of factory . |
DockSituationIgnore |
getIgnore()
Gets the filter which decides, which elements are stored. |
protected boolean |
ignoreChildren(DockStation station)
Tells whether to ignore the children of the station when saving or not. |
protected boolean |
ignoreElement(DockElement element)
Tells whether to ignore this element when saving. |
Map<String,DockStation> |
read(byte[] data)
Reads data as stream and returns the roots of the
DockElements which were found. |
Map<String,DockStation> |
read(DataInputStream in)
Reads in and returns the roots of the
DockElements which were found. |
DockLayoutComposition |
readComposition(DataInputStream in)
Reads one DockLayoutComposition and all its children. |
DockLayoutComposition |
readCompositionXML(XElement element)
Reads a DockLayoutComposition from an xml element. |
Map<String,DockStation> |
readXML(XElement root)
Reads a set of DockStation s that were stored earlier. |
void |
setIgnore(DockSituationIgnore ignore)
Sets a filter which decides, which elements (stations and dockables) are stored. |
byte[] |
write(Map<String,DockStation> stations)
Writes all locations and relationships of the DockStations
stations and their children into an array of bytes. |
void |
write(Map<String,DockStation> stations,
DataOutputStream out)
Writes all locations and relationships of the DockStations
stations and their children into the stream out . |
void |
writeComposition(DockLayoutComposition composition,
DataOutputStream out)
Writes the contents of composition and all its children
to out . |
void |
writeCompositionXML(DockLayoutComposition composition,
XElement element)
Writes the contents of composition into element without
changing the attributes of element . |
void |
writeXML(Map<String,DockStation> stations,
XElement element)
Writes all locations and relationships of the DockStation s
stations and their children as xml. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DockSituation(DockFactory<?,?>... factories)
DockElements
factories
- the factoriespublic DockSituation()
DefaultDockable
,
SplitDockStation
, StackDockStation
and
FlapDockStation
will be preinstalled.
Method Detail |
---|
public void setIgnore(DockSituationIgnore ignore)
ignore
- the filter or null
public DockSituationIgnore getIgnore()
null
public void add(DockFactory<?,?> factory)
factory
- the additional factorypublic DockLayoutComposition convert(DockElement element)
element
and all its children into a
DockLayoutComposition
.
element
- the element to convert
null
if the element is ignored
IllegalArgumentException
- if one element has an unknown id of
a DockFactory
.
ClassCastException
- if an element does not specify the correct
DockFactory
.public DockElement convert(DockLayoutComposition composition)
composition
and creates a DockElement
that matches the composition.
composition
- the composition to analyze
null
if the factory for
composition
was not foundpublic void writeComposition(DockLayoutComposition composition, DataOutputStream out) throws IOException
composition
and all its children
to out
.
composition
- the composition to write, should be created by
this
DockSituation
or a DockSituation
with
similar properties.out
- the stream to write into
IOException
- if an I/O-error occurspublic DockLayoutComposition readComposition(DataInputStream in) throws IOException
DockLayoutComposition
and all its children.
in
- the stream to read from
null
if the factory was missing
IOException
- if an I/O-error occurspublic byte[] write(Map<String,DockStation> stations) throws IOException
DockStations
stations
and their children into an array of bytes.
stations
- The stations to store, a call to read(byte[])
would return the same map. Only the roots are needed.
IOException
- if the information can't be writtenpublic void write(Map<String,DockStation> stations, DataOutputStream out) throws IOException
DockStations
stations
and their children into the stream out
.
stations
- The stations to store, only the roots are needed.out
- the stream to write in
IOException
- if the stream throws an exceptionpublic Map<String,DockStation> read(byte[] data) throws IOException
data
as stream and returns the roots of the
DockElements
which were found.
data
- the array to read
IOException
- if data
can't be readpublic Map<String,DockStation> read(DataInputStream in) throws IOException
in
and returns the roots of the
DockElements
which were found.
in
- the stream to read
IOException
- if the stream can't be readpublic void writeCompositionXML(DockLayoutComposition composition, XElement element)
composition
into element
without
changing the attributes of element
.
composition
- the composition to writeelement
- the element to write into
IllegalArgumentException
- if a factory is missingpublic DockLayoutComposition readCompositionXML(XElement element)
DockLayoutComposition
from an xml element.
element
- the element to read
XException
- if something is missing or malformed in element
public void writeXML(Map<String,DockStation> stations, XElement element) throws IOException
DockStation
s
stations
and their children as xml.
stations
- The stations to store, only the roots are needed.element
- the element to write into, attributes of element
will
not be changed
IOException
- if an I/O-error occurspublic Map<String,DockStation> readXML(XElement root)
DockStation
s that were stored earlier.
root
- the xml element from which to read
protected boolean ignoreElement(DockElement element)
DockSituationIgnore
of this situation.
element
- the element which might not be saved
true
if the element should not be savedprotected boolean ignoreChildren(DockStation station)
DockSituationIgnore
of this situation.
station
- the station whose children might be ignored
true
if the station is saved as having no childrenprotected String getID(DockElement dockable)
dockable
.
dockable
- the dockable to write
getID(DockFactory)
,
getFactory(String)
protected String getID(DockFactory<?,?> factory)
factory
. The default behavior is just to
return DockFactory.getID()
. Note that this method should be
a bijection to getFactory(String)
.
factory
- the factory whose id is needed
protected DockFactory<? extends DockElement,?> getFactory(String id)
id
. Note that this
method should be a bijection to getID(DockFactory)
. The
default behavior compares id
with the
getID(DockFactory)
.
id
- the name of the factory
null
if no factory has this id
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |