net.clackrouter.jgraph.utils.gui
Class PositionManager

java.lang.Object
  extended by net.clackrouter.jgraph.utils.gui.PositionManager

public class PositionManager
extends java.lang.Object


Field Summary
protected static java.util.Vector containers
          vector with all registered containers
protected static java.lang.String DIVIDER_LOCATION
          Key suffix for the Registry to save and load the dividerlocation for the JSplitPane
protected static java.lang.String FRAME_HEIGHT
          Key suffix for the Registry to save and load the frame height for the component
protected static java.lang.String FRAME_STATE
          Key suffix for the Registry to save and load the frame state for the component
protected static java.lang.String FRAME_WIDTH
          Key suffix for the Registry to save and load the frame width for the component
protected static java.lang.String FRAME_X
          Key suffix for the Registry to save and load the frame x position for the component
protected static java.lang.String FRAME_Y
          Key suffix for the Registry to save and load the frame y position for the component
protected static net.clackrouter.jgraph.utils.gui.PosComponentListener posComponentListener
          we only need one adapter for all components
protected static net.clackrouter.jgraph.utils.gui.PosPropertyChangeListener posPropertyChangeListener
          We only need one listener for all split panes.
 
Constructor Summary
PositionManager()
           
 
Method Summary
static void addComponent(java.awt.Component comp)
          Adds a component to the control of the position manager.
static int getIntPos(java.awt.Component comp, java.lang.String extension, int defaultValue)
          Returns an int value from the preferences.
static java.lang.String getKey(java.awt.Component comp)
          Gets the key for the component.
static java.util.prefs.Preferences getPreferences()
          Returns the Preferences Node which can use for position storings.
static void main(java.lang.String[] args)
          Implements a test case
static void removeComponent(java.awt.Component comp)
          Removes a component from the control of the position manager.
static void setIntPos(java.awt.Component comp, java.lang.String extension, int value)
          Sets a value for the component.
static void updateComponent(java.awt.Component comp)
          The method reads the old position values and sets them to the component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FRAME_WIDTH

protected static final java.lang.String FRAME_WIDTH
Key suffix for the Registry to save and load the frame width for the component

See Also:
Constant Field Values

FRAME_HEIGHT

protected static final java.lang.String FRAME_HEIGHT
Key suffix for the Registry to save and load the frame height for the component

See Also:
Constant Field Values

FRAME_STATE

protected static final java.lang.String FRAME_STATE
Key suffix for the Registry to save and load the frame state for the component

See Also:
Constant Field Values

FRAME_X

protected static final java.lang.String FRAME_X
Key suffix for the Registry to save and load the frame x position for the component

See Also:
Constant Field Values

FRAME_Y

protected static final java.lang.String FRAME_Y
Key suffix for the Registry to save and load the frame y position for the component

See Also:
Constant Field Values

DIVIDER_LOCATION

protected static final java.lang.String DIVIDER_LOCATION
Key suffix for the Registry to save and load the dividerlocation for the JSplitPane

See Also:
Constant Field Values

containers

protected static java.util.Vector containers
vector with all registered containers


posComponentListener

protected static net.clackrouter.jgraph.utils.gui.PosComponentListener posComponentListener
we only need one adapter for all components


posPropertyChangeListener

protected static net.clackrouter.jgraph.utils.gui.PosPropertyChangeListener posPropertyChangeListener
We only need one listener for all split panes. The listener reacts at each movement and stores the new position.

Constructor Detail

PositionManager

public PositionManager()
Method Detail

addComponent

public static void addComponent(java.awt.Component comp)
Adds a component to the control of the position manager. Note: Register the Container before opening a window! For example:
        JFrame f = new JFrame();
  PositionManager.addContainer(f);
  f.setVisible(true);
  
Adds the needed listeners at the component. Before the addition the method reads the old position values and sets them to the component. If the method can't find old values then the method will try to get the screen size and will set 2/3 % from the screen size to the frame. If there is no availabe screen size the method uses the 400 x 600 dimensions. Currently we a support for the following components

Parameters:
comp - the concerning component

updateComponent

public static void updateComponent(java.awt.Component comp)
The method reads the old position values and sets them to the component. If the method can't find old values then the method will try to get the screen size and will set 2/3 % from the screen size to the frame. If there is no availabe screen size the method uses the 400 x 600 dimensions. Currently we a support for the following components

Parameters:
comp - the concerning container

removeComponent

public static void removeComponent(java.awt.Component comp)
Removes a component from the control of the position manager. The method removes the unused listeners from the component.


setIntPos

public static void setIntPos(java.awt.Component comp,
                             java.lang.String extension,
                             int value)
Sets a value for the component. You can use the extension to differ several values for the component. If you use the same extension at the getIntPos(Component, String, int) method, you will get back the value.

Parameters:
comp - the component

getKey

public static java.lang.String getKey(java.awt.Component comp)
Gets the key for the component. The key is addition from the full qualified class name and the name property. If the name property is null, you only will get the full qualified class name. If you have got two frames with the same class but with different window positions, then you should use different names and everything will work fine.

Parameters:
comp -

getPreferences

public static java.util.prefs.Preferences getPreferences()
Returns the Preferences Node which can use for position storings.


getIntPos

public static int getIntPos(java.awt.Component comp,
                            java.lang.String extension,
                            int defaultValue)
Returns an int value from the preferences. You can use the extension to store differ values for on component

Parameters:
comp - the component
extension - a value to save different values for the component
defaultValue - the default value
Returns:
the value, if available or the default value
See Also:
setIntPos(Component, String, int)

main

public static void main(java.lang.String[] args)
Implements a test case

Parameters:
args -