|
||||||||||
| 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 |
void |
addAdjacent(AdjacentDockFactory<?> factory)
Adds an adjacent 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 tries to create a
DockElement that matches the composition. |
java.lang.String |
convertFactoryId(DockFactory<?,?,?> factory)
Tells what identifier is used for factory in the
DockLayoutComposition. |
java.lang.String |
convertFactoryId(java.lang.String id)
Tells what identifier the DockFactory has, for which the
identifier id is used within a DockLayoutComposition. |
Perspective |
createPerspective()
Creates a new Perspective that uses the settings made on this DockSituation. |
protected void |
estimateLocations(DefaultLocationEstimationMap map)
Recursively tries to estimate the locations of all DockLayoutInfos that can
be found in map. |
void |
estimateLocations(DockLayoutComposition composition)
Tries to guess the location of the elements stored in the tree below composition. |
void |
estimateLocations(DockLayoutComposition composition,
DockableProperty location)
Tries to guess the location of the elements stored in the tree below composition, assuming that composition itself
is at location location. |
DockLayoutComposition |
fillMissing(DockLayoutComposition composition)
Using the factories currently known to this DockSituation, this
method tries to fill gaps in composition. |
protected DockLayoutInfo |
fillMissing(DockLayoutInfo info)
Called by fillMissing(DockLayoutComposition) only for
DockLayoutInfos which contain a DockLayout. |
AdjacentDockFactory<?> |
getAdjacentFactory(java.lang.String id)
Gets the adjacent factory which has the given id. |
protected java.lang.String |
getAdjacentFactoryID(java.lang.String id)
Transforms an id read from a stream to the id of the adjacent factory which would be used. |
java.util.Map<java.lang.String,AdjacentDockFactory<?>> |
getAdjacentFactorys()
Gets all the adjacent factories that are currently registered at this DockSituation,
the returned Map is unmodifiable. |
protected java.lang.String |
getAdjacentID(AdjacentDockFactory<?> factory)
Gets the id of factory. |
DockFactory<? extends DockElement,?,?> |
getFactory(java.lang.String id)
Gets the factory which has the given id. |
protected java.lang.String |
getFactoryID(DockLayoutInfo info)
Reads the id of the factory which was used to create info. |
protected java.lang.String |
getFactoryID(java.lang.String id)
Transforms an id read from a stream to the id of the factory which would be used. |
protected java.lang.String |
getID(DockElement element)
Gets the id of the factory which is needed to write (and later read) element |
protected java.lang.String |
getID(DockFactory<?,?,?> factory)
Gets the id of factory. |
protected java.lang.String |
getID(PerspectiveElement element)
Gets the id of the factory which is needed to write (and later read) element |
DockSituationIgnore |
getIgnore()
Gets the filter which decides, which elements are stored. |
PlaceholderStrategy |
getIntermediatePlaceholders()
Gets the strategy for deleting invalid placeholders in the intermediate format. |
MissingDockFactory |
getMissingAdjacentFactory()
Gets the factory which is used when another AdjacentDockFactory
is missing. |
MissingDockFactory |
getMissingFactory()
Gets the factory which is used when another factory is missing. |
protected Path |
getPlaceholder(DockElement element)
Gets a placeholder for element using the current PlaceholderStrategy. |
PlaceholderStrategy |
getPlaceholderStrategy()
Gets the current strategy for removing invalid placeholders. |
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. |
java.util.Map<java.lang.String,DockStation> |
read(byte[] data)
Reads data as stream and returns the roots of the
DockElements which were found. |
java.util.Map<java.lang.String,DockStation> |
read(java.io.DataInputStream in)
Reads in and returns the roots of the
DockElements which were found. |
DockLayoutComposition |
readComposition(java.io.DataInputStream in)
Reads one DockLayoutComposition and all its children. |
java.util.Map<java.lang.String,DockLayoutComposition> |
readCompositions(java.io.DataInputStream in)
Reads in and returns the map of DockLayoutCompositions that was
stored. |
java.util.Map<java.lang.String,DockLayoutComposition> |
readCompositionsXML(XElement root)
Reads a set of DockLayoutCompositions that were stored earlier. |
DockLayoutComposition |
readCompositionXML(XElement element)
Reads a DockLayoutComposition from an xml element. |
java.util.Map<java.lang.String,DockStation> |
readXML(XElement root)
Reads a set of DockStations that were stored earlier. |
void |
setIgnore(DockSituationIgnore ignore)
Sets a filter which decides, which elements (stations and dockables) are stored. |
void |
setIntermediatePlaceholders(PlaceholderStrategy intermediatePlaceholders)
Sets the strategy for deleting invalid placeholders in the intermediate format |
void |
setMissingAdjacentFactory(MissingDockFactory missingAdjacent)
Sets a factory which is used when a AdjacentDockFactory is missing. |
void |
setMissingFactory(MissingDockFactory missingFactory)
Sets a factory which is used whenever no ordinary DockFactory
can be found to read something. |
void |
setPlaceholderStrategy(PlaceholderStrategy placeholders)
Sets a strategy for deleting invalid placeholders. |
byte[] |
write(java.util.Map<java.lang.String,DockStation> stations)
Writes all locations and relationships of the DockStations
stations and their children into an array of bytes. |
void |
write(java.util.Map<java.lang.String,DockStation> stations,
java.io.DataOutputStream out)
Writes all locations and relationships of the DockStations
stations and their children into the stream out. |
void |
writeComposition(DockLayoutComposition composition,
java.io.DataOutputStream out)
Writes the contents of composition and all its children
to out. |
void |
writeCompositions(java.util.Map<java.lang.String,DockLayoutComposition> stations,
java.io.DataOutputStream out)
Writes all information stored in stations to out. |
void |
writeCompositionsXML(java.util.Map<java.lang.String,DockLayoutComposition> stations,
XElement element)
Writes the contents of station into element. |
void |
writeCompositionXML(DockLayoutComposition composition,
XElement element)
Writes the contents of composition into element without
changing the attributes of element. |
void |
writeXML(java.util.Map<java.lang.String,DockStation> stations,
XElement element)
Writes all locations and relationships of the DockStations
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 Perspective createPerspective()
Perspective that uses the settings made on this DockSituation. Changes on the
properties of this DockSituation will be noticed and used by the created Perspective. However
changes on the properties of the Perspective will not influence this DockSituation.Perspectives that need the client to make additional settings before
it can be used.
public void setIgnore(DockSituationIgnore ignore)
ignore - the filter or nullpublic DockSituationIgnore getIgnore()
nullpublic void setPlaceholderStrategy(PlaceholderStrategy placeholders)
placeholders - the strategy, null for keeping all placeholderspublic PlaceholderStrategy getPlaceholderStrategy()
nullpublic void setIntermediatePlaceholders(PlaceholderStrategy intermediatePlaceholders)
intermediatePlaceholders - the strategy, can be nullpublic PlaceholderStrategy getIntermediatePlaceholders()
nullprotected Path getPlaceholder(DockElement element)
element using the current PlaceholderStrategy.
element - some element, not null
nullpublic void add(DockFactory<?,?,?> factory)
factory - the additional factorypublic void addAdjacent(AdjacentDockFactory<?> factory)
factory - the new factorypublic void setMissingFactory(MissingDockFactory missingFactory)
DockFactory
can be found to read something. The missingFactory can convert
the input to any Object it likes, but if a missing factory
is later added to this situation, then that object needs to be casted
into the object used by the original factory. So when working with
a MissingDockFactory handling different types of layout-data
needs to be done very carefully. Note that this factory is only used to convert
byte-stream or xml data to the intermediate format. It cannot create any Dockable or
DockElement nor store any data.
missingFactory - the factory, can be nullpublic MissingDockFactory getMissingFactory()
nullsetMissingFactory(MissingDockFactory)public void setMissingAdjacentFactory(MissingDockFactory missingAdjacent)
AdjacentDockFactory is missing.
There are the same issues with this factory than with the one used
by setMissingFactory(MissingDockFactory).
missingAdjacent - the new factory, can be nullsetMissingFactory(MissingDockFactory)public MissingDockFactory getMissingAdjacentFactory()
AdjacentDockFactory
is missing.
nullsetMissingAdjacentFactory(MissingDockFactory)public DockLayoutComposition convert(DockElement element)
element and all its children into a
DockLayoutComposition.
element - the element to convert
null if the element is ignored
java.lang.IllegalArgumentException - if one element has an unknown id of
a DockFactory.
java.lang.ClassCastException - if an element does not specify the correct
DockFactory.
@Todo(compatibility=COMPATIBLE,
priority=MAJOR,
target=VERSION_1_1_1,
description="setting Dockable.parent to null should also be done in the stations whose layout changes")
public DockElement convert(DockLayoutComposition composition)
composition and tries to create a
DockElement that matches the composition.
composition - the composition to analyze
DockElement
if the factory for composition was not found
public void writeComposition(DockLayoutComposition composition,
java.io.DataOutputStream out)
throws java.io.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
java.io.IOException - if an I/O-error occurs
public DockLayoutComposition readComposition(java.io.DataInputStream in)
throws java.io.IOException
DockLayoutComposition and all its children.
in - the stream to read from
null if the factory was missing
java.io.IOException - if an I/O-error occurs
public byte[] write(java.util.Map<java.lang.String,DockStation> stations)
throws java.io.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.
java.io.IOException - if the information can't be written
public void write(java.util.Map<java.lang.String,DockStation> stations,
java.io.DataOutputStream out)
throws java.io.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
java.io.IOException - if the stream throws an exception
public void writeCompositions(java.util.Map<java.lang.String,DockLayoutComposition> stations,
java.io.DataOutputStream out)
throws java.io.IOException
stations to out.
stations - Representations of the root-stations.out - the stream to write in
java.io.IOException - if the stream throws an exception
public java.util.Map<java.lang.String,DockStation> read(byte[] data)
throws java.io.IOException
data as stream and returns the roots of the
DockElements which were found.
data - the array to read
java.io.IOException - if data can't be read
public java.util.Map<java.lang.String,DockStation> read(java.io.DataInputStream in)
throws java.io.IOException
in and returns the roots of the
DockElements which were found.
in - the stream to read
java.io.IOException - if the stream can't be read
public java.util.Map<java.lang.String,DockLayoutComposition> readCompositions(java.io.DataInputStream in)
throws java.io.IOException
in and returns the map of DockLayoutCompositions that was
stored.
in - the stream to read from
java.io.IOException - if an I/O-error occurs
public 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
java.lang.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(java.util.Map<java.lang.String,DockStation> stations,
XElement element)
DockStations
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
public void writeCompositionsXML(java.util.Map<java.lang.String,DockLayoutComposition> stations,
XElement element)
station into element.
stations - the items to writeelement - the element to write into, the attributes of element
will not be changedpublic java.util.Map<java.lang.String,DockStation> readXML(XElement root)
DockStations that were stored earlier.
root - the xml element from which to read
public java.util.Map<java.lang.String,DockLayoutComposition> readCompositionsXML(XElement root)
DockLayoutCompositions that were stored earlier.
root - the xml element from which to read
public DockLayoutComposition fillMissing(DockLayoutComposition composition)
throws java.io.IOException,
XException
DockSituation, this
method tries to fill gaps in composition. It checks
all the DockLayoutInfos, if an info contains a byte array or
an XElement, then this method tries to use a factory to
read the element. If a missing factory
is present, then this factory is used as well.
composition - the composition to read
composition or a new composition if this
method changed something
java.io.IOException - if some stream was opened but cannot be read
XException - if some xml element was found but cannot be readprotected DockLayoutInfo fillMissing(DockLayoutInfo info)
fillMissing(DockLayoutComposition) only for
DockLayoutInfos which contain a DockLayout. This method
can apply further updates to info if necessary. The default
implementation just returns info.DockFactorys
and use a DockLayout even for incomplete data.
info - the info to update
info if nothing changed or a new
DockLayoutInfo if additional information could be retrievedpublic void estimateLocations(DockLayoutComposition composition)
composition. Invoking this method is the same as calling
guessLocation( composition, composition.getLayout().getLocation() );.
composition - the composition whose location will be determined
public void estimateLocations(DockLayoutComposition composition,
DockableProperty location)
composition, assuming that composition itself
is at location location. This method reads out the
DockLayoutInfo through DockLayoutComposition.getLayout()
and then calls DockLayoutInfo.setLocation(DockableProperty), so
composition gets modified by this method. This method stops
its recursion if the location of a child of composition
was not found.composition does not have childrencomposition does not carry a DockLayoutDockFactory registered for the factory-id found
in compositionfillMissing(DockLayoutComposition) before invoking this method.
composition - the composition whose children should be analyzedlocation - the location of composition, can be nullprotected void estimateLocations(DefaultLocationEstimationMap map)
DockLayoutInfos that can
be found in map.DefaultLocationEstimationMap.finish().
map - the root of the tree for which locations need to be estimatedprotected 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 java.lang.String getID(PerspectiveElement element)
element
element - the element to read
getID(DockFactory),
getFactory(String)protected java.lang.String getID(DockElement element)
element
element - the element to read
getID(DockFactory),
getFactory(String)protected java.lang.String getID(DockFactory<?,?,?> factory)
factory. The default behavior is just to
return DockConverter.getID(). Note that this method should be
a bijection to getFactory(String).
factory - the factory whose id is needed
protected java.lang.String getFactoryID(DockLayoutInfo info)
info.
This returns the id of the factory as it is used internally by this
DockSituation.
info - the info to check
null if info does not contain
data
java.lang.IllegalArgumentException - if the data of info is in the wrong format
XException - if the data of info is in the wrong formatpublic java.lang.String convertFactoryId(DockFactory<?,?,?> factory)
factory in the
DockLayoutComposition.getID(DockFactory), but
getID(DockFactory) is intended for internal use while this
method is intended to be used by clients which read out a DockLayoutComposition.
factory - the factory which might be used
getID(DockFactory)public java.lang.String convertFactoryId(java.lang.String id)
DockFactory has, for which the
identifier id is used within a DockLayoutComposition.getFactoryID(String), but while
getFactoryID(String) is intended for internal use, this method
is intended for clients.
id - an identifier found in a DockLayoutComposition
DockFactoryprotected java.lang.String getFactoryID(java.lang.String id)
DockFactory factory = ...
factory.getID().equals( getFactoryID( getID( factory )));
id - the id read from a stream
protected java.lang.String getAdjacentID(AdjacentDockFactory<?> factory)
factory. The default behavior is just to
return DockConverter.getID(). Note that this method should be
a bijection to getAdjacentFactory(String).
factory - the factory whose id is needed
protected java.lang.String getAdjacentFactoryID(java.lang.String id)
AdjacentDockFactory factory = ...
factory.getID().equals( getFactoryID( getAdjacentID( factory )));
id - the id read from a stream
public DockFactory<? extends DockElement,?,?> getFactory(java.lang.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 idpublic AdjacentDockFactory<?> getAdjacentFactory(java.lang.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 idpublic java.util.Map<java.lang.String,AdjacentDockFactory<?>> getAdjacentFactorys()
DockSituation,
the returned Map is unmodifiable.
AdjacentDockFactorys.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||