Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug 423573 - Angles should never be integer

* Deprecate angle attribute at AbstractText and Style
* Introduce rotation attribute at AbstractText and Style
* Transfer value from angle to rotation in model layer
* Added test that reading of old diagrams transfers data

Change-Id: I62dba570f595fbc3c2cdd32c284ce009c068950c
  • Loading branch information...
commit a9d6fbf9e35164836068bf5357d383ea2bef55ea 1 parent 73a2ba0
@mwenz mwenz authored
Showing with 781 additions and 94 deletions.
  1. +3 −2 examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/StyleUtil.java
  2. +73 −0 plugins/org.eclipse.graphiti.mm/.settings/.api_filters
  3. +16 −2 plugins/org.eclipse.graphiti.mm/model/graphiti.ecore
  4. +55 −11 plugins/org.eclipse.graphiti.mm/src-gen/org/eclipse/graphiti/mm/algorithms/AbstractText.java
  5. +56 −2 plugins/org.eclipse.graphiti.mm/src-gen/org/eclipse/graphiti/mm/algorithms/AlgorithmsPackage.java
  6. +81 −7 plugins/org.eclipse.graphiti.mm/src-gen/org/eclipse/graphiti/mm/algorithms/impl/AbstractTextImpl.java
  7. +13 −1 plugins/org.eclipse.graphiti.mm/src-gen/org/eclipse/graphiti/mm/algorithms/impl/AlgorithmsPackageImpl.java
  8. +93 −25 plugins/org.eclipse.graphiti.mm/src-gen/org/eclipse/graphiti/mm/algorithms/styles/Style.java
  9. +35 −2 plugins/org.eclipse.graphiti.mm/src-gen/org/eclipse/graphiti/mm/algorithms/styles/StylesPackage.java
  10. +82 −15 plugins/org.eclipse.graphiti.mm/src-gen/org/eclipse/graphiti/mm/algorithms/styles/impl/StyleImpl.java
  11. +13 −1 plugins/org.eclipse.graphiti.mm/src-gen/org/eclipse/graphiti/mm/algorithms/styles/impl/StylesPackageImpl.java
  12. +6 −5 plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/figures/GFText.java
  13. +15 −1 plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/services/IGaService.java
  14. +48 −3 plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/services/impl/GaServiceImpl.java
  15. +8 −3 tests/org.eclipse.graphiti.tests/src/org/eclipse/graphiti/tests/GFAbstractCreateTestCase.java
  16. +5 −2 tests/org.eclipse.graphiti.tests/src/org/eclipse/graphiti/tests/cases/GaServiceTest.java
  17. +3 −2 ....eclipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/features/AddAnythingFeature.java
  18. +5 −5 tests/org.eclipse.graphiti.ui.tests/src/org/eclipse/graphiti/ui/tests/AllTests.java
  19. +36 −5 tests/org.eclipse.graphiti.ui.tests/src/org/eclipse/graphiti/ui/tests/PackageTest.java
  20. +17 −0 ...se.graphiti.ui.tests/src/org/eclipse/graphiti/ui/tests/compatibility/AbstractText_angle_to_rotation.diagram
  21. +114 −0 tests/org.eclipse.graphiti.ui.tests/src/org/eclipse/graphiti/ui/tests/compatibility/CompatibilityTests.java
  22. +4 −0 ...g.eclipse.graphiti.ui.tests/src/org/eclipse/graphiti/ui/tests/compatibility/Style_angle_to_rotation.diagram
View
5 examples/org.eclipse.graphiti.examples.tutorial/src/org/eclipse/graphiti/examples/tutorial/StyleUtil.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2011 SAP AG.
+ * Copyright (c) 2005, 2014 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
@@ -9,6 +9,7 @@
*
* Contributors:
* SAP AG - initial API, implementation and documentation
+ * mwenz - Bug 423573 - Angles should never be integer
*
* </copyright>
*
@@ -112,7 +113,7 @@ public static Style getStyleForTextDecorator(Diagram diagram) {
private static void setCommonTextValues(Diagram diagram, IGaService gaService, Style style) {
style.setFilled(false);
- style.setAngle(0);
+ style.setRotation(0d);
style.setHorizontalAlignment(Orientation.ALIGNMENT_CENTER);
style.setVerticalAlignment(Orientation.ALIGNMENT_CENTER);
style.setForeground(gaService.manageColor(diagram, E_CLASS_TEXT_FOREGROUND));
View
73 plugins/org.eclipse.graphiti.mm/.settings/.api_filters
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<component id="org.eclipse.graphiti.mm" version="2">
+ <resource path="META-INF/MANIFEST.MF">
+ <filter comment="Bug 423573 - Angles should never be integer" id="923795461">
+ <message_arguments>
+ <message_argument value="0.11.0"/>
+ <message_argument value="0.10.0"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src-gen/org/eclipse/graphiti/mm/algorithms/AbstractText.java" type="org.eclipse.graphiti.mm.algorithms.AbstractText">
+ <filter comment="Bug 423573 - Angles should never be integer" id="403804204">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.mm.algorithms.AbstractText"/>
+ <message_argument value="getRotation()"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Bug 423573 - Angles should never be integer" id="403804204">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.mm.algorithms.AbstractText"/>
+ <message_argument value="setRotation(Double)"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src-gen/org/eclipse/graphiti/mm/algorithms/AlgorithmsPackage.java" type="org.eclipse.graphiti.mm.algorithms.AlgorithmsPackage">
+ <filter comment="Bug 423573 - Angles should never be integer" id="388194388">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.mm.algorithms.AlgorithmsPackage"/>
+ <message_argument value="ABSTRACT_TEXT_FEATURE_COUNT"/>
+ <message_argument value="23"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Bug 423573 - Angles should never be integer" id="388194388">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.mm.algorithms.AlgorithmsPackage"/>
+ <message_argument value="MULTI_TEXT_FEATURE_COUNT"/>
+ <message_argument value="23"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Bug 423573 - Angles should never be integer" id="388194388">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.mm.algorithms.AlgorithmsPackage"/>
+ <message_argument value="TEXT_FEATURE_COUNT"/>
+ <message_argument value="23"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src-gen/org/eclipse/graphiti/mm/algorithms/AlgorithmsPackage.java" type="org.eclipse.graphiti.mm.algorithms.AlgorithmsPackage$Literals">
+ <filter comment="Bug 423573 - Angles should never be integer" id="403767336">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.mm.algorithms.AlgorithmsPackage.Literals"/>
+ <message_argument value="ABSTRACT_TEXT__ROTATION"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src-gen/org/eclipse/graphiti/mm/algorithms/styles/StylesPackage.java" type="org.eclipse.graphiti.mm.algorithms.styles.StylesPackage">
+ <filter comment="Bug 423573 - Angles should never be integer" id="388194388">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.mm.algorithms.styles.StylesPackage"/>
+ <message_argument value="STYLE_FEATURE_COUNT"/>
+ <message_argument value="19"/>
+ </message_arguments>
+ </filter>
+ </resource>
+ <resource path="src-gen/org/eclipse/graphiti/mm/algorithms/styles/StylesPackage.java" type="org.eclipse.graphiti.mm.algorithms.styles.StylesPackage$Literals">
+ <filter comment="Bug 423573 - Angles should never be integer" id="403767336">
+ <message_arguments>
+ <message_argument value="org.eclipse.graphiti.mm.algorithms.styles.StylesPackage.Literals"/>
+ <message_argument value="STYLE__ROTATION"/>
+ </message_arguments>
+ </filter>
+ </resource>
+</component>
View
18 plugins/org.eclipse.graphiti.mm/model/graphiti.ecore
@@ -200,11 +200,18 @@
unique="false" eType="#//algorithms/styles/Orientation" defaultValueLiteral="ALIGNMENT_CENTER"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="angle" ordered="false"
unique="false" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject"
- defaultValueLiteral="0"/>
+ defaultValueLiteral="0">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="@deprecated This attribute exists because of compatibility (after&#xD;&#xA;removing old diagrams would not be readable any more). It is replaced&#xD;&#xA;by the new attribute rotation."/>
+ </eAnnotations>
+ </eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="value" ordered="false"
unique="false" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="styleRegions" upperBound="-1"
eType="#//algorithms/styles/TextStyleRegion" containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="rotation" ordered="false"
+ unique="false" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"
+ defaultValueLiteral="0"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="MultiText" eSuperTypes="#//algorithms/AbstractText"/>
<eSubpackages name="styles" nsURI="http://eclipse.org/graphiti/mm/algorithms/styles"
@@ -253,7 +260,11 @@
<eStructuralFeatures xsi:type="ecore:EAttribute" name="verticalAlignment"
ordered="false" unique="false" eType="#//algorithms/styles/Orientation"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="angle" ordered="false"
- unique="false" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject"/>
+ unique="false" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EIntegerObject">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="documentation" value="@deprecated This attribute exists because of compatibility (after&#xD;&#xA;removing old diagrams would not be readable any more). It is replaced&#xD;&#xA;by the new attribute rotation."/>
+ </eAnnotations>
+ </eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="stretchH" ordered="false"
unique="false" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBooleanObject"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="stretchV" ordered="false"
@@ -262,6 +273,9 @@
unique="false" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBooleanObject"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="styleContainer" ordered="false"
unique="false" lowerBound="1" eType="#//StyleContainer" eOpposite="#//StyleContainer/styles"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="rotation" ordered="false"
+ unique="false" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDoubleObject"
+ defaultValueLiteral="0"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="AbstractStyle" abstract="true">
<eStructuralFeatures xsi:type="ecore:EReference" name="background" ordered="false"
View
66 plugins/org.eclipse.graphiti.mm/src-gen/org/eclipse/graphiti/mm/algorithms/AbstractText.java
@@ -1,7 +1,7 @@
/**
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2014 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
@@ -9,6 +9,7 @@
*
* Contributors:
* SAP AG - initial API, implementation and documentation
+ * mwenz - Bug 423573 - Angles should never be integer
*
* </copyright>
*/
@@ -33,6 +34,7 @@
* <li>{@link org.eclipse.graphiti.mm.algorithms.AbstractText#getAngle <em>Angle</em>}</li>
* <li>{@link org.eclipse.graphiti.mm.algorithms.AbstractText#getValue <em>Value</em>}</li>
* <li>{@link org.eclipse.graphiti.mm.algorithms.AbstractText#getStyleRegions <em>Style Regions</em>}</li>
+ * <li>{@link org.eclipse.graphiti.mm.algorithms.AbstractText#getRotation <em>Rotation</em>}</li>
* </ul>
* </p>
*
@@ -130,14 +132,18 @@
void setVerticalAlignment(Orientation value);
/**
- * Returns the value of the '<em><b>Angle</b></em>' attribute.
- * The default value is <code>"0"</code>.
- * <!-- begin-user-doc -->
+ * Returns the value of the '<em><b>Angle</b></em>' attribute. The default
+ * value is <code>"0"</code>. <!-- begin-user-doc -->
* <p>
- * If the meaning of the '<em>Angle</em>' attribute isn't clear,
- * there really should be more of a description here...
+ * If the meaning of the '<em>Angle</em>' attribute isn't clear, there
+ * really should be more of a description here...
* </p>
- * <!-- end-user-doc -->
+ * <!-- end-user-doc --> <!-- begin-model-doc -->
+ *
+ * @deprecated This attribute exists because of compatibility (after
+ * removing old diagrams would not be readable any more). It is
+ * replaced by the new attribute rotation.
+ * @see #getRotation() <!-- end-model-doc -->
* @return the value of the '<em>Angle</em>' attribute.
* @see #setAngle(Integer)
* @see org.eclipse.graphiti.mm.algorithms.AlgorithmsPackage#getAbstractText_Angle()
@@ -147,10 +153,16 @@
Integer getAngle();
/**
- * Sets the value of the '{@link org.eclipse.graphiti.mm.algorithms.AbstractText#getAngle <em>Angle</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Angle</em>' attribute.
+ * Sets the value of the '
+ * {@link org.eclipse.graphiti.mm.algorithms.AbstractText#getAngle
+ * <em>Angle</em>}' attribute. <!-- begin-user-doc -->
+ *
+ * @deprecated This attribute exists because of compatibility (after
+ * removing old diagrams would not be readable any more). It is
+ * replaced by the new attribute rotation.
+ * @see AbstractText#setRotation(Double) <!-- end-user-doc -->
+ * @param value
+ * the new value of the '<em>Angle</em>' attribute.
* @see #getAngle()
* @generated
*/
@@ -199,4 +211,36 @@
*/
EList<TextStyleRegion> getStyleRegions();
+ /**
+ * Returns the value of the '<em><b>Rotation</b></em>' attribute. The
+ * default value is <code>"0"</code>. <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Rotation</em>' attribute isn't clear, there
+ * really should be more of a description here...
+ * </p>
+ *
+ * @since 0.11 <!-- end-user-doc -->
+ *
+ * @return the value of the '<em>Rotation</em>' attribute.
+ * @see #setRotation(Double)
+ * @see org.eclipse.graphiti.mm.algorithms.AlgorithmsPackage#getAbstractText_Rotation()
+ * @model default="0" unique="false" ordered="false"
+ * @generated
+ */
+ Double getRotation();
+
+ /**
+ * Sets the value of the '
+ * {@link org.eclipse.graphiti.mm.algorithms.AbstractText#getRotation
+ * <em>Rotation</em>}' attribute. <!-- begin-user-doc -->
+ *
+ * @since 0.11 <!-- end-user-doc -->
+ *
+ * @param value
+ * the new value of the '<em>Rotation</em>' attribute.
+ * @see #getRotation()
+ * @generated
+ */
+ void setRotation(Double value);
+
} // AbstractText
View
58 plugins/org.eclipse.graphiti.mm/src-gen/org/eclipse/graphiti/mm/algorithms/AlgorithmsPackage.java
@@ -1,7 +1,7 @@
/**
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2014 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
@@ -9,6 +9,7 @@
*
* Contributors:
* SAP AG - initial API, implementation and documentation
+ * mwenz - Bug 423573 - Angles should never be integer
*
* </copyright>
*/
@@ -815,13 +816,24 @@
int ABSTRACT_TEXT__STYLE_REGIONS = GRAPHICS_ALGORITHM_FEATURE_COUNT + 5;
/**
+ * The feature id for the '<em><b>Rotation</b></em>' attribute. <!--
+ * begin-user-doc -->
+ *
+ * @since 0.11 <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ */
+ int ABSTRACT_TEXT__ROTATION = GRAPHICS_ALGORITHM_FEATURE_COUNT + 6;
+
+ /**
* The number of structural features of the '<em>Abstract Text</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- int ABSTRACT_TEXT_FEATURE_COUNT = GRAPHICS_ALGORITHM_FEATURE_COUNT + 6;
+ int ABSTRACT_TEXT_FEATURE_COUNT = GRAPHICS_ALGORITHM_FEATURE_COUNT + 7;
/**
* The meta object id for the '{@link org.eclipse.graphiti.mm.algorithms.impl.TextImpl <em>Text</em>}' class.
@@ -1042,6 +1054,16 @@
int TEXT__STYLE_REGIONS = ABSTRACT_TEXT__STYLE_REGIONS;
/**
+ * The feature id for the '<em><b>Rotation</b></em>' attribute. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ * @since 0.11
+ */
+ int TEXT__ROTATION = ABSTRACT_TEXT__ROTATION;
+
+ /**
* The number of structural features of the '<em>Text</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -2201,6 +2223,16 @@
int MULTI_TEXT__STYLE_REGIONS = ABSTRACT_TEXT__STYLE_REGIONS;
/**
+ * The feature id for the '<em><b>Rotation</b></em>' attribute. <!--
+ * begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @ordered
+ * @since 0.11
+ */
+ int MULTI_TEXT__ROTATION = ABSTRACT_TEXT__ROTATION;
+
+ /**
* The number of structural features of the '<em>Multi Text</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -2556,6 +2588,19 @@
EReference getAbstractText_StyleRegions();
/**
+ * Returns the meta object for the attribute '
+ * {@link org.eclipse.graphiti.mm.algorithms.AbstractText#getRotation
+ * <em>Rotation</em>}'. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @return the meta object for the attribute '<em>Rotation</em>'.
+ * @see org.eclipse.graphiti.mm.algorithms.AbstractText#getRotation()
+ * @see #getAbstractText()
+ * @generated
+ * @since 0.11
+ */
+ EAttribute getAbstractText_Rotation();
+
+ /**
* Returns the meta object for class '{@link org.eclipse.graphiti.mm.algorithms.MultiText <em>Multi Text</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -2869,6 +2914,15 @@
EReference ABSTRACT_TEXT__STYLE_REGIONS = eINSTANCE.getAbstractText_StyleRegions();
/**
+ * The meta object literal for the '<em><b>Rotation</b></em>' attribute
+ * feature. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated
+ * @since 0.11
+ */
+ EAttribute ABSTRACT_TEXT__ROTATION = eINSTANCE.getAbstractText_Rotation();
+
+ /**
* The meta object literal for the '{@link org.eclipse.graphiti.mm.algorithms.impl.MultiTextImpl <em>Multi Text</em>}' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
View
88 plugins/org.eclipse.graphiti.mm/src-gen/org/eclipse/graphiti/mm/algorithms/impl/AbstractTextImpl.java
@@ -1,7 +1,7 @@
/**
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2014 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
@@ -9,6 +9,8 @@
*
* Contributors:
* SAP AG - initial API, implementation and documentation
+ * mwenz - Bug 423573 - Angles should never be integer
+ *
*
* </copyright>
*/
@@ -28,6 +30,7 @@
import org.eclipse.graphiti.mm.algorithms.AlgorithmsPackage;
import org.eclipse.graphiti.mm.algorithms.styles.Font;
import org.eclipse.graphiti.mm.algorithms.styles.Orientation;
+import org.eclipse.graphiti.mm.algorithms.styles.StylesPackage;
import org.eclipse.graphiti.mm.algorithms.styles.TextStyleRegion;
/**
@@ -43,6 +46,7 @@
* <li>{@link org.eclipse.graphiti.mm.algorithms.impl.AbstractTextImpl#getAngle <em>Angle</em>}</li>
* <li>{@link org.eclipse.graphiti.mm.algorithms.impl.AbstractTextImpl#getValue <em>Value</em>}</li>
* <li>{@link org.eclipse.graphiti.mm.algorithms.impl.AbstractTextImpl#getStyleRegions <em>Style Regions</em>}</li>
+ * <li>{@link org.eclipse.graphiti.mm.algorithms.impl.AbstractTextImpl#getRotation <em>Rotation</em>}</li>
* </ul>
* </p>
*
@@ -150,6 +154,26 @@
protected EList<TextStyleRegion> styleRegions;
/**
+ * The default value of the '{@link #getRotation() <em>Rotation</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getRotation()
+ * @generated
+ * @ordered
+ */
+ protected static final Double ROTATION_EDEFAULT = new Double(0.0);
+
+ /**
+ * The cached value of the '{@link #getRotation() <em>Rotation</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getRotation()
+ * @generated
+ * @ordered
+ */
+ protected Double rotation = ROTATION_EDEFAULT;
+
+ /**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
@@ -249,22 +273,31 @@ public void setVerticalAlignment(Orientation newVerticalAlignment) {
}
/**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated not
*/
public Integer getAngle() {
- return angle;
+ Double rotation = getRotation();
+ if (rotation == null) {
+ return null;
+ }
+ return (int) Math.round(rotation);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @generated
+ * @generated not
*/
public void setAngle(Integer newAngle) {
Integer oldAngle = angle;
- angle = newAngle;
+ angle = ANGLE_EDEFAULT;
+ if (newAngle != null) {
+ setRotation(newAngle.doubleValue());
+ } else {
+ setRotation(null);
+ }
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, AlgorithmsPackage.ABSTRACT_TEXT__ANGLE, oldAngle, angle));
}
@@ -307,6 +340,35 @@ public void setValue(String newValue) {
* <!-- end-user-doc -->
* @generated
*/
+ public Double getRotation() {
+ return rotation;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated not
+ */
+ public void setRotation(Double newRotation) {
+ Double oldRotation = rotation;
+ rotation = newRotation;
+ Integer oldAngle = angle;
+ if (newRotation != null) {
+ angle = new Long(Math.round(newRotation)).intValue();
+ } else {
+ angle = null;
+ }
+ if (eNotificationRequired()) {
+ eNotify(new ENotificationImpl(this, Notification.SET, AlgorithmsPackage.ABSTRACT_TEXT__ROTATION, oldRotation, rotation));
+ eNotify(new ENotificationImpl(this, Notification.SET, StylesPackage.STYLE__ANGLE, oldAngle, angle));
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
@@ -337,6 +399,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) {
return getValue();
case AlgorithmsPackage.ABSTRACT_TEXT__STYLE_REGIONS:
return getStyleRegions();
+ case AlgorithmsPackage.ABSTRACT_TEXT__ROTATION:
+ return getRotation();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -369,6 +433,9 @@ public void eSet(int featureID, Object newValue) {
getStyleRegions().clear();
getStyleRegions().addAll((Collection<? extends TextStyleRegion>)newValue);
return;
+ case AlgorithmsPackage.ABSTRACT_TEXT__ROTATION:
+ setRotation((Double)newValue);
+ return;
}
super.eSet(featureID, newValue);
}
@@ -399,6 +466,9 @@ public void eUnset(int featureID) {
case AlgorithmsPackage.ABSTRACT_TEXT__STYLE_REGIONS:
getStyleRegions().clear();
return;
+ case AlgorithmsPackage.ABSTRACT_TEXT__ROTATION:
+ setRotation(ROTATION_EDEFAULT);
+ return;
}
super.eUnset(featureID);
}
@@ -423,6 +493,8 @@ public boolean eIsSet(int featureID) {
return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value);
case AlgorithmsPackage.ABSTRACT_TEXT__STYLE_REGIONS:
return styleRegions != null && !styleRegions.isEmpty();
+ case AlgorithmsPackage.ABSTRACT_TEXT__ROTATION:
+ return ROTATION_EDEFAULT == null ? rotation != null : !ROTATION_EDEFAULT.equals(rotation);
}
return super.eIsSet(featureID);
}
@@ -445,6 +517,8 @@ public String toString() {
result.append(angle);
result.append(", value: ");
result.append(value);
+ result.append(", rotation: ");
+ result.append(rotation);
result.append(')');
return result.toString();
}
View
14 plugins/org.eclipse.graphiti.mm/src-gen/org/eclipse/graphiti/mm/algorithms/impl/AlgorithmsPackageImpl.java
@@ -1,7 +1,7 @@
/**
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2014 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
@@ -9,6 +9,7 @@
*
* Contributors:
* SAP AG - initial API, implementation and documentation
+ * mwenz - Bug 423573 - Angles should never be integer
*
* </copyright>
*/
@@ -488,6 +489,15 @@ public EReference getAbstractText_StyleRegions() {
* <!-- end-user-doc -->
* @generated
*/
+ public EAttribute getAbstractText_Rotation() {
+ return (EAttribute)abstractTextEClass.getEStructuralFeatures().get(6);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
public EClass getMultiText() {
return multiTextEClass;
}
@@ -561,6 +571,7 @@ public void createPackageContents() {
createEAttribute(abstractTextEClass, ABSTRACT_TEXT__ANGLE);
createEAttribute(abstractTextEClass, ABSTRACT_TEXT__VALUE);
createEReference(abstractTextEClass, ABSTRACT_TEXT__STYLE_REGIONS);
+ createEAttribute(abstractTextEClass, ABSTRACT_TEXT__ROTATION);
multiTextEClass = createEClass(MULTI_TEXT);
}
@@ -656,6 +667,7 @@ public void initializePackageContents() {
initEAttribute(getAbstractText_Angle(), ecorePackage.getEIntegerObject(), "angle", "0", 0, 1, AbstractText.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED);
initEAttribute(getAbstractText_Value(), ecorePackage.getEString(), "value", null, 1, 1, AbstractText.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED);
initEReference(getAbstractText_StyleRegions(), theStylesPackage.getTextStyleRegion(), null, "styleRegions", null, 0, -1, AbstractText.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getAbstractText_Rotation(), ecorePackage.getEDoubleObject(), "rotation", "0", 0, 1, AbstractText.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED);
initEClass(multiTextEClass, MultiText.class, "MultiText", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
}
View
118 plugins/org.eclipse.graphiti.mm/src-gen/org/eclipse/graphiti/mm/algorithms/styles/Style.java
@@ -1,7 +1,7 @@
/**
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2014 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
@@ -9,6 +9,7 @@
*
* Contributors:
* SAP AG - initial API, implementation and documentation
+ * mwenz - Bug 423573 - Angles should never be integer
*
* </copyright>
*/
@@ -17,26 +18,52 @@
import org.eclipse.graphiti.mm.StyleContainer;
/**
- * <!-- begin-user-doc -->
- * A representation of the model object '<em><b>Style</b></em>'.
- * <!-- end-user-doc -->
- *
- * <p>
- * The following features are supported:
- * <ul>
- * <li>{@link org.eclipse.graphiti.mm.algorithms.styles.Style#getId <em>Id</em>}</li>
- * <li>{@link org.eclipse.graphiti.mm.algorithms.styles.Style#getDescription <em>Description</em>}</li>
- * <li>{@link org.eclipse.graphiti.mm.algorithms.styles.Style#getFont <em>Font</em>}</li>
- * <li>{@link org.eclipse.graphiti.mm.algorithms.styles.Style#getHorizontalAlignment <em>Horizontal Alignment</em>}</li>
- * <li>{@link org.eclipse.graphiti.mm.algorithms.styles.Style#getVerticalAlignment <em>Vertical Alignment</em>}</li>
- * <li>{@link org.eclipse.graphiti.mm.algorithms.styles.Style#getAngle <em>Angle</em>}</li>
- * <li>{@link org.eclipse.graphiti.mm.algorithms.styles.Style#getStretchH <em>Stretch H</em>}</li>
- * <li>{@link org.eclipse.graphiti.mm.algorithms.styles.Style#getStretchV <em>Stretch V</em>}</li>
- * <li>{@link org.eclipse.graphiti.mm.algorithms.styles.Style#getProportional <em>Proportional</em>}</li>
- * <li>{@link org.eclipse.graphiti.mm.algorithms.styles.Style#getStyleContainer <em>Style Container</em>}</li>
- * </ul>
- * </p>
- *
+ * <!-- begin-user-doc --> A representation of the model object '
+ * <em><b>Style</b></em>'.
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>
+ * {@link org.eclipse.graphiti.mm.algorithms.styles.Style#getId
+ * <em>Id</em>}</li>
+ * <li>
+ * {@link org.eclipse.graphiti.mm.algorithms.styles.Style#getDescription
+ * <em>Description</em>}</li>
+ * <li>
+ * {@link org.eclipse.graphiti.mm.algorithms.styles.Style#getFont
+ * <em>Font</em>}</li>
+ * <li>
+ * {@link org.eclipse.graphiti.mm.algorithms.styles.Style#getHorizontalAlignment
+ * <em>Horizontal Alignment</em>}</li>
+ * <li>
+ * {@link org.eclipse.graphiti.mm.algorithms.styles.Style#getVerticalAlignment
+ * <em>Vertical Alignment</em>}</li>
+ * <li>
+ * {@link org.eclipse.graphiti.mm.algorithms.styles.Style#getAngle
+ * <em>Angle</em>}</li>
+ * <li>
+ * {@link org.eclipse.graphiti.mm.algorithms.styles.Style#getStretchH
+ * <em>Stretch H</em>}</li>
+ * <li>
+ * {@link org.eclipse.graphiti.mm.algorithms.styles.Style#getStretchV
+ * <em>Stretch V</em>}</li>
+ * <li>
+ * {@link org.eclipse.graphiti.mm.algorithms.styles.Style#getProportional
+ * <em>Proportional</em>}</li>
+ * <li>
+ * {@link org.eclipse.graphiti.mm.algorithms.styles.Style#getStyleContainer
+ * <em>Style Container</em>}</li>
+ * <li>
+ * {@link org.eclipse.graphiti.mm.algorithms.styles.Style#getRotation
+ * <em>Rotation</em>}</li>
+ * </ul>
+ * </p>
+ *
* @see org.eclipse.graphiti.mm.algorithms.styles.StylesPackage#getStyle()
* @model
* @generated
@@ -186,6 +213,11 @@
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
+ * <!-- begin-model-doc -->
+ * @deprecated This attribute exists because of compatibility (after
+ * removing old diagrams would not be readable any more). It is replaced
+ * by the new attribute rotation.
+ * <!-- end-model-doc -->
* @return the value of the '<em>Angle</em>' attribute.
* @see #setAngle(Integer)
* @see org.eclipse.graphiti.mm.algorithms.styles.StylesPackage#getStyle_Angle()
@@ -195,10 +227,16 @@
Integer getAngle();
/**
- * Sets the value of the '{@link org.eclipse.graphiti.mm.algorithms.styles.Style#getAngle <em>Angle</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Angle</em>' attribute.
+ * Sets the value of the '
+ * {@link org.eclipse.graphiti.mm.algorithms.styles.Style#getAngle
+ * <em>Angle</em>}' attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
+ * <!-- begin-model-doc -->
+ * @deprecated This attribute exists because of compatibility (after
+ * removing old diagrams would not be readable any more). It is
+ * replaced by the new attribute rotation. <!-- end-model-doc
+ * -->
+ * @param value
+ * the new value of the '<em>Angle</em>' attribute.
* @see #getAngle()
* @generated
*/
@@ -310,4 +348,34 @@
*/
void setStyleContainer(StyleContainer value);
+ /**
+ * Returns the value of the '<em><b>Rotation</b></em>' attribute. The
+ * default value is <code>"0"</code>. <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Rotation</em>' attribute isn't clear, there
+ * really should be more of a description here...
+ * </p>
+ *
+ * @since 0.11 <!-- end-user-doc -->
+ * @return the value of the '<em>Rotation</em>' attribute.
+ * @see #setRotation(Double)
+ * @see org.eclipse.graphiti.mm.algorithms.styles.StylesPackage#getStyle_Rotation()
+ * @model default="0" unique="false" ordered="false"
+ * @generated
+ */
+ Double getRotation();
+
+ /**
+ * Sets the value of the '
+ * {@link org.eclipse.graphiti.mm.algorithms.styles.Style#getRotation
+ * <em>Rotation</em>}' attribute. <!-- begin-user-doc -->
+ *
+ * @since 0.11 <!-- end-user-doc -->
+ * @param value
+ * the new value of the '<em>Rotation</em>' attribute.
+ * @see #getRotation()
+ * @generated
+ */
+ void setRotation(Double value);
+
} // Style
View
37 plugins/org.eclipse.graphiti.mm/src-gen/org/eclipse/graphiti/mm/algorithms/styles/StylesPackage.java
@@ -1,7 +1,7 @@
/**
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2014 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
@@ -9,6 +9,7 @@
*
* Contributors:
* SAP AG - initial API, implementation and documentation
+ * mwenz - Bug 423573 - Angles should never be integer
*
* </copyright>
*/
@@ -281,13 +282,23 @@
int STYLE__STYLE_CONTAINER = MmPackage.STYLE_CONTAINER_FEATURE_COUNT + 17;
/**
+ * The feature id for the '<em><b>Rotation</b></em>' attribute. <!--
+ * begin-user-doc -->
+ *
+ * @since 0.11 <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int STYLE__ROTATION = MmPackage.STYLE_CONTAINER_FEATURE_COUNT + 18;
+
+ /**
* The number of structural features of the '<em>Style</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
- int STYLE_FEATURE_COUNT = MmPackage.STYLE_CONTAINER_FEATURE_COUNT + 18;
+ int STYLE_FEATURE_COUNT = MmPackage.STYLE_CONTAINER_FEATURE_COUNT + 19;
/**
* The meta object id for the '{@link org.eclipse.graphiti.mm.algorithms.styles.impl.AbstractStyleImpl <em>Abstract Style</em>}' class.
@@ -1082,6 +1093,19 @@
EReference getStyle_StyleContainer();
/**
+ * Returns the meta object for the attribute '
+ * {@link org.eclipse.graphiti.mm.algorithms.styles.Style#getRotation
+ * <em>Rotation</em>}'. <!-- begin-user-doc -->
+ *
+ * @since 0.11 <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Rotation</em>'.
+ * @see org.eclipse.graphiti.mm.algorithms.styles.Style#getRotation()
+ * @see #getStyle()
+ * @generated
+ */
+ EAttribute getStyle_Rotation();
+
+ /**
* Returns the meta object for class '{@link org.eclipse.graphiti.mm.algorithms.styles.AbstractStyle <em>Abstract Style</em>}'.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
@@ -1843,6 +1867,15 @@
EReference STYLE__STYLE_CONTAINER = eINSTANCE.getStyle_StyleContainer();
/**
+ * The meta object literal for the '<em><b>Rotation</b></em>' attribute
+ * feature. <!-- begin-user-doc -->
+ *
+ * @since 0.11 <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute STYLE__ROTATION = eINSTANCE.getStyle_Rotation();
+
+ /**
* The meta object literal for the '{@link org.eclipse.graphiti.mm.algorithms.styles.impl.AbstractStyleImpl <em>Abstract Style</em>}' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
View
97 plugins/org.eclipse.graphiti.mm/src-gen/org/eclipse/graphiti/mm/algorithms/styles/impl/StyleImpl.java
@@ -1,7 +1,7 @@
/**
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2014 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
@@ -9,6 +9,7 @@
*
* Contributors:
* SAP AG - initial API, implementation and documentation
+ * mwenz - Bug 423573 - Angles should never be integer
*
* </copyright>
*/
@@ -16,17 +17,12 @@
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
-
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
-
import org.eclipse.emf.ecore.impl.ENotificationImpl;
-
import org.eclipse.emf.ecore.util.EcoreUtil;
-
import org.eclipse.graphiti.mm.MmPackage;
import org.eclipse.graphiti.mm.StyleContainer;
-
import org.eclipse.graphiti.mm.algorithms.styles.AbstractStyle;
import org.eclipse.graphiti.mm.algorithms.styles.Color;
import org.eclipse.graphiti.mm.algorithms.styles.Font;
@@ -35,7 +31,6 @@
import org.eclipse.graphiti.mm.algorithms.styles.RenderingStyle;
import org.eclipse.graphiti.mm.algorithms.styles.Style;
import org.eclipse.graphiti.mm.algorithms.styles.StylesPackage;
-
import org.eclipse.graphiti.mm.impl.StyleContainerImpl;
/**
@@ -63,6 +58,7 @@
* <li>{@link org.eclipse.graphiti.mm.algorithms.styles.impl.StyleImpl#getStretchV <em>Stretch V</em>}</li>
* <li>{@link org.eclipse.graphiti.mm.algorithms.styles.impl.StyleImpl#getProportional <em>Proportional</em>}</li>
* <li>{@link org.eclipse.graphiti.mm.algorithms.styles.impl.StyleImpl#getStyleContainer <em>Style Container</em>}</li>
+ * <li>{@link org.eclipse.graphiti.mm.algorithms.styles.impl.StyleImpl#getRotation <em>Rotation</em>}</li>
* </ul>
* </p>
*
@@ -388,6 +384,26 @@
protected Boolean proportional = PROPORTIONAL_EDEFAULT;
/**
+ * The default value of the '{@link #getRotation() <em>Rotation</em>}'
+ * attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @see #getRotation()
+ * @generated not
+ * @ordered
+ */
+ protected static final Double ROTATION_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getRotation() <em>Rotation</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getRotation()
+ * @generated
+ * @ordered
+ */
+ protected Double rotation = ROTATION_EDEFAULT;
+
+ /**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
@@ -826,22 +842,31 @@ public void setVerticalAlignment(Orientation newVerticalAlignment) {
}
/**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated not
*/
public Integer getAngle() {
- return angle;
+ Double rotation = getRotation();
+ if (rotation == null) {
+ return null;
+ }
+ return (int) Math.round(rotation);
}
/**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated not
*/
public void setAngle(Integer newAngle) {
Integer oldAngle = angle;
- angle = newAngle;
+ angle = ANGLE_EDEFAULT;
+ if (newAngle != null) {
+ setRotation(newAngle.doubleValue());
+ } else {
+ setRotation(null);
+ }
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, StylesPackage.STYLE__ANGLE, oldAngle, angle));
}
@@ -965,6 +990,36 @@ else if (eNotificationRequired())
* <!-- end-user-doc -->
* @generated
*/
+ public Double getRotation() {
+ return rotation;
+ }
+
+ /**
+ * <!-- begin-user-doc --> <!-- end-user-doc -->
+ *
+ * @generated not
+ */
+ public void setRotation(Double newRotation) {
+ Double oldRotation = rotation;
+ rotation = newRotation;
+ Integer oldAngle = angle;
+ if (newRotation != null) {
+ angle = new Long(Math.round(newRotation)).intValue();
+ } else {
+ angle = null;
+ }
+ if (eNotificationRequired()) {
+ eNotify(new ENotificationImpl(this, Notification.SET, StylesPackage.STYLE__ROTATION, oldRotation, rotation));
+ eNotify(new ENotificationImpl(this, Notification.SET, StylesPackage.STYLE__ANGLE, oldAngle, angle));
+ }
+
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
@@ -1055,6 +1110,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) {
case StylesPackage.STYLE__STYLE_CONTAINER:
if (resolve) return getStyleContainer();
return basicGetStyleContainer();
+ case StylesPackage.STYLE__ROTATION:
+ return getRotation();
}
return super.eGet(featureID, resolve, coreType);
}
@@ -1121,6 +1178,9 @@ public void eSet(int featureID, Object newValue) {
case StylesPackage.STYLE__STYLE_CONTAINER:
setStyleContainer((StyleContainer)newValue);
return;
+ case StylesPackage.STYLE__ROTATION:
+ setRotation((Double)newValue);
+ return;
}
super.eSet(featureID, newValue);
}
@@ -1187,6 +1247,9 @@ public void eUnset(int featureID) {
case StylesPackage.STYLE__STYLE_CONTAINER:
setStyleContainer((StyleContainer)null);
return;
+ case StylesPackage.STYLE__ROTATION:
+ setRotation(ROTATION_EDEFAULT);
+ return;
}
super.eUnset(featureID);
}
@@ -1235,6 +1298,8 @@ public boolean eIsSet(int featureID) {
return PROPORTIONAL_EDEFAULT == null ? proportional != null : !PROPORTIONAL_EDEFAULT.equals(proportional);
case StylesPackage.STYLE__STYLE_CONTAINER:
return basicGetStyleContainer() != null;
+ case StylesPackage.STYLE__ROTATION:
+ return ROTATION_EDEFAULT == null ? rotation != null : !ROTATION_EDEFAULT.equals(rotation);
}
return super.eIsSet(featureID);
}
@@ -1321,6 +1386,8 @@ public String toString() {
result.append(stretchV);
result.append(", proportional: ");
result.append(proportional);
+ result.append(", rotation: ");
+ result.append(rotation);
result.append(')');
return result.toString();
}
View
14 ...ns/org.eclipse.graphiti.mm/src-gen/org/eclipse/graphiti/mm/algorithms/styles/impl/StylesPackageImpl.java
@@ -1,7 +1,7 @@
/**
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2014 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
@@ -9,6 +9,7 @@
*
* Contributors:
* SAP AG - initial API, implementation and documentation
+ * mwenz - Bug 423573 - Angles should never be integer
*
* </copyright>
*/
@@ -366,6 +367,15 @@ public EReference getStyle_StyleContainer() {
* <!-- end-user-doc -->
* @generated
*/
+ public EAttribute getStyle_Rotation() {
+ return (EAttribute)styleEClass.getEStructuralFeatures().get(10);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
public EClass getAbstractStyle() {
return abstractStyleEClass;
}
@@ -916,6 +926,7 @@ public void createPackageContents() {
createEAttribute(styleEClass, STYLE__STRETCH_V);
createEAttribute(styleEClass, STYLE__PROPORTIONAL);
createEReference(styleEClass, STYLE__STYLE_CONTAINER);
+ createEAttribute(styleEClass, STYLE__ROTATION);
abstractStyleEClass = createEClass(ABSTRACT_STYLE);
createEReference(abstractStyleEClass, ABSTRACT_STYLE__BACKGROUND);
@@ -1037,6 +1048,7 @@ public void initializePackageContents() {
initEAttribute(getStyle_StretchV(), ecorePackage.getEBooleanObject(), "stretchV", null, 0, 1, Style.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED);
initEAttribute(getStyle_Proportional(), ecorePackage.getEBooleanObject(), "proportional", null, 0, 1, Style.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED);
initEReference(getStyle_StyleContainer(), theMmPackage.getStyleContainer(), theMmPackage.getStyleContainer_Styles(), "styleContainer", null, 1, 1, Style.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED);
+ initEAttribute(getStyle_Rotation(), ecorePackage.getEDoubleObject(), "rotation", "0", 0, 1, Style.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED);
initEClass(abstractStyleEClass, AbstractStyle.class, "AbstractStyle", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEReference(getAbstractStyle_Background(), this.getColor(), null, "background", null, 0, 1, AbstractStyle.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, !IS_DERIVED, !IS_ORDERED);
View
11 plugins/org.eclipse.graphiti.ui/src/org/eclipse/graphiti/ui/internal/figures/GFText.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2012 SAP AG.
+ * Copyright (c) 2005, 2014 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
@@ -13,6 +13,7 @@
* mgorning - Bug 374190 - Vertically aligned text disappears after the height of TextImpl is increased
* mgorning - Bug 368124 - ConnectionDecorator with Text causes problems
* mwenz - Bug 405920 - Text background color is ignored on rotated text
+ * mwenz - Bug 423573 - Angles should never be integer
*
* </copyright>
*
@@ -102,10 +103,10 @@ public void paintFigure(Graphics graphics) {
return;
}
- int angle = 0;
- angle = Graphiti.getGaService().getAngle(text, true);
+ double rotation = 0;
+ rotation = Graphiti.getGaService().getRotation(text, true);
- if (angle != 0) {
+ if (rotation != 0) {
// Fix for Bug 405920. Set the background color for rotated
// texts on basis of the original rectangle. Needs to be
// reworked as part of the general rework of this class with Bug
@@ -126,7 +127,7 @@ public void paintFigure(Graphics graphics) {
// the offset to x
// and y based on
// angle
- graphics.rotate(angle);
+ graphics.rotate(new Float(rotation));
rect = new Rectangle(0, 0, 5000, 5000); // TODO calculate the
// real clip rectangle
// from the angle
View
16 plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/services/IGaService.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2012 SAP AG.
+ * Copyright (c) 2005, 2014 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
@@ -11,6 +11,7 @@
* SAP AG - initial API, implementation and documentation
* mwenz - Bug 355347 - Remove setters of Graphiti's Font Interface
* cbrand - Bug 376585 - Clean-up deprecations in Graphiti
+ * mwenz - Bug 423573 - Angles should never be integer
*
* </copyright>
*
@@ -101,10 +102,23 @@
* @param checkStyles
* the check styles
* @return the angle
+ * @deprecated replaced by {@link #getRotation(AbstractText, boolean)}
*/
public int getAngle(AbstractText at, boolean checkStyles);
/**
+ * Gets the angle.
+ *
+ * @param at
+ * the abstract text
+ * @param checkStyles
+ * the check styles
+ * @return the angle
+ * @since 0.11
+ */
+ public double getRotation(AbstractText at, boolean checkStyles);
+
+ /**
* Gets the background color.
*
* @param ga
View
51 plugins/org.eclipse.graphiti/src/org/eclipse/graphiti/services/impl/GaServiceImpl.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2012 SAP AG.
+ * Copyright (c) 2005, 2014 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
@@ -12,6 +12,7 @@
* mwenz - Bug 355347 - Remove setters of Graphiti's Font Interface
* jpasch - Bug 352542 - Add "plain"-create methods for working with styles
* mwenz - Bug 364126 - Make GaServiceImpl extensible
+ * mwenz - Bug 423573 - Angles should never be integer
*
* </copyright>
*
@@ -125,6 +126,21 @@ private static final Integer getAngle(Style style) {
}
}
+ private static final Double getRotation(Style style) {
+ Double rotation = style.getRotation();
+ if (rotation == null) {
+ StyleContainer styleContainer = style.getStyleContainer();
+ if (styleContainer instanceof Style) {
+ Style parentStyle = (Style) styleContainer;
+ return getRotation(parentStyle);
+ } else {
+ return null;
+ }
+ } else {
+ return rotation;
+ }
+ }
+
private static final Color getBackgroundColor(Style style) {
Color bg = style.getBackground();
if (bg == null) {
@@ -1145,6 +1161,8 @@ public final Style findStyle(StyleContainer styleContainer, String id) {
* @see
* org.eclipse.graphiti.services.IGaService#getAngle(org.eclipse.graphiti
* .mm.pictograms.AbstractText, boolean)
+ *
+ * @deprecated replaced by {@link #getRotation(AbstractText, boolean)}
*/
public final int getAngle(AbstractText at, boolean checkStyles) {
Integer angle = at.getAngle();
@@ -1167,6 +1185,33 @@ public final int getAngle(AbstractText at, boolean checkStyles) {
* (non-Javadoc)
*
* @see
+ * org.eclipse.graphiti.services.IGaService#getRotation(org.eclipse.graphiti
+ * .mm.pictograms.AbstractText, boolean)
+ */
+ /**
+ * @since 0.11
+ */
+ public final double getRotation(AbstractText at, boolean checkStyles) {
+ Double angle = at.getRotation();
+ if (angle == null) {
+ if (checkStyles) {
+ Style style = at.getStyle();
+ if (style != null) {
+ Double styleValue = getRotation(style);
+ if (styleValue != null)
+ return styleValue;
+ }
+ }
+ } else {
+ return angle;
+ }
+ return 0; // default value
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
* org.eclipse.graphiti.services.IGaService#getBackgroundColor(org.eclipse
* .graphiti.mm.pictograms.GraphicsAlgorithm, boolean)
*/
@@ -1399,7 +1444,7 @@ public final void resetAll(AbstractStyle abstractStyle) {
abstractStyle.setTransparency(null);
if (abstractStyle instanceof AbstractText) {
AbstractText text = (AbstractText) abstractStyle;
- text.setAngle(null);
+ text.setRotation(null);
text.setFont(null);
text.setHorizontalAlignment(Orientation.UNSPECIFIED);
text.setVerticalAlignment(Orientation.UNSPECIFIED);
@@ -1410,7 +1455,7 @@ public final void resetAll(AbstractStyle abstractStyle) {
image.setStretchV(null);
} else if (abstractStyle instanceof Style) {
Style style = (Style) abstractStyle;
- style.setAngle(null);
+ style.setRotation(null);
style.setFont(null);
style.setHorizontalAlignment(Orientation.UNSPECIFIED);
style.setVerticalAlignment(Orientation.UNSPECIFIED);
View
11 tests/org.eclipse.graphiti.tests/src/org/eclipse/graphiti/tests/GFAbstractCreateTestCase.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2014 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
@@ -9,6 +9,7 @@
*
* Contributors:
* SAP AG - initial API, implementation and documentation
+ * mwenz - Bug 423573 - Angles should never be integer
*
* </copyright>
*
@@ -63,7 +64,8 @@ protected void checkInheritedPlainStyleDefaultsFromMetamodel(Style style) {
assertNull(style.getStretchH());
assertNull(style.getStretchV());
assertNull(style.getFont());
- assertNull(style.getAngle());
+ assertNull(style.getAngle()); // Ok
+ assertNull(style.getRotation());
}
protected void checkInheritedStyleDefaultsFromMetamodel(Style style) {
@@ -80,7 +82,8 @@ protected void checkInheritedStyleDefaultsFromMetamodel(Style style) {
assertNull(style.getStretchH());
assertNull(style.getStretchV());
assertNull(style.getFont());
- assertNull(style.getAngle());
+ assertNull(style.getAngle()); // Ok
+ assertNull(style.getRotation());
}
protected void checkPlainGraphicsAlgorithmDefaults(GraphicsAlgorithm ga) {
@@ -114,6 +117,7 @@ protected void checkPlainImageDefaults(Image im) {
protected void checkTextDefaults(AbstractText text, String value) {
checkGraphicsAlgorithmDefaults(text);
assertEquals(new Integer(0), text.getAngle());
+ assertEquals(new Double(0d), text.getRotation());
assertEquals(Orientation.ALIGNMENT_LEFT, text.getHorizontalAlignment());
assertEquals(Orientation.ALIGNMENT_CENTER, text.getVerticalAlignment());
assertFalse(text.getFilled());
@@ -123,6 +127,7 @@ protected void checkTextDefaults(AbstractText text, String value) {
protected void checkPlainTextDefaults(AbstractText text, String value) {
checkPlainGraphicsAlgorithmDefaults(text);
assertNull(text.getAngle());
+ assertNull(text.getRotation());
assertEquals(Orientation.UNSPECIFIED, text.getHorizontalAlignment());
assertEquals(Orientation.UNSPECIFIED, text.getVerticalAlignment());
assertEquals(value, text.getValue());
View
7 tests/org.eclipse.graphiti.tests/src/org/eclipse/graphiti/tests/cases/GaServiceTest.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2011 SAP AG.
+ * Copyright (c) 2005, 2014 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
@@ -10,6 +10,7 @@
* Contributors:
* SAP AG - initial API, implementation and documentation
* mwenz - Bug 355347 - Remove setters of Graphiti's Font Interface
+ * mwenz - Bug 423573 - Angles should never be integer
*
* </copyright>
*
@@ -618,6 +619,7 @@ public void getter() {
Text text = gas.createDefaultText(d, s1);
assertNotNull(text);
assertNotNull(gas.getAngle(text, false));
+ assertNotNull(gas.getRotation(text, false));
assertNotNull(gas.getLineWidth(text, false));
assertNotNull(gas.getLineStyle(text, false));
assertNotNull(gas.getFont(text, false));
@@ -658,7 +660,7 @@ public void getterWithCheckStyles() {
style.setLineWidth(3);
text.setStyle(style);
- // Rest information on text, such that the style is queried.
+ // Reset information on text, such that the style is queried.
text.setAngle(null);
text.setLineWidth(null);
text.setLineStyle(LineStyle.UNSPECIFIED);
@@ -671,6 +673,7 @@ public void getterWithCheckStyles() {
assertNotNull(text);
assertEquals(2, gas.getAngle(text, true));
+ assertEquals(2, gas.getRotation(text, true), 0);
assertEquals(3, gas.getLineWidth(text, true));
assertEquals(LineStyle.DASH, gas.getLineStyle(text, true));
assertEquals(font, gas.getFont(text, true));
View
5 ...lipse.graphiti.testtool.sketch/src/org/eclipse/graphiti/testtool/sketch/features/AddAnythingFeature.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2010 SAP AG.
+ * Copyright (c) 2005, 2014 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
@@ -9,6 +9,7 @@
*
* Contributors:
* SAP AG - initial API, implementation and documentation
+ * mwenz - Bug 423573 - Angles should never be integer
*
* </copyright>
*
@@ -53,7 +54,7 @@ public PictogramElement add(IAddContext context) {
String text = newObject.getClass().getName() + " - " + newObject.toString();
Text textGa = gaService.createDefaultText(getDiagram(), r, text);
gaService.setLocationAndSize(textGa, 0, 0, 400, 100);
- textGa.setAngle(-1);
+ textGa.setRotation(-1d);
// Create an italic font to use it later in the rich tooltip
gaService.manageFont(getDiagram(), IGaService.DEFAULT_FONT, IGaService.DEFAULT_FONT_SIZE, true, false);
View
10 tests/org.eclipse.graphiti.ui.tests/src/org/eclipse/graphiti/ui/tests/AllTests.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2013 SAP AG.
+ * Copyright (c) 2005, 2014 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
@@ -11,20 +11,20 @@
* SAP AG - initial API, implementation and documentation
* mwenz - Bug 324859 - Need Undo/Redo support for Non-EMF based domain objects
* mwenz - Bug 415884 - Cannot query size of a multi-line text
+ * mwenz - Bug 423573 - Angles should never be integer
*
* </copyright>
*
*******************************************************************************/
package org.eclipse.graphiti.ui.tests;
+import org.eclipse.graphiti.ui.tests.compatibility.CompatibilityTests;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({ PackageTest.class, CommandStackTest.class, MigrationServiceTest.class,
- CustomUndoableFeatureTest.class, RollbackTest.class, LayoutServiceTest.class, CommandTest.class })
+ CustomUndoableFeatureTest.class, RollbackTest.class, LayoutServiceTest.class, CommandTest.class,
+ CompatibilityTests.class })
public class AllTests {
-
- // test comment3
-
}
View
41 tests/org.eclipse.graphiti.ui.tests/src/org/eclipse/graphiti/ui/tests/PackageTest.java
@@ -1,7 +1,7 @@
/*******************************************************************************
* <copyright>
*
- * Copyright (c) 2005, 2012 SAP AG.
+ * Copyright (c) 2005, 2014 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
@@ -13,6 +13,7 @@
* DefaultSaveImageFeature
* cbrand - Bug 376585 - Clean-up deprecations in Graphiti
* Philip Alldredge - Bug 418676 - Undo is not disabled when canUndo is false for Palette features
+ * mwenz - Bug 423573 - Angles should never be integer
* </copyright>
*
*******************************************************************************/
@@ -1040,10 +1041,10 @@ public void testInternal() throws Exception {
IGaService gaService = Graphiti.getGaService();
- gaService.getAngle(abstractTextMock, false);
- gaService.getAngle(abstractTextMock, false);
- gaService.getAngle(abstractTextMock, true);
- gaService.getAngle(abstractTextMock, true);
+ assertEquals(0, gaService.getAngle(abstractTextMock, false), 0);
+ assertEquals(0, gaService.getAngle(abstractTextMock, false), 0);
+ assertEquals(0, gaService.getAngle(abstractTextMock, true), 0);
+ assertEquals(-1, gaService.getAngle(abstractTextMock, true), 0);
// verify(styleMock);
@@ -1540,4 +1541,34 @@ public void testDiagramEditorFactory() {
}
+ @Test
+ public void testGaServiceGetRotation() throws Exception {
+ Style styleMock = createNiceMock(Style.class);
+ expect(styleMock.getRotation()).andReturn(null);
+ expect(styleMock.getStyleContainer()).andReturn(styleMock);
+ expect(styleMock.getRotation()).andReturn(null);
+ expect(styleMock.getStyleContainer()).andReturn(null);
+ expect(styleMock.getRotation()).andReturn(new Double(-1));
+ replay(styleMock);
+
+ AbstractText abstractTextMock = createNiceMock(AbstractText.class);
+ // run 1
+ expect(abstractTextMock.getRotation()).andReturn(null);
+ // run 2
+ expect(abstractTextMock.getRotation()).andReturn(new Double(0));
+ // run 3
+ expect(abstractTextMock.getRotation()).andReturn(null);
+ expect(abstractTextMock.getStyle()).andReturn(styleMock);
+ // run 4
+ expect(abstractTextMock.getRotation()).andReturn(null);
+ expect(abstractTextMock.getStyle()).andReturn(styleMock);
+ replay(abstractTextMock);
+
+ IGaService gaService = Graphiti.getGaService();
+
+ assertEquals(0, gaService.getRotation(abstractTextMock, false), 0d);
+ assertEquals(0, gaService.getRotation(abstractTextMock, false), 0d);
+ assertEquals(0, gaService.getRotation(abstractTextMock, true), 0d);
+ assertEquals(-1, gaService.getRotation(abstractTextMock, true), 0d);
+ }
}
View
17 ...graphiti.ui.tests/src/org/eclipse/graphiti/ui/tests/compatibility/AbstractText_angle_to_rotation.diagram
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="ASCII"?>
+<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" gridUnit="10" diagramTypeId="testtool.sketch" name="S3" snapToGrid="true" version="0.10.0">
+ <graphicsAlgorithm xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.0" lineWidth="1" transparency="0.0" width="1000" height="1000"/>
+ <children visible="true" active="true">
+ <graphicsAlgorithm xsi:type="al:Rectangle" background="//@colors.1" foreground="//@colors.2" lineWidth="2" transparency="0.3" width="101" height="101" x="50" y="50">
+ <graphicsAlgorithmChildren xsi:type="al:MultiText" foreground="//@colors.3" lineWidth="1" filled="false" transparency="0.0" width="101" height="101" font="//@fonts.1" horizontalAlignment="ALIGNMENT_CENTER" value="new element" angle="45"/>
+ </graphicsAlgorithm>
+ <anchors xsi:type="pi:ChopboxAnchor"/>
+ </children>
+ <colors red="227" green="238" blue="249"/>
+ <colors red="255" green="255" blue="255"/>
+ <colors/>
+ <colors blue="255"/>
+ <fonts name="Arial" size="8"/>
+ <fonts name="Comic Sans MS" size="14"/>
+ <fonts name="Arial" size="8" italic="true"/>
+</pi:Diagram>
View
114 tests/org.eclipse.graphiti.ui.tests/src/org/eclipse/graphiti/ui/tests/compatibility/CompatibilityTests.java
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * <copyright>
+ *
+ * Copyright (c) 2014, 2014 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SAP AG - initial API, implementation and documentation (Bug 423573 - Angles should never be integer)
+ *
+ * </copyright>
+ *
+ *******************************************************************************/
+package org.eclipse.graphiti.ui.tests.compatibility;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.URL;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.graphiti.mm.algorithms.AlgorithmsPackage;
+import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm;
+import org.eclipse.graphiti.mm.algorithms.MultiText;
+import org.eclipse.graphiti.mm.algorithms.styles.Style;
+import org.eclipse.graphiti.mm.algorithms.styles.StylesPackage;
+import org.eclipse.graphiti.mm.pictograms.Diagram;
+import org.eclipse.graphiti.mm.pictograms.PictogramsPackage;
+import org.eclipse.graphiti.mm.pictograms.Shape;
+import org.eclipse.graphiti.ui.services.GraphitiUi;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class CompatibilityTests {
+
+ private static TransactionalEditingDomain editingDomain;
+
+ @BeforeClass
+ public static void before() {
+ editingDomain = GraphitiUi.getEmfService().createResourceSetAndEditingDomain();
+ ResourceSet resourceSet = editingDomain.getResourceSet();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
+ .put("diagram", new XMIResourceFactoryImpl()); //$NON-NLS-1$
+
+ // Register the packages of our model with EMF.
+ {
+ @SuppressWarnings("unused")
+ Object o = PictogramsPackage.eINSTANCE;
+ o = AlgorithmsPackage.eINSTANCE;
+ o = StylesPackage.eINSTANCE;
+ }
+ }
+
+ @AfterClass
+ public static void after() {
+ editingDomain.dispose();
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testCanReadDiagramWithAngleAttributeInAbstractText() throws Exception {
+
+ // Load diagram file.
+ URL resource = getClass().getClassLoader().getResource(
+ "org/eclipse/graphiti/ui/tests/compatibility/AbstractText_angle_to_rotation.diagram"); //$NON-NLS-1$
+ URI createFileURI = URI.createFileURI(resource.getFile());
+ ResourceSet resourceSet = editingDomain.getResourceSet();
+ Resource diagramResource = resourceSet.getResource(createFileURI, true);
+
+ final Diagram diagram = (Diagram) diagramResource.getEObject("/0"); //$NON-NLS-1$
+
+ EList<Shape> children = diagram.getChildren();
+ Shape shape = children.get(0);
+ GraphicsAlgorithm graphicsAlgorithm = shape.getGraphicsAlgorithm();
+ EList<GraphicsAlgorithm> graphicsAlgorithmChildren = graphicsAlgorithm.getGraphicsAlgorithmChildren();
+ MultiText text = (MultiText) graphicsAlgorithmChildren.get(0);
+
+ // Text has angle attribute set to 45
+ // -> Reading the object must have stored the value in the new replacing
+ // field rotation but also (for compatibility) in the angle attribute
+ assertEquals(45d, text.getRotation(), 0d);
+ assertEquals(new Integer(45), text.getAngle());
+ }
+
+ @SuppressWarnings("deprecation")
+ @Test
+ public void testCanReadDiagramWithAngleAttributeInStyle() throws Exception {
+
+ // Load diagram file.
+ URL resource = getClass().getClassLoader().getResource(
+ "org/eclipse/graphiti/ui/tests/compatibility/Style_angle_to_rotation.diagram"); //$NON-NLS-1$
+ URI createFileURI = URI.createFileURI(resource.getFile());
+ ResourceSet resourceSet = editingDomain.getResourceSet();
+ Resource diagramResource = resourceSet.getResource(createFileURI, true);
+
+ final Diagram diagram = (Diagram) diagramResource.getEObject("/0"); //$NON-NLS-1$
+
+ EList<Style> styles = diagram.getStyles();
+ Style style = styles.get(0);
+
+ // Style has angle attribute set to 30
+ // -> Reading the object must have stored the value in the new replacing
+ // field rotation but also (for compatibility) in the angle attribute
+ assertEquals(30d, style.getRotation(), 0d);
+ assertEquals(new Integer(30), style.getAngle());
+ }
+}
View
4 ...clipse.graphiti.ui.tests/src/org/eclipse/graphiti/ui/tests/compatibility/Style_angle_to_rotation.diagram
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="ASCII"?>
+<pi:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:al="http://eclipse.org/graphiti/mm/algorithms" xmlns:pi="http://eclipse.org/graphiti/mm/pictograms" visible="true" gridUnit="10" diagramTypeId="testtool.sketch" name="S3" snapToGrid="true" version="0.10.0">
+ <styles lineStyle="UNSPECIFIED" filled="false" id="ECLASS-TEXT" angle="30"/>
+</pi:Diagram>
Please sign in to comment.
Something went wrong with that request. Please try again.