diff --git a/src/net/sourceforge/plantuml/AbstractPSystem.java b/src/net/sourceforge/plantuml/AbstractPSystem.java index 6da961e29..879a833e8 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: 18280 $ + * Revision $Revision: 18790 $ * */ package net.sourceforge.plantuml; @@ -43,6 +43,9 @@ import net.sourceforge.plantuml.command.ProtectedCommand; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.version.License; import net.sourceforge.plantuml.version.Version; @@ -87,11 +90,11 @@ public abstract class AbstractPSystem implements Diagram { return 1; } - public Display getTitle() { + public DisplayPositionned getTitle() { if (source == null) { - return Display.empty(); + return new DisplayPositionned(Display.empty(), HorizontalAlignment.CENTER, VerticalAlignment.TOP); } - return source.getTitle(); + return new DisplayPositionned(source.getTitle(), HorizontalAlignment.CENTER, VerticalAlignment.TOP); } public String getWarningOrError() { @@ -109,7 +112,7 @@ public abstract class AbstractPSystem implements Diagram { cmd = new ProtectedCommand(cmd); return cmd.execute(this, lines); } - + public boolean hasUrl() { return false; } diff --git a/src/net/sourceforge/plantuml/Annotated.java b/src/net/sourceforge/plantuml/Annotated.java new file mode 100644 index 000000000..f75822238 --- /dev/null +++ b/src/net/sourceforge/plantuml/Annotated.java @@ -0,0 +1,50 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, 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 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: 18790 $ + * + */ +package net.sourceforge.plantuml; + +import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; + +public interface Annotated { + + public DisplayPositionned getTitle(); + + public DisplayPositionned getCaption(); + + public DisplayPositionned getLegend(); + + public DisplayPositionned getHeader(); + + public DisplayPositionned getFooter(); + +} diff --git a/src/net/sourceforge/plantuml/AnnotatedWorker.java b/src/net/sourceforge/plantuml/AnnotatedWorker.java new file mode 100644 index 000000000..ca35ebabe --- /dev/null +++ b/src/net/sourceforge/plantuml/AnnotatedWorker.java @@ -0,0 +1,134 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, 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 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: 18790 $ + * + */ +package net.sourceforge.plantuml; + +import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; +import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.svek.DecorateEntityImage; +import net.sourceforge.plantuml.svek.TextBlockBackcolored; + +public class AnnotatedWorker { + + private final Annotated annotated; + private final ISkinParam skinParam; + + public AnnotatedWorker(Annotated annotated, ISkinParam skinParam) { + this.annotated = annotated; + this.skinParam = skinParam; + + } + + public TextBlockBackcolored addAdd(TextBlock result) { + result = addLegend(result); + result = addTitle(result); + result = addCaption(result); + result = addHeaderAndFooter(result); + return (TextBlockBackcolored) result; + } + + private TextBlock addLegend(TextBlock original) { + if (DisplayPositionned.isNull(annotated.getLegend())) { + return original; + } + final TextBlock text = EntityImageLegend.create(annotated.getLegend().getDisplay(), getSkinParam()); + + return DecorateEntityImage.add(original, text, annotated.getLegend().getHorizontalAlignment(), annotated + .getLegend().getVerticalAlignment()); + } + + private ISkinParam getSkinParam() { + return skinParam; + } + + private TextBlock addCaption(TextBlock original) { + if (DisplayPositionned.isNull(annotated.getCaption())) { + return original; + } + final TextBlock text = getCaption(); + + return DecorateEntityImage.addBottom(original, text, HorizontalAlignment.CENTER); + } + + public TextBlock getCaption() { + if (DisplayPositionned.isNull(annotated.getCaption())) { + return TextBlockUtils.empty(0, 0); + } + return annotated + .getCaption() + .getDisplay() + .create(new FontConfiguration(getSkinParam(), FontParam.CAPTION, null), HorizontalAlignment.CENTER, + getSkinParam()); + } + + private TextBlock addTitle(TextBlock original) { + if (DisplayPositionned.isNull(annotated.getTitle())) { + return original; + } + final TextBlock text = annotated + .getTitle() + .getDisplay() + .create(new FontConfiguration(getSkinParam(), FontParam.TITLE, null), HorizontalAlignment.CENTER, + getSkinParam()); + + return DecorateEntityImage.addTop(original, text, HorizontalAlignment.CENTER); + // return new DecorateTextBlock(original, text, HorizontalAlignment.CENTER); + } + + private TextBlock addHeaderAndFooter(TextBlock original) { + if (DisplayPositionned.isNull(annotated.getFooter()) && DisplayPositionned.isNull(annotated.getHeader())) { + return original; + } + final TextBlock textFooter = DisplayPositionned.isNull(annotated.getFooter()) ? null : annotated + .getFooter() + .getDisplay() + .create(new FontConfiguration(getSkinParam(), FontParam.FOOTER, null), + annotated.getFooter().getHorizontalAlignment(), getSkinParam()); + final TextBlock textHeader = DisplayPositionned.isNull(annotated.getHeader()) ? null : annotated + .getHeader() + .getDisplay() + .create(new FontConfiguration(getSkinParam(), FontParam.HEADER, null), + annotated.getHeader().getHorizontalAlignment(), getSkinParam()); + + // return new DecorateTextBlock(original, textHeader, annotated.getHeader().getHorizontalAlignment(), + // textFooter, + // annotated.getFooter().getHorizontalAlignment()); + return new DecorateEntityImage(original, textHeader, annotated.getHeader().getHorizontalAlignment(), + textFooter, annotated.getFooter().getHorizontalAlignment()); + } + +} diff --git a/src/net/sourceforge/plantuml/FontParam.java b/src/net/sourceforge/plantuml/FontParam.java index 13382f1ea..21953726d 100644 --- a/src/net/sourceforge/plantuml/FontParam.java +++ b/src/net/sourceforge/plantuml/FontParam.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18802 $ * */ package net.sourceforge.plantuml; @@ -88,6 +88,7 @@ public enum FontParam { STATE_ATTRIBUTE(12, Font.PLAIN), // LEGEND(14, Font.PLAIN), // TITLE(18, Font.PLAIN), // + CAPTION(14, Font.PLAIN), // SWIMLANE_TITLE(18, Font.PLAIN), // FOOTER(10, Font.PLAIN, "#888888", FontParamConstant.FAMILY), // HEADER(10, Font.PLAIN, "#888888", FontParamConstant.FAMILY), // diff --git a/src/net/sourceforge/plantuml/ISkinParam.java b/src/net/sourceforge/plantuml/ISkinParam.java index 61b1712a7..5d53e1924 100644 --- a/src/net/sourceforge/plantuml/ISkinParam.java +++ b/src/net/sourceforge/plantuml/ISkinParam.java @@ -118,8 +118,6 @@ public interface ISkinParam extends ISkinSimple { public boolean useOctagonForActivity(Stereotype stereotype); - public IHtmlColorSet getIHtmlColorSet(); - public int groupInheritance(); public boolean useGuillemet(); diff --git a/src/net/sourceforge/plantuml/ISkinSimple.java b/src/net/sourceforge/plantuml/ISkinSimple.java index 7566bbee8..e1d6d7c24 100644 --- a/src/net/sourceforge/plantuml/ISkinSimple.java +++ b/src/net/sourceforge/plantuml/ISkinSimple.java @@ -33,6 +33,8 @@ */ package net.sourceforge.plantuml; +import net.sourceforge.plantuml.graphic.IHtmlColorSet; + public interface ISkinSimple extends SpriteContainer { public String getValue(String key); @@ -42,5 +44,7 @@ public interface ISkinSimple extends SpriteContainer { public String getMonospacedFamily(); public int getTabSize(); + + public IHtmlColorSet getIHtmlColorSet(); } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/NewpagedDiagram.java b/src/net/sourceforge/plantuml/NewpagedDiagram.java index b032a3cc2..12a12f51f 100644 --- a/src/net/sourceforge/plantuml/NewpagedDiagram.java +++ b/src/net/sourceforge/plantuml/NewpagedDiagram.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import net.sourceforge.plantuml.command.BlocLines; @@ -136,4 +137,8 @@ public class NewpagedDiagram extends AbstractPSystem { } } + public final List getDiagrams() { + return Collections.unmodifiableList(diagrams); + } + } diff --git a/src/net/sourceforge/plantuml/PSystemBuilder.java b/src/net/sourceforge/plantuml/PSystemBuilder.java index 735bbee0e..013d3a755 100644 --- a/src/net/sourceforge/plantuml/PSystemBuilder.java +++ b/src/net/sourceforge/plantuml/PSystemBuilder.java @@ -75,6 +75,7 @@ import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory; import net.sourceforge.plantuml.statediagram.StateDiagramFactory; import net.sourceforge.plantuml.sudoku.PSystemSudokuFactory; import net.sourceforge.plantuml.turing.PSystemTuringFactory; +import net.sourceforge.plantuml.ugraphic.sprite.PSystemListInternalSpritesFactory; import net.sourceforge.plantuml.version.License; import net.sourceforge.plantuml.version.PSystemLicenseFactory; import net.sourceforge.plantuml.version.PSystemVersionFactory; @@ -129,6 +130,7 @@ public class PSystemBuilder { factories.add(new PSystemListFontsFactory()); factories.add(new PSystemOpenIconicFactory()); factories.add(new PSystemListOpenIconicFactory()); + factories.add(new PSystemListInternalSpritesFactory()); factories.add(new PSystemSaltFactory(DiagramType.SALT)); factories.add(new PSystemSaltFactory(DiagramType.UML)); factories.add(new PSystemDotFactory(DiagramType.DOT)); diff --git a/src/net/sourceforge/plantuml/PSystemError.java b/src/net/sourceforge/plantuml/PSystemError.java index 1c491ccd3..01c8e798c 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: 18280 $ + * Revision $Revision: 18790 $ */ package net.sourceforge.plantuml; @@ -323,7 +323,7 @@ public class PSystemError extends AbstractPSystem { final StringBuilder sb = new StringBuilder(); sb.append(getDescription()); sb.append('\n'); - for (CharSequence t : getTitle()) { + for (CharSequence t : getTitle().getDisplay()) { sb.append(t); sb.append('\n'); } diff --git a/src/net/sourceforge/plantuml/Run.java b/src/net/sourceforge/plantuml/Run.java index a349686b7..4328940f7 100644 --- a/src/net/sourceforge/plantuml/Run.java +++ b/src/net/sourceforge/plantuml/Run.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18309 $ * */ package net.sourceforge.plantuml; @@ -64,8 +64,8 @@ import net.sourceforge.plantuml.preproc.Defines; import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory; import net.sourceforge.plantuml.statediagram.StateDiagramFactory; import net.sourceforge.plantuml.swing.MainWindow2; -import net.sourceforge.plantuml.ugraphic.SpriteGrayLevel; -import net.sourceforge.plantuml.ugraphic.SpriteUtils; +import net.sourceforge.plantuml.ugraphic.sprite.SpriteGrayLevel; +import net.sourceforge.plantuml.ugraphic.sprite.SpriteUtils; import net.sourceforge.plantuml.version.Version; public class Run { diff --git a/src/net/sourceforge/plantuml/SkinParam.java b/src/net/sourceforge/plantuml/SkinParam.java index e63ec8ec8..b88045f92 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: 18291 $ + * Revision $Revision: 18309 $ * */ package net.sourceforge.plantuml; @@ -62,10 +62,10 @@ import net.sourceforge.plantuml.svek.PackageStyle; import net.sourceforge.plantuml.ugraphic.ColorMapper; import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; import net.sourceforge.plantuml.ugraphic.ColorMapperMonochrome; -import net.sourceforge.plantuml.ugraphic.Sprite; -import net.sourceforge.plantuml.ugraphic.SpriteImage; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UStroke; +import net.sourceforge.plantuml.ugraphic.sprite.Sprite; +import net.sourceforge.plantuml.ugraphic.sprite.SpriteImage; public class SkinParam implements ISkinParam { diff --git a/src/net/sourceforge/plantuml/SkinParamDelegator.java b/src/net/sourceforge/plantuml/SkinParamDelegator.java index 5767c5ea1..c8330639c 100644 --- a/src/net/sourceforge/plantuml/SkinParamDelegator.java +++ b/src/net/sourceforge/plantuml/SkinParamDelegator.java @@ -45,9 +45,9 @@ import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.svek.ConditionStyle; import net.sourceforge.plantuml.svek.PackageStyle; import net.sourceforge.plantuml.ugraphic.ColorMapper; -import net.sourceforge.plantuml.ugraphic.Sprite; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UStroke; +import net.sourceforge.plantuml.ugraphic.sprite.Sprite; public class SkinParamDelegator implements ISkinParam { diff --git a/src/net/sourceforge/plantuml/SpriteContainer.java b/src/net/sourceforge/plantuml/SpriteContainer.java index 1bd5c2160..07b5945e5 100644 --- a/src/net/sourceforge/plantuml/SpriteContainer.java +++ b/src/net/sourceforge/plantuml/SpriteContainer.java @@ -33,7 +33,7 @@ */ package net.sourceforge.plantuml; -import net.sourceforge.plantuml.ugraphic.Sprite; +import net.sourceforge.plantuml.ugraphic.sprite.Sprite; public interface SpriteContainer { diff --git a/src/net/sourceforge/plantuml/SpriteContainerEmpty.java b/src/net/sourceforge/plantuml/SpriteContainerEmpty.java index 25f560e58..b05ff22b9 100644 --- a/src/net/sourceforge/plantuml/SpriteContainerEmpty.java +++ b/src/net/sourceforge/plantuml/SpriteContainerEmpty.java @@ -34,12 +34,15 @@ package net.sourceforge.plantuml; import net.sourceforge.plantuml.creole.CommandCreoleMonospaced; -import net.sourceforge.plantuml.ugraphic.Sprite; +import net.sourceforge.plantuml.graphic.HtmlColorSetSimple; +import net.sourceforge.plantuml.graphic.IHtmlColorSet; +import net.sourceforge.plantuml.ugraphic.sprite.Sprite; +import net.sourceforge.plantuml.ugraphic.sprite.SpriteImage; public class SpriteContainerEmpty implements SpriteContainer, ISkinSimple { public Sprite getSprite(String name) { - return null; + return SpriteImage.fromInternal(name); } public String getValue(String key) { @@ -62,4 +65,8 @@ public class SpriteContainerEmpty implements SpriteContainer, ISkinSimple { return 8; } + public IHtmlColorSet getIHtmlColorSet() { + return new HtmlColorSetSimple(); + } + } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/UmlDiagram.java b/src/net/sourceforge/plantuml/UmlDiagram.java index b42e23649..146d67100 100644 --- a/src/net/sourceforge/plantuml/UmlDiagram.java +++ b/src/net/sourceforge/plantuml/UmlDiagram.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18801 $ * */ package net.sourceforge.plantuml; @@ -59,7 +59,7 @@ import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.UmlSource; -import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; import net.sourceforge.plantuml.cucadiagram.UnparsableGraphvizException; import net.sourceforge.plantuml.flashcode.FlashCodeFactory; import net.sourceforge.plantuml.flashcode.FlashCodeUtils; @@ -77,41 +77,47 @@ import net.sourceforge.plantuml.svek.EmptySvgException; import net.sourceforge.plantuml.svek.GraphvizCrash; import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; import net.sourceforge.plantuml.ugraphic.ImageBuilder; -import net.sourceforge.plantuml.ugraphic.Sprite; import net.sourceforge.plantuml.ugraphic.UAntiAliasing; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UImage; import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.ugraphic.sprite.Sprite; import net.sourceforge.plantuml.version.Version; -public abstract class UmlDiagram extends AbstractPSystem implements Diagram { +public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Annotated { private boolean rotation; private boolean hideUnlinkedData; private int minwidth = Integer.MAX_VALUE; - private Display title = Display.NULL; - private Display header = Display.NULL; - private Display footer = Display.NULL; - private Display legend = Display.NULL; - private HorizontalAlignment legendAlignment = HorizontalAlignment.CENTER; - private VerticalAlignment legendVerticalAlignment = VerticalAlignment.BOTTOM; + private DisplayPositionned title = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.TOP); + private DisplayPositionned caption = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM); + private DisplayPositionned header = DisplayPositionned.none(HorizontalAlignment.RIGHT, VerticalAlignment.TOP); + private DisplayPositionned footer = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM); + private DisplayPositionned legend = DisplayPositionned.none(HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM); - private HorizontalAlignment headerAlignment = HorizontalAlignment.RIGHT; - private HorizontalAlignment footerAlignment = HorizontalAlignment.CENTER; private final Pragma pragma = new Pragma(); private Scale scale; private Animation animation; private final SkinParam skinParam = new SkinParam(); - final public void setTitle(Display strings) { - this.title = strings; + final public void setTitle(DisplayPositionned title) { + this.title = title; } - final public Display getTitle() { + final public void setCaption(DisplayPositionned caption) { + this.caption = caption; + } + + final public DisplayPositionned getCaption() { + return caption; + } + + @Override + final public DisplayPositionned getTitle() { return title; } @@ -139,45 +145,23 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram { skinParam.setParam(StringUtils.goLowerCase(key), value); } - public final Display getHeader() { + public final DisplayPositionned getHeader() { return header; } - public final void setHeader(Display header) { + public final void setHeader(DisplayPositionned header) { this.header = header; } - public final Display getFooter() { + public final DisplayPositionned getFooter() { return footer; } - public final void setFooter(Display footer) { + public final void setFooter(DisplayPositionned footer) { this.footer = footer; } - public final HorizontalAlignment getHeaderAlignment() { - return headerAlignment; - } - - public final void setHeaderAlignment(HorizontalAlignment headerAlignment) { - this.headerAlignment = headerAlignment; - } - - public final HorizontalAlignment getFooterAlignment() { - return footerAlignment; - } - - public final HorizontalAlignment getAlignmentTeoz(FontParam param) { - if (param == FontParam.FOOTER) { - return getFooterAlignment(); - } - if (param == FontParam.HEADER) { - return getHeaderAlignment(); - } - throw new IllegalArgumentException(); - } - - public final Display getFooterOrHeaderTeoz(FontParam param) { + public final DisplayPositionned getFooterOrHeaderTeoz(FontParam param) { if (param == FontParam.FOOTER) { return getFooter(); } @@ -187,10 +171,6 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram { throw new IllegalArgumentException(); } - public final void setFooterAlignment(HorizontalAlignment footerAlignment) { - this.footerAlignment = footerAlignment; - } - abstract public UmlDiagramType getUmlDiagramType(); public Pragma getPragma() { @@ -431,21 +411,11 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram { skinParam.addSprite(name, sprite); } - public final Display getLegend() { + public final DisplayPositionned getLegend() { return legend; } - public final HorizontalAlignment getLegendAlignment() { - return legendAlignment; - } - - public final VerticalAlignment getLegendVerticalAlignment() { - return legendVerticalAlignment; - } - - public final void setLegend(Display legend, HorizontalAlignment horizontalAlignment, VerticalAlignment valignment) { + public final void setLegend(DisplayPositionned legend) { this.legend = legend; - this.legendAlignment = horizontalAlignment; - this.legendVerticalAlignment = valignment; } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java index d6591c84d..5f4941eea 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ActivityDiagram3.java @@ -37,26 +37,22 @@ import java.awt.geom.Dimension2D; import java.io.IOException; import java.io.OutputStream; +import net.sourceforge.plantuml.AnnotatedWorker; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.FileFormatOption; -import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Scale; import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle; -import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlanes; import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescriptionImpl; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.cucadiagram.Stereotype; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.TextBlockCompressed; @@ -65,10 +61,7 @@ import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.skin.rose.Rose; -import net.sourceforge.plantuml.svek.DecorateEntityImage; -import net.sourceforge.plantuml.svek.DecorateTextBlock; import net.sourceforge.plantuml.ugraphic.ImageBuilder; -import net.sourceforge.plantuml.ugraphic.UFont; public class ActivityDiagram3 extends UmlDiagram { @@ -160,16 +153,6 @@ public class ActivityDiagram3 extends UmlDiagram { return UmlDiagramType.ACTIVITY; } - private TextBlock addLegend(TextBlock original) { - final Display legend = getLegend(); - if (Display.isNull(legend)) { - return original; - } - final TextBlock text = EntityImageLegend.create(legend, getSkinParam()); - - return DecorateEntityImage.add(original, text, getLegendAlignment(), getLegendVerticalAlignment()); - } - @Override protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { @@ -178,10 +161,8 @@ public class ActivityDiagram3 extends UmlDiagram { // TextBlock result = swinlanes; TextBlock result = new TextBlockCompressed(swinlanes); result = new TextBlockRecentred(result); - result = addLegend(result); - result = addTitle(result); - result = addHeaderAndFooter(result); final ISkinParam skinParam = getSkinParam(); + result = new AnnotatedWorker(this, skinParam).addAdd(result); final Dimension2D dim = TextBlockUtils.getMinMax(result).getDimension(); final double margin = 10; final double dpiFactor = getDpiFactor(fileFormatOption, Dimension2DDouble.delta(dim, 2 * margin, 0)); @@ -206,40 +187,15 @@ public class ActivityDiagram3 extends UmlDiagram { return dpiFactor; } - private TextBlock addTitle(TextBlock original) { - final Display title = getTitle(); - if (Display.isNull(title)) { - return original; - } - final TextBlock text = title.create(new FontConfiguration(getSkinParam(), FontParam.TITLE, null), - HorizontalAlignment.CENTER, getSkinParam()); - - return new DecorateTextBlock(original, text, HorizontalAlignment.CENTER); - } - - private TextBlock addHeaderAndFooter(TextBlock original) { - final Display footer = getFooter(); - final Display header = getHeader(); - if (Display.isNull(footer) && Display.isNull(header)) { - return original; - } - final TextBlock textFooter = Display.isNull(footer) ? null : footer.create(new FontConfiguration( - getSkinParam(), FontParam.FOOTER, null), getFooterAlignment(), getSkinParam()); - final TextBlock textHeader = Display.isNull(header) ? null : header.create(new FontConfiguration( - getSkinParam(), FontParam.HEADER, null), getHeaderAlignment(), getSkinParam()); - - return new DecorateTextBlock(original, textHeader, getHeaderAlignment(), textFooter, getFooterAlignment()); - } - - private final UFont getFont(FontParam fontParam) { - final ISkinParam skinParam = getSkinParam(); - return skinParam.getFont(null, false, fontParam); - } - - private final HtmlColor getFontColor(FontParam fontParam, Stereotype stereotype2) { - final ISkinParam skinParam = getSkinParam(); - return skinParam.getFontHtmlColor(stereotype2, fontParam); - } + // private final UFont getFont(FontParam fontParam) { + // final ISkinParam skinParam = getSkinParam(); + // return skinParam.getFont(null, false, fontParam); + // } + // + // private final HtmlColor getFontColor(FontParam fontParam, Stereotype stereotype2) { + // final ISkinParam skinParam = getSkinParam(); + // return skinParam.getFontHtmlColor(stereotype2, fontParam); + // } public void fork() { final InstructionFork instructionFork = new InstructionFork(current(), nextLinkRenderer()); @@ -307,7 +263,10 @@ public class ActivityDiagram3 extends UmlDiagram { public CommandExecutionResult elseIf(Display test, Display whenThen, HtmlColor color) { if (current() instanceof InstructionIf) { - ((InstructionIf) current()).elseIf(test, whenThen, nextLinkRenderer(), color); + final boolean ok = ((InstructionIf) current()).elseIf(test, whenThen, nextLinkRenderer(), color); + if (ok == false) { + return CommandExecutionResult.error("You cannot put an elseIf here"); + } setNextLinkRendererInternal(null); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java index acaff8142..c183a8423 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionIf.java @@ -108,13 +108,14 @@ public class InstructionIf implements Instruction, InstructionCollection { return true; } - public void elseIf(Display test, Display whenThen, LinkRendering nextLinkRenderer, HtmlColor color) { + public boolean elseIf(Display test, Display whenThen, LinkRendering nextLinkRenderer, HtmlColor color) { if (elseBranch != null) { - throw new IllegalStateException(); + return false; } this.current.setInlinkRendering(nextLinkRenderer); this.current = new Branch(swimlane, whenThen, test, color); this.thens.add(current); + return true; } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java index 57da6adb3..63e181b75 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionSimple.java @@ -40,7 +40,6 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory; import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled; import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; diff --git a/src/net/sourceforge/plantuml/activitydiagram3/InstructionStop.java b/src/net/sourceforge/plantuml/activitydiagram3/InstructionStop.java index 1e0a4f6fe..0e2754130 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/InstructionStop.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/InstructionStop.java @@ -42,6 +42,8 @@ import net.sourceforge.plantuml.sequencediagram.NotePosition; public class InstructionStop extends MonoSwimable implements Instruction { private final LinkRendering inlinkRendering; + private Display note; + private NotePosition notePosition; public InstructionStop(Swimlane swimlane, LinkRendering inlinkRendering) { super(swimlane); @@ -49,7 +51,11 @@ public class InstructionStop extends MonoSwimable implements Instruction { } public Ftile createFtile(FtileFactory factory) { - return factory.stop(getSwimlaneIn()); + Ftile result = factory.stop(getSwimlaneIn()); + if (note != null) { + result = factory.addNote(result, note, notePosition); + } + return result; } public void add(Instruction other) { @@ -65,7 +71,9 @@ public class InstructionStop extends MonoSwimable implements Instruction { } public boolean addNote(Display note, NotePosition position) { - throw new UnsupportedOperationException(); + this.note = note; + this.notePosition = position; + return true; } } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java index 1ca77d8b4..f740b12a8 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/FtileFactoryDelegator.java @@ -46,12 +46,13 @@ import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.IHtmlColorSet; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.skin.rose.Rose; -import net.sourceforge.plantuml.ugraphic.Sprite; +import net.sourceforge.plantuml.ugraphic.sprite.Sprite; public class FtileFactoryDelegator implements FtileFactory { @@ -200,4 +201,8 @@ public class FtileFactoryDelegator implements FtileFactory { return skinParam.getTabSize(); } + public IHtmlColorSet getIHtmlColorSet() { + return skinParam.getIHtmlColorSet(); + } + } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java index ece963bfa..8f9443bfa 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/VCompactFactory.java @@ -55,12 +55,13 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDecorateIn; import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDecorateOut; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.IHtmlColorSet; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.skin.rose.Rose; -import net.sourceforge.plantuml.ugraphic.Sprite; import net.sourceforge.plantuml.ugraphic.UFont; +import net.sourceforge.plantuml.ugraphic.sprite.Sprite; public class VCompactFactory implements FtileFactory { @@ -187,4 +188,8 @@ public class VCompactFactory implements FtileFactory { return skinParam.getTabSize(); } + public IHtmlColorSet getIHtmlColorSet() { + return skinParam.getIHtmlColorSet(); + } + } diff --git a/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java b/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java index 712237a8c..5813c0341 100644 --- a/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java +++ b/src/net/sourceforge/plantuml/classdiagram/ClassDiagramFactory.java @@ -37,6 +37,7 @@ import java.util.ArrayList; import java.util.List; import net.sourceforge.plantuml.AbstractPSystem; +import net.sourceforge.plantuml.NewpagedDiagram; import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.classdiagram.command.CommandAddMethod; import net.sourceforge.plantuml.classdiagram.command.CommandAllowMixing; @@ -67,8 +68,9 @@ import net.sourceforge.plantuml.command.note.FactoryNoteOnEntityCommand; import net.sourceforge.plantuml.command.note.FactoryNoteOnLinkCommand; import net.sourceforge.plantuml.command.note.FactoryTipOnEntityCommand; import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.cucadiagram.Link; -import net.sourceforge.plantuml.objectdiagram.command.CommandAddData; +import net.sourceforge.plantuml.descdiagram.command.CommandNewpage; import net.sourceforge.plantuml.objectdiagram.command.CommandCreateEntityObject; import net.sourceforge.plantuml.objectdiagram.command.CommandCreateEntityObjectMultilines; @@ -87,6 +89,7 @@ public class ClassDiagramFactory extends UmlDiagramFactory { addCommonCommands(cmds); cmds.add(new CommandRankDir()); + cmds.add(new CommandNewpage(this)); cmds.add(new CommandPage()); cmds.add(new CommandAddMethod()); @@ -145,8 +148,18 @@ public class ClassDiagramFactory extends UmlDiagramFactory { @Override public String checkFinalError(AbstractPSystem sys) { - final ClassDiagram system = (ClassDiagram) sys; + if (sys instanceof NewpagedDiagram) { + for (Diagram p : ((NewpagedDiagram) sys).getDiagrams()) { + checkFinal((ClassDiagram) p); + } + } else { + final ClassDiagram system = (ClassDiagram) sys; + checkFinal(system); + } + return super.checkFinalError(sys); + } + private void checkFinal(final ClassDiagram system) { for (Link link : system.getLinks()) { final int len = link.getLength(); if (len == 1) { @@ -157,23 +170,7 @@ public class ClassDiagramFactory extends UmlDiagramFactory { } } } - system.applySingleStrategy(); - - // for (IGroup g : system.getGroups(true)) { - // final List standalones = new ArrayList(); - // for (ILeaf ent : g.getLeafsDirect()) { - // if (system.isStandalone(ent)) { - // standalones.add(ent); - // } - // } - // if (standalones.size() < 3) { - // continue; - // } - // final Magma magma = new Magma(system, standalones); - // magma.putInSquare(); - // } - return super.checkFinalError(system); } } diff --git a/src/net/sourceforge/plantuml/command/CommandCaption.java b/src/net/sourceforge/plantuml/command/CommandCaption.java new file mode 100644 index 000000000..2a5040ef3 --- /dev/null +++ b/src/net/sourceforge/plantuml/command/CommandCaption.java @@ -0,0 +1,57 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, 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 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: 18788 $ + * + */ +package net.sourceforge.plantuml.command; + +import java.util.List; + +import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.VerticalAlignment; + +public class CommandCaption extends SingleLineCommand { + + public CommandCaption() { + super("(?i)^caption(?:[%s]*:[%s]*|[%s]+)(.*[\\p{L}0-9_.].*)$"); + } + + @Override + protected CommandExecutionResult executeArg(UmlDiagram diagram, List arg) { + diagram.setCaption(new DisplayPositionned(Display.getWithNewlines(arg.get(0)), HorizontalAlignment.CENTER, + VerticalAlignment.BOTTOM)); + return CommandExecutionResult.ok(); + } + +} diff --git a/src/net/sourceforge/plantuml/command/CommandFooter.java b/src/net/sourceforge/plantuml/command/CommandFooter.java index e43076d38..ba01b9ad6 100644 --- a/src/net/sourceforge/plantuml/command/CommandFooter.java +++ b/src/net/sourceforge/plantuml/command/CommandFooter.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18789 $ * */ package net.sourceforge.plantuml.command; @@ -38,7 +38,9 @@ import java.util.List; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.VerticalAlignment; public class CommandFooter extends SingleLineCommand { @@ -49,11 +51,8 @@ public class CommandFooter extends SingleLineCommand { @Override protected CommandExecutionResult executeArg(UmlDiagram diagram, List arg) { final String align = arg.get(0); - if (align != null) { - diagram.setFooterAlignment(HorizontalAlignment.valueOf(StringUtils.goUpperCase(align))); - } - diagram.setFooter(Display.getWithNewlines(arg.get(1))); + diagram.setFooter(new DisplayPositionned(Display.getWithNewlines(arg.get(1)), HorizontalAlignment.fromString( + align, HorizontalAlignment.CENTER), VerticalAlignment.BOTTOM)); return CommandExecutionResult.ok(); } - } diff --git a/src/net/sourceforge/plantuml/command/CommandHeader.java b/src/net/sourceforge/plantuml/command/CommandHeader.java index 63155482c..387385ba0 100644 --- a/src/net/sourceforge/plantuml/command/CommandHeader.java +++ b/src/net/sourceforge/plantuml/command/CommandHeader.java @@ -28,17 +28,18 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18789 $ * */ package net.sourceforge.plantuml.command; import java.util.List; -import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.VerticalAlignment; public class CommandHeader extends SingleLineCommand { @@ -49,11 +50,8 @@ public class CommandHeader extends SingleLineCommand { @Override protected CommandExecutionResult executeArg(UmlDiagram diagram, List arg) { final String align = arg.get(0); - if (align != null) { - diagram.setHeaderAlignment(HorizontalAlignment.valueOf(StringUtils.goUpperCase(align))); - } - diagram.setHeader(Display.getWithNewlines(arg.get(1))); + diagram.setHeader(new DisplayPositionned(Display.getWithNewlines(arg.get(1)), HorizontalAlignment.fromString( + align, HorizontalAlignment.RIGHT), VerticalAlignment.TOP)); return CommandExecutionResult.ok(); } - } diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesFooter.java b/src/net/sourceforge/plantuml/command/CommandMultilinesFooter.java index 1fc7d6fd9..64450ea62 100644 --- a/src/net/sourceforge/plantuml/command/CommandMultilinesFooter.java +++ b/src/net/sourceforge/plantuml/command/CommandMultilinesFooter.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18789 $ * */ package net.sourceforge.plantuml.command; @@ -38,7 +38,9 @@ import java.util.regex.Matcher; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.VerticalAlignment; public class CommandMultilinesFooter extends CommandMultilines { @@ -58,13 +60,11 @@ public class CommandMultilinesFooter extends CommandMultilines { throw new IllegalStateException(); } final String align = m.group(1); - if (align != null) { - diagram.setFooterAlignment(HorizontalAlignment.valueOf(StringUtils.goUpperCase(align))); - } lines = lines.subExtract(1, 1); final Display strings = lines.toDisplay(); if (strings.size() > 0) { - diagram.setFooter(strings); + diagram.setFooter(new DisplayPositionned(strings, HorizontalAlignment.fromString(align, + HorizontalAlignment.CENTER), VerticalAlignment.BOTTOM)); return CommandExecutionResult.ok(); } return CommandExecutionResult.error("Empty footer"); diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesHeader.java b/src/net/sourceforge/plantuml/command/CommandMultilinesHeader.java index 18307e5b2..e13c45587 100644 --- a/src/net/sourceforge/plantuml/command/CommandMultilinesHeader.java +++ b/src/net/sourceforge/plantuml/command/CommandMultilinesHeader.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18789 $ * */ package net.sourceforge.plantuml.command; @@ -38,20 +38,21 @@ import java.util.regex.Matcher; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.VerticalAlignment; public class CommandMultilinesHeader extends CommandMultilines { public CommandMultilinesHeader() { super("(?i)^(?:(left|right|center)?[%s]*)header$"); } - + @Override public String getPatternEnd() { return "(?i)^end[%s]?header$"; } - public CommandExecutionResult execute(final UmlDiagram diagram, BlocLines lines) { lines = lines.trim(false); final Matcher m = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499())); @@ -59,13 +60,11 @@ public class CommandMultilinesHeader extends CommandMultilines { throw new IllegalStateException(); } final String align = m.group(1); - if (align != null) { - diagram.setHeaderAlignment(HorizontalAlignment.valueOf(StringUtils.goUpperCase(align))); - } lines = lines.subExtract(1, 1); final Display strings = lines.toDisplay(); if (strings.size() > 0) { - diagram.setHeader(strings); + diagram.setHeader(new DisplayPositionned(strings, HorizontalAlignment.fromString(align, + HorizontalAlignment.RIGHT), VerticalAlignment.TOP)); return CommandExecutionResult.ok(); } return CommandExecutionResult.error("Empty header"); diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesLegend.java b/src/net/sourceforge/plantuml/command/CommandMultilinesLegend.java index 566f6f224..d062ae498 100644 --- a/src/net/sourceforge/plantuml/command/CommandMultilinesLegend.java +++ b/src/net/sourceforge/plantuml/command/CommandMultilinesLegend.java @@ -39,6 +39,7 @@ import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.VerticalAlignment; @@ -76,7 +77,7 @@ public class CommandMultilinesLegend extends CommandMultilines2 { if (alignment == null) { alignment = HorizontalAlignment.CENTER; } - diagram.setLegend(strings, alignment, valignment); + diagram.setLegend(new DisplayPositionned(strings, alignment, valignment)); return CommandExecutionResult.ok(); } return CommandExecutionResult.error("No legend defined"); diff --git a/src/net/sourceforge/plantuml/command/CommandMultilinesTitle.java b/src/net/sourceforge/plantuml/command/CommandMultilinesTitle.java index 9b7f0e14c..204961898 100644 --- a/src/net/sourceforge/plantuml/command/CommandMultilinesTitle.java +++ b/src/net/sourceforge/plantuml/command/CommandMultilinesTitle.java @@ -28,13 +28,16 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18788 $ * */ package net.sourceforge.plantuml.command; import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.VerticalAlignment; public class CommandMultilinesTitle extends CommandMultilines { @@ -52,7 +55,7 @@ public class CommandMultilinesTitle extends CommandMultilines { lines = lines.removeEmptyColumns(); final Display strings = lines.toDisplay(); if (strings.size() > 0) { - diagram.setTitle(strings); + diagram.setTitle(new DisplayPositionned(strings, HorizontalAlignment.CENTER, VerticalAlignment.TOP)); return CommandExecutionResult.ok(); } return CommandExecutionResult.error("No title defined"); diff --git a/src/net/sourceforge/plantuml/command/CommandSpriteFile.java b/src/net/sourceforge/plantuml/command/CommandSpriteFile.java index 1ec638968..f95055f78 100644 --- a/src/net/sourceforge/plantuml/command/CommandSpriteFile.java +++ b/src/net/sourceforge/plantuml/command/CommandSpriteFile.java @@ -46,7 +46,7 @@ import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.ugraphic.SpriteImage; +import net.sourceforge.plantuml.ugraphic.sprite.SpriteImage; import net.sourceforge.plantuml.version.PSystemVersion; public class CommandSpriteFile extends SingleLineCommand2 { diff --git a/src/net/sourceforge/plantuml/command/CommandTitle.java b/src/net/sourceforge/plantuml/command/CommandTitle.java index 42a3f3a42..99c287022 100644 --- a/src/net/sourceforge/plantuml/command/CommandTitle.java +++ b/src/net/sourceforge/plantuml/command/CommandTitle.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18788 $ * */ package net.sourceforge.plantuml.command; @@ -37,6 +37,9 @@ import java.util.List; import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.VerticalAlignment; public class CommandTitle extends SingleLineCommand { @@ -46,7 +49,8 @@ public class CommandTitle extends SingleLineCommand { @Override protected CommandExecutionResult executeArg(UmlDiagram diagram, List arg) { - diagram.setTitle(Display.getWithNewlines(arg.get(0))); + diagram.setTitle(new DisplayPositionned(Display.getWithNewlines(arg.get(0)), HorizontalAlignment.CENTER, + VerticalAlignment.TOP)); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/command/FactorySpriteCommand.java b/src/net/sourceforge/plantuml/command/FactorySpriteCommand.java index 53c58add3..4c472d858 100644 --- a/src/net/sourceforge/plantuml/command/FactorySpriteCommand.java +++ b/src/net/sourceforge/plantuml/command/FactorySpriteCommand.java @@ -43,8 +43,8 @@ import net.sourceforge.plantuml.command.note.SingleMultiFactoryCommand; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.ugraphic.Sprite; -import net.sourceforge.plantuml.ugraphic.SpriteGrayLevel; +import net.sourceforge.plantuml.ugraphic.sprite.Sprite; +import net.sourceforge.plantuml.ugraphic.sprite.SpriteGrayLevel; public final class FactorySpriteCommand implements SingleMultiFactoryCommand { diff --git a/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java b/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java index f0d725ffa..fbe8bc495 100644 --- a/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java +++ b/src/net/sourceforge/plantuml/command/UmlDiagramFactory.java @@ -264,6 +264,7 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory { cmds.add(new CommandMultilinesComment()); cmds.add(new CommandPragma()); cmds.add(new CommandTitle()); + cmds.add(new CommandCaption()); cmds.add(new CommandMultilinesTitle()); cmds.add(new CommandMultilinesLegend()); diff --git a/src/net/sourceforge/plantuml/creole/Atom.java b/src/net/sourceforge/plantuml/creole/Atom.java index d0d2009a5..dc8a1d22f 100644 --- a/src/net/sourceforge/plantuml/creole/Atom.java +++ b/src/net/sourceforge/plantuml/creole/Atom.java @@ -46,5 +46,5 @@ interface Atom extends UShape { public double getStartingAltitude(StringBounder stringBounder); public void drawU(UGraphic ug); - + } diff --git a/src/net/sourceforge/plantuml/creole/AtomEmbededSystem.java b/src/net/sourceforge/plantuml/creole/AtomEmbededSystem.java index 92120a39f..4e94eb419 100644 --- a/src/net/sourceforge/plantuml/creole/AtomEmbededSystem.java +++ b/src/net/sourceforge/plantuml/creole/AtomEmbededSystem.java @@ -109,6 +109,6 @@ class AtomEmbededSystem implements Atom { private Diagram getSystem() throws IOException, InterruptedException { final BlockUml blockUml = new BlockUml(lines2, 0); return blockUml.getDiagram(); - } + } diff --git a/src/net/sourceforge/plantuml/creole/AtomImg.java b/src/net/sourceforge/plantuml/creole/AtomImg.java index 9361d8b39..76db802eb 100644 --- a/src/net/sourceforge/plantuml/creole/AtomImg.java +++ b/src/net/sourceforge/plantuml/creole/AtomImg.java @@ -50,7 +50,6 @@ import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.FileSystem; import net.sourceforge.plantuml.code.Base64Coder; import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.ImgValign; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.ugraphic.UFont; @@ -149,5 +148,6 @@ public class AtomImg implements Atom { ug.draw(new UImage(image)); // tileImage.drawU(ug.apply(new UTranslate(0, -h))); } + } diff --git a/src/net/sourceforge/plantuml/creole/AtomOpenIcon.java b/src/net/sourceforge/plantuml/creole/AtomOpenIcon.java index 3232d7e49..d9b1b3ef3 100644 --- a/src/net/sourceforge/plantuml/creole/AtomOpenIcon.java +++ b/src/net/sourceforge/plantuml/creole/AtomOpenIcon.java @@ -69,5 +69,5 @@ public class AtomOpenIcon implements Atom { public void drawU(UGraphic ug) { asTextBlock().drawU(ug); } - + } diff --git a/src/net/sourceforge/plantuml/creole/AtomSprite.java b/src/net/sourceforge/plantuml/creole/AtomSprite.java index b87ff8082..92cb03c09 100644 --- a/src/net/sourceforge/plantuml/creole/AtomSprite.java +++ b/src/net/sourceforge/plantuml/creole/AtomSprite.java @@ -61,5 +61,5 @@ public class AtomSprite implements Atom { public void drawU(UGraphic ug) { sprite.drawU(ug); } - + } diff --git a/src/net/sourceforge/plantuml/creole/AtomTable.java b/src/net/sourceforge/plantuml/creole/AtomTable.java index b6325ee76..8a2e55b9e 100644 --- a/src/net/sourceforge/plantuml/creole/AtomTable.java +++ b/src/net/sourceforge/plantuml/creole/AtomTable.java @@ -42,18 +42,27 @@ import java.util.Map; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.ugraphic.UChangeBackColor; import net.sourceforge.plantuml.ugraphic.UChangeColor; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.URectangle; import net.sourceforge.plantuml.ugraphic.UTranslate; public class AtomTable implements Atom { class Line { private final List cells = new ArrayList(); + private final List cellsBackColor = new ArrayList(); + private final HtmlColor lineBackColor; - public void add(Atom cell) { + private Line(HtmlColor lineBackColor) { + this.lineBackColor = lineBackColor; + } + + public void add(Atom cell, HtmlColor cellBackColor) { cells.add(cell); + cellsBackColor.add(cellBackColor); } public int size() { @@ -87,8 +96,27 @@ public class AtomTable implements Atom { public void drawU(UGraphic ug) { initMap(ug.getStringBounder()); - for (Line line : lines) { - for (Atom cell : line.cells) { + for (int i = 0; i < getNbLines(); i++) { + final Line line = lines.get(i); + if (line.lineBackColor != null) { + final double y1 = getStartingY(i); + final double y2 = getStartingY(i + 1); + final double x1 = getStartingX(0); + final double x2 = getStartingX(getNbCols()); + ug.apply(new UChangeColor(null)).apply(new UChangeBackColor(line.lineBackColor)) + .apply(new UTranslate(x1, y1)).draw(new URectangle(x2 - x1, y2 - y1)); + } + for (int j = 0; j < getNbCols(); j++) { + final Atom cell = line.cells.get(j); + final HtmlColor cellBackColor = line.cellsBackColor.get(j); + if (cellBackColor != null) { + final double y1 = getStartingY(i); + final double y2 = getStartingY(i + 1); + final double x1 = getStartingX(j); + final double x2 = getStartingX(j + 1); + ug.apply(new UChangeColor(null)).apply(new UChangeBackColor(cellBackColor)) + .apply(new UTranslate(x1, y1)).draw(new URectangle(x2 - x1, y2 - y1)); + } final Position pos = positions.get(cell); cell.drawU(ug.apply(pos.getTranslate())); } @@ -210,13 +238,12 @@ public class AtomTable implements Atom { return lines.get(lines.size() - 1); } - public void addCell(Atom cell) { - lastLine().add(cell); + public void addCell(Atom cell, HtmlColor cellBackColor) { + lastLine().add(cell, cellBackColor); positions.clear(); } - public void newLine() { - lines.add(new Line()); + public void newLine(HtmlColor lineBackColor) { + lines.add(new Line(lineBackColor)); } - } diff --git a/src/net/sourceforge/plantuml/creole/AtomText.java b/src/net/sourceforge/plantuml/creole/AtomText.java index 9f5504894..515da95fd 100644 --- a/src/net/sourceforge/plantuml/creole/AtomText.java +++ b/src/net/sourceforge/plantuml/creole/AtomText.java @@ -255,4 +255,5 @@ public class AtomText implements Atom { public final String getText() { return text; } + } diff --git a/src/net/sourceforge/plantuml/creole/AtomTree.java b/src/net/sourceforge/plantuml/creole/AtomTree.java index b137f670b..be205f8d3 100644 --- a/src/net/sourceforge/plantuml/creole/AtomTree.java +++ b/src/net/sourceforge/plantuml/creole/AtomTree.java @@ -98,5 +98,5 @@ public class AtomTree implements Atom { this.cells.add(cell); this.levels.put(cell, level); } - + } diff --git a/src/net/sourceforge/plantuml/creole/AtomWithMargin.java b/src/net/sourceforge/plantuml/creole/AtomWithMargin.java index cd9c31fde..2e7ca9d96 100644 --- a/src/net/sourceforge/plantuml/creole/AtomWithMargin.java +++ b/src/net/sourceforge/plantuml/creole/AtomWithMargin.java @@ -63,5 +63,5 @@ class AtomWithMargin implements Atom { public void drawU(UGraphic ug) { atom.drawU(ug.apply(new UTranslate(0, marginY1))); } - + } diff --git a/src/net/sourceforge/plantuml/creole/Bullet.java b/src/net/sourceforge/plantuml/creole/Bullet.java index 44dedeb6b..9b085bb83 100644 --- a/src/net/sourceforge/plantuml/creole/Bullet.java +++ b/src/net/sourceforge/plantuml/creole/Bullet.java @@ -104,6 +104,6 @@ public class Bullet implements Atom { private Dimension2D calculateDimension1(StringBounder stringBounder) { return new Dimension2DDouble(getWidth(stringBounder), 3); } - + } diff --git a/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java b/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java index 3c2d2ada5..09a3b3ac6 100644 --- a/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java +++ b/src/net/sourceforge/plantuml/creole/CreoleHorizontalLine.java @@ -102,5 +102,5 @@ public class CreoleHorizontalLine implements Atom { public double getStartingAltitude(StringBounder stringBounder) { return 0; } - + } diff --git a/src/net/sourceforge/plantuml/creole/CreoleParser.java b/src/net/sourceforge/plantuml/creole/CreoleParser.java index b484aa4ff..dfd59a274 100644 --- a/src/net/sourceforge/plantuml/creole/CreoleParser.java +++ b/src/net/sourceforge/plantuml/creole/CreoleParser.java @@ -62,7 +62,7 @@ public class CreoleParser { } private Stripe createStripe(String line, CreoleContext context, Stripe lastStripe) { - if (lastStripe instanceof StripeTable && line.startsWith("|") && line.endsWith("|")) { + if (lastStripe instanceof StripeTable && isTableLine(line)) { final StripeTable table = (StripeTable) lastStripe; table.analyzeAndAddNormal(line); return null; @@ -70,7 +70,7 @@ public class CreoleParser { final StripeTree tree = (StripeTree) lastStripe; tree.analyzeAndAdd(line); return null; - } else if (line.startsWith("|=") && line.endsWith("|")) { + } else if (isTableLine(line)) { return new StripeTable(fontConfiguration, skinParam, line); } else if (isTreeStart(line)) { return new StripeTree(fontConfiguration, skinParam, line); @@ -79,6 +79,14 @@ public class CreoleParser { .createStripe(context); } + private static boolean isTableLine(String line) { + return line.matches("^(\\<#\\w+\\>)?\\|(\\=)?.*\\|$"); + } + + public static boolean doesStartByColor(String line) { + return line.matches("^(\\<#\\w+\\>).*"); + } + public static boolean isTreeStart(String line) { // return false; return line.startsWith("|_"); diff --git a/src/net/sourceforge/plantuml/creole/SheetBlock1.java b/src/net/sourceforge/plantuml/creole/SheetBlock1.java index bfce9c367..a1b6c4d6e 100644 --- a/src/net/sourceforge/plantuml/creole/SheetBlock1.java +++ b/src/net/sourceforge/plantuml/creole/SheetBlock1.java @@ -162,4 +162,5 @@ public class SheetBlock1 extends AbstractTextBlock implements TextBlock, Atom, S public double getEndingX(StringBounder stringBounder, double y) { return calculateDimension(stringBounder).getWidth(); } + } diff --git a/src/net/sourceforge/plantuml/creole/SheetBlock2.java b/src/net/sourceforge/plantuml/creole/SheetBlock2.java index f469821c9..2802c1e01 100644 --- a/src/net/sourceforge/plantuml/creole/SheetBlock2.java +++ b/src/net/sourceforge/plantuml/creole/SheetBlock2.java @@ -77,4 +77,5 @@ public class SheetBlock2 extends AbstractTextBlock implements TextBlock, Atom { public Rectangle2D getInnerPosition(String member, StringBounder stringBounder) { return block.getInnerPosition(member, stringBounder); } + } diff --git a/src/net/sourceforge/plantuml/creole/StripeSimple.java b/src/net/sourceforge/plantuml/creole/StripeSimple.java index 7c8e14b40..d485db61e 100644 --- a/src/net/sourceforge/plantuml/creole/StripeSimple.java +++ b/src/net/sourceforge/plantuml/creole/StripeSimple.java @@ -44,13 +44,13 @@ import net.sourceforge.plantuml.graphic.FontPosition; import net.sourceforge.plantuml.graphic.FontStyle; import net.sourceforge.plantuml.graphic.ImgValign; import net.sourceforge.plantuml.openiconic.OpenIcon; -import net.sourceforge.plantuml.ugraphic.Sprite; +import net.sourceforge.plantuml.ugraphic.sprite.Sprite; import net.sourceforge.plantuml.utils.CharHidder; public class StripeSimple implements Stripe { final private List atoms = new ArrayList(); - private final List commands = new ArrayList(); + final private List commands = new ArrayList(); private FontConfiguration fontConfiguration; diff --git a/src/net/sourceforge/plantuml/creole/StripeTable.java b/src/net/sourceforge/plantuml/creole/StripeTable.java index 239a745d3..6e1672acf 100644 --- a/src/net/sourceforge/plantuml/creole/StripeTable.java +++ b/src/net/sourceforge/plantuml/creole/StripeTable.java @@ -41,6 +41,7 @@ import java.util.StringTokenizer; import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.HtmlColor; public class StripeTable implements Stripe { @@ -74,10 +75,39 @@ public class StripeTable implements Stripe { return new SheetBlock1(sheet, 0, padding); } + private HtmlColor getBackColor(String line) { + if (CreoleParser.doesStartByColor(line)) { + final int idx1 = line.indexOf('#'); + final int idx2 = line.indexOf('>'); + if (idx2 == -1) { + throw new IllegalStateException(); + } + final String color = line.substring(idx1, idx2); + return skinParam.getIHtmlColorSet().getColorIfValid(color); + } + return null; + } + + private String withouBackColor(String line) { + final int idx2 = line.indexOf('>'); + if (idx2 == -1) { + throw new IllegalStateException(); + } + return line.substring(idx2 + 1); + } + private void analyzeAndAddInternal(String line, Mode mode) { - table.newLine(); + HtmlColor lineBackColor = getBackColor(line); + if (lineBackColor != null) { + line = withouBackColor(line); + } + table.newLine(lineBackColor); for (final StringTokenizer st = new StringTokenizer(line, "|"); st.hasMoreTokens();) { String v = st.nextToken(); + HtmlColor cellBackColor = getBackColor(v); + if (cellBackColor != null) { + v = withouBackColor(v); + } if (mode == Mode.HEADER && v.startsWith("=")) { v = v.substring(1); } @@ -89,7 +119,7 @@ public class StripeTable implements Stripe { cell.analyzeAndAdd(s); cells.add(cell); } - table.addCell(asAtom(cells, skinParam.getPadding())); + table.addCell(asAtom(cells, skinParam.getPadding()), cellBackColor); } } diff --git a/src/net/sourceforge/plantuml/cucadiagram/DisplayPositionned.java b/src/net/sourceforge/plantuml/cucadiagram/DisplayPositionned.java new file mode 100644 index 000000000..904978917 --- /dev/null +++ b/src/net/sourceforge/plantuml/cucadiagram/DisplayPositionned.java @@ -0,0 +1,76 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, 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 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: 8218 $ + * + */ +package net.sourceforge.plantuml.cucadiagram; + +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.VerticalAlignment; + +public class DisplayPositionned { + + private final Display display; + private final HorizontalAlignment horizontalAlignment; + private final VerticalAlignment verticalAlignment; + + public DisplayPositionned(Display display, HorizontalAlignment horizontalAlignment, + VerticalAlignment verticalAlignment) { + this.display = display; + this.horizontalAlignment = horizontalAlignment; + this.verticalAlignment = verticalAlignment; + } + + public static DisplayPositionned none(HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) { + return new DisplayPositionned(Display.NULL, horizontalAlignment, verticalAlignment); + } + + public final Display getDisplay() { + return display; + } + + public final HorizontalAlignment getHorizontalAlignment() { + return horizontalAlignment; + } + + public final VerticalAlignment getVerticalAlignment() { + return verticalAlignment; + } + + public static boolean isNull(DisplayPositionned data) { + return data == null || Display.isNull(data.display); + } + + public boolean hasUrl() { + return display.hasUrl(); + } + +} diff --git a/src/net/sourceforge/plantuml/cucadiagram/Link.java b/src/net/sourceforge/plantuml/cucadiagram/Link.java index f5f0b7ffa..06b49a76e 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: 18280 $ + * Revision $Revision: 18823 $ * */ package net.sourceforge.plantuml.cucadiagram; @@ -245,6 +245,25 @@ public class Link implements Hideable, Removeable { return result; } + private boolean isReallyGroup(IEntity ent) { + if (ent.isGroup() == false) { + return false; + } + final IGroup group = (IGroup) ent; + return group.getChildren().size() + group.getLeafsDirect().size() > 0; + } + + public LinkType getTypePatchCluster() { + LinkType result = getType(); + if (isReallyGroup(getEntity1())) { + result = result.withoutDecors2(); + } + if (isReallyGroup(getEntity2())) { + result = result.withoutDecors1(); + } + return result; + } + private LinkType getTypeSpecialForPrinting() { if (opale) { return new LinkType(LinkDecor.NONE, LinkDecor.NONE); diff --git a/src/net/sourceforge/plantuml/cucadiagram/LinkType.java b/src/net/sourceforge/plantuml/cucadiagram/LinkType.java index c11d84a76..b7c8b747d 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/LinkType.java +++ b/src/net/sourceforge/plantuml/cucadiagram/LinkType.java @@ -52,6 +52,14 @@ public class LinkType { this(hat1, decor1, LinkStyle.NORMAL, LinkMiddleDecor.NONE, decor2, hat2); } + public LinkType withoutDecors1() { + return new LinkType(hat1, LinkDecor.NONE, style, middleDecor, decor2, hat2); + } + + public LinkType withoutDecors2() { + return new LinkType(hat1, decor1, style, middleDecor, LinkDecor.NONE, hat2); + } + // public boolean contains(LinkDecor decors) { // return decor1 == decors || decor2 == decors; // } diff --git a/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java b/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java index 49dda0e73..d55d2fa56 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: 18291 $ + * Revision $Revision: 18317 $ * */ package net.sourceforge.plantuml.cucadiagram; @@ -48,12 +48,13 @@ import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.IHtmlColorSet; import net.sourceforge.plantuml.svek.PackageStyle; import net.sourceforge.plantuml.ugraphic.UFont; +import net.sourceforge.plantuml.ugraphic.sprite.SpriteUtils; public class Stereotype implements CharSequence, Hideable { private final static Pattern circleChar = MyPattern .cmpile("\\<\\<[%s]*\\(?(\\S)[%s]*,[%s]*(#[0-9a-fA-F]{6}|\\w+)[%s]*(?:[),](.*?))?\\>\\>"); - private final static Pattern circleSprite = MyPattern - .cmpile("\\<\\<[%s]*\\(?\\$([-\\p{L}0-9_/]+)[%s]*(?:,[%s]*(#[0-9a-fA-F]{6}|\\w+))?[%s]*(?:[),](.*?))?\\>\\>"); + private final static Pattern circleSprite = MyPattern.cmpile("\\<\\<[%s]*\\(?\\$(" + SpriteUtils.SPRITE_NAME + + ")[%s]*(?:,[%s]*(#[0-9a-fA-F]{6}|\\w+))?[%s]*(?:[),](.*?))?\\>\\>"); private final String label; private final HtmlColor htmlColor; diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandNewpage.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandNewpage.java index 4ff581f26..2c34f4915 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandNewpage.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandNewpage.java @@ -59,8 +59,8 @@ public class CommandNewpage extends SingleLineCommand2 { @Override protected CommandExecutionResult executeArg(AbstractPSystem diagram, RegexResult arg) { - // NewpagedDiagram result = NewpagedDiagram.newpage(diagram, factory.createEmptyDiagram()); NewpagedDiagram result = new NewpagedDiagram(diagram, factory.createEmptyDiagram()); + // NewpagedDiagram result = NewpagedDiagram.newpage(diagram, factory.createEmptyDiagram()); return CommandExecutionResult.newDiagram(result); } } diff --git a/src/net/sourceforge/plantuml/donors/PSystemDonors.java b/src/net/sourceforge/plantuml/donors/PSystemDonors.java index 9859326f8..1814c6df1 100644 --- a/src/net/sourceforge/plantuml/donors/PSystemDonors.java +++ b/src/net/sourceforge/plantuml/donors/PSystemDonors.java @@ -58,7 +58,7 @@ import net.sourceforge.plantuml.version.PSystemVersion; public class PSystemDonors extends AbstractPSystem { - public static final String DONORS = "UDfTKa5osp0ClECLF6lIHoXMwuvi9ncxxI4tM48is3IXa9HRwMszzME5qigYZHDtW0LsGUGs-n_auOKYUPExA8wnWc-KpI5dMCiCVO1yek8UbdvEKGyxscE8ZCuyIUCWTxLuinIA0utFjpUjcChHmHgJGIv2mHDW2_dSMYwmwsO9FImvkmqdK4ugkm2xI6r3pYn4MlLNJ7CemEfyHnKF2x7ip5QwG51sT_diA6fa0Yt39b6DvnJggDpIBtIrhdFHi7OzeE_LwVPgsntWALKV1tYsV552mTL9bLypxE1pkBPsYOYCBb0CPuw-Dsjif4OenwM_DgZjaxgCxFnT6gTUr-GmQftgKrtbF_5qkd7bwXlumMHjP9Nsx2CFy7LErm8RhXgovX7Pzga3EwHYGhYNLXAwJoLMxnq5KtHxZ_grThR_GuwHgiQiF0QS9Hr8BpRvm9_ZeMc9MSc5qxlvk9plitz6s2QtF8wuyNbKTfjScPp6HJsAHuUsVJ2l557Q05lrYxusAnv_6hvOyUFwDtz-MwluBytvuOe0"; + public static final String DONORS = "UDfTKa6MsZ0CtUiKNkTD3v4XBNq1PlgWxM9sWcY8m5YfxT26itNNYrMX3JPePJtfI__BlxJ5_o0FNoYIDwMBuXXty9MA57A2fQJK1oWdA6vXxbE91jZG5aDaTEP5MWUbQyIRkL2yqFXyVzUEgHqTB35Rv29KF2LieKoZvGoRFb4OOCx5VJY1UcBP1zX4wbfoPYRIgRvgsaC15gS7g7YOYMLdrj87Whf_g1S7KI5JqZ6iCjPuobDTLLhwXQxHSyvQrgbxz8CgNTzakpsyvEpZ1LujdnLGyUwep6yLTl0nt4QxZ4H1PwWk9uv-C4jifK6enwE_jQZZixw2RFekZUEWPt8OjK_vAQ_w7tawtgbopLrwHR8EiWfxzP4ly3cL6u4LxrgovXdP3ha2Uyd9XF18hIPq7shS_UWfcAhVUjIljKd-Tpb4shLcuJ5WehGdTMpsWJz7escBMSYPSzzSdVCjwMU4TURbSSMTpeEYkynbSXmFzImU7ThkoRnHHEa2h5Kl-iOiUFnf-6J5Z-TV_VbjxTK3oHysywgwwo_hGETg"; public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException { final GraphicStrings result = getGraphicStrings(); diff --git a/src/net/sourceforge/plantuml/eps/EpsGraphics.java b/src/net/sourceforge/plantuml/eps/EpsGraphics.java index 7cd592c8c..ae0901908 100644 --- a/src/net/sourceforge/plantuml/eps/EpsGraphics.java +++ b/src/net/sourceforge/plantuml/eps/EpsGraphics.java @@ -517,6 +517,9 @@ public class EpsGraphics { } protected void appendColor(Color c) { + if (c == null) { + return; + } final double r = c.getRed() / 255.0; final double g = c.getGreen() / 255.0; final double b = c.getBlue() / 255.0; @@ -524,6 +527,9 @@ public class EpsGraphics { } protected void appendColorShort(Color c) { + if (c == null) { + return; + } final double r = c.getRed() / 255.0; final double g = c.getGreen() / 255.0; final double b = c.getBlue() / 255.0; diff --git a/src/net/sourceforge/plantuml/graphic/DateEventUtils.java b/src/net/sourceforge/plantuml/graphic/DateEventUtils.java index 4a2d321bf..f9a05949b 100644 --- a/src/net/sourceforge/plantuml/graphic/DateEventUtils.java +++ b/src/net/sourceforge/plantuml/graphic/DateEventUtils.java @@ -73,7 +73,7 @@ public class DateEventUtils { "a character on a keyboard and seen it show up on their", "own computer's screen right in front of them.\"", "\t\t\t\t\t\t\t\t\t\tSteve Wozniak"); return TextBlockUtils.mergeTB(textBlock, getComment(asList, color), HorizontalAlignment.LEFT); - } else if ("01-07".equals(today) || "01-08".equals(today)) { + } else if ("01-07".equals(today)) { return addCharlie(textBlock); } diff --git a/src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java b/src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java index fd5dc9b0e..04b3d6f20 100644 --- a/src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java +++ b/src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java @@ -28,15 +28,17 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18789 $ * */ package net.sourceforge.plantuml.graphic; +import net.sourceforge.plantuml.StringUtils; + public enum HorizontalAlignment { LEFT, CENTER, RIGHT; - + public static HorizontalAlignment fromString(String s) { if (LEFT.name().equalsIgnoreCase(s)) { return LEFT; @@ -50,4 +52,19 @@ public enum HorizontalAlignment { return null; } + public static HorizontalAlignment fromString(String s, HorizontalAlignment defaultValue) { + if (defaultValue == null) { + throw new IllegalArgumentException(); + } + if (s == null) { + return defaultValue; + } + s = StringUtils.goUpperCase(s); + final HorizontalAlignment result = fromString(s); + if (result == null) { + return defaultValue; + } + return result; + } + } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java index e70a9b83f..dbc673e90 100644 --- a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java +++ b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java @@ -162,13 +162,13 @@ public class QuoteUtils { "Take it easy, don't push the little button on the joystick!", // "I'm a very private person.", // "To sculpt an elephant from a big block of marble, just knock away all the bits that don't look like an elephant.", // - "Who said you could talk to me? Have I got something on my face ?" + "Who said you could talk to me? Have I got something on my face ?", // + "We've been through worst", // + "United we stand", // + "We shall never surrender", // + "Absolute honesty isn't always the most diplomatic nor the safest form of communication with emotional beings.", // + "Humor: seventy-five percent. [Confirmed] Self destruct sequence in T minus 10, 9... " // ); - // We've been through worst - // United we stand - // We shall never surrender - // Absolute honesty isn't always the most diplomatic nor the safest form of communication with emotional beings. - // Humor: seventy-five percent. [Confirmed] Self destruct sequence in T minus 10, 9... private QuoteUtils() { } diff --git a/src/net/sourceforge/plantuml/graphic/SingleLine.java b/src/net/sourceforge/plantuml/graphic/SingleLine.java index 60c737fb3..5fb404767 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: 18280 $ + * Revision $Revision: 18309 $ * */ package net.sourceforge.plantuml.graphic; @@ -40,9 +40,9 @@ import java.util.List; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.SpriteContainer; import net.sourceforge.plantuml.Url; -import net.sourceforge.plantuml.ugraphic.Sprite; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; +import net.sourceforge.plantuml.ugraphic.sprite.Sprite; class SingleLine extends AbstractTextBlock implements Line { diff --git a/src/net/sourceforge/plantuml/graphic/Splitter.java b/src/net/sourceforge/plantuml/graphic/Splitter.java index 9ee2b7302..6d50e9d3e 100644 --- a/src/net/sourceforge/plantuml/graphic/Splitter.java +++ b/src/net/sourceforge/plantuml/graphic/Splitter.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18317 $ * */ package net.sourceforge.plantuml.graphic; @@ -41,8 +41,9 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import net.sourceforge.plantuml.command.regex.MyPattern; import net.sourceforge.plantuml.StringUtils; +import net.sourceforge.plantuml.command.regex.MyPattern; +import net.sourceforge.plantuml.ugraphic.sprite.SpriteUtils; public class Splitter { @@ -58,8 +59,8 @@ public class Splitter { public static final String fontFamilyPattern = "\\]+)/?\\>"; public static final String svgAttributePattern = "\\]+)/?\\>"; public static final String openiconPattern = "\\<&([-\\w]+)\\>"; - public static final String spritePattern = "\\<\\$[\\p{L}0-9_]+\\>"; - public static final String spritePattern2 = "\\<\\$([\\p{L}0-9_]+)\\>"; + public static final String spritePattern = "\\<\\$" + SpriteUtils.SPRITE_NAME + "\\>"; + public static final String spritePattern2 = "\\<\\$(" + SpriteUtils.SPRITE_NAME + ")\\>"; static final String htmlTag; static final String linkPattern = "\\[\\[([^\\[\\]]+)\\]\\]"; diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockRecentred.java b/src/net/sourceforge/plantuml/graphic/TextBlockRecentred.java index 3ac1461ed..2d43e54e6 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockRecentred.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockRecentred.java @@ -35,11 +35,12 @@ package net.sourceforge.plantuml.graphic; import java.awt.geom.Dimension2D; +import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class TextBlockRecentred extends AbstractTextBlock implements TextBlock { +public class TextBlockRecentred extends AbstractTextBlock implements TextBlockBackcolored { private final TextBlock textBlock; @@ -57,4 +58,8 @@ public class TextBlockRecentred extends AbstractTextBlock implements TextBlock { return minMax.getDimension(); } + public HtmlColor getBackcolor() { + return ((TextBlockBackcolored) textBlock).getBackcolor(); + } + } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/posimo/DotPath.java b/src/net/sourceforge/plantuml/posimo/DotPath.java index dbdff95a4..c4484e0f1 100644 --- a/src/net/sourceforge/plantuml/posimo/DotPath.java +++ b/src/net/sourceforge/plantuml/posimo/DotPath.java @@ -543,60 +543,21 @@ public class DotPath implements UShape, Moveable { if (tail != null) { // System.err.println("beziers1=" + this.toString()); final ClusterPosition clusterPosition = tail.getClusterPosition(); - if (clusterPosition.contains(getStartPoint()) == false) { - throw new IllegalStateException(); - } - final DotPath result = new DotPath(); - int idx = 0; - while (idx + 1 < this.beziers.size() && clusterPosition.contains(this.beziers.get(idx).getP2())) { - if (clusterPosition.contains(this.beziers.get(idx).getP1()) == false) { - throw new IllegalStateException(); - } - idx++; - } - if (clusterPosition.contains(this.beziers.get(idx).getP2())) { - // System.err.println("strange1"); - } else { - assert clusterPosition.contains(this.beziers.get(idx).getP1()); - assert clusterPosition.contains(this.beziers.get(idx).getP2()) == false; - CubicCurve2D current = this.beziers.get(idx); - for (int k = 0; k < 8; k++) { - // System.err.println("length=" + length(current)); - final CubicCurve2D.Double part1 = new CubicCurve2D.Double(); - final CubicCurve2D.Double part2 = new CubicCurve2D.Double(); - current.subdivide(part1, part2); - assert part1.getP2().equals(part2.getP1()); - if (clusterPosition.contains(part1.getP2())) { - current = part2; - } else { - result.beziers.add(0, part2); - current = part1; + if (clusterPosition.contains(getStartPoint())) { + final DotPath result = new DotPath(); + int idx = 0; + while (idx + 1 < this.beziers.size() && clusterPosition.contains(this.beziers.get(idx).getP2())) { + if (clusterPosition.contains(this.beziers.get(idx).getP1()) == false) { + throw new IllegalStateException(); } + idx++; } - for (int i = idx + 1; i < this.beziers.size(); i++) { - result.beziers.add(this.beziers.get(i)); - } - me = result; - } - } - if (head != null) { - // System.err.println("beziers2=" + me.toString()); - final DotPath result = new DotPath(); - final ClusterPosition clusterPosition = head.getClusterPosition(); - if (clusterPosition.contains(getEndPoint()) == false) { - // System.err.println("strange3"); - return me; - } - for (CubicCurve2D.Double current : me.beziers) { - if (clusterPosition.contains(current.getP2()) == false) { - result.beziers.add(current); + if (clusterPosition.contains(this.beziers.get(idx).getP2())) { + // System.err.println("strange1"); } else { - if (clusterPosition.contains(current.getP1())) { - // System.err.println("strange2"); - return me; - } - assert clusterPosition.contains(current.getP1()) == false; - assert clusterPosition.contains(current.getP2()); + assert clusterPosition.contains(this.beziers.get(idx).getP1()); + assert clusterPosition.contains(this.beziers.get(idx).getP2()) == false; + CubicCurve2D current = this.beziers.get(idx); for (int k = 0; k < 8; k++) { // System.err.println("length=" + length(current)); final CubicCurve2D.Double part1 = new CubicCurve2D.Double(); @@ -604,15 +565,51 @@ public class DotPath implements UShape, Moveable { current.subdivide(part1, part2); assert part1.getP2().equals(part2.getP1()); if (clusterPosition.contains(part1.getP2())) { - current = part1; - } else { - result.beziers.add(part1); current = part2; - // System.err.println("k=" + k + " result=" + result.toString()); + } else { + result.beziers.add(0, part2); + current = part1; } } - // System.err.println("Final Result=" + result.toString()); - return result; + for (int i = idx + 1; i < this.beziers.size(); i++) { + result.beziers.add(this.beziers.get(i)); + } + me = result; + } + } + } + if (head != null) { + // System.err.println("beziers2=" + me.toString()); + final DotPath result = new DotPath(); + final ClusterPosition clusterPosition = head.getClusterPosition(); + if (clusterPosition.contains(getEndPoint())) { + for (CubicCurve2D.Double current : me.beziers) { + if (clusterPosition.contains(current.getP2()) == false) { + result.beziers.add(current); + } else { + if (clusterPosition.contains(current.getP1())) { + // System.err.println("strange2"); + return me; + } + assert clusterPosition.contains(current.getP1()) == false; + assert clusterPosition.contains(current.getP2()); + for (int k = 0; k < 8; k++) { + // System.err.println("length=" + length(current)); + final CubicCurve2D.Double part1 = new CubicCurve2D.Double(); + final CubicCurve2D.Double part2 = new CubicCurve2D.Double(); + current.subdivide(part1, part2); + assert part1.getP2().equals(part2.getP1()); + if (clusterPosition.contains(part1.getP2())) { + current = part1; + } else { + result.beziers.add(part1); + current = part2; + // System.err.println("k=" + k + " result=" + result.toString()); + } + } + // System.err.println("Final Result=" + result.toString()); + return result; + } } } diff --git a/src/net/sourceforge/plantuml/salt/Dictionary.java b/src/net/sourceforge/plantuml/salt/Dictionary.java index ed226e31c..0fa73b366 100644 --- a/src/net/sourceforge/plantuml/salt/Dictionary.java +++ b/src/net/sourceforge/plantuml/salt/Dictionary.java @@ -39,9 +39,11 @@ import java.util.Map; import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.SpriteContainer; import net.sourceforge.plantuml.creole.CommandCreoleMonospaced; +import net.sourceforge.plantuml.graphic.HtmlColorSetSimple; +import net.sourceforge.plantuml.graphic.IHtmlColorSet; import net.sourceforge.plantuml.salt.element.Element; import net.sourceforge.plantuml.salt.element.WrappedElement; -import net.sourceforge.plantuml.ugraphic.Sprite; +import net.sourceforge.plantuml.ugraphic.sprite.Sprite; public class Dictionary implements SpriteContainer, ISkinSimple { @@ -83,4 +85,8 @@ public class Dictionary implements SpriteContainer, ISkinSimple { return 8; } + public IHtmlColorSet getIHtmlColorSet() { + return new HtmlColorSetSimple(); + } + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java index 548b1006f..a7d047abf 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java +++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java @@ -54,6 +54,7 @@ import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescriptionImpl; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.SymbolContext; import net.sourceforge.plantuml.sequencediagram.graphic.FileMaker; @@ -473,7 +474,7 @@ public class SequenceDiagram extends UmlDiagram { return true; } } - if (Display.isNull(getLegend()) == false && getLegend().hasUrl()) { + if (DisplayPositionned.isNull(getLegend()) == false && getLegend().hasUrl()) { return true; } return false; diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramArea.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramArea.java index b73418d54..70abe0085 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramArea.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramArea.java @@ -28,12 +28,17 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 18280 $ + * Revision $Revision: 18806 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; +import java.awt.geom.Dimension2D; + import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.png.PngTitler; +import net.sourceforge.plantuml.utils.MathUtils; public class SequenceDiagramArea { @@ -47,6 +52,9 @@ public class SequenceDiagramArea { private double titleWidth; private double titleHeight; + private double captionWidth; + private double captionHeight; + private double footerWidth; private double footerHeight; private double footerMargin; @@ -56,9 +64,18 @@ public class SequenceDiagramArea { this.sequenceHeight = height; } - public void setTitleArea(double titleWidth, double titleHeight) { - this.titleWidth = titleWidth; - this.titleHeight = titleHeight; + public void setTitleArea(double width, double height) { + this.titleWidth = width; + this.titleHeight = height; + } + + private void setCaptionArea(double width, double height) { + this.captionWidth = width; + this.captionHeight = height; + } + + public void setCaptionArea(Dimension2D dim) { + setCaptionArea(dim.getWidth(), dim.getHeight()); } public void setHeaderArea(double headerWidth, double headerHeight, double headerMargin) { @@ -74,21 +91,11 @@ public class SequenceDiagramArea { } public double getWidth() { - double result = sequenceWidth; - if (headerWidth > result) { - result = headerWidth; - } - if (titleWidth > result) { - result = titleWidth; - } - if (footerWidth > result) { - result = footerWidth; - } - return result; + return MathUtils.max(sequenceWidth, headerWidth, titleWidth, footerWidth, captionWidth); } public double getHeight() { - return sequenceHeight + headerHeight + headerMargin + titleHeight + footerMargin + footerHeight; + return sequenceHeight + headerHeight + headerMargin + titleHeight + footerMargin + footerHeight + captionHeight; } public double getTitleX() { @@ -99,6 +106,14 @@ public class SequenceDiagramArea { return headerHeight + headerMargin; } + public double getCaptionX() { + return (getWidth() - captionWidth) / 2; + } + + public double getCaptionY() { + return sequenceHeight + headerHeight + headerMargin + titleHeight; + } + public double getSequenceAreaX() { return (getWidth() - sequenceWidth) / 2; } @@ -112,7 +127,7 @@ public class SequenceDiagramArea { } public double getFooterY() { - return sequenceHeight + headerHeight + headerMargin + titleHeight + footerMargin; + return sequenceHeight + headerHeight + headerMargin + titleHeight + footerMargin + captionHeight; } public double getFooterX(HorizontalAlignment align) { @@ -141,4 +156,18 @@ public class SequenceDiagramArea { throw new IllegalStateException(); } + public void initFooter(PngTitler pngTitler) { + final Dimension2D dim = pngTitler.getTextDimension(TextBlockUtils.getDummyStringBounder()); + if (dim != null) { + setFooterArea(dim.getWidth(), dim.getHeight(), 3); + } + } + + public void initHeader(PngTitler pngTitler) { + final Dimension2D dim = pngTitler.getTextDimension(TextBlockUtils.getDummyStringBounder()); + if (dim != null) { + setHeaderArea(dim.getWidth(), dim.getHeight(), 3); + } + } + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java index 1a262d5ab..7fef13898 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java @@ -41,12 +41,14 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import net.sourceforge.plantuml.AnnotatedWorker; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.StringBounder; @@ -117,7 +119,8 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker { for (Newpage n : newpages) { positions.put(n, initializer.getYposition(dummyStringBounder, n)); } - pages = create(drawableSet, positions, sequenceDiagram.isShowFootbox(), sequenceDiagram.getTitle()).getPages(); + pages = create(drawableSet, positions, sequenceDiagram.isShowFootbox(), sequenceDiagram.getTitle().getDisplay()) + .getPages(); } public int getNbPages() { @@ -144,6 +147,9 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker { final SequenceDiagramArea area = new SequenceDiagramArea(fullDimension.getWidth(), page.getHeight()); final Component compTitle; + final TextBlock caption = new AnnotatedWorker(diagram, diagram.getSkinParam()).getCaption(); + area.setCaptionArea(caption.calculateDimension(dummyStringBounder)); + if (Display.isNull(page.getTitle())) { compTitle = null; } else { @@ -152,17 +158,15 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker { area.setTitleArea(compTitle.getPreferredWidth(dummyStringBounder), compTitle.getPreferredHeight(dummyStringBounder)); } - addFooter2(area); - addHeader2(area); + area.initFooter(getPngTitler(FontParam.FOOTER)); + area.initHeader(getPngTitler(FontParam.HEADER)); - // final FileFormat fileFormat = fileFormatOption.getFileFormat(); - - final Display legend = diagram.getLegend(); + final DisplayPositionned legend = diagram.getLegend(); final TextBlock legendBlock; - if (Display.isNull(legend)) { + if (DisplayPositionned.isNull(legend)) { legendBlock = TextBlockUtils.empty(0, 0); } else { - legendBlock = EntityImageLegend.create(legend, diagram.getSkinParam()); + legendBlock = EntityImageLegend.create(legend.getDisplay(), diagram.getSkinParam()); } final Dimension2D dimLegend = TextBlockUtils.getDimension(legendBlock); @@ -198,11 +202,12 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker { compTitle.drawU(ug.apply(new UTranslate(area.getTitleX(), area.getTitleY())), new Area( new Dimension2DDouble(w, h)), new SimpleContext2D(false)); } + caption.drawU(ug.apply(new UTranslate(area.getCaptionX(), area.getCaptionY()))); final double delta1 = Math.max(0, dimLegend.getWidth() - area.getWidth()); - final boolean legendTop = Display.isNull(legend) == false - && diagram.getLegendVerticalAlignment() == VerticalAlignment.TOP; + final boolean legendTop = DisplayPositionned.isNull(legend) == false + && legend.getVerticalAlignment() == VerticalAlignment.TOP; double sequenceAreaY = area.getSequenceAreaY(); if (legendTop) { @@ -211,14 +216,14 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker { drawableSet.drawU22(ug.apply(new UTranslate(area.getSequenceAreaX() + delta1 / 2, sequenceAreaY)), delta, fullDimension.getWidth(), page, diagram.isShowFootbox()); - addHeader3(area, ug); - addFooter3(area, ug); + drawHeader(area, ug); + drawFooter(area, ug); - if (Display.isNull(legend) == false) { + if (DisplayPositionned.isNull(legend) == false) { final double delta2; - if (diagram.getLegendAlignment() == HorizontalAlignment.LEFT) { + if (legend.getHorizontalAlignment() == HorizontalAlignment.LEFT) { delta2 = 0; - } else if (diagram.getLegendAlignment() == HorizontalAlignment.RIGHT) { + } else if (legend.getHorizontalAlignment() == HorizontalAlignment.RIGHT) { delta2 = Math.max(0, area.getWidth() - dimLegend.getWidth()); } else { delta2 = Math.max(0, area.getWidth() - dimLegend.getWidth()) / 2; @@ -232,6 +237,26 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker { return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os); } + private void drawFooter(SequenceDiagramArea area, UGraphic ug) { + final PngTitler pngTitler = getPngTitler(FontParam.FOOTER); + final TextBlock text = pngTitler.getTextBlock(); + if (text == null) { + return; + } + text.drawU(ug.apply(new UTranslate(area.getFooterX(diagram.getFooter().getHorizontalAlignment()), area + .getFooterY()))); + } + + private void drawHeader(SequenceDiagramArea area, UGraphic ug) { + final PngTitler pngTitler = getPngTitler(FontParam.HEADER); + final TextBlock text = pngTitler.getTextBlock(); + if (text == null) { + return; + } + text.drawU(ug.apply(new UTranslate(area.getHeaderX(diagram.getHeader().getHorizontalAlignment()), area + .getHeaderY()))); + } + private double oneOf(double a, double b) { if (a == 1) { return b; @@ -259,58 +284,14 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker { return diagram.getScale().getScale(width, height); } - private void addFooter2(SequenceDiagramArea area) { + private PngTitler getPngTitler(final FontParam fontParam) { final HtmlColor hyperlinkColor = diagram.getSkinParam().getHyperlinkColor(); - final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(null, FontParam.FOOTER); - final String fontFamily = diagram.getSkinParam().getFont(null, false, FontParam.FOOTER).getFamily(null); - final int fontSize = diagram.getSkinParam().getFont(null, false, FontParam.FOOTER).getSize(); - final PngTitler pngTitler = new PngTitler(titleColor, diagram.getFooter(), fontSize, fontFamily, - diagram.getFooterAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink()); - final Dimension2D dim = pngTitler.getTextDimension(dummyStringBounder); - if (dim != null) { - area.setFooterArea(dim.getWidth(), dim.getHeight(), 3); - } - } - - private void addHeader2(SequenceDiagramArea area) { - final HtmlColor hyperlinkColor = diagram.getSkinParam().getHyperlinkColor(); - final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(null, FontParam.HEADER); - final String fontFamily = diagram.getSkinParam().getFont(null, false, FontParam.HEADER).getFamily(null); - final int fontSize = diagram.getSkinParam().getFont(null, false, FontParam.HEADER).getSize(); - final PngTitler pngTitler = new PngTitler(titleColor, diagram.getHeader(), fontSize, fontFamily, - diagram.getHeaderAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink()); - final Dimension2D dim = pngTitler.getTextDimension(dummyStringBounder); - if (dim != null) { - area.setHeaderArea(dim.getWidth(), dim.getHeight(), 3); - } - } - - private void addFooter3(SequenceDiagramArea area, UGraphic ug) { - final HtmlColor hyperlinkColor = diagram.getSkinParam().getHyperlinkColor(); - final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(null, FontParam.FOOTER); - final String fontFamily = diagram.getSkinParam().getFont(null, false, FontParam.FOOTER).getFamily(null); - final int fontSize = diagram.getSkinParam().getFont(null, false, FontParam.FOOTER).getSize(); - final PngTitler pngTitler = new PngTitler(titleColor, diagram.getFooter(), fontSize, fontFamily, - diagram.getFooterAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink()); - final TextBlock text = pngTitler.getTextBlock(); - if (text == null) { - return; - } - text.drawU(ug.apply(new UTranslate(area.getFooterX(diagram.getFooterAlignment()), area.getFooterY()))); - } - - private void addHeader3(SequenceDiagramArea area, UGraphic ug) { - final HtmlColor hyperlinkColor = diagram.getSkinParam().getHyperlinkColor(); - final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(null, FontParam.HEADER); - final String fontFamily = diagram.getSkinParam().getFont(null, false, FontParam.HEADER).getFamily(null); - final int fontSize = diagram.getSkinParam().getFont(null, false, FontParam.HEADER).getSize(); - final PngTitler pngTitler = new PngTitler(titleColor, diagram.getHeader(), fontSize, fontFamily, - diagram.getHeaderAlignment(), hyperlinkColor, diagram.getSkinParam().useUnderlineForHyperlink()); - final TextBlock text = pngTitler.getTextBlock(); - if (text == null) { - return; - } - text.drawU(ug.apply(new UTranslate(area.getHeaderX(diagram.getHeaderAlignment()), area.getHeaderY()))); + final HtmlColor titleColor = diagram.getSkinParam().getFontHtmlColor(null, fontParam); + final String fontFamily = diagram.getSkinParam().getFont(null, false, fontParam).getFamily(null); + final int fontSize = diagram.getSkinParam().getFont(null, false, fontParam).getSize(); + return new PngTitler(titleColor, diagram.getFooterOrHeaderTeoz(fontParam).getDisplay(), fontSize, fontFamily, + diagram.getFooterOrHeaderTeoz(fontParam).getHorizontalAlignment(), hyperlinkColor, diagram + .getSkinParam().useUnderlineForHyperlink()); } } diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java index eb22e36f6..9c0776c71 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java @@ -41,11 +41,11 @@ import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.Scale; import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; import net.sourceforge.plantuml.api.ImageDataSimple; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.StringBounder; @@ -131,14 +131,14 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { englobers.drawEnglobers(goDownForEnglobers(ug), main.calculateDimension(stringBounder).getHeight() + this.heightEnglober1 + this.heightEnglober2 / 2, new SimpleContext2D(true)); - printAligned(ug, diagram.getAlignmentTeoz(FontParam.HEADER), header); + printAligned(ug, diagram.getFooterOrHeaderTeoz(FontParam.HEADER).getHorizontalAlignment(), header); ug = goDown(ug, header); printAligned(ug, HorizontalAlignment.CENTER, title); ug = goDown(ug, title); - if (diagram.getLegendVerticalAlignment() == VerticalAlignment.TOP) { - printAligned(ug, diagram.getLegendAlignment(), legend); + if (diagram.getLegend().getVerticalAlignment() == VerticalAlignment.TOP) { + printAligned(ug, diagram.getLegend().getHorizontalAlignment(), legend); ug = goDown(ug, legend); } @@ -147,12 +147,12 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { ug = goDown(ug, main); ug = ug.apply(new UTranslate(0, this.heightEnglober2)); - if (diagram.getLegendVerticalAlignment() == VerticalAlignment.BOTTOM) { - printAligned(ug, diagram.getLegendAlignment(), legend); + if (diagram.getLegend().getVerticalAlignment() == VerticalAlignment.BOTTOM) { + printAligned(ug, diagram.getLegend().getHorizontalAlignment(), legend); ug = goDown(ug, legend); } - printAligned(ug, diagram.getAlignmentTeoz(FontParam.FOOTER), footer); + printAligned(ug, diagram.getFooterOrHeaderTeoz(FontParam.FOOTER).getHorizontalAlignment(), footer); ug2.writeImageTOBEMOVED(os, isWithMetadata ? diagram.getMetadata() : null, diagram.getDpi(fileFormatOption)); @@ -162,7 +162,7 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { private UGraphic goDownForEnglobers(UGraphic ug) { ug = goDown(ug, title); ug = goDown(ug, header); - if (diagram.getLegendVerticalAlignment() == VerticalAlignment.TOP) { + if (diagram.getLegend().getVerticalAlignment() == VerticalAlignment.TOP) { ug = goDown(ug, legend); } return ug; @@ -210,16 +210,16 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { } private TextBlock getTitle() { - final Display title = diagram.getTitle(); - if (Display.isNull(title)) { + if (DisplayPositionned.isNull(diagram.getTitle())) { return new ComponentAdapter(null); } - final Component compTitle = skin.createComponent(ComponentType.TITLE, null, getSkinParam(), title); + final Component compTitle = skin.createComponent(ComponentType.TITLE, null, getSkinParam(), diagram.getTitle() + .getDisplay()); return new ComponentAdapter(compTitle); } private TextBlock getLegend() { - final Display legend = diagram.getLegend(); + final Display legend = diagram.getLegend().getDisplay(); if (Display.isNull(legend)) { return TextBlockUtils.empty(0, 0); } @@ -227,16 +227,17 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { } public TextBlock getFooterOrHeader(final FontParam param) { - final Display display = diagram.getFooterOrHeaderTeoz(param); - if (Display.isNull(display)) { + if (DisplayPositionned.isNull(diagram.getFooterOrHeaderTeoz(param))) { return new TeozLayer(null, stringBounder, param); } + final Display display = diagram.getFooterOrHeaderTeoz(param).getDisplay(); final HtmlColor hyperlinkColor = getSkinParam().getHyperlinkColor(); final HtmlColor titleColor = getSkinParam().getFontHtmlColor(null, param); final String fontFamily = getSkinParam().getFont(null, false, param).getFamily(null); final int fontSize = getSkinParam().getFont(null, false, param).getSize(); - final PngTitler pngTitler = new PngTitler(titleColor, display, fontSize, fontFamily, - diagram.getAlignmentTeoz(param), hyperlinkColor, getSkinParam().useUnderlineForHyperlink()); + final PngTitler pngTitler = new PngTitler(titleColor, display, fontSize, fontFamily, diagram + .getFooterOrHeaderTeoz(param).getHorizontalAlignment(), hyperlinkColor, getSkinParam() + .useUnderlineForHyperlink()); return new TeozLayer(pngTitler, stringBounder, param); } diff --git a/src/net/sourceforge/plantuml/statediagram/command/CommandLinkState.java b/src/net/sourceforge/plantuml/statediagram/command/CommandLinkState.java index 44eaf9f63..34314ec3c 100644 --- a/src/net/sourceforge/plantuml/statediagram/command/CommandLinkState.java +++ b/src/net/sourceforge/plantuml/statediagram/command/CommandLinkState.java @@ -77,7 +77,7 @@ public class CommandLinkState extends SingleLineCommand2 { new RegexLeaf("[%s]*"), // getStatePattern("ENT2"), // new RegexLeaf("[%s]*"), // - new RegexLeaf("LABEL", "(?::[%s]*([^%g]+))?"), // + new RegexLeaf("LABEL", "(?::[%s]*(.+))?"), // new RegexLeaf("$")); } diff --git a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java index 1ef3ee3ef..9b3f266b6 100644 --- a/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java +++ b/src/net/sourceforge/plantuml/svek/CucaDiagramFileMakerSvek.java @@ -40,29 +40,23 @@ import java.io.OutputStream; import java.util.ArrayList; import java.util.List; +import net.sourceforge.plantuml.AnnotatedWorker; import net.sourceforge.plantuml.EmptyImageBuilder; -import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.Scale; import net.sourceforge.plantuml.UmlDiagramType; -import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.cucadiagram.CucaDiagram; -import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Link; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramSimplifierActivity; import net.sourceforge.plantuml.cucadiagram.dot.CucaDiagramSimplifierState; import net.sourceforge.plantuml.cucadiagram.dot.DotData; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounderUtils; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.UFont; @@ -116,9 +110,7 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker { svek2 = buildCucaDiagramFileMakerSvek2(DotMode.NO_LEFT_RIGHT); result = svek2.createFile(diagram.getDotStringSkek()); } - result = addLegend(result); - result = addTitle(result); - result = addHeaderAndFooter(result); + result = new AnnotatedWorker(diagram, diagram.getSkinParam()).addAdd(result); final String widthwarning = diagram.getSkinParam().getValue("widthwarning"); if (widthwarning != null && widthwarning.matches("\\d+")) { @@ -169,45 +161,6 @@ public final class CucaDiagramFileMakerSvek implements CucaDiagramFileMaker { return warningOrError; } - private TextBlockBackcolored addHeaderAndFooter(TextBlockBackcolored original) { - final Display footer = diagram.getFooter(); - final Display header = diagram.getHeader(); - if (Display.isNull(footer) && Display.isNull(header)) { - return original; - } - final TextBlock textFooter = Display.isNull(footer) ? null : footer.create( - new FontConfiguration(diagram.getSkinParam(), FontParam.FOOTER, null), diagram.getFooterAlignment(), - diagram.getSkinParam()); - final TextBlock textHeader = Display.isNull(header) ? null : header.create( - new FontConfiguration(diagram.getSkinParam(), FontParam.HEADER, null), diagram.getHeaderAlignment(), - diagram.getSkinParam()); - - return new DecorateEntityImage(original, textHeader, diagram.getHeaderAlignment(), textFooter, - diagram.getFooterAlignment()); - } - - private TextBlockBackcolored addTitle(TextBlockBackcolored original) { - final Display title = diagram.getTitle(); - if (Display.isNull(title)) { - return original; - } - final TextBlock text = title.create(new FontConfiguration(diagram.getSkinParam(), FontParam.TITLE, null), - HorizontalAlignment.CENTER, diagram.getSkinParam()); - - return DecorateEntityImage.addTop(original, text, HorizontalAlignment.CENTER); - } - - private TextBlockBackcolored addLegend(TextBlockBackcolored original) { - final Display legend = diagram.getLegend(); - if (Display.isNull(legend)) { - return original; - } - final TextBlock text = EntityImageLegend.create(legend, diagram.getSkinParam()); - - return DecorateEntityImage.add(original, text, diagram.getLegendAlignment(), - diagram.getLegendVerticalAlignment()); - } - private final UFont getFont(FontParam fontParam) { final ISkinParam skinParam = diagram.getSkinParam(); return skinParam.getFont(null, false, fontParam); diff --git a/src/net/sourceforge/plantuml/svek/DecorateTextBlock.java b/src/net/sourceforge/plantuml/svek/DecorateTextBlock.java deleted file mode 100644 index 2115a1278..000000000 --- a/src/net/sourceforge/plantuml/svek/DecorateTextBlock.java +++ /dev/null @@ -1,136 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2017, 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 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: 4236 $ - * - */ -package net.sourceforge.plantuml.svek; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.graphic.AbstractTextBlock; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class DecorateTextBlock extends AbstractTextBlock implements TextBlock { - - private final TextBlock original; - private final HorizontalAlignment horizontal1; - private final TextBlock text1; - private final HorizontalAlignment horizontal2; - private final TextBlock text2; - - private double deltaX; - private double deltaY; - - public DecorateTextBlock(TextBlock original, TextBlock text, HorizontalAlignment horizontal) { - this(original, text, horizontal, null, null); - } - - public DecorateTextBlock(TextBlock original, TextBlock text1, HorizontalAlignment horizontal1, TextBlock text2, - HorizontalAlignment horizontal2) { - this.original = original; - this.horizontal1 = horizontal1; - this.text1 = text1; - this.horizontal2 = horizontal2; - this.text2 = text2; - } - - public void drawU(UGraphic ug) { - final StringBounder stringBounder = ug.getStringBounder(); - final Dimension2D dimOriginal = original.calculateDimension(stringBounder); - final Dimension2D dimText1 = getTextDim(text1, stringBounder); - final Dimension2D dimText2 = getTextDim(text2, stringBounder); - final Dimension2D dimTotal = calculateDimension(stringBounder); - - final double yText1 = 0; - final double yImage = yText1 + dimText1.getHeight(); - final double yText2 = yImage + dimOriginal.getHeight(); - - final double xImage = (dimTotal.getWidth() - dimOriginal.getWidth()) / 2; - - if (text1 != null) { - final double xText1 = getTextX(dimText1, dimTotal, horizontal1); - text1.drawU(ug.apply(new UTranslate(xText1, yText1))); - } - original.drawU(ug.apply(new UTranslate(xImage, yImage))); - deltaX = xImage; - deltaY = yImage; - if (text2 != null) { - final double xText2 = getTextX(dimText2, dimTotal, horizontal2); - text2.drawU(ug.apply(new UTranslate(xText2, yText2))); - } - } - - private Dimension2D getTextDim(TextBlock text, StringBounder stringBounder) { - if (text == null) { - return new Dimension2DDouble(0, 0); - } - return text.calculateDimension(stringBounder); - } - - private double getTextX(final Dimension2D dimText, final Dimension2D dimTotal, HorizontalAlignment h) { - if (h == HorizontalAlignment.CENTER) { - return (dimTotal.getWidth() - dimText.getWidth()) / 2; - } else if (h == HorizontalAlignment.LEFT) { - return 0; - } else if (h == HorizontalAlignment.RIGHT) { - return dimTotal.getWidth() - dimText.getWidth(); - } else { - throw new IllegalStateException(); - } - } - - public Dimension2D calculateDimension(StringBounder stringBounder) { - final Dimension2D dimOriginal = original.calculateDimension(stringBounder); - final Dimension2D dimText = Dimension2DDouble.mergeTB(getTextDim(text1, stringBounder), - getTextDim(text2, stringBounder)); - return Dimension2DDouble.mergeTB(dimOriginal, dimText); - } - - private double getDeltaX() { - if (original instanceof DecorateTextBlock) { - return deltaX + ((DecorateTextBlock) original).deltaX; - } - return deltaX; - } - - private double getDeltaY() { - if (original instanceof DecorateTextBlock) { - return deltaY + ((DecorateTextBlock) original).deltaY; - } - return deltaY; - } - -} \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/svek/DotStringFactory.java b/src/net/sourceforge/plantuml/svek/DotStringFactory.java index e0851fb77..d954bd2eb 100644 --- a/src/net/sourceforge/plantuml/svek/DotStringFactory.java +++ b/src/net/sourceforge/plantuml/svek/DotStringFactory.java @@ -50,6 +50,7 @@ import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.cucadiagram.IGroup; import net.sourceforge.plantuml.cucadiagram.Rankdir; import net.sourceforge.plantuml.cucadiagram.dot.DotData; +import net.sourceforge.plantuml.cucadiagram.dot.DotSplines; import net.sourceforge.plantuml.cucadiagram.dot.Graphviz; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils; import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion; @@ -165,7 +166,16 @@ public class DotStringFactory implements Moveable { sb.append("compound=true;"); SvekUtils.println(sb); } - + + final DotSplines dotSplines = dotData.getSkinParam().getDotSplines(); + if (dotSplines == DotSplines.POLYLINE) { + sb.append("splines=polyline;"); + SvekUtils.println(sb); + } else if (dotSplines == DotSplines.ORTHO) { + sb.append("splines=ortho;"); + SvekUtils.println(sb); + } + if (dotData.getSkinParam().getRankdir() == Rankdir.LEFT_TO_RIGHT) { sb.append("rankdir=LR;"); SvekUtils.println(sb); diff --git a/src/net/sourceforge/plantuml/svek/Line.java b/src/net/sourceforge/plantuml/svek/Line.java index de60af082..a3f2ca252 100644 --- a/src/net/sourceforge/plantuml/svek/Line.java +++ b/src/net/sourceforge/plantuml/svek/Line.java @@ -85,7 +85,6 @@ import net.sourceforge.plantuml.ugraphic.UPolygon; import net.sourceforge.plantuml.ugraphic.UShape; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; -import net.sourceforge.plantuml.utils.MathUtils; public class Line implements Moveable, Hideable { @@ -323,7 +322,7 @@ public class Line implements Moveable, Hideable { sb.append(endUid); // } sb.append("["); - final LinkType linkType = link.getType(); + final LinkType linkType = link.getTypePatchCluster(); String decoration = linkType.getSpecificDecorationSvek(); if (decoration.endsWith(",") == false) { decoration += ","; @@ -435,7 +434,7 @@ public class Line implements Moveable, Hideable { } private UDrawable getExtremity(LinkHat hat, LinkDecor decor, PointListIterator pointListIterator, Point2D center, - double angle, Cluster cluster) { + double angle, Cluster cluster, boolean isGroup) { final ExtremityFactory extremityFactory = decor.getExtremityFactory(); if (OptionFlags.USE_COMPOUND == false && cluster != null) { @@ -480,6 +479,7 @@ public class Line implements Moveable, Hideable { } final int end = svg.indexOf("\"", idx + 3); final String path = svg.substring(idx + 3, end); + dotPath = new DotPath(path, fullHeight); if (OptionFlags.USE_COMPOUND == false) { if (projectionCluster != null) { @@ -498,9 +498,9 @@ public class Line implements Moveable, Hideable { final LinkType linkType = link.getType(); this.extremity2 = getExtremity(linkType.getHat2(), linkType.getDecor2(), pointListIterator, - dotPath.getStartPoint(), dotPath.getStartAngle() + Math.PI, ltail); + dotPath.getStartPoint(), dotPath.getStartAngle() + Math.PI, ltail, link.getEntity1().isGroup()); this.extremity1 = getExtremity(linkType.getHat1(), linkType.getDecor1(), pointListIterator, - dotPath.getEndPoint(), dotPath.getEndAngle(), lhead); + dotPath.getEndPoint(), dotPath.getEndAngle(), lhead, link.getEntity2().isGroup()); if (this.labelText != null) { final Point2D pos = getXY(svg, this.noteLabelColor, fullHeight); diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityDiamond.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityDiamond.java index f45ed9939..ff2682919 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityDiamond.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityDiamond.java @@ -35,6 +35,7 @@ package net.sourceforge.plantuml.svek.extremity; import java.awt.geom.Point2D; +import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.ugraphic.UChangeBackColor; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UPolygon; @@ -61,6 +62,8 @@ class ExtremityDiamond extends Extremity { public void drawU(UGraphic ug) { if (fill) { ug = ug.apply(new UChangeBackColor(ug.getParam().getColor())); + } else { + ug = ug.apply(new UChangeBackColor(HtmlColorUtils.WHITE)); } ug.draw(polygon); } diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryDiamond.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryDiamond.java index 3bd1613ea..897f6f8d2 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryDiamond.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryDiamond.java @@ -42,9 +42,15 @@ public class ExtremityFactoryDiamond extends AbstractExtremityFactory implements private final boolean fill; + @Override + public UDrawable createUDrawable(Point2D p0, double angle) { + return new ExtremityDiamond(p0, angle - Math.PI / 2, fill); + } + public ExtremityFactoryDiamond(boolean fill) { this.fill = fill; } + public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) { final double ortho = atan2(p0, p2); return new ExtremityDiamond(p1, ortho, fill); diff --git a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryPlus.java b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryPlus.java index 1b5af1eec..98d22b870 100644 --- a/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryPlus.java +++ b/src/net/sourceforge/plantuml/svek/extremity/ExtremityFactoryPlus.java @@ -40,8 +40,9 @@ import net.sourceforge.plantuml.svek.AbstractExtremityFactory; public class ExtremityFactoryPlus extends AbstractExtremityFactory implements ExtremityFactory { + @Override public UDrawable createUDrawable(Point2D center, double angle) { - return ExtremityPlus.create(center, angle + Math.PI / 2); + return ExtremityPlus.create(center, angle - Math.PI / 2); } public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) { diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java b/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java index ed37b2cab..eaa2a58c7 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageTips.java @@ -138,6 +138,9 @@ public class EntityImageTips extends AbstractEntityImage { } else { x += 4; } + if (memberPosition == null) { + return; + } final double y = positionOther.getY() - positionMe.getY() - height + memberPosition.getCenterY(); final Point2D pp2 = new Point2D.Double(x, y); opale.setOpale(position.reverseDirection(), pp1, pp2); diff --git a/src/net/sourceforge/plantuml/swing/SpriteWindow.java b/src/net/sourceforge/plantuml/swing/SpriteWindow.java index 0c2515d47..37bbdad6e 100644 --- a/src/net/sourceforge/plantuml/swing/SpriteWindow.java +++ b/src/net/sourceforge/plantuml/swing/SpriteWindow.java @@ -51,8 +51,8 @@ import javax.swing.SwingUtilities; import javax.swing.Timer; import net.sourceforge.plantuml.Log; -import net.sourceforge.plantuml.ugraphic.SpriteGrayLevel; -import net.sourceforge.plantuml.ugraphic.SpriteUtils; +import net.sourceforge.plantuml.ugraphic.sprite.SpriteGrayLevel; +import net.sourceforge.plantuml.ugraphic.sprite.SpriteUtils; import net.sourceforge.plantuml.version.PSystemVersion; public class SpriteWindow extends JFrame { diff --git a/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java b/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java index 283ab8a54..8a26d75de 100644 --- a/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java +++ b/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java @@ -78,6 +78,7 @@ public class LanguageDescriptor { keyword.add("as"); keyword.add("also"); keyword.add("autonumber"); + keyword.add("caption"); keyword.add("title"); keyword.add("newpage"); keyword.add("box"); diff --git a/src/net/sourceforge/plantuml/ugraphic/sprite/PSystemListInternalSprites.java b/src/net/sourceforge/plantuml/ugraphic/sprite/PSystemListInternalSprites.java new file mode 100644 index 000000000..d5c6f1536 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/sprite/PSystemListInternalSprites.java @@ -0,0 +1,93 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, 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 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: 4041 $ + * + */ +package net.sourceforge.plantuml.ugraphic.sprite; + +import java.awt.Font; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import net.sourceforge.plantuml.AbstractPSystem; +import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.core.DiagramDescription; +import net.sourceforge.plantuml.core.DiagramDescriptionImpl; +import net.sourceforge.plantuml.core.ImageData; +import net.sourceforge.plantuml.graphic.GraphicStrings; +import net.sourceforge.plantuml.graphic.HtmlColorUtils; +import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; +import net.sourceforge.plantuml.ugraphic.ImageBuilder; +import net.sourceforge.plantuml.ugraphic.UAntiAliasing; +import net.sourceforge.plantuml.ugraphic.UFont; + +public class PSystemListInternalSprites extends AbstractPSystem { + + public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException { + final GraphicStrings result = getGraphicStrings(); + final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(), + getMetadata(), null, 0, 0, null, false); + imageBuilder.addUDrawable(result); + return imageBuilder.writeImageTOBEMOVED(fileFormat, os); + } + + private GraphicStrings getGraphicStrings() throws IOException { + final List lines = new ArrayList(); + lines.add("List Current Sprits"); + lines.add("Credit to"); + lines.add("http://www.archimatetool.com"); + lines.add(" "); + for (String folder : RessourcesUtils.getJarFile("sprites", true)) { + lines.add("" + folder + " :"); + lines.add(" "); + for (String png : RessourcesUtils.getJarFile("sprites/" + folder, false)) { + if (png.endsWith(".png")) { + final String spriteName = png.substring(0, png.length() - 4); + lines.add("<$archimate/" + spriteName + "> " + spriteName); + } + } + } + + final UFont font = new UFont("SansSerif", Font.PLAIN, 12); + final GraphicStrings graphicStrings = new GraphicStrings(lines, font, HtmlColorUtils.BLACK, + HtmlColorUtils.WHITE, UAntiAliasing.ANTI_ALIASING_ON); + graphicStrings.setMaxLine(35); + return graphicStrings; + } + + public DiagramDescription getDescription() { + return new DiagramDescriptionImpl("(Sprites)", getClass()); + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/sprite/PSystemListInternalSpritesFactory.java b/src/net/sourceforge/plantuml/ugraphic/sprite/PSystemListInternalSpritesFactory.java new file mode 100644 index 000000000..417fb2723 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/sprite/PSystemListInternalSpritesFactory.java @@ -0,0 +1,51 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, 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 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: 3830 $ + * + */ +package net.sourceforge.plantuml.ugraphic.sprite; + +import net.sourceforge.plantuml.AbstractPSystem; +import net.sourceforge.plantuml.StringUtils; +import net.sourceforge.plantuml.command.PSystemSingleLineFactory; + +public class PSystemListInternalSpritesFactory extends PSystemSingleLineFactory { + + @Override + protected AbstractPSystem executeLine(String line) { + final String lineLower = StringUtils.goLowerCase(line); + if (lineLower.startsWith("listsprite")) { + return new PSystemListInternalSprites(); + } + return null; + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/sprite/RessourcesUtils.java b/src/net/sourceforge/plantuml/ugraphic/sprite/RessourcesUtils.java new file mode 100644 index 000000000..4b657f708 --- /dev/null +++ b/src/net/sourceforge/plantuml/ugraphic/sprite/RessourcesUtils.java @@ -0,0 +1,117 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, 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 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: 3837 $ + * + */ +package net.sourceforge.plantuml.ugraphic.sprite; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.net.URLDecoder; +import java.util.Collections; +import java.util.Enumeration; +import java.util.Set; +import java.util.TreeSet; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +import net.sourceforge.plantuml.version.Version; + +public class RessourcesUtils { + + public static Set getJarFile(String path, boolean folder) throws IOException { + if (path.startsWith("/") || path.endsWith("/")) { + throw new IllegalArgumentException(); + } + final URL resource = Version.class.getClassLoader().getResource("net/sourceforge/plantuml/version/logo.png"); + final String protocol = resource.getProtocol(); + if ("file".equals(protocol)) { + final URL local = Version.class.getClassLoader().getResource(path); + try { + return listEntry(new File(local.toURI())); + } catch (URISyntaxException e) { + e.printStackTrace(); + return null; + } + } + if ("jar".equals(protocol)) { + final String classFile = Version.class.getName().replace(".", "/") + ".class"; + final URL versionURL = Version.class.getClassLoader().getResource(classFile); + final String jarPath = versionURL.getPath().substring(5, versionURL.getPath().indexOf("!")); + if (folder) { + return listFolders(new JarFile(URLDecoder.decode(jarPath, "UTF-8")), path + "/"); + } else { + return listFiles(new JarFile(URLDecoder.decode(jarPath, "UTF-8")), path + "/"); + + } + } + return Collections. emptySet(); + } + + private static Set listFiles(JarFile jarFile, String path) { + final Enumeration entries = jarFile.entries(); + final Set result = new TreeSet(); + while (entries.hasMoreElements()) { + final String name = entries.nextElement().getName(); + if (name.startsWith(path)) { + result.add(name.substring(path.length())); + } + } + return result; + } + + private static Set listFolders(JarFile jarFile, String path) { + final Enumeration entries = jarFile.entries(); + final Set result = new TreeSet(); + while (entries.hasMoreElements()) { + final String name = entries.nextElement().getName(); + if (name.startsWith(path)) { + final String folder = name.substring(path.length()); + final int x = folder.indexOf('/'); + if (x != -1) { + result.add(folder.substring(0, x)); + } + } + } + return result; + } + + private static Set listEntry(File dir) { + final Set result = new TreeSet(); + for (String n : dir.list()) { + result.add(n); + } + return result; + } + +} diff --git a/src/net/sourceforge/plantuml/ugraphic/Sprite.java b/src/net/sourceforge/plantuml/ugraphic/sprite/Sprite.java similarity index 96% rename from src/net/sourceforge/plantuml/ugraphic/Sprite.java rename to src/net/sourceforge/plantuml/ugraphic/sprite/Sprite.java index 13dd5d9a0..15a904968 100644 --- a/src/net/sourceforge/plantuml/ugraphic/Sprite.java +++ b/src/net/sourceforge/plantuml/ugraphic/sprite/Sprite.java @@ -31,7 +31,7 @@ * Revision $Revision: 3837 $ * */ -package net.sourceforge.plantuml.ugraphic; +package net.sourceforge.plantuml.ugraphic.sprite; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.TextBlock; diff --git a/src/net/sourceforge/plantuml/ugraphic/SpriteGrayLevel.java b/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteGrayLevel.java similarity index 98% rename from src/net/sourceforge/plantuml/ugraphic/SpriteGrayLevel.java rename to src/net/sourceforge/plantuml/ugraphic/sprite/SpriteGrayLevel.java index b0597356d..e190be838 100644 --- a/src/net/sourceforge/plantuml/ugraphic/SpriteGrayLevel.java +++ b/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteGrayLevel.java @@ -31,7 +31,7 @@ * Revision $Revision: 3837 $ * */ -package net.sourceforge.plantuml.ugraphic; +package net.sourceforge.plantuml.ugraphic.sprite; import java.awt.Color; import java.awt.image.BufferedImage; @@ -43,6 +43,7 @@ import java.util.List; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.code.AsciiEncoder; import net.sourceforge.plantuml.code.CompressionZlib; +import net.sourceforge.plantuml.ugraphic.ColorChangerMonochrome; public enum SpriteGrayLevel { diff --git a/src/net/sourceforge/plantuml/ugraphic/SpriteImage.java b/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteImage.java similarity index 94% rename from src/net/sourceforge/plantuml/ugraphic/SpriteImage.java rename to src/net/sourceforge/plantuml/ugraphic/sprite/SpriteImage.java index a5f4cf184..d36023a9d 100644 --- a/src/net/sourceforge/plantuml/ugraphic/SpriteImage.java +++ b/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteImage.java @@ -31,7 +31,7 @@ * Revision $Revision: 3837 $ * */ -package net.sourceforge.plantuml.ugraphic; +package net.sourceforge.plantuml.ugraphic.sprite; import java.awt.geom.Dimension2D; import java.awt.image.BufferedImage; @@ -45,6 +45,8 @@ import net.sourceforge.plantuml.graphic.AbstractTextBlock; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UImage; public class SpriteImage implements Sprite { diff --git a/src/net/sourceforge/plantuml/ugraphic/SpriteMonochrome.java b/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteMonochrome.java similarity index 94% rename from src/net/sourceforge/plantuml/ugraphic/SpriteMonochrome.java rename to src/net/sourceforge/plantuml/ugraphic/sprite/SpriteMonochrome.java index ce43f1a5e..c203505c8 100644 --- a/src/net/sourceforge/plantuml/ugraphic/SpriteMonochrome.java +++ b/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteMonochrome.java @@ -31,7 +31,7 @@ * Revision $Revision: 3837 $ * */ -package net.sourceforge.plantuml.ugraphic; +package net.sourceforge.plantuml.ugraphic.sprite; import java.awt.Color; import java.awt.geom.Dimension2D; @@ -44,6 +44,9 @@ import net.sourceforge.plantuml.graphic.HtmlColorGradient; import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.ugraphic.ColorMapper; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UImage; public class SpriteMonochrome implements Sprite { diff --git a/src/net/sourceforge/plantuml/ugraphic/SpriteUtils.java b/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteUtils.java similarity index 95% rename from src/net/sourceforge/plantuml/ugraphic/SpriteUtils.java rename to src/net/sourceforge/plantuml/ugraphic/sprite/SpriteUtils.java index 23b062909..4a0c4897e 100644 --- a/src/net/sourceforge/plantuml/ugraphic/SpriteUtils.java +++ b/src/net/sourceforge/plantuml/ugraphic/sprite/SpriteUtils.java @@ -31,13 +31,15 @@ * Revision $Revision: 3837 $ * */ -package net.sourceforge.plantuml.ugraphic; +package net.sourceforge.plantuml.ugraphic.sprite; import java.awt.image.BufferedImage; import java.util.List; public class SpriteUtils { + public static final String SPRITE_NAME = "[-\\p{L}0-9_/]+"; + private SpriteUtils() { } diff --git a/src/net/sourceforge/plantuml/version/License.java b/src/net/sourceforge/plantuml/version/License.java index bb1ea9796..668db9db4 100644 --- a/src/net/sourceforge/plantuml/version/License.java +++ b/src/net/sourceforge/plantuml/version/License.java @@ -212,7 +212,7 @@ public enum License { text.add(""); text.add("(C) Copyright 2009-2017, Arnaud Roques"); text.add(""); - text.add("Project Info: http://plantuml.sourceforge.net"); + text.add("Project Info: http://plantuml.com"); text.add(""); return text; } @@ -225,7 +225,7 @@ public enum License { h.add(" *"); h.add(" * (C) Copyright 2009-2017, Arnaud Roques"); h.add(" *"); - h.add(" * Project Info: http://plantuml.sourceforge.net"); + h.add(" * Project Info: http://plantuml.com"); h.add(" * "); h.add(" * This file is part of PlantUML."); h.add(" *"); @@ -320,7 +320,8 @@ public enum License { throw new IllegalStateException(); } text.add(""); - text.add("Icon provided by OpenIconic : https://useiconic.com/open/"); + text.add("Icons provided by OpenIconic : https://useiconic.com/open"); + text.add("Archimate sprites provided by Archi : http://www.archimatetool.com"); text.add(""); return text; } diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 210d05f98..dddd4800f 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: 18306 $ + * Revision $Revision: 18828 $ * */ package net.sourceforge.plantuml.version; @@ -39,7 +39,7 @@ import java.util.Date; public class Version { public static int version() { - return 8034; + return 8035; } public static String versionString() { @@ -63,7 +63,7 @@ public class Version { } private static long compileTime() { - return 1452334079157L; + return 1454151644150L; } public static String compileTimeString() {