2013-12-10 19:36:50 +00:00
|
|
|
/* ========================================================================
|
|
|
|
* PlantUML : a free UML diagram generator
|
|
|
|
* ========================================================================
|
|
|
|
*
|
2023-02-22 18:43:48 +00:00
|
|
|
* (C) Copyright 2009-2024, Arnaud Roques
|
2013-12-10 19:36:50 +00:00
|
|
|
*
|
2023-02-22 18:43:48 +00:00
|
|
|
* Project Info: https://plantuml.com
|
2022-02-15 18:11:51 +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:
|
2022-02-15 18:11:51 +00:00
|
|
|
*
|
2023-02-22 18:43:48 +00:00
|
|
|
* https://plantuml.com/patreon (only 1$ per month!)
|
|
|
|
* https://plantuml.com/paypal
|
2022-02-15 18:11:51 +00:00
|
|
|
*
|
2013-12-10 19:36:50 +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
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
|
|
* 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
|
|
|
|
* Modified by : Arno Peterson
|
2022-02-15 18:11:51 +00:00
|
|
|
*
|
2013-12-10 19:36:50 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
package net.sourceforge.plantuml.svek.image;
|
|
|
|
|
2022-02-16 18:59:44 +00:00
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.EnumMap;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.Set;
|
2013-12-10 19:36:50 +00:00
|
|
|
|
2023-02-22 18:43:48 +00:00
|
|
|
import net.sourceforge.plantuml.abel.Entity;
|
|
|
|
import net.sourceforge.plantuml.abel.EntityPortion;
|
|
|
|
import net.sourceforge.plantuml.abel.Link;
|
2020-12-14 18:31:06 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.BodyFactory;
|
2015-04-07 18:18:37 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.PortionShower;
|
2023-02-22 18:43:48 +00:00
|
|
|
import net.sourceforge.plantuml.decoration.symbol.USymbol;
|
2023-03-13 20:46:30 +00:00
|
|
|
import net.sourceforge.plantuml.decoration.symbol.USymbolActorBusiness;
|
2023-02-22 18:43:48 +00:00
|
|
|
import net.sourceforge.plantuml.decoration.symbol.USymbols;
|
|
|
|
import net.sourceforge.plantuml.klimt.Fashion;
|
2023-02-02 17:59:43 +00:00
|
|
|
import net.sourceforge.plantuml.klimt.Shadowable;
|
|
|
|
import net.sourceforge.plantuml.klimt.UGroupType;
|
|
|
|
import net.sourceforge.plantuml.klimt.UStroke;
|
|
|
|
import net.sourceforge.plantuml.klimt.UTranslate;
|
|
|
|
import net.sourceforge.plantuml.klimt.color.ColorType;
|
2023-02-22 18:43:48 +00:00
|
|
|
import net.sourceforge.plantuml.klimt.color.Colors;
|
2023-02-02 17:59:43 +00:00
|
|
|
import net.sourceforge.plantuml.klimt.color.HColor;
|
2023-02-22 18:43:48 +00:00
|
|
|
import net.sourceforge.plantuml.klimt.creole.Display;
|
|
|
|
import net.sourceforge.plantuml.klimt.drawing.UGraphic;
|
|
|
|
import net.sourceforge.plantuml.klimt.drawing.UGraphicStencil;
|
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.geom.HorizontalAlignment;
|
2023-02-26 18:51:17 +00:00
|
|
|
import net.sourceforge.plantuml.klimt.geom.MagneticBorder;
|
|
|
|
import net.sourceforge.plantuml.klimt.geom.MagneticBorderNone;
|
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.TextBlockUtils;
|
|
|
|
import net.sourceforge.plantuml.klimt.shape.UComment;
|
|
|
|
import net.sourceforge.plantuml.stereo.Stereotype;
|
|
|
|
import net.sourceforge.plantuml.style.ISkinParam;
|
2020-05-07 14:12:08 +00:00
|
|
|
import net.sourceforge.plantuml.style.PName;
|
|
|
|
import net.sourceforge.plantuml.style.SName;
|
|
|
|
import net.sourceforge.plantuml.style.Style;
|
2022-03-01 18:11:51 +00:00
|
|
|
import net.sourceforge.plantuml.style.StyleSignatureBasic;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.svek.AbstractEntityImage;
|
2021-02-02 10:12:15 +00:00
|
|
|
import net.sourceforge.plantuml.svek.Bibliotekon;
|
2017-04-05 17:37:42 +00:00
|
|
|
import net.sourceforge.plantuml.svek.Margins;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.svek.ShapeType;
|
2021-03-07 12:23:24 +00:00
|
|
|
import net.sourceforge.plantuml.svek.SvekNode;
|
2023-02-02 17:59:43 +00:00
|
|
|
import net.sourceforge.plantuml.text.Guillemet;
|
|
|
|
import net.sourceforge.plantuml.url.Url;
|
2017-04-05 17:37:42 +00:00
|
|
|
import net.sourceforge.plantuml.utils.MathUtils;
|
2013-12-10 19:36:50 +00:00
|
|
|
|
2015-07-11 09:32:49 +00:00
|
|
|
public class EntityImageDescription extends AbstractEntityImage {
|
2013-12-10 19:36:50 +00:00
|
|
|
|
2015-09-28 20:42:17 +00:00
|
|
|
private final ShapeType shapeType;
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
final private Url url;
|
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
private final TextBlock asSmall;
|
2013-12-10 19:36:50 +00:00
|
|
|
|
2015-09-28 20:42:17 +00:00
|
|
|
private final TextBlock name;
|
2017-04-05 17:37:42 +00:00
|
|
|
private final TextBlock desc;
|
|
|
|
|
|
|
|
private TextBlock stereo;
|
|
|
|
|
|
|
|
private final boolean hideText;
|
2017-05-10 19:51:15 +00:00
|
|
|
private final Collection<Link> links;
|
2017-06-05 11:27:21 +00:00
|
|
|
private final boolean useRankSame;
|
2018-10-21 19:44:14 +00:00
|
|
|
private final boolean fixCircleLabelOverlapping;
|
2021-02-02 10:12:15 +00:00
|
|
|
private final Bibliotekon bibliotekon;
|
2023-02-22 18:43:48 +00:00
|
|
|
private final Fashion ctx;
|
2015-09-28 20:42:17 +00:00
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
public EntityImageDescription(Entity entity, ISkinParam skinParam2, PortionShower portionShower,
|
2021-03-07 12:23:24 +00:00
|
|
|
Collection<Link> links, SName styleName, Bibliotekon bibliotekon) {
|
2021-11-15 18:27:27 +00:00
|
|
|
super(entity, entity.getColors().mute(skinParam2));
|
2020-09-30 20:57:58 +00:00
|
|
|
this.useRankSame = getSkinParam().useRankSame();
|
2021-02-02 10:12:15 +00:00
|
|
|
this.bibliotekon = bibliotekon;
|
2020-09-30 20:57:58 +00:00
|
|
|
this.fixCircleLabelOverlapping = getSkinParam().fixCircleLabelOverlapping();
|
2018-01-28 22:08:15 +00:00
|
|
|
|
2017-05-10 19:51:15 +00:00
|
|
|
this.links = links;
|
2017-04-05 17:37:42 +00:00
|
|
|
USymbol symbol = getUSymbol(entity);
|
2022-02-17 18:27:32 +00:00
|
|
|
if (symbol == USymbols.FOLDER)
|
2018-05-06 19:59:19 +00:00
|
|
|
this.shapeType = ShapeType.FOLDER;
|
2022-02-17 18:27:32 +00:00
|
|
|
else if (symbol == USymbols.HEXAGON)
|
2021-02-02 10:12:15 +00:00
|
|
|
this.shapeType = ShapeType.HEXAGON;
|
2022-02-17 18:27:32 +00:00
|
|
|
else if (symbol == USymbols.INTERFACE)
|
2020-09-30 20:57:58 +00:00
|
|
|
this.shapeType = getSkinParam().fixCircleLabelOverlapping() ? ShapeType.RECTANGLE_WITH_CIRCLE_INSIDE
|
2018-08-26 12:09:50 +00:00
|
|
|
: ShapeType.RECTANGLE;
|
2022-02-01 20:21:45 +00:00
|
|
|
else
|
2018-05-06 19:59:19 +00:00
|
|
|
this.shapeType = ShapeType.RECTANGLE;
|
2022-02-01 20:21:45 +00:00
|
|
|
|
2022-02-17 18:27:32 +00:00
|
|
|
this.hideText = symbol == USymbols.INTERFACE;
|
2013-12-10 19:36:50 +00:00
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
this.url = entity.getUrl99();
|
2013-12-10 19:36:50 +00:00
|
|
|
|
2021-11-15 18:27:27 +00:00
|
|
|
final Colors colors = entity.getColors();
|
2022-04-10 19:24:55 +00:00
|
|
|
|
2023-03-13 20:46:30 +00:00
|
|
|
final StyleSignatureBasic tmp;
|
|
|
|
if (symbol instanceof USymbolActorBusiness)
|
|
|
|
tmp = StyleSignatureBasic.of(SName.root, SName.element, styleName, SName.actor, SName.business,
|
|
|
|
SName.title);
|
|
|
|
else
|
|
|
|
tmp = StyleSignatureBasic.of(SName.root, SName.element, styleName, symbol.getSName(), SName.title);
|
|
|
|
|
2022-04-10 19:24:55 +00:00
|
|
|
final Stereotype stereotype = entity.getStereotype();
|
2022-09-15 17:24:26 +00:00
|
|
|
final Style styleTitle = tmp.withTOBECHANGED(stereotype).getMergedStyle(getSkinParam().getCurrentStyleBuilder())
|
2022-04-10 19:24:55 +00:00
|
|
|
.eventuallyOverride(colors);
|
|
|
|
|
|
|
|
final Style styleStereo = tmp.forStereotypeItself(stereotype)
|
|
|
|
.getMergedStyle(getSkinParam().getCurrentStyleBuilder());
|
2022-10-18 20:57:44 +00:00
|
|
|
|
2023-06-21 18:50:30 +00:00
|
|
|
final StyleSignatureBasic tmp2 = StyleSignatureBasic.of(SName.root, SName.element, styleName,
|
|
|
|
symbol.getSName());
|
|
|
|
final Style style = tmp2.withTOBECHANGED(stereotype).getMergedStyle(getSkinParam().getCurrentStyleBuilder())
|
2022-10-18 20:57:44 +00:00
|
|
|
.eventuallyOverride(colors);
|
|
|
|
|
2022-09-18 17:08:06 +00:00
|
|
|
final HColor forecolor = styleTitle.value(PName.LineColor).asColor(getSkinParam().getIHtmlColorSet());
|
2022-05-21 09:41:00 +00:00
|
|
|
|
|
|
|
HColor backcolor = colors.getColor(ColorType.BACK);
|
2022-04-10 19:24:55 +00:00
|
|
|
if (backcolor == null)
|
2022-09-18 17:08:06 +00:00
|
|
|
backcolor = styleTitle.value(PName.BackGroundColor).asColor(getSkinParam().getIHtmlColorSet());
|
2022-04-10 19:24:55 +00:00
|
|
|
|
2022-09-15 17:24:26 +00:00
|
|
|
final double roundCorner = styleTitle.value(PName.RoundCorner).asDouble();
|
|
|
|
final double diagonalCorner = styleTitle.value(PName.DiagonalCorner).asDouble();
|
|
|
|
final double deltaShadow = styleTitle.value(PName.Shadowing).asDouble();
|
|
|
|
final UStroke stroke = styleTitle.getStroke(colors);
|
2022-09-18 17:08:06 +00:00
|
|
|
final FontConfiguration fcTitle = styleTitle.getFontConfiguration(getSkinParam().getIHtmlColorSet());
|
2023-06-21 18:50:30 +00:00
|
|
|
final FontConfiguration fc = style.getFontConfiguration(getSkinParam().getIHtmlColorSet());
|
2022-09-18 17:08:06 +00:00
|
|
|
final FontConfiguration fcStereo = styleStereo.getFontConfiguration(getSkinParam().getIHtmlColorSet());
|
2022-09-15 17:24:26 +00:00
|
|
|
final HorizontalAlignment defaultAlign = styleTitle.getHorizontalAlignment();
|
2017-04-05 17:37:42 +00:00
|
|
|
|
2016-12-21 22:10:29 +00:00
|
|
|
assert getStereo() == stereotype;
|
2020-10-12 20:56:58 +00:00
|
|
|
|
2023-02-22 18:43:48 +00:00
|
|
|
ctx = new Fashion(backcolor, forecolor).withStroke(stroke).withShadow(deltaShadow).withCorner(roundCorner,
|
2021-02-02 10:12:15 +00:00
|
|
|
diagonalCorner);
|
2015-04-07 18:18:37 +00:00
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
final Display codeDisplay = Display.getWithNewlines(entity.getName());
|
2022-11-04 17:36:03 +00:00
|
|
|
if ((entity.getDisplay().equalsLike(codeDisplay) && symbol.getSName() == SName.package_)
|
2022-07-21 17:01:57 +00:00
|
|
|
|| entity.getDisplay().isWhite())
|
2022-10-18 20:57:44 +00:00
|
|
|
desc = TextBlockUtils.empty(style.value(PName.MinimumWidth).asDouble(), 0);
|
2023-06-21 18:50:30 +00:00
|
|
|
else if (entity.getDisplay().equalsLike(codeDisplay))
|
2023-02-22 18:43:48 +00:00
|
|
|
desc = BodyFactory.create3(entity.getDisplay(), getSkinParam(), defaultAlign, fcTitle, style.wrapWidth(),
|
|
|
|
styleTitle);
|
2023-06-21 18:50:30 +00:00
|
|
|
else
|
|
|
|
desc = BodyFactory.create3(entity.getDisplay(), getSkinParam(), defaultAlign, fc, style.wrapWidth(), style);
|
2020-09-30 20:57:58 +00:00
|
|
|
|
2017-04-05 17:37:42 +00:00
|
|
|
stereo = TextBlockUtils.empty(0, 0);
|
2015-04-07 18:18:37 +00:00
|
|
|
|
2022-02-01 20:21:45 +00:00
|
|
|
if (stereotype != null && stereotype.getSprite(getSkinParam()) != null)
|
2019-03-01 22:16:29 +00:00
|
|
|
stereo = stereotype.getSprite(getSkinParam());
|
2022-02-01 20:21:45 +00:00
|
|
|
else if (stereotype != null && stereotype.getLabel(Guillemet.DOUBLE_COMPARATOR) != null
|
|
|
|
&& portionShower.showPortion(EntityPortion.STEREOTYPE, entity))
|
2020-12-01 21:39:27 +00:00
|
|
|
stereo = Display.getWithNewlines(stereotype.getLabel(getSkinParam().guillemet())).create(fcStereo,
|
2015-09-28 20:42:17 +00:00
|
|
|
HorizontalAlignment.CENTER, getSkinParam());
|
2013-12-10 19:36:50 +00:00
|
|
|
|
2021-03-07 12:23:24 +00:00
|
|
|
name = BodyFactory.create2(getSkinParam().getDefaultTextAlignment(HorizontalAlignment.CENTER), codeDisplay,
|
2022-09-15 17:24:26 +00:00
|
|
|
getSkinParam(), stereotype, entity, styleTitle);
|
2015-07-11 09:32:49 +00:00
|
|
|
|
2022-02-01 20:21:45 +00:00
|
|
|
if (hideText)
|
2020-05-07 14:12:08 +00:00
|
|
|
asSmall = symbol.asSmall(TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0), TextBlockUtils.empty(0, 0),
|
2021-03-07 12:23:24 +00:00
|
|
|
ctx, getSkinParam().getStereotypeAlignment());
|
2022-02-01 20:21:45 +00:00
|
|
|
else
|
2021-03-07 12:23:24 +00:00
|
|
|
asSmall = symbol.asSmall(name, desc, stereo, ctx, getSkinParam().getStereotypeAlignment());
|
2022-02-01 20:21:45 +00:00
|
|
|
|
2017-04-05 17:37:42 +00:00
|
|
|
}
|
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
private USymbol getUSymbol(Entity entity) {
|
2020-06-21 20:31:45 +00:00
|
|
|
final USymbol result = entity.getUSymbol() == null ? getSkinParam().componentStyle().toUSymbol()
|
2020-05-07 14:12:08 +00:00
|
|
|
: entity.getUSymbol();
|
2021-05-14 08:42:57 +00:00
|
|
|
return Objects.requireNonNull(result);
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
2022-09-12 20:08:34 +00:00
|
|
|
public XDimension2D getNameDimension(StringBounder stringBounder) {
|
2022-02-01 20:21:45 +00:00
|
|
|
if (hideText)
|
2022-09-12 20:08:34 +00:00
|
|
|
return new XDimension2D(0, 0);
|
2022-02-01 20:21:45 +00:00
|
|
|
|
2015-09-28 20:42:17 +00:00
|
|
|
return name.calculateDimension(stringBounder);
|
|
|
|
}
|
|
|
|
|
2022-09-12 20:08:34 +00:00
|
|
|
public XDimension2D calculateDimension(StringBounder stringBounder) {
|
2015-04-07 18:18:37 +00:00
|
|
|
return asSmall.calculateDimension(stringBounder);
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
2017-04-05 17:37:42 +00:00
|
|
|
@Override
|
|
|
|
public Margins getShield(StringBounder stringBounder) {
|
2022-02-01 20:21:45 +00:00
|
|
|
if (hideText == false)
|
2017-12-11 21:02:10 +00:00
|
|
|
return Margins.NONE;
|
2022-02-01 20:21:45 +00:00
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
if (isThereADoubleLink((Entity) getEntity(), links))
|
2018-05-01 17:26:04 +00:00
|
|
|
return Margins.NONE;
|
2022-02-01 20:21:45 +00:00
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
if (fixCircleLabelOverlapping == false && hasSomeHorizontalLinkVisible((Entity) getEntity(), links))
|
2017-12-11 21:02:10 +00:00
|
|
|
return Margins.NONE;
|
2022-02-01 20:21:45 +00:00
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
if (hasSomeHorizontalLinkDoubleDecorated((Entity) getEntity(), links))
|
2017-12-11 21:02:10 +00:00
|
|
|
return Margins.NONE;
|
2022-02-01 20:21:45 +00:00
|
|
|
|
2022-09-12 20:08:34 +00:00
|
|
|
final XDimension2D dimStereo = stereo.calculateDimension(stringBounder);
|
|
|
|
final XDimension2D dimDesc = desc.calculateDimension(stringBounder);
|
|
|
|
final XDimension2D dimSmall = asSmall.calculateDimension(stringBounder);
|
2017-12-11 21:02:10 +00:00
|
|
|
final double x = Math.max(dimStereo.getWidth(), dimDesc.getWidth());
|
|
|
|
double suppX = x - dimSmall.getWidth();
|
2022-02-01 20:21:45 +00:00
|
|
|
if (suppX < 1)
|
2017-12-11 21:02:10 +00:00
|
|
|
suppX = 1;
|
2022-02-01 20:21:45 +00:00
|
|
|
|
2017-12-11 21:02:10 +00:00
|
|
|
final double y = MathUtils.max(1, dimDesc.getHeight(), dimStereo.getHeight());
|
|
|
|
return new Margins(suppX / 2, suppX / 2, y, y);
|
2017-04-05 17:37:42 +00:00
|
|
|
}
|
2017-06-05 11:27:21 +00:00
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
private boolean hasSomeHorizontalLinkVisible(Entity leaf, Collection<Link> links) {
|
2022-02-01 20:21:45 +00:00
|
|
|
for (Link link : links)
|
|
|
|
if (link.getLength() == 1 && link.contains(leaf) && link.isInvis() == false)
|
2017-05-10 19:51:15 +00:00
|
|
|
return true;
|
2022-02-01 20:21:45 +00:00
|
|
|
|
2017-05-10 19:51:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
private boolean isThereADoubleLink(Entity leaf, Collection<Link> links) {
|
|
|
|
final Set<Entity> others = new HashSet<>();
|
2018-05-01 17:26:04 +00:00
|
|
|
for (Link link : links) {
|
|
|
|
if (link.contains(leaf)) {
|
2023-02-06 21:04:53 +00:00
|
|
|
final Entity other = link.getOther(leaf);
|
2018-05-01 17:26:04 +00:00
|
|
|
final boolean changed = others.add(other);
|
2022-02-01 20:21:45 +00:00
|
|
|
if (changed == false)
|
2018-05-01 17:26:04 +00:00
|
|
|
return true;
|
2022-02-01 20:21:45 +00:00
|
|
|
|
2018-05-01 17:26:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-02-06 21:04:53 +00:00
|
|
|
private boolean hasSomeHorizontalLinkDoubleDecorated(Entity leaf, Collection<Link> links) {
|
2022-02-01 20:21:45 +00:00
|
|
|
for (Link link : links)
|
|
|
|
if (link.getLength() == 1 && link.contains(leaf) && link.getType().isDoubleDecorated())
|
2017-12-11 21:02:10 +00:00
|
|
|
return true;
|
2022-02-01 20:21:45 +00:00
|
|
|
|
2017-12-11 21:02:10 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
final public void drawU(UGraphic ug) {
|
2023-02-06 21:04:53 +00:00
|
|
|
ug.draw(new UComment("entity " + getEntity().getName()));
|
2022-02-16 18:59:44 +00:00
|
|
|
final Map<UGroupType, String> typeIDent = new EnumMap<>(UGroupType.class);
|
2023-02-06 21:04:53 +00:00
|
|
|
typeIDent.put(UGroupType.CLASS, "elem " + getEntity().getName() + " selected");
|
|
|
|
typeIDent.put(UGroupType.ID, "elem_" + getEntity().getName());
|
2022-02-15 18:11:51 +00:00
|
|
|
ug.startGroup(typeIDent);
|
2021-02-28 13:44:02 +00:00
|
|
|
|
2022-02-01 20:21:45 +00:00
|
|
|
if (url != null)
|
2013-12-10 19:36:50 +00:00
|
|
|
ug.startUrl(url);
|
2022-02-01 20:21:45 +00:00
|
|
|
|
|
|
|
if (shapeType == ShapeType.HEXAGON)
|
2021-02-02 10:12:15 +00:00
|
|
|
drawHexagon(ctx.apply(ug));
|
2022-02-01 20:21:45 +00:00
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
asSmall.drawU(ug);
|
2021-02-02 10:12:15 +00:00
|
|
|
|
2017-04-05 17:37:42 +00:00
|
|
|
if (hideText) {
|
|
|
|
final double space = 8;
|
2022-09-12 20:08:34 +00:00
|
|
|
final XDimension2D dimSmall = asSmall.calculateDimension(ug.getStringBounder());
|
|
|
|
final XDimension2D dimDesc = desc.calculateDimension(ug.getStringBounder());
|
2018-12-22 11:11:40 +00:00
|
|
|
final double posx1 = (dimSmall.getWidth() - dimDesc.getWidth()) / 2;
|
2020-12-01 21:39:27 +00:00
|
|
|
|
2020-10-12 20:56:58 +00:00
|
|
|
UGraphic ugDesc = ug.apply(new UTranslate(posx1, space + dimSmall.getHeight()));
|
|
|
|
ugDesc = UGraphicStencil.create(ugDesc, dimDesc);
|
|
|
|
desc.drawU(ugDesc);
|
2020-12-01 21:39:27 +00:00
|
|
|
|
2022-09-12 20:08:34 +00:00
|
|
|
final XDimension2D dimStereo = stereo.calculateDimension(ug.getStringBounder());
|
2018-12-22 11:11:40 +00:00
|
|
|
final double posx2 = (dimSmall.getWidth() - dimStereo.getWidth()) / 2;
|
|
|
|
stereo.drawU(ug.apply(new UTranslate(posx2, -space - dimStereo.getHeight())));
|
2017-04-05 17:37:42 +00:00
|
|
|
}
|
2015-04-07 18:18:37 +00:00
|
|
|
|
2022-02-01 20:21:45 +00:00
|
|
|
if (url != null)
|
2020-05-17 21:15:50 +00:00
|
|
|
ug.closeUrl();
|
2021-02-28 13:44:02 +00:00
|
|
|
|
|
|
|
ug.closeGroup();
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
2021-02-02 10:12:15 +00:00
|
|
|
private void drawHexagon(UGraphic ug) {
|
2022-02-01 20:21:45 +00:00
|
|
|
if (bibliotekon == null)
|
2021-02-02 10:12:15 +00:00
|
|
|
throw new IllegalStateException();
|
2022-02-01 20:21:45 +00:00
|
|
|
|
2021-02-02 10:12:15 +00:00
|
|
|
final SvekNode node = bibliotekon.getNode(getEntity());
|
|
|
|
final Shadowable hexagon = node.getPolygon();
|
2021-11-01 14:47:30 +00:00
|
|
|
if (hexagon != null) {
|
|
|
|
hexagon.setDeltaShadow(ctx.getDeltaShadow());
|
|
|
|
ug.draw(hexagon);
|
|
|
|
}
|
2021-02-02 10:12:15 +00:00
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
public ShapeType getShapeType() {
|
2015-09-28 20:42:17 +00:00
|
|
|
return shapeType;
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
2018-12-22 11:11:40 +00:00
|
|
|
@Override
|
|
|
|
public double getOverscanX(StringBounder stringBounder) {
|
|
|
|
if (hideText) {
|
2022-09-12 20:08:34 +00:00
|
|
|
final XDimension2D dimSmall = asSmall.calculateDimension(stringBounder);
|
|
|
|
final XDimension2D dimDesc = desc.calculateDimension(stringBounder);
|
|
|
|
final XDimension2D dimStereo = stereo.calculateDimension(stringBounder);
|
2018-12-22 11:11:40 +00:00
|
|
|
final double posx1 = (dimSmall.getWidth() - dimDesc.getWidth()) / 2;
|
|
|
|
final double posx2 = (dimSmall.getWidth() - dimStereo.getWidth()) / 2;
|
|
|
|
return MathUtils.max(-posx1, -posx2, 0);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2023-02-26 18:51:17 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public MagneticBorder getMagneticBorder() {
|
|
|
|
if (shapeType == ShapeType.FOLDER)
|
|
|
|
return asSmall.getMagneticBorder();
|
|
|
|
// return new MagneticBorder() {
|
|
|
|
//
|
|
|
|
// @Override
|
|
|
|
// public UTranslate getForceAt(StringBounder stringBounder, XPoint2D pt) {
|
|
|
|
// if ((pt.getX() >= 0 && pt.getX() <= 0 + calculateDimension(stringBounder).getWidth()
|
|
|
|
// && pt.getY() <= 0)) {
|
|
|
|
// final XDimension2D dimName = getNameDimension(stringBounder);
|
|
|
|
// if (pt.getX() < 0 + dimName.getWidth())
|
2023-03-04 09:34:43 +00:00
|
|
|
// return UTranslate.none();
|
2023-02-26 18:51:17 +00:00
|
|
|
//
|
|
|
|
// return new UTranslate(0, dimName.getHeight() + 4);
|
|
|
|
// }
|
2023-03-04 09:34:43 +00:00
|
|
|
// return UTranslate.none();
|
2023-02-26 18:51:17 +00:00
|
|
|
// }
|
|
|
|
// };
|
|
|
|
return new MagneticBorderNone();
|
|
|
|
}
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|