1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-01 16:10:48 +00:00
plantuml/src/net/sourceforge/plantuml/skin/rose/Rose.java

537 lines
26 KiB
Java
Raw Normal View History

2010-11-15 20:35:36 +00:00
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
2022-03-07 19:33:46 +00:00
* (C) Copyright 2009-2023, 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;
2015-11-01 18:37:20 +00:00
import net.sourceforge.plantuml.SkinParamUtils;
2020-12-01 21:39:27 +00:00
import net.sourceforge.plantuml.UseStyle;
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;
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;
2021-06-27 16:50:40 +00:00
import net.sourceforge.plantuml.sequencediagram.NotePosition;
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;
2022-03-01 18:11:51 +00:00
import net.sourceforge.plantuml.style.StyleSignatureBasic;
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;
2020-03-18 10:50:02 +00:00
import net.sourceforge.plantuml.ugraphic.color.HColor;
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
2020-03-18 10:50:02 +00:00
public HColor 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
2020-03-18 10:50:02 +00:00
public HColor getHtmlColor(ISkinParam skin, ColorParam color) {
2019-01-16 18:34:41 +00:00
return getHtmlColor(skin, null, color);
2011-01-05 18:23:06 +00:00
}
2020-03-18 10:50:02 +00:00
public HColor getHtmlColor(ISkinParam skin, Stereotype stereotype, ColorParam... colorParams) {
2019-01-16 18:34:41 +00:00
for (ColorParam param : colorParams) {
2020-03-18 10:50:02 +00:00
final HColor result = skin.getHtmlColor(param, stereotype, false);
2019-01-16 18:34:41 +00:00
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) {
2022-03-19 12:48:23 +00:00
return FontConfiguration.create(skinParam, fontParam, null);
2015-04-20 19:45:13 +00:00
}
2021-06-27 16:50:40 +00:00
public Component createComponentNote(Style[] styles, ComponentType type, ISkinParam param,
Display stringsToDisplay) {
checkRose();
return createComponentNote(styles, type, param, stringsToDisplay, null);
}
private void checkRose() {
// Quite ugly, but we want to ensure that TextSkin overrides those methods
if (this.getClass() != Rose.class)
throw new IllegalStateException("" + this.getClass());
}
public Component createComponentNote(Style[] styles, ComponentType type, ISkinParam param, Display stringsToDisplay,
NotePosition notePosition) {
checkRose();
final HorizontalAlignment textAlign;
final HorizontalAlignment position;
if (notePosition == NotePosition.OVER_SEVERAL) {
textAlign = param.getHorizontalAlignment(AlignmentParam.noteTextAlignment, null, false,
HorizontalAlignment.LEFT);
if (textAlign == param.getHorizontalAlignment(AlignmentParam.noteTextAlignment, null, false,
HorizontalAlignment.CENTER))
// Which means we use default
position = textAlign;
else
position = HorizontalAlignment.CENTER;
} else {
textAlign = param.getHorizontalAlignment(AlignmentParam.noteTextAlignment, null, false, null);
position = textAlign;
}
final Stereotype stereotype = stringsToDisplay == null ? null : stringsToDisplay.getStereotypeIfAny();
final double roundCorner = param.getRoundCorner(CornerParam.DEFAULT, null);
if (type == ComponentType.NOTE) {
return new ComponentRoseNote(styles == null ? null : styles[0],
getSymbolContext(stereotype, param, ColorParam.noteBorder), getUFont2(param, FontParam.NOTE),
stringsToDisplay, paddingX, paddingY, param, roundCorner, textAlign, position);
}
if (type == ComponentType.NOTE_HEXAGONAL) {
return new ComponentRoseNoteHexagonal(styles == null ? null : styles[0],
getSymbolContext(stereotype, param, ColorParam.noteBorder), getUFont2(param, FontParam.NOTE),
stringsToDisplay, param, textAlign);
}
if (type == ComponentType.NOTE_BOX) {
return new ComponentRoseNoteBox(styles == null ? null : styles[0],
getSymbolContext(stereotype, param, ColorParam.noteBorder), getUFont2(param, FontParam.NOTE),
stringsToDisplay, param, roundCorner, textAlign);
}
throw new UnsupportedOperationException(type.toString());
}
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) {
2021-06-27 16:50:40 +00:00
checkRose();
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
2020-03-18 10:50:02 +00:00
final Stereotype stereotype = stringsToDisplay == null ? null : stringsToDisplay.getStereotypeIfAny();
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);
2020-03-18 10:50:02 +00:00
final double diagonalCorner = param.getDiagonalCorner(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],
2020-03-18 10:50:02 +00:00
getSymbolContext(stereotype, param, ColorParam.participantBorder),
getUFont2(param, FontParam.PARTICIPANT), stringsToDisplay, param, roundCorner, diagonalCorner,
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],
2020-03-18 10:50:02 +00:00
getSymbolContext(stereotype, param, ColorParam.participantBorder),
getUFont2(param, FontParam.PARTICIPANT), stringsToDisplay, param, roundCorner, diagonalCorner,
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],
2020-03-18 10:50:02 +00:00
getSymbolContext(stereotype, param, ColorParam.collectionsBorder),
getUFont2(param, FontParam.PARTICIPANT), stringsToDisplay, param, roundCorner, diagonalCorner,
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],
2020-03-18 10:50:02 +00:00
getSymbolContext(stereotype, param, ColorParam.collectionsBorder),
getUFont2(param, FontParam.PARTICIPANT), stringsToDisplay, param, roundCorner, diagonalCorner,
newFontForStereotype, getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(),
true, padding);
2010-11-15 20:35:36 +00:00
}
if (type == ComponentType.PARTICIPANT_LINE) {
2020-03-18 10:50:02 +00:00
final HColor borderColor = getHtmlColor(param, stereotype, ColorParam.sequenceLifeLineBorder);
2021-05-06 21:23:05 +00:00
return new ComponentRoseLine(param.getThemeStyle(), styles == null ? null : styles[0], borderColor, false,
2020-03-18 10:50:02 +00:00
getStroke(param, LineParam.sequenceLifeLineBorder, 1), param.getIHtmlColorSet());
2011-01-23 19:36:52 +00:00
}
if (type == ComponentType.CONTINUE_LINE) {
2020-03-18 10:50:02 +00:00
final HColor borderColor = getHtmlColor(param, stereotype, ColorParam.sequenceLifeLineBorder);
2021-05-06 21:23:05 +00:00
return new ComponentRoseLine(param.getThemeStyle(), styles == null ? null : styles[0], borderColor, true,
2020-03-18 10:50:02 +00:00
getStroke(param, LineParam.sequenceLifeLineBorder, 1.5), param.getIHtmlColorSet());
2010-11-15 20:35:36 +00:00
}
if (type == ComponentType.ACTOR_HEAD) {
2020-06-21 20:31:45 +00:00
return new ComponentRoseActor(param.actorStyle(), styles == null ? null : styles[0],
2020-03-18 10:50:02 +00:00
styles == null ? null : styles[1], getSymbolContext(stereotype, 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) {
2020-06-21 20:31:45 +00:00
return new ComponentRoseActor(param.actorStyle(), styles == null ? null : styles[0],
2020-03-18 10:50:02 +00:00
styles == null ? null : styles[1], getSymbolContext(stereotype, param, ColorParam.actorBorder),
getUFont2(param, FontParam.ACTOR), stringsToDisplay, false, param, newFontForStereotype,
2019-12-10 21:45:49 +00:00
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],
2020-03-18 10:50:02 +00:00
getSymbolContext(stereotype, 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],
2020-03-18 10:50:02 +00:00
getSymbolContext(stereotype, 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],
2020-03-18 10:50:02 +00:00
getSymbolContext(stereotype, 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],
2020-03-18 10:50:02 +00:00
getSymbolContext(stereotype, 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],
2020-03-18 10:50:02 +00:00
getSymbolContext(stereotype, 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],
2020-03-18 10:50:02 +00:00
getSymbolContext(stereotype, 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],
2020-03-18 10:50:02 +00:00
getSymbolContext(stereotype, param, ColorParam.queueBorder), getUFont2(param, FontParam.QUEUE),
2019-07-14 20:09:26 +00:00
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],
2020-03-18 10:50:02 +00:00
getSymbolContext(stereotype, param, ColorParam.queueBorder), 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],
2020-03-18 10:50:02 +00:00
getSymbolContext(stereotype, 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],
2020-03-18 10:50:02 +00:00
getSymbolContext(stereotype, 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) {
2021-06-27 16:50:40 +00:00
throw new UnsupportedOperationException();
2010-11-15 20:35:36 +00:00
}
2011-09-07 20:41:58 +00:00
if (type == ComponentType.NOTE_HEXAGONAL) {
2021-06-27 16:50:40 +00:00
throw new UnsupportedOperationException();
2011-09-07 20:41:58 +00:00
}
if (type == ComponentType.NOTE_BOX) {
2021-06-27 16:50:40 +00:00
throw new UnsupportedOperationException();
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);
2020-03-18 10:50:02 +00:00
final HColor smallColor = SkinParamUtils.getFontColor(param, FontParam.SEQUENCE_GROUP, null);
2015-11-01 18:37:20 +00:00
if (smallColor != null) {
smallFont = smallFont.changeColor(smallColor);
}
2020-03-18 10:50:02 +00:00
return new ComponentRoseGroupingHeader(styles == null ? null : styles[0], styles == null ? null : styles[1],
param.getBackgroundColor(), getSymbolContext(stereotype, param, ColorParam.sequenceGroupBorder),
2020-03-18 10:50:02 +00:00
bigFont, smallFont, stringsToDisplay, param, roundCorner);
2010-11-15 20:35:36 +00:00
}
if (type == ComponentType.GROUPING_ELSE) {
2020-03-18 10:50:02 +00:00
return new ComponentRoseGroupingElse(styles == null ? null : styles[0],
getHtmlColor(param, stereotype, ColorParam.sequenceGroupBorder),
getUFont2(param, FontParam.SEQUENCE_GROUP), stringsToDisplay.get(0), param,
param.getBackgroundColor(), roundCorner);
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) {
2021-05-06 21:23:05 +00:00
return new ComponentRoseActiveLine(param.getThemeStyle(), styles == null ? null : styles[0],
2020-03-18 10:50:02 +00:00
getSymbolContext(stereotype, param, ColorParam.sequenceLifeLineBorder), true, true,
param.getIHtmlColorSet());
2011-01-29 15:09:35 +00:00
}
if (type == ComponentType.ALIVE_BOX_CLOSE_OPEN) {
2021-05-06 21:23:05 +00:00
return new ComponentRoseActiveLine(param.getThemeStyle(), styles == null ? null : styles[0],
2020-03-18 10:50:02 +00:00
getSymbolContext(stereotype, param, ColorParam.sequenceLifeLineBorder), true, false,
param.getIHtmlColorSet());
2011-01-29 15:09:35 +00:00
}
if (type == ComponentType.ALIVE_BOX_OPEN_CLOSE) {
2021-05-06 21:23:05 +00:00
return new ComponentRoseActiveLine(param.getThemeStyle(), styles == null ? null : styles[0],
2020-03-18 10:50:02 +00:00
getSymbolContext(stereotype, param, ColorParam.sequenceLifeLineBorder), false, true,
param.getIHtmlColorSet());
2011-01-29 15:09:35 +00:00
}
if (type == ComponentType.ALIVE_BOX_OPEN_OPEN) {
2021-05-06 21:23:05 +00:00
return new ComponentRoseActiveLine(param.getThemeStyle(), styles == null ? null : styles[0],
2020-03-18 10:50:02 +00:00
getSymbolContext(stereotype, 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) {
2020-03-18 10:50:02 +00:00
return new ComponentRoseDelayLine(null, getHtmlColor(param, stereotype, ColorParam.sequenceLifeLineBorder));
2011-01-12 19:06:53 +00:00
}
if (type == ComponentType.DELAY_TEXT) {
2020-03-18 10:50:02 +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) {
2022-02-12 17:27:51 +00:00
return new ComponentRoseDestroy(styles == null ? null : styles[0],
getHtmlColor(param, stereotype, ColorParam.sequenceLifeLineBorder), param);
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) {
2020-03-18 10:50:02 +00:00
return new ComponentRoseDivider(styles == null ? null : styles[0],
getUFont2(param, FontParam.SEQUENCE_DIVIDER),
getHtmlColor(param, stereotype, ColorParam.sequenceDividerBackground), stringsToDisplay, param,
deltaShadow(param, ColorParam.sequenceDividerBackground) > 0,
getStroke(param, LineParam.sequenceDividerBorder, 2),
getHtmlColor(param, stereotype, 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],
2020-03-18 10:50:02 +00:00
getUFont2(param, FontParam.SEQUENCE_REFERENCE),
getSymbolContext(stereotype, param, ColorParam.sequenceReferenceBorder), bigFont, stringsToDisplay,
2021-06-27 16:50:40 +00:00
param.getHorizontalAlignment(AlignmentParam.sequenceReferenceAlignment, null, false, null), param,
2020-03-18 10:50:02 +00:00
getHtmlColor(param, stereotype, ColorParam.sequenceReferenceBackground));
2016-11-04 21:39:29 +00:00
}
2010-11-15 20:35:36 +00:00
if (type == ComponentType.ENGLOBER) {
2020-03-18 10:50:02 +00:00
return new ComponentRoseEnglober(styles == null ? null : styles[0],
getSymbolContext(stereotype, 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
2021-06-27 16:50:40 +00:00
throw new UnsupportedOperationException();
2010-11-15 20:35:36 +00:00
}
2021-06-27 16:50:40 +00:00
public Component createComponentNewPage(ISkinParam param) {
checkRose();
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) {
2021-06-27 16:50:40 +00:00
checkRose();
2020-03-18 10:50:02 +00:00
final HColor sequenceArrow = config.getColor() == null ? getHtmlColor(param, ColorParam.arrow)
: config.getColor();
2019-03-01 22:16:29 +00:00
if (config.getArrowDirection() == ArrowDirection.SELF) {
2020-03-18 10:50:02 +00:00
return new ComponentRoseSelfArrow(styles == null ? null : styles[0], sequenceArrow,
getUFont2(param, FontParam.ARROW), stringsToDisplay, config, param, param.maxMessageSize(),
2019-07-14 20:09:26 +00:00
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();
2020-12-01 21:39:27 +00:00
if (UseStyle.useBetaStyle()) {
2022-03-01 18:11:51 +00:00
final StyleSignatureBasic signature = StyleSignatureBasic.of(SName.root, SName.element, SName.sequenceDiagram,
2019-09-14 18:12:04 +00:00
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,
2021-06-27 16:50:40 +00:00
arrowDirection, config.isReverseDefine(), null);
2019-09-14 18:12:04 +00:00
textHorizontalAlignment = param.getHorizontalAlignment(AlignmentParam.sequenceMessageTextAlignment,
2021-06-27 16:50:40 +00:00
config.getArrowDirection(), false, null);
2019-09-14 18:12:04 +00:00
}
2020-03-18 10:50:02 +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;
2019-11-03 17:40:03 +00:00
} else if (color == ColorParam.boundaryBorder) {
skinParameter = SkinParameter.BOUNDARY;
} else if (color == ColorParam.controlBorder) {
skinParameter = SkinParameter.CONTROL;
} else if (color == ColorParam.entityBorder) {
skinParameter = SkinParameter.ENTITY;
} else if (color == ColorParam.collectionsBorder) {
skinParameter = SkinParameter.COLLECTIONS;
} else if (color == ColorParam.databaseBorder) {
skinParameter = SkinParameter.DATABASE;
2019-03-29 22:14:07 +00:00
}
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
}
2020-03-18 10:50:02 +00:00
private SymbolContext getSymbolContext(Stereotype stereotype, ISkinParam skin, ColorParam color) {
2015-05-03 15:36:36 +00:00
if (color == ColorParam.participantBorder) {
2020-03-18 10:50:02 +00:00
return new SymbolContext(getHtmlColor(skin, stereotype, ColorParam.participantBackground),
getHtmlColor(skin, stereotype, 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) {
2020-03-18 10:50:02 +00:00
return new SymbolContext(getHtmlColor(skin, stereotype, ColorParam.actorBackground),
getHtmlColor(skin, stereotype, 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) {
2020-03-18 10:50:02 +00:00
return new SymbolContext(getHtmlColor(skin, stereotype, ColorParam.boundaryBackground),
getHtmlColor(skin, stereotype, ColorParam.boundaryBorder))
.withStroke(getStroke(skin, LineParam.sequenceActorBorder, 2))
.withDeltaShadow(deltaShadow(skin, color));
2016-11-04 21:39:29 +00:00
}
if (color == ColorParam.controlBorder) {
2020-03-18 10:50:02 +00:00
return new SymbolContext(getHtmlColor(skin, stereotype, ColorParam.controlBackground),
getHtmlColor(skin, stereotype, 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) {
2020-03-18 10:50:02 +00:00
return new SymbolContext(getHtmlColor(skin, stereotype, ColorParam.collectionsBackground),
getHtmlColor(skin, stereotype, ColorParam.collectionsBorder))
.withStroke(getStroke(skin, LineParam.sequenceActorBorder, 1.5))
.withDeltaShadow(deltaShadow(skin, color));
}
if (color == ColorParam.queueBorder) {
final double tmp = deltaShadow(skin, color);
return new SymbolContext(getHtmlColor(skin, stereotype, ColorParam.queueBackground),
getHtmlColor(skin, stereotype, ColorParam.queueBorder))
.withStroke(getStroke(skin, LineParam.queueBorder, 2)).withDeltaShadow(tmp);
2018-01-28 22:08:15 +00:00
}
2016-11-04 21:39:29 +00:00
if (color == ColorParam.entityBorder) {
2019-11-03 17:40:03 +00:00
final double tmp = deltaShadow(skin, color);
2020-03-18 10:50:02 +00:00
return new SymbolContext(getHtmlColor(skin, stereotype, ColorParam.entityBackground),
getHtmlColor(skin, stereotype, ColorParam.entityBorder))
.withStroke(getStroke(skin, LineParam.sequenceActorBorder, 2)).withDeltaShadow(tmp);
2016-11-04 21:39:29 +00:00
}
if (color == ColorParam.databaseBorder) {
2020-03-18 10:50:02 +00:00
return new SymbolContext(getHtmlColor(skin, stereotype, ColorParam.databaseBackground),
getHtmlColor(skin, stereotype, 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) {
2020-03-18 10:50:02 +00:00
return new SymbolContext(getHtmlColor(skin, stereotype, ColorParam.sequenceLifeLineBackground),
getHtmlColor(skin, stereotype, ColorParam.sequenceLifeLineBorder))
.withDeltaShadow(deltaShadow(skin, color));
2015-05-03 15:36:36 +00:00
}
if (color == ColorParam.noteBorder) {
2020-03-18 10:50:02 +00:00
return new SymbolContext(getHtmlColor(skin, stereotype, ColorParam.noteBackground),
getHtmlColor(skin, stereotype, ColorParam.noteBorder))
.withStroke(getStroke(skin, LineParam.noteBorder, 1))
.withDeltaShadow(deltaShadow(skin, color));
2015-05-03 15:36:36 +00:00
}
if (color == ColorParam.sequenceGroupBorder) {
2020-03-18 10:50:02 +00:00
return new SymbolContext(getHtmlColor(skin, stereotype, ColorParam.sequenceGroupBackground),
getHtmlColor(skin, stereotype, ColorParam.sequenceGroupBorder))
.withStroke(getStroke(skin, LineParam.sequenceGroupBorder, 2))
.withDeltaShadow(deltaShadow(skin, color));
2015-05-03 15:36:36 +00:00
}
if (color == ColorParam.sequenceBoxBorder) {
2020-03-18 10:50:02 +00:00
return new SymbolContext(getHtmlColor(skin, stereotype, ColorParam.sequenceBoxBackground),
getHtmlColor(skin, stereotype, ColorParam.sequenceBoxBorder));
2015-05-03 15:36:36 +00:00
}
if (color == ColorParam.sequenceReferenceBorder) {
2020-03-18 10:50:02 +00:00
return new SymbolContext(getHtmlColor(skin, stereotype, ColorParam.sequenceReferenceHeaderBackground),
getHtmlColor(skin, stereotype, 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
}