diff options
author | Henrik Rentz-Reichert | 2017-12-08 16:58:07 +0000 |
---|---|---|
committer | Henrik Rentz-Reichert | 2017-12-08 16:58:07 +0000 |
commit | 97db531e8fa6d639abf4ac2bbbb1dbdb5ad79f15 (patch) | |
tree | 17f3f1f424fbcef316aca5c0ec1e7bdc65dac042 | |
parent | cbdeed7e39a3508eaf354104fbcf69f22ad11437 (diff) | |
download | org.eclipse.etrice-97db531e8fa6d639abf4ac2bbbb1dbdb5ad79f15.tar.gz org.eclipse.etrice-97db531e8fa6d639abf4ac2bbbb1dbdb5ad79f15.tar.xz org.eclipse.etrice-97db531e8fa6d639abf4ac2bbbb1dbdb5ad79f15.zip |
Bug 511330 - [core.genmodel.fsm] introduce simplified generator model
for state machines
* fixes in automatic placement of inherited state graph items
* node positions
* bend point positions
Change-Id: Idc611bb1c03ab3b1c426cc2fce4ca781f1b2dd16
3 files changed, 24 insertions, 29 deletions
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/BaseDiagramPositionProvider.xtend b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/BaseDiagramPositionProvider.xtend index aca12cb84..083c0e12e 100644 --- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/BaseDiagramPositionProvider.xtend +++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/BaseDiagramPositionProvider.xtend @@ -68,7 +68,7 @@ class BaseDiagramPositionProvider implements IPositionProvider { override getGraphPosAndSize(StateGraph sg) { // graph is child of border shape, see initial point val pe = baseDiagram.getPictograms(sg).findFirst[parentBo instanceof ModelComponent] - if(pe != null){ + if (pe !== null){ val visibleGa = pe.graphicsAlgorithm.graphicsAlgorithmChildren.head new PosAndSize(pe.graphicsAlgorithm.x, pe.graphicsAlgorithm.y, visibleGa.width, visibleGa.height) } @@ -82,18 +82,18 @@ class BaseDiagramPositionProvider implements IPositionProvider { baseDiagram.getPictograms(trans).head } newArrayList => [ pointList | - if(pe instanceof Connection){ + if (pe instanceof Connection){ val graphPosAndSize = getGraphPosAndSize(trans.eContainer as StateGraph) val text = pe.connectionDecorators.map[graphicsAlgorithm].filter(Text).head - if(text != null){ + if (text !== null){ pointList += new Pos( - ((text.x / graphPosAndSize.width as double) * sx) as int, - ((text.y / graphPosAndSize.height as double) * sy) as int + (((text.x / graphPosAndSize.width as double) * sx) as int), + (((text.y / graphPosAndSize.height as double) * sy) as int) ) - if(pe instanceof FreeFormConnection){ - pointList += pe.bendpoints.map[new Pos( - ((text.x / graphPosAndSize.width as double) * sx + x) as int, - ((text.y / graphPosAndSize.height as double) * sy + y) as int + if (pe instanceof FreeFormConnection){ + pointList += pe.bendpoints.map[pt | new Pos( + (((pt.x / graphPosAndSize.width as double) * sx + x) as int) - StateGraphSupport.MARGIN, + (((pt.y / graphPosAndSize.height as double) * sy + y) as int) - StateGraphSupport.MARGIN )] } } @@ -122,7 +122,7 @@ class BaseDiagramPositionProvider implements IPositionProvider { } } - // TODO: better naming, this is initial point + // TODO: better naming, this is the initial point override getPosition(StateGraph graph) { // initial point bo is graph and it is child of border shape baseDiagram.getPictograms(graph).findFirst[parentBo instanceof StateGraph]?.toPosAndSize(graph.margin) @@ -134,7 +134,7 @@ class BaseDiagramPositionProvider implements IPositionProvider { override getSubPosition(StateGraphNode subNode) { val pe = baseDiagram.getPictograms(subNode).findFirst[parentBo instanceof State] - if(pe != null){ + if (pe !== null){ val parentPe = pe.eContainer as PictogramElement val relX = pe.graphicsAlgorithm.getX() as double / (parentPe.graphicsAlgorithm.getWidth() - 2 * StateSupport.MARGIN) val relY = pe.graphicsAlgorithm.getY() as double / (parentPe.graphicsAlgorithm.getHeight() - 2 * StateSupport.MARGIN) diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/util/DiagramEditingUtil.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/util/DiagramEditingUtil.java index faadabd60..c90cd2e26 100644 --- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/util/DiagramEditingUtil.java +++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/support/util/DiagramEditingUtil.java @@ -474,7 +474,7 @@ public class DiagramEditingUtil { n++; } - int delta = (int) (scaleX * (n+1)); + int delta = (int) (scaleX / (n+1)); int pos = delta; int h = StateGraphSupport.MARGIN; @@ -508,7 +508,7 @@ public class DiagramEditingUtil { private void addStateGraphNodes(List<? extends StateGraphNode> nodes, IPositionProvider positionProvider, ContainerShape sgShape, IFeatureProvider fp, HashMap<String, Anchor> node2anchor) { - List<PosAndSize> positions = getPositions(nodes, positionProvider, sgShape.getGraphicsAlgorithm().getX()); + List<PosAndSize> positions = getPositions(nodes, positionProvider, sgShape.getGraphicsAlgorithm().getWidth()); int idx = 0; for (StateGraphNode node : nodes) { diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/xtend-gen/org/eclipse/etrice/ui/behavior/fsm/support/BaseDiagramPositionProvider.java b/plugins/org.eclipse.etrice.ui.behavior.fsm/xtend-gen/org/eclipse/etrice/ui/behavior/fsm/support/BaseDiagramPositionProvider.java index 55e7293be..732824347 100644 --- a/plugins/org.eclipse.etrice.ui.behavior.fsm/xtend-gen/org/eclipse/etrice/ui/behavior/fsm/support/BaseDiagramPositionProvider.java +++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/xtend-gen/org/eclipse/etrice/ui/behavior/fsm/support/BaseDiagramPositionProvider.java @@ -10,7 +10,6 @@ */ package org.eclipse.etrice.ui.behavior.fsm.support; -import com.google.common.base.Objects; import com.google.common.collect.Iterables; import java.util.ArrayList; import java.util.List; @@ -26,6 +25,7 @@ import org.eclipse.etrice.core.fsm.fSM.TrPoint; import org.eclipse.etrice.core.fsm.fSM.Transition; import org.eclipse.etrice.ui.behavior.fsm.provider.BaseDiagramProvider; import org.eclipse.etrice.ui.behavior.fsm.support.IPositionProvider; +import org.eclipse.etrice.ui.behavior.fsm.support.StateGraphSupport; import org.eclipse.etrice.ui.behavior.fsm.support.StateSupport; import org.eclipse.etrice.ui.behavior.fsm.support.TrPointSupport; import org.eclipse.graphiti.mm.algorithms.GraphicsAlgorithm; @@ -117,8 +117,7 @@ public class BaseDiagramPositionProvider implements IPositionProvider { }; final PictogramElement pe = IterableExtensions.<PictogramElement>findFirst(this.baseDiagram.getPictograms(sg), _function); IPositionProvider.PosAndSize _xifexpression = null; - boolean _notEquals = (!Objects.equal(pe, null)); - if (_notEquals) { + if ((pe != null)) { IPositionProvider.PosAndSize _xblockexpression_1 = null; { final GraphicsAlgorithm visibleGa = IterableExtensions.<GraphicsAlgorithm>head(pe.getGraphicsAlgorithm().getGraphicsAlgorithmChildren()); @@ -155,8 +154,7 @@ public class BaseDiagramPositionProvider implements IPositionProvider { return it.getGraphicsAlgorithm(); }; final Text text = IterableExtensions.<Text>head(Iterables.<Text>filter(ListExtensions.<ConnectionDecorator, GraphicsAlgorithm>map(((Connection)pe).getConnectionDecorators(), _function_1), Text.class)); - boolean _notEquals = (!Objects.equal(text, null)); - if (_notEquals) { + if ((text != null)) { int _x = text.getX(); int _width = graphPosAndSize.getWidth(); double _divide = (_x / ((double) _width)); @@ -165,25 +163,23 @@ public class BaseDiagramPositionProvider implements IPositionProvider { int _height = graphPosAndSize.getHeight(); double _divide_1 = (_y / ((double) _height)); double _multiply_1 = (_divide_1 * this.sy); - IPositionProvider.Pos _pos = new IPositionProvider.Pos( - ((int) _multiply), - ((int) _multiply_1)); + IPositionProvider.Pos _pos = new IPositionProvider.Pos(((int) _multiply), ((int) _multiply_1)); pointList.add(_pos); if ((pe instanceof FreeFormConnection)) { - final Function1<Point, IPositionProvider.Pos> _function_2 = (Point it) -> { - int _x_1 = text.getX(); + final Function1<Point, IPositionProvider.Pos> _function_2 = (Point pt) -> { + int _x_1 = pt.getX(); int _width_1 = graphPosAndSize.getWidth(); double _divide_2 = (_x_1 / ((double) _width_1)); double _multiply_2 = (_divide_2 * this.sx); double _plus = (_multiply_2 + this.x); - int _y_1 = text.getY(); + int _minus = (((int) _plus) - StateGraphSupport.MARGIN); + int _y_1 = pt.getY(); int _height_1 = graphPosAndSize.getHeight(); double _divide_3 = (_y_1 / ((double) _height_1)); double _multiply_3 = (_divide_3 * this.sy); double _plus_1 = (_multiply_3 + this.y); - return new IPositionProvider.Pos( - ((int) _plus), - ((int) _plus_1)); + int _minus_1 = (((int) _plus_1) - StateGraphSupport.MARGIN); + return new IPositionProvider.Pos(_minus, _minus_1); }; List<IPositionProvider.Pos> _map = ListExtensions.<Point, IPositionProvider.Pos>map(((FreeFormConnection)pe).getBendpoints(), _function_2); Iterables.<IPositionProvider.Pos>addAll(pointList, _map); @@ -274,8 +270,7 @@ public class BaseDiagramPositionProvider implements IPositionProvider { return Boolean.valueOf((_parentBo instanceof State)); }; final PictogramElement pe = IterableExtensions.<PictogramElement>findFirst(this.baseDiagram.getPictograms(subNode), _function); - boolean _notEquals = (!Objects.equal(pe, null)); - if (_notEquals) { + if ((pe != null)) { EObject _eContainer = pe.eContainer(); final PictogramElement parentPe = ((PictogramElement) _eContainer); int _x = pe.getGraphicsAlgorithm().getX(); |