1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-05 01:50:49 +00:00

Start to add Problem Diagrams

This commit is contained in:
Arnaud Roques 2018-05-21 21:15:19 +02:00
parent d7ecae5722
commit 1aec937bbe
15 changed files with 1021 additions and 8 deletions

View File

@ -165,7 +165,17 @@ public enum ColorParam {
iconPublicBackground(HtmlColorUtils.COL_84BE84),
iconIEMandatory(HtmlColorUtils.BLACK),
arrowLollipop(HtmlColorUtils.WHITE);
arrowLollipop(HtmlColorUtils.WHITE),
domainBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK),
domainBorder(HtmlColorUtils.MY_RED, ColorType.LINE),
designedDomainBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK),
designedDomainBorder(HtmlColorUtils.MY_RED, ColorType.LINE),
machineBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK),
machineBorder(HtmlColorUtils.MY_RED, ColorType.LINE),
requirementBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK),
requirementBorder(HtmlColorUtils.MY_RED, ColorType.LINE);
private final boolean isBackground;
private final HtmlColor defaultValue;

View File

@ -118,7 +118,15 @@ public enum FontParam {
STACK_STEREOTYPE(14, Font.ITALIC), //
ACTOR_STEREOTYPE(14, Font.ITALIC), //
SEQUENCE_STEREOTYPE(14, Font.ITALIC), //
PARTITION(14, Font.PLAIN); //
PARTITION(14, Font.PLAIN),
DESIGNED_DOMAIN(12, Font.PLAIN), //
DESIGNED_DOMAIN_STEREOTYPE(12, Font.ITALIC), //
DOMAIN(12, Font.PLAIN), //
DOMAIN_STEREOTYPE(12, Font.ITALIC), //
MACHINE(12, Font.PLAIN), //
MACHINE_STEREOTYPE(12, Font.ITALIC), //
REQUIREMENT(12, Font.PLAIN), //
REQUIREMENT_STEREOTYPE(12, Font.ITALIC); //
private final int defaultSize;
private final int fontStyle;

View File

@ -57,7 +57,8 @@ public enum LineParam {
rectangleBorder,
componentBorder,
cardBorder,
agentBorder;
agentBorder,
domainBorder, designedDomainBorder, machineBorder, requirementBorder;
// sequenceBoxBorder(0.1);
}

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.cucadiagram;
public enum GroupType {
PACKAGE, STATE, CONCURRENT_STATE, INNER_ACTIVITY, CONCURRENT_ACTIVITY
PACKAGE, STATE, CONCURRENT_STATE, INNER_ACTIVITY, CONCURRENT_ACTIVITY, DOMAIN, REQUIREMENT
}

View File

@ -54,6 +54,8 @@ public enum LeafType {
STATE, STATE_CONCURRENT, PSEUDO_STATE, STATE_CHOICE, STATE_FORK_JOIN,
BLOCK, ENTITY,
DOMAIN, REQUIREMENT,
STILL_UNKNOWN;

View File

@ -247,4 +247,28 @@ public class Stereotype implements CharSequence {
return null;
}
public boolean isBiddableOrUncertain() {
return label.equalsIgnoreCase("<<B>>") || label.equalsIgnoreCase("<<Biddable>>")
|| label.equalsIgnoreCase("<<Uncertain>>");
}
public boolean isCausal() {
return label.equalsIgnoreCase("<<C>>") || label.equalsIgnoreCase("<<Causal>>");
}
public boolean isLexicalOrGiven() {
return label.equalsIgnoreCase("<<L>>") || label.equalsIgnoreCase("<<Lexical>>")
|| label.equalsIgnoreCase("<<X>>") || label.equalsIgnoreCase("<<Given>>");
}
public boolean isDesignedOrSolved() {
return label.equalsIgnoreCase("<<D>>") || label.equalsIgnoreCase("<<Designed>>")
|| label.equalsIgnoreCase("<<Nested>>") || label.equalsIgnoreCase("<<Solved>>");
}
public boolean isMachineOrSpecification() {
return label.equalsIgnoreCase("M") || label.equalsIgnoreCase("<<Machine>>") || label.equalsIgnoreCase("<<S>>")
|| label.equalsIgnoreCase("<<Spec>>") || label.equalsIgnoreCase("<<Specification>>");
}
}

View File

@ -0,0 +1,94 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, 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.descdiagram;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class BoxedCharacter extends AbstractTextBlock implements TextBlock {
private final String c;
private final UFont font;
private final HtmlColor innerCircle;
private final HtmlColor circle;
private final HtmlColor fontColor;
private final double radius;
public BoxedCharacter(char c, double size, UFont font, HtmlColor innerCircle, HtmlColor circle, HtmlColor fontColor) {
this.c = "" + c;
this.font = font;
this.innerCircle = innerCircle;
this.circle = circle;
this.fontColor = fontColor;
this.radius = size;
}
public void drawU(UGraphic ug) {
if (circle != null) {
ug = ug.apply(new UChangeColor(circle));
}
// final HtmlColor back = ug.getParam().getBackcolor();
ug = ug.apply(new UChangeBackColor(innerCircle));
ug.draw(new URectangle(2 * radius, 2 * radius));
ug = ug.apply(new UChangeColor(fontColor));
ug = ug.apply(new UTranslate(radius, radius));
ug.draw(new UCenteredCharacter(c.charAt(0), font));
}
final public double getPreferredWidth(StringBounder stringBounder) {
return 2 * radius;
}
final public double getPreferredHeight(StringBounder stringBounder) {
return 2 * radius;
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return new Dimension2DDouble(getPreferredWidth(stringBounder), getPreferredHeight(stringBounder));
}
}

View File

@ -0,0 +1,144 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, 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: Yijun Yu
*
*
*/
package net.sourceforge.plantuml.descdiagram;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
import net.sourceforge.plantuml.classdiagram.command.GenericRegexProducer;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.IGroup;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.graphic.color.ColorType;
public class CommandCreateDomain extends SingleLineCommand2<DescriptionDiagram> {
public static final String DISPLAY_WITH_GENERIC = "[%g](.+?)(?:\\<(" + GenericRegexProducer.PATTERN + ")\\>)?[%g]";
public static final String CODE = "[^%s{}%g<>]+";
public CommandCreateDomain() {
super(getRegexConcat());
}
private static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("TYPE", // TODO yy
"(requirement|domain)[%s]+"), //
new RegexLeaf("DISPLAY", DISPLAY_WITH_GENERIC), new RegexLeaf("[%s]+as[%s]+"), //
new RegexLeaf("CODE", "([a-zA-Z0-9]+)"), new RegexLeaf("[%s]*"), new RegexLeaf("STEREO",
"(\\<\\<.+\\>\\>)?"), //
// domain: lexical, causal, biddable
// requirement: FR, NFR, quality
new RegexLeaf("[%s]*"), //
new RegexLeaf("GROUP", "(\\{)?"), //
new RegexLeaf("$"));
}
@Override
protected CommandExecutionResult executeArg(DescriptionDiagram diagram, RegexResult arg) {
String type = arg.get("TYPE", 0);
String display = arg.getLazzy("DISPLAY", 0);
String code = arg.getLazzy("CODE", 0);
if (code == null) {
code = display;
}
final String genericOption = arg.getLazzy("DISPLAY", 1);
final String generic = genericOption != null ? genericOption : arg.get("GENERIC", 0);
final String stereotype = arg.get("STEREO", 0);
if (diagram.leafExist(Code.of(code))) {
return CommandExecutionResult.error("Object already exists : " + code);
}
Display d = Display.getWithNewlines(display);
final String urlString = arg.get("URL", 0);
final String group = arg.get("GROUP", 0);
IEntity entity;
if (group != null) {
final IGroup currentGroup = diagram.getCurrentGroup();
diagram.gotoGroup2(Code.of(code), d, type.equalsIgnoreCase("domain") ? GroupType.DOMAIN
: GroupType.REQUIREMENT, currentGroup, NamespaceStrategy.SINGLE);
entity = diagram.getCurrentGroup();
} else {
entity = diagram.createLeaf(Code.of(code), d, type.equalsIgnoreCase("domain") ? LeafType.DOMAIN
: LeafType.REQUIREMENT, null);
}
if (stereotype != null) {
entity.setStereotype(new Stereotype(stereotype, diagram.getSkinParam().getCircledCharacterRadius(), diagram
.getSkinParam().getFont(null, false, FontParam.CIRCLED_CHARACTER), diagram.getSkinParam()
.getIHtmlColorSet()));
}
if (urlString != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
final Url url = urlBuilder.getUrl(urlString);
entity.addUrl(url);
}
entity.setSpecificColorTOBEREMOVED(ColorType.BACK,
diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
if (type.equalsIgnoreCase("domain")) {
if (stereotype != null && stereotype.equalsIgnoreCase("<<Machine>>")) {
type = "machine";
}
if (stereotype != null && stereotype.equalsIgnoreCase("<<Causal>>")) {
type = "causal";
}
if (stereotype != null && stereotype.equalsIgnoreCase("<<Designed>>")) {
type = "designed";
}
if (stereotype != null && stereotype.equalsIgnoreCase("<<Lexical>>")) {
type = "lexical";
}
if (stereotype != null && stereotype.equalsIgnoreCase("<<Biddable>>")) {
type = "biddable";
}
}
USymbol usymbol = USymbol.getFromString(type, diagram.getSkinParam().useUml2ForComponent());
entity.setUSymbol(usymbol);
return CommandExecutionResult.ok();
}
}

