bibliothek.gui.dock.support.lookandfeel
Class LookAndFeelList

java.lang.Object
  extended by bibliothek.gui.dock.support.lookandfeel.LookAndFeelList

@Todo(compatibility=COMPATIBLE,
      priority=MAJOR,
      target=VERSION_1_1_1,
      description="persistent storage: use string identifier instead of integer")
public class LookAndFeelList
extends java.lang.Object

A list of LookAndFeels, can setup a LookAndFeel when asked. It's possible to add a LookAndFeelListener to this list and receive events whenever the LookAndFeel changes.
Clients should use getDefaultList() to get a list of LookAndFeels

Author:
Benjamin Sigg

Nested Class Summary
static class LookAndFeelList.Info
          Information about a LookAndFeel.
 
Constructor Summary
protected LookAndFeelList()
          Crates a new list and collects all available LookAndFeels.
 
Method Summary
 void add(LookAndFeelList.Info info)
          Adds a new LookAndFeel to the list.
 void addComponentCollector(ComponentCollector c)
          Adds a set of root-Components to this list, the set of roots will be used to find all JComponents which need to be updated when the LookAndFeel changes.
 void addLookAndFeelListener(LookAndFeelListener listener)
          Adds a listener to this list, the listener will be notified whenever the LookAndFeel is changed.
 LookAndFeelList.Info get(int index)
          Gets the index'th LookAndFeel.
 LookAndFeelList.Info getDefault()
          Gets information about the LookAndFeel that is used when the system can decide on its own.
static LookAndFeelList getDefaultList()
          Gets the global list of LookAndFeels
 LookAndFeelList.Info getFull(int index)
          Gets the index'th LookAndFeel, where 0 means the default, 1 the system and anything else the normal, moved by 2 steps, LookAndFeels.
 LookAndFeelList.Info getLookAndFeel()
          Gets the LookAndFeel which is currently used.
 LookAndFeelList.Info getSystem()
          Gets information about the LookAndFeel that imitates the native look of the system.
 int indexOf(LookAndFeelList.Info info)
          Gets the location of info.
 int indexOfFull(LookAndFeelList.Info info)
          Gets the index of info, where 0 means the default, 1 the system and anything else the normal, moved by 2 steps, LookAndFeels.
 void insert(int index, LookAndFeelList.Info info)
          Inserts a new LookAndFeel into the list.
 boolean isAllowReadOnlyOnce()
          Whether multiple calls to read(DataInputStream) have an effect or not.
protected  java.util.Collection<java.awt.Component> listComponents()
          Creates a list containing all root-Components of this application, the ComponentCollectors are used to build this list.
protected  LookAndFeelListener[] listeners()
          Gets all LookAndFeelListener that are known to this list.
 void read(java.io.DataInputStream in)
          Reads which LookAndFeel was used earlier and calls setLookAndFeel to set the old LookAndFeel.
 void readXML(XElement element)
          Reads which LookAndFeel was used earlier and calls setLookAndFeel to set the old LookAndFeel.
 void remove(int index)
          Removes a LookAndFeel from this list.
 void remove(LookAndFeelList.Info info)
          Removes the LookAndFeel at location index from this list.
 void removeComponentCollector(ComponentCollector c)
          Removes an earlier added set of roots.
 void removeLookAndFeelListener(LookAndFeelListener listener)
          Removes a listener from this list.
 void setAllowReadOnlyOnce(boolean allowReadOnlyOnce)
          Sets whether multiple calls to read(DataInputStream) will have an effect.
 void setDefault(LookAndFeelList.Info defaultInfo)
          Sets the default- LookAndFeel.
static void setDefaultList(LookAndFeelList list)
          Sets the default LookAndFeelList.
 void setLookAndFeel(LookAndFeelList.Info lookAndFeel)
          Exchanges the currently used LookAndFeel.
 void setReadOnce(boolean read)
          Sets whether this list has already read something once, or whether it is fresh.
 void setSystem(LookAndFeelList.Info systemInfo)
          Sets the system- LookAndFeel.
 int size()
          Gets the number of LookAndFeels that are known to this list.
 void write(java.io.DataOutputStream out)
          Writes which LookAndFeel is currently used.
 void writeXML(XElement element)
          Writes which LookAndFeel is currently used.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LookAndFeelList

protected LookAndFeelList()
Crates a new list and collects all available LookAndFeels.

Method Detail

getDefaultList

public static LookAndFeelList getDefaultList()
Gets the global list of LookAndFeels

Returns:
the global list, not null

setDefaultList

public static void setDefaultList(LookAndFeelList list)
Sets the default LookAndFeelList.

Parameters:
list - the list, can be null

isAllowReadOnlyOnce

public boolean isAllowReadOnlyOnce()
Whether multiple calls to read(DataInputStream) have an effect or not.

Returns:
true if only the first read-call has an effect.

setAllowReadOnlyOnce

public void setAllowReadOnlyOnce(boolean allowReadOnlyOnce)
Sets whether multiple calls to read(DataInputStream) will have an effect.

