1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-06-21 09:32:20 +00:00
plantuml/src/net/sourceforge/plantuml/skin/rose/Rose.java

297 lines
16 KiB
Java
Raw Normal View History

2010-11-15 20:35:36 +00:00
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009, Arnaud Roques
*
* Project Info: http://plantuml.sourceforge.net
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 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.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
2011-08-08 17:48:29 +00:00
* Revision $Revision: 6602 $
2010-11-15 20:35:36 +00:00
*
*/
package net.sourceforge.plantuml.skin.rose;
import java.util.Arrays;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
2011-08-08 17:48:29 +00:00
import net.sourceforge.plantuml.AlignParam;
2010-11-15 20:35:36 +00:00
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.skin.Component;
import net.sourceforge.plantuml.skin.ComponentType;
import net.sourceforge.plantuml.skin.Skin;
2011-08-08 17:48:29 +00:00
import net.sourceforge.plantuml.ugraphic.UFont;
2010-11-15 20:35:36 +00:00
public class Rose implements Skin {
private final Map<ColorParam, HtmlColor> defaultsColor = new EnumMap<ColorParam, HtmlColor>(ColorParam.class);
public Rose() {
2011-01-23 19:36:52 +00:00
defaultsColor.put(ColorParam.background, HtmlColor.getColorIfValid("white"));
defaultsColor.put(ColorParam.sequenceArrow, HtmlColor.getColorIfValid("#A80036"));
defaultsColor.put(ColorParam.usecaseArrow, HtmlColor.getColorIfValid("#A80036"));
defaultsColor.put(ColorParam.classArrow, HtmlColor.getColorIfValid("#A80036"));
defaultsColor.put(ColorParam.objectArrow, HtmlColor.getColorIfValid("#A80036"));
defaultsColor.put(ColorParam.activityArrow, HtmlColor.getColorIfValid("#A80036"));
defaultsColor.put(ColorParam.componentArrow, HtmlColor.getColorIfValid("#A80036"));
defaultsColor.put(ColorParam.stateArrow, HtmlColor.getColorIfValid("#A80036"));
defaultsColor.put(ColorParam.sequenceLifeLineBackground, HtmlColor.getColorIfValid("white"));
defaultsColor.put(ColorParam.sequenceLifeLineBorder, HtmlColor.getColorIfValid("#A80036"));
defaultsColor.put(ColorParam.sequenceGroupBackground, HtmlColor.getColorIfValid("#EEEEEE"));
2011-08-08 17:48:29 +00:00
defaultsColor.put(ColorParam.sequenceGroupBorder, HtmlColor.BLACK);
2011-01-23 19:36:52 +00:00
defaultsColor.put(ColorParam.sequenceDividerBackground, HtmlColor.getColorIfValid("#EEEEEE"));
2011-08-08 17:48:29 +00:00
defaultsColor.put(ColorParam.sequenceReferenceBorder, HtmlColor.BLACK);
defaultsColor.put(ColorParam.sequenceReferenceBackground, HtmlColor.getColorIfValid("white"));
defaultsColor.put(ColorParam.sequenceReferenceHeaderBackground, HtmlColor.getColorIfValid("#EEEEEE"));
2011-04-19 16:50:40 +00:00
defaultsColor.put(ColorParam.sequenceBoxBorder, HtmlColor.getColorIfValid("#A80036"));
defaultsColor.put(ColorParam.sequenceBoxBackground, HtmlColor.getColorIfValid("#DDDDDD"));
2011-01-23 19:36:52 +00:00
defaultsColor.put(ColorParam.noteBackground, HtmlColor.getColorIfValid("#FBFB77"));
defaultsColor.put(ColorParam.noteBorder, HtmlColor.getColorIfValid("#A80036"));
defaultsColor.put(ColorParam.activityBackground, HtmlColor.getColorIfValid("#FEFECE"));
defaultsColor.put(ColorParam.activityBorder, HtmlColor.getColorIfValid("#A80036"));
2011-08-08 17:48:29 +00:00
defaultsColor.put(ColorParam.activityStart, HtmlColor.BLACK);
defaultsColor.put(ColorParam.activityEnd, HtmlColor.BLACK);
defaultsColor.put(ColorParam.activityBar, HtmlColor.BLACK);
2011-01-23 19:36:52 +00:00
defaultsColor.put(ColorParam.stateBackground, HtmlColor.getColorIfValid("#FEFECE"));
defaultsColor.put(ColorParam.stateBorder, HtmlColor.getColorIfValid("#A80036"));
2011-08-08 17:48:29 +00:00
defaultsColor.put(ColorParam.stateStart, HtmlColor.BLACK);
defaultsColor.put(ColorParam.stateEnd, HtmlColor.BLACK);
2011-01-23 19:36:52 +00:00
defaultsColor.put(ColorParam.usecaseBackground, HtmlColor.getColorIfValid("#FEFECE"));
defaultsColor.put(ColorParam.usecaseBorder, HtmlColor.getColorIfValid("#A80036"));
defaultsColor.put(ColorParam.componentBackground, HtmlColor.getColorIfValid("#FEFECE"));
defaultsColor.put(ColorParam.componentBorder, HtmlColor.getColorIfValid("#A80036"));
defaultsColor.put(ColorParam.componentInterfaceBackground, HtmlColor.getColorIfValid("#FEFECE"));
defaultsColor.put(ColorParam.componentInterfaceBorder, HtmlColor.getColorIfValid("#A80036"));
defaultsColor.put(ColorParam.usecaseActorBackground, HtmlColor.getColorIfValid("#FEFECE"));
defaultsColor.put(ColorParam.usecaseActorBorder, HtmlColor.getColorIfValid("#A80036"));
defaultsColor.put(ColorParam.sequenceActorBackground, HtmlColor.getColorIfValid("#FEFECE"));
defaultsColor.put(ColorParam.sequenceActorBorder, HtmlColor.getColorIfValid("#A80036"));
defaultsColor.put(ColorParam.sequenceParticipantBackground, HtmlColor.getColorIfValid("#FEFECE"));
defaultsColor.put(ColorParam.sequenceParticipantBorder, HtmlColor.getColorIfValid("#A80036"));
defaultsColor.put(ColorParam.classBackground, HtmlColor.getColorIfValid("#FEFECE"));
defaultsColor.put(ColorParam.classBorder, HtmlColor.getColorIfValid("#A80036"));
defaultsColor.put(ColorParam.objectBackground, HtmlColor.getColorIfValid("#FEFECE"));
defaultsColor.put(ColorParam.objectBorder, HtmlColor.getColorIfValid("#A80036"));
defaultsColor.put(ColorParam.stereotypeCBackground, HtmlColor.getColorIfValid("#ADD1B2"));
defaultsColor.put(ColorParam.stereotypeABackground, HtmlColor.getColorIfValid("#A9DCDF"));
defaultsColor.put(ColorParam.stereotypeIBackground, HtmlColor.getColorIfValid("#B4A7E5"));
defaultsColor.put(ColorParam.stereotypeEBackground, HtmlColor.getColorIfValid("#EB937F"));
defaultsColor.put(ColorParam.packageBackground, HtmlColor.getColorIfValid("#FEFECE"));
2011-08-08 17:48:29 +00:00
defaultsColor.put(ColorParam.packageBorder, HtmlColor.BLACK);
2011-01-23 19:36:52 +00:00
defaultsColor.put(ColorParam.iconPrivate, HtmlColor.getColorIfValid("#C82930"));
defaultsColor.put(ColorParam.iconPrivateBackground, HtmlColor.getColorIfValid("#F24D5C"));
defaultsColor.put(ColorParam.iconProtected, HtmlColor.getColorIfValid("#B38D22"));
defaultsColor.put(ColorParam.iconProtectedBackground, HtmlColor.getColorIfValid("#FFFF44"));
defaultsColor.put(ColorParam.iconPackage, HtmlColor.getColorIfValid("#1963A0"));
defaultsColor.put(ColorParam.iconPackageBackground, HtmlColor.getColorIfValid("#4177AF"));
defaultsColor.put(ColorParam.iconPublic, HtmlColor.getColorIfValid("#038048"));
defaultsColor.put(ColorParam.iconPublicBackground, HtmlColor.getColorIfValid("#84BE84"));
2010-11-15 20:35:36 +00:00
}
2011-08-08 17:48:29 +00:00
public HtmlColor getFontColor(ISkinParam skin, FontParam fontParam) {
return skin.getFontHtmlColor(fontParam, null);
2010-11-15 20:35:36 +00:00
}
2011-01-11 07:42:49 +00:00
2010-11-15 20:35:36 +00:00
public HtmlColor getHtmlColor(ISkinParam param, ColorParam color) {
2011-01-05 18:23:06 +00:00
return getHtmlColor(param, color, null);
}
public HtmlColor getHtmlColor(ISkinParam param, ColorParam color, String stereotype) {
HtmlColor result = param.getHtmlColor(color, stereotype);
2010-11-15 20:35:36 +00:00
if (result == null) {
result = defaultsColor.get(color);
if (result == null) {
throw new IllegalArgumentException();
}
}
return result;
}
public Component createComponent(ComponentType type, ISkinParam param, List<? extends CharSequence> stringsToDisplay) {
2011-08-08 17:48:29 +00:00
final HtmlColor background = param.getBackgroundColor();
final HtmlColor groupBorder = getHtmlColor(param, ColorParam.sequenceGroupBorder);
final HtmlColor groupBackground = getHtmlColor(param, ColorParam.sequenceGroupBackground);
final HtmlColor sequenceDividerBackground = getHtmlColor(param, ColorParam.sequenceDividerBackground);
final HtmlColor sequenceReferenceBackground = getHtmlColor(param, ColorParam.sequenceReferenceBackground);
final HtmlColor sequenceReferenceHeaderBackground = getHtmlColor(param,
ColorParam.sequenceReferenceHeaderBackground);
final HtmlColor sequenceReferenceBorder = getHtmlColor(param, ColorParam.sequenceReferenceBorder);
final HtmlColor lifeLineBackgroundColor = getHtmlColor(param, ColorParam.sequenceLifeLineBackground);
final HtmlColor sequenceArrow = getHtmlColor(param, ColorParam.sequenceArrow);
final HtmlColor sequenceActorBackground = getHtmlColor(param, ColorParam.sequenceActorBackground);
final HtmlColor sequenceParticipantBackground = getHtmlColor(param, ColorParam.sequenceParticipantBackground);
2010-11-15 20:35:36 +00:00
// final Color borderColor = getHtmlColor(param,
// ColorParam.border).getColor();
2011-08-08 17:48:29 +00:00
final UFont fontArrow = param.getFont(FontParam.SEQUENCE_ARROW, null);
final UFont fontGrouping = param.getFont(FontParam.SEQUENCE_GROUP, null);
final UFont fontParticipant = param.getFont(FontParam.SEQUENCE_PARTICIPANT, null);
final UFont fontActor = param.getFont(FontParam.SEQUENCE_ACTOR, null);
2010-11-15 20:35:36 +00:00
2011-01-11 07:42:49 +00:00
if (type.isArrow()) {
if (type.getArrowConfiguration().isSelfArrow()) {
return new ComponentRoseSelfArrow(sequenceArrow, getFontColor(param, FontParam.SEQUENCE_ARROW),
fontArrow, stringsToDisplay, type.getArrowConfiguration());
}
2010-11-15 20:35:36 +00:00
return new ComponentRoseArrow(sequenceArrow, getFontColor(param, FontParam.SEQUENCE_ARROW), fontArrow,
2011-08-08 17:48:29 +00:00
stringsToDisplay, type.getArrowConfiguration(),
param.getHorizontalAlignement(AlignParam.SEQUENCE_MESSAGE_ALIGN));
2010-11-15 20:35:36 +00:00
}
if (type == ComponentType.PARTICIPANT_HEAD) {
2011-08-08 17:48:29 +00:00
final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceParticipantBorder);
2010-11-15 20:35:36 +00:00
return new ComponentRoseParticipant(sequenceParticipantBackground, borderColor, getFontColor(param,
FontParam.SEQUENCE_PARTICIPANT), fontParticipant, stringsToDisplay);
}
if (type == ComponentType.PARTICIPANT_TAIL) {
2011-08-08 17:48:29 +00:00
final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceParticipantBorder);
2010-11-15 20:35:36 +00:00
return new ComponentRoseParticipant(sequenceParticipantBackground, borderColor, getFontColor(param,
FontParam.SEQUENCE_PARTICIPANT), fontParticipant, stringsToDisplay);
}
if (type == ComponentType.PARTICIPANT_LINE) {
2011-08-08 17:48:29 +00:00
final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder);
2011-01-23 19:36:52 +00:00
return new ComponentRoseLine(borderColor, false);
}
if (type == ComponentType.CONTINUE_LINE) {
2011-08-08 17:48:29 +00:00
final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder);
2011-01-23 19:36:52 +00:00
return new ComponentRoseLine(borderColor, true);
2010-11-15 20:35:36 +00:00
}
if (type == ComponentType.ACTOR_HEAD) {
2011-08-08 17:48:29 +00:00
final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceActorBorder);
2010-11-15 20:35:36 +00:00
return new ComponentRoseActor(sequenceActorBackground, borderColor, getFontColor(param,
FontParam.SEQUENCE_ACTOR), fontActor, stringsToDisplay, true);
}
if (type == ComponentType.ACTOR_TAIL) {
2011-08-08 17:48:29 +00:00
final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceActorBorder);
2010-11-15 20:35:36 +00:00
return new ComponentRoseActor(sequenceActorBackground, borderColor, getFontColor(param,
FontParam.SEQUENCE_ACTOR), fontActor, stringsToDisplay, false);
}
if (type == ComponentType.NOTE) {
2011-08-08 17:48:29 +00:00
final HtmlColor noteBackgroundColor = getHtmlColor(param, ColorParam.noteBackground);
final HtmlColor borderColor = getHtmlColor(param, ColorParam.noteBorder);
final UFont fontNote = param.getFont(FontParam.NOTE, null);
2010-11-15 20:35:36 +00:00
return new ComponentRoseNote(noteBackgroundColor, borderColor, getFontColor(param, FontParam.NOTE),
fontNote, stringsToDisplay);
}
if (type == ComponentType.GROUPING_HEADER) {
2011-08-08 17:48:29 +00:00
final UFont fontGroupingHeader = param.getFont(FontParam.SEQUENCE_GROUP_HEADER, null);
2011-04-19 16:50:40 +00:00
return new ComponentRoseGroupingHeader(getFontColor(param, FontParam.SEQUENCE_GROUP_HEADER), background,
groupBackground, groupBorder, fontGroupingHeader, fontGrouping, stringsToDisplay);
2010-11-15 20:35:36 +00:00
}
if (type == ComponentType.GROUPING_BODY) {
2011-04-19 16:50:40 +00:00
return new ComponentRoseGroupingBody(background, groupBorder);
2010-11-15 20:35:36 +00:00
}
if (type == ComponentType.GROUPING_TAIL) {
2011-04-19 16:50:40 +00:00
return new ComponentRoseGroupingTail(getFontColor(param, FontParam.SEQUENCE_GROUP), groupBorder);
2010-11-15 20:35:36 +00:00
}
if (type == ComponentType.GROUPING_ELSE) {
2011-04-19 16:50:40 +00:00
return new ComponentRoseGroupingElse(getFontColor(param, FontParam.SEQUENCE_GROUP), groupBorder,
fontGrouping, stringsToDisplay.get(0));
2010-11-15 20:35:36 +00:00
}
2011-01-29 15:09:35 +00:00
if (type == ComponentType.ALIVE_BOX_CLOSE_CLOSE) {
2011-08-08 17:48:29 +00:00
final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder);
2011-01-29 15:09:35 +00:00
return new ComponentRoseActiveLine(borderColor, lifeLineBackgroundColor, true, true);
}
if (type == ComponentType.ALIVE_BOX_CLOSE_OPEN) {
2011-08-08 17:48:29 +00:00
final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder);
2011-01-29 15:09:35 +00:00
return new ComponentRoseActiveLine(borderColor, lifeLineBackgroundColor, true, false);
}
if (type == ComponentType.ALIVE_BOX_OPEN_CLOSE) {
2011-08-08 17:48:29 +00:00
final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder);
2011-01-29 15:09:35 +00:00
return new ComponentRoseActiveLine(borderColor, lifeLineBackgroundColor, false, true);
}
if (type == ComponentType.ALIVE_BOX_OPEN_OPEN) {
2011-08-08 17:48:29 +00:00
final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder);
2011-01-29 15:09:35 +00:00
return new ComponentRoseActiveLine(borderColor, lifeLineBackgroundColor, false, false);
2010-11-15 20:35:36 +00:00
}
2011-01-12 19:06:53 +00:00
if (type == ComponentType.DELAY_LINE) {
2011-08-08 17:48:29 +00:00
final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder);
2011-01-12 19:06:53 +00:00
return new ComponentRoseDelayLine(borderColor);
}
if (type == ComponentType.DELAY_TEXT) {
return new ComponentRoseDelayText(getFontColor(param, FontParam.SEQUENCE_DELAY), param.getFont(
FontParam.SEQUENCE_DELAY, null), stringsToDisplay);
}
2010-11-15 20:35:36 +00:00
if (type == ComponentType.DESTROY) {
2011-08-08 17:48:29 +00:00
final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder);
2010-11-15 20:35:36 +00:00
return new ComponentRoseDestroy(borderColor);
}
if (type == ComponentType.NEWPAGE) {
2011-04-19 16:50:40 +00:00
return new ComponentRoseNewpage(getFontColor(param, FontParam.SEQUENCE_GROUP));
2010-11-15 20:35:36 +00:00
}
if (type == ComponentType.DIVIDER) {
2011-01-11 07:42:49 +00:00
return new ComponentRoseDivider(getFontColor(param, FontParam.SEQUENCE_DIVIDER), param.getFont(
FontParam.SEQUENCE_DIVIDER, null), sequenceDividerBackground, stringsToDisplay);
2010-11-15 20:35:36 +00:00
}
2011-04-19 16:50:40 +00:00
if (type == ComponentType.REFERENCE) {
2011-08-08 17:48:29 +00:00
final HtmlColor sequenceReferenceBackground2 = getHtmlColor(param, ColorParam.sequenceReferenceBackground);
final HtmlColor sequenceReferenceHeaderBackground2 = getHtmlColor(param,
ColorParam.sequenceReferenceHeaderBackground);
final UFont fontGroupingHeader = param.getFont(FontParam.SEQUENCE_GROUP_HEADER, null);
return new ComponentRoseReference(getFontColor(param, FontParam.SEQUENCE_REFERENCE), getFontColor(param,
FontParam.SEQUENCE_GROUP), param.getFont(FontParam.SEQUENCE_REFERENCE, null),
sequenceReferenceBorder, sequenceReferenceHeaderBackground, sequenceReferenceBackground,
fontGroupingHeader, stringsToDisplay,
param.getHorizontalAlignement(AlignParam.SEQUENCE_REFERENCE_ALIGN));
2011-04-19 16:50:40 +00:00
}
2010-11-15 20:35:36 +00:00
if (type == ComponentType.TITLE) {
2011-01-11 07:42:49 +00:00
return new ComponentRoseTitle(getFontColor(param, FontParam.SEQUENCE_TITLE), param.getFont(
FontParam.SEQUENCE_TITLE, null), stringsToDisplay);
2010-11-15 20:35:36 +00:00
}
if (type == ComponentType.SIGNATURE) {
2011-08-08 17:48:29 +00:00
return new ComponentRoseTitle(HtmlColor.BLACK, fontGrouping, Arrays.asList("This skin was created ",
2010-11-15 20:35:36 +00:00
"in April 2009."));
}
if (type == ComponentType.ENGLOBER) {
2011-08-08 17:48:29 +00:00
final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceBoxBorder);
final HtmlColor backColor = getHtmlColor(param, ColorParam.sequenceBoxBackground);
2010-11-15 20:35:36 +00:00
return new ComponentRoseEnglober(borderColor, backColor, stringsToDisplay, getFontColor(param,
2011-04-19 16:50:40 +00:00
FontParam.SEQUENCE_BOX), param.getFont(FontParam.SEQUENCE_BOX, null));
2010-11-15 20:35:36 +00:00
}
return null;
}
public Object getProtocolVersion() {
return 1;
}
}