mesquite.lib
Class Associable

java.lang.Object
  extended by mesquite.lib.Listened
      extended by mesquite.lib.Attachable
          extended by mesquite.lib.Associable
All Implemented Interfaces:
Annotatable, Commandable, HTMLDescribable, Listable, Listenable, Selectionable
Direct Known Subclasses:
AssociableWithSpecs, MesquiteTree

public abstract class Associable
extends Attachable
implements Commandable, Annotatable, Selectionable

A class that contains serially repeated parts, to each of which may be attached information. For example, a Tree contains many nodes, and information might be attached to each node. A Taxa contains taxons, a CharacterData contains characters, and so on. The purpose of this class is to coordinate this attached ("associated") information. Subclasses include FileElement (and thus CharacterData and Taxa) and Tree.


Field Summary
protected  java.lang.String comment
           
protected  ObjectArray comments
          The object array storing comments (e.g.
protected  int numParts
           
protected  boolean rememberDefaultOrder
           
protected  Bits selected
          The bit field indicating which parts are selected currently.
protected  long versionNumber
          A number recording the version number.
 
Fields inherited from class mesquite.lib.Listened
allListeners, classes, classesNotified, listeners, listenersRemaining, notifications
 
Fields inherited from interface mesquite.lib.HTMLDescribable
verbose
 
Constructor Summary
Associable()
           
Associable(int numParts)
           
 
Method Summary
 boolean addParts(int starting, int num)
           
 boolean anyAssociatedObject(NameReference nRef)
          Returns true iff there is at least one associate object of type nRef
 boolean anySelected()
          Returns whether there are any selected parts
 void clearAllAssociatedBits(NameReference nRef)
           
 boolean contiguousSelection()
          Returns whether there are selected parts that form a contiguous selection
 boolean contiguousSelectionOld()
          Returns whether there are selected parts that form a contiguous selection.
 void copyCurrentToPreviousOrder()
           
 void deassignAllAssociatedLongs(NameReference nRef)
           
 void deassignAssociated()
           
 void deassignAssociated(int node)
           
 void deleteJustAdded()
           
 boolean deleteParts(int starting, int num)
           
 void deselectAll()
          Deselects all parts
 void dispose()
          Disposes this associable
 java.lang.Object doCommand(java.lang.String commandName, java.lang.String arguments, CommandChecker checker)
          For Commandable interface.
 void equalizeParts(Associable other, int otherPart, int part)
           
 void exchangeAssociated(int node1, int node2)
           
 int firstSelected()
          Returns index of first selected part
 java.lang.String getAnnotation()
          Returns the comment (e.g., footnote) of this element
 java.lang.String getAnnotation(int part)
          Returns whether the part is selected
 boolean getAssociatedBit(NameReference nRef, int index)
           
 Bits getAssociatedBits(int index)
           
 double getAssociatedDouble(NameReference nRef, int index)
           
 DoubleArray getAssociatedDoubles(int index)
           
 long getAssociatedLong(NameReference nRef, int index)
           
 LongArray getAssociatedLongs(int index)
           
 java.lang.Object getAssociatedObject(NameReference nRef, int index)
           
 ObjectArray getAssociatedObjects(int index)
           
 int getDefaultPosition(int part)
           
 boolean getDirty()
          Returns whether the element is dirty (changed since last file save) or not
 boolean getJustAdded(int part)
           
 int getNumberAssociatedBits()
           
 int getNumberAssociatedDoubles()
           
 int getNumberAssociatedLongs()
           
 int getNumberAssociatedObjects()
           
 int getNumberOfParts()
           
 int getNumberOfSelectableParts()
          Returns number of parts that can be selected
 boolean getSelected(int part)
          Returns whether the part is selected
 Bits getSelectedBits()
          Returns selected directly
 Snapshot getSnapshot(MesquiteFile file)
           
 long getVersionNumber()
          Returns version number of Associable.
 Bits getWhichAssociatedBits(NameReference nRef)
           
 DoubleArray getWhichAssociatedDouble(NameReference nRef)
           
 LongArray getWhichAssociatedLong(NameReference nRef)
           
 ObjectArray getWhichAssociatedObject(NameReference nRef)
           
protected  boolean inBounds(int part)
          Returns true if part is within bounds.
 int lastSelected()
          Returns index of last selected part
 java.lang.String listAssociates()
           
 NameReference makeAssociatedBits(java.lang.String name)
           
 NameReference makeAssociatedDoubles(java.lang.String name)
           
 NameReference makeAssociatedLongs(java.lang.String name)
           
 NameReference makeAssociatedObjects(java.lang.String name)
           
 boolean moveParts(int starting, int num, int justAfter)
           
 int numberSelected()
          Returns number of selected parts
 int numberSelected(boolean onlyCountSelected)
          returns number of parts that are selected or, if onlyCountSelected is false, all parts
 void readAssociated(java.lang.String assocString, int node, MesquiteInteger pos)
           
 void recordCurrentOrder()
           
protected  void recordDefaultOrder()
           
 void recordPreviousOrder()
           
 void removeAssociatedBits(NameReference nRef)
           
 void removeAssociatedDoubles(NameReference nRef)
           
 void removeAssociatedLongs(NameReference nRef)
           
 void removeAssociatedObjects(NameReference nRef)
           
 void resetDefaultOrderToCurrent()
           
 void resetJustAdded()
           
 void restoreToPreviousOrder()
           
 void selectAll()
          Selects all parts
 void setAnnotation(int part, java.lang.String comment)
          Sets the comment for a part
 void setAnnotation(java.lang.String e, boolean notify)
          Sets the comment (e.g., footnote) of this element
 void setAssociatedBit(NameReference nRef, int index, boolean value)
           
 void setAssociatedDouble(NameReference nRef, int index, double value)
           
 void setAssociatedLong(NameReference nRef, int index, long value)
           
 void setAssociatedObject(NameReference nRef, int index, java.lang.Object value)
           
 void setAssociateds(Associable a)
           
 void setDefaultPosition(int part, int position)
           
 void setDirty(boolean d)
          Sets the element as dirty (changed since last file save) or not
 void setJustAdded(int part, boolean b)
           
 void setNumberOfParts(int num)
          Set the number of parts to given number.
 void setSelected(int part, boolean select)
          Sets whether or not the part is selected
 boolean swapParts(int first, int second)
           
 java.lang.String toHTMLStringDescription()
           
 void transferAssociated(int fromNode, int toNode)
           
 java.lang.String writeAssociated(int node, boolean associatedUseComments)
           
 void zeroAllAssociatedDoubles(NameReference nRef)
           
 void zeroAllAssociatedLongs(NameReference nRef)
           
 void zeroAllAssociatedObjects(NameReference nRef)
           
 
Methods inherited from class mesquite.lib.Attachable
anyAttachments, attach, attachIfUniqueName, detach, getAttachment, getAttachment, getAttachments, listAttachments, readAttachments, setAttachments, writeAttachments
 
Methods inherited from class mesquite.lib.Listened
addListener, addListenerHighPriority, amIListening, decrementNotifySuppress, doAfterNotify, getRemainingListeners, incrementNotifySuppress, listListeners, notifyDisposing, notifyListeners, notifyListeners, removeListener, reportListeners, setDumpNotified
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface mesquite.lib.Listable
getName
 
Methods inherited from interface mesquite.lib.Listenable
addListener, addListenerHighPriority, amIListening, decrementNotifySuppress, incrementNotifySuppress, listListeners, notifyListeners, removeListener
 

Field Detail

numParts

protected int numParts

rememberDefaultOrder

protected boolean rememberDefaultOrder

versionNumber

protected long versionNumber
A number recording the version number. With every change of the object, the version number is incremented. Used now for trees and taxa.


comment

protected java.lang.String comment

selected

protected Bits selected
The bit field indicating which parts are selected currently. This is instantiated only if needed.


comments

protected ObjectArray comments
The object array storing comments (e.g. footnotes) for each of the parts. This is instantiated only if needed.

Constructor Detail

Associable

public Associable(int numParts)

Associable

public Associable()
Method Detail

dispose

public void dispose()
Disposes this associable

Overrides:
dispose in class Attachable

toHTMLStringDescription

public java.lang.String toHTMLStringDescription()
Specified by:
toHTMLStringDescription in interface HTMLDescribable
Overrides:
toHTMLStringDescription in class Attachable

equalizeParts

public void equalizeParts(Associable other,
                          int otherPart,
                          int part)

setJustAdded

public void setJustAdded(int part,
                         boolean b)

getJustAdded

public boolean getJustAdded(int part)

resetJustAdded

public void resetJustAdded()

deleteJustAdded

public void deleteJustAdded()

recordDefaultOrder

protected void recordDefaultOrder()

recordCurrentOrder

public void recordCurrentOrder()

recordPreviousOrder

public void recordPreviousOrder()

copyCurrentToPreviousOrder

public void copyCurrentToPreviousOrder()

getVersionNumber

public long getVersionNumber()
Returns version number of Associable. Version number should be incremented with each change.


getNumberOfParts

public int getNumberOfParts()

getSnapshot

public Snapshot getSnapshot(MesquiteFile file)

doCommand

public java.lang.Object doCommand(java.lang.String commandName,
                                  java.lang.String arguments,
                                  CommandChecker checker)
For Commandable interface. TODO: have setDouble and pass part; have getDouble and pass part. Likewise for long, etc.

Specified by:
doCommand in interface Commandable

setAnnotation

public void setAnnotation(java.lang.String e,
                          boolean notify)
Sets the comment (e.g., footnote) of this element

Specified by:
setAnnotation in interface Annotatable

getAnnotation

public java.lang.String getAnnotation()
Returns the comment (e.g., footnote) of this element

Specified by:
getAnnotation in interface Annotatable

setDirty

public void setDirty(boolean d)
Sets the element as dirty (changed since last file save) or not


getDirty

public boolean getDirty()
Returns whether the element is dirty (changed since last file save) or not


inBounds

protected boolean inBounds(int part)
Returns true if part is within bounds.


listAssociates

public java.lang.String listAssociates()

writeAssociated

public java.lang.String writeAssociated(int node,
                                        boolean associatedUseComments)

readAssociated

public void readAssociated(java.lang.String assocString,
                           int node,
                           MesquiteInteger pos)

setAssociateds

public void setAssociateds(Associable a)

transferAssociated

public void transferAssociated(int fromNode,
                               int toNode)

exchangeAssociated

public void exchangeAssociated(int node1,
                               int node2)

deassignAssociated

public void deassignAssociated(int node)

deassignAssociated

public void deassignAssociated()

setNumberOfParts

public void setNumberOfParts(int num)
Set the number of parts to given number. THIS MUST BE CALLED whenever the number of parts (characters, nodes, etc.) changes.


addParts

public boolean addParts(int starting,
                        int num)

deleteParts

public boolean deleteParts(int starting,
                           int num)

moveParts

public boolean moveParts(int starting,
                         int num,
                         int justAfter)

restoreToPreviousOrder

public void restoreToPreviousOrder()

swapParts

public boolean swapParts(int first,
                         int second)

getDefaultPosition

public int getDefaultPosition(int part)

setDefaultPosition

public void setDefaultPosition(int part,
                               int position)

resetDefaultOrderToCurrent

public void resetDefaultOrderToCurrent()

setAnnotation

public void setAnnotation(int part,
                          java.lang.String comment)
Sets the comment for a part


getAnnotation

public java.lang.String getAnnotation(int part)
Returns whether the part is selected


getNumberOfSelectableParts

public int getNumberOfSelectableParts()
Returns number of parts that can be selected

Specified by:
getNumberOfSelectableParts in interface Selectionable

setSelected

public void setSelected(int part,
                        boolean select)
Sets whether or not the part is selected

Specified by:
setSelected in interface Selectionable

getSelected

public boolean getSelected(int part)
Returns whether the part is selected

Specified by:
getSelected in interface Selectionable

deselectAll

public void deselectAll()
Deselects all parts

Specified by:
deselectAll in interface Selectionable

selectAll

public void selectAll()
Selects all parts

Specified by:
selectAll in interface Selectionable

firstSelected

public int firstSelected()
Returns index of first selected part


lastSelected

public int lastSelected()
Returns index of last selected part


getSelectedBits

public Bits getSelectedBits()
Returns selected directly


contiguousSelection

public boolean contiguousSelection()
Returns whether there are selected parts that form a contiguous selection


contiguousSelectionOld

public boolean contiguousSelectionOld()
Returns whether there are selected parts that form a contiguous selection. VERY SLOW.


anySelected

public boolean anySelected()
Returns whether there are any selected parts

Specified by:
anySelected in interface Selectionable

numberSelected

public int numberSelected()
Returns number of selected parts

Specified by:
numberSelected in interface Selectionable

numberSelected

public int numberSelected(boolean onlyCountSelected)
returns number of parts that are selected or, if onlyCountSelected is false, all parts


getNumberAssociatedBits

public int getNumberAssociatedBits()

getAssociatedBits

public Bits getAssociatedBits(int index)

makeAssociatedBits

public NameReference makeAssociatedBits(java.lang.String name)

removeAssociatedBits

public void removeAssociatedBits(NameReference nRef)

getWhichAssociatedBits

public Bits getWhichAssociatedBits(NameReference nRef)

clearAllAssociatedBits

public void clearAllAssociatedBits(NameReference nRef)

setAssociatedBit

public void setAssociatedBit(NameReference nRef,
                             int index,
                             boolean value)

getAssociatedBit

public boolean getAssociatedBit(NameReference nRef,
                                int index)

getNumberAssociatedLongs

public int getNumberAssociatedLongs()

getAssociatedLongs

public LongArray getAssociatedLongs(int index)

makeAssociatedLongs

public NameReference makeAssociatedLongs(java.lang.String name)

removeAssociatedLongs

public void removeAssociatedLongs(NameReference nRef)

getWhichAssociatedLong

public LongArray getWhichAssociatedLong(NameReference nRef)

deassignAllAssociatedLongs

public void deassignAllAssociatedLongs(NameReference nRef)

zeroAllAssociatedLongs

public void zeroAllAssociatedLongs(NameReference nRef)

setAssociatedLong

public void setAssociatedLong(NameReference nRef,
                              int index,
                              long value)

getAssociatedLong

public long getAssociatedLong(NameReference nRef,
                              int index)

getNumberAssociatedDoubles

public int getNumberAssociatedDoubles()

getAssociatedDoubles

public DoubleArray getAssociatedDoubles(int index)

makeAssociatedDoubles

public NameReference makeAssociatedDoubles(java.lang.String name)

removeAssociatedDoubles

public void removeAssociatedDoubles(NameReference nRef)

getWhichAssociatedDouble

public DoubleArray getWhichAssociatedDouble(NameReference nRef)

zeroAllAssociatedDoubles

public void zeroAllAssociatedDoubles(NameReference nRef)

setAssociatedDouble

public void setAssociatedDouble(NameReference nRef,
                                int index,
                                double value)

getAssociatedDouble

public double getAssociatedDouble(NameReference nRef,
                                  int index)

getNumberAssociatedObjects

public int getNumberAssociatedObjects()

getAssociatedObjects

public ObjectArray getAssociatedObjects(int index)

makeAssociatedObjects

public NameReference makeAssociatedObjects(java.lang.String name)

removeAssociatedObjects

public void removeAssociatedObjects(NameReference nRef)

getWhichAssociatedObject

public ObjectArray getWhichAssociatedObject(NameReference nRef)

zeroAllAssociatedObjects

public void zeroAllAssociatedObjects(NameReference nRef)

setAssociatedObject

public void setAssociatedObject(NameReference nRef,
                                int index,
                                java.lang.Object value)

getAssociatedObject

public java.lang.Object getAssociatedObject(NameReference nRef,
                                            int index)

anyAssociatedObject

public boolean anyAssociatedObject(NameReference nRef)
Returns true iff there is at least one associate object of type nRef