2010-11-15 20:35:36 +00:00
|
|
|
/* ========================================================================
|
|
|
|
* PlantUML : a free UML diagram generator
|
|
|
|
* ========================================================================
|
|
|
|
*
|
2023-02-22 18:43:48 +00:00
|
|
|
* (C) Copyright 2009-2024, Arnaud Roques
|
2010-11-15 20:35:36 +00:00
|
|
|
*
|
2023-02-22 18:43:48 +00:00
|
|
|
* Project Info: https://plantuml.com
|
2010-11-15 20:35:36 +00:00
|
|
|
*
|
2017-03-15 19:13:31 +00:00
|
|
|
* If you like this project or if you find it useful, you can support us at:
|
|
|
|
*
|
2023-02-22 18:43:48 +00:00
|
|
|
* https://plantuml.com/patreon (only 1$ per month!)
|
|
|
|
* https://plantuml.com/paypal
|
2017-03-15 19:13:31 +00:00
|
|
|
*
|
2010-11-15 20:35:36 +00:00
|
|
|
* This file is part of PlantUML.
|
|
|
|
*
|
|
|
|
* PlantUML is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* PlantUML distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
2013-12-10 19:36:50 +00:00
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
2010-11-15 20:35:36 +00:00
|
|
|
* License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Original Author: Arnaud Roques
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2023-02-22 18:43:48 +00:00
|
|
|
package net.sourceforge.plantuml.abel;
|
2010-11-15 20:35:36 +00:00
|
|
|
|
2021-05-09 21:14:40 +00:00
|
|
|
import java.util.Objects;
|
2010-11-25 21:12:39 +00:00
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
import net.sourceforge.plantuml.OptionFlags;
|
2023-02-22 18:43:48 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.EntityPort;
|
|
|
|
import net.sourceforge.plantuml.cucadiagram.ICucaDiagram;
|
|
|
|
import net.sourceforge.plantuml.cucadiagram.LinkConstraint;
|
|
|
|
import net.sourceforge.plantuml.decoration.LinkDecor;
|
|
|
|
import net.sourceforge.plantuml.decoration.LinkType;
|
|
|
|
import net.sourceforge.plantuml.decoration.WithLinkType;
|
|
|
|
import net.sourceforge.plantuml.decoration.symbol.USymbolInterface;
|
|
|
|
import net.sourceforge.plantuml.klimt.creole.Display;
|
2023-02-02 17:59:43 +00:00
|
|
|
import net.sourceforge.plantuml.klimt.font.FontConfiguration;
|
|
|
|
import net.sourceforge.plantuml.klimt.font.StringBounder;
|
|
|
|
import net.sourceforge.plantuml.klimt.font.UFont;
|
|
|
|
import net.sourceforge.plantuml.klimt.geom.HorizontalAlignment;
|
2023-02-22 18:43:48 +00:00
|
|
|
import net.sourceforge.plantuml.klimt.geom.XDimension2D;
|
|
|
|
import net.sourceforge.plantuml.klimt.shape.TextBlock;
|
|
|
|
import net.sourceforge.plantuml.klimt.shape.UComment;
|
2018-10-21 19:44:14 +00:00
|
|
|
import net.sourceforge.plantuml.skin.VisibilityModifier;
|
2023-02-22 18:43:48 +00:00
|
|
|
import net.sourceforge.plantuml.stereo.Stereotype;
|
|
|
|
import net.sourceforge.plantuml.style.ISkinSimple;
|
2019-07-14 20:09:26 +00:00
|
|
|
import net.sourceforge.plantuml.style.StyleBuilder;
|
2016-07-04 19:06:50 +00:00
|
|
|
import net.sourceforge.plantuml.svek.Bibliotekon;
|
2023-02-02 17:59:43 +00:00
|
|
|
import net.sourceforge.plantuml.url.Url;
|
2022-12-17 11:01:10 +00:00
|
|
|
import net.sourceforge.plantuml.utils.LineLocation;
|
2010-11-15 20:35:36 +00:00
|
|
|
|
2018-06-25 19:05:58 +00:00
|
|
|
public class Link extends WithLinkType implements Hideable, Removeable {
|
2010-11-15 20:35:36 +00:00
|
|
|
|
2019-07-14 20:09:26 +00:00
|
|
|
public final StyleBuilder getStyleBuilder() {
|
|
|
|
return styleBuilder;
|
|
|
|
}
|
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
final private Entity cl1;
|
|
|
|
final private Entity cl2;
|
2016-07-04 19:06:50 +00:00
|
|
|
|
|
|
|
private String port1;
|
|
|
|
private String port2;
|
|
|
|
|
2022-08-24 16:46:33 +00:00
|
|
|
private final LinkArg linkArg;
|
2010-11-15 20:35:36 +00:00
|
|
|
|
2022-08-29 16:21:06 +00:00
|
|
|
final private String uid;
|
2010-11-15 20:35:36 +00:00
|
|
|
|
2022-09-06 08:49:43 +00:00
|
|
|
private CucaNote note;
|
2011-08-08 17:48:29 +00:00
|
|
|
|
2010-11-15 20:35:36 +00:00
|
|
|
private boolean invis = false;
|
2011-01-05 18:23:06 +00:00
|
|
|
private double weight = 1.0;
|
2010-11-15 20:35:36 +00:00
|
|
|
|
2011-04-19 16:50:40 +00:00
|
|
|
private boolean constraint = true;
|
2011-08-08 17:48:29 +00:00
|
|
|
private boolean inverted = false;
|
2020-05-17 21:15:50 +00:00
|
|
|
private LinkArrow linkArrow = LinkArrow.NONE_OR_SEVERAL;
|
2011-08-08 17:48:29 +00:00
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
private boolean opale;
|
|
|
|
private boolean horizontalSolitary;
|
2015-04-07 18:18:37 +00:00
|
|
|
private String sametail;
|
2019-07-14 20:09:26 +00:00
|
|
|
private final StyleBuilder styleBuilder;
|
2021-03-07 12:23:24 +00:00
|
|
|
private Stereotype stereotype;
|
2022-11-04 17:36:03 +00:00
|
|
|
private final IEntityFactory entityFactory;
|
2011-03-20 21:40:07 +00:00
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
private Url url;
|
|
|
|
|
2019-08-26 17:07:21 +00:00
|
|
|
public String idCommentForSvg() {
|
2022-01-27 17:08:03 +00:00
|
|
|
if (type.looksLikeRevertedForSvg())
|
2023-02-06 21:04:53 +00:00
|
|
|
return getEntity1().getName() + "-backto-" + getEntity2().getName();
|
2022-01-27 17:08:03 +00:00
|
|
|
|
|
|
|
if (type.looksLikeNoDecorAtAllSvg())
|
2023-02-06 21:04:53 +00:00
|
|
|
return getEntity1().getName() + "-" + getEntity2().getName();
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
return getEntity1().getName() + "-to-" + getEntity2().getName();
|
2019-08-26 17:07:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public UComment commentForSvg() {
|
2022-01-27 17:08:03 +00:00
|
|
|
if (type.looksLikeRevertedForSvg())
|
2023-02-22 18:43:48 +00:00
|
|
|
return new UComment("reverse link " + getEntity1().getName() + " to " + getEntity2().getName());
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
return new UComment("link " + getEntity1().getName() + " to " + getEntity2().getName());
|
2019-08-26 17:07:21 +00:00
|
|
|
}
|
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
public Link(IEntityFactory entityFactory, StyleBuilder styleBuilder, Entity cl1, Entity cl2, LinkType type,
|
2022-11-04 17:36:03 +00:00
|
|
|
LinkArg linkArg) {
|
2022-08-24 16:46:33 +00:00
|
|
|
if (linkArg.getLength() < 1)
|
2010-11-15 20:35:36 +00:00
|
|
|
throw new IllegalArgumentException();
|
2022-08-23 16:39:27 +00:00
|
|
|
|
2022-11-04 17:36:03 +00:00
|
|
|
this.entityFactory = entityFactory;
|
2019-07-14 20:09:26 +00:00
|
|
|
this.styleBuilder = styleBuilder;
|
2021-05-09 21:14:40 +00:00
|
|
|
this.cl1 = Objects.requireNonNull(cl1);
|
|
|
|
this.cl2 = Objects.requireNonNull(cl2);
|
2022-08-29 16:21:06 +00:00
|
|
|
|
2010-11-15 20:35:36 +00:00
|
|
|
this.type = type;
|
2023-02-06 21:04:53 +00:00
|
|
|
final ICucaDiagram diagram = ((Entity) cl1).getDiagram();
|
2022-09-12 20:08:34 +00:00
|
|
|
this.uid = "LNK" + diagram.getUniqueSequence();
|
2018-10-21 19:44:14 +00:00
|
|
|
|
2022-08-24 16:46:33 +00:00
|
|
|
this.linkArg = linkArg;
|
2022-09-06 08:49:43 +00:00
|
|
|
|
2022-09-12 20:08:34 +00:00
|
|
|
if (diagram.getPragma().useKermor()) {
|
2022-09-06 08:49:43 +00:00
|
|
|
if (cl1.getEntityPosition().isNormal() == false ^ cl2.getEntityPosition().isNormal() == false)
|
|
|
|
setConstraint(false);
|
|
|
|
}
|
2022-01-27 17:08:03 +00:00
|
|
|
}
|
2010-11-15 20:35:36 +00:00
|
|
|
|
|
|
|
public Link getInv() {
|
2022-11-04 17:36:03 +00:00
|
|
|
final Link result = new Link(entityFactory, styleBuilder, cl2, cl1, getType().getInversed(), linkArg.getInv());
|
2018-04-06 20:36:30 +00:00
|
|
|
result.inverted = !this.inverted;
|
2016-07-04 19:06:50 +00:00
|
|
|
result.port1 = this.port2;
|
|
|
|
result.port2 = this.port1;
|
2018-04-06 20:36:30 +00:00
|
|
|
result.url = this.url;
|
2020-02-18 21:24:31 +00:00
|
|
|
result.linkConstraint = this.linkConstraint;
|
2021-03-07 12:23:24 +00:00
|
|
|
result.stereotype = stereotype;
|
2022-08-24 16:46:33 +00:00
|
|
|
result.linkArg.setVisibilityModifier(this.linkArg.getVisibilityModifier());
|
2011-08-08 17:48:29 +00:00
|
|
|
return result;
|
2011-03-20 21:40:07 +00:00
|
|
|
}
|
|
|
|
|
2018-06-25 19:05:58 +00:00
|
|
|
@Override
|
2015-04-07 18:18:37 +00:00
|
|
|
public void goNorank() {
|
|
|
|
setConstraint(false);
|
|
|
|
}
|
|
|
|
|
2010-11-15 20:35:36 +00:00
|
|
|
public String getLabeldistance() {
|
|
|
|
// Default in dot 1.0
|
2022-08-24 16:46:33 +00:00
|
|
|
return getLinkArg().getLabeldistance();
|
2010-11-15 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getLabelangle() {
|
|
|
|
// Default in dot -25
|
2022-08-24 16:46:33 +00:00
|
|
|
return getLinkArg().getLabelangle();
|
2010-11-15 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getUid() {
|
|
|
|
return uid;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isInvis() {
|
2022-01-27 17:08:03 +00:00
|
|
|
if (type.isInvisible())
|
2013-12-10 19:36:50 +00:00
|
|
|
return true;
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2010-11-15 20:35:36 +00:00
|
|
|
return invis;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void setInvis(boolean invis) {
|
|
|
|
this.invis = invis;
|
|
|
|
}
|
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
public boolean isBetween(Entity cl1, Entity cl2) {
|
2023-03-24 18:07:32 +00:00
|
|
|
if (cl1 == this.cl1 && cl2 == this.cl2)
|
2010-11-15 20:35:36 +00:00
|
|
|
return true;
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2023-03-24 18:07:32 +00:00
|
|
|
if (cl1 == this.cl2 && cl2 == this.cl1)
|
2010-11-15 20:35:36 +00:00
|
|
|
return true;
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2010-11-15 20:35:36 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
2022-08-24 16:46:33 +00:00
|
|
|
return super.toString() + " {" + linkArg.getLength() + "} " + cl1 + "-->" + cl2;
|
2010-11-15 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
public Entity getEntity1() {
|
2022-11-04 17:36:03 +00:00
|
|
|
return cl1;
|
|
|
|
}
|
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
public Entity getEntity2() {
|
2010-11-15 20:35:36 +00:00
|
|
|
return cl2;
|
|
|
|
}
|
|
|
|
|
2016-07-04 19:06:50 +00:00
|
|
|
public EntityPort getEntityPort1(Bibliotekon bibliotekon) {
|
2023-01-31 19:27:04 +00:00
|
|
|
return getEntityPort(cl1, port1, bibliotekon);
|
2016-07-04 19:06:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public EntityPort getEntityPort2(Bibliotekon bibliotekon) {
|
2023-01-31 19:27:04 +00:00
|
|
|
return getEntityPort(cl2, port2, bibliotekon);
|
2022-09-01 17:40:58 +00:00
|
|
|
}
|
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
private EntityPort getEntityPort(Entity leaf, String port, Bibliotekon bibliotekon) {
|
2022-09-01 17:40:58 +00:00
|
|
|
if (leaf.getEntityPosition().usePortP())
|
|
|
|
return EntityPort.forPort(bibliotekon.getNodeUid(leaf));
|
|
|
|
return EntityPort.create(bibliotekon.getNodeUid(leaf), port);
|
2016-07-04 19:06:50 +00:00
|
|
|
}
|
|
|
|
|
2018-06-25 19:05:58 +00:00
|
|
|
@Override
|
2010-11-15 20:35:36 +00:00
|
|
|
public LinkType getType() {
|
2022-01-27 17:08:03 +00:00
|
|
|
if (opale)
|
2011-09-08 10:42:27 +00:00
|
|
|
return new LinkType(LinkDecor.NONE, LinkDecor.NONE);
|
2022-01-27 17:08:03 +00:00
|
|
|
|
|
|
|
if (getSametail() != null)
|
2015-04-07 18:18:37 +00:00
|
|
|
return new LinkType(LinkDecor.NONE, LinkDecor.NONE);
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
LinkType result = type;
|
|
|
|
if (OptionFlags.USE_INTERFACE_EYE1) {
|
2022-01-27 17:08:03 +00:00
|
|
|
if (isLollipopInterfaceEye(cl1))
|
2015-04-07 18:18:37 +00:00
|
|
|
type = type.withLollipopInterfaceEye1();
|
2022-01-27 17:08:03 +00:00
|
|
|
|
|
|
|
if (isLollipopInterfaceEye(cl2))
|
2015-04-07 18:18:37 +00:00
|
|
|
type = type.withLollipopInterfaceEye2();
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
private boolean isReallyGroup(Entity ent) {
|
2022-01-27 17:08:03 +00:00
|
|
|
if (ent.isGroup() == false)
|
2016-01-30 12:20:07 +00:00
|
|
|
return false;
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
final Entity group = (Entity) ent;
|
|
|
|
return group.groups().size() + group.leafs().size() > 0;
|
2016-01-30 12:20:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public LinkType getTypePatchCluster() {
|
|
|
|
LinkType result = getType();
|
2022-01-27 17:08:03 +00:00
|
|
|
if (isReallyGroup(getEntity1()))
|
2016-01-30 12:20:07 +00:00
|
|
|
result = result.withoutDecors2();
|
2022-01-27 17:08:03 +00:00
|
|
|
|
|
|
|
if (isReallyGroup(getEntity2()))
|
2016-01-30 12:20:07 +00:00
|
|
|
result = result.withoutDecors1();
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2016-01-30 12:20:07 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
private LinkType getTypeSpecialForPrinting() {
|
2022-10-18 20:57:44 +00:00
|
|
|
if (opale)
|
2015-04-07 18:18:37 +00:00
|
|
|
return new LinkType(LinkDecor.NONE, LinkDecor.NONE);
|
2022-10-18 20:57:44 +00:00
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
LinkType result = type;
|
|
|
|
if (OptionFlags.USE_INTERFACE_EYE1) {
|
2022-01-27 17:08:03 +00:00
|
|
|
if (isLollipopInterfaceEye(cl1))
|
2015-04-07 18:18:37 +00:00
|
|
|
type = type.withLollipopInterfaceEye1();
|
2022-01-27 17:08:03 +00:00
|
|
|
|
|
|
|
if (isLollipopInterfaceEye(cl2))
|
2015-04-07 18:18:37 +00:00
|
|
|
type = type.withLollipopInterfaceEye2();
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
private boolean isLollipopInterfaceEye(Entity ent) {
|
2015-04-07 18:18:37 +00:00
|
|
|
return ent.getUSymbol() instanceof USymbolInterface;
|
2010-11-15 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
public Display getLabel() {
|
2022-08-24 16:46:33 +00:00
|
|
|
return getLinkArg().getLabel();
|
2010-11-15 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getLength() {
|
2022-08-24 16:46:33 +00:00
|
|
|
return getLinkArg().getLength();
|
2010-11-15 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
2011-01-09 19:00:05 +00:00
|
|
|
public final void setLength(int length) {
|
2022-08-24 16:46:33 +00:00
|
|
|
this.getLinkArg().setLength(length);
|
2011-01-09 19:00:05 +00:00
|
|
|
}
|
|
|
|
|
2022-10-05 20:32:57 +00:00
|
|
|
public String getQuantifier1() {
|
|
|
|
return getLinkArg().getQuantifier1();
|
2010-11-15 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
2022-10-05 20:32:57 +00:00
|
|
|
public String getQuantifier2() {
|
|
|
|
return getLinkArg().getQuantifier2();
|
2010-11-15 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
2011-01-05 18:23:06 +00:00
|
|
|
public final double getWeight() {
|
2010-11-15 20:35:36 +00:00
|
|
|
return weight;
|
|
|
|
}
|
|
|
|
|
2011-01-05 18:23:06 +00:00
|
|
|
public final void setWeight(double weight) {
|
2010-11-15 20:35:36 +00:00
|
|
|
this.weight = weight;
|
|
|
|
}
|
|
|
|
|
2022-09-06 08:49:43 +00:00
|
|
|
public final CucaNote getNote() {
|
2010-11-15 20:35:36 +00:00
|
|
|
return note;
|
|
|
|
}
|
|
|
|
|
2022-09-06 08:49:43 +00:00
|
|
|
public final void addNote(CucaNote note) {
|
2010-11-15 20:35:36 +00:00
|
|
|
this.note = note;
|
2011-08-08 17:48:29 +00:00
|
|
|
}
|
|
|
|
|
2016-09-29 19:51:18 +00:00
|
|
|
public final void addNoteFrom(Link other, NoteLinkStrategy strategy) {
|
2022-09-06 08:49:43 +00:00
|
|
|
if (other.note != null)
|
|
|
|
this.note = other.note.withStrategy(strategy);
|
2016-09-29 19:51:18 +00:00
|
|
|
}
|
2010-11-15 20:35:36 +00:00
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
public boolean isAutoLinkOfAGroup() {
|
2022-01-27 17:08:03 +00:00
|
|
|
if (getEntity1().isGroup() == false)
|
2010-11-15 20:35:36 +00:00
|
|
|
return false;
|
2022-01-27 17:08:03 +00:00
|
|
|
|
|
|
|
if (getEntity2().isGroup() == false)
|
2010-11-15 20:35:36 +00:00
|
|
|
return false;
|
2022-01-27 17:08:03 +00:00
|
|
|
|
|
|
|
if (getEntity1() == getEntity2())
|
2010-11-15 20:35:36 +00:00
|
|
|
return true;
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2010-11-15 20:35:36 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
public boolean containsType(LeafType type) {
|
2022-01-27 17:08:03 +00:00
|
|
|
if (getEntity1().getLeafType() == type || getEntity2().getLeafType() == type)
|
2010-11-15 20:35:36 +00:00
|
|
|
return true;
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2010-11-15 20:35:36 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
public boolean contains(Entity entity) {
|
2023-03-22 18:25:52 +00:00
|
|
|
if (getEntity1() == entity)
|
2010-11-15 20:35:36 +00:00
|
|
|
return true;
|
2023-03-22 18:25:52 +00:00
|
|
|
if (getEntity2() == entity)
|
2022-10-18 20:57:44 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
public Entity getOther(Entity entity) {
|
2023-03-22 18:25:52 +00:00
|
|
|
if (getEntity1() == entity)
|
2013-12-10 19:36:50 +00:00
|
|
|
return getEntity2();
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2023-03-22 18:25:52 +00:00
|
|
|
if (getEntity2() == entity)
|
2013-12-10 19:36:50 +00:00
|
|
|
return getEntity1();
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
throw new IllegalArgumentException();
|
2010-11-15 20:35:36 +00:00
|
|
|
}
|
|
|
|
|
2022-08-24 16:46:33 +00:00
|
|
|
// public double getMarginDecors1(StringBounder stringBounder, UFont fontQualif, ISkinSimple spriteContainer) {
|
|
|
|
// final double q = getQualifierMargin(stringBounder, fontQualif, linkArg.getQualifier1(), spriteContainer);
|
|
|
|
// final LinkDecor decor = getType().getDecor1();
|
|
|
|
// return decor.getMargin() + q;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// public double getMarginDecors2(StringBounder stringBounder, UFont fontQualif, ISkinSimple spriteContainer) {
|
|
|
|
// final double q = getQualifierMargin(stringBounder, fontQualif, linkArg.getQualifier2(), spriteContainer);
|
|
|
|
// final LinkDecor decor = getType().getDecor2();
|
|
|
|
// return decor.getMargin() + q;
|
|
|
|
// }
|
2010-11-25 21:12:39 +00:00
|
|
|
|
2022-10-05 20:32:57 +00:00
|
|
|
private double getQuantifierMargin(StringBounder stringBounder, UFont fontQualif, String qualif,
|
2015-04-07 18:18:37 +00:00
|
|
|
ISkinSimple spriteContainer) {
|
2010-11-25 21:12:39 +00:00
|
|
|
if (qualif != null) {
|
2015-09-28 20:42:17 +00:00
|
|
|
final TextBlock b = Display.create(qualif).create(FontConfiguration.blackBlueTrue(fontQualif),
|
2015-07-11 09:32:49 +00:00
|
|
|
HorizontalAlignment.LEFT, spriteContainer);
|
2022-09-12 20:08:34 +00:00
|
|
|
final XDimension2D dim = b.calculateDimension(stringBounder);
|
2010-11-25 21:12:39 +00:00
|
|
|
return Math.max(dim.getWidth(), dim.getHeight());
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-04-19 16:50:40 +00:00
|
|
|
public final boolean isConstraint() {
|
|
|
|
return constraint;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void setConstraint(boolean constraint) {
|
|
|
|
this.constraint = constraint;
|
|
|
|
}
|
2011-09-08 10:42:27 +00:00
|
|
|
|
|
|
|
public void setOpale(boolean opale) {
|
|
|
|
this.opale = opale;
|
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
public final void setHorizontalSolitary(boolean horizontalSolitary) {
|
|
|
|
this.horizontalSolitary = horizontalSolitary;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isHorizontalSolitary() {
|
|
|
|
return horizontalSolitary;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final LinkArrow getLinkArrow() {
|
2022-01-27 17:08:03 +00:00
|
|
|
if (inverted)
|
2013-12-10 19:36:50 +00:00
|
|
|
return linkArrow.reverse();
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
return linkArrow;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void setLinkArrow(LinkArrow linkArrow) {
|
|
|
|
this.linkArrow = linkArrow;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isInverted() {
|
|
|
|
return inverted;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasEntryPoint() {
|
2022-09-06 08:49:43 +00:00
|
|
|
return (getEntity1().isGroup() == false && getEntity1().getEntityPosition() != EntityPosition.NORMAL)
|
|
|
|
|| (getEntity2().isGroup() == false && getEntity2().getEntityPosition() != EntityPosition.NORMAL);
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasTwoEntryPointsSameContainer() {
|
|
|
|
return getEntity1().isGroup() == false && getEntity2().isGroup() == false
|
2022-09-06 08:49:43 +00:00
|
|
|
&& getEntity1().getEntityPosition() != EntityPosition.NORMAL
|
|
|
|
&& getEntity2().getEntityPosition() != EntityPosition.NORMAL
|
2013-12-10 19:36:50 +00:00
|
|
|
&& getEntity1().getParentContainer() == getEntity2().getParentContainer();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Url getUrl() {
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setUrl(Url url) {
|
|
|
|
this.url = url;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isHidden() {
|
|
|
|
return hidden || cl1.isHidden() || cl2.isHidden();
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean sameConnections(Link other) {
|
2022-01-27 17:08:03 +00:00
|
|
|
if (this.cl1 == other.cl1 && this.cl2 == other.cl2)
|
2013-12-10 19:36:50 +00:00
|
|
|
return true;
|
2022-01-27 17:08:03 +00:00
|
|
|
|
|
|
|
if (this.cl1 == other.cl2 && this.cl2 == other.cl1)
|
2013-12-10 19:36:50 +00:00
|
|
|
return true;
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
return false;
|
2011-09-08 10:42:27 +00:00
|
|
|
}
|
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
public boolean doesTouch(Link other) {
|
2022-01-27 17:08:03 +00:00
|
|
|
if (this.cl1 == other.cl1)
|
2015-04-07 18:18:37 +00:00
|
|
|
return true;
|
2022-01-27 17:08:03 +00:00
|
|
|
|
|
|
|
if (this.cl1 == other.cl2)
|
2015-04-07 18:18:37 +00:00
|
|
|
return true;
|
2022-01-27 17:08:03 +00:00
|
|
|
|
|
|
|
if (this.cl2 == other.cl1)
|
2015-04-07 18:18:37 +00:00
|
|
|
return true;
|
2022-01-27 17:08:03 +00:00
|
|
|
|
|
|
|
if (this.cl2 == other.cl2)
|
2015-04-07 18:18:37 +00:00
|
|
|
return true;
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isAutolink() {
|
|
|
|
return cl1 == cl2;
|
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
public boolean isRemoved() {
|
2022-11-04 17:36:03 +00:00
|
|
|
final Stereotype stereotype = getStereotype();
|
|
|
|
if (stereotype != null && entityFactory.isRemoved(stereotype))
|
|
|
|
return true;
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
return cl1.isRemoved() || cl2.isRemoved();
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasUrl() {
|
2022-08-24 16:46:33 +00:00
|
|
|
if (Display.isNull(linkArg.getLabel()) == false && linkArg.getLabel().hasUrl())
|
2013-12-10 19:36:50 +00:00
|
|
|
return true;
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
return getUrl() != null;
|
|
|
|
}
|
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
public String getSametail() {
|
|
|
|
return sametail;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSametail(String sametail) {
|
|
|
|
this.sametail = sametail;
|
|
|
|
}
|
2013-12-10 19:36:50 +00:00
|
|
|
|
2016-07-04 19:06:50 +00:00
|
|
|
public void setPortMembers(String port1, String port2) {
|
|
|
|
this.port1 = port1;
|
|
|
|
this.port2 = port2;
|
2022-01-27 17:08:03 +00:00
|
|
|
if (port1 != null)
|
2023-05-11 19:06:04 +00:00
|
|
|
cl1.addPortShortName(port1);
|
2022-01-27 17:08:03 +00:00
|
|
|
|
|
|
|
if (port2 != null)
|
2023-05-11 19:06:04 +00:00
|
|
|
cl2.addPortShortName(port2);
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2016-07-04 19:06:50 +00:00
|
|
|
}
|
|
|
|
|
2020-02-18 21:24:31 +00:00
|
|
|
private LinkConstraint linkConstraint;
|
|
|
|
|
|
|
|
public void setLinkConstraint(LinkConstraint linkConstraint) {
|
|
|
|
this.linkConstraint = linkConstraint;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final LinkConstraint getLinkConstraint() {
|
|
|
|
return linkConstraint;
|
|
|
|
}
|
|
|
|
|
2020-08-25 17:24:17 +00:00
|
|
|
private LineLocation codeLine;
|
|
|
|
|
|
|
|
public String getCodeLine() {
|
2022-01-27 17:08:03 +00:00
|
|
|
if (codeLine == null)
|
2020-08-25 17:24:17 +00:00
|
|
|
return null;
|
2022-01-27 17:08:03 +00:00
|
|
|
|
2020-08-25 17:24:17 +00:00
|
|
|
return "" + codeLine.getPosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCodeLine(LineLocation location) {
|
|
|
|
this.codeLine = location;
|
|
|
|
}
|
|
|
|
|
2021-03-07 12:23:24 +00:00
|
|
|
public void setStereotype(Stereotype stereotype) {
|
|
|
|
this.stereotype = stereotype;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Stereotype getStereotype() {
|
|
|
|
return stereotype;
|
|
|
|
}
|
|
|
|
|
2022-08-24 16:46:33 +00:00
|
|
|
public final LinkArg getLinkArg() {
|
|
|
|
return linkArg;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final VisibilityModifier getVisibilityModifier() {
|
|
|
|
return getLinkArg().getVisibilityModifier();
|
|
|
|
}
|
|
|
|
|
2023-03-21 22:47:11 +00:00
|
|
|
public final boolean isOpale() {
|
|
|
|
return opale;
|
|
|
|
}
|
|
|
|
|
2023-07-24 13:05:33 +00:00
|
|
|
public final boolean hasKal1() {
|
|
|
|
return this.linkArg.getKal1() != null && !this.linkArg.getKal1().isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean hasKal2() {
|
|
|
|
return this.linkArg.getKal2() != null && !this.linkArg.getKal2().isEmpty();
|
|
|
|
}
|
2010-11-15 20:35:36 +00:00
|
|
|
}
|