Bug 352542: Adjust tutorial to "plain-Create-methods" for graphic
algorithms
diff --git a/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/StyleUtil.java b/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/StyleUtil.java
index d4cc324..24c5085 100644
--- a/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/StyleUtil.java
+++ b/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/StyleUtil.java
@@ -1,7 +1,7 @@
 /*******************************************************************************
  * <copyright>
  *
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2011 SAP AG.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -15,9 +15,8 @@
  *******************************************************************************/
 package org.eclipse.graphiti.examples.tutorial;
 
-import java.util.Collection;
-
-import org.eclipse.graphiti.mm.StyleContainer;
+import org.eclipse.graphiti.mm.algorithms.styles.LineStyle;
+import org.eclipse.graphiti.mm.algorithms.styles.Orientation;
 import org.eclipse.graphiti.mm.algorithms.styles.Style;
 import org.eclipse.graphiti.mm.pictograms.Diagram;
 import org.eclipse.graphiti.services.Graphiti;
@@ -26,58 +25,79 @@
 import org.eclipse.graphiti.util.IColorConstant;
 import org.eclipse.graphiti.util.PredefinedColoredAreas;
 
+/**
+ * Styles are created here with "plain"-methods, i.e. all values have to be set
+ * explicitly.
+ */
 public class StyleUtil {
 
-	private static final IColorConstant E_CLASS_TEXT_FOREGROUND = new ColorConstant(51, 51, 153);
-
-	private static final IColorConstant E_CLASS_FOREGROUND = new ColorConstant(255, 102, 0);
-
-	private static String DEFAULT_FONT = "Arial"; //$NON-NLS-1$
+	private static final IColorConstant E_CLASS_TEXT_FOREGROUND = new ColorConstant(0, 0, 0);
+	private static final IColorConstant E_CLASS_FOREGROUND = new ColorConstant(98, 131, 167);
+	private static final String DEFAULT_FONT = "Arial"; //$NON-NLS-1$
 
 	public static Style getStyleForEClass(Diagram diagram) {
 		final String styleId = "E-CLASS"; //$NON-NLS-1$
-
-		Style style = findStyle(diagram, styleId);
-
 		IGaService gaService = Graphiti.getGaService();
+
+		// Is style already persisted?
+		Style style = gaService.findStyle(diagram, styleId);
+
 		if (style == null) { // style not found - create new style
-			style = gaService.createStyle(diagram, styleId);
+			style = gaService.createPlainStyle(diagram, styleId);
+			setCommonValues(style);
+			style.setFilled(true);
 			style.setForeground(gaService.manageColor(diagram, E_CLASS_FOREGROUND));
-			//gaService.setRenderingStyle(style, TutorialColoredAreas.getLimeWhiteAdaptions());
+			// style.setRenderingStyle(style,
+			// TutorialColoredAreas.getLimeWhiteAdaptions());
 			gaService.setRenderingStyle(style, PredefinedColoredAreas.getBlueWhiteGlossAdaptions());
-			style.setLineWidth(2);
 		}
 		return style;
 	}
 
 	public static Style getStyleForEClassText(Diagram diagram) {
 		final String styleId = "ECLASS-TEXT"; //$NON-NLS-1$
+		IGaService gaService = Graphiti.getGaService();
 
-		// this is a child style of the e-class-style
-		Style parentStyle = getStyleForEClass(diagram);
-		Style style = findStyle(parentStyle, styleId);
-
+		// Is style already persisted?
+		Style style = gaService.findStyle(diagram, styleId);
 		if (style == null) { // style not found - create new style
-			IGaService gaService = Graphiti.getGaService();
-			style = gaService.createStyle(getStyleForEClass(diagram), styleId);
-			// "overwrites" values from parent style
-			style.setForeground(gaService.manageColor(diagram, E_CLASS_TEXT_FOREGROUND));
+
+			style = gaService.createPlainStyle(getStyleForEClass(diagram), styleId);
+			setCommonValues(style);
+			setCommonTextValues(diagram, gaService, style);
 			style.setFont(gaService.manageFont(diagram, DEFAULT_FONT, 8, false, true));
 		}
 		return style;
 	}
 
-	// find the style with a given id in the style-container, can return null
-	private static Style findStyle(StyleContainer styleContainer, String id) {
-		// find and return style
-		Collection<Style> styles = styleContainer.getStyles();
-		if (styles != null) {
-			for (Style style : styles) {
-				if (id.equals(style.getId())) {
-					return style;
-				}
-			}
+	public static Style getStyleForTextDecorator(Diagram diagram) {
+		final String styleId = "TEXT-DECORATOR-TEXT"; //$NON-NLS-1$
+		IGaService gaService = Graphiti.getGaService();
+
+		// Is style already persisted?
+		Style style = gaService.findStyle(diagram, styleId);
+		if (style == null) { // style not found - create new style
+
+			style = gaService.createPlainStyle(getStyleForEClass(diagram), styleId);
+			setCommonValues(style);
+			setCommonTextValues(diagram, gaService, style);
+			style.setFont(gaService.manageFont(diagram, DEFAULT_FONT, 8, false, false));
 		}
-		return null;
+		return style;
+	}
+
+	private static void setCommonTextValues(Diagram diagram, IGaService gaService, Style style) {
+		style.setFilled(false);
+		style.setAngle(0);
+		style.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
+		style.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
+		style.setForeground(gaService.manageColor(diagram, E_CLASS_TEXT_FOREGROUND));
+	}
+
+	private static void setCommonValues(Style style) {
+		style.setLineStyle(LineStyle.SOLID);
+		style.setLineVisible(true);
+		style.setLineWidth(2);
+		style.setTransparency(0.0);
 	}
 }
diff --git a/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/features/TutorialAddEClassFeature.java b/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/features/TutorialAddEClassFeature.java
index 7f13ba9..5352764 100644
--- a/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/features/TutorialAddEClassFeature.java
+++ b/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/features/TutorialAddEClassFeature.java
@@ -1,7 +1,7 @@
 /*******************************************************************************
  * <copyright>
  *
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2011 SAP AG.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -26,7 +26,6 @@
 import org.eclipse.graphiti.mm.algorithms.Rectangle;
 import org.eclipse.graphiti.mm.algorithms.RoundedRectangle;
 import org.eclipse.graphiti.mm.algorithms.Text;
-import org.eclipse.graphiti.mm.algorithms.styles.Orientation;
 import org.eclipse.graphiti.mm.pictograms.BoxRelativeAnchor;
 import org.eclipse.graphiti.mm.pictograms.ContainerShape;
 import org.eclipse.graphiti.mm.pictograms.Diagram;
@@ -82,7 +81,7 @@
 			gaService.setLocationAndSize(invisibleRectangle, context.getX(), context.getY(), width + INVISIBLE_RECT_RIGHT, height);
 
 			// create and set visible rectangle inside invisible rectangle
-			roundedRectangle = gaService.createRoundedRectangle(invisibleRectangle, 5, 5);
+			roundedRectangle = gaService.createPlainRoundedRectangle(invisibleRectangle, 5, 5);
 			roundedRectangle.setParentGraphicsAlgorithm(invisibleRectangle);
 			roundedRectangle.setStyle(StyleUtil.getStyleForEClass(getDiagram()));
 			gaService.setLocationAndSize(roundedRectangle, 0, 0, width, height);
@@ -103,7 +102,7 @@
 			final Shape shape = peCreateService.createShape(containerShape, false);
 
 			// create and set graphics algorithm
-			final Polyline polyline = gaService.createPolyline(shape, new int[] { 0, 20, width, 20 });
+			final Polyline polyline = gaService.createPlainPolyline(shape, new int[] { 0, 20, width, 20 });
 			polyline.setStyle(StyleUtil.getStyleForEClass(getDiagram()));
 		}
 
@@ -113,10 +112,8 @@
 			final Shape shape = peCreateService.createShape(containerShape, false);
 
 			// create and set text graphics algorithm
-			final Text text = gaService.createText(shape, addedClass.getName());
+			final Text text = gaService.createPlainText(shape, addedClass.getName());
 			text.setStyle(StyleUtil.getStyleForEClassText(getDiagram()));
-			text.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
-			text.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
 			gaService.setLocationAndSize(text, 0, 0, width, 20);
 
 			// create link and wire it
@@ -140,19 +137,19 @@
 		final BoxRelativeAnchor boxAnchor = peCreateService.createBoxRelativeAnchor(containerShape);
 		boxAnchor.setRelativeWidth(1.0);
 		boxAnchor.setRelativeHeight(0.38); // Use golden section
+
 		// anchor references visible rectangle instead of invisible rectangle
 		boxAnchor.setReferencedGraphicsAlgorithm(roundedRectangle);
+
 		// assign a graphics algorithm for the box relative anchor
-		//		final Rectangle boxRect = gaService.createEllipse(boxAnchor);
-		final Ellipse ellipse = gaService.createEllipse(boxAnchor);
-		ellipse.setFilled(true);
+		final Ellipse ellipse = gaService.createPlainEllipse(boxAnchor);
+
 		// anchor is located on the right border of the visible rectangle
 		// and touches the border of the invisible rectangle
 		final int w = INVISIBLE_RECT_RIGHT;
 		gaService.setLocationAndSize(ellipse, -w, -w, 2 * w, 2 * w);
-		//		final Color c = gaService.manageColor(getDiagram(), IColorConstant.DARK_BLUE);
-		//		boxRect.setBackground(c);
 		ellipse.setStyle(StyleUtil.getStyleForEClass(getDiagram()));
+
 		// call the layout feature
 		layoutPictogramElement(containerShape);
 
diff --git a/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/features/TutorialAddEReferenceFeature.java b/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/features/TutorialAddEReferenceFeature.java
index 03f7381..bdfcf7e 100644
--- a/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/features/TutorialAddEReferenceFeature.java
+++ b/examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/features/TutorialAddEReferenceFeature.java
@@ -1,7 +1,7 @@
 /*******************************************************************************
  * <copyright>
  *
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2011 SAP AG.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -41,15 +41,15 @@
 	public PictogramElement add(IAddContext context) {
 		IAddConnectionContext addConContext = (IAddConnectionContext) context;
 		EReference addedEReference = (EReference) context.getNewObject();
-
 		IPeCreateService peCreateService = Graphiti.getPeCreateService();
+
 		// CONNECTION WITH POLYLINE
 		Connection connection = peCreateService.createFreeFormConnection(getDiagram());
 		connection.setStart(addConContext.getSourceAnchor());
 		connection.setEnd(addConContext.getTargetAnchor());
 
 		IGaService gaService = Graphiti.getGaService();
-		Polyline polyline = gaService.createPolyline(connection);
+		Polyline polyline = gaService.createPlainPolyline(connection);
 		polyline.setStyle(StyleUtil.getStyleForEClass(getDiagram()));
 
 		// create link and wire it
@@ -57,9 +57,10 @@
 
 		// add dynamic text decorator for the reference name
 		ConnectionDecorator textDecorator = peCreateService.createConnectionDecorator(connection, true, 0.5, true);
-		Text text = gaService.createDefaultText(getDiagram(), textDecorator);
-		text.setStyle(StyleUtil.getStyleForEClassText((getDiagram())));
+		Text text = gaService.createPlainText(textDecorator);
+		text.setStyle(StyleUtil.getStyleForTextDecorator((getDiagram())));
 		gaService.setLocation(text, 10, 0);
+
 		// set reference name in the text decorator
 		EReference eReference = (EReference) context.getNewObject();
 		text.setValue(eReference.getName());
@@ -68,9 +69,6 @@
 		ConnectionDecorator cd;
 		cd = peCreateService.createConnectionDecorator(connection, false, 1.0, true);
 		createArrow(cd);
-		//		cd = PeUtil.createConnectionDecorator(connection, false, 1.0, true);
-		//		createRhombus(cd);
-
 		return connection;
 	}
 
@@ -85,16 +83,9 @@
 	}
 
 	private Polyline createArrow(GraphicsAlgorithmContainer gaContainer) {
-		Polyline polyline = Graphiti.getGaCreateService().createPolyline(gaContainer, new int[] { -15, 10, 0, 0, -15, -10 });
+		Polyline polyline = Graphiti.getGaCreateService().createPlainPolyline(gaContainer,
+				new int[] { -15, 10, 0, 0, -15, -10 });
 		polyline.setStyle(StyleUtil.getStyleForEClass(getDiagram()));
 		return polyline;
 	}
-
-	//	private Polygon createRhombus(GraphicsAlgorithmContainer gaContainer) {
-	//		Polygon polygon = GaUtil.createPolygon(gaContainer, new int[] { 0, 0, -10, 10, -20, 0, -10, -10 });
-	//		polygon.setForeground(manageColor(IColorConstant.BLACK));
-	//		polygon.setBackground(manageColor(IColorConstant.BLACK));
-	//		polygon.setLineWidth(2);
-	//		return polygon;
-	//	}
 }
diff --git a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/internal/services/impl/GaServiceImpl.java b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/internal/services/impl/GaServiceImpl.java
index d3e340d..a2f3b0f 100644
--- a/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/internal/services/impl/GaServiceImpl.java
+++ b/plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/internal/services/impl/GaServiceImpl.java
@@ -1644,7 +1644,6 @@
 
 	private void setDefaultGraphicsAlgorithmValues(GraphicsAlgorithm graphicsAlgorithm) {
 		setLocationAndSize(graphicsAlgorithm, 0, 0, 0, 0);
-		// graphicsAlgorithm.unsetLineVisible();
 		graphicsAlgorithm.setLineStyle(LineStyle.SOLID);
 		graphicsAlgorithm.setLineWidth(1);
 		graphicsAlgorithm.setTransparency(0d);