plantuml/src/net/sourceforge/plantuml/skin/rose/Rose.java

450 lines
23 KiB
Java
Raw Normal View History

2010-11-15 20:35:36 +00:00
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
2019-01-16 18:34:41 +00:00
* (C) Copyright 2009-2020, Arnaud Roques
2010-11-15 20:35:36 +00:00
*
2016-03-06 16:47:34 +00:00
* Project Info: http://plantuml.com
2010-11-15 20:35:36 +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
*
2010-11-15 20:35:36 +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
2010-11-15 20:35:36 +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
*
*
*/
package net.sourceforge.plantuml.skin.rose;
2018-07-27 21:56:46 +00:00
import net.sourceforge.plantuml.AlignmentParam;
2010-11-15 20:35:36 +00:00
import net.sourceforge.plantuml.ColorParam;
2019-03-01 22:16:29 +00:00
import net.sourceforge.plantuml.CornerParam;
2010-11-15 20:35:36 +00:00
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.LineParam;
2017-02-26 16:26:11 +00:00
import net.sourceforge.plantuml.PaddingParam;
2019-09-14 18:12:04 +00:00
import net.sourceforge.plantuml.SkinParam;
2015-11-01 18:37:20 +00:00
import net.sourceforge.plantuml.SkinParamUtils;
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.Stereotype;
2015-05-03 15:36:36 +00:00
import net.sourceforge.plantuml.graphic.FontConfiguration;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
2010-11-15 20:35:36 +00:00
import net.sourceforge.plantuml.graphic.HtmlColor;
2019-03-29 22:14:07 +00:00
import net.sourceforge.plantuml.graphic.SkinParameter;
2015-05-03 15:36:36 +00:00
import net.sourceforge.plantuml.graphic.SymbolContext;
2019-04-21 20:40:01 +00:00
import net.sourceforge.plantuml.skin.ArrowComponent;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.skin.ArrowConfiguration;
import net.sourceforge.plantuml.skin.ArrowDirection;
2010-11-15 20:35:36 +00:00
import net.sourceforge.plantuml.skin.Component;
import net.sourceforge.plantuml.skin.ComponentType;
2019-09-14 18:12:04 +00:00
import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.SName;
2019-07-14 20:09:26 +00:00
import net.sourceforge.plantuml.style.Style;
2019-09-14 18:12:04 +00:00
import net.sourceforge.plantuml.style.StyleSignature;
2011-08-08 17:48:29 +00:00
import net.sourceforge.plantuml.ugraphic.UFont;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.ugraphic.UStroke;
2010-11-15 20:35:36 +00:00
2019-03-01 22:16:29 +00:00
public class Rose {
2010-11-15 20:35:36 +00:00
2013-12-10 19:36:50 +00:00
final private double paddingX = 5;
2019-09-22 17:20:16 +00:00
final public static double paddingY = 5;
2010-11-15 20:35:36 +00:00
2011-08-08 17:48:29 +00:00
public HtmlColor getFontColor(ISkinParam skin, FontParam fontParam) {
2016-01-09 12:15:40 +00:00
return skin.getFontHtmlColor(null, fontParam);
2010-11-15 20:35:36 +00:00
}
2011-01-11 07:42:49 +00:00
2019-01-16 18:34:41 +00:00
public HtmlColor getHtmlColor(ISkinParam skin, ColorParam color) {
return getHtmlColor(skin, null, color);
2011-01-05 18:23:06 +00:00
}
2019-01-16 18:34:41 +00:00
public HtmlColor getHtmlColor(ISkinParam skin, Stereotype stereotype, ColorParam... colorParams) {
for (ColorParam param : colorParams) {
final HtmlColor result = skin.getHtmlColor(param, stereotype, false);
if (result != null) {
return result;
}
2010-11-15 20:35:36 +00:00
}
2019-01-16 18:34:41 +00:00
return colorParams[0].getDefaultValue();
2010-11-15 20:35:36 +00:00
}
2015-09-28 20:42:17 +00:00
private FontConfiguration getUFont2(ISkinParam skinParam, FontParam fontParam) {
return new FontConfiguration(skinParam, fontParam, null);
2015-04-20 19:45:13 +00:00
}
2019-07-14 20:09:26 +00:00
public Component createComponent(Style[] styles, ComponentType type, ArrowConfiguration config, ISkinParam param,
2013-12-10 19:36:50 +00:00
Display stringsToDisplay) {
2016-01-09 12:15:40 +00:00
final UFont fontGrouping = param.getFont(null, false, FontParam.SEQUENCE_GROUP);
2010-11-15 20:35:36 +00:00
2016-01-09 12:15:40 +00:00
final UFont newFontForStereotype = param.getFont(null, false, FontParam.SEQUENCE_STEREOTYPE);
2010-11-15 20:35:36 +00:00
2011-01-11 07:42:49 +00:00
if (type.isArrow()) {
2019-07-14 20:09:26 +00:00
return createComponentArrow(null, config, param, stringsToDisplay);
2010-11-15 20:35:36 +00:00
}
2017-02-26 16:26:11 +00:00
final double padding = param.getPadding(PaddingParam.PARTICIPANT);
2018-04-06 20:36:30 +00:00
final double roundCorner = param.getRoundCorner(CornerParam.DEFAULT, null);
2010-11-15 20:35:36 +00:00
if (type == ComponentType.PARTICIPANT_HEAD) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseParticipant(styles == null ? null : styles[0], styles == null ? null : styles[1],
getSymbolContext(param, ColorParam.participantBorder), getUFont2(param, FontParam.PARTICIPANT),
stringsToDisplay, param, roundCorner, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), false, padding);
2010-11-15 20:35:36 +00:00
}
if (type == ComponentType.PARTICIPANT_TAIL) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseParticipant(styles == null ? null : styles[0], styles == null ? null : styles[1],
getSymbolContext(param, ColorParam.participantBorder), getUFont2(param, FontParam.PARTICIPANT),
stringsToDisplay, param, roundCorner, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), false, padding);
2016-06-19 14:16:41 +00:00
}
if (type == ComponentType.COLLECTIONS_HEAD) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseParticipant(styles == null ? null : styles[0], styles == null ? null : styles[1],
getSymbolContext(param, ColorParam.collectionsBorder), getUFont2(param, FontParam.PARTICIPANT),
stringsToDisplay, param, roundCorner, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), true, padding);
2016-06-19 14:16:41 +00:00
}
if (type == ComponentType.COLLECTIONS_TAIL) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseParticipant(styles == null ? null : styles[0], styles == null ? null : styles[1],
getSymbolContext(param, ColorParam.collectionsBorder), getUFont2(param, FontParam.PARTICIPANT),
stringsToDisplay, param, roundCorner, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), true, padding);
2010-11-15 20:35:36 +00:00
}
if (type == ComponentType.PARTICIPANT_LINE) {
2011-08-08 17:48:29 +00:00
final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder);
2019-07-14 20:09:26 +00:00
return new ComponentRoseLine(styles == null ? null : styles[0], borderColor, false, getStroke(param,
LineParam.sequenceLifeLineBorder, 1), param.getIHtmlColorSet());
2011-01-23 19:36:52 +00:00
}
if (type == ComponentType.CONTINUE_LINE) {
2011-08-08 17:48:29 +00:00
final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder);
2019-07-14 20:09:26 +00:00
return new ComponentRoseLine(styles == null ? null : styles[0], borderColor, true, getStroke(param,
LineParam.sequenceLifeLineBorder, 1.5), param.getIHtmlColorSet());
2010-11-15 20:35:36 +00:00
}
if (type == ComponentType.ACTOR_HEAD) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseActor(styles == null ? null : styles[0], styles == null ? null : styles[1],
getSymbolContext(param, ColorParam.actorBorder), getUFont2(param, FontParam.ACTOR),
stringsToDisplay, true, param, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE));
2010-11-15 20:35:36 +00:00
}
if (type == ComponentType.ACTOR_TAIL) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseActor(styles == null ? null : styles[0], styles == null ? null : styles[1],
getSymbolContext(param, ColorParam.actorBorder), getUFont2(param, FontParam.ACTOR),
stringsToDisplay, false, param, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE));
2013-12-10 19:36:50 +00:00
}
if (type == ComponentType.BOUNDARY_HEAD) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseBoundary(styles == null ? null : styles[0], styles == null ? null : styles[1],
getSymbolContext(param, ColorParam.boundaryBorder), getUFont2(param, FontParam.BOUNDARY),
stringsToDisplay, true, param, newFontForStereotype, getFontColor(param,
FontParam.BOUNDARY_STEREOTYPE));
2013-12-10 19:36:50 +00:00
}
if (type == ComponentType.BOUNDARY_TAIL) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseBoundary(styles == null ? null : styles[0], styles == null ? null : styles[1],
getSymbolContext(param, ColorParam.boundaryBorder), getUFont2(param, FontParam.BOUNDARY),
stringsToDisplay, false, param, newFontForStereotype, getFontColor(param,
FontParam.BOUNDARY_STEREOTYPE));
2013-12-10 19:36:50 +00:00
}
if (type == ComponentType.CONTROL_HEAD) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseControl(styles == null ? null : styles[0], styles == null ? null : styles[1],
getSymbolContext(param, ColorParam.controlBorder), getUFont2(param, FontParam.CONTROL),
stringsToDisplay, true, param, newFontForStereotype, getFontColor(param,
FontParam.CONTROL_STEREOTYPE));
2013-12-10 19:36:50 +00:00
}
if (type == ComponentType.CONTROL_TAIL) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseControl(styles == null ? null : styles[0], styles == null ? null : styles[1],
getSymbolContext(param, ColorParam.controlBorder), getUFont2(param, FontParam.CONTROL),
stringsToDisplay, false, param, newFontForStereotype, getFontColor(param,
FontParam.CONTROL_STEREOTYPE));
2013-12-10 19:36:50 +00:00
}
if (type == ComponentType.ENTITY_HEAD) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseEntity(styles == null ? null : styles[0], styles == null ? null : styles[1],
getSymbolContext(param, ColorParam.entityBorder), getUFont2(param, FontParam.ENTITY),
stringsToDisplay, true, param, newFontForStereotype, getFontColor(param,
FontParam.ENTITY_STEREOTYPE));
2013-12-10 19:36:50 +00:00
}
if (type == ComponentType.ENTITY_TAIL) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseEntity(styles == null ? null : styles[0], styles == null ? null : styles[1],
getSymbolContext(param, ColorParam.entityBorder), getUFont2(param, FontParam.ENTITY),
stringsToDisplay, false, param, newFontForStereotype, getFontColor(param,
FontParam.ENTITY_STEREOTYPE));
2013-12-10 19:36:50 +00:00
}
2017-06-05 11:27:21 +00:00
if (type == ComponentType.QUEUE_HEAD) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseQueue(styles == null ? null : styles[0], styles == null ? null : styles[1],
getSymbolContext(param, ColorParam.entityBorder), getUFont2(param, FontParam.QUEUE),
stringsToDisplay, true, param, newFontForStereotype,
getFontColor(param, FontParam.QUEUE_STEREOTYPE));
2017-06-05 11:27:21 +00:00
}
if (type == ComponentType.QUEUE_TAIL) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseQueue(styles == null ? null : styles[0], styles == null ? null : styles[1],
getSymbolContext(param, ColorParam.entityBorder), getUFont2(param, FontParam.QUEUE),
stringsToDisplay, false, param, newFontForStereotype, getFontColor(param,
FontParam.QUEUE_STEREOTYPE));
2017-06-05 11:27:21 +00:00
}
2013-12-10 19:36:50 +00:00
if (type == ComponentType.DATABASE_HEAD) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseDatabase(styles == null ? null : styles[0], styles == null ? null : styles[1],
getSymbolContext(param, ColorParam.databaseBorder), getUFont2(param, FontParam.DATABASE),
stringsToDisplay, true, param, newFontForStereotype, getFontColor(param,
FontParam.DATABASE_STEREOTYPE));
2013-12-10 19:36:50 +00:00
}
if (type == ComponentType.DATABASE_TAIL) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseDatabase(styles == null ? null : styles[0], styles == null ? null : styles[1],
getSymbolContext(param, ColorParam.databaseBorder), getUFont2(param, FontParam.DATABASE),
stringsToDisplay, false, param, newFontForStereotype, getFontColor(param,
FontParam.DATABASE_STEREOTYPE));
2010-11-15 20:35:36 +00:00
}
if (type == ComponentType.NOTE) {
2019-01-16 18:34:41 +00:00
final HorizontalAlignment alignment = param.getHorizontalAlignment(AlignmentParam.noteTextAlignment, null,
false);
2019-07-14 20:09:26 +00:00
return new ComponentRoseNote(styles == null ? null : styles[0], getSymbolContext(param,
ColorParam.noteBorder), getUFont2(param, FontParam.NOTE), stringsToDisplay, paddingX, paddingY,
param, roundCorner, alignment);
2010-11-15 20:35:36 +00:00
}
2011-09-07 20:41:58 +00:00
if (type == ComponentType.NOTE_HEXAGONAL) {
2019-01-16 18:34:41 +00:00
final HorizontalAlignment alignment = param.getHorizontalAlignment(AlignmentParam.noteTextAlignment, null,
false);
2019-07-14 20:09:26 +00:00
return new ComponentRoseNoteHexagonal(styles == null ? null : styles[0], getSymbolContext(param,
ColorParam.noteBorder), getUFont2(param, FontParam.NOTE), stringsToDisplay, param, alignment);
2011-09-07 20:41:58 +00:00
}
if (type == ComponentType.NOTE_BOX) {
2019-01-16 18:34:41 +00:00
final HorizontalAlignment alignment = param.getHorizontalAlignment(AlignmentParam.noteTextAlignment, null,
false);
2019-07-14 20:09:26 +00:00
return new ComponentRoseNoteBox(styles == null ? null : styles[0], getSymbolContext(param,
ColorParam.noteBorder), getUFont2(param, FontParam.NOTE), stringsToDisplay, param, roundCorner,
alignment);
2011-09-07 20:41:58 +00:00
}
2015-11-01 18:37:20 +00:00
final FontConfiguration bigFont = getUFont2(param, FontParam.SEQUENCE_GROUP_HEADER);
2010-11-15 20:35:36 +00:00
if (type == ComponentType.GROUPING_HEADER) {
2015-11-01 18:37:20 +00:00
FontConfiguration smallFont = bigFont.forceFont(fontGrouping, null);
final HtmlColor smallColor = SkinParamUtils.getFontColor(param, FontParam.SEQUENCE_GROUP, null);
if (smallColor != null) {
smallFont = smallFont.changeColor(smallColor);
}
2019-07-14 20:09:26 +00:00
return new ComponentRoseGroupingHeader(styles == null ? null : styles[0],
styles == null ? null : styles[1], param.getBackgroundColor(), getSymbolContext(param,
ColorParam.sequenceGroupBorder), bigFont, smallFont, stringsToDisplay, param, roundCorner);
2010-11-15 20:35:36 +00:00
}
if (type == ComponentType.GROUPING_ELSE) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseGroupingElse(styles == null ? null : styles[0], getHtmlColor(param,
ColorParam.sequenceGroupBorder), getUFont2(param, FontParam.SEQUENCE_GROUP),
stringsToDisplay.get(0), param, param.getBackgroundColor());
2013-12-10 19:36:50 +00:00
}
if (type == ComponentType.GROUPING_SPACE) {
return new ComponentRoseGroupingSpace(7);
2010-11-15 20:35:36 +00:00
}
2011-01-29 15:09:35 +00:00
if (type == ComponentType.ALIVE_BOX_CLOSE_CLOSE) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseActiveLine(styles == null ? null : styles[0], getSymbolContext(param,
ColorParam.sequenceLifeLineBorder), true, true, param.getIHtmlColorSet());
2011-01-29 15:09:35 +00:00
}
if (type == ComponentType.ALIVE_BOX_CLOSE_OPEN) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseActiveLine(styles == null ? null : styles[0], getSymbolContext(param,
ColorParam.sequenceLifeLineBorder), true, false, param.getIHtmlColorSet());
2011-01-29 15:09:35 +00:00
}
if (type == ComponentType.ALIVE_BOX_OPEN_CLOSE) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseActiveLine(styles == null ? null : styles[0], getSymbolContext(param,
ColorParam.sequenceLifeLineBorder), false, true, param.getIHtmlColorSet());
2011-01-29 15:09:35 +00:00
}
if (type == ComponentType.ALIVE_BOX_OPEN_OPEN) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseActiveLine(styles == null ? null : styles[0], getSymbolContext(param,
ColorParam.sequenceLifeLineBorder), false, false, param.getIHtmlColorSet());
2010-11-15 20:35:36 +00:00
}
2011-01-12 19:06:53 +00:00
if (type == ComponentType.DELAY_LINE) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseDelayLine(null, getHtmlColor(param, ColorParam.sequenceLifeLineBorder));
2011-01-12 19:06:53 +00:00
}
if (type == ComponentType.DELAY_TEXT) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseDelayText(styles == null ? null : styles[0], getUFont2(param,
FontParam.SEQUENCE_DELAY), stringsToDisplay, param);
2011-01-12 19:06:53 +00:00
}
2010-11-15 20:35:36 +00:00
if (type == ComponentType.DESTROY) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseDestroy(null, getHtmlColor(param, ColorParam.sequenceLifeLineBorder));
2010-11-15 20:35:36 +00:00
}
if (type == ComponentType.NEWPAGE) {
2019-04-21 20:40:01 +00:00
throw new UnsupportedOperationException();
2010-11-15 20:35:36 +00:00
}
if (type == ComponentType.DIVIDER) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseDivider(styles == null ? null : styles[0], getUFont2(param,
FontParam.SEQUENCE_DIVIDER), getHtmlColor(param, ColorParam.sequenceDividerBackground),
stringsToDisplay, param, deltaShadow(param, ColorParam.sequenceDividerBackground) > 0, getStroke(
param, LineParam.sequenceDividerBorder, 2), getHtmlColor(param,
ColorParam.sequenceDividerBorder));
2010-11-15 20:35:36 +00:00
}
2011-04-19 16:50:40 +00:00
if (type == ComponentType.REFERENCE) {
2019-08-26 17:07:21 +00:00
return new ComponentRoseReference(styles == null ? null : styles[0], styles == null ? null : styles[1],
getUFont2(param, FontParam.SEQUENCE_REFERENCE), getSymbolContext(param,
ColorParam.sequenceReferenceBorder), bigFont, stringsToDisplay,
param.getHorizontalAlignment(AlignmentParam.sequenceReferenceAlignment, null, false), param,
getHtmlColor(param, ColorParam.sequenceReferenceBackground));
2016-11-04 21:39:29 +00:00
}
2010-11-15 20:35:36 +00:00
if (type == ComponentType.ENGLOBER) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseEnglober(styles == null ? null : styles[0], getSymbolContext(param,
ColorParam.sequenceBoxBorder), stringsToDisplay, getUFont2(param, FontParam.SEQUENCE_BOX), param,
roundCorner);
2010-11-15 20:35:36 +00:00
}
2013-12-10 19:36:50 +00:00
2010-11-15 20:35:36 +00:00
return null;
}
2019-04-21 20:40:01 +00:00
public ComponentRoseNewpage createComponentNewPage(ISkinParam param) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseNewpage(null, getHtmlColor(param, ColorParam.sequenceNewpageSeparator));
2019-04-21 20:40:01 +00:00
}
2019-07-14 20:09:26 +00:00
public ArrowComponent createComponentArrow(Style[] styles, ArrowConfiguration config, ISkinParam param,
Display stringsToDisplay) {
2019-03-01 22:16:29 +00:00
final HtmlColor sequenceArrow = config.getColor() == null ? getHtmlColor(param, ColorParam.arrow) : config
.getColor();
if (config.getArrowDirection() == ArrowDirection.SELF) {
2019-07-14 20:09:26 +00:00
return new ComponentRoseSelfArrow(styles == null ? null : styles[0], sequenceArrow, getUFont2(param,
FontParam.ARROW), stringsToDisplay, config, param, param.maxMessageSize(),
param.strictUmlStyle() == false);
2019-03-01 22:16:29 +00:00
}
2019-09-14 18:12:04 +00:00
HorizontalAlignment messageHorizontalAlignment;
final HorizontalAlignment textHorizontalAlignment;
final ArrowDirection arrowDirection = config.getArrowDirection();
if (SkinParam.USE_STYLES()) {
final StyleSignature signature = StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram,
SName.arrow);
final Style textStyle = signature.getMergedStyle(param.getCurrentStyleBuilder());
final String value = textStyle.value(PName.HorizontalAlignment).asString();
messageHorizontalAlignment = textStyle.getHorizontalAlignment();
textHorizontalAlignment = textStyle.getHorizontalAlignment();
2019-09-22 17:20:16 +00:00
if ("first".equalsIgnoreCase(value)) {
final boolean isReverseDefine = config.isReverseDefine();
if (arrowDirection == ArrowDirection.RIGHT_TO_LEFT_REVERSE) {
if (isReverseDefine) {
messageHorizontalAlignment = HorizontalAlignment.LEFT;
} else {
messageHorizontalAlignment = HorizontalAlignment.RIGHT;
}
} else {
if (isReverseDefine) {
messageHorizontalAlignment = HorizontalAlignment.RIGHT;
} else {
messageHorizontalAlignment = HorizontalAlignment.LEFT;
}
}
} else if ("direction".equalsIgnoreCase(value)) {
2019-09-14 18:12:04 +00:00
if (arrowDirection == ArrowDirection.LEFT_TO_RIGHT_NORMAL) {
messageHorizontalAlignment = HorizontalAlignment.LEFT;
} else if (arrowDirection == ArrowDirection.RIGHT_TO_LEFT_REVERSE) {
messageHorizontalAlignment = HorizontalAlignment.RIGHT;
} else if (arrowDirection == ArrowDirection.BOTH_DIRECTION) {
messageHorizontalAlignment = HorizontalAlignment.CENTER;
}
} else if ("reversedirection".equalsIgnoreCase(value)) {
if (arrowDirection == ArrowDirection.LEFT_TO_RIGHT_NORMAL) {
messageHorizontalAlignment = HorizontalAlignment.RIGHT;
} else if (arrowDirection == ArrowDirection.RIGHT_TO_LEFT_REVERSE) {
messageHorizontalAlignment = HorizontalAlignment.LEFT;
} else if (arrowDirection == ArrowDirection.BOTH_DIRECTION) {
messageHorizontalAlignment = HorizontalAlignment.CENTER;
}
}
} else {
messageHorizontalAlignment = param.getHorizontalAlignment(AlignmentParam.sequenceMessageAlignment,
arrowDirection, config.isReverseDefine());
textHorizontalAlignment = param.getHorizontalAlignment(AlignmentParam.sequenceMessageTextAlignment,
config.getArrowDirection(), false);
}
2019-07-14 20:09:26 +00:00
return new ComponentRoseArrow(styles == null ? null : styles[0], sequenceArrow, getUFont2(param,
FontParam.ARROW), stringsToDisplay, config, messageHorizontalAlignment, param, textHorizontalAlignment,
param.maxMessageSize(), param.strictUmlStyle() == false, param.responseMessageBelowArrow());
2019-03-01 22:16:29 +00:00
}
2019-03-29 22:14:07 +00:00
private double deltaShadow(ISkinParam param, ColorParam color) {
SkinParameter skinParameter = null;
if (color == ColorParam.participantBorder) {
skinParameter = SkinParameter.PARTICIPANT;
} else if (color == ColorParam.actorBorder) {
skinParameter = SkinParameter.ACTOR;
}
final boolean result = skinParameter == null ? param.shadowing(null) : param.shadowing2(null, skinParameter);
return result ? 4.0 : 0;
2015-05-03 15:36:36 +00:00
}
2019-03-29 22:14:07 +00:00
private SymbolContext getSymbolContext(ISkinParam skin, ColorParam color) {
2015-05-03 15:36:36 +00:00
if (color == ColorParam.participantBorder) {
2019-03-29 22:14:07 +00:00
return new SymbolContext(getHtmlColor(skin, ColorParam.participantBackground), getHtmlColor(skin,
ColorParam.participantBorder))
.withStroke(getStroke(skin, LineParam.sequenceParticipantBorder, 1.5)).withDeltaShadow(
deltaShadow(skin, color));
2015-05-03 15:36:36 +00:00
}
if (color == ColorParam.actorBorder) {
2019-03-29 22:14:07 +00:00
return new SymbolContext(getHtmlColor(skin, ColorParam.actorBackground), getHtmlColor(skin,
ColorParam.actorBorder)).withStroke(getStroke(skin, LineParam.sequenceActorBorder, 2))
.withDeltaShadow(deltaShadow(skin, color));
2015-05-03 15:36:36 +00:00
}
2016-11-04 21:39:29 +00:00
if (color == ColorParam.boundaryBorder) {
2019-03-29 22:14:07 +00:00
return new SymbolContext(getHtmlColor(skin, ColorParam.boundaryBackground), getHtmlColor(skin,
ColorParam.boundaryBorder)).withStroke(getStroke(skin, LineParam.sequenceActorBorder, 2))
.withDeltaShadow(deltaShadow(skin, color));
2016-11-04 21:39:29 +00:00
}
if (color == ColorParam.controlBorder) {
2019-03-29 22:14:07 +00:00
return new SymbolContext(getHtmlColor(skin, ColorParam.controlBackground), getHtmlColor(skin,
ColorParam.controlBorder)).withStroke(getStroke(skin, LineParam.sequenceActorBorder, 2))
.withDeltaShadow(deltaShadow(skin, color));
2016-11-04 21:39:29 +00:00
}
2018-01-28 22:08:15 +00:00
if (color == ColorParam.collectionsBorder) {
2019-03-29 22:14:07 +00:00
return new SymbolContext(getHtmlColor(skin, ColorParam.collectionsBackground), getHtmlColor(skin,
ColorParam.collectionsBorder)).withStroke(getStroke(skin, LineParam.sequenceActorBorder, 1.5))
.withDeltaShadow(deltaShadow(skin, color));
2018-01-28 22:08:15 +00:00
}
2016-11-04 21:39:29 +00:00
if (color == ColorParam.entityBorder) {
2019-03-29 22:14:07 +00:00
return new SymbolContext(getHtmlColor(skin, ColorParam.entityBackground), getHtmlColor(skin,
ColorParam.entityBorder)).withStroke(getStroke(skin, LineParam.sequenceActorBorder, 2))
.withDeltaShadow(deltaShadow(skin, color));
2016-11-04 21:39:29 +00:00
}
if (color == ColorParam.databaseBorder) {
2019-03-29 22:14:07 +00:00
return new SymbolContext(getHtmlColor(skin, ColorParam.databaseBackground), getHtmlColor(skin,
ColorParam.databaseBorder)).withStroke(getStroke(skin, LineParam.sequenceActorBorder, 2))
.withDeltaShadow(deltaShadow(skin, color));
2016-11-04 21:39:29 +00:00
}
2015-05-03 15:36:36 +00:00
if (color == ColorParam.sequenceLifeLineBorder) {
2019-03-29 22:14:07 +00:00
return new SymbolContext(getHtmlColor(skin, ColorParam.sequenceLifeLineBackground), getHtmlColor(skin,
ColorParam.sequenceLifeLineBorder)).withDeltaShadow(deltaShadow(skin, color));
2015-05-03 15:36:36 +00:00
}
if (color == ColorParam.noteBorder) {
2019-03-29 22:14:07 +00:00
return new SymbolContext(getHtmlColor(skin, ColorParam.noteBackground), getHtmlColor(skin,
ColorParam.noteBorder)).withStroke(getStroke(skin, LineParam.noteBorder, 1)).withDeltaShadow(
deltaShadow(skin, color));
2015-05-03 15:36:36 +00:00
}
if (color == ColorParam.sequenceGroupBorder) {
2019-03-29 22:14:07 +00:00
return new SymbolContext(getHtmlColor(skin, ColorParam.sequenceGroupBackground), getHtmlColor(skin,
ColorParam.sequenceGroupBorder)).withStroke(getStroke(skin, LineParam.sequenceGroupBorder, 2))
.withDeltaShadow(deltaShadow(skin, color));
2015-05-03 15:36:36 +00:00
}
if (color == ColorParam.sequenceBoxBorder) {
2019-03-29 22:14:07 +00:00
return new SymbolContext(getHtmlColor(skin, ColorParam.sequenceBoxBackground), getHtmlColor(skin,
2015-05-03 15:36:36 +00:00
ColorParam.sequenceBoxBorder));
}
if (color == ColorParam.sequenceReferenceBorder) {
2019-03-29 22:14:07 +00:00
return new SymbolContext(getHtmlColor(skin, ColorParam.sequenceReferenceHeaderBackground), getHtmlColor(
skin, ColorParam.sequenceReferenceBorder)).withStroke(
getStroke(skin, LineParam.sequenceReferenceBorder, 2)).withDeltaShadow(deltaShadow(skin, color));
2015-05-03 15:36:36 +00:00
}
throw new IllegalArgumentException();
}
2013-12-10 19:36:50 +00:00
static public UStroke getStroke(ISkinParam param, LineParam lineParam, double defaultValue) {
2015-04-07 18:18:37 +00:00
final UStroke result = param.getThickness(lineParam, null);
2013-12-10 19:36:50 +00:00
if (result == null) {
return new UStroke(defaultValue);
}
return result;
}
2010-11-15 20:35:36 +00:00
}