Package org.graffiti.editor
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 Summary
Fields Modifier and Type Field Description ObjectselectionSyncObjectDOCUMENT ME! -
Constructor Summary
Constructors Constructor Description GravistoService() -
Method Summary
Modifier and Type Method Description static voidaddActionOnKeystroke(JDialog comp, ActionListener action, KeyStroke key)voidaddFrame(GraffitiInternalFrame frame)Adds a new internal frame to the list of pattern editor frames.static voidaddKnownMemoryHog(MemoryHog memoryHog)voidaddKnownOptionPane(Object identifyer, OptionPane optionPane)Adds a optionPane to the list of known options-panes.voidaddPatternSession(Session session)Adds a Session to the list of patternSessions.voidalgorithmAttachData(Algorithm algorithm)static voidattachData(Algorithm algorithm)static BufferedImageblurImage(BufferedImage image, float blurRadius)static voidcheckEventDispatchThread()Prints a log message in case this method is not called on the Event Dispatch Thread.static voidenableContent(JComponent comp, boolean enabled)static voidensureActiveViewAndSession(MouseEvent e)voidframesDeselect()Unselects all editor frames in the main view.static voidfreeMemory(boolean freeAlsoMemoryHogs)AlgorithmgetAlgorithmInstanceFromFriendlyName(String name)Returns a algorithm instance, defined by its name (e.g.static BufferedImagegetBufferedImage(Image icon)static StringgetFileModificationDateAndTime(File file, String returnIfNotFound)static StringgetHashFromFile(File f, HashType type)static StringgetHashFromFile(String filename, HashType type)static StringgetHashFromInputStream(InputStream is, HashType type)static StringgetHashFromInputStream(InputStream is, ObjectRef optFileSize, HashType type)static BufferedImagegetImage(URL fileUrl)static GravistoServicegetInstance()Returns the single instance of this class.ArrayList<OptionPane>getKnownOptionPanes()MainFramegetMainFrame()Returns the main frame (application window).Vector<Graph>getMainGraphs()Returns aVectorwhich contains a list of graphs from the main view.Vector<Session>getMainSessions()Returns aVectorwhich contains a list of sessions, loaded in the main view.static JLabelgetMemoryInfoLabel(boolean shortInfo)ArrayList<Graph>getPatternGraphs()Returns aVectorwhich contains a list of pattern graphs.List<Session>getPatternSessionList()AListof the pattern sessions.DefaultPluginEntrygetPluginInstanceFromPluginDescription(String pluginDescription)Returns a plugin instance, given by its classname.static URLgetResource(Class<?> class1, String name)static URLgetResource(Class<?> location, String filename, String optExt)static BufferedImagegetScaledImage(BufferedImage icon, int w, int h)static BufferedImagegetScaledImage(Image icon, int w, int h)EditorSessiongetSessionFromGraph(Graph graph)SessiongetSessionFromView(View thisView)booleanisEditorFrameSelected()Checks if an editor frame in the main view is selected.voidloadFile(String fileName)static voidloadFiles()voidloadFiles(File[] files)static ImageIconloadIcon(Class<?> class1, String name)static ImageIconloadIcon(Class<?> class1, String name, int w, int h)booleanpluginSelectionMoveAllowed()A global variable, for communication between the IPK Editing Tools and some IPK Layouter.voidpluginSetMoveAllowed(boolean value)A global variable, for communication between the IPK Editing Tools and some IPK Layouter.static voidprocessUndoableAlgorithm(Algorithm algorithm)Process undoable edits for AbstractAlgorithm instances.voidremoveFrame(GraffitiInternalFrame frame)static voidrun(String pluginNameOrClassName, ActionEvent event)voidrunAlgorithm(Algorithm algorithm, boolean enableMultipleSessionProcessing, ActionEvent event)voidrunAlgorithm(Algorithm algorithm, ActionEvent event)voidrunAlgorithm(Algorithm algorithm, Graph graph, Selection selection, boolean enableMultipleSessionProcessing, ActionEvent event)voidrunAlgorithm(Algorithm algorithm, Graph graph, Selection selection, ActionEvent event)voidrunPlugin(String pluginNameOrClassName, Graph g, ActionEvent event)Starts a plugin and returns, as soon as the plugin execution has finished.static voidsaveRessource(Class<?> reference, String folder, String fileName, String targetFileName)ToDo Test this method (untested copy).static ShowImageshowImage(BufferedImage img, String title)static voidunzipFile(File archive)
-
Field Details
-
selectionSyncObject
DOCUMENT ME!
-
-
Constructor Details
-
GravistoService
public GravistoService()
-
-
Method Details
-
getInstance
Returns the single instance of this class.- Returns:
- The single instance of this "Singleton".
-
addKnownOptionPane
Adds a optionPane to the list of known options-panes. The list of known option-panes can be retrieved withgetKnownOptionPanes.- Parameters:
optionPane- A new known optionPane. If already known, not added again.
-
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
Returns aVectorwhich contains a list of sessions, loaded in the main view.- Returns:
Vectorwith elements of the typeEditorSession. Returns empty Vector, if no sessions are loaded.
-
getPatternSessionList
AListof the pattern sessions. PatternSessions are sessions, which are loaded in the pattern tab.- Returns:
- The pattern sessions.
-
getMainFrame
Returns the main frame (application window).- Returns:
- The main frame.
-
getMainGraphs
Returns aVectorwhich contains a list of graphs from the main view.- Returns:
Vectorwith elements of the typeGraph.
-
getPatternGraphs
Returns aVectorwhich contains a list of pattern graphs.- Returns:
Vectorwith elements of the typeGraph. If no patterns are loaded or available, this method returns an emptyVector.
-
addFrame
Adds a new internal frame to the list of pattern editor frames. Can be used by the methodisEditorFrameSelectedfor the decision, whether a given frame is a editor frame or a pattern editor frame.- Parameters:
frame- New pattern editor frame.
-
addPatternSession
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
Returns a algorithm instance, defined by its name (e.g. menu item text)- Parameters:
name- The menu item text.- Returns:
- The algorithm instance.
-
getPluginInstanceFromPluginDescription
Returns a plugin instance, given by its classname.- Parameters:
pluginDescription-- Returns:
- The plugin instance, if the plugin is loaded.
-
run
-
runPlugin
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
-
runAlgorithm
public void runAlgorithm(Algorithm algorithm, boolean enableMultipleSessionProcessing, ActionEvent event) -
algorithmAttachData
- Parameters:
listener-
-
attachData
-
runAlgorithm
-
runAlgorithm
public void runAlgorithm(Algorithm algorithm, Graph graph, Selection selection, boolean enableMultipleSessionProcessing, ActionEvent event)- Parameters:
algorithm-nonInteractiveGraph-nonInteractiveSelection-
-
processUndoableAlgorithm
Process undoable edits for AbstractAlgorithm instances.- Parameters:
algorithm- the previously executed algorithm- Since:
- 2.7.0
-
removeFrame
- Parameters:
frame-
-
loadFile
-
loadFiles
public static void loadFiles() -
loadFiles
-
getSessionFromView
-
addActionOnKeystroke
-
blurImage
-
getImage
- Throws:
IOException
-
getScaledImage
- Parameters:
w- negative values have special meaning, they are ignoredh- at least w or h needs to be positive
-
getBufferedImage
-
getScaledImage
- Parameters:
w- negative values have special meaning, they are ignoredh- at least w or h needs to be positive
-
showImage
-
getMemoryInfoLabel
-
loadIcon
-
loadIcon
-
getResource
-
getResource
-
addKnownMemoryHog
-
ensureActiveViewAndSession
-
getFileModificationDateAndTime
-
checkEventDispatchThread
public static void checkEventDispatchThread()Prints a log message in case this method is not called on the Event Dispatch Thread. -
getSessionFromGraph
-
freeMemory
public static void freeMemory(boolean freeAlsoMemoryHogs) -
unzipFile
- Throws:
Exception
-
saveRessource
public static void saveRessource(Class<?> reference, String folder, String fileName, String targetFileName) throws IOExceptionToDo Test this method (untested copy).- Throws:
IOException
-
enableContent
-
getHashFromFile
- Throws:
Exception
-
getHashFromFile
- Throws:
Exception
-
getHashFromInputStream
- Throws:
Exception
-
getHashFromInputStream
public static String getHashFromInputStream(InputStream is, ObjectRef optFileSize, HashType type) throws Exception- Throws:
Exception
-