edu.mit.csail.sdg.alloy4viz
Class VizState

java.lang.Object
  extended by edu.mit.csail.sdg.alloy4viz.VizState

public final class VizState
extends java.lang.Object

Mutable; this stores an unprojected model as well as the current theme customization.

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


Nested Class Summary
 class VizState.MInt
           
 class VizState.MMap<T>
           
 class VizState.MString
           
 
Field Summary
 VizState.MMap<java.lang.Boolean> attribute
           
 VizState.MMap<java.lang.Boolean> constraint
           
 VizState.MMap<DotColor> edgeColor
           
 VizState.MMap<DotStyle> edgeStyle
           
 VizState.MMap<java.lang.Boolean> edgeVisible
           
 VizState.MMap<java.lang.Boolean> hideUnconnected
           
 VizState.MString label
           
 VizState.MMap<java.lang.Boolean> layoutBack
           
 VizState.MMap<java.lang.Boolean> mergeArrows
           
 VizState.MMap<DotColor> nodeColor
           
 VizState.MMap<DotStyle> nodeStyle
           
 VizState.MMap<java.lang.Boolean> nodeVisible
           
 VizState.MMap<java.lang.Boolean> number
           
 VizState.MMap<DotShape> shape
           
 VizState.MMap<java.lang.Boolean> showAsAttr
           
 VizState.MMap<java.lang.Boolean> showAsLabel
           
 VizState.MInt weight
           
 
Constructor Summary
VizState(AlloyInstance originalInstance)
          Construct a new VizState (with default theme settings) for the given instance; if world!=null, it is the root of the AST.
VizState(VizState old)
          Make a copy of an existing VizState object.
 
Method Summary
 boolean canProject(AlloyType type)
          Returns true iff the type is not univ, and it is a toplevel type.
 boolean changedSinceLastSave()
          True if the theme has been modified since last save.
 void deproject(AlloyType type)
          Removes type from the list of projected types if it is currently projected.
 void deprojectAll()
          Removes every entry from the list of projected types.
 AlloyModel getCurrentModel()
          Returns the current (possibly projected) model.
 DotPalette getEdgePalette()
          Gets the default edge palette.
 int getFontSize()
          Returns the font size.
 javax.swing.JPanel getGraph(AlloyProjection projectionChoice)
          Generate a VizGraphPanel for a given projection choice, using the current settings.
 DotPalette getNodePalette()
          Gets the default node palette.
 AlloyInstance getOriginalInstance()
          Returns the original unprojected model.
 AlloyModel getOriginalModel()
          Returns the original unprojected model.
 ConstSet<AlloyType> getProjectedTypes()
          Gets an unmodifiable copy of the set of types we are currently projecting over.
 boolean hideMeta()
          Returns whether we will hide meta sigs/fields/relations.
 void hideMeta(java.lang.Boolean newValue)
          Sets whether we will hide meta sigs/fields/relations.
 boolean hidePrivate()
          Returns whether we will hide private sigs/fields/relations.
 void hidePrivate(java.lang.Boolean newValue)
          Sets whether we will hide private sigs/fields/relations.
 boolean isTopLevel(AlloyType type)
          Returns true iff the type is not univ, and it is a toplevel type.
 void loadInstance(AlloyInstance unprojectedInstance)
          Load a new instance into this VizState object (the input argument is treated as a new unprojected instance); if world!=null, it is the root of the AST
 void loadPaletteXML(java.lang.String filename)
          Erase the current theme customizations and then load it from a file.
 DotColor nodeColor(AlloyAtom a, AlloyInstance i)
           
 DotStyle nodeStyle(AlloyAtom a, AlloyInstance i)
           
 boolean nodeVisible(AlloyAtom a, AlloyInstance i)
           
 void project(AlloyType type)
          Adds type to the list of projected types if it's a toplevel type.
 void resetTheme()
          Clears the current theme.
 void savePaletteXML(java.lang.String filename)
          Saves the current theme to a file (which will be overwritten if it exists already).
 void setEdgePalette(DotPalette x)
          Sets the default edge palette.
 void setFontSize(int n)
          Sets the font size.
 void setNodePalette(DotPalette x)
          Sets the default node palette.
 DotShape shape(AlloyAtom a, AlloyInstance i)
           
 boolean useOriginalName()
          Returns whether we will use original atom names.
 void useOriginalName(java.lang.Boolean newValue)
          Sets whether we will use original atom names or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

weight

public final VizState.MInt weight

label

public final VizState.MString label

nodeColor

public final VizState.MMap<DotColor> nodeColor

edgeColor

public final VizState.MMap<DotColor> edgeColor

