Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 261715 Details for
Bug 493136
Dot Attributes inconsistent handling
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Add missing DotInterpreter logic for node attributes handling
493136-Add-missing-DotInterperter-logic-for-node-attributes-handling.patch (text/plain), 33.81 KB, created by
Tamas Miklossy
on 2016-05-13 05:47:37 EDT
(
hide
)
Description:
Add missing DotInterpreter logic for node attributes handling
Filename:
MIME Type:
Creator:
Tamas Miklossy
Created:
2016-05-13 05:47:37 EDT
Size:
33.81 KB
patch
obsolete
>diff --git a/org.eclipse.gef4.dot.tests/src/org/eclipse/gef4/dot/tests/DotImportTests.java b/org.eclipse.gef4.dot.tests/src/org/eclipse/gef4/dot/tests/DotImportTests.java >index 2a1a1c2..fcee2ad 100644 >--- a/org.eclipse.gef4.dot.tests/src/org/eclipse/gef4/dot/tests/DotImportTests.java >+++ b/org.eclipse.gef4.dot.tests/src/org/eclipse/gef4/dot/tests/DotImportTests.java >@@ -15,8 +15,11 @@ > > import java.io.File; > >+import org.eclipse.gef4.dot.internal.DotAttributes; > import org.eclipse.gef4.dot.internal.DotImport; >+import org.eclipse.gef4.graph.Edge; > import org.eclipse.gef4.graph.Graph; >+import org.eclipse.gef4.graph.Node; > import org.junit.Assert; > import org.junit.Test; > >@@ -91,4 +94,775 @@ > assertEquals(2, graph.getEdges().size()); > } > >+ @Test >+ public void edge_arrowhead() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__DIGRAPH); >+ Node[] nodes = createNodes(); >+ Edge e1 = new Edge.Builder(nodes[0], nodes[1]) >+ .attr(DotAttributes._NAME__GNE, "1->2") //$NON-NLS-1$ >+ .attr(DotAttributes.ARROWHEAD__E, "crow") //$NON-NLS-1$ >+ .buildEdge(); >+ Edge e2 = new Edge.Builder(nodes[2], nodes[3]) >+ .attr(DotAttributes._NAME__GNE, "3->4") //$NON-NLS-1$ >+ .attr(DotAttributes.ARROWHEAD__E, "crow") //$NON-NLS-1$ >+ .buildEdge(); >+ Graph expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_ARROWHEAD_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__DIGRAPH); >+ DotAttributes.setArrowHead(e1, "diamond"); >+ DotAttributes.setArrowHead(e2, "dot"); >+ expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_ARROWHEAD_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__DIGRAPH); >+ DotAttributes.setArrowHead(e1, "vee"); >+ DotAttributes.setArrowHead(e2, "tee"); >+ expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_ARROWHEAD_OVERRIDE); >+ } >+ >+ @Test >+ public void edge_arrowsize() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__DIGRAPH); >+ Node[] nodes = createNodes(); >+ Edge e1 = new Edge.Builder(nodes[0], nodes[1]) >+ .attr(DotAttributes._NAME__GNE, "1->2") //$NON-NLS-1$ >+ .attr(DotAttributes.ARROWSIZE__E, "1.5") //$NON-NLS-1$ >+ .buildEdge(); >+ Edge e2 = new Edge.Builder(nodes[2], nodes[3]) >+ .attr(DotAttributes._NAME__GNE, "3->4") //$NON-NLS-1$ >+ .attr(DotAttributes.ARROWSIZE__E, "1.5") //$NON-NLS-1$ >+ .buildEdge(); >+ Graph expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_ARROWSIZE_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__DIGRAPH); >+ DotAttributes.setArrowSize(e1, "2.0"); >+ DotAttributes.setArrowSize(e2, "2.1"); >+ expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_ARROWSIZE_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__DIGRAPH); >+ DotAttributes.setArrowSize(e1, "2.3"); >+ DotAttributes.setArrowSize(e2, "2.2"); >+ expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_ARROWSIZE_OVERRIDE); >+ } >+ >+ @Test >+ public void edge_arrowtail() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__DIGRAPH); >+ Node[] nodes = createNodes(); >+ Edge e1 = new Edge.Builder(nodes[0], nodes[1]) >+ .attr(DotAttributes._NAME__GNE, "1->2") //$NON-NLS-1$ >+ .attr(DotAttributes.ARROWTAIL__E, "box") //$NON-NLS-1$ >+ .buildEdge(); >+ Edge e2 = new Edge.Builder(nodes[2], nodes[3]) >+ .attr(DotAttributes._NAME__GNE, "3->4") //$NON-NLS-1$ >+ .attr(DotAttributes.ARROWTAIL__E, "box") //$NON-NLS-1$ >+ .buildEdge(); >+ Graph expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_ARROWTAIL_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__DIGRAPH); >+ DotAttributes.setArrowTail(e1, "lbox"); >+ DotAttributes.setArrowTail(e2, "rbox"); >+ expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_ARROWTAIL_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__DIGRAPH); >+ DotAttributes.setArrowTail(e1, "olbox"); >+ DotAttributes.setArrowTail(e2, "obox"); >+ expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_ARROWTAIL_OVERRIDE); >+ } >+ >+ @Test >+ public void edge_dir() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__DIGRAPH); >+ Node[] nodes = createNodes(); >+ Edge e1 = new Edge.Builder(nodes[0], nodes[1]) >+ .attr(DotAttributes._NAME__GNE, "1->2") //$NON-NLS-1$ >+ .attr(DotAttributes.DIR__E, "forward") //$NON-NLS-1$ >+ .buildEdge(); >+ Edge e2 = new Edge.Builder(nodes[2], nodes[3]) >+ .attr(DotAttributes._NAME__GNE, "3->4") //$NON-NLS-1$ >+ .attr(DotAttributes.DIR__E, "forward") //$NON-NLS-1$ >+ .buildEdge(); >+ Graph expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_DIR_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__DIGRAPH); >+ DotAttributes.setDir(e1, "forward"); >+ DotAttributes.setDir(e2, "back"); >+ expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_DIR_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__DIGRAPH); >+ DotAttributes.setDir(e1, "both"); >+ DotAttributes.setDir(e2, "back"); >+ expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_DIR_OVERRIDE); >+ } >+ >+ @Test >+ public void edge_headlabel() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node[] nodes = createNodes(); >+ Edge e1 = new Edge.Builder(nodes[0], nodes[1]) >+ .attr(DotAttributes._NAME__GNE, "1--2") //$NON-NLS-1$ >+ .attr(DotAttributes.HEADLABEL__E, "EdgeHeadLabel1") //$NON-NLS-1$ >+ .buildEdge(); >+ Edge e2 = new Edge.Builder(nodes[2], nodes[3]) >+ .attr(DotAttributes._NAME__GNE, "3--4") //$NON-NLS-1$ >+ .attr(DotAttributes.HEADLABEL__E, "EdgeHeadLabel1") //$NON-NLS-1$ >+ .buildEdge(); >+ Graph expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_HEADLABEL_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setHeadLabel(e1, "EdgeHeadLabel2"); >+ DotAttributes.setHeadLabel(e2, "EdgeHeadLabel3"); >+ expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_HEADLABEL_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setHeadLabel(e1, "EdgeHeadLabel5"); >+ DotAttributes.setHeadLabel(e2, "EdgeHeadLabel4"); >+ expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_HEADLABEL_OVERRIDE); >+ } >+ >+ @Test >+ public void edge_headlp() { >+ // no global/override attribute tests, since they do not make sense >+ // test local attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node[] nodes = createNodes(); >+ Edge e1 = new Edge.Builder(nodes[0], nodes[1]) >+ .attr(DotAttributes._NAME__GNE, "1--2") //$NON-NLS-1$ >+ .attr(DotAttributes.HEAD_LP__E, "2.2,3.3") //$NON-NLS-1$ >+ .buildEdge(); >+ Edge e2 = new Edge.Builder(nodes[2], nodes[3]) >+ .attr(DotAttributes._NAME__GNE, "3--4") //$NON-NLS-1$ >+ .attr(DotAttributes.HEAD_LP__E, "-2.2,-3.3") //$NON-NLS-1$ >+ .buildEdge(); >+ Graph expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_HEAD_LP_LOCAL); >+ } >+ >+ @Test >+ public void edge_id() { >+ // no global/override attribute tests, since they do not make sense >+ // test local attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node[] nodes = createNodes(); >+ Edge e1 = new Edge.Builder(nodes[0], nodes[1]) >+ .attr(DotAttributes._NAME__GNE, "1--2") //$NON-NLS-1$ >+ .attr(DotAttributes.ID__GNE, "edgeID2") //$NON-NLS-1$ >+ .buildEdge(); >+ Edge e2 = new Edge.Builder(nodes[2], nodes[3]) >+ .attr(DotAttributes._NAME__GNE, "3--4") //$NON-NLS-1$ >+ .attr(DotAttributes.ID__GNE, "edgeID3") //$NON-NLS-1$ >+ .buildEdge(); >+ Graph expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_ID_LOCAL); >+ } >+ >+ @Test >+ public void edge_label() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node[] nodes = createNodes(); >+ Edge e1 = new Edge.Builder(nodes[0], nodes[1]) >+ .attr(DotAttributes._NAME__GNE, "1--2") //$NON-NLS-1$ >+ .attr(DotAttributes.LABEL__GNE, "Edge1") //$NON-NLS-1$ >+ .buildEdge(); >+ Edge e2 = new Edge.Builder(nodes[2], nodes[3]) >+ .attr(DotAttributes._NAME__GNE, "3--4") //$NON-NLS-1$ >+ .attr(DotAttributes.LABEL__GNE, "Edge1") //$NON-NLS-1$ >+ .buildEdge(); >+ Graph expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_LABEL_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setLabel(e1, "Edge1"); >+ DotAttributes.setLabel(e2, "Edge2"); >+ expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_LABEL_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setLabel(e1, "Edge4"); >+ DotAttributes.setLabel(e2, "Edge3"); >+ expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_LABEL_OVERRIDE); >+ } >+ >+ @Test >+ public void edge_lp() { >+ // no global/override attribute tests, since they do not make sense >+ // test local attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node[] nodes = createNodes(); >+ Edge e1 = new Edge.Builder(nodes[0], nodes[1]) >+ .attr(DotAttributes._NAME__GNE, "1--2") //$NON-NLS-1$ >+ .attr(DotAttributes.LP__GE, "0.3,0.4") //$NON-NLS-1$ >+ .buildEdge(); >+ Edge e2 = new Edge.Builder(nodes[2], nodes[3]) >+ .attr(DotAttributes._NAME__GNE, "3--4") //$NON-NLS-1$ >+ .attr(DotAttributes.LP__GE, "0.5,0.6") //$NON-NLS-1$ >+ .buildEdge(); >+ Graph expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_LP_LOCAL); >+ } >+ >+ @Test >+ public void edge_pos() { >+ // no global/override attribute tests, since they do not make sense >+ // test local attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node[] nodes = createNodes(); >+ Edge e1 = new Edge.Builder(nodes[0], nodes[1]) >+ .attr(DotAttributes._NAME__GNE, "1--2") //$NON-NLS-1$ >+ .attr(DotAttributes.POS__NE, "0.0,0.0 1.0,1.0 2.0,2.0 3.0,3.0") //$NON-NLS-1$ >+ .buildEdge(); >+ Edge e2 = new Edge.Builder(nodes[2], nodes[3]) >+ .attr(DotAttributes._NAME__GNE, "3--4") //$NON-NLS-1$ >+ .attr(DotAttributes.POS__NE, "4.0,4.0 5.0,5.0 6.0,6.0 7.0,7.0") //$NON-NLS-1$ >+ .buildEdge(); >+ Graph expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_POS_LOCAL); >+ } >+ >+ @Test >+ public void edge_style() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node[] nodes = createNodes(); >+ Edge e1 = new Edge.Builder(nodes[0], nodes[1]) >+ .attr(DotAttributes._NAME__GNE, "1--2") //$NON-NLS-1$ >+ .attr(DotAttributes.STYLE__E, "dashed") //$NON-NLS-1$ >+ .buildEdge(); >+ Edge e2 = new Edge.Builder(nodes[2], nodes[3]) >+ .attr(DotAttributes._NAME__GNE, "3--4") //$NON-NLS-1$ >+ .attr(DotAttributes.STYLE__E, "dashed") //$NON-NLS-1$ >+ .buildEdge(); >+ Graph expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_STYLE_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setStyle(e1, "dashed"); >+ DotAttributes.setStyle(e2, "dotted"); >+ expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_STYLE_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setStyle(e1, "bold, dotted"); >+ DotAttributes.setStyle(e2, "bold"); >+ expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_STYLE_OVERRIDE); >+ } >+ >+ @Test >+ public void edge_taillabel() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node[] nodes = createNodes(); >+ Edge e1 = new Edge.Builder(nodes[0], nodes[1]) >+ .attr(DotAttributes._NAME__GNE, "1--2") //$NON-NLS-1$ >+ .attr(DotAttributes.TAILLABEL__E, "EdgeTailLabel1") //$NON-NLS-1$ >+ .buildEdge(); >+ Edge e2 = new Edge.Builder(nodes[2], nodes[3]) >+ .attr(DotAttributes._NAME__GNE, "3--4") //$NON-NLS-1$ >+ .attr(DotAttributes.TAILLABEL__E, "EdgeTailLabel1") //$NON-NLS-1$ >+ .buildEdge(); >+ Graph expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_TAILLABEL_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setTailLabel(e1, "EdgeTailLabel2"); >+ DotAttributes.setTailLabel(e2, "EdgeTailLabel3"); >+ expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_TAILLABEL_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setTailLabel(e1, "EdgeTailLabel5"); >+ DotAttributes.setTailLabel(e2, "EdgeTailLabel4"); >+ expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_TAILLABEL_OVERRIDE); >+ } >+ >+ @Test >+ public void edge_taillp() { >+ // no global/override attribute tests, since they do not make sense >+ // test local attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node[] nodes = createNodes(); >+ Edge e1 = new Edge.Builder(nodes[0], nodes[1]) >+ .attr(DotAttributes._NAME__GNE, "1--2") //$NON-NLS-1$ >+ .attr(DotAttributes.TAIL_LP__E, "-4.5,-6.7") //$NON-NLS-1$ >+ .buildEdge(); >+ Edge e2 = new Edge.Builder(nodes[2], nodes[3]) >+ .attr(DotAttributes._NAME__GNE, "3--4") //$NON-NLS-1$ >+ .attr(DotAttributes.TAIL_LP__E, "-8.9,-10.11") //$NON-NLS-1$ >+ .buildEdge(); >+ Graph expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_TAIL_LP_LOCAL); >+ } >+ >+ @Test >+ public void edge_xlabel() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node[] nodes = createNodes(); >+ Edge e1 = new Edge.Builder(nodes[0], nodes[1]) >+ .attr(DotAttributes._NAME__GNE, "1--2") //$NON-NLS-1$ >+ .attr(DotAttributes.XLABEL__NE, "EdgeExternalLabel1") //$NON-NLS-1$ >+ .buildEdge(); >+ Edge e2 = new Edge.Builder(nodes[2], nodes[3]) >+ .attr(DotAttributes._NAME__GNE, "3--4") //$NON-NLS-1$ >+ .attr(DotAttributes.XLABEL__NE, "EdgeExternalLabel1") //$NON-NLS-1$ >+ .buildEdge(); >+ Graph expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_XLABEL_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setXLabel(e1, "EdgeExternalLabel2"); >+ DotAttributes.setXLabel(e2, "EdgeExternalLabel3"); >+ expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_XLABEL_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setXLabel(e1, "EdgeExternalLabel5"); >+ DotAttributes.setXLabel(e2, "EdgeExternalLabel4"); >+ expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_XLABEL_OVERRIDE); >+ } >+ >+ @Test >+ public void edge_xlp() { >+ // no global/override attribute tests, since they do not make sense >+ // test local attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node[] nodes = createNodes(); >+ Edge e1 = new Edge.Builder(nodes[0], nodes[1]) >+ .attr(DotAttributes._NAME__GNE, "1--2") //$NON-NLS-1$ >+ .attr(DotAttributes.XLP__NE, ".3,.4") //$NON-NLS-1$ >+ .buildEdge(); >+ Edge e2 = new Edge.Builder(nodes[2], nodes[3]) >+ .attr(DotAttributes._NAME__GNE, "3--4") //$NON-NLS-1$ >+ .attr(DotAttributes.XLP__NE, ".5,.6") //$NON-NLS-1$ >+ .buildEdge(); >+ Graph expected = graph.nodes(nodes).edges(e1, e2).build(); >+ testString(expected, DotSampleGraphs.EDGE_XLP_LOCAL); >+ } >+ >+ @Test >+ public void node_distortion() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node n1 = new Node.Builder().attr(DotAttributes._NAME__GNE, "1") //$NON-NLS-1$ >+ .attr(DotAttributes.DISTORTION__N, "1.1").buildNode(); >+ Node n2 = new Node.Builder().attr(DotAttributes._NAME__GNE, "2") //$NON-NLS-1$ >+ .attr(DotAttributes.DISTORTION__N, "1.1").buildNode(); >+ Graph expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_DISTORTION_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setDistortion(n1, "1.2"); >+ DotAttributes.setDistortion(n2, "1.3"); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_DISTORTION_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setDistortion(n1, "1.5"); >+ DotAttributes.setDistortion(n2, "1.4"); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_DISTORTION_OVERRIDE); >+ } >+ >+ @Test >+ public void node_fixedsize() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node n1 = new Node.Builder().attr(DotAttributes._NAME__GNE, "1") //$NON-NLS-1$ >+ .attr(DotAttributes.FIXEDSIZE__N, "true").buildNode(); >+ Node n2 = new Node.Builder().attr(DotAttributes._NAME__GNE, "2") //$NON-NLS-1$ >+ .attr(DotAttributes.FIXEDSIZE__N, "true").buildNode(); >+ Graph expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_FIXEDSIZE_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setFixedSizeParsed(n1, true); >+ DotAttributes.setFixedSizeParsed(n2, false); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_FIXEDSIZE_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setFixedSizeParsed(n1, false); >+ DotAttributes.setFixedSizeParsed(n2, true); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_FIXEDSIZE_OVERRIDE); >+ } >+ >+ @Test >+ public void node_height() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node n1 = new Node.Builder().attr(DotAttributes._NAME__GNE, "1") //$NON-NLS-1$ >+ .attr(DotAttributes.HEIGHT__N, "1.2").buildNode(); >+ Node n2 = new Node.Builder().attr(DotAttributes._NAME__GNE, "2") //$NON-NLS-1$ >+ .attr(DotAttributes.HEIGHT__N, "1.2").buildNode(); >+ Graph expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_HEIGHT_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setHeightParsed(n1, 3.4); >+ DotAttributes.setHeightParsed(n2, 5.6); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_HEIGHT_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setHeightParsed(n1, 9.11); >+ DotAttributes.setHeightParsed(n2, 7.8); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_HEIGHT_OVERRIDE); >+ } >+ >+ @Test >+ public void node_id() { >+ // no global/override attribute tests, since they do not make sense >+ // test local attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node n1 = new Node.Builder().attr(DotAttributes._NAME__GNE, "1") //$NON-NLS-1$ >+ .attr(DotAttributes.ID__GNE, "NodeID1").buildNode(); //$NON-NLS-1$ .buildNode(); >+ Node n2 = new Node.Builder().attr(DotAttributes._NAME__GNE, "2") //$NON-NLS-1$ >+ .attr(DotAttributes.ID__GNE, "NodeID2").buildNode(); >+ Graph expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_ID_LOCAL); >+ } >+ >+ @Test >+ public void node_label() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node n1 = new Node.Builder().attr(DotAttributes._NAME__GNE, "1") //$NON-NLS-1$ >+ .attr(DotAttributes.LABEL__GNE, "Node1").buildNode(); >+ Node n2 = new Node.Builder().attr(DotAttributes._NAME__GNE, "2") //$NON-NLS-1$ >+ .attr(DotAttributes.LABEL__GNE, "Node1").buildNode(); >+ Graph expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_LABEL_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setLabel(n1, "Node1"); >+ DotAttributes.setLabel(n2, "Node2"); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_LABEL_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setLabel(n1, "Node4"); >+ DotAttributes.setLabel(n2, "Node3"); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_LABEL_OVERRIDE); >+ } >+ >+ @Test >+ public void node_pos() { >+ // no global/override attribute tests, since they do not make sense >+ // test local attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node n1 = new Node.Builder().attr(DotAttributes._NAME__GNE, "1") //$NON-NLS-1$ >+ .attr(DotAttributes.POS__NE, ".1,.2!").buildNode(); //$NON-NLS-1$ .buildNode(); >+ Node n2 = new Node.Builder().attr(DotAttributes._NAME__GNE, "2") //$NON-NLS-1$ >+ .attr(DotAttributes.POS__NE, "-0.1,-2.3!").buildNode(); >+ Graph expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_POS_LOCAL); >+ } >+ >+ @Test >+ public void node_shape() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node n1 = new Node.Builder().attr(DotAttributes._NAME__GNE, "1") //$NON-NLS-1$ >+ .attr(DotAttributes.SHAPE__N, "box").buildNode(); >+ Node n2 = new Node.Builder().attr(DotAttributes._NAME__GNE, "2") //$NON-NLS-1$ >+ .attr(DotAttributes.SHAPE__N, "box").buildNode(); >+ Graph expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_SHAPE_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setShape(n1, "oval"); >+ DotAttributes.setShape(n2, "house"); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_SHAPE_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setShape(n1, "circle"); >+ DotAttributes.setShape(n2, "pentagon"); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_SHAPE_OVERRIDE); >+ } >+ >+ @Test >+ public void node_sides() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node n1 = new Node.Builder().attr(DotAttributes._NAME__GNE, "1") //$NON-NLS-1$ >+ .attr(DotAttributes.SIDES__N, "3").buildNode(); >+ Node n2 = new Node.Builder().attr(DotAttributes._NAME__GNE, "2") //$NON-NLS-1$ >+ .attr(DotAttributes.SIDES__N, "3").buildNode(); >+ Graph expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_SIDES_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setSidesParsed(n1, 4); >+ DotAttributes.setSidesParsed(n2, 5); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_SIDES_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setSidesParsed(n1, 7); >+ DotAttributes.setSidesParsed(n2, 6); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_SIDES_OVERRIDE); >+ } >+ >+ @Test >+ public void node_skew() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node n1 = new Node.Builder().attr(DotAttributes._NAME__GNE, "1") //$NON-NLS-1$ >+ .attr(DotAttributes.SKEW__N, "1.2").buildNode(); >+ Node n2 = new Node.Builder().attr(DotAttributes._NAME__GNE, "2") //$NON-NLS-1$ >+ .attr(DotAttributes.SKEW__N, "1.2").buildNode(); >+ Graph expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_SKEW_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setSkewParsed(n1, 3.4); >+ DotAttributes.setSkewParsed(n2, 5.6); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_SKEW_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setSkewParsed(n1, -7.8); >+ DotAttributes.setSkewParsed(n2, 7.8); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_SKEW_OVERRIDE); >+ } >+ >+ @Test >+ public void node_style() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node n1 = new Node.Builder().attr(DotAttributes._NAME__GNE, "1") //$NON-NLS-1$ >+ .attr(DotAttributes.STYLE__E, "solid, dashed").buildNode(); >+ Node n2 = new Node.Builder().attr(DotAttributes._NAME__GNE, "2") //$NON-NLS-1$ >+ .attr(DotAttributes.STYLE__E, "solid, dashed").buildNode(); >+ Graph expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_STYLE_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setStyle(n1, "bold"); >+ DotAttributes.setStyle(n2, "dotted"); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_STYLE_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setStyle(n1, "rounded"); >+ DotAttributes.setStyle(n2, "bold, filled"); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_STYLE_OVERRIDE); >+ } >+ >+ @Test >+ public void node_width() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node n1 = new Node.Builder().attr(DotAttributes._NAME__GNE, "1") //$NON-NLS-1$ >+ .attr(DotAttributes.WIDTH__N, "1.2").buildNode(); >+ Node n2 = new Node.Builder().attr(DotAttributes._NAME__GNE, "2") //$NON-NLS-1$ >+ .attr(DotAttributes.WIDTH__N, "1.2").buildNode(); >+ Graph expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_WIDTH_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setWidthParsed(n1, 3.4); >+ DotAttributes.setWidthParsed(n2, 5.6); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_WIDTH_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setWidthParsed(n1, 9.11); >+ DotAttributes.setWidthParsed(n2, 7.8); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_WIDTH_OVERRIDE); >+ } >+ >+ @Test >+ public void node_xlabel() { >+ // test global attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node n1 = new Node.Builder().attr(DotAttributes._NAME__GNE, "1") //$NON-NLS-1$ >+ .attr(DotAttributes.XLABEL__NE, "NodeExternalLabel1") >+ .buildNode(); >+ Node n2 = new Node.Builder().attr(DotAttributes._NAME__GNE, "2") //$NON-NLS-1$ >+ .attr(DotAttributes.XLABEL__NE, "NodeExternalLabel1") >+ .buildNode(); >+ Graph expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_XLABEL_GLOBAL); >+ >+ // test local attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setXLabel(n1, "NodeExternalLabel2"); >+ DotAttributes.setXLabel(n2, "NodeExternalLabel3"); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_XLABEL_LOCAL); >+ >+ // test override attribute >+ graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ DotAttributes.setXLabel(n1, "NodeExternalLabel5"); >+ DotAttributes.setXLabel(n2, "NodeExternalLabel4"); >+ expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_XLABEL_OVERRIDE); >+ } >+ >+ @Test >+ public void node_xlp() { >+ // no global/override attribute tests, since they do not make sense >+ // test local attribute >+ Graph.Builder graph = new Graph.Builder().attr(DotAttributes._TYPE__G, >+ DotAttributes._TYPE__G__GRAPH); >+ Node n1 = new Node.Builder().attr(DotAttributes._NAME__GNE, "1") //$NON-NLS-1$ >+ .attr(DotAttributes.XLP__NE, "-0.3,-0.4").buildNode(); //$NON-NLS-1$ .buildNode(); >+ Node n2 = new Node.Builder().attr(DotAttributes._NAME__GNE, "2") //$NON-NLS-1$ >+ .attr(DotAttributes.XLP__NE, "-1.5,-1.6").buildNode(); >+ Graph expected = graph.nodes(n1, n2).build(); >+ testString(expected, DotSampleGraphs.NODE_XLP_LOCAL); >+ } >+ >+ private Node[] createNodes() { >+ Node n1 = new Node.Builder().attr(DotAttributes._NAME__GNE, "1") //$NON-NLS-1$ >+ .buildNode(); >+ Node n2 = new Node.Builder().attr(DotAttributes._NAME__GNE, "2") //$NON-NLS-1$ >+ .buildNode(); >+ Node n3 = new Node.Builder().attr(DotAttributes._NAME__GNE, "3") //$NON-NLS-1$ >+ .buildNode(); >+ Node n4 = new Node.Builder().attr(DotAttributes._NAME__GNE, "4") //$NON-NLS-1$ >+ .buildNode(); >+ return new Node[] { n1, n2, n3, n4 }; >+ } >+ >+ private void testString(Graph expected, String dot) { >+ Graph graph = new DotImport().importDot(dot); >+ Assert.assertNotNull("Resulting graph must not be null", graph); //$NON-NLS-1$ >+ Assert.assertEquals(expected.toString(), graph.toString()); >+ } > } >diff --git a/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/DotInterpreter.java b/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/DotInterpreter.java >index 329cdf4..7da5902 100644 >--- a/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/DotInterpreter.java >+++ b/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/DotInterpreter.java >@@ -290,6 +290,12 @@ > if (skew != null) { > DotAttributes.setSkew(node, skew); > } >+ >+ // style >+ String style = getAttributeValue(nodeStmt, DotAttributes.STYLE__E); >+ if (style != null) { >+ DotAttributes.setStyle(node, style); >+ } > return super.caseNodeStmt(nodeStmt); > } > >@@ -486,6 +492,26 @@ > DotAttributes.setFixedSize(node, > globalNodeAttributes.get(DotAttributes.FIXEDSIZE__N)); > } >+ if (globalNodeAttributes.containsKey(DotAttributes.DISTORTION__N)) { >+ DotAttributes.setDistortion(node, >+ globalNodeAttributes.get(DotAttributes.DISTORTION__N)); >+ } >+ if (globalNodeAttributes.containsKey(DotAttributes.SHAPE__N)) { >+ DotAttributes.setShape(node, >+ globalNodeAttributes.get(DotAttributes.SHAPE__N)); >+ } >+ if (globalNodeAttributes.containsKey(DotAttributes.SIDES__N)) { >+ DotAttributes.setSides(node, >+ globalNodeAttributes.get(DotAttributes.SIDES__N)); >+ } >+ if (globalNodeAttributes.containsKey(DotAttributes.SKEW__N)) { >+ DotAttributes.setSkew(node, >+ globalNodeAttributes.get(DotAttributes.SKEW__N)); >+ } >+ if (globalNodeAttributes.containsKey(DotAttributes.STYLE__E)) { >+ DotAttributes.setStyle(node, >+ globalNodeAttributes.get(DotAttributes.STYLE__E)); >+ } > } > return nodesByName.get(nodeName); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
nyssen
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 493136
:
261510
|
261511
|
261535
|
261562
|
261603
|
261698
| 261715