Skip to content
Snippets Groups Projects
Commit 37506f6a authored by Ulrich Schöpp's avatar Ulrich Schöpp Committed by Ulrich Schöpp
Browse files

Improve text position when port has connection


Signed-off-by: default avatarUlrich Schöpp <schoepp@fortiss.org>
Issue-Ref: 4184
parent 79264dec
No related branches found
No related tags found
1 merge request!166Polish diagram appearance
......@@ -7,7 +7,7 @@ LayoutedLineLinkVisual.java 5fc26086e2f63afee403379ba8f09f5113d4c025 GREEN
LayoutedRectangularAnchorageContentVisualBase.java 9d5ab8fbad2900a26ec5ea620f9f1a2a1656da77 GREEN
LayoutedRectangularAnchorageDiagramVisualBase.java b9aa51cce71d8f6c4e400f6019b3cab0a1ed6df6 GREEN
LayoutedRectangularContentVisualBase.java 61698ffd771ee2ad798025df8195d1bc09c2c765 GREEN
NamedLayoutedCircularAnchorageContentVisual.java b9fd5f93af193d2a1e2ea9c6d0b54d219a5224c4 YELLOW
NamedLayoutedCircularAnchorageContentVisual.java 070b45fdae674995a3063f93bcc572facd934df7 YELLOW
NamedLayoutedCircularAnchorageDiagramVisual.java eb1e736d7715b86dbc3ca0551bb754157f71cc5f GREEN
NamedLayoutedCurveLinkVisual.java 7945b2f550d5e4804f44891294ee60cc8ffcbf1e GREEN
NamedLayoutedEllipticContentVisual.java f96a956c2f71b675eee56cfc613684397545da68 GREEN
......
......@@ -17,7 +17,10 @@ package org.fortiss.tooling.base.ui.editor.fx.visual;
import static org.fortiss.tooling.base.ui.utils.LWFXEditorUtils.stickyConnectorHasVisibleConnections;
import org.fortiss.tooling.base.model.element.IConnection;
import org.fortiss.tooling.base.model.element.IConnector;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.base.model.element.IHierarchicElementContainer;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramLayers;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
......@@ -25,6 +28,8 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IVisual;
import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.widgets.AlignedText;
import org.fortiss.tooling.kernel.model.INamedElement;
import com.google.common.base.Predicate;
import javafx.geometry.Pos;
import javafx.geometry.Rectangle2D;
......@@ -60,9 +65,15 @@ public class NamedLayoutedCircularAnchorageContentVisual<T extends ILayoutedMode
if(bounds.getMaxX() >= attachedToBounds.getMinX() &&
bounds.getMinX() < attachedToBounds.getMinX()) {
// left
nameText.setX(bounds.getMinX());
nameText.setY(bounds.getMinY() + bounds.getHeight() / 2);
nameText.setAlignment(Pos.CENTER_RIGHT);
if(!hasConnection()) {
nameText.setX(bounds.getMinX());
nameText.setY(bounds.getMinY() + bounds.getHeight() / 2);
nameText.setAlignment(Pos.CENTER_RIGHT);
} else {
nameText.setX(bounds.getMinX() + bounds.getWidth() / 4);
nameText.setY(bounds.getMinY() + bounds.getHeight() / 4);
nameText.setAlignment(Pos.BOTTOM_RIGHT);
}
} else if(bounds.getMaxY() >= attachedToBounds.getMinY() &&
bounds.getMinY() < attachedToBounds.getMinY()) {
// top
......@@ -77,9 +88,15 @@ public class NamedLayoutedCircularAnchorageContentVisual<T extends ILayoutedMode
nameText.setAlignment(Pos.TOP_CENTER);
} else {
// right
nameText.setX(bounds.getMaxX());
nameText.setY(bounds.getMinY() + bounds.getHeight() / 2);
nameText.setAlignment(Pos.CENTER_LEFT);
if(!hasConnection()) {
nameText.setX(bounds.getMaxX());
nameText.setY(bounds.getMinY() + bounds.getHeight() / 2);
nameText.setAlignment(Pos.CENTER_LEFT);
} else {
nameText.setX(bounds.getMaxX() - bounds.getWidth() / 4);
nameText.setY(bounds.getMinY() + bounds.getHeight() / 4);
nameText.setAlignment(Pos.BOTTOM_LEFT);
}
}
if(nameText.getParent() == null) {
......@@ -90,6 +107,16 @@ public class NamedLayoutedCircularAnchorageContentVisual<T extends ILayoutedMode
}
}
/** Does the port have a connection at this level? */
private boolean hasConnection() {
T port = getModelElement();
IHierarchicElement element = port.getOwner();
IHierarchicElementContainer container = element.getContainer();
Predicate<IConnection> atSameLevel = connection -> container.equals(connection.getOwner());
return port.getIncoming().stream().anyMatch(atSameLevel) ||
port.getOutgoing().stream().anyMatch(atSameLevel);
}
/** {@inheritDoc} */
@Override
public void removeAllVisuals(DiagramLayers layers) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment