This article describes and demonstrates how the sophisticated layout algorithms provided by yFiles for Java can be used from within a C++ application. The main idea to make this work is to provide a convenient communication layer for a C++ application and a Java process executing a yFiles-based layout service. What this package includes C++ Source Code that will allow you to
Furthermore, the package includes Java Source Code for the yFiles layout server, and sample code that shows how to effectively use the C++ extension.
1. Unzip the [CppExtensionForYFiles.zip]. The unzipped file contains following folders:
2. From your yFiles 2.7 for Java distribution, now copy lib/y.jar to the lib folder of the C++ extension.
The Visual Studio project file (yFilesCPPInterface.sln) is located in the root path of the yFilesCPP distribution. 1. Open the project file. 2. Build the solution with F7. 3. Execute the demo with F5 or start the "yFilesCPPDemo.exe" from the Debug folder (yFilesCPPRoot/Debug).
The C++ extension currently comes with four source code demos. Each of the examples creates their own graph, configures the corresponding layout algorithm, manipulates the graph by an automatic layout and writes the output to the console and to an XML-encoded GraphML file. The output to the console represents each of the graphs, before and after the layout calculation. The generated GraphML files contains the graph including the resulting layout. To view these GraphML files (example1.graphml ... example4.graphml) you can use the freely availalbe yEd Graph Editor. The GraphML files are located in the debug folder (yFilesCPPRoot/Debug).
The C++ extension for yFiles uses the freely available Xerces-C++ library to implement the communication protocol for the layout service. The Xerces-C++ library is partially included in the lib/ directory of the extension package. The Apache License ver. 2.0 applies to the Xerces-C++ distribution.