gumbo.visualize.data.impl.swing
Class SwingDataProxy

java.lang.Object
  |
  +--gumbo.util.AbstractDisposable
        |
        +--gumbo.visualize.data.impl.swing.SwingDataProxy
All Implemented Interfaces:
DataModelListener, Disposable, Graphic, GraphicPresence, GraphicResource, GraphicView, InteractableGraphic, Interactor
Direct Known Subclasses:
SwingTreeNode

public abstract class SwingDataProxy
extends AbstractDisposable
implements GraphicView, InteractableGraphic, DataModelListener

A GraphicView intended for use as a non-spatial proxy for a displayable shape, such as for use by a Swing cell renderer (see JTree, JList). Includes capabilities for interaction feedback and global consistency management (see ConsistencyManager.getGlobalConsistencyManager()). Also includes support for automatically updating a graphic label if the associated data model's client data changes.

Version:
$Revision: 1.1 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.

Constructor Summary
SwingDataProxy(PartView view)
          Creates an instance.
 
Method Summary
 void clientDataChanged(java.lang.Object source, DataModel target)
          Default implementation: If getAutoLabel() is null or the client data is unknown, nothing happens; otherwise, calls getAutoLabel().clientDataChanged(), then updateFeedback().
protected  ClientLabelGraphic getAutoLabel()
          Called by the system to get this graphic view's label, which will be automatically updated if the associated data model's client data changes and is recognized (see clientDataChanged()).
 DataView getDataView()
          Gets the data view implemented by this graphic view.
 java.lang.Object getGraphic()
          Returns this object because no native graphic is involved since realization is handled by the whole view graphic.
 InteractorState getInteractorState()
          Gets the interactor state value for this interactor.
protected  void implDispose()
          Removes this from the consistency and data model managers, then disposes the super.
protected  SwingDataProxy initSwingDataProxy(LabelGraphic label)
          Used by subclasses and serialization to initialize this object, including its label.
 void prepareGraphicPresence()
          Default implementation: Does nothing.
 void realizeGraphicPresence()
          Does nothing because realization is handled by the whole view graphic.
protected  void updateFeedback()
          Called by the system to prepare and realize the graphic's interaction feedback according to the current interaction state.
 
Methods inherited from class gumbo.util.AbstractDisposable
dispose, isDisposed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gumbo.util.Disposable
dispose, isDisposed
 

Constructor Detail

SwingDataProxy

public SwingDataProxy(PartView view)
Creates an instance. Must call initSwingDataProxy() before using this object. Should call updateFeedback() at end of subclass init.

Throws:
java.lang.IllegalStateException - getGraphic() is not a JComponent.
Method Detail

initSwingDataProxy

protected final SwingDataProxy initSwingDataProxy(LabelGraphic label)
Used by subclasses and serialization to initialize this object, including its label. Throws an exception if the label is different from the initial one.

Parameters:
label - Reference to the label. Null if none.
Returns:
Reference to this object (which facilitates inline construction). Never null.

updateFeedback

protected void updateFeedback()
Called by the system to prepare and realize the graphic's interaction feedback according to the current interaction state. Typically, color is used in a feedback presentation (see DataFeedback.feedbackColor(). Default implementation: Does nothing.


getAutoLabel

protected final ClientLabelGraphic getAutoLabel()
Called by the system to get this graphic view's label, which will be automatically updated if the associated data model's client data changes and is recognized (see clientDataChanged()).

Returns:
Reference to the label. Null if none.

clientDataChanged

public void clientDataChanged(java.lang.Object source,
                              DataModel target)
Default implementation: If getAutoLabel() is null or the client data is unknown, nothing happens; otherwise, calls getAutoLabel().clientDataChanged(), then updateFeedback().

Specified by:
clientDataChanged in interface DataModelListener
Parameters:
source - The source object sending the event. Never null.
target - The affected data model. Never null.

getInteractorState

public InteractorState getInteractorState()
Description copied from interface: Interactor
Gets the interactor state value for this interactor.

Specified by:
getInteractorState in interface Interactor
Returns:
Reference to the interactor state. Never null.

getDataView

public DataView getDataView()
Description copied from interface: GraphicView
Gets the data view implemented by this graphic view.

Specified by:
getDataView in interface GraphicView
Returns:
Reference to the data view. Never null.

prepareGraphicPresence

public void prepareGraphicPresence()
Default implementation: Does nothing.

Specified by:
prepareGraphicPresence in interface GraphicPresence

realizeGraphicPresence

public void realizeGraphicPresence()
Does nothing because realization is handled by the whole view graphic.

Specified by:
realizeGraphicPresence in interface GraphicPresence

getGraphic

public java.lang.Object getGraphic()
Returns this object because no native graphic is involved since realization is handled by the whole view graphic.

Specified by:
getGraphic in interface Graphic
Returns:
The target graphic object. Possibly this object (self-proxy, direct implementation), but never null.

implDispose

protected void implDispose()
Removes this from the consistency and data model managers, then disposes the super.

Specified by:
implDispose in class AbstractDisposable