From ba1088ea01f82a4ec62b03fd3f808c6760f01b53 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Wed, 11 Jul 2018 17:35:57 +0200
Subject: [PATCH] creating modifications simplified

---
 ...ntisenseRnaCellDesignerAliasConverter.java | 177 ++++++-------
 .../RnaCellDesignerAliasConverter.java        | 240 +++++++++---------
 .../structure/CellDesignerAntisenseRna.java   |   2 +-
 .../structure/CellDesignerGene.java           |   2 +-
 .../structure/CellDesignerProtein.java        |   2 +-
 .../structure/CellDesignerRna.java            |   2 +-
 .../CellDesignerModificationResidue.java      | 116 +++------
 7 files changed, 253 insertions(+), 288 deletions(-)

diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AntisenseRnaCellDesignerAliasConverter.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AntisenseRnaCellDesignerAliasConverter.java
index f558c3d7f1..f94f91807d 100644
--- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AntisenseRnaCellDesignerAliasConverter.java
+++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/AntisenseRnaCellDesignerAliasConverter.java
@@ -19,97 +19,104 @@ import lcsb.mapviewer.model.map.species.Species;
  */
 public class AntisenseRnaCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<Species> {
 
-	/**
-	 * Default constructor.
-	 * 
-	 * @param sbgn
-	 *          Should the converter use sbgn standard
-	 */
-	protected AntisenseRnaCellDesignerAliasConverter(boolean sbgn) {
-		super(sbgn);
-	}
+  /**
+   * Default constructor.
+   * 
+   * @param sbgn
+   *          Should the converter use sbgn standard
+   */
+  protected AntisenseRnaCellDesignerAliasConverter(boolean sbgn) {
+    super(sbgn);
+  }
 
-	/**
-	 * How big should be the arc in rectangle for nucleic acid feature
-	 * representation.
-	 */
-	private static final int RECTANGLE_CORNER_ARC_SIZE = 5;
+  /**
+   * How big should be the arc in rectangle for nucleic acid feature
+   * representation.
+   */
+  private static final int RECTANGLE_CORNER_ARC_SIZE = 5;
 
-	@Override
-	public Point2D getPointCoordinates(Species alias, CellDesignerAnchor anchor) {
-		if (invalidAnchorPosition(alias, anchor)) {
-			return alias.getCenter();
-		}
-		if (isSbgn()) {
-			return getRectangleTransformation().getPointOnRectangleByAnchor(alias.getX(), alias.getY(), alias.getWidth(), alias.getHeight(), anchor);
-		}
-		ArrayList<Point2D> points = getPoints(alias);
-		return getPolygonTransformation().getPointOnPolygonByAnchor(points, anchor);
-	}
+  @Override
+  public Point2D getPointCoordinates(Species alias, CellDesignerAnchor anchor) {
+    if (invalidAnchorPosition(alias, anchor)) {
+      return alias.getCenter();
+    }
+    if (isSbgn()) {
+      return getRectangleTransformation().getPointOnRectangleByAnchor(alias.getX(), alias.getY(), alias.getWidth(),
+          alias.getHeight(), anchor);
+    }
+    ArrayList<Point2D> points = getPoints(alias);
+    return getPolygonTransformation().getPointOnPolygonByAnchor(points, anchor);
+  }
 
-	@Override
-	protected PathIterator getBoundPathIterator(Species alias) {
-		return getAntisebseRnaPath(alias).getPathIterator(new AffineTransform());
-	}
+  @Override
+  protected PathIterator getBoundPathIterator(Species alias) {
+    return getAntisebseRnaPath(alias).getPathIterator(new AffineTransform());
+  }
 
-	/**
-	 * Returns shape of the AntisenseRna as a list of points.
-	 * 
-	 * @param alias
-	 *          alias for which we are looking for a border
-	 * @return list of points defining border of the given alias
-	 */
-	private ArrayList<Point2D> getPoints(Element alias) {
-		double x = alias.getX();
-		double y = alias.getY();
-		double width = alias.getWidth();
-		double height = alias.getHeight();
-		ArrayList<Point2D> points = new ArrayList<Point2D>();
+  /**
+   * Returns shape of the AntisenseRna as a list of points.
+   * 
+   * @param alias
+   *          alias for which we are looking for a border
+   * @return list of points defining border of the given alias
+   */
+  private ArrayList<Point2D> getPoints(Element alias) {
+    double x = alias.getX();
+    double y = alias.getY();
+    double width = alias.getWidth();
+    double height = alias.getHeight();
+    ArrayList<Point2D> points = new ArrayList<Point2D>();
 
-		// CHECKSTYLE:OFF
-		points.add(new Point2D.Double(x + width / 8, y + height / 2));
-		points.add(new Point2D.Double(x, y));
-		points.add(new Point2D.Double(x + width * 3 / 8, y));
-		points.add(new Point2D.Double(x + width * 3 / 4, y));
-		points.add(new Point2D.Double(x + width * 7 / 8, y + height / 2));
-		points.add(new Point2D.Double(x + width, y + height));
-		points.add(new Point2D.Double(x + width * 5 / 8, y + height));
-		points.add(new Point2D.Double(x + width / 4, y + height));
-		// CHECKSTYLE:ON
-		return points;
-	}
+    // CHECKSTYLE:OFF
+    points.add(new Point2D.Double(x + width / 8, y + height / 2));
+    points.add(new Point2D.Double(x, y));
+    points.add(new Point2D.Double(x + width * 3 / 8, y));
+    points.add(new Point2D.Double(x + width * 3 / 4, y));
+    points.add(new Point2D.Double(x + width * 7 / 8, y + height / 2));
+    points.add(new Point2D.Double(x + width, y + height));
+    points.add(new Point2D.Double(x + width * 5 / 8, y + height));
+    points.add(new Point2D.Double(x + width / 4, y + height));
+    // CHECKSTYLE:ON
+    return points;
+  }
 
-	/**
-	 * Returns shape of the AntisenseRna as a GeneralPath object.
-	 * 
-	 * @param alias
-	 *          alias for which we are looking for a border
-	 * @return GeneralPath object defining border of the given alias
-	 */
-	private GeneralPath getAntisebseRnaPath(Element alias) {
-		// CHECKSTYLE:OFF
-		GeneralPath path;
-		if (!isSbgn()) {
-			path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 4);
-			path.moveTo(alias.getX(), alias.getY());
-			path.lineTo(alias.getX() + alias.getWidth() * 3 / 4, alias.getY());
-			path.lineTo(alias.getX() + alias.getWidth(), alias.getY() + alias.getHeight());
-			path.lineTo(alias.getX() + alias.getWidth() / 4, alias.getY() + alias.getHeight());
-			path.closePath();
-		} else {
-			path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 6);
-			double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight();
+  /**
+   * Returns shape of the AntisenseRna as a GeneralPath object.
+   * 
+   * @param alias
+   *          alias for which we are looking for a border
+   * @return GeneralPath object defining border of the given alias
+   */
+  private GeneralPath getAntisebseRnaPath(Element alias) {
+    // CHECKSTYLE:OFF
+    GeneralPath path;
+    if (!isSbgn()) {
+      path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 4);
+      path.moveTo(alias.getX(), alias.getY());
+      path.lineTo(alias.getX() + alias.getWidth() * 3 / 4, alias.getY());
+      path.lineTo(alias.getX() + alias.getWidth(), alias.getY() + alias.getHeight());
+      path.lineTo(alias.getX() + alias.getWidth() / 4, alias.getY() + alias.getHeight());
+      path.closePath();
+    } else {
+      path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 6);
+      double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight();
 
-			path.moveTo(x, y);
-			path.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE);
-			path.curveTo(x, y + height, x + RECTANGLE_CORNER_ARC_SIZE, y + height, x + RECTANGLE_CORNER_ARC_SIZE, y + height);
-			path.lineTo(x + width - RECTANGLE_CORNER_ARC_SIZE, y + height);
-			path.curveTo(x + width, y + height, x + width, y + height - RECTANGLE_CORNER_ARC_SIZE, x + width, y + height - RECTANGLE_CORNER_ARC_SIZE);
-			path.lineTo(x + width, y);
-			path.closePath();
-		}
-		// CHECKSTYLE:ON
-		return path;
-	}
+      path.moveTo(x, y);
+      path.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE);
+      path.curveTo(x, y + height, x + RECTANGLE_CORNER_ARC_SIZE, y + height, x + RECTANGLE_CORNER_ARC_SIZE, y + height);
+      path.lineTo(x + width - RECTANGLE_CORNER_ARC_SIZE, y + height);
+      path.curveTo(x + width, y + height, x + width, y + height - RECTANGLE_CORNER_ARC_SIZE, x + width,
+          y + height - RECTANGLE_CORNER_ARC_SIZE);
+      path.lineTo(x + width, y);
+      path.closePath();
+    }
+    // CHECKSTYLE:ON
+    return path;
+  }
+
+  @Override
+  public Point2D getResidueCoordinates(Species element, double angle) {
+    return new Point2D.Double(element.getX() + element.getWidth() * 3.0 / 4.0 * angle, element.getY());
+  }
 
 }
diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/RnaCellDesignerAliasConverter.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/RnaCellDesignerAliasConverter.java
index 0cee48a0e6..7116bb1f8a 100644
--- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/RnaCellDesignerAliasConverter.java
+++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/geometry/RnaCellDesignerAliasConverter.java
@@ -1,118 +1,122 @@
-package lcsb.mapviewer.converter.model.celldesigner.geometry;
-
-import java.awt.geom.AffineTransform;
-import java.awt.geom.GeneralPath;
-import java.awt.geom.PathIterator;
-import java.awt.geom.Point2D;
-import java.util.ArrayList;
-
-import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor;
-import lcsb.mapviewer.model.map.species.Element;
-import lcsb.mapviewer.model.map.species.Species;
-
-/**
- * Class that provides CellDesigner specific graphical information for Rna.
- * It's used for conversion from xml to normal x,y coordinates.
- * 
- * @author Piotr Gawron
- * 
- */
-public class RnaCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<Species> {
-
-	/**
-	 * Default constructor.
-	 * 
-	 * @param sbgn
-	 *          Should the converter use sbgn standard
-	 */
-	protected RnaCellDesignerAliasConverter(boolean sbgn) {
-		super(sbgn);
-	}
-
-	/**
-	 * How big should be the arc in rectangle for nucleic acid feature representation.
-	 */	
-	private static final int	RECTANGLE_CORNER_ARC_SIZE	= 5;
-	
-	@Override
-	public Point2D getPointCoordinates(Species alias, CellDesignerAnchor anchor) {
-		if (invalidAnchorPosition(alias, anchor)) {
-			return alias.getCenter();
-		}
-		if (isSbgn()) {
-			return getRectangleTransformation().getPointOnRectangleByAnchor(alias.getX(), alias.getY(),
-																																			alias.getWidth(), alias.getHeight(), anchor);
-		}
-		ArrayList<Point2D> points = getPoints(alias);
-		return getPolygonTransformation().getPointOnPolygonByAnchor(points, anchor);
-	}
-
-	@Override
-	public PathIterator getBoundPathIterator(Species alias) {
-		return getRnaPath(alias).getPathIterator(new AffineTransform());
-	}
-
-	/**
-	 * Returns shape of the Rna as a list of points.
-	 * 
-	 * @param alias
-	 *          alias for which we are looking for a border
-	 * @return list of points defining border of the given alias
-	 */
-	private ArrayList<Point2D> getPoints(Element alias) {
-		double x = alias.getX();
-		double y = alias.getY();
-		double width = alias.getWidth();
-		double height = alias.getHeight();
-		ArrayList<Point2D> points = new ArrayList<Point2D>();
-		// CHECKSTYLE:OFF
-		points.add(new Point2D.Double(x + width / 8, y + height / 2));
-		points.add(new Point2D.Double(x + width / 4, y));
-		points.add(new Point2D.Double(x + width * 5 / 8, y));
-		points.add(new Point2D.Double(x + width, y));
-		points.add(new Point2D.Double(x + width * 7 / 8, y + height / 2));
-		points.add(new Point2D.Double(x + width * 3 / 4, y + height));
-		points.add(new Point2D.Double(x + width * 3 / 8, y + height));
-		// CHECKSTYLE:ON
-		points.add(new Point2D.Double(x, y + height));
-		return points;
-	}
-
-	/**
-	 * Returns shape of the Rna as a GeneralPath object.
-	 * 
-	 * @param alias
-	 *          alias for which we are looking for a border
-	 * @return GeneralPath object defining border of the given alias
-	 */
-	private GeneralPath getRnaPath(Element alias) {
-		// CHECKSTYLE:OFF
-		GeneralPath path;
-		if (!isSbgn()) {
-			path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 4);
-			path.moveTo(alias.getX() + alias.getWidth() / 4, alias.getY());
-			path.lineTo(alias.getX() + alias.getWidth(), alias.getY());
-			path.lineTo(alias.getX() + alias.getWidth() * 3 / 4, alias.getY() + alias.getHeight());
-			path.lineTo(alias.getX(), alias.getY() + alias.getHeight());
-			path.closePath();
-		} else {
-			path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 6);
-			double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight();
-			
-			path.moveTo(x, y);
-			path.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE);
-			path.curveTo(x, y + height,
-																			x + RECTANGLE_CORNER_ARC_SIZE, y + height,
-																			x + RECTANGLE_CORNER_ARC_SIZE, y + height);
-			path.lineTo(x + width - RECTANGLE_CORNER_ARC_SIZE, y + height);
-			path.curveTo(x + width, y + height,
-																			x + width, y + height - RECTANGLE_CORNER_ARC_SIZE,
-																			x + width, y + height - RECTANGLE_CORNER_ARC_SIZE);
-			path.lineTo(x + width, y);
-			path.closePath();
-		}
-		// CHECKSTYLE:ON
-		return path;
-	}
-
-}
+package lcsb.mapviewer.converter.model.celldesigner.geometry;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+
+import lcsb.mapviewer.converter.model.celldesigner.geometry.helper.CellDesignerAnchor;
+import lcsb.mapviewer.model.map.species.Element;
+import lcsb.mapviewer.model.map.species.Species;
+
+/**
+ * Class that provides CellDesigner specific graphical information for Rna. It's
+ * used for conversion from xml to normal x,y coordinates.
+ * 
+ * @author Piotr Gawron
+ * 
+ */
+public class RnaCellDesignerAliasConverter extends AbstractCellDesignerAliasConverter<Species> {
+
+  /**
+   * Default constructor.
+   * 
+   * @param sbgn
+   *          Should the converter use sbgn standard
+   */
+  protected RnaCellDesignerAliasConverter(boolean sbgn) {
+    super(sbgn);
+  }
+
+  /**
+   * How big should be the arc in rectangle for nucleic acid feature
+   * representation.
+   */
+  private static final int RECTANGLE_CORNER_ARC_SIZE = 5;
+
+  @Override
+  public Point2D getPointCoordinates(Species alias, CellDesignerAnchor anchor) {
+    if (invalidAnchorPosition(alias, anchor)) {
+      return alias.getCenter();
+    }
+    if (isSbgn()) {
+      return getRectangleTransformation().getPointOnRectangleByAnchor(alias.getX(), alias.getY(), alias.getWidth(),
+          alias.getHeight(), anchor);
+    }
+    ArrayList<Point2D> points = getPoints(alias);
+    return getPolygonTransformation().getPointOnPolygonByAnchor(points, anchor);
+  }
+
+  @Override
+  public PathIterator getBoundPathIterator(Species alias) {
+    return getRnaPath(alias).getPathIterator(new AffineTransform());
+  }
+
+  /**
+   * Returns shape of the Rna as a list of points.
+   * 
+   * @param alias
+   *          alias for which we are looking for a border
+   * @return list of points defining border of the given alias
+   */
+  private ArrayList<Point2D> getPoints(Element alias) {
+    double x = alias.getX();
+    double y = alias.getY();
+    double width = alias.getWidth();
+    double height = alias.getHeight();
+    ArrayList<Point2D> points = new ArrayList<Point2D>();
+    // CHECKSTYLE:OFF
+    points.add(new Point2D.Double(x + width / 8, y + height / 2));
+    points.add(new Point2D.Double(x + width / 4, y));
+    points.add(new Point2D.Double(x + width * 5 / 8, y));
+    points.add(new Point2D.Double(x + width, y));
+    points.add(new Point2D.Double(x + width * 7 / 8, y + height / 2));
+    points.add(new Point2D.Double(x + width * 3 / 4, y + height));
+    points.add(new Point2D.Double(x + width * 3 / 8, y + height));
+    // CHECKSTYLE:ON
+    points.add(new Point2D.Double(x, y + height));
+    return points;
+  }
+
+  /**
+   * Returns shape of the Rna as a GeneralPath object.
+   * 
+   * @param alias
+   *          alias for which we are looking for a border
+   * @return GeneralPath object defining border of the given alias
+   */
+  private GeneralPath getRnaPath(Element alias) {
+    // CHECKSTYLE:OFF
+    GeneralPath path;
+    if (!isSbgn()) {
+      path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 4);
+      path.moveTo(alias.getX() + alias.getWidth() / 4, alias.getY());
+      path.lineTo(alias.getX() + alias.getWidth(), alias.getY());
+      path.lineTo(alias.getX() + alias.getWidth() * 3 / 4, alias.getY() + alias.getHeight());
+      path.lineTo(alias.getX(), alias.getY() + alias.getHeight());
+      path.closePath();
+    } else {
+      path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 6);
+      double x = alias.getX(), y = alias.getY(), width = alias.getWidth(), height = alias.getHeight();
+
+      path.moveTo(x, y);
+      path.lineTo(x, y + height - RECTANGLE_CORNER_ARC_SIZE);
+      path.curveTo(x, y + height, x + RECTANGLE_CORNER_ARC_SIZE, y + height, x + RECTANGLE_CORNER_ARC_SIZE, y + height);
+      path.lineTo(x + width - RECTANGLE_CORNER_ARC_SIZE, y + height);
+      path.curveTo(x + width, y + height, x + width, y + height - RECTANGLE_CORNER_ARC_SIZE, x + width,
+          y + height - RECTANGLE_CORNER_ARC_SIZE);
+      path.lineTo(x + width, y);
+      path.closePath();
+    }
+    // CHECKSTYLE:ON
+    return path;
+  }
+
+  @Override
+  public Point2D getResidueCoordinates(Species element, double angle) {
+    return new Point2D.Double(element.getX() + element.getWidth() / 4.0 + element.getWidth() * 3.0 / 4.0 * angle,
+        element.getY());
+  }
+
+}
diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRna.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRna.java
index be71b282d6..dd6373dc29 100644
--- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRna.java
+++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerAntisenseRna.java
@@ -146,7 +146,7 @@ public class CellDesignerAntisenseRna extends CellDesignerSpecies<AntisenseRna>
   @Override
   public void updateModelElementAfterLayoutAdded(Species element) {
     for (CellDesignerModificationResidue region : regions) {
-      ((AntisenseRna) element).addRegion(region.createAntisenseRegionAlias(element));
+      ((AntisenseRna) element).addRegion(region.createModificationResidue(element));
     }
   }
 
diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGene.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGene.java
index db286beee2..7e485de816 100644
--- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGene.java
+++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerGene.java
@@ -115,7 +115,7 @@ public class CellDesignerGene extends CellDesignerSpecies<Gene> {
   @Override
   public void updateModelElementAfterLayoutAdded(Species element) {
     for (CellDesignerModificationResidue region : modificationResidues) {
-      ((Gene) element).addModificationResidue(region.createGeneModification(element));
+      ((Gene) element).addModificationResidue(region.createModificationResidue(element));
     }
   }
 
diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProtein.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProtein.java
index 12892adc56..9fa15ca0df 100644
--- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProtein.java
+++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerProtein.java
@@ -152,7 +152,7 @@ public class CellDesignerProtein<T extends Protein> extends CellDesignerSpecies<
   @Override
   public void updateModelElementAfterLayoutAdded(Species element) {
     for (CellDesignerModificationResidue mr : modificationResidues) {
-      ((Protein) element).addModificationResidue(mr.createProteinModification(element));
+      ((Protein) element).addModificationResidue(mr.createModificationResidue(element));
     }
   }
 
diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRna.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRna.java
index 2c0bc90eea..745cc58d1b 100644
--- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRna.java
+++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/CellDesignerRna.java
@@ -145,7 +145,7 @@ public class CellDesignerRna extends CellDesignerSpecies<Rna> {
   public void updateModelElementAfterLayoutAdded(Species element) {
     for (CellDesignerModificationResidue region : regions) {
       Rna rna = (Rna) element;
-      rna.addRegion(region.createRnaRegionAlias(rna));
+      rna.addRegion(region.createModificationResidue(rna));
     }
   }
 
diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerModificationResidue.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerModificationResidue.java
index 20eeb4f427..49a4e24703 100644
--- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerModificationResidue.java
+++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/structure/fields/CellDesignerModificationResidue.java
@@ -1,6 +1,5 @@
 package lcsb.mapviewer.converter.model.celldesigner.structure.fields;
 
-import java.awt.geom.Point2D;
 import java.io.Serializable;
 
 import org.apache.log4j.Logger;
@@ -348,19 +347,46 @@ public class CellDesignerModificationResidue implements Serializable {
    * 
    * @return {@link ModificationResidue} representing this object in a model
    */
-  public ModificationResidue createProteinModification(Element element) {
+  public ModificationResidue createModificationResidue(Element element) {
     CellDesignerAliasConverter converter = new CellDesignerAliasConverter(element, false);
 
-    ModificationResidue result = null;
     if (modificationType == null) {
       throw new InvalidArgumentException("No type information for modification: " + idModificationResidue);
     } else if (modificationType.equals("RESIDUE")) {
-      result = new Residue();
-      ((Residue) result).setState(this.getState());
+      return createResidue(element, converter);
+    } else if (modificationType.equals("MODIFICATION_SITE")) {
+      return createModificationSite(element, converter);
+    } else if (modificationType.equals("CODING_REGION")) {
+      return createCodingRegion(element, converter);
+    } else if (modificationType.equals("PROTEIN_BINDING_DOMAIN")) {
+      return createProteinBindingDomain(element, converter);
     } else {
-      throw new InvalidArgumentException("Unknown protein modification type: " + modificationType);
+      throw new InvalidArgumentException("Unknown modification type: " + modificationType);
     }
 
+  }
+
+  private ProteinBindingDomain createProteinBindingDomain(Element element, CellDesignerAliasConverter converter) {
+    ProteinBindingDomain result = new ProteinBindingDomain();
+    result.setWidth(element.getWidth() * size);
+    result.setIdModificationResidue(idModificationResidue);
+    result.setName(name);
+    result.setPosition(converter.getResidueCoordinates(element, angle));
+    return result;
+  }
+
+  private CodingRegion createCodingRegion(Element element, CellDesignerAliasConverter converter) {
+    CodingRegion result = new CodingRegion();
+    result.setWidth(element.getWidth() * size);
+    result.setIdModificationResidue(idModificationResidue);
+    result.setName(name);
+    result.setPosition(converter.getResidueCoordinates(element, angle));
+    return result;
+  }
+
+  private ModificationSite createModificationSite(Element element, CellDesignerAliasConverter converter) {
+    ModificationSite result = new ModificationSite();
+    result.setState(this.getState());
     result.setIdModificationResidue(this.getIdModificationResidue());
     result.setName(this.getName());
     if (angle == null) {
@@ -371,26 +397,9 @@ public class CellDesignerModificationResidue implements Serializable {
     return result;
   }
 
-  /**
-   * Creates model representation of {@link ModificationResidue}.
-   * 
-   * @return {@link ModificationResidue} representing this object in a model
-   */
-  public ModificationResidue createGeneModification(Element element) {
-    CellDesignerAliasConverter converter = new CellDesignerAliasConverter(element, false);
-    ModificationResidue result;
-
-    if (modificationType == null) {
-      logger.debug(this);
-      throw new InvalidArgumentException("Unknown gene modification type");
-    } else if (modificationType.equals("MODIFICATION_SITE")) {
-      result = new ModificationSite();
-      ((ModificationSite) result).setState(this.getState());
-    } else {
-      logger.debug(this);
-      throw new InvalidArgumentException("Unknown gene modification type: " + modificationType);
-    }
-
+  private Residue createResidue(Element element, CellDesignerAliasConverter converter) {
+    Residue result = new Residue();
+    result.setState(this.getState());
     result.setIdModificationResidue(this.getIdModificationResidue());
     result.setName(this.getName());
     if (angle == null) {
@@ -401,61 +410,6 @@ public class CellDesignerModificationResidue implements Serializable {
     return result;
   }
 
-  /**
-   * Creates model representation of {@link AntisenseRnaRegion}.
-   * 
-   * @return {@link AntisenseRnaRegion} representing this object in a model
-   */
-  public ModificationResidue createAntisenseRegionAlias(Element element) {
-    ModificationResidue result;
-    if (modificationType.equals("MODIFICATION_SITE")) {
-      result = new ModificationSite();
-    } else if (modificationType.equals("CODING_REGION")) {
-      result = new CodingRegion();
-      ((CodingRegion) result).setWidth(element.getWidth() * size);
-    } else if (modificationType.equals("PROTEIN_BINDING_DOMAIN")) {
-      result = new ProteinBindingDomain();
-      ((ProteinBindingDomain) result).setWidth(element.getWidth() * size);
-    } else {
-      throw new InvalidArgumentException("Unknown antisense rna modification type: " + modificationType);
-
-    }
-    result.setIdModificationResidue(idModificationResidue);
-    result.setName(name);
-
-    result.setPosition(new Point2D.Double(element.getX() + element.getWidth() * 3.0 / 4.0 * pos, element.getY()));
-    return result;
-  }
-
-  /**
-   * Creates model representation of {@link RnaRegion}.
-   * 
-   * @return {@link RnaRegion} representing this object in a model
-   */
-  public ModificationResidue createRnaRegionAlias(Element element) {
-    ModificationResidue result;
-    if (modificationType == null) {
-      throw new InvalidArgumentException("No type information for modification: " + idModificationResidue);
-    } else if (modificationType.equals("MODIFICATION_SITE")) {
-      result = new ModificationSite();
-      ((ModificationSite) result).setState(this.state);
-    } else if (modificationType.equals("CODING_REGION")) {
-      result = new CodingRegion();
-      ((CodingRegion) result).setWidth(element.getWidth() * size);
-    } else if (modificationType.equals("PROTEIN_BINDING_DOMAIN")) {
-      result = new ProteinBindingDomain();
-      ((ProteinBindingDomain) result).setWidth(element.getWidth() * size);
-    } else {
-      throw new InvalidArgumentException("Unknown antisense rna modification type: " + modificationType);
-
-    }
-    result.setIdModificationResidue(this.idModificationResidue);
-    result.setPosition(new Point2D.Double(
-        element.getX() + element.getWidth() / 4.0 + element.getWidth() * 3.0 / 4.0 * pos, element.getY()));
-    result.setName(this.name);
-    return result;
-  }
-
   public String getModificationType() {
     return modificationType;
   }
-- 
GitLab