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 Object
selectionSyncObject
DOCUMENT ME! -
Constructor Summary
Constructors Constructor Description GravistoService()
-
Method Summary
Modifier and Type Method Description static void
addActionOnKeystroke(JDialog comp, ActionListener action, KeyStroke key)
void
addFrame(GraffitiInternalFrame frame)
Adds a new internal frame to the list of pattern editor frames.static void
addKnownMemoryHog(MemoryHog memoryHog)
void
addKnownOptionPane(Object identifyer, OptionPane optionPane)
Adds a optionPane to the list of known options-panes.void
addPatternSession(Session session)
Adds a Session to the list of patternSessions.void
algorithmAttachData(Algorithm algorithm)
static void
attachData(Algorithm algorithm)
static BufferedImage
blurImage(BufferedImage image, float blurRadius)
static void
checkEventDispatchThread()
Prints a log message in case this method is not called on the Event Dispatch Thread.static void
enableContent(JComponent comp, boolean enabled)
static void
ensureActiveViewAndSession(MouseEvent e)
void
framesDeselect()
Unselects all editor frames in the main view.static void
freeMemory(boolean freeAlsoMemoryHogs)
Algorithm
getAlgorithmInstanceFromFriendlyName(String name)
Returns a algorithm instance, defined by its name (e.g.static BufferedImage
getBufferedImage(Image icon)
static String
getFileModificationDateAndTime(File file, String returnIfNotFound)
static String
getHashFromFile(File f, HashType type)
static String
getHashFromFile(String filename, HashType type)
static String
getHashFromInputStream(InputStream is, HashType type)
static String
getHashFromInputStream(InputStream is, ObjectRef optFileSize, HashType type)
static BufferedImage
getImage(URL fileUrl)
static GravistoService
getInstance()
Returns the single instance of this class.ArrayList<OptionPane>
getKnownOptionPanes()
MainFrame
getMainFrame()
Returns the main frame (application window).Vector<Graph>
getMainGraphs()
Returns aVector
which contains a list of graphs from the main view.Vector<Session>
getMainSessions()
Returns aVector
which contains a list of sessions, loaded in the main view.static JLabel
getMemoryInfoLabel(boolean shortInfo)
ArrayList<Graph>
getPatternGraphs()
Returns aVector
which contains a list of pattern graphs.List<Session>
getPatternSessionList()
AList
of the pattern sessions.DefaultPluginEntry
getPluginInstanceFromPluginDescription(String pluginDescription)
Returns a plugin instance, given by its classname.static URL
getResource(Class<?> class1, String name)
static URL
getResource(Class<?> location, String filename, String optExt)
static BufferedImage
getScaledImage(BufferedImage icon, int w, int h)
static BufferedImage
getScaledImage(Image icon, int w, int h)
EditorSession
getSessionFromGraph(Graph graph)
Session
getSessionFromView(View thisView)
boolean
isEditorFrameSelected()
Checks if an editor frame in the main view is selected.void
loadFile(String fileName)
static void
loadFiles()
void
loadFiles(File[] files)
static ImageIcon
loadIcon(Class<?> class1, String name)
static ImageIcon
loadIcon(Class<?> class1, String name, int w, int h)
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.static void
processUndoableAlgorithm(Algorithm algorithm)
Process undoable edits for AbstractAlgorithm instances.void
removeFrame(GraffitiInternalFrame frame)
static void
run(String pluginNameOrClassName, ActionEvent event)
void
runAlgorithm(Algorithm algorithm, boolean enableMultipleSessionProcessing, ActionEvent event)
void
runAlgorithm(Algorithm algorithm, ActionEvent event)
void
runAlgorithm(Algorithm algorithm, Graph graph, Selection selection, boolean enableMultipleSessionProcessing, ActionEvent event)
void
runAlgorithm(Algorithm algorithm, Graph graph, Selection selection, ActionEvent event)
void
runPlugin(String pluginNameOrClassName, Graph g, ActionEvent event)
Starts a plugin and returns, as soon as the plugin execution has finished.static void
saveRessource(Class<?> reference, String folder, String fileName, String targetFileName)
ToDo Test this method (untested copy).static ShowImage
showImage(BufferedImage img, String title)
static void
unzipFile(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 aVector
which contains a list of sessions, loaded in the main view.- Returns:
Vector
with elements of the typeEditorSession
. Returns empty Vector, if no sessions are loaded.
-
getPatternSessionList
AList
of 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 aVector
which contains a list of graphs from the main view.- Returns:
Vector
with elements of the typeGraph
.
-
getPatternGraphs
Returns aVector
which contains a list of pattern graphs.- Returns:
Vector
with 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 methodisEditorFrameSelected
for 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
-