agg.attribute.view.impl
Class ViewSetting

java.lang.Object
  extended by agg.attribute.impl.AttrObject
      extended by agg.attribute.impl.ManagedObject
          extended by agg.attribute.view.impl.ViewSetting
All Implemented Interfaces:
AttrViewSetting, Disposable, java.io.Serializable, java.util.Observer
Direct Known Subclasses:
MaskedViewSetting, OpenViewSetting

public abstract class ViewSetting
extends ManagedObject
implements AttrViewSetting

Common superclass for OpenViewSetting and MaskedViewSetting. Provides most routines for handling own observers and event propagation. Most methods that actually manipulate the layout of attribute tuples are in the subclasses mentioned above.

See Also:
Serialized Form

Field Summary
protected  java.util.Hashtable<AttrTuple,java.util.Vector<java.lang.ref.WeakReference<AttrViewObserver>>> observerTab
          Table of observers for tuples.
 
Fields inherited from class agg.attribute.impl.ManagedObject
manager
 
Fields inherited from class agg.attribute.impl.AttrObject
classHandlerExpr, classObject, classString, initialized
 
Constructor Summary
ViewSetting(AttrTupleManager m)
           
 
Method Summary
protected  void addObserverForTuple(AttrViewObserver o, AttrTuple attr)
          Adding an observer for an attribute to its observers' table.
 void dispose()
          Prepare myself for garbage collection.
 void finalize()
           
protected  void fireAttrChanged(TupleObject attr, int id, int slot0, int slot1)
          Called from within this class whenever the format (layout) of an attribute is changed.
protected abstract  TupleFormat getFormat(AttrTuple attr)
          Getting the format for a (type) tuple.
protected  java.util.Vector<java.lang.ref.WeakReference<AttrViewObserver>> getObserversForTuple(AttrTuple attr)
          Getting the observers of a tuple managed in this view.
 void moveSlotAppending(AttrTuple attr, int srcSlot, int destSlot)
          Moves the member at "srcSlot" to "destSlot", appending-wise.
protected  void notifyObservers(AttrTuple attr, int id, int slot0, int slot1)
          Called by fireAttrChanged() from this class.
protected  void propagateAttrEvent(AttrEvent event)
          Propagating incoming attribute events to my view observers.
protected abstract  void removeFormat(AttrType type)
          Removing the format for a (type) tuple.
protected  void removeObserverForTuple(AttrViewObserver o, AttrTuple attr)
          Removing an observer for an attribute from its observers' table.
 java.lang.String toString(AttrTuple attr)
           
 
Methods inherited from class agg.attribute.impl.ManagedObject
getAttrManager, getManager
 
Methods inherited from class agg.attribute.impl.AttrObject
defaultToString, err, err, getInstRepr, log, log, log, logEnteredMethod, logPrintln, logPrintln, stdoutPrintOnEnter, stdoutPrintOnExit, toString, update, warn, warn, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface agg.attribute.view.AttrViewSetting
addObserver, convertIndexToSlot, convertSlotToIndex, getMaskedView, getOpenView, getSize, hasObserver, isVisible, moveSlotInserting, removeObserver, resetTuple, setAllVisible, setVisible, setVisibleAt
 

Field Detail

observerTab

protected transient java.util.Hashtable<AttrTuple,java.util.Vector<java.lang.ref.WeakReference<AttrViewObserver>>> observerTab
Table of observers for tuples.

Constructor Detail

ViewSetting

public ViewSetting(AttrTupleManager m)
Method Detail

dispose

public void dispose()
Description copied from interface: Disposable
Prepare myself for garbage collection.

Specified by:
dispose in interface Disposable

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object

getFormat

protected abstract TupleFormat getFormat(AttrTuple attr)
Getting the format for a (type) tuple. Formats are created lazily "on demand". It means that when there is no format for the specified AttrTuple yet, it is created and returned.


removeFormat

protected abstract void removeFormat(AttrType type)
Removing the format for a (type) tuple.


getObserversForTuple

protected java.util.Vector<java.lang.ref.WeakReference<AttrViewObserver>> getObserversForTuple(AttrTuple attr)
Getting the observers of a tuple managed in this view.

Returns:
A vector of observers for the specified tuple or null if the tuple is not in this view.

addObserverForTuple

protected void addObserverForTuple(AttrViewObserver o,
                                   AttrTuple attr)
Adding an observer for an attribute to its observers' table.


removeObserverForTuple

protected void removeObserverForTuple(AttrViewObserver o,
                                      AttrTuple attr)
Removing an observer for an attribute from its observers' table.


notifyObservers

protected void notifyObservers(AttrTuple attr,
                               int id,
                               int slot0,
                               int slot1)
Called by fireAttrChanged() from this class. The change event is sent only to observers who are interested in the attribute's representation.


fireAttrChanged

protected void fireAttrChanged(TupleObject attr,
                               int id,
                               int slot0,
                               int slot1)
Called from within this class whenever the format (layout) of an attribute is changed. Since the change affects only the attribute type representation, two things are important: 1. Only observers that are interested in the attribute's REPRESENTATION should be notified. This is ensured by the sub-method notifyObservers(). 2. All the observers of attribute types that are attribute instances have to notify THEIR view observers as well. Usually this propagating mechanism is provided by the TupleObject class. But here, it cannot be used (see 1.). Therefore, this method loops over all the observers of 'attr' if it's a type and recursively calls fireAttrChanged() for all the AttrInstance instances among them. The same holds for interfaces.


propagateAttrEvent

protected void propagateAttrEvent(AttrEvent event)
Propagating incoming attribute events to my view observers.


moveSlotAppending

public void moveSlotAppending(AttrTuple attr,
                              int srcSlot,
                              int destSlot)
Description copied from interface: AttrViewSetting
Moves the member at "srcSlot" to "destSlot", appending-wise.

Specified by:
moveSlotAppending in interface AttrViewSetting

toString

public java.lang.String toString(AttrTuple attr)