diff --git a/src/net/sourceforge/plantuml/asciiart/TextSkin.java b/src/net/sourceforge/plantuml/asciiart/TextSkin.java index 7432eb5d2..443dff23d 100644 --- a/src/net/sourceforge/plantuml/asciiart/TextSkin.java +++ b/src/net/sourceforge/plantuml/asciiart/TextSkin.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.asciiart; import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.skin.ArrowComponent; import net.sourceforge.plantuml.skin.ArrowConfiguration; @@ -61,104 +62,103 @@ public class TextSkin extends Rose { Display stringsToDisplay) { if (config.getArrowDirection() == ArrowDirection.LEFT_TO_RIGHT_NORMAL || config.getArrowDirection() == ArrowDirection.RIGHT_TO_LEFT_REVERSE - || config.getArrowDirection() == ArrowDirection.BOTH_DIRECTION) { + || config.getArrowDirection() == ArrowDirection.BOTH_DIRECTION) return new ComponentTextArrow(ComponentType.ARROW, config, stringsToDisplay, fileFormat, param.maxAsciiMessageLength()); - } - if (config.isSelfArrow()) { + + if (config.isSelfArrow()) return new ComponentTextSelfArrow(ComponentType.ARROW, config, stringsToDisplay, fileFormat); - } + throw new UnsupportedOperationException(); } @Override public Component createComponentNote(Style[] styles, ComponentType type, ISkinParam param, Display stringsToDisplay, - NotePosition notePosition) { - if (type == ComponentType.NOTE || type == ComponentType.NOTE_BOX) { + Colors colors, NotePosition notePosition) { + if (type == ComponentType.NOTE || type == ComponentType.NOTE_BOX) return new ComponentTextNote(type, stringsToDisplay, fileFormat); - } + throw new UnsupportedOperationException(type.toString()); } @Override - public Component createComponentNote(Style[] styles, ComponentType type, ISkinParam param, - Display stringsToDisplay) { - return createComponentNote(styles, type, param, stringsToDisplay, null); + public Component createComponentNote(Style[] styles, ComponentType type, ISkinParam param, Display stringsToDisplay, + Colors colors) { + return createComponentNote(styles, type, param, stringsToDisplay, colors, null); } @Override public Component createComponent(Style style[], ComponentType type, ArrowConfiguration config, ISkinParam param, Display stringsToDisplay) { - if (type == ComponentType.ACTOR_HEAD || type == ComponentType.ACTOR_TAIL) { + if (type == ComponentType.ACTOR_HEAD || type == ComponentType.ACTOR_TAIL) return new ComponentTextActor(type, stringsToDisplay, fileFormat, fileFormat == FileFormat.UTXT ? AsciiShape.STICKMAN_UNICODE : AsciiShape.STICKMAN); - } - if (type == ComponentType.BOUNDARY_HEAD || type == ComponentType.BOUNDARY_TAIL) { + + if (type == ComponentType.BOUNDARY_HEAD || type == ComponentType.BOUNDARY_TAIL) return new ComponentTextShape(type, stringsToDisplay, AsciiShape.BOUNDARY); - } - if (type == ComponentType.DATABASE_HEAD || type == ComponentType.DATABASE_TAIL) { + + if (type == ComponentType.DATABASE_HEAD || type == ComponentType.DATABASE_TAIL) return new ComponentTextShape(type, stringsToDisplay, AsciiShape.DATABASE); - } - if (type.name().endsWith("_HEAD") || type.name().endsWith("_TAIL")) { + + if (type.name().endsWith("_HEAD") || type.name().endsWith("_TAIL")) return new ComponentTextParticipant(type, stringsToDisplay, fileFormat); - } + if (type.isArrow() && (config.getArrowDirection() == ArrowDirection.LEFT_TO_RIGHT_NORMAL || config.getArrowDirection() == ArrowDirection.RIGHT_TO_LEFT_REVERSE - || config.getArrowDirection() == ArrowDirection.BOTH_DIRECTION)) { + || config.getArrowDirection() == ArrowDirection.BOTH_DIRECTION)) return new ComponentTextArrow(type, config, stringsToDisplay, fileFormat, param.maxAsciiMessageLength()); - } - if (type.isArrow() && config.isSelfArrow()) { + + if (type.isArrow() && config.isSelfArrow()) return new ComponentTextSelfArrow(type, config, stringsToDisplay, fileFormat); - } - if (type == ComponentType.PARTICIPANT_LINE) { + + if (type == ComponentType.PARTICIPANT_LINE) return new ComponentTextLine(type, fileFormat); - } - if (type == ComponentType.CONTINUE_LINE) { + + if (type == ComponentType.CONTINUE_LINE) return new ComponentTextLine(type, fileFormat); - } - if (type == ComponentType.DELAY_LINE) { + + if (type == ComponentType.DELAY_LINE) return new ComponentTextLine(type, fileFormat); - } - if (type == ComponentType.ALIVE_BOX_CLOSE_CLOSE) { + + if (type == ComponentType.ALIVE_BOX_CLOSE_CLOSE) return new ComponentTextActiveLine(fileFormat); - } - if (type == ComponentType.ALIVE_BOX_CLOSE_OPEN) { + + if (type == ComponentType.ALIVE_BOX_CLOSE_OPEN) return new ComponentTextActiveLine(fileFormat); - } - if (type == ComponentType.ALIVE_BOX_OPEN_CLOSE) { + + if (type == ComponentType.ALIVE_BOX_OPEN_CLOSE) return new ComponentTextActiveLine(fileFormat); - } - if (type == ComponentType.ALIVE_BOX_OPEN_OPEN) { + + if (type == ComponentType.ALIVE_BOX_OPEN_OPEN) return new ComponentTextActiveLine(fileFormat); - } - if (type == ComponentType.DIVIDER) { + + if (type == ComponentType.DIVIDER) return new ComponentTextDivider(type, stringsToDisplay, fileFormat); - } - if (type == ComponentType.GROUPING_HEADER) { + + if (type == ComponentType.GROUPING_HEADER) return new ComponentTextGroupingHeader(type, stringsToDisplay, fileFormat); - } - if (type == ComponentType.GROUPING_SPACE) { + + if (type == ComponentType.GROUPING_SPACE) return new ComponentRoseGroupingSpace(1); - } - if (type == ComponentType.GROUPING_ELSE) { + + if (type == ComponentType.GROUPING_ELSE) return new ComponentTextGroupingElse(type, stringsToDisplay, fileFormat); - } - if (type == ComponentType.DELAY_TEXT) { + + if (type == ComponentType.DELAY_TEXT) return new ComponentTextDelay(type, stringsToDisplay, fileFormat); - } - if (type == ComponentType.DESTROY) { + + if (type == ComponentType.DESTROY) return new ComponentTextDestroy(); - } - if (type == ComponentType.REFERENCE) { + + if (type == ComponentType.REFERENCE) return new ComponentTextReference(stringsToDisplay, fileFormat); - } + throw new UnsupportedOperationException(type.toString()); } - + @Override public Component createComponentNewPage(ISkinParam param) { return new ComponentTextNewpage(fileFormat); } - } diff --git a/src/net/sourceforge/plantuml/eggs/PSystemWelcome.java b/src/net/sourceforge/plantuml/eggs/PSystemWelcome.java index 91e2663e2..e298035d0 100644 --- a/src/net/sourceforge/plantuml/eggs/PSystemWelcome.java +++ b/src/net/sourceforge/plantuml/eggs/PSystemWelcome.java @@ -69,7 +69,6 @@ public class PSystemWelcome extends PlainDiagram { strings.add(" "); strings.add("You will find more information about PlantUML syntax on https://plantuml.com"); strings.add(" "); - strings.add("(If you use this software, you accept its license)"); strings.add("(Details by typing \"\"license\"\" keyword)"); strings.add(" "); if (position == GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT) { diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java index 4d47fc274..10aa1097f 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java @@ -39,7 +39,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; -import net.sourceforge.plantuml.AlignmentParam; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.OptionFlags; @@ -47,7 +46,6 @@ import net.sourceforge.plantuml.PaddingParam; import net.sourceforge.plantuml.SkinParamBackcolored; import net.sourceforge.plantuml.SkinParamBackcoloredReference; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.sequencediagram.AbstractMessage; import net.sourceforge.plantuml.sequencediagram.Delay; @@ -65,7 +63,6 @@ import net.sourceforge.plantuml.sequencediagram.Message; import net.sourceforge.plantuml.sequencediagram.MessageExo; import net.sourceforge.plantuml.sequencediagram.Newpage; import net.sourceforge.plantuml.sequencediagram.Note; -import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.Notes; import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.ParticipantEnglober; @@ -409,7 +406,8 @@ class DrawableSetInitializer { for (Note noteOnMessage : m.getNoteOnMessages()) { final ISkinParam sk = noteOnMessage.getSkinParamBackcolored(drawableSet.getSkinParam()); final Component note = drawableSet.getSkin().createComponentNote(noteOnMessage.getUsedStyles(), - noteOnMessage.getNoteStyle().getNoteComponentType(), sk, noteOnMessage.getStrings()); + noteOnMessage.getNoteStyle().getNoteComponentType(), sk, noteOnMessage.getStrings(), + noteOnMessage.getColors()); notes.add(note); } if (m.isParallel()) @@ -467,7 +465,7 @@ class DrawableSetInitializer { } final Component component = drawableSet.getSkin().createComponentNote(n.getUsedStyles(), type, skinParam, - n.getStrings(), n.getPosition()); + n.getStrings(), n.getColors(), n.getPosition()); final NoteBox noteBox = new NoteBox(freeY2.getFreeY(range), component, p1, p2, n.getPosition(), n.getUrl()); return noteBox; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java index 34b188d52..210b6c277 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java @@ -85,8 +85,10 @@ class Step1Message extends Step1Abstract { final List noteOnMessages = message.getNoteOnMessages(); for (Note noteOnMessage : noteOnMessages) { final ISkinParam skinParam = noteOnMessage.getSkinParamBackcolored(drawingSet.getSkinParam()); - addNote(drawingSet.getSkin().createComponentNote(noteOnMessage.getUsedStyles(), - noteOnMessage.getNoteStyle().getNoteComponentType(), skinParam, noteOnMessage.getStrings())); + final Component note = drawingSet.getSkin().createComponentNote(noteOnMessage.getUsedStyles(), + noteOnMessage.getNoteStyle().getNoteComponentType(), skinParam, noteOnMessage.getStrings(), + noteOnMessage.getColors()); + addNote(note); } } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java index 56a7e1f4c..66c86769e 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java @@ -68,8 +68,9 @@ class Step1MessageExo extends Step1Abstract { final List noteOnMessages = message.getNoteOnMessages(); for (Note noteOnMessage : noteOnMessages) { final ISkinParam skinParam = noteOnMessage.getSkinParamBackcolored(drawingSet.getSkinParam()); - addNote(drawingSet.getSkin().createComponentNote(noteOnMessage.getUsedStyles(), ComponentType.NOTE, skinParam, - noteOnMessage.getStrings())); + final Component note = drawingSet.getSkin().createComponentNote(noteOnMessage.getUsedStyles(), + ComponentType.NOTE, skinParam, noteOnMessage.getStrings(), noteOnMessage.getColors()); + addNote(note); } } @@ -132,11 +133,11 @@ class Step1MessageExo extends Step1Abstract { final MessageExoType type = m.getType(); ArrowConfiguration result = null; - if (type.getDirection() == 1) + if (type.getDirection() == 1) result = m.getArrowConfiguration(); - else + else result = m.getArrowConfiguration().reverse(); - + // result = result.withDecoration1(m.getArrowConfiguration().getDecoration1()); // result = result.withDecoration2(m.getArrowConfiguration().getDecoration2()); return result; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteBottomTopAbstract.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteBottomTopAbstract.java index 6d44f72f5..f42c865cf 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteBottomTopAbstract.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteBottomTopAbstract.java @@ -92,7 +92,7 @@ public abstract class CommunicationTileNoteBottomTopAbstract extends AbstractTil final protected Component getComponent(StringBounder stringBounder) { final Component comp = skin.createComponentNote(noteOnMessage.getUsedStyles(), ComponentType.NOTE, - noteOnMessage.getSkinParamBackcolored(skinParam), noteOnMessage.getStrings()); + noteOnMessage.getSkinParamBackcolored(skinParam), noteOnMessage.getStrings(), noteOnMessage.getColors()); return comp; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java index 38728cd9c..287dcba75 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java @@ -35,9 +35,8 @@ */ package net.sourceforge.plantuml.sequencediagram.teoz; -import net.sourceforge.plantuml.awt.geom.Dimension2D; - import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.awt.geom.Dimension2D; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.real.Real; @@ -87,8 +86,8 @@ public class CommunicationTileNoteLeft extends AbstractTile { } private Component getComponent(StringBounder stringBounder) { - final Component comp = skin.createComponentNote(noteOnMessage.getUsedStyles(), ComponentType.NOTE, noteOnMessage.getSkinParamBackcolored(skinParam), - noteOnMessage.getStrings()); + final Component comp = skin.createComponentNote(noteOnMessage.getUsedStyles(), ComponentType.NOTE, + noteOnMessage.getSkinParamBackcolored(skinParam), noteOnMessage.getStrings(), noteOnMessage.getColors()); return comp; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java index 508dc50ef..6e56f1026 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java @@ -91,8 +91,9 @@ public class CommunicationTileNoteRight extends AbstractTile { } private Component getComponent(StringBounder stringBounder) { - final Component comp = skin.createComponentNote(noteOnMessage.getUsedStyles(), ComponentType.NOTE, noteOnMessage.getSkinParamBackcolored(skinParam), - noteOnMessage.getStrings()); + final Component comp = skin.createComponentNote(noteOnMessage.getUsedStyles(), ComponentType.NOTE, + noteOnMessage.getSkinParamBackcolored(skinParam), noteOnMessage.getStrings(), + noteOnMessage.getColors()); return comp; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.java index 686dc2742..400115e90 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.java @@ -85,7 +85,8 @@ public class CommunicationTileSelfNoteRight extends AbstractTile { private Component getComponent(StringBounder stringBounder) { final Component comp = skin.createComponentNote(noteOnMessage.getUsedStyles(), ComponentType.NOTE, - noteOnMessage.getSkinParamBackcolored(skinParam), noteOnMessage.getStrings()); + noteOnMessage.getSkinParamBackcolored(skinParam), noteOnMessage.getStrings(), + noteOnMessage.getColors()); return comp; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java index 60e0dd244..e1643f168 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java @@ -82,7 +82,7 @@ public class NoteTile extends AbstractTile implements Tile { private Component getComponent(StringBounder stringBounder) { final Component comp = skin.createComponentNote(note.getUsedStyles(), getNoteComponentType(note.getNoteStyle()), - note.getSkinParamBackcolored(skinParam), note.getStrings(), note.getPosition()); + note.getSkinParamBackcolored(skinParam), note.getStrings(), note.getColors(), note.getPosition()); return comp; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/NotesTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/NotesTile.java index 3039dbe67..e8975f0c5 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/NotesTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/NotesTile.java @@ -78,7 +78,7 @@ public class NotesTile extends AbstractTile implements Tile { private Component getComponent(StringBounder stringBounder, Note note) { final Component comp = skin.createComponentNote(note.getUsedStyles(), getNoteComponentType(note.getNoteStyle()), - note.getSkinParamBackcolored(skinParam), note.getStrings(), note.getPosition()); + note.getSkinParamBackcolored(skinParam), note.getStrings(), note.getColors(), note.getPosition()); return comp; } diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNote.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNote.java index 2df47d511..d0f6aa6f3 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNote.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNote.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.SymbolContext; +import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.skin.AbstractTextualComponent; import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.style.PName; @@ -61,13 +62,14 @@ final public class ComponentRoseNote extends AbstractTextualComponent implements private final HorizontalAlignment position; public ComponentRoseNote(Style style, Display strings, double paddingX, double paddingY, - ISkinSimple spriteContainer, HorizontalAlignment textAlignment, HorizontalAlignment position) { - super(style, spriteContainer.wrapWidth(), textAlignment == HorizontalAlignment.CENTER ? 15 : 6, 15, 5, spriteContainer, - strings, true); + ISkinSimple spriteContainer, HorizontalAlignment textAlignment, HorizontalAlignment position, + Colors colors) { + super(style, spriteContainer.wrapWidth(), textAlignment == HorizontalAlignment.CENTER ? 15 : 6, 15, 5, + spriteContainer, strings, true); this.paddingX = paddingX; this.paddingY = paddingY; this.position = position; - this.symbolContext = style.getSymbolContext(spriteContainer.getThemeStyle(), getIHtmlColorSet()); + this.symbolContext = style.getSymbolContext(spriteContainer.getThemeStyle(), getIHtmlColorSet(), colors); this.roundCorner = style.value(PName.RoundCorner).asInt(); } diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteBox.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteBox.java index 40c5fda36..5ddf85a30 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteBox.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteBox.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.SymbolContext; +import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.skin.AbstractTextualComponent; import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.style.PName; @@ -53,10 +54,10 @@ final public class ComponentRoseNoteBox extends AbstractTextualComponent { private final SymbolContext symbolContext; private final double roundCorner; - public ComponentRoseNoteBox(Style style, Display strings, ISkinSimple spriteContainer) { + public ComponentRoseNoteBox(Style style, Display strings, ISkinSimple spriteContainer, Colors colors) { super(style, spriteContainer.wrapWidth(), 4, 4, 4, spriteContainer, strings, false); - this.symbolContext = style.getSymbolContext(spriteContainer.getThemeStyle(), getIHtmlColorSet()); + this.symbolContext = style.getSymbolContext(spriteContainer.getThemeStyle(), getIHtmlColorSet(), colors); this.roundCorner = style.value(PName.RoundCorner).asInt(); } diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteHexagonal.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteHexagonal.java index df2e2caa5..cd62c9186 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteHexagonal.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseNoteHexagonal.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.SymbolContext; +import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.skin.AbstractTextualComponent; import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.style.Style; @@ -52,10 +53,10 @@ final public class ComponentRoseNoteHexagonal extends AbstractTextualComponent { private final int cornersize = 10; private final SymbolContext symbolContext; - public ComponentRoseNoteHexagonal(Style style, Display strings, ISkinSimple spriteContainer) { + public ComponentRoseNoteHexagonal(Style style, Display strings, ISkinSimple spriteContainer, Colors colors) { super(style, spriteContainer.wrapWidth(), 12, 12, 4, spriteContainer, strings, false); - this.symbolContext = style.getSymbolContext(spriteContainer.getThemeStyle(), getIHtmlColorSet()); + this.symbolContext = style.getSymbolContext(spriteContainer.getThemeStyle(), getIHtmlColorSet(), colors); } diff --git a/src/net/sourceforge/plantuml/skin/rose/Rose.java b/src/net/sourceforge/plantuml/skin/rose/Rose.java index d0ff9038d..75c632a8f 100644 --- a/src/net/sourceforge/plantuml/skin/rose/Rose.java +++ b/src/net/sourceforge/plantuml/skin/rose/Rose.java @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.PaddingParam; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.skin.ArrowComponent; import net.sourceforge.plantuml.skin.ArrowConfiguration; @@ -75,12 +76,6 @@ public class Rose { return colorParams[0].getDefaultValue(); } - 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) @@ -89,7 +84,13 @@ public class Rose { } public Component createComponentNote(Style[] styles, ComponentType type, ISkinParam param, Display stringsToDisplay, - NotePosition notePosition) { + Colors colors) { + checkRose(); + return createComponentNote(styles, type, param, stringsToDisplay, colors, null); + } + + public Component createComponentNote(Style[] styles, ComponentType type, ISkinParam param, Display stringsToDisplay, + Colors colors, NotePosition notePosition) { checkRose(); final HorizontalAlignment textAlign; final HorizontalAlignment position; @@ -109,13 +110,13 @@ public class Rose { if (type == ComponentType.NOTE) return new ComponentRoseNote(styles == null ? null : styles[0], stringsToDisplay, paddingX, paddingY, param, - textAlign, position); + textAlign, position, colors); if (type == ComponentType.NOTE_HEXAGONAL) - return new ComponentRoseNoteHexagonal(styles == null ? null : styles[0], stringsToDisplay, param); + return new ComponentRoseNoteHexagonal(styles == null ? null : styles[0], stringsToDisplay, param, colors); if (type == ComponentType.NOTE_BOX) - return new ComponentRoseNoteBox(styles == null ? null : styles[0], stringsToDisplay, param); + return new ComponentRoseNoteBox(styles == null ? null : styles[0], stringsToDisplay, param, colors); throw new UnsupportedOperationException(type.toString()); } diff --git a/src/net/sourceforge/plantuml/style/Style.java b/src/net/sourceforge/plantuml/style/Style.java index 3afd6195b..a280e7c4e 100644 --- a/src/net/sourceforge/plantuml/style/Style.java +++ b/src/net/sourceforge/plantuml/style/Style.java @@ -200,13 +200,21 @@ public class Style { return FontConfiguration.create(font, color, hyperlinkColor, true); } - public SymbolContext getSymbolContext(ThemeStyle themeStyle, HColorSet set) { - final HColor backColor = value(PName.BackGroundColor).asColor(themeStyle, set); - final HColor foreColor = value(PName.LineColor).asColor(themeStyle, set); + public SymbolContext getSymbolContext(ThemeStyle themeStyle, HColorSet set, Colors colors) { + HColor backColor = colors == null ? null : colors.getColor(ColorType.BACK); + if (backColor == null) + backColor = value(PName.BackGroundColor).asColor(themeStyle, set); + HColor foreColor = colors == null ? null : colors.getColor(ColorType.LINE); + if (foreColor == null) + foreColor = value(PName.LineColor).asColor(themeStyle, set); final double deltaShadowing = value(PName.Shadowing).asDouble(); return new SymbolContext(backColor, foreColor).withStroke(getStroke()).withDeltaShadow(deltaShadowing); } + public SymbolContext getSymbolContext(ThemeStyle themeStyle, HColorSet set) { + return getSymbolContext(themeStyle, set, null); + } + public Style eventuallyOverride(UStroke stroke) { if (stroke == null) return this; @@ -269,7 +277,7 @@ public class Style { final FontConfiguration fc = getFontConfiguration(spriteContainer.getThemeStyle(), set); return display.create(fc, alignment, spriteContainer); } - + public static final String ID_TITLE = "_title"; public static final String ID_CAPTION = "_caption"; public static final String ID_LEGEND = "_legend"; diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageNoteLink.java b/src/net/sourceforge/plantuml/svek/image/EntityImageNoteLink.java index 80fe09820..94562be79 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageNoteLink.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageNoteLink.java @@ -63,7 +63,7 @@ public class EntityImageNoteLink extends AbstractTextBlock implements IEntityIma final Rose skin = new Rose(); comp = skin.createComponentNote( new Style[] { ComponentType.NOTE.getStyleSignature().getMergedStyle(styleBuilder) }, ComponentType.NOTE, - colors.mute(skinParam), note); + skinParam, note, colors); } public Dimension2D calculateDimension(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 5e9e10969..2889ee833 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -81,7 +81,7 @@ public class Version { } public static int beta() { - final int beta = 3; + final int beta = 4; return beta; } diff --git a/test/nonreg/scxml/SCXML0001_Test.java b/test/nonreg/scxml/SCXML0001_Test.java new file mode 100644 index 000000000..30123d9f7 --- /dev/null +++ b/test/nonreg/scxml/SCXML0001_Test.java @@ -0,0 +1,44 @@ +package nonreg.scxml; + +import java.io.IOException; + +import org.junit.jupiter.api.Test; + +/* + + +Test diagram MUST be put between triple quotes + +""" +@startuml +state s1 +state s2 +[*] --> s1 + +s1 --> s2 : play +@enduml +""" + +Expected result MUST be put between triple brackets + +{{{ + + + + + + + + + +}}} + + */ +public class SCXML0001_Test extends ScXmlTest { + + @Test + void testSimple() throws IOException { + checkXmlAndDescription("(3 entities)"); + } + +} diff --git a/test/nonreg/scxml/SCXML0002_Test.java b/test/nonreg/scxml/SCXML0002_Test.java new file mode 100644 index 000000000..33ad5cbfb --- /dev/null +++ b/test/nonreg/scxml/SCXML0002_Test.java @@ -0,0 +1,61 @@ +package nonreg.scxml; + +import java.io.IOException; + +import org.junit.jupiter.api.Test; + +/* + + +https://github.com/plantuml/plantuml/issues/1100 + + +Test diagram MUST be put between triple quotes + +""" +@startuml +state counter{ +state count_start +state count_done +state "count_val[3:0]" +[*] -> count_idle +count_idle --> count_ongoing: count_start +state count_idle: count_val := 0 +state count_ongoing: count_val := count_val +1 +count_ongoing -> count_finish: count_val != MAX_VAL +state count_finish: count_done:=1 +count_finish -> count_idle +} +@enduml +""" + +Expected result MUST be put between triple brackets + +{{{ + + + + + + + + + + + + + + + + + +}}} + */ +public class SCXML0002_Test extends ScXmlTest { + + @Test + void testSimple() throws IOException { + checkXmlAndDescription("(7 entities)"); + } + +} diff --git a/test/nonreg/scxml/ScXmlTest.java b/test/nonreg/scxml/ScXmlTest.java new file mode 100644 index 000000000..51222a5a7 --- /dev/null +++ b/test/nonreg/scxml/ScXmlTest.java @@ -0,0 +1,100 @@ +package nonreg.scxml; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; +import java.util.concurrent.atomic.AtomicInteger; + +import net.sourceforge.plantuml.FileFormat; +import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.SourceStringReader; +import net.sourceforge.plantuml.core.DiagramDescription; + +public class ScXmlTest { + + private static final String TRIPLE_QUOTE = "\"\"\""; + + protected void checkXmlAndDescription(final String expectedDescription) + throws IOException, UnsupportedEncodingException { + final String actual = runPlantUML(expectedDescription, FileFormat.SCXML); + final String expected = readStringFromSourceFile(getDiagramFile(), "{{{", "}}}"); + + if (sortString(actual).equals(sortString(expected)) == false) { + assertEquals(expected, actual, "Generated ScXml is not ok"); + } + + } + + private String sortString(String s) { + final Map map = new TreeMap<>(); + for (int i = 0; i < s.length(); i++) { + final char ch = s.charAt(i); + // We ignore non writable characters + if (ch <= ' ') + continue; + + AtomicInteger count = map.get(ch); + if (count == null) + map.put(ch, new AtomicInteger(1)); + else + count.addAndGet(1); + } + return map.toString(); + } + + private String getLocalFolder() { + return "test/" + getPackageName().replace(".", "/"); + } + + private String getPackageName() { + return getClass().getPackage().getName(); + } + + private Path getDiagramFile() { + return Paths.get(getLocalFolder(), getClass().getSimpleName() + ".java"); + } + + private String runPlantUML(String expectedDescription, FileFormat format) + throws IOException, UnsupportedEncodingException { + final String diagramText = readStringFromSourceFile(getDiagramFile(), TRIPLE_QUOTE, TRIPLE_QUOTE); + final SourceStringReader ssr = new SourceStringReader(diagramText, UTF_8); + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final DiagramDescription diagramDescription = ssr.outputImage(baos, 0, new FileFormatOption(format)); + assertEquals(expectedDescription, diagramDescription.getDescription(), "Bad description"); + + return new String(baos.toByteArray(), UTF_8); + } + + private String readStringFromSourceFile(Path path, String startMarker, String endMarker) throws IOException { + assertTrue(Files.exists(path), "Cannot find " + path); + assertTrue(Files.isReadable(path), "Cannot read " + path); + final List allLines = Files.readAllLines(path, UTF_8); + final int first = allLines.indexOf(startMarker); + final int last = allLines.lastIndexOf(endMarker); + assertTrue(first != -1); + assertTrue(last != -1); + assertTrue(last > first); + return packString(allLines.subList(first + 1, last)); + } + + private String packString(Collection list) { + final StringBuilder sb = new StringBuilder(); + for (String s : list) { + sb.append(s); + sb.append("\n"); + } + return sb.toString(); + } + +} diff --git a/test/nonreg/xmi/XmiTest.java b/test/nonreg/xmi/XmiTest.java index 8af2e0f10..347249b30 100644 --- a/test/nonreg/xmi/XmiTest.java +++ b/test/nonreg/xmi/XmiTest.java @@ -28,15 +28,15 @@ public class XmiTest { protected void checkXmlAndDescription(final String expectedDescription) throws IOException, UnsupportedEncodingException { final String star = runPlantUML(expectedDescription, FileFormat.XMI_STAR); - final String startExpected = readStringFromSourceFile(getDiagramFile(), "{{{star", "}}}star"); + final String starExpected = readStringFromSourceFile(getDiagramFile(), "{{{star", "}}}star"); // This is really a hack. Since XML generation does not guarantee the order of // attributes, we make an easy to do check by sorting characters. // Of course, this is really incomplete: a faulty String may match the expected // result if, for example, an attribute is moved from a node to another. // However, we consider that it is a good start. - if (sortString(star).equals(sortString(startExpected)) == false) { - assertEquals(startExpected, star, "XmiStar: Generated GraphML is not ok"); + if (sortString(star).equals(sortString(starExpected)) == false) { + assertEquals(starExpected, star, "XmiStar: Generated GraphML is not ok"); } final String argo = runPlantUML(expectedDescription, FileFormat.XMI_ARGO);