Class GravistoService

java.lang.Object
org.graffiti.editor.GravistoService
All Implemented Interfaces:
HelperClass

public class GravistoService
extends Object
implements HelperClass
Provides access to global variables, needed for various extensions to Graffiti. Plugins can use the Preferences structure to save settings.
Recent revisions:
2.7.0
  • Field Details

    • selectionSyncObject

      public volatile Object selectionSyncObject
      DOCUMENT ME!
  • Constructor Details

    • GravistoService

      public GravistoService()
  • Method Details

    • getInstance

      public static GravistoService getInstance()
      Returns the single instance of this class.
      Returns:
      The single instance of this "Singleton".
    • addKnownOptionPane

      public void addKnownOptionPane​(Object identifyer, OptionPane optionPane)
      Adds a optionPane to the list of known options-panes. The list of known option-panes can be retrieved with getKnownOptionPanes.
      Parameters:
      optionPane - A new known optionPane. If already known, not added again.
    • getKnownOptionPanes

      public ArrayList<OptionPane> getKnownOptionPanes()
      Returns:
      Returns a list of known optionPanes. (type OptionPane )
    • 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.
    • 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 ArrayList<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 decision, 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.
    • run

      public static void run​(String pluginNameOrClassName, ActionEvent event)
    • runPlugin

      public void runPlugin​(String pluginNameOrClassName, Graph g, ActionEvent event)
      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.
    • runAlgorithm

      public void runAlgorithm​(Algorithm algorithm, ActionEvent event)
    • runAlgorithm

      public void runAlgorithm​(Algorithm algorithm, boolean enableMultipleSessionProcessing, ActionEvent event)
    • algorithmAttachData

      public void algorithmAttachData​(Algorithm algorithm)
      Parameters:
      listener -
    • attachData

      public static void attachData​(Algorithm algorithm)
    • runAlgorithm

      public void runAlgorithm​(Algorithm algorithm, Graph graph, Selection selection, ActionEvent event)
    • runAlgorithm

      public void runAlgorithm​(Algorithm algorithm, Graph graph, Selection selection, boolean enableMultipleSessionProcessing, ActionEvent event)
      Parameters:
      algorithm -
      nonInteractiveGraph -
      nonInteractiveSelection -
    • processUndoableAlgorithm

      public static void processUndoableAlgorithm​(Algorithm algorithm)
      Process undoable edits for AbstractAlgorithm instances.
      Parameters:
      algorithm - the previously executed algorithm
      Since:
      2.7.0
    • removeFrame

      public void removeFrame​(GraffitiInternalFrame frame)
      Parameters:
      frame -
    • loadFile

      public void loadFile​(String fileName)
    • loadFiles

      public static void loadFiles()
    • loadFiles

      public void loadFiles​(File[] files)
    • getSessionFromView

      public Session getSessionFromView​(View thisView)
    • addActionOnKeystroke

      public static void addActionOnKeystroke​(JDialog comp, ActionListener action, KeyStroke key)
    • blurImage

      public static BufferedImage blurImage​(BufferedImage image, float blurRadius)
    • getImage

      public static BufferedImage getImage​(URL fileUrl) throws IOException
      Throws:
      IOException
    • getScaledImage

      public static BufferedImage getScaledImage​(Image icon, int w, int h)
      Parameters:
      w - negative values have special meaning, they are ignored
      h - at least w or h needs to be positive
    • getBufferedImage

      public static BufferedImage getBufferedImage​(Image icon)
    • getScaledImage

      public static BufferedImage getScaledImage​(BufferedImage icon, int w, int h)
      Parameters:
      w - negative values have special meaning, they are ignored
      h - at least w or h needs to be positive
    • showImage

      public static ShowImage showImage​(BufferedImage img, String title)
    • getMemoryInfoLabel

      public static JLabel getMemoryInfoLabel​(boolean shortInfo)
    • loadIcon

      public static ImageIcon loadIcon​(Class<?> class1, String name)
    • loadIcon

      public static ImageIcon loadIcon​(Class<?> class1, String name, int w, int h)
    • getResource

      public static URL getResource​(Class<?> class1, String name)
    • getResource

      public static URL getResource​(Class<?> location, String filename, String optExt)
    • addKnownMemoryHog

      public static void addKnownMemoryHog​(MemoryHog memoryHog)
    • ensureActiveViewAndSession

      public static void ensureActiveViewAndSession​(MouseEvent e)
    • getFileModificationDateAndTime

      public static String getFileModificationDateAndTime​(File file, String returnIfNotFound)
    • checkEventDispatchThread

      public static void checkEventDispatchThread()
      Prints a log message in case this method is not called on the Event Dispatch Thread.
    • getSessionFromGraph

      public EditorSession getSessionFromGraph​(Graph graph)
    • freeMemory

      public static void freeMemory​(boolean freeAlsoMemoryHogs)
    • unzipFile

      public static void unzipFile​(File archive) throws Exception
      Throws:
      Exception
    • saveRessource

      public static void saveRessource​(Class<?> reference, String folder, String fileName, String targetFileName) throws IOException
      ToDo Test this method (untested copy).
      Throws:
      IOException
    • enableContent

      public static void enableContent​(JComponent comp, boolean enabled)
    • getHashFromFile

      public static String getHashFromFile​(String filename, HashType type) throws Exception
      Throws:
      Exception
    • getHashFromFile

      public static String getHashFromFile​(File f, HashType type) throws Exception
      Throws:
      Exception
    • getHashFromInputStream

      public static String getHashFromInputStream​(InputStream is, HashType type) throws Exception
      Throws:
      Exception
    • getHashFromInputStream

      public static String getHashFromInputStream​(InputStream is, ObjectRef optFileSize, HashType type) throws Exception
      Throws:
      Exception