Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 493136 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.gef4.dot.tests/src/org/eclipse/gef4/dot/tests/DotAttributesTests.java (-63 / +468 lines)
Lines 28-40 Link Here
28
import org.eclipse.gef4.dot.internal.parser.arrowtype.DeprecatedShape;
28
import org.eclipse.gef4.dot.internal.parser.arrowtype.DeprecatedShape;
29
import org.eclipse.gef4.dot.internal.parser.arrowtype.PrimitiveShape;
29
import org.eclipse.gef4.dot.internal.parser.arrowtype.PrimitiveShape;
30
import org.eclipse.gef4.dot.internal.parser.dir.DirType;
30
import org.eclipse.gef4.dot.internal.parser.dir.DirType;
31
import org.eclipse.gef4.dot.internal.parser.layout.Layout;
31
import org.eclipse.gef4.dot.internal.parser.point.Point;
32
import org.eclipse.gef4.dot.internal.parser.point.Point;
32
import org.eclipse.gef4.dot.internal.parser.point.PointFactory;
33
import org.eclipse.gef4.dot.internal.parser.point.PointFactory;
33
import org.eclipse.gef4.dot.internal.parser.rankdir.Rankdir;
34
import org.eclipse.gef4.dot.internal.parser.rankdir.Rankdir;
35
import org.eclipse.gef4.dot.internal.parser.shape.PolygonBasedNodeShape;
36
import org.eclipse.gef4.dot.internal.parser.shape.PolygonBasedShape;
37
import org.eclipse.gef4.dot.internal.parser.shape.RecordBasedNodeShape;
38
import org.eclipse.gef4.dot.internal.parser.shape.RecordBasedShape;
39
import org.eclipse.gef4.dot.internal.parser.shape.Shape;
40
import org.eclipse.gef4.dot.internal.parser.shape.ShapeFactory;
34
import org.eclipse.gef4.dot.internal.parser.splines.Splines;
41
import org.eclipse.gef4.dot.internal.parser.splines.Splines;
35
import org.eclipse.gef4.dot.internal.parser.splinetype.Spline;
42
import org.eclipse.gef4.dot.internal.parser.splinetype.Spline;
36
import org.eclipse.gef4.dot.internal.parser.splinetype.SplineType;
43
import org.eclipse.gef4.dot.internal.parser.splinetype.SplineType;
37
import org.eclipse.gef4.dot.internal.parser.splinetype.SplinetypeFactory;
44
import org.eclipse.gef4.dot.internal.parser.splinetype.SplinetypeFactory;
45
import org.eclipse.gef4.dot.internal.parser.style.Style;
46
import org.eclipse.gef4.dot.internal.parser.style.StyleFactory;
47
import org.eclipse.gef4.dot.internal.parser.style.StyleItem;
38
import org.eclipse.gef4.graph.Edge;
48
import org.eclipse.gef4.graph.Edge;
39
import org.eclipse.gef4.graph.Graph;
49
import org.eclipse.gef4.graph.Graph;
40
import org.eclipse.gef4.graph.Node;
50
import org.eclipse.gef4.graph.Node;
Lines 303-309 Link Here
303
		assertTrue(EcoreUtil.equals(validEdgeHeadLpParsed,
313
		assertTrue(EcoreUtil.equals(validEdgeHeadLpParsed,
304
				DotAttributes.getHeadLpParsed(edge)));
314
				DotAttributes.getHeadLpParsed(edge)));
305
315
306
		// TODO: add test cases for setting invalid edge head label positions
316
		// set invalid string values
317
		try {
318
			DotAttributes.setHeadLp(edge, "foo");
319
			fail("Expecting IllegalArgumentException.");
320
		} catch (IllegalArgumentException e) {
321
			assertEquals(
322
					"Cannot set edge attribute 'head_lp' to 'foo'. The value 'foo' is not a syntactically correct point: No viable alternative at character 'f'. No viable alternative at character 'o'. No viable alternative at character 'o'.",
323
					e.getMessage());
324
		}
307
	}
325
	}
308
326
309
	@Test
327
	@Test
Lines 331-338 Link Here
331
		final String validEdgeLabel = "edgeLabel";
349
		final String validEdgeLabel = "edgeLabel";
332
		DotAttributes.setLabel(edge, validEdgeLabel);
350
		DotAttributes.setLabel(edge, validEdgeLabel);
333
		assertEquals(validEdgeLabel, DotAttributes.getLabel(edge));
351
		assertEquals(validEdgeLabel, DotAttributes.getLabel(edge));
334
335
		// TODO: add test cases for setting invalid edge label
336
	}
352
	}
337
353
338
	@Test
354
	@Test
Lines 354-360 Link Here
354
		assertTrue(EcoreUtil.equals(validEdgeLpParsed,
370
		assertTrue(EcoreUtil.equals(validEdgeLpParsed,
355
				DotAttributes.getLpParsed(edge)));
371
				DotAttributes.getLpParsed(edge)));
356
372
357
		// TODO: add test cases for setting invalid edge label positions
373
		// set invalid string values
374
		try {
375
			DotAttributes.setLp(edge, "foo");
376
			fail("Expecting IllegalArgumentException.");
377
		} catch (IllegalArgumentException e) {
378
			assertEquals(
379
					"Cannot set edge attribute 'lp' to 'foo'. The value 'foo' is not a syntactically correct point: No viable alternative at character 'f'. No viable alternative at character 'o'. No viable alternative at character 'o'.",
380
					e.getMessage());
381
		}
358
	}
382
	}
359
383
360
	@Test
384
	@Test
Lines 506-546 Link Here
506
		Edge edge = new Edge.Builder(n1, n2).buildEdge();
530
		Edge edge = new Edge.Builder(n1, n2).buildEdge();
507
531
508
		// set valid string values
532
		// set valid string values
509
		String validEdgeStyle = "bold";
533
		String[] validEdgeStyleItems = { "bold", "dashed", "dotted", "invis",
534
				"solid", "tapered" };
535
536
		for (String validEdgeStyleItem : validEdgeStyleItems) {
537
			DotAttributes.setStyle(edge, validEdgeStyleItem);
538
			assertEquals(validEdgeStyleItem, DotAttributes.getStyle(edge));
539
540
			Style styleParsed = StyleFactory.eINSTANCE.createStyle();
541
			StyleItem styleItem = StyleFactory.eINSTANCE.createStyleItem();
542
			styleItem.setName(validEdgeStyleItem);
543
			styleParsed.getStyleItems().add(styleItem);
544
			assertTrue(EcoreUtil.equals(styleParsed,
545
					DotAttributes.getStyleParsed(edge)));
546
		}
547
548
		String validEdgeStyle = "";
510
		DotAttributes.setStyle(edge, validEdgeStyle);
549
		DotAttributes.setStyle(edge, validEdgeStyle);
511
		assertEquals(validEdgeStyle, DotAttributes.getStyle(edge));
550
		assertEquals(validEdgeStyle, DotAttributes.getStyle(edge));
512
551
513
		validEdgeStyle = "dashed";
552
		// set valid parsed values
514
		DotAttributes.setStyle(edge, validEdgeStyle);
553
		Style styleParsed = StyleFactory.eINSTANCE.createStyle();
515
		assertEquals(validEdgeStyle, DotAttributes.getStyle(edge));
554
		StyleItem styleItem1 = StyleFactory.eINSTANCE.createStyleItem();
555
		styleItem1.setName("bold");
556
		StyleItem styleItem2 = StyleFactory.eINSTANCE.createStyleItem();
557
		styleItem2.setName("dashed");
516
558
517
		validEdgeStyle = "dotted";
559
		styleParsed.getStyleItems().add(styleItem1);
518
		DotAttributes.setStyle(edge, validEdgeStyle);
560
		styleParsed.getStyleItems().add(styleItem2);
519
		assertEquals(validEdgeStyle, DotAttributes.getStyle(edge));
561
		DotAttributes.setStyleParsed(edge, styleParsed);
562
		assertEquals("bold , dashed", DotAttributes.getStyle(edge));
520
563
521
		validEdgeStyle = "invis";
564
		// set syntactically invalid values
522
		DotAttributes.setStyle(edge, validEdgeStyle);
565
		try {
523
		assertEquals(validEdgeStyle, DotAttributes.getStyle(edge));
566
			DotAttributes.setStyle(edge, "bold, ");
567
			fail("Expecting IllegalArgumentException.");
568
		} catch (IllegalArgumentException e) {
569
			assertEquals(
570
					"Cannot set edge attribute 'style' to 'bold, '. The value 'bold, ' is not a syntactically correct style: Mismatched input '<EOF>' expecting RULE_NAME.",
571
					e.getMessage());
572
		}
524
573
525
		validEdgeStyle = "solid";
574
		// set syntactically correct, but semantically invalid values
526
		DotAttributes.setStyle(edge, validEdgeStyle);
527
		assertEquals(validEdgeStyle, DotAttributes.getStyle(edge));
528
529
		validEdgeStyle = "tapered";
530
		DotAttributes.setStyle(edge, validEdgeStyle);
531
		assertEquals(validEdgeStyle, DotAttributes.getStyle(edge));
532
533
		validEdgeStyle = "";
534
		DotAttributes.setStyle(edge, validEdgeStyle);
535
		assertEquals(validEdgeStyle, DotAttributes.getStyle(edge));
536
537
		// set invalid string values
538
		try {
575
		try {
539
			DotAttributes.setStyle(edge, "foo");
576
			DotAttributes.setStyle(edge, "foo");
540
			fail("Expecting IllegalArgumentException.");
577
			fail("Expecting IllegalArgumentException.");
541
		} catch (IllegalArgumentException e) {
578
		} catch (IllegalArgumentException e) {
542
			assertEquals(
579
			assertEquals(
543
					"Cannot set edge attribute 'style' to 'foo'. The style value 'foo' is not semantically correct: Value should be one of 'bold', 'dashed', 'dotted', 'invis', 'solid', 'tapered'.",
580
					"Cannot set edge attribute 'style' to 'foo'. The style value 'foo' is not semantically correct: Value should be one of 'bold', 'dashed', 'dotted', 'invis', 'solid', 'tapered'.",
581
					e.getMessage());
582
		}
583
584
		try {
585
			DotAttributes.setStyle(edge, "diagonals");
586
			fail("Expecting IllegalArgumentException.");
587
		} catch (IllegalArgumentException e) {
588
			assertEquals(
589
					"Cannot set edge attribute 'style' to 'diagonals'. The style value 'diagonals' is not semantically correct: Value should be one of 'bold', 'dashed', 'dotted', 'invis', 'solid', 'tapered'.",
544
					e.getMessage());
590
					e.getMessage());
545
		}
591
		}
546
	}
592
	}
Lines 580-586 Link Here
580
		assertTrue(EcoreUtil.equals(validEdgeTailLpParsed,
626
		assertTrue(EcoreUtil.equals(validEdgeTailLpParsed,
581
				DotAttributes.getTailLpParsed(edge)));
627
				DotAttributes.getTailLpParsed(edge)));
582
628
583
		// TODO: add test cases for setting invalid edge tail label positions
629
		// set invalid string values
630
		try {
631
			DotAttributes.setTailLp(edge, "foo");
632
			fail("Expecting IllegalArgumentException.");
633
		} catch (IllegalArgumentException e) {
634
			assertEquals(
635
					"Cannot set edge attribute 'tail_lp' to 'foo'. The value 'foo' is not a syntactically correct point: No viable alternative at character 'f'. No viable alternative at character 'o'. No viable alternative at character 'o'.",
636
					e.getMessage());
637
		}
584
	}
638
	}
585
639
586
	@Test
640
	@Test
Lines 593-600 Link Here
593
		final String validEdgeXLabel = "edgeXLabel";
647
		final String validEdgeXLabel = "edgeXLabel";
594
		DotAttributes.setXLabel(edge, validEdgeXLabel);
648
		DotAttributes.setXLabel(edge, validEdgeXLabel);
595
		assertEquals(validEdgeXLabel, DotAttributes.getXLabel(edge));
649
		assertEquals(validEdgeXLabel, DotAttributes.getXLabel(edge));
596
597
		// TODO: add test cases for setting invalid edge xlabel
598
	}
650
	}
599
651
600
	@Test
652
	@Test
Lines 615-622 Link Here
615
		assertEquals("33.0, 54.6", DotAttributes.getXlp(edge));
667
		assertEquals("33.0, 54.6", DotAttributes.getXlp(edge));
616
		assertTrue(EcoreUtil.equals(DotAttributes.getXlpParsed(edge), xlp));
668
		assertTrue(EcoreUtil.equals(DotAttributes.getXlpParsed(edge), xlp));
617
669
618
		// TODO: add test cases for setting invalid edge exterior label
670
		// set invalid string values
619
		// positions
671
		try {
672
			DotAttributes.setXlp(edge, "foo");
673
			fail("Expecting IllegalArgumentException.");
674
		} catch (IllegalArgumentException e) {
675
			assertEquals(
676
					"Cannot set edge attribute 'xlp' to 'foo'. The value 'foo' is not a syntactically correct point: No viable alternative at character 'f'. No viable alternative at character 'o'. No viable alternative at character 'o'.",
677
					e.getMessage());
678
		}
620
	}
679
	}
621
680
622
	@Test
681
	@Test
Lines 668-673 Link Here
668
	}
727
	}
669
728
670
	@Test
729
	@Test
730
	public void graph_label() {
731
		Graph g = new Graph.Builder().build();
732
733
		// set valid string values
734
		final String validGraphLabel = "graphLabel";
735
		DotAttributes.setLabel(g, validGraphLabel);
736
		assertEquals(validGraphLabel, DotAttributes.getLabel(g));
737
	}
738
739
	@Test
671
	public void graph_layout() {
740
	public void graph_layout() {
672
		Graph g = new Graph.Builder().build();
741
		Graph g = new Graph.Builder().build();
673
742
Lines 675-708 Link Here
675
		String validGraphLayout = "circo";
744
		String validGraphLayout = "circo";
676
		DotAttributes.setLayout(g, validGraphLayout);
745
		DotAttributes.setLayout(g, validGraphLayout);
677
		assertEquals(validGraphLayout, DotAttributes.getLayout(g));
746
		assertEquals(validGraphLayout, DotAttributes.getLayout(g));
747
		assertEquals(Layout.CIRCO, DotAttributes.getLayoutParsed(g));
678
748
679
		validGraphLayout = "dot";
749
		validGraphLayout = "dot";
680
		DotAttributes.setLayout(g, validGraphLayout);
750
		DotAttributes.setLayout(g, validGraphLayout);
681
		assertEquals(validGraphLayout, DotAttributes.getLayout(g));
751
		assertEquals(validGraphLayout, DotAttributes.getLayout(g));
752
		assertEquals(Layout.DOT, DotAttributes.getLayoutParsed(g));
682
753
683
		validGraphLayout = "fdp";
754
		validGraphLayout = "fdp";
684
		DotAttributes.setLayout(g, validGraphLayout);
755
		DotAttributes.setLayout(g, validGraphLayout);
685
		assertEquals(validGraphLayout, DotAttributes.getLayout(g));
756
		assertEquals(validGraphLayout, DotAttributes.getLayout(g));
757
		assertEquals(Layout.FDP, DotAttributes.getLayoutParsed(g));
686
758
687
		validGraphLayout = "grid";
759
		validGraphLayout = "grid";
688
		DotAttributes.setLayout(g, validGraphLayout);
760
		DotAttributes.setLayout(g, validGraphLayout);
689
		assertEquals(validGraphLayout, DotAttributes.getLayout(g));
761
		assertEquals(validGraphLayout, DotAttributes.getLayout(g));
762
		assertEquals(Layout.GRID, DotAttributes.getLayoutParsed(g));
690
763
691
		validGraphLayout = "neato";
764
		validGraphLayout = "neato";
692
		DotAttributes.setLayout(g, validGraphLayout);
765
		DotAttributes.setLayout(g, validGraphLayout);
693
		assertEquals(validGraphLayout, DotAttributes.getLayout(g));
766
		assertEquals(validGraphLayout, DotAttributes.getLayout(g));
767
		assertEquals(Layout.NEATO, DotAttributes.getLayoutParsed(g));
694
768
695
		validGraphLayout = "osage";
769
		validGraphLayout = "osage";
696
		DotAttributes.setLayout(g, validGraphLayout);
770
		DotAttributes.setLayout(g, validGraphLayout);
697
		assertEquals(validGraphLayout, DotAttributes.getLayout(g));
771
		assertEquals(validGraphLayout, DotAttributes.getLayout(g));
772
		assertEquals(Layout.OSAGE, DotAttributes.getLayoutParsed(g));
698
773
699
		validGraphLayout = "sfdp";
774
		validGraphLayout = "sfdp";
700
		DotAttributes.setLayout(g, validGraphLayout);
775
		DotAttributes.setLayout(g, validGraphLayout);
701
		assertEquals(validGraphLayout, DotAttributes.getLayout(g));
776
		assertEquals(validGraphLayout, DotAttributes.getLayout(g));
777
		assertEquals(Layout.SFDP, DotAttributes.getLayoutParsed(g));
702
778
703
		validGraphLayout = "twopi";
779
		validGraphLayout = "twopi";
704
		DotAttributes.setLayout(g, validGraphLayout);
780
		DotAttributes.setLayout(g, validGraphLayout);
705
		assertEquals(validGraphLayout, DotAttributes.getLayout(g));
781
		assertEquals(validGraphLayout, DotAttributes.getLayout(g));
782
		assertEquals(Layout.TWOPI, DotAttributes.getLayoutParsed(g));
783
784
		// set valid parsed values
785
		Layout validGraphLayoutParsed = Layout.CIRCO;
786
		DotAttributes.setLayoutParsed(g, validGraphLayoutParsed);
787
		assertEquals(validGraphLayoutParsed.toString(),
788
				DotAttributes.getLayout(g));
789
		assertEquals(validGraphLayoutParsed, DotAttributes.getLayoutParsed(g));
790
791
		validGraphLayoutParsed = Layout.DOT;
792
		DotAttributes.setLayoutParsed(g, validGraphLayoutParsed);
793
		assertEquals(validGraphLayoutParsed.toString(),
794
				DotAttributes.getLayout(g));
795
		assertEquals(validGraphLayoutParsed, DotAttributes.getLayoutParsed(g));
796
797
		validGraphLayoutParsed = Layout.CIRCO;
798
		DotAttributes.setLayoutParsed(g, validGraphLayoutParsed);
799
		assertEquals(validGraphLayoutParsed.toString(),
800
				DotAttributes.getLayout(g));
801
		assertEquals(validGraphLayoutParsed, DotAttributes.getLayoutParsed(g));
802
803
		validGraphLayoutParsed = Layout.FDP;
804
		DotAttributes.setLayoutParsed(g, validGraphLayoutParsed);
805
		assertEquals(validGraphLayoutParsed.toString(),
806
				DotAttributes.getLayout(g));
807
		assertEquals(validGraphLayoutParsed, DotAttributes.getLayoutParsed(g));
808
809
		validGraphLayoutParsed = Layout.GRID;
810
		DotAttributes.setLayoutParsed(g, validGraphLayoutParsed);
811
		assertEquals(validGraphLayoutParsed.toString(),
812
				DotAttributes.getLayout(g));
813
		assertEquals(validGraphLayoutParsed, DotAttributes.getLayoutParsed(g));
814
815
		validGraphLayoutParsed = Layout.NEATO;
816
		DotAttributes.setLayoutParsed(g, validGraphLayoutParsed);
817
		assertEquals(validGraphLayoutParsed.toString(),
818
				DotAttributes.getLayout(g));
819
		assertEquals(validGraphLayoutParsed, DotAttributes.getLayoutParsed(g));
820
821
		validGraphLayoutParsed = Layout.OSAGE;
822
		DotAttributes.setLayoutParsed(g, validGraphLayoutParsed);
823
		assertEquals(validGraphLayoutParsed.toString(),
824
				DotAttributes.getLayout(g));
825
		assertEquals(validGraphLayoutParsed, DotAttributes.getLayoutParsed(g));
826
827
		validGraphLayoutParsed = Layout.SFDP;
828
		DotAttributes.setLayoutParsed(g, validGraphLayoutParsed);
829
		assertEquals(validGraphLayoutParsed.toString(),
830
				DotAttributes.getLayout(g));
831
		assertEquals(validGraphLayoutParsed, DotAttributes.getLayoutParsed(g));
832
833
		validGraphLayoutParsed = Layout.TWOPI;
834
		DotAttributes.setLayoutParsed(g, validGraphLayoutParsed);
835
		assertEquals(validGraphLayoutParsed.toString(),
836
				DotAttributes.getLayout(g));
837
		assertEquals(validGraphLayoutParsed, DotAttributes.getLayoutParsed(g));
706
838
707
		// set invalid string values
839
		// set invalid string values
708
		try {
840
		try {
Lines 711-716 Link Here
711
		} catch (IllegalArgumentException e) {
843
		} catch (IllegalArgumentException e) {
712
			assertEquals(
844
			assertEquals(
713
					"Cannot set graph attribute 'layout' to 'foo'. The layout value 'foo' is not semantically correct: Value should be one of 'circo', 'dot', 'fdp', 'grid', 'neato', 'osage', 'sfdp', 'twopi'.",
845
					"Cannot set graph attribute 'layout' to 'foo'. The layout value 'foo' is not semantically correct: Value should be one of 'circo', 'dot', 'fdp', 'grid', 'neato', 'osage', 'sfdp', 'twopi'.",
846
					e.getMessage());
847
		}
848
	}
849
850
	@Test
851
	public void graph_lp() {
852
		Graph g = new Graph.Builder().build();
853
854
		// set valid string values
855
		String validGraphLp = "0.0,1.1";
856
		DotAttributes.setLp(g, validGraphLp);
857
		assertEquals(validGraphLp, DotAttributes.getLp(g));
858
859
		// set valid parsed values
860
		Point validGraphLpParsed = PointFactory.eINSTANCE.createPoint();
861
		validGraphLpParsed.setX(2.2);
862
		validGraphLpParsed.setY(3.3);
863
		DotAttributes.setLpParsed(g, validGraphLpParsed);
864
		assertTrue(EcoreUtil.equals(validGraphLpParsed,
865
				DotAttributes.getLpParsed(g)));
866
		assertEquals("2.2, 3.3", DotAttributes.getLp(g));
867
868
		// set invalid string values
869
		try {
870
			DotAttributes.setLp(g, "foo");
871
			fail("Expecting IllegalArgumentException.");
872
		} catch (IllegalArgumentException e) {
873
			assertEquals(
874
					"Cannot set graph attribute 'lp' to 'foo'. The value 'foo' is not a syntactically correct point: No viable alternative at character 'f'. No viable alternative at character 'o'. No viable alternative at character 'o'.",
714
					e.getMessage());
875
					e.getMessage());
715
		}
876
		}
716
	}
877
	}
Lines 915-920 Link Here
915
	}
1076
	}
916
1077
917
	@Test
1078
	@Test
