From a80a3daf680b0ca7f1c3e16de8022a2dadf7d213 Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Tue, 11 Jan 2011 08:42:49 +0100 Subject: [PATCH] Version 5930 --- .../activitydiagram/command/CommandIf.java | 2 +- .../ActivityDiagramFactory2.java | 2 + .../activitydiagram2/command/CommandIf2.java | 2 +- .../plantuml/asciiart/ComponentTextArrow.java | 6 +- .../asciiart/ComponentTextSelfArrow.java | 20 +- .../plantuml/asciiart/TextSkin.java | 9 +- .../AbstractClassOrObjectDiagram.java | 29 ++- .../plantuml/printskin/PrintSkin.java | 8 +- .../sequencediagram/AbstractMessage.java | 19 +- .../plantuml/sequencediagram/Message.java | 10 +- .../plantuml/sequencediagram/MessageExo.java | 8 +- .../SequenceDiagramFactory.java | 6 +- .../{CommandArrow2.java => CommandArrow.java} | 65 +++--- .../command/CommandExoArrowAny.java | 49 +++-- .../command/CommandExoArrowLeft.java | 12 +- .../command/CommandExoArrowRight.java | 14 +- .../sequencediagram/graphic/Step1Message.java | 31 ++- .../graphic/Step1MessageExo.java | 16 +- .../sourceforge/plantuml/skin/ArrowBody.java | 38 ++++ .../plantuml/skin/ArrowConfiguration.java | 116 ++++++++++ .../plantuml/skin/ArrowDirection.java | 38 ++++ .../sourceforge/plantuml/skin/ArrowHead.java | 38 ++++ .../sourceforge/plantuml/skin/ArrowPart.java | 38 ++++ .../plantuml/skin/ComponentType.java | 198 +++++++++++------- .../plantuml/skin/bluemodern/BlueModern.java | 46 ++-- .../skin/rose/AbstractComponentRoseArrow.java | 27 ++- .../skin/rose/ComponentRoseArrow.java | 100 ++++++--- .../skin/rose/ComponentRoseSelfArrow.java | 49 +++-- .../sourceforge/plantuml/skin/rose/Rose.java | 58 ++--- .../sourceforge/plantuml/version/Version.java | 6 +- 30 files changed, 720 insertions(+), 340 deletions(-) rename src/net/sourceforge/plantuml/sequencediagram/command/{CommandArrow2.java => CommandArrow.java} (70%) create mode 100644 src/net/sourceforge/plantuml/skin/ArrowBody.java create mode 100644 src/net/sourceforge/plantuml/skin/ArrowConfiguration.java create mode 100644 src/net/sourceforge/plantuml/skin/ArrowDirection.java create mode 100644 src/net/sourceforge/plantuml/skin/ArrowHead.java create mode 100644 src/net/sourceforge/plantuml/skin/ArrowPart.java diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java index bef07f071..ec3a00567 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandIf.java @@ -67,7 +67,7 @@ public class CommandIf extends SingleLineCommand2 { new RegexLeaf("\\s*"), new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), new RegexLeaf("\\s*"), - new RegexLeaf("IF", "if\\s*\"([^\"]*)\"\\s*(?:as\\s+([\\p{L}0-9_.]+)\\s+)?then$")); + new RegexLeaf("IF", "if\\s*\"([^\"]*)\"\\s*(?:as\\s+([\\p{L}0-9_.]+)\\s+)?(?:then)?$")); } diff --git a/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagramFactory2.java b/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagramFactory2.java index d127e276b..701469b71 100644 --- a/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagramFactory2.java +++ b/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagramFactory2.java @@ -33,6 +33,7 @@ */ package net.sourceforge.plantuml.activitydiagram2; +import net.sourceforge.plantuml.activitydiagram2.command.CommandEndif2; import net.sourceforge.plantuml.activitydiagram2.command.CommandIf2; import net.sourceforge.plantuml.activitydiagram2.command.CommandNewActivity; import net.sourceforge.plantuml.activitydiagram2.command.CommandStart; @@ -54,6 +55,7 @@ public class ActivityDiagramFactory2 extends AbstractUmlSystemCommandFactory { addCommand(new CommandStart(system)); addCommand(new CommandNewActivity(system)); addCommand(new CommandIf2(system)); + addCommand(new CommandEndif2(system)); // addCommand(new CommandLinkActivity(system)); // addCommand(new CommandPartition(system)); diff --git a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandIf2.java b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandIf2.java index 3348ec370..0b1e3c95b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandIf2.java +++ b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandIf2.java @@ -54,7 +54,7 @@ public class CommandIf2 extends SingleLineCommand2 { new RegexLeaf("\\s*"), new RegexLeaf("TEST", "\"([^\"]+)\""), new RegexLeaf("\\s*"), - new RegexLeaf("then"), + new RegexLeaf("(then)?"), new RegexLeaf("$")); } diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java index ad777309f..a9222e64c 100644 --- a/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java +++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java @@ -65,15 +65,15 @@ public class ComponentTextArrow implements Component { final int yarrow = height - 2; charArea.drawHLine(fileFormat == FileFormat.UTXT ? '\u2500' : '-', yarrow, 1, width); - if (type == ComponentType.DOTTED_ARROW || type == ComponentType.RETURN_DOTTED_ARROW) { + if (type.getArrowConfiguration().isDotted()) { for (int i = 1; i < width; i += 2) { charArea.drawChar(' ', i, yarrow); } } - if (type == ComponentType.ARROW || type == ComponentType.DOTTED_ARROW) { + if (type.getArrowConfiguration().isLeftToRightNormal()) { charArea.drawChar('>', width - 1, yarrow); - } else if (type == ComponentType.RETURN_ARROW || type == ComponentType.RETURN_DOTTED_ARROW) { + } else if (type.getArrowConfiguration().isRightToLeftReverse()) { charArea.drawChar('<', 1, yarrow); } else { throw new UnsupportedOperationException(); diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java index 5d6ed1a62..7b84e4ed4 100644 --- a/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java +++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextSelfArrow.java @@ -66,24 +66,24 @@ public class ComponentTextSelfArrow implements Component { charArea.fillRect(' ', 0, 0, width, height); if (fileFormat == FileFormat.UTXT) { - if (type == ComponentType.SELF_ARROW) { - charArea.drawStringLR("\u2500\u2500\u2500\u2500\u2510", 0, 0); - charArea.drawStringLR("\u2502", 4, 1); - charArea.drawStringLR("<\u2500\u2500\u2500\u2518", 0, 2); - } else if (type == ComponentType.DOTTED_SELF_ARROW) { + if (type.getArrowConfiguration().isDotted()) { charArea.drawStringLR("\u2500 \u2500 \u2510", 0, 0); charArea.drawStringLR("|", 4, 1); charArea.drawStringLR("< \u2500 \u2518", 0, 2); + } else { + charArea.drawStringLR("\u2500\u2500\u2500\u2500\u2510", 0, 0); + charArea.drawStringLR("\u2502", 4, 1); + charArea.drawStringLR("<\u2500\u2500\u2500\u2518", 0, 2); } } else { - if (type == ComponentType.SELF_ARROW) { - charArea.drawStringLR("----.", 0, 0); - charArea.drawStringLR("|", 4, 1); - charArea.drawStringLR("<---'", 0, 2); - } else if (type == ComponentType.DOTTED_SELF_ARROW) { + if (type.getArrowConfiguration().isDotted()) { charArea.drawStringLR("- - .", 0, 0); charArea.drawStringLR("|", 4, 1); charArea.drawStringLR("< - '", 0, 2); + } else { + charArea.drawStringLR("----.", 0, 0); + charArea.drawStringLR("|", 4, 1); + charArea.drawStringLR("<---'", 0, 2); } } diff --git a/src/net/sourceforge/plantuml/asciiart/TextSkin.java b/src/net/sourceforge/plantuml/asciiart/TextSkin.java index 210e3899a..936b0e9c2 100644 --- a/src/net/sourceforge/plantuml/asciiart/TextSkin.java +++ b/src/net/sourceforge/plantuml/asciiart/TextSkin.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5140 $ + * Revision $Revision: 5921 $ * */ package net.sourceforge.plantuml.asciiart; @@ -56,11 +56,12 @@ public class TextSkin implements Skin { if (type == ComponentType.ACTOR_HEAD || type == ComponentType.ACTOR_TAIL) { return new ComponentTextActor(type, stringsToDisplay, fileFormat); } - if (type == ComponentType.ARROW || type == ComponentType.RETURN_ARROW || type == ComponentType.DOTTED_ARROW - || type == ComponentType.RETURN_DOTTED_ARROW) { + if (type.isArrow() + && (type.getArrowConfiguration().isLeftToRightNormal() || type.getArrowConfiguration() + .isRightToLeftReverse())) { return new ComponentTextArrow(type, stringsToDisplay, fileFormat); } - if (type == ComponentType.SELF_ARROW || type == ComponentType.DOTTED_SELF_ARROW) { + if (type.isArrow() && type.getArrowConfiguration().isSelfArrow()) { return new ComponentTextSelfArrow(type, stringsToDisplay, fileFormat); } if (type == ComponentType.PARTICIPANT_LINE || type == ComponentType.ACTOR_LINE) { diff --git a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java index 12ce78e38..a9cae1870 100644 --- a/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java +++ b/src/net/sourceforge/plantuml/objectdiagram/AbstractClassOrObjectDiagram.java @@ -194,12 +194,12 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram removeLink(existingLink); } - entity1ToPoint = new Link(entity1, point, existingLink.getType().getPart2(), existingLink.getLabel(), existingLink - .getLength(), existingLink.getQualifier1(), null, existingLink.getLabeldistance(), existingLink - .getLabelangle()); - pointToEntity2 = new Link(point, entity2, existingLink.getType().getPart1(), existingLink.getLabel(), existingLink - .getLength(), null, existingLink.getQualifier2(), existingLink.getLabeldistance(), existingLink - .getLabelangle()); + entity1ToPoint = new Link(entity1, point, existingLink.getType().getPart2(), existingLink.getLabel(), + existingLink.getLength(), existingLink.getQualifier1(), null, existingLink.getLabeldistance(), + existingLink.getLabelangle()); + pointToEntity2 = new Link(point, entity2, existingLink.getType().getPart1(), null, + existingLink.getLength(), null, existingLink.getQualifier2(), existingLink.getLabeldistance(), + existingLink.getLabelangle()); addLink(entity1ToPoint); addLink(pointToEntity2); @@ -217,8 +217,21 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram } void createInSecond(LinkType linkType, String label) { - entity1ToPoint = new Link(entity1, point, existingLink.getType(), null, 2); - pointToEntity2 = new Link(point, entity2, existingLink.getType(), null, 2); + existingLink = foundLink(entity1, entity2); + if (existingLink == null) { + existingLink = new Link(entity1, entity2, new LinkType(LinkDecor.NONE, LinkDecor.NONE), null, 2); + } else { + removeLink(existingLink); + } + + entity1ToPoint = new Link(entity1, point, existingLink.getType().getPart2(), existingLink.getLabel(), 2, + existingLink.getQualifier1(), null, existingLink.getLabeldistance(), existingLink.getLabelangle()); + pointToEntity2 = new Link(point, entity2, existingLink.getType().getPart1(), null, 2, null, existingLink + .getQualifier2(), existingLink.getLabeldistance(), existingLink.getLabelangle()); + // entity1ToPoint = new Link(entity1, point, existingLink.getType(), + // null, 2); + // pointToEntity2 = new Link(point, entity2, existingLink.getType(), + // null, 2); addLink(entity1ToPoint); addLink(pointToEntity2); if (other.pointToAssocied.getEntity1().getType() == EntityType.POINT_FOR_ASSOCIATION) { diff --git a/src/net/sourceforge/plantuml/printskin/PrintSkin.java b/src/net/sourceforge/plantuml/printskin/PrintSkin.java index 2fd4ca6ed..5b50a3f15 100644 --- a/src/net/sourceforge/plantuml/printskin/PrintSkin.java +++ b/src/net/sourceforge/plantuml/printskin/PrintSkin.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5872 $ + * Revision $Revision: 5924 $ * */ package net.sourceforge.plantuml.printskin; @@ -88,18 +88,18 @@ class PrintSkin extends AbstractPSystem { } private BufferedImage createImage() { - final EmptyImageBuilder builder = new EmptyImageBuilder(1000, 1000, Color.WHITE); + final EmptyImageBuilder builder = new EmptyImageBuilder(1500, 830, Color.WHITE); final BufferedImage im = builder.getBufferedImage(); final Graphics2D g2d = builder.getGraphics2D(); ug = new UGraphicG2d(g2d, null, 1.0); - for (ComponentType type : EnumSet.allOf(ComponentType.class)) { + for (ComponentType type : ComponentType.all() ) { printComponent(type); ypos += 10; maxYpos = Math.max(maxYpos, ypos); - if (ypos > 500) { + if (ypos > 620) { ypos = 0; xpos += 200; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java b/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java index f2523dd79..0f9361e74 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java +++ b/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java @@ -38,12 +38,14 @@ import java.util.Collections; import java.util.List; import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.skin.ArrowConfiguration; public abstract class AbstractMessage implements Event { final private List label; - final private boolean dotted; - final private boolean full; +// final private boolean dotted; +// final private boolean full; + final private ArrowConfiguration arrowConfiguration; final private List lifeEvents = new ArrayList(); private List notes; @@ -51,10 +53,9 @@ public abstract class AbstractMessage implements Event { private HtmlColor noteBackColor; private final String messageNumber; - public AbstractMessage(List label, boolean dotted, boolean full, String messageNumber) { + public AbstractMessage(List label, ArrowConfiguration arrowConfiguration, String messageNumber) { this.label = label; - this.dotted = dotted; - this.full = full; + this.arrowConfiguration = arrowConfiguration; this.messageNumber = messageNumber; } @@ -87,12 +88,8 @@ public abstract class AbstractMessage implements Event { return Collections.unmodifiableList(label); } - public final boolean isDotted() { - return dotted; - } - - public final boolean isFull() { - return full; + public final ArrowConfiguration getArrowConfiguration() { + return arrowConfiguration; } public final List getNote() { diff --git a/src/net/sourceforge/plantuml/sequencediagram/Message.java b/src/net/sourceforge/plantuml/sequencediagram/Message.java index b3d150c06..4577895a3 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Message.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Message.java @@ -28,21 +28,23 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4663 $ + * Revision $Revision: 5923 $ * */ package net.sourceforge.plantuml.sequencediagram; import java.util.List; +import net.sourceforge.plantuml.skin.ArrowConfiguration; + public class Message extends AbstractMessage { final private Participant p1; final private Participant p2; - public Message(Participant p1, Participant p2, List label, - boolean dotted, boolean full, String messageNumber) { - super(label, dotted, full, messageNumber); + public Message(Participant p1, Participant p2, List label, ArrowConfiguration arrowConfiguration, + String messageNumber) { + super(label, arrowConfiguration, messageNumber); this.p1 = p1; this.p2 = p2; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java b/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java index 10d9f14eb..694c002eb 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java +++ b/src/net/sourceforge/plantuml/sequencediagram/MessageExo.java @@ -35,14 +35,16 @@ package net.sourceforge.plantuml.sequencediagram; import java.util.List; +import net.sourceforge.plantuml.skin.ArrowConfiguration; + public class MessageExo extends AbstractMessage { final private MessageExoType type; final private Participant participant; - public MessageExo(Participant p, MessageExoType type, List label, - boolean dotted, boolean full, String messageNumber) { - super(label, dotted, full, messageNumber); + public MessageExo(Participant p, MessageExoType type, List label, ArrowConfiguration arrowConfiguration, + String messageNumber) { + super(label, arrowConfiguration, messageNumber); this.participant = p; this.type = type; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java index 221011637..ca11e2976 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java +++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5731 $ + * Revision $Revision: 5925 $ * */ package net.sourceforge.plantuml.sequencediagram; @@ -36,7 +36,7 @@ package net.sourceforge.plantuml.sequencediagram; import net.sourceforge.plantuml.command.AbstractUmlSystemCommandFactory; import net.sourceforge.plantuml.sequencediagram.command.CommandActivate; import net.sourceforge.plantuml.sequencediagram.command.CommandActivate2; -import net.sourceforge.plantuml.sequencediagram.command.CommandArrow2; +import net.sourceforge.plantuml.sequencediagram.command.CommandArrow; import net.sourceforge.plantuml.sequencediagram.command.CommandAutoNewpage; import net.sourceforge.plantuml.sequencediagram.command.CommandAutonumber; import net.sourceforge.plantuml.sequencediagram.command.CommandBoxEnd; @@ -71,7 +71,7 @@ public class SequenceDiagramFactory extends AbstractUmlSystemCommandFactory { addCommand(new CommandParticipant(system)); addCommand(new CommandParticipant2(system)); - addCommand(new CommandArrow2(system)); + addCommand(new CommandArrow(system)); addCommand(new CommandExoArrowLeft(system)); addCommand(new CommandExoArrowRight(system)); addCommand(new CommandNoteSequence(system)); diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow2.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java similarity index 70% rename from src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow2.java rename to src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java index 7cb001dbe..d70e530f1 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow2.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandArrow.java @@ -47,34 +47,36 @@ import net.sourceforge.plantuml.command.regex.RegexPartialMatch; import net.sourceforge.plantuml.sequencediagram.Message; import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; +import net.sourceforge.plantuml.skin.ArrowConfiguration; +import net.sourceforge.plantuml.skin.ArrowDirection; +import net.sourceforge.plantuml.skin.ArrowPart; -public class CommandArrow2 extends SingleLineCommand2 { +public class CommandArrow extends SingleLineCommand2 { - public CommandArrow2(SequenceDiagram sequenceDiagram) { - super(sequenceDiagram, - getRegexConcat()); + public CommandArrow(SequenceDiagram sequenceDiagram) { + super(sequenceDiagram, getRegexConcat()); } - + static RegexConcat getRegexConcat() { return new RegexConcat( - new RegexLeaf("^"), - new RegexOr("PART1", - new RegexLeaf("PART1CODE", "([\\p{L}0-9_.]+)"), - new RegexLeaf("PART1LONG", "\"([^\"]+)\""), - new RegexLeaf("PART1LONGCODE", "\"([^\"]+)\"\\s*as\\s+([\\p{L}0-9_.]+)"), + new RegexLeaf("^"), // + new RegexOr("PART1", // + new RegexLeaf("PART1CODE", "([\\p{L}0-9_.]+)"), // + new RegexLeaf("PART1LONG", "\"([^\"]+)\""), // + new RegexLeaf("PART1LONGCODE", "\"([^\"]+)\"\\s*as\\s+([\\p{L}0-9_.]+)"), // new RegexLeaf("PART1CODELONG", "([\\p{L}0-9_.]+)\\s+as\\s*\"([^\"]+)\"")), - new RegexLeaf("\\s*"), - new RegexLeaf("ARROW", "([=-]+[>\\]]{1,2}|[<\\[]{1,2}[=-]+)"), - new RegexLeaf("\\s*"), - new RegexOr("PART2", - new RegexLeaf("PART2CODE", "([\\p{L}0-9_.]+)"), - new RegexLeaf("PART2LONG", "\"([^\"]+)\""), - new RegexLeaf("PART2LONGCODE", "\"([^\"]+)\"\\s*as\\s+([\\p{L}0-9_.]+)"), + new RegexLeaf("\\s*"), // + new RegexLeaf("ARROW", "([=-]+(?:>>?|//?|\\\\\\\\?)|(?:< arg2, String n) { final String code; final List display; @@ -104,17 +106,18 @@ public class CommandArrow2 extends SingleLineCommand2 { final String arrow = StringUtils.manageArrowForSequence(arg2.get("ARROW").get(0)); - if (arrow.endsWith(">")) { + if (arrow.endsWith(">") || arrow.endsWith("\\") || arrow.endsWith("/")) { p1 = getOrCreateParticipant(arg2, "PART1"); p2 = getOrCreateParticipant(arg2, "PART2"); - } else if (arrow.startsWith("<")) { + } else if (arrow.startsWith("<") || arrow.startsWith("\\") || arrow.startsWith("/")) { p2 = getOrCreateParticipant(arg2, "PART1"); p1 = getOrCreateParticipant(arg2, "PART2"); } else { throw new IllegalStateException(arg2.toString()); } - - final boolean full = (arrow.endsWith(">>") || arrow.startsWith("<<"))==false; + + final boolean sync = arrow.endsWith(">>") || arrow.startsWith("<<") || arrow.contains("\\\\") + || arrow.contains("//"); final boolean dotted = arrow.contains("--"); @@ -125,7 +128,21 @@ public class CommandArrow2 extends SingleLineCommand2 { labels = StringUtils.getWithNewlines(arg2.get("MESSAGE").get(0)); } - getSystem().addMessage(new Message(p1, p2, labels, dotted, full, getSystem().getNextMessageNumber())); + ArrowConfiguration config = ArrowConfiguration.withDirection(ArrowDirection.LEFT_TO_RIGHT_NORMAL); + if (dotted) { + config = config.withDotted(); + } + if (sync) { + config = config.withAsync(); + } + if (arrow.endsWith("\\") || arrow.startsWith("/")) { + config = config.withPart(ArrowPart.TOP_PART); + } + if (arrow.endsWith("/") || arrow.startsWith("\\")) { + config = config.withPart(ArrowPart.BOTTOM_PART); + } + + getSystem().addMessage(new Message(p1, p2, labels, config, getSystem().getNextMessageNumber())); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java index 7c678be7c..81dbe3aec 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowAny.java @@ -43,12 +43,15 @@ import net.sourceforge.plantuml.sequencediagram.MessageExo; import net.sourceforge.plantuml.sequencediagram.MessageExoType; import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; +import net.sourceforge.plantuml.skin.ArrowConfiguration; +import net.sourceforge.plantuml.skin.ArrowDirection; +import net.sourceforge.plantuml.skin.ArrowPart; abstract class CommandExoArrowAny extends SingleLineCommand { private final int posArrow; private final int posParticipant; - + public CommandExoArrowAny(SequenceDiagram sequenceDiagram, String pattern, int posArrow, int posParticipant) { super(sequenceDiagram, pattern); this.posArrow = posArrow; @@ -58,9 +61,11 @@ abstract class CommandExoArrowAny extends SingleLineCommand { @Override final protected CommandExecutionResult executeArg(List arg) { final String arrow = StringUtils.manageArrowForSequence(arg.get(posArrow)); - final Participant p = getSystem().getOrCreateParticipant(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(posParticipant))); + final Participant p = getSystem().getOrCreateParticipant( + StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(posParticipant))); - final boolean full = (arrow.endsWith(">>") || arrow.startsWith("<<")) == false; + final boolean sync = arrow.endsWith(">>") || arrow.startsWith("<<") || arrow.contains("//") + || arrow.contains("\\\\"); final boolean dotted = arrow.contains("--"); final List labels; @@ -70,28 +75,30 @@ abstract class CommandExoArrowAny extends SingleLineCommand { labels = StringUtils.getWithNewlines(arg.get(2)); } + ArrowConfiguration config = ArrowConfiguration.withDirection(ArrowDirection.LEFT_TO_RIGHT_NORMAL); + if (dotted) { + config = config.withDotted(); + } + if (sync) { + config = config.withAsync(); + } + config = config.withPart(getArrowPart(arrow)); + getSystem().addMessage( - new MessageExo(p, getMessageExoType(arrow), labels, dotted, - full, getSystem().getNextMessageNumber())); + new MessageExo(p, getMessageExoType(arrow), labels, config, getSystem().getNextMessageNumber())); return CommandExecutionResult.ok(); } + private ArrowPart getArrowPart(String arrow) { + if (arrow.contains("/")) { + return ArrowPart.BOTTOM_PART; + } + if (arrow.contains("\\")) { + return ArrowPart.TOP_PART; + } + return ArrowPart.FULL; + } + abstract MessageExoType getMessageExoType(String arrow); -// final MessageExoType getMessageExoType(String arrow) { -// if (arrow.startsWith("[") && arrow.endsWith(">")) { -// return MessageExoType.FROM_LEFT; -// } -// if (arrow.startsWith("[<")) { -// return MessageExoType.TO_LEFT; -// } -// if (arrow.startsWith("<") && arrow.endsWith("]")) { -// return MessageExoType.FROM_RIGHT; -// } -// if (arrow.endsWith(">]")) { -// return MessageExoType.TO_RIGHT; -// } -// throw new IllegalArgumentException(arrow); -// } - } diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java index 28c56dae2..36a841e14 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandExoArrowLeft.java @@ -39,8 +39,10 @@ import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; public class CommandExoArrowLeft extends CommandExoArrowAny { public CommandExoArrowLeft(SequenceDiagram sequenceDiagram) { - super(sequenceDiagram, - "(?i)^(\\[?[=-]+>{1,2}|\\[?\\<{1,2}[=-]+)\\s*([\\p{L}0-9_.]+|\"[^\"]+\")\\s*(?::\\s*(.*))?$", 0, 1); + super( + sequenceDiagram, + "(?i)^(\\[?[=-]+(?:>>?|//?|\\\\\\\\?)|\\[?(?:<{1,2}\\]?|\\<{1,2}[=-]+\\]?)\\s*(?::\\s*(.*))?$", - 1, 0); + super(sequenceDiagram, + "(?i)^([\\p{L}0-9_.]+|\"[^\"]+\")\\s*([=-]+(?:>>?|//?|\\\\\\\\?)\\]?|(?:<")) { return MessageExoType.TO_RIGHT; } + if (arrow.startsWith("/") || arrow.startsWith("\\")) { + return MessageExoType.FROM_RIGHT; + } + if (arrow.endsWith("\\]") || arrow.endsWith("/]") || arrow.endsWith("\\") || arrow.endsWith("/")) { + return MessageExoType.TO_RIGHT; + } throw new IllegalArgumentException(arrow); } - + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java index 9ed9c92d9..4d40fd633 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5275 $ + * Revision $Revision: 5928 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.sequencediagram.InGroupableList; import net.sourceforge.plantuml.sequencediagram.LifeEvent; import net.sourceforge.plantuml.sequencediagram.Message; import net.sourceforge.plantuml.sequencediagram.NotePosition; +import net.sourceforge.plantuml.skin.ArrowDirection; import net.sourceforge.plantuml.skin.ComponentType; class Step1Message extends Step1Abstract { @@ -78,8 +79,8 @@ class Step1Message extends Step1Abstract { final Arrow graphic = createArrow(); final double arrowYStartLevel = graphic.getArrowYStartLevel(getStringBounder()); final double arrowYEndLevel = graphic.getArrowYEndLevel(getStringBounder()); - - //final double delta1 = isSelfMessage() ? 4 : 0; + + // final double delta1 = isSelfMessage() ? 4 : 0; final double delta1 = 0; for (LifeEvent lifeEvent : getMessage().getLiveEvents()) { @@ -192,22 +193,32 @@ class Step1Message extends Step1Abstract { } private ComponentType getSelfArrowType(Message m) { - return m.isDotted() ? ComponentType.DOTTED_SELF_ARROW : ComponentType.SELF_ARROW; + ComponentType result = m.getArrowConfiguration().isDotted() ? ComponentType.getArrow(ArrowDirection.SELF) + .withDotted() : ComponentType.getArrow(ArrowDirection.SELF); + if (m.getArrowConfiguration().isDotted()) { + result = result.withDotted(); + } + if (m.getArrowConfiguration().isASync()) { + result = result.withAsync(); + } + result = result.withPart(m.getArrowConfiguration().getPart()); + return result; } private ComponentType getArrowType(Message m, final double x1, final double x2) { ComponentType result = null; if (x2 > x1) { - result = ComponentType.ARROW; + result = ComponentType.getArrow(ArrowDirection.LEFT_TO_RIGHT_NORMAL); } else { - result = ComponentType.RETURN_ARROW; + result = ComponentType.getArrow(ArrowDirection.RIGHT_TO_LEFT_REVERSE); } - if (m.isDotted()) { - result = result.getDotted(); + if (m.getArrowConfiguration().isDotted()) { + result = result.withDotted(); } - if (m.isFull() == false) { - result = result.getAsync(); + if (m.getArrowConfiguration().isASync()) { + result = result.withAsync(); } + result = result.withPart(m.getArrowConfiguration().getPart()); return result; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java index 4b8d7fb03..3da3185c5 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1MessageExo.java @@ -46,6 +46,9 @@ import net.sourceforge.plantuml.sequencediagram.LifeEvent; import net.sourceforge.plantuml.sequencediagram.MessageExo; import net.sourceforge.plantuml.sequencediagram.MessageExoType; import net.sourceforge.plantuml.sequencediagram.MessageNumber; +import net.sourceforge.plantuml.skin.ArrowBody; +import net.sourceforge.plantuml.skin.ArrowDirection; +import net.sourceforge.plantuml.skin.ArrowHead; import net.sourceforge.plantuml.skin.ComponentType; class Step1MessageExo extends Step1Abstract { @@ -139,16 +142,17 @@ class Step1MessageExo extends Step1Abstract { ComponentType result = null; final MessageExoType type = m.getType(); if (type.getDirection() == 1) { - result = ComponentType.ARROW; + result = ComponentType.getArrow(ArrowDirection.LEFT_TO_RIGHT_NORMAL); } else { - result = ComponentType.RETURN_ARROW; + result = ComponentType.getArrow(ArrowDirection.RIGHT_TO_LEFT_REVERSE); } - if (m.isDotted()) { - result = result.getDotted(); + if (m.getArrowConfiguration().isDotted()) { + result = result.withDotted(); } - if (m.isFull() == false) { - result = result.getAsync(); + if (m.getArrowConfiguration().isASync()) { + result = result.withAsync(); } + result = result.withPart(m.getArrowConfiguration().getPart()); return result; } diff --git a/src/net/sourceforge/plantuml/skin/ArrowBody.java b/src/net/sourceforge/plantuml/skin/ArrowBody.java new file mode 100644 index 000000000..16b9cc32a --- /dev/null +++ b/src/net/sourceforge/plantuml/skin/ArrowBody.java @@ -0,0 +1,38 @@ +/* ======================================================================== + * 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 + * + * Revision $Revision: 5191 $ + * + */ +package net.sourceforge.plantuml.skin; + +public enum ArrowBody { + NORMAL, DOTTED; +} diff --git a/src/net/sourceforge/plantuml/skin/ArrowConfiguration.java b/src/net/sourceforge/plantuml/skin/ArrowConfiguration.java new file mode 100644 index 000000000..081b49b57 --- /dev/null +++ b/src/net/sourceforge/plantuml/skin/ArrowConfiguration.java @@ -0,0 +1,116 @@ +/* ======================================================================== + * 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 + * + * Revision $Revision: 5191 $ + * + */ +package net.sourceforge.plantuml.skin; + +public class ArrowConfiguration { + + private final ArrowDirection direction; + private final ArrowBody body; + private final ArrowHead head; + private final ArrowPart part; + + private ArrowConfiguration(ArrowDirection direction, ArrowBody body, ArrowHead head, ArrowPart part) { + if (direction == null || body == null || head == null || part == null) { + throw new IllegalArgumentException(); + } + this.part = part; + this.direction = direction; + this.body = body; + this.head = head; + } + + public String name() { + return direction.name().substring(0, 4) + "-" + body.name() + "-" + head.name() + "-" + + part.name().substring(0, 3); + } + + @Override + public int hashCode() { + return direction.hashCode() + body.hashCode() + head.hashCode() + part.hashCode(); + } + + @Override + public boolean equals(Object other) { + final ArrowConfiguration this2 = (ArrowConfiguration) other; + return direction == this2.direction && body == this2.body && head == this2.head && part == this2.part; + } + + public static ArrowConfiguration withDirection(ArrowDirection direction) { + return new ArrowConfiguration(direction, ArrowBody.NORMAL, ArrowHead.NORMAL, ArrowPart.FULL); + } + + public ArrowConfiguration withAsync() { + return new ArrowConfiguration(direction, body, ArrowHead.ASYNC, part); + } + + public ArrowConfiguration withDotted() { + return new ArrowConfiguration(direction, ArrowBody.DOTTED, head, part); + } + + public ArrowConfiguration withPart(ArrowPart part) { +// if (part != ArrowPart.BOTTOM_PART && part != ArrowPart.TOP_PART) { +// throw new IllegalArgumentException(); +// } + return new ArrowConfiguration(direction, body, head, part); + } + + public boolean isLeftToRightNormal() { + return this.direction == ArrowDirection.LEFT_TO_RIGHT_NORMAL; + } + + public boolean isRightToLeftReverse() { + return this.direction == ArrowDirection.RIGHT_TO_LEFT_REVERSE; + } + + public boolean isSelfArrow() { + return this.direction == ArrowDirection.SELF; + } + + public boolean isDotted() { + return body == ArrowBody.DOTTED; + } + +// public boolean isSync() { +// return this.head == ArrowHead.NORMAL; +// } + + public boolean isASync() { + return this.head == ArrowHead.ASYNC; + } + + public final ArrowPart getPart() { + return part; + } + +} diff --git a/src/net/sourceforge/plantuml/skin/ArrowDirection.java b/src/net/sourceforge/plantuml/skin/ArrowDirection.java new file mode 100644 index 000000000..cff5f16d3 --- /dev/null +++ b/src/net/sourceforge/plantuml/skin/ArrowDirection.java @@ -0,0 +1,38 @@ +/* ======================================================================== + * 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 + * + * Revision $Revision: 5191 $ + * + */ +package net.sourceforge.plantuml.skin; + +public enum ArrowDirection { + LEFT_TO_RIGHT_NORMAL, RIGHT_TO_LEFT_REVERSE, SELF +} diff --git a/src/net/sourceforge/plantuml/skin/ArrowHead.java b/src/net/sourceforge/plantuml/skin/ArrowHead.java new file mode 100644 index 000000000..d858cecf8 --- /dev/null +++ b/src/net/sourceforge/plantuml/skin/ArrowHead.java @@ -0,0 +1,38 @@ +/* ======================================================================== + * 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 + * + * Revision $Revision: 5191 $ + * + */ +package net.sourceforge.plantuml.skin; + +public enum ArrowHead { + NORMAL, ASYNC +} diff --git a/src/net/sourceforge/plantuml/skin/ArrowPart.java b/src/net/sourceforge/plantuml/skin/ArrowPart.java new file mode 100644 index 000000000..a3b0406f8 --- /dev/null +++ b/src/net/sourceforge/plantuml/skin/ArrowPart.java @@ -0,0 +1,38 @@ +/* ======================================================================== + * 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 + * + * Revision $Revision: 5191 $ + * + */ +package net.sourceforge.plantuml.skin; + +public enum ArrowPart { + FULL, TOP_PART, BOTTOM_PART +} diff --git a/src/net/sourceforge/plantuml/skin/ComponentType.java b/src/net/sourceforge/plantuml/skin/ComponentType.java index f723782ec..95206fd2a 100644 --- a/src/net/sourceforge/plantuml/skin/ComponentType.java +++ b/src/net/sourceforge/plantuml/skin/ComponentType.java @@ -33,98 +33,134 @@ */ package net.sourceforge.plantuml.skin; -public enum ComponentType { - ACTOR_HEAD, ACTOR_LINE, ACTOR_TAIL, +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; - ALIVE_LINE, DESTROY, +public class ComponentType { - ARROW, DOTTED_ARROW, DOTTED_SELF_ARROW, RETURN_ARROW, RETURN_DOTTED_ARROW, SELF_ARROW, + private static final Map arrows = new HashMap(); + private static final List nonArrows = new ArrayList(); - ASYNC_ARROW, ASYNC_DOTTED_ARROW, ASYNC_RETURN_ARROW, ASYNC_RETURN_DOTTED_ARROW, + static public final ComponentType ACTOR_HEAD = new ComponentType("ACTOR_HEAD"); + static public final ComponentType ACTOR_LINE = new ComponentType("ACTOR_LINE"); + static public final ComponentType ACTOR_TAIL = new ComponentType("ACTOR_TAIL"); - GROUPING_BODY, GROUPING_ELSE, GROUPING_HEADER, GROUPING_TAIL, + // + static public final ComponentType ALIVE_LINE = new ComponentType("ALIVE_LINE"); + static public final ComponentType DESTROY = new ComponentType("DESTROY"); - NEWPAGE, NOTE, DIVIDER, - - ENGLOBER, + // + static public final ComponentType GROUPING_BODY = new ComponentType("GROUPING_BODY"); + static public final ComponentType GROUPING_ELSE = new ComponentType("GROUPING_ELSE"); + static public final ComponentType GROUPING_HEADER = new ComponentType("GROUPING_HEADER"); + static public final ComponentType GROUPING_TAIL = new ComponentType("GROUPING_TAIL"); + // + static public final ComponentType NEWPAGE = new ComponentType("NEWPAGE"); + static public final ComponentType NOTE = new ComponentType("NOTE"); + static public final ComponentType DIVIDER = new ComponentType("DIVIDER"); + static public final ComponentType ENGLOBER = new ComponentType("ENGLOBER"); - PARTICIPANT_HEAD, PARTICIPANT_LINE, PARTICIPANT_TAIL, + // + static public final ComponentType PARTICIPANT_HEAD = new ComponentType("PARTICIPANT_HEAD"); + static public final ComponentType PARTICIPANT_LINE = new ComponentType("PARTICIPANT_LINE"); + static public final ComponentType PARTICIPANT_TAIL = new ComponentType("PARTICIPANT_TAIL"); - TITLE, SIGNATURE; + // + static public final ComponentType TITLE = new ComponentType("TITLE"); + static public final ComponentType SIGNATURE = new ComponentType("SIGNATURE"); - public ComponentType getDotted() { - if (this == ComponentType.ARROW) { - return ComponentType.DOTTED_ARROW; - } else if (this == ComponentType.DOTTED_ARROW) { - throw new IllegalStateException(); - } else if (this == ComponentType.DOTTED_SELF_ARROW) { - throw new IllegalStateException(); - } else if (this == ComponentType.RETURN_ARROW) { - return ComponentType.RETURN_DOTTED_ARROW; - } else if (this == ComponentType.RETURN_DOTTED_ARROW) { - throw new IllegalStateException(); - } else if (this == ComponentType.SELF_ARROW) { - return ComponentType.DOTTED_SELF_ARROW; - } else if (this == ComponentType.ASYNC_ARROW) { - return ComponentType.ASYNC_DOTTED_ARROW; - } else if (this == ComponentType.ASYNC_DOTTED_ARROW) { - throw new IllegalStateException(); - } else if (this == ComponentType.ASYNC_RETURN_ARROW) { - return ComponentType.ASYNC_RETURN_DOTTED_ARROW; - } else if (this == ComponentType.ASYNC_RETURN_DOTTED_ARROW) { - throw new IllegalStateException(); - } - throw new UnsupportedOperationException(); - } - - public ComponentType getAsync() { - if (this == ComponentType.ARROW) { - return ComponentType.ASYNC_ARROW; - } else if (this == ComponentType.DOTTED_ARROW) { - return ComponentType.ASYNC_DOTTED_ARROW; - } else if (this == ComponentType.DOTTED_SELF_ARROW) { - throw new IllegalStateException(); - } else if (this == ComponentType.RETURN_ARROW) { - return ComponentType.ASYNC_RETURN_ARROW; - } else if (this == ComponentType.RETURN_DOTTED_ARROW) { - return ComponentType.ASYNC_RETURN_DOTTED_ARROW; - } else if (this == ComponentType.SELF_ARROW) { - throw new IllegalStateException(); - } else if (this == ComponentType.ASYNC_ARROW) { - throw new IllegalStateException(); - } else if (this == ComponentType.ASYNC_DOTTED_ARROW) { - throw new IllegalStateException(); - } else if (this == ComponentType.ASYNC_RETURN_ARROW) { - throw new IllegalStateException(); - } else if (this == ComponentType.ASYNC_RETURN_DOTTED_ARROW) { - throw new IllegalStateException(); - } - throw new UnsupportedOperationException(); + private final ArrowConfiguration arrowConfiguration; + private final String name; + + private ComponentType(String name) { + this(name, null); + nonArrows.add(this); } - public ComponentType getReverse() { - if (this == ComponentType.ARROW) { - return ComponentType.RETURN_ARROW; - } else if (this == ComponentType.DOTTED_ARROW) { - return ComponentType.RETURN_DOTTED_ARROW; - } else if (this == ComponentType.DOTTED_SELF_ARROW) { - throw new IllegalStateException(); - } else if (this == ComponentType.RETURN_ARROW) { - throw new IllegalStateException(); - } else if (this == ComponentType.RETURN_DOTTED_ARROW) { - throw new IllegalStateException(); - } else if (this == ComponentType.SELF_ARROW) { - throw new IllegalStateException(); - } else if (this == ComponentType.ASYNC_ARROW) { - return ComponentType.ASYNC_RETURN_ARROW; - } else if (this == ComponentType.ASYNC_DOTTED_ARROW) { - return ComponentType.ASYNC_RETURN_DOTTED_ARROW; - } else if (this == ComponentType.ASYNC_RETURN_ARROW) { - throw new IllegalStateException(); - } else if (this == ComponentType.ASYNC_RETURN_DOTTED_ARROW) { - throw new IllegalStateException(); + private ComponentType(String name, ArrowConfiguration arrowConfiguration) { + this.name = name; + this.arrowConfiguration = arrowConfiguration; + } + + public static ComponentType getArrow(ArrowDirection direction) { + final ArrowConfiguration config = ArrowConfiguration.withDirection(direction); + return getArrow(config); + } + + private static ComponentType getArrow(ArrowConfiguration config) { + ComponentType result = arrows.get(config); + if (result == null) { + result = new ComponentType(config.name(), config); + arrows.put(config, result); } - throw new UnsupportedOperationException(); + return result; + } + + public ComponentType withAsync() { + checkArrow(); + return ComponentType.getArrow(arrowConfiguration.withAsync()); + } + + public ComponentType withDotted() { + checkArrow(); + return ComponentType.getArrow(arrowConfiguration.withDotted()); + } + + public ComponentType withPart(ArrowPart part) { + checkArrow(); + return ComponentType.getArrow(arrowConfiguration.withPart(part)); + } + + public String name() { + return name; + } + + public boolean isArrow() { + return this.arrowConfiguration != null; + } + + private void checkArrow() { + if (this.arrowConfiguration == null) { + throw new IllegalArgumentException(name()); + } + } + + public static Collection all() { + // ARROW, DOTTED_ARROW, DOTTED_SELF_ARROW, RETURN_ARROW, + // RETURN_DOTTED_ARROW, SELF_ARROW, + // ASYNC_ARROW, ASYNC_DOTTED_ARROW, ASYNC_RETURN_ARROW, + // ASYNC_RETURN_DOTTED_ARROW, + + final List all = new ArrayList(); + all.add(ComponentType.getArrow(ArrowDirection.LEFT_TO_RIGHT_NORMAL)); + all.add(ComponentType.getArrow(ArrowDirection.RIGHT_TO_LEFT_REVERSE)); + all.add(ComponentType.getArrow(ArrowDirection.SELF)); + all.add(ComponentType.getArrow(ArrowDirection.LEFT_TO_RIGHT_NORMAL).withDotted()); + all.add(ComponentType.getArrow(ArrowDirection.RIGHT_TO_LEFT_REVERSE).withDotted()); + all.add(ComponentType.getArrow(ArrowDirection.SELF).withDotted()); + + for (ComponentType type : new ArrayList(all)) { + all.add(type.withAsync()); + } + + final List simples = new ArrayList(all); + for (ComponentType type : simples) { + all.add(type.withPart(ArrowPart.TOP_PART)); + } + for (ComponentType type : simples) { + all.add(type.withPart(ArrowPart.BOTTOM_PART)); + } + + all.addAll(nonArrows); + return Collections.unmodifiableCollection(all); + } + + public final ArrowConfiguration getArrowConfiguration() { + return arrowConfiguration; } } diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java b/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java index 0798ccb45..4bf36c6ff 100644 --- a/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java +++ b/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5728 $ + * Revision $Revision: 5926 $ * */ package net.sourceforge.plantuml.skin.bluemodern; @@ -65,6 +65,15 @@ public class BlueModern implements Skin { public Component createComponent(ComponentType type, ISkinParam param, List stringsToDisplay) { + if (type.isArrow()) { + if (type.getArrowConfiguration().isSelfArrow()) { + return new ComponentBlueModernSelfArrow(Color.BLACK, Color.BLACK, normalFont, stringsToDisplay, type + .getArrowConfiguration().isDotted(), true); + } + return new ComponentBlueModernArrow(Color.BLACK, Color.BLACK, normalFont, stringsToDisplay, type + .getArrowConfiguration().isLeftToRightNormal() ? 1 : -1, type.getArrowConfiguration().isDotted(), + type.getArrowConfiguration().isASync()==false); + } if (type == ComponentType.PARTICIPANT_HEAD) { return new ComponentBlueModernParticipant(blue1, blue2, Color.WHITE, participantFont, stringsToDisplay); } @@ -74,37 +83,6 @@ public class BlueModern implements Skin { if (type == ComponentType.PARTICIPANT_LINE) { return new ComponentBlueModernLine(lineColor); } - if (type == ComponentType.SELF_ARROW) { - return new ComponentBlueModernSelfArrow(Color.BLACK, Color.BLACK, normalFont, stringsToDisplay, false, true); - } - if (type == ComponentType.DOTTED_SELF_ARROW) { - return new ComponentBlueModernSelfArrow(Color.BLACK, Color.BLACK, normalFont, stringsToDisplay, true, true); - } - if (type == ComponentType.ARROW) { - return new ComponentBlueModernArrow(Color.BLACK, Color.BLACK, normalFont, stringsToDisplay, 1, false, true); - } - if (type == ComponentType.ASYNC_ARROW) { - return new ComponentBlueModernArrow(Color.BLACK, Color.BLACK, normalFont, stringsToDisplay, 1, false, false); - } - if (type == ComponentType.DOTTED_ARROW) { - return new ComponentBlueModernArrow(Color.BLACK, Color.BLACK, normalFont, stringsToDisplay, 1, true, true); - } - if (type == ComponentType.ASYNC_DOTTED_ARROW) { - return new ComponentBlueModernArrow(Color.BLACK, Color.BLACK, normalFont, stringsToDisplay, 1, true, false); - } - if (type == ComponentType.RETURN_ARROW) { - return new ComponentBlueModernArrow(Color.BLACK, Color.BLACK, normalFont, stringsToDisplay, -1, false, true); - } - if (type == ComponentType.ASYNC_RETURN_ARROW) { - return new ComponentBlueModernArrow(Color.BLACK, Color.BLACK, normalFont, stringsToDisplay, -1, false, - false); - } - if (type == ComponentType.RETURN_DOTTED_ARROW) { - return new ComponentBlueModernArrow(Color.BLACK, Color.BLACK, normalFont, stringsToDisplay, -1, true, true); - } - if (type == ComponentType.ASYNC_RETURN_DOTTED_ARROW) { - return new ComponentBlueModernArrow(Color.BLACK, Color.BLACK, normalFont, stringsToDisplay, -1, true, false); - } if (type == ComponentType.ACTOR_HEAD) { return new ComponentBlueModernActor(blue2, blue1, blue1, participantFont, stringsToDisplay, true); } @@ -150,8 +128,8 @@ public class BlueModern implements Skin { "in April 2009.")); } if (type == ComponentType.ENGLOBER) { - return new ComponentBlueModernEnglober(blue1, blue3, stringsToDisplay, Color.BLACK, param - .getFont(FontParam.SEQUENCE_ENGLOBER, null)); + return new ComponentBlueModernEnglober(blue1, blue3, stringsToDisplay, Color.BLACK, param.getFont( + FontParam.SEQUENCE_ENGLOBER, null)); } return null; diff --git a/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java b/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java index c7b956e22..da8ccf790 100644 --- a/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java +++ b/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4631 $ + * Revision $Revision: 5922 $ * */ package net.sourceforge.plantuml.skin.rose; @@ -40,20 +40,21 @@ import java.util.List; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.skin.AbstractTextualComponent; import net.sourceforge.plantuml.skin.ArrowComponent; +import net.sourceforge.plantuml.skin.ArrowConfiguration; public abstract class AbstractComponentRoseArrow extends AbstractTextualComponent implements ArrowComponent { private final int arrowDeltaX = 10; private final int arrowDeltaY = 4; - private final boolean dotted; - private final boolean full; +// private final boolean dotted; +// private final boolean full; private final Color foregroundColor; + private final ArrowConfiguration arrowConfiguration; public AbstractComponentRoseArrow(Color foregroundColor, Color fontColor, Font font, - List stringsToDisplay, boolean dotted, boolean full) { + List stringsToDisplay, ArrowConfiguration arrowConfiguration) { super(stringsToDisplay, fontColor, font, HorizontalAlignement.LEFT, 7, 7, 2); - this.dotted = dotted; - this.full = full; + this.arrowConfiguration = arrowConfiguration; this.foregroundColor = foregroundColor; } @@ -74,12 +75,16 @@ public abstract class AbstractComponentRoseArrow extends AbstractTextualComponen return 6; } - final protected boolean isDotted() { - return dotted; + public final ArrowConfiguration getArrowConfiguration() { + return arrowConfiguration; } - final protected boolean isFull() { - return full; - } +// final protected boolean isDotted() { +// return dotted; +// } +// +// final protected boolean isFull() { +// return full; +// } } diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java index d1135ac52..cddea1982 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4632 $ + * Revision $Revision: 5926 $ * */ package net.sourceforge.plantuml.skin.rose; @@ -40,6 +40,8 @@ import java.awt.geom.Point2D; import java.util.List; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.skin.ArrowConfiguration; +import net.sourceforge.plantuml.skin.ArrowPart; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.UPolygon; @@ -47,15 +49,9 @@ import net.sourceforge.plantuml.ugraphic.UStroke; public class ComponentRoseArrow extends AbstractComponentRoseArrow { - private final int direction; - public ComponentRoseArrow(Color foregroundColor, Color fontColor, Font font, - List stringsToDisplay, int direction, boolean dotted, boolean full) { - super(foregroundColor, fontColor, font, stringsToDisplay, dotted, full); - this.direction = direction; - if (direction != 1 && direction != -1) { - throw new IllegalArgumentException(); - } + List stringsToDisplay, ArrowConfiguration arrowConfiguration) { + super(foregroundColor, fontColor, font, stringsToDisplay, arrowConfiguration); } @Override @@ -66,49 +62,87 @@ public class ComponentRoseArrow extends AbstractComponentRoseArrow { final int x2 = (int) dimensionToUse.getWidth(); - if (isDotted()) { + if (getArrowConfiguration().isDotted()) { stroke(ug, 2); } // ug.draw(0, textHeight, new ULine(x2, 0)); - if (isDotted()) { + if (getArrowConfiguration().isDotted()) { ug.getParam().setStroke(new UStroke()); } final int direction = getDirection(); if (direction == 1) { - if (isFull()) { + if (getArrowConfiguration().isASync()) { + if (getArrowConfiguration().getPart() != ArrowPart.BOTTOM_PART) { + ug.draw(x2, textHeight, new ULine(-getArrowDeltaX(), -getArrowDeltaY())); + } + if (getArrowConfiguration().getPart() != ArrowPart.TOP_PART) { + ug.draw(x2, textHeight, new ULine(-getArrowDeltaX(), getArrowDeltaY())); + } + } else { ug.getParam().setBackcolor(getForegroundColor()); - final UPolygon polygon = new UPolygon(); - polygon.addPoint(x2 - getArrowDeltaX(), textHeight - getArrowDeltaY()); - polygon.addPoint(x2, textHeight); - polygon.addPoint(x2 - getArrowDeltaX(), textHeight + getArrowDeltaY()); + final UPolygon polygon = getPolygonNormal(textHeight, x2); ug.draw(0, 0, polygon); ug.getParam().setBackcolor(null); - } else { - ug.draw(x2, textHeight, new ULine(-getArrowDeltaX(), -getArrowDeltaY())); - ug.draw(x2, textHeight, new ULine(-getArrowDeltaX(), getArrowDeltaY())); } } else { - if (isFull()) { + if (getArrowConfiguration().isASync()) { + if (getArrowConfiguration().getPart() != ArrowPart.BOTTOM_PART) { + ug.draw(0, textHeight, new ULine(getArrowDeltaX(), -getArrowDeltaY())); + } + if (getArrowConfiguration().getPart() != ArrowPart.TOP_PART) { + ug.draw(0, textHeight, new ULine(getArrowDeltaX(), getArrowDeltaY())); + } + } else { ug.getParam().setBackcolor(getForegroundColor()); - final UPolygon polygon = new UPolygon(); - polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY()); - polygon.addPoint(0, textHeight); - polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY()); + final UPolygon polygon = getPolygonReverse(textHeight); ug.draw(0, 0, polygon); ug.getParam().setBackcolor(null); - } else { - ug.draw(0, textHeight, new ULine(getArrowDeltaX(), -getArrowDeltaY())); - ug.draw(0, textHeight, new ULine(getArrowDeltaX(), getArrowDeltaY())); } } getTextBlock().drawU(ug, getMarginX1(), 0); } + private UPolygon getPolygonNormal(final int textHeight, final int x2) { + final UPolygon polygon = new UPolygon(); + if (getArrowConfiguration().getPart() == ArrowPart.TOP_PART) { + polygon.addPoint(x2 - getArrowDeltaX(), textHeight - getArrowDeltaY()); + polygon.addPoint(x2, textHeight); + polygon.addPoint(x2 - getArrowDeltaX(), textHeight); + } else if (getArrowConfiguration().getPart() == ArrowPart.BOTTOM_PART) { + polygon.addPoint(x2 - getArrowDeltaX(), textHeight); + polygon.addPoint(x2, textHeight); + polygon.addPoint(x2 - getArrowDeltaX(), textHeight + getArrowDeltaY()); + } else { + polygon.addPoint(x2 - getArrowDeltaX(), textHeight - getArrowDeltaY()); + polygon.addPoint(x2, textHeight); + polygon.addPoint(x2 - getArrowDeltaX(), textHeight + getArrowDeltaY()); + } + return polygon; + } + + private UPolygon getPolygonReverse(final int textHeight) { + final UPolygon polygon = new UPolygon(); + if (getArrowConfiguration().getPart() == ArrowPart.TOP_PART) { + polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY()); + polygon.addPoint(0, textHeight); + polygon.addPoint(getArrowDeltaX(), textHeight); + } else if (getArrowConfiguration().getPart() == ArrowPart.BOTTOM_PART) { + polygon.addPoint(getArrowDeltaX(), textHeight); + polygon.addPoint(0, textHeight); + polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY()); + } else { + polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY()); + polygon.addPoint(0, textHeight); + polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY()); + } + return polygon; + } + public Point2D getStartPoint(StringBounder stringBounder, Dimension2D dimensionToUse) { final int textHeight = (int) getTextHeight(stringBounder); - if (direction == 1) { + if (getDirection() == 1) { return new Point2D.Double(getPaddingX(), textHeight + getPaddingY()); } return new Point2D.Double(dimensionToUse.getWidth() + getPaddingX(), textHeight + getPaddingY()); @@ -116,14 +150,20 @@ public class ComponentRoseArrow extends AbstractComponentRoseArrow { public Point2D getEndPoint(StringBounder stringBounder, Dimension2D dimensionToUse) { final int textHeight = (int) getTextHeight(stringBounder); - if (direction == 1) { + if (getDirection() == 1) { return new Point2D.Double(dimensionToUse.getWidth() + getPaddingX(), textHeight + getPaddingY()); } return new Point2D.Double(getPaddingX(), textHeight + getPaddingY()); } final protected int getDirection() { - return direction; + if (getArrowConfiguration().isLeftToRightNormal()) { + return 1; + } + if (getArrowConfiguration().isRightToLeftReverse()) { + return -1; + } + throw new IllegalStateException(); } @Override diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java index 24a5def2e..19384a00c 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4633 $ + * Revision $Revision: 5926 $ * */ package net.sourceforge.plantuml.skin.rose; @@ -40,6 +40,8 @@ import java.awt.geom.Point2D; import java.util.List; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.skin.ArrowConfiguration; +import net.sourceforge.plantuml.skin.ArrowPart; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.UPolygon; @@ -50,8 +52,8 @@ public class ComponentRoseSelfArrow extends AbstractComponentRoseArrow { private final double arrowWidth = 45; public ComponentRoseSelfArrow(Color foregroundColor, Color colorFont, Font font, - List stringsToDisplay, boolean dotted, boolean full) { - super(foregroundColor, colorFont, font, stringsToDisplay, dotted, full); + List stringsToDisplay, ArrowConfiguration arrowConfiguration) { + super(foregroundColor, colorFont, font, stringsToDisplay, arrowConfiguration); } @Override @@ -62,7 +64,7 @@ public class ComponentRoseSelfArrow extends AbstractComponentRoseArrow { ug.getParam().setColor(getForegroundColor()); final double x2 = arrowWidth; - if (isDotted()) { + if (getArrowConfiguration().isDotted()) { stroke(ug, 2); } @@ -73,28 +75,45 @@ public class ComponentRoseSelfArrow extends AbstractComponentRoseArrow { ug.draw(x2, textHeight, new ULine(0, textAndArrowHeight - textHeight)); ug.draw(0, textAndArrowHeight, new ULine(x2, 0)); - if (isDotted()) { + if (getArrowConfiguration().isDotted()) { ug.getParam().setStroke(new UStroke()); } -// ug.draw(0, textAndArrowHeight, new ULine(getArrowDeltaX(), -getArrowDeltaY())); -// ug.draw(0, textAndArrowHeight, new ULine(getArrowDeltaX(), getArrowDeltaY())); - if (isFull()) { + if (getArrowConfiguration().isASync()) { + if (getArrowConfiguration().getPart() != ArrowPart.BOTTOM_PART) { + ug.draw(0, textAndArrowHeight, new ULine(getArrowDeltaX(), -getArrowDeltaY())); + } + if (getArrowConfiguration().getPart() != ArrowPart.TOP_PART) { + ug.draw(0, textAndArrowHeight, new ULine(getArrowDeltaX(), getArrowDeltaY())); + } + } else { ug.getParam().setBackcolor(getForegroundColor()); - final UPolygon polygon = new UPolygon(); - polygon.addPoint(getArrowDeltaX(), textAndArrowHeight - getArrowDeltaY()); - polygon.addPoint(0, textAndArrowHeight); - polygon.addPoint(getArrowDeltaX(), textAndArrowHeight + getArrowDeltaY()); + final UPolygon polygon = getPolygon(textAndArrowHeight); ug.draw(0, 0, polygon); ug.getParam().setBackcolor(null); - } else { - ug.draw(0, textHeight, new ULine(getArrowDeltaX(), -getArrowDeltaY())); - ug.draw(0, textHeight, new ULine(getArrowDeltaX(), getArrowDeltaY())); } getTextBlock().drawU(ug, getMarginX1(), 0); } + private UPolygon getPolygon(final double textAndArrowHeight) { + final UPolygon polygon = new UPolygon(); + if (getArrowConfiguration().getPart() == ArrowPart.TOP_PART) { + polygon.addPoint(getArrowDeltaX(), textAndArrowHeight - getArrowDeltaY()); + polygon.addPoint(0, textAndArrowHeight); + polygon.addPoint(getArrowDeltaX(), textAndArrowHeight); + } else if (getArrowConfiguration().getPart() == ArrowPart.BOTTOM_PART) { + polygon.addPoint(getArrowDeltaX(), textAndArrowHeight); + polygon.addPoint(0, textAndArrowHeight); + polygon.addPoint(getArrowDeltaX(), textAndArrowHeight + getArrowDeltaY()); + } else { + polygon.addPoint(getArrowDeltaX(), textAndArrowHeight - getArrowDeltaY()); + polygon.addPoint(0, textAndArrowHeight); + polygon.addPoint(getArrowDeltaX(), textAndArrowHeight + getArrowDeltaY()); + } + return polygon; + } + public Point2D getStartPoint(StringBounder stringBounder, Dimension2D dimensionToUse) { final int textHeight = (int) getTextHeight(stringBounder); return new Point2D.Double(getPaddingX(), textHeight + getPaddingY()); diff --git a/src/net/sourceforge/plantuml/skin/rose/Rose.java b/src/net/sourceforge/plantuml/skin/rose/Rose.java index 782c0732c..741904000 100644 --- a/src/net/sourceforge/plantuml/skin/rose/Rose.java +++ b/src/net/sourceforge/plantuml/skin/rose/Rose.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5823 $ + * Revision $Revision: 5922 $ * */ package net.sourceforge.plantuml.skin.rose; @@ -124,12 +124,11 @@ public class Rose implements Skin { public Color getFontColor(ISkinParam skin, FontParam fontParam) { return skin.getFontHtmlColor(fontParam, null).getColor(); } - + public HtmlColor getHtmlColor(ISkinParam param, ColorParam color) { return getHtmlColor(param, color, null); } - public HtmlColor getHtmlColor(ISkinParam param, ColorParam color, String stereotype) { HtmlColor result = param.getHtmlColor(color, stereotype); if (result == null) { @@ -158,48 +157,15 @@ public class Rose implements Skin { final Font fontParticipant = param.getFont(FontParam.SEQUENCE_PARTICIPANT, null); final Font fontActor = param.getFont(FontParam.SEQUENCE_ACTOR, null); - if (type == ComponentType.SELF_ARROW) { - return new ComponentRoseSelfArrow(sequenceArrow, getFontColor(param, FontParam.SEQUENCE_ARROW), fontArrow, - stringsToDisplay, false, true); - } - if (type == ComponentType.DOTTED_SELF_ARROW) { - return new ComponentRoseSelfArrow(sequenceArrow, getFontColor(param, FontParam.SEQUENCE_ARROW), fontArrow, - stringsToDisplay, true, true); - } - if (type == ComponentType.ARROW) { + if (type.isArrow()) { + if (type.getArrowConfiguration().isSelfArrow()) { + return new ComponentRoseSelfArrow(sequenceArrow, getFontColor(param, FontParam.SEQUENCE_ARROW), + fontArrow, stringsToDisplay, type.getArrowConfiguration()); + } return new ComponentRoseArrow(sequenceArrow, getFontColor(param, FontParam.SEQUENCE_ARROW), fontArrow, - stringsToDisplay, 1, false, true); - } - if (type == ComponentType.ASYNC_ARROW) { - return new ComponentRoseArrow(sequenceArrow, getFontColor(param, FontParam.SEQUENCE_ARROW), fontArrow, - stringsToDisplay, 1, false, false); - } + stringsToDisplay, type.getArrowConfiguration()); - if (type == ComponentType.RETURN_ARROW) { - return new ComponentRoseArrow(sequenceArrow, getFontColor(param, FontParam.SEQUENCE_ARROW), fontArrow, - stringsToDisplay, -1, false, true); } - if (type == ComponentType.ASYNC_RETURN_ARROW) { - return new ComponentRoseArrow(sequenceArrow, getFontColor(param, FontParam.SEQUENCE_ARROW), fontArrow, - stringsToDisplay, -1, false, false); - } - if (type == ComponentType.DOTTED_ARROW) { - return new ComponentRoseArrow(sequenceArrow, getFontColor(param, FontParam.SEQUENCE_ARROW), fontArrow, - stringsToDisplay, 1, true, true); - } - if (type == ComponentType.ASYNC_DOTTED_ARROW) { - return new ComponentRoseArrow(sequenceArrow, getFontColor(param, FontParam.SEQUENCE_ARROW), fontArrow, - stringsToDisplay, 1, true, false); - } - if (type == ComponentType.RETURN_DOTTED_ARROW) { - return new ComponentRoseArrow(sequenceArrow, getFontColor(param, FontParam.SEQUENCE_ARROW), fontArrow, - stringsToDisplay, -1, true, true); - } - if (type == ComponentType.ASYNC_RETURN_DOTTED_ARROW) { - return new ComponentRoseArrow(sequenceArrow, getFontColor(param, FontParam.SEQUENCE_ARROW), fontArrow, - stringsToDisplay, -1, true, false); - } - if (type == ComponentType.PARTICIPANT_HEAD) { final Color borderColor = getHtmlColor(param, ColorParam.sequenceParticipantBorder).getColor(); return new ComponentRoseParticipant(sequenceParticipantBackground, borderColor, getFontColor(param, @@ -262,12 +228,12 @@ public class Rose implements Skin { return new ComponentRoseNewpage(getFontColor(param, FontParam.SEQUENCE_GROUPING)); } if (type == ComponentType.DIVIDER) { - return new ComponentRoseDivider(getFontColor(param, FontParam.SEQUENCE_DIVIDER), param - .getFont(FontParam.SEQUENCE_DIVIDER, null), sequenceDividerBackground, stringsToDisplay); + return new ComponentRoseDivider(getFontColor(param, FontParam.SEQUENCE_DIVIDER), param.getFont( + FontParam.SEQUENCE_DIVIDER, null), sequenceDividerBackground, stringsToDisplay); } if (type == ComponentType.TITLE) { - return new ComponentRoseTitle(getFontColor(param, FontParam.SEQUENCE_TITLE), param - .getFont(FontParam.SEQUENCE_TITLE, null), stringsToDisplay); + return new ComponentRoseTitle(getFontColor(param, FontParam.SEQUENCE_TITLE), param.getFont( + FontParam.SEQUENCE_TITLE, null), stringsToDisplay); } if (type == ComponentType.SIGNATURE) { return new ComponentRoseTitle(Color.BLACK, fontGrouping, Arrays.asList("This skin was created ", diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 15c01403d..ebfe1231c 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5912 $ + * Revision $Revision: 5931 $ * */ package net.sourceforge.plantuml.version; @@ -36,11 +36,11 @@ package net.sourceforge.plantuml.version; public class Version { public static int version() { - return 5911; + return 5930; } public static long compileTime() { - return 1294598580421L; + return 1294686127593L; } }