summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2013-08-08 18:43:37 (EDT)
committerJuergen Haug2013-08-08 18:43:37 (EDT)
commit2fb2114c5287c41f2cf624476f0fe9e4bc18cbbb (patch)
treeb461bdd88fc6044c779f502c8dab78a6ae6f76f9
parent2af0dfc2f970f9e87d4a30a0ae4207c418933c41 (diff)
downloadorg.eclipse.etrice-2fb2114c5287c41f2cf624476f0fe9e4bc18cbbb.zip
org.eclipse.etrice-2fb2114c5287c41f2cf624476f0fe9e4bc18cbbb.tar.gz
org.eclipse.etrice-2fb2114c5287c41f2cf624476f0fe9e4bc18cbbb.tar.bz2
[ui.behavior] Bug 404875 - update of bend points wrong if base diagramrefs/changes/66/15266/1
has different offset
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/DefaultPositionProvider.java17
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/IPositionProvider.java8
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/SupportUtil.java2
3 files changed, 23 insertions, 4 deletions
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/DefaultPositionProvider.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/DefaultPositionProvider.java
index da2b850..cca29c6 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/DefaultPositionProvider.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/DefaultPositionProvider.java
@@ -58,6 +58,7 @@ public class DefaultPositionProvider implements IPositionProvider {
private HashMap<String, PosAndSize> sg2sz = new HashMap<String, PosAndSize>();
private double scaleX;
private double scaleY;
+ private int posX, posY;
public DefaultPositionProvider(ActorClass ac) {
mapPositions(ac.getBase());
@@ -71,6 +72,12 @@ public class DefaultPositionProvider implements IPositionProvider {
this.scaleX = sx;
this.scaleY = sy;
}
+
+ @Override
+ public void setPosition(int x, int y){
+ this.posX = x;
+ this.posY = y;
+ }
public PosAndSize getPosition(StateGraphNode node) {
Position pos = obj2pos.get(RoomNameProvider.getFullPath(node));
@@ -113,13 +120,15 @@ public class DefaultPositionProvider implements IPositionProvider {
ArrayList<Position> list = trans2points.get(RoomNameProvider.getFullPath(trans));
if (list!=null) {
+ int i = 0;
for (Position p : list) {
Pos pos =
new Pos(
- (int) (p.x * scaleX),
- (int) (p.y * scaleY)
+ (int) (p.x * scaleX) + ((i==0)?0:posX),
+ (int) (p.y * scaleY) + ((i==0)?0:posY)
);
result.add(pos);
+ i++;
}
}
@@ -262,8 +271,8 @@ public class DefaultPositionProvider implements IPositionProvider {
if (conn instanceof FreeFormConnection) {
for (Point bp : ((FreeFormConnection) conn).getBendpoints()) {
pos = new Position();
- pos.x = bp.getX() / ((double)sz.getWidth());
- pos.y = bp.getY() / ((double)sz.getHeight());
+ pos.x = (bp.getX() - sz.getX()) / ((double)sz.getWidth());
+ pos.y = (bp.getY() - sz.getY()) / ((double)sz.getHeight());
points.add(pos);
}
}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/IPositionProvider.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/IPositionProvider.java
index d382611..bf50223 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/IPositionProvider.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/IPositionProvider.java
@@ -89,6 +89,14 @@ public interface IPositionProvider {
* @param sy scale in y direction
*/
public void setScale(double sx, double sy);
+
+ /**
+ * Set the position of the state graph to which coordinates should be mapped.
+ *
+ * @param x
+ * @param y
+ */
+ public void setPosition(int x, int y);
/**
* @param sg a {@link StateGraph}
diff --git a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/SupportUtil.java b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/SupportUtil.java
index f883f83..5591055 100644
--- a/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/SupportUtil.java
+++ b/plugins/org.eclipse.etrice.ui.behavior/src/org/eclipse/etrice/ui/behavior/support/SupportUtil.java
@@ -466,6 +466,7 @@ public class SupportUtil {
GraphicsAlgorithm borderRect = sgShape.getGraphicsAlgorithm().getGraphicsAlgorithmChildren().get(0);
ctx.getPositionProvider().setScale(borderRect.getWidth(), borderRect.getHeight());
+ ctx.getPositionProvider().setPosition(sgShape.getGraphicsAlgorithm().getX(), sgShape.getGraphicsAlgorithm().getY());
addInitialPointIff(ctx, ctx.getPositionProvider(), sgShape, fp, node2anchor);
addStateGraphNodes(ctx.getTrPoints(), ctx.getPositionProvider(), sgShape, fp, node2anchor);
@@ -522,6 +523,7 @@ public class SupportUtil {
GraphicsAlgorithm borderRect = sgShape.getGraphicsAlgorithm().getGraphicsAlgorithmChildren().get(0);
ctx.getPositionProvider().setScale(borderRect.getWidth(), borderRect.getHeight());
+ ctx.getPositionProvider().setPosition(sgShape.getGraphicsAlgorithm().getX(), sgShape.getGraphicsAlgorithm().getY());
// states
{