1079
	public void graph_type() {
1080
		Graph g = new Graph.Builder().build();
1081
1082
		// set valid string values
1083
		String validGraphType = "graph";
1084
		DotAttributes._setType(g, validGraphType);
1085
		assertEquals(validGraphType, DotAttributes._getType(g));
1086
1087
		validGraphType = "digraph";
1088
		DotAttributes._setType(g, validGraphType);
1089
		assertEquals(validGraphType, DotAttributes._getType(g));
1090
1091
		// set invalid string values
1092
		try {
1093
			DotAttributes._setType(g, "foo");
1094
			fail("Expecting IllegalArgumentException.");
1095
		} catch (IllegalArgumentException e) {
1096
			assertEquals(
1097
					"Cannot set graph attribute \"type\" to \"foo\"; supported values: graph, digraph",
1098
					e.getMessage());
1099
		}
1100
	}
1101
1102
	@Test
918
	public void node_distortion() {
1103
	public void node_distortion() {
919
		Node n = new Node.Builder().buildNode();
1104
		Node n = new Node.Builder().buildNode();
920
1105
Lines 967-996 Link Here
967
	}
1152
	}
968
1153
969
	@Test
1154
	@Test
970
	public void graph_type() {
971
		Graph g = new Graph.Builder().build();
972
973
		// set valid string values
974
		String validGraphType = "graph";
975
		DotAttributes._setType(g, validGraphType);
976
		assertEquals(validGraphType, DotAttributes._getType(g));
977
978
		validGraphType = "digraph";
979
		DotAttributes._setType(g, validGraphType);
980
		assertEquals(validGraphType, DotAttributes._getType(g));
981
982
		// set invalid string values
983
		try {
984
			DotAttributes._setType(g, "foo");
985
			fail("Expecting IllegalArgumentException.");
986
		} catch (IllegalArgumentException e) {
987
			assertEquals(
988
					"Cannot set graph attribute \"type\" to \"foo\"; supported values: graph, digraph",
989
					e.getMessage());
990
		}
991
	}
992
993
	@Test
994
	public void node_fixedsize() {
1155
	public void node_fixedsize() {
995
		Node n = new Node.Builder().buildNode();
1156
		Node n = new Node.Builder().buildNode();
996
1157
Lines 1014-1020 Link Here
1014
		assertEquals(validNodeFixedSizeParsed,
1175
		assertEquals(validNodeFixedSizeParsed,
1015
				DotAttributes.getFixedSizeParsed(n));
1176
				DotAttributes.getFixedSizeParsed(n));
1016
1177
1017
		// TODO: add test cases for setting invalid graph fixedsize
1178
		// set invalid string values
1179
		try {
1180
			DotAttributes.setFixedSize(n, "foo");
1181
			fail("Expecting IllegalArgumentException.");
1182
		} catch (IllegalArgumentException e) {
1183
			assertEquals(
1184
					"Cannot set node attribute 'fixedsize' to 'foo'. The value 'foo' is not a syntactically correct bool: The given value 'foo' does not (case-insensitively) equal 'true', 'yes', 'false', or 'no' and is also not parsable as an integer value.",
1185
					e.getMessage());
1186
		}
1018
	}
1187
	}
1019
1188
1020
	@Test
1189
	@Test
Lines 1082-1089 Link Here
1082
		final String validNodeLabel = "nodeLabel";
1251
		final String validNodeLabel = "nodeLabel";
1083
		DotAttributes.setLabel(n, validNodeLabel);
1252
		DotAttributes.setLabel(n, validNodeLabel);
1084
		assertEquals(validNodeLabel, DotAttributes.getLabel(n));
1253
		assertEquals(validNodeLabel, DotAttributes.getLabel(n));
1085
1086
		// TODO: add test cases for setting invalid node label
1087
	}
1254
	}
1088
1255
1089
	@Test
1256
	@Test
Lines 1123-1128 Link Here
1123
		} catch (IllegalArgumentException e) {
1290
		} catch (IllegalArgumentException e) {
1124
			assertEquals(
1291
			assertEquals(
1125
					"Cannot set node attribute 'pos' to '47x, 11'. The value '47x, 11' is not a syntactically correct point: No viable alternative at character 'x'.",
1292
					"Cannot set node attribute 'pos' to '47x, 11'. The value '47x, 11' is not a syntactically correct point: No viable alternative at character 'x'.",
1293
					e.getMessage());
1294
		}
1295
	}
1296
1297
	@Test
1298
	public void node_shape() {
1299
		Node n = new Node.Builder().buildNode();
1300
1301
		// set valid (polygon based) string values
1302
		String[] validPolygonBasedNodeShapes = { "assembly", "box", "box3d",
1303
				"cds", "circle", "component", "cylinder", "diamond",
1304
				"doublecircle", "doubleoctagon", "egg", "ellipse",
1305
				"fivepoverhang", "folder", "hexagon", "house", "insulator",
1306
				"invhouse", "invtrapezium", "invtriangle", "larrow",
1307
				"lpromoter", "Mcircle", "Mdiamond", "Msquare", "none", "note",
1308
				"noverhang", "octagon", "oval", "parallelogram", "pentagon",
1309
				"plain", "plaintext", "point", "polygon", "primersite",
1310
				"promoter", "proteasesite", "proteinstab", "rarrow", "rect",
1311
				"rectangle", "restrictionsite", "ribosite", "rnastab",
1312
				"rpromoter", "septagon", "signature", "square", "star", "tab",
1313
				"terminator", "threepoverhang", "trapezium", "triangle",
1314
				"tripleoctagon", "underline", "utr" };
1315
1316
		for (String validPolygonBasedNodeShape : validPolygonBasedNodeShapes) {
1317
			DotAttributes.setShape(n, validPolygonBasedNodeShape);
1318
			assertEquals(validPolygonBasedNodeShape, DotAttributes.getShape(n));
1319
1320
			Shape shapeParsed = ShapeFactory.eINSTANCE.createShape();
1321
			PolygonBasedShape polygonBasedShape = ShapeFactory.eINSTANCE
1322
					.createPolygonBasedShape();
1323
			polygonBasedShape.setShape(
1324
					PolygonBasedNodeShape.get(validPolygonBasedNodeShape));
1325
			shapeParsed.setShape(polygonBasedShape);
1326
			assertTrue(EcoreUtil.equals(shapeParsed,
1327
					DotAttributes.getShapeParsed(n)));
1328
		}
1329
1330
		// set valid (record based) string values
1331
		String[] validRecordBasedNodeShapes = { "record", "Mrecord" };
1332
1333
		for (String validRecordBasedNodeShape : validRecordBasedNodeShapes) {
1334
			DotAttributes.setShape(n, validRecordBasedNodeShape);
1335
			assertEquals(validRecordBasedNodeShape, DotAttributes.getShape(n));
1336
1337
			Shape shapeParsed = ShapeFactory.eINSTANCE.createShape();
1338
			RecordBasedShape recordBasedShape = ShapeFactory.eINSTANCE
1339
					.createRecordBasedShape();
1340
			recordBasedShape.setShape(
1341
					RecordBasedNodeShape.get(validRecordBasedNodeShape));
1342
			shapeParsed.setShape(recordBasedShape);
1343
			assertTrue(EcoreUtil.equals(shapeParsed,
1344
					DotAttributes.getShapeParsed(n)));
1345
		}
1346
1347
		// set valid parsed values
1348
		Shape validNodeShapeParsed = ShapeFactory.eINSTANCE.createShape();
1349
		PolygonBasedShape polygonBasedShape = ShapeFactory.eINSTANCE
1350
				.createPolygonBasedShape();
1351
		polygonBasedShape.setShape(PolygonBasedNodeShape.BOX);
1352
		validNodeShapeParsed.setShape(polygonBasedShape);
1353
		DotAttributes.setShapeParsed(n, validNodeShapeParsed);
1354
		assertEquals("box", DotAttributes.getShape(n));
1355
1356
		// set invalid string values
1357
		try {
1358
			DotAttributes.setShape(n, "foo");
1359
			fail("Expecting IllegalArgumentException.");
1360
		} catch (IllegalArgumentException e) {
1361
			assertEquals(
1362
					"Cannot set node attribute 'shape' to 'foo'. The value 'foo' is not a syntactically correct shape: Mismatched character 'o' expecting 'l'.",
1363
					e.getMessage());
1364
		}
1365
	}
