org.graffiti.editor
Class GraffitiSingleton

java.lang.Object
  extended by org.graffiti.editor.GraffitiSingleton

public class GraffitiSingleton
extends Object

Provides access to global variables, needed for various extensions to Graffiti. Plugins can use the Preferences structure to save settings.


Field Summary
static String COPYRIGHT_NOTICE
          Gravisto's copyright notice.
 Object selectionSyncObject
          DOCUMENT ME!
 
Constructor Summary
GraffitiSingleton()
           
 
Method Summary
 void addErrorMessage(String errorMsg)
          Adds a errorMessage to a global list.
 void addFrame(GraffitiInternalFrame frame)
          Adds a new internal frame to the list of pattern editor frames.
 void addPatternSession(Session session)
          Adds a Session to the list of patternSessions.
 void clearErrorMessages()
          Removes the current error messages.
 void framesDeselect()
          Unselects all editor frames in the main view.
 Algorithm getAlgorithmInstanceFromFriendlyName(String name)
          Returns a algorithm instance, defined by its name (e.g.
 String[] getErrorMessages()
          Returns pending error messages that were not shown to the user immediatly.
static GraffitiSingleton getInstance()
          Returns the single instance of this class.
 MainFrame getMainFrame()
          Returns the main frame (application window).
 Vector<Graph> getMainGraphs()
          Returns a Vector which contains a list of graphs from the main view.
 Vector<Session> getMainSessions()
          Returns a Vector which contains a list of sessions, loaded in the main view.
 Vector<Graph> getPatternGraphs()
          Returns a Vector which contains a list of pattern graphs.
 List<Session> getPatternSessionList()
          A List of the pattern sessions.
 DefaultPluginEntry getPluginInstanceFromPluginDescription(String pluginDescription)
          Returns a plugin instance, given by its classname.
 boolean isEditorFrameSelected()
          Checks if an editor frame in the main view is selected.
 boolean pluginSelectionMoveAllowed()
          A global variable, for communication between the IPK Editing Tools and some IPK Layouter.
 void pluginSetMoveAllowed(boolean value)
          A global variable, for communication between the IPK Editing Tools and some IPK Layouter.
 void reportError(Logger logger, String errorMessage)
          Write an error message to the console and add an entry to the logger.
static void runAlgorithm(Algorithm algorithm)
           
 String runPlugin(String pluginNameOrClassName, Graph g)
          Starts a plugin and returns, as soon as the plugin execution has finished.
 void setMainFrame(MainFrame mainFrame)
          Memorize the main frame.
static boolean showParameterDialog(Parametrizable parametrizable)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

selectionSyncObject

public volatile Object selectionSyncObject
DOCUMENT ME!


COPYRIGHT_NOTICE

public static final String COPYRIGHT_NOTICE
Gravisto's copyright notice.

Constructor Detail

GraffitiSingleton

public GraffitiSingleton()
Method Detail

getInstance

public static GraffitiSingleton getInstance()
Returns the single instance of this class.

Returns:
The single instance of this "Singleton".

pluginSelectionMoveAllowed

public boolean pluginSelectionMoveAllowed()
A global variable, for communication between the IPK Editing Tools and some IPK Layouter. This will be later eventually be removed.

Returns:
If value is true, the selection should not be moved by the layouter algorithms.

pluginSetMoveAllowed

public void pluginSetMoveAllowed(boolean value)
A global variable, for communication between the IPK Editing Tools and some IPK Layouter. This will be later eventually be removed.

Parameters:
value - set to true, if the selection should not be moved by the layouter algorithms.

setMainFrame

public void setMainFrame(MainFrame mainFrame)
Memorize the main frame.

Parameters:
mainFrame - The main frame.

getMainSessions

public Vector<Session> getMainSessions()
Returns a Vector which contains a list of sessions, loaded in the main view.

Returns:
Vector with elements of the type EditorSession. Returns empty Vector, if no sessions are loaded.

getPatternSessionList

public List<Session> getPatternSessionList()
A List of the pattern sessions. PatternSessions are sessions, which are loaded in the pattern tab.

Returns:
The pattern sessions.

getMainFrame

public MainFrame getMainFrame()
Returns the main frame (application window).

Returns:
The main frame.

getMainGraphs

public Vector<Graph> getMainGraphs()
Returns a Vector which contains a list of graphs from the main view.

Returns:
Vector with elements of the type Graph.

getPatternGraphs

public Vector<Graph> getPatternGraphs()
Returns a Vector which contains a list of pattern graphs.

Returns:
Vector with elements of the type Graph. If no patterns are loaded or available, this method returns an empty Vector.

addFrame

public void addFrame(GraffitiInternalFrame frame)
Adds a new internal frame to the list of pattern editor frames. Can be used by the method isEditorFrameSelected for the decission, whether a given frame is a editor frame or a pattern editor frame.

Parameters:
frame - New pattern editor frame.

addPatternSession

public void addPatternSession(Session session)
Adds a Session to the list of patternSessions. This method is called by the patternInspector in the action handler for the load and new button action.

Parameters:
session - The new session, which should be known as a session, containing a pattern graph.

isEditorFrameSelected

public boolean isEditorFrameSelected()
Checks if an editor frame in the main view is selected.

Returns:
True, if an editor frame is selected.

framesDeselect

public void framesDeselect()
Unselects all editor frames in the main view.


getAlgorithmInstanceFromFriendlyName

public Algorithm getAlgorithmInstanceFromFriendlyName(String name)
Returns a algorithm instance, defined by its name (e.g. menu item text)

Parameters:
name - The menu item text.
Returns:
The algorithm instance.

getPluginInstanceFromPluginDescription

public DefaultPluginEntry getPluginInstanceFromPluginDescription(String pluginDescription)
Returns a plugin instance, given by its classname.

Parameters:
pluginDescription -
Returns:
The plugin instance, if the plugin is loaded.

runPlugin

public String runPlugin(String pluginNameOrClassName,
                        Graph g)
Starts a plugin and returns, as soon as the plugin execution has finished.

Parameters:
pluginNameOrClassName - of Algorithm to execute or Menu Item Text (from PluginMenu or Context Menu) or Classname of Plugin.
g - Graph instance the plugin should work with.
Returns:
Empty String if success, otherwise Error message

showParameterDialog

public static boolean showParameterDialog(Parametrizable parametrizable)

runAlgorithm

public static void runAlgorithm(Algorithm algorithm)

reportError

public void reportError(Logger logger,
                        String errorMessage)
Write an error message to the console and add an entry to the logger.

Parameters:
logger -
errorMessage -

addErrorMessage

public void addErrorMessage(String errorMsg)
Adds a errorMessage to a global list. The error messages can be retreived with getErrorMessages and cleared with clearErrorMessages.

Parameters:
errorMsg -

clearErrorMessages

public void clearErrorMessages()
Removes the current error messages. E.g. after showing them to the user.


getErrorMessages

public String[] getErrorMessages()
Returns pending error messages that were not shown to the user immediatly.

Returns:
Pending Error Messages


Generated at 2012-05-30 11:00:36 PM CEST