1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-05-28 22:20:49 +00:00
plantuml/src/net/sourceforge/plantuml/sequencediagram/Note.java

197 lines
5.1 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.sequencediagram;
2019-07-14 20:09:26 +00:00
import java.util.List;
2015-05-03 15:36:36 +00:00
import net.sourceforge.plantuml.ISkinParam;
2019-07-14 20:09:26 +00:00
import net.sourceforge.plantuml.SkinParam;
2010-11-15 20:35:36 +00:00
import net.sourceforge.plantuml.SpecificBackcolorable;
2011-04-19 16:50:40 +00:00
import net.sourceforge.plantuml.Url;
2013-12-10 19:36:50 +00:00
import net.sourceforge.plantuml.cucadiagram.Display;
2019-07-14 20:09:26 +00:00
import net.sourceforge.plantuml.cucadiagram.Stereotype;
2015-09-28 20:42:17 +00:00
import net.sourceforge.plantuml.graphic.color.Colors;
2019-07-14 20:09:26 +00:00
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleBuilder;
2019-08-26 17:07:21 +00:00
import net.sourceforge.plantuml.style.StyleSignature;
2019-07-14 20:09:26 +00:00
import net.sourceforge.plantuml.style.WithStyle;
2010-11-15 20:35:36 +00:00
2019-09-22 17:20:16 +00:00
final public class Note extends AbstractEvent implements Event, SpecificBackcolorable, WithStyle {
2010-11-15 20:35:36 +00:00
private final Participant p;
private final Participant p2;
2013-12-10 19:36:50 +00:00
private final Display strings;
2010-11-15 20:35:36 +00:00
2019-09-22 17:20:16 +00:00
private/* final */NotePosition position;
public void temporaryProtectedUntilTeozIsStandard() {
if (position == NotePosition.BOTTOM || position == NotePosition.TOP) {
position = NotePosition.LEFT;
}
}
2019-07-14 20:09:26 +00:00
private final StyleBuilder styleBuilder;
private NoteStyle noteStyle = NoteStyle.NORMAL;
2018-06-25 19:05:58 +00:00
private Colors colors = Colors.empty();
2015-11-01 18:37:20 +00:00
2017-03-12 17:22:02 +00:00
private Url url;
2011-04-19 16:50:40 +00:00
2019-07-14 20:09:26 +00:00
private Style style;
2019-08-26 17:07:21 +00:00
public StyleSignature getDefaultStyleDefinition() {
2019-07-14 20:09:26 +00:00
return noteStyle.getDefaultStyleDefinition();
}
public Style[] getUsedStyles() {
if (style != null) {
return new Style[] { style.eventuallyOverride(colors) };
}
return new Style[] { style };
2010-11-15 20:35:36 +00:00
}
2019-07-14 20:09:26 +00:00
public Note(Participant p, NotePosition position, Display strings, StyleBuilder styleBuilder) {
this(p, null, position, strings, styleBuilder);
2018-06-25 19:05:58 +00:00
}
2019-07-14 20:09:26 +00:00
public Note(Display strings, NotePosition position, NoteStyle style, StyleBuilder styleBuilder) {
this(null, null, position, strings, styleBuilder);
this.noteStyle = style;
2011-04-19 16:50:40 +00:00
}
2019-07-14 20:09:26 +00:00
public Note(Participant p, Participant p2, Display strings, StyleBuilder styleBuilder) {
this(p, p2, NotePosition.OVER_SEVERAL, strings, styleBuilder);
}
private Note(Participant p, Participant p2, NotePosition position, Display strings, StyleBuilder styleBuilder) {
2010-11-15 20:35:36 +00:00
this.p = p;
this.p2 = p2;
2019-07-14 20:09:26 +00:00
this.styleBuilder = styleBuilder;
2011-04-19 16:50:40 +00:00
this.position = position;
2017-03-12 17:22:02 +00:00
this.strings = strings;
2019-07-14 20:09:26 +00:00
if (SkinParam.USE_STYLES()) {
this.style = getDefaultStyleDefinition().getMergedStyle(styleBuilder);
}
}
public void setStereotype(Stereotype stereotype) {
if (SkinParam.USE_STYLES()) {
final List<Style> others = stereotype.getStyles(styleBuilder);
this.style = getDefaultStyleDefinition().mergeWith(others).getMergedStyle(styleBuilder);
}
2011-04-19 16:50:40 +00:00
}
2018-06-25 19:05:58 +00:00
public Note withPosition(NotePosition newPosition) {
if (position == newPosition) {
return this;
}
2019-07-14 20:09:26 +00:00
final Note result = new Note(p, p2, newPosition, strings, styleBuilder);
result.noteStyle = this.noteStyle;
2018-06-25 19:05:58 +00:00
result.url = this.url;
result.colors = this.colors;
2019-03-29 22:14:07 +00:00
result.parallel = this.parallel;
2018-06-25 19:05:58 +00:00
return result;
}
2010-11-15 20:35:36 +00:00
public Participant getParticipant() {
return p;
}
public Participant getParticipant2() {
return p2;
}
2013-12-10 19:36:50 +00:00
public Display getStrings() {
2010-11-15 20:35:36 +00:00
return strings;
}
public NotePosition getPosition() {
return position;
}
2019-07-14 20:09:26 +00:00
final public Colors getColors(ISkinParam skinParam) {
2015-09-28 20:42:17 +00:00
return colors;
}
2011-02-14 11:56:34 +00:00
2015-09-28 20:42:17 +00:00
public void setColors(Colors colors) {
this.colors = colors;
2010-11-15 20:35:36 +00:00
}
2011-02-14 11:56:34 +00:00
public boolean dealWith(Participant someone) {
return p == someone || p2 == someone;
}
2011-04-19 16:50:40 +00:00
public Url getUrl() {
return url;
}
2013-12-10 19:36:50 +00:00
public boolean hasUrl() {
return url != null;
}
2019-07-14 20:09:26 +00:00
public final NoteStyle getNoteStyle() {
return noteStyle;
2011-09-07 20:41:58 +00:00
}
2019-07-14 20:09:26 +00:00
public final void setNoteStyle(NoteStyle style) {
this.noteStyle = style;
2011-09-07 20:41:58 +00:00
}
2015-11-01 18:37:20 +00:00
public ISkinParam getSkinParamBackcolored(ISkinParam skinParam) {
return colors.mute(skinParam);
}
@Override
public String toString() {
return super.toString() + " " + strings;
2015-05-03 15:36:36 +00:00
}
2017-03-12 17:22:02 +00:00
public void setUrl(Url url) {
this.url = url;
}
2019-03-29 22:14:07 +00:00
private boolean parallel = false;
public void goParallel() {
this.parallel = true;
}
public boolean isParallel() {
return parallel;
}
2010-11-15 20:35:36 +00:00
}