View File

@ -39,7 +39,6 @@ import java.util.ArrayList;
import java.util.List;
import net.sourceforge.plantuml.classdiagram.command.CommandHideShow2;
import net.sourceforge.plantuml.classdiagram.command.CommandHideShowSpecificClass;
import net.sourceforge.plantuml.classdiagram.command.CommandRemoveRestore;
import net.sourceforge.plantuml.classdiagram.command.CommandUrl;
import net.sourceforge.plantuml.command.Command;
@ -117,6 +116,7 @@ public class DescriptionDiagramFactory extends UmlDiagramFactory {
// cmds.add(new CommandHideShowSpecificClass());
cmds.add(new CommandArchimate());
cmds.add(new CommandCreateDomain());
return cmds;
}

View File

@ -0,0 +1,164 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, 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: Yijun Yu
*
*
*/
package net.sourceforge.plantuml.descdiagram;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
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.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.svek.AbstractEntityImage;
import net.sourceforge.plantuml.svek.ShapeType;
import net.sourceforge.plantuml.ugraphic.PlacementStrategyY1Y2;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULayoutGroup;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class EntityImageDesignedDomain extends AbstractEntityImage {
final private TextBlock name;
final private TextBlock stereo;
final private Url url;
public EntityImageDesignedDomain(ILeaf entity, ISkinParam skinParam) {
super(entity, skinParam);
final Stereotype stereotype = entity.getStereotype();
this.name = TextBlockUtils.withMargin(
entity.getDisplay().create(new FontConfiguration(getSkinParam(), FontParam.DESIGNED_DOMAIN, stereotype),
HorizontalAlignment.CENTER, skinParam), 2, 2);
if (stereotype == null || stereotype.getLabel(false) == null) {
this.stereo = null;
} else {
this.stereo = Display.create(stereotype.getLabels(skinParam.useGuillemet())).create(
new FontConfiguration(getSkinParam(), FontParam.DESIGNED_DOMAIN_STEREOTYPE, stereotype),
HorizontalAlignment.CENTER, skinParam);
}
this.url = entity.getUrl99();
// System.out.println(entity.getStereotype());
}
private UStroke getStroke() {
UStroke stroke = getSkinParam().getThickness(LineParam.designedDomainBorder, getStereo());
if (stroke == null) {
stroke = new UStroke(1.5);
}
return stroke;
}
private Dimension2D getTitleDimension(StringBounder stringBounder) {
return getNameAndSteretypeDimension(stringBounder);
}
private Dimension2D getNameAndSteretypeDimension(StringBounder stringBounder) {
final Dimension2D nameDim = name.calculateDimension(stringBounder);
final Dimension2D stereoDim = stereo == null ? new Dimension2DDouble(0, 0) : stereo
.calculateDimension(stringBounder);
final Dimension2D nameAndStereo = new Dimension2DDouble(Math.max(nameDim.getWidth(), stereoDim.getWidth()),
nameDim.getHeight() + stereoDim.getHeight());
return nameAndStereo;
}
public double getStartingX(StringBounder stringBounder, double y) {
return 0;
}
public double getEndingX(StringBounder stringBounder, double y) {
return calculateDimension(stringBounder).getWidth();
}
final public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final Dimension2D dimTotal = calculateDimension(stringBounder);
final Dimension2D dimTitle = getTitleDimension(stringBounder);
final double widthTotal = dimTotal.getWidth();
final double heightTotal = dimTotal.getHeight();
final URectangle rect = new URectangle(widthTotal, heightTotal, 0, 0);
URectangle rect2 = new URectangle(4, heightTotal, 0, 0);
ug = ug.apply(new UChangeColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.designedDomainBorder, getStereo())));
HtmlColor backcolor = getEntity().getColors(getSkinParam()).getColor(ColorType.BACK);
if (backcolor == null) {
backcolor = SkinParamUtils.getColor(getSkinParam(), ColorParam.designedDomainBackground, getStereo());
}
ug = ug.apply(new UChangeBackColor(backcolor));
if (url != null) {
ug.startUrl(url);
}
final UStroke stroke = getStroke();
ug.apply(stroke).draw(rect);
ug.apply(stroke).draw(rect2);
final ULayoutGroup header = new ULayoutGroup(new PlacementStrategyY1Y2(ug.getStringBounder()));
header.add(name);
header.drawU(ug.apply(new UTranslate(4, 0)), dimTotal.getWidth(), dimTitle.getHeight());
if (url != null) {
ug.closeAction();
}
}
public ShapeType getShapeType() {
return ShapeType.RECTANGLE;
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
final Dimension2D dimTitle = getTitleDimension(stringBounder);
final double width = dimTitle.getWidth();
final double height = dimTitle.getHeight();
return new Dimension2DDouble(width + 5, height);
}
}

