com.miginfocom.ashape
Class DefaultAShapeProvider

java.lang.Object
  extended by com.miginfocom.ashape.DefaultAShapeProvider
All Implemented Interfaces:
AShapeProvider

public class DefaultAShapeProvider
extends java.lang.Object
implements AShapeProvider

This factory bind a context to a RootAShape.

The context could be anything, including null, and is a contract between the object that asks for a shape and the shape provider. If the provider doesn't recognize the context (its type or value) it should return a value less than zero, which ensures it will not be asked for a ARootShape.

There is a context map for this object and one static context map for the whole JVM. If the context map for this object doesn't contain a map to a RootAShape the static, global, map is quired. If nothing there either the default shape is returned.

If the context isn't recognized the default shape is returned.

See Also:
setShape(com.miginfocom.ashape.shapes.RootAShape, Object)

Constructor Summary
DefaultAShapeProvider()
          Constructor.
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener l)
          Adds a listener that gets notified when something changes in this provider.
 void addChangeListener(javax.swing.event.ChangeListener l, boolean asWeakRef)
          Adds a listener that gets notified when something changes in this provider.
static void addStaticChangeListener(javax.swing.event.ChangeListener l)
          Adds a static listener that gets notified when something changes.
static void addStaticChangeListener(javax.swing.event.ChangeListener l, boolean asWeakRef)
          Adds a static listener that gets notified when something changes.
 boolean fireChanged()
          Fires a structurat change event to the listeners
protected static boolean fireStaticChanged()
          Fires a structurat change event to the listeners
 RootAShape getShape(java.lang.Object context)
          Returns a shape for the context.
 void removeChangeListener(javax.swing.event.ChangeListener l)
          Removes the listener, if it is in the list.
static void removeStaticChangeListener(javax.swing.event.ChangeListener l)
          Removes the listener, if it is in the list.
 void setShape(RootAShape shape, java.lang.Object context)
          Binds a shape to the context in THIS factory
static void setShapeGlobally(RootAShape shape, java.lang.Object context)
          Binds a shape to the context in the global (static) context map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultAShapeProvider

public DefaultAShapeProvider()
Constructor.

Method Detail

getShape

public RootAShape getShape(java.lang.Object context)
Description copied from interface: AShapeProvider
Returns a shape for the context. The returned shape may be shared globally so it should not be changed.

Specified by:
getShape in interface AShapeProvider
Parameters:
context - The context to return the shape for.
Returns:
A shape or null if not able to provide a shape for context.

setShape

public void setShape(RootAShape shape,
                     java.lang.Object context)
Binds a shape to the context in THIS factory

Parameters:
shape - The new default shape.
See Also:
setShapeGlobally(com.miginfocom.ashape.shapes.RootAShape, Object)

setShapeGlobally

public static void setShapeGlobally(RootAShape shape,
                                    java.lang.Object context)
Binds a shape to the context in the global (static) context map. This map will be quired AFTER the local map is checked.

Parameters:
shape - The new default shape. Use null to clear.
See Also:
setShape(com.miginfocom.ashape.shapes.RootAShape, Object)

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l)
Description copied from interface: AShapeProvider
Adds a listener that gets notified when something changes in this provider. Will be added as strong reference.

Specified by:
addChangeListener in interface AShapeProvider
Parameters:
l - The listener. Not null

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l,
                              boolean asWeakRef)
Description copied from interface: AShapeProvider
Adds a listener that gets notified when something changes in this provider.

Specified by:
addChangeListener in interface AShapeProvider
Parameters:
l - The listener. Not null
asWeakRef - If the listener should be added wrapped in a WeakReference. This defers memory leak problems since the garbage collector can collect the listener if it is only referenced from this list.
Note! This (weak reference) can not be used with listeners that doesn't have another real (a.k.a Strong) reference to it, as for instance an annonymous inner class. If one such listener is added it will be removed almost immediately by the garbage collector.

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener l)
Description copied from interface: AShapeProvider
Removes the listener, if it is in the list.

Specified by:
removeChangeListener in interface AShapeProvider
Parameters:
l - The listener to remove, not null.

fireChanged

public boolean fireChanged()
Fires a structurat change event to the listeners

Returns:
If there was any listeners registered.

addStaticChangeListener

public static void addStaticChangeListener(javax.swing.event.ChangeListener l)
Adds a static listener that gets notified when something changes. Will be added as strong reference.

Parameters:
l - The listener. Not null

addStaticChangeListener

public static void addStaticChangeListener(javax.swing.event.ChangeListener l,
                                           boolean asWeakRef)
Adds a static listener that gets notified when something changes.

Parameters:
l - The listener. Not null
asWeakRef - If the listener should be added wrapped in a WeakReference. This defers memory leak problems since the garbage collector can collect the listener if it is only referenced from this list.
Note! This (weak reference) can not be used with listeners that doesn't have another real (a.k.a Strong) reference to it, as for instance an annonymous inner class. If one such listener is added it will be removed almost immediately by the garbage collector.

removeStaticChangeListener

public static void removeStaticChangeListener(javax.swing.event.ChangeListener l)
Removes the listener, if it is in the list.

Parameters:
l - The listener to remove, not null.

fireStaticChanged

protected static boolean fireStaticChanged()
Fires a structurat change event to the listeners

Returns:
If there was any listeners registered.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.