edu.mit.csail.sdg.alloy4viz
Class VizGUI

java.lang.Object
  extended by edu.mit.csail.sdg.alloy4viz.VizGUI
All Implemented Interfaces:
java.awt.event.ComponentListener, java.util.EventListener

public final class VizGUI
extends java.lang.Object
implements java.awt.event.ComponentListener

GUI main window for the visualizer.

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


Constructor Summary
VizGUI(boolean standalone, java.lang.String xmlFileName, javax.swing.JMenu windowmenu)
          Creates a new visualization GUI window; this method can only be called by the AWT event thread.
VizGUI(boolean standalone, java.lang.String xmlFileName, javax.swing.JMenu windowmenu, Computer enumerator, Computer evaluator)
          Creates a new visualization GUI window; this method can only be called by the AWT event thread.
VizGUI(boolean standalone, java.lang.String xmlFileName, javax.swing.JMenu windowmenu, Computer enumerator, Computer evaluator, boolean makeWindow)
          Creates a new visualization GUI window; this method can only be called by the AWT event thread.
 
Method Summary
 void addMinMaxActions(javax.swing.JMenu menu)
          This method inserts "Minimize" and "Maximize" entries into a JMenu.
 void componentHidden(java.awt.event.ComponentEvent e)
          Invoked when the Visualizationwindow is hidden.
 void componentMoved(java.awt.event.ComponentEvent e)
          Invoked when the Visualizationwindow is moved.
 void componentResized(java.awt.event.ComponentEvent e)
          Invoked when the Visualizationwindow is resized.
 void componentShown(java.awt.event.ComponentEvent e)
          Invoked when the Visualizationwindow is shown.
 void doSetFontSize(int fontSize)
          This method changes the font size for everything (except the graph)
 Runner doShowTree()
          This method changes the display mode to show the instance as a tree (the return value is always null).
 Runner doShowTxt()
          This method changes the display mode to show the equivalent dot text (the return value is always null).
 Runner doShowViz()
          This method changes the display mode to show the instance as a graph (the return value is always null).
 ConstList<java.lang.String> getInstances()
          Return the list of XML files loaded in this session so far.
 java.lang.String getInstanceTitle(java.lang.String xmlFileName)
          Returns a short descriptive title associated with an XML file.
 javax.swing.JSplitPane getPanel()
          Returns the JSplitPane containing the customization/evaluator panel in the left and the graph on the right.
 java.lang.String getThemeFilename()
          Returns the current THM filename; "" if no theme file is currently loaded.
 GraphViewer getViewer()
          Returns the GraphViewer that contains the graph; can be null if the graph hasn't been loaded yet.
 VizState getVizState()
          Returns the current visualization settings (and you can call getOriginalInstance() on it to get the current instance).
 java.lang.String getXMLfilename()
          Returns the current XML filename; "" if no file is currently loaded.
 boolean loadThemeFile(java.lang.String filename)
          This method loads a specific theme file.
 void loadXML(java.lang.String fileName, boolean forcefully)
          Load the XML instance.
 boolean saveThemeFile(java.lang.String filename)
          This method saves a specific current theme (if filename==null, it asks the user); returns true if it succeeded.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VizGUI

public VizGUI(boolean standalone,
              java.lang.String xmlFileName,
              javax.swing.JMenu windowmenu)
Creates a new visualization GUI window; this method can only be called by the AWT event thread.

Parameters:
standalone - - whether the JVM should shutdown after the last file is closed
xmlFileName - - the filename of the incoming XML file; "" if there's no file to open
windowmenu - - if standalone==false and windowmenu!=null, then this will be added as a menu on the menubar

Note: if standalone==false and xmlFileName.length()==0, then we will initially hide the window.


VizGUI

public VizGUI(boolean standalone,
              java.lang.String xmlFileName,
              javax.swing.JMenu windowmenu,
              Computer enumerator,
              Computer evaluator)
Creates a new visualization GUI window; this method can only be called by the AWT event thread.

Parameters:
standalone - - whether the JVM should shutdown after the last file is closed
xmlFileName - - the filename of the incoming XML file; "" if there's no file to open
windowmenu - - if standalone==false and windowmenu!=null, then this will be added as a menu on the menubar
enumerator - - if it's not null, it provides solution enumeration ability
evaluator - - if it's not null, it provides solution evaluation ability

Note: if standalone==false and xmlFileName.length()==0, then we will initially hide the window.


VizGUI

public VizGUI(boolean standalone,
              java.lang.String xmlFileName,
              javax.swing.JMenu windowmenu,
              Computer enumerator,
              Computer evaluator,
              boolean makeWindow)
Creates a new visualization GUI window; this method can only be called by the AWT event thread.

Parameters:
standalone - - whether the JVM should shutdown after the last file is closed
xmlFileName - - the filename of the incoming XML file; "" if there's no file to open
windowmenu - - if standalone==false and windowmenu!=null, then this will be added as a menu on the menubar
enumerator - - if it's not null, it provides solution enumeration ability
evaluator - - if it's not null, it provides solution evaluation ability
makeWindow - - if false, then we will only construct the JSplitPane, without making the window

Note: if standalone==false and xmlFileName.length()==0 and makeWindow==true, then we will initially hide the window.

Method Detail

getVizState

public VizState getVizState()
Returns the current visualization settings (and you can call getOriginalInstance() on it to get the current instance). If you make changes to the state, you should call doApply() on the VizGUI object to refresh the screen.


getPanel

public javax.swing.JSplitPane getPanel()
Returns the JSplitPane containing the customization/evaluator panel in the left and the graph on the right.


getThemeFilename

public java.lang.String getThemeFilename()
Returns the current THM filename; "" if no theme file is currently loaded.


getXMLfilename

public java.lang.String getXMLfilename()
Returns the current XML filename; "" if no file is currently loaded.


getInstances

public ConstList<java.lang.String> getInstances()
Return the list of XML files loaded in this session so far.


getInstanceTitle

public java.lang.String getInstanceTitle(java.lang.String xmlFileName)
Returns a short descriptive title associated with an XML file.


componentResized

public void componentResized(java.awt.event.ComponentEvent e)
Invoked when the Visualizationwindow is resized.

Specified by:
componentResized in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
Invoked when the Visualizationwindow is moved.

Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
Invoked when the Visualizationwindow is shown.

Specified by:
componentShown in interface java.awt.event.ComponentListener

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
Invoked when the Visualizationwindow is hidden.

Specified by:
componentHidden in interface java.awt.event.ComponentListener

getViewer

public GraphViewer getViewer()
Returns the GraphViewer that contains the graph; can be null if the graph hasn't been loaded yet.


loadXML

public void loadXML(java.lang.String fileName,
                    boolean forcefully)
Load the XML instance.


loadThemeFile

public boolean loadThemeFile(java.lang.String filename)
This method loads a specific theme file.


saveThemeFile

public boolean saveThemeFile(java.lang.String filename)
This method saves a specific current theme (if filename==null, it asks the user); returns true if it succeeded.


doSetFontSize

public void doSetFontSize(int fontSize)
This method changes the font size for everything (except the graph)


addMinMaxActions

public void addMinMaxActions(javax.swing.JMenu menu)
This method inserts "Minimize" and "Maximize" entries into a JMenu.


doShowViz

public Runner doShowViz()
This method changes the display mode to show the instance as a graph (the return value is always null).


doShowTree

public Runner doShowTree()
This method changes the display mode to show the instance as a tree (the return value is always null).


doShowTxt

public Runner doShowTxt()
This method changes the display mode to show the equivalent dot text (the return value is always null).