View File

@ -0,0 +1,174 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, 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: Yijun Yu
*
*
*/
package net.sourceforge.plantuml.descdiagram;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
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.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.svek.AbstractEntityImage;
import net.sourceforge.plantuml.svek.ShapeType;
import net.sourceforge.plantuml.ugraphic.PlacementStrategyY1Y2;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULayoutGroup;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class EntityImageDomain extends AbstractEntityImage {
final private TextBlock name;
final private TextBlock tag;
final private TextBlock stereo;
final private Url url;
public EntityImageDomain(ILeaf entity, ISkinParam skinParam, char typeLetter) {
super(entity, skinParam);
final Stereotype stereotype = entity.getStereotype();
FontConfiguration fc = new FontConfiguration(getSkinParam(), FontParam.DESIGNED_DOMAIN, stereotype);
this.name = TextBlockUtils.withMargin(entity.getDisplay().create(fc, HorizontalAlignment.CENTER, skinParam), 2,
2);
if (stereotype == null || stereotype.getLabel(false) == null) {
this.stereo = null;
} else {
this.stereo = Display.create(stereotype.getLabels(skinParam.useGuillemet())).create(
new FontConfiguration(getSkinParam(), FontParam.DESIGNED_DOMAIN_STEREOTYPE, stereotype),
HorizontalAlignment.CENTER, skinParam);
}
this.tag = new BoxedCharacter(typeLetter, 8, UFont.byDefault(8), stereotype.getHtmlColor(), null, fc.getColor());
this.url = entity.getUrl99();
}
private UStroke getStroke() {
UStroke stroke = getSkinParam().getThickness(LineParam.domainBorder, getStereo());
if (stroke == null) {
stroke = new UStroke(1.5);
}
return stroke;
}
private Dimension2D getTitleDimension(StringBounder stringBounder) {
return getNameAndSteretypeDimension(stringBounder);
}
private Dimension2D getNameAndSteretypeDimension(StringBounder stringBounder) {
final Dimension2D nameDim = name.calculateDimension(stringBounder);
final Dimension2D stereoDim = stereo == null ? new Dimension2DDouble(0, 0) : stereo
.calculateDimension(stringBounder);
final Dimension2D nameAndStereo = new Dimension2DDouble(Math.max(nameDim.getWidth(), stereoDim.getWidth()),
nameDim.getHeight() + stereoDim.getHeight());
return nameAndStereo;
}
public double getStartingX(StringBounder stringBounder, double y) {
return 0;
}
public double getEndingX(StringBounder stringBounder, double y) {
return calculateDimension(stringBounder).getWidth();
}
final public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final Dimension2D dimTotal = calculateDimension(stringBounder);
final Dimension2D dimTitle = getTitleDimension(stringBounder);
final Dimension2D dimTag = getTagDimension(stringBounder);
final double widthTotal = dimTotal.getWidth();
final double heightTotal = dimTotal.getHeight();
final URectangle rect = new URectangle(widthTotal, heightTotal, 0, 0);
ug = ug.apply(new UChangeColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.domainBorder, getStereo())));
HtmlColor backcolor = getEntity().getColors(getSkinParam()).getColor(ColorType.BACK);
if (backcolor == null) {
backcolor = SkinParamUtils.getColor(getSkinParam(), ColorParam.domainBackground, getStereo());
}
ug = ug.apply(new UChangeBackColor(backcolor));
if (url != null) {
ug.startUrl(url);
}
final UStroke stroke = getStroke();
ug.apply(stroke).draw(rect);
final ULayoutGroup header = new ULayoutGroup(new PlacementStrategyY1Y2(ug.getStringBounder()));
header.add(name);
header.drawU(ug, dimTotal.getWidth(), dimTitle.getHeight());
final ULayoutGroup footer = new ULayoutGroup(new PlacementStrategyY1Y2(ug.getStringBounder()));
footer.add(tag);
footer.drawU(ug.apply(new UTranslate(dimTotal.getWidth() - dimTag.getWidth(), dimTitle.getHeight())),
dimTag.getWidth(), dimTag.getHeight());
if (url != null) {
ug.closeAction();
}
}
private Dimension2D getTagDimension(StringBounder stringBounder) {
final Dimension2D tagDim = tag == null ? new Dimension2DDouble(0, 0) : tag.calculateDimension(stringBounder);
return tagDim;
}
public ShapeType getShapeType() {
return ShapeType.RECTANGLE;
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
final Dimension2D dimTitle = getTitleDimension(stringBounder);
final double width = dimTitle.getWidth();
final double height = dimTitle.getHeight();
final Dimension2D dimTag = getTagDimension(stringBounder);
return new Dimension2DDouble(width, height + dimTag.getHeight());
}
}

