com.javadocking.visualizer
Class FloatExternalizer

java.lang.Object
  extended by com.javadocking.visualizer.FloatExternalizer
All Implemented Interfaces:
Externalizer, Visualizer

public class FloatExternalizer
extends java.lang.Object
implements Externalizer

This is the default externalizer. It shows the externalized dockable in a floating window that contains an ExternalizeDock.

Author:
Heidi Rakels.

Constructor Summary
FloatExternalizer(java.awt.Window owner)
          Constructs an externalizer with the given window as owner for the windows.
 
Method Summary
 void addWindowFocusListener(java.awt.event.WindowFocusListener windowFocusListener)
          Adds the listener that will listen to the window focus events of all the floating windows created by this class.
 boolean canVisualizeDockable(Dockable dockableToVisualize)
          Determines if a dockable can be visualized by this visualizer.
 void externalizeDockable(Dockable dockable, java.awt.Point position)
          Externalizes the dockable in this float externalizer and puts the dockable in the given position.
protected  void getDefaultFloatingWindowLocation(java.awt.Point location)
          Moves the location inside the screen where the floating window has to be placed.
 java.awt.Window getOwner()
          Gets the window that owns the floating windows created by this dock.
 int getState()
          Determines the state of the dockables that are visualized by this visualizer.
 Dockable getVisualizedDockable(int index)
          Gets the visualized dockable with the specified index.
 int getVisualizedDockableCount()
          Gets the number of visualized dockables of this visualizer.
 void loadProperties(java.lang.String prefix, java.util.Properties properties, java.util.Map dockablesMap, java.awt.Window owner)
           Loads the properties for this visualizer.
 void moveExternalizedDockable(Dockable dockable, java.awt.Point position, java.awt.Point dockableOffset)
          Moves the externalized dockable in this float dock.
 void removeVisualizedDockable(Dockable dockableToRemove)
          Removes the visualized dockables from this visualizer.
 void removeWindowFocusListener(java.awt.event.WindowFocusListener windowFocusListener)
          Removes the given listener.
 void saveProperties(java.lang.String prefix, java.util.Properties properties)
           Saves the properties of this visualizer in the given properties object.
 void setOwner(java.awt.Window newOwner)
          Sets the window that owns the floating windows created by this dock.
 void visualizeDockable(Dockable dockable)
          Adds a dockable to this visualizer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FloatExternalizer

public FloatExternalizer(java.awt.Window owner)
Constructs an externalizer with the given window as owner for the windows.

Parameters:
owner - The window that owns the floating windows created by this dock.
Method Detail

moveExternalizedDockable

public void moveExternalizedDockable(Dockable dockable,
                                     java.awt.Point position,
                                     java.awt.Point dockableOffset)
Moves the externalized dockable in this float dock. The dockable should be externalized in a child dock of this float dock. The dockable state should be DockableState.EXTERNALIZED.

Specified by:
moveExternalizedDockable in interface Externalizer
Parameters:
dockable - The dockable to move.
position - The location, where the dockable will be placed.
dockableOffset - The offset of the mouse position in the externalizer.

visualizeDockable

public void visualizeDockable(Dockable dockable)
Description copied from interface: Visualizer
Adds a dockable to this visualizer.

Specified by:
visualizeDockable in interface Visualizer
Parameters:
dockable - The dockable whose content has to be visualized. May not be nul.

canVisualizeDockable

public boolean canVisualizeDockable(Dockable dockableToVisualize)
Description copied from interface: Visualizer
Determines if a dockable can be visualized by this visualizer.

Specified by:
canVisualizeDockable in interface Visualizer
Parameters:
dockableToVisualize - The dockable whose content has to be visualized. May not be nul.
Returns:
True if the dockable can be visualized, lse otherwise.

getState

public int getState()
Description copied from interface: Visualizer
Determines the state of the dockables that are visualized by this visualizer.

