-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1071] Support the border node label display
The auto layout uses the CoreOptions.PORT_LABELS_PLACEMENT with the value PortLabelPlacement.outside(). It means that the label is positioned on a corner of the border node without entering the parent node. The incremental layout uses, for the border nodes label, the same policy. It is applied when the border node is moved on its container and when it is newly created. Bug: #1071 Signed-off-by: Laurent Fasani <[email protected]>
- Loading branch information
1 parent
c7ac914
commit 9930786
Showing
9 changed files
with
210 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ain/java/org/eclipse/sirius/components/diagrams/layout/incremental/BorderNodesOnSide.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.diagrams.layout.incremental; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import org.eclipse.sirius.components.diagrams.layout.incremental.data.NodeLayoutData; | ||
import org.eclipse.sirius.components.diagrams.layout.incremental.utils.RectangleSide; | ||
|
||
/** | ||
* Class representing border node on a parent side. | ||
* | ||
* @author lfasani | ||
*/ | ||
public class BorderNodesOnSide { | ||
|
||
private final List<NodeLayoutData> borderNodes; | ||
|
||
private final RectangleSide side; | ||
|
||
BorderNodesOnSide(RectangleSide side, List<NodeLayoutData> borderNodes) { | ||
this.side = Objects.requireNonNull(side); | ||
this.borderNodes = Objects.requireNonNull(borderNodes); | ||
} | ||
|
||
public List<NodeLayoutData> getBorderNodes() { | ||
return this.borderNodes; | ||
} | ||
|
||
public RectangleSide getSide() { | ||
return this.side; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...rius/components/diagrams/layout/incremental/provider/BorderNodeLabelPositionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.sirius.components.diagrams.layout.incremental.provider; | ||
|
||
import java.util.Optional; | ||
|
||
import org.eclipse.sirius.components.diagrams.Position; | ||
import org.eclipse.sirius.components.diagrams.events.IDiagramEvent; | ||
import org.eclipse.sirius.components.diagrams.events.MoveEvent; | ||
import org.eclipse.sirius.components.diagrams.layout.incremental.data.LabelLayoutData; | ||
import org.eclipse.sirius.components.diagrams.layout.incremental.data.NodeLayoutData; | ||
import org.eclipse.sirius.components.diagrams.layout.incremental.utils.RectangleSide; | ||
|
||
/** | ||
* Provides the position logic to apply to a BorderNode Label. | ||
* | ||
* @author lfasani | ||
*/ | ||
public class BorderNodeLabelPositionProvider { | ||
|
||
public void updateLabelPosition(Optional<IDiagramEvent> optionalDiagramElementEvent, RectangleSide side, NodeLayoutData borderNodeLayoutData) { | ||
LabelLayoutData label = borderNodeLayoutData.getLabel(); | ||
if (label != null) { | ||
// @formatter:off | ||
Boolean isBorderNodeMoved = optionalDiagramElementEvent | ||
.filter(MoveEvent.class::isInstance) | ||
.map(MoveEvent.class::cast) | ||
.map(MoveEvent::getNodeId) | ||
.filter(borderNodeLayoutData.getId()::equals) | ||
.isPresent(); | ||
// @formatter:on | ||
|
||
if (borderNodeLayoutData.getLabel().getPosition().getX() == -1 || Boolean.TRUE.equals(isBorderNodeMoved)) { | ||
if (RectangleSide.NORTH.equals(side)) { | ||
label.setPosition(Position.at(-label.getTextBounds().getSize().getWidth(), -label.getTextBounds().getSize().getHeight())); | ||
} else if (RectangleSide.EAST.equals(side)) { | ||
label.setPosition(Position.at(borderNodeLayoutData.getSize().getWidth(), borderNodeLayoutData.getSize().getHeight())); | ||
} else { | ||
label.setPosition(Position.at(-label.getTextBounds().getSize().getWidth(), borderNodeLayoutData.getSize().getHeight())); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.