2011-08-08 17:48:29 +00:00
|
|
|
/* ========================================================================
|
|
|
|
* PlantUML : a free UML diagram generator
|
|
|
|
* ========================================================================
|
|
|
|
*
|
2016-01-09 12:15:40 +00:00
|
|
|
* (C) Copyright 2009-2017, Arnaud Roques
|
2011-08-08 17:48:29 +00:00
|
|
|
*
|
2016-03-06 16:47:34 +00:00
|
|
|
* Project Info: http://plantuml.com
|
2011-08-08 17:48:29 +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:
|
|
|
|
*
|
|
|
|
* http://plantuml.com/patreon (only 1$ per month!)
|
|
|
|
* http://plantuml.com/paypal
|
|
|
|
*
|
2011-08-08 17:48:29 +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
|
2011-08-08 17:48:29 +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
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2013-12-10 19:36:50 +00:00
|
|
|
package net.sourceforge.plantuml.svek.image;
|
2011-08-08 17:48:29 +00:00
|
|
|
|
|
|
|
import java.awt.geom.Dimension2D;
|
|
|
|
|
2018-07-27 21:56:46 +00:00
|
|
|
import net.sourceforge.plantuml.AlignmentParam;
|
2011-08-08 17:48:29 +00:00
|
|
|
import net.sourceforge.plantuml.ColorParam;
|
|
|
|
import net.sourceforge.plantuml.Dimension2DDouble;
|
|
|
|
import net.sourceforge.plantuml.FontParam;
|
|
|
|
import net.sourceforge.plantuml.ISkinParam;
|
2015-04-07 18:18:37 +00:00
|
|
|
import net.sourceforge.plantuml.LineParam;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.SkinParamUtils;
|
2017-03-12 17:22:02 +00:00
|
|
|
import net.sourceforge.plantuml.Url;
|
2016-09-29 19:51:18 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
|
|
|
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.ILeaf;
|
2016-09-29 19:51:18 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.PortionShower;
|
2011-08-08 17:48:29 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
|
|
|
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
2011-08-08 17:48:29 +00:00
|
|
|
import net.sourceforge.plantuml.graphic.HtmlColor;
|
|
|
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
|
|
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
|
|
|
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
2015-09-28 20:42:17 +00:00
|
|
|
import net.sourceforge.plantuml.graphic.color.ColorType;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.svek.AbstractEntityImage;
|
|
|
|
import net.sourceforge.plantuml.svek.Cluster;
|
|
|
|
import net.sourceforge.plantuml.svek.ClusterDecoration;
|
|
|
|
import net.sourceforge.plantuml.svek.ShapeType;
|
2011-08-08 17:48:29 +00:00
|
|
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
2015-04-07 18:18:37 +00:00
|
|
|
import net.sourceforge.plantuml.ugraphic.UStroke;
|
2011-08-08 17:48:29 +00:00
|
|
|
|
2015-08-05 20:17:01 +00:00
|
|
|
public class EntityImageEmptyPackage extends AbstractEntityImage {
|
2011-08-08 17:48:29 +00:00
|
|
|
|
2017-03-12 17:22:02 +00:00
|
|
|
private final TextBlock desc;
|
|
|
|
private final static int MARGIN = 10;
|
|
|
|
private final HtmlColor specificBackColor;
|
|
|
|
private final ISkinParam skinParam;
|
|
|
|
private final Stereotype stereotype;
|
|
|
|
private final TextBlock stereoBlock;
|
|
|
|
private final Url url;
|
2011-08-08 17:48:29 +00:00
|
|
|
|
2016-09-29 19:51:18 +00:00
|
|
|
public EntityImageEmptyPackage(ILeaf entity, ISkinParam skinParam, PortionShower portionShower) {
|
2011-08-08 17:48:29 +00:00
|
|
|
super(entity, skinParam);
|
2013-12-10 19:36:50 +00:00
|
|
|
this.skinParam = skinParam;
|
2015-09-28 20:42:17 +00:00
|
|
|
this.specificBackColor = entity.getColors(skinParam).getColor(ColorType.BACK);
|
2013-12-10 19:36:50 +00:00
|
|
|
this.stereotype = entity.getStereotype();
|
2016-09-29 19:51:18 +00:00
|
|
|
this.desc = entity.getDisplay().create(new FontConfiguration(getSkinParam(), FontParam.PACKAGE, stereotype),
|
2015-08-05 20:17:01 +00:00
|
|
|
HorizontalAlignment.CENTER, skinParam);
|
2017-03-12 17:22:02 +00:00
|
|
|
this.url = entity.getUrl99();
|
2016-09-29 19:51:18 +00:00
|
|
|
|
|
|
|
if (stereotype == null || stereotype.getLabel(false) == null
|
|
|
|
|| portionShower.showPortion(EntityPortion.STEREOTYPE, entity) == false) {
|
|
|
|
stereoBlock = TextBlockUtils.empty(0, 0);
|
|
|
|
} else {
|
|
|
|
stereoBlock = TextBlockUtils.withMargin(
|
|
|
|
Display.create(stereotype.getLabels(skinParam.useGuillemet())).create(
|
|
|
|
new FontConfiguration(getSkinParam(), FontParam.PACKAGE_STEREOTYPE, stereotype),
|
|
|
|
HorizontalAlignment.CENTER, skinParam), 1, 0);
|
|
|
|
}
|
|
|
|
|
2011-08-08 17:48:29 +00:00
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
2016-09-29 19:51:18 +00:00
|
|
|
final Dimension2D dimDesc = desc.calculateDimension(stringBounder);
|
|
|
|
Dimension2D dim = TextBlockUtils.mergeTB(desc, stereoBlock, HorizontalAlignment.LEFT).calculateDimension(
|
|
|
|
stringBounder);
|
|
|
|
dim = Dimension2DDouble.atLeast(dim, 0, 2 * dimDesc.getHeight());
|
|
|
|
return Dimension2DDouble.delta(dim, MARGIN * 2, MARGIN * 2);
|
2011-08-08 17:48:29 +00:00
|
|
|
}
|
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
private UStroke getStroke() {
|
|
|
|
UStroke stroke = getSkinParam().getThickness(LineParam.packageBorder, getStereo());
|
|
|
|
if (stroke == null) {
|
2017-12-11 21:02:10 +00:00
|
|
|
stroke = new UStroke(1.5);
|
2015-04-07 18:18:37 +00:00
|
|
|
}
|
|
|
|
return stroke;
|
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
final public void drawU(UGraphic ug) {
|
2017-03-12 17:22:02 +00:00
|
|
|
if (url != null) {
|
|
|
|
ug.startUrl(url);
|
|
|
|
}
|
|
|
|
|
2011-08-08 17:48:29 +00:00
|
|
|
final StringBounder stringBounder = ug.getStringBounder();
|
2013-12-10 19:36:50 +00:00
|
|
|
final Dimension2D dimTotal = calculateDimension(stringBounder);
|
2011-08-08 17:48:29 +00:00
|
|
|
|
|
|
|
final double widthTotal = dimTotal.getWidth();
|
|
|
|
final double heightTotal = dimTotal.getHeight();
|
|
|
|
|
2015-08-05 20:17:01 +00:00
|
|
|
final HtmlColor back = Cluster.getBackColor(specificBackColor, skinParam, stereotype);
|
2016-12-14 21:01:03 +00:00
|
|
|
final double roundCorner = 0;
|
2011-08-08 17:48:29 +00:00
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
final ClusterDecoration decoration = new ClusterDecoration(getSkinParam().getPackageStyle(), null, desc,
|
2016-09-29 19:51:18 +00:00
|
|
|
stereoBlock, 0, 0, widthTotal, heightTotal, getStroke());
|
|
|
|
|
|
|
|
decoration.drawU(ug, back, SkinParamUtils.getColor(getSkinParam(), ColorParam.packageBorder, getStereo()),
|
2018-09-23 12:15:14 +00:00
|
|
|
getSkinParam().shadowing(getEntity().getStereotype()), roundCorner,
|
2018-11-26 18:46:22 +00:00
|
|
|
getSkinParam().getHorizontalAlignment(AlignmentParam.packageTitleAlignment, null, false));
|
2011-08-08 17:48:29 +00:00
|
|
|
|
2017-03-12 17:22:02 +00:00
|
|
|
if (url != null) {
|
|
|
|
ug.closeAction();
|
|
|
|
}
|
|
|
|
|
2011-08-08 17:48:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public ShapeType getShapeType() {
|
2013-12-10 19:36:50 +00:00
|
|
|
return ShapeType.RECTANGLE;
|
2011-08-08 17:48:29 +00:00
|
|
|
}
|
2011-09-08 10:42:27 +00:00
|
|
|
|
2011-08-08 17:48:29 +00:00
|
|
|
}
|