2011-08-08 17:48:29 +00:00
|
|
|
/* ========================================================================
|
|
|
|
* PlantUML : a free UML diagram generator
|
|
|
|
* ========================================================================
|
|
|
|
*
|
2015-04-07 18:18:37 +00:00
|
|
|
* (C) Copyright 2009-2014, Arnaud Roques
|
2011-08-08 17:48:29 +00:00
|
|
|
*
|
|
|
|
* Project Info: http://plantuml.sourceforge.net
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
|
|
|
* in the United States and other countries.]
|
|
|
|
*
|
|
|
|
* Original Author: Arnaud Roques
|
|
|
|
*
|
|
|
|
* Revision $Revision: 6711 $
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
package net.sourceforge.plantuml.svek;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import net.sourceforge.plantuml.ColorParam;
|
|
|
|
import net.sourceforge.plantuml.FontParam;
|
|
|
|
import net.sourceforge.plantuml.ISkinParam;
|
2015-06-20 10:54:49 +00:00
|
|
|
import net.sourceforge.plantuml.SkinParamUtils;
|
2011-08-08 17:48:29 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
|
|
|
import net.sourceforge.plantuml.cucadiagram.EntityUtils;
|
2011-08-08 17:48:29 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.GroupHierarchy;
|
|
|
|
import net.sourceforge.plantuml.cucadiagram.GroupType;
|
|
|
|
import net.sourceforge.plantuml.cucadiagram.IEntity;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.IGroup;
|
|
|
|
import net.sourceforge.plantuml.cucadiagram.ILeaf;
|
|
|
|
import net.sourceforge.plantuml.cucadiagram.LeafType;
|
2011-08-08 17:48:29 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.Link;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.Member;
|
|
|
|
import net.sourceforge.plantuml.cucadiagram.MethodsOrFieldsArea;
|
2011-08-08 17:48:29 +00:00
|
|
|
import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
|
|
|
import net.sourceforge.plantuml.cucadiagram.dot.DotData;
|
|
|
|
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;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
2011-08-08 17:48:29 +00:00
|
|
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.graphic.TextBlockEmpty;
|
2011-08-08 17:48:29 +00:00
|
|
|
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.graphic.TextBlockWidth;
|
2011-08-08 17:48:29 +00:00
|
|
|
import net.sourceforge.plantuml.skin.rose.Rose;
|
2013-12-10 19:36:50 +00:00
|
|
|
import net.sourceforge.plantuml.svek.image.EntityImageState;
|
2011-08-08 17:48:29 +00:00
|
|
|
import net.sourceforge.plantuml.ugraphic.UFont;
|
2015-04-07 18:18:37 +00:00
|
|
|
import net.sourceforge.plantuml.ugraphic.UStroke;
|
2011-08-08 17:48:29 +00:00
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
public final class GroupPngMakerState {
|
2011-08-08 17:48:29 +00:00
|
|
|
|
|
|
|
private final CucaDiagram diagram;
|
2013-12-10 19:36:50 +00:00
|
|
|
private final IGroup group;
|
2011-08-08 17:48:29 +00:00
|
|
|
|
|
|
|
class InnerGroupHierarchy implements GroupHierarchy {
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
public Collection<IGroup> getChildrenGroups(IGroup parent) {
|
|
|
|
if (EntityUtils.groupRoot(parent)) {
|
2011-08-08 17:48:29 +00:00
|
|
|
return diagram.getChildrenGroups(group);
|
|
|
|
}
|
|
|
|
return diagram.getChildrenGroups(parent);
|
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
public boolean isEmpty(IGroup g) {
|
2011-08-08 17:48:29 +00:00
|
|
|
return diagram.isEmpty(g);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
public GroupPngMakerState(CucaDiagram diagram, IGroup group) {
|
2011-08-08 17:48:29 +00:00
|
|
|
this.diagram = diagram;
|
|
|
|
this.group = group;
|
2013-12-10 19:36:50 +00:00
|
|
|
if (group.isGroup() == false) {
|
|
|
|
throw new IllegalArgumentException();
|
|
|
|
}
|
2011-08-08 17:48:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private List<Link> getPureInnerLinks() {
|
|
|
|
final List<Link> result = new ArrayList<Link>();
|
|
|
|
for (Link link : diagram.getLinks()) {
|
2013-12-10 19:36:50 +00:00
|
|
|
if (EntityUtils.isPureInnerLink12(group, link)) {
|
2011-08-08 17:48:29 +00:00
|
|
|
result.add(link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
public IEntityImage getImage() {
|
2013-12-10 19:36:50 +00:00
|
|
|
final Display display = group.getDisplay();
|
2015-04-07 18:18:37 +00:00
|
|
|
final ISkinParam skinParam = diagram.getSkinParam();
|
2015-06-20 10:54:49 +00:00
|
|
|
final HtmlColor textColor = SkinParamUtils.getFontColor(skinParam, FontParam.STATE, group.getStereotype());
|
2015-07-11 09:32:49 +00:00
|
|
|
final TextBlock title = display.create(new FontConfiguration(getFont(FontParam.STATE),
|
|
|
|
textColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()), HorizontalAlignment.CENTER, diagram.getSkinParam());
|
2011-08-08 17:48:29 +00:00
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
if (group.size() == 0) {
|
|
|
|
return new EntityImageState(group, diagram.getSkinParam());
|
2011-08-08 17:48:29 +00:00
|
|
|
}
|
|
|
|
final List<Link> links = getPureInnerLinks();
|
2013-12-10 19:36:50 +00:00
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
// boolean hasVerticalLine = false;
|
|
|
|
// for (ILeaf leaf : group.getLeafsDirect()) {
|
|
|
|
// if (leaf.getEntityType() == LeafType.STATE_CONCURRENT) {
|
|
|
|
// hasVerticalLine = true;
|
|
|
|
// }
|
|
|
|
// }
|
2011-08-08 17:48:29 +00:00
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
final DotData dotData = new DotData(group, links, group.getLeafsDirect(), diagram.getUmlDiagramType(),
|
2015-04-07 18:18:37 +00:00
|
|
|
skinParam, new InnerGroupHierarchy(), diagram.getColorMapper(), diagram.getEntityFactory(),
|
|
|
|
diagram.isHideEmptyDescriptionForState(), DotMode.NORMAL, diagram.getNamespaceSeparator(),
|
|
|
|
diagram.getPragma());
|
2011-08-08 17:48:29 +00:00
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
final CucaDiagramFileMakerSvek2 svek2 = new CucaDiagramFileMakerSvek2(dotData, diagram.getEntityFactory(),
|
2015-04-07 18:18:37 +00:00
|
|
|
diagram.getSource(), diagram.getPragma());
|
|
|
|
UStroke stroke = group.getSpecificLineStroke();
|
|
|
|
if (stroke == null) {
|
|
|
|
stroke = new UStroke(1.5);
|
|
|
|
}
|
2013-12-10 19:36:50 +00:00
|
|
|
|
|
|
|
if (group.getGroupType() == GroupType.CONCURRENT_STATE) {
|
|
|
|
// return new InnerStateConcurrent(svek2.createFile());
|
|
|
|
return svek2.createFile();
|
|
|
|
} else if (group.getGroupType() == GroupType.STATE) {
|
2015-04-07 18:18:37 +00:00
|
|
|
HtmlColor borderColor = group.getSpecificLineColor();
|
|
|
|
if (borderColor == null) {
|
2015-04-20 19:45:13 +00:00
|
|
|
borderColor = getColor(ColorParam.stateBorder, group.getStereotype());
|
2015-04-07 18:18:37 +00:00
|
|
|
}
|
2013-12-10 19:36:50 +00:00
|
|
|
final Stereotype stereo = group.getStereotype();
|
|
|
|
final HtmlColor backColor = group.getSpecificBackColor() == null ? getColor(ColorParam.stateBackground,
|
|
|
|
stereo) : group.getSpecificBackColor();
|
2015-06-07 10:23:10 +00:00
|
|
|
final List<Member> members = ((IEntity) group).getBodier().getFieldsToDisplay();
|
2013-12-10 19:36:50 +00:00
|
|
|
final TextBlockWidth attribute;
|
|
|
|
if (members.size() == 0) {
|
|
|
|
attribute = new TextBlockEmpty();
|
|
|
|
} else {
|
|
|
|
attribute = new MethodsOrFieldsArea(members, FontParam.STATE_ATTRIBUTE, diagram.getSkinParam());
|
|
|
|
}
|
|
|
|
|
|
|
|
final Stereotype stereotype = group.getStereotype();
|
|
|
|
final boolean withSymbol = stereotype != null && stereotype.isWithOOSymbol();
|
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
final boolean containsOnlyConcurrentStates = containsOnlyConcurrentStates(dotData);
|
|
|
|
final IEntityImage image = containsOnlyConcurrentStates ? svek2.createFileForConcurrentState() : svek2
|
|
|
|
.createFile();
|
|
|
|
return new InnerStateAutonom(image, title, attribute, borderColor, backColor, skinParam.shadowing(),
|
|
|
|
group.getUrl99(), withSymbol, stroke);
|
2011-08-08 17:48:29 +00:00
|
|
|
}
|
|
|
|
|
2013-12-10 19:36:50 +00:00
|
|
|
throw new UnsupportedOperationException(group.getGroupType().toString());
|
2011-08-08 17:48:29 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-04-07 18:18:37 +00:00
|
|
|
private boolean containsOnlyConcurrentStates(DotData dotData) {
|
|
|
|
for (ILeaf leaf : dotData.getLeafs()) {
|
|
|
|
if (leaf instanceof IGroup == false) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (((IGroup) leaf).getEntityType() != LeafType.STATE_CONCURRENT) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-08-08 17:48:29 +00:00
|
|
|
private UFont getFont(FontParam fontParam) {
|
|
|
|
final ISkinParam skinParam = diagram.getSkinParam();
|
2015-04-07 18:18:37 +00:00
|
|
|
return skinParam.getFont(fontParam, null, false);
|
2011-08-08 17:48:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private final Rose rose = new Rose();
|
|
|
|
|
|
|
|
protected final HtmlColor getColor(ColorParam colorParam, Stereotype stereo) {
|
|
|
|
final ISkinParam skinParam = diagram.getSkinParam();
|
2015-04-07 18:18:37 +00:00
|
|
|
return rose.getHtmlColor(skinParam, colorParam, stereo);
|
2011-08-08 17:48:29 +00:00
|
|
|
}
|
|
|
|
}
|