nodeStyle

public final VizState.MMap<DotStyle> nodeStyle

edgeStyle

public final VizState.MMap<DotStyle> edgeStyle

shape

public final VizState.MMap<DotShape> shape

attribute

public final VizState.MMap<java.lang.Boolean> attribute

mergeArrows

public final VizState.MMap<java.lang.Boolean> mergeArrows

constraint

public final VizState.MMap<java.lang.Boolean> constraint

layoutBack

public final VizState.MMap<java.lang.Boolean> layoutBack

edgeVisible

public final VizState.MMap<java.lang.Boolean> edgeVisible

nodeVisible

public final VizState.MMap<java.lang.Boolean> nodeVisible

number

public final VizState.MMap<java.lang.Boolean> number

hideUnconnected

public final VizState.MMap<java.lang.Boolean> hideUnconnected

showAsAttr

public final VizState.MMap<java.lang.Boolean> showAsAttr

showAsLabel

public final VizState.MMap<java.lang.Boolean> showAsLabel
Constructor Detail

VizState

public VizState(AlloyInstance originalInstance)
Construct a new VizState (with default theme settings) for the given instance; if world!=null, it is the root of the AST.


VizState

public VizState(VizState old)
Make a copy of an existing VizState object.

Method Detail

resetTheme

public void resetTheme()
Clears the current theme.


loadInstance

public void loadInstance(AlloyInstance unprojectedInstance)
Load a new instance into this VizState object (the input argument is treated as a new unprojected instance); if world!=null, it is the root of the AST


loadPaletteXML

public void loadPaletteXML(java.lang.String filename)
                    throws java.io.IOException
Erase the current theme customizations and then load it from a file.

Throws:
java.io.IOException - - if an error occurred

savePaletteXML

public void savePaletteXML(java.lang.String filename)
                    throws java.io.IOException
Saves the current theme to a file (which will be overwritten if it exists already).

Throws:
java.io.IOException - - if an error occurred

getGraph

public javax.swing.JPanel getGraph(AlloyProjection projectionChoice)
Generate a VizGraphPanel for a given projection choice, using the current settings.


changedSinceLastSave

public boolean changedSinceLastSave()
True if the theme has been modified since last save.


getOriginalInstance

public AlloyInstance getOriginalInstance()
Returns the original unprojected model.


getOriginalModel

public AlloyModel getOriginalModel()
Returns the original unprojected model.


getCurrentModel

public AlloyModel getCurrentModel()
Returns the current (possibly projected) model.


getProjectedTypes

public ConstSet<AlloyType> getProjectedTypes()
Gets an unmodifiable copy of the set of types we are currently projecting over.


canProject

public boolean canProject(AlloyType type)
Returns true iff the type is not univ, and it is a toplevel type.


isTopLevel

public boolean isTopLevel(AlloyType type)
Returns true iff the type is not univ, and it is a toplevel type.


project

public void project(AlloyType type)
Adds type to the list of projected types if it's a toplevel type.


deproject

public void deproject(AlloyType type)
Removes type from the list of projected types if it is currently projected.


deprojectAll

public void deprojectAll()
Removes every entry from the list of projected types.


useOriginalName

public boolean useOriginalName()
Returns whether we will use original atom names.


useOriginalName

public void useOriginalName(java.lang.Boolean newValue)
Sets whether we will use original atom names or not.


hidePrivate

public boolean hidePrivate()
Returns whether we will hide private sigs/fields/relations.


hidePrivate

public void hidePrivate(java.lang.Boolean newValue)
Sets whether we will hide private sigs/fields/relations.


hideMeta

public boolean hideMeta()
Returns whether we will hide meta sigs/fields/relations.


hideMeta

public void hideMeta(java.lang.Boolean newValue)
Sets whether we will hide meta sigs/fields/relations.


getFontSize

public int getFontSize()
Returns the font size.


setFontSize

public void setFontSize(int n)
Sets the font size.


getNodePalette

public DotPalette getNodePalette()
Gets the default node palette.


setNodePalette

public void setNodePalette(DotPalette x)
Sets the default node palette.


getEdgePalette

public DotPalette getEdgePalette()
Gets the default edge palette.


setEdgePalette

public void setEdgePalette(DotPalette x)
Sets the default edge palette.


nodeColor

public DotColor nodeColor(AlloyAtom a,
                          AlloyInstance i)

nodeStyle

public DotStyle nodeStyle(AlloyAtom a,
                          AlloyInstance i)

shape

public DotShape shape(AlloyAtom a,
                      AlloyInstance i)

nodeVisible

public boolean nodeVisible(AlloyAtom a,
                           AlloyInstance i)