Specified by:
getState in interface Visualizer
Returns:
The state of the dockables that are visualized by this visualizer. The special state is a constant defined by DockableState, but not DockableState.NORMAL or DockableState.CLOSED.

getVisualizedDockable

public Dockable getVisualizedDockable(int index)
                               throws java.lang.IndexOutOfBoundsException
Description copied from interface: Visualizer
Gets the visualized dockable with the specified index.

Specified by:
getVisualizedDockable in interface Visualizer
Returns:
The visualized dockable with the specified index.
Throws:
java.lang.IndexOutOfBoundsException - If the index is out of range (index < 0 || index >= getvisualizedDockableCount()).

getVisualizedDockableCount

public int getVisualizedDockableCount()
Description copied from interface: Visualizer
Gets the number of visualized dockables of this visualizer.

Specified by:
getVisualizedDockableCount in interface Visualizer
Returns:
The number of visualized dockables of this visualizer.

removeVisualizedDockable

public void removeVisualizedDockable(Dockable dockableToRemove)
Description copied from interface: Visualizer
Removes the visualized dockables from this visualizer.

Specified by:
removeVisualizedDockable in interface Visualizer

saveProperties

public void saveProperties(java.lang.String prefix,
                           java.util.Properties properties)
Description copied from interface: Visualizer

Saves the properties of this visualizer in the given properties object.

The property names for this visualizer should start with the given prefix.

Specified by:
saveProperties in interface Visualizer
Parameters:
prefix - The prefix for the property names.
properties - The properties object to which the properties should be added.

loadProperties

public void loadProperties(java.lang.String prefix,
                           java.util.Properties properties,
                           java.util.Map dockablesMap,
                           java.awt.Window owner)
                    throws java.io.IOException
Description copied from interface: Visualizer

Loads the properties for this visualizer. The properties can be found in the given properties object. The property names for this visualizer start with the given prefix.

The dockables can be added to this visualizer. This is not obligatory. They can be found in the given dockables mapping.

This method should be called after the empty constructor to create the content of the visualizer. Don't call this method for a visualizer that already has a content.

Specified by:
loadProperties in interface Visualizer
Parameters:
prefix - The prefix of the names of the properties that have been intended for this visualizer.
properties - The properties object that contains the properties for this visualizer. It can contain also properties for other objects, but they will have another prefix.
dockablesMap - A mapping that contains the available dockables.
  • map key: the ID of the dockable (java.lang.String).
  • map value: the dockable (Dockable).
owner - The owner window of the visualizer in the dock model (DockModel).
Throws:
java.io.IOException - If an error occures while decoding the properties.

getOwner

public java.awt.Window getOwner()
Gets the window that owns the floating windows created by this dock.

Returns:
The window that owns the floating windows created by this dock.

setOwner

public void setOwner(java.awt.Window newOwner)
Sets the window that owns the floating windows created by this dock.

Parameters:
newOwner - The window that owns the floating windows created by this dock.

externalizeDockable

public void externalizeDockable(Dockable dockable,
                                java.awt.Point position)
Externalizes the dockable in this float externalizer and puts the dockable in the given position.

Parameters:
dockable - The dockable externalize.
position - The location, where the dockable will be placed.

addWindowFocusListener

public void addWindowFocusListener(java.awt.event.WindowFocusListener windowFocusListener)
Adds the listener that will listen to the window focus events of all the floating windows created by this class.

Parameters:
windowFocusListener - The listener that will listen to the window focus events of all the floating windows created by this class.

removeWindowFocusListener

public void removeWindowFocusListener(java.awt.event.WindowFocusListener windowFocusListener)
Removes the given listener.

Parameters:
windowFocusListener - The listener that listens to the window focus events of all the floating windows created by this class.

getDefaultFloatingWindowLocation

protected void getDefaultFloatingWindowLocation(java.awt.Point location)
Moves the location inside the screen where the floating window has to be placed.

Parameters:
location - The location where the floating window will be put, if the requested location is outside the screen.