From 5ddc03f92d231377260330e5ed998af6162bfc3d Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Sun, 23 Jan 2011 20:36:52 +0100 Subject: [PATCH] Version 6035 --- pom.xml | 187 ++++++++++++++++++ .../sourceforge/plantuml/AbstractPSystem.java | 4 +- src/net/sourceforge/plantuml/ErrorUml.java | 4 +- src/net/sourceforge/plantuml/OptionFlags.java | 4 +- src/net/sourceforge/plantuml/OptionPrint.java | 48 +---- .../sourceforge/plantuml/PSystemError.java | 10 +- .../plantuml/PSystemSingleBuilder.java | 24 ++- src/net/sourceforge/plantuml/SkinParam.java | 10 +- src/net/sourceforge/plantuml/UmlSource.java | 15 ++ .../activitydiagram/command/CommandEndif.java | 2 +- .../command/CommandPartition.java | 4 +- .../activitydiagram2/ActivityDiagram2.java | 74 +++++-- .../ActivityDiagramFactory2.java | 12 +- .../activitydiagram2/ConditionalContext2.java | 6 +- .../activitydiagram2/PendingLink.java | 56 ++++++ .../command/CommandGoto2.java | 65 ++++++ .../activitydiagram2/command/CommandIf2.java | 2 +- .../command/CommandLabel2.java | 65 ++++++ ...Activity.java => CommandNewActivity2.java} | 11 +- .../{CommandStart.java => CommandStart2.java} | 4 +- .../plantuml/asciiart/TextSkin.java | 7 +- .../command/CommandLinkClass2.java | 1 - .../command/CommandNamespace.java | 2 +- .../code/ArobaseStringCompressor.java | 26 ++- .../AbstractUmlSystemCommandFactory.java | 6 +- .../plantuml/command/CommandPackage.java | 4 +- .../command/PSystemCommandFactory.java | 3 +- .../plantuml/cucadiagram/Link.java | 7 +- .../plantuml/cucadiagram/Stereotype.java | 5 +- .../cucadiagram/dot/AbstractGraphviz.java | 12 +- .../plantuml/cucadiagram/dot/DotMaker.java | 54 +++-- .../cucadiagram/dot/GraphvizUtils.java | 87 +++++++- .../plantuml/cucadiagram/dot/PlayField.java | 12 +- .../sourceforge/plantuml/graph/Elastane.java | 10 +- .../plantuml/graph/EntityImageActivity.java | 9 +- .../plantuml/graph/EntityImageActor.java | 7 +- .../graph/EntityImageCircleInterface.java | 41 ++-- .../plantuml/graph/EntityImageClass.java | 7 +- .../plantuml/graph/EntityImageComponent.java | 7 +- .../plantuml/graph/EntityImageDefault.java | 7 +- .../plantuml/graph/EntityImageNote.java | 7 +- .../plantuml/graph/EntityImageUsecase.java | 7 +- .../plantuml/graph/MethodsOrFieldsArea.java | 6 +- .../plantuml/graph/MethodsOrFieldsArea2.java | 3 +- .../plantuml/graphic/ColorAndSizeChange.java | 4 +- .../plantuml/graphic/ColorChange.java | 2 +- .../plantuml/graphic/FontStyle.java | 12 +- .../plantuml/graphic/GraphicStrings.java | 5 +- .../plantuml/graphic/HtmlColor.java | 17 +- .../plantuml/graphic/SingleLine.java | 6 +- .../plantuml/graphic/TextBlockSimple.java | 19 +- .../plantuml/graphic/TextBlockSpotted.java | 56 +++--- .../plantuml/graphic/TextBlockUtils.java | 31 ++- .../plantuml/graphic/TextBlockWithNumber.java | 12 +- .../sourceforge/plantuml/png/PngTitler.java | 8 +- .../plantuml/posimo/EntityImageBlock.java | 5 +- .../plantuml/posimo/EntityImageClass2.java | 12 +- .../sourceforge/plantuml/posimo/Frame.java | 4 +- .../plantuml/posimo/LabelImage.java | 7 +- .../plantuml/printskin/PrintSkin.java | 23 +-- .../graphic/DrawableSetInitializer.java | 29 ++- .../sequencediagram/graphic/LifeLine.java | 25 ++- .../graphic/LivingParticipantBox.java | 6 +- .../sequencediagram/graphic/MessageArrow.java | 6 +- .../graphic/MessageExoArrow.java | 6 +- .../graphic/MessageSelfArrow.java | 4 +- .../sequencediagram/graphic/NoteBox.java | 22 +-- .../graphic/ParticipantBox.java | 24 ++- .../graphic/ParticipantBoxSimple.java | 8 +- .../sequencediagram/graphic/Pushable.java | 7 +- .../sequencediagram/graphic/Segment.java | 69 ++++--- .../graphic/SegmentColored.java | 99 ++++++++++ .../sequencediagram/graphic/Step1Message.java | 5 +- .../skin/AbstractTextualComponent.java | 5 +- .../plantuml/skin/ComponentType.java | 7 +- .../plantuml/skin/GrayComponent.java | 6 +- .../plantuml/skin/bluemodern/BlueModern.java | 8 +- .../ComponentBlueModernGroupingHeader.java | 14 +- .../ComponentBlueModernSelfArrow.java | 8 +- .../skin/rose/ComponentRoseDelayLine.java | 13 +- .../rose/ComponentRoseGroupingHeader.java | 29 ++- .../plantuml/skin/rose/ComponentRoseLine.java | 12 +- .../sourceforge/plantuml/skin/rose/Rose.java | 126 ++++++------ .../command/CommandCreatePackageState.java | 4 +- .../command/CommandCreatePackageState2.java | 2 +- .../plantuml/sudoku/GraphicsSudoku.java | 10 +- .../plantuml/suggest/SuggestEngine.java | 62 +++--- .../plantuml/suggest/SuggestEngineResult.java | 39 +++- .../plantuml/suggest/Variator.java | 41 ++++ .../plantuml/suggest/VariatorAddOneChar.java | 62 ++++++ .../VariatorAddOneCharBetweenWords.java | 76 +++++++ .../plantuml/suggest/VariatorAddTwoChar.java | 67 +++++++ .../suggest/VariatorIteratorAdaptor.java | 66 +++++++ .../suggest/VariatorRemoveOneChar.java | 60 ++++++ .../plantuml/suggest/VariatorSwapChar.java | 60 ++++++ .../plantuml/suggest/VariatorSwapLetter.java | 74 +++++++ .../sourceforge/plantuml/svg/SvgTitler.java | 4 +- .../plantuml/ugraphic/UGraphic.java | 6 +- .../plantuml/ugraphic/UGraphicUtils.java | 4 + .../plantuml/ugraphic/eps/UGraphicEps.java | 3 + .../plantuml/ugraphic/g2d/DriverTextG2d.java | 20 +- .../plantuml/ugraphic/g2d/UGraphicG2d.java | 12 +- .../plantuml/ugraphic/svg/UGraphicSvg.java | 4 + .../plantuml/ugraphic/txt/UGraphicTxt.java | 3 + .../plantuml/version/PSystemVersion.java | 9 +- .../sourceforge/plantuml/version/Version.java | 6 +- 106 files changed, 1861 insertions(+), 538 deletions(-) create mode 100644 pom.xml create mode 100644 src/net/sourceforge/plantuml/activitydiagram2/PendingLink.java create mode 100644 src/net/sourceforge/plantuml/activitydiagram2/command/CommandGoto2.java create mode 100644 src/net/sourceforge/plantuml/activitydiagram2/command/CommandLabel2.java rename src/net/sourceforge/plantuml/activitydiagram2/command/{CommandNewActivity.java => CommandNewActivity2.java} (86%) rename src/net/sourceforge/plantuml/activitydiagram2/command/{CommandStart.java => CommandStart2.java} (93%) create mode 100644 src/net/sourceforge/plantuml/sequencediagram/graphic/SegmentColored.java create mode 100644 src/net/sourceforge/plantuml/suggest/Variator.java create mode 100644 src/net/sourceforge/plantuml/suggest/VariatorAddOneChar.java create mode 100644 src/net/sourceforge/plantuml/suggest/VariatorAddOneCharBetweenWords.java create mode 100644 src/net/sourceforge/plantuml/suggest/VariatorAddTwoChar.java create mode 100644 src/net/sourceforge/plantuml/suggest/VariatorIteratorAdaptor.java create mode 100644 src/net/sourceforge/plantuml/suggest/VariatorRemoveOneChar.java create mode 100644 src/net/sourceforge/plantuml/suggest/VariatorSwapChar.java create mode 100644 src/net/sourceforge/plantuml/suggest/VariatorSwapLetter.java diff --git a/pom.xml b/pom.xml new file mode 100644 index 000000000..df51959cf --- /dev/null +++ b/pom.xml @@ -0,0 +1,187 @@ + + + + 4.0.0 + + net.sourceforge.plantuml + plantuml + 1.0.6035-SNAPSHOT + jar + + PlantUML + + PlantUML is a component that allows to quickly write : + * sequence diagram, + * use case diagram, + * class diagram, + * activity diagram, + * component diagram, + * state diagram + * object diagram + + http://plantuml.sourceforge.net + + + org.sonatype.oss + oss-parent + 5 + + + + + org.apache.ant + ant + 1.8.1 + provided + + + + + + The GNU General Public License + http://www.gnu.org/licenses/gpl.txt + repo + + + + + http://plantuml.svn.sourceforge.net/viewvc/plantuml + https://plantuml.svn.sourceforge.net/svnroot/plantuml + + + + Sourceforge + http://sourceforge.net/tracker/?group_id=259736 + + + + + arnaud.roques + Arnaud Roques + plantuml@gmail.com + + + + + ${project.basedir}/src + + + ${project.basedir}/src + + net/sourceforge/plantuml/version/logo.png + + + + + + maven-compiler-plugin + 2.3.2 + + 1.5 + 1.5 + false + + + + maven-source-plugin + + + attach-sources + + jar + + + + + + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + + + maven-jar-plugin + + + + net.sourceforge.plantuml.Run + + + + + + maven-release-plugin + 2.1 + + forked-path + + + + + + + + release-sign-artifacts + + + performRelease + true + + + + + + maven-gpg-plugin + 1.1 + + + sign-artifacts + verify + + sign + + + + + + + + + + diff --git a/src/net/sourceforge/plantuml/AbstractPSystem.java b/src/net/sourceforge/plantuml/AbstractPSystem.java index 0ebf56725..270a4d5d2 100644 --- a/src/net/sourceforge/plantuml/AbstractPSystem.java +++ b/src/net/sourceforge/plantuml/AbstractPSystem.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5520 $ + * Revision $Revision: 6002 $ * */ package net.sourceforge.plantuml; @@ -77,5 +77,5 @@ public abstract class AbstractPSystem implements PSystem { public int getNbImages() { return 1; } - + } diff --git a/src/net/sourceforge/plantuml/ErrorUml.java b/src/net/sourceforge/plantuml/ErrorUml.java index d93f1a6dd..951ad25d9 100644 --- a/src/net/sourceforge/plantuml/ErrorUml.java +++ b/src/net/sourceforge/plantuml/ErrorUml.java @@ -60,12 +60,12 @@ class ErrorUml { @Override public int hashCode() { - return error.hashCode() + type.hashCode() + position; + return error.hashCode() + type.hashCode() + position + (suggest == null ? 0 : suggest.hashCode()); } @Override public String toString() { - return type.toString() + " " + position + " " + error; + return type.toString() + " " + position + " " + error + " " + suggest; } public final String getError() { diff --git a/src/net/sourceforge/plantuml/OptionFlags.java b/src/net/sourceforge/plantuml/OptionFlags.java index 73917cf88..00d43a03e 100644 --- a/src/net/sourceforge/plantuml/OptionFlags.java +++ b/src/net/sourceforge/plantuml/OptionFlags.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5974 $ + * Revision $Revision: 5977 $ * */ package net.sourceforge.plantuml; @@ -36,7 +36,7 @@ package net.sourceforge.plantuml; public class OptionFlags { static public final boolean PBBACK = false; - static public final boolean SUGGEST = false; + static public final boolean SUGGEST = true; void reset() { keepTmpFiles = false; diff --git a/src/net/sourceforge/plantuml/OptionPrint.java b/src/net/sourceforge/plantuml/OptionPrint.java index 00b4c66f0..37d1dab4f 100644 --- a/src/net/sourceforge/plantuml/OptionPrint.java +++ b/src/net/sourceforge/plantuml/OptionPrint.java @@ -28,17 +28,14 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5211 $ + * Revision $Revision: 6007 $ * */ package net.sourceforge.plantuml; import java.io.File; import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Collections; import java.util.Date; -import java.util.List; import java.util.Properties; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils; @@ -47,53 +44,12 @@ import net.sourceforge.plantuml.version.Version; public class OptionPrint { static public void printTestDot() throws InterruptedException { - for (String s : getTestDotStrings()) { + for (String s : GraphvizUtils.getTestDotStrings(false)) { System.err.println(s); } exit(); } - static public List getTestDotStrings() { - final List result = new ArrayList(); - final String ent = GraphvizUtils.getenvGraphvizDot(); - if (ent == null) { - result.add("The environment variable GRAPHVIZ_DOT has not been set"); - } else { - result.add("The environment variable GRAPHVIZ_DOT has been set to " + ent); - } - final File dotExe = GraphvizUtils.getDotExe(); - result.add("Dot executable is " + dotExe); - - boolean ok = true; - if (dotExe == null) { - result.add("Error: No dot executable found"); - ok = false; - } else if (dotExe.exists() == false) { - result.add("Error: file does not exist"); - ok = false; - } else if (dotExe.isFile() == false) { - result.add("Error: not a valid file"); - ok = false; - } else if (dotExe.canRead() == false) { - result.add("Error: cannot be read"); - ok = false; - } - - if (ok) { - try { - final String version = GraphvizUtils.dotVersion(); - result.add("Dot version: " + version); - result.add("Installation seems OK"); - } catch (Exception e) { - e.printStackTrace(); - } - } else { - result.add("Error: only sequence diagrams will be generated"); - } - - return Collections.unmodifiableList(result); - } - static public void printHelp() throws InterruptedException { final String charset = Charset.defaultCharset().displayName(); diff --git a/src/net/sourceforge/plantuml/PSystemError.java b/src/net/sourceforge/plantuml/PSystemError.java index 830bacb9e..ab0a57252 100644 --- a/src/net/sourceforge/plantuml/PSystemError.java +++ b/src/net/sourceforge/plantuml/PSystemError.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5971 $ + * Revision $Revision: 5999 $ */ package net.sourceforge.plantuml; @@ -132,9 +132,13 @@ public class PSystemError extends AbstractPSystem { underscore.append("^"); } plainStrings.add(underscore.toString()); + final Collection textErrors = new LinkedHashSet(); for (ErrorUml er : printedErrors) { - htmlStrings.add(" " + er.getError()); - plainStrings.add(" " + er.getError()); + textErrors.add(er.getError()); + } + for (String er : textErrors) { + htmlStrings.add(" " + er); + plainStrings.add(" " + er); } boolean suggested = false; for (ErrorUml er : printedErrors) { diff --git a/src/net/sourceforge/plantuml/PSystemSingleBuilder.java b/src/net/sourceforge/plantuml/PSystemSingleBuilder.java index c228387ec..621f12d01 100644 --- a/src/net/sourceforge/plantuml/PSystemSingleBuilder.java +++ b/src/net/sourceforge/plantuml/PSystemSingleBuilder.java @@ -39,6 +39,7 @@ import java.util.Arrays; import java.util.Iterator; import java.util.List; +import net.sourceforge.plantuml.command.AbstractUmlSystemCommandFactory; import net.sourceforge.plantuml.command.Command; import net.sourceforge.plantuml.command.CommandControl; import net.sourceforge.plantuml.command.CommandExecutionResult; @@ -76,7 +77,9 @@ final public class PSystemSingleBuilder { throw new UnsupportedOperationException(); } - if (systemFactory instanceof PSystemCommandFactory) { + if (s.isEmpty()) { + sys = buildEmptyError(); + } else if (systemFactory instanceof PSystemCommandFactory) { executeUmlCommand((PSystemCommandFactory) systemFactory); } else if (systemFactory instanceof PSystemBasicFactory) { executeUmlBasic((PSystemBasicFactory) systemFactory); @@ -89,7 +92,8 @@ final public class PSystemSingleBuilder { final String s = next(); if (BlockUmlBuilder.isArobaseEnduml(s)) { if (source.getSize() == 2) { - sys = buildEmptyError(source); + assert false; + sys = buildEmptyError(); } else { sys = (AbstractPSystem) systemFactory.getSystem(); } @@ -109,9 +113,16 @@ final public class PSystemSingleBuilder { sys.setSource(source); } - private PSystemError buildEmptyError(UmlSource source) { + private PSystemError buildEmptyError() { final PSystemError result = new PSystemError(source, new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Empty description", 1)); + result.setSource(source); + return result; + } + + private PSystemError buildEmptyError(String err) { + final PSystemError result = new PSystemError(source, new ErrorUml(ErrorUmlType.EXECUTION_ERROR, err, 1)); + result.setSource(source); return result; } @@ -120,8 +131,13 @@ final public class PSystemSingleBuilder { while (hasNext()) { final String s = next(); if (BlockUmlBuilder.isArobaseEnduml(s)) { + final String err = ((AbstractUmlSystemCommandFactory) systemFactory).checkFinalError(); + if (err != null) { + sys = buildEmptyError(err); + } if (source.getSize() == 2) { - sys = buildEmptyError(source); + assert false; + sys = buildEmptyError(); } else { sys = (AbstractPSystem) systemFactory.getSystem(); } diff --git a/src/net/sourceforge/plantuml/SkinParam.java b/src/net/sourceforge/plantuml/SkinParam.java index 26171e852..3be8dd19a 100644 --- a/src/net/sourceforge/plantuml/SkinParam.java +++ b/src/net/sourceforge/plantuml/SkinParam.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5845 $ + * Revision $Revision: 5983 $ * */ package net.sourceforge.plantuml; @@ -72,7 +72,7 @@ public class SkinParam implements ISkinParam { public HtmlColor getBackgroundColor() { final HtmlColor result = getHtmlColor(ColorParam.background, null); if (result == null) { - return new HtmlColor("white"); + return HtmlColor.getColorIfValid("white"); } return result; } @@ -101,14 +101,14 @@ public class SkinParam implements ISkinParam { checkStereotype(stereotype); final String value2 = getValue(param.name() + "color" + stereotype); if (value2 != null && HtmlColor.isValid(value2)) { - return new HtmlColor(value2); + return HtmlColor.getColorIfValid(value2); } } final String value = getValue(param.name() + "color"); if (value == null || HtmlColor.isValid(value) == false) { return null; } - return new HtmlColor(value); + return HtmlColor.getColorIfValid(value); } private void checkStereotype(String stereotype) { @@ -172,7 +172,7 @@ public class SkinParam implements ISkinParam { if (value == null || HtmlColor.isValid(value) == false) { value = param.getDefaultColor(); } - return new HtmlColor(value); + return HtmlColor.getColorIfValid(value); } public int getFontStyle(FontParam param, String stereotype) { diff --git a/src/net/sourceforge/plantuml/UmlSource.java b/src/net/sourceforge/plantuml/UmlSource.java index d1e3f779f..1c422c688 100644 --- a/src/net/sourceforge/plantuml/UmlSource.java +++ b/src/net/sourceforge/plantuml/UmlSource.java @@ -80,4 +80,19 @@ final public class UmlSource { return source.size(); } + public boolean isEmpty() { + for (String s : source) { + if (BlockUmlBuilder.isArobaseStartuml(s)) { + continue; + } + if (BlockUmlBuilder.isArobaseEnduml(s)) { + continue; + } + if (s.trim().length() != 0) { + return false; + } + } + return true; + } + } diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndif.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndif.java index 7b0b7acdd..ae51eec5b 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndif.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandEndif.java @@ -42,7 +42,7 @@ import net.sourceforge.plantuml.command.SingleLineCommand; public class CommandEndif extends SingleLineCommand { public CommandEndif(ActivityDiagram diagram) { - super(diagram, "(?i)^endif$"); + super(diagram, "(?i)^end ?if$"); } @Override diff --git a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java index f2379baea..0cee587aa 100644 --- a/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java +++ b/src/net/sourceforge/plantuml/activitydiagram/command/CommandPartition.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5048 $ + * Revision $Revision: 5983 $ * */ package net.sourceforge.plantuml.activitydiagram.command; @@ -57,7 +57,7 @@ public class CommandPartition extends SingleLineCommand { p.setBold(true); final String color = arg.get(1); if (color != null) { - p.setBackColor(new HtmlColor(color)); + p.setBackColor(HtmlColor.getColorIfValid(color)); } return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagram2.java b/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagram2.java index 7a7b315ad..b251d32f3 100644 --- a/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagram2.java +++ b/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagram2.java @@ -36,7 +36,11 @@ package net.sourceforge.plantuml.activitydiagram2; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; import java.util.List; +import java.util.Map; import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.UmlDiagramType; @@ -51,10 +55,13 @@ import net.sourceforge.plantuml.cucadiagram.LinkType; public class ActivityDiagram2 extends CucaDiagram { - private Collection last2 = new ArrayList(); + private Collection waitings = new ArrayList(); private ConditionalContext2 currentContext; private int futureLength = 2; + private final Collection pendingLabels = new HashSet(); + private final Map labels = new HashMap(); + final protected List getDotStrings() { return Arrays.asList("nodesep=.20;", "ranksep=0.4;", "edge [fontsize=11,labelfontsize=11];", "node [fontsize=11];"); @@ -69,16 +76,26 @@ public class ActivityDiagram2 extends CucaDiagram { return UmlDiagramType.ACTIVITY; } + public boolean isReachable() { + return waitings.size() > 0; + } + public void newActivity(String display) { - if (last2.size() == 0) { + if (waitings.size() == 0) { throw new IllegalStateException(); } final Entity act = createEntity(getAutoCode(), display, EntityType.ACTIVITY); - for (IEntity last : this.last2) { + for (IEntity last : this.waitings) { this.addLink(new Link(last, act, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), null, futureLength)); } - this.last2.clear(); - this.last2.add(act); + + for (String p : pendingLabels) { + labels.put(p, act); + } + pendingLabels.clear(); + + this.waitings.clear(); + this.waitings.add(act); this.futureLength = 2; } @@ -88,36 +105,61 @@ public class ActivityDiagram2 extends CucaDiagram { } public void start() { - if (last2.size() != 0) { + if (waitings.size() != 0) { throw new IllegalStateException(); } - this.last2.add(createEntity("start", "start", EntityType.CIRCLE_START)); + this.waitings.add(createEntity("start", "start", EntityType.CIRCLE_START)); } public void startIf(String test) { final IEntity br = createEntity(getAutoCode(), "", EntityType.BRANCH); currentContext = new ConditionalContext2(currentContext, br, Direction.DOWN); - for (IEntity last : this.last2) { + for (IEntity last : this.waitings) { this.addLink(new Link(last, br, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), null, futureLength)); } - this.last2.clear(); - this.last2.add(br); - this.futureLength = 1; + this.waitings.clear(); + this.waitings.add(br); + this.futureLength = 2; } public Collection getLastEntityConsulted2() { - return this.last2; + return this.waitings; } public void endif() { - this.last2.add(currentContext.getPending()); + this.waitings.add(currentContext.getPending()); currentContext = currentContext.getParent(); } public void else2() { - this.currentContext.setPending(this.last2.iterator().next()); - this.last2.clear(); - this.last2.add(currentContext.getBranch()); + this.currentContext.setPending(this.waitings.iterator().next()); + this.waitings.clear(); + this.waitings.add(currentContext.getBranch()); } + public void label(String label) { + pendingLabels.add(label); + for (final Iterator it = pendingLinks.iterator(); it.hasNext();) { + final PendingLink pending = it.next(); + if (pending.getLabel().equals(label)) { + waitings.add(pending.getEntityFrom()); + it.remove(); + } + } + } + + private final Collection pendingLinks = new ArrayList(); + + public void callGoto(String label) { + final IEntity dest = labels.get(label); + for (IEntity last : this.waitings) { + if (dest == null) { + this.pendingLinks.add(new PendingLink(last, label)); + + } else { + this.addLink(new Link(last, dest, new LinkType(LinkDecor.ARROW, LinkDecor.NONE), null, futureLength)); + } + } + this.waitings.clear(); + } } diff --git a/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagramFactory2.java b/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagramFactory2.java index bdedc8fac..97df5c28a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagramFactory2.java +++ b/src/net/sourceforge/plantuml/activitydiagram2/ActivityDiagramFactory2.java @@ -35,9 +35,11 @@ package net.sourceforge.plantuml.activitydiagram2; import net.sourceforge.plantuml.activitydiagram2.command.CommandElse2; import net.sourceforge.plantuml.activitydiagram2.command.CommandEndif2; +import net.sourceforge.plantuml.activitydiagram2.command.CommandGoto2; import net.sourceforge.plantuml.activitydiagram2.command.CommandIf2; -import net.sourceforge.plantuml.activitydiagram2.command.CommandNewActivity; -import net.sourceforge.plantuml.activitydiagram2.command.CommandStart; +import net.sourceforge.plantuml.activitydiagram2.command.CommandLabel2; +import net.sourceforge.plantuml.activitydiagram2.command.CommandNewActivity2; +import net.sourceforge.plantuml.activitydiagram2.command.CommandStart2; import net.sourceforge.plantuml.command.AbstractUmlSystemCommandFactory; public class ActivityDiagramFactory2 extends AbstractUmlSystemCommandFactory { @@ -53,11 +55,13 @@ public class ActivityDiagramFactory2 extends AbstractUmlSystemCommandFactory { system = new ActivityDiagram2(); addCommonCommands(system); - addCommand(new CommandStart(system)); - addCommand(new CommandNewActivity(system)); + addCommand(new CommandStart2(system)); + addCommand(new CommandNewActivity2(system)); addCommand(new CommandIf2(system)); addCommand(new CommandEndif2(system)); addCommand(new CommandElse2(system)); + addCommand(new CommandLabel2(system)); + addCommand(new CommandGoto2(system)); // addCommand(new CommandLinkActivity(system)); // addCommand(new CommandPartition(system)); diff --git a/src/net/sourceforge/plantuml/activitydiagram2/ConditionalContext2.java b/src/net/sourceforge/plantuml/activitydiagram2/ConditionalContext2.java index 2da4e4837..904c6791f 100644 --- a/src/net/sourceforge/plantuml/activitydiagram2/ConditionalContext2.java +++ b/src/net/sourceforge/plantuml/activitydiagram2/ConditionalContext2.java @@ -33,10 +33,6 @@ */ package net.sourceforge.plantuml.activitydiagram2; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; - import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.cucadiagram.EntityType; import net.sourceforge.plantuml.cucadiagram.IEntity; @@ -47,7 +43,7 @@ public class ConditionalContext2 { private final IEntity branch; private final Direction direction; private final ConditionalContext2 parent; - + public ConditionalContext2(ConditionalContext2 parent, IEntity branch, Direction direction) { if (branch.getType() != EntityType.BRANCH) { throw new IllegalArgumentException(); diff --git a/src/net/sourceforge/plantuml/activitydiagram2/PendingLink.java b/src/net/sourceforge/plantuml/activitydiagram2/PendingLink.java new file mode 100644 index 000000000..1ec02098f --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram2/PendingLink.java @@ -0,0 +1,56 @@ +/* ======================================================================== + * 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: 5721 $ + * + */ +package net.sourceforge.plantuml.activitydiagram2; + +import net.sourceforge.plantuml.cucadiagram.IEntity; + +public class PendingLink { + + private final IEntity entityFrom; + private final String label; + + public PendingLink(IEntity entityFrom, String label) { + this.entityFrom = entityFrom; + this.label = label; + } + + public final IEntity getEntityFrom() { + return entityFrom; + } + + public final String getLabel() { + return label; + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandGoto2.java b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandGoto2.java new file mode 100644 index 000000000..e9cee3f9b --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandGoto2.java @@ -0,0 +1,65 @@ +/* ======================================================================== + * 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: 4762 $ + * + */ +package net.sourceforge.plantuml.activitydiagram2.command; + +import java.util.Map; + +import net.sourceforge.plantuml.activitydiagram2.ActivityDiagram2; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexPartialMatch; + +public class CommandGoto2 extends SingleLineCommand2 { + + public CommandGoto2(ActivityDiagram2 diagram) { + super(diagram, getRegexConcat()); + } + + static RegexConcat getRegexConcat() { + return new RegexConcat(new RegexLeaf("^"), // + new RegexLeaf("goto\\s+"), // + new RegexLeaf("LABEL", "([\\p{L}0-9_.]+)"), // + new RegexLeaf(":?"), // + new RegexLeaf("$")); + } + + @Override + protected CommandExecutionResult executeArg(Map arg) { + getSystem().callGoto(arg.get("LABEL").get(0)); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandIf2.java b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandIf2.java index 0b1e3c95b..a8f01a794 100644 --- a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandIf2.java +++ b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandIf2.java @@ -52,7 +52,7 @@ public class CommandIf2 extends SingleLineCommand2 { return new RegexConcat(new RegexLeaf("^"), new RegexLeaf("if"), new RegexLeaf("\\s*"), - new RegexLeaf("TEST", "\"([^\"]+)\""), + new RegexLeaf("TEST", "[\"(](.+)[\")]"), new RegexLeaf("\\s*"), new RegexLeaf("(then)?"), new RegexLeaf("$")); diff --git a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandLabel2.java b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandLabel2.java new file mode 100644 index 000000000..afd4d92fd --- /dev/null +++ b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandLabel2.java @@ -0,0 +1,65 @@ +/* ======================================================================== + * 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: 4762 $ + * + */ +package net.sourceforge.plantuml.activitydiagram2.command; + +import java.util.Map; + +import net.sourceforge.plantuml.activitydiagram2.ActivityDiagram2; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexPartialMatch; + +public class CommandLabel2 extends SingleLineCommand2 { + + public CommandLabel2(ActivityDiagram2 diagram) { + super(diagram, getRegexConcat()); + } + + static RegexConcat getRegexConcat() { + return new RegexConcat(new RegexLeaf("^"), + new RegexLeaf("LABEL", "([\\p{L}0-9_.]+)"), + new RegexLeaf(":"), + new RegexLeaf("$")); + } + + + @Override + protected CommandExecutionResult executeArg(Map arg) { + getSystem().label(arg.get("LABEL").get(0)); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandNewActivity.java b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandNewActivity2.java similarity index 86% rename from src/net/sourceforge/plantuml/activitydiagram2/command/CommandNewActivity.java rename to src/net/sourceforge/plantuml/activitydiagram2/command/CommandNewActivity2.java index b05d11e8f..29acecf2a 100644 --- a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandNewActivity.java +++ b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandNewActivity2.java @@ -39,10 +39,10 @@ import net.sourceforge.plantuml.activitydiagram2.ActivityDiagram2; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand; -public class CommandNewActivity extends SingleLineCommand { +public class CommandNewActivity2 extends SingleLineCommand { - public CommandNewActivity(ActivityDiagram2 diagram) { - super(diagram, "(?i)^\"([^\"]+)\"$"); + public CommandNewActivity2(ActivityDiagram2 diagram) { + super(diagram, "(?i)^[\"<](.+)[\">]$"); } @Override @@ -50,6 +50,11 @@ public class CommandNewActivity extends SingleLineCommand { if (getSystem().entities().size() == 0) { return CommandExecutionResult.error("Missing start keyword"); } + + if (getSystem().isReachable() == false) { + return CommandExecutionResult.error("Unreachable statement"); + } + getSystem().newActivity(arg.get(0)); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandStart.java b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandStart2.java similarity index 93% rename from src/net/sourceforge/plantuml/activitydiagram2/command/CommandStart.java rename to src/net/sourceforge/plantuml/activitydiagram2/command/CommandStart2.java index 59ee8f750..803130cc4 100644 --- a/src/net/sourceforge/plantuml/activitydiagram2/command/CommandStart.java +++ b/src/net/sourceforge/plantuml/activitydiagram2/command/CommandStart2.java @@ -39,9 +39,9 @@ import net.sourceforge.plantuml.activitydiagram2.ActivityDiagram2; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand; -public class CommandStart extends SingleLineCommand { +public class CommandStart2 extends SingleLineCommand { - public CommandStart(ActivityDiagram2 diagram) { + public CommandStart2(ActivityDiagram2 diagram) { super(diagram, "(?i)^start$"); } diff --git a/src/net/sourceforge/plantuml/asciiart/TextSkin.java b/src/net/sourceforge/plantuml/asciiart/TextSkin.java index cb5b82f1c..1facd04d4 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: 5941 $ + * Revision $Revision: 6008 $ * */ package net.sourceforge.plantuml.asciiart; @@ -64,7 +64,10 @@ public class TextSkin implements Skin { if (type.isArrow() && type.getArrowConfiguration().isSelfArrow()) { return new ComponentTextSelfArrow(type, stringsToDisplay, fileFormat); } - if (type == ComponentType.PARTICIPANT_LINE || type == ComponentType.ACTOR_LINE) { + if (type == ComponentType.PARTICIPANT_LINE) { + return new ComponentTextLine(fileFormat); + } + if (type == ComponentType.CONTINUE_LINE) { return new ComponentTextLine(fileFormat); } if (type == ComponentType.DELAY_LINE) { diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass2.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass2.java index b3b207fc7..2d938f2aa 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass2.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandLinkClass2.java @@ -39,7 +39,6 @@ import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UmlDiagramType; -import net.sourceforge.plantuml.UniqueSequence; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.RegexConcat; diff --git a/src/net/sourceforge/plantuml/classdiagram/command/CommandNamespace.java b/src/net/sourceforge/plantuml/classdiagram/command/CommandNamespace.java index 302e446e0..8abad3ac6 100644 --- a/src/net/sourceforge/plantuml/classdiagram/command/CommandNamespace.java +++ b/src/net/sourceforge/plantuml/classdiagram/command/CommandNamespace.java @@ -56,7 +56,7 @@ public class CommandNamespace extends SingleLineCommand { p.setBold(true); final String color = arg.get(1); if (color != null) { - p.setBackColor(new HtmlColor(color)); + p.setBackColor(HtmlColor.getColorIfValid(color)); } return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/code/ArobaseStringCompressor.java b/src/net/sourceforge/plantuml/code/ArobaseStringCompressor.java index ced002ccd..702734f16 100644 --- a/src/net/sourceforge/plantuml/code/ArobaseStringCompressor.java +++ b/src/net/sourceforge/plantuml/code/ArobaseStringCompressor.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 3827 $ + * Revision $Revision: 5980 $ * */ package net.sourceforge.plantuml.code; @@ -44,13 +44,31 @@ public class ArobaseStringCompressor implements StringCompressor { public String compress(String s) throws IOException { final Matcher m = p.matcher(s); if (m.find()) { - return m.group(2); + return clean(m.group(2)); } return ""; } - public String decompress(String stringAnnoted) throws IOException { - return stringAnnoted; + public String decompress(String s) throws IOException { + return clean(s); } + private String clean(String s) { + s = s.trim(); + s = clean1(s); + s = s.replaceAll("@enduml[^\\n\\r]*", ""); + s = s.replaceAll("@startuml[^\\n\\r]*", ""); + s = s.trim(); + return s; + } + + private String clean1(String s) { + final Matcher m = p.matcher(s); + if (m.matches()) { + return m.group(2); + } + return s; + } + + } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/command/AbstractUmlSystemCommandFactory.java b/src/net/sourceforge/plantuml/command/AbstractUmlSystemCommandFactory.java index 50a165eae..b2e069784 100644 --- a/src/net/sourceforge/plantuml/command/AbstractUmlSystemCommandFactory.java +++ b/src/net/sourceforge/plantuml/command/AbstractUmlSystemCommandFactory.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5764 $ + * Revision $Revision: 6002 $ * */ package net.sourceforge.plantuml.command; @@ -44,6 +44,10 @@ public abstract class AbstractUmlSystemCommandFactory implements PSystemCommandF reset(); } + public String checkFinalError() { + return null; + } + private List cmds = new ArrayList(); final public CommandControl isValid(List lines) { diff --git a/src/net/sourceforge/plantuml/command/CommandPackage.java b/src/net/sourceforge/plantuml/command/CommandPackage.java index 5d9bae12c..72ead852f 100644 --- a/src/net/sourceforge/plantuml/command/CommandPackage.java +++ b/src/net/sourceforge/plantuml/command/CommandPackage.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5536 $ + * Revision $Revision: 5983 $ * */ package net.sourceforge.plantuml.command; @@ -67,7 +67,7 @@ public class CommandPackage extends SingleLineCommand { p.setBold(true); final String color = arg.get(2); if (color != null) { - p.setBackColor(new HtmlColor(color)); + p.setBackColor(HtmlColor.getColorIfValid(color)); } return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/command/PSystemCommandFactory.java b/src/net/sourceforge/plantuml/command/PSystemCommandFactory.java index 7d1f56fc3..5de1a78ee 100644 --- a/src/net/sourceforge/plantuml/command/PSystemCommandFactory.java +++ b/src/net/sourceforge/plantuml/command/PSystemCommandFactory.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 3828 $ + * Revision $Revision: 6002 $ * */ package net.sourceforge.plantuml.command; @@ -42,4 +42,5 @@ public interface PSystemCommandFactory extends PSystemFactory { CommandControl isValid(List lines); Command createCommand(List lines); + } diff --git a/src/net/sourceforge/plantuml/cucadiagram/Link.java b/src/net/sourceforge/plantuml/cucadiagram/Link.java index 2a58ec3e0..8a1a15e86 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Link.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Link.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5908 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.cucadiagram; @@ -40,6 +40,7 @@ import java.util.Arrays; import net.sourceforge.plantuml.UniqueSequence; import net.sourceforge.plantuml.cucadiagram.dot.DrawFile; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; @@ -272,8 +273,8 @@ public class Link implements Imaged { private double getQualifierMargin(StringBounder stringBounder, Font fontQualif, String qualif) { if (qualif != null) { - final TextBlock b = TextBlockUtils.create(Arrays.asList(qualif), fontQualif, Color.BLACK, - HorizontalAlignement.LEFT); + final TextBlock b = TextBlockUtils.create(Arrays.asList(qualif), new FontConfiguration(fontQualif, + Color.BLACK), HorizontalAlignement.LEFT); final Dimension2D dim = b.calculateDimension(stringBounder); return Math.max(dim.getWidth(), dim.getHeight()); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java b/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java index 07542b6b5..8be7fab3f 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5771 $ + * Revision $Revision: 5982 $ * */ package net.sourceforge.plantuml.cucadiagram; @@ -68,7 +68,8 @@ public class Stereotype implements CharSequence { } else { this.label = null; } - this.htmlColor = new HtmlColor(m.group(2)); + final String colName = m.group(2); + this.htmlColor = HtmlColor.getColorIfValid(colName); this.character = m.group(1).charAt(0); } else { this.label = label; diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java b/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java index 1623ae88b..9da246209 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/AbstractGraphviz.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5794 $ + * Revision $Revision: 6005 $ * */ package net.sourceforge.plantuml.cucadiagram.dot; @@ -148,7 +148,15 @@ abstract class AbstractGraphviz implements Graphviz { msg.add("File cannot be read"); } } - msg.add("Cannot find Graphviz: try 'java -jar plantuml.jar -testdot'"); + msg.add("Cannot find Graphviz. You should try"); + msg.add(" "); + msg.add("@startuml"); + msg.add("testdot"); + msg.add("@enduml"); + msg.add(" "); + msg.add(" or "); + msg.add(" "); + msg.add("java -jar plantuml.jar -testdot"); final GraphicStrings errorResult = new GraphicStrings(msg); errorResult.writeImage(os, format); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/DotMaker.java b/src/net/sourceforge/plantuml/cucadiagram/dot/DotMaker.java index aa65a19d2..9ab2fa30f 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/DotMaker.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/DotMaker.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5972 $ + * Revision $Revision: 6035 $ * */ package net.sourceforge.plantuml.cucadiagram.dot; @@ -63,9 +63,11 @@ import net.sourceforge.plantuml.cucadiagram.Group; import net.sourceforge.plantuml.cucadiagram.GroupType; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Link; +import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.Member; import net.sourceforge.plantuml.cucadiagram.Rankdir; import net.sourceforge.plantuml.cucadiagram.Stereotype; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.TextBlock; @@ -92,6 +94,11 @@ final public class DotMaker implements GraphvizMaker { private final boolean isVisibilityModifierPresent; + // http://www.graphviz.org/bugs/b2114.html + private static final boolean TURN_AROUND_B2114 = false; + + private final Set hasAlreadyOneIncommingArrowLenghtOne; + public static void goJunit() { isJunit = true; } @@ -105,6 +112,7 @@ final public class DotMaker implements GraphvizMaker { } else { this.isVisibilityModifierPresent = false; } + this.hasAlreadyOneIncommingArrowLenghtOne = TURN_AROUND_B2114 ? new HashSet() : null; } public String createDotString() throws IOException { @@ -130,10 +138,10 @@ final public class DotMaker implements GraphvizMaker { final boolean huge = data.getEntities().size() > 800; sb.append("digraph unix {"); - //if (isJunit == false) { - for (String s : dotStrings) { - sb.append(s); - } + // if (isJunit == false) { + for (String s : dotStrings) { + sb.append(s); + } // } sb.append("bgcolor=\"" + data.getSkinParam().getBackgroundColor().getAsHtml() + "\";"); if (huge) { @@ -142,6 +150,7 @@ final public class DotMaker implements GraphvizMaker { sb.append("ratio=auto;"); // sb.append("concentrate=true;"); } + // sb.append("ordering=out;"); sb.append("compound=true;"); sb.append("remincross=true;"); sb.append("searchsize=500;"); @@ -500,11 +509,15 @@ final public class DotMaker implements GraphvizMaker { final DrawFile noteLink = link.getImageFile(); + boolean hasLabel = false; + if (link.getLabel() != null) { decoration.append("label=<" + manageHtmlIB(link.getLabel(), getArrowFontParam(), null) + ">,"); + hasLabel = true; } else if (noteLink != null) { decoration .append("label=<" + getHtmlForLinkNote(noteLink.getPngOrEps(fileFormat == FileFormat.EPS)) + ">,"); + hasLabel = true; } if (link.getQualifier1() != null) { @@ -513,16 +526,26 @@ final public class DotMaker implements GraphvizMaker { if (link.getQualifier2() != null) { decoration.append("headlabel=<" + manageHtmlIB(link.getQualifier2(), getArrowFontParam(), null) + ">,"); } - decoration.append(link.getType().getSpecificDecoration()); + final int len = link.getLength(); + String uid1 = link.getEntity1().getUid(); + String uid2 = link.getEntity2().getUid(); + LinkType typeToDraw = link.getType(); + if (TURN_AROUND_B2114 && len == 1 && hasAlreadyOneIncommingArrowLenghtOne.contains(uid2) && hasLabel) { + typeToDraw = typeToDraw.getInv(); + } + if (TURN_AROUND_B2114 && len == 1) { + hasAlreadyOneIncommingArrowLenghtOne.add(uid2); + } + decoration.append(typeToDraw.getSpecificDecoration()); if (link.isInvis()) { decoration.append(",style=invis"); } - final int len = link.getLength(); + // if (len == 1) { + // decoration.append(",constraint=false"); + // } final String lenString = len >= 3 ? ",minlen=" + (len - 1) : ""; - String uid1 = link.getEntity1().getUid(); - String uid2 = link.getEntity2().getUid(); if (link.getEntity1().getType() == EntityType.GROUP) { uid1 = getHiddenNodeUid(link.getEntity1().getParent(), link); decoration.append(",ltail=" + link.getEntity1().getParent().getUid() + "v"); @@ -594,7 +617,7 @@ final public class DotMaker implements GraphvizMaker { if (noteLink == null) { continue; } - final Link phantom = new Link(link.getEntity1(), link.getEntity2(), link.getType(), "", link.getLength()); + final Link phantom = new Link(link.getEntity1(), link.getEntity2(), link.getType(), null, link.getLength()); phantom.setInvis(true); result.add(phantom); } @@ -657,10 +680,6 @@ final public class DotMaker implements GraphvizMaker { } private void eventuallySameRank(StringBuilder sb, Group entityPackage, Link link) { - // if (workAroundDotBug()) { - // throw new UnsupportedOperationException("workAroundDotBug"); - // // return; - // } final int len = link.getLength(); if (len == 1 && link.getEntity1().getParent() == entityPackage && link.getEntity2().getParent() == entityPackage) { @@ -1258,7 +1277,8 @@ final public class DotMaker implements GraphvizMaker { } final Font font = data.getSkinParam().getFont(FontParam.CLASS_ATTRIBUTE, null); final Color color = getFontHtmlColor(FontParam.CLASS_ATTRIBUTE, null).getColor(); - final TextBlock text = TextBlockUtils.create(texts, font, color, HorizontalAlignement.LEFT); + final TextBlock text = TextBlockUtils.create(texts, new FontConfiguration(font, color), + HorizontalAlignement.LEFT); final File feps = FileUtils.createTempFile("member", ".eps"); UGraphicEps.copyEpsToFile(new UDrawable() { public void drawU(UGraphic ug) { @@ -1542,8 +1562,8 @@ final public class DotMaker implements GraphvizMaker { } private String manageSpace(int size) { - final DotExpression dotExpression = new DotExpression(" ", size, new HtmlColor("white"), null, Font.PLAIN, - fileFormat); + final DotExpression dotExpression = new DotExpression(" ", size, HtmlColor.getColorIfValid("white"), null, + Font.PLAIN, fileFormat); final String result = dotExpression.getDotHtml(); return result; } diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java index 0cccf627e..e044ba344 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/GraphvizUtils.java @@ -28,16 +28,25 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4826 $ + * Revision $Revision: 6007 $ * */ package net.sourceforge.plantuml.cucadiagram.dot; import java.io.File; import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import net.sourceforge.plantuml.StringUtils; public class GraphvizUtils { + private static int DOT_VERSION_LIMIT = 226; + private static boolean isWindows() { return File.separatorChar == '\\'; } @@ -55,7 +64,7 @@ public class GraphvizUtils { public static String getenvGraphvizDot() { final String env = System.getProperty("GRAPHVIZ_DOT"); - if (env != null) { + if (StringUtils.isNotEmpty(env)) { return env; } return System.getenv("GRAPHVIZ_DOT"); @@ -79,4 +88,78 @@ public class GraphvizUtils { } return dotVersion; } + + static int retrieveVersion(String s) { + if (s == null) { + return -1; + } + final Pattern p = Pattern.compile("\\s([12].\\d\\d)\\D"); + final Matcher m = p.matcher(s); + if (m.find() == false) { + return -1; + } + return Integer.parseInt(m.group(1).replaceAll("\\.", "")); + } + + public static int getDotVersion() throws IOException, InterruptedException { + return retrieveVersion(dotVersion()); + } + + static public List getTestDotStrings(boolean withRichText) { + String red = ""; + String bold = ""; + if (withRichText) { + red = ""; + bold = ""; + } + final List result = new ArrayList(); + final String ent = GraphvizUtils.getenvGraphvizDot(); + if (ent == null) { + result.add("The environment variable GRAPHVIZ_DOT has not been set"); + } else { + result.add("The environment variable GRAPHVIZ_DOT has been set to " + ent); + } + final File dotExe = GraphvizUtils.getDotExe(); + result.add("Dot executable is " + dotExe); + + boolean ok = true; + if (dotExe == null) { + result.add(red + "Error: No dot executable found"); + ok = false; + } else if (dotExe.exists() == false) { + result.add(red + "Error: file does not exist"); + ok = false; + } else if (dotExe.isFile() == false) { + result.add(red + "Error: not a valid file"); + ok = false; + } else if (dotExe.canRead() == false) { + result.add(red + "Error: cannot be read"); + ok = false; + } + + if (ok) { + try { + final String version = GraphvizUtils.dotVersion(); + result.add("Dot version: " + version); + final int v = GraphvizUtils.getDotVersion(); + if (v == -1) { + result.add("Warning : cannot determine dot version"); + } else { + if (v < DOT_VERSION_LIMIT) { + result.add(bold + "Warning : Your dot installation seems old"); + result.add(bold + "Some diagrams may have issues"); + } else { + result.add(bold + "Installation seems OK"); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } else { + result.add("Error: only sequence diagrams will be generated"); + } + + return Collections.unmodifiableList(result); + } + } diff --git a/src/net/sourceforge/plantuml/cucadiagram/dot/PlayField.java b/src/net/sourceforge/plantuml/cucadiagram/dot/PlayField.java index aee1c53da..004ba1c8c 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/dot/PlayField.java +++ b/src/net/sourceforge/plantuml/cucadiagram/dot/PlayField.java @@ -57,6 +57,7 @@ import net.sourceforge.plantuml.cucadiagram.Group; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.LinkType; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; @@ -144,7 +145,8 @@ public final class PlayField { // entityImageBlock.getDimension(stringBounder); // final Block b = new Block(uid++, d.getWidth() + 2 * // marginDecorator, d.getHeight() + 2 * marginDecorator); - final MargedBlock b = new MargedBlock(stringBounder, entityImageBlock, getMargin(stringBounder, ent, links), parentCluster); + final MargedBlock b = new MargedBlock(stringBounder, entityImageBlock, + getMargin(stringBounder, ent, links), parentCluster); blocks.put(ent, b); // images.put(ent, entityImageBlock); @@ -258,16 +260,16 @@ public final class PlayField { final String qual1 = link.getQualifier1(); if (qual1 != null) { - final TextBlock b = TextBlockUtils.create(Arrays.asList(qual1), fontQualif, - skinParam.getFontHtmlColor(FontParam.CLASS_ARROW, null).getColor(), HorizontalAlignement.LEFT); + final TextBlock b = TextBlockUtils.create(Arrays.asList(qual1), new FontConfiguration(fontQualif, + skinParam.getFontHtmlColor(FontParam.CLASS_ARROW, null).getColor()), HorizontalAlignement.LEFT); final Point2D pos = p.getDotPath().getStartPoint(); b.drawU(ug, pos.getX(), pos.getY()); } final String qual2 = link.getQualifier2(); if (qual2 != null) { - final TextBlock b = TextBlockUtils.create(Arrays.asList(qual2), fontQualif, - skinParam.getFontHtmlColor(FontParam.CLASS_ARROW, null).getColor(), HorizontalAlignement.LEFT); + final TextBlock b = TextBlockUtils.create(Arrays.asList(qual2), new FontConfiguration(fontQualif, + skinParam.getFontHtmlColor(FontParam.CLASS_ARROW, null).getColor()), HorizontalAlignement.LEFT); final Point2D pos = p.getDotPath().getEndPoint(); b.drawU(ug, pos.getX(), pos.getY()); } diff --git a/src/net/sourceforge/plantuml/graph/Elastane.java b/src/net/sourceforge/plantuml/graph/Elastane.java index 3cb835eda..3cc93d6d8 100644 --- a/src/net/sourceforge/plantuml/graph/Elastane.java +++ b/src/net/sourceforge/plantuml/graph/Elastane.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4626 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.graph; @@ -57,6 +57,7 @@ import net.sourceforge.plantuml.geom.CollectionUtils; import net.sourceforge.plantuml.geom.Point2DInt; import net.sourceforge.plantuml.geom.PolylineBreakeable; import net.sourceforge.plantuml.geom.XMoveable; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounderUtils; import net.sourceforge.plantuml.graphic.TextBlock; @@ -264,10 +265,11 @@ public class Elastane { final String label = l.getLabel(); if (label != null) { final Point2DInt center = polyline.getFirst().getCenter(); - final TextBlock textBlock = TextBlockUtils.create(Arrays.asList(label), g2d.getFont(), Color.BLACK, - HorizontalAlignement.LEFT); + final TextBlock textBlock = TextBlockUtils.create(Arrays.asList(label), + new FontConfiguration(g2d.getFont(), Color.BLACK), HorizontalAlignement.LEFT); final Dimension2D dim = textBlock.calculateDimension(StringBounderUtils.asStringBounder(g2d)); - textBlock.drawTOBEREMOVED(g2d, center.getXint() - dim.getWidth() / 2, center.getYint() - dim.getHeight() / 2); + textBlock.drawTOBEREMOVED(g2d, center.getXint() - dim.getWidth() / 2, + center.getYint() - dim.getHeight() / 2); } g2d.setColor(red); diff --git a/src/net/sourceforge/plantuml/graph/EntityImageActivity.java b/src/net/sourceforge/plantuml/graph/EntityImageActivity.java index 91bb80c46..611f574d9 100644 --- a/src/net/sourceforge/plantuml/graph/EntityImageActivity.java +++ b/src/net/sourceforge/plantuml/graph/EntityImageActivity.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4959 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.graph; @@ -41,6 +41,7 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.cucadiagram.Entity; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounderUtils; @@ -56,14 +57,14 @@ class EntityImageActivity extends AbstractEntityImage { public EntityImageActivity(Entity entity) { super(entity); - this.text = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), getFont14(), Color.BLACK, - HorizontalAlignement.CENTER); + this.text = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), new FontConfiguration( + getFont14(), Color.BLACK), HorizontalAlignement.CENTER); } @Override public Dimension2D getDimension(StringBounder stringBounder) { final Dimension2D dim = text.calculateDimension(stringBounder); - return Dimension2DDouble.delta(dim, 2*xMargin, 2*yMargin); + return Dimension2DDouble.delta(dim, 2 * xMargin, 2 * yMargin); } @Override diff --git a/src/net/sourceforge/plantuml/graph/EntityImageActor.java b/src/net/sourceforge/plantuml/graph/EntityImageActor.java index 318f14b17..bbf4b4987 100644 --- a/src/net/sourceforge/plantuml/graph/EntityImageActor.java +++ b/src/net/sourceforge/plantuml/graph/EntityImageActor.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4189 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.graph; @@ -41,6 +41,7 @@ import java.awt.geom.Rectangle2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.cucadiagram.Entity; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounderUtils; @@ -55,8 +56,8 @@ class EntityImageActor extends AbstractEntityImage { public EntityImageActor(Entity entity) { super(entity); - this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), getFont14(), Color.BLACK, - HorizontalAlignement.CENTER); + this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), new FontConfiguration( + getFont14(), Color.BLACK), HorizontalAlignement.CENTER); this.stickman = new StickMan(getYellow(), getRed()); } diff --git a/src/net/sourceforge/plantuml/graph/EntityImageCircleInterface.java b/src/net/sourceforge/plantuml/graph/EntityImageCircleInterface.java index 732218298..8b44f8471 100644 --- a/src/net/sourceforge/plantuml/graph/EntityImageCircleInterface.java +++ b/src/net/sourceforge/plantuml/graph/EntityImageCircleInterface.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5343 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.graph; @@ -40,6 +40,7 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.cucadiagram.Entity; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; @@ -53,8 +54,8 @@ class EntityImageCircleInterface extends AbstractEntityImage { public EntityImageCircleInterface(Entity entity) { super(entity); - this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), getFont14(), Color.BLACK, - HorizontalAlignement.CENTER); + this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), new FontConfiguration( + getFont14(), Color.BLACK), HorizontalAlignement.CENTER); this.circleInterface = new CircleInterface(getYellow(), getRed()); } @@ -69,22 +70,22 @@ class EntityImageCircleInterface extends AbstractEntityImage { @Override public void draw(Graphics2D g2d) { throw new UnsupportedOperationException(); -// final Dimension2D dimTotal = getDimension(StringBounderUtils.asStringBounder(g2d)); -// final Dimension2D nameDim = name.calculateDimension(StringBounderUtils.asStringBounder(g2d)); -// -// final double manWidth = circleInterface.getPreferredWidth(StringBounderUtils.asStringBounder(g2d)); -// final double manHeight = circleInterface.getPreferredHeight(StringBounderUtils.asStringBounder(g2d)); -// -// final double manX = (dimTotal.getWidth() - manWidth) / 2; -// -// g2d.setColor(Color.WHITE); -// g2d.fill(new Rectangle2D.Double(0, 0, dimTotal.getWidth(), dimTotal.getHeight())); -// -// g2d.translate(manX, 0); -// circleInterface.draw(g2d); -// g2d.translate(-manX, 0); -// -// g2d.setColor(Color.BLACK); -// name.drawTOBEREMOVED(g2d, (dimTotal.getWidth() - nameDim.getWidth()) / 2, manHeight); + // final Dimension2D dimTotal = getDimension(StringBounderUtils.asStringBounder(g2d)); + // final Dimension2D nameDim = name.calculateDimension(StringBounderUtils.asStringBounder(g2d)); + // + // final double manWidth = circleInterface.getPreferredWidth(StringBounderUtils.asStringBounder(g2d)); + // final double manHeight = circleInterface.getPreferredHeight(StringBounderUtils.asStringBounder(g2d)); + // + // final double manX = (dimTotal.getWidth() - manWidth) / 2; + // + // g2d.setColor(Color.WHITE); + // g2d.fill(new Rectangle2D.Double(0, 0, dimTotal.getWidth(), dimTotal.getHeight())); + // + // g2d.translate(manX, 0); + // circleInterface.draw(g2d); + // g2d.translate(-manX, 0); + // + // g2d.setColor(Color.BLACK); + // name.drawTOBEREMOVED(g2d, (dimTotal.getWidth() - nameDim.getWidth()) / 2, manHeight); } } diff --git a/src/net/sourceforge/plantuml/graph/EntityImageClass.java b/src/net/sourceforge/plantuml/graph/EntityImageClass.java index 19997a89d..f8cfb47a6 100644 --- a/src/net/sourceforge/plantuml/graph/EntityImageClass.java +++ b/src/net/sourceforge/plantuml/graph/EntityImageClass.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5798 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.graph; @@ -42,6 +42,7 @@ import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.cucadiagram.Entity; import net.sourceforge.plantuml.cucadiagram.EntityType; import net.sourceforge.plantuml.graphic.CircledCharacter; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounderUtils; @@ -60,8 +61,8 @@ class EntityImageClass extends AbstractEntityImage { public EntityImageClass(Entity entity) { super(entity); - this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), getFont14(), Color.BLACK, - HorizontalAlignement.CENTER); + this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), new FontConfiguration( + getFont14(), Color.BLACK), HorizontalAlignement.CENTER); this.methods = new MethodsOrFieldsArea(entity.methods2(), getFont14()); this.fields = new MethodsOrFieldsArea(entity.fields2(), getFont14()); diff --git a/src/net/sourceforge/plantuml/graph/EntityImageComponent.java b/src/net/sourceforge/plantuml/graph/EntityImageComponent.java index 68c46fdce..c88faa8c3 100644 --- a/src/net/sourceforge/plantuml/graph/EntityImageComponent.java +++ b/src/net/sourceforge/plantuml/graph/EntityImageComponent.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4959 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.graph; @@ -43,6 +43,7 @@ import java.awt.geom.Rectangle2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.cucadiagram.Entity; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounderUtils; @@ -56,8 +57,8 @@ class EntityImageComponent extends AbstractEntityImage { public EntityImageComponent(Entity entity) { super(entity); - this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), getFont14(), Color.BLACK, - HorizontalAlignement.CENTER); + this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), new FontConfiguration( + getFont14(), Color.BLACK), HorizontalAlignement.CENTER); } @Override diff --git a/src/net/sourceforge/plantuml/graph/EntityImageDefault.java b/src/net/sourceforge/plantuml/graph/EntityImageDefault.java index 3c8456114..88f426c45 100644 --- a/src/net/sourceforge/plantuml/graph/EntityImageDefault.java +++ b/src/net/sourceforge/plantuml/graph/EntityImageDefault.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4125 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.graph; @@ -40,6 +40,7 @@ import java.util.Arrays; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.cucadiagram.Entity; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounderUtils; @@ -52,8 +53,8 @@ class EntityImageDefault extends AbstractEntityImage { public EntityImageDefault(Entity entity) { super(entity); - this.textBlock = TextBlockUtils.create(Arrays.asList(entity.getDisplay()), getFont14(), Color.BLACK, - HorizontalAlignement.CENTER); + this.textBlock = TextBlockUtils.create(Arrays.asList(entity.getDisplay()), new FontConfiguration(getFont14(), + Color.BLACK), HorizontalAlignement.CENTER); } @Override diff --git a/src/net/sourceforge/plantuml/graph/EntityImageNote.java b/src/net/sourceforge/plantuml/graph/EntityImageNote.java index 628c3d758..faffe8bd7 100644 --- a/src/net/sourceforge/plantuml/graph/EntityImageNote.java +++ b/src/net/sourceforge/plantuml/graph/EntityImageNote.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4959 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.graph; @@ -41,6 +41,7 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.cucadiagram.Entity; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounderUtils; @@ -56,8 +57,8 @@ class EntityImageNote extends AbstractEntityImage { public EntityImageNote(Entity entity) { super(entity); - this.text = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), getFont14(), Color.BLACK, - HorizontalAlignement.CENTER); + this.text = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), new FontConfiguration( + getFont14(), Color.BLACK), HorizontalAlignement.CENTER); } @Override diff --git a/src/net/sourceforge/plantuml/graph/EntityImageUsecase.java b/src/net/sourceforge/plantuml/graph/EntityImageUsecase.java index 7168b9ff5..bc8721496 100644 --- a/src/net/sourceforge/plantuml/graph/EntityImageUsecase.java +++ b/src/net/sourceforge/plantuml/graph/EntityImageUsecase.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4125 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.graph; @@ -44,6 +44,7 @@ import java.awt.geom.Rectangle2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.cucadiagram.Entity; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounderUtils; @@ -56,8 +57,8 @@ class EntityImageUsecase extends AbstractEntityImage { public EntityImageUsecase(Entity entity) { super(entity); - this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), getFont14(), Color.BLACK, - HorizontalAlignement.CENTER); + this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), new FontConfiguration( + getFont14(), Color.BLACK), HorizontalAlignement.CENTER); } @Override diff --git a/src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea.java b/src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea.java index bc8c79c23..4c7151c7c 100644 --- a/src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea.java +++ b/src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5609 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.graph; @@ -43,6 +43,7 @@ import java.util.List; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.cucadiagram.Member; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounderUtils; @@ -80,7 +81,8 @@ public class MethodsOrFieldsArea { } private TextBlock createTextBlock(String s) { - return TextBlockUtils.create(Arrays.asList(s), font, Color.BLACK, HorizontalAlignement.LEFT); + return TextBlockUtils.create(Arrays.asList(s), new FontConfiguration(font, Color.BLACK), + HorizontalAlignement.LEFT); } public void drawTOBEREMOVED(Graphics2D g2d, double x, double y) { diff --git a/src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea2.java b/src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea2.java index 90f1babf5..331328beb 100644 --- a/src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea2.java +++ b/src/net/sourceforge/plantuml/graph/MethodsOrFieldsArea2.java @@ -45,6 +45,7 @@ import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.cucadiagram.Member; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; @@ -98,7 +99,7 @@ public class MethodsOrFieldsArea2 { } private TextBlock createTextBlock(String s) { - return TextBlockUtils.create(Arrays.asList(s), font, color, HorizontalAlignement.LEFT); + return TextBlockUtils.create(Arrays.asList(s), new FontConfiguration(font, color), HorizontalAlignement.LEFT); } public void drawTOBEREMOVED(Graphics2D g2d, double x, double y) { diff --git a/src/net/sourceforge/plantuml/graphic/ColorAndSizeChange.java b/src/net/sourceforge/plantuml/graphic/ColorAndSizeChange.java index d56c497e7..9ceb5d8a2 100644 --- a/src/net/sourceforge/plantuml/graphic/ColorAndSizeChange.java +++ b/src/net/sourceforge/plantuml/graphic/ColorAndSizeChange.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 3834 $ + * Revision $Revision: 5983 $ * */ package net.sourceforge.plantuml.graphic; @@ -48,7 +48,7 @@ class ColorAndSizeChange implements FontChange { ColorAndSizeChange(String s) { final Matcher matcherColor = colorPattern.matcher(s); if (matcherColor.find()) { - color = new HtmlColor(matcherColor.group(1)); + color = HtmlColor.getColorIfValid(matcherColor.group(1)); } else { color = null; } diff --git a/src/net/sourceforge/plantuml/graphic/ColorChange.java b/src/net/sourceforge/plantuml/graphic/ColorChange.java index 5e63a05d6..c41b088a5 100644 --- a/src/net/sourceforge/plantuml/graphic/ColorChange.java +++ b/src/net/sourceforge/plantuml/graphic/ColorChange.java @@ -47,7 +47,7 @@ class ColorChange implements FontChange { if (matcherColor.find() == false) { throw new IllegalArgumentException(); } - this.color = new HtmlColor(matcherColor.group(1)); + this.color = HtmlColor.getColorIfValid(matcherColor.group(1)); } HtmlColor getColor() { diff --git a/src/net/sourceforge/plantuml/graphic/FontStyle.java b/src/net/sourceforge/plantuml/graphic/FontStyle.java index 106429d9e..1c3d59068 100644 --- a/src/net/sourceforge/plantuml/graphic/FontStyle.java +++ b/src/net/sourceforge/plantuml/graphic/FontStyle.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5507 $ + * Revision $Revision: 6000 $ * */ package net.sourceforge.plantuml.graphic; @@ -40,7 +40,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public enum FontStyle { - PLAIN, ITALIC, BOLD, UNDERLINE, STRIKE, WAVE; + PLAIN, ITALIC, BOLD, UNDERLINE, STRIKE, WAVE, BACKCOLOR; public Font mutateFont(Font font) { if (this == ITALIC) { @@ -65,6 +65,9 @@ public enum FontStyle { if (this == WAVE) { return "\\<[wW](?::(#[0-9a-fA-F]{6}|\\w+))?\\>"; } + if (this == BACKCOLOR) { + return "\\<[bB][aA][cC][kK](?::(#[0-9a-fA-F]{6}|\\w+))?\\>"; + } if (this == STRIKE) { return "\\<(?:s|S|strike|STRIKE|del|DEL)(?::(#[0-9a-fA-F]{6}|\\w+))?\\>"; } @@ -78,7 +81,7 @@ public enum FontStyle { } final String color = m.group(1); if (color!= null && HtmlColor.isValid(color)) { - return new HtmlColor(color).getColor(); + return HtmlColor.getColorIfValid(color).getColor(); } return null; } @@ -96,6 +99,9 @@ public enum FontStyle { if (this == WAVE) { return "\\"; } + if (this == BACKCOLOR) { + return "\\"; + } if (this == STRIKE) { return "\\"; } diff --git a/src/net/sourceforge/plantuml/graphic/GraphicStrings.java b/src/net/sourceforge/plantuml/graphic/GraphicStrings.java index 365caae55..523a0f5b7 100644 --- a/src/net/sourceforge/plantuml/graphic/GraphicStrings.java +++ b/src/net/sourceforge/plantuml/graphic/GraphicStrings.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5872 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.graphic; @@ -138,7 +138,8 @@ public class GraphicStrings { } public Dimension2D drawU(final UGraphic ug) { - final TextBlock textBlock = TextBlockUtils.create(strings, font, green, HorizontalAlignement.LEFT); + final TextBlock textBlock = TextBlockUtils.create(strings, new FontConfiguration(font, green), + HorizontalAlignement.LEFT); Dimension2D size = textBlock.calculateDimension(ug.getStringBounder()); textBlock.drawU(ug, 0, 0); diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColor.java b/src/net/sourceforge/plantuml/graphic/HtmlColor.java index 6871c69f4..e72f67ce8 100644 --- a/src/net/sourceforge/plantuml/graphic/HtmlColor.java +++ b/src/net/sourceforge/plantuml/graphic/HtmlColor.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5204 $ + * Revision $Revision: 5983 $ * */ package net.sourceforge.plantuml.graphic; @@ -77,6 +77,7 @@ public class HtmlColor { register("DarkCyan", "#008B8B"); register("DarkGoldenRod", "#B8860B"); register("DarkGray", "#A9A9A9"); + register("DarkGrey", "#A9A9A9"); register("DarkGreen", "#006400"); register("DarkKhaki", "#BDB76B"); register("DarkMagenta", "#8B008B"); @@ -88,11 +89,13 @@ public class HtmlColor { register("DarkSeaGreen", "#8FBC8F"); register("DarkSlateBlue", "#483D8B"); register("DarkSlateGray", "#2F4F4F"); + register("DarkSlateGrey", "#2F4F4F"); register("DarkTurquoise", "#00CED1"); register("DarkViolet", "#9400D3"); register("DeepPink", "#FF1493"); register("DeepSkyBlue", "#00BFFF"); register("DimGray", "#696969"); + register("DimGrey", "#696969"); register("DodgerBlue", "#1E90FF"); register("FireBrick", "#B22222"); register("FloralWhite", "#FFFAF0"); @@ -103,6 +106,7 @@ public class HtmlColor { register("Gold", "#FFD700"); register("GoldenRod", "#DAA520"); register("Gray", "#808080"); + register("Grey", "#808080"); register("Green", "#008000"); register("GreenYellow", "#ADFF2F"); register("HoneyDew", "#F0FFF0"); @@ -119,6 +123,7 @@ public class HtmlColor { register("LightCoral", "#F08080"); register("LightCyan", "#E0FFFF"); register("LightGoldenRodYellow", "#FAFAD2"); + register("LightGray", "#D3D3D3"); register("LightGrey", "#D3D3D3"); register("LightGreen", "#90EE90"); register("LightPink", "#FFB6C1"); @@ -126,6 +131,7 @@ public class HtmlColor { register("LightSeaGreen", "#20B2AA"); register("LightSkyBlue", "#87CEFA"); register("LightSlateGray", "#778899"); + register("LightSlateGrey", "#778899"); register("LightSteelBlue", "#B0C4DE"); register("LightYellow", "#FFFFE0"); register("Lime", "#00FF00"); @@ -178,6 +184,7 @@ public class HtmlColor { register("SkyBlue", "#87CEEB"); register("SlateBlue", "#6A5ACD"); register("SlateGray", "#708090"); + register("SlateGrey", "#708090"); register("Snow", "#FFFAFA"); register("SpringGreen", "#00FF7F"); register("SteelBlue", "#4682B4"); @@ -201,7 +208,7 @@ public class HtmlColor { private final Color color; - public HtmlColor(String s) { + private HtmlColor(String s) { if (s.matches("#[0-9A-Fa-f]{6}")) { color = new Color(Integer.parseInt(s.substring(1), 16)); } else { @@ -215,9 +222,9 @@ public class HtmlColor { assert isValid(s); } - private HtmlColor(Color c) { - this.color = c; - } +// private HtmlColor(Color c) { +// this.color = c; +// } static public boolean isValid(String s) { if (s.matches("#[0-9A-Fa-f]{6}")) { diff --git a/src/net/sourceforge/plantuml/graphic/SingleLine.java b/src/net/sourceforge/plantuml/graphic/SingleLine.java index 209f41abb..5bceeb6da 100644 --- a/src/net/sourceforge/plantuml/graphic/SingleLine.java +++ b/src/net/sourceforge/plantuml/graphic/SingleLine.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5741 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.graphic; @@ -48,15 +48,13 @@ class SingleLine implements Line { private final List blocs = new ArrayList(); private final HorizontalAlignement horizontalAlignement; - public SingleLine(String text, Font font, Color paint, HorizontalAlignement horizontalAlignement) { + public SingleLine(String text, FontConfiguration fontConfiguration, HorizontalAlignement horizontalAlignement) { if (text.length() == 0) { text = " "; } this.horizontalAlignement = horizontalAlignement; final Splitter lineSplitter = new Splitter(text); - FontConfiguration fontConfiguration = new FontConfiguration(font, paint); - for (HtmlCommand cmd : lineSplitter.getHtmlCommands(false)) { if (cmd instanceof Text) { final String s = ((Text) cmd).getText(); diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java b/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java index a60e9fa41..08899358b 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java @@ -28,13 +28,11 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4125 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.graphic; -import java.awt.Color; -import java.awt.Font; import java.awt.Graphics2D; import java.awt.geom.Dimension2D; import java.util.ArrayList; @@ -48,21 +46,21 @@ class TextBlockSimple implements TextBlock { private final List lines = new ArrayList(); - protected TextBlockSimple(List texts, Font font, Color paint, + protected TextBlockSimple(List texts, FontConfiguration fontConfiguration, HorizontalAlignement horizontalAlignement) { for (CharSequence s : texts) { if (s instanceof Stereotype) { - lines.add(createLineForStereotype(font, paint, (Stereotype) s, horizontalAlignement)); + lines.add(createLineForStereotype(fontConfiguration, (Stereotype) s, horizontalAlignement)); } else { - lines.add(new SingleLine(s.toString(), font, paint, horizontalAlignement)); + lines.add(new SingleLine(s.toString(), fontConfiguration, horizontalAlignement)); } } } - private SingleLine createLineForStereotype(Font font, Color paint, Stereotype s, + private SingleLine createLineForStereotype(FontConfiguration fontConfiguration, Stereotype s, HorizontalAlignement horizontalAlignement) { assert s.getLabel() != null; - return new SingleLine(s.getLabel(), font.deriveFont(Font.ITALIC), paint, horizontalAlignement); + return new SingleLine(s.getLabel(), fontConfiguration.add(FontStyle.ITALIC), horizontalAlignement); } public Dimension2D calculateDimension(StringBounder stringBounder) { @@ -95,7 +93,7 @@ class TextBlockSimple implements TextBlock { y += line.calculateDimension(StringBounderUtils.asStringBounder(g2d)).getHeight(); } } - + public void drawU(UGraphic ug, double x, double y) { final Dimension2D dimText = getTextDimension(ug.getStringBounder()); @@ -103,8 +101,7 @@ class TextBlockSimple implements TextBlock { final HorizontalAlignement lineHorizontalAlignement = line.getHorizontalAlignement(); double deltaX = 0; if (lineHorizontalAlignement == HorizontalAlignement.CENTER) { - final double diff = dimText.getWidth() - - line.calculateDimension(ug.getStringBounder()).getWidth(); + final double diff = dimText.getWidth() - line.calculateDimension(ug.getStringBounder()).getWidth(); deltaX = diff / 2.0; } line.drawU(ug, x + deltaX, y); diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockSpotted.java b/src/net/sourceforge/plantuml/graphic/TextBlockSpotted.java index c7e285f92..12ddd5466 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockSpotted.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockSpotted.java @@ -28,13 +28,11 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4169 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.graphic; -import java.awt.Color; -import java.awt.Font; import java.awt.Graphics2D; import java.awt.geom.Dimension2D; import java.util.List; @@ -46,9 +44,9 @@ class TextBlockSpotted extends TextBlockSimple { private final CircledCharacter circledCharacter; - public TextBlockSpotted(CircledCharacter circledCharacter, List texts, Font font, - Color paint, HorizontalAlignement horizontalAlignement) { - super(texts, font, paint, horizontalAlignement); + public TextBlockSpotted(CircledCharacter circledCharacter, List texts, + FontConfiguration fontConfiguration, HorizontalAlignement horizontalAlignement) { + super(texts, fontConfiguration, horizontalAlignement); this.circledCharacter = circledCharacter; } @@ -58,8 +56,8 @@ class TextBlockSpotted extends TextBlockSimple { final double heightCircledCharacter = circledCharacter.getPreferredHeight(stringBounder); final Dimension2D dim = super.calculateDimension(stringBounder); - return new Dimension2DDouble(dim.getWidth() + widthCircledCharacter, Math.max(heightCircledCharacter, dim - .getHeight())); + return new Dimension2DDouble(dim.getWidth() + widthCircledCharacter, Math.max(heightCircledCharacter, + dim.getHeight())); } private double getCircledCharacterWithAndMargin(StringBounder stringBounder) { @@ -68,36 +66,36 @@ class TextBlockSpotted extends TextBlockSimple { @Override public void drawTOBEREMOVED(Graphics2D g2d, double x, double y) { -// final AffineTransform at = g2d.getTransform(); -// final StringBounder stringBounder = StringBounderUtils.asStringBounder(g2d); -// -// final double deltaY = calculateDimension(StringBounderUtils.asStringBounder(g2d)).getHeight() -// - circledCharacter.getPreferredHeight(stringBounder); -// -// // g2d.translate(x, y + deltaY / 2.0); -// circledCharacter.draw(g2d, (int) x, (int) (y + deltaY / 2.0)); -// // circledCharacter.draw(g2d); -// -// g2d.setTransform(at); -// final double widthCircledCharacter = getCircledCharacterWithAndMargin(stringBounder); -// g2d.translate(widthCircledCharacter, 0); -// -// super.drawTOBEREMOVED(g2d, x, y); -// -// g2d.setTransform(at); + // final AffineTransform at = g2d.getTransform(); + // final StringBounder stringBounder = StringBounderUtils.asStringBounder(g2d); + // + // final double deltaY = calculateDimension(StringBounderUtils.asStringBounder(g2d)).getHeight() + // - circledCharacter.getPreferredHeight(stringBounder); + // + // // g2d.translate(x, y + deltaY / 2.0); + // circledCharacter.draw(g2d, (int) x, (int) (y + deltaY / 2.0)); + // // circledCharacter.draw(g2d); + // + // g2d.setTransform(at); + // final double widthCircledCharacter = getCircledCharacterWithAndMargin(stringBounder); + // g2d.translate(widthCircledCharacter, 0); + // + // super.drawTOBEREMOVED(g2d, x, y); + // + // g2d.setTransform(at); throw new UnsupportedOperationException(); } - + @Override public void drawU(UGraphic ug, double x, double y) { final double atX = ug.getTranslateX(); final double atY = ug.getTranslateY(); final StringBounder stringBounder = ug.getStringBounder(); -// final double deltaY = calculateDimension(stringBounder).getHeight() -// - circledCharacter.getPreferredHeight(stringBounder); + // final double deltaY = calculateDimension(stringBounder).getHeight() + // - circledCharacter.getPreferredHeight(stringBounder); - //circledCharacter.drawU(ug, (int) x, (int) (y + deltaY / 2.0)); + // circledCharacter.drawU(ug, (int) x, (int) (y + deltaY / 2.0)); circledCharacter.drawU(ug, x, y); ug.setTranslate(atX, atY); diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java b/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java index 955f78a70..09dbcb6c6 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java @@ -28,13 +28,11 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4111 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.graphic; -import java.awt.Color; -import java.awt.Font; import java.util.List; import net.sourceforge.plantuml.cucadiagram.Stereotype; @@ -42,38 +40,39 @@ import net.sourceforge.plantuml.sequencediagram.MessageNumber; public class TextBlockUtils { - public static TextBlock create(List texts, Font font, Color paint, + public static TextBlock create(List texts, FontConfiguration fontConfiguration, HorizontalAlignement horizontalAlignement) { if (texts.size() > 0 && texts.get(0) instanceof Stereotype) { - return createStereotype(texts, font, paint, horizontalAlignement); + return createStereotype(texts, fontConfiguration, horizontalAlignement); } if (texts.size() > 0 && texts.get(0) instanceof MessageNumber) { - return createMessageNumber(texts, font, paint, horizontalAlignement); + return createMessageNumber(texts, fontConfiguration, horizontalAlignement); } - return new TextBlockSimple(texts, font, paint, horizontalAlignement); + return new TextBlockSimple(texts, fontConfiguration, horizontalAlignement); } - private static TextBlock createMessageNumber(List texts, Font font, Color paint, - HorizontalAlignement horizontalAlignement) { + private static TextBlock createMessageNumber(List texts, + FontConfiguration fontConfiguration, HorizontalAlignement horizontalAlignement) { final MessageNumber number = (MessageNumber) texts.get(0); - return new TextBlockWithNumber(number.getNumber(), texts.subList(1, texts.size()), font, paint, + return new TextBlockWithNumber(number.getNumber(), texts.subList(1, texts.size()), fontConfiguration, horizontalAlignement); } - private static TextBlock createStereotype(List texts, Font font, Color paint, + private static TextBlock createStereotype(List texts, FontConfiguration fontConfiguration, HorizontalAlignement horizontalAlignement) { final Stereotype stereotype = (Stereotype) texts.get(0); if (stereotype.isSpotted()) { - final CircledCharacter circledCharacter = new CircledCharacter(stereotype.getCharacter(), stereotype - .getRadius(), stereotype.getCircledFont(), stereotype.getColor(), null, paint); + final CircledCharacter circledCharacter = new CircledCharacter(stereotype.getCharacter(), + stereotype.getRadius(), stereotype.getCircledFont(), stereotype.getColor(), null, + fontConfiguration.getColor()); if (stereotype.getLabel() == null) { - return new TextBlockSpotted(circledCharacter, texts.subList(1, texts.size()), font, paint, + return new TextBlockSpotted(circledCharacter, texts.subList(1, texts.size()), fontConfiguration, horizontalAlignement); } - return new TextBlockSpotted(circledCharacter, texts, font, paint, horizontalAlignement); + return new TextBlockSpotted(circledCharacter, texts, fontConfiguration, horizontalAlignement); } - return new TextBlockSimple(texts, font, paint, horizontalAlignement); + return new TextBlockSimple(texts, fontConfiguration, horizontalAlignement); } // static private Font deriveForCircleCharacter(Font font) { diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockWithNumber.java b/src/net/sourceforge/plantuml/graphic/TextBlockWithNumber.java index 7a90c16a9..d915b3d74 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockWithNumber.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockWithNumber.java @@ -28,13 +28,11 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4125 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.graphic; -import java.awt.Color; -import java.awt.Font; import java.awt.Graphics2D; import java.awt.geom.Dimension2D; import java.util.Arrays; @@ -47,10 +45,10 @@ class TextBlockWithNumber extends TextBlockSimple { private final TextBlock numText; - public TextBlockWithNumber(String number, List texts, Font font, Color paint, + public TextBlockWithNumber(String number, List texts, FontConfiguration fontConfiguration, HorizontalAlignement horizontalAlignement) { - super(texts, font, paint, horizontalAlignement); - this.numText = TextBlockUtils.create(Arrays.asList(number), font, paint, HorizontalAlignement.LEFT); + super(texts, fontConfiguration, horizontalAlignement); + this.numText = TextBlockUtils.create(Arrays.asList(number), fontConfiguration, HorizontalAlignement.LEFT); } @Override @@ -77,7 +75,7 @@ class TextBlockWithNumber extends TextBlockSimple { numText.drawTOBEREMOVED(g2d, x, y + deltaY / 2.0); super.drawTOBEREMOVED(g2d, x + getNumberWithAndMargin(stringBounder), y); } - + @Override public void drawU(UGraphic ug, double x, double y) { final StringBounder stringBounder = ug.getStringBounder(); diff --git a/src/net/sourceforge/plantuml/png/PngTitler.java b/src/net/sourceforge/plantuml/png/PngTitler.java index 353b17818..5bb95d320 100644 --- a/src/net/sourceforge/plantuml/png/PngTitler.java +++ b/src/net/sourceforge/plantuml/png/PngTitler.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5793 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.png; @@ -41,6 +41,7 @@ import java.awt.geom.Dimension2D; import java.awt.image.BufferedImage; import java.util.List; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounderUtils; @@ -91,7 +92,7 @@ public class PngTitler { return null; } final Font normalFont = new Font(fontFamily, Font.PLAIN, fontSize); - return TextBlockUtils.create(text, normalFont, textColor, horizontalAlignement); + return TextBlockUtils.create(text, new FontConfiguration(normalFont, textColor), horizontalAlignement); } static private BufferedImage addTitle(BufferedImage im, Color background, Color textColor, List text, @@ -100,7 +101,8 @@ public class PngTitler { final Font normalFont = new Font(fontFamily, Font.PLAIN, fontSize); final Graphics2D oldg2d = im.createGraphics(); - final TextBlock textBloc = TextBlockUtils.create(text, normalFont, textColor, horizontalAlignement); + final TextBlock textBloc = TextBlockUtils.create(text, new FontConfiguration(normalFont, textColor), + horizontalAlignement); final Dimension2D dimText = textBloc.calculateDimension(StringBounderUtils.asStringBounder(oldg2d)); oldg2d.dispose(); diff --git a/src/net/sourceforge/plantuml/posimo/EntityImageBlock.java b/src/net/sourceforge/plantuml/posimo/EntityImageBlock.java index 60a7dfcf7..1084c86cf 100644 --- a/src/net/sourceforge/plantuml/posimo/EntityImageBlock.java +++ b/src/net/sourceforge/plantuml/posimo/EntityImageBlock.java @@ -48,6 +48,7 @@ import net.sourceforge.plantuml.cucadiagram.EntityType; import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.dot.PlayField; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; @@ -77,8 +78,8 @@ public class EntityImageBlock implements IEntityImageBlock { this.links = links; if (StringUtils.isNotEmpty(entity.getDisplay())) { - this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), - param.getFont(titleParam, null), Color.BLACK, HorizontalAlignement.CENTER); + this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), new FontConfiguration( + param.getFont(titleParam, null), Color.BLACK), HorizontalAlignement.CENTER); } else { this.name = null; } diff --git a/src/net/sourceforge/plantuml/posimo/EntityImageClass2.java b/src/net/sourceforge/plantuml/posimo/EntityImageClass2.java index dba55b780..0f075ddf5 100644 --- a/src/net/sourceforge/plantuml/posimo/EntityImageClass2.java +++ b/src/net/sourceforge/plantuml/posimo/EntityImageClass2.java @@ -49,6 +49,7 @@ import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.graph.MethodsOrFieldsArea2; import net.sourceforge.plantuml.graphic.CircledCharacter; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; @@ -70,15 +71,16 @@ public class EntityImageClass2 extends AbstractEntityImage2 { public EntityImageClass2(IEntity entity, ISkinParam skinParam, Collection links) { super(entity, skinParam); - this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), getFont(FontParam.CLASS), - Color.BLACK, HorizontalAlignement.CENTER); + this.name = TextBlockUtils.create(StringUtils.getWithNewlines(entity.getDisplay()), new FontConfiguration( + getFont(FontParam.CLASS), Color.BLACK), HorizontalAlignement.CENTER); final Stereotype stereotype = entity.getStereotype(); if (stereotype == null || stereotype.getLabel() == null) { this.stereo = null; } else { - this.stereo = TextBlockUtils.create(StringUtils.getWithNewlines(stereotype.getLabel()), - getFont(FontParam.CLASS_STEREOTYPE), getFontColor(FontParam.CLASS_STEREOTYPE), - HorizontalAlignement.CENTER); + this.stereo = TextBlockUtils + .create(StringUtils.getWithNewlines(stereotype.getLabel()), new FontConfiguration( + getFont(FontParam.CLASS_STEREOTYPE), getFontColor(FontParam.CLASS_STEREOTYPE)), + HorizontalAlignement.CENTER); } this.methods = new MethodsOrFieldsArea2(entity.methods2(), FontParam.CLASS_ATTRIBUTE, skinParam); this.fields = new MethodsOrFieldsArea2(entity.fields2(), FontParam.CLASS_ATTRIBUTE, skinParam); diff --git a/src/net/sourceforge/plantuml/posimo/Frame.java b/src/net/sourceforge/plantuml/posimo/Frame.java index 5604c0251..6195531cf 100644 --- a/src/net/sourceforge/plantuml/posimo/Frame.java +++ b/src/net/sourceforge/plantuml/posimo/Frame.java @@ -41,6 +41,7 @@ import java.util.List; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; @@ -116,7 +117,8 @@ public class Frame implements Component { private TextBlock createTextBloc() { final Font font = skinParam.getFont(FontParam.PACKAGE, null); final Color textColor = skinParam.getFontHtmlColor(FontParam.PACKAGE, null).getColor(); - final TextBlock bloc = TextBlockUtils.create(name, font, textColor, HorizontalAlignement.LEFT); + final TextBlock bloc = TextBlockUtils.create(name, new FontConfiguration(font, textColor), + HorizontalAlignement.LEFT); return bloc; } diff --git a/src/net/sourceforge/plantuml/posimo/LabelImage.java b/src/net/sourceforge/plantuml/posimo/LabelImage.java index c91066e45..0990209b6 100644 --- a/src/net/sourceforge/plantuml/posimo/LabelImage.java +++ b/src/net/sourceforge/plantuml/posimo/LabelImage.java @@ -40,6 +40,7 @@ import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.cucadiagram.Link; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; @@ -61,14 +62,14 @@ public class LabelImage { // this.entity = entity; this.param = param; this.rose = rose; - this.name = TextBlockUtils.create(StringUtils.getWithNewlines(link.getLabel()), param.getFont(FontParam.CLASS, null), - Color.BLACK, HorizontalAlignement.CENTER); + this.name = TextBlockUtils.create(StringUtils.getWithNewlines(link.getLabel()), + new FontConfiguration(param.getFont(FontParam.CLASS, null), Color.BLACK), HorizontalAlignement.CENTER); } public Dimension2D getDimension(StringBounder stringBounder) { final Dimension2D dim = name.calculateDimension(stringBounder); return dim; - //return Dimension2DDouble.delta(dim, 2 * margin); + // return Dimension2DDouble.delta(dim, 2 * margin); } public void drawU(UGraphic ug, double x, double y) { diff --git a/src/net/sourceforge/plantuml/printskin/PrintSkin.java b/src/net/sourceforge/plantuml/printskin/PrintSkin.java index 5b50a3f15..3aa30fd14 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: 5924 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.printskin; @@ -41,7 +41,6 @@ import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.util.Arrays; -import java.util.EnumSet; import java.util.List; import net.sourceforge.plantuml.AbstractPSystem; @@ -49,6 +48,7 @@ import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.EmptyImageBuilder; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.SkinParam; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; @@ -73,7 +73,8 @@ class PrintSkin extends AbstractPSystem { private float ypos = 0; private float maxYpos = 0; - public List createFiles(File suggestedFile, FileFormatOption fileFormat) throws IOException, InterruptedException { + public List createFiles(File suggestedFile, FileFormatOption fileFormat) throws IOException, + InterruptedException { final List result = Arrays.asList(suggestedFile); final BufferedImage im = createImage(); @@ -92,10 +93,10 @@ class PrintSkin extends AbstractPSystem { final BufferedImage im = builder.getBufferedImage(); final Graphics2D g2d = builder.getGraphics2D(); - + ug = new UGraphicG2d(g2d, null, 1.0); - for (ComponentType type : ComponentType.all() ) { + for (ComponentType type : ComponentType.all()) { printComponent(type); ypos += 10; maxYpos = Math.max(maxYpos, ypos); @@ -128,22 +129,22 @@ class PrintSkin extends AbstractPSystem { } ug.getParam().setColor(Color.LIGHT_GRAY); ug.getParam().setBackcolor(Color.LIGHT_GRAY); - ug.draw(xpos-1, ypos-1, new URectangle(width+2, height+2)); - //g2d.drawRect((int) xpos - 1, (int) ypos - 1, (int) width + 2, (int) height + 2); + ug.draw(xpos - 1, ypos - 1, new URectangle(width + 2, height + 2)); + // g2d.drawRect((int) xpos - 1, (int) ypos - 1, (int) width + 2, (int) height + 2); - //final AffineTransform at = g2d.getTransform(); - //g2d.translate(xpos, ypos); + // final AffineTransform at = g2d.getTransform(); + // g2d.translate(xpos, ypos); ug.translate(xpos, ypos); ug.getParam().reset(); comp.drawU(ug, new Dimension2DDouble(width, height), new SimpleContext2D(false)); ug.translate(-xpos, -ypos); - //g2d.setTransform(at); + // g2d.setTransform(at); ypos += height; } private void println(String s) { - final TextBlock textBlock = TextBlockUtils.create(Arrays.asList(s), FONT1, Color.BLACK, + final TextBlock textBlock = TextBlockUtils.create(Arrays.asList(s), new FontConfiguration(FONT1, Color.BLACK), HorizontalAlignement.LEFT); textBlock.drawU(ug, xpos, ypos); ypos += textBlock.calculateDimension(ug.getStringBounder()).getHeight(); diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java index ceec85d30..c52c27747 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5942 $ + * Revision $Revision: 6016 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; @@ -64,17 +64,15 @@ import net.sourceforge.plantuml.skin.Skin; class DrawableSetInitializer { + private ComponentType defaultLineType; private final DrawableSet drawableSet; private final boolean showTail; private double freeX = 0; private double freeY = 0; - // private final double groupingMargin = 10; private final double autonewpage; - // private int maxGrouping = 0; - private ConstraintSet constraintSet; public DrawableSetInitializer(Skin skin, ISkinParam skinParam, boolean showTail, double autonewpage) { @@ -86,11 +84,22 @@ class DrawableSetInitializer { private double lastFreeY = 0; + private boolean hasDelay() { + for (Event ev : drawableSet.getAllEvents()) { + if (ev instanceof Delay) { + return true; + } + } + return false; + } + public DrawableSet createDrawableSet(StringBounder stringBounder) { if (freeY != 0) { throw new IllegalStateException(); } + this.defaultLineType = hasDelay() ? ComponentType.CONTINUE_LINE : ComponentType.PARTICIPANT_LINE; + for (Participant p : drawableSet.getAllParticipants()) { prepareParticipant(stringBounder, p); } @@ -271,11 +280,11 @@ class DrawableSetInitializer { if (m.getType() != GroupingType.START) { throw new IllegalStateException(); } - final ISkinParam skinParam = new SkinParamBackcolored(drawableSet.getSkinParam(), m.getBackColorElement(), m - .getBackColorGeneral()); + final ISkinParam skinParam = new SkinParamBackcolored(drawableSet.getSkinParam(), m.getBackColorElement(), + m.getBackColorGeneral()); // this.maxGrouping++; - final List strings = m.getTitle().equals("group") ? Arrays.asList(m.getComment()) : Arrays.asList(m - .getTitle(), m.getComment()); + final List strings = m.getTitle().equals("group") ? Arrays.asList(m.getComment()) : Arrays.asList( + m.getTitle(), m.getComment()); final Component header = drawableSet.getSkin().createComponent(ComponentType.GROUPING_HEADER, skinParam, strings); final InGroupableList inGroupableList = new InGroupableList(m, freeY); @@ -387,7 +396,7 @@ class DrawableSetInitializer { p.getDisplay()); final Component tail = drawableSet.getSkin().createComponent(ComponentType.PARTICIPANT_TAIL, skinParam, p.getDisplay()); - final Component line = drawableSet.getSkin().createComponent(ComponentType.PARTICIPANT_LINE, + final Component line = drawableSet.getSkin().createComponent(this.defaultLineType, drawableSet.getSkinParam(), p.getDisplay()); final Component delayLine = drawableSet.getSkin().createComponent(ComponentType.DELAY_LINE, drawableSet.getSkinParam(), p.getDisplay()); @@ -398,7 +407,7 @@ class DrawableSetInitializer { p.getDisplay()); final Component tail = drawableSet.getSkin().createComponent(ComponentType.ACTOR_TAIL, skinParam, p.getDisplay()); - final Component line = drawableSet.getSkin().createComponent(ComponentType.ACTOR_LINE, + final Component line = drawableSet.getSkin().createComponent(this.defaultLineType, drawableSet.getSkinParam(), p.getDisplay()); final Component delayLine = drawableSet.getSkin().createComponent(ComponentType.DELAY_LINE, drawableSet.getSkinParam(), p.getDisplay()); diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java index b6f4fa808..61e10ab21 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java @@ -28,13 +28,14 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5636 $ + * Revision $Revision: 6026 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import net.sourceforge.plantuml.ISkinParam; @@ -167,18 +168,22 @@ class LifeLine { return delta; } - Collection getSegments() { - final Collection result = new ArrayList(); + Collection getSegments() { + final Collection result = new ArrayList(); for (int i = 0; i < events.size(); i++) { - final Segment seg = getSegment(i); + final SegmentColored seg = getSegment(i); if (seg != null) { - result.add(seg); + result.addAll(cutSegmentIfNeed(seg, participant.getDelays())); } } return result; } - private Segment getSegment(int i) { + static Collection cutSegmentIfNeed(SegmentColored seg, Collection delays) { + return Collections.singleton(seg); + } + + private SegmentColored getSegment(int i) { if (events.get(i).type != LifeSegmentVariation.LARGER) { return null; } @@ -190,10 +195,10 @@ class LifeLine { level--; } if (level == 0) { - return new Segment(events.get(i).y, events.get(j).y, events.get(i).backcolor); + return new SegmentColored(events.get(i).y, events.get(j).y, events.get(i).backcolor); } } - return new Segment(events.get(i).y, events.get(events.size() - 1).y, events.get(i).backcolor); + return new SegmentColored(events.get(i).y, events.get(events.size() - 1).y, events.get(i).backcolor); } public void drawU(UGraphic ug, Skin skin, ISkinParam skinParam) { @@ -204,10 +209,10 @@ class LifeLine { ug.translate(getStartingX(stringBounder), 0); - for (Segment seg : getSegments()) { + for (SegmentColored seg : getSegments()) { final ISkinParam skinParam2 = new SkinParamBackcolored(skinParam, seg.getSpecificBackColor()); final Component comp = skin.createComponent(ComponentType.ALIVE_LINE, skinParam2, null); - final int currentLevel = getLevel(seg.getPos1()); + final int currentLevel = getLevel(seg.getSegment().getPos1()); seg.drawU(ug, comp, currentLevel); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/LivingParticipantBox.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/LivingParticipantBox.java index 8c9a2d33e..f16befe69 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/LivingParticipantBox.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/LivingParticipantBox.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5870 $ + * Revision $Revision: 6024 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; @@ -61,14 +61,14 @@ public class LivingParticipantBox implements InGroupable { return lifeLine; } - public Segment getLiveThicknessAt(StringBounder stringBounder, double y) { + public SegmentColored getLiveThicknessAt(StringBounder stringBounder, double y) { final double left = lifeLine.getLeftShift(y); assert left >= 0; final double right = lifeLine.getRightShift(y); assert right >= 0 : "right=" + right; final double centerX = participantBox.getCenterX(stringBounder); // System.err.println("Attention, null for segment"); - return new Segment(centerX - left, centerX + right, null); + return new SegmentColored(centerX - left, centerX + right, null); } public void drawLineU(UGraphic ug, double startingY, double endingY, boolean showTail) { diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageArrow.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageArrow.java index 9bae61128..1a477ea10 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageArrow.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageArrow.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5870 $ + * Revision $Revision: 6026 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; @@ -71,12 +71,12 @@ class MessageArrow extends Arrow { private double getLeftStartInternal(StringBounder stringBounder) { return getParticipantAt(stringBounder, NotePosition.LEFT).getLiveThicknessAt(stringBounder, - getArrowYStartLevel(stringBounder)).getPos2(); + getArrowYStartLevel(stringBounder)).getSegment().getPos2(); } private double getRightEndInternal(StringBounder stringBounder) { return getParticipantAt(stringBounder, NotePosition.RIGHT).getLiveThicknessAt(stringBounder, - getArrowYStartLevel(stringBounder)).getPos1(); + getArrowYStartLevel(stringBounder)).getSegment().getPos1(); } @Override diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageExoArrow.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageExoArrow.java index 97df4f0f6..b25a4bc25 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageExoArrow.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageExoArrow.java @@ -70,12 +70,12 @@ public class MessageExoArrow extends Arrow { // - getPreferredWidth(stringBounder)); return 0; } - return p.getLiveThicknessAt(stringBounder, getArrowYStartLevel(stringBounder)).getPos2(); + return p.getLiveThicknessAt(stringBounder, getArrowYStartLevel(stringBounder)).getSegment().getPos2(); } private double getRightEndInternal(StringBounder stringBounder, double maxX) { if (type == MessageExoType.FROM_LEFT || type == MessageExoType.TO_LEFT) { - return p.getLiveThicknessAt(stringBounder, getArrowYStartLevel(stringBounder)).getPos1(); + return p.getLiveThicknessAt(stringBounder, getArrowYStartLevel(stringBounder)).getSegment().getPos1(); } return Math.max(maxX, getLeftStartInternal(stringBounder) + getPreferredWidth(stringBounder)); } @@ -159,5 +159,5 @@ public class MessageExoArrow extends Arrow { public double getActualWidth(StringBounder stringBounder) { return getActualWidth(stringBounder, getMaxX()); } - + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageSelfArrow.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageSelfArrow.java index 803dad82b..1424cf154 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageSelfArrow.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageSelfArrow.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5870 $ + * Revision $Revision: 6026 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; @@ -73,7 +73,7 @@ class MessageSelfArrow extends Arrow { @Override public double getStartingX(StringBounder stringBounder) { - return p1.getLiveThicknessAt(stringBounder, getArrowYStartLevel(stringBounder)).getPos2(); + return p1.getLiveThicknessAt(stringBounder, getArrowYStartLevel(stringBounder)).getSegment().getPos2(); } @Override diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/NoteBox.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/NoteBox.java index 45dced98d..664445379 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/NoteBox.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/NoteBox.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5870 $ + * Revision $Revision: 6026 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; @@ -91,12 +91,12 @@ class NoteBox extends GraphicalElement implements InGroupable { @Override public double getStartingX(StringBounder stringBounder) { - final Segment segment = getSegment(stringBounder); + final SegmentColored segment = getSegment(stringBounder); final int xStart; if (position == NotePosition.LEFT) { - xStart = (int) (segment.getPos1() - getPreferredWidth(stringBounder)); + xStart = (int) (segment.getSegment().getPos1() - getPreferredWidth(stringBounder)); } else if (position == NotePosition.RIGHT) { - xStart = (int) (segment.getPos2()); + xStart = (int) (segment.getSegment().getPos2()); } else if (position == NotePosition.OVER) { xStart = (int) (p1.getParticipantBox().getCenterX(stringBounder) - getPreferredWidth(stringBounder) / 2); } else if (position == NotePosition.OVER_SEVERAL) { @@ -106,15 +106,16 @@ class NoteBox extends GraphicalElement implements InGroupable { } else { throw new IllegalStateException(); } -// if (InGroupableList.NEW_METHOD) { -// System.err.println("GET STARTING X OF " + this + " " + (xStart + delta)); -// } + // if (InGroupableList.NEW_METHOD) { + // System.err.println("GET STARTING X OF " + this + " " + (xStart + + // delta)); + // } return xStart + delta; } - private Segment getSegment(StringBounder stringBounder) { - final Segment segment = p1.getLiveThicknessAt(stringBounder, getStartingY()); - final Segment segment2 = p1.getLiveThicknessAt(stringBounder, getStartingY() + private SegmentColored getSegment(StringBounder stringBounder) { + final SegmentColored segment = p1.getLiveThicknessAt(stringBounder, getStartingY()); + final SegmentColored segment2 = p1.getLiveThicknessAt(stringBounder, getStartingY() + comp.getPreferredHeight(stringBounder)); return segment.merge(segment2); } @@ -135,5 +136,4 @@ class NoteBox extends GraphicalElement implements InGroupable { return toString(); } - } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java index d9afb7d64..453a0109b 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBox.java @@ -28,12 +28,14 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5942 $ + * Revision $Revision: 6016 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; import java.util.List; import net.sourceforge.plantuml.Dimension2DDouble; @@ -106,8 +108,10 @@ public class ParticipantBox implements Pushable { final double y1 = topStartingY - head.getPreferredHeight(stringBounder) - line.getPreferredHeight(stringBounder) / 2; ug.translate(startingX + outMargin, y1); - head.drawU(ug, new Dimension2DDouble(head.getPreferredWidth(stringBounder), head - .getPreferredHeight(stringBounder)), new SimpleContext2D(false)); + head.drawU( + ug, + new Dimension2DDouble(head.getPreferredWidth(stringBounder), head.getPreferredHeight(stringBounder)), + new SimpleContext2D(false)); ug.setTranslate(atX, atY); } @@ -119,8 +123,10 @@ public class ParticipantBox implements Pushable { // throw new IllegalStateException(); // } ug.translate(startingX + outMargin, positionTail); - tail.drawU(ug, new Dimension2DDouble(tail.getPreferredWidth(stringBounder), tail - .getPreferredHeight(stringBounder)), new SimpleContext2D(false)); + tail.drawU( + ug, + new Dimension2DDouble(tail.getPreferredWidth(stringBounder), tail.getPreferredHeight(stringBounder)), + new SimpleContext2D(false)); ug.setTranslate(atX, atY); } } @@ -128,8 +134,9 @@ public class ParticipantBox implements Pushable { public void drawParticipantHead(UGraphic ug) { ug.translate(outMargin, 0); final StringBounder stringBounder = ug.getStringBounder(); - head.drawU(ug, new Dimension2DDouble(head.getPreferredWidth(stringBounder), head - .getPreferredHeight(stringBounder)), new SimpleContext2D(false)); + head.drawU(ug, + new Dimension2DDouble(head.getPreferredWidth(stringBounder), head.getPreferredHeight(stringBounder)), + new SimpleContext2D(false)); ug.translate(-outMargin, 0); } @@ -175,7 +182,10 @@ public class ParticipantBox implements Pushable { public void addDelay(GraphicalDelayText delay) { this.delays.add(delay); + } + public Collection getDelays() { + return Collections.unmodifiableCollection(delays); } } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBoxSimple.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBoxSimple.java index 593c4e60b..2ff325c03 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBoxSimple.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/ParticipantBoxSimple.java @@ -28,11 +28,13 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5249 $ + * Revision $Revision: 6016 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; +import java.util.Collection; + import net.sourceforge.plantuml.graphic.StringBounder; class ParticipantBoxSimple implements Pushable { @@ -66,5 +68,9 @@ class ParticipantBoxSimple implements Pushable { return 0; } + public Collection getDelays() { + return null; + } + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Pushable.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Pushable.java index c06c7d63c..b3ff81d01 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/Pushable.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Pushable.java @@ -28,11 +28,13 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5249 $ + * Revision $Revision: 6016 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; +import java.util.Collection; + import net.sourceforge.plantuml.graphic.StringBounder; interface Pushable { @@ -42,5 +44,8 @@ interface Pushable { double getCenterX(StringBounder stringBounder); void pushToLeft(double deltaX); + + public Collection getDelays(); + } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Segment.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Segment.java index 1b1595012..e959ac11d 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/Segment.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Segment.java @@ -33,33 +33,25 @@ */ package net.sourceforge.plantuml.sequencediagram.graphic; -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.Component; -import net.sourceforge.plantuml.skin.SimpleContext2D; -import net.sourceforge.plantuml.ugraphic.UGraphic; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; class Segment { final private double pos1; final private double pos2; - final private HtmlColor backcolor; - Segment(double pos1, double pos2, HtmlColor backcolor) { + Segment(double pos1, double pos2) { this.pos1 = pos1; this.pos2 = pos2; - this.backcolor = backcolor; if (pos2 < pos1) { - throw new IllegalArgumentException("pos1=" + pos1 + " pos2=" + pos2); + throw new IllegalArgumentException(); } } - - public HtmlColor getSpecificBackColor() { - return backcolor; - } @Override public boolean equals(Object obj) { @@ -72,40 +64,53 @@ class Segment { return new Double(pos1).hashCode() + new Double(pos2).hashCode(); } - public boolean contains(double y) { + final public boolean contains(double y) { return y >= pos1 && y <= pos2; } + final public boolean contains(Segment other) { + return contains(other.pos1) && contains(other.pos2); + } + @Override public String toString() { return "" + pos1 + " - " + pos2; } - public void drawU(UGraphic ug, Component comp, int level) { - final double atX = ug.getTranslateX(); - final double atY = ug.getTranslateY(); - - final StringBounder stringBounder = ug.getStringBounder(); - ug.translate((level - 1) * comp.getPreferredWidth(stringBounder) / 2, pos1); - final Dimension2D dim = new Dimension2DDouble(comp.getPreferredWidth(stringBounder), pos2 - pos1); - comp.drawU(ug, dim, new SimpleContext2D(false)); - ug.setTranslate(atX, atY); - } - - public double getLength() { + final public double getLength() { return pos2 - pos1; } - public double getPos1() { + final public double getPos1() { return pos1; } - public double getPos2() { + final public double getPos2() { return pos2; } public Segment merge(Segment this2) { - return new Segment(Math.min(this.pos1, this2.pos1), Math.max(this.pos2, this2.pos2), backcolor); + return new Segment(Math.min(this.pos1, this2.pos1), Math.max(this.pos2, this2.pos2)); + } + + public Collection cutSegmentIfNeed(Collection delays) { + final List result = new ArrayList(delays); + Collections.sort(result, new SortPos1()); + result.add(this); + return Collections.unmodifiableCollection(result); + } + + private Collection cutSegmentIfNeed(Segment other) { + if (this.contains(other) == false) { + throw new IllegalArgumentException(); + } + return Arrays.asList(new Segment(this.pos1, other.pos1), new Segment(this.pos2, other.pos2)); + } + + static class SortPos1 implements Comparator { + public int compare(Segment segA, Segment segB) { + return (int) Math.signum(segB.pos1 - segA.pos1); + } } } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SegmentColored.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SegmentColored.java new file mode 100644 index 000000000..5a9fba82b --- /dev/null +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SegmentColored.java @@ -0,0 +1,99 @@ +/* ======================================================================== + * 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: 6026 $ + * + */ +package net.sourceforge.plantuml.sequencediagram.graphic; + +import java.awt.geom.Dimension2D; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.skin.Component; +import net.sourceforge.plantuml.skin.SimpleContext2D; +import net.sourceforge.plantuml.ugraphic.UGraphic; + +class SegmentColored { + + final private Segment segment; + final private HtmlColor backcolor; + + SegmentColored(double pos1, double pos2, HtmlColor backcolor) { + this(new Segment(pos1, pos2), backcolor); + } + + private SegmentColored(Segment segment, HtmlColor backcolor) { + this.segment = segment; + this.backcolor = backcolor; + } + + public HtmlColor getSpecificBackColor() { + return backcolor; + } + + @Override + public boolean equals(Object obj) { + final SegmentColored this2 = (SegmentColored) obj; + return this.segment.equals(this2.segment); + } + + @Override + public int hashCode() { + return this.segment.hashCode(); + } + + @Override + public String toString() { + return this.segment.toString(); + } + + public void drawU(UGraphic ug, Component comp, int level) { + final double atX = ug.getTranslateX(); + final double atY = ug.getTranslateY(); + + final StringBounder stringBounder = ug.getStringBounder(); + ug.translate((level - 1) * comp.getPreferredWidth(stringBounder) / 2, segment.getPos1()); + final Dimension2D dim = new Dimension2DDouble(comp.getPreferredWidth(stringBounder), segment.getPos2() + - segment.getPos1()); + comp.drawU(ug, dim, new SimpleContext2D(false)); + ug.setTranslate(atX, atY); + } + + public SegmentColored merge(SegmentColored this2) { + return new SegmentColored(this.segment.merge(this2.segment), backcolor); + } + + public final Segment getSegment() { + return segment; + } + +} diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java index 4d40fd633..d8b148d99 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: 5928 $ + * Revision $Revision: 6026 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; @@ -90,7 +90,8 @@ class Step1Message extends Step1Abstract { final double length; if (isSelfMessage()) { length = graphic.getArrowOnlyWidth(getStringBounder()) - + getLivingParticipantBox1().getLiveThicknessAt(getStringBounder(), arrowYStartLevel).getLength(); + + getLivingParticipantBox1().getLiveThicknessAt(getStringBounder(), arrowYStartLevel) + .getSegment().getLength(); } else { length = graphic.getArrowOnlyWidth(getStringBounder()) + getLivingParticipantBox(NotePosition.LEFT).getLifeLine().getRightShift(arrowYStartLevel) diff --git a/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java b/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java index 20b54c4db..b9bdb19d4 100644 --- a/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java +++ b/src/net/sourceforge/plantuml/skin/AbstractTextualComponent.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5741 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.skin; @@ -39,6 +39,7 @@ import java.awt.geom.Dimension2D; import java.util.Arrays; import java.util.List; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; @@ -76,7 +77,7 @@ public abstract class AbstractTextualComponent extends AbstractComponent { if (strings.size() == 1 && strings.get(0).length() == 0) { textBlock = new TextBlockEmpty(); } else { - textBlock = TextBlockUtils.create(strings, font, fontColor, horizontalAlignement); + textBlock = TextBlockUtils.create(strings, new FontConfiguration(font, fontColor), horizontalAlignement); } } diff --git a/src/net/sourceforge/plantuml/skin/ComponentType.java b/src/net/sourceforge/plantuml/skin/ComponentType.java index f37582939..eeb1eb3a4 100644 --- a/src/net/sourceforge/plantuml/skin/ComponentType.java +++ b/src/net/sourceforge/plantuml/skin/ComponentType.java @@ -46,15 +46,17 @@ public class ComponentType { private static final List nonArrows = new ArrayList(); 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"); // static public final ComponentType ALIVE_LINE = new ComponentType("ALIVE_LINE"); - static public final ComponentType DELAY_LINE = new ComponentType("DELAY_LINE"); static public final ComponentType DELAY_TEXT = new ComponentType("DELAY_TEXT"); static public final ComponentType DESTROY = new ComponentType("DESTROY"); + static public final ComponentType DELAY_LINE = new ComponentType("DELAY_LINE"); + static public final ComponentType PARTICIPANT_LINE = new ComponentType("PARTICIPANT_LINE"); + static public final ComponentType CONTINUE_LINE = new ComponentType("CONTINUE_LINE"); + // static public final ComponentType GROUPING_BODY = new ComponentType("GROUPING_BODY"); static public final ComponentType GROUPING_ELSE = new ComponentType("GROUPING_ELSE"); @@ -68,7 +70,6 @@ public class ComponentType { // 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"); // diff --git a/src/net/sourceforge/plantuml/skin/GrayComponent.java b/src/net/sourceforge/plantuml/skin/GrayComponent.java index 3fa42da79..6123f9ca8 100644 --- a/src/net/sourceforge/plantuml/skin/GrayComponent.java +++ b/src/net/sourceforge/plantuml/skin/GrayComponent.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4167 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.skin; @@ -39,6 +39,7 @@ import java.awt.geom.Dimension2D; import java.util.ArrayList; import java.util.List; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; @@ -70,7 +71,8 @@ class GrayComponent extends AbstractComponent { strings.add(n.substring(i, Math.min(i + split, n.length()))); } - final TextBlock textBlock = TextBlockUtils.create(strings, NORMAL, Color.BLACK, HorizontalAlignement.LEFT); + final TextBlock textBlock = TextBlockUtils.create(strings, new FontConfiguration(NORMAL, Color.BLACK), + HorizontalAlignement.LEFT); textBlock.drawU(ug, 0, 0); } diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java b/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java index f9bc9e931..723ee6dbd 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: 5944 $ + * Revision $Revision: 6008 $ * */ package net.sourceforge.plantuml.skin.bluemodern; @@ -82,15 +82,15 @@ public class BlueModern implements Skin { if (type == ComponentType.PARTICIPANT_LINE) { return new ComponentBlueModernLine(lineColor); } + if (type == ComponentType.CONTINUE_LINE) { + return new ComponentBlueModernLine(lineColor); + } if (type == ComponentType.ACTOR_HEAD) { return new ComponentBlueModernActor(blue2, blue1, blue1, participantFont, stringsToDisplay, true); } if (type == ComponentType.ACTOR_TAIL) { return new ComponentBlueModernActor(blue2, blue1, blue1, participantFont, stringsToDisplay, false); } - if (type == ComponentType.ACTOR_LINE) { - return new ComponentBlueModernLine(lineColor); - } if (type == ComponentType.NOTE) { return new ComponentBlueModernNote(Color.WHITE, Color.BLACK, Color.BLACK, normalFont, stringsToDisplay); } diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java index e058374c8..67c6b1668 100644 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java +++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5889 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.skin.bluemodern; @@ -39,6 +39,7 @@ import java.awt.geom.Dimension2D; import java.util.Arrays; import java.util.List; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; @@ -71,8 +72,8 @@ public class ComponentBlueModernGroupingHeader extends AbstractTextualComponent if (strings.size() == 1 || strings.get(1) == null) { this.commentTextBlock = null; } else { - this.commentTextBlock = TextBlockUtils.create(Arrays.asList("[" + strings.get(1) + "]"), smallFont, - fontColor2, HorizontalAlignement.LEFT); + this.commentTextBlock = TextBlockUtils.create(Arrays.asList("[" + strings.get(1) + "]"), + new FontConfiguration(smallFont, fontColor2), HorizontalAlignement.LEFT); } } @@ -106,7 +107,6 @@ public class ComponentBlueModernGroupingHeader extends AbstractTextualComponent ug.draw(0, 0, new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight())); } - @Override protected void drawInternalU(UGraphic ug, Dimension2D dimensionToUse) { final StringBounder stringBounder = ug.getStringBounder(); @@ -128,7 +128,7 @@ public class ComponentBlueModernGroupingHeader extends AbstractTextualComponent ug.getParam().setColor(borderColor); ug.draw(0, 0, polygon); ug.draw(0, 0, new ULine(dimensionToUse.getWidth(), 0)); - + final double heightWithoutPadding = dimensionToUse.getHeight() - getPaddingY(); ug.draw(dimensionToUse.getWidth(), 0, new ULine(0, heightWithoutPadding)); @@ -138,11 +138,11 @@ public class ComponentBlueModernGroupingHeader extends AbstractTextualComponent getTextBlock().drawU(ug, getMarginX1(), getMarginY()); if (commentTextBlock != null) { - //final Dimension2D size = commentTextBlock.calculateDimension(stringBounder); + // final Dimension2D size = commentTextBlock.calculateDimension(stringBounder); ug.getParam().setColor(generalBackgroundColor); final int x1 = getMarginX1() + textWidth; final int y2 = getMarginY() + 1; - //ug.draw(x1, y2, new URectangle(size.getWidth() + 2 * commentMargin, size.getHeight())); + // ug.draw(x1, y2, new URectangle(size.getWidth() + 2 * commentMargin, size.getHeight())); commentTextBlock.drawU(ug, x1 + commentMargin, y2); } diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernSelfArrow.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernSelfArrow.java index d56c634b1..f069222d5 100644 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernSelfArrow.java +++ b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernSelfArrow.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5945 $ + * Revision $Revision: 5977 $ * */ package net.sourceforge.plantuml.skin.bluemodern; @@ -107,12 +107,12 @@ public class ComponentBlueModernSelfArrow extends AbstractComponentBlueModernArr polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY() + delta); polygon.addPoint(0, textHeight + delta); polygon.addPoint(getArrowDeltaX(), textHeight + delta); - } else if (getArrowConfiguration().getPart() == ArrowPart.TOP_PART) { - polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY() + delta); + } else if (getArrowConfiguration().getPart() == ArrowPart.BOTTOM_PART) { + polygon.addPoint(getArrowDeltaX(), textHeight + delta); polygon.addPoint(0, textHeight + delta); polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY() + delta); } else { - polygon.addPoint(getArrowDeltaX(), textHeight + delta); + polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY() + delta); polygon.addPoint(0, textHeight + delta); polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY() + delta); } diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayLine.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayLine.java index 4981cbf57..0f9b8195e 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayLine.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseDelayLine.java @@ -53,10 +53,19 @@ public class ComponentRoseDelayLine extends AbstractComponent { @Override protected void drawInternalU(UGraphic ug, Dimension2D dimensionToUse) { ug.getParam().setColor(color); - //stroke(ug, 0.4, 2.5); - stroke(ug, 0.2, 1.5); + // stroke(ug, 0.4, 2.5); + stroke(ug, 1, 4); final int x = (int) (dimensionToUse.getWidth() / 2); + ug.setAntiAliasing(false); ug.draw(x, 0, new ULine(0, dimensionToUse.getHeight())); + ug.setAntiAliasing(true); + final double dx = 5; + final double dy = 1.5; + final double space = 1.5; + final double middle = dimensionToUse.getHeight() / 2; + ug.getParam().setStroke(new UStroke(1)); +// ug.draw(x - dx, middle + dy - space, new ULine(2 * dx, -2 * dy)); +// ug.draw(x - dx, middle + dy + space, new ULine(2 * dx, -2 * dy)); ug.getParam().setStroke(new UStroke()); } diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java index 232b65784..b8e501447 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseGroupingHeader.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5889 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.skin.rose; @@ -39,6 +39,7 @@ import java.awt.geom.Dimension2D; import java.util.Arrays; import java.util.List; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; @@ -60,19 +61,16 @@ public class ComponentRoseGroupingHeader extends AbstractTextualComponent { private final Color groupBackground; private final Color background; - public ComponentRoseGroupingHeader(Color fontColor, Color background, - Color groupBackground, Font bigFont, Font smallFont, - List strings) { - super(strings.get(0), fontColor, bigFont, HorizontalAlignement.LEFT, - 15, 30, 1); + public ComponentRoseGroupingHeader(Color fontColor, Color background, Color groupBackground, Font bigFont, + Font smallFont, List strings) { + super(strings.get(0), fontColor, bigFont, HorizontalAlignement.LEFT, 15, 30, 1); this.groupBackground = groupBackground; this.background = background; if (strings.size() == 1 || strings.get(1) == null) { this.commentTextBlock = null; } else { - this.commentTextBlock = TextBlockUtils.create(Arrays.asList("[" - + strings.get(1) + "]"), smallFont, fontColor, - HorizontalAlignement.LEFT); + this.commentTextBlock = TextBlockUtils.create(Arrays.asList("[" + strings.get(1) + "]"), + new FontConfiguration(smallFont, fontColor), HorizontalAlignement.LEFT); } } @@ -87,8 +85,7 @@ public class ComponentRoseGroupingHeader extends AbstractTextualComponent { if (commentTextBlock == null) { sup = commentMargin * 2; } else { - final Dimension2D size = commentTextBlock - .calculateDimension(stringBounder); + final Dimension2D size = commentTextBlock.calculateDimension(stringBounder); sup = getMarginX1() + commentMargin + size.getWidth(); } @@ -101,15 +98,13 @@ public class ComponentRoseGroupingHeader extends AbstractTextualComponent { } @Override - protected void drawBackgroundInternalU(UGraphic ug, - Dimension2D dimensionToUse) { + protected void drawBackgroundInternalU(UGraphic ug, Dimension2D dimensionToUse) { if (this.background == null) { return; } ug.getParam().setColor(null); ug.getParam().setBackcolor(background); - ug.draw(0, 0, new URectangle(dimensionToUse.getWidth(), dimensionToUse - .getHeight())); + ug.draw(0, 0, new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight())); } @Override @@ -134,10 +129,10 @@ public class ComponentRoseGroupingHeader extends AbstractTextualComponent { ug.draw(0, 0, polygon); final double heightWithoutPadding = dimensionToUse.getHeight() - getPaddingY(); - + ug.draw(0, 0, new ULine(dimensionToUse.getWidth(), 0)); ug.draw(dimensionToUse.getWidth(), 0, new ULine(0, heightWithoutPadding)); - ug.draw(0, textHeight, new ULine(0, heightWithoutPadding-textHeight)); + ug.draw(0, textHeight, new ULine(0, heightWithoutPadding - textHeight)); ug.getParam().setStroke(new UStroke()); getTextBlock().drawU(ug, getMarginX1(), getMarginY()); diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseLine.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseLine.java index 35a76fd0e..0acc4b341 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseLine.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseLine.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5937 $ + * Revision $Revision: 6008 $ * */ package net.sourceforge.plantuml.skin.rose; @@ -45,15 +45,21 @@ import net.sourceforge.plantuml.ugraphic.UStroke; public class ComponentRoseLine extends AbstractComponent { private final Color color; + private final boolean continueLine; - public ComponentRoseLine(Color color) { + public ComponentRoseLine(Color color, boolean continueLine) { this.color = color; + this.continueLine = continueLine; } @Override protected void drawInternalU(UGraphic ug, Dimension2D dimensionToUse) { ug.getParam().setColor(color); - stroke(ug, 5, 5); + if (continueLine) { + ug.getParam().setStroke(new UStroke()); + } else { + stroke(ug, 5, 5); + } final int x = (int) (dimensionToUse.getWidth() / 2); ug.draw(x, 0, new ULine(0, dimensionToUse.getHeight())); ug.getParam().setStroke(new UStroke()); diff --git a/src/net/sourceforge/plantuml/skin/rose/Rose.java b/src/net/sourceforge/plantuml/skin/rose/Rose.java index 1d18cf4f2..9963fec48 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: 5943 $ + * Revision $Revision: 6008 $ * */ package net.sourceforge.plantuml.skin.rose; @@ -53,72 +53,72 @@ public class Rose implements Skin { private final Map defaultsColor = new EnumMap(ColorParam.class); public Rose() { - defaultsColor.put(ColorParam.background, new HtmlColor("white")); + defaultsColor.put(ColorParam.background, HtmlColor.getColorIfValid("white")); - defaultsColor.put(ColorParam.sequenceArrow, new HtmlColor("#A80036")); - defaultsColor.put(ColorParam.usecaseArrow, new HtmlColor("#A80036")); - defaultsColor.put(ColorParam.classArrow, new HtmlColor("#A80036")); - defaultsColor.put(ColorParam.objectArrow, new HtmlColor("#A80036")); - defaultsColor.put(ColorParam.activityArrow, new HtmlColor("#A80036")); - defaultsColor.put(ColorParam.componentArrow, new HtmlColor("#A80036")); - defaultsColor.put(ColorParam.stateArrow, new HtmlColor("#A80036")); + defaultsColor.put(ColorParam.sequenceArrow, HtmlColor.getColorIfValid("#A80036")); + defaultsColor.put(ColorParam.usecaseArrow, HtmlColor.getColorIfValid("#A80036")); + defaultsColor.put(ColorParam.classArrow, HtmlColor.getColorIfValid("#A80036")); + defaultsColor.put(ColorParam.objectArrow, HtmlColor.getColorIfValid("#A80036")); + defaultsColor.put(ColorParam.activityArrow, HtmlColor.getColorIfValid("#A80036")); + defaultsColor.put(ColorParam.componentArrow, HtmlColor.getColorIfValid("#A80036")); + defaultsColor.put(ColorParam.stateArrow, HtmlColor.getColorIfValid("#A80036")); - defaultsColor.put(ColorParam.sequenceLifeLineBackground, new HtmlColor("white")); - defaultsColor.put(ColorParam.sequenceLifeLineBorder, new HtmlColor("#A80036")); - defaultsColor.put(ColorParam.sequenceGroupBackground, new HtmlColor("#EEEEEE")); - defaultsColor.put(ColorParam.sequenceDividerBackground, new HtmlColor("#EEEEEE")); - defaultsColor.put(ColorParam.sequenceEngloberLine, new HtmlColor("#A80036")); - defaultsColor.put(ColorParam.sequenceEngloberBackground, new HtmlColor("#DDDDDD")); + defaultsColor.put(ColorParam.sequenceLifeLineBackground, HtmlColor.getColorIfValid("white")); + defaultsColor.put(ColorParam.sequenceLifeLineBorder, HtmlColor.getColorIfValid("#A80036")); + defaultsColor.put(ColorParam.sequenceGroupBackground, HtmlColor.getColorIfValid("#EEEEEE")); + defaultsColor.put(ColorParam.sequenceDividerBackground, HtmlColor.getColorIfValid("#EEEEEE")); + defaultsColor.put(ColorParam.sequenceEngloberLine, HtmlColor.getColorIfValid("#A80036")); + defaultsColor.put(ColorParam.sequenceEngloberBackground, HtmlColor.getColorIfValid("#DDDDDD")); - defaultsColor.put(ColorParam.noteBackground, new HtmlColor("#FBFB77")); - defaultsColor.put(ColorParam.noteBorder, new HtmlColor("#A80036")); + defaultsColor.put(ColorParam.noteBackground, HtmlColor.getColorIfValid("#FBFB77")); + defaultsColor.put(ColorParam.noteBorder, HtmlColor.getColorIfValid("#A80036")); - defaultsColor.put(ColorParam.activityBackground, new HtmlColor("#FEFECE")); - defaultsColor.put(ColorParam.activityBorder, new HtmlColor("#A80036")); - defaultsColor.put(ColorParam.activityStart, new HtmlColor("black")); - defaultsColor.put(ColorParam.activityEnd, new HtmlColor("black")); - defaultsColor.put(ColorParam.activityBar, new HtmlColor("black")); + defaultsColor.put(ColorParam.activityBackground, HtmlColor.getColorIfValid("#FEFECE")); + defaultsColor.put(ColorParam.activityBorder, HtmlColor.getColorIfValid("#A80036")); + defaultsColor.put(ColorParam.activityStart, HtmlColor.getColorIfValid("black")); + defaultsColor.put(ColorParam.activityEnd, HtmlColor.getColorIfValid("black")); + defaultsColor.put(ColorParam.activityBar, HtmlColor.getColorIfValid("black")); - defaultsColor.put(ColorParam.stateBackground, new HtmlColor("#FEFECE")); - defaultsColor.put(ColorParam.stateBorder, new HtmlColor("#A80036")); - defaultsColor.put(ColorParam.stateStart, new HtmlColor("black")); - defaultsColor.put(ColorParam.stateEnd, new HtmlColor("black")); + defaultsColor.put(ColorParam.stateBackground, HtmlColor.getColorIfValid("#FEFECE")); + defaultsColor.put(ColorParam.stateBorder, HtmlColor.getColorIfValid("#A80036")); + defaultsColor.put(ColorParam.stateStart, HtmlColor.getColorIfValid("black")); + defaultsColor.put(ColorParam.stateEnd, HtmlColor.getColorIfValid("black")); - defaultsColor.put(ColorParam.usecaseBackground, new HtmlColor("#FEFECE")); - defaultsColor.put(ColorParam.usecaseBorder, new HtmlColor("#A80036")); - defaultsColor.put(ColorParam.componentBackground, new HtmlColor("#FEFECE")); - defaultsColor.put(ColorParam.componentBorder, new HtmlColor("#A80036")); - defaultsColor.put(ColorParam.componentInterfaceBackground, new HtmlColor("#FEFECE")); - defaultsColor.put(ColorParam.componentInterfaceBorder, new HtmlColor("#A80036")); - defaultsColor.put(ColorParam.usecaseActorBackground, new HtmlColor("#FEFECE")); - defaultsColor.put(ColorParam.usecaseActorBorder, new HtmlColor("#A80036")); + defaultsColor.put(ColorParam.usecaseBackground, HtmlColor.getColorIfValid("#FEFECE")); + defaultsColor.put(ColorParam.usecaseBorder, HtmlColor.getColorIfValid("#A80036")); + defaultsColor.put(ColorParam.componentBackground, HtmlColor.getColorIfValid("#FEFECE")); + defaultsColor.put(ColorParam.componentBorder, HtmlColor.getColorIfValid("#A80036")); + defaultsColor.put(ColorParam.componentInterfaceBackground, HtmlColor.getColorIfValid("#FEFECE")); + defaultsColor.put(ColorParam.componentInterfaceBorder, HtmlColor.getColorIfValid("#A80036")); + defaultsColor.put(ColorParam.usecaseActorBackground, HtmlColor.getColorIfValid("#FEFECE")); + defaultsColor.put(ColorParam.usecaseActorBorder, HtmlColor.getColorIfValid("#A80036")); - defaultsColor.put(ColorParam.sequenceActorBackground, new HtmlColor("#FEFECE")); - defaultsColor.put(ColorParam.sequenceActorBorder, new HtmlColor("#A80036")); - defaultsColor.put(ColorParam.sequenceParticipantBackground, new HtmlColor("#FEFECE")); - defaultsColor.put(ColorParam.sequenceParticipantBorder, new HtmlColor("#A80036")); - defaultsColor.put(ColorParam.classBackground, new HtmlColor("#FEFECE")); - defaultsColor.put(ColorParam.classBorder, new HtmlColor("#A80036")); + defaultsColor.put(ColorParam.sequenceActorBackground, HtmlColor.getColorIfValid("#FEFECE")); + defaultsColor.put(ColorParam.sequenceActorBorder, HtmlColor.getColorIfValid("#A80036")); + defaultsColor.put(ColorParam.sequenceParticipantBackground, HtmlColor.getColorIfValid("#FEFECE")); + defaultsColor.put(ColorParam.sequenceParticipantBorder, HtmlColor.getColorIfValid("#A80036")); + defaultsColor.put(ColorParam.classBackground, HtmlColor.getColorIfValid("#FEFECE")); + defaultsColor.put(ColorParam.classBorder, HtmlColor.getColorIfValid("#A80036")); - defaultsColor.put(ColorParam.objectBackground, new HtmlColor("#FEFECE")); - defaultsColor.put(ColorParam.objectBorder, new HtmlColor("#A80036")); + defaultsColor.put(ColorParam.objectBackground, HtmlColor.getColorIfValid("#FEFECE")); + defaultsColor.put(ColorParam.objectBorder, HtmlColor.getColorIfValid("#A80036")); - defaultsColor.put(ColorParam.stereotypeCBackground, new HtmlColor("#ADD1B2")); - defaultsColor.put(ColorParam.stereotypeABackground, new HtmlColor("#A9DCDF")); - defaultsColor.put(ColorParam.stereotypeIBackground, new HtmlColor("#B4A7E5")); - defaultsColor.put(ColorParam.stereotypeEBackground, new HtmlColor("#EB937F")); + defaultsColor.put(ColorParam.stereotypeCBackground, HtmlColor.getColorIfValid("#ADD1B2")); + defaultsColor.put(ColorParam.stereotypeABackground, HtmlColor.getColorIfValid("#A9DCDF")); + defaultsColor.put(ColorParam.stereotypeIBackground, HtmlColor.getColorIfValid("#B4A7E5")); + defaultsColor.put(ColorParam.stereotypeEBackground, HtmlColor.getColorIfValid("#EB937F")); - defaultsColor.put(ColorParam.packageBackground, new HtmlColor("#FEFECE")); - defaultsColor.put(ColorParam.packageBorder, new HtmlColor("black")); + defaultsColor.put(ColorParam.packageBackground, HtmlColor.getColorIfValid("#FEFECE")); + defaultsColor.put(ColorParam.packageBorder, HtmlColor.getColorIfValid("black")); - defaultsColor.put(ColorParam.iconPrivate, new HtmlColor("#C82930")); - defaultsColor.put(ColorParam.iconPrivateBackground, new HtmlColor("#F24D5C")); - defaultsColor.put(ColorParam.iconProtected, new HtmlColor("#B38D22")); - defaultsColor.put(ColorParam.iconProtectedBackground, new HtmlColor("#FFFF44")); - defaultsColor.put(ColorParam.iconPackage, new HtmlColor("#1963A0")); - defaultsColor.put(ColorParam.iconPackageBackground, new HtmlColor("#4177AF")); - defaultsColor.put(ColorParam.iconPublic, new HtmlColor("#038048")); - defaultsColor.put(ColorParam.iconPublicBackground, new HtmlColor("#84BE84")); + defaultsColor.put(ColorParam.iconPrivate, HtmlColor.getColorIfValid("#C82930")); + defaultsColor.put(ColorParam.iconPrivateBackground, HtmlColor.getColorIfValid("#F24D5C")); + defaultsColor.put(ColorParam.iconProtected, HtmlColor.getColorIfValid("#B38D22")); + defaultsColor.put(ColorParam.iconProtectedBackground, HtmlColor.getColorIfValid("#FFFF44")); + defaultsColor.put(ColorParam.iconPackage, HtmlColor.getColorIfValid("#1963A0")); + defaultsColor.put(ColorParam.iconPackageBackground, HtmlColor.getColorIfValid("#4177AF")); + defaultsColor.put(ColorParam.iconPublic, HtmlColor.getColorIfValid("#038048")); + defaultsColor.put(ColorParam.iconPublicBackground, HtmlColor.getColorIfValid("#84BE84")); } public Color getFontColor(ISkinParam skin, FontParam fontParam) { @@ -178,7 +178,11 @@ public class Rose implements Skin { } if (type == ComponentType.PARTICIPANT_LINE) { final Color borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder).getColor(); - return new ComponentRoseLine(borderColor); + return new ComponentRoseLine(borderColor, false); + } + if (type == ComponentType.CONTINUE_LINE) { + final Color borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder).getColor(); + return new ComponentRoseLine(borderColor, true); } if (type == ComponentType.ACTOR_HEAD) { final Color borderColor = getHtmlColor(param, ColorParam.sequenceActorBorder).getColor(); @@ -190,10 +194,6 @@ public class Rose implements Skin { return new ComponentRoseActor(sequenceActorBackground, borderColor, getFontColor(param, FontParam.SEQUENCE_ACTOR), fontActor, stringsToDisplay, false); } - if (type == ComponentType.ACTOR_LINE) { - final Color borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder).getColor(); - return new ComponentRoseLine(borderColor); - } if (type == ComponentType.NOTE) { final Color noteBackgroundColor = getHtmlColor(param, ColorParam.noteBackground).getColor(); final Color borderColor = getHtmlColor(param, ColorParam.noteBorder).getColor(); @@ -221,8 +221,8 @@ public class Rose implements Skin { return new ComponentRoseActiveLine(borderColor, lifeLineBackgroundColor); } if (type == ComponentType.DELAY_LINE) { - // final Color borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder).getColor(); - final Color borderColor = getFontColor(param, FontParam.SEQUENCE_DELAY); + final Color borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder).getColor(); + // final Color borderColor = getFontColor(param, FontParam.SEQUENCE_DELAY); return new ComponentRoseDelayLine(borderColor); } if (type == ComponentType.DELAY_TEXT) { diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java b/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java index 93835e7f6..1fabb47cd 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5742 $ + * Revision $Revision: 5983 $ * */ package net.sourceforge.plantuml.statediagram.command; @@ -63,7 +63,7 @@ public class CommandCreatePackageState extends SingleLineCommand { p.setStereotype(stereotype); } if (arg.get(3) != null && HtmlColor.isValid(arg.get(3))) { - p.setBackColor(new HtmlColor(arg.get(3))); + p.setBackColor(HtmlColor.getColorIfValid(arg.get(3))); } return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState2.java b/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState2.java index ea1960ec8..b9ff893fd 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState2.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandCreatePackageState2.java @@ -61,7 +61,7 @@ public class CommandCreatePackageState2 extends SingleLineCommand p.setStereotype(stereotype); } if (arg.get(3) != null && HtmlColor.isValid(arg.get(3))) { - p.setBackColor(new HtmlColor(arg.get(3))); + p.setBackColor(HtmlColor.getColorIfValid(arg.get(3))); } return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/sudoku/GraphicsSudoku.java b/src/net/sourceforge/plantuml/sudoku/GraphicsSudoku.java index bf00aa43f..c8f3e39f3 100644 --- a/src/net/sourceforge/plantuml/sudoku/GraphicsSudoku.java +++ b/src/net/sourceforge/plantuml/sudoku/GraphicsSudoku.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5872 $ + * Revision $Revision: 6009 $ * */ package net.sourceforge.plantuml.sudoku; @@ -44,6 +44,7 @@ import java.util.Arrays; import java.util.List; import net.sourceforge.plantuml.EmptyImageBuilder; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; @@ -90,8 +91,8 @@ public class GraphicsSudoku { for (int y = 0; y < 9; y++) { final int num = sudoku.getGiven(x, y); if (num > 0) { - final TextBlock text = TextBlockUtils.create(Arrays.asList("" + num), numberFont, Color.BLACK, - HorizontalAlignement.CENTER); + final TextBlock text = TextBlockUtils.create(Arrays.asList("" + num), new FontConfiguration( + numberFont, Color.BLACK), HorizontalAlignement.CENTER); text.drawTOBEREMOVED(g2d, numberxOffset + x * cellWidth, numberyOffset + y * cellHeight); } } @@ -113,7 +114,8 @@ public class GraphicsSudoku { texts.add("http://plantuml.sourceforge.net"); texts.add("Seed " + Long.toString(sudoku.getSeed(), 36)); texts.add("Difficulty " + sudoku.getRatting()); - final TextBlock textBlock = TextBlockUtils.create(texts, font, Color.BLACK, HorizontalAlignement.LEFT); + final TextBlock textBlock = TextBlockUtils.create(texts, new FontConfiguration(font, Color.BLACK), + HorizontalAlignement.LEFT); textBlock.drawTOBEREMOVED(g2d, 0, 0); g2d.dispose(); diff --git a/src/net/sourceforge/plantuml/suggest/SuggestEngine.java b/src/net/sourceforge/plantuml/suggest/SuggestEngine.java index 6d82baa53..321749046 100644 --- a/src/net/sourceforge/plantuml/suggest/SuggestEngine.java +++ b/src/net/sourceforge/plantuml/suggest/SuggestEngine.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.suggest; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -49,13 +50,13 @@ import net.sourceforge.plantuml.command.ProtectedCommand; final public class SuggestEngine { - // private final UmlSource source; private final PSystemCommandFactory systemFactory; private final Iterator it; - private int nb = 0; + // private int nb = 0; + private String current = ""; + private String previous = ""; public SuggestEngine(UmlSource source, PSystemCommandFactory systemFactory) { - // this.source = source; this.systemFactory = systemFactory; this.it = source.iterator(); if (BlockUmlBuilder.isArobaseStartuml(next()) == false) { @@ -68,8 +69,10 @@ final public class SuggestEngine { } private String next() { - nb++; - return it.next(); + // nb++; + this.previous = this.current; + this.current = it.next(); + return current; } public SuggestEngineResult tryToSuggest() throws IOException { @@ -129,31 +132,46 @@ final public class SuggestEngine { } - SuggestEngineResult checkAndCorrect(String incorrectLine) { - CommandControl commandControl = systemFactory.isValid(Arrays.asList(incorrectLine)); + SuggestEngineResult checkAndCorrect(final String incorrectLine) { + final CommandControl commandControl = systemFactory.isValid(Arrays.asList(incorrectLine)); if (commandControl != CommandControl.NOT_OK) { return SuggestEngineResult.SYNTAX_OK; } - // Remove one - for (int i = 0; i < incorrectLine.length(); i++) { - final String newS = incorrectLine.substring(0, i) + incorrectLine.substring(i + 1); - commandControl = systemFactory.isValid(Arrays.asList(newS)); - if (commandControl != CommandControl.NOT_OK) { - return new SuggestEngineResult(newS, nb); - } + if (incorrectLine.trim().startsWith("{") + && systemFactory.isValid(Arrays.asList(previous + " {")) != CommandControl.NOT_OK) { + return new SuggestEngineResult(previous + " {"); } - // Inverse - for (int i = 0; i < incorrectLine.length() - 1; i++) { - final String newS = incorrectLine.substring(0, i) + incorrectLine.charAt(i + 1) + incorrectLine.charAt(i) - + incorrectLine.substring(i + 2); - commandControl = systemFactory.isValid(Arrays.asList(newS)); - if (commandControl != CommandControl.NOT_OK) { - return new SuggestEngineResult(newS, nb); + final Collection> all = new ArrayList>(); + all.add(new VariatorRemoveOneChar(incorrectLine)); + all.add(new VariatorSwapLetter(incorrectLine)); + // all.add(new VariatorAddOneCharBetweenWords(incorrectLine, ':')); + all.add(new VariatorAddOneCharBetweenWords(incorrectLine, '-')); + all.add(new VariatorAddOneCharBetweenWords(incorrectLine, ' ')); + // all.add(new VariatorAddTwoChar(incorrectLine, '\"')); + + for (Iterator it : all) { + final SuggestEngineResult result = tryThis(it); + if (result != null) { + return result; } } - return SuggestEngineResult.CANNOT_CORRECT; } + + private SuggestEngineResult tryThis(Iterator it) { + while (it.hasNext()) { + final String newS = it.next(); + if (newS.trim().length() == 0) { + continue; + } + final CommandControl commandControl = systemFactory.isValid(Arrays.asList(newS)); + if (commandControl != CommandControl.NOT_OK) { + return new SuggestEngineResult(newS); + } + } + return null; + + } } diff --git a/src/net/sourceforge/plantuml/suggest/SuggestEngineResult.java b/src/net/sourceforge/plantuml/suggest/SuggestEngineResult.java index 16f09a4fe..7b9d3ced8 100644 --- a/src/net/sourceforge/plantuml/suggest/SuggestEngineResult.java +++ b/src/net/sourceforge/plantuml/suggest/SuggestEngineResult.java @@ -33,11 +33,11 @@ */ package net.sourceforge.plantuml.suggest; + public class SuggestEngineResult { private final SuggestEngineStatus status; private final String suggestedLine; - private final int numLine; public static final SuggestEngineResult CANNOT_CORRECT = new SuggestEngineResult(SuggestEngineStatus.CANNOT_CORRECT); public static final SuggestEngineResult SYNTAX_OK = new SuggestEngineResult(SuggestEngineStatus.SYNTAX_OK); @@ -48,13 +48,40 @@ public class SuggestEngineResult { } this.status = status; this.suggestedLine = null; - this.numLine = -1; } - public SuggestEngineResult(String suggestedLine, int numLine) { + @Override + public String toString() { + return status + " " + suggestedLine; + } + + @Override + public int hashCode() { + return status.hashCode() + (suggestedLine == null ? 0 : suggestedLine.hashCode()); + } + + @Override + public boolean equals(Object obj) { + final SuggestEngineResult this2 = (SuggestEngineResult) obj; + return status.equals(this2.status) && sameString(suggestedLine, this2.suggestedLine); + } + + private static boolean sameString(String a, String b) { + if (a == null && b == null) { + return true; + } + if (a != null || b != null) { + return false; + } + return a.equals(b); + } + + public SuggestEngineResult(String suggestedLine) { + if (suggestedLine.trim().length() == 0) { + throw new IllegalArgumentException(); + } this.status = SuggestEngineStatus.ONE_SUGGESTION; this.suggestedLine = suggestedLine; - this.numLine = numLine; } public final SuggestEngineStatus getStatus() { @@ -65,8 +92,4 @@ public class SuggestEngineResult { return suggestedLine; } - public final int getNumLine() { - return numLine; - } - } diff --git a/src/net/sourceforge/plantuml/suggest/Variator.java b/src/net/sourceforge/plantuml/suggest/Variator.java new file mode 100644 index 000000000..56a577989 --- /dev/null +++ b/src/net/sourceforge/plantuml/suggest/Variator.java @@ -0,0 +1,41 @@ +/* ======================================================================== + * 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: 4975 $ + * + */ +package net.sourceforge.plantuml.suggest; + +public interface Variator { + + String getData(); + void nextStep(); + +} diff --git a/src/net/sourceforge/plantuml/suggest/VariatorAddOneChar.java b/src/net/sourceforge/plantuml/suggest/VariatorAddOneChar.java new file mode 100644 index 000000000..de16b665e --- /dev/null +++ b/src/net/sourceforge/plantuml/suggest/VariatorAddOneChar.java @@ -0,0 +1,62 @@ +/* ======================================================================== + * 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: 4975 $ + * + */ +package net.sourceforge.plantuml.suggest; + +public class VariatorAddOneChar extends VariatorIteratorAdaptor { + + private final String data; + private final char toAdd; + private int i; + + public VariatorAddOneChar(String data, char toAdd) { + this.data = data; + this.toAdd = toAdd; + } + + @Override + Variator getVariator() { + return new Variator() { + public String getData() { + if (i > data.length()) { + return null; + } + return data.substring(0, i) + toAdd + data.substring(i); + } + + public void nextStep() { + i++; + } + }; + } +} diff --git a/src/net/sourceforge/plantuml/suggest/VariatorAddOneCharBetweenWords.java b/src/net/sourceforge/plantuml/suggest/VariatorAddOneCharBetweenWords.java new file mode 100644 index 000000000..3516bd09c --- /dev/null +++ b/src/net/sourceforge/plantuml/suggest/VariatorAddOneCharBetweenWords.java @@ -0,0 +1,76 @@ +/* ======================================================================== + * 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: 4975 $ + * + */ +package net.sourceforge.plantuml.suggest; + +public class VariatorAddOneCharBetweenWords extends VariatorIteratorAdaptor { + + private final String data; + private final char toAdd; + private int i; + + public VariatorAddOneCharBetweenWords(String data, char toAdd) { + this.data = data; + this.toAdd = toAdd; + i++; + ensureBetweenWords(); + } + + private void ensureBetweenWords() { + while (i < data.length() && inWord()) { + i++; + } + + } + + private boolean inWord() { + return Character.isLetterOrDigit(data.charAt(i - 1)) && Character.isLetterOrDigit(data.charAt(i)); + } + + @Override + Variator getVariator() { + return new Variator() { + public String getData() { + if (i > data.length() - 1) { + return null; + } + return data.substring(0, i) + toAdd + data.substring(i); + } + + public void nextStep() { + i++; + ensureBetweenWords(); + } + }; + } +} diff --git a/src/net/sourceforge/plantuml/suggest/VariatorAddTwoChar.java b/src/net/sourceforge/plantuml/suggest/VariatorAddTwoChar.java new file mode 100644 index 000000000..8f1e4540b --- /dev/null +++ b/src/net/sourceforge/plantuml/suggest/VariatorAddTwoChar.java @@ -0,0 +1,67 @@ +/* ======================================================================== + * 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: 4975 $ + * + */ +package net.sourceforge.plantuml.suggest; + +public class VariatorAddTwoChar extends VariatorIteratorAdaptor { + + private final String data; + private final char toAdd; + private int i; + private int j = 1; + + public VariatorAddTwoChar(String data, char toAdd) { + this.data = data; + this.toAdd = toAdd; + } + + @Override + Variator getVariator() { + return new Variator() { + public String getData() { + if (i >= data.length()) { + return null; + } + return data.substring(0, i) + toAdd + data.substring(i, j) + toAdd + data.substring(j); + } + + public void nextStep() { + j++; + if (j > data.length()) { + i++; + j = i + 1; + } + } + }; + } +} diff --git a/src/net/sourceforge/plantuml/suggest/VariatorIteratorAdaptor.java b/src/net/sourceforge/plantuml/suggest/VariatorIteratorAdaptor.java new file mode 100644 index 000000000..a8c23a375 --- /dev/null +++ b/src/net/sourceforge/plantuml/suggest/VariatorIteratorAdaptor.java @@ -0,0 +1,66 @@ +/* ======================================================================== + * 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: 4975 $ + * + */ +package net.sourceforge.plantuml.suggest; + +import java.util.Iterator; +import java.util.NoSuchElementException; + +public abstract class VariatorIteratorAdaptor implements Iterator { + + private final Variator variator; + + abstract Variator getVariator(); + + public VariatorIteratorAdaptor() { + this.variator = getVariator(); + } + + public boolean hasNext() { + return variator.getData() != null; + } + + public String next() { + final String result = variator.getData(); + if (result == null) { + throw new NoSuchElementException(); + } + this.variator.nextStep(); + return result; + } + + public void remove() { + throw new UnsupportedOperationException(); + } + +} diff --git a/src/net/sourceforge/plantuml/suggest/VariatorRemoveOneChar.java b/src/net/sourceforge/plantuml/suggest/VariatorRemoveOneChar.java new file mode 100644 index 000000000..d88d91ab8 --- /dev/null +++ b/src/net/sourceforge/plantuml/suggest/VariatorRemoveOneChar.java @@ -0,0 +1,60 @@ +/* ======================================================================== + * 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: 4975 $ + * + */ +package net.sourceforge.plantuml.suggest; + +public class VariatorRemoveOneChar extends VariatorIteratorAdaptor { + + private final String data; + private int i; + + public VariatorRemoveOneChar(String data) { + this.data = data; + } + + @Override + Variator getVariator() { + return new Variator() { + public String getData() { + if (i >= data.length()) { + return null; + } + return data.substring(0, i) + data.substring(i + 1); + } + + public void nextStep() { + i++; + } + }; + } +} diff --git a/src/net/sourceforge/plantuml/suggest/VariatorSwapChar.java b/src/net/sourceforge/plantuml/suggest/VariatorSwapChar.java new file mode 100644 index 000000000..a8fa4ddca --- /dev/null +++ b/src/net/sourceforge/plantuml/suggest/VariatorSwapChar.java @@ -0,0 +1,60 @@ +/* ======================================================================== + * 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: 4975 $ + * + */ +package net.sourceforge.plantuml.suggest; + +public class VariatorSwapChar extends VariatorIteratorAdaptor { + + private final String data; + private int i; + + public VariatorSwapChar(String data) { + this.data = data; + } + + @Override + Variator getVariator() { + return new Variator() { + public String getData() { + if (i >= data.length() - 1) { + return null; + } + return data.substring(0, i) + data.charAt(i + 1) + data.charAt(i) + data.substring(i + 2); + } + + public void nextStep() { + i++; + } + }; + } +} diff --git a/src/net/sourceforge/plantuml/suggest/VariatorSwapLetter.java b/src/net/sourceforge/plantuml/suggest/VariatorSwapLetter.java new file mode 100644 index 000000000..9777dc683 --- /dev/null +++ b/src/net/sourceforge/plantuml/suggest/VariatorSwapLetter.java @@ -0,0 +1,74 @@ +/* ======================================================================== + * 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: 4975 $ + * + */ +package net.sourceforge.plantuml.suggest; + +public class VariatorSwapLetter extends VariatorIteratorAdaptor { + + private final String data; + private int i; + + public VariatorSwapLetter(String data) { + this.data = data; + ensureTwoLetters(); + } + + private void ensureTwoLetters() { + while (i < data.length() - 1 && areTwoLetters() == false) { + i++; + } + + } + + private boolean areTwoLetters() { + return Character.isLetter(data.charAt(i)) && Character.isLetter(data.charAt(i + 1)); + + } + + @Override + Variator getVariator() { + return new Variator() { + public String getData() { + if (i >= data.length() - 1) { + return null; + } + return data.substring(0, i) + data.charAt(i + 1) + data.charAt(i) + data.substring(i + 2); + } + + public void nextStep() { + i++; + ensureTwoLetters(); + } + }; + } +} diff --git a/src/net/sourceforge/plantuml/svg/SvgTitler.java b/src/net/sourceforge/plantuml/svg/SvgTitler.java index 0ef78a7c9..fc4316625 100644 --- a/src/net/sourceforge/plantuml/svg/SvgTitler.java +++ b/src/net/sourceforge/plantuml/svg/SvgTitler.java @@ -42,6 +42,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramFileMaker; +import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignement; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockUtils; @@ -72,7 +73,8 @@ public final class SvgTitler { textBloc = null; } else { final Font normalFont = new Font(fontFamily, Font.PLAIN, fontSize); - textBloc = TextBlockUtils.create(text, normalFont, textColor, HorizontalAlignement.LEFT); + textBloc = TextBlockUtils.create(text, new FontConfiguration(normalFont, textColor), + HorizontalAlignement.LEFT); } } diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphic.java b/src/net/sourceforge/plantuml/ugraphic/UGraphic.java index 300677158..25a0c5289 100644 --- a/src/net/sourceforge/plantuml/ugraphic/UGraphic.java +++ b/src/net/sourceforge/plantuml/ugraphic/UGraphic.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 4129 $ + * Revision $Revision: 5988 $ * */ package net.sourceforge.plantuml.ugraphic; @@ -44,9 +44,11 @@ public interface UGraphic { public UParam getParam(); public void draw(double x, double y, UShape shape); + public void centerChar(double x, double y, char c, Font font); public void translate(double dx, double dy); + public void setTranslate(double dx, double dy); public double getTranslateX(); @@ -55,4 +57,6 @@ public interface UGraphic { public void setClip(UClip clip); + public void setAntiAliasing(boolean trueForOn); + } diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphicUtils.java b/src/net/sourceforge/plantuml/ugraphic/UGraphicUtils.java index 69375e0f4..ca62cfd7b 100644 --- a/src/net/sourceforge/plantuml/ugraphic/UGraphicUtils.java +++ b/src/net/sourceforge/plantuml/ugraphic/UGraphicUtils.java @@ -77,6 +77,10 @@ public abstract class UGraphicUtils { public void translate(double dx, double dy) { g.translate(dx, dy); } + + public void setAntiAliasing(boolean trueForOn) { + g.setAntiAliasing(trueForOn); + } }; } diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/UGraphicEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/UGraphicEps.java index 6684c3dbd..281a8a571 100644 --- a/src/net/sourceforge/plantuml/ugraphic/eps/UGraphicEps.java +++ b/src/net/sourceforge/plantuml/ugraphic/eps/UGraphicEps.java @@ -127,4 +127,7 @@ public class UGraphicEps extends AbstractUGraphic implements ClipCo pw.close(); } + public void setAntiAliasing(boolean trueForOn) { + } + } diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java index d51c89885..e6e4b5dfe 100644 --- a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java +++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5735 $ + * Revision $Revision: 6000 $ * */ package net.sourceforge.plantuml.ugraphic.g2d; @@ -40,6 +40,7 @@ import java.awt.FontMetrics; import java.awt.Graphics2D; import java.awt.GraphicsEnvironment; import java.awt.geom.Dimension2D; +import java.awt.geom.Rectangle2D; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Log; @@ -54,9 +55,9 @@ import net.sourceforge.plantuml.ugraphic.UText; public class DriverTextG2d implements UDriver { -// static { -// printFont(); -// } + // static { + // printFont(); + // } private static void printFont() { final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); @@ -70,7 +71,18 @@ public class DriverTextG2d implements UDriver { public void draw(UShape ushape, double x, double y, UParam param, Graphics2D g2d) { final UText shape = (UText) ushape; final FontConfiguration fontConfiguration = shape.getFontConfiguration(); + final Font font = fontConfiguration.getFont(); + if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) { + final Dimension2D dim = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText()); + final Color extended = fontConfiguration.getExtendedColor(); + if (extended != null) { + g2d.setColor(extended); + g2d.setBackground(extended); + g2d.fill(new Rectangle2D.Double(x, y - dim.getHeight() + 1.5, dim.getWidth(), dim.getHeight())); + } + } + g2d.setFont(font); g2d.setColor(fontConfiguration.getColor()); g2d.drawString(shape.getText(), (float) x, (float) y); diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/UGraphicG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/UGraphicG2d.java index 5952942b8..c1674f722 100644 --- a/src/net/sourceforge/plantuml/ugraphic/g2d/UGraphicG2d.java +++ b/src/net/sourceforge/plantuml/ugraphic/g2d/UGraphicG2d.java @@ -28,13 +28,14 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 5793 $ + * Revision $Revision: 5988 $ * */ package net.sourceforge.plantuml.ugraphic.g2d; import java.awt.Font; import java.awt.Graphics2D; +import java.awt.RenderingHints; import java.awt.Shape; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; @@ -122,4 +123,13 @@ public class UGraphicG2d extends AbstractUGraphic { return dpiFactor; } + public void setAntiAliasing(boolean trueForOn) { + if (trueForOn) { + getGraphicObject().setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + } else { + getGraphicObject().setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); + } + + } + } diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/UGraphicSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/UGraphicSvg.java index 35afcf9ce..158699aed 100644 --- a/src/net/sourceforge/plantuml/ugraphic/svg/UGraphicSvg.java +++ b/src/net/sourceforge/plantuml/ugraphic/svg/UGraphicSvg.java @@ -130,5 +130,9 @@ public class UGraphicSvg extends AbstractUGraphic implements ClipCo DriverTextAsPathSvg.drawPathIterator(getGraphicObject(), xpos + getTranslateX(), ypos + getTranslateY(), t .getOutline(null).getPathIterator(null)); } + + public void setAntiAliasing(boolean trueForOn) { + } + } diff --git a/src/net/sourceforge/plantuml/ugraphic/txt/UGraphicTxt.java b/src/net/sourceforge/plantuml/ugraphic/txt/UGraphicTxt.java index 0d93a01e1..40b5e3284 100644 --- a/src/net/sourceforge/plantuml/ugraphic/txt/UGraphicTxt.java +++ b/src/net/sourceforge/plantuml/ugraphic/txt/UGraphicTxt.java @@ -79,4 +79,7 @@ public class UGraphicTxt extends AbstractCommonUGraphic { return new TranslatedCharArea(charArea, (int) getTranslateX(), (int) getTranslateY()); } + public void setAntiAliasing(boolean trueForOn) { + } + } diff --git a/src/net/sourceforge/plantuml/version/PSystemVersion.java b/src/net/sourceforge/plantuml/version/PSystemVersion.java index df18fd728..5a391cbe6 100644 --- a/src/net/sourceforge/plantuml/version/PSystemVersion.java +++ b/src/net/sourceforge/plantuml/version/PSystemVersion.java @@ -49,7 +49,7 @@ import javax.imageio.ImageIO; import net.sourceforge.plantuml.AbstractPSystem; import net.sourceforge.plantuml.FileFormatOption; -import net.sourceforge.plantuml.OptionPrint; +import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils; import net.sourceforge.plantuml.graphic.GraphicPosition; import net.sourceforge.plantuml.graphic.GraphicStrings; @@ -69,7 +69,8 @@ public class PSystemVersion extends AbstractPSystem { } } - public List createFiles(File suggestedFile, FileFormatOption fileFormat) throws IOException, InterruptedException { + public List createFiles(File suggestedFile, FileFormatOption fileFormat) throws IOException, + InterruptedException { OutputStream os = null; try { os = new FileOutputStream(suggestedFile); @@ -91,7 +92,7 @@ public class PSystemVersion extends AbstractPSystem { strings.add("PlantUML version " + Version.version() + " (" + new Date(Version.compileTime()) + ")"); strings.add(" "); - strings.addAll(OptionPrint.getTestDotStrings()); + strings.addAll(GraphvizUtils.getTestDotStrings(true)); strings.add(" "); final Properties p = System.getProperties(); strings.add(p.getProperty("java.runtime.name")); @@ -119,7 +120,7 @@ public class PSystemVersion extends AbstractPSystem { public static PSystemVersion createTestDot() throws IOException { final List strings = new ArrayList(); - strings.addAll(OptionPrint.getTestDotStrings()); + strings.addAll(GraphvizUtils.getTestDotStrings(true)); return new PSystemVersion(false, strings); } diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index a01416c68..f9277db7f 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: 5975 $ + * Revision $Revision: 6036 $ * */ package net.sourceforge.plantuml.version; @@ -36,11 +36,11 @@ package net.sourceforge.plantuml.version; public class Version { public static int version() { - return 5974; + return 6035; } public static long compileTime() { - return 1294953848234L; + return 1295780772390L; } }