/* ======================================================================== * PlantUML : a free UML diagram generator * ======================================================================== * * (C) Copyright 2009-2023, Arnaud Roques * * Project Info: http://plantuml.com * * If you like this project or if you find it useful, you can support us at: * * http://plantuml.com/patreon (only 1$ per month!) * http://plantuml.com/paypal * * 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 * * */ package net.sourceforge.plantuml.svek; import java.awt.geom.Point2D; import java.util.List; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Hideable; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.awt.geom.Dimension2D; import net.sourceforge.plantuml.cucadiagram.EntityPosition; import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.entity.EntityImpl; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.posimo.Positionable; import net.sourceforge.plantuml.svek.image.AbstractEntityImageBorder; import net.sourceforge.plantuml.svek.image.EntityImageDescription; import net.sourceforge.plantuml.svek.image.EntityImageLollipopInterface; import net.sourceforge.plantuml.ugraphic.Shadowable; import net.sourceforge.plantuml.ugraphic.UPolygon; public class SvekNode implements Positionable, IShapePseudo, Hideable { private final ShapeType type; private final double width; private final double height; private final String uid; private final int color; private double minX; private double minY; private final Margins shield; private final EntityPosition entityPosition; private final IEntityImage image; public EntityPosition getEntityPosition() { return entityPosition; } private Cluster cluster; private final boolean top; public final Cluster getCluster() { return cluster; } public final void setCluster(Cluster cluster) { this.cluster = cluster; } @Override public String toString() { return super.toString() + " " + image + " " + type; } private final ILeaf leaf; private final IGroup group; SvekNode(ILeaf ent, IEntityImage image, ColorSequence colorSequence, StringBounder stringBounder) { final Dimension2D dim = image.calculateDimension(stringBounder); this.entityPosition = ent.getEntityPosition(); this.image = image; this.top = ent.isTop(); this.type = image.getShapeType(); this.width = dim.getWidth(); this.height = dim.getHeight(); this.color = colorSequence.getValue(); this.uid = String.format("sh%04d", color); this.shield = image.getShield(stringBounder); if (shield.isZero() == false && type != ShapeType.RECTANGLE && type != ShapeType.RECTANGLE_HTML_FOR_PORTS && type != ShapeType.RECTANGLE_WITH_CIRCLE_INSIDE) { throw new IllegalArgumentException(); } if (((EntityImpl) ent).getOriginalGroup() == null) { this.group = null; this.leaf = ent; } else { this.group = ((EntityImpl) ent).getOriginalGroup(); this.leaf = null; } } public final ShapeType getType() { return type; } public final double getWidth() { return width; } public final double getHeight() { return height; } public void appendShape(StringBuilder sb, StringBounder stringBounder) { if (type == ShapeType.RECTANGLE_HTML_FOR_PORTS) { appendLabelHtmlSpecialForLink(sb, stringBounder); return; } if (type == ShapeType.RECTANGLE_WITH_CIRCLE_INSIDE) { appendHtml(sb); return; } if (type == ShapeType.RECTANGLE && shield.isZero() == false) { appendHtml(sb); return; } sb.append(uid); sb.append(" ["); appendShapeInternal(sb); sb.append(","); sb.append("label=\"\""); sb.append(","); sb.append("width=" + SvekUtils.pixelToInches(getWidth())); sb.append(","); sb.append("height=" + SvekUtils.pixelToInches(getHeight())); sb.append(","); sb.append("color=\"" + StringUtils.sharp000000(color) + "\""); sb.append("];"); SvekUtils.println(sb); } private void appendHtml(StringBuilder sb) { sb.append(uid); sb.append(" ["); sb.append("shape=plaintext,"); sb.append("label=<"); appendLabelHtml(sb); sb.append(">"); sb.append("];"); SvekUtils.println(sb); } private void appendLabelHtml(StringBuilder sb) { // Log.println("shield=" + shield); sb.append("
"); sb.append(" | "); appendTd(sb, shield.getX2(), 1); sb.append("