2013-12-10 19:36:50 +00:00
|
|
|
/* ========================================================================
|
|
|
|
* PlantUML : a free UML diagram generator
|
|
|
|
* ========================================================================
|
|
|
|
*
|
2016-01-09 12:15:40 +00:00
|
|
|
* (C) Copyright 2009-2017, Arnaud Roques
|
2013-12-10 19:36:50 +00:00
|
|
|
*
|
2016-03-06 16:47:34 +00:00
|
|
|
* Project Info: http://plantuml.com
|
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
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
package net.sourceforge.plantuml.svek.image;
|
|
|
|
|
|
|
|
import java.awt.geom.Dimension2D;
|
|
|
|
|
|
|
|
import net.sourceforge.plantuml.ISkinParam;
|
|
|
|
import net.sourceforge.plantuml.SkinParamUtils;
|
|
|
|
import net.sourceforge.plantuml.Url;
|
2015-04-07 18:18:37 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.BodyEnhanced;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
2015-04-07 18:18:37 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.ILeaf;
|
2015-04-07 18:18:37 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.PortionShower;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
|
|
|
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
|
|
|
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
|
|
|
import net.sourceforge.plantuml.graphic.HtmlColor;
|
|
|
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
|
|
|
import net.sourceforge.plantuml.graphic.SymbolContext;
|
|
|
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
|
|
|
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
|
|
|
import net.sourceforge.plantuml.graphic.USymbol;
|
2015-07-11 09:32:49 +00:00
|
|
|
import net.sourceforge.plantuml.graphic.USymbolFolder;
|
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.ShapeType;
|
2016-07-25 19:25:28 +00:00
|
|
|
import net.sourceforge.plantuml.ugraphic.UComment;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
|
|
|
import net.sourceforge.plantuml.ugraphic.UStroke;
|
|
|
|
|
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;
|
|
|
|
|
2015-07-11 09:32:49 +00:00
|
|
|
public EntityImageDescription(ILeaf entity, ISkinParam skinParam, PortionShower portionShower) {
|
2015-09-28 20:42:17 +00:00
|
|
|
super(entity, entity.getColors(skinParam).mute(skinParam));
|
2013-12-10 19:36:50 +00:00
|
|
|
final Stereotype stereotype = entity.getStereotype();
|
2016-01-09 12:15:40 +00:00
|
|
|
USymbol symbol = entity.getUSymbol() == null ? (getSkinParam().useUml2ForComponent() ? USymbol.COMPONENT2
|
2015-04-07 18:18:37 +00:00
|
|
|
: USymbol.COMPONENT1) : entity.getUSymbol();
|
|
|
|
if (symbol == null) {
|
|
|
|
throw new IllegalArgumentException();
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
2015-09-28 20:42:17 +00:00
|
|
|
shapeType = symbol == USymbol.FOLDER ? ShapeType.FOLDER : ShapeType.RECTANGLE;
|
2013-12-10 19:36:50 +00:00
|
|
|
|
2015-07-11 09:32:49 +00:00
|
|
|
final Display codeDisplay = Display.getWithNewlines(entity.getCode());
|
|
|
|
final TextBlock desc = (entity.getDisplay().equals(codeDisplay) && symbol instanceof USymbolFolder)
|
|
|
|
|| entity.getDisplay().isWhite() ? TextBlockUtils.empty(0, 0) : new BodyEnhanced(entity.getDisplay(),
|
2017-02-15 21:34:36 +00:00
|
|
|
symbol.getFontParam(), getSkinParam(), HorizontalAlignment.LEFT, stereotype,
|
2017-03-12 17:22:02 +00:00
|
|
|
symbol.manageHorizontalLine(), false, entity);
|
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
|
|
|
|
2015-09-28 20:42:17 +00:00
|
|
|
HtmlColor backcolor = getEntity().getColors(getSkinParam()).getColor(ColorType.BACK);
|
2015-04-07 18:18:37 +00:00
|
|
|
if (backcolor == null) {
|
|
|
|
backcolor = SkinParamUtils.getColor(getSkinParam(), symbol.getColorParamBack(), getStereo());
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
2015-04-07 18:18:37 +00:00
|
|
|
// backcolor = HtmlColorUtils.BLUE;
|
2016-12-21 22:10:29 +00:00
|
|
|
assert getStereo() == stereotype;
|
|
|
|
final HtmlColor forecolor = SkinParamUtils.getColor(getSkinParam(), symbol.getColorParamBorder(), stereotype);
|
2016-12-14 21:01:03 +00:00
|
|
|
final double roundCorner = symbol.getSkinParameter().getRoundCorner(getSkinParam(), stereotype);
|
2016-12-21 22:10:29 +00:00
|
|
|
final UStroke stroke = symbol.getSkinParameter().getStroke(getSkinParam(), stereotype);
|
|
|
|
final SymbolContext ctx = new SymbolContext(backcolor, forecolor).withStroke(stroke)
|
2016-12-14 21:01:03 +00:00
|
|
|
.withShadow(getSkinParam().shadowing2(symbol.getSkinParameter())).withRoundCorner(roundCorner);
|
2015-04-07 18:18:37 +00:00
|
|
|
|
|
|
|
TextBlock stereo = TextBlockUtils.empty(0, 0);
|
|
|
|
|
2016-01-09 12:15:40 +00:00
|
|
|
if (stereotype != null && stereotype.getSprite() != null
|
|
|
|
&& getSkinParam().getSprite(stereotype.getSprite()) != null) {
|
|
|
|
symbol = symbol.withStereoAlignment(HorizontalAlignment.RIGHT);
|
2016-04-04 19:05:10 +00:00
|
|
|
stereo = getSkinParam().getSprite(stereotype.getSprite()).asTextBlock(stereotype.getHtmlColor(), 1);
|
2016-01-09 12:15:40 +00:00
|
|
|
} else if (stereotype != null && stereotype.getLabel(false) != null
|
2015-04-07 18:18:37 +00:00
|
|
|
&& portionShower.showPortion(EntityPortion.STEREOTYPE, entity)) {
|
2015-07-11 09:32:49 +00:00
|
|
|
stereo = Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())).create(
|
2015-09-28 20:42:17 +00:00
|
|
|
new FontConfiguration(getSkinParam(), symbol.getFontParamStereotype(), stereotype),
|
|
|
|
HorizontalAlignment.CENTER, getSkinParam());
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
2015-09-28 20:42:17 +00:00
|
|
|
name = new BodyEnhanced(codeDisplay, symbol.getFontParam(), getSkinParam(), HorizontalAlignment.CENTER,
|
2017-03-12 17:22:02 +00:00
|
|
|
stereotype, symbol.manageHorizontalLine(), false, entity);
|
2015-07-11 09:32:49 +00:00
|
|
|
|
|
|
|
asSmall = symbol.asSmall(name, desc, stereo, ctx);
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
2015-09-28 20:42:17 +00:00
|
|
|
public Dimension2D getNameDimension(StringBounder stringBounder) {
|
|
|
|
return name.calculateDimension(stringBounder);
|
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
2015-04-07 18:18:37 +00:00
|
|
|
return asSmall.calculateDimension(stringBounder);
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
final public void drawU(UGraphic ug) {
|
2016-07-25 19:25:28 +00:00
|
|
|
ug.draw(new UComment("entity " + getEntity().getCode().getFullName()));
|
2013-12-10 19:36:50 +00:00
|
|
|
if (url != null) {
|
|
|
|
ug.startUrl(url);
|
|
|
|
}
|
2015-04-07 18:18:37 +00:00
|
|
|
asSmall.drawU(ug);
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
if (url != null) {
|
|
|
|
ug.closeAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public ShapeType getShapeType() {
|
2015-09-28 20:42:17 +00:00
|
|
|
return shapeType;
|
2013-12-10 19:36:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getShield() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|