Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 518417

Summary: Implement Graph Pretty Printing
Product: [Tools] GEF Reporter: Tamas Miklossy <miklossy>
Component: GEF DOTAssignee: gef-inbox <gef-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: 5.0.100 (Photon) M5   
Hardware: PC   
OS: Windows NT   
Whiteboard:

Description Tamas Miklossy CLA 2017-06-17 05:58:01 EDT
The current implementation of the org.eclipse.gef.graph.Graph.toString() method prints the graph into a single line. 

To improve readability, it would be useful to have a graph pretty printer that prints the graph in several lines and using appropriate indentation. It should also be customizeable which character to use for newline/indenting.

For example, for the graph defined under org.eclipse.gef.dot.tests.DotTestUtils.getSimpleGraph() the following output of a GraphPrettyPrinter could be a nice solution:

Graph attr {
    graph-layout-algorithm : TreeLayout {
        direction : top -> down
        resize : false
    }
}
.nodes {
    Node {
        element-label : 1
        node-shape : GeometryNode@4c51cf28
        node-size : Dimension(54.0, 36.0)
    }
    Node {
        element-label : 2
        node-shape : GeometryNode@6995bf68
        node-size : Dimension(54.0, 36.0)
    }
    Node {
        element-label : 3
        node-shape : GeometryNode@5143c662
        node-size : Dimension(54.0, 36.0)
    }
}.edges {
    Edge {
        edge-curve : GeometryNode@77825085
        edge-curve-css-style : -fx-stroke-line-cap: butt;
        } from Node {
            element-label : 1
            node-shape : GeometryNode@4c51cf28
            node-size : Dimension(54.0, 36.0)
        } to Node {
            element-label : 2
            node-shape : GeometryNode@6995bf68
            node-size : Dimension(54.0, 36.0)
    }
    Edge {
        edge-curve : GeometryNode@3568f9d2
        edge-curve-css-style : -fx-stroke-line-cap: butt;
        } from Node {
            element-label : 1
            node-shape : GeometryNode@4c51cf28
            node-size : Dimension(54.0, 36.0)
        } to Node {
            element-label : 3
            node-shape : GeometryNode@5143c662
            node-size : Dimension(54.0, 36.0)
     }
}
Comment 1 Tamas Miklossy CLA 2018-01-14 10:46:22 EST
I pushed the following changes to origin/master:

[518417] Add implementation of the GEF Graph Pretty Printer.

- Provider a Pretty Printer within the org.eclipse.gef.graph component
to be able to create a formatted representation of a graph, node or
edge.
- Add corresponding @since 5.1.0 tag to the PrettyPrinter class.
- Update version number of the GEF graph component from 5.0.0 to 5.1.0.

Resolving as fixed in 5.1.0 (Photon) M5.
Comment 2 Tamas Miklossy CLA 2018-02-04 04:46:33 EST
The PrettyPrinter has been moved the from GEF Graph to GEF DOT component.