1366
1367
	@Test
1368
	public void node_sides() {
1369
		Node n = new Node.Builder().buildNode();
1370
1371
		// set valid string values
1372
		String validNodeSides = "5";
1373
		DotAttributes.setSides(n, validNodeSides);
1374
		assertEquals(validNodeSides, DotAttributes.getSides(n));
1375
		assertEquals(5, DotAttributes.getSidesParsed(n).intValue());
1376
1377
		// set the minimum valid value
1378
		validNodeSides = "0";
1379
		DotAttributes.setSides(n, validNodeSides);
1380
		assertEquals(validNodeSides, DotAttributes.getSides(n));
1381
		assertEquals(0, DotAttributes.getSidesParsed(n).intValue());
1382
1383
		// set valid parsed values
1384
		Integer validNodeSidesParsed = 3;
1385
		DotAttributes.setSidesParsed(n, validNodeSidesParsed);
1386
		assertEquals("3", DotAttributes.getSides(n));
1387
		assertEquals(validNodeSidesParsed, DotAttributes.getSidesParsed(n));
1388
1389
		validNodeSidesParsed = 42;
1390
		DotAttributes.setSidesParsed(n, validNodeSidesParsed);
1391
		assertEquals("42", DotAttributes.getSides(n));
1392
		assertEquals(validNodeSidesParsed, DotAttributes.getSidesParsed(n));
1393
1394
		// set syntactically invalid values
1395
		try {
1396
			DotAttributes.setSides(n, "42x");
1397
			fail("Expecting IllegalArgumentException.");
1398
		} catch (IllegalArgumentException e) {
1399
			assertEquals(
1400
					"Cannot set node attribute 'sides' to '42x'. The value '42x' is not a syntactically correct int: For input string: \"42x\".",
1401
					e.getMessage());
1402
		}
1403
1404
		// set syntactically correct, but semantically invalid values
1405
		try {
1406
			DotAttributes.setSides(n, "-1");
1407
			fail("Expecting IllegalArgumentException.");
1408
		} catch (IllegalArgumentException e) {
1409
			assertEquals(
1410
					"Cannot set node attribute 'sides' to '-1'. The int value '-1' is not semantically correct: Value may not be smaller than 0.",
1411
					e.getMessage());
1412
		}
1413
	}
1414
1415
	@Test
1416
	public void node_skew() {
1417
		Node n = new Node.Builder().buildNode();
1418
1419
		// set valid string values
1420
		String validNodeSkew = "5";
1421
		DotAttributes.setSkew(n, validNodeSkew);
1422
		assertEquals(validNodeSkew, DotAttributes.getSkew(n));
1423
		assertEquals(5.0, DotAttributes.getSkewParsed(n).doubleValue(), 0.0);
1424
1425
		// set the minimum valid value
1426
		validNodeSkew = "-100.0";
1427
		DotAttributes.setSkew(n, validNodeSkew);
1428
		assertEquals(validNodeSkew, DotAttributes.getSkew(n));
1429
		assertEquals(-100.0, DotAttributes.getSkewParsed(n).doubleValue(), 0.0);
1430
1431
		// set valid parsed values
1432
		Double validNodeSkewParsed = 10.0;
1433
		DotAttributes.setSkewParsed(n, validNodeSkewParsed);
1434
		assertEquals("10.0", DotAttributes.getSkew(n));
1435
		assertEquals(validNodeSkewParsed, DotAttributes.getSkewParsed(n));
1436
1437
		validNodeSkewParsed = 9.9;
1438
		DotAttributes.setSkewParsed(n, validNodeSkewParsed);
1439
		assertEquals("9.9", DotAttributes.getSkew(n));
1440
		assertEquals(validNodeSkewParsed, DotAttributes.getSkewParsed(n));
1441
1442
		// set syntactically invalid values
1443
		try {
1444
			DotAttributes.setSkew(n, "42x");
1445
			fail("Expecting IllegalArgumentException.");
1446
		} catch (IllegalArgumentException e) {
1447
			assertEquals(
1448
					"Cannot set node attribute 'skew' to '42x'. The value '42x' is not a syntactically correct double: For input string: \"42x\".",
1449
					e.getMessage());
1450
		}
1451
1452
		// set syntactically correct, but semantically invalid values
1453
		try {
1454
			DotAttributes.setSkew(n, "-100.01");
1455
			fail("Expecting IllegalArgumentException.");
1456
		} catch (IllegalArgumentException e) {
1457
			assertEquals(
1458
					"Cannot set node attribute 'skew' to '-100.01'. The double value '-100.01' is not semantically correct: Value may not be smaller than -100.0.",
1459
					e.getMessage());
1460
		}
1461
	}
1462
1463
	@Test
1464
	public void node_style() {
1465
		Node node = new Node.Builder().buildNode();
1466
1467
		// set valid string values
1468
		String[] validNodeStyleItems = { "bold", "dashed", "diagonals",
1469
				"dotted", "filled", "invis", "radial", "rounded", "solid",
1470
				"striped", "wedged" };
1471
1472
		for (String validNodeStyleItem : validNodeStyleItems) {
1473
			DotAttributes.setStyle(node, validNodeStyleItem);
1474
			assertEquals(validNodeStyleItem, DotAttributes.getStyle(node));
1475
1476
			Style styleParsed = StyleFactory.eINSTANCE.createStyle();
1477
			StyleItem styleItem = StyleFactory.eINSTANCE.createStyleItem();
1478
			styleItem.setName(validNodeStyleItem);
1479
			styleParsed.getStyleItems().add(styleItem);
1480
			assertTrue(EcoreUtil.equals(styleParsed,
1481
					DotAttributes.getStyleParsed(node)));
1482
		}
1483
1484
		String validNodeStyle = "";
1485
		DotAttributes.setStyle(node, validNodeStyle);
1486
		assertEquals(validNodeStyle, DotAttributes.getStyle(node));
1487
1488
		// set valid parsed values
1489
		Style styleParsed = StyleFactory.eINSTANCE.createStyle();
1490
		StyleItem styleItem1 = StyleFactory.eINSTANCE.createStyleItem();
1491
		styleItem1.setName("bold");
1492
		StyleItem styleItem2 = StyleFactory.eINSTANCE.createStyleItem();
1493
		styleItem2.setName("dashed");
1494
1495
		styleParsed.getStyleItems().add(styleItem1);
1496
		styleParsed.getStyleItems().add(styleItem2);
1497
		DotAttributes.setStyleParsed(node, styleParsed);
1498
		assertEquals("bold , dashed", DotAttributes.getStyle(node));
1499
1500
		// set syntactically invalid values
1501
		try {
1502
			DotAttributes.setStyle(node, "bold, ");
1503
			fail("Expecting IllegalArgumentException.");
1504
		} catch (IllegalArgumentException e) {
1505
			assertEquals(
1506
					"Cannot set node attribute 'style' to 'bold, '. The value 'bold, ' is not a syntactically correct style: Mismatched input '<EOF>' expecting RULE_NAME.",
1507
					e.getMessage());
1508
		}
1509
1510
		// set syntactically correct, but semantically invalid values
1511
		try {
1512
			DotAttributes.setStyle(node, "foo");
1513
			fail("Expecting IllegalArgumentException.");
1514
		} catch (IllegalArgumentException e) {
1515
			assertEquals(
1516
					"Cannot set node attribute 'style' to 'foo'. The style value 'foo' is not semantically correct: Value should be one of 'bold', 'dashed', 'diagonals', 'dotted', 'filled', 'invis', 'radial', 'rounded', 'solid', 'striped', 'wedged'.",
1517
					e.getMessage());
1518
		}
1519
1520
		try {
1521
			DotAttributes.setStyle(node, "tapered");
1522
			fail("Expecting IllegalArgumentException.");
1523
		} catch (IllegalArgumentException e) {
1524
			assertEquals(
1525
					"Cannot set node attribute 'style' to 'tapered'. The style value 'tapered' is not semantically correct: Value should be one of 'bold', 'dashed', 'diagonals', 'dotted', 'filled', 'invis', 'radial', 'rounded', 'solid', 'striped', 'wedged'.",
1126
					e.getMessage());
1526
					e.getMessage());
1127
		}
1527
		}
1128
	}
1528
	}
Lines 1183-1190 Link Here
1183
		final String validNodeXLabel = "nodeXLabel";
1583
		final String validNodeXLabel = "nodeXLabel";
1184
		DotAttributes.setXLabel(n, validNodeXLabel);
1584
		DotAttributes.setXLabel(n, validNodeXLabel);
1185
		assertEquals(validNodeXLabel, DotAttributes.getXLabel(n));
1585
		assertEquals(validNodeXLabel, DotAttributes.getXLabel(n));
1186
1187
		// TODO: add test cases for setting invalid node xlabel
1188
	}
1586
	}
1189
1587
1190
	@Test
1588
	@Test
Lines 1204-1210 Link Here
1204
		assertEquals("33.0, 54.6!", DotAttributes.getXlp(n));
1602
		assertEquals("33.0, 54.6!", DotAttributes.getXlp(n));
1205
		assertTrue(EcoreUtil.equals(DotAttributes.getXlpParsed(n), xlp));
1603
		assertTrue(EcoreUtil.equals(DotAttributes.getXlpParsed(n), xlp));
1206
1604
1207
		// TODO: add test cases for setting invalid node exterior label
1605
		// set invalid string values
1208
		// positions
1606
		try {
1607
			DotAttributes.setXlp(n, "foo");
1608
			fail("Expecting IllegalArgumentException.");
1609
		} catch (IllegalArgumentException e) {
1610
			assertEquals(
1611
					"Cannot set node attribute 'xlp' to 'foo'. The value 'foo' is not a syntactically correct point: No viable alternative at character 'f'. No viable alternative at character 'o'. No viable alternative at character 'o'.",
1612
					e.getMessage());
1613
		}
1209
	}
1614
	}
1210
}
1615
}
(-)a/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/DotAttributes.java (-20 / +111 lines)
Lines 149-157 Link Here
149
	public static final String LAYOUT__G = "layout";
149
	public static final String LAYOUT__G = "layout";
150
150
151
	/**
151
	/**
152
	 * Specifies 'lp' attribute (label position) of an edge.
152
	 * Specifies the 'lp' attribute (label position) of a graph or edge.
153
	 */
153
	 */
154
	public static final String LP__E = "lp";
154
	public static final String LP__GE = "lp";
155
155
156
	/**
156
	/**
157
	 * Specifies the 'pos' attribute of a node or edge.
157
	 * Specifies the 'pos' attribute of a node or edge.
Lines 738-749 Link Here
738
	}
738
	}
739
739
740
	/**
740
	/**
741
	 * Returns the value of the {@link #LAYOUT__G} property of the given
741
	 * Returns the (parsed) value of the {@link #LAYOUT__G} property of the
742
	 * {@link Graph}.
742
	 * given {@link Graph}.
743
	 * 
743
	 * 
744
	 * @param graph
744
	 * @param graph
745
	 *            The {@link Graph} for which to return the value of the
745
	 *            The {@link Graph} for which to return the value of the
746
	 *            {@link #LAYOUT__G} property.
746
	 *            {@link #LAYOUT__G} property, parsed as a {@link Layout}.
747
	 * @return The value of the {@link #LAYOUT__G} property of the given
747
	 * @return The value of the {@link #LAYOUT__G} property of the given
748
	 *         {@link Graph}.
748
	 *         {@link Graph}.
749
	 */
749
	 */
Lines 752-783 Link Here
752
	}
752
	}
753
753
754
	/**
754
	/**
755
	 * Returns the value of the {@link #LP__E} property of the given
755
	 * Returns the value of the {@link #LP__GE} property of the given
756
	 * {@link Edge}.
756
	 * {@link Edge}.
757
	 * 
757
	 * 
758
	 * @param edge
758
	 * @param edge
759
	 *            The {@link Edge} for which to return the value of the
759
	 *            The {@link Edge} for which to return the value of the
760
	 *            {@link #LP__E} property.
760
	 *            {@link #LP__GE} property.
761
	 * @return The value of the {@link #LP__E} property of the given
761
	 * @return The value of the {@link #LP__GE} property of the given
762
	 *         {@link Edge}.
762
	 *         {@link Edge}.
763
	 */
763
	 */
764
	public static String getLp(Edge edge) {
764
	public static String getLp(Edge edge) {
765
		return (String) edge.attributesProperty().get(LP__E);
765
		return (String) edge.attributesProperty().get(LP__GE);
766
	}
766
	}
767
767
768
	/**
768
	/**
769
	 * Returns the (parsed) value of the {@link #LP__E} property of the given
769
	 * Returns the value of the {@link #LP__GE} property of the given
770
	 * {@link Graph}.
771
	 * 
772
	 * @param graph
773
	 *            The {@link Graph} for which to return the value of the
774
	 *            {@link #LP__GE} property.
775
	 * @return The value of the {@link #LP__GE} property of the given
776
	 *         {@link Graph}.
777
	 */
778
	public static String getLp(Graph graph) {
779
		return (String) graph.attributesProperty().get(LP__GE);
780
	}
781
782
	/**
783
	 * Returns the (parsed) value of the {@link #LP__GE} property of the given
770
	 * {@link Edge}.
784
	 * {@link Edge}.
771
	 * 
785
	 * 
772
	 * @param edge
786
	 * @param edge
773
	 *            The {@link Edge} for which to return the value of the
787
	 *            The {@link Edge} for which to return the value of the
774
	 *            {@link #LP__E} property, parsed as a {@link Point}.
788
	 *            {@link #LP__GE} property, parsed as a {@link Point}.
775
	 * @return The value of the {@link #LP__E} property of the given
789
	 * @return The value of the {@link #LP__GE} property of the given
776
	 *         {@link Edge}.
790
	 *         {@link Edge}.
777
	 */
791
	 */
778
	public static Point getLpParsed(Edge edge) {
792
	public static Point getLpParsed(Edge edge) {
779
		return DotLanguageSupport.parseAttributeValue(
793
		return DotLanguageSupport.parseAttributeValue(
780
				DotLanguageSupport.POINT_PARSER, getLp(edge));
794
				DotLanguageSupport.POINT_PARSER, getLp(edge));
795
	}
796
797
	/**
798
	 * Returns the (parsed) value of the {@link #LP__GE} property of the given
799
	 * {@link Graph}.
800
	 * 
801
	 * @param graph
802
	 *            The {@link Graph} for which to return the value of the
803
	 *            {@link #LP__GE} property, parsed as a {@link Point}.
804
	 * @return The value of the {@link #LP__GE} property of the given
805
	 *         {@link Graph}.
806
	 */
807
	public static Point getLpParsed(Graph graph) {
808
		return DotLanguageSupport.parseAttributeValue(
809
				DotLanguageSupport.POINT_PARSER, getLp(graph));
781
	}
810
	}