Parameters:
allowReadOnlyOnce - true if only the first read will have an effect, false if the LookAndFeel can change every time read(DataInputStream) is called.

setReadOnce

public void setReadOnce(boolean read)
Sets whether this list has already read something once, or whether it is fresh. Can be used to reset a list to its initial state.

Parameters:
read - true if at least one time one of the read methods was called, false otherwise.

addLookAndFeelListener

public void addLookAndFeelListener(LookAndFeelListener listener)
Adds a listener to this list, the listener will be notified whenever the LookAndFeel is changed.

Parameters:
listener - the new listener

removeLookAndFeelListener

public void removeLookAndFeelListener(LookAndFeelListener listener)
Removes a listener from this list.

Parameters:
listener - the listener to remove

listeners

protected LookAndFeelListener[] listeners()
Gets all LookAndFeelListener that are known to this list.

Returns:
the list of listeners

addComponentCollector

public void addComponentCollector(ComponentCollector c)
Adds a set of root-Components to this list, the set of roots will be used to find all JComponents which need to be updated when the LookAndFeel changes.

Parameters:
c - the new set of roots

removeComponentCollector

public void removeComponentCollector(ComponentCollector c)
Removes an earlier added set of roots.

Parameters:
c - the roots

add

public void add(LookAndFeelList.Info info)
Adds a new LookAndFeel to the list.

Parameters:
info - the new LookAndFeel

insert

public void insert(int index,
                   LookAndFeelList.Info info)
Inserts a new LookAndFeel into the list.

Parameters:
index - the location of the new LookAndFeel
info - the new LookAndFeel

size

public int size()
Gets the number of LookAndFeels that are known to this list.

Returns:
the number of LookAndFeels

get

public LookAndFeelList.Info get(int index)
Gets the index'th LookAndFeel.

Parameters:
index - the location of the LookAndFeel
Returns:
the LookAndFeel

indexOf

public int indexOf(LookAndFeelList.Info info)
Gets the location of info.

Parameters:
info - a LookAndFeel
Returns:
the location of info or -1

getFull

public LookAndFeelList.Info getFull(int index)
Gets the index'th LookAndFeel, where 0 means the default, 1 the system and anything else the normal, moved by 2 steps, LookAndFeels.

Parameters:
index - the location of the LookAndFeel
Returns:
the selected LookAndFeel

indexOfFull

public int indexOfFull(LookAndFeelList.Info info)
Gets the index of info, where 0 means the default, 1 the system and anything else the normal, moved by 2 steps, LookAndFeels.

Parameters:
info - the LookAndFeel to search
Returns:
the location of info

remove

public void remove(LookAndFeelList.Info info)
Removes the LookAndFeel at location index from this list.

Parameters:
info - the LookAndFeel to remove

remove

public void remove(int index)
Removes a LookAndFeel from this list.

Parameters:
index - the location of the element to remove

getLookAndFeel

public LookAndFeelList.Info getLookAndFeel()
Gets the LookAndFeel which is currently used.

Returns:
the currently used LookAndFeel

setLookAndFeel

public void setLookAndFeel(LookAndFeelList.Info lookAndFeel)
Exchanges the currently used LookAndFeel.

Parameters:
lookAndFeel - information about a LookAndFeel, not null

getDefault

public LookAndFeelList.Info getDefault()
Gets information about the LookAndFeel that is used when the system can decide on its own.

Returns:
information about a LookAndFeel

setDefault

public void setDefault(LookAndFeelList.Info defaultInfo)
Sets the default- LookAndFeel. Please note that getDefault() will return another LookAndFeelList.Info, even if the behavior of that other info is the same as defaultInfo.

Parameters:
defaultInfo - the default LookAndFeel

getSystem

public LookAndFeelList.Info getSystem()
Gets information about the LookAndFeel that imitates the native look of the system.

Returns:
information about a LookAndFeel

setSystem

public void setSystem(LookAndFeelList.Info systemInfo)
Sets the system- LookAndFeel. Please note that getSystem() will return another LookAndFeelList.Info, even if the behavior of that other info is the same as systemInfo.

Parameters:
systemInfo - the system LookAndFeel

write

public void write(java.io.DataOutputStream out)
           throws java.io.IOException
Writes which LookAndFeel is currently used.

Parameters:
out - the stream to write into
Throws:
java.io.IOException - if the method can't write into out

read

public void read(java.io.DataInputStream in)
          throws java.io.IOException
Reads which LookAndFeel was used earlier and calls setLookAndFeel to set the old LookAndFeel.

Parameters:
in - the stream to read from
Throws:
java.io.IOException - if in can't be read

writeXML

public void writeXML(XElement element)
Writes which LookAndFeel is currently used.

Parameters:
element - the element to write into, the attributes of element will not be changed.

readXML

public void readXML(XElement element)
Reads which LookAndFeel was used earlier and calls setLookAndFeel to set the old LookAndFeel.

Parameters:
element - the element to read from

listComponents

protected java.util.Collection<java.awt.Component> listComponents()
Creates a list containing all root-Components of this application, the ComponentCollectors are used to build this list.

Returns:
the list of roots