View File

@ -0,0 +1,163 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, 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: Yijun Yu
*
*
*/
package net.sourceforge.plantuml.descdiagram;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
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.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.svek.AbstractEntityImage;
import net.sourceforge.plantuml.svek.ShapeType;
import net.sourceforge.plantuml.ugraphic.PlacementStrategyY1Y2;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULayoutGroup;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class EntityImageMachine extends AbstractEntityImage {
final private TextBlock name;
final private TextBlock stereo;
final private Url url;
public EntityImageMachine(ILeaf entity, ISkinParam skinParam) {
super(entity, skinParam);
final Stereotype stereotype = entity.getStereotype();
this.name = TextBlockUtils.withMargin(
entity.getDisplay().create(new FontConfiguration(getSkinParam(), FontParam.MACHINE, stereotype),
HorizontalAlignment.CENTER, skinParam), 2, 2);
if (stereotype == null || stereotype.getLabel(false) == null) {
this.stereo = null;
} else {
this.stereo = Display.create(stereotype.getLabels(skinParam.useGuillemet())).create(
new FontConfiguration(getSkinParam(), FontParam.MACHINE_STEREOTYPE, stereotype),
HorizontalAlignment.CENTER, skinParam);
}
this.url = entity.getUrl99();
}
private UStroke getStroke() {
UStroke stroke = getSkinParam().getThickness(LineParam.machineBorder, getStereo());
if (stroke == null) {
stroke = new UStroke(1.5);
}
return stroke;
}
private Dimension2D getTitleDimension(StringBounder stringBounder) {
return getNameAndSteretypeDimension(stringBounder);
}
private Dimension2D getNameAndSteretypeDimension(StringBounder stringBounder) {
final Dimension2D nameDim = name.calculateDimension(stringBounder);
final Dimension2D stereoDim = stereo == null ? new Dimension2DDouble(0, 0) : stereo
.calculateDimension(stringBounder);
final Dimension2D nameAndStereo = new Dimension2DDouble(Math.max(nameDim.getWidth(), stereoDim.getWidth()),
nameDim.getHeight() + stereoDim.getHeight());
return nameAndStereo;
}
public double getStartingX(StringBounder stringBounder, double y) {
return 0;
}
public double getEndingX(StringBounder stringBounder, double y) {
return calculateDimension(stringBounder).getWidth();
}
final public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final Dimension2D dimTotal = calculateDimension(stringBounder);
final Dimension2D dimTitle = getTitleDimension(stringBounder);
final double widthTotal = dimTotal.getWidth();
final double heightTotal = dimTotal.getHeight();
final URectangle rect = new URectangle(widthTotal, heightTotal, 0, 0);
URectangle rect2 = new URectangle(4, heightTotal, 0, 0);
ug = ug.apply(new UChangeColor(SkinParamUtils.getColor(getSkinParam(), ColorParam.machineBorder, getStereo())));
HtmlColor backcolor = getEntity().getColors(getSkinParam()).getColor(ColorType.BACK);
if (backcolor == null) {
backcolor = SkinParamUtils.getColor(getSkinParam(), ColorParam.machineBackground, getStereo());
}
ug = ug.apply(new UChangeBackColor(backcolor));
if (url != null) {
ug.startUrl(url);
}
final UStroke stroke = getStroke();
ug.apply(stroke).draw(rect);
ug.apply(new UTranslate(4, 0)).apply(stroke).draw(rect2);
final ULayoutGroup header = new ULayoutGroup(new PlacementStrategyY1Y2(ug.getStringBounder()));
header.add(name);
header.drawU(ug.apply(new UTranslate(5, 0)), dimTotal.getWidth(), dimTitle.getHeight());
if (url != null) {
ug.closeAction();
}
}
public ShapeType getShapeType() {
return ShapeType.RECTANGLE;
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
final Dimension2D dimTitle = getTitleDimension(stringBounder);
final double width = dimTitle.getWidth();
final double height = dimTitle.getHeight();
return new Dimension2DDouble(width + 10, height);
}
}