782
811
783
	/**
812
	/**
Lines 1385-1392 Link Here
1385
	 *            {@link #FIXEDSIZE__N} property.
1414
	 *            {@link #FIXEDSIZE__N} property.
1386
	 * @param fixedSize
1415
	 * @param fixedSize
1387
	 *            The new value for the {@link #FIXEDSIZE__N} property.
1416
	 *            The new value for the {@link #FIXEDSIZE__N} property.
1417
	 * @throws IllegalArgumentException
1418
	 *             when the given <i>fixedSize</i> value is not supported.
1388
	 */
1419
	 */
1389
	public static void setFixedSize(Node node, String fixedSize) {
1420
	public static void setFixedSize(Node node, String fixedSize) {
1421
		validate(AttributeContext.NODE, FIXEDSIZE__N, fixedSize);
1390
		node.attributesProperty().put(FIXEDSIZE__N, fixedSize);
1422
		node.attributesProperty().put(FIXEDSIZE__N, fixedSize);
1391
	}
1423
	}
1392
1424
Lines 1399-1404 Link Here
1399
	 *            {@link #FIXEDSIZE__N} property.
1431
	 *            {@link #FIXEDSIZE__N} property.
1400
	 * @param fixedSizeParsed
1432
	 * @param fixedSizeParsed
1401
	 *            The new value for the {@link #FIXEDSIZE__N} property.
1433
	 *            The new value for the {@link #FIXEDSIZE__N} property.
1434
	 * @throws IllegalArgumentException
1435
	 *             when the given <i>fixedSizeParsed</i> value is not supported.
1402
	 */
1436
	 */
1403
	public static void setFixedSizeParsed(Node node, Boolean fixedSizeParsed) {
1437
	public static void setFixedSizeParsed(Node node, Boolean fixedSizeParsed) {
1404
		setFixedSize(node, fixedSizeParsed.toString());
1438
		setFixedSize(node, fixedSizeParsed.toString());
Lines 1462-1469 Link Here
1462
	 *            {@link #HEAD_LP__E} property.
1496
	 *            {@link #HEAD_LP__E} property.
1463
	 * @param headLp
1497
	 * @param headLp
1464
	 *            The new value for the {@link #HEAD_LP__E} property.
1498
	 *            The new value for the {@link #HEAD_LP__E} property.
1499
	 * @throws IllegalArgumentException
1500
	 *             when the given <i>headLp</i> value is not supported.
1465
	 */
1501
	 */
1466
	public static void setHeadLp(Edge edge, String headLp) {
1502
	public static void setHeadLp(Edge edge, String headLp) {
1503
		validate(AttributeContext.EDGE, HEAD_LP__E, headLp);
1467
		edge.attributesProperty().put(HEAD_LP__E, headLp);
1504
		edge.attributesProperty().put(HEAD_LP__E, headLp);
1468
	}
1505
	}
1469
1506
Lines 1476-1481 Link Here
1476
	 *            {@link #HEAD_LP__E} property.
1513
	 *            {@link #HEAD_LP__E} property.
1477
	 * @param headLpParsed
1514
	 * @param headLpParsed
1478
	 *            The new value for the {@link #HEAD_LP__E} property.
1515
	 *            The new value for the {@link #HEAD_LP__E} property.
1516
	 * @throws IllegalArgumentException
1517
	 *             when the given <i>headLpParsed</i> value is not supported.
1479
	 */
1518
	 */
1480
	public static void setHeadLpParsed(Edge edge, Point headLpParsed) {
1519
	public static void setHeadLpParsed(Edge edge, Point headLpParsed) {
1481
		setHeadLp(edge,
1520
		setHeadLp(edge,
Lines 1582-1588 Link Here
1582
	 *            The new value for the {@link #LABEL__GNE} property.
1621
	 *            The new value for the {@link #LABEL__GNE} property.
1583
	 */
1622
	 */
1584
	public static void setLabel(Graph graph, String label) {
1623
	public static void setLabel(Graph graph, String label) {
1585
		validate(AttributeContext.GRAPH, LABEL__GNE, label);
1586
		graph.attributesProperty().put(LABEL__GNE, label);
1624
		graph.attributesProperty().put(LABEL__GNE, label);
1587
	}
1625
	}
1588
1626
Lines 1634-1664 Link Here
1634
	}
1672
	}
1635
1673
1636
	/**
1674
	/**
1637
	 * Sets the {@link #LP__E} property of the given {@link Edge} to the given
1675
	 * Sets the {@link #LP__GE} property of the given {@link Edge} to the given
1638
	 * <i>lp</i> value.
1676
	 * <i>lp</i> value.
1639
	 * 
1677
	 * 
1640
	 * @param edge
1678
	 * @param edge
1641
	 *            The {@link Edge} for which to change the value of the
1679
	 *            The {@link Edge} for which to change the value of the
1642
	 *            {@link #LP__E} property.
1680
	 *            {@link #LP__GE} property.
1643
	 * @param lp
1681
	 * @param lp
1644
	 *            The new value for the {@link #LP__E} property.
1682
	 *            The new value for the {@link #LP__GE} property.
1683
	 * @throws IllegalArgumentException
1684
	 *             when the given <i>lp</i> value is not supported.
1645
	 */
1685
	 */
1646
	public static void setLp(Edge edge, String lp) {
1686
	public static void setLp(Edge edge, String lp) {
1647
		edge.attributesProperty().put(LP__E, lp);
1687
		validate(AttributeContext.EDGE, LP__GE, lp);
1688
		edge.attributesProperty().put(LP__GE, lp);
1648
	}
1689
	}
1649
1690
1650
	/**
1691
	/**
1651
	 * Sets the {@link #LP__E} property of the given {@link Edge} to the given
1692
	 * Sets the {@link #LP__GE} property of the given {@link Graph} to the given
1693
	 * <i>lp</i> value.
1694
	 * 
1695
	 * @param graph
1696
	 *            The {@link Graph} for which to change the value of the
1697
	 *            {@link #LP__GE} property.
1698
	 * @param lp
1699
	 *            The new value for the {@link #LP__GE} property.
1700
	 * @throws IllegalArgumentException
1701
	 *             when the given <i>lp</i> value is not supported.
1702
	 */
1703
	public static void setLp(Graph graph, String lp) {
1704
		validate(AttributeContext.GRAPH, LP__GE, lp);
1705
		graph.attributesProperty().put(LP__GE, lp);
1706
	}
1707
1708
	/**
1709
	 * Sets the {@link #LP__GE} property of the given {@link Edge} to the given
1652
	 * <i>lpParsed</i> value.
1710
	 * <i>lpParsed</i> value.
1653
	 * 
1711
	 * 
1654
	 * @param edge
1712
	 * @param edge
1655
	 *            The {@link Edge} for which to change the value of the
1713
	 *            The {@link Edge} for which to change the value of the
1656
	 *            {@link #LP__E} property.
1714
	 *            {@link #LP__GE} property.
1657
	 * @param lpParsed
1715
	 * @param lpParsed
1658
	 *            The new value for the {@link #LP__E} property.
1716
	 *            The new value for the {@link #LP__GE} property.
1717
	 * @throws IllegalArgumentException
1718
	 *             when the given <i>lpParsed</i> value is not supported.
1659
	 */
1719
	 */
1660
	public static void setLpParsed(Edge edge, Point lpParsed) {
1720
	public static void setLpParsed(Edge edge, Point lpParsed) {
1661
		setLp(edge, serialize(DotLanguageSupport.POINT_SERIALIZER, lpParsed));
1721
		setLp(edge, serialize(DotLanguageSupport.POINT_SERIALIZER, lpParsed));
1722
	}
1723
1724
	/**
1725
	 * Sets the {@link #LP__GE} property of the given {@link Graph} to the given
1726
	 * <i>lpParsed</i> value.
1727
	 * 
1728
	 * @param graph
1729
	 *            The {@link Graph} for which to change the value of the
1730
	 *            {@link #LP__GE} property.
1731
	 * @param lpParsed
1732
	 *            The new value for the {@link #LP__GE} property.
1733
	 * @throws IllegalArgumentException
1734
	 *             when the given <i>lpParsed</i> value is not supported.
1735
	 */
1736
	public static void setLpParsed(Graph graph, Point lpParsed) {
1737
		setLp(graph, serialize(DotLanguageSupport.POINT_SERIALIZER, lpParsed));
1662
	}
1738
	}
1663
1739
1664
	/**
1740
	/**
Lines 1985-1992 Link Here
1985
	 *            {@link #TAIL_LP__E} property.
2061
	 *            {@link #TAIL_LP__E} property.
1986
	 * @param tailLp
2062
	 * @param tailLp
1987
	 *            The new value for the {@link #TAIL_LP__E} property.
2063
	 *            The new value for the {@link #TAIL_LP__E} property.
2064
	 * @throws IllegalArgumentException
2065
	 *             when the given <i>tailLp</i> value is not supported.
1988
	 */
2066
	 */
1989
	public static void setTailLp(Edge edge, String tailLp) {
2067
	public static void setTailLp(Edge edge, String tailLp) {
2068
		validate(AttributeContext.EDGE, TAIL_LP__E, tailLp);
1990
		edge.attributesProperty().put(TAIL_LP__E, tailLp);
2069
		edge.attributesProperty().put(TAIL_LP__E, tailLp);
1991
	}
2070
	}
1992
2071
Lines 1999-2004 Link Here
1999
	 *            {@link #TAIL_LP__E} property.
2078
	 *            {@link #TAIL_LP__E} property.
2000
	 * @param tailLpParsed
2079
	 * @param tailLpParsed
2001
	 *            The new value for the {@link #TAIL_LP__E} property.
2080
	 *            The new value for the {@link #TAIL_LP__E} property.
2081
	 * @throws IllegalArgumentException
2082
	 *             when the given <i>tailLpParsed</i> value is not supported.
2002
	 */
2083
	 */
2003
	public static void setTailLpParsed(Edge edge, Point tailLpParsed) {
2084
	public static void setTailLpParsed(Edge edge, Point tailLpParsed) {
2004
		setTailLp(edge,
2085
		setTailLp(edge,
Lines 2075-2082 Link Here
2075
	 *            {@link #XLP__NE} property.
2156
	 *            {@link #XLP__NE} property.
2076
	 * @param xlp
2157
	 * @param xlp
2077
	 *            The new value for the {@link #XLP__NE} property.
2158
	 *            The new value for the {@link #XLP__NE} property.
2159
	 * @throws IllegalArgumentException
2160
	 *             when the given <i>xlp</i> value is not supported.
2078
	 */
2161
	 */
2079
	public static void setXlp(Edge edge, String xlp) {
2162
	public static void setXlp(Edge edge, String xlp) {
2163
		validate(AttributeContext.EDGE, XLP__NE, xlp);
2080
		edge.attributesProperty().put(XLP__NE, xlp);
2164
		edge.attributesProperty().put(XLP__NE, xlp);
2081
	}
2165
	}
2082
2166
Lines 2089-2096 Link Here
2089
	 *            {@link #XLP__NE} property.
2173
	 *            {@link #XLP__NE} property.
2090
	 * @param xlp
2174
	 * @param xlp
2091
	 *            The new value for the {@link #XLP__NE} property.
2175
	 *            The new value for the {@link #XLP__NE} property.
2176
	 * @throws IllegalArgumentException
2177
	 *             when the given <i>xlp</i> value is not supported.
2092
	 */
2178
	 */
2093
	public static void setXlp(Node node, String xlp) {
2179
	public static void setXlp(Node node, String xlp) {
2180
		validate(AttributeContext.NODE, XLP__NE, xlp);
2094
		node.attributesProperty().put(XLP__NE, xlp);
2181
		node.attributesProperty().put(XLP__NE, xlp);
2095
	}
2182
	}
2096
2183
Lines 2103-2108 Link Here
2103
	 *            {@link #XLP__NE} property.
2190
	 *            {@link #XLP__NE} property.
2104
	 * @param xlpParsed
2191
	 * @param xlpParsed
2105
	 *            The new value for the {@link #XLP__NE} property.
2192
	 *            The new value for the {@link #XLP__NE} property.
2193
	 * @throws IllegalArgumentException
2194
	 *             when the given <i>xlpParsed</i> value is not supported.
2106
	 */
2195
	 */
2107
	public static void setXlpParsed(Edge edge, Point xlpParsed) {
2196
	public static void setXlpParsed(Edge edge, Point xlpParsed) {
2108
		setXlp(edge, serialize(DotLanguageSupport.POINT_SERIALIZER, xlpParsed));
2197
		setXlp(edge, serialize(DotLanguageSupport.POINT_SERIALIZER, xlpParsed));
Lines 2117-2122 Link Here
2117
	 *            {@link #XLP__NE} property.
2206
	 *            {@link #XLP__NE} property.
2118
	 * @param xlpParsed
2207
	 * @param xlpParsed
2119
	 *            The new value for the {@link #XLP__NE} property.
2208
	 *            The new value for the {@link #XLP__NE} property.
2209
	 * @throws IllegalArgumentException
2210
	 *             when the given <i>xlpParsed</i> value is not supported.
2120
	 */
2211
	 */
2121
	public static void setXlpParsed(Node node, Point xlpParsed) {
2212
	public static void setXlpParsed(Node node, Point xlpParsed) {
2122
		setXlp(node, serialize(DotLanguageSupport.POINT_SERIALIZER, xlpParsed));
2213
		setXlp(node, serialize(DotLanguageSupport.POINT_SERIALIZER, xlpParsed));
(-)a/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/DotInterpreter.java (-1 / +1 lines)
Lines 297-303 Link Here
297
	public Object caseEdgeStmtNode(EdgeStmtNode object) {
297
	public Object caseEdgeStmtNode(EdgeStmtNode object) {
298
		currentEdgeId = getAttributeValue(object, DotAttributes.ID__GNE);
298
		currentEdgeId = getAttributeValue(object, DotAttributes.ID__GNE);
299
		currentEdgeLabel = getAttributeValue(object, DotAttributes.LABEL__GNE);
299
		currentEdgeLabel = getAttributeValue(object, DotAttributes.LABEL__GNE);
300
		currentEdgeLp = getAttributeValue(object, DotAttributes.LP__E);
300
		currentEdgeLp = getAttributeValue(object, DotAttributes.LP__GE);
301
		currentEdgeXLabel = getAttributeValue(object, DotAttributes.XLABEL__NE);
301
		currentEdgeXLabel = getAttributeValue(object, DotAttributes.XLABEL__NE);
302
		currentEdgeXlp = getAttributeValue(object, DotAttributes.XLP__NE);
302
		currentEdgeXlp = getAttributeValue(object, DotAttributes.XLP__NE);
303
		currentEdgeStyle = getAttributeValue(object, DotAttributes.STYLE__E);
303
		currentEdgeStyle = getAttributeValue(object, DotAttributes.STYLE__E);
(-)a/org.eclipse.gef4.dot/src/org/eclipse/gef4/dot/internal/parser/validation/DotJavaValidator.java (+7 lines)
Lines 268-273 Link Here
268
				}
268
				}
269
			}
269
			}
270
			return findings;
270
			return findings;
271
		} else if (DotAttributes.HEAD_LP__E.equals(name)
272
				|| DotAttributes.LP__GE.equals(name)
273
				|| DotAttributes.TAIL_LP__E.equals(name)
274
				|| DotAttributes.XLP__NE.equals(name)) {
275
			return validateObjectAttributeValue(DotLanguageSupport.POINT_PARSER,
276
					DotLanguageSupport.POINT_VALIDATOR, name, unquotedValue,
277
					PointPackage.Literals.POINT, "point");
271
		}
278
		}
272
		return Collections.emptyList();
279
		return Collections.emptyList();
273
280

Return to bug 493136