edu.mit.csail.sdg.alloy4viz
Class AlloyAtom

java.lang.Object
  extended by edu.mit.csail.sdg.alloy4viz.AlloyAtom
All Implemented Interfaces:
java.lang.Comparable<AlloyAtom>

public final class AlloyAtom
extends java.lang.Object
implements java.lang.Comparable<AlloyAtom>

Immutable; represents an Alloy atom in an instance.

Thread Safety: Can be called only by the AWT event thread.


Constructor Summary
AlloyAtom(AlloyType type, int index)
          Create a new AlloyAtom with the given type and index.
AlloyAtom(AlloyType type, int index, java.lang.String originalName)
          Create a new AlloyAtom with the given type, index, and label.
 
Method Summary
 int compareTo(AlloyAtom otherAtom)
          Compare first by type, then by index, then by the original names.
 boolean equals(java.lang.Object other)
          Two AlloyAtoms are equal if they have the same type, same index, and same original name.
 AlloyType getType()
          Return the type of the AlloyAtom.
 java.lang.String getVizName(VizState theme, boolean numberAtoms)
          Return a label for this atom as recommended by a theme (theme can be null if there's no theme to consult).
 int hashCode()
          Returns a hash code based on the type and index.
 java.lang.String toString()
          Provides a human-readable label for debugging purpose.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AlloyAtom

public AlloyAtom(AlloyType type,
                 int index)
Create a new AlloyAtom with the given type and index.


AlloyAtom

public AlloyAtom(AlloyType type,
                 int index,
                 java.lang.String originalName)
Create a new AlloyAtom with the given type, index, and label.

Method Detail

getVizName

public java.lang.String getVizName(VizState theme,
                                   boolean numberAtoms)
Return a label for this atom as recommended by a theme (theme can be null if there's no theme to consult).


getType

public AlloyType getType()
Return the type of the AlloyAtom.


toString

public java.lang.String toString()
Provides a human-readable label for debugging purpose.

Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(AlloyAtom otherAtom)
Compare first by type, then by index, then by the original names.
We guarantee x.equals(y) iff x.compareTo(y)==0

As a special cosmetic enhancement: if we're comparing integer atoms, we want to ignore the difference between seqInt and Int.

Specified by:
compareTo in interface java.lang.Comparable<AlloyAtom>

equals

public boolean equals(java.lang.Object other)
Two AlloyAtoms are equal if they have the same type, same index, and same original name.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Returns a hash code based on the type and index.

Overrides:
hashCode in class java.lang.Object