summaryrefslogtreecommitdiff
path: root/src/net/sourceforge/plantuml/graphic
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/sourceforge/plantuml/graphic')
-rw-r--r--src/net/sourceforge/plantuml/graphic/AddStyle.java60
-rw-r--r--src/net/sourceforge/plantuml/graphic/CircledCharacter.java115
-rw-r--r--src/net/sourceforge/plantuml/graphic/ColorAndSizeChange.java85
-rw-r--r--src/net/sourceforge/plantuml/graphic/ColorChange.java64
-rw-r--r--src/net/sourceforge/plantuml/graphic/DateEventUtils.java107
-rw-r--r--src/net/sourceforge/plantuml/graphic/DisplayUtils.java55
-rw-r--r--src/net/sourceforge/plantuml/graphic/EmbededSystemLine.java109
-rw-r--r--src/net/sourceforge/plantuml/graphic/ExposantChange.java49
-rw-r--r--src/net/sourceforge/plantuml/graphic/FontChange.java40
-rw-r--r--src/net/sourceforge/plantuml/graphic/FontConfiguration.java243
-rw-r--r--src/net/sourceforge/plantuml/graphic/FontFamilyChange.java60
-rw-r--r--src/net/sourceforge/plantuml/graphic/FontPosition.java73
-rw-r--r--src/net/sourceforge/plantuml/graphic/FontStyle.java162
-rw-r--r--src/net/sourceforge/plantuml/graphic/GraphicPosition.java41
-rw-r--r--src/net/sourceforge/plantuml/graphic/GraphicStrings.java188
-rw-r--r--src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java54
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlColor.java41
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlColorGradient.java86
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlColorSet.java45
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlColorSetSimple.java284
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlColorSimple.java78
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlColorTransparent.java39
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlColorUserDef.java39
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlColorUtils.java115
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlCommand.java38
-rw-r--r--src/net/sourceforge/plantuml/graphic/HtmlCommandFactory.java141
-rw-r--r--src/net/sourceforge/plantuml/graphic/IHtmlColorSet.java47
-rw-r--r--src/net/sourceforge/plantuml/graphic/Img.java153
-rw-r--r--src/net/sourceforge/plantuml/graphic/ImgValign.java39
-rw-r--r--src/net/sourceforge/plantuml/graphic/Line.java41
-rw-r--r--src/net/sourceforge/plantuml/graphic/QuoteUtils.java160
-rw-r--r--src/net/sourceforge/plantuml/graphic/RemoveStyle.java49
-rw-r--r--src/net/sourceforge/plantuml/graphic/ResetFont.java43
-rw-r--r--src/net/sourceforge/plantuml/graphic/SingleLine.java141
-rw-r--r--src/net/sourceforge/plantuml/graphic/SizeChange.java64
-rw-r--r--src/net/sourceforge/plantuml/graphic/SkinParameter.java131
-rw-r--r--src/net/sourceforge/plantuml/graphic/Splitter.java157
-rw-r--r--src/net/sourceforge/plantuml/graphic/SpriteCommand.java58
-rw-r--r--src/net/sourceforge/plantuml/graphic/StringBounder.java45
-rw-r--r--src/net/sourceforge/plantuml/graphic/StringBounderUtils.java57
-rw-r--r--src/net/sourceforge/plantuml/graphic/SvgAttributes.java81
-rw-r--r--src/net/sourceforge/plantuml/graphic/SvgAttributesChange.java59
-rw-r--r--src/net/sourceforge/plantuml/graphic/SymbolContext.java119
-rw-r--r--src/net/sourceforge/plantuml/graphic/Text.java61
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlock.java45
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockArrow.java110
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockBordered.java65
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockCompressed.java73
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockCompressed2.java62
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockEmpty.java75
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockGeneric.java71
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockHorizontal.java75
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockLineBefore.java85
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockMarged.java68
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockMinWidth.java71
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockRecentred.java61
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockSimple.java203
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockSpotted.java81
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockUtils.java217
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockVertical2.java89
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockWidth.java44
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextBlockWidthAdapter.java63
-rw-r--r--src/net/sourceforge/plantuml/graphic/TextLink.java58
-rw-r--r--src/net/sourceforge/plantuml/graphic/TileImage.java66
-rw-r--r--src/net/sourceforge/plantuml/graphic/TileImageSvg.java74
-rw-r--r--src/net/sourceforge/plantuml/graphic/TileText.java134
-rw-r--r--src/net/sourceforge/plantuml/graphic/UDrawable.java43
-rw-r--r--src/net/sourceforge/plantuml/graphic/UDrawableUtils.java50
-rw-r--r--src/net/sourceforge/plantuml/graphic/UGraphicDelegator.java91
-rw-r--r--src/net/sourceforge/plantuml/graphic/UGraphicInterceptorUDrawable.java61
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbol.java159
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolActor.java54
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolArtifact.java132
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolBoundary.java53
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolCard.java117
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolCloud.java132
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolComponent1.java99
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolComponent2.java114
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolControl.java60
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolDatabase.java169
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolEntityDomain.java59
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolFolder.java150
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolFrame.java138
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolInterface.java52
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolNode.java132
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolQueue.java172
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolRect.java113
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java86
-rw-r--r--src/net/sourceforge/plantuml/graphic/USymbolStorage.java106
-rw-r--r--src/net/sourceforge/plantuml/graphic/UnusedSpace.java173
-rw-r--r--src/net/sourceforge/plantuml/graphic/VerticalAlignment.java52
-rw-r--r--src/net/sourceforge/plantuml/graphic/VerticalPosition.java41
92 files changed, 8414 insertions, 0 deletions
diff --git a/src/net/sourceforge/plantuml/graphic/AddStyle.java b/src/net/sourceforge/plantuml/graphic/AddStyle.java
new file mode 100644
index 0000000..0a7800b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/AddStyle.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+
+public class AddStyle implements FontChange {
+
+ private final FontStyle style;
+ private final HtmlColor extendedColor;
+
+ public AddStyle(FontStyle style, HtmlColor extendedColor) {
+ this.style = style;
+ this.extendedColor = extendedColor;
+ }
+
+ public AddStyle(String s) {
+ this(FontStyle.getStyle(s), FontStyle.getStyle(s).getExtendedColor(s));
+ }
+
+ public FontConfiguration apply(FontConfiguration initial) {
+ initial = initial.add(style);
+ if (extendedColor != null) {
+ initial = initial.changeExtendedColor(extendedColor);
+ }
+ return initial;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/CircledCharacter.java b/src/net/sourceforge/plantuml/graphic/CircledCharacter.java
new file mode 100644
index 0000000..0247c2b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/CircledCharacter.java
@@ -0,0 +1,115 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class CircledCharacter implements TextBlock {
+
+ private final String c;
+ private final UFont font;
+ private final HtmlColor innerCircle;
+ private final HtmlColor circle;
+ private final HtmlColor fontColor;
+ private final double radius;
+
+ public CircledCharacter(char c, double radius, UFont font, HtmlColor innerCircle, HtmlColor circle,
+ HtmlColor fontColor) {
+ this.c = "" + c;
+ this.radius = radius;
+ this.font = font;
+ this.innerCircle = innerCircle;
+ this.circle = circle;
+ this.fontColor = fontColor;
+ }
+
+ // public void draw(ColorMapper colorMapper, Graphics2D g2d, int x, int y, double dpiFactor) {
+ // drawU(new UGraphicG2d(colorMapper, g2d, null, 1.0), x, y);
+ // }
+
+ public void drawU(UGraphic ug) {
+ if (circle != null) {
+ ug = ug.apply(new UChangeColor(circle));
+ }
+ // final HtmlColor back = ug.getParam().getBackcolor();
+ ug = ug.apply(new UChangeBackColor(innerCircle));
+ ug.draw(new UEllipse(radius * 2, radius * 2));
+ ug = ug.apply(new UChangeColor(fontColor));
+ ug = ug.apply(new UTranslate(radius, radius));
+ ug.draw(new UCenteredCharacter(c.charAt(0), font));
+ }
+
+ final public double getPreferredWidth(StringBounder stringBounder) {
+ return 2 * radius;
+ }
+
+ final public double getPreferredHeight(StringBounder stringBounder) {
+ return 2 * radius;
+ }
+
+ // private PathIterator getPathIteratorCharacter(FontRenderContext frc) {
+ // final TextLayout textLayout = new TextLayout(c, font.getFont(), frc);
+ // final Shape s = textLayout.getOutline(null);
+ // return s.getPathIterator(null);
+ // }
+ //
+ // private UPath getUPath(FontRenderContext frc) {
+ // final UPath result = new UPath();
+ //
+ // final PathIterator path = getPathIteratorCharacter(frc);
+ //
+ // final double coord[] = new double[6];
+ // while (path.isDone() == false) {
+ // final int code = path.currentSegment(coord);
+ // result.add(coord, USegmentType.getByCode(code));
+ // path.next();
+ // }
+ //
+ // return result;
+ // }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(getPreferredWidth(stringBounder), getPreferredHeight(stringBounder));
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/ColorAndSizeChange.java b/src/net/sourceforge/plantuml/graphic/ColorAndSizeChange.java
new file mode 100644
index 0000000..c1a0c98
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/ColorAndSizeChange.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+class ColorAndSizeChange implements FontChange {
+
+ static final Pattern colorPattern = MyPattern.cmpile("(?i)color\\s*=\\s*[%g]?(#[0-9a-fA-F]{6}|\\w+)[%g]?");
+
+ static final Pattern sizePattern = MyPattern.cmpile("(?i)size\\s*=\\s*[%g]?(\\d+)[%g]?");
+
+ private final HtmlColor color;
+ private final Integer size;
+
+ ColorAndSizeChange(String s) {
+ final Matcher matcherColor = colorPattern.matcher(s);
+ if (matcherColor.find()) {
+ color = HtmlColorSet.getInstance().getColorIfValid(matcherColor.group(1));
+ } else {
+ color = null;
+ }
+ final Matcher matcherSize = sizePattern.matcher(s);
+ if (matcherSize.find()) {
+ size = new Integer(matcherSize.group(1));
+ } else {
+ size = null;
+ }
+ }
+
+ HtmlColor getColor() {
+ return color;
+ }
+
+ Integer getSize() {
+ return size;
+ }
+
+ public FontConfiguration apply(FontConfiguration initial) {
+ FontConfiguration result = initial;
+ if (color != null) {
+ result = result.changeColor(color);
+ }
+ if (size != null) {
+ result = result.changeSize(size);
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/ColorChange.java b/src/net/sourceforge/plantuml/graphic/ColorChange.java
new file mode 100644
index 0000000..f0e3207
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/ColorChange.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+class ColorChange implements FontChange {
+
+ static private final Pattern colorPattern = MyPattern.cmpile("(?i)" + Splitter.fontColorPattern2);
+
+ private final HtmlColor color;
+
+ ColorChange(String s) {
+ final Matcher matcherColor = colorPattern.matcher(s);
+ if (matcherColor.find() == false) {
+ throw new IllegalArgumentException();
+ }
+ this.color = HtmlColorSet.getInstance().getColorIfValid(matcherColor.group(1));
+ }
+
+ HtmlColor getColor() {
+ return color;
+ }
+
+ public FontConfiguration apply(FontConfiguration initial) {
+ return initial.changeColor(color);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/DateEventUtils.java b/src/net/sourceforge/plantuml/graphic/DateEventUtils.java
new file mode 100644
index 0000000..d2d5225
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/DateEventUtils.java
@@ -0,0 +1,107 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.Font;
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.version.PSystemVersion;
+
+public class DateEventUtils {
+
+ public static TextBlock addEvent(TextBlock textBlock, HtmlColor color) {
+ final DateFormat dateFormat = new SimpleDateFormat("MM-dd");
+ final String today = dateFormat.format(new Date());
+
+ if ("11-05".equals(today)) {
+ final List<String> asList = Arrays.asList("<u>November 5th, 1955",
+ "Doc Brown's discovery of the Flux Capacitor, that makes time-travel possible.");
+ return TextBlockUtils.mergeTB(textBlock, getComment(asList, color), HorizontalAlignment.LEFT);
+ } else if ("08-29".equals(today)) {
+ final List<String> asList = Arrays.asList("<u>August 29th, 1997",
+ "Skynet becomes self-aware at 02:14 AM Eastern Time.");
+ return TextBlockUtils.mergeTB(textBlock, getComment(asList, color), HorizontalAlignment.LEFT);
+ } else if ("06-29".equals(today)) {
+ final List<String> asList = Arrays.asList("<u>June 29th, 1975",
+ "\"It was the first time in history that anyone had typed",
+ "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\t<i>Steve Wozniak");
+ return TextBlockUtils.mergeTB(textBlock, getComment(asList, color), HorizontalAlignment.LEFT);
+ } else if ("01-07".equals(today) || "01-08".equals(today)) {
+ return addCharlie(textBlock);
+
+ }
+
+ return textBlock;
+ }
+
+ private static TextBlock addCharlie(TextBlock textBlock) {
+ final TextBlock charlie = new TextBlock() {
+ private final BufferedImage charlie = PSystemVersion.getCharlieImage();
+
+ public void drawU(UGraphic ug) {
+ ug.draw(new UImage(charlie));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(charlie.getWidth(), charlie.getHeight());
+ }
+ };
+ return TextBlockUtils.mergeTB(charlie, textBlock, HorizontalAlignment.LEFT);
+
+ }
+
+ private static TextBlock getComment(final List<String> asList, HtmlColor color) {
+ final UFont font = new UFont("SansSerif", Font.BOLD, 14);
+ TextBlock comment = TextBlockUtils.create(Display.create(asList), new FontConfiguration(font, color,
+ HtmlColorUtils.BLUE, true), HorizontalAlignment.LEFT, new SpriteContainerEmpty());
+ comment = TextBlockUtils.withMargin(comment, 4, 4);
+ comment = new TextBlockBordered(comment, color);
+ comment = TextBlockUtils.withMargin(comment, 10, 10);
+ return comment;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/DisplayUtils.java b/src/net/sourceforge/plantuml/graphic/DisplayUtils.java
new file mode 100644
index 0000000..32d5708
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/DisplayUtils.java
@@ -0,0 +1,55 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.SpriteContainer;
+import net.sourceforge.plantuml.cucadiagram.Display;
+
+public class DisplayUtils {
+
+ private static Display breakLines(Display texts, FontConfiguration fontConfiguration,
+ SpriteContainer spriteContainer, double maxWidth) {
+ if (texts.size() != 1) {
+ return texts;
+ }
+ final CharSequence s = texts.get(0);
+ Display result = Display.empty();
+ final int nb = s.length() / 2;
+ result = result.add(s.subSequence(0, nb));
+ result = result.add(s.subSequence(nb + 1, s.length()));
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/EmbededSystemLine.java b/src/net/sourceforge/plantuml/graphic/EmbededSystemLine.java
new file mode 100644
index 0000000..cd7b3f4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/EmbededSystemLine.java
@@ -0,0 +1,109 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.List;
+
+import javax.imageio.ImageIO;
+
+import net.sourceforge.plantuml.BlockUml;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.EmbededDiagram;
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.core.Diagram;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+class EmbededSystemLine implements Line {
+
+ final private List<? extends CharSequence> lines;
+
+ public EmbededSystemLine(EmbededDiagram sys) {
+ this.lines = sys.getLines().as();
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ try {
+ final BufferedImage im = getImage();
+ return new Dimension2DDouble(im.getWidth(), im.getHeight());
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return new Dimension2DDouble(42, 42);
+ }
+
+ public void drawU(UGraphic ug) {
+ try {
+ final BufferedImage im = getImage();
+ final UShape image = new UImage(im);
+ ug.draw(image);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ private BufferedImage getImage() throws IOException, InterruptedException {
+ final Diagram system = getSystem();
+ final ByteArrayOutputStream os = new ByteArrayOutputStream();
+ system.exportDiagram(os, 0, new FileFormatOption(FileFormat.PNG));
+ os.close();
+ final ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
+ final BufferedImage im = ImageIO.read(is);
+ is.close();
+ return im;
+ }
+
+ public HorizontalAlignment getHorizontalAlignment() {
+ return HorizontalAlignment.LEFT;
+ }
+
+ private Diagram getSystem() throws IOException, InterruptedException {
+ final BlockUml blockUml = new BlockUml(lines, 0);
+ return blockUml.getDiagram();
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/ExposantChange.java b/src/net/sourceforge/plantuml/graphic/ExposantChange.java
new file mode 100644
index 0000000..2c7d117
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/ExposantChange.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+class ExposantChange implements FontChange {
+
+ private final FontPosition fontPosition;
+
+ ExposantChange(FontPosition fontPosition) {
+ this.fontPosition = fontPosition;
+ }
+
+ public FontConfiguration apply(FontConfiguration initial) {
+ return initial.changeFontPosition(fontPosition);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/FontChange.java b/src/net/sourceforge/plantuml/graphic/FontChange.java
new file mode 100644
index 0000000..91e3003
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/FontChange.java
@@ -0,0 +1,40 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public interface FontChange extends HtmlCommand {
+
+ FontConfiguration apply(FontConfiguration initial);
+}
diff --git a/src/net/sourceforge/plantuml/graphic/FontConfiguration.java b/src/net/sourceforge/plantuml/graphic/FontConfiguration.java
new file mode 100644
index 0000000..dcc5a1f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/FontConfiguration.java
@@ -0,0 +1,243 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.EnumSet;
+import java.util.Map;
+
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ISkinParam;
+import net.sourceforge.plantuml.SkinParamUtils;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class FontConfiguration {
+
+ private final EnumSet<FontStyle> styles;
+ private final UFont currentFont;
+ private final UFont motherFont;
+ private final HtmlColor motherColor;
+ private final HtmlColor hyperlinkColor;
+ private final HtmlColor currentColor;
+ private final HtmlColor extendedColor;
+ private final FontPosition fontPosition;
+ private final SvgAttributes svgAttributes;
+ private final boolean hyperlink;
+ private final boolean useUnderlineForHyperlink;
+
+ public FontConfiguration(UFont font, HtmlColor color, HtmlColor hyperlinkColor, boolean useUnderlineForHyperlink) {
+ this(getStyles(font), font, color, font, color, null, FontPosition.NORMAL, new SvgAttributes(), false,
+ hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ public FontConfiguration(ISkinParam skinParam, FontParam fontParam, Stereotype stereo) {
+ this(SkinParamUtils.getFont(skinParam, fontParam, stereo), SkinParamUtils.getFontColor(skinParam, fontParam,
+ stereo), skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink());
+ }
+
+ //---
+
+ public final boolean useUnderlineForHyperlink() {
+ return useUnderlineForHyperlink;
+ }
+
+ public final HtmlColor getHyperlinkColor() {
+ return hyperlinkColor;
+ }
+
+ //---
+
+ private static EnumSet<FontStyle> getStyles(UFont font) {
+ final boolean bold = font.isBold();
+ final boolean italic = font.isItalic();
+ if (bold && italic) {
+ return EnumSet.of(FontStyle.ITALIC, FontStyle.BOLD);
+ }
+ if (bold) {
+ return EnumSet.of(FontStyle.BOLD);
+ }
+ if (italic) {
+ return EnumSet.of(FontStyle.ITALIC);
+ }
+ return EnumSet.noneOf(FontStyle.class);
+ }
+
+ @Override
+ public String toString() {
+ return styles.toString() + " " + currentColor;
+ }
+
+ private FontConfiguration(EnumSet<FontStyle> styles, UFont motherFont, HtmlColor motherColor, UFont currentFont,
+ HtmlColor currentColor, HtmlColor extendedColor, FontPosition fontPosition, SvgAttributes svgAttributes,
+ boolean hyperlink, HtmlColor hyperlinkColor, boolean useUnderlineForHyperlink) {
+ this.styles = styles;
+ this.currentFont = currentFont;
+ this.motherFont = motherFont;
+ this.currentColor = currentColor;
+ this.motherColor = motherColor;
+ this.extendedColor = extendedColor;
+ this.fontPosition = fontPosition;
+ this.svgAttributes = svgAttributes;
+ this.hyperlink = hyperlink;
+ this.hyperlinkColor = hyperlinkColor;
+ this.useUnderlineForHyperlink = useUnderlineForHyperlink;
+ }
+
+ public FontConfiguration forceFont(UFont newFont, HtmlColor htmlColorForStereotype) {
+ if (newFont == null) {
+ return add(FontStyle.ITALIC);
+ }
+ FontConfiguration result = new FontConfiguration(styles, newFont, motherColor, newFont, currentColor,
+ extendedColor, fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink);
+ if (htmlColorForStereotype != null) {
+ result = result.changeColor(htmlColorForStereotype);
+ }
+ return result;
+ }
+
+ public FontConfiguration changeAttributes(SvgAttributes toBeAdded) {
+ return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, extendedColor,
+ fontPosition, svgAttributes.add(toBeAdded), hyperlink, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ private FontConfiguration withHyperlink() {
+ return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, extendedColor,
+ fontPosition, svgAttributes, true, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ public FontConfiguration changeColor(HtmlColor htmlColor) {
+ return new FontConfiguration(styles, motherFont, motherColor, currentFont, htmlColor, extendedColor,
+ fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ FontConfiguration changeExtendedColor(HtmlColor newExtendedColor) {
+ return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, newExtendedColor,
+ fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ public FontConfiguration changeSize(float size) {
+ return new FontConfiguration(styles, motherFont, motherColor, currentFont.deriveSize(size), currentColor,
+ extendedColor, fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ public FontConfiguration bigger(double delta) {
+ return changeSize((float) (currentFont.getSize() + delta));
+ }
+
+ public FontConfiguration changeFontPosition(FontPosition fontPosition) {
+ return new FontConfiguration(styles, motherFont, motherColor, currentFont, currentColor, extendedColor,
+ fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ public FontConfiguration changeFamily(String family) {
+ return new FontConfiguration(styles, motherFont, motherColor, new UFont(family, currentFont.getStyle(),
+ currentFont.getSize()), currentColor, extendedColor, fontPosition, svgAttributes, hyperlink,
+ hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ public FontConfiguration resetFont() {
+ return new FontConfiguration(styles, motherFont, motherColor, motherFont, motherColor, null,
+ FontPosition.NORMAL, new SvgAttributes(), hyperlink, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ FontConfiguration add(FontStyle style) {
+ final EnumSet<FontStyle> r = styles.clone();
+ r.add(style);
+ return new FontConfiguration(r, motherFont, motherColor, currentFont, currentColor, extendedColor,
+ fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ public FontConfiguration italic() {
+ return add(FontStyle.ITALIC);
+ }
+
+ public FontConfiguration bold() {
+ return add(FontStyle.BOLD);
+ }
+
+ public FontConfiguration underline() {
+ return add(FontStyle.UNDERLINE);
+ }
+
+ public FontConfiguration hyperlink() {
+ if (useUnderlineForHyperlink) {
+ return add(FontStyle.UNDERLINE).withHyperlink();
+ }
+ return withHyperlink();
+ }
+
+ FontConfiguration remove(FontStyle style) {
+ final EnumSet<FontStyle> r = styles.clone();
+ r.remove(style);
+ return new FontConfiguration(r, motherFont, motherColor, currentFont, currentColor, extendedColor,
+ fontPosition, svgAttributes, hyperlink, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ public UFont getFont() {
+ UFont result = currentFont;
+ for (FontStyle style : styles) {
+ result = style.mutateFont(result);
+ }
+ return fontPosition.mute(result);
+ }
+
+ public HtmlColor getColor() {
+ if (hyperlink) {
+ return hyperlinkColor;
+ }
+ return currentColor;
+ }
+
+ public HtmlColor getExtendedColor() {
+ return extendedColor;
+ }
+
+ public boolean containsStyle(FontStyle style) {
+ return styles.contains(style);
+ }
+
+ public int getSpace() {
+ return fontPosition.getSpace();
+ }
+
+ public Map<String, String> getAttributes() {
+ return svgAttributes.attributes();
+ }
+
+ public double getSize2D() {
+ return currentFont.getSize2D();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/FontFamilyChange.java b/src/net/sourceforge/plantuml/graphic/FontFamilyChange.java
new file mode 100644
index 0000000..476f67c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/FontFamilyChange.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+class FontFamilyChange implements FontChange {
+
+ static private final Pattern colorPattern = MyPattern.cmpile("(?i)" + Splitter.fontFamilyPattern);
+
+ private final String family;
+
+ FontFamilyChange(String s) {
+ final Matcher matcherColor = colorPattern.matcher(s);
+ if (matcherColor.find() == false) {
+ throw new IllegalArgumentException();
+ }
+ this.family = matcherColor.group(1).trim();
+ }
+
+ public FontConfiguration apply(FontConfiguration initial) {
+ return initial.changeFamily(family);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/FontPosition.java b/src/net/sourceforge/plantuml/graphic/FontPosition.java
new file mode 100644
index 0000000..e049510
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/FontPosition.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public enum FontPosition {
+ NORMAL, EXPOSANT, INDICE;
+
+ public int getSpace() {
+ if (this == EXPOSANT) {
+ return -6;
+ }
+ if (this == INDICE) {
+ return 3;
+ }
+ return 0;
+ }
+
+ public UFont mute(UFont font) {
+ if (this == NORMAL) {
+ return font;
+ }
+ int size = font.getSize() - 3;
+ if (size < 2) {
+ size = 2;
+ }
+ return font.deriveSize((float) size);
+ }
+
+ public String getHtmlTag() {
+ if (this == EXPOSANT) {
+ return "sup";
+ }
+ if (this == INDICE) {
+ return "sub";
+ }
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/FontStyle.java b/src/net/sourceforge/plantuml/graphic/FontStyle.java
new file mode 100644
index 0000000..bde9eb9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/FontStyle.java
@@ -0,0 +1,162 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.Font;
+import java.util.EnumSet;
+import java.util.regex.Matcher;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public enum FontStyle {
+ PLAIN, ITALIC, BOLD, UNDERLINE, STRIKE, WAVE, BACKCOLOR;
+
+ public UFont mutateFont(UFont font) {
+ if (this == ITALIC) {
+ return font.deriveStyle(font.getStyle() | Font.ITALIC);
+ }
+ if (this == BOLD) {
+ return font.deriveStyle(font.getStyle() | Font.BOLD);
+ }
+ return font;
+ }
+
+ public String getActivationPattern() {
+ if (this == ITALIC) {
+ return "\\<[iI]\\>";
+ }
+ if (this == BOLD) {
+ return "\\<[bB]\\>";
+ }
+ if (this == UNDERLINE) {
+ return "\\<[uU](?::(#[0-9a-fA-F]{6}|\\w+))?\\>";
+ }
+ if (this == WAVE) {
+ return "\\<[wW](?::(#[0-9a-fA-F]{6}|\\w+))?\\>";
+ }
+ if (this == BACKCOLOR) {
+ return "\\<[bB][aA][cC][kK](?::(#[0-9a-fA-F]{6}|\\w+))?\\>";
+ }
+ if (this == STRIKE) {
+ return "\\<(?:s|S|strike|STRIKE|del|DEL)(?::(#[0-9a-fA-F]{6}|\\w+))?\\>";
+ }
+ return null;
+ }
+
+ public boolean canHaveExtendedColor() {
+ if (this == UNDERLINE) {
+ return true;
+ }
+ if (this == WAVE) {
+ return true;
+ }
+ if (this == BACKCOLOR) {
+ return true;
+ }
+ if (this == STRIKE) {
+ return true;
+ }
+ return false;
+ }
+
+
+ public String getCreoleSyntax() {
+ if (this == ITALIC) {
+ return "//";
+ }
+ if (this == BOLD) {
+ return "\\*\\*";
+ }
+ if (this == UNDERLINE) {
+ return "__";
+ }
+ if (this == WAVE) {
+ return "~~";
+ }
+ if (this == STRIKE) {
+ return "--";
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ public HtmlColor getExtendedColor(String s) {
+ final Matcher m = MyPattern.cmpile(getActivationPattern()).matcher(s);
+ if (m.find() == false || m.groupCount() != 1) {
+ return null;
+ }
+ final String color = m.group(1);
+ if (HtmlColorSet.getInstance().getColorIfValid(color) != null) {
+ return HtmlColorSet.getInstance().getColorIfValid(color);
+ }
+ return null;
+ }
+
+ public String getDeactivationPattern() {
+ if (this == ITALIC) {
+ return "\\</[iI]\\>";
+ }
+ if (this == BOLD) {
+ return "\\</[bB]\\>";
+ }
+ if (this == UNDERLINE) {
+ return "\\</[uU]\\>";
+ }
+ if (this == WAVE) {
+ return "\\</[wW]\\>";
+ }
+ if (this == BACKCOLOR) {
+ return "\\</[bB][aA][cC][kK]\\>";
+ }
+ if (this == STRIKE) {
+ return "\\</(?:s|S|strike|STRIKE|del|DEL)\\>";
+ }
+ return null;
+ }
+
+ public static FontStyle getStyle(String line) {
+ for (FontStyle style : EnumSet.allOf(FontStyle.class)) {
+ if (style == FontStyle.PLAIN) {
+ continue;
+ }
+ if (line.matches(style.getActivationPattern()) || line.matches(style.getDeactivationPattern())) {
+ return style;
+ }
+ }
+ throw new IllegalArgumentException(line);
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/GraphicPosition.java b/src/net/sourceforge/plantuml/graphic/GraphicPosition.java
new file mode 100644
index 0000000..a63ac0a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/GraphicPosition.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+
+public enum GraphicPosition {
+ BOTTOM, BACKGROUND_CORNER_BOTTOM_RIGHT, BACKGROUND_CORNER_TOP_RIGHT
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/GraphicStrings.java b/src/net/sourceforge/plantuml/graphic/GraphicStrings.java
new file mode 100644
index 0000000..382dfc5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/GraphicStrings.java
@@ -0,0 +1,188 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.Font;
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.SpriteContainerEmpty;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.svek.IEntityImage;
+import net.sourceforge.plantuml.svek.ShapeType;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class GraphicStrings implements IEntityImage {
+
+ private final HtmlColor background;
+
+ private final UFont font;
+
+ private final HtmlColor green;
+
+ private final HtmlColor hyperlinkColor = HtmlColorUtils.BLUE;
+
+ private final boolean useUnderlineForHyperlink = true;
+
+ private final List<String> strings;
+
+ private final BufferedImage image;
+
+ private final GraphicPosition position;
+
+ private final UAntiAliasing antiAliasing;
+
+ private final ColorMapper colorMapper = new ColorMapperIdentity();
+
+ public static GraphicStrings createDefault(List<String> strings, boolean useRed) {
+ if (useRed) {
+ return new GraphicStrings(strings, new UFont("SansSerif", Font.BOLD, 14), HtmlColorUtils.BLACK,
+ HtmlColorUtils.RED_LIGHT, UAntiAliasing.ANTI_ALIASING_ON);
+ }
+ return new GraphicStrings(strings, new UFont("SansSerif", Font.BOLD, 14), HtmlColorSet.getInstance()
+ .getColorIfValid("#33FF02"), HtmlColorUtils.BLACK, UAntiAliasing.ANTI_ALIASING_ON);
+ }
+
+ public GraphicStrings(List<String> strings, UFont font, HtmlColor green, HtmlColor background,
+ UAntiAliasing antiAliasing) {
+ this(strings, font, green, background, antiAliasing, null, null);
+ }
+
+ public GraphicStrings(List<String> strings, UFont font, HtmlColor green, HtmlColor background,
+ UAntiAliasing antiAliasing, BufferedImage image, GraphicPosition position) {
+ this.strings = strings;
+ this.font = font;
+ this.green = green;
+ this.background = background;
+ this.image = image;
+ this.position = position;
+ this.antiAliasing = antiAliasing;
+ }
+
+ private double minWidth;
+
+ public void setMinWidth(double minWidth) {
+ this.minWidth = minWidth;
+ }
+
+ private int maxLine = 0;
+
+ private TextBlock getTextBlock() {
+ TextBlock result = null;
+ if (maxLine == 0) {
+ result = TextBlockUtils.create(Display.create(strings), new FontConfiguration(font, green, hyperlinkColor, useUnderlineForHyperlink),
+ HorizontalAlignment.LEFT, new SpriteContainerEmpty());
+ } else {
+ for (int i = 0; i < strings.size(); i += maxLine) {
+ final int n = Math.min(i + maxLine, strings.size());
+ final TextBlock textBlock1 = TextBlockUtils.create(Display.create(strings.subList(i, n)),
+ new FontConfiguration(font, green, hyperlinkColor, useUnderlineForHyperlink), HorizontalAlignment.LEFT,
+ new SpriteContainerEmpty());
+ if (result == null) {
+ result = textBlock1;
+ } else {
+ result = TextBlockUtils.withMargin(result, 0, 10, 0, 0);
+ result = TextBlockUtils.mergeLR(result, textBlock1, VerticalAlignment.TOP);
+ }
+ }
+ }
+ result = DateEventUtils.addEvent(result, green);
+ return result;
+ }
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D size = calculateDimension(ug.getStringBounder());
+ getTextBlock().drawU(ug.apply(new UChangeColor(green)));
+
+ if (image != null) {
+ if (position == GraphicPosition.BOTTOM) {
+ ug.apply(new UTranslate((size.getWidth() - image.getWidth()) / 2, size.getHeight() - image.getHeight()))
+ .draw(new UImage(image));
+ } else if (position == GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT) {
+ ug.apply(new UTranslate(size.getWidth() - image.getWidth(), size.getHeight() - image.getHeight()))
+ .draw(new UImage(image));
+ } else if (position == GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT) {
+ ug.apply(new UTranslate(size.getWidth() - image.getWidth() - 1, 1)).draw(new UImage(image));
+ }
+ }
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ Dimension2D dim = getTextBlock().calculateDimension(stringBounder);
+ if (dim.getWidth() < minWidth) {
+ dim = new Dimension2DDouble(minWidth, dim.getHeight());
+ }
+ if (image != null) {
+ if (position == GraphicPosition.BOTTOM) {
+ dim = new Dimension2DDouble(dim.getWidth(), dim.getHeight() + image.getHeight());
+ } else if (position == GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT) {
+ dim = new Dimension2DDouble(dim.getWidth() + image.getWidth(), dim.getHeight());
+ } else if (position == GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT) {
+ dim = new Dimension2DDouble(dim.getWidth() + image.getWidth(), dim.getHeight());
+ }
+ }
+ return dim;
+ }
+
+ public ShapeType getShapeType() {
+ return ShapeType.RECTANGLE;
+ }
+
+ public HtmlColor getBackcolor() {
+ return background;
+ }
+
+ public int getShield() {
+ return 0;
+ }
+
+ public boolean isHidden() {
+ return false;
+ }
+
+ public final void setMaxLine(int maxLine) {
+ this.maxLine = maxLine;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java b/src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java
new file mode 100644
index 0000000..9ef51ab
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HorizontalAlignment.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public enum HorizontalAlignment {
+
+ LEFT, CENTER, RIGHT;
+
+ public static HorizontalAlignment fromString(String s) {
+ if (LEFT.name().equalsIgnoreCase(s)) {
+ return LEFT;
+ }
+ if (CENTER.name().equalsIgnoreCase(s)) {
+ return CENTER;
+ }
+ if (RIGHT.name().equalsIgnoreCase(s)) {
+ return RIGHT;
+ }
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColor.java b/src/net/sourceforge/plantuml/graphic/HtmlColor.java
new file mode 100644
index 0000000..a65c7a3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColor.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+
+public interface HtmlColor {
+
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorGradient.java b/src/net/sourceforge/plantuml/graphic/HtmlColorGradient.java
new file mode 100644
index 0000000..02aeaf1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColorGradient.java
@@ -0,0 +1,86 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.Color;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+
+public class HtmlColorGradient implements HtmlColor {
+
+ private final HtmlColor color1;
+ private final HtmlColor color2;
+ private final char policy;
+
+ public HtmlColorGradient(HtmlColor color1, HtmlColor color2, char policy) {
+ if (color1 == null || color2 == null) {
+ throw new IllegalArgumentException();
+ }
+ this.color1 = color1;
+ this.color2 = color2;
+ this.policy = policy;
+ }
+
+ public final HtmlColor getColor1() {
+ return color1;
+ }
+
+ public final HtmlColor getColor2() {
+ return color2;
+ }
+
+ public final Color getColor(ColorMapper mapper, double coeff) {
+ if (coeff > 1 || coeff < 0) {
+ throw new IllegalArgumentException("c=" + coeff);
+ }
+ final Color c1 = mapper.getMappedColor(color1);
+ final Color c2 = mapper.getMappedColor(color2);
+ final int vred = c2.getRed() - c1.getRed();
+ final int vgreen = c2.getGreen() - c1.getGreen();
+ final int vblue = c2.getBlue() - c1.getBlue();
+
+ final int red = c1.getRed() + (int) (coeff * vred);
+ final int green = c1.getGreen() + (int) (coeff * vgreen);
+ final int blue = c1.getBlue() + (int) (coeff * vblue);
+
+ return new Color(red, green, blue);
+
+ }
+
+ public final char getPolicy() {
+ return policy;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorSet.java b/src/net/sourceforge/plantuml/graphic/HtmlColorSet.java
new file mode 100644
index 0000000..ac179df
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColorSet.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public class HtmlColorSet {
+
+ private final static IHtmlColorSet singleton = new HtmlColorSetSimple();
+
+ public static IHtmlColorSet getInstance() {
+ return singleton;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorSetSimple.java b/src/net/sourceforge/plantuml/graphic/HtmlColorSetSimple.java
new file mode 100644
index 0000000..258110b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColorSetSimple.java
@@ -0,0 +1,284 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.Color;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.regex.Matcher;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+public class HtmlColorSetSimple implements IHtmlColorSet {
+
+ private final Map<String, String> htmlNames;
+ private final Set<String> names;
+
+ public Collection<String> names() {
+ return Collections.unmodifiableSet(names);
+ }
+
+ public HtmlColor getColorIfValid(String s) {
+ return getColorIfValid(s, false);
+ }
+
+ public HtmlColor getColorIfValid(String s, boolean acceptTransparent) {
+ if (s == null) {
+ return null;
+ }
+ final Matcher m = MyPattern.cmpile("[-\\\\|/]").matcher(s);
+ if (m.find()) {
+ final char sep = m.group(0).charAt(0);
+ final int idx = s.indexOf(sep);
+ final String s1 = s.substring(0, idx);
+ final String s2 = s.substring(idx + 1);
+ if (isValid(s1, false) == false || isValid(s2, false) == false) {
+ return null;
+ }
+ return new HtmlColorGradient(build(s1), build(s2), sep);
+ // return getColorIfValid(s2);
+ }
+ if (isValid(s, acceptTransparent) == false) {
+ return new HtmlColorUserDef();
+ }
+ return build(s);
+ }
+
+ public HtmlColorSetSimple() {
+ // Taken from http://perl.wikipedia.com/wiki/Named_colors ?
+ // http://www.w3schools.com/HTML/html_colornames.asp
+ htmlNames = new HashMap<String, String>();
+ names = new TreeSet<String>();
+ register("AliceBlue", "#F0F8FF");
+ register("AntiqueWhite", "#FAEBD7");
+ register("Aqua", "#00FFFF");
+ register("Aquamarine", "#7FFFD4");
+ register("Azure", "#F0FFFF");
+ register("Beige", "#F5F5DC");
+ register("Bisque", "#FFE4C4");
+ register("Black", "#000000");
+ register("BlanchedAlmond", "#FFEBCD");
+ register("Blue", "#0000FF");
+ register("BlueViolet", "#8A2BE2");
+ register("Brown", "#A52A2A");
+ register("BurlyWood", "#DEB887");
+ register("CadetBlue", "#5F9EA0");
+ register("Chartreuse", "#7FFF00");
+ register("Chocolate", "#D2691E");
+ register("Coral", "#FF7F50");
+ register("CornflowerBlue", "#6495ED");
+ register("Cornsilk", "#FFF8DC");
+ register("Crimson", "#DC143C");
+ register("Cyan", "#00FFFF");
+ register("DarkBlue", "#00008B");
+ register("DarkCyan", "#008B8B");
+ register("DarkGoldenRod", "#B8860B");
+ register("DarkGray", "#A9A9A9");
+ register("DarkGrey", "#A9A9A9");
+ register("DarkGreen", "#006400");
+ register("DarkKhaki", "#BDB76B");
+ register("DarkMagenta", "#8B008B");
+ register("DarkOliveGreen", "#556B2F");
+ register("Darkorange", "#FF8C00");
+ register("DarkOrchid", "#9932CC");
+ register("DarkRed", "#8B0000");
+ register("DarkSalmon", "#E9967A");
+ register("DarkSeaGreen", "#8FBC8F");
+ register("DarkSlateBlue", "#483D8B");
+ register("DarkSlateGray", "#2F4F4F");
+ register("DarkSlateGrey", "#2F4F4F");
+ register("DarkTurquoise", "#00CED1");
+ register("DarkViolet", "#9400D3");
+ register("DeepPink", "#FF1493");
+ register("DeepSkyBlue", "#00BFFF");
+ register("DimGray", "#696969");
+ register("DimGrey", "#696969");
+ register("DodgerBlue", "#1E90FF");
+ register("FireBrick", "#B22222");
+ register("FloralWhite", "#FFFAF0");
+ register("ForestGreen", "#228B22");
+ register("Fuchsia", "#FF00FF");
+ register("Gainsboro", "#DCDCDC");
+ register("GhostWhite", "#F8F8FF");
+ register("Gold", "#FFD700");
+ register("GoldenRod", "#DAA520");
+ register("Gray", "#808080");
+ register("Grey", "#808080");
+ register("Green", "#008000");
+ register("GreenYellow", "#ADFF2F");
+ register("HoneyDew", "#F0FFF0");
+ register("HotPink", "#FF69B4");
+ register("IndianRed", "#CD5C5C");
+ register("Indigo", "#4B0082");
+ register("Ivory", "#FFFFF0");
+ register("Khaki", "#F0E68C");
+ register("Lavender", "#E6E6FA");
+ register("LavenderBlush", "#FFF0F5");
+ register("LawnGreen", "#7CFC00");
+ register("LemonChiffon", "#FFFACD");
+ register("LightBlue", "#ADD8E6");
+ register("LightCoral", "#F08080");
+ register("LightCyan", "#E0FFFF");
+ register("LightGoldenRodYellow", "#FAFAD2");
+ register("LightGray", "#D3D3D3");
+ register("LightGrey", "#D3D3D3");
+ register("LightGreen", "#90EE90");
+ register("LightPink", "#FFB6C1");
+ register("LightSalmon", "#FFA07A");
+ register("LightSeaGreen", "#20B2AA");
+ register("LightSkyBlue", "#87CEFA");
+ register("LightSlateGray", "#778899");
+ register("LightSlateGrey", "#778899");
+ register("LightSteelBlue", "#B0C4DE");
+ register("LightYellow", "#FFFFE0");
+ register("Lime", "#00FF00");
+ register("LimeGreen", "#32CD32");
+ register("Linen", "#FAF0E6");
+ register("Magenta", "#FF00FF");
+ register("Maroon", "#800000");
+ register("MediumAquaMarine", "#66CDAA");
+ register("MediumBlue", "#0000CD");
+ register("MediumOrchid", "#BA55D3");
+ register("MediumPurple", "#9370D8");
+ register("MediumSeaGreen", "#3CB371");
+ register("MediumSlateBlue", "#7B68EE");
+ register("MediumSpringGreen", "#00FA9A");
+ register("MediumTurquoise", "#48D1CC");
+ register("MediumVioletRed", "#C71585");
+ register("MidnightBlue", "#191970");
+ register("MintCream", "#F5FFFA");
+ register("MistyRose", "#FFE4E1");
+ register("Moccasin", "#FFE4B5");
+ register("NavajoWhite", "#FFDEAD");
+ register("Navy", "#000080");
+ register("OldLace", "#FDF5E6");
+ register("Olive", "#808000");
+ register("OliveDrab", "#6B8E23");
+ register("Orange", "#FFA500");
+ register("OrangeRed", "#FF4500");
+ register("Orchid", "#DA70D6");
+ register("PaleGoldenRod", "#EEE8AA");
+ register("PaleGreen", "#98FB98");
+ register("PaleTurquoise", "#AFEEEE");
+ register("PaleVioletRed", "#D87093");
+ register("PapayaWhip", "#FFEFD5");
+ register("PeachPuff", "#FFDAB9");
+ register("Peru", "#CD853F");
+ register("Pink", "#FFC0CB");
+ register("Plum", "#DDA0DD");
+ register("PowderBlue", "#B0E0E6");
+ register("Purple", "#800080");
+ register("Red", "#FF0000");
+ register("RosyBrown", "#BC8F8F");
+ register("RoyalBlue", "#4169E1");
+ register("SaddleBrown", "#8B4513");
+ register("Salmon", "#FA8072");
+ register("SandyBrown", "#F4A460");
+ register("SeaGreen", "#2E8B57");
+ register("SeaShell", "#FFF5EE");
+ register("Sienna", "#A0522D");
+ register("Silver", "#C0C0C0");
+ register("SkyBlue", "#87CEEB");
+ register("SlateBlue", "#6A5ACD");
+ register("SlateGray", "#708090");
+ register("SlateGrey", "#708090");
+ register("Snow", "#FFFAFA");
+ register("SpringGreen", "#00FF7F");
+ register("SteelBlue", "#4682B4");
+ register("Tan", "#D2B48C");
+ register("Teal", "#008080");
+ register("Thistle", "#D8BFD8");
+ register("Tomato", "#FF6347");
+ register("Turquoise", "#40E0D0");
+ register("Violet", "#EE82EE");
+ register("Wheat", "#F5DEB3");
+ register("White", "#FFFFFF");
+ register("WhiteSmoke", "#F5F5F5");
+ register("Yellow", "#FFFF00");
+ register("YellowGreen", "#9ACD32");
+ }
+
+ private void register(String s, String color) {
+ htmlNames.put(StringUtils.goLowerCase(s), color);
+ names.add(s);
+ }
+
+ private HtmlColor build(String s) {
+
+ s = removeFirstDieseAndgoLowerCase(s);
+ final Color color;
+ if (s.equalsIgnoreCase("transparent")) {
+ return new HtmlColorTransparent();
+ } else if (s.matches("[0-9A-Fa-f]{6}")) {
+ color = new Color(Integer.parseInt(s, 16));
+ } else {
+ final String value = htmlNames.get(s);
+ if (value == null) {
+ throw new IllegalArgumentException(s);
+ }
+ color = new Color(Integer.parseInt(value.substring(1), 16));
+ }
+ return new HtmlColorSimple(color, false);
+ }
+
+ private boolean isValid(String s, boolean acceptTransparent) {
+ s = removeFirstDieseAndgoLowerCase(s);
+ if (s.matches("[0-9A-Fa-f]{6}")) {
+ return true;
+ }
+ if (acceptTransparent && s.equalsIgnoreCase("transparent")) {
+ return true;
+ }
+ if (htmlNames.containsKey(s)) {
+ return true;
+ }
+ return false;
+
+ }
+
+ private String removeFirstDieseAndgoLowerCase(String s) {
+ s = StringUtils.goLowerCase(s);
+ if (s.startsWith("#")) {
+ s = s.substring(1);
+ }
+ return s;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorSimple.java b/src/net/sourceforge/plantuml/graphic/HtmlColorSimple.java
new file mode 100644
index 0000000..07f863d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColorSimple.java
@@ -0,0 +1,78 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.Color;
+
+import net.sourceforge.plantuml.ugraphic.ColorChangerMonochrome;
+
+public class HtmlColorSimple implements HtmlColor {
+
+
+ private final Color color;
+ private final boolean monochrome;
+
+ @Override
+ public int hashCode() {
+ return color.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other instanceof HtmlColorSimple == false) {
+ return false;
+ }
+ return this.color.equals(((HtmlColorSimple) other).color);
+ }
+
+
+ HtmlColorSimple(Color c, boolean monochrome) {
+ this.color = c;
+ this.monochrome = monochrome;
+ }
+
+
+ public Color getColor999() {
+ return color;
+ }
+
+ public HtmlColorSimple asMonochrome() {
+ if (monochrome) {
+ throw new IllegalStateException();
+ }
+ return new HtmlColorSimple(new ColorChangerMonochrome().getChangedColor(color), true);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorTransparent.java b/src/net/sourceforge/plantuml/graphic/HtmlColorTransparent.java
new file mode 100644
index 0000000..76bdcd2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColorTransparent.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public class HtmlColorTransparent implements HtmlColor {
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorUserDef.java b/src/net/sourceforge/plantuml/graphic/HtmlColorUserDef.java
new file mode 100644
index 0000000..e1a2dd7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColorUserDef.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public class HtmlColorUserDef implements HtmlColor {
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlColorUtils.java b/src/net/sourceforge/plantuml/graphic/HtmlColorUtils.java
new file mode 100644
index 0000000..2c0c682
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlColorUtils.java
@@ -0,0 +1,115 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+
+public class HtmlColorUtils {
+
+ public static final String COLOR_REGEXP = "#\\w+[-\\\\|/]?\\w+";
+
+ public static final HtmlColor BLACK;
+ public static final HtmlColor WHITE;
+ public static final HtmlColor RED_LIGHT;
+ public static final HtmlColor RED_DARK;
+ public static final HtmlColor RED;
+ public static final HtmlColor GREEN;
+ public static final HtmlColor BLUE;
+ public static final HtmlColor GRAY;
+ public static final HtmlColor LIGHT_GRAY;
+ public static final HtmlColor MY_YELLOW;
+ public static final HtmlColor MY_RED;
+
+ public static final HtmlColor COL_C82930;
+ public static final HtmlColor COL_F24D5C;
+ public static final HtmlColor COL_1963A0;
+ public static final HtmlColor COL_4177AF;
+ public static final HtmlColor COL_B38D22;
+ public static final HtmlColor COL_FFFF44;
+ public static final HtmlColor COL_038048;
+ public static final HtmlColor COL_84BE84;
+ public static final HtmlColor COL_DDDDDD;
+ public static final HtmlColor COL_EEEEEE;
+ public static final HtmlColor COL_FBFB77;
+ public static final HtmlColor COL_ADD1B2;
+ public static final HtmlColor COL_A9DCDF;
+ public static final HtmlColor COL_EB937F;
+ public static final HtmlColor COL_B4A7E5;
+ public static final HtmlColor COL_527BC6;
+ public static final HtmlColor COL_D1DBEF;
+ public static final HtmlColor COL_D7E0F2;
+ public static final HtmlColor COL_989898;
+ public static final HtmlColor COL_BBBBBB;
+
+
+ static {
+
+ final IHtmlColorSet set = new HtmlColorSetSimple();
+
+ BLACK = set.getColorIfValid("black");
+ WHITE = set.getColorIfValid("white");
+ RED_LIGHT = set.getColorIfValid("#FEF6F3");
+ RED_DARK = set.getColorIfValid("#CD0A0A");
+ RED = set.getColorIfValid("#FF0000");
+ GREEN = set.getColorIfValid("#00FF00");
+ BLUE = set.getColorIfValid("#0000FF");
+ GRAY = set.getColorIfValid("#808080");
+ LIGHT_GRAY = set.getColorIfValid("#C0C0C0");
+ MY_YELLOW = set.getColorIfValid("#FEFECE");
+ MY_RED = set.getColorIfValid("#A80036");
+
+ COL_C82930 = set.getColorIfValid("#C82930");
+ COL_F24D5C = set.getColorIfValid("#F24D5C");
+ COL_1963A0 = set.getColorIfValid("#1963A0");
+ COL_4177AF = set.getColorIfValid("#4177AF");
+ COL_B38D22 = set.getColorIfValid("#B38D22");
+ COL_FFFF44 = set.getColorIfValid("#FFFF44");
+ COL_038048 = set.getColorIfValid("#038048");
+ COL_84BE84 = set.getColorIfValid("#84BE84");
+ COL_DDDDDD = set.getColorIfValid("#DDDDDD");
+ COL_EEEEEE = set.getColorIfValid("#EEEEEE");
+ COL_FBFB77 = set.getColorIfValid("#FBFB77");
+ COL_ADD1B2 = set.getColorIfValid("#ADD1B2");
+ COL_A9DCDF = set.getColorIfValid("#A9DCDF");
+ COL_EB937F = set.getColorIfValid("#EB937F");
+ COL_B4A7E5 = set.getColorIfValid("#B4A7E5");
+ COL_527BC6 = set.getColorIfValid("#527BC6");
+ COL_D1DBEF = set.getColorIfValid("#D1DBEF");
+ COL_D7E0F2 = set.getColorIfValid("#D7E0F2");
+ COL_989898 = set.getColorIfValid("#989898");
+ COL_BBBBBB = set.getColorIfValid("#BBBBBB");
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlCommand.java b/src/net/sourceforge/plantuml/graphic/HtmlCommand.java
new file mode 100644
index 0000000..c6bd5b3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlCommand.java
@@ -0,0 +1,38 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public interface HtmlCommand {
+}
diff --git a/src/net/sourceforge/plantuml/graphic/HtmlCommandFactory.java b/src/net/sourceforge/plantuml/graphic/HtmlCommandFactory.java
new file mode 100644
index 0000000..03e5dbe
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/HtmlCommandFactory.java
@@ -0,0 +1,141 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.EnumSet;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.UrlBuilder;
+import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+class HtmlCommandFactory {
+
+ static final Pattern addStyle;
+ static final Pattern removeStyle;
+
+ static {
+ final StringBuilder sbAddStyle = new StringBuilder();
+ final StringBuilder sbRemoveStyle = new StringBuilder();
+
+ for (FontStyle style : EnumSet.allOf(FontStyle.class)) {
+ if (style == FontStyle.PLAIN) {
+ continue;
+ }
+ if (sbAddStyle.length() > 0) {
+ sbAddStyle.append('|');
+ sbRemoveStyle.append('|');
+ }
+ sbAddStyle.append(style.getActivationPattern());
+ sbRemoveStyle.append(style.getDeactivationPattern());
+ }
+
+ addStyle = MyPattern.cmpile(sbAddStyle.toString(), Pattern.CASE_INSENSITIVE);
+ removeStyle = MyPattern.cmpile(sbRemoveStyle.toString(), Pattern.CASE_INSENSITIVE);
+ }
+
+ private Pattern htmlTag = MyPattern.cmpile(Splitter.htmlTag, Pattern.CASE_INSENSITIVE);
+
+ HtmlCommand getHtmlCommand(String s) {
+ if (htmlTag.matcher(s).matches() == false) {
+ return new Text(s);
+ }
+ if (MyPattern.mtches(s, Splitter.imgPattern)) {
+ return Img.getInstance(s, true);
+ }
+
+ if (MyPattern.mtches(s, Splitter.imgPatternNoSrcColon)) {
+ return Img.getInstance(s, false);
+ }
+
+ if (addStyle.matcher(s).matches()) {
+ return new AddStyle(s);
+ }
+ if (removeStyle.matcher(s).matches()) {
+ return new RemoveStyle(FontStyle.getStyle(s));
+ }
+
+ if (MyPattern.mtches(s, Splitter.fontPattern)) {
+ return new ColorAndSizeChange(s);
+ }
+
+ if (MyPattern.mtches(s, Splitter.fontColorPattern2)) {
+ return new ColorChange(s);
+ }
+
+ if (MyPattern.mtches(s, Splitter.fontSizePattern2)) {
+ return new SizeChange(s);
+ }
+
+ if (MyPattern.mtches(s, Splitter.fontSup)) {
+ return new ExposantChange(FontPosition.EXPOSANT);
+ }
+
+ if (MyPattern.mtches(s, Splitter.fontSub)) {
+ return new ExposantChange(FontPosition.INDICE);
+ }
+
+ if (MyPattern.mtches(s, Splitter.endFontPattern)) {
+ return new ResetFont();
+ }
+
+ if (MyPattern.mtches(s, Splitter.endSupSub)) {
+ return new ExposantChange(FontPosition.NORMAL);
+ }
+
+ if (MyPattern.mtches(s, Splitter.fontFamilyPattern)) {
+ return new FontFamilyChange(s);
+ }
+
+ if (MyPattern.mtches(s, Splitter.spritePattern)) {
+ return new SpriteCommand(s);
+ }
+
+ if (MyPattern.mtches(s, Splitter.linkPattern)) {
+ final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.STRICT);
+ final Url url = urlBuilder.getUrl(s);
+ url.setMember(true);
+ return new TextLink(url);
+ }
+
+ if (MyPattern.mtches(s, Splitter.svgAttributePattern)) {
+ return new SvgAttributesChange(s);
+ }
+
+ return null;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/IHtmlColorSet.java b/src/net/sourceforge/plantuml/graphic/IHtmlColorSet.java
new file mode 100644
index 0000000..f5619c2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/IHtmlColorSet.java
@@ -0,0 +1,47 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.Collection;
+
+public interface IHtmlColorSet {
+
+ public Collection<String> names();
+
+ public HtmlColor getColorIfValid(String s);
+
+ public HtmlColor getColorIfValid(String s, boolean acceptTransparent);
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/Img.java b/src/net/sourceforge/plantuml/graphic/Img.java
new file mode 100644
index 0000000..d12c86c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/Img.java
@@ -0,0 +1,153 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.imageio.ImageIO;
+
+import net.sourceforge.plantuml.FileSystem;
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+public class Img implements HtmlCommand {
+
+ final static private Pattern srcPattern = MyPattern.cmpile("(?i)src[%s]*=[%s]*[\"%q]?([^%s\">]+)[\"%q]?");
+ final static private Pattern vspacePattern = MyPattern.cmpile("(?i)vspace[%s]*=[%s]*[\"%q]?(\\d+)[\"%q]?");
+ final static private Pattern valignPattern = MyPattern.cmpile("(?i)valign[%s]*=[%s]*[\"%q]?(top|bottom|middle)[\"%q]?");
+ final static private Pattern noSrcColonPattern = MyPattern.cmpile("(?i)" + Splitter.imgPatternNoSrcColon);
+
+ private final TextBlock tileImage;
+
+ private Img(TextBlock image) {
+ this.tileImage = image;
+ }
+
+ static int getVspace(String html) {
+ final Matcher m = vspacePattern.matcher(html);
+ if (m.find() == false) {
+ return 0;
+ }
+ return Integer.parseInt(m.group(1));
+ }
+
+ static ImgValign getValign(String html) {
+ final Matcher m = valignPattern.matcher(html);
+ if (m.find() == false) {
+ return ImgValign.TOP;
+ }
+ return ImgValign.valueOf(StringUtils.goUpperCase(m.group(1)));
+ }
+
+ static HtmlCommand getInstance(String html, boolean withSrc) {
+ if (withSrc) {
+ final Matcher m = srcPattern.matcher(html);
+ final int vspace = getVspace(html);
+ final ImgValign valign = getValign(html);
+ return build(m, valign, vspace);
+ }
+ final Matcher m = noSrcColonPattern.matcher(html);
+ return build(m, ImgValign.TOP, 0);
+ }
+
+ private static HtmlCommand build(final Matcher m, final ImgValign valign, final int vspace) {
+ if (m.find() == false) {
+ return new Text("(SYNTAX ERROR)");
+ }
+ final String src = m.group(1);
+ try {
+ final File f = FileSystem.getInstance().getFile(src);
+ if (f.exists() == false) {
+ // Check if valid URL
+ if (src.startsWith("http:") || src.startsWith("https:")) {
+ final byte image[] = getFile(src);
+ final BufferedImage read = ImageIO.read(new ByteArrayInputStream(image));
+ if (read == null) {
+ return new Text("(Cannot decode: " + src + ")");
+ }
+ return new Img(new TileImage(read, valign, vspace));
+ }
+ return new Text("(File not found: " + f + ")");
+ }
+ if (f.getName().endsWith(".svg")) {
+ return new Img(new TileImageSvg(f));
+ }
+ final BufferedImage read = ImageIO.read(f);
+ if (read == null) {
+ return new Text("(Cannot decode: " + f + ")");
+ }
+ return new Img(new TileImage(ImageIO.read(f), valign, vspace));
+ } catch (IOException e) {
+ return new Text("ERROR " + e.toString());
+ }
+ }
+
+ public TextBlock createMonoImage() {
+ return tileImage;
+ }
+
+ // Added by Alain Corbiere
+ static byte[] getFile(String host) throws IOException {
+ final ByteArrayOutputStream image = new ByteArrayOutputStream();
+ InputStream input = null;
+ try {
+ final URL url = new URL(host);
+ final URLConnection connection = url.openConnection();
+ input = connection.getInputStream();
+ final byte[] buffer = new byte[1024];
+ int read;
+ while ((read = input.read(buffer)) > 0) {
+ image.write(buffer, 0, read);
+ }
+ image.close();
+ return image.toByteArray();
+ } finally {
+ if (input != null) {
+ input.close();
+ }
+ }
+ }
+ // End
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/ImgValign.java b/src/net/sourceforge/plantuml/graphic/ImgValign.java
new file mode 100644
index 0000000..9c9c3d6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/ImgValign.java
@@ -0,0 +1,39 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public enum ImgValign {
+ TOP, BOTTOM, MIDDLE
+}
diff --git a/src/net/sourceforge/plantuml/graphic/Line.java b/src/net/sourceforge/plantuml/graphic/Line.java
new file mode 100644
index 0000000..21795a1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/Line.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+
+interface Line extends TextBlock {
+
+ HorizontalAlignment getHorizontalAlignment();
+}
diff --git a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java
new file mode 100644
index 0000000..30a7a6a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java
@@ -0,0 +1,160 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class QuoteUtils {
+
+ private static final List<String> quotes = Arrays
+ .asList(//
+ "He's dead, Jim.", //
+ "By Grabthar's hammer, by the sons of Worvan, you shall be avenged.", //
+ "Roads? Where we're going, we don't need roads.", //
+ "The time is out of joint.", //
+ "C'est curieux chez les marins ce besoin de faire des phrases.", //
+ "I'm talking about the other Peter, the one on the other side.", //
+ "May the Force be with you!", //
+ "Never give up, never surrender...", //
+ "Hasta la vista, baby.", //
+ "Hey, Doc, we better back up. We don't have enough road to get up to 88.", //
+ "Greetings, Professor Falken. Shall we play a game?", //
+ "I can't change the law of physics!", //
+ "A strange game. The only winning move is not to play.", //
+ "I'm the Gatekeeper, are you the Keymaster?", //
+ "I am the Master Control Program. No one User wrote me.", //
+ "Life? Don't talk to me about life.", //
+ "I always thought something was fundamentally wrong with the universe.", //
+ "A robot may not injure a human being or, through inaction, allow a human being to come to harm.", //
+ "Surrender may be our only option.", //
+ "Six by nine. Forty two.", //
+ "It's life, Jim, but not as we know it.", //
+ "Don't Panic!", //
+ "What do you mean? An African or European swallow?", //
+ "You forgot to say please...", //
+ "You have died of dysentery.", //
+ "Wouldn't you prefer a nice game of chess?", //
+ "When you have eliminated the impossible, whatever remains, however improbable, must be the truth.", //
+ "I know now why you cry. But it's something I can never do.", //
+ "Resistance is futile. You will be assimilated.", //
+ "Anything different is good.", //
+ "Cracked by Aldo Reset and Laurent Rueil.", //
+ "I'm both. I'm a celebrity in an emergency.", //
+ "Do you know this great great polish actor, Joseph Tura?", //
+ "To infinity and beyond!", //
+ "Space: the final frontier...", //
+ "Sur mon billet, tenez, y a ecrit Saint-Lazare, c'est mes yeux ou quoi ?", //
+ "The boy is important. He has to live.", //
+ "Once upon a time in a galaxy far, far away...", //
+ "And you know there's a long long way ahead of you...", //
+ "An allergy to oxygen? Elm blight?", //
+ "But alors you are French!", //
+ "N'ai-je donc tant vecu que pour cette infamie?", //
+ "Something is rotten in the State of Denmark.", //
+ "Hey, what do you want? Miracles?", //
+ "1.21 gigawatts! 1.21 gigawatts. Great Scott! ", //
+ "What the hell is a gigawatt?", //
+ "I need a vacation.", //
+ "On devrait jamais quitter Montauban.", //
+ "My force is a platform that you can climb on...", //
+ "There's something weird, and it don't look good...", //
+ "Et rien vraiment ne change mais tout est different", //
+ "Beam me up, Scotty.", //
+ "There is no spoon.", //
+ "Follow the white rabbit.", //
+ "Never send a human to do a machine's job.", //
+ "Guru meditation. Press left mouse button to continue.", //
+ "I don't think we're in Kansas anymore.", //
+ "Luke, I am your father.", //
+ "Blood, Sweat and Tears", //
+ "Houston, we have a problem.", //
+ "Boot failure, press any key to continue", //
+ "Big mistake!", //
+ "How many UML designers does it take to change a lightbulb ?", //
+ "Do you like movies about gladiators ?", //
+ "The spirit of learning is a lasting frontier.", //
+ "It is curious for sailors this need for making sentences.", //
+ "Hoping for the best, but expecting the worst", //
+ "The will to go on when I'm hurt deep inside.", //
+ "If it bleeds, we can kill it.", //
+ "Houston, I have a bad feeling about this mission.", //
+ "Mama always said life was like a box of chocolates. You never know what you're gonna get.", //
+ "By the way, is there anyone on board who knows how to fly a plane?", //
+ "Dave, this conversation can serve no purpose anymore. Goodbye.", //
+ "It can only be attributable to human error.", //
+ "Looks like I picked the wrong week to quit smoking.", //
+ "You humans act so strange. Everything you create is used to destroy.", //
+ "Where did you learn how to negotiate like that?", //
+ "Sir, are you classified as human?", //
+ "We're not gonna make it, are we?", //
+ "It's in your nature to destroy yourselves.", //
+ "The more contact I have with humans, the more I learn.", //
+ "Would it save you a lot of time if I just gave up and went mad now?", //
+ "Reality is frequently inaccurate.", //
+ "Don't believe anything you read on the net. Except this. Well, including this, I suppose.", //
+ "A cup of tea would restore my normality.", //
+ "Anything that thinks logically can be fooled by something else that thinks at least as logically as it does.", //
+ "In an infinite Universe anything can happen.", //
+ "Sometimes if you received an answer, the question might be taken away.", //
+ "Please call me Eddie if it will help you to relax.", //
+ "I don't believe it. Prove it to me and I still won't believe it.", //
+ "Totally mad, utter nonsense. But we'll do it because it's brilliant nonsense.", //
+ "This sentence is not true.", //
+ "I would rather die standing than live on my knees.", //
+ "You are being watched.", //
+ "Did you feed them after midnight?", //
+ "How do you explain school to higher intelligence?", //
+ "People sometimes make mistakes.", //
+ "Look, I don't have time for a conversation right now.", //
+ "All problems in computer science can be solved by another level of indirection", //
+ "...except for the problem of too many levels of indirection", //
+ "I know because I built it", //
+ "Even the smallest person can change the course of the future.", //
+ "If you are a friend, you speak the password, and the doors will open.", //
+ "You Shall Not Pass", //
+ "73.6% Of All Statistics Are Made Up", //
+ "We can neither confirm nor deny that this is crashing"
+ // When the beating of your heart echoes the beating of the drums
+ // Never trust a computer you can't throw out a window
+ );
+ private QuoteUtils() {
+ }
+
+ public static String getSomeQuote() {
+ final int v = (int) (System.currentTimeMillis() / 1000L);
+ return quotes.get(v % quotes.size());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/RemoveStyle.java b/src/net/sourceforge/plantuml/graphic/RemoveStyle.java
new file mode 100644
index 0000000..95cf117
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/RemoveStyle.java
@@ -0,0 +1,49 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+class RemoveStyle implements FontChange {
+
+ private final FontStyle style;
+
+ RemoveStyle(FontStyle style) {
+ this.style = style;
+ }
+
+ public FontConfiguration apply(FontConfiguration initial) {
+ return initial.remove(style);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/ResetFont.java b/src/net/sourceforge/plantuml/graphic/ResetFont.java
new file mode 100644
index 0000000..5c82273
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/ResetFont.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+class ResetFont implements FontChange {
+
+ public FontConfiguration apply(FontConfiguration initial) {
+ return initial.resetFont();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/SingleLine.java b/src/net/sourceforge/plantuml/graphic/SingleLine.java
new file mode 100644
index 0000000..b9b1418
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/SingleLine.java
@@ -0,0 +1,141 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+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;
+
+class SingleLine implements Line {
+
+ private final List<TextBlock> blocs = new ArrayList<TextBlock>();
+ private final HorizontalAlignment horizontalAlignment;
+
+ public SingleLine(String text, FontConfiguration fontConfiguration, HorizontalAlignment horizontalAlignment,
+ SpriteContainer spriteContainer) {
+ if (text.length() == 0) {
+ text = " ";
+ }
+ this.horizontalAlignment = horizontalAlignment;
+ final Splitter lineSplitter = new Splitter(text);
+
+ for (HtmlCommand cmd : lineSplitter.getHtmlCommands(false)) {
+ if (cmd instanceof Text) {
+ final String s = ((Text) cmd).getText();
+ blocs.add(new TileText(s, fontConfiguration, null));
+ } else if (cmd instanceof TextLink) {
+ final String s = ((TextLink) cmd).getText();
+ final Url url = ((TextLink) cmd).getUrl();
+ // blocs.add(new TileText(s, fontConfiguration.add(FontStyle.UNDERLINE), url));
+ blocs.add(new TileText(s, fontConfiguration, url));
+ } else if (cmd instanceof Img) {
+ blocs.add(((Img) cmd).createMonoImage());
+ } else if (cmd instanceof SpriteCommand) {
+ final Sprite sprite = spriteContainer.getSprite(((SpriteCommand) cmd).getSprite());
+ if (sprite != null) {
+ blocs.add(sprite.asTextBlock(fontConfiguration.getColor()));
+ }
+ } else if (cmd instanceof FontChange) {
+ fontConfiguration = ((FontChange) cmd).apply(fontConfiguration);
+ }
+ }
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ double width = 0;
+ double height = 0;
+ for (TextBlock b : blocs) {
+ final Dimension2D size2D = b.calculateDimension(stringBounder);
+ width += size2D.getWidth();
+ height = Math.max(height, size2D.getHeight());
+ }
+ return new Dimension2DDouble(width, height);
+ }
+
+ // private double maxDeltaY(Graphics2D g2d) {
+ // double result = 0;
+ // final Dimension2D dim = calculateDimension(StringBounderUtils.asStringBounder(g2d));
+ // for (TextBlock b : blocs) {
+ // if (b instanceof TileText == false) {
+ // continue;
+ // }
+ // final Dimension2D dimBloc = b.calculateDimension(StringBounderUtils.asStringBounder(g2d));
+ // final double deltaY = dim.getHeight() - dimBloc.getHeight() + ((TileText) b).getFontSize2D();
+ // result = Math.max(result, deltaY);
+ // }
+ // return result;
+ // }
+
+ private double maxDeltaY(UGraphic ug) {
+ double result = 0;
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ for (TextBlock b : blocs) {
+ if (b instanceof TileText == false) {
+ continue;
+ }
+ final Dimension2D dimBloc = b.calculateDimension(ug.getStringBounder());
+ final double deltaY = dim.getHeight() - dimBloc.getHeight() + ((TileText) b).getFontSize2D();
+ result = Math.max(result, deltaY);
+ }
+ return result;
+ }
+
+ public void drawU(UGraphic ug) {
+ final double deltaY = maxDeltaY(ug);
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dim = calculateDimension(stringBounder);
+ double x = 0;
+ for (TextBlock b : blocs) {
+ if (b instanceof TileText) {
+ b.drawU(ug.apply(new UTranslate(x, deltaY)));
+ } else {
+ final double dy = dim.getHeight() - b.calculateDimension(stringBounder).getHeight();
+ b.drawU(ug.apply(new UTranslate(x, dy)));
+ }
+ x += b.calculateDimension(stringBounder).getWidth();
+ }
+ }
+
+ public HorizontalAlignment getHorizontalAlignment() {
+ return horizontalAlignment;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/SizeChange.java b/src/net/sourceforge/plantuml/graphic/SizeChange.java
new file mode 100644
index 0000000..22f4445
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/SizeChange.java
@@ -0,0 +1,64 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+class SizeChange implements FontChange {
+
+ static private final Pattern sizePattern = MyPattern.cmpile("(?i)" + Splitter.fontSizePattern2);
+
+ private final Integer size;
+
+ SizeChange(String s) {
+ final Matcher matcherSize = sizePattern.matcher(s);
+ if (matcherSize.find() == false) {
+ throw new IllegalArgumentException();
+ }
+ size = new Integer(matcherSize.group(1));
+ }
+
+ Integer getSize() {
+ return size;
+ }
+
+ public FontConfiguration apply(FontConfiguration initial) {
+ return initial.changeSize(size);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/SkinParameter.java b/src/net/sourceforge/plantuml/graphic/SkinParameter.java
new file mode 100644
index 0000000..76c9dda
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/SkinParameter.java
@@ -0,0 +1,131 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.FontParam;
+
+public class SkinParameter {
+
+ public static final SkinParameter DATABASE = new SkinParameter("DATABASE", ColorParam.databaseBackground,
+ ColorParam.databaseBorder, FontParam.DATABASE, FontParam.DATABASE_STEREOTYPE);
+
+ public static final SkinParameter ARTIFACT = new SkinParameter("ARTIFACT", ColorParam.artifactBackground,
+ ColorParam.artifactBorder, FontParam.ARTIFACT, FontParam.ARTIFACT_STEREOTYPE);
+
+ public static final SkinParameter COMPONENT1 = new SkinParameter("COMPONENT1", ColorParam.componentBackground,
+ ColorParam.componentBorder, FontParam.COMPONENT, FontParam.COMPONENT_STEREOTYPE);
+
+ public static final SkinParameter NODE = new SkinParameter("NODE", ColorParam.nodeBackground,
+ ColorParam.nodeBorder, FontParam.NODE, FontParam.NODE_STEREOTYPE);
+
+ public static final SkinParameter STORAGE = new SkinParameter("STORAGE", ColorParam.storageBackground,
+ ColorParam.storageBorder, FontParam.STORAGE, FontParam.STORAGE_STEREOTYPE);
+
+ public static final SkinParameter QUEUE = new SkinParameter("QUEUE", ColorParam.queueBackground,
+ ColorParam.queueBorder, FontParam.QUEUE, FontParam.QUEUE_STEREOTYPE);
+
+ public static final SkinParameter CLOUD = new SkinParameter("CLOUD", ColorParam.cloudBackground,
+ ColorParam.cloudBorder, FontParam.CLOUD, FontParam.CLOUD_STEREOTYPE);
+
+ public static final SkinParameter FRAME = new SkinParameter("FRAME", ColorParam.frameBackground,
+ ColorParam.frameBorder, FontParam.FRAME, FontParam.FRAME_STEREOTYPE);
+
+ public static final SkinParameter COMPONENT2 = new SkinParameter("COMPONENT2", ColorParam.componentBackground,
+ ColorParam.componentBorder, FontParam.COMPONENT, FontParam.COMPONENT_STEREOTYPE);
+
+ public static final SkinParameter AGENT = new SkinParameter("AGENT", ColorParam.agentBackground,
+ ColorParam.agentBorder, FontParam.AGENT, FontParam.AGENT_STEREOTYPE);
+
+ public static final SkinParameter FOLDER = new SkinParameter("FOLDER", ColorParam.folderBackground,
+ ColorParam.folderBorder, FontParam.FOLDER, FontParam.FOLDER_STEREOTYPE);
+
+ public static final SkinParameter PACKAGE = new SkinParameter("PACKAGE", ColorParam.packageBackground,
+ ColorParam.packageBorder, FontParam.FOLDER, FontParam.FOLDER_STEREOTYPE);
+
+ public static final SkinParameter CARD = new SkinParameter("CARD", ColorParam.rectangleBackground,
+ ColorParam.rectangleBorder, FontParam.RECTANGLE, FontParam.RECTANGLE_STEREOTYPE);
+
+ public static final SkinParameter ACTOR = new SkinParameter("ACTOR", ColorParam.actorBackground,
+ ColorParam.actorBorder, FontParam.ACTOR, FontParam.ACTOR_STEREOTYPE);
+
+ public static final SkinParameter BOUNDARY = new SkinParameter("BOUNDARY", ColorParam.boundaryBackground,
+ ColorParam.boundaryBorder, FontParam.BOUNDARY, FontParam.BOUNDARY_STEREOTYPE);
+
+ public static final SkinParameter CONTROL = new SkinParameter("CONTROL", ColorParam.controlBackground,
+ ColorParam.controlBorder, FontParam.CONTROL, FontParam.CONTROL_STEREOTYPE);
+
+ public static final SkinParameter ENTITY_DOMAIN = new SkinParameter("ENTITY_DOMAIN", ColorParam.entityBackground,
+ ColorParam.entityBorder, FontParam.ENTITY, FontParam.ENTITY_STEREOTYPE);
+
+ public static final SkinParameter INTERFACE = new SkinParameter("INTERFACE", ColorParam.interfaceBackground,
+ ColorParam.interfaceBorder, FontParam.INTERFACE, FontParam.INTERFACE_STEREOTYPE);
+
+ private final ColorParam colorParamBorder;
+ private final ColorParam colorParamBack;
+ private final FontParam fontParam;
+ private final FontParam fontParamStereotype;
+ private final String name;
+
+ private SkinParameter(String name, ColorParam colorParamBack, ColorParam colorParamBorder, FontParam fontParam,
+ FontParam fontParamStereotype) {
+ this.name = name;
+ this.colorParamBack = colorParamBack;
+ this.colorParamBorder = colorParamBorder;
+ this.fontParam = fontParam;
+ this.fontParamStereotype = fontParamStereotype;
+ }
+
+ public String getUpperCaseName() {
+ return name;
+ }
+
+ public ColorParam getColorParamBorder() {
+ return colorParamBorder;
+ }
+
+ public ColorParam getColorParamBack() {
+ return colorParamBack;
+ }
+
+ public FontParam getFontParam() {
+ return fontParam;
+ }
+
+ public FontParam getFontParamStereotype() {
+ return fontParamStereotype;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/Splitter.java b/src/net/sourceforge/plantuml/graphic/Splitter.java
new file mode 100644
index 0000000..9bf186d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/Splitter.java
@@ -0,0 +1,157 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumSet;
+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;
+
+public class Splitter {
+
+ static final String endFontPattern = "\\</font\\>|\\</color\\>|\\</size\\>|\\</text\\>";
+ static final String endSupSub = "\\</sup\\>|\\</sub\\>";
+ public static final String fontPattern = "\\<font(\\s+size[%s]*=[%s]*[%g]?\\d+[%g]?|[%s]+color[%s]*=\\s*[%g]?(#[0-9a-fA-F]{6}|\\w+)[%g]?)+[%s]*\\>";
+ public static final String fontColorPattern2 = "\\<color[\\s:]+(#[0-9a-fA-F]{6}|#?\\w+)[%s]*\\>";
+ public static final String fontSizePattern2 = "\\<size[\\s:]+(\\d+)[%s]*\\>";
+ static final String fontSup = "\\<sup\\>";
+ static final String fontSub = "\\<sub\\>";
+ static final String imgPattern = "\\<img\\s+(src[%s]*=[%s]*[%q%g]?[^\\s%g>]+[%q%g]?[%s]*|vspace\\s*=\\s*[%q%g]?\\d+[%q%g]?\\s*|valign[%s]*=[%s]*[%q%g]?(top|middle|bottom)[%q%g]?[%s]*)+\\>";
+ public static final String imgPatternNoSrcColon = "\\<img[\\s:]+([^>]+)/?\\>";
+ public static final String fontFamilyPattern = "\\<font[\\s:]+([^>]+)/?\\>";
+ public static final String svgAttributePattern = "\\<text[\\s:]+([^>]+)/?\\>";
+ public static final String openiconPattern = "\\<&([-\\w]+)\\>";
+ public static final String spritePattern = "\\<\\$[\\p{L}0-9_]+\\>";
+ public static final String spritePattern2 = "\\<\\$([\\p{L}0-9_]+)\\>";
+ static final String htmlTag;
+
+ static final String linkPattern = "\\[\\[([^\\[\\]]+)\\]\\]";
+
+ private static final Pattern tagOrText;
+
+ static {
+ final StringBuilder sb = new StringBuilder("(?i)");
+
+ for (FontStyle style : EnumSet.allOf(FontStyle.class)) {
+ if (style == FontStyle.PLAIN) {
+ continue;
+ }
+ sb.append(style.getActivationPattern());
+ sb.append('|');
+ sb.append(style.getDeactivationPattern());
+ sb.append('|');
+ }
+ sb.append(fontPattern);
+ sb.append('|');
+ sb.append(fontColorPattern2);
+ sb.append('|');
+ sb.append(fontSizePattern2);
+ sb.append('|');
+ sb.append(fontSup);
+ sb.append('|');
+ sb.append(fontSub);
+ sb.append('|');
+ sb.append(endFontPattern);
+ sb.append('|');
+ sb.append(endSupSub);
+ sb.append('|');
+ sb.append(imgPattern);
+ sb.append('|');
+ sb.append(imgPatternNoSrcColon);
+ sb.append('|');
+ sb.append(fontFamilyPattern);
+ sb.append('|');
+ sb.append(spritePattern);
+ sb.append('|');
+ sb.append(linkPattern);
+ sb.append('|');
+ sb.append(svgAttributePattern);
+
+ htmlTag = sb.toString();
+ tagOrText = MyPattern.cmpile(htmlTag + "|.+?(?=" + htmlTag + ")|.+$", Pattern.CASE_INSENSITIVE);
+ }
+
+ private final List<String> splitted = new ArrayList<String>();
+
+ public Splitter(String s) {
+ final Matcher matcher = tagOrText.matcher(s);
+ while (matcher.find()) {
+ String part = matcher.group(0);
+ part = StringUtils.showComparatorCharacters(part);
+ splitted.add(part);
+ }
+ }
+
+ List<String> getSplittedInternal() {
+ return splitted;
+ }
+
+ public List<HtmlCommand> getHtmlCommands(boolean newLineAlone) {
+ final HtmlCommandFactory factory = new HtmlCommandFactory();
+ final List<HtmlCommand> result = new ArrayList<HtmlCommand>();
+ for (String s : getSplittedInternal()) {
+ final HtmlCommand cmd = factory.getHtmlCommand(s);
+ if (newLineAlone && cmd instanceof Text) {
+ result.addAll(splitText((Text) cmd));
+ } else {
+ result.add(cmd);
+ }
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ private Collection<Text> splitText(Text cmd) {
+ String s = cmd.getText();
+ final Collection<Text> result = new ArrayList<Text>();
+ while (true) {
+ final int x = s.indexOf(Text.NEWLINE.getText());
+ if (x == -1) {
+ result.add(new Text(s));
+ return result;
+ }
+ if (x > 0) {
+ result.add(new Text(s.substring(0, x)));
+ }
+ result.add(Text.NEWLINE);
+ s = s.substring(x + 2);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/SpriteCommand.java b/src/net/sourceforge/plantuml/graphic/SpriteCommand.java
new file mode 100644
index 0000000..8650fb0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/SpriteCommand.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public class SpriteCommand implements HtmlCommand {
+
+ private final String sprite;
+
+ SpriteCommand(String sprite) {
+ if (sprite == null) {
+ throw new IllegalArgumentException();
+ }
+ if (sprite.startsWith("<$") == false) {
+ throw new IllegalArgumentException();
+ }
+ if (sprite.endsWith(">") == false) {
+ throw new IllegalArgumentException();
+ }
+ this.sprite = sprite.substring(2, sprite.length() - 1).trim();
+ }
+
+ public String getSprite() {
+ return sprite;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/StringBounder.java b/src/net/sourceforge/plantuml/graphic/StringBounder.java
new file mode 100644
index 0000000..69b02ce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/StringBounder.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public interface StringBounder {
+
+ public Dimension2D calculateDimension(UFont font, String text);
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/StringBounderUtils.java b/src/net/sourceforge/plantuml/graphic/StringBounderUtils.java
new file mode 100644
index 0000000..a9916a7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/StringBounderUtils.java
@@ -0,0 +1,57 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.FontMetrics;
+import java.awt.Graphics2D;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Rectangle2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class StringBounderUtils {
+
+ public static StringBounder asStringBounder(final Graphics2D g2d) {
+
+ return new StringBounder() {
+ public Dimension2D calculateDimension(UFont font, String text) {
+ final FontMetrics fm = g2d.getFontMetrics(font.getFont());
+ final Rectangle2D rect = fm.getStringBounds(text, g2d);
+ return new Dimension2DDouble(rect.getWidth(), rect.getHeight());
+ }
+ };
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/SvgAttributes.java b/src/net/sourceforge/plantuml/graphic/SvgAttributes.java
new file mode 100644
index 0000000..ae15f80
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/SvgAttributes.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.StringUtils;
+
+public class SvgAttributes {
+
+ private final Map<String, String> attributes = new TreeMap<String, String>();
+
+ public SvgAttributes() {
+ }
+
+ private SvgAttributes(SvgAttributes other) {
+ this.attributes.putAll(other.attributes);
+ }
+
+ public SvgAttributes(String args) {
+ final Pattern p = MyPattern.cmpile("(\\w+)\\s*=\\s*([%g][^%g]*[%g]|(?:\\w+))");
+ final Matcher m = p.matcher(args);
+ while (m.find()) {
+ attributes.put(m.group(1), StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m.group(2)));
+ }
+ }
+
+ public Map<String, String> attributes() {
+ return Collections.unmodifiableMap(attributes);
+ }
+
+ public SvgAttributes add(String key, String value) {
+ final SvgAttributes result = new SvgAttributes(this);
+ result.attributes.put(key, value);
+ return result;
+ }
+
+ public SvgAttributes add(SvgAttributes toBeAdded) {
+ final SvgAttributes result = new SvgAttributes(this);
+ result.attributes.putAll(toBeAdded.attributes);
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/SvgAttributesChange.java b/src/net/sourceforge/plantuml/graphic/SvgAttributesChange.java
new file mode 100644
index 0000000..3ff9b0e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/SvgAttributesChange.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import net.sourceforge.plantuml.command.regex.MyPattern;
+
+class SvgAttributesChange implements FontChange {
+
+ static final Pattern pattern = MyPattern.cmpile(Splitter.svgAttributePattern);
+ private final SvgAttributes attributes;
+
+ SvgAttributesChange(String s) {
+ final Matcher m = pattern.matcher(s);
+ if (m.find() == false) {
+ throw new IllegalStateException();
+ }
+ attributes = new SvgAttributes(m.group(1));
+ }
+
+ public FontConfiguration apply(FontConfiguration initial) {
+ return initial.changeAttributes(attributes);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/SymbolContext.java b/src/net/sourceforge/plantuml/graphic/SymbolContext.java
new file mode 100644
index 0000000..eb28041
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/SymbolContext.java
@@ -0,0 +1,119 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class SymbolContext {
+
+ private final HtmlColor backColor;
+ private final HtmlColor foreColor;
+ private final UStroke stroke;
+ private final boolean shadowing;
+ private final double deltaShadow;
+
+ private SymbolContext(HtmlColor backColor, HtmlColor foreColor, UStroke stroke, boolean shadowing,
+ double deltaShadow) {
+ this.backColor = backColor;
+ this.foreColor = foreColor;
+ this.stroke = stroke;
+ this.shadowing = shadowing;
+ this.deltaShadow = deltaShadow;
+ // if (backColor instanceof HtmlColorTransparent) {
+ // throw new UnsupportedOperationException();
+ // }
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " backColor=" + backColor + " foreColor=" + foreColor;
+ }
+
+ final public UGraphic apply(UGraphic ug) {
+ return applyStroke(applyColors(ug));
+ }
+
+ public UGraphic applyColors(UGraphic ug) {
+ return ug.apply(new UChangeColor(foreColor)).apply(new UChangeBackColor(backColor));
+ }
+
+ public UGraphic applyStroke(UGraphic ug) {
+ return ug.apply(stroke);
+ }
+
+ public SymbolContext(HtmlColor backColor, HtmlColor foreColor) {
+ this(backColor, foreColor, new UStroke(), false, 0);
+ }
+
+ public SymbolContext withShadow(boolean newShadow) {
+ return new SymbolContext(backColor, foreColor, stroke, newShadow, deltaShadow);
+ }
+
+ public SymbolContext withDeltaShadow(double deltaShadow) {
+ return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow);
+ }
+
+ public SymbolContext withStroke(UStroke newStroke) {
+ return new SymbolContext(backColor, foreColor, newStroke, shadowing, deltaShadow);
+ }
+
+ public SymbolContext withBackColor(HtmlColor backColor) {
+ return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow);
+ }
+
+ public HtmlColor getBackColor() {
+ return backColor;
+ }
+
+ public HtmlColor getForeColor() {
+ return foreColor;
+ }
+
+ public UStroke getStroke() {
+ return stroke;
+ }
+
+ public boolean isShadowing() {
+ return shadowing || deltaShadow > 0;
+ }
+
+ public double getDeltaShadow() {
+ return deltaShadow;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/Text.java b/src/net/sourceforge/plantuml/graphic/Text.java
new file mode 100644
index 0000000..5b70d2d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/Text.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public class Text implements HtmlCommand {
+
+ private final String text;
+
+ public static final Text NEWLINE = new Text("\\n");
+
+ Text(String text) {
+ this.text = text.replaceAll("\\\\\\[", "[").replaceAll("\\\\\\]", "]");
+ if (text.indexOf('\n') != -1) {
+ throw new IllegalArgumentException();
+ }
+ if (text.length() == 0) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public String getText() {
+ assert text.length() > 0;
+ return text;
+ }
+
+ public boolean isNewline() {
+ return text.equals("\\n");
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlock.java b/src/net/sourceforge/plantuml/graphic/TextBlock.java
new file mode 100644
index 0000000..b148ecb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlock.java
@@ -0,0 +1,45 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public interface TextBlock extends UDrawable, UShape {
+
+ public Dimension2D calculateDimension(StringBounder stringBounder);
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockArrow.java b/src/net/sourceforge/plantuml/graphic/TextBlockArrow.java
new file mode 100644
index 0000000..4a8b111
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockArrow.java
@@ -0,0 +1,110 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Direction;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TextBlockArrow implements TextBlock {
+
+ private final double size;
+ private final Direction arrow;
+ private final HtmlColor color;
+
+ public TextBlockArrow(Direction arrow, FontConfiguration fontConfiguration) {
+ if (arrow == null) {
+ throw new IllegalArgumentException();
+ }
+ this.arrow = arrow;
+ // this.size = fontConfiguration.getFont().getSize2D() * 0 + 30;
+ this.size = fontConfiguration.getFont().getSize2D();
+ this.color = fontConfiguration.getColor();
+
+ }
+
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UChangeBackColor(color));
+ ug = ug.apply(new UChangeColor(color));
+ int triSize = (int) (size * .8 - 3);
+ if (triSize % 2 == 1) {
+ triSize--;
+ }
+ final UPolygon triangle = getTriangle(triSize);
+ if (arrow == Direction.RIGHT || arrow == Direction.LEFT) {
+ ug.apply(new UTranslate(2, (size - triSize) - 2)).draw(triangle);
+ } else {
+ ug.apply(new UTranslate(2, (size - triSize) - 2)).draw(triangle);
+ }
+ }
+
+ private UPolygon getTriangle(int triSize) {
+ final UPolygon triangle = new UPolygon();
+ if (arrow == Direction.RIGHT) {
+ triangle.addPoint(0, 0);
+ triangle.addPoint(triSize, triSize / 2);
+ triangle.addPoint(0, triSize);
+ triangle.addPoint(0, 0);
+ } else if (arrow == Direction.LEFT) {
+ triangle.addPoint(triSize, 0);
+ triangle.addPoint(0, triSize / 2);
+ triangle.addPoint(triSize, triSize);
+ triangle.addPoint(triSize, 0);
+ } else if (arrow == Direction.UP) {
+ triangle.addPoint(0, triSize);
+ triangle.addPoint(triSize / 2, 0);
+ triangle.addPoint(triSize, triSize);
+ triangle.addPoint(0, triSize);
+ } else if (arrow == Direction.DOWN) {
+ triangle.addPoint(0, 0);
+ triangle.addPoint(triSize / 2, triSize);
+ triangle.addPoint(triSize, 0);
+ triangle.addPoint(0, 0);
+ } else {
+ throw new IllegalStateException();
+ }
+ return triangle;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(size, size);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockBordered.java b/src/net/sourceforge/plantuml/graphic/TextBlockBordered.java
new file mode 100644
index 0000000..1e2780a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockBordered.java
@@ -0,0 +1,65 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class TextBlockBordered implements TextBlock {
+
+ private final TextBlock textBlock;
+ private final HtmlColor color;
+
+ public TextBlockBordered(TextBlock textBlock, HtmlColor color) {
+ this.textBlock = textBlock;
+ this.color = color;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = textBlock.calculateDimension(stringBounder);
+ return Dimension2DDouble.delta(dim, 1, 1);
+ }
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = textBlock.calculateDimension(ug.getStringBounder());
+ textBlock.drawU(ug.apply(new UTranslate(1, 1)));
+ ug.apply(new UChangeColor(color)).draw(new URectangle(dim.getWidth(), dim.getHeight()));
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockCompressed.java b/src/net/sourceforge/plantuml/graphic/TextBlockCompressed.java
new file mode 100644
index 0000000..12f7343
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockCompressed.java
@@ -0,0 +1,73 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.CompressionTransform;
+import net.sourceforge.plantuml.ugraphic.SlotFinder;
+import net.sourceforge.plantuml.ugraphic.SlotSet;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphicCompress;
+
+public class TextBlockCompressed implements TextBlock {
+
+ private final TextBlock textBlock;
+
+ public TextBlockCompressed(TextBlock textBlock) {
+ this.textBlock = textBlock;
+ }
+
+ public void drawU(final UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final CompressionTransform compressionTransform = getCompressionTransform(stringBounder);
+ textBlock.drawU(new UGraphicCompress(ug, compressionTransform));
+ }
+
+ private CompressionTransform getCompressionTransform(final StringBounder stringBounder) {
+ final SlotFinder slotFinder = new SlotFinder(stringBounder);
+ textBlock.drawU(slotFinder);
+ final SlotSet ysSlotSet = slotFinder.getYSlotSet().reverse().smaller(5.0);
+ final CompressionTransform compressionTransform = new CompressionTransform(ysSlotSet);
+ return compressionTransform;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final CompressionTransform compressionTransform = getCompressionTransform(stringBounder);
+ final Dimension2D dim = textBlock.calculateDimension(stringBounder);
+ return new Dimension2DDouble(dim.getWidth(), compressionTransform.transform(dim.getHeight()));
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockCompressed2.java b/src/net/sourceforge/plantuml/graphic/TextBlockCompressed2.java
new file mode 100644
index 0000000..66bba9b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockCompressed2.java
@@ -0,0 +1,62 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.CompressionTransform;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphicCompress2;
+
+public class TextBlockCompressed2 implements TextBlock {
+
+ private final TextBlock textBlock;
+ private final CompressionTransform compressionTransform;
+
+ public TextBlockCompressed2(TextBlock textBlock, CompressionTransform compressionTransform) {
+ this.textBlock = textBlock;
+ this.compressionTransform = compressionTransform;
+ }
+
+ public void drawU(final UGraphic ug) {
+ textBlock.drawU(new UGraphicCompress2(ug, compressionTransform));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = textBlock.calculateDimension(stringBounder);
+ return new Dimension2DDouble(compressionTransform.transform(dim.getWidth()), dim.getHeight());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockEmpty.java b/src/net/sourceforge/plantuml/graphic/TextBlockEmpty.java
new file mode 100644
index 0000000..514bd7c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockEmpty.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class TextBlockEmpty implements TextBlockWidth, TextBlock {
+
+ private final double width;
+ private final double height;
+
+ public TextBlockEmpty(double width, double height) {
+ this.width = width;
+ this.height = height;
+ }
+
+ public TextBlockEmpty() {
+ this(0, 0);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+
+ public void drawU(UGraphic ug) {
+ }
+
+ public TextBlock asTextBlock(final double widthToUse) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return TextBlockEmpty.this.calculateDimension(stringBounder);
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockGeneric.java b/src/net/sourceforge/plantuml/graphic/TextBlockGeneric.java
new file mode 100644
index 0000000..ac050d0
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockGeneric.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class TextBlockGeneric implements TextBlock {
+
+ private final TextBlock textBlock;
+ private final HtmlColor background;
+ private final HtmlColor border;
+
+ public TextBlockGeneric(TextBlock textBlock, HtmlColor background, HtmlColor border) {
+ this.textBlock = textBlock;
+ this.border = border;
+ this.background = background;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = textBlock.calculateDimension(stringBounder);
+ return dim;
+ }
+
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UChangeBackColor(background));
+ ug = ug.apply(new UChangeColor(border));
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug.apply(new UStroke(2, 2, 1)).draw(new URectangle(dim.getWidth(), dim.getHeight()));
+
+ textBlock.drawU(ug);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockHorizontal.java b/src/net/sourceforge/plantuml/graphic/TextBlockHorizontal.java
new file mode 100644
index 0000000..eef19f9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockHorizontal.java
@@ -0,0 +1,75 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class TextBlockHorizontal implements TextBlock {
+
+ private final TextBlock b1;
+ private final TextBlock b2;
+ private final VerticalAlignment alignment;
+
+ public TextBlockHorizontal(TextBlock b1, TextBlock b2, VerticalAlignment alignment) {
+ this.b1 = b1;
+ this.b2 = b2;
+ this.alignment = alignment;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim1 = b1.calculateDimension(stringBounder);
+ final Dimension2D dim2 = b2.calculateDimension(stringBounder);
+ return Dimension2DDouble.mergeLR(dim1, dim2);
+ }
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ final Dimension2D dimb1 = b1.calculateDimension(ug.getStringBounder());
+ final Dimension2D dimb2 = b2.calculateDimension(ug.getStringBounder());
+ final Dimension2D dim1 = b1.calculateDimension(ug.getStringBounder());
+ if (alignment == VerticalAlignment.CENTER) {
+ b1.drawU(ug.apply(new UTranslate(0, ((dim.getHeight() - dimb1.getHeight()) / 2))));
+ b2.drawU(ug.apply(new UTranslate(dim1.getWidth(), ((dim.getHeight() - dimb2.getHeight()) / 2))));
+ } else {
+ b1.drawU(ug);
+ b2.drawU(ug.apply(new UTranslate(dim1.getWidth(), 0)));
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockLineBefore.java b/src/net/sourceforge/plantuml/graphic/TextBlockLineBefore.java
new file mode 100644
index 0000000..3d74311
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockLineBefore.java
@@ -0,0 +1,85 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UHorizontalLine;
+
+public class TextBlockLineBefore implements TextBlock {
+
+ private final TextBlock textBlock;
+ private final char separator;
+ private final TextBlock title;
+
+ public TextBlockLineBefore(TextBlock textBlock, char separator, TextBlock title) {
+ this.textBlock = textBlock;
+ this.separator = separator;
+ this.title = title;
+ }
+
+ public TextBlockLineBefore(TextBlock textBlock, char separator) {
+ this(textBlock, separator, null);
+ }
+
+ public TextBlockLineBefore(TextBlock textBlock) {
+ this(textBlock, '\0');
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = textBlock.calculateDimension(stringBounder);
+ if (title != null) {
+ final Dimension2D dimTitle = title.calculateDimension(stringBounder);
+ return Dimension2DDouble.atLeast(dim, dimTitle.getWidth() + 8, dimTitle.getHeight());
+ }
+ return dim;
+ }
+
+ public void drawU(UGraphic ug) {
+ final HtmlColor color = ug.getParam().getColor();
+ if (title == null) {
+ UHorizontalLine.infinite(1, 1, separator).drawMe(ug);
+ }
+ textBlock.drawU(ug);
+ ug = ug.apply(new UChangeColor(color));
+ if (title != null) {
+ UHorizontalLine.infinite(1, 1, title, separator).drawMe(ug);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockMarged.java b/src/net/sourceforge/plantuml/graphic/TextBlockMarged.java
new file mode 100644
index 0000000..d734f9a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockMarged.java
@@ -0,0 +1,68 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class TextBlockMarged implements TextBlock {
+
+ private final TextBlock textBlock;
+ private final double x1;
+ private final double x2;
+ private final double y1;
+ private final double y2;
+
+ public TextBlockMarged(TextBlock textBlock, double x1, double x2, double y1, double y2) {
+ this.textBlock = textBlock;
+ this.x1 = x1;
+ this.x2 = x2;
+ this.y1 = y1;
+ this.y2 = y2;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = textBlock.calculateDimension(stringBounder);
+ return Dimension2DDouble.delta(dim, x1 + x2, y1 + y2);
+ }
+
+ public void drawU(UGraphic ug) {
+ textBlock.drawU(ug.apply(new UTranslate(x1, y1)));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockMinWidth.java b/src/net/sourceforge/plantuml/graphic/TextBlockMinWidth.java
new file mode 100644
index 0000000..db62e12
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockMinWidth.java
@@ -0,0 +1,71 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class TextBlockMinWidth implements TextBlock {
+
+ private final TextBlock textBlock;
+ private final double minWidth;
+ private final HorizontalAlignment horizontalAlignment;
+
+ public TextBlockMinWidth(TextBlock textBlock, double minWidth, HorizontalAlignment horizontalAlignment) {
+ this.textBlock = textBlock;
+ this.minWidth = minWidth;
+ this.horizontalAlignment = horizontalAlignment;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = textBlock.calculateDimension(stringBounder);
+ return Dimension2DDouble.atLeast(dim, minWidth, 0);
+ }
+
+ public void drawU(UGraphic ug) {
+ if (horizontalAlignment == HorizontalAlignment.LEFT) {
+ textBlock.drawU(ug);
+ } else if (horizontalAlignment == HorizontalAlignment.RIGHT) {
+ final Dimension2D dim = textBlock.calculateDimension(ug.getStringBounder());
+ final double diffx = minWidth - dim.getWidth();
+ textBlock.drawU(ug.apply(new UTranslate(diffx, 0)));
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockRecentred.java b/src/net/sourceforge/plantuml/graphic/TextBlockRecentred.java
new file mode 100644
index 0000000..1cfdbc4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockRecentred.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ugraphic.MinMax;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TextBlockRecentred implements TextBlock {
+
+ private final TextBlock textBlock;
+
+ public TextBlockRecentred(TextBlock textBlock) {
+ this.textBlock = textBlock;
+ }
+
+ public void drawU(final UGraphic ug) {
+ final MinMax minMax = TextBlockUtils.getMinMax(textBlock);
+ textBlock.drawU(ug.apply(new UTranslate(-minMax.getMinX(), -minMax.getMinY())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final MinMax minMax = TextBlockUtils.getMinMax(textBlock);
+ return minMax.getDimension();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java b/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java
new file mode 100644
index 0000000..a9b10c2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java
@@ -0,0 +1,203 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.EmbededDiagram;
+import net.sourceforge.plantuml.SpriteContainer;
+import net.sourceforge.plantuml.command.regex.MyPattern;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class TextBlockSimple implements TextBlock {
+
+ private List<Line> lines2;
+
+ private final Display texts;
+ private final FontConfiguration fontConfiguration;
+ private final UFont fontForStereotype;
+ private final HorizontalAlignment horizontalAlignment;
+ private final SpriteContainer spriteContainer;
+ private final double maxMessageSize;
+ private final HtmlColor htmlColorForStereotype;
+
+ protected TextBlockSimple(Display texts, FontConfiguration fontConfiguration,
+ HorizontalAlignment horizontalAlignment, SpriteContainer spriteContainer, double maxMessageSize) {
+ this(texts, fontConfiguration, horizontalAlignment, spriteContainer, maxMessageSize, null, null);
+ }
+
+ protected TextBlockSimple(Display texts, FontConfiguration fontConfiguration,
+ HorizontalAlignment horizontalAlignment, SpriteContainer spriteContainer, double maxMessageSize,
+ UFont fontForStereotype, HtmlColor htmlColorForStereotype) {
+ this.texts = texts;
+ this.fontConfiguration = fontConfiguration;
+ this.horizontalAlignment = horizontalAlignment;
+ this.spriteContainer = spriteContainer;
+ this.maxMessageSize = maxMessageSize;
+ this.fontForStereotype = fontForStereotype;
+ this.htmlColorForStereotype = htmlColorForStereotype;
+ }
+
+ private List<Line> getLines(StringBounder stringBounder) {
+ if (lines2 == null) {
+ if (stringBounder == null) {
+ throw new IllegalStateException();
+ }
+ this.lines2 = new ArrayList<Line>();
+ for (CharSequence s : texts) {
+ if (s instanceof Stereotype) {
+ lines2.addAll(createLinesForStereotype(
+ fontConfiguration.forceFont(fontForStereotype, htmlColorForStereotype), (Stereotype) s,
+ horizontalAlignment, spriteContainer));
+ } else if (s instanceof EmbededDiagram) {
+ lines2.add(new EmbededSystemLine((EmbededDiagram) s));
+ } else {
+ addInLines(stringBounder, s.toString());
+ }
+ }
+ }
+ return lines2;
+ }
+
+ private void addInLines(StringBounder stringBounder, String s) {
+ if (maxMessageSize == 0) {
+ addSingleLine(s);
+ } else if (maxMessageSize > 0) {
+ final StringTokenizer st = new StringTokenizer(s, " ", true);
+ final StringBuilder currentLine = new StringBuilder();
+ while (st.hasMoreTokens()) {
+ final String token = st.nextToken();
+ final double w = getTextWidth(stringBounder, currentLine + token);
+ if (w > maxMessageSize) {
+ addSingleLineNoSpace(currentLine.toString());
+ currentLine.setLength(0);
+ if (token.startsWith(" ") == false) {
+ currentLine.append(token);
+ }
+ } else {
+ currentLine.append(token);
+ }
+ }
+ addSingleLineNoSpace(currentLine.toString());
+ } else if (maxMessageSize < 0) {
+ final StringBuilder currentLine = new StringBuilder();
+ for (int i = 0; i < s.length(); i++) {
+ final char c = s.charAt(i);
+ final double w = getTextWidth(stringBounder, currentLine.toString() + c);
+ if (w > -maxMessageSize) {
+ addSingleLineNoSpace(currentLine.toString());
+ currentLine.setLength(0);
+ if (c != ' ') {
+ currentLine.append(c);
+ }
+ } else {
+ currentLine.append(c);
+ }
+ }
+ addSingleLineNoSpace(currentLine.toString());
+ }
+ }
+
+ private void addSingleLineNoSpace(String s) {
+ if (s.length() == 0 || MyPattern.mtches(s, "^[%s]*$ ")) {
+ return;
+ }
+ lines2.add(new SingleLine(s, fontConfiguration, horizontalAlignment, spriteContainer));
+ }
+
+ private void addSingleLine(String s) {
+ lines2.add(new SingleLine(s, fontConfiguration, horizontalAlignment, spriteContainer));
+ }
+
+ private double getTextWidth(StringBounder stringBounder, String s) {
+ final Line line = new SingleLine(s, fontConfiguration, horizontalAlignment, spriteContainer);
+ return line.calculateDimension(stringBounder).getWidth();
+ }
+
+ private List<SingleLine> createLinesForStereotype(FontConfiguration fontConfiguration, Stereotype s,
+ HorizontalAlignment horizontalAlignment, SpriteContainer spriteContainer) {
+ assert s.getLabel(false) != null;
+ final List<SingleLine> result = new ArrayList<SingleLine>();
+ for (String st : s.getLabels(spriteContainer.useGuillemet())) {
+// st = Stereotype.manageGuillemet(st);
+ result.add(new SingleLine(st, fontConfiguration, horizontalAlignment, spriteContainer));
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return getTextDimension(stringBounder);
+ }
+
+ protected final Dimension2D getTextDimension(StringBounder stringBounder) {
+ double width = 0;
+ double height = 0;
+ for (Line line : getLines(stringBounder)) {
+ final Dimension2D size2D = line.calculateDimension(stringBounder);
+ height += size2D.getHeight();
+ width = Math.max(width, size2D.getWidth());
+ }
+ return new Dimension2DDouble(width, height);
+ }
+
+ public void drawU(UGraphic ug) {
+ double y = 0;
+ final Dimension2D dimText = getTextDimension(ug.getStringBounder());
+
+ for (Line line : getLines(ug.getStringBounder())) {
+ final HorizontalAlignment lineHorizontalAlignment = line.getHorizontalAlignment();
+ double deltaX = 0;
+ if (lineHorizontalAlignment == HorizontalAlignment.CENTER) {
+ final double diff = dimText.getWidth() - line.calculateDimension(ug.getStringBounder()).getWidth();
+ deltaX = diff / 2.0;
+ } else if (lineHorizontalAlignment == HorizontalAlignment.RIGHT) {
+ final double diff = dimText.getWidth() - line.calculateDimension(ug.getStringBounder()).getWidth();
+ deltaX = diff;
+ }
+ line.drawU(ug.apply(new UTranslate(deltaX, y)));
+ y += line.calculateDimension(ug.getStringBounder()).getHeight();
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockSpotted.java b/src/net/sourceforge/plantuml/graphic/TextBlockSpotted.java
new file mode 100644
index 0000000..8a6089c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockSpotted.java
@@ -0,0 +1,81 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.SpriteContainer;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class TextBlockSpotted extends TextBlockSimple {
+
+ private final CircledCharacter circledCharacter;
+
+ public TextBlockSpotted(CircledCharacter circledCharacter, Display texts, FontConfiguration fontConfiguration,
+ HorizontalAlignment horizontalAlignment, SpriteContainer spriteContainer) {
+ super(texts, fontConfiguration, horizontalAlignment, spriteContainer, 0);
+ this.circledCharacter = circledCharacter;
+ }
+
+ @Override
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final double widthCircledCharacter = getCircledCharacterWithAndMargin(stringBounder);
+ final double heightCircledCharacter = circledCharacter.getPreferredHeight(stringBounder);
+
+ final Dimension2D dim = super.calculateDimension(stringBounder);
+ return new Dimension2DDouble(dim.getWidth() + widthCircledCharacter, Math.max(heightCircledCharacter,
+ dim.getHeight()));
+ }
+
+ private double getCircledCharacterWithAndMargin(StringBounder stringBounder) {
+ return circledCharacter.getPreferredWidth(stringBounder) + 6.0;
+ }
+
+ @Override
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+
+ circledCharacter.drawU(ug);
+
+ final double widthCircledCharacter = getCircledCharacterWithAndMargin(stringBounder);
+
+ super.drawU(ug.apply(new UTranslate(widthCircledCharacter, 0)));
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java b/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java
new file mode 100644
index 0000000..a39fc07
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java
@@ -0,0 +1,217 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics2D;
+import java.awt.font.FontRenderContext;
+import java.awt.font.LineMetrics;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.awt.image.BufferedImage;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ISkinSimple;
+import net.sourceforge.plantuml.SpriteContainer;
+import net.sourceforge.plantuml.creole.CreoleParser;
+import net.sourceforge.plantuml.creole.Sheet;
+import net.sourceforge.plantuml.creole.SheetBlock1;
+import net.sourceforge.plantuml.creole.SheetBlock2;
+import net.sourceforge.plantuml.cucadiagram.Display;
+import net.sourceforge.plantuml.cucadiagram.Stereotype;
+import net.sourceforge.plantuml.posimo.Positionable;
+import net.sourceforge.plantuml.posimo.PositionableImpl;
+import net.sourceforge.plantuml.sequencediagram.MessageNumber;
+import net.sourceforge.plantuml.ugraphic.LimitFinder;
+import net.sourceforge.plantuml.ugraphic.MinMax;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class TextBlockUtils {
+
+ public static TextBlock create(Display texts, FontConfiguration fontConfiguration,
+ HorizontalAlignment horizontalAlignment, ISkinSimple spriteContainer) {
+ return create(texts, fontConfiguration, horizontalAlignment, spriteContainer, false);
+ }
+
+ public static TextBlock create(Display texts, FontConfiguration fontConfiguration,
+ HorizontalAlignment horizontalAlignment, ISkinSimple spriteContainer, boolean modeSimpleLine) {
+ if (texts == null) {
+ return empty(0, 0);
+ }
+ return create(texts, fontConfiguration, horizontalAlignment, spriteContainer, 0, modeSimpleLine, null, null);
+ }
+
+ public static TextBlock create(Display texts, FontConfiguration fontConfiguration,
+ HorizontalAlignment horizontalAlignment, ISkinSimple spriteContainer, double maxMessageSize,
+ boolean modeSimpleLine, UFont fontForStereotype, HtmlColor htmlColorForStereotype) {
+ if (texts.getNaturalHorizontalAlignment() != null) {
+ horizontalAlignment = texts.getNaturalHorizontalAlignment();
+ }
+ if (texts.size() > 0) {
+ if (texts.get(0) instanceof Stereotype) {
+ return createStereotype(texts, fontConfiguration, horizontalAlignment, spriteContainer, 0,
+ fontForStereotype, htmlColorForStereotype);
+ }
+ if (texts.get(texts.size() - 1) instanceof Stereotype) {
+ return createStereotype(texts, fontConfiguration, horizontalAlignment, spriteContainer,
+ texts.size() - 1, fontForStereotype, htmlColorForStereotype);
+ }
+ if (texts.get(0) instanceof MessageNumber) {
+ return createMessageNumber(texts, fontConfiguration, horizontalAlignment, spriteContainer,
+ maxMessageSize);
+ }
+ }
+
+ return getCreole(texts, fontConfiguration, horizontalAlignment, spriteContainer, maxMessageSize, modeSimpleLine);
+ }
+
+ private static TextBlock getCreole(Display texts, FontConfiguration fontConfiguration,
+ HorizontalAlignment horizontalAlignment, ISkinSimple spriteContainer, double maxMessageSize,
+ boolean modeSimpleLine) {
+ final Sheet sheet = new CreoleParser(fontConfiguration, horizontalAlignment, spriteContainer, modeSimpleLine)
+ .createSheet(texts);
+ final SheetBlock1 sheetBlock1 = new SheetBlock1(sheet, maxMessageSize, spriteContainer == null ? 0
+ : spriteContainer.getPadding());
+ return new SheetBlock2(sheetBlock1, sheetBlock1, new UStroke(1.5));
+ }
+
+ private static TextBlock createMessageNumber(Display texts, FontConfiguration fontConfiguration,
+ HorizontalAlignment horizontalAlignment, ISkinSimple spriteContainer, double maxMessageSize) {
+ TextBlock tb1 = getCreole(texts.subList(0, 1), fontConfiguration, horizontalAlignment, spriteContainer,
+ maxMessageSize, false);
+ tb1 = TextBlockUtils.withMargin(tb1, 0, 4, 0, 0);
+ final TextBlock tb2 = getCreole(texts.subList(1, texts.size()), fontConfiguration, horizontalAlignment,
+ spriteContainer, maxMessageSize, false);
+ return TextBlockUtils.mergeLR(tb1, tb2, VerticalAlignment.CENTER);
+
+ }
+
+ private static TextBlock createStereotype(Display texts, FontConfiguration fontConfiguration,
+ HorizontalAlignment horizontalAlignment, SpriteContainer spriteContainer, int position,
+ UFont fontForStereotype, HtmlColor htmlColorForStereotype) {
+ final Stereotype stereotype = (Stereotype) texts.get(position);
+ if (stereotype.isSpotted()) {
+ final CircledCharacter circledCharacter = new CircledCharacter(stereotype.getCharacter(),
+ stereotype.getRadius(), stereotype.getCircledFont(), stereotype.getHtmlColor(), null,
+ fontConfiguration.getColor());
+ if (stereotype.getLabel(false) == null) {
+ return new TextBlockSpotted(circledCharacter, texts.subList(1, texts.size()), fontConfiguration,
+ horizontalAlignment, spriteContainer);
+ }
+ return new TextBlockSpotted(circledCharacter, texts, fontConfiguration, horizontalAlignment,
+ spriteContainer);
+ }
+ return new TextBlockSimple(texts, fontConfiguration, horizontalAlignment, spriteContainer, 0, fontForStereotype, htmlColorForStereotype);
+ }
+
+ public static TextBlock withMargin(TextBlock textBlock, double marginX, double marginY) {
+ return new TextBlockMarged(textBlock, marginX, marginX, marginY, marginY);
+ }
+
+ public static TextBlock withMinWidth(TextBlock textBlock, double minWidth, HorizontalAlignment horizontalAlignment) {
+ return new TextBlockMinWidth(textBlock, minWidth, horizontalAlignment);
+ }
+
+ public static TextBlock withMargin(TextBlock textBlock, double marginX1, double marginX2, double marginY1,
+ double marginY2) {
+ return new TextBlockMarged(textBlock, marginX1, marginX2, marginY1, marginY2);
+ }
+
+ public static TextBlock empty(final double width, final double height) {
+ return new TextBlock() {
+ public void drawU(UGraphic ug) {
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+ public static Positionable asPositionable(TextBlock textBlock, StringBounder stringBounder, Point2D pt) {
+ return new PositionableImpl(pt, textBlock.calculateDimension(stringBounder));
+ }
+
+ public static TextBlock mergeLR(TextBlock b1, TextBlock b2, VerticalAlignment verticallAlignment) {
+ return new TextBlockHorizontal(b1, b2, verticallAlignment);
+ }
+
+ public static TextBlock mergeTB(TextBlock b1, TextBlock b2, HorizontalAlignment horizontalAlignment) {
+ return new TextBlockVertical2(b1, b2, horizontalAlignment);
+ }
+
+ public static MinMax getMinMax(TextBlock tb, StringBounder stringBounder) {
+ final LimitFinder limitFinder = new LimitFinder(stringBounder, false);
+ tb.drawU(limitFinder);
+ return limitFinder.getMinMax();
+ }
+
+ private static final Graphics2D gg;
+ private static final StringBounder dummyStringBounder;
+
+ static {
+ final BufferedImage imDummy = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
+ gg = imDummy.createGraphics();
+ dummyStringBounder = StringBounderUtils.asStringBounder(gg);
+ }
+
+ public static StringBounder getDummyStringBounder() {
+ return dummyStringBounder;
+ }
+
+ public static FontRenderContext getFontRenderContext() {
+ return gg.getFontRenderContext();
+ }
+
+ public static MinMax getMinMax(TextBlock tb) {
+ return getMinMax(tb, dummyStringBounder);
+ }
+
+ public static Dimension2D getDimension(TextBlock tb) {
+ return tb.calculateDimension(dummyStringBounder);
+ }
+
+ public static LineMetrics getLineMetrics(UFont font, String text) {
+ return font.getLineMetrics(gg, text);
+ }
+
+ public static FontMetrics getFontMetrics(Font font) {
+ return gg.getFontMetrics(font);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockVertical2.java b/src/net/sourceforge/plantuml/graphic/TextBlockVertical2.java
new file mode 100644
index 0000000..fbf3cb8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockVertical2.java
@@ -0,0 +1,89 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TextBlockVertical2 implements TextBlock {
+
+ private final List<TextBlock> blocks = new ArrayList<TextBlock>();
+ private final HorizontalAlignment horizontalAlignment;
+
+ public TextBlockVertical2(TextBlock b1, TextBlock b2, HorizontalAlignment horizontalAlignment) {
+ this.blocks.add(b1);
+ this.blocks.add(b2);
+ this.horizontalAlignment = horizontalAlignment;
+ }
+
+ public TextBlockVertical2(List<TextBlock> all, HorizontalAlignment horizontalAlignment) {
+ if (all.size() < 2) {
+ throw new IllegalArgumentException();
+ }
+ this.blocks.addAll(all);
+ this.horizontalAlignment = horizontalAlignment;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ Dimension2D dim = blocks.get(0).calculateDimension(stringBounder);
+ for (int i = 1; i < blocks.size(); i++) {
+ dim = Dimension2DDouble.mergeTB(dim, blocks.get(i).calculateDimension(stringBounder));
+ }
+ return dim;
+ }
+
+ public void drawU(UGraphic ug) {
+ double y = 0;
+ final Dimension2D dimtotal = calculateDimension(ug.getStringBounder());
+ for (TextBlock b : blocks) {
+ final Dimension2D dimb = b.calculateDimension(ug.getStringBounder());
+ if (horizontalAlignment == HorizontalAlignment.LEFT) {
+ b.drawU(ug.apply(new UTranslate(0, y)));
+ } else if (horizontalAlignment == HorizontalAlignment.CENTER) {
+ final double dx = (dimtotal.getWidth() - dimb.getWidth()) / 2;
+ b.drawU(ug.apply(new UTranslate(dx, y)));
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ y += dimb.getHeight();
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockWidth.java b/src/net/sourceforge/plantuml/graphic/TextBlockWidth.java
new file mode 100644
index 0000000..4da6229
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockWidth.java
@@ -0,0 +1,44 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+public interface TextBlockWidth {
+
+ Dimension2D calculateDimension(StringBounder stringBounder);
+
+ TextBlock asTextBlock(double widthToUse);
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockWidthAdapter.java b/src/net/sourceforge/plantuml/graphic/TextBlockWidthAdapter.java
new file mode 100644
index 0000000..fbf3c63
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextBlockWidthAdapter.java
@@ -0,0 +1,63 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public class TextBlockWidthAdapter implements TextBlock {
+
+ private final TextBlockWidth textBlockWidth;
+ private final double width;
+
+ // public final void setWidth(double width) {
+ // this.width = width;
+ // }
+
+ public TextBlockWidthAdapter(TextBlockWidth textBlockWidth, double widthToUse) {
+ this.textBlockWidth = textBlockWidth;
+ this.width = widthToUse;
+ }
+
+ public void drawU(UGraphic ug) {
+ textBlockWidth.asTextBlock(width).drawU(ug);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return textBlockWidth.calculateDimension(stringBounder);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TextLink.java b/src/net/sourceforge/plantuml/graphic/TextLink.java
new file mode 100644
index 0000000..f5c2e82
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TextLink.java
@@ -0,0 +1,58 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.Url;
+
+public class TextLink implements HtmlCommand {
+
+ private final Url url;
+
+ TextLink(Url url) {
+ if (url == null) {
+ throw new IllegalArgumentException();
+ }
+ this.url = url;
+ }
+
+ public String getText() {
+ return url.getLabel();
+ }
+
+ public Url getUrl() {
+ return url;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TileImage.java b/src/net/sourceforge/plantuml/graphic/TileImage.java
new file mode 100644
index 0000000..8d254f2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TileImage.java
@@ -0,0 +1,66 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TileImage implements TextBlock {
+
+ private final BufferedImage image;
+ private final int vspace;
+
+ public TileImage(BufferedImage image, ImgValign valign, int vspace) {
+ if (image == null) {
+ throw new IllegalArgumentException();
+ }
+ this.image = image;
+ this.vspace = vspace;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(image.getWidth(), image.getHeight() + 2 * vspace);
+ }
+
+ public void drawU(UGraphic ug) {
+ ug.apply(new UTranslate(0, vspace)).draw(new UImage(image));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TileImageSvg.java b/src/net/sourceforge/plantuml/graphic/TileImageSvg.java
new file mode 100644
index 0000000..623dd14
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TileImageSvg.java
@@ -0,0 +1,74 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UImageSvg;
+
+public class TileImageSvg implements TextBlock {
+
+ private final UImageSvg svg;
+
+ public TileImageSvg(File svgFile) throws IOException {
+ this.svg = createSvg(svgFile);
+ }
+
+ private UImageSvg createSvg(File svgFile) throws IOException {
+ final BufferedReader br = new BufferedReader(new FileReader(svgFile));
+ final StringBuilder sb = new StringBuilder();
+ String s;
+ while ((s = br.readLine()) != null) {
+ sb.append(s);
+ }
+ br.close();
+ return new UImageSvg(sb.toString());
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(svg.getWidth(), svg.getHeight());
+ }
+
+ public void drawU(UGraphic ug) {
+ ug.draw(svg);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/TileText.java b/src/net/sourceforge/plantuml/graphic/TileText.java
new file mode 100644
index 0000000..f9511c4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/TileText.java
@@ -0,0 +1,134 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.util.StringTokenizer;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.ugraphic.UChangeColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UText;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class TileText implements TextBlock {
+
+ private final String text;
+ private final FontConfiguration fontConfiguration;
+ private final Url url;
+
+ public TileText(String text, FontConfiguration fontConfiguration, Url url) {
+ this.fontConfiguration = fontConfiguration;
+ this.text = text;
+ this.url = url;
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D rect = stringBounder.calculateDimension(fontConfiguration.getFont(), text);
+ final int spaceBottom = Math.abs(fontConfiguration.getSpace());
+ Log.debug("g2d=" + rect);
+ Log.debug("Size for " + text + " is " + rect);
+ double h = rect.getHeight();
+ if (h < 10) {
+ h = 10;
+ }
+ final double width = text.indexOf('\t') == -1 ? rect.getWidth() : getWidth(stringBounder);
+ return new Dimension2DDouble(width, h + spaceBottom);
+ }
+
+ public double getFontSize2D() {
+ return fontConfiguration.getFont().getSize2D();
+ }
+
+ double getTabSize(StringBounder stringBounder) {
+ return stringBounder.calculateDimension(fontConfiguration.getFont(), " ").getWidth();
+ }
+
+ public void drawU(UGraphic ug) {
+ double x = 0;
+ if (url != null) {
+ ug.startUrl(url);
+ }
+ ug = ug.apply(new UChangeColor(fontConfiguration.getColor()));
+
+ final StringTokenizer tokenizer = new StringTokenizer(text, "\t", true);
+
+ if (tokenizer.hasMoreTokens()) {
+ final double tabSize = getTabSize(ug.getStringBounder());
+ while (tokenizer.hasMoreTokens()) {
+ final String s = tokenizer.nextToken();
+ if (s.equals("\t")) {
+ final double remainder = x % tabSize;
+ x += tabSize - remainder;
+ } else {
+ final UText utext = new UText(s, fontConfiguration);
+ final Dimension2D dim = ug.getStringBounder().calculateDimension(fontConfiguration.getFont(), s);
+ final int space = fontConfiguration.getSpace();
+ final double ypos;
+ if (space < 0) {
+ ypos = space /*- getFontSize2D() - space*/;
+ } else {
+ ypos = space;
+ }
+ ug.apply(new UTranslate(x, ypos)).draw(utext);
+ x += dim.getWidth();
+ }
+ }
+ }
+ if (url != null) {
+ ug.closeAction();
+ }
+ }
+
+ double getWidth(StringBounder stringBounder) {
+ final StringTokenizer tokenizer = new StringTokenizer(text, "\t", true);
+ final double tabSize = getTabSize(stringBounder);
+ double x = 0;
+ while (tokenizer.hasMoreTokens()) {
+ final String s = tokenizer.nextToken();
+ if (s.equals("\t")) {
+ final double remainder = x % tabSize;
+ x += tabSize - remainder;
+ } else {
+ final Dimension2D dim = stringBounder.calculateDimension(fontConfiguration.getFont(), s);
+ x += dim.getWidth();
+ }
+ }
+ return x;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/UDrawable.java b/src/net/sourceforge/plantuml/graphic/UDrawable.java
new file mode 100644
index 0000000..9bbbd02
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/UDrawable.java
@@ -0,0 +1,43 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+
+public interface UDrawable {
+
+ public void drawU(UGraphic ug);
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/UDrawableUtils.java b/src/net/sourceforge/plantuml/graphic/UDrawableUtils.java
new file mode 100644
index 0000000..b5b00c7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/UDrawableUtils.java
@@ -0,0 +1,50 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class UDrawableUtils {
+
+ public static UDrawable move(final UDrawable orig, final double dx, final double dy) {
+ return new UDrawable() {
+ public void drawU(UGraphic ug) {
+ orig.drawU(ug.apply(new UTranslate(dx, dy)));
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/UGraphicDelegator.java b/src/net/sourceforge/plantuml/graphic/UGraphicDelegator.java
new file mode 100644
index 0000000..8e475eb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/UGraphicDelegator.java
@@ -0,0 +1,91 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public abstract class UGraphicDelegator implements UGraphic {
+
+ final private UGraphic ug;
+
+ public final boolean isSpecialTxt() {
+ return ug.isSpecialTxt();
+ }
+
+
+ public UGraphicDelegator(UGraphic ug) {
+ this.ug = ug;
+ }
+
+ public StringBounder getStringBounder() {
+ return ug.getStringBounder();
+ }
+
+ public UParam getParam() {
+ return ug.getParam();
+ }
+
+ public void draw(UShape shape) {
+ ug.draw(shape);
+ }
+
+ public ColorMapper getColorMapper() {
+ return ug.getColorMapper();
+ }
+
+ public void startUrl(Url url) {
+ ug.startUrl(url);
+ }
+
+ public void closeAction() {
+ ug.closeAction();
+ }
+
+ protected UGraphic getUg() {
+ return ug;
+ }
+
+ public void flushUg() {
+ ug.flushUg();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/UGraphicInterceptorUDrawable.java b/src/net/sourceforge/plantuml/graphic/UGraphicInterceptorUDrawable.java
new file mode 100644
index 0000000..6e13067
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/UGraphicInterceptorUDrawable.java
@@ -0,0 +1,61 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class UGraphicInterceptorUDrawable extends UGraphicDelegator {
+
+ public UGraphicInterceptorUDrawable(UGraphic ug) {
+ super(ug);
+ }
+
+ public void draw(UShape shape) {
+ if (shape instanceof UDrawable) {
+ final UDrawable drawable = (UDrawable) shape;
+ drawable.drawU(this);
+ } else {
+ getUg().draw(shape);
+ }
+
+ }
+
+ public UGraphic apply(UChange change) {
+ return new UGraphicInterceptorUDrawable(getUg().apply(change));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbol.java b/src/net/sourceforge/plantuml/graphic/USymbol.java
new file mode 100644
index 0000000..d159f96
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbol.java
@@ -0,0 +1,159 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.StringUtils;
+
+public abstract class USymbol {
+
+ private static final Map<String, USymbol> all = new HashMap<String, USymbol>();
+
+ public final static USymbol STORAGE = record("STORAGE", SkinParameter.STORAGE, new USymbolStorage());
+ public final static USymbol DATABASE = record("DATABASE", SkinParameter.DATABASE, new USymbolDatabase());
+ public final static USymbol CLOUD = record("CLOUD", SkinParameter.CLOUD, new USymbolCloud());
+ public final static USymbol CARD = record("CARD", SkinParameter.CARD, new USymbolCard(SkinParameter.CARD));
+ public final static USymbol FRAME = record("FRAME", SkinParameter.FRAME, new USymbolFrame());
+ public final static USymbol NODE = record("NODE", SkinParameter.NODE, new USymbolNode());
+ public final static USymbol ARTIFACT = record("ARTIFACT", SkinParameter.ARTIFACT, new USymbolArtifact());
+ public final static USymbol PACKAGE = record("PACKAGE", SkinParameter.PACKAGE, new USymbolFolder(
+ SkinParameter.PACKAGE));
+ public final static USymbol FOLDER = record("FOLDER", SkinParameter.FOLDER, new USymbolFolder(SkinParameter.FOLDER));
+ public final static USymbol RECTANGLE = record("RECTANGLE", SkinParameter.CARD, new USymbolRect(SkinParameter.CARD));
+ public final static USymbol AGENT = record("AGENT", SkinParameter.AGENT, new USymbolRect(SkinParameter.AGENT));
+ public final static USymbol ACTOR = record("ACTOR", SkinParameter.ACTOR, new USymbolActor());
+ public final static USymbol USECASE = null;
+ public final static USymbol COMPONENT1 = record("COMPONENT1", SkinParameter.COMPONENT1, new USymbolComponent1());
+ public final static USymbol COMPONENT2 = record("COMPONENT2", SkinParameter.COMPONENT2, new USymbolComponent2());
+ public final static USymbol BOUNDARY = record("BOUNDARY", SkinParameter.BOUNDARY, new USymbolBoundary());
+ public final static USymbol ENTITY_DOMAIN = record("ENTITY_DOMAIN", SkinParameter.ENTITY_DOMAIN,
+ new USymbolEntityDomain(2));
+ public final static USymbol CONTROL = record("CONTROL", SkinParameter.CONTROL, new USymbolControl(2));
+ public final static USymbol INTERFACE = record("INTERFACE", SkinParameter.INTERFACE, new USymbolInterface());
+ public final static USymbol QUEUE = record("QUEUE", SkinParameter.QUEUE, new USymbolQueue());
+
+ abstract public SkinParameter getSkinParameter();
+
+ public FontParam getFontParam() {
+ return getSkinParameter().getFontParam();
+ }
+
+ public FontParam getFontParamStereotype() {
+ return getSkinParameter().getFontParamStereotype();
+
+ }
+
+ public ColorParam getColorParamBack() {
+ return getSkinParameter().getColorParamBack();
+ }
+
+ public ColorParam getColorParamBorder() {
+ return getSkinParameter().getColorParamBorder();
+ }
+
+ public static USymbol getFromString(String s) {
+ final USymbol result = all.get(StringUtils.goUpperCase(s));
+ if (result == null) {
+ if (s.equalsIgnoreCase("component")) {
+ return COMPONENT2;
+ }
+ throw new IllegalArgumentException("s=" + s);
+ }
+ return result;
+ }
+
+ private static USymbol record(String code, SkinParameter skinParameter, USymbol symbol) {
+ all.put(StringUtils.goUpperCase(code), symbol);
+ return symbol;
+ }
+
+ public abstract TextBlock asSmall(TextBlock label, TextBlock stereotype, SymbolContext symbolContext);
+
+ public abstract TextBlock asBig(TextBlock label, TextBlock stereotype, double width, double height,
+ SymbolContext symbolContext);
+
+ static class Margin {
+ private final double x1;
+ private final double x2;
+ private final double y1;
+ private final double y2;
+
+ Margin(double x1, double x2, double y1, double y2) {
+ this.x1 = x1;
+ this.x2 = x2;
+ this.y1 = y1;
+ this.y2 = y2;
+ }
+
+ double getWidth() {
+ return x1 + x2;
+ }
+
+ double getHeight() {
+ return y1 + y2;
+ }
+
+ public Dimension2D addDimension(Dimension2D dim) {
+ return new Dimension2DDouble(dim.getWidth() + x1 + x2, dim.getHeight() + y1 + y2);
+ }
+
+ public double getX1() {
+ return x1;
+ }
+
+ public double getY1() {
+ return y1;
+ }
+ }
+
+ public boolean manageHorizontalLine() {
+ return false;
+ }
+
+ public int suppHeightBecauseOfShape() {
+ return 0;
+ }
+
+ public int suppWidthBecauseOfShape() {
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolActor.java b/src/net/sourceforge/plantuml/graphic/USymbolActor.java
new file mode 100644
index 0000000..ac209d1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolActor.java
@@ -0,0 +1,54 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.skin.StickMan;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+class USymbolActor extends USymbolSimpleAbstract {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.ACTOR;
+ }
+
+
+ @Override
+ protected TextBlock getDrawing(SymbolContext symbolContext) {
+ final double deltaShadow = symbolContext.isShadowing() ? 4.0 : 0.0;
+ return new StickMan(symbolContext.withDeltaShadow(deltaShadow).withStroke(new UStroke(2)));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolArtifact.java b/src/net/sourceforge/plantuml/graphic/USymbolArtifact.java
new file mode 100644
index 0000000..79cd066
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolArtifact.java
@@ -0,0 +1,132 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolArtifact extends USymbol {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.ARTIFACT;
+ }
+
+
+ private void drawArtifact(UGraphic ug, double widthTotal, double heightTotal, boolean shadowing) {
+
+ final URectangle form = new URectangle(widthTotal, heightTotal);
+ if (shadowing) {
+ form.setDeltaShadow(4);
+ }
+
+ ug.draw(form);
+
+ final UPolygon polygon = new UPolygon();
+ polygon.addPoint(0, 0);
+ final double heightSymbol = 14;
+ polygon.addPoint(0, heightSymbol);
+ final double widthSymbol = 12;
+ polygon.addPoint(widthSymbol, heightSymbol);
+ final int cornersize = 6;
+ polygon.addPoint(widthSymbol, cornersize);
+ polygon.addPoint(widthSymbol - cornersize, 0);
+ polygon.addPoint(0, 0);
+ // if (shadowing) {
+ // polygon.setDeltaShadow(3.0);
+ // }
+
+ final double xSymbol = widthTotal - widthSymbol - 5;
+ final double ySymbol = 5;
+
+ ug.apply(new UTranslate(xSymbol, ySymbol)).draw(polygon);
+ ug.apply(new UTranslate(xSymbol + widthSymbol - cornersize, ySymbol)).draw(new ULine(0, cornersize));
+ ug.apply(new UTranslate(xSymbol + widthSymbol, ySymbol + cornersize)).draw(new ULine(-cornersize, 0));
+
+ }
+
+ private Margin getMargin() {
+ return new Margin(10, 10 + 10, 10 + 3, 10);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawArtifact(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawArtifact(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+ stereotype.drawU(ug.apply(new UTranslate(posStereo, 2)));
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double posTitle = (width - dimTitle.getWidth()) / 2;
+ title.drawU(ug.apply(new UTranslate(posTitle, 2 + dimStereo.getHeight())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolBoundary.java b/src/net/sourceforge/plantuml/graphic/USymbolBoundary.java
new file mode 100644
index 0000000..dbf67f9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolBoundary.java
@@ -0,0 +1,53 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.svek.Boundary;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+class USymbolBoundary extends USymbolSimpleAbstract {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.BOUNDARY;
+ }
+
+
+ @Override
+ protected TextBlock getDrawing(final SymbolContext symbolContext) {
+ return new Boundary(symbolContext.withDeltaShadow(symbolContext.isShadowing() ? 4.0 : 0.0).withStroke(
+ new UStroke(2)));
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolCard.java b/src/net/sourceforge/plantuml/graphic/USymbolCard.java
new file mode 100644
index 0000000..7b44855
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolCard.java
@@ -0,0 +1,117 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolCard extends USymbol {
+
+ private final SkinParameter skinParameter;
+
+ public USymbolCard(SkinParameter skinParameter) {
+ this.skinParameter = skinParameter;
+ }
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return skinParameter;
+ }
+
+
+ private void drawRect(UGraphic ug, double width, double height, boolean shadowing, double top) {
+ final URectangle shape = new URectangle(width, height);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ ug.draw(shape);
+ if (top != 0) {
+ ug.apply(new UTranslate(0, top)).draw(new ULine(width, 0));
+ }
+ }
+
+ private Margin getMargin() {
+ return new Margin(10, 10, 3, 3);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing(), 0);
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing(), dimTitle.getHeight()
+ + dimStereo.getHeight() + 4);
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+ stereotype.drawU(ug.apply(new UTranslate(posStereo, 2)));
+ final double posTitle = (width - dimTitle.getWidth()) / 2;
+ title.drawU(ug.apply(new UTranslate(posTitle, 2 + dimStereo.getHeight())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolCloud.java b/src/net/sourceforge/plantuml/graphic/USymbolCloud.java
new file mode 100644
index 0000000..a867749
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolCloud.java
@@ -0,0 +1,132 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolCloud extends USymbol {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.CLOUD;
+ }
+
+
+ private void drawCloud(UGraphic ug, double width, double height, boolean shadowing) {
+ final UPath shape = getSpecificFrontierForCloud(width, height);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ ug.apply(new UTranslate(3, -3)).draw(shape);
+ }
+
+ private UPath getSpecificFrontierForCloud(double width, double height) {
+ final UPath path = new UPath();
+ path.moveTo(0, 10);
+ double x = 0;
+ for (int i = 0; i < width - 9; i += 10) {
+ path.cubicTo(i, -3 + 10, 2 + i, -5 + 10, 5 + i, -5 + 10);
+ path.cubicTo(8 + i, -5 + 10, 10 + i, -3 + 10, 10 + i, 10);
+ x = i + 10;
+ }
+ double y = 0;
+ for (int j = 10; j < height - 9; j += 10) {
+ path.cubicTo(x + 3, j, x + 5, 2 + j, x + 5, 5 + j);
+ path.cubicTo(x + 5, 8 + j, x + 3, 10 + j, x, 10 + j);
+ y = j + 10;
+ }
+ for (int i = 0; i < width - 9; i += 10) {
+ path.cubicTo(x - i, y + 3, x - 3 - i, y + 5, x - 5 - i, y + 5);
+ path.cubicTo(x - 8 - i, y + 5, x - 10 - i, y + 3, x - 10 - i, y);
+ }
+ for (int j = 0; j < height - 9 - 10; j += 10) {
+ path.cubicTo(-3, y - j, -5, y - 2 - j, -5, y - 5 - j);
+ path.cubicTo(-5, y - 8 - j, -3, y - 10 - j, 0, y - 10 - j);
+ }
+ return path;
+ }
+
+ private Margin getMargin() {
+ return new Margin(10, 10, 10, 10);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawCloud(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawCloud(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+ stereotype.drawU(ug.apply(new UTranslate(posStereo, 13)));
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double posTitle = (width - dimTitle.getWidth()) / 2;
+ title.drawU(ug.apply(new UTranslate(posTitle, 13 + dimStereo.getHeight())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolComponent1.java b/src/net/sourceforge/plantuml/graphic/USymbolComponent1.java
new file mode 100644
index 0000000..2445c8b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolComponent1.java
@@ -0,0 +1,99 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolComponent1 extends USymbol {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.COMPONENT1;
+ }
+
+
+ private void drawNode(UGraphic ug, double widthTotal, double heightTotal, boolean shadowing) {
+
+ final URectangle form = new URectangle(widthTotal, heightTotal);
+ if (shadowing) {
+ form.setDeltaShadow(4);
+ }
+
+ ug.draw(form);
+ final UShape small = new URectangle(10, 5);
+
+ // UML 1 Component Notation
+ ug.apply(new UTranslate(-5, 5)).draw(small);
+ ug.apply(new UTranslate(-5, heightTotal - 10)).draw(small);
+
+ }
+
+ private Margin getMargin() {
+ return new Margin(10, 10, 10, 10);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+ ug = symbolContext.apply(ug);
+ drawNode(ug, dimTotal.getWidth(), dimTotal.getHeight(), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolComponent2.java b/src/net/sourceforge/plantuml/graphic/USymbolComponent2.java
new file mode 100644
index 0000000..6a74bc6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolComponent2.java
@@ -0,0 +1,114 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.ColorParam;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.FontParam;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolComponent2 extends USymbol {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.COMPONENT2;
+ }
+
+
+ private void drawNode(UGraphic ug, double widthTotal, double heightTotal, boolean shadowing) {
+
+ final URectangle form = new URectangle(widthTotal, heightTotal);
+ if (shadowing) {
+ form.setDeltaShadow(4);
+ }
+
+ final UShape small = new URectangle(15, 10);
+ final UShape tiny = new URectangle(4, 2);
+
+ ug.draw(form);
+
+ // UML 2 Component Notation
+ ug.apply(new UTranslate(widthTotal - 20, 5)).draw(small);
+ ug.apply(new UTranslate(widthTotal - 22, 7)).draw(tiny);
+ ug.apply(new UTranslate(widthTotal - 22, 11)).draw(tiny);
+
+ }
+
+ private Margin getMargin() {
+ return new Margin(10 + 5, 20 + 5, 15 + 5, 5 + 5);
+ }
+
+ public TextBlock asSmall(final TextBlock label, TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawNode(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ label.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dim = label.calculateDimension(stringBounder);
+ return getMargin().addDimension(dim);
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawNode(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ title.drawU(ug.apply(new UTranslate(3, 13)));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolControl.java b/src/net/sourceforge/plantuml/graphic/USymbolControl.java
new file mode 100644
index 0000000..7f9dfbd
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolControl.java
@@ -0,0 +1,60 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.svek.Control;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+class USymbolControl extends USymbolSimpleAbstract {
+
+ private final double thickness;
+
+ public USymbolControl(double thickness) {
+ this.thickness = thickness;
+ }
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.CONTROL;
+ }
+
+
+ @Override
+ protected TextBlock getDrawing(final SymbolContext symbolContext) {
+ return new Control(symbolContext.withDeltaShadow(symbolContext.isShadowing() ? 4.0 : 0.0).withStroke(
+ new UStroke(thickness)));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolDatabase.java b/src/net/sourceforge/plantuml/graphic/USymbolDatabase.java
new file mode 100644
index 0000000..4eda644
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolDatabase.java
@@ -0,0 +1,169 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.AbstractUGraphicHorizontalLine;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UHorizontalLine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolDatabase extends USymbol {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.DATABASE;
+ }
+
+
+
+ private void drawDatabase(UGraphic ug, double width, double height, boolean shadowing) {
+ final UPath shape = new UPath();
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ shape.moveTo(0, 10);
+ shape.cubicTo(0, 0, width / 2, 0, width / 2, 0);
+ shape.cubicTo(width / 2, 0, width, 0, width, 10);
+ shape.lineTo(width, height - 10);
+ shape.cubicTo(width, height, width / 2, height, width / 2, height);
+ shape.cubicTo(width / 2, height, 0, height, 0, height - 10);
+ shape.lineTo(0, 10);
+
+ ug.draw(shape);
+
+ final UPath closing = getClosingPath(width);
+ ug.apply(new UChangeBackColor(null)).draw(closing);
+
+ }
+
+ private UPath getClosingPath(double width) {
+ final UPath closing = new UPath();
+ closing.moveTo(0, 10);
+ closing.cubicTo(0, 20, width / 2, 20, width / 2, 20);
+ closing.cubicTo(width / 2, 20, width, 20, width, 10);
+ return closing;
+ }
+
+ class MyUGraphicDatabase extends AbstractUGraphicHorizontalLine {
+
+ private final double endingX;
+
+ @Override
+ protected AbstractUGraphicHorizontalLine copy(UGraphic ug) {
+ return new MyUGraphicDatabase(ug, endingX);
+ }
+
+ public MyUGraphicDatabase(UGraphic ug, double endingX) {
+ super(ug);
+ this.endingX = endingX;
+ }
+
+ @Override
+ protected void drawHline(UGraphic ug, UHorizontalLine line, UTranslate translate) {
+ final UPath closing = getClosingPath(endingX);
+ ug = ug.apply(translate);
+ ug.apply(line.getStroke()).apply(new UChangeBackColor(null)).apply(new UTranslate(0, -15)).draw(closing);
+ if (line.isDouble()) {
+ ug.apply(line.getStroke()).apply(new UChangeBackColor(null)).apply(new UTranslate(0, -15 + 2))
+ .draw(closing);
+ }
+ line.drawTitleInternal(ug, 0, endingX, 0, true);
+ }
+
+ }
+
+ private Margin getMargin() {
+ return new Margin(10, 10, 20, 5);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawDatabase(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ final UGraphic ug2 = new MyUGraphicDatabase(ug, dim.getWidth());
+ tb.drawU(ug2.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawDatabase(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+ stereotype.drawU(ug.apply(new UTranslate(posStereo, 0)));
+
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double posTitle = (width - dimTitle.getWidth()) / 2;
+ title.drawU(ug.apply(new UTranslate(posTitle, 21)));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+ public boolean manageHorizontalLine() {
+ return true;
+ }
+
+ @Override
+ public int suppHeightBecauseOfShape() {
+ return 15;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolEntityDomain.java b/src/net/sourceforge/plantuml/graphic/USymbolEntityDomain.java
new file mode 100644
index 0000000..bfc6ed6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolEntityDomain.java
@@ -0,0 +1,59 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.svek.EntityDomain;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+class USymbolEntityDomain extends USymbolSimpleAbstract {
+
+ private final double thickness;
+
+ public USymbolEntityDomain(double thickness) {
+ this.thickness = thickness;
+ }
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.ENTITY_DOMAIN;
+ }
+
+
+ @Override
+ protected TextBlock getDrawing(final SymbolContext symbolContext) {
+ return new EntityDomain(symbolContext.withDeltaShadow(symbolContext.isShadowing() ? 4.0 : 0.0).withStroke(
+ new UStroke(thickness)));
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolFolder.java b/src/net/sourceforge/plantuml/graphic/USymbolFolder.java
new file mode 100644
index 0000000..2c924fa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolFolder.java
@@ -0,0 +1,150 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+public class USymbolFolder extends USymbol {
+
+ private final static int marginTitleX1 = 3;
+ private final static int marginTitleX2 = 3;
+ private final static int marginTitleX3 = 7;
+ private final static int marginTitleY0 = 0;
+ private final static int marginTitleY1 = 3;
+ private final static int marginTitleY2 = 3;
+
+ private final SkinParameter skinParameter;
+
+ public USymbolFolder(SkinParameter skinParameter) {
+ this.skinParameter = skinParameter;
+ }
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return skinParameter;
+ }
+
+ private void drawFolder(UGraphic ug, double width, double height, Dimension2D dimTitle, boolean shadowing) {
+
+ final double wtitle;
+ if (dimTitle.getWidth() == 0) {
+ wtitle = Math.max(30, width / 4);
+ } else {
+ wtitle = dimTitle.getWidth() + marginTitleX1 + marginTitleX2;
+ }
+ final double htitle = getHTitle(dimTitle);
+
+ final UPolygon shape = new UPolygon();
+ shape.addPoint(0, 0);
+ shape.addPoint(wtitle, 0);
+
+ shape.addPoint(wtitle + marginTitleX3, htitle);
+ shape.addPoint(width, htitle);
+ shape.addPoint(width, height);
+ shape.addPoint(0, height);
+ shape.addPoint(0, 0);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ ug.draw(shape);
+ ug.apply(new UTranslate(0, htitle)).draw(new ULine(wtitle + marginTitleX3, 0));
+ }
+
+ private double getHTitle(Dimension2D dimTitle) {
+ final double htitle;
+ if (dimTitle.getWidth() == 0) {
+ htitle = 10;
+ } else {
+ htitle = dimTitle.getHeight() + marginTitleY1 + marginTitleY2;
+ }
+ return htitle;
+ }
+
+ private Margin getMargin() {
+ return new Margin(10, 10 + 10, 10 + 3, 10);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawFolder(ug, dim.getWidth(), dim.getHeight(), new Dimension2DDouble(0, 0),
+ symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dim = calculateDimension(stringBounder);
+ ug = symbolContext.apply(ug);
+ final Dimension2D dimTitle = title.calculateDimension(stringBounder);
+ drawFolder(ug, dim.getWidth(), dim.getHeight(), dimTitle, symbolContext.isShadowing());
+ title.drawU(ug.apply(new UTranslate(4, 2)));
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+
+ stereotype.drawU(ug.apply(new UTranslate(4 + posStereo, 2 + getHTitle(dimTitle))));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolFrame.java b/src/net/sourceforge/plantuml/graphic/USymbolFrame.java
new file mode 100644
index 0000000..f9c146d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolFrame.java
@@ -0,0 +1,138 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolFrame extends USymbol {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.FRAME;
+ }
+
+
+ private void drawFrame(UGraphic ug, double width, double height, Dimension2D dimTitle, boolean shadowing) {
+ final URectangle shape = new URectangle(width, height);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+
+ ug.draw(shape);
+
+ final double textWidth;
+ final int cornersize;
+ if (dimTitle.getWidth() == 0) {
+ textWidth = width / 3;
+ cornersize = 7;
+ } else {
+ textWidth = dimTitle.getWidth() + 10;
+ cornersize = 10;
+ }
+ final double textHeight = getYpos(dimTitle);
+
+ final UPath polygon = new UPath();
+ polygon.moveTo(textWidth, 1);
+
+ polygon.lineTo(textWidth, textHeight - cornersize);
+ polygon.lineTo(textWidth - cornersize, textHeight);
+
+ polygon.lineTo(0, textHeight);
+ ug.draw(polygon);
+
+ }
+
+ private double getYpos(Dimension2D dimTitle) {
+ if (dimTitle.getWidth() == 0) {
+ return 12;
+ }
+ return dimTitle.getHeight() + 3;
+ }
+
+ private Margin getMargin() {
+ return new Margin(10 + 5, 20 + 5, 15 + 5, 5 + 5);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawFrame(ug, dim.getWidth(), dim.getHeight(), new Dimension2DDouble(0, 0), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dim = calculateDimension(stringBounder);
+ ug = symbolContext.apply(ug);
+ final Dimension2D dimTitle = title.calculateDimension(stringBounder);
+ drawFrame(ug, dim.getWidth(), dim.getHeight(), dimTitle, symbolContext.isShadowing());
+ title.drawU(ug.apply(new UTranslate(3, 1)));
+
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+
+ stereotype.drawU(ug.apply(new UTranslate(4 + posStereo, 2 + getYpos(dimTitle))));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolInterface.java b/src/net/sourceforge/plantuml/graphic/USymbolInterface.java
new file mode 100644
index 0000000..33bcec8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolInterface.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import net.sourceforge.plantuml.svek.CircleInterface2;
+
+public class USymbolInterface extends USymbolSimpleAbstract {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.INTERFACE;
+ }
+
+ @Override
+ protected TextBlock getDrawing(SymbolContext symbolContext) {
+ return new CircleInterface2(symbolContext.getBackColor(), symbolContext.getForeColor(),
+ symbolContext.isShadowing() ? 4.0 : 0.0);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolNode.java b/src/net/sourceforge/plantuml/graphic/USymbolNode.java
new file mode 100644
index 0000000..3c4305c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolNode.java
@@ -0,0 +1,132 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolNode extends USymbol {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.NODE;
+ }
+
+
+ private void drawNode(UGraphic ug, double width, double height, boolean shadowing) {
+ final UPolygon shape = new UPolygon();
+ shape.addPoint(0, 10);
+ shape.addPoint(10, 0);
+ shape.addPoint(width, 0);
+ shape.addPoint(width, height - 10);
+ shape.addPoint(width - 10, height);
+ shape.addPoint(0, height);
+ shape.addPoint(0, 10);
+ if (shadowing) {
+ shape.setDeltaShadow(2);
+ }
+ ug.draw(shape);
+
+ ug.apply(new UTranslate(width - 10, 10)).draw(new ULine(9, -9));
+ ug.apply(new UTranslate(0, 10)).draw(new ULine(width - 10, 0));
+ ug.apply(new UTranslate(width - 10, 10)).draw(new ULine(0, height - 10));
+
+ }
+
+ private Margin getMargin() {
+ return new Margin(10 + 5, 20 + 5, 15 + 5, 5 + 5);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawNode(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawNode(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ ug = ug.apply(new UTranslate(-4, 11));
+
+ final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+ stereotype.drawU(ug.apply(new UTranslate(posStereo, 2)));
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double posTitle = (width - dimTitle.getWidth()) / 2;
+ title.drawU(ug.apply(new UTranslate(posTitle, 2 + dimStereo.getHeight())));
+
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+ @Override
+ public int suppHeightBecauseOfShape() {
+ return 5;
+ }
+
+ @Override
+ public int suppWidthBecauseOfShape() {
+ return 60;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolQueue.java b/src/net/sourceforge/plantuml/graphic/USymbolQueue.java
new file mode 100644
index 0000000..01aefa9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolQueue.java
@@ -0,0 +1,172 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.AbstractUGraphicHorizontalLine;
+import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UHorizontalLine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolQueue extends USymbol {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.QUEUE;
+ }
+
+
+ private final double dx = 5;
+
+ private void drawDatabase(UGraphic ug, double width, double height, boolean shadowing) {
+ final UPath shape = new UPath();
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ shape.moveTo(dx, 0);
+ shape.lineTo(width - dx, 0);
+ shape.cubicTo(width, 0, width, height / 2, width, height / 2);
+ shape.cubicTo(width, height / 2, width, height, width - dx, height);
+ shape.lineTo(dx, height);
+
+ shape.cubicTo(0, height, 0, height / 2, 0, height / 2);
+ shape.cubicTo(0, height / 2, 0, 0, dx, 0);
+
+ ug.draw(shape);
+
+ final UPath closing = getClosingPath(width, height);
+ ug.apply(new UChangeBackColor(null)).draw(closing);
+
+ }
+
+ private UPath getClosingPath(double width, double height) {
+ final UPath closing = new UPath();
+ closing.moveTo(width - dx, 0);
+ closing.cubicTo(width - dx * 2, 0, width - dx * 2, height / 2, width - dx * 2, height / 2);
+ closing.cubicTo(width - dx * 2, height, width - dx, height, width - dx, height);
+ return closing;
+ }
+
+ class MyUGraphicDatabase extends AbstractUGraphicHorizontalLine {
+
+ private final double endingX;
+
+ @Override
+ protected AbstractUGraphicHorizontalLine copy(UGraphic ug) {
+ return new MyUGraphicDatabase(ug, endingX);
+ }
+
+ public MyUGraphicDatabase(UGraphic ug, double endingX) {
+ super(ug);
+ this.endingX = endingX;
+ }
+
+ @Override
+ protected void drawHline(UGraphic ug, UHorizontalLine line, UTranslate translate) {
+ // final UPath closing = getClosingPath(endingX);
+ // ug = ug.apply(translate);
+ // ug.apply(line.getStroke()).apply(new UChangeBackColor(null)).apply(new UTranslate(0, -15)).draw(closing);
+ // if (line.isDouble()) {
+ // ug.apply(line.getStroke()).apply(new UChangeBackColor(null)).apply(new UTranslate(0, -15 + 2))
+ // .draw(closing);
+ // }
+ line.drawTitleInternal(ug, 0, endingX, 0, true);
+ }
+
+ }
+
+ private Margin getMargin() {
+ return new Margin(5, 15, 5, 5);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawDatabase(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ final UGraphic ug2 = new MyUGraphicDatabase(ug, dim.getWidth());
+ tb.drawU(ug2.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ throw new UnsupportedOperationException();
+ // return new TextBlock() {
+ //
+ // public void drawU(UGraphic ug) {
+ // final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ // ug = symbolContext.apply(ug);
+ // drawDatabase(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ // final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
+ // final double posStereo = (width - dimStereo.getWidth()) / 2;
+ // stereotype.drawU(ug.apply(new UTranslate(posStereo, 0)));
+ //
+ // final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ // final double posTitle = (width - dimTitle.getWidth()) / 2;
+ // title.drawU(ug.apply(new UTranslate(posTitle, 21)));
+ // }
+ //
+ // public Dimension2D calculateDimension(StringBounder stringBounder) {
+ // return new Dimension2DDouble(width, height);
+ // }
+ // };
+ }
+
+ public boolean manageHorizontalLine() {
+ return true;
+ }
+
+ // @Override
+ // public int suppHeightBecauseOfShape() {
+ // return 15;
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolRect.java b/src/net/sourceforge/plantuml/graphic/USymbolRect.java
new file mode 100644
index 0000000..ac154db
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolRect.java
@@ -0,0 +1,113 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolRect extends USymbol {
+
+ private final SkinParameter skinParameter;
+
+
+ public USymbolRect(SkinParameter skinParameter) {
+ this.skinParameter = skinParameter;
+ }
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return skinParameter;
+ }
+
+
+ private void drawRect(UGraphic ug, double width, double height, boolean shadowing) {
+ final URectangle shape = new URectangle(width, height);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ ug.draw(shape);
+ }
+
+ private Margin getMargin() {
+ return new Margin(10, 10, 10, 10);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+ stereotype.drawU(ug.apply(new UTranslate(posStereo, 2)));
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double posTitle = (width - dimTitle.getWidth()) / 2;
+ title.drawU(ug.apply(new UTranslate(posTitle, 2 + dimStereo.getHeight())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java b/src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java
new file mode 100644
index 0000000..f98aa63
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolSimpleAbstract.java
@@ -0,0 +1,86 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+abstract class USymbolSimpleAbstract extends USymbol {
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ if (stereotype == null) {
+ throw new IllegalArgumentException();
+ }
+ final TextBlock stickman = getDrawing(symbolContext);
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final StringBounder stringBounder = ug.getStringBounder();
+ final Dimension2D dimName = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ final Dimension2D dimStickMan = stickman.calculateDimension(stringBounder);
+ final Dimension2D dimTotal = calculateDimension(stringBounder);
+ final double stickmanX = (dimTotal.getWidth() - dimStickMan.getWidth()) / 2;
+ final double stickmanY = dimStereo.getHeight();
+ ug = symbolContext.apply(ug);
+ stickman.drawU(ug.apply(new UTranslate(stickmanX, stickmanY)));
+ final double labelX = (dimTotal.getWidth() - dimName.getWidth()) / 2;
+ final double labelY = dimStickMan.getHeight() + dimStereo.getHeight();
+ label.drawU(ug.apply(new UTranslate(labelX, labelY)));
+
+ final double stereoX = (dimTotal.getWidth() - dimStereo.getWidth()) / 2;
+ stereotype.drawU(ug.apply(new UTranslate(stereoX, 0)));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimName = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ final Dimension2D dimActor = stickman.calculateDimension(stringBounder);
+ return Dimension2DDouble.mergeLayoutT12B3(dimStereo, dimActor, dimName);
+ }
+ };
+ }
+
+ abstract protected TextBlock getDrawing(final SymbolContext symbolContext);
+
+ public TextBlock asBig(final TextBlock title, TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ throw new UnsupportedOperationException();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/USymbolStorage.java b/src/net/sourceforge/plantuml/graphic/USymbolStorage.java
new file mode 100644
index 0000000..0ef378b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/USymbolStorage.java
@@ -0,0 +1,106 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UTranslate;
+
+class USymbolStorage extends USymbol {
+
+ @Override
+ public SkinParameter getSkinParameter() {
+ return SkinParameter.STORAGE;
+ }
+
+ private void drawStorage(UGraphic ug, double width, double height, boolean shadowing) {
+ final URectangle shape = new URectangle(width, height, 70, 70);
+ if (shadowing) {
+ shape.setDeltaShadow(3.0);
+ }
+ ug.draw(shape);
+ }
+
+ private Margin getMargin() {
+ return new Margin(10, 10, 10, 10);
+ }
+
+ public TextBlock asSmall(final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawStorage(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+ final Margin margin = getMargin();
+ final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, HorizontalAlignment.CENTER);
+ tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ final Dimension2D dimLabel = label.calculateDimension(stringBounder);
+ final Dimension2D dimStereo = stereotype.calculateDimension(stringBounder);
+ return getMargin().addDimension(Dimension2DDouble.mergeTB(dimStereo, dimLabel));
+ }
+ };
+ }
+
+ public TextBlock asBig(final TextBlock title, final TextBlock stereotype, final double width, final double height,
+ final SymbolContext symbolContext) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ final Dimension2D dim = calculateDimension(ug.getStringBounder());
+ ug = symbolContext.apply(ug);
+ drawStorage(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing());
+
+ final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder());
+ final double posStereo = (width - dimStereo.getWidth()) / 2;
+ stereotype.drawU(ug.apply(new UTranslate(posStereo, 5)));
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double posTitle = (width - dimTitle.getWidth()) / 2;
+ title.drawU(ug.apply(new UTranslate(posTitle, 7 + dimStereo.getHeight())));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(width, height);
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/UnusedSpace.java b/src/net/sourceforge/plantuml/graphic/UnusedSpace.java
new file mode 100644
index 0000000..2c820e9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/UnusedSpace.java
@@ -0,0 +1,173 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+import java.awt.Graphics2D;
+import java.awt.image.BufferedImage;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.ugraphic.UFont;
+
+public class UnusedSpace {
+
+ static class Point {
+ final private double x;
+ final private double y;
+
+ Point(double x, double y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ public double getDistSq(Point other) {
+ final double dx = this.x - other.x;
+ final double dy = this.y - other.y;
+ return dx * dx + dy * dy;
+ }
+ }
+
+ private static final int HALF_SIZE = 20;
+
+ private double meanX2;
+ private double meanY2;
+
+ private final List<Point> points = new ArrayList<Point>();
+
+ final private static Map<Object, UnusedSpace> cache = new HashMap<Object, UnusedSpace>();
+
+ public static UnusedSpace getUnusedSpace(UFont font, char c) {
+ final Object key = Arrays.asList(font, c);
+ UnusedSpace result = cache.get(key);
+ if (result == null) {
+ result = new UnusedSpace(font, c);
+ cache.put(key, result);
+ }
+ return result;
+ }
+
+ private UnusedSpace(UFont font, char c) {
+ final BufferedImage im = new BufferedImage(2 * HALF_SIZE, 2 * HALF_SIZE, BufferedImage.TYPE_INT_RGB);
+ final Graphics2D g2d = im.createGraphics();
+ g2d.setFont(font.getFont());
+ g2d.drawString("" + c, HALF_SIZE, HALF_SIZE);
+
+ int minI = Integer.MAX_VALUE;
+ int minJ = Integer.MAX_VALUE;
+ int maxI = Integer.MIN_VALUE;
+ int maxJ = Integer.MIN_VALUE;
+
+ for (int i = 0; i < im.getWidth(); i++) {
+ for (int j = 0; j < im.getHeight(); j++) {
+ if (isPoint(im, i, j)) {
+ if (i < minI) {
+ minI = i;
+ }
+ if (j < minJ) {
+ minJ = j;
+ }
+ if (i > maxI) {
+ maxI = i;
+ }
+ if (j > maxJ) {
+ maxJ = j;
+ }
+ points.add(new Point(i, j));
+ }
+ }
+ }
+
+ double min = Double.MAX_VALUE;
+ for (int i = minI * 4; i <= maxI * 4; i++) {
+ for (int j = minJ * 4; j < maxJ * 4; j++) {
+ final Point p = new Point(i / 4.0, j / 4.0);
+ final double d = biggestDistSqFromPoint(p);
+ if (d < min) {
+ min = d;
+ this.meanX2 = i / 4.0 - HALF_SIZE;
+ this.meanY2 = j / 4.0 - HALF_SIZE;
+ }
+ }
+ }
+
+ // g2d.setColor(Color.RED);
+ // g2d.draw(new Line2D.Double(meanX2 + HALF_SIZE - 1, meanY2 + HALF_SIZE
+ // - 1, meanX2 + HALF_SIZE + 1, meanY2
+ // + HALF_SIZE + 1));
+ // g2d.draw(new Line2D.Double(meanX2 + HALF_SIZE + 1, meanY2 + HALF_SIZE
+ // - 1, meanX2 + HALF_SIZE - 1, meanY2
+ // + HALF_SIZE + 1));
+
+ // int cpt = 1;
+ // try {
+ // ImageIO.write(im, "png", new File("c:/img" + cpt + ".png"));
+ // cpt++;
+ // } catch (IOException e) {
+ // e.printStackTrace();
+ // }
+
+ }
+
+ private double biggestDistSqFromPoint(Point p) {
+ double result = 0;
+ for (Point other : points) {
+ final double d = p.getDistSq(other);
+ if (d > result) {
+ result = d;
+ }
+ }
+ return result;
+ }
+
+ private static boolean isPoint(BufferedImage im, int x, int y) {
+ final int color = im.getRGB(x, y) & 0x00FFFFFF;
+ if (color == 0) {
+ return false;
+ }
+ return true;
+ }
+
+ public double getCenterX() {
+ return meanX2;
+ }
+
+ public double getCenterY() {
+ return meanY2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/graphic/VerticalAlignment.java b/src/net/sourceforge/plantuml/graphic/VerticalAlignment.java
new file mode 100644
index 0000000..a5427a1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/VerticalAlignment.java
@@ -0,0 +1,52 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public enum VerticalAlignment {
+ TOP, CENTER, BOTTOM;
+
+ public static VerticalAlignment fromString(String s) {
+ if (TOP.name().equalsIgnoreCase(s)) {
+ return TOP;
+ }
+ // if (CENTER.name().equalsIgnoreCase(s)) {
+ // return CENTER;
+ // }
+ if (BOTTOM.name().equalsIgnoreCase(s)) {
+ return BOTTOM;
+ }
+ return BOTTOM;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/graphic/VerticalPosition.java b/src/net/sourceforge/plantuml/graphic/VerticalPosition.java
new file mode 100644
index 0000000..74f9fd3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/graphic/VerticalPosition.java
@@ -0,0 +1,41 @@
+/* ========================================================================
+ * PlantUML : a free UML diagram generator
+ * ========================================================================
+ *
+ * (C) Copyright 2009-2014, Arnaud Roques
+ *
+ * Project Info: http://plantuml.sourceforge.net
+ *
+ * This file is part of PlantUML.
+ *
+ * Licensed under The MIT License (Massachusetts Institute of Technology License)
+ *
+ * See http://opensource.org/licenses/MIT
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+ * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Original Author: Arnaud Roques
+ */
+package net.sourceforge.plantuml.graphic;
+
+public enum VerticalPosition {
+
+ TOP, BOTTOM
+
+}