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

Show anchorage labels on the outside of components


Signed-off-by: default avatarUlrich Schöpp <schoepp@fortiss.org>
Issue-Ref: 4184
parent c255769e
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 5ba0b5d133998eac47425696ef0a02b575418c2d GREEN
NamedLayoutedCircularAnchorageContentVisual.java e1427071046afe94a6e6e1d54fec39387d94ee36 YELLOW
NamedLayoutedCircularAnchorageDiagramVisual.java eb1e736d7715b86dbc3ca0551bb754157f71cc5f GREEN
NamedLayoutedCurveLinkVisual.java 7945b2f550d5e4804f44891294ee60cc8ffcbf1e GREEN
NamedLayoutedEllipticContentVisual.java f96a956c2f71b675eee56cfc613684397545da68 GREEN
......
......@@ -24,6 +24,7 @@ import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundl
import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IVisual;
import org.fortiss.tooling.kernel.model.INamedElement;
import javafx.geometry.Bounds;
import javafx.geometry.Rectangle2D;
import javafx.geometry.VPos;
import javafx.scene.text.Text;
......@@ -61,6 +62,30 @@ public class NamedLayoutedCircularAnchorageContentVisual<T extends ILayoutedMode
if(nameText.getParent() == null) {
layers.getVisualFeedbackLayer().add(nameText, getMVCBundle());
}
// Depending on the side, show text to left or top of anchorage.
Bounds textBounds = nameText.getBoundsInLocal();
double width = textBounds.getWidth() + bounds.getWidth();
double verticalMiddle = bounds.getHeight() / 2;
Rectangle2D attachedToBounds =
getMVCBundle().getAttachedTo().getVisual().getCurrentBounds();
// left
if(textBounds.getMaxX() >= attachedToBounds.getMinX() &&
textBounds.getMaxX() - width < attachedToBounds.getMinX() &&
textBounds.getMinX() - width >= 0) {
nameText.setX(nameText.getX() - width);
}
// top
if(textBounds.getMaxY() >= attachedToBounds.getMinY() &&
textBounds.getMaxY() - verticalMiddle < attachedToBounds.getMinY() &&
textBounds.getMinY() - verticalMiddle >= 0) {
nameText.setY(nameText.getY() - verticalMiddle);
}
// bottom
if(textBounds.getMinY() <= attachedToBounds.getMaxY() &&
textBounds.getMaxY() + bounds.getHeight() / 2 >= attachedToBounds.getMaxY()) {
nameText.setY(nameText.getY() + verticalMiddle);
}
} else if(nameText.getParent() != null) {
layers.getVisualFeedbackLayer().remove(nameText);
}
......
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