bibliothek.gui.dock.station.screen.window
Class DisplayerScreenDockWindow

java.lang.Object
  extended by bibliothek.gui.dock.station.screen.window.DisplayerScreenDockWindow
All Implemented Interfaces:
ScreenDockWindow
Direct Known Subclasses:
AbstractScreenDockWindow

public abstract class DisplayerScreenDockWindow
extends Object
implements ScreenDockWindow

A window that uses a DockableDisplayer to show the Dockable.

Author:
Benjamin Sigg

Nested Class Summary
protected  class DisplayerScreenDockWindow.Background
          The algorithm that paints the background of this window.
 
Constructor Summary
DisplayerScreenDockWindow(ScreenDockStation station, WindowConfiguration configuration)
          Creates a new window
 
Method Summary
 void addScreenDockWindowListener(ScreenDockWindowListener listener)
          Adds a listener to this window, the listener has to be informed about changes of this window.
 boolean contains(int x, int y)
          Tells whether the point x/y is over this window or not.
protected  WindowMover createTitleMover()
          Creates a new WindowMover which is used to move this window if the DockTitle is dragged by the mouse.
protected  void discardDisplayer()
          Replaces the current DockableDisplayer with a new instance.
protected  void fireFullscreenChanged()
          Informs all listeners that the fullscreen state changed
protected  void fireShapeChanged()
          Informs all listeners that the current size or position changed
protected  void fireVisibilityChanged()
          Informs all listeners that the visibility state changed
 WindowConfiguration getConfiguration()
          Gets the configuration which was used to set up this window.
 DockController getController()
          Gets the controller in whose realm this window is used.
 Dockable getDockable()
          Gets the Dockable which is currently shown in this window.
 DockableDisplayer getDockableDisplayer()
          Gets the DockableDisplayer which manages the dockable.
 Dimension getMinimumWindowSize()
          Gets the minimum size this window should have.
 Rectangle getNormalBounds()
          Gets the boundaries this window should use if not in fullscreen mode.
 Point getOffsetDrop()
          Gets an offset that will be added to the location when dropping a window.
A value of null indicates that no such offset is available.
 Point getOffsetMove()
          Gets an offset that will be subtracted from the location when moving the window around.
 ScreenDockStation getStation()
          Gets the station which owns this window.
 Point getTitleCenter()
          Gets the center of the title of this window.
protected abstract  Component getWindowComponent()
          Gets the component on which ScreenDockWindow.setWindowBounds(java.awt.Rectangle, boolean) is applied.
 boolean inCombineArea(int x, int y)
          Checks what would happen if a Dockable is dropped at point x/y.
protected  void init(WindowConfiguration configuration)
          Called the first time when a Dockable is set.
 boolean inTitleArea(int x, int y)
          Checks whether at x/y there is a title.
 boolean isFullscreen()
          Tells whether this window is in fullscreen mode or not.
protected  boolean isMoveOnTitleGrab()
          Tells whether this window can be moved by grabbing the title.
 boolean isShowTitle()
          Tells whether the DockTitle is generally shown.
protected  ScreenDockWindowListener[] listeners()
          Gets a list of all listeners that are currently registered.
 void removeScreenDockWindowListener(ScreenDockWindowListener listener)
          Removes a listener from this window.
protected abstract  void setBackground(BackgroundAlgorithm background)
          Sets the algorithm that paints the background of this window.
 void setController(DockController controller)
          Sets the controller in whose realm this window will be used.
 void setDockable(Dockable dockable)
          Sets the Dockable which should be shown on this window.
 void setFullscreen(boolean fullscreen)
          Changes the mode of this window to fullscreen or to normal.
 void setFullscreenStrategy(ScreenDockFullscreenStrategy strategy)
          Tells this window what strategy to use for handling fullscreen mode.
 void setNormalBounds(Rectangle bounds)
          Sets the boundaries this window should use if not in fullscreen mode.
 void setShowTitle(boolean showTitle)
          Sets whether the DockTitle should be shown or not.
protected abstract  void showDisplayer(DockableDisplayer displayer)
          Forces the subclass of this window to show displayer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bibliothek.gui.dock.station.screen.ScreenDockWindow
checkWindowBounds, destroy, getDockableInsets, getWindowBounds, isVisible, setPaintCombining, setPaintRemoval, setPreventFocusStealing, setVisible, setWindowBounds, toFront, validate
 

Constructor Detail

DisplayerScreenDockWindow

public DisplayerScreenDockWindow(ScreenDockStation station,
                                 WindowConfiguration configuration)
Creates a new window

Parameters:
station - the owner of this window, not null
configuration - default configuration of this window, cannot be changed once the window is created
Method Detail

init

protected void init(WindowConfiguration configuration)
Called the first time when a Dockable is set.

Parameters:
configuration - the configuration that is to be applied

isMoveOnTitleGrab

protected boolean isMoveOnTitleGrab()
Tells whether this window can be moved by grabbing the title.

Returns:
whether a WindowMover has been created

createTitleMover

protected WindowMover createTitleMover()
Creates a new WindowMover which is used to move this window if the DockTitle is dragged by the mouse. This method is only called if WindowConfiguration.isMoveOnTitleGrab() returns true.

Returns:
the new mover, can be null

addScreenDockWindowListener

public void addScreenDockWindowListener(ScreenDockWindowListener listener)
Description copied from interface: ScreenDockWindow
Adds a listener to this window, the listener has to be informed about changes of this window.

Specified by:
addScreenDockWindowListener in interface ScreenDockWindow
Parameters:
listener - the new listener

removeScreenDockWindowListener

public void removeScreenDockWindowListener(ScreenDockWindowListener listener)
Description copied from interface: ScreenDockWindow
Removes a listener from this window.

Specified by:
removeScreenDockWindowListener in interface ScreenDockWindow
Parameters:
listener - the listener to remove

listeners

protected ScreenDockWindowListener[] listeners()
Gets a list of all listeners that are currently registered.

Returns:
all listeners

fireFullscreenChanged

protected void fireFullscreenChanged()
Informs all listeners that the fullscreen state changed


fireVisibilityChanged

protected void fireVisibilityChanged()
Informs all listeners that the visibility state changed


fireShapeChanged

protected void fireShapeChanged()
Informs all listeners that the current size or position changed


showDisplayer

protected abstract void showDisplayer(DockableDisplayer displayer)
Forces the subclass of this window to show displayer. Only one displayer should be shown at any time. A new displayer replaces an old one.

Parameters:
displayer - the displayer to show or null to remove the current displayer

getWindowComponent

protected abstract Component getWindowComponent()
Gets the component on which ScreenDockWindow.setWindowBounds(java.awt.Rectangle, boolean) is applied.

Returns:
the base component

setBackground

protected abstract void setBackground(BackgroundAlgorithm background)
Sets the algorithm that paints the background of this window.

Parameters:
background - the algorithm, may be null

setShowTitle

public void setShowTitle(boolean showTitle)
Sets whether the DockTitle should be shown or not.

Parameters:
showTitle - true if the title should be visible, false otherwise

isShowTitle

public boolean isShowTitle()
Tells whether the DockTitle is generally shown.

Returns:
true if the title is shown

getDockable

public Dockable getDockable()
Description copied from interface: ScreenDockWindow
Gets the Dockable which is currently shown in this window.

Specified by:
getDockable in interface ScreenDockWindow
Returns:
the current element, can be null
See Also:
ScreenDockWindow.setDockable(Dockable)

getDockableDisplayer

public DockableDisplayer getDockableDisplayer()
Description copied from interface: ScreenDockWindow
Gets the DockableDisplayer which manages the dockable.

Specified by:
getDockableDisplayer in interface ScreenDockWindow
Returns:
the displayer or null

setDockable

public void setDockable(Dockable dockable)
Description copied from interface: ScreenDockWindow
Sets the Dockable which should be shown on this window.

Specified by:
setDockable in interface ScreenDockWindow
Parameters:
dockable - the new element, can be null to remove an old Dockable

getConfiguration

public WindowConfiguration getConfiguration()
Gets the configuration which was used to set up this window.

Returns:
the configuration, should not be modified by clients or subclasses

discardDisplayer

protected void discardDisplayer()
Replaces the current DockableDisplayer with a new instance.


setFullscreenStrategy

public void setFullscreenStrategy(ScreenDockFullscreenStrategy strategy)
Description copied from interface: ScreenDockWindow
Tells this window what strategy to use for handling fullscreen mode.

Specified by:
setFullscreenStrategy in interface ScreenDockWindow
Parameters:
strategy - the strategy

isFullscreen

public boolean isFullscreen()
Description copied from interface: ScreenDockWindow
Tells whether this window is in fullscreen mode or not. This method should call ScreenDockFullscreenStrategy.isFullscreen(ScreenDockWindow), subclasses may execute additional checks.

Specified by:
isFullscreen in interface ScreenDockWindow
Returns:
true if fullscreen mode is active

setFullscreen

public void setFullscreen(boolean fullscreen)
Description copied from interface: ScreenDockWindow
Changes the mode of this window to fullscreen or to normal. This method should call ScreenDockFullscreenStrategy.setFullscreen(ScreenDockWindow, boolean), subclasses may execute additional code.

Specified by:
setFullscreen in interface ScreenDockWindow
Parameters:
fullscreen - the new state

setNormalBounds

public void setNormalBounds(Rectangle bounds)
Description copied from interface: ScreenDockWindow
Sets the boundaries this window should use if not in fullscreen mode. This boundaries need to be stored but must not be applied. This property is intended to be used by a ScreenDockFullscreenStrategy and is usually set to null if this window is not in fullscreen mode.

Specified by:
setNormalBounds in interface ScreenDockWindow
Parameters:
bounds - the normal bounds, can be null

getNormalBounds

public Rectangle getNormalBounds()
Description copied from interface: ScreenDockWindow
Gets the boundaries this window should use if not in fullscreen mode.

Specified by:
getNormalBounds in interface ScreenDockWindow
Returns:
the boundaries, can be null

getMinimumWindowSize

public Dimension getMinimumWindowSize()
Description copied from interface: ScreenDockWindow
Gets the minimum size this window should have. Usually these boundaries are used by a BoundaryRestriction, but there are no guarantees that the window is not made smaller than this size.

Specified by:
getMinimumWindowSize in interface ScreenDockWindow
Returns:
the minimum size

setController

public void setController(DockController controller)
Description copied from interface: ScreenDockWindow
Sets the controller in whose realm this window will be used. This method will be called after the controller of the owning ScreenDockStation was set, so AbstractDockStation.getController() will always return the same value as controller. This also implies that any method of the station called from this method already uses the new controller.

Specified by:
setController in interface ScreenDockWindow
Parameters:
controller - the new controller, can be null

getTitleCenter

public Point getTitleCenter()
Description copied from interface: ScreenDockWindow
Gets the center of the title of this window. In general the center of the title should remain visible all the time.

Specified by:
getTitleCenter in interface ScreenDockWindow
Returns:
the center, can be null

getOffsetDrop

public Point getOffsetDrop()
Description copied from interface: ScreenDockWindow
Gets an offset that will be added to the location when dropping a window.
A value of null indicates that no such offset is available.

Specified by:
getOffsetDrop in interface ScreenDockWindow
Returns:
the offset or null

getOffsetMove

public Point getOffsetMove()
Description copied from interface: ScreenDockWindow
Gets an offset that will be subtracted from the location when moving the window around. The offset should be equal to the point 0/0 on the DockTitle of the Dockable shown in this window. The value null can be returned to indicate that such an offset is not available.

Specified by:
getOffsetMove in interface ScreenDockWindow
Returns:
the offset or null

inTitleArea

public boolean inTitleArea(int x,
                           int y)
Description copied from interface: ScreenDockWindow
Checks whether at x/y there is a title.

Specified by:
inTitleArea in interface ScreenDockWindow
Parameters:
x - an x coordinate in the screen
y - an y coordinate in the screen
Returns:
true if there is a title, false otherwise

inCombineArea

public boolean inCombineArea(int x,
                             int y)
Description copied from interface: ScreenDockWindow
Checks what would happen if a Dockable is dropped at point x/y.

Specified by:
inCombineArea in interface ScreenDockWindow
Parameters:
x - an x coordinate in the screen
y - an y coordinate in the screen
Returns:
true if dropping a Dockable at x/y should lead to a combination of the dropped element and the element in this window, false otherwise

contains

public boolean contains(int x,
                        int y)
Description copied from interface: ScreenDockWindow
Tells whether the point x/y is over this window or not.

Specified by:
contains in interface ScreenDockWindow
Parameters:
x - an x coordinate in the screen
y - an y coordinate in the screen
Returns:
true if this window is under x/y, false otherwise

getController

public DockController getController()
Gets the controller in whose realm this window is used.

Returns:
the controller, can be null

getStation

public ScreenDockStation getStation()
Description copied from interface: ScreenDockWindow
Gets the station which owns this window.

Specified by:
getStation in interface ScreenDockWindow
Returns:
the owner, not null