/** * Layouts all combined fragments of this view. The width is determined by the position of the * covered lifelines. */ private void layoutCombinedFragments() { for (Entry<CombinedFragment, CombinedFragmentView> entry : combinedFragments.entrySet()) { CombinedFragmentView combinedFragmentView = entry.getValue(); float minX = Float.MAX_VALUE; float maxX = -1; for (Lifeline lifeline : entry.getKey().getCovered()) { LifelineView lifelineView = lifelines.get(lifeline); Vector3D position = lifelineView.getPosition(TransformSpace.GLOBAL); minX = Math.min(minX, position.getX()); maxX = Math.max(maxX, position.getX() + lifelineView.getWidth() + LIFEINE_SPACING); /** * Take into consideration the size of other fragments as well, since they could be quite * wide. */ for (InteractionFragment fragment : lifeline.getCoveredBy()) { /** * Check whether the fragment is part of this combined fragment in its containment * hierarchy. */ if (EcoreUtil.isAncestor(entry.getKey(), fragment)) { RamRectangleComponent fragmentView = fragments.get(fragment); if (fragmentView != null) { Vector3D fragmentPosition = fragmentView.getPosition(TransformSpace.GLOBAL); maxX = Math.max( maxX, fragmentPosition.getX() + fragmentView.getWidth() + LIFEINE_SPACING); } } } } Vector3D position = combinedFragmentView.getPosition(TransformSpace.GLOBAL); position.setX(minX); combinedFragmentView.setPositionGlobal(position); combinedFragmentView.setMinimumWidth(maxX - minX); } }