2016-01-30 12:20:07 +00:00
|
|
|
/* ========================================================================
|
|
|
|
* PlantUML : a free UML diagram generator
|
|
|
|
* ========================================================================
|
|
|
|
*
|
|
|
|
* (C) Copyright 2009-2017, Arnaud Roques
|
|
|
|
*
|
2016-03-06 16:47:34 +00:00
|
|
|
* Project Info: http://plantuml.com
|
2016-01-30 12:20:07 +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
|
|
|
|
*
|
2016-01-30 12:20:07 +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
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
package net.sourceforge.plantuml;
|
|
|
|
|
|
|
|
import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend;
|
|
|
|
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
|
2018-05-06 19:59:19 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.DisplaySection;
|
2016-01-30 12:20:07 +00:00
|
|
|
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
|
|
|
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
|
|
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
|
|
|
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
|
|
|
import net.sourceforge.plantuml.svek.DecorateEntityImage;
|
|
|
|
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
|
|
|
|
|
|
|
|
public class AnnotatedWorker {
|
|
|
|
|
|
|
|
private final Annotated annotated;
|
|
|
|
private final ISkinParam skinParam;
|
|
|
|
|
|
|
|
public AnnotatedWorker(Annotated annotated, ISkinParam skinParam) {
|
|
|
|
this.annotated = annotated;
|
|
|
|
this.skinParam = skinParam;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public TextBlockBackcolored addAdd(TextBlock result) {
|
|
|
|
result = addLegend(result);
|
|
|
|
result = addTitle(result);
|
|
|
|
result = addCaption(result);
|
|
|
|
result = addHeaderAndFooter(result);
|
|
|
|
return (TextBlockBackcolored) result;
|
|
|
|
}
|
|
|
|
|
|
|
|
private TextBlock addLegend(TextBlock original) {
|
2018-05-01 17:26:04 +00:00
|
|
|
final DisplayPositionned legend = annotated.getLegend();
|
2018-05-06 19:59:19 +00:00
|
|
|
if (legend.isNull()) {
|
2016-01-30 12:20:07 +00:00
|
|
|
return original;
|
|
|
|
}
|
2018-05-01 17:26:04 +00:00
|
|
|
final TextBlock text = EntityImageLegend.create(legend.getDisplay(), getSkinParam());
|
2016-01-30 12:20:07 +00:00
|
|
|
|
2018-05-01 17:26:04 +00:00
|
|
|
return DecorateEntityImage.add(original, text, legend.getHorizontalAlignment(), legend.getVerticalAlignment());
|
2016-01-30 12:20:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private ISkinParam getSkinParam() {
|
|
|
|
return skinParam;
|
|
|
|
}
|
|
|
|
|
|
|
|
private TextBlock addCaption(TextBlock original) {
|
2018-05-01 17:26:04 +00:00
|
|
|
final DisplayPositionned caption = annotated.getCaption();
|
2018-05-06 19:59:19 +00:00
|
|
|
if (caption.isNull()) {
|
2016-01-30 12:20:07 +00:00
|
|
|
return original;
|
|
|
|
}
|
|
|
|
final TextBlock text = getCaption();
|
|
|
|
|
|
|
|
return DecorateEntityImage.addBottom(original, text, HorizontalAlignment.CENTER);
|
|
|
|
}
|
|
|
|
|
|
|
|
public TextBlock getCaption() {
|
2018-05-01 17:26:04 +00:00
|
|
|
final DisplayPositionned caption = annotated.getCaption();
|
2018-05-06 19:59:19 +00:00
|
|
|
if (caption.isNull()) {
|
2016-01-30 12:20:07 +00:00
|
|
|
return TextBlockUtils.empty(0, 0);
|
|
|
|
}
|
2018-05-01 17:26:04 +00:00
|
|
|
return caption.getDisplay().create(new FontConfiguration(getSkinParam(), FontParam.CAPTION, null),
|
|
|
|
HorizontalAlignment.CENTER, getSkinParam());
|
2016-01-30 12:20:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private TextBlock addTitle(TextBlock original) {
|
2016-11-04 21:39:29 +00:00
|
|
|
final DisplayPositionned title = annotated.getTitle();
|
2018-05-06 19:59:19 +00:00
|
|
|
if (title.isNull()) {
|
2016-01-30 12:20:07 +00:00
|
|
|
return original;
|
|
|
|
}
|
2016-11-04 21:39:29 +00:00
|
|
|
ISkinParam skinParam = getSkinParam();
|
|
|
|
final FontConfiguration fontConfiguration = new FontConfiguration(skinParam, FontParam.TITLE, null);
|
2016-01-30 12:20:07 +00:00
|
|
|
|
2016-11-04 21:39:29 +00:00
|
|
|
final TextBlock block = TextBlockUtils.title(fontConfiguration, title.getDisplay(), skinParam);
|
|
|
|
return DecorateEntityImage.addTop(original, block, HorizontalAlignment.CENTER);
|
2016-01-30 12:20:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private TextBlock addHeaderAndFooter(TextBlock original) {
|
2018-05-06 19:59:19 +00:00
|
|
|
final DisplaySection footer = annotated.getFooter();
|
|
|
|
final DisplaySection header = annotated.getHeader();
|
|
|
|
if (footer.isNull() && header.isNull()) {
|
2016-01-30 12:20:07 +00:00
|
|
|
return original;
|
|
|
|
}
|
2018-05-01 17:26:04 +00:00
|
|
|
TextBlock textFooter = null;
|
2018-05-06 19:59:19 +00:00
|
|
|
if (footer.isNull() == false) {
|
|
|
|
textFooter = footer.createRibbon(new FontConfiguration(getSkinParam(), FontParam.FOOTER, null), getSkinParam());
|
2018-05-01 17:26:04 +00:00
|
|
|
}
|
|
|
|
TextBlock textHeader = null;
|
2018-05-06 19:59:19 +00:00
|
|
|
if (header.isNull() == false) {
|
|
|
|
textHeader = header.createRibbon(new FontConfiguration(getSkinParam(), FontParam.HEADER, null), getSkinParam());
|
2018-05-01 17:26:04 +00:00
|
|
|
}
|
2016-01-30 12:20:07 +00:00
|
|
|
|
2018-05-01 17:26:04 +00:00
|
|
|
return DecorateEntityImage.addTopAndBottom(original, textHeader, header.getHorizontalAlignment(), textFooter,
|
|
|
|
footer.getHorizontalAlignment());
|
|
|
|
}
|
2016-01-30 12:20:07 +00:00
|
|
|
}
|