View File

@ -0,0 +1,203 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, 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: Yijun Yu
*
*
*/
package net.sourceforge.plantuml.descdiagram;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.creole.Stencil;
import net.sourceforge.plantuml.cucadiagram.BodyEnhanced;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
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.SkinParameter;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.svek.AbstractEntityImage;
import net.sourceforge.plantuml.svek.ShapeType;
import net.sourceforge.plantuml.ugraphic.AbstractUGraphicHorizontalLine;
import net.sourceforge.plantuml.ugraphic.TextBlockInEllipse;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UHorizontalLine;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class EntityImageRequirement extends AbstractEntityImage {
final private TextBlock desc;
final private Url url;
public EntityImageRequirement(ILeaf entity, ISkinParam skinParam) {
super(entity, skinParam);
final Stereotype stereotype = entity.getStereotype();
final TextBlock tmp = new BodyEnhanced(entity.getDisplay(), FontParam.USECASE, skinParam,
HorizontalAlignment.CENTER, stereotype, true, false, entity);
if (stereotype == null || stereotype.getLabel(false) == null) {
this.desc = tmp;
} else {
final TextBlock stereo = Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet()))
.create(new FontConfiguration(getSkinParam(), FontParam.USECASE_STEREOTYPE, stereotype),
HorizontalAlignment.CENTER, skinParam);
this.desc = TextBlockUtils.mergeTB(stereo, tmp, HorizontalAlignment.CENTER);
}
this.url = entity.getUrl99();
}
private UStroke getStroke() {
UStroke stroke = getSkinParam().getThickness(LineParam.usecaseBorder, getStereo());
if (stroke == null) {
stroke = new UStroke(7, 7, 1.5);
// stroke = new UStroke(1.5);
}
return stroke;
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return new TextBlockInEllipse(desc, stringBounder).calculateDimension(stringBounder);
}
final public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final TextBlockInEllipse ellipse = new TextBlockInEllipse(desc, stringBounder);
if (getSkinParam().shadowing2(SkinParameter.USECASE)) {
ellipse.setDeltaShadow(3);
}
if (url != null) {
ug.startUrl(url);
}
ug = ug.apply(getStroke());
HtmlColor linecolor = getEntity().getColors(getSkinParam()).getColor(ColorType.LINE);
if (linecolor == null) {
linecolor = SkinParamUtils.getColor(getSkinParam(), ColorParam.usecaseBorder, getStereo());
}
ug = ug.apply(new UChangeColor(linecolor));
HtmlColor backcolor = getEntity().getColors(getSkinParam()).getColor(ColorType.BACK);
if (backcolor == null) {
backcolor = SkinParamUtils.getColor(getSkinParam(), ColorParam.usecaseBackground, getStereo());
}
ug = ug.apply(new UChangeBackColor(backcolor));
final UGraphic ug2 = new MyUGraphicEllipse(ug, 0, 0, ellipse.getUEllipse());
ellipse.drawU(ug2);
if (url != null) {
ug.closeAction();
}
}
public ShapeType getShapeType() {
return ShapeType.OVAL;
}
static class MyUGraphicEllipse extends AbstractUGraphicHorizontalLine {
private final double startingX;
private final double yTheoricalPosition;
private final UEllipse ellipse;
@Override
protected AbstractUGraphicHorizontalLine copy(UGraphic ug) {
return new MyUGraphicEllipse(ug, startingX, yTheoricalPosition, ellipse);
}
MyUGraphicEllipse(UGraphic ug, double startingX, double yTheoricalPosition, UEllipse ellipse) {
super(ug);
this.startingX = startingX;
this.ellipse = ellipse;
this.yTheoricalPosition = yTheoricalPosition;
}
private double getNormalized(double y) {
if (y < yTheoricalPosition) {
throw new IllegalArgumentException();
}
y = y - yTheoricalPosition;
if (y > ellipse.getHeight()) {
throw new IllegalArgumentException();
}
return y;
}
private double getStartingXInternal(double y) {
return startingX + ellipse.getStartingX(getNormalized(y));
}
private double getEndingXInternal(double y) {
return startingX + ellipse.getEndingX(getNormalized(y));
}
private Stencil getStencil2(UTranslate translate) {
final double dy = translate.getDy();
return new Stencil() {
public double getStartingX(StringBounder stringBounder, double y) {
return getStartingXInternal(y + dy);
}
public double getEndingX(StringBounder stringBounder, double y) {
return getEndingXInternal(y + dy);
}
};
}
@Override
protected void drawHline(UGraphic ug, UHorizontalLine line, UTranslate translate) {
final UStroke stroke = new UStroke(1.5);
line.drawLineInternal(ug.apply(translate), getStencil2(translate), 0, stroke);
}
}
}

View File

@ -78,6 +78,10 @@ import net.sourceforge.plantuml.cucadiagram.dot.ExeState;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion;
import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood;
import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory;
import net.sourceforge.plantuml.descdiagram.EntityImageDesignedDomain;
import net.sourceforge.plantuml.descdiagram.EntityImageDomain;
import net.sourceforge.plantuml.descdiagram.EntityImageMachine;
import net.sourceforge.plantuml.descdiagram.EntityImageRequirement;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
@ -429,7 +433,28 @@ public final class DotDataImageBuilder {
if (leaf.getLeafType() == LeafType.TIPS) {
return new EntityImageTips(leaf, skinParam, bibliotekon);
}
throw new UnsupportedOperationException(leaf.getLeafType().toString());
// TODO Clean
if (leaf.getLeafType() == LeafType.DOMAIN && leaf.getStereotype() != null
&& leaf.getStereotype().isMachineOrSpecification()) {
return new EntityImageMachine(leaf, skinParam);
} else if (leaf.getLeafType() == LeafType.DOMAIN && leaf.getStereotype() != null
&& leaf.getStereotype().isDesignedOrSolved()) {
return new EntityImageDesignedDomain(leaf, skinParam);
} else if (leaf.getLeafType() == LeafType.REQUIREMENT) {
return new EntityImageRequirement(leaf, skinParam);
} else if (leaf.getLeafType() == LeafType.DOMAIN && leaf.getStereotype() != null
&& leaf.getStereotype().isLexicalOrGiven()) {
return new EntityImageDomain(leaf, skinParam, 'X');
} else if (leaf.getLeafType() == LeafType.DOMAIN && leaf.getStereotype() != null
&& leaf.getStereotype().isCausal()) {
return new EntityImageDomain(leaf, skinParam, 'C');
} else if (leaf.getLeafType() == LeafType.DOMAIN && leaf.getStereotype() != null
&& leaf.getStereotype().isBiddableOrUncertain()) {
return new EntityImageDomain(leaf, skinParam, 'B');
} else if (leaf.getLeafType() == LeafType.DOMAIN) {
return new EntityImageDomain(leaf, skinParam, 'P');
} else
throw new UnsupportedOperationException(leaf.getLeafType().toString());
}
private Collection<ILeaf> getUnpackagedEntities() {

View File

@ -75,7 +75,7 @@ public class Version {
}
public static int beta() {
final int beta = 0;
final int beta = 1;
return beta;
}