Package de.unijena.cheminf.scaffolds
Class GraphStreamUtility
java.lang.Object
de.unijena.cheminf.scaffolds.GraphStreamUtility
Contains functionalities to visualise CDK-Scaffold-generated scaffold networks and trees in a
very basic way, employing the open GraphStream graph library.
Please note that this is a very basic functionality primarily meant for visual inspection and debugging.
GraphStream might also throw errors in some cases where the problem lies with the library, not
this functionality here.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
Default setting value for whether to label nodes with their index and level in the created graphs.static final org.openscience.cdk.depict.DepictionGenerator
Default CDK depiction generator used to create structure images for the graph nodesstatic final String
Default ID given to the created graphs if no ID is given.static final String
Default style sheet that is used for the created graphs if no custom style is defined.static final String
Default graph viewer used for visualisation.static final String
the cdk-scaffold ScaffoldNodeBase instances represented by a node in the created graph is stored under this property key. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
displayWithGraphStream
(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection) The ScaffoldNodeCollectionBase (scaffold network or tree) is displayed in an application window using GraphStream.static void
displayWithGraphStream
(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection, boolean areNodesLabelled) The ScaffoldNodeCollectionBase (scaffold network or tree) is displayed in an application window using GraphStream.static void
displayWithGraphStream
(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection, boolean areNodesLabelled, org.openscience.cdk.depict.DepictionGenerator aDepictionGenerator) The ScaffoldNodeCollectionBase (scaffold network or tree) is displayed in an application window using GraphStream.static void
displayWithGraphStream
(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection, boolean areNodesLabelled, org.openscience.cdk.depict.DepictionGenerator aDepictionGenerator, String aStyleSheet) The ScaffoldNodeCollectionBase (scaffold network or tree) is displayed in an application window using GraphStream.static void
displayWithGraphStream
(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection, boolean areNodesLabelled, org.openscience.cdk.depict.DepictionGenerator aDepictionGenerator, String aStyleSheet, String aGraphStreamUIProperty) The ScaffoldNodeCollectionBase (scaffold network or tree) is displayed in an application window using GraphStream.static org.graphstream.graph.Graph
generateGraphFromScaffoldNodeCollection
(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection) The ScaffoldNodeCollectionBase (scaffold network or tree) is parsed into a GraphStream Graph object with nodes depicting the scaffolds.static org.graphstream.graph.Graph
generateGraphFromScaffoldNodeCollection
(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection, boolean areNodesLabelled) The ScaffoldNodeCollectionBase (scaffold network or tree) is parsed into a GraphStream Graph object with nodes depicting the scaffolds.static org.graphstream.graph.Graph
generateGraphFromScaffoldNodeCollection
(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection, boolean areNodesLabelled, org.openscience.cdk.depict.DepictionGenerator aCDKDepictionGenerator) The ScaffoldNodeCollectionBase (scaffold network or tree) is parsed into a GraphStream Graph object with nodes depicting the scaffolds.static org.graphstream.graph.Graph
generateGraphFromScaffoldNodeCollection
(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection, boolean areNodesLabelled, org.openscience.cdk.depict.DepictionGenerator aCDKDepictionGenerator, String aStyleSheet) The ScaffoldNodeCollectionBase (scaffold network or tree) is parsed into a GraphStream Graph object with nodes depicting the scaffolds.static org.graphstream.graph.Graph
generateGraphFromScaffoldNodeCollection
(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection, boolean areNodesLabelled, org.openscience.cdk.depict.DepictionGenerator aCDKDepictionGenerator, String aStyleSheet, String aGraphID) The ScaffoldNodeCollectionBase (scaffold network or tree) is parsed into a GraphStream Graph object with nodes depicting the scaffolds.static org.graphstream.graph.Graph
generateGraphFromScaffoldNodeCollection
(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection, boolean areNodesLabelled, org.openscience.cdk.depict.DepictionGenerator aCDKDepictionGenerator, String aStyleSheet, org.graphstream.graph.Graph aGraph) The ScaffoldNodeCollectionBase (scaffold network or tree) is parsed into a GraphStream Graph object with nodes depicting the scaffolds.static File
Folder to store screenshots, temporary image files, etc.static File
Folder for temporary files like the node structure depictions.static void
screenshotGraph
(org.graphstream.graph.Graph aGraph, String aFilePath) Creates a screenshot of the given graph using the "ui.screenshot" attribute.static void
screenshotGraphHighQuality
(org.graphstream.graph.Graph aGraph, String aFilePath) Creates a high quality screenshot of the given graph using the FileSinkImages method writeAll().static void
screenshotGraphHighQuality
(org.graphstream.graph.Graph aGraph, String aFilePath, org.graphstream.stream.file.FileSinkImages aFileSinkImages) Creates a high quality screenshot of the given graph using the FileSinkImages method writeAll().static void
setGraphStreamDisplayFolder
(File aDirectory) Sets the folder to store screenshots, temporary image files, etc.static void
setTempFolder
(File aDirectory) Sets the folder for temporary files like the node structure depictions.
-
Field Details
-
DEFAULT_GRAPH_STYLE_SHEET
Default style sheet that is used for the created graphs if no custom style is defined.- See Also:
-
DEFAULT_GRAPH_ID
Default ID given to the created graphs if no ID is given.- See Also:
-
DEFAULT_GRAPHSTREAM_UI
Default graph viewer used for visualisation.- See Also:
-
DEFAULT_ARE_NODES_LABELLED
public static final boolean DEFAULT_ARE_NODES_LABELLEDDefault setting value for whether to label nodes with their index and level in the created graphs.- See Also:
-
DEFAULT_CDK_DEPICTION_GENERATOR
public static final org.openscience.cdk.depict.DepictionGenerator DEFAULT_CDK_DEPICTION_GENERATORDefault CDK depiction generator used to create structure images for the graph nodes -
GRAPH_NODE_PROPERTY_KEY_SCAFFOLD_NODE_BASE_INSTANCE
the cdk-scaffold ScaffoldNodeBase instances represented by a node in the created graph is stored under this property key.- See Also:
-
-
Method Details
-
getGraphStreamDisplayFolder
Folder to store screenshots, temporary image files, etc.- Returns:
- output folder
-
setGraphStreamDisplayFolder
public static void setGraphStreamDisplayFolder(File aDirectory) throws NullPointerException, IllegalArgumentException Sets the folder to store screenshots, temporary image files, etc.- Parameters:
aDirectory
- folder directory where the JRE can write and read- Throws:
NullPointerException
- if the given folder is nullIllegalArgumentException
- if the JRE is unable to read and write in the given folder
-
getTempFolder
Folder for temporary files like the node structure depictions.- Returns:
- folder for temporary files
-
setTempFolder
public static void setTempFolder(File aDirectory) throws NullPointerException, IllegalArgumentException Sets the folder for temporary files like the node structure depictions.- Parameters:
aDirectory
- folder directory where the JRE can write and read- Throws:
NullPointerException
- if the given folder is nullIllegalArgumentException
- if the JRE is unable to read and write in the given folder
-
displayWithGraphStream
public static void displayWithGraphStream(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection) throws NullPointerException, IllegalArgumentException, IOException The ScaffoldNodeCollectionBase (scaffold network or tree) is displayed in an application window using GraphStream.
NOTE: It is not recommended displaying multiple graphs at the same time using this method because of multithreading issues.- Parameters:
aScaffoldNodeCollection
- displayed scaffold graph- Throws:
NullPointerException
- if any parameter is nullIllegalArgumentException
- if any parameter does not fulfil its requirementsIOException
- if image files cannot be written for the depicted scaffold structures
-
displayWithGraphStream
public static void displayWithGraphStream(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection, boolean areNodesLabelled) throws NullPointerException, IllegalArgumentException, IOException The ScaffoldNodeCollectionBase (scaffold network or tree) is displayed in an application window using GraphStream. The optional numbering of the nodes reflects their respective indices in the exported adjacency matrix and their level in the graph.
NOTE: It is not recommended displaying multiple graphs at the same time using this method because of multithreading issues.- Parameters:
aScaffoldNodeCollection
- displayed scaffold graphareNodesLabelled
- adds a label with node level and node index if true- Throws:
NullPointerException
- if any parameter is nullIllegalArgumentException
- if any parameter does not fulfil its requirementsIOException
- if image files cannot be written for the depicted scaffold structures
-
displayWithGraphStream
public static void displayWithGraphStream(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection, boolean areNodesLabelled, org.openscience.cdk.depict.DepictionGenerator aDepictionGenerator) throws NullPointerException, IllegalArgumentException, IOException The ScaffoldNodeCollectionBase (scaffold network or tree) is displayed in an application window using GraphStream. The optional numbering of the nodes reflects their respective indices in the exported adjacency matrix and their level in the graph.
NOTE: It is not recommended displaying multiple graphs at the same time using this method because of multithreading issues.- Parameters:
aScaffoldNodeCollection
- displayed scaffold graphareNodesLabelled
- adds a label with node level and node index if trueaDepictionGenerator
- CDK depiction generator used for generating the structure images on the graph nodes- Throws:
NullPointerException
- if any parameter is nullIllegalArgumentException
- if any parameter does not fulfil its requirementsIOException
- if image files cannot be written for the depicted scaffold structures
-
displayWithGraphStream
public static void displayWithGraphStream(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection, boolean areNodesLabelled, org.openscience.cdk.depict.DepictionGenerator aDepictionGenerator, String aStyleSheet) throws NullPointerException, IllegalArgumentException, IOException The ScaffoldNodeCollectionBase (scaffold network or tree) is displayed in an application window using GraphStream. The optional numbering of the nodes reflects their respective indices in the exported adjacency matrix and their level in the graph.
NOTE: It is not recommended displaying multiple graphs at the same time using this method because of multithreading issues.- Parameters:
aScaffoldNodeCollection
- displayed scaffold graphareNodesLabelled
- adds a label with node level and node index if trueaDepictionGenerator
- CDK depiction generator used for generating the structure images on the graph nodesaStyleSheet
- style sheet property for the graph- Throws:
NullPointerException
- if any parameter is nullIllegalArgumentException
- if any parameter does not fulfil its requirementsIOException
- if image files cannot be written for the depicted scaffold structures
-
displayWithGraphStream
public static void displayWithGraphStream(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection, boolean areNodesLabelled, org.openscience.cdk.depict.DepictionGenerator aDepictionGenerator, String aStyleSheet, String aGraphStreamUIProperty) throws NullPointerException, IllegalArgumentException, IOException The ScaffoldNodeCollectionBase (scaffold network or tree) is displayed in an application window using GraphStream. The optional numbering of the nodes reflects their respective indices in the exported adjacency matrix and their level in the graph. The GraphStream UI property defines which graphics library is employed, Java Swing (more reliable) or JavaFX (more experimental).
NOTE: It is not recommended displaying multiple graphs at the same time using this method because of multithreading issues.- Parameters:
aScaffoldNodeCollection
- displayed scaffold graphareNodesLabelled
- adds a label with node level and node index if trueaDepictionGenerator
- CDK depiction generator used for generating the structure images on the graph nodesaStyleSheet
- style sheet property for the graphaGraphStreamUIProperty
- "swing" or "javafx" (make sure to have installed the respective dependencies)- Throws:
NullPointerException
- if any parameter is nullIllegalArgumentException
- if any parameter does not fulfil its requirementsIOException
- if image files cannot be written for the depicted scaffold structures
-
generateGraphFromScaffoldNodeCollection
public static org.graphstream.graph.Graph generateGraphFromScaffoldNodeCollection(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection) throws IOException The ScaffoldNodeCollectionBase (scaffold network or tree) is parsed into a GraphStream Graph object with nodes depicting the scaffolds.- Parameters:
aScaffoldNodeCollection
- scaffold graph (scaffold tree or network) to parse- Returns:
- GraphStream Graph instance representing the given scaffold graph with structure depictions of the scaffolds on its nodes
- Throws:
NullPointerException
- if any parameter is nullIllegalArgumentException
- if any parameter does not fulfil its requirementsIOException
- if image files cannot be written for the depicted scaffold structures
-
generateGraphFromScaffoldNodeCollection
public static org.graphstream.graph.Graph generateGraphFromScaffoldNodeCollection(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection, boolean areNodesLabelled) throws IOException The ScaffoldNodeCollectionBase (scaffold network or tree) is parsed into a GraphStream Graph object with nodes depicting the scaffolds. The optional numbering of the nodes reflects their respective indices in the exported adjacency matrix and their level in the graph.- Parameters:
aScaffoldNodeCollection
- scaffold graph (scaffold tree or network) to parseareNodesLabelled
- adds a label with node level and node index if true- Returns:
- GraphStream Graph instance representing the given scaffold graph with structure depictions of the scaffolds on its nodes
- Throws:
NullPointerException
- if any parameter is nullIllegalArgumentException
- if any parameter does not fulfil its requirementsIOException
- if image files cannot be written for the depicted scaffold structures
-
generateGraphFromScaffoldNodeCollection
public static org.graphstream.graph.Graph generateGraphFromScaffoldNodeCollection(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection, boolean areNodesLabelled, org.openscience.cdk.depict.DepictionGenerator aCDKDepictionGenerator) throws IOException The ScaffoldNodeCollectionBase (scaffold network or tree) is parsed into a GraphStream Graph object with nodes depicting the scaffolds. The optional numbering of the nodes reflects their respective indices in the exported adjacency matrix and their level in the graph.- Parameters:
aScaffoldNodeCollection
- scaffold graph (scaffold tree or network) to parseareNodesLabelled
- adds a label with node level and node index if trueaCDKDepictionGenerator
- CDK depiction generator used for generating the structure images on the graph nodes- Returns:
- GraphStream Graph instance representing the given scaffold graph with structure depictions of the scaffolds on its nodes
- Throws:
NullPointerException
- if any parameter is nullIllegalArgumentException
- if any parameter does not fulfil its requirementsIOException
- if image files cannot be written for the depicted scaffold structures
-
generateGraphFromScaffoldNodeCollection
public static org.graphstream.graph.Graph generateGraphFromScaffoldNodeCollection(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection, boolean areNodesLabelled, org.openscience.cdk.depict.DepictionGenerator aCDKDepictionGenerator, String aStyleSheet) throws IOException The ScaffoldNodeCollectionBase (scaffold network or tree) is parsed into a GraphStream Graph object with nodes depicting the scaffolds. The optional numbering of the nodes reflects their respective indices in the exported adjacency matrix and their level in the graph.- Parameters:
aScaffoldNodeCollection
- scaffold graph (scaffold tree or network) to parseareNodesLabelled
- adds a label with node level and node index if trueaCDKDepictionGenerator
- CDK depiction generator used for generating the structure images on the graph nodesaStyleSheet
- style sheet property for the graph- Returns:
- GraphStream Graph instance representing the given scaffold graph with structure depictions of the scaffolds on its nodes
- Throws:
NullPointerException
- if any parameter is nullIllegalArgumentException
- if any parameter does not fulfil its requirementsIOException
- if image files cannot be written for the depicted scaffold structures
-
generateGraphFromScaffoldNodeCollection
public static org.graphstream.graph.Graph generateGraphFromScaffoldNodeCollection(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection, boolean areNodesLabelled, org.openscience.cdk.depict.DepictionGenerator aCDKDepictionGenerator, String aStyleSheet, String aGraphID) throws IOException The ScaffoldNodeCollectionBase (scaffold network or tree) is parsed into a GraphStream Graph object with nodes depicting the scaffolds. The optional numbering of the nodes reflects their respective indices in the exported adjacency matrix and their level in the graph.- Parameters:
aScaffoldNodeCollection
- scaffold graph (scaffold tree or network) to parseareNodesLabelled
- adds a label with node level and node index if trueaCDKDepictionGenerator
- CDK depiction generator used for generating the structure images on the graph nodesaStyleSheet
- style sheet property for the graphaGraphID
- id given to the newly created Graph instance- Returns:
- GraphStream Graph instance representing the given scaffold graph with structure depictions of the scaffolds on its nodes
- Throws:
NullPointerException
- if any parameter is nullIllegalArgumentException
- if any parameter does not fulfil its requirementsIOException
- if image files cannot be written for the depicted scaffold structures
-
generateGraphFromScaffoldNodeCollection
public static org.graphstream.graph.Graph generateGraphFromScaffoldNodeCollection(org.openscience.cdk.tools.scaffold.ScaffoldNodeCollectionBase aScaffoldNodeCollection, boolean areNodesLabelled, org.openscience.cdk.depict.DepictionGenerator aCDKDepictionGenerator, String aStyleSheet, org.graphstream.graph.Graph aGraph) throws NullPointerException, IllegalArgumentException, IOException The ScaffoldNodeCollectionBase (scaffold network or tree) is parsed into a GraphStream Graph object with nodes depicting the scaffolds. The optional numbering of the nodes reflects their respective indices in the exported adjacency matrix and their level in the graph.- Parameters:
aScaffoldNodeCollection
- scaffold graph (scaffold tree or network) to parseareNodesLabelled
- adds a label with node level and node index if trueaCDKDepictionGenerator
- CDK depiction generator used for generating the structure images on the graph nodesaStyleSheet
- style sheet property for the graphaGraph
- empty(!) Graph instance (convenience here, e.g. to connect a file sink image instance to the graph before it is constructed)- Returns:
- GraphStream Graph instance representing the given scaffold graph with structure depictions of the scaffolds on its nodes
- Throws:
NullPointerException
- if any parameter is nullIllegalArgumentException
- if any parameter does not fulfil its requirementsIOException
- if image files cannot be written for the depicted scaffold structures
-
screenshotGraph
public static void screenshotGraph(org.graphstream.graph.Graph aGraph, String aFilePath) throws NullPointerException, IllegalArgumentException, IOException Creates a screenshot of the given graph using the "ui.screenshot" attribute.- Parameters:
aGraph
- graph to screenshotaFilePath
- file path were the screenshot should be created (existing files will be overridden)- Throws:
NullPointerException
- if any parameter is nullIllegalArgumentException
- if any parameter does not fulfil its requirementsIOException
- if an I/O error occurs while writing
-
screenshotGraphHighQuality
public static void screenshotGraphHighQuality(org.graphstream.graph.Graph aGraph, String aFilePath) throws NullPointerException, IllegalArgumentException, IOException Creates a high quality screenshot of the given graph using the FileSinkImages method writeAll().
NOTE: It is not recommended screenshotting multiple graphs at the same time using this method because of multithreading issues.- Parameters:
aGraph
- graph to screenshotaFilePath
- file path were the screenshot should be created (existing files will be overridden)- Throws:
NullPointerException
- if any parameter is nullIllegalArgumentException
- if any parameter does not fulfil its requirementsIOException
- if an I/O error occurs while writing
-
screenshotGraphHighQuality
public static void screenshotGraphHighQuality(org.graphstream.graph.Graph aGraph, String aFilePath, org.graphstream.stream.file.FileSinkImages aFileSinkImages) throws NullPointerException, IllegalArgumentException, IOException Creates a high quality screenshot of the given graph using the FileSinkImages method writeAll().
NOTE: It is not recommended screenshotting multiple graphs at the same time using this method because of multithreading issues.- Parameters:
aGraph
- graph to screenshotaFilePath
- file path were the screenshot should be created (existing files will be overridden)aFileSinkImages
- FileSinkImages instance with custom configuration to create the screenshot- Throws:
NullPointerException
- if any parameter is nullIllegalArgumentException
- if any parameter does not fulfil its requirementsIOException
- if an I/O error occurs while writing
-