summaryrefslogtreecommitdiff
path: root/src/net/sourceforge/plantuml/ugraphic
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/sourceforge/plantuml/ugraphic')
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/AbstractCommonUGraphic.java150
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/AbstractPlacementStrategy.java114
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/AbstractShadowable.java49
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/AbstractUGraphic.java97
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/AbstractUGraphicHorizontalLine.java74
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ClipContainer.java39
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ColorChangerMonochrome.java48
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ColorMapper.java44
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ColorMapperIdentity.java59
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ColorMapperMonochrome.java51
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ColorMapperTransparentWrapper.java63
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/CompressionTransform.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/FontChecker.java246
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java304
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/InflaterSet.java68
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/LimitFinder.java228
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/MinMax.java135
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/MinMaxMutable.java104
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/PlacementStrategy.java48
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/PlacementStrategyVisibility.java71
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/PlacementStrategyX1X2.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/PlacementStrategyX1Y2Y3.java88
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2Center.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2Left.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/Scalable.java40
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ShadowManager.java78
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/Shadowable.java43
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/Slot.java99
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/SlotFinder.java140
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/SlotFinderX.java151
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/SlotSet.java121
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/Sprite.java44
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/SpriteGrayLevel.java281
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/SpriteImage.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/SpriteMonochrome.java119
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/SpriteUtils.java76
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/TextBlockInEllipse.java87
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/TextLimitFinder.java135
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UAntiAliasing.java53
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UCenteredCharacter.java55
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UChange.java41
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UChangeBackColor.java56
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UChangeColor.java50
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UClip.java154
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UDriver.java40
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UEllipse.java106
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UEmpty.java58
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UFont.java154
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UFontContext.java39
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UFontUser.java39
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UGraphic.java59
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UGraphic2.java43
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UGraphicCompress.java89
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UGraphicCompress2.java97
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UGraphicFilter.java61
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UGraphicNull.java76
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UGraphicStencil.java62
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UGraphicUtils.java127
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UHidden.java41
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UHorizontalLine.java181
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UImage.java59
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UImageSvg.java78
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ULayoutGroup.java63
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/ULine.java73
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UMotif.java169
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UParam.java52
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UParamNull.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UPath.java143
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UPattern.java41
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UPixel.java38
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UPolygon.java130
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/URectangle.java105
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UScale.java62
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/USegment.java62
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/USegmentType.java60
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UShape.java39
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UStroke.java95
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UText.java74
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/UTranslate.java89
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/arc/ExtendedGeneralPath.java766
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/arc/ExtendedPathIterator.java133
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/DriverCenteredCharacterEps.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/DriverDotPathEps.java57
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/DriverEllipseEps.java86
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/DriverImageEps.java71
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/DriverLineEps.java79
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/DriverPathEps.java57
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/DriverPolygonEps.java93
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/DriverRectangleEps.java98
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/DriverTextEps.java225
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/eps/UGraphicEps.java143
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverCenteredCharacterG2d.java63
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverDotPathG2d.java64
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverEllipseG2d.java143
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverImageG2d.java61
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverLineG2d.java82
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2d.java158
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2dLegacy.java157
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathOldG2d.java156
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverPixelG2d.java51
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverPolygonG2d.java127
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverRectangleG2d.java179
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverShadowedG2d.java111
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextAsPathG2d.java152
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java145
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/g2d/UGraphicG2d.java216
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/hand/HandJiggle.java152
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/hand/UDotPathHand.java60
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/hand/UEllipseHand.java90
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/hand/UGraphicHandwritten.java141
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/hand/ULineHand.java58
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/hand/UPathHand.java85
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/hand/UPolygonHand.java67
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/hand/URectangleHand.java78
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/html5/DriverLineHtml5.java82
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/html5/DriverNopHtml5.java46
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/html5/DriverRectangleHtml5.java99
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/html5/Html5Drawer.java134
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/html5/UGraphicHtml5.java141
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverCenteredCharacterSvg.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverDotPathSvg.java60
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverEllipseSvg.java108
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverImagePng.java76
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverImageSvgSvg.java50
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverLineSvg.java87
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverPathSvg.java83
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverPolygonSvg.java89
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverRectangleSvg.java96
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverTextAsPathSvg.java105
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java103
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/svg/UGraphicSvg.java174
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverAtomTextTikz.java53
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverCenteredCharacterTikz.java66
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverDotPathTikz.java53
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverEllipseTikz.java73
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverLineTikz.java56
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverNoneTikz.java48
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverPolygonTikz.java57
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverRectangleTikz.java58
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverUPathTikz.java53
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/DriverUTextTikz.java53
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/tikz/UGraphicTikz.java124
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/txt/UGraphicTxt.java119
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/DriverDotPathVdx.java50
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/DriverLineVdx.java55
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/DriverNoneVdx.java47
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/DriverPolygonVdx.java50
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/DriverRectangleVdx.java55
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/DriverTextVdx.java80
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/DriverUPathVdx.java52
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/UGraphicVdx.java123
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/VisioGraphics.java187
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/VisioLine.java117
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/VisioRectangle.java120
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/VisioShape.java46
-rw-r--r--src/net/sourceforge/plantuml/ugraphic/visio/VisioText.java128
157 files changed, 15061 insertions, 0 deletions
diff --git a/src/net/sourceforge/plantuml/ugraphic/AbstractCommonUGraphic.java b/src/net/sourceforge/plantuml/ugraphic/AbstractCommonUGraphic.java
new file mode 100644
index 0000000..5c0de1b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/AbstractCommonUGraphic.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.ugraphic;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public abstract class AbstractCommonUGraphic implements UGraphic {
+
+ private UStroke stroke = new UStroke();
+ private UPattern pattern = UPattern.FULL;
+ private boolean hidden = false;
+ private HtmlColor backColor = null;
+ private HtmlColor color = null;
+
+ private UTranslate translate = new UTranslate();
+
+ private final ColorMapper colorMapper;
+ private UClip clip;
+ private double scale = 1;
+
+ public UGraphic apply(UChange change) {
+ final AbstractCommonUGraphic copy = copyUGraphic();
+ if (change instanceof UTranslate) {
+ copy.translate = ((UTranslate) change).scaled(scale).compose(copy.translate);
+ } else if (change instanceof UClip) {
+ copy.clip = (UClip) change;
+ copy.clip = copy.clip.translate(getTranslateX(), getTranslateY());
+ } else if (change instanceof UStroke) {
+ copy.stroke = (UStroke) change;
+ } else if (change instanceof UPattern) {
+ copy.pattern = (UPattern) change;
+ } else if (change instanceof UHidden) {
+ copy.hidden = change == UHidden.HIDDEN;
+ } else if (change instanceof UChangeBackColor) {
+ copy.backColor = ((UChangeBackColor) change).getBackColor();
+ } else if (change instanceof UChangeColor) {
+ copy.color = ((UChangeColor) change).getColor();
+ } else if (change instanceof UScale) {
+ final double factor = ((UScale) change).getScale();
+ copy.scale = scale * factor;
+ }
+ return copy;
+ }
+
+ final public UClip getClip() {
+ return clip;
+ }
+
+ public AbstractCommonUGraphic(ColorMapper colorMapper) {
+ this.colorMapper = colorMapper;
+ }
+
+ protected AbstractCommonUGraphic(AbstractCommonUGraphic other) {
+ this.colorMapper = other.colorMapper;
+ this.translate = other.translate;
+ this.clip = other.clip;
+
+ this.stroke = other.stroke;
+ this.pattern = other.pattern;
+ this.hidden = other.hidden;
+ this.color = other.color;
+ this.backColor = other.backColor;
+ this.scale = other.scale;
+ }
+
+ protected abstract AbstractCommonUGraphic copyUGraphic();
+
+ final public UParam getParam() {
+ return new UParam() {
+
+ public boolean isHidden() {
+ return hidden;
+ }
+
+ public UStroke getStroke() {
+ return stroke;
+ }
+
+ public HtmlColor getColor() {
+ return color;
+ }
+
+ public HtmlColor getBackcolor() {
+ return backColor;
+ }
+
+ public UPattern getPattern() {
+ return pattern;
+ }
+
+ public double getScale() {
+ return scale;
+ }
+ };
+ }
+
+ final protected double getTranslateX() {
+ return translate.getDx();
+ }
+
+ final protected double getTranslateY() {
+ return translate.getDy();
+ }
+
+ final public ColorMapper getColorMapper() {
+ return new ColorMapperTransparentWrapper(colorMapper);
+ }
+
+ public void flushUg() {
+
+ }
+
+ public boolean isSpecialTxt() {
+ return false;
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/AbstractPlacementStrategy.java b/src/net/sourceforge/plantuml/ugraphic/AbstractPlacementStrategy.java
new file mode 100644
index 0000000..760246b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/AbstractPlacementStrategy.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.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public abstract class AbstractPlacementStrategy implements PlacementStrategy {
+
+ private final StringBounder stringBounder;
+ private final Map<TextBlock, Dimension2D> dimensions = new LinkedHashMap<TextBlock, Dimension2D>();
+
+ public AbstractPlacementStrategy(StringBounder stringBounder) {
+ this.stringBounder = stringBounder;
+ }
+
+ public void add(TextBlock block) {
+ this.dimensions.put(block, block.calculateDimension(stringBounder));
+ }
+
+ protected Map<TextBlock, Dimension2D> getDimensions() {
+ return dimensions;
+ }
+
+ protected double getSumWidth() {
+ return getSumWidth(dimensions.values().iterator());
+ }
+
+ protected double getSumHeight() {
+ return getSumHeight(dimensions.values().iterator());
+ }
+
+ protected double getMaxHeight() {
+ return getMaxHeight(dimensions.values().iterator());
+ }
+
+ protected double getMaxWidth() {
+ return getMaxWidth(dimensions.values().iterator());
+ }
+
+ protected double getSumWidth(Iterator<Dimension2D> it) {
+ double result = 0;
+ while (it.hasNext()) {
+ result += it.next().getWidth();
+ }
+ return result;
+ }
+
+ protected double getSumHeight(Iterator<Dimension2D> it) {
+ double result = 0;
+ while (it.hasNext()) {
+ result += it.next().getHeight();
+ }
+ return result;
+ }
+
+ protected double getMaxWidth(Iterator<Dimension2D> it) {
+ double result = 0;
+ while (it.hasNext()) {
+ result = Math.max(result, it.next().getWidth());
+ }
+ return result;
+ }
+
+ protected double getMaxHeight(Iterator<Dimension2D> it) {
+ double result = 0;
+ while (it.hasNext()) {
+ result = Math.max(result, it.next().getHeight());
+ }
+ return result;
+ }
+
+ protected final StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/AbstractShadowable.java b/src/net/sourceforge/plantuml/ugraphic/AbstractShadowable.java
new file mode 100644
index 0000000..693bf64
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/AbstractShadowable.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.ugraphic;
+
+abstract class AbstractShadowable implements Shadowable {
+
+ private double deltaShadow;
+
+ public double getDeltaShadow() {
+ return deltaShadow;
+ }
+
+ public void setDeltaShadow(double deltaShadow) {
+ this.deltaShadow = deltaShadow;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphic.java b/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphic.java
new file mode 100644
index 0000000..0db6067
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphic.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class AbstractUGraphic<O> extends AbstractCommonUGraphic {
+
+ private final O g2d;
+
+ private final Map<Class<? extends UShape>, UDriver<O>> drivers = new HashMap<Class<? extends UShape>, UDriver<O>>();
+
+ public AbstractUGraphic(ColorMapper colorMapper, O g2d) {
+ super(colorMapper);
+ this.g2d = g2d;
+ }
+
+ protected AbstractUGraphic(AbstractUGraphic<O> other) {
+ super(other);
+ this.g2d = other.g2d;
+ // this.drivers.putAll(other.drivers);
+ }
+
+ protected final O getGraphicObject() {
+ return g2d;
+ }
+
+ protected boolean manageHiddenAutomatically() {
+ return true;
+ }
+
+ final protected void registerDriver(Class<? extends UShape> cl, UDriver<O> driver) {
+ this.drivers.put(cl, driver);
+ }
+
+ public final void draw(UShape shape) {
+ if (shape instanceof UEmpty) {
+ return;
+ }
+ final UDriver<O> driver = drivers.get(shape.getClass());
+ if (driver == null) {
+ throw new UnsupportedOperationException(shape.getClass().toString() + " " + this.getClass());
+ }
+ if (getParam().isHidden() && manageHiddenAutomatically()) {
+ return;
+ }
+ beforeDraw();
+ if (shape instanceof Scalable) {
+ final double scale = getParam().getScale();
+ shape = ((Scalable) shape).getScaled(scale);
+ driver.draw(shape, getTranslateX(), getTranslateY(), getColorMapper(), getParam(), g2d);
+ } else {
+ driver.draw(shape, getTranslateX(), getTranslateY(), getColorMapper(), getParam(), g2d);
+ }
+ afterDraw();
+ }
+
+ protected void beforeDraw() {
+ }
+
+ protected void afterDraw() {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphicHorizontalLine.java b/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphicHorizontalLine.java
new file mode 100644
index 0000000..54739f6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/AbstractUGraphicHorizontalLine.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.ugraphic;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.graphic.UGraphicDelegator;
+
+public abstract class AbstractUGraphicHorizontalLine extends UGraphicDelegator {
+
+ private UTranslate translate = new UTranslate();
+
+ public UGraphic apply(UChange change) {
+ final AbstractUGraphicHorizontalLine result;
+ if (change instanceof UTranslate) {
+ result = copy(getUg());
+ result.translate = this.translate.compose((UTranslate) change);
+ } else {
+ result = copy(getUg().apply(change));
+ result.translate = this.translate;
+ }
+ return result;
+ }
+
+ protected abstract AbstractUGraphicHorizontalLine copy(UGraphic ug);
+
+ protected AbstractUGraphicHorizontalLine(UGraphic ug) {
+ super(ug);
+ }
+
+ protected abstract void drawHline(UGraphic ug, UHorizontalLine line, UTranslate translate);
+
+ public void draw(UShape shape) {
+ if (shape instanceof UHorizontalLine) {
+ drawHline(getUg(), (UHorizontalLine) shape, new UTranslate(0, translate.getDy()));
+ } else {
+ getUg().apply(translate).draw(shape);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ClipContainer.java b/src/net/sourceforge/plantuml/ugraphic/ClipContainer.java
new file mode 100644
index 0000000..e8d460b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ClipContainer.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.ugraphic;
+
+public interface ClipContainer {
+ public UClip getClip();
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ColorChangerMonochrome.java b/src/net/sourceforge/plantuml/ugraphic/ColorChangerMonochrome.java
new file mode 100644
index 0000000..a1754c7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ColorChangerMonochrome.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.Color;
+
+public class ColorChangerMonochrome {
+
+ public Color getChangedColor(Color color) {
+ if (color==null) {
+ return null;
+ }
+ final int grayScale = (int) (color.getRed() * .3 + color.getGreen() * .59 + color.getBlue() * .11);
+ return new Color(grayScale, grayScale, grayScale);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ColorMapper.java b/src/net/sourceforge/plantuml/ugraphic/ColorMapper.java
new file mode 100644
index 0000000..0154e03
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ColorMapper.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.ugraphic;
+
+import java.awt.Color;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public interface ColorMapper {
+
+ Color getMappedColor(HtmlColor color);
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ColorMapperIdentity.java b/src/net/sourceforge/plantuml/ugraphic/ColorMapperIdentity.java
new file mode 100644
index 0000000..0aa7765
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ColorMapperIdentity.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.ugraphic;
+
+import java.awt.Color;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorSimple;
+import net.sourceforge.plantuml.graphic.HtmlColorTransparent;
+import net.sourceforge.plantuml.graphic.HtmlColorUserDef;
+
+public class ColorMapperIdentity implements ColorMapper {
+
+ public Color getMappedColor(HtmlColor color) {
+ if (color == null) {
+ return null;
+ }
+ if (color instanceof HtmlColorTransparent) {
+ throw new UnsupportedOperationException();
+ }
+ if (color instanceof HtmlColorUserDef) {
+ // Impact on JCCKIT
+ return Color.WHITE;
+ }
+ return ((HtmlColorSimple) color).getColor999();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ColorMapperMonochrome.java b/src/net/sourceforge/plantuml/ugraphic/ColorMapperMonochrome.java
new file mode 100644
index 0000000..d2a0e2b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ColorMapperMonochrome.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.Color;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class ColorMapperMonochrome implements ColorMapper {
+
+ public Color getMappedColor(HtmlColor htmlColor) {
+ if (htmlColor == null) {
+ return null;
+ }
+ final Color color = new ColorMapperIdentity().getMappedColor(htmlColor);
+ final int grayScale = (int) (color.getRed() * .3 + color.getGreen() * .59 + color.getBlue() * .11);
+ return new Color(grayScale, grayScale, grayScale);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ColorMapperTransparentWrapper.java b/src/net/sourceforge/plantuml/ugraphic/ColorMapperTransparentWrapper.java
new file mode 100644
index 0000000..954b783
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ColorMapperTransparentWrapper.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.ugraphic;
+
+import java.awt.Color;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorTransparent;
+
+public class ColorMapperTransparentWrapper implements ColorMapper {
+
+ private final ColorMapper mapper;
+
+ public ColorMapperTransparentWrapper(ColorMapper mapper) {
+ if (mapper == null) {
+ throw new IllegalArgumentException();
+ }
+ this.mapper = mapper;
+ }
+
+ public Color getMappedColor(HtmlColor color) {
+ if (color == null) {
+ return null;
+ }
+ if (color instanceof HtmlColorTransparent) {
+ return Color.WHITE;
+ }
+ return mapper.getMappedColor(color);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/CompressionTransform.java b/src/net/sourceforge/plantuml/ugraphic/CompressionTransform.java
new file mode 100644
index 0000000..9f8268b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/CompressionTransform.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.ugraphic;
+
+import java.util.List;
+
+public class CompressionTransform {
+
+ private final List<Slot> all;
+
+ public CompressionTransform(SlotSet slotSet) {
+ this.all = slotSet.getSlots();
+ }
+
+ public double transform(double v) {
+ return v - getCompressDelta(v);
+ }
+
+ private double getCompressDelta(double v) {
+ double result = 0;
+ for (Slot s : all) {
+ if (s.getStart() > v) {
+ continue;
+ }
+ if (v > s.getEnd()) {
+ result += s.size();
+ } else {
+ result += v - s.getStart();
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/FontChecker.java b/src/net/sourceforge/plantuml/ugraphic/FontChecker.java
new file mode 100644
index 0000000..c234d28
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/FontChecker.java
@@ -0,0 +1,246 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.Font;
+import java.awt.GraphicsEnvironment;
+import java.awt.Shape;
+import java.awt.font.TextLayout;
+import java.awt.geom.PathIterator;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.imageio.ImageIO;
+import javax.xml.transform.TransformerException;
+
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+
+public class FontChecker {
+
+ final private UFont font;
+ private static final Set<String> SQUARRE = new HashSet<String>(Arrays.asList("MI=I=XM=I=IX",
+ "MI=I=XM=I=IXMI=I=XM=I=IX"));
+
+ public FontChecker(UFont font) {
+ this.font = font;
+ }
+
+ public boolean isCharOk(char c) {
+ return SQUARRE.contains(getCharDesc(c)) == false;
+ }
+
+ static private String getType(int type, double oldX, double oldY, double x, double y) {
+ if (type == PathIterator.SEG_CLOSE) {
+ return "X";
+ }
+ if (type == PathIterator.SEG_LINETO) {
+ if (oldX == x) {
+ return "I";
+ }
+ if (oldY == y) {
+ return "=";
+ }
+ return "L";
+ }
+ if (type == PathIterator.SEG_MOVETO) {
+ return "M";
+ }
+ if (type == PathIterator.SEG_QUADTO) {
+ return "Q";
+ }
+ if (type == PathIterator.SEG_CUBICTO) {
+ return "C";
+ }
+ throw new IllegalArgumentException();
+ }
+
+ public String getCharDesc(char c) {
+ final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext());
+ final Shape sh = t.getOutline(null);
+ final double current[] = new double[6];
+ final PathIterator it = sh.getPathIterator(null);
+ int sum = 0;
+ final StringBuilder result = new StringBuilder();
+ while (it.isDone() == false) {
+ final double oldX = current[0];
+ final double oldY = current[1];
+ final int nb = it.currentSegment(current);
+ sum += nb;
+ result.append(getType(nb, oldX, oldY, current[0], current[1]));
+ it.next();
+ }
+ return result.toString();
+ }
+
+ public String getCharDescVerbose(char c) {
+ final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext());
+ final Shape sh = t.getOutline(null);
+ final double current[] = new double[6];
+ final PathIterator it = sh.getPathIterator(null);
+ int sum = 0;
+ final StringBuilder result = new StringBuilder();
+ while (it.isDone() == false) {
+ final double oldX = current[0];
+ final double oldY = current[1];
+ final int nb = it.currentSegment(current);
+ sum += nb;
+ result.append(getType(nb, oldX, oldY, current[0], current[1]));
+ appendValue(result, current);
+ it.next();
+ }
+ return result.toString();
+ }
+
+ private void appendValue(StringBuilder result, double[] current) {
+ for (double v : current) {
+ final int i = (int) (v * 100);
+ result.append(i);
+ result.append(":");
+ }
+
+ }
+
+ public void printChar(final PrintWriter pw, char c) throws IOException, TransformerException {
+ pw.println("<p>");
+ final int ascii = (int) c;
+ pw.println(ascii + " - " + Integer.toHexString(ascii) + " - ");
+ pw.println("&#" + ascii + ";");
+ final String svg = getSvgImage(c);
+ pw.println(svg);
+ }
+
+ private String getSvgImage(char c) throws IOException, TransformerException {
+ final SvgGraphics svg = new SvgGraphics(1.0);
+ svg.setStrokeColor("black");
+ svg.svgImage(getBufferedImage(c), 0, 0);
+ final ByteArrayOutputStream os = new ByteArrayOutputStream();
+ svg.createXml(os);
+ os.close();
+ return new String(os.toByteArray());
+ }
+
+ public BufferedImage getBufferedImage(final char c) throws IOException {
+ assert c != '\t';
+ final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1, null, null, null, 0, 0, null, false);
+ final double dim = 20;
+ imageBuilder.addUDrawable(new UDrawable() {
+ public void drawU(UGraphic ug) {
+ ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+ ug.draw(new URectangle(dim - 1, dim - 1));
+ if (ug instanceof UGraphic2) {
+ ug = (UGraphic2) ug.apply(new UTranslate(dim / 3, 2 * dim / 3));
+ final UText text = new UText("" + c, new FontConfiguration(font, HtmlColorUtils.BLACK,
+ HtmlColorUtils.BLUE, true));
+ ug.draw(text);
+ }
+ }
+ });
+ final ByteArrayOutputStream os = new ByteArrayOutputStream();
+ imageBuilder.writeImageTOBEMOVED(FileFormat.PNG, os);
+ os.close();
+ return ImageIO.read(new ByteArrayInputStream(os.toByteArray()));
+ }
+
+ // public BufferedImage getBufferedImageOld(char c) throws IOException {
+ // final double dim = 20;
+ // UGraphic2 ug = new FileFormatOption(FileFormat.PNG).createUGraphic(new Dimension2DDouble(dim, dim));
+ // ug = (UGraphic2) ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
+ // ug.draw(new URectangle(dim - 1, dim - 1));
+ // ug = (UGraphic2) ug.apply(new UTranslate(dim / 3, 2 * dim / 3));
+ // final UText text = new UText("" + c, new FontConfiguration(font, HtmlColorUtils.BLACK));
+ // ug.draw(text);
+ // final ByteArrayOutputStream os = new ByteArrayOutputStream();
+ // ug.writeImageTOBEMOVED(os, null, 96);
+ // os.close();
+ // return ImageIO.read(new ByteArrayInputStream(os.toByteArray()));
+ // }
+
+ public static void main(String[] args) throws IOException, TransformerException {
+
+ final String name = args[0];
+ final int size = Integer.parseInt(args[1]);
+ final int v1 = Integer.parseInt(args[2]);
+ final int v2 = Integer.parseInt(args[3]);
+ final File f = new File("fontchecker-" + name + "-" + v1 + "-" + v2 + ".html");
+
+ final FontChecker fc = new FontChecker(new UFont(name, Font.PLAIN, size));
+ final PrintWriter pw = new PrintWriter(f);
+ pw.println("<html>");
+ pw.println("<h1>PROBLEM</h1>");
+ for (int i = v1; i <= v2; i++) {
+ final char c = (char) i;
+ final boolean ok = fc.isCharOk(c);
+ if (ok == false) {
+ fc.printChar(pw, c);
+ pw.println("</p>");
+ }
+ }
+ pw.println("<h1>OK</h1>");
+ final String allFontNames[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
+ for (int i = v1; i <= v2; i++) {
+ final char c = (char) i;
+ final boolean ok = fc.isCharOk(c);
+ if (ok) {
+ fc.printChar(pw, c);
+ final String desc = fc.getCharDescVerbose(c);
+ for (String n : allFontNames) {
+ final FontChecker other = new FontChecker(new UFont(n, Font.PLAIN, size));
+ final String descOther = other.getCharDescVerbose(c);
+ if (desc.equals(descOther)) {
+ pw.println("&nbsp;");
+ pw.println(n);
+ }
+ }
+ pw.println("</p>");
+
+ }
+ }
+ pw.println("</html>");
+ pw.close();
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java
new file mode 100644
index 0000000..57fd164
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ImageBuilder.java
@@ -0,0 +1,304 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Image;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Set;
+
+import javax.imageio.ImageIO;
+import javax.swing.ImageIcon;
+
+import net.sourceforge.plantuml.AnimatedGifEncoder;
+import net.sourceforge.plantuml.CMapData;
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.EmptyImageBuilder;
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileUtils;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.anim.AffineTransformation;
+import net.sourceforge.plantuml.anim.Animation;
+import net.sourceforge.plantuml.api.ImageDataComplex;
+import net.sourceforge.plantuml.api.ImageDataSimple;
+import net.sourceforge.plantuml.core.ImageData;
+import net.sourceforge.plantuml.eps.EpsStrategy;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.graphic.HtmlColorSimple;
+import net.sourceforge.plantuml.graphic.HtmlColorTransparent;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.mjpeg.MJPEGGenerator;
+import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps;
+import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
+import net.sourceforge.plantuml.ugraphic.hand.UGraphicHandwritten;
+import net.sourceforge.plantuml.ugraphic.html5.UGraphicHtml5;
+import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg;
+import net.sourceforge.plantuml.ugraphic.tikz.UGraphicTikz;
+import net.sourceforge.plantuml.ugraphic.visio.UGraphicVdx;
+import net.sourceforge.plantuml.StringUtils;
+
+public class ImageBuilder {
+
+ private final ColorMapper colorMapper;
+ private final double dpiFactor;
+ private final HtmlColor mybackcolor;
+ private final String metadata;
+ private final String warningOrError;
+ private final double margin1;
+ private final double margin2;
+ private final Animation affineTransformations;
+ private final boolean useHandwritten;
+
+ // private final AffineTransform affineTransform;
+ // private final boolean withMetadata;
+ // private final boolean useRedForError;
+
+ private UDrawable udrawable;
+
+ public ImageBuilder(ColorMapper colorMapper, double dpiFactor, HtmlColor mybackcolor, String metadata,
+ String warningOrError, double margin1, double margin2, Animation affineTransformations,
+ boolean useHandwritten) {
+ this.colorMapper = colorMapper;
+ this.dpiFactor = dpiFactor;
+ this.mybackcolor = mybackcolor;
+ this.metadata = metadata;
+ this.warningOrError = warningOrError;
+ this.margin1 = margin1;
+ this.margin2 = margin2;
+ this.affineTransformations = affineTransformations;
+ this.useHandwritten = useHandwritten;
+ }
+
+ public void addUDrawable(UDrawable udrawable) {
+ this.udrawable = udrawable;
+ }
+
+ public ImageData writeImageTOBEMOVED(FileFormat fileFormat, OutputStream os) throws IOException {
+ if (fileFormat == FileFormat.MJPEG) {
+ return writeImageMjpeg(os);
+ } else if (fileFormat == FileFormat.ANIMATED_GIF) {
+ return writeImageAnimatedGif(os);
+ }
+ return writeImageTOBEMOVED(fileFormat, os, affineTransformations);
+ }
+
+ private ImageData writeImageTOBEMOVED(FileFormat fileFormat, OutputStream os, Animation affineTransforms)
+ throws IOException {
+ final LimitFinder limitFinder = new LimitFinder(TextBlockUtils.getDummyStringBounder(), true);
+ udrawable.drawU(limitFinder);
+ Dimension2D dim = new Dimension2DDouble(limitFinder.getMaxX() + 1 + margin1 + margin2, limitFinder.getMaxY()
+ + 1 + margin1 + margin2);
+ double dx = 0;
+ double dy = 0;
+ if (affineTransforms != null) {
+ final MinMax minmax = affineTransformations.getMinMax(dim);
+ affineTransforms.setDimension(dim);
+ dim = minmax.getDimension();
+ dx = -minmax.getMinX();
+ dy = -minmax.getMinY();
+ }
+
+ final UGraphic2 ug = createUGraphic(fileFormat, dim, affineTransforms, dx, dy);
+ udrawable.drawU(handwritten(ug.apply(new UTranslate(margin1, margin1))));
+ ug.writeImageTOBEMOVED(os, metadata, 96);
+ os.flush();
+
+ if (ug instanceof UGraphicG2d) {
+ final Set<Url> urls = ((UGraphicG2d) ug).getAllUrlsEncountered();
+ if (urls.size() > 0) {
+ final CMapData cmap = CMapData.cmapString(urls, dpiFactor);
+ return new ImageDataComplex(dim, cmap, warningOrError);
+ }
+ }
+
+ return new ImageDataSimple(dim);
+ }
+
+ private UGraphic handwritten(UGraphic ug) {
+ if (useHandwritten) {
+ return new UGraphicHandwritten(ug);
+ }
+ return ug;
+ }
+
+ private ImageData writeImageMjpeg(OutputStream os) throws IOException {
+
+ final LimitFinder limitFinder = new LimitFinder(TextBlockUtils.getDummyStringBounder(), true);
+ udrawable.drawU(limitFinder);
+ final Dimension2D dim = new Dimension2DDouble(limitFinder.getMaxX() + 1 + margin1 + margin2,
+ limitFinder.getMaxY() + 1 + margin1 + margin2);
+
+ final File f = new File("c:/tmp.avi");
+
+ final int nbframe = 100;
+
+ final MJPEGGenerator m = new MJPEGGenerator(f, getAviImage(null).getWidth(null), getAviImage(null).getHeight(
+ null), 12.0, nbframe);
+ for (int i = 0; i < nbframe; i++) {
+ // AffineTransform at = AffineTransform.getRotateInstance(1.0);
+ AffineTransform at = AffineTransform.getTranslateInstance(dim.getWidth() / 2, dim.getHeight() / 2);
+ at.rotate(90.0 * Math.PI / 180.0 * i / 100);
+ at.translate(-dim.getWidth() / 2, -dim.getHeight() / 2);
+ // final AffineTransform at = AffineTransform.getTranslateInstance(i, 0);
+ // final ImageIcon ii = new ImageIcon(getAviImage(at));
+ // m.addImage(ii.getImage());
+ throw new UnsupportedOperationException();
+ }
+ m.finishAVI();
+
+ FileUtils.copyToStream(f, os);
+
+ return new ImageDataSimple(dim);
+
+ }
+
+ private ImageData writeImageAnimatedGif(OutputStream os) throws IOException {
+
+ final LimitFinder limitFinder = new LimitFinder(TextBlockUtils.getDummyStringBounder(), true);
+ udrawable.drawU(limitFinder);
+ final Dimension2D dim = new Dimension2DDouble(limitFinder.getMaxX() + 1 + margin1 + margin2,
+ limitFinder.getMaxY() + 1 + margin1 + margin2);
+
+ final MinMax minmax = affineTransformations.getMinMax(dim);
+
+ final AnimatedGifEncoder e = new AnimatedGifEncoder();
+ // e.setQuality(1);
+ e.setRepeat(0);
+ e.start(os);
+ // e.setDelay(1000); // 1 frame per sec
+ // e.setDelay(100); // 10 frame per sec
+ e.setDelay(60); // 16 frame per sec
+ // e.setDelay(50); // 20 frame per sec
+
+ for (AffineTransformation at : affineTransformations.getAll()) {
+ final ImageIcon ii = new ImageIcon(getAviImage(at));
+ e.addFrame((BufferedImage) ii.getImage());
+ }
+ e.finish();
+ return new ImageDataSimple(dim);
+
+ }
+
+ private Image getAviImage(AffineTransformation affineTransform) throws IOException {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ writeImageTOBEMOVED(FileFormat.PNG, baos, Animation.singleton(affineTransform));
+ baos.close();
+
+ final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ final Image im = ImageIO.read(bais);
+ bais.close();
+ return im;
+ }
+
+ private UGraphic2 createUGraphic(FileFormat fileFormat, final Dimension2D dim, Animation affineTransforms,
+ double dx, double dy) {
+ switch (fileFormat) {
+ case PNG:
+ return createUGraphicPNG(colorMapper, dpiFactor, dim, mybackcolor, affineTransforms, dx, dy);
+ case SVG:
+ return createUGraphicSVG(colorMapper, dpiFactor, dim, mybackcolor);
+ case EPS:
+ return new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
+ case EPS_TEXT:
+ return new UGraphicEps(colorMapper, EpsStrategy.WITH_MACRO_AND_TEXT);
+ case HTML5:
+ return new UGraphicHtml5(colorMapper);
+ case VDX:
+ return new UGraphicVdx(colorMapper);
+ case LATEX:
+ return new UGraphicTikz(colorMapper);
+ default:
+ throw new UnsupportedOperationException(fileFormat.toString());
+ }
+ }
+
+ private UGraphic2 createUGraphicSVG(ColorMapper colorMapper, double scale, Dimension2D dim, HtmlColor mybackcolor) {
+ Color backColor = Color.WHITE;
+ if (mybackcolor instanceof HtmlColorSimple) {
+ backColor = colorMapper.getMappedColor(mybackcolor);
+ }
+ final UGraphicSvg ug;
+ if (mybackcolor instanceof HtmlColorGradient) {
+ ug = new UGraphicSvg(colorMapper, (HtmlColorGradient) mybackcolor, false, scale);
+ } else if (backColor == null || backColor.equals(Color.WHITE)) {
+ ug = new UGraphicSvg(colorMapper, false, scale);
+ } else {
+ ug = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(backColor), false, scale);
+ }
+ return ug;
+
+ }
+
+ private UGraphic2 createUGraphicPNG(ColorMapper colorMapper, double dpiFactor, final Dimension2D dim,
+ HtmlColor mybackcolor, Animation affineTransforms, double dx, double dy) {
+ Color backColor = Color.WHITE;
+ if (mybackcolor instanceof HtmlColorSimple) {
+ backColor = colorMapper.getMappedColor(mybackcolor);
+ } else if (mybackcolor instanceof HtmlColorTransparent) {
+ backColor = null;
+ }
+
+ /*
+ * if (rotation) { builder = new EmptyImageBuilder((int) (dim.getHeight() * dpiFactor), (int) (dim.getWidth() *
+ * dpiFactor), backColor); graphics2D = builder.getGraphics2D(); graphics2D.rotate(-Math.PI / 2);
+ * graphics2D.translate(-builder.getBufferedImage().getHeight(), 0); } else {
+ */
+ final EmptyImageBuilder builder = new EmptyImageBuilder((int) (dim.getWidth() * dpiFactor),
+ (int) (dim.getHeight() * dpiFactor), backColor);
+ final Graphics2D graphics2D = builder.getGraphics2D();
+
+ // }
+ final UGraphicG2d ug = new UGraphicG2d(colorMapper, graphics2D, dpiFactor, affineTransforms == null ? null
+ : affineTransforms.getFirst(), dx, dy);
+ ug.setBufferedImage(builder.getBufferedImage());
+ final BufferedImage im = ((UGraphicG2d) ug).getBufferedImage();
+ if (mybackcolor instanceof HtmlColorGradient) {
+ ug.apply(new UChangeBackColor(mybackcolor)).draw(new URectangle(im.getWidth(), im.getHeight()));
+ }
+
+ return ug;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/InflaterSet.java b/src/net/sourceforge/plantuml/ugraphic/InflaterSet.java
new file mode 100644
index 0000000..64cc1b1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/InflaterSet.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.ugraphic;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class InflaterSet {
+
+ static class Inflater {
+ private final double start;
+ private final double size;
+
+ private Inflater(double start, double size) {
+ this.start = start;
+ this.size = size;
+ }
+ }
+
+ private final List<Inflater> all = new ArrayList<Inflater>();
+
+ public void addInflater(double start, double size) {
+ all.add(new Inflater(start, size));
+ }
+
+ public double inflate(double v) {
+ double result = v;
+ for (Inflater in : all) {
+ if (v > in.start) {
+ result += in.size;
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/LimitFinder.java b/src/net/sourceforge/plantuml/ugraphic/LimitFinder.java
new file mode 100644
index 0000000..b1034aa
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/LimitFinder.java
@@ -0,0 +1,228 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.posimo.DotPath;
+
+public class LimitFinder implements UGraphic {
+
+ public boolean isSpecialTxt() {
+ return false;
+ }
+
+ public UGraphic apply(UChange change) {
+ if (change instanceof UTranslate) {
+ return new LimitFinder(stringBounder, minmax, translate.compose((UTranslate) change), clip);
+ } else if (change instanceof UStroke) {
+ return new LimitFinder(this);
+ } else if (change instanceof UChangeBackColor) {
+ return new LimitFinder(this);
+ } else if (change instanceof UChangeColor) {
+ return new LimitFinder(this);
+ } else if (change instanceof UHidden) {
+ return new LimitFinder(this);
+ } else if (change instanceof UAntiAliasing) {
+ return new LimitFinder(this);
+ } else if (change instanceof UClip) {
+ final LimitFinder copy = new LimitFinder(this);
+ copy.clip = (UClip) change;
+ copy.clip = copy.clip.translate(translate);
+ return copy;
+ }
+ throw new UnsupportedOperationException(change.getClass().toString());
+ }
+
+ private final StringBounder stringBounder;
+ private final UTranslate translate;
+ private final MinMaxMutable minmax;
+ private UClip clip;
+
+ public LimitFinder(StringBounder stringBounder, boolean initToZero) {
+ this(stringBounder, MinMaxMutable.getEmpty(initToZero), new UTranslate(), null);
+ }
+
+ private LimitFinder(StringBounder stringBounder, MinMaxMutable minmax, UTranslate translate, UClip clip) {
+ this.stringBounder = stringBounder;
+ this.minmax = minmax;
+ this.translate = translate;
+ this.clip = clip;
+ }
+
+ private LimitFinder(LimitFinder other) {
+ this(other.stringBounder, other.minmax, other.translate, other.clip);
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public UParam getParam() {
+ return new UParamNull();
+ }
+
+ private void addPoint(double x, double y) {
+ if (clip == null || clip.isInside(x, y)) {
+ minmax.addPoint(x, y);
+ }
+ }
+
+ public void draw(UShape shape) {
+ final double x = translate.getDx();
+ final double y = translate.getDy();
+ if (shape instanceof UText) {
+ drawText(x, y, (UText) shape);
+ } else if (shape instanceof ULine) {
+ drawULine(x, y, (ULine) shape);
+ } else if (shape instanceof UEllipse) {
+ drawEllipse(x, y, (UEllipse) shape);
+ } else if (shape instanceof UPolygon) {
+ drawUPolygon(x, y, (UPolygon) shape);
+ } else if (shape instanceof UPath) {
+ drawUPath(x, y, (UPath) shape);
+ } else if (shape instanceof URectangle) {
+ drawRectangle(x, y, (URectangle) shape);
+ } else if (shape instanceof DotPath) {
+ drawDotPath(x, y, (DotPath) shape);
+ } else if (shape instanceof UImage) {
+ drawImage(x, y, (UImage) shape);
+ } else if (shape instanceof UEmpty) {
+ drawEmpty(x, y, (UEmpty) shape);
+ } else if (shape instanceof TextBlock) {
+ final TextBlock tb = (TextBlock) shape;
+ tb.drawU(this);
+ } else if (shape instanceof UCenteredCharacter) {
+ // To be done
+ } else if (shape instanceof UPixel) {
+ addPoint(x, y);
+ } else {
+ throw new UnsupportedOperationException(shape.getClass().getName());
+ }
+ }
+
+ private void drawEmpty(double x, double y, UEmpty shape) {
+ addPoint(x, y);
+ addPoint(x + shape.getWidth(), y + shape.getHeight());
+ }
+
+ private void drawUPath(double x, double y, UPath shape) {
+ addPoint(x + shape.getMinX(), y + shape.getMinY());
+ addPoint(x + shape.getMaxX(), y + shape.getMaxY());
+ }
+
+ private void drawUPolygon(double x, double y, UPolygon shape) {
+ if (shape.getPoints().size() == 0) {
+ return;
+ }
+ addPoint(x + shape.getMinX(), y + shape.getMinY());
+ addPoint(x + shape.getMaxX(), y + shape.getMaxY());
+ }
+
+ private void drawULine(double x, double y, ULine shape) {
+ addPoint(x, y);
+ addPoint(x + shape.getDX(), y + shape.getDY());
+ }
+
+ private void drawRectangle(double x, double y, URectangle shape) {
+ addPoint(x, y);
+ addPoint(x + shape.getWidth(), y + shape.getHeight());
+ }
+
+ private void drawDotPath(double x, double y, DotPath shape) {
+ final MinMax shapeMinMax = shape.getMinMax();
+ addPoint(x + shapeMinMax.getMinX(), y + shapeMinMax.getMinY());
+ addPoint(x + shapeMinMax.getMaxX(), y + shapeMinMax.getMaxY());
+ }
+
+ private void drawImage(double x, double y, UImage shape) {
+ addPoint(x, y);
+ addPoint(x + shape.getWidth(), y + shape.getHeight());
+ }
+
+ private void drawEllipse(double x, double y, UEllipse shape) {
+ addPoint(x, y);
+ addPoint(x + shape.getWidth(), y + shape.getHeight());
+ }
+
+ private void drawText(double x, double y, UText text) {
+ final Dimension2D dim = stringBounder.calculateDimension(text.getFontConfiguration().getFont(), text.getText());
+ y -= dim.getHeight() - 1.5;
+ addPoint(x, y);
+ addPoint(x, y + dim.getHeight());
+ addPoint(x + dim.getWidth(), y);
+ addPoint(x + dim.getWidth(), y + dim.getHeight());
+ }
+
+ public ColorMapper getColorMapper() {
+ return new ColorMapperIdentity();
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ public double getMaxX() {
+ return minmax.getMaxX();
+ }
+
+ public double getMaxY() {
+ return minmax.getMaxY();
+ }
+
+ public double getMinX() {
+ return minmax.getMinX();
+ }
+
+ public double getMinY() {
+ return minmax.getMinY();
+ }
+
+ public MinMax getMinMax() {
+ if (minmax.isInfinity()) {
+ return MinMax.getEmpty(true);
+ }
+ return MinMax.fromMutable(minmax);
+ }
+
+ public void flushUg() {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/MinMax.java b/src/net/sourceforge/plantuml/ugraphic/MinMax.java
new file mode 100644
index 0000000..a8dec9d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/MinMax.java
@@ -0,0 +1,135 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+
+public class MinMax {
+
+ private final double maxX;
+ private final double maxY;
+ private final double minX;
+ private final double minY;
+
+ public static MinMax getEmpty(boolean initToZero) {
+ if (initToZero) {
+ return new MinMax(0, 0, 0, 0);
+ }
+ return new MinMax(Double.MAX_VALUE, Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE);
+ }
+
+ @Override
+ public String toString() {
+ return "(" + minX + "," + minY + ")->(" + maxX + "," + maxY + ")";
+ }
+
+ public static MinMax fromMutable(MinMaxMutable minmax) {
+ return new MinMax(minmax.getMinX(), minmax.getMinY(), minmax.getMaxX(), minmax.getMaxY());
+ }
+
+ private MinMax(double minX, double minY, double maxX, double maxY) {
+ this.minX = minX;
+ this.minY = minY;
+ this.maxX = maxX;
+ this.maxY = maxY;
+ }
+
+ public MinMax addPoint(Point2D pt) {
+ return addPoint(pt.getX(), pt.getY());
+ }
+
+ public MinMax addPoint(double x, double y) {
+ return new MinMax(Math.min(x, minX), Math.min(y, minY), Math.max(x, maxX), Math.max(y, maxY));
+ }
+
+ public MinMax addMinMax(MinMax other) {
+ return new MinMax(Math.min(other.minX, minX), Math.min(other.minY, minY), Math.max(other.maxX, maxX), Math.max(other.maxY, maxY));
+ }
+
+ public static MinMax fromMax(double maxX, double maxY) {
+ return MinMax.getEmpty(true).addPoint(maxX, maxY);
+ }
+
+ public static MinMax fromDim(Dimension2D dim) {
+ return fromMax(dim.getWidth(), dim.getHeight());
+ }
+
+ public final double getMaxX() {
+ return maxX;
+ }
+
+ public final double getMaxY() {
+ return maxY;
+ }
+
+ public final double getMinX() {
+ return minX;
+ }
+
+ public final double getMinY() {
+ return minY;
+ }
+
+ public double getHeight() {
+ return maxY - minY;
+ }
+
+ public double getWidth() {
+ return maxX - minX;
+ }
+
+ public Dimension2D getDimension() {
+ return new Dimension2DDouble(maxX - minX, maxY - minY);
+ }
+
+ public void drawGrey(UGraphic ug) {
+ final HtmlColor color = HtmlColorUtils.GRAY;
+ ug = ug.apply(new UChangeColor(color)).apply(new UChangeBackColor(color));
+ ug = ug.apply(new UTranslate(minX, minY));
+ ug.draw(new URectangle(getWidth(), getHeight()));
+ }
+
+ public MinMax translate(UTranslate translate) {
+ final double dx = translate.getDx();
+ final double dy = translate.getDy();
+ return new MinMax(minX + dx, minY + dy, maxX + dx, maxY + dy);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/MinMaxMutable.java b/src/net/sourceforge/plantuml/ugraphic/MinMaxMutable.java
new file mode 100644
index 0000000..3c45961
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/MinMaxMutable.java
@@ -0,0 +1,104 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+
+public class MinMaxMutable {
+
+ private double maxX;
+ private double maxY;
+ private double minX;
+ private double minY;
+
+ public static MinMaxMutable getEmpty(boolean initToZero) {
+ if (initToZero) {
+ return new MinMaxMutable(0, 0, 0, 0);
+ }
+ return new MinMaxMutable(Double.MAX_VALUE, Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE);
+ }
+
+ public boolean isInfinity() {
+ return minX == Double.MAX_VALUE;
+ }
+
+ @Override
+ public String toString() {
+ return "X=" + minX + " " + maxX + " Y=" + minY + " " + maxY;
+ }
+
+ private MinMaxMutable(double minX, double minY, double maxX, double maxY) {
+ this.minX = minX;
+ this.minY = minY;
+ this.maxX = maxX;
+ this.maxY = maxY;
+ }
+
+ public void addPoint(double x, double y) {
+ this.maxX = Math.max(x, maxX);
+ this.maxY = Math.max(y, maxY);
+ this.minX = Math.min(x, minX);
+ this.minY = Math.min(y, minY);
+ }
+
+ public static MinMaxMutable fromMax(double maxX, double maxY) {
+ final MinMaxMutable result = MinMaxMutable.getEmpty(true);
+ result.addPoint(maxX, maxY);
+ return result;
+ }
+
+ public final double getMaxX() {
+ return maxX;
+ }
+
+ public final double getMaxY() {
+ return maxY;
+ }
+
+ public final double getMinX() {
+ return minX;
+ }
+
+ public final double getMinY() {
+ return minY;
+ }
+
+ public Dimension2D getDimension() {
+ return new Dimension2DDouble(maxX - minX, maxY - minY);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/PlacementStrategy.java b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategy.java
new file mode 100644
index 0000000..55c7a22
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategy.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.geom.Point2D;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public interface PlacementStrategy {
+
+ public void add(TextBlock block);
+
+ public Map<TextBlock, Point2D> getPositions(double width, double height);
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyVisibility.java b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyVisibility.java
new file mode 100644
index 0000000..0ee98e7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyVisibility.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.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class PlacementStrategyVisibility extends AbstractPlacementStrategy {
+
+ private final int col2;
+
+ public PlacementStrategyVisibility(StringBounder stringBounder, int col2) {
+ super(stringBounder);
+ this.col2 = col2;
+ }
+
+ public Map<TextBlock, Point2D> getPositions(double width, double height) {
+ final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
+ double y = 0;
+ for (final Iterator<Map.Entry<TextBlock, Dimension2D>> it = getDimensions().entrySet().iterator(); it.hasNext();) {
+ final Map.Entry<TextBlock, Dimension2D> ent1 = it.next();
+ final Map.Entry<TextBlock, Dimension2D> ent2 = it.next();
+ final double height1 = ent1.getValue().getHeight();
+ final double height2 = ent2.getValue().getHeight();
+ final double maxHeight = Math.max(height1, height2);
+ result.put(ent1.getKey(), new Point2D.Double(0, 2 + y + (maxHeight - height1) / 2));
+ result.put(ent2.getKey(), new Point2D.Double(col2, y + (maxHeight - height2) / 2));
+ y += maxHeight;
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyX1X2.java b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyX1X2.java
new file mode 100644
index 0000000..fd29ef6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyX1X2.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.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class PlacementStrategyX1X2 extends AbstractPlacementStrategy {
+
+ public PlacementStrategyX1X2(StringBounder stringBounder) {
+ super(stringBounder);
+ }
+
+ public Map<TextBlock, Point2D> getPositions(double width, double height) {
+ final double usedWidth = getSumWidth();
+ //double maxHeight = getMaxHeight();
+
+ final double space = (width - usedWidth) / (getDimensions().size() + 1);
+ final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
+ double x = space;
+ for (Map.Entry<TextBlock, Dimension2D> ent : getDimensions().entrySet()) {
+ final double y = (height - ent.getValue().getHeight()) / 2;
+ result.put(ent.getKey(), new Point2D.Double(x, y));
+ x += ent.getValue().getWidth() + space;
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyX1Y2Y3.java b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyX1Y2Y3.java
new file mode 100644
index 0000000..e36e707
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyX1Y2Y3.java
@@ -0,0 +1,88 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class PlacementStrategyX1Y2Y3 extends AbstractPlacementStrategy {
+
+ public PlacementStrategyX1Y2Y3(StringBounder stringBounder) {
+ super(stringBounder);
+ }
+
+ public Map<TextBlock, Point2D> getPositions(double width, double height) {
+ final Dimension2D first = getDimensions().values().iterator().next();
+
+ final double maxWidthButFirst = getMaxWidth(butFirst());
+ final double sumHeightButFirst = getSumHeight(butFirst());
+
+ final double space = (width - first.getWidth() - maxWidthButFirst) / 3;
+
+ final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
+ // double x = space * 2;
+
+ final Iterator<Map.Entry<TextBlock, Dimension2D>> it = getDimensions().entrySet().iterator();
+ final Map.Entry<TextBlock, Dimension2D> ent = it.next();
+ double y = (height - ent.getValue().getHeight()) / 2;
+ result.put(ent.getKey(), new Point2D.Double(space, y));
+
+ // x += ent.getValue().getWidth() + space;
+
+ y = (height - sumHeightButFirst) / 2;
+ while (it.hasNext()) {
+ final Map.Entry<TextBlock, Dimension2D> ent2 = it.next();
+ final TextBlock textBlock = ent2.getKey();
+ final Dimension2D dim = getDimensions().get(textBlock);
+ final double x = 2 * space + first.getWidth() + (maxWidthButFirst - dim.getWidth()) / 2;
+ result.put(textBlock, new Point2D.Double(x, y));
+ y += ent2.getValue().getHeight();
+ }
+ return result;
+ }
+
+ private Iterator<Dimension2D> butFirst() {
+ final Iterator<Dimension2D> iterator = getDimensions().values().iterator();
+ iterator.next();
+ return iterator;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2.java b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2.java
new file mode 100644
index 0000000..de64e95
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2.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.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class PlacementStrategyY1Y2 extends AbstractPlacementStrategy {
+
+ public PlacementStrategyY1Y2(StringBounder stringBounder) {
+ super(stringBounder);
+ }
+
+ public Map<TextBlock, Point2D> getPositions(double width, double height) {
+ final double usedHeight = getSumHeight();
+ //double maxWidth = getMaxWidth();
+
+ final double space = (height - usedHeight) / (getDimensions().size() + 1);
+ final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
+ double y = space;
+ for (Map.Entry<TextBlock, Dimension2D> ent : getDimensions().entrySet()) {
+ final double x = (width - ent.getValue().getWidth()) / 2;
+ result.put(ent.getKey(), new Point2D.Double(x, y));
+ y += ent.getValue().getHeight() + space;
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2Center.java b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2Center.java
new file mode 100644
index 0000000..1e47e2d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2Center.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.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class PlacementStrategyY1Y2Center extends AbstractPlacementStrategy {
+
+ public PlacementStrategyY1Y2Center(StringBounder stringBounder) {
+ super(stringBounder);
+ }
+
+ public Map<TextBlock, Point2D> getPositions(double width, double height) {
+ final double usedHeight = getSumHeight();
+ // double maxWidth = getMaxWidth();
+
+ final double space = (height - usedHeight) / (getDimensions().size() + 1);
+ final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
+ double y = space;
+ for (Map.Entry<TextBlock, Dimension2D> ent : getDimensions().entrySet()) {
+ final double x = (width - ent.getValue().getWidth()) / 2;
+ result.put(ent.getKey(), new Point2D.Double(x, y));
+ y += ent.getValue().getHeight() + space;
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2Left.java b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2Left.java
new file mode 100644
index 0000000..c80acc5
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/PlacementStrategyY1Y2Left.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.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class PlacementStrategyY1Y2Left extends AbstractPlacementStrategy {
+
+ public PlacementStrategyY1Y2Left(StringBounder stringBounder) {
+ super(stringBounder);
+ }
+
+ public Map<TextBlock, Point2D> getPositions(double width, double height) {
+ final double usedHeight = getSumHeight();
+ //double maxWidth = getMaxWidth();
+
+ final double space = (height - usedHeight) / (getDimensions().size() + 1);
+ final Map<TextBlock, Point2D> result = new LinkedHashMap<TextBlock, Point2D>();
+ double y = space;
+ for (Map.Entry<TextBlock, Dimension2D> ent : getDimensions().entrySet()) {
+ final double x = 0;
+ result.put(ent.getKey(), new Point2D.Double(x, y));
+ y += ent.getValue().getHeight() + space;
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/Scalable.java b/src/net/sourceforge/plantuml/ugraphic/Scalable.java
new file mode 100644
index 0000000..4aef956
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/Scalable.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.ugraphic;
+
+public interface Scalable {
+
+ public UShape getScaled(double scale);
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ShadowManager.java b/src/net/sourceforge/plantuml/ugraphic/ShadowManager.java
new file mode 100644
index 0000000..b7b9bb4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ShadowManager.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.ugraphic;
+
+import java.awt.Color;
+
+public class ShadowManager {
+
+ // http://www.w3schools.com/svg/svg_feoffset.asp
+
+ private final int c1;
+ private final int c2;
+
+ public ShadowManager(int c1, int c2) {
+ this.c1 = c1;
+ this.c2 = c2;
+ }
+
+ public double[] getShadowDeltaPoints(double deltaShadow, double diff, double[] points) {
+ double cx = 0;
+ double cy = 0;
+ for (int i = 0; i < points.length; i += 2) {
+ cx += points[i];
+ cy += points[i + 1];
+ }
+ final int nbPoints = points.length / 2;
+
+ cx = cx / nbPoints;
+ cy = cy / nbPoints;
+
+ final double[] result = new double[points.length];
+ for (int i = 0; i < result.length; i += 2) {
+ final double diffx = points[i] > cx ? -diff : diff;
+ final double diffy = points[i + 1] > cy ? -diff : diff;
+ result[i] = points[i] + diffx + deltaShadow;
+ result[i + 1] = points[i + 1] + diffy + deltaShadow;
+ }
+ return result;
+ }
+
+ public Color getColor(double delta, double total) {
+ final int c = (int) (c2 + 1.0 * delta / total * (c1 - c2));
+ return new Color(c, c, c);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/Shadowable.java b/src/net/sourceforge/plantuml/ugraphic/Shadowable.java
new file mode 100644
index 0000000..a6ca149
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/Shadowable.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.ugraphic;
+
+public interface Shadowable extends UShape {
+
+ public void setDeltaShadow(double deltaShadow);
+
+ public double getDeltaShadow();
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/Slot.java b/src/net/sourceforge/plantuml/ugraphic/Slot.java
new file mode 100644
index 0000000..6bdff47
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/Slot.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.ugraphic;
+
+public class Slot implements Comparable<Slot> {
+
+ private final double start;
+ private final double end;
+
+ public Slot(double start, double end) {
+ if (start >= end) {
+ throw new IllegalArgumentException();
+ }
+ this.start = start;
+ this.end = end;
+ }
+
+ @Override
+ public String toString() {
+ return "(" + start + "," + end + ")";
+ }
+
+ public double getStart() {
+ return start;
+ }
+
+ public double getEnd() {
+ return end;
+ }
+
+ public double size() {
+ return end - start;
+ }
+
+ public boolean contains(double v) {
+ return v >= start && v <= end;
+ }
+
+ public boolean intersect(Slot other) {
+ return contains(other.start) || contains(other.end) || other.contains(start) || other.contains(end);
+ }
+
+ public Slot merge(Slot other) {
+ return new Slot(Math.min(start, other.start), Math.max(end, other.end));
+ }
+
+ public Slot intersect(double otherStart, double otherEnd) {
+ if (otherStart >= end) {
+ return null;
+ }
+ if (otherEnd <= start) {
+ return null;
+ }
+ return new Slot(Math.max(start, otherStart), Math.min(end, otherEnd));
+ }
+
+ public int compareTo(Slot other) {
+ if (this.start < other.start) {
+ return -1;
+ }
+ if (this.start > other.start) {
+ return 1;
+ }
+ return 0;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/SlotFinder.java b/src/net/sourceforge/plantuml/ugraphic/SlotFinder.java
new file mode 100644
index 0000000..8474246
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/SlotFinder.java
@@ -0,0 +1,140 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public class SlotFinder implements UGraphic {
+
+ public boolean isSpecialTxt() {
+ return false;
+ }
+
+ public UGraphic apply(UChange change) {
+ if (change instanceof UTranslate) {
+ return new SlotFinder(stringBounder, yslot, translate.compose((UTranslate) change));
+ } else if (change instanceof UStroke) {
+ return new SlotFinder(this);
+ } else if (change instanceof UChangeBackColor) {
+ return new SlotFinder(this);
+ } else if (change instanceof UChangeColor) {
+ return new SlotFinder(this);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private final SlotSet yslot;
+ private final StringBounder stringBounder;
+ private final UTranslate translate;
+
+ public SlotFinder(StringBounder stringBounder) {
+ this(stringBounder, new SlotSet(), new UTranslate());
+ }
+
+ private SlotFinder(StringBounder stringBounder, SlotSet yslot, UTranslate translate) {
+ this.stringBounder = stringBounder;
+ this.yslot = yslot;
+ this.translate = translate;
+ }
+
+ private SlotFinder(SlotFinder other) {
+ this(other.stringBounder, other.yslot, other.translate);
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public UParam getParam() {
+ return new UParamNull();
+ }
+
+ public void draw(UShape shape) {
+ final double x = translate.getDx();
+ final double y = translate.getDy();
+ if (shape instanceof URectangle) {
+ drawRectangle(x, y, (URectangle) shape);
+ } else if (shape instanceof UPolygon) {
+ drawPolygon(x, y, (UPolygon) shape);
+ } else if (shape instanceof UEllipse) {
+ drawEllipse(x, y, (UEllipse) shape);
+ } else if (shape instanceof UText) {
+ drawText(x, y, (UText) shape);
+ } else if (shape instanceof UEmpty) {
+ drawEmpty(x, y, (UEmpty) shape);
+ }
+ }
+
+ private void drawEmpty(double x, double y, UEmpty shape) {
+ yslot.addSlot(y, y + shape.getHeight());
+ }
+
+ private void drawText(double x, double y, UText shape) {
+ final TextLimitFinder finder = new TextLimitFinder(stringBounder, false);
+ finder.apply(new UTranslate(x, y)).draw(shape);
+ yslot.addSlot(finder.getMinY(), finder.getMaxY());
+ }
+
+ private void drawEllipse(double x, double y, UEllipse shape) {
+ yslot.addSlot(y, y + shape.getHeight());
+ }
+
+ private void drawPolygon(double x, double y, UPolygon shape) {
+ yslot.addSlot(y + shape.getMinY(), y + shape.getMaxY());
+ }
+
+ private void drawRectangle(double x, double y, URectangle shape) {
+ yslot.addSlot(y, y + shape.getHeight());
+ }
+
+ public ColorMapper getColorMapper() {
+ return new ColorMapperIdentity();
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ public SlotSet getYSlotSet() {
+ return yslot;
+ }
+
+ public void flushUg() {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/SlotFinderX.java b/src/net/sourceforge/plantuml/ugraphic/SlotFinderX.java
new file mode 100644
index 0000000..4b8889f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/SlotFinderX.java
@@ -0,0 +1,151 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public class SlotFinderX implements UGraphic {
+
+ public boolean isSpecialTxt() {
+ return false;
+ }
+
+ public UGraphic apply(UChange change) {
+ if (change instanceof UTranslate) {
+ return new SlotFinderX(stringBounder, xslot, yslot, translate.compose((UTranslate) change));
+ } else if (change instanceof UStroke) {
+ return new SlotFinderX(this);
+ } else if (change instanceof UChangeBackColor) {
+ return new SlotFinderX(this);
+ } else if (change instanceof UChangeColor) {
+ return new SlotFinderX(this);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private final SlotSet xslot;
+ private final SlotSet yslot;
+ private final StringBounder stringBounder;
+ private final UTranslate translate;
+
+ public SlotFinderX(StringBounder stringBounder) {
+ this(stringBounder, new SlotSet(), new SlotSet(), new UTranslate());
+ }
+
+ private SlotFinderX(StringBounder stringBounder, SlotSet xslot, SlotSet yslot, UTranslate translate) {
+ this.stringBounder = stringBounder;
+ this.xslot = xslot;
+ this.yslot = yslot;
+ this.translate = translate;
+ }
+
+ private SlotFinderX(SlotFinderX other) {
+ this(other.stringBounder, other.xslot, other.yslot, other.translate);
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public UParam getParam() {
+ return new UParamNull();
+ }
+
+ public void draw(UShape shape) {
+ final double x = translate.getDx();
+ final double y = translate.getDy();
+ if (shape instanceof URectangle) {
+ drawRectangle(x, y, (URectangle) shape);
+ } else if (shape instanceof UPolygon) {
+ drawPolygon(x, y, (UPolygon) shape);
+ } else if (shape instanceof UEllipse) {
+ drawEllipse(x, y, (UEllipse) shape);
+ } else if (shape instanceof UText) {
+ drawText(x, y, (UText) shape);
+ } else if (shape instanceof UEmpty) {
+ drawEmpty(x, y, (UEmpty) shape);
+ }
+ }
+
+ private void drawEmpty(double x, double y, UEmpty shape) {
+ xslot.addSlot(x, x + shape.getWidth());
+ yslot.addSlot(y, y + shape.getHeight());
+ }
+
+ private void drawText(double x, double y, UText shape) {
+ final TextLimitFinder finder = new TextLimitFinder(stringBounder, false);
+ finder.apply(new UTranslate(x, y)).draw(shape);
+ xslot.addSlot(finder.getMinX(), finder.getMaxX());
+ yslot.addSlot(finder.getMinY(), finder.getMaxY());
+ }
+
+ private void drawEllipse(double x, double y, UEllipse shape) {
+ xslot.addSlot(x, x + shape.getWidth());
+ yslot.addSlot(y, y + shape.getHeight());
+ }
+
+ private void drawPolygon(double x, double y, UPolygon shape) {
+ xslot.addSlot(x + shape.getMinX(), x + shape.getMaxX());
+ yslot.addSlot(y + shape.getMinY(), y + shape.getMaxY());
+ }
+
+ private void drawRectangle(double x, double y, URectangle shape) {
+ xslot.addSlot(x, x + shape.getWidth());
+ yslot.addSlot(y, y + shape.getHeight());
+ }
+
+ public ColorMapper getColorMapper() {
+ return new ColorMapperIdentity();
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ public SlotSet getXSlotSet() {
+ return xslot;
+ }
+
+ public SlotSet getYSlotSet() {
+ return yslot;
+ }
+
+ public void flushUg() {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/SlotSet.java b/src/net/sourceforge/plantuml/ugraphic/SlotSet.java
new file mode 100644
index 0000000..bf31fd9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/SlotSet.java
@@ -0,0 +1,121 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+public class SlotSet implements Iterable<Slot> {
+
+ private final List<Slot> all = new ArrayList<Slot>();
+
+ public SlotSet filter(double start, double end) {
+ final SlotSet result = new SlotSet();
+ for (Slot slot : all) {
+ final Slot intersec = slot.intersect(start, end);
+ if (intersec != null) {
+ result.all.add(intersec);
+ }
+ }
+ return result;
+ }
+
+ public void addAll(SlotSet other) {
+ this.all.addAll(other.all);
+ }
+
+ public void addSlot(double start, double end) {
+ final List<Slot> collisions = new ArrayList<Slot>();
+ Slot newSlot = new Slot(start, end);
+ for (final Iterator<Slot> it = all.iterator(); it.hasNext();) {
+ final Slot s = it.next();
+ if (s.intersect(newSlot)) {
+ it.remove();
+ collisions.add(s);
+ }
+ }
+ for (Slot s : collisions) {
+ newSlot = newSlot.merge(s);
+ }
+ all.add(newSlot);
+ }
+
+ public SlotSet smaller(double margin) {
+ final SlotSet result = new SlotSet();
+ for (Slot sl : all) {
+ if (sl.size() <= 2 * margin) {
+ continue;
+ }
+ result.addSlot(sl.getStart() + margin, sl.getEnd() - margin);
+ }
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return all.toString();
+ }
+
+ public List<Slot> getSlots() {
+ return Collections.unmodifiableList(all);
+ }
+
+ public Iterator<Slot> iterator() {
+ return getSlots().iterator();
+ }
+
+ public SlotSet reverse() {
+ final SlotSet result = new SlotSet();
+ Collections.sort(all);
+ Slot last = null;
+ for (Slot slot : all) {
+ if (last != null) {
+ result.addSlot(last.getEnd(), slot.getStart());
+ }
+ last = slot;
+ }
+ return result;
+ }
+
+ public void drawDebugX(UGraphic ug, double size) {
+ for (Slot slot : all) {
+ final URectangle rect = new URectangle(slot.getEnd() - slot.getStart(), size);
+ ug.apply(new UTranslate(slot.getStart(), 0)).draw(rect);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/Sprite.java b/src/net/sourceforge/plantuml/ugraphic/Sprite.java
new file mode 100644
index 0000000..3e657db
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/Sprite.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.ugraphic;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public interface Sprite {
+
+ public TextBlock asTextBlock(final HtmlColor color);
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/SpriteGrayLevel.java b/src/net/sourceforge/plantuml/ugraphic/SpriteGrayLevel.java
new file mode 100644
index 0000000..d69f478
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/SpriteGrayLevel.java
@@ -0,0 +1,281 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.Color;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.code.AsciiEncoder;
+import net.sourceforge.plantuml.code.CompressionZlib;
+
+public enum SpriteGrayLevel {
+
+ GRAY_16(16), GRAY_8(8), GRAY_4(4);
+
+ private final int nbColor;
+ private static final ColorChangerMonochrome mono = new ColorChangerMonochrome();
+
+ private SpriteGrayLevel(int nbColor) {
+ this.nbColor = nbColor;
+ }
+
+ public static SpriteGrayLevel get(int n) {
+ if (n == 4) {
+ return SpriteGrayLevel.GRAY_4;
+ }
+ if (n == 8) {
+ return SpriteGrayLevel.GRAY_8;
+ }
+ if (n == 16) {
+ return SpriteGrayLevel.GRAY_16;
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ public int getNbColor() {
+ return nbColor;
+ }
+
+ public List<String> encode(BufferedImage img) {
+ if (this == GRAY_16) {
+ return encode16(img);
+ }
+ if (this == GRAY_8) {
+ return encode8(img);
+ }
+ if (this == GRAY_4) {
+ return encode4(img);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private List<String> encode16(BufferedImage img) {
+ final int width = img.getWidth();
+ final int height = img.getHeight();
+ // final int type = img.getType();
+
+ final List<String> result = new ArrayList<String>();
+
+ for (int y = 0; y < height; y++) {
+ final StringBuilder sb = new StringBuilder();
+ for (int x = 0; x < width; x++) {
+ final int level = getGrayOn16(img, x, y);
+ final char code = "0123456789ABCDEF".charAt(level);
+ sb.append(code);
+ }
+ result.add(sb.toString());
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ private List<String> encode8(BufferedImage img) {
+ final int width = img.getWidth();
+ final int height = img.getHeight();
+ // final int type = img.getType();
+
+ final List<String> result = new ArrayList<String>();
+ final AsciiEncoder encoder = new AsciiEncoder();
+
+ for (int y = 0; y < height; y += 2) {
+ final StringBuilder sb = new StringBuilder();
+ for (int x = 0; x < width; x++) {
+ final int level1 = getGrayOn16(img, x, y) / 2;
+ assert level1 >= 0 && level1 <= 7;
+ final int level2 = getGrayOn16(img, x, y + 1) / 2;
+ assert level2 >= 0 && level2 <= 7;
+ final int v = level1 * 8 + level2;
+ sb.append(encoder.encode6bit((byte) v));
+ }
+ result.add(sb.toString());
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ private List<String> encode4(BufferedImage img) {
+ final int width = img.getWidth();
+ final int height = img.getHeight();
+ // final int type = img.getType();
+
+ final List<String> result = new ArrayList<String>();
+ final AsciiEncoder encoder = new AsciiEncoder();
+
+ for (int y = 0; y < height; y += 3) {
+ final StringBuilder sb = new StringBuilder();
+ for (int x = 0; x < width; x++) {
+ final int level1 = getGrayOn16(img, x, y) / 4;
+ assert level1 >= 0 && level1 <= 3;
+ final int level2 = getGrayOn16(img, x, y + 1) / 4;
+ assert level2 >= 0 && level2 <= 3;
+ final int level3 = getGrayOn16(img, x, y + 2) / 4;
+ assert level3 >= 0 && level3 <= 3;
+ final int v = level1 * 16 + level2 * 4 + level3;
+ sb.append(encoder.encode6bit((byte) v));
+ }
+ result.add(sb.toString());
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ private int getGrayOn16(BufferedImage img, int x, int y) {
+ if (x >= img.getWidth()) {
+ return 0;
+ }
+ if (y >= img.getHeight()) {
+ return 0;
+ }
+ final Color g = mono.getChangedColor(new Color(img.getRGB(x, y)));
+ final int grey = 255 - g.getRed();
+ return grey / 16;
+ }
+
+ public Sprite buildSprite(int width, int height, List<String> strings) {
+ if (this == SpriteGrayLevel.GRAY_16) {
+ return buildSprite16(strings);
+ }
+ if (this == SpriteGrayLevel.GRAY_8) {
+ return buildSprite8(width, height, strings);
+ }
+ if (this == SpriteGrayLevel.GRAY_4) {
+ return buildSprite4(width, height, strings);
+ }
+ throw new UnsupportedOperationException(toString());
+ }
+
+ private Sprite buildSprite16(List<String> strings) {
+ final SpriteMonochrome result = new SpriteMonochrome(strings.get(0).length(), strings.size(), 16);
+ for (int col = 0; col < result.getWidth(); col++) {
+ for (int line = 0; line < result.getHeight(); line++) {
+ if (col >= strings.get(line).length()) {
+ continue;
+ }
+ if (strings.get(line).charAt(col) != '0') {
+ final String s = "" + strings.get(line).charAt(col);
+ final int x = Integer.parseInt(StringUtils.goUpperCase(s), 16);
+ result.setPixel(col, line, x);
+ }
+ }
+ }
+ return result;
+ }
+
+ private Sprite buildSprite8(int width, int height, List<String> strings) {
+ final AsciiEncoder encoder = new AsciiEncoder();
+ final SpriteMonochrome result = new SpriteMonochrome(width, height, 8);
+ for (int col = 0; col < result.getWidth(); col++) {
+ for (int line = 0; line < strings.size(); line++) {
+ if (col >= strings.get(line).length()) {
+ continue;
+ }
+ final int v = encoder.decode6bit(strings.get(line).charAt(col));
+ final int w1 = v / 8;
+ final int w2 = v % 8;
+ result.setPixel(col, line * 2, w1);
+ result.setPixel(col, line * 2 + 1, w2);
+
+ }
+ }
+ return result;
+ }
+
+ private Sprite buildSprite4(int width, int height, List<String> strings) {
+ final AsciiEncoder encoder = new AsciiEncoder();
+ final SpriteMonochrome result = new SpriteMonochrome(width, height, 4);
+ for (int col = 0; col < result.getWidth(); col++) {
+ for (int line = 0; line < strings.size(); line++) {
+ if (col >= strings.get(line).length()) {
+ continue;
+ }
+ int v = encoder.decode6bit(strings.get(line).charAt(col));
+ final int w1 = v / 16;
+ v = v % 16;
+ final int w2 = v / 4;
+ final int w3 = v % 4;
+ result.setPixel(col, line * 3, w1);
+ result.setPixel(col, line * 3 + 1, w2);
+ result.setPixel(col, line * 3 + 2, w3);
+
+ }
+ }
+ return result;
+ }
+
+ public List<String> encodeZ(BufferedImage img) {
+ final int width = img.getWidth();
+ final int height = img.getHeight();
+ final byte raw[] = new byte[width * height];
+ final BufferedImage grayImg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+ int cpt = 0;
+ final int coef = 16 / nbColor;
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ final int color = getGrayOn16(img, x, y) / coef;
+ raw[cpt++] = (byte) color;
+ grayImg.setRGB(x, y, color * coef);
+ }
+ }
+ final byte[] comp = new CompressionZlib().compress(raw);
+ return cut(new AsciiEncoder().encode(comp));
+ }
+
+ private List<String> cut(String s) {
+ final List<String> result = new ArrayList<String>();
+ for (int i = 0; i < s.length(); i += 120) {
+ final int j = Math.min(i + 120, s.length());
+ result.add(s.substring(i, j));
+
+ }
+ return Collections.unmodifiableList(result);
+ }
+
+ public Sprite buildSpriteZ(int width, int height, String compressed) throws IOException {
+ final byte comp[] = new AsciiEncoder().decode(compressed);
+ final byte img[] = new CompressionZlib().decompress(comp);
+ final SpriteMonochrome result = new SpriteMonochrome(width, height, nbColor);
+ int cpt = 0;
+ for (int line = 0; line < result.getHeight(); line++) {
+ for (int col = 0; col < result.getWidth(); col++) {
+ result.setPixel(col, line, img[cpt++]);
+
+ }
+ }
+ return result;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/SpriteImage.java b/src/net/sourceforge/plantuml/ugraphic/SpriteImage.java
new file mode 100644
index 0000000..1380e5d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/SpriteImage.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.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class SpriteImage implements Sprite {
+
+ private final UImage img;
+
+ public SpriteImage(BufferedImage img) {
+ this.img = new UImage(img);
+ }
+
+ public TextBlock asTextBlock(final HtmlColor color) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ ug.draw(img);
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(img.getWidth(), img.getHeight());
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/SpriteMonochrome.java b/src/net/sourceforge/plantuml/ugraphic/SpriteMonochrome.java
new file mode 100644
index 0000000..4015d1e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/SpriteMonochrome.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.ugraphic;
+
+import java.awt.Color;
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.graphic.HtmlColorUtils;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class SpriteMonochrome implements Sprite {
+
+ private final int width;
+ private final int height;
+ private final int grayLevel;
+ private final int pixels[][];
+
+ SpriteMonochrome(int width, int height, int grayLevel) {
+ if (grayLevel != 2 && grayLevel != 4 && grayLevel != 8 && grayLevel != 16) {
+ throw new IllegalArgumentException();
+ }
+ this.width = width;
+ this.height = height;
+ this.grayLevel = grayLevel;
+ this.pixels = new int[height][width];
+ }
+
+ void setPixel(int x, int y, int level) {
+ if (x < 0 || x >= width) {
+ return;
+ }
+ if (y < 0 || y >= height) {
+ return;
+ }
+ if (level < 0 || level >= grayLevel) {
+ throw new IllegalArgumentException("level=" + level + " grayLevel=" + grayLevel);
+ }
+ pixels[y][x] = level;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ int getWidth() {
+ return width;
+ }
+
+ public UImage toUImage(ColorMapper colorMapper, HtmlColor backcolor, HtmlColor color) {
+ final BufferedImage im = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+
+ if (backcolor == null) {
+ backcolor = HtmlColorUtils.WHITE;
+ }
+ if (color == null) {
+ backcolor = HtmlColorUtils.BLACK;
+ }
+ final HtmlColorGradient gradient = new HtmlColorGradient(backcolor, color, '\0');
+ for (int col = 0; col < width; col++) {
+ for (int line = 0; line < height; line++) {
+ final double coef = 1.0 * pixels[line][col] / (grayLevel - 1);
+ final Color c = gradient.getColor(colorMapper, coef);
+ im.setRGB(col, line, c.getRGB());
+ }
+ }
+ return new UImage(im);
+ }
+
+ public TextBlock asTextBlock(final HtmlColor color) {
+ return new TextBlock() {
+
+ public void drawU(UGraphic ug) {
+ ug.draw(toUImage(ug.getColorMapper(), ug.getParam().getBackcolor(), color));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return new Dimension2DDouble(getWidth(), getHeight());
+ }
+ };
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/SpriteUtils.java b/src/net/sourceforge/plantuml/ugraphic/SpriteUtils.java
new file mode 100644
index 0000000..5871057
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/SpriteUtils.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.image.BufferedImage;
+import java.util.List;
+
+public class SpriteUtils {
+
+ private SpriteUtils() {
+ }
+
+ public static String encode(BufferedImage img, String name, SpriteGrayLevel level) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("sprite $" + name + " [" + img.getWidth() + "x" + img.getHeight() + "/" + level.getNbColor()
+ + "] {\n");
+ final List<String> result = level.encode(img);
+ for (String s : result) {
+ sb.append(s);
+ sb.append("\n");
+ }
+ sb.append("}\n");
+ return sb.toString();
+ }
+
+ public static String encodeCompressed(BufferedImage img, String name, SpriteGrayLevel level) {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("sprite $" + name + " [" + img.getWidth() + "x" + img.getHeight() + "/" + level.getNbColor() + "z] ");
+ final List<String> list = level.encodeZ(img);
+ if (list.size() == 1) {
+ sb.append(list.get(0));
+ sb.append("\n");
+ } else {
+ sb.append("{\n");
+ for (String s : list) {
+ sb.append(s);
+ sb.append("\n");
+ }
+ sb.append("}\n");
+ }
+ return sb.toString();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/TextBlockInEllipse.java b/src/net/sourceforge/plantuml/ugraphic/TextBlockInEllipse.java
new file mode 100644
index 0000000..af93e63
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/TextBlockInEllipse.java
@@ -0,0 +1,87 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.svek.image.ContainingEllipse;
+import net.sourceforge.plantuml.svek.image.Footprint;
+
+public class TextBlockInEllipse implements TextBlock {
+
+ private final TextBlock text;
+ private final ContainingEllipse ellipse;
+
+ public TextBlockInEllipse(TextBlock text, StringBounder stringBounder) {
+ this.text = text;
+ final Dimension2D textDim = text.calculateDimension(stringBounder);
+ double alpha = textDim.getHeight() / textDim.getWidth();
+ if (alpha < .2) {
+ alpha = .2;
+ } else if (alpha > .8) {
+ alpha = .8;
+ }
+ final Footprint footprint = new Footprint(stringBounder);
+ ellipse = footprint.getEllipse(text, alpha);
+
+ }
+
+ public UEllipse getUEllipse() {
+ return ellipse.asUEllipse().bigger(6);
+ }
+
+ public void drawU(UGraphic ug) {
+ final UEllipse sh = getUEllipse();
+ final Point2D center = ellipse.getCenter();
+
+ final double dx = sh.getWidth() / 2 - center.getX();
+ final double dy = sh.getHeight() / 2 - center.getY();
+
+ ug.draw(sh);
+
+ text.drawU(ug.apply(new UTranslate(dx, (dy - 2))));
+ }
+
+ public Dimension2D calculateDimension(StringBounder stringBounder) {
+ return getUEllipse().getDimension();
+ }
+
+ public void setDeltaShadow(double deltaShadow) {
+ ellipse.setDeltaShadow(deltaShadow);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/TextLimitFinder.java b/src/net/sourceforge/plantuml/ugraphic/TextLimitFinder.java
new file mode 100644
index 0000000..4e3a04f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/TextLimitFinder.java
@@ -0,0 +1,135 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.geom.Dimension2D;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public class TextLimitFinder implements UGraphic {
+
+ public boolean isSpecialTxt() {
+ return false;
+ }
+
+ public UGraphic apply(UChange change) {
+ if (change instanceof UTranslate) {
+ return new TextLimitFinder(stringBounder, minmax, translate.compose((UTranslate) change));
+ } else if (change instanceof UStroke) {
+ return new TextLimitFinder(this);
+ } else if (change instanceof UChangeBackColor) {
+ return new TextLimitFinder(this);
+ } else if (change instanceof UChangeColor) {
+ return new TextLimitFinder(this);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private final StringBounder stringBounder;
+ private final UTranslate translate;
+ private final MinMaxMutable minmax;
+
+ public TextLimitFinder(StringBounder stringBounder, boolean initToZero) {
+ this(stringBounder, MinMaxMutable.getEmpty(initToZero), new UTranslate());
+ }
+
+ private TextLimitFinder(StringBounder stringBounder, MinMaxMutable minmax, UTranslate translate) {
+ this.stringBounder = stringBounder;
+ this.minmax = minmax;
+ this.translate = translate;
+ }
+
+ private TextLimitFinder(TextLimitFinder other) {
+ this(other.stringBounder, other.minmax, other.translate);
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public UParam getParam() {
+ return new UParamNull();
+ }
+
+ public void draw(UShape shape) {
+ if (shape instanceof UText) {
+ final double x = translate.getDx();
+ final double y = translate.getDy();
+ drawText(x, y, (UText) shape);
+ }
+ }
+
+ public ColorMapper getColorMapper() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ private void drawText(double x, double y, UText text) {
+ final Dimension2D dim = stringBounder.calculateDimension(text.getFontConfiguration().getFont(), text.getText());
+ y -= dim.getHeight() - 1.5;
+ minmax.addPoint(x, y);
+ minmax.addPoint(x, y + dim.getHeight());
+ minmax.addPoint(x + dim.getWidth(), y);
+ minmax.addPoint(x + dim.getWidth(), y + dim.getHeight());
+ }
+
+ public double getMaxX() {
+ return minmax.getMaxX();
+ }
+
+ public double getMaxY() {
+ return minmax.getMaxY();
+ }
+
+ public double getMinX() {
+ return minmax.getMinX();
+ }
+
+ public double getMinY() {
+ return minmax.getMinY();
+ }
+
+ public void flushUg() {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UAntiAliasing.java b/src/net/sourceforge/plantuml/ugraphic/UAntiAliasing.java
new file mode 100644
index 0000000..1b4c01c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UAntiAliasing.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.ugraphic;
+
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+
+public enum UAntiAliasing implements UChange {
+
+ ANTI_ALIASING_ON, ANTI_ALIASING_OFF;
+
+ public void apply(Graphics2D g2d) {
+ if (this == ANTI_ALIASING_ON) {
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ } else {
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
+ }
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UCenteredCharacter.java b/src/net/sourceforge/plantuml/ugraphic/UCenteredCharacter.java
new file mode 100644
index 0000000..6ed6abf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UCenteredCharacter.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.ugraphic;
+
+public class UCenteredCharacter implements UShape {
+
+ private final char c;
+ private final UFont font;
+
+ public UCenteredCharacter(char c, UFont font) {
+ this.c = c;
+ this.font = font;
+ }
+
+ public char getChar() {
+ return c;
+ }
+
+ public UFont getFont() {
+ return font;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UChange.java b/src/net/sourceforge/plantuml/ugraphic/UChange.java
new file mode 100644
index 0000000..ecc9e5c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UChange.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.ugraphic;
+
+
+public interface UChange {
+
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UChangeBackColor.java b/src/net/sourceforge/plantuml/ugraphic/UChangeBackColor.java
new file mode 100644
index 0000000..b47460f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UChangeBackColor.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class UChangeBackColor implements UChange {
+
+ private final HtmlColor color;
+
+ public UChangeBackColor(HtmlColor color) {
+ this.color = color;
+ }
+
+ public HtmlColor getBackColor() {
+ return color;
+ }
+
+ // private HtmlColor color = null;
+ // private HtmlColor backcolor = null;
+ // private UStroke stroke = new UStroke(1);
+ // private boolean hidden = false;
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UChangeColor.java b/src/net/sourceforge/plantuml/ugraphic/UChangeColor.java
new file mode 100644
index 0000000..8b312b8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UChangeColor.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.ugraphic;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class UChangeColor implements UChange {
+
+ private final HtmlColor color;
+
+ public UChangeColor(HtmlColor color) {
+ this.color = color;
+ }
+
+ public HtmlColor getColor() {
+ return color;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UClip.java b/src/net/sourceforge/plantuml/ugraphic/UClip.java
new file mode 100644
index 0000000..9b738b4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UClip.java
@@ -0,0 +1,154 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
+
+public class UClip implements UChange {
+
+ private final double x;
+ private final double y;
+ private final double width;
+ private final double height;
+
+ public UClip(double x, double y, double width, double height) {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+
+ @Override
+ public String toString() {
+ return "CLIP x=" + x + " y=" + y + " w=" + width + " h=" + height;
+ }
+
+ public UClip translate(double dx, double dy) {
+ return new UClip(x + dx, y + dy, width, height);
+ }
+
+ public UClip translate(UTranslate translate) {
+ return translate(translate.getDx(), translate.getDy());
+ }
+
+
+ public final double getX() {
+ return x;
+ }
+
+ public final double getY() {
+ return y;
+ }
+
+ public final double getWidth() {
+ return width;
+ }
+
+ public final double getHeight() {
+ return height;
+ }
+
+ public boolean isInside(double xp, double yp) {
+ if (xp < x) {
+ assert getClippedX(xp) != xp;
+ return false;
+ }
+ if (xp > x + width) {
+ assert getClippedX(xp) != xp;
+ return false;
+ }
+ if (yp < y) {
+ assert getClippedY(yp) != yp;
+ return false;
+ }
+ if (yp > y + height) {
+ assert getClippedY(yp) != yp;
+ return false;
+ }
+ assert getClippedX(xp) == xp;
+ assert getClippedY(yp) == yp;
+ return true;
+ }
+
+ public Rectangle2D.Double getClippedRectangle(Rectangle2D.Double r) {
+ return (Rectangle2D.Double) r.createIntersection(new Rectangle2D.Double(x, y, width, height));
+ }
+
+ public Line2D.Double getClippedLine(Line2D.Double line) {
+ if (isInside(line.x1, line.y1) && isInside(line.x2, line.y2)) {
+ return line;
+ }
+ if (isInside(line.x1, line.y1) == false && isInside(line.x2, line.y2) == false) {
+ return null;
+ }
+ if (line.x1 != line.x2 && line.y1 != line.y2) {
+ return null;
+ }
+ assert line.x1 == line.x2 || line.y1 == line.y2;
+ if (line.y1 == line.y2) {
+ final double newx1 = getClippedX(line.x1);
+ final double newx2 = getClippedX(line.x2);
+ return new Line2D.Double(newx1, line.y1, newx2, line.y2);
+ }
+ if (line.x1 == line.x2) {
+ final double newy1 = getClippedY(line.y1);
+ final double newy2 = getClippedY(line.y2);
+ return new Line2D.Double(line.x1, newy1, line.x2, newy2);
+ }
+ throw new IllegalStateException();
+ }
+
+ private double getClippedX(double xp) {
+ if (xp < x) {
+ return x;
+ }
+ if (xp > x + width) {
+ return x + width;
+ }
+ return xp;
+ }
+
+ private double getClippedY(double yp) {
+ if (yp < y) {
+ return y;
+ }
+ if (yp > y + height) {
+ return y + height;
+ }
+ return yp;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UDriver.java b/src/net/sourceforge/plantuml/ugraphic/UDriver.java
new file mode 100644
index 0000000..c7bff33
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UDriver.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.ugraphic;
+
+public interface UDriver<O> {
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, O object);
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UEllipse.java b/src/net/sourceforge/plantuml/ugraphic/UEllipse.java
new file mode 100644
index 0000000..32990e7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UEllipse.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.ugraphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+
+public class UEllipse extends AbstractShadowable implements Scalable {
+
+ private final double width;
+ private final double height;
+ private final double start;
+ private final double extend;
+
+ public UShape getScaled(double scale) {
+ if (scale == 1) {
+ return this;
+ }
+ final AbstractShadowable result = new UEllipse(width * scale, height * scale, start, extend);
+ result.setDeltaShadow(this.getDeltaShadow());
+ return result;
+ }
+
+ public UEllipse(double width, double height) {
+ this(width, height, 0, 0);
+ }
+
+ public UEllipse(double width, double height, double start, double extend) {
+ this.width = width;
+ this.height = height;
+ this.start = start;
+ this.extend = extend;
+ }
+
+ public double getWidth() {
+ return width;
+ }
+
+ public double getHeight() {
+ return height;
+ }
+
+ public final double getStart() {
+ return start;
+ }
+
+ public final double getExtend() {
+ return extend;
+ }
+
+ public Dimension2D getDimension() {
+ return new Dimension2DDouble(width, height);
+ }
+
+ public UEllipse bigger(double more) {
+ final UEllipse result = new UEllipse(width + more, height + more);
+ result.setDeltaShadow(getDeltaShadow());
+ return result;
+ }
+
+ public double getStartingX(double y) {
+ y = y / height * 2;
+ final double x = 1 - Math.sqrt(1 - (y - 1) * (y - 1));
+ return x * width / 2;
+ }
+
+ public double getEndingX(double y) {
+ y = y / height * 2;
+ final double x = 1 + Math.sqrt(1 - (y - 1) * (y - 1));
+ return x * width / 2;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UEmpty.java b/src/net/sourceforge/plantuml/ugraphic/UEmpty.java
new file mode 100644
index 0000000..d5b1fdf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UEmpty.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.ugraphic;
+
+public class UEmpty implements UShape {
+
+ private final double width;
+ private final double height;
+
+ public UEmpty(double width, double height) {
+ if (width == 0) {
+ throw new IllegalArgumentException();
+ }
+ this.width = width;
+ this.height = height;
+ }
+
+ public double getWidth() {
+ return width;
+ }
+
+ public double getHeight() {
+ return height;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UFont.java b/src/net/sourceforge/plantuml/ugraphic/UFont.java
new file mode 100644
index 0000000..d5aec22
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UFont.java
@@ -0,0 +1,154 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics2D;
+import java.awt.font.FontRenderContext;
+import java.awt.font.LineMetrics;
+
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+
+public class UFont {
+
+ private final Font font;
+ private final String family;
+
+ public UFont(String fontFamily, int fontStyle, int fontSize) {
+ this(new Font(fontFamily, fontStyle, fontSize), fontFamily);
+ }
+
+ private UFont(Font font, String family) {
+ this.font = font;
+ this.family = family;
+ }
+
+ public final Font getFont() {
+ return font;
+ }
+
+ public FontConfiguration toFont2(HtmlColor color, boolean useUnderlineForHyperlink, HtmlColor hyperlinkColor) {
+ return new FontConfiguration(this, color, hyperlinkColor, useUnderlineForHyperlink);
+ }
+
+ public UFont scaled(double scale) {
+ if (scale == 1) {
+ return this;
+ }
+ final float current = font.getSize2D();
+ return deriveSize((float) (current * scale));
+ }
+
+ public UFont deriveSize(float size) {
+ return new UFont(font.deriveFont(size), family);
+ }
+
+ public UFont deriveStyle(int style) {
+ return new UFont(font.deriveFont(style), family);
+ }
+
+ public int getStyle() {
+ return font.getStyle();
+ }
+
+ public int getSize() {
+ return font.getSize();
+ }
+
+ public double getSize2D() {
+ return font.getSize2D();
+ }
+
+ public boolean isBold() {
+ return font.isBold();
+ }
+
+ public boolean isItalic() {
+ return font.isItalic();
+ }
+
+ public String getFamily(UFontContext context) {
+ if (context == UFontContext.EPS) {
+ if (family == null) {
+ return "Times-Roman";
+ }
+ return font.getPSName();
+ }
+ if (context == UFontContext.SVG) {
+ if (family.equalsIgnoreCase("sansserif")) {
+ return "sans-serif";
+ }
+ return family;
+ }
+ return family;
+ }
+
+ @Override
+ public String toString() {
+ return font.toString()/* + " " + font.getPSName() */;
+ }
+
+ @Override
+ public int hashCode() {
+ return font.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof UFont == false) {
+ return false;
+ }
+ return this.font.equals(((UFont) obj).font);
+ }
+
+ @Deprecated
+ public static UFont getCurrentFont(Graphics2D g2d) {
+ // return new UFont(g2d.getFont(), g2d.getFont().getFontName());
+ throw new UnsupportedOperationException();
+ }
+
+ public LineMetrics getLineMetrics(Graphics2D gg, String text) {
+ final FontRenderContext frc = gg.getFontRenderContext();
+ return font.getLineMetrics(text, frc);
+ }
+
+ public FontMetrics getFontMetrics() {
+ return TextBlockUtils.getFontMetrics(getFont());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UFontContext.java b/src/net/sourceforge/plantuml/ugraphic/UFontContext.java
new file mode 100644
index 0000000..76f827e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UFontContext.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.ugraphic;
+
+public enum UFontContext {
+ JAVA, EPS, SVG, DOT, SYSTEM, PNG
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UFontUser.java b/src/net/sourceforge/plantuml/ugraphic/UFontUser.java
new file mode 100644
index 0000000..6007947
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UFontUser.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.ugraphic;
+
+public enum UFontUser {
+ JAVA, DOT
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphic.java b/src/net/sourceforge/plantuml/ugraphic/UGraphic.java
new file mode 100644
index 0000000..a6c8d8b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UGraphic.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.ugraphic;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+
+public interface UGraphic {
+
+ public StringBounder getStringBounder();
+
+ public UParam getParam();
+
+ public void draw(UShape shape);
+
+ public UGraphic apply(UChange change);
+
+ public ColorMapper getColorMapper();
+
+ public void startUrl(Url url);
+
+ public void closeAction();
+
+ public void flushUg();
+
+ public boolean isSpecialTxt();
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphic2.java b/src/net/sourceforge/plantuml/ugraphic/UGraphic2.java
new file mode 100644
index 0000000..ed92e2a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UGraphic2.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.ugraphic;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public interface UGraphic2 extends UGraphic {
+
+ public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException;
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphicCompress.java b/src/net/sourceforge/plantuml/ugraphic/UGraphicCompress.java
new file mode 100644
index 0000000..b9f9b09
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UGraphicCompress.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.ugraphic;
+
+import net.sourceforge.plantuml.graphic.UGraphicDelegator;
+
+public class UGraphicCompress extends UGraphicDelegator {
+
+ public UGraphic apply(UChange change) {
+ if (change instanceof UTranslate) {
+ return new UGraphicCompress(getUg(), compressionTransform, translate.compose((UTranslate) change));
+ } else if (change instanceof UStroke || change instanceof UChangeBackColor || change instanceof UChangeColor) {
+ return new UGraphicCompress(getUg().apply(change), compressionTransform, translate);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private final CompressionTransform compressionTransform;
+ private final UTranslate translate;
+
+ public UGraphicCompress(UGraphic ug, CompressionTransform compressionTransform) {
+ this(ug, compressionTransform, new UTranslate());
+ }
+
+ private UGraphicCompress(UGraphic ug, CompressionTransform compressionTransform, UTranslate translate) {
+ super(ug);
+ this.compressionTransform = compressionTransform;
+ this.translate = translate;
+ }
+
+ public void draw(UShape shape) {
+ final double x = translate.getDx();
+ final double y = translate.getDy();
+ if (shape instanceof ULine) {
+ drawLine(x, y, (ULine) shape);
+ } else {
+ getUg().apply(new UTranslate(x, ct(y))).draw(shape);
+ }
+ }
+
+ private void drawLine(double x, double y, ULine shape) {
+ drawLine(x, ct(y), x + shape.getDX(), ct(y + shape.getDY()));
+ }
+
+ private double ct(double v) {
+ return compressionTransform.transform(v);
+ }
+
+ private void drawLine(double x1, double y1, double x2, double y2) {
+ final double xmin = Math.min(x1, x2);
+ final double xmax = Math.max(x1, x2);
+ final double ymin = Math.min(y1, y2);
+ final double ymax = Math.max(y1, y2);
+ getUg().apply(new UTranslate(xmin, ymin)).draw(new ULine(xmax - xmin, ymax - ymin));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphicCompress2.java b/src/net/sourceforge/plantuml/ugraphic/UGraphicCompress2.java
new file mode 100644
index 0000000..664f5ae
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UGraphicCompress2.java
@@ -0,0 +1,97 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
+import net.sourceforge.plantuml.graphic.UGraphicDelegator;
+
+public class UGraphicCompress2 extends UGraphicDelegator {
+
+ public UGraphic apply(UChange change) {
+ if (change instanceof UTranslate) {
+ return new UGraphicCompress2(getUg(), compressionTransform, translate.compose((UTranslate) change));
+ } else if (change instanceof UStroke || change instanceof UChangeBackColor || change instanceof UChangeColor) {
+ return new UGraphicCompress2(getUg().apply(change), compressionTransform, translate);
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ private final CompressionTransform compressionTransform;
+ private final UTranslate translate;
+
+ public UGraphicCompress2(UGraphic ug, CompressionTransform compressionTransform) {
+ this(ug, compressionTransform, new UTranslate());
+ }
+
+ private UGraphicCompress2(UGraphic ug, CompressionTransform compressionTransform, UTranslate translate) {
+ super(ug);
+ this.compressionTransform = compressionTransform;
+ this.translate = translate;
+ }
+
+ public void draw(UShape shape) {
+ final double x = translate.getDx();
+ final double y = translate.getDy();
+ if (shape instanceof ULine) {
+ drawLine(x, y, (ULine) shape);
+ } else if (shape instanceof Snake) {
+ drawSnake(x, y, (Snake) shape);
+ } else {
+ getUg().apply(new UTranslate(ct(x), y)).draw(shape);
+ }
+ }
+
+ private void drawSnake(double x, double y, Snake shape) {
+ final Snake transformed = shape.translate(new UTranslate(x, y)).transformX(compressionTransform);
+ getUg().draw(transformed);
+ }
+
+ private void drawLine(double x, double y, ULine shape) {
+ drawLine(ct(x), y, ct(x + shape.getDX()), y + shape.getDY());
+ }
+
+ private double ct(double v) {
+ return compressionTransform.transform(v);
+ }
+
+ private void drawLine(double x1, double y1, double x2, double y2) {
+ final double xmin = Math.min(x1, x2);
+ final double xmax = Math.max(x1, x2);
+ final double ymin = Math.min(y1, y2);
+ final double ymax = Math.max(y1, y2);
+ getUg().apply(new UTranslate(xmin, ymin)).draw(new ULine(xmax - xmin, ymax - ymin));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphicFilter.java b/src/net/sourceforge/plantuml/ugraphic/UGraphicFilter.java
new file mode 100644
index 0000000..f6f7cc2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UGraphicFilter.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.ugraphic;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import net.sourceforge.plantuml.graphic.UGraphicDelegator;
+
+public class UGraphicFilter extends UGraphicDelegator {
+
+ public UGraphic apply(UChange translate) {
+ throw new UnsupportedOperationException();
+ }
+
+ private final Collection<Class<? extends UShape>> toprint;
+
+ public UGraphicFilter(UGraphic ug, Class<? extends UShape>... toprint) {
+ super(ug);
+ this.toprint = Arrays.asList(toprint);
+ }
+
+ public void draw(UShape shape) {
+ if (toprint.contains(shape.getClass())) {
+ getUg().draw(shape);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphicNull.java b/src/net/sourceforge/plantuml/ugraphic/UGraphicNull.java
new file mode 100644
index 0000000..f1f665e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UGraphicNull.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+
+public class UGraphicNull extends AbstractUGraphic<String> implements EnsureVisible, UGraphic2 {
+
+ @Override
+ protected AbstractCommonUGraphic copyUGraphic() {
+ return new UGraphicNull(this);
+ }
+
+ private UGraphicNull(UGraphicNull other) {
+ super(other);
+ }
+
+ public UGraphicNull() {
+ super(new ColorMapperIdentity(), "foo");
+ }
+
+ public StringBounder getStringBounder() {
+ return TextBlockUtils.getDummyStringBounder();
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
+ }
+
+ public void ensureVisible(double x, double y) {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphicStencil.java b/src/net/sourceforge/plantuml/ugraphic/UGraphicStencil.java
new file mode 100644
index 0000000..a68de23
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UGraphicStencil.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.ugraphic;
+
+import net.sourceforge.plantuml.creole.Stencil;
+
+public class UGraphicStencil extends AbstractUGraphicHorizontalLine {
+
+ private final Stencil stencil;
+ private final UStroke defaultStroke;
+
+ public UGraphicStencil(UGraphic ug, Stencil stencil, UStroke defaultStroke) {
+ super(ug);
+ this.stencil = stencil;
+ this.defaultStroke = defaultStroke;
+ }
+
+ @Override
+ protected AbstractUGraphicHorizontalLine copy(UGraphic ug) {
+ return new UGraphicStencil(ug, stencil, defaultStroke);
+ }
+
+ @Override
+ protected void drawHline(UGraphic ug, UHorizontalLine line, UTranslate translate) {
+ line.drawLineInternal(ug, stencil, translate.getDy(), defaultStroke);
+ // final UDrawable ud = stencil.convert(line, ug.getStringBounder());
+ // ud.drawU(ug.apply(translate));
+ // line.drawLine(ug.apply(translate), startingX, endingX, 0, defaultStroke);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UGraphicUtils.java b/src/net/sourceforge/plantuml/ugraphic/UGraphicUtils.java
new file mode 100644
index 0000000..6d35f62
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UGraphicUtils.java
@@ -0,0 +1,127 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.Graphics2D;
+import java.awt.geom.Dimension2D;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.EmptyImageBuilder;
+import net.sourceforge.plantuml.FileFormat;
+import net.sourceforge.plantuml.FileFormatOption;
+import net.sourceforge.plantuml.eps.EpsStrategy;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.TextBlock;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.png.PngIO;
+import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps;
+import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
+import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg;
+import net.sourceforge.plantuml.StringUtils;
+
+public abstract class UGraphicUtils {
+
+ public static UDrawable translate(final UDrawable d, final double dx, final double dy) {
+ return new UDrawable() {
+ public void drawU(UGraphic ug) {
+ d.drawU(ug.apply(new UTranslate(dx, dy)));
+ }
+ };
+
+ }
+
+ public static void writeImage(OutputStream os, String metadata, FileFormatOption fileFormatOption,
+ ColorMapper colorMapper, HtmlColor background, TextBlock image) throws IOException {
+ final FileFormat fileFormat = fileFormatOption.getFileFormat();
+ if (fileFormat == FileFormat.PNG) {
+ final BufferedImage im = createImage(colorMapper, background, image);
+ PngIO.write(im, os, fileFormatOption.isWithMetadata() ? metadata : null, 96);
+ } else if (fileFormat == FileFormat.SVG) {
+ final UGraphicSvg svg = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(colorMapper
+ .getMappedColor(background)), false, 1.0);
+ image.drawU(svg);
+ svg.createXml(os);
+ } else if (fileFormat == FileFormat.EPS) {
+ final UGraphicEps ug = new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
+ image.drawU(ug);
+ os.write(ug.getEPSCode().getBytes());
+ } else if (fileFormat == FileFormat.EPS_TEXT) {
+ final UGraphicEps ug = new UGraphicEps(colorMapper, EpsStrategy.WITH_MACRO_AND_TEXT);
+ image.drawU(ug);
+ os.write(ug.getEPSCode().getBytes());
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private static BufferedImage createImage(ColorMapper colorMapper, HtmlColor background, TextBlock image) {
+ EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, colorMapper.getMappedColor(background));
+ Graphics2D g2d = builder.getGraphics2D();
+
+ final UGraphicG2d tmp = new UGraphicG2d(colorMapper, g2d, 1.0);
+ final Dimension2D size = image.calculateDimension(tmp.getStringBounder());
+ g2d.dispose();
+
+ builder = new EmptyImageBuilder(size.getWidth(), size.getHeight(), colorMapper.getMappedColor(background));
+ final BufferedImage im = builder.getBufferedImage();
+ g2d = builder.getGraphics2D();
+
+ final UGraphicG2d ug = new UGraphicG2d(colorMapper, g2d, 1.0);
+ image.drawU(ug);
+ g2d.dispose();
+ return im;
+ }
+
+ // public static void writeImage(OutputStream os, UGraphic ug, String metadata, int dpi) throws IOException {
+ // if (ug instanceof UGraphicG2d) {
+ // final BufferedImage im = ((UGraphicG2d) ug).getBufferedImage();
+ // PngIO.write(im, os, metadata, dpi);
+ // } else if (ug instanceof UGraphicSvg) {
+ // final UGraphicSvg svg = (UGraphicSvg) ug;
+ // svg.createXml(os);
+ // } else if (ug instanceof UGraphicEps) {
+ // final UGraphicEps eps = (UGraphicEps) ug;
+ // os.write(eps.getEPSCode().getBytes());
+ // } else if (ug instanceof UGraphicHtml5) {
+ // final UGraphicHtml5 html5 = (UGraphicHtml5) ug;
+ // os.write(html5.generateHtmlCode().getBytes());
+ // } else {
+ // throw new UnsupportedOperationException();
+ // }
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UHidden.java b/src/net/sourceforge/plantuml/ugraphic/UHidden.java
new file mode 100644
index 0000000..3ab0698
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UHidden.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.ugraphic;
+
+public enum UHidden implements UChange {
+
+ NORMAL_SHOWN, HIDDEN;
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UHorizontalLine.java b/src/net/sourceforge/plantuml/ugraphic/UHorizontalLine.java
new file mode 100644
index 0000000..f82749a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UHorizontalLine.java
@@ -0,0 +1,181 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.creole.Stencil;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class UHorizontalLine implements UShape {
+
+ private final double skipAtStart;
+ private final double skipAtEnd;
+ private final TextBlock title;
+ private final boolean blankTitle;
+ private final char style;
+
+ private UHorizontalLine(double skipAtStart, double skipAtEnd, TextBlock title, boolean blankTitle, char style) {
+ this.skipAtEnd = skipAtEnd;
+ this.skipAtStart = skipAtStart;
+ this.title = title;
+ this.blankTitle = blankTitle;
+ this.style = style;
+ }
+
+ public static UHorizontalLine infinite(double skipAtStart, double skipAtEnd, char style) {
+ return new UHorizontalLine(skipAtStart, skipAtEnd, null, false, style);
+ }
+
+ public static UHorizontalLine infinite(double skipAtStart, double skipAtEnd, TextBlock title, char style) {
+ return new UHorizontalLine(skipAtStart, skipAtEnd, title, false, style);
+ }
+
+ public boolean isDouble() {
+ return style == '=';
+ }
+
+ // static public UHorizontalLine infinite(UStroke stroke) {
+ // return new UHorizontalLine(0, 0, null, false, stroke);
+ // }
+
+ public void drawLineInternal(final UGraphic ug, Stencil stencil, double y, UStroke defaultStroke) {
+ stencil = addSkip(stencil);
+ final UStroke strokeToUse = style == '\0' ? defaultStroke : getStroke();
+ final UGraphic ugStroke = ug.apply(strokeToUse);
+ if (title == null) {
+ drawHLine(stencil, y, ugStroke);
+ return;
+ }
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ drawHLine(firstHalf(stencil, dimTitle.getWidth()), y, ugStroke);
+ final double startingX = stencil.getStartingX(ug.getStringBounder(), y);
+ final double endingX = stencil.getEndingX(ug.getStringBounder(), y);
+ drawTitleInternal(ug, startingX, endingX, y, false);
+ drawHLine(secondHalf(stencil, dimTitle.getWidth()), y, ugStroke);
+ }
+
+ private Stencil addSkip(final Stencil stencil) {
+ return new Stencil() {
+ public double getStartingX(StringBounder stringBounder, double y) {
+ return stencil.getStartingX(stringBounder, y) + skipAtStart;
+ }
+
+ public double getEndingX(StringBounder stringBounder, double y) {
+ return stencil.getEndingX(stringBounder, y) - skipAtEnd;
+ }
+ };
+ }
+
+ private static Stencil firstHalf(final Stencil stencil, final double widthTitle) {
+ return new Stencil() {
+ public double getStartingX(StringBounder stringBounder, double y) {
+ return stencil.getStartingX(stringBounder, y);
+ }
+
+ public double getEndingX(StringBounder stringBounder, double y) {
+ final double start = stencil.getStartingX(stringBounder, y);
+ final double end = stencil.getEndingX(stringBounder, y);
+ final double len = (end - start - widthTitle) / 2;
+ return start + len;
+ }
+ };
+ }
+
+ private static Stencil secondHalf(final Stencil stencil, final double widthTitle) {
+ return new Stencil() {
+ public double getStartingX(StringBounder stringBounder, double y) {
+ final double start = stencil.getStartingX(stringBounder, y);
+ final double end = stencil.getEndingX(stringBounder, y);
+ final double len = (end - start - widthTitle) / 2;
+ return end - len;
+ }
+
+ public double getEndingX(StringBounder stringBounder, double y) {
+ return stencil.getEndingX(stringBounder, y);
+ }
+ };
+ }
+
+ private void drawHLine(Stencil stencil, double y, final UGraphic ug) {
+ drawSimpleHline(ug, stencil, y);
+ if (style == '=') {
+ drawSimpleHline(ug, stencil, y + 2);
+ }
+ }
+
+ private static void drawSimpleHline(UGraphic ug, Stencil stencil, double y) {
+ final double startingX = stencil.getStartingX(ug.getStringBounder(), y);
+ final double endingX = stencil.getEndingX(ug.getStringBounder(), y);
+ ug.apply(new UTranslate(startingX, y)).draw(new ULine(endingX - startingX, 0));
+ }
+
+ public void drawTitleInternal(UGraphic ug, double startingX, double endingX, double y, boolean clearArea) {
+ if (title == null || blankTitle) {
+ return;
+ }
+ final double widthToUse = endingX - startingX;
+ final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder());
+ final double space = (widthToUse - dimTitle.getWidth()) / 2;
+ final double x1 = startingX + space;
+ final double y1 = y - dimTitle.getHeight() / 2 - 0.5;
+ ug = ug.apply(new UTranslate(x1, y1));
+ if (clearArea) {
+ ug.apply(getStroke()).draw(new URectangle(dimTitle));
+ }
+ title.drawU(ug);
+ }
+
+ public void drawMe(UGraphic ug) {
+ ug.draw(this);
+ }
+
+ public UStroke getStroke() {
+ if (style == '\0') {
+ throw new IllegalStateException();
+ // return null;
+ } else if (style == '=') {
+ return new UStroke();
+ } else if (style == '.') {
+ return new UStroke(1, 2, 1);
+ } else if (style == '-') {
+ return new UStroke();
+ } else {
+ return new UStroke(1.5);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UImage.java b/src/net/sourceforge/plantuml/ugraphic/UImage.java
new file mode 100644
index 0000000..20be1e9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UImage.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.ugraphic;
+
+import java.awt.image.BufferedImage;
+
+public class UImage implements UShape {
+
+ private final BufferedImage image;
+
+ public UImage(BufferedImage image) {
+ this.image = image;
+ }
+
+ public final BufferedImage getImage() {
+ return image;
+ }
+
+ public double getWidth() {
+ return image.getWidth();
+ }
+
+ public double getHeight() {
+ return image.getHeight();
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UImageSvg.java b/src/net/sourceforge/plantuml/ugraphic/UImageSvg.java
new file mode 100644
index 0000000..d431a2f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UImageSvg.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.ugraphic;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class UImageSvg implements UShape {
+
+ private final String svg;
+
+ public UImageSvg(String svg) {
+ if (svg.startsWith("<?xml")) {
+ final int idx = svg.indexOf("<svg");
+ svg = svg.substring(idx);
+ }
+ this.svg = svg;
+ }
+
+ public final String getSvg() {
+ if (svg.startsWith("<svg")) {
+ final int idx = svg.indexOf(">");
+ return "<svg>" + svg.substring(idx + 1);
+ }
+ return svg;
+ }
+
+ private int getData(String name) {
+ final Pattern p = Pattern.compile("(?i)" + name + "\\W+(\\d+)");
+ final Matcher m = p.matcher(svg);
+ if (m.find()) {
+ final String s = m.group(1);
+ return Integer.parseInt(s);
+ }
+ throw new IllegalStateException("Cannot find " + name);
+ }
+
+ public int getHeight() {
+ return getData("height");
+ }
+
+ public int getWidth() {
+ return getData("width");
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ULayoutGroup.java b/src/net/sourceforge/plantuml/ugraphic/ULayoutGroup.java
new file mode 100644
index 0000000..9a9718c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ULayoutGroup.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.ugraphic;
+
+import java.awt.geom.Point2D;
+import java.util.Map;
+
+import net.sourceforge.plantuml.graphic.TextBlock;
+
+public class ULayoutGroup {
+
+ private final PlacementStrategy placementStrategy;
+
+ public ULayoutGroup(PlacementStrategy placementStrategy) {
+ this.placementStrategy = placementStrategy;
+ }
+
+ public void drawU(UGraphic ug, double x, double y, double width, double height) {
+ for (Map.Entry<TextBlock, Point2D> ent : placementStrategy.getPositions(width, height).entrySet()) {
+ final TextBlock block = ent.getKey();
+ final Point2D pos = ent.getValue();
+ block.drawU(ug.apply(new UTranslate((x + pos.getX()), (y + pos.getY()))));
+ }
+ }
+
+ public void add(TextBlock block) {
+ placementStrategy.add(block);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/ULine.java b/src/net/sourceforge/plantuml/ugraphic/ULine.java
new file mode 100644
index 0000000..23cf32e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/ULine.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.ugraphic;
+
+public class ULine extends AbstractShadowable implements Scalable {
+
+ private final double dx;
+ private final double dy;
+
+ public UShape getScaled(double scale) {
+ if (scale == 1) {
+ return this;
+ }
+ final AbstractShadowable result = new ULine(dx * scale, dy * scale);
+ result.setDeltaShadow(this.getDeltaShadow());
+ return result;
+ }
+
+ public ULine(double dx, double dy) {
+ this.dx = dx;
+ this.dy = dy;
+ }
+
+ @Override
+ public String toString() {
+ return "ULine dx=" + dx + " dy=" + dy;
+ }
+
+ public double getDX() {
+ return dx;
+ }
+
+ public double getDY() {
+ return dy;
+ }
+
+ public double getLength() {
+ return Math.sqrt(dx * dx + dy * dy);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UMotif.java b/src/net/sourceforge/plantuml/ugraphic/UMotif.java
new file mode 100644
index 0000000..20094eb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UMotif.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.ugraphic;
+
+import java.awt.geom.CubicCurve2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import net.sourceforge.plantuml.posimo.DotPath;
+
+public class UMotif {
+
+ private final List<Point2D> points = new ArrayList<Point2D>();
+
+ public UMotif(int... data) {
+ for (int i = 0; i < data.length; i += 2) {
+ points.add(new Point2D.Double(data[i], data[i + 1]));
+ }
+ }
+
+ public UMotif(String s) {
+ final Point2D last = new Point2D.Double();
+ for (int i = 0; i < s.length(); i++) {
+ final Point2D read = convertPoint(s.charAt(i));
+ last.setLocation(last.getX() + read.getX(), last.getY() + read.getY());
+ points.add(new Point2D.Double(last.getX(), last.getY()));
+ }
+ }
+
+ double getLength() {
+ return points.get(0).distance(points.get(points.size() - 1));
+ }
+
+ List<Point2D> getPoints() {
+ return Collections.unmodifiableList(points);
+ }
+
+ public DotPath getRectangle(double width, double height) {
+ final double len = getLength();
+ final int nb1 = (int) (width / len);
+ DotPath h1 = drawHorizontal(0, 0, nb1);
+ final int nb2 = (int) (height / len);
+ final DotPath v1 = drawVertical(h1.getEndPoint().getX(), h1.getEndPoint().getY(), nb2);
+ h1 = h1.addAfter(v1);
+ return h1;
+ }
+
+ static Point2D convertPoint(char c) {
+ final int v = convertFromChar(c);
+ final int x = v % 7;
+ final int y = v / 7;
+ return new Point2D.Double(x - 3, y - 3);
+ }
+
+ static int convertFromChar(char c) {
+ if (c >= 'A' && c <= 'Z') {
+ return c - 'A';
+ }
+ if (c >= 'a' && c <= 'w') {
+ return c - 'a' + 26;
+ }
+ throw new IllegalArgumentException();
+ }
+
+ // public void drawOld(UGraphic ug, double x, double y) {
+ // final UPath path = new UPath();
+ // path.add(new double[] { x, y }, USegmentType.SEG_MOVETO);
+ // for (Point2D p : points) {
+ // path.add(new double[] { x + p.getX(), y + p.getY() },
+ // USegmentType.SEG_LINETO);
+ // }
+ // ug.draw(0, 0, path);
+ // }
+
+ public void drawHorizontal(UGraphic ug, double x, double y, int nb) {
+ final DotPath path = drawHorizontal(x, y, nb);
+ ug.draw(path);
+ }
+
+ public void drawVertical(UGraphic ug, double x, double y, int nb) {
+ final DotPath path = drawVertical(x, y, nb);
+ ug.draw(path);
+ }
+
+ DotPath drawHorizontal(double x, double y, int nb) {
+ DotPath path = new DotPath();
+ for (int i = 0; i < nb; i++) {
+ path = addHorizontal(x, y, path);
+ x = path.getEndPoint().getX();
+ y = path.getEndPoint().getY();
+ }
+ return path;
+ }
+
+ DotPath drawVertical(double x, double y, int nb) {
+ DotPath path = new DotPath();
+ for (int i = 0; i < nb; i++) {
+ path = addVertical(x, y, path);
+ x = path.getEndPoint().getX();
+ y = path.getEndPoint().getY();
+ }
+ return path;
+ }
+
+ private DotPath addHorizontal(double x, double y, DotPath path) {
+ double lastx = 0;
+ double lasty = 0;
+ for (Point2D p : points) {
+ final double x1 = lastx + x;
+ final double y1 = lasty + y;
+ final double x2 = p.getX() + x;
+ final double y2 = p.getY() + y;
+ path = path.addAfter(new CubicCurve2D.Double(x1, y1, x1, y1, x2, y2, x2, y2));
+ lastx = p.getX();
+ lasty = p.getY();
+ }
+ return path;
+ }
+
+ private DotPath addVertical(double x, double y, DotPath path) {
+ double lastx = 0;
+ double lasty = 0;
+ for (Point2D p : points) {
+ final double x1 = lastx + x;
+ final double y1 = lasty + y;
+ final double x2 = p.getY() + x;
+ final double y2 = p.getX() + y;
+ path = path.addAfter(new CubicCurve2D.Double(x1, y1, x1, y1, x2, y2, x2, y2));
+ lastx = p.getY();
+ lasty = p.getX();
+ }
+ return path;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UParam.java b/src/net/sourceforge/plantuml/ugraphic/UParam.java
new file mode 100644
index 0000000..c13acda
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UParam.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.ugraphic;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public interface UParam {
+
+ public HtmlColor getColor();
+
+ public HtmlColor getBackcolor();
+
+ public UStroke getStroke();
+
+ public boolean isHidden();
+
+ public UPattern getPattern();
+
+ public double getScale();
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UParamNull.java b/src/net/sourceforge/plantuml/ugraphic/UParamNull.java
new file mode 100644
index 0000000..78c16b4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UParamNull.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.ugraphic;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+
+public class UParamNull implements UParam {
+
+ public HtmlColor getColor() {
+ return null;
+ }
+
+ public HtmlColor getBackcolor() {
+ return null;
+ }
+
+ public UStroke getStroke() {
+ return new UStroke();
+ }
+
+ public boolean isHidden() {
+ return false;
+ }
+
+ public UPattern getPattern() {
+ return UPattern.FULL;
+ }
+
+ public double getScale() {
+ return 1;
+ }
+
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UPath.java b/src/net/sourceforge/plantuml/ugraphic/UPath.java
new file mode 100644
index 0000000..3bd6a98
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UPath.java
@@ -0,0 +1,143 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class UPath extends AbstractShadowable implements Iterable<USegment> {
+
+ private final List<USegment> segments = new ArrayList<USegment>();
+ private MinMax minmax = MinMax.getEmpty(false);
+
+ private boolean isOpenIconic;
+
+ public void add(double[] coord, USegmentType pathType) {
+ segments.add(new USegment(coord, pathType));
+ if (pathType == USegmentType.SEG_ARCTO) {
+ minmax = minmax.addPoint(coord[5], coord[6]);
+// minmax = minmax.addPoint(coord[5] + coord[0], coord[6] + coord[1]);
+// minmax = minmax.addPoint(coord[5] - coord[0], coord[6] - coord[1]);
+ } else {
+ for (int i = 0; i < coord.length; i += 2) {
+ minmax = minmax.addPoint(coord[i], coord[i + 1]);
+ }
+ }
+ }
+
+ public void moveTo(Point2D pt) {
+ moveTo(pt.getX(), pt.getY());
+ }
+
+ public void lineTo(Point2D pt) {
+ lineTo(pt.getX(), pt.getY());
+ }
+
+ public void moveTo(double x, double y) {
+ add(new double[] { x, y }, USegmentType.SEG_MOVETO);
+ }
+
+ public void lineTo(double x, double y) {
+ add(new double[] { x, y }, USegmentType.SEG_LINETO);
+ }
+
+ public void cubicTo(double ctrlx1, double ctrly1, double ctrlx2, double ctrly2, double x2, double y2) {
+ add(new double[] { ctrlx1, ctrly1, ctrlx2, ctrly2, x2, y2 }, USegmentType.SEG_CUBICTO);
+ }
+
+ public void quadTo(double ctrlx, double ctrly, double x2, double y2) {
+ add(new double[] { ctrlx, ctrly, ctrlx, ctrly, x2, y2 }, USegmentType.SEG_CUBICTO);
+ }
+
+ public void quadTo(Point2D ctrl, Point2D pt) {
+ quadTo(ctrl.getX(), ctrl.getY(), pt.getX(), pt.getY());
+ }
+
+ public void arcTo(double rx, double ry, double x_axis_rotation, double large_arc_flag, double sweep_flag, double x,
+ double y) {
+ add(new double[] { rx, ry, x_axis_rotation, large_arc_flag, sweep_flag, x, y }, USegmentType.SEG_ARCTO);
+ // lineTo(x, y);
+ }
+
+ public void arcTo(Point2D pt, double radius, double large_arc_flag, double sweep_flag) {
+ add(new double[] { radius, radius, 0, large_arc_flag, sweep_flag, pt.getX(), pt.getY() },
+ USegmentType.SEG_ARCTO);
+ // lineTo(x, y);
+ }
+
+ public void closePath() {
+ // System.err.println("CLOSE_PATH");
+ }
+
+ public double getMaxX() {
+ return minmax.getMaxX();
+ }
+
+ public double getMaxY() {
+ return minmax.getMaxY();
+ }
+
+ public double getMinX() {
+ return minmax.getMinX();
+ }
+
+ public double getMinY() {
+ return minmax.getMinY();
+ }
+
+ @Override
+ public String toString() {
+ return segments.toString();
+ }
+
+ public Iterator<USegment> iterator() {
+ return segments.iterator();
+ }
+
+ public boolean isOpenIconic() {
+ return isOpenIconic;
+ }
+
+ public void setOpenIconic(boolean isOpenIconic) {
+ this.isOpenIconic = isOpenIconic;
+ }
+
+ // public boolean isEmpty() {
+ // return segments.size() == 0;
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UPattern.java b/src/net/sourceforge/plantuml/ugraphic/UPattern.java
new file mode 100644
index 0000000..a51f772
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UPattern.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.ugraphic;
+
+public enum UPattern implements UChange {
+
+ FULL, HORIZONTAL_STRIPE, VERTICAL_STRIPE, SMALL_CIRCLE
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UPixel.java b/src/net/sourceforge/plantuml/ugraphic/UPixel.java
new file mode 100644
index 0000000..d7f428e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UPixel.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.ugraphic;
+
+public class UPixel implements UShape {
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UPolygon.java b/src/net/sourceforge/plantuml/ugraphic/UPolygon.java
new file mode 100644
index 0000000..2cfdf0d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UPolygon.java
@@ -0,0 +1,130 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.List;
+
+public class UPolygon extends AbstractShadowable {
+
+ private final List<Point2D.Double> all = new ArrayList<Point2D.Double>();
+
+ private MinMax minmax = MinMax.getEmpty(false);
+
+ public UPolygon() {
+ }
+
+ public UPolygon(List<Point2D.Double> points) {
+ all.addAll(points);
+ for (Point2D.Double pt : all) {
+ manageMinMax(pt.getX(), pt.getY());
+ }
+ }
+
+ public void addPoint(double x, double y) {
+ all.add(new Point2D.Double(x, y));
+ manageMinMax(x, y);
+ }
+
+ private void manageMinMax(double x, double y) {
+ minmax = minmax.addPoint(x, y);
+ }
+
+ public List<Point2D.Double> getPoints() {
+ return all;
+ }
+
+ public UPolygon translate(double dx, double dy) {
+ final UPolygon result = new UPolygon();
+ for (Point2D.Double pt : all) {
+ result.addPoint(pt.x + dx, pt.y + dy);
+ }
+ return result;
+ }
+
+ public void rotate(double theta) {
+ final AffineTransform rotate = AffineTransform.getRotateInstance(theta);
+ for (Point2D.Double pt : all) {
+ rotate.transform(pt, pt);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " " + all;
+ }
+
+ public double getHeight() {
+ return minmax.getHeight();
+ }
+
+ public double getWidth() {
+ return minmax.getWidth();
+ }
+
+ public double getMinX() {
+ return minmax.getMinX();
+ }
+
+ public double getMinY() {
+ return minmax.getMinY();
+ }
+
+ public double getMaxX() {
+ return minmax.getMaxX();
+
+ }
+
+ public double getMaxY() {
+ return minmax.getMaxY();
+ }
+
+ public MinMax getMinMax() {
+ return minmax;
+ }
+
+ public double[] getPointArray(double x, double y) {
+ final double points[] = new double[getPoints().size() * 2];
+ int i = 0;
+
+ for (Point2D pt : getPoints()) {
+ points[i++] = pt.getX() + x;
+ points[i++] = pt.getY() + y;
+ }
+ return points;
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/URectangle.java b/src/net/sourceforge/plantuml/ugraphic/URectangle.java
new file mode 100644
index 0000000..658632c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/URectangle.java
@@ -0,0 +1,105 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+import java.awt.geom.Dimension2D;
+
+public class URectangle extends AbstractShadowable implements Scalable {
+
+ private final double width;
+ private final double height;
+ private final double rx;
+ private final double ry;
+
+ public UShape getScaled(double scale) {
+ if (scale == 1) {
+ return this;
+ }
+ final AbstractShadowable result = new URectangle(width * scale, height * scale, rx * scale, ry * scale);
+ result.setDeltaShadow(this.getDeltaShadow());
+ return result;
+ }
+
+ public URectangle(double width, double height) {
+ this(width, height, 0, 0);
+ }
+
+ public URectangle(double width, double height, double rx, double ry) {
+ // if (height == 0) {
+ // throw new IllegalArgumentException();
+ // }
+ if (width == 0) {
+ throw new IllegalArgumentException();
+ }
+ this.width = width;
+ this.height = height;
+ this.rx = rx;
+ this.ry = ry;
+ }
+
+ public URectangle(Dimension2D dim) {
+ this(dim.getWidth(), dim.getHeight());
+ }
+
+ @Override
+ public String toString() {
+ return "width=" + width + " height=" + height;
+ }
+
+ public double getWidth() {
+ return width;
+ }
+
+ public double getHeight() {
+ return height;
+ }
+
+ public double getRx() {
+ return rx;
+ }
+
+ public double getRy() {
+ return ry;
+ }
+
+ public URectangle clip(UClip clip) {
+ return this;
+ }
+
+ public MinMax getMinMax() {
+ return MinMax.fromMax(width, height);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UScale.java b/src/net/sourceforge/plantuml/ugraphic/UScale.java
new file mode 100644
index 0000000..f9676d2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UScale.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.ugraphic;
+
+
+public class UScale implements UChange {
+
+ private final double scale;
+
+ @Override
+ public String toString() {
+ return "scale scale=" + scale;
+ }
+
+ public UScale(double scale) {
+ this.scale = scale;
+ }
+
+ public double getScale() {
+ return scale;
+ }
+
+// public Point2D getTranslated(Point2D p) {
+// if (p == null) {
+// return null;
+// }
+// return new Point2D.Double(p.getX() + dx, p.getY() + dy);
+// }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/USegment.java b/src/net/sourceforge/plantuml/ugraphic/USegment.java
new file mode 100644
index 0000000..0b27ca3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/USegment.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.ugraphic;
+
+import java.util.Arrays;
+
+public class USegment {
+
+ private final double coord[];
+ private final USegmentType pathType;
+
+ public USegment(double[] coord, USegmentType pathType) {
+ this.coord = coord.clone();
+ this.pathType = pathType;
+ }
+
+ @Override
+ public String toString() {
+ return pathType.toString() + " " + Arrays.toString(coord);
+ }
+
+ public final double[] getCoord() {
+ return coord;
+ }
+
+ public final USegmentType getSegmentType() {
+ return pathType;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/USegmentType.java b/src/net/sourceforge/plantuml/ugraphic/USegmentType.java
new file mode 100644
index 0000000..36f4e05
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/USegmentType.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.ugraphic;
+
+import java.awt.geom.PathIterator;
+import java.util.EnumSet;
+import net.sourceforge.plantuml.ugraphic.arc.ExtendedPathIterator;
+
+public enum USegmentType {
+
+ SEG_MOVETO(PathIterator.SEG_MOVETO), SEG_LINETO(PathIterator.SEG_LINETO), SEG_QUADTO(PathIterator.SEG_QUADTO), SEG_CUBICTO(
+ PathIterator.SEG_CUBICTO), SEG_CLOSE(PathIterator.SEG_CLOSE), SEG_ARCTO(ExtendedPathIterator.SEG_ARCTO);
+
+ private final int code;
+
+ private USegmentType(int code) {
+ this.code = code;
+ }
+
+ public static USegmentType getByCode(int code) {
+ for (USegmentType p : EnumSet.allOf(USegmentType.class)) {
+ if (p.code == code) {
+ return p;
+ }
+ }
+ throw new IllegalArgumentException();
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UShape.java b/src/net/sourceforge/plantuml/ugraphic/UShape.java
new file mode 100644
index 0000000..18a77c7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UShape.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.ugraphic;
+
+
+public interface UShape {
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UStroke.java b/src/net/sourceforge/plantuml/ugraphic/UStroke.java
new file mode 100644
index 0000000..cc4bf86
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UStroke.java
@@ -0,0 +1,95 @@
+/* ========================================================================
+ * 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.ugraphic;
+
+public class UStroke implements UChange {
+
+ private final double dashVisible;
+ private final double dashSpace;
+ private final double thickness;
+
+ @Override
+ public String toString() {
+ return "" + dashVisible + "-" + dashSpace + "-" + thickness;
+ }
+
+ public UStroke(double dashVisible, double dashSpace, double thickness) {
+ this.dashVisible = dashVisible;
+ this.dashSpace = dashSpace;
+ this.thickness = thickness;
+ }
+
+ public UStroke(double thickness) {
+ this(0, 0, thickness);
+ }
+
+ public UStroke() {
+ this(1.0);
+ }
+
+ public double getDashVisible() {
+ return dashVisible;
+ }
+
+ public double getDashSpace() {
+ return dashSpace;
+ }
+
+ public double getThickness() {
+ return thickness;
+ }
+
+ public String getDasharraySvg() {
+ if (dashVisible == 0) {
+ return null;
+ }
+ return "" + dashVisible + "," + dashSpace;
+ }
+
+ public String getDashTikz() {
+ if (dashVisible == 0) {
+ return null;
+ }
+ return "on " + dashVisible + "pt off " + dashSpace + "pt";
+ }
+
+ // public String getDasharrayEps() {
+ // if (dashVisible == 0) {
+ // return null;
+ // }
+ // return "" + dashVisible + " " + dashSpace;
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UText.java b/src/net/sourceforge/plantuml/ugraphic/UText.java
new file mode 100644
index 0000000..ee458e7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UText.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.ugraphic;
+
+import java.awt.font.LineMetrics;
+
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+
+public class UText implements UShape {
+
+ private final String text;
+ private final FontConfiguration font;
+
+ @Override
+ public String toString() {
+ return "UText[" + text + "]";
+ }
+
+ public UText(String text, FontConfiguration font) {
+ assert text.indexOf('\t') == -1;
+ this.text = text;
+ this.font = font;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public FontConfiguration getFontConfiguration() {
+ return font;
+ }
+
+ public double getDescent() {
+ final LineMetrics fm = TextBlockUtils.getLineMetrics(font.getFont(), text);
+ final double descent = fm.getDescent();
+ return descent;
+ }
+
+
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/UTranslate.java b/src/net/sourceforge/plantuml/ugraphic/UTranslate.java
new file mode 100644
index 0000000..c6349f6
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/UTranslate.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.ugraphic;
+
+import java.awt.geom.Point2D;
+
+public class UTranslate implements UChange {
+
+ private final double dx;
+ private final double dy;
+
+ @Override
+ public String toString() {
+ return "translate dx=" + dx + " dy=" + dy;
+ }
+
+ public UTranslate(double dx, double dy) {
+ this.dx = dx;
+ this.dy = dy;
+ }
+
+ public UTranslate(Point2D p) {
+ this(p.getX(), p.getY());
+ }
+
+ public UTranslate() {
+ this(0, 0);
+ }
+
+ public double getDx() {
+ return dx;
+ }
+
+ public double getDy() {
+ return dy;
+ }
+
+ public Point2D getTranslated(Point2D p) {
+ if (p == null) {
+ return null;
+ }
+ return new Point2D.Double(p.getX() + dx, p.getY() + dy);
+ }
+
+ public UTranslate scaled(double scale) {
+ return new UTranslate(dx * scale, dy * scale);
+ }
+
+ public UTranslate compose(UTranslate other) {
+ return new UTranslate(dx + other.dx, dy + other.dy);
+ }
+
+ public UTranslate reverse() {
+ return new UTranslate(-dx, -dy);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/arc/ExtendedGeneralPath.java b/src/net/sourceforge/plantuml/ugraphic/arc/ExtendedGeneralPath.java
new file mode 100644
index 0000000..579ce51
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/arc/ExtendedGeneralPath.java
@@ -0,0 +1,766 @@
+/* ========================================================================
+ * 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.ugraphic.arc;
+
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Arc2D;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+import java.util.Arrays;
+
+/**
+ * The <code>ExtendedGeneralPath</code> class represents a geometric path constructed from straight lines, quadratic and
+ * cubic (Bezier) curves and elliptical arc. This class delegates lines and curves to an enclosed
+ * <code>GeneralPath</code>. Elliptical arc is implemented using an <code>Arc2D</code> in double precision.
+ *
+ * <p>
+ * <b>Warning</b> : An elliptical arc may be composed of several path segments. For futher details, see the SVG
+ * Appendix&nbsp;F.6
+ *
+ * @author <a href="mailto:Thierry.Kormann@sophia.inria.fr">Thierry Kormann</a>
+ * @version $Id: ExtendedGeneralPath.java 594018 2007-11-12 04:17:41Z cam $
+ */
+public class ExtendedGeneralPath implements Shape, Cloneable {
+
+ /** The enclosed general path. */
+ private GeneralPath path;
+
+ private int numVals = 0;
+ private int numSeg = 0;
+ private double[] values = null;
+ private int[] types = null;
+
+ private double mx;
+ private double my;
+ private double cx;
+ private double cy;
+
+ /**
+ * Constructs a new <code>ExtendedGeneralPath</code>.
+ */
+ public ExtendedGeneralPath() {
+ path = new GeneralPath();
+ }
+
+ /**
+ * Constructs a new <code>ExtendedGeneralPath</code> with the specified winding rule to control operations that
+ * require the interior of the path to be defined.
+ */
+ public ExtendedGeneralPath(int rule) {
+ path = new GeneralPath(rule);
+ }
+
+ /**
+ * Constructs a new <code>ExtendedGeneralPath</code> object with the specified winding rule and the specified
+ * initial capacity to store path coordinates.
+ */
+ public ExtendedGeneralPath(int rule, int initialCapacity) {
+ path = new GeneralPath(rule, initialCapacity);
+ }
+
+ /**
+ * Constructs a new <code>ExtendedGeneralPath</code> object from an arbitrary <code>Shape</code> object.
+ */
+ public ExtendedGeneralPath(Shape s) {
+ this();
+ append(s, false);
+ }
+
+ /**
+ * Adds an elliptical arc, defined by two radii, an angle from the x-axis, a flag to choose the large arc or not, a
+ * flag to indicate if we increase or decrease the angles and the final point of the arc.
+ *
+ * @param rx
+ * the x radius of the ellipse
+ * @param ry
+ * the y radius of the ellipse
+ *
+ * @param angle
+ * the angle from the x-axis of the current coordinate system to the x-axis of the ellipse in degrees.
+ *
+ * @param largeArcFlag
+ * the large arc flag. If true the arc spanning less than or equal to 180 degrees is chosen, otherwise
+ * the arc spanning greater than 180 degrees is chosen
+ *
+ * @param sweepFlag
+ * the sweep flag. If true the line joining center to arc sweeps through decreasing angles otherwise it
+ * sweeps through increasing angles
+ *
+ * @param x
+ * the absolute x coordinate of the final point of the arc.
+ * @param y
+ * the absolute y coordinate of the final point of the arc.
+ */
+ public void arcTo(double rx, double ry, double angle, boolean largeArcFlag, boolean sweepFlag,
+ double x, double y) {
+
+ // Ensure radii are valid
+ if (rx == 0 || ry == 0) {
+ lineTo(x, y);
+ return;
+ }
+
+ checkMoveTo(); // check if prev command was moveto
+
+ // Get the current (x, y) coordinates of the path
+ final double x0 = cx;
+ final double y0 = cy;
+ if (x0 == x && y0 == y) {
+ // If the endpoints (x, y) and (x0, y0) are identical, then this
+ // is equivalent to omitting the elliptical arc segment entirely.
+ return;
+ }
+
+ final Arc2D arc = computeArc(x0, y0, rx, ry, angle, largeArcFlag, sweepFlag, x, y);
+ if (arc == null) {
+ return;
+ }
+
+ final AffineTransform t = AffineTransform.getRotateInstance(Math.toRadians(angle), arc.getCenterX(),
+ arc.getCenterY());
+ final Shape s = t.createTransformedShape(arc);
+ path.append(s, true);
+
+ makeRoom(7);
+ types[numSeg++] = ExtendedPathIterator.SEG_ARCTO;
+ values[numVals++] = rx;
+ values[numVals++] = ry;
+ values[numVals++] = angle;
+ values[numVals++] = largeArcFlag ? 1 : 0;
+ values[numVals++] = sweepFlag ? 1 : 0;
+ cx = values[numVals++] = x;
+ cy = values[numVals++] = y;
+ }
+
+ /**
+ * This constructs an unrotated Arc2D from the SVG specification of an Elliptical arc. To get the final arc you need
+ * to apply a rotation transform such as:
+ *
+ * AffineTransform.getRotateInstance (angle, arc.getX()+arc.getWidth()/2, arc.getY()+arc.getHeight()/2);
+ */
+ public static Arc2D computeArc(double x0, double y0, double rx, double ry, double angle, boolean largeArcFlag,
+ boolean sweepFlag, double x, double y) {
+ //
+ // Elliptical arc implementation based on the SVG specification notes
+ //
+
+ // Compute the half distance between the current and the final point
+ final double dx2 = (x0 - x) / 2.0;
+ final double dy2 = (y0 - y) / 2.0;
+ // Convert angle from degrees to radians
+ angle = Math.toRadians(angle % 360.0);
+ final double cosAngle = Math.cos(angle);
+ final double sinAngle = Math.sin(angle);
+
+ //
+ // Step 1 : Compute (x1, y1)
+ //
+ final double x1 = cosAngle * dx2 + sinAngle * dy2;
+ final double y1 = -sinAngle * dx2 + cosAngle * dy2;
+ // Ensure radii are large enough
+ rx = Math.abs(rx);
+ ry = Math.abs(ry);
+ double prx = rx * rx;
+ double pry = ry * ry;
+ final double px1 = x1 * x1;
+ final double py1 = y1 * y1;
+ // check that radii are large enough
+ final double radiiCheck = px1 / prx + py1 / pry;
+ if (radiiCheck > 1) {
+ rx = Math.sqrt(radiiCheck) * rx;
+ ry = Math.sqrt(radiiCheck) * ry;
+ prx = rx * rx;
+ pry = ry * ry;
+ }
+
+ //
+ // Step 2 : Compute (cx1, cy1)
+ //
+ double sign = (largeArcFlag == sweepFlag) ? -1 : 1;
+ double sq = ((prx * pry) - (prx * py1) - (pry * px1)) / ((prx * py1) + (pry * px1));
+ sq = (sq < 0) ? 0 : sq;
+ final double coef = sign * Math.sqrt(sq);
+ final double cx1 = coef * ((rx * y1) / ry);
+ final double cy1 = coef * -((ry * x1) / rx);
+
+ //
+ // Step 3 : Compute (cx, cy) from (cx1, cy1)
+ //
+ final double sx2 = (x0 + x) / 2.0;
+ final double sy2 = (y0 + y) / 2.0;
+ final double cx = sx2 + (cosAngle * cx1 - sinAngle * cy1);
+ final double cy = sy2 + (sinAngle * cx1 + cosAngle * cy1);
+
+ //
+ // Step 4 : Compute the angleStart (angle1) and the angleExtent (dangle)
+ //
+ final double ux = (x1 - cx1) / rx;
+ final double uy = (y1 - cy1) / ry;
+ final double vx = (-x1 - cx1) / rx;
+ final double vy = (-y1 - cy1) / ry;
+ // Compute the angle start
+ double n = Math.sqrt((ux * ux) + (uy * uy));
+ double p = ux; // (1 * ux) + (0 * uy)
+ sign = (uy < 0) ? -1.0 : 1.0;
+ double angleStart = Math.toDegrees(sign * Math.acos(p / n));
+
+ // Compute the angle extent
+ n = Math.sqrt((ux * ux + uy * uy) * (vx * vx + vy * vy));
+ p = ux * vx + uy * vy;
+ sign = (ux * vy - uy * vx < 0) ? -1.0 : 1.0;
+ double angleExtent = Math.toDegrees(sign * Math.acos(p / n));
+ if (!sweepFlag && angleExtent > 0) {
+ angleExtent -= 360f;
+ } else if (sweepFlag && angleExtent < 0) {
+ angleExtent += 360f;
+ }
+ angleExtent %= 360f;
+ angleStart %= 360f;
+
+ //
+ // We can now build the resulting Arc2D in double precision
+ //
+ final Arc2D.Double arc = new Arc2D.Double();
+ arc.x = cx - rx;
+ arc.y = cy - ry;
+ arc.width = rx * 2.0;
+ arc.height = ry * 2.0;
+ arc.start = -angleStart;
+ arc.extent = -angleExtent;
+
+ return arc;
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void moveTo(double x, double y) {
+ // Don't add moveto to general path unless there is a reason.
+ makeRoom(2);
+ types[numSeg++] = PathIterator.SEG_MOVETO;
+ cx = mx = values[numVals++] = x;
+ cy = my = values[numVals++] = y;
+
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void lineTo(double x, double y) {
+ checkMoveTo(); // check if prev command was moveto
+ path.lineTo(x, y);
+
+ makeRoom(2);
+ types[numSeg++] = PathIterator.SEG_LINETO;
+ cx = values[numVals++] = x;
+ cy = values[numVals++] = y;
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void quadTo(double x1, double y1, double x2, double y2) {
+ checkMoveTo(); // check if prev command was moveto
+ path.quadTo(x1, y1, x2, y2);
+
+ makeRoom(4);
+ types[numSeg++] = PathIterator.SEG_QUADTO;
+ values[numVals++] = x1;
+ values[numVals++] = y1;
+ cx = values[numVals++] = x2;
+ cy = values[numVals++] = y2;
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void curveTo(double x1, double y1, double x2, double y2, double x3, double y3) {
+ checkMoveTo(); // check if prev command was moveto
+ path.curveTo(x1, y1, x2, y2, x3, y3);
+
+ makeRoom(6);
+ types[numSeg++] = PathIterator.SEG_CUBICTO;
+ values[numVals++] = x1;
+ values[numVals++] = y1;
+ values[numVals++] = x2;
+ values[numVals++] = y2;
+ cx = values[numVals++] = x3;
+ cy = values[numVals++] = y3;
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void closePath() {
+ // Don't double close path.
+ if (numSeg != 0 && types[numSeg - 1] == PathIterator.SEG_CLOSE) {
+ return;
+ }
+
+ // Only close path if the previous command wasn't a moveto
+ if (numSeg != 0 && types[numSeg - 1] != PathIterator.SEG_MOVETO) {
+ path.closePath();
+ }
+
+ makeRoom(0);
+ types[numSeg++] = PathIterator.SEG_CLOSE;
+ cx = mx;
+ cy = my;
+ }
+
+ /**
+ * Checks if previous command was a moveto command, skipping a close command (if present).
+ */
+ protected void checkMoveTo() {
+ if (numSeg == 0) {
+ return;
+ }
+
+ switch (types[numSeg - 1]) {
+
+ case PathIterator.SEG_MOVETO:
+ path.moveTo(values[numVals - 2], values[numVals - 1]);
+ break;
+
+ case PathIterator.SEG_CLOSE:
+ if (numSeg == 1) {
+ return;
+ }
+ if (types[numSeg - 2] == PathIterator.SEG_MOVETO) {
+ path.moveTo(values[numVals - 2], values[numVals - 1]);
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void append(Shape s, boolean connect) {
+ append(s.getPathIterator(new AffineTransform()), connect);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void append(PathIterator pi, boolean connect) {
+ final double[] vals = new double[6];
+
+ while (!pi.isDone()) {
+ Arrays.fill(vals, 0);
+ int type = pi.currentSegment(vals);
+ pi.next();
+ if (connect && numVals != 0) {
+ if (type == PathIterator.SEG_MOVETO) {
+ final double x = vals[0];
+ final double y = vals[1];
+ if (x != cx || y != cy) {
+ // Change MOVETO to LINETO.
+ type = PathIterator.SEG_LINETO;
+ } else {
+ // Redundent segment (move to current loc) drop it...
+ if (pi.isDone()) {
+ break; // Nothing interesting
+ }
+ type = pi.currentSegment(vals);
+ pi.next();
+ }
+ }
+ connect = false;
+ }
+
+ switch (type) {
+ case PathIterator.SEG_CLOSE:
+ closePath();
+ break;
+ case PathIterator.SEG_MOVETO:
+ moveTo(vals[0], vals[1]);
+ break;
+ case PathIterator.SEG_LINETO:
+ lineTo(vals[0], vals[1]);
+ break;
+ case PathIterator.SEG_QUADTO:
+ quadTo(vals[0], vals[1], vals[2], vals[3]);
+ break;
+ case PathIterator.SEG_CUBICTO:
+ curveTo(vals[0], vals[1], vals[2], vals[3], vals[4], vals[5]);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void append(ExtendedPathIterator epi, boolean connect) {
+ final double[] vals = new double[7];
+ while (!epi.isDone()) {
+ Arrays.fill(vals, 0);
+ int type = epi.currentSegment(vals);
+ epi.next();
+ if (connect && numVals != 0) {
+ if (type == PathIterator.SEG_MOVETO) {
+ final double x = vals[0];
+ final double y = vals[1];
+ if ((x != cx) || (y != cy)) {
+ // Change MOVETO to LINETO.
+ type = PathIterator.SEG_LINETO;
+ } else {
+ // Redundant segment (move to current loc) drop it...
+ if (epi.isDone()) {
+ break; // Nothing interesting
+ }
+ type = epi.currentSegment(vals);
+ epi.next();
+ }
+ }
+ connect = false;
+ }
+
+ switch (type) {
+ case PathIterator.SEG_CLOSE:
+ closePath();
+ break;
+ case PathIterator.SEG_MOVETO:
+ moveTo(vals[0], vals[1]);
+ break;
+ case PathIterator.SEG_LINETO:
+ lineTo(vals[0], vals[1]);
+ break;
+ case PathIterator.SEG_QUADTO:
+ quadTo(vals[0], vals[1], vals[2], vals[3]);
+ break;
+ case PathIterator.SEG_CUBICTO:
+ curveTo(vals[0], vals[1], vals[2], vals[3], vals[4], vals[5]);
+ break;
+ case ExtendedPathIterator.SEG_ARCTO:
+ arcTo(vals[0], vals[1], vals[2], vals[3] != 0, vals[4] != 0, vals[5], vals[6]);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public int getWindingRule() {
+ return path.getWindingRule();
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void setWindingRule(int rule) {
+ path.setWindingRule(rule);
+ }
+
+ /**
+ * get the current position or <code>null</code>.
+ */
+ public Point2D getCurrentPoint() {
+ if (numVals == 0) {
+ return null;
+ }
+ return new Point2D.Double(cx, cy);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void reset() {
+ path.reset();
+
+ numSeg = 0;
+ numVals = 0;
+ values = null;
+ types = null;
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public void transform(AffineTransform at) {
+ if (at.getType() != AffineTransform.TYPE_IDENTITY) {
+ throw new IllegalArgumentException("ExtendedGeneralPaths can not be transformed");
+ }
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public Shape createTransformedShape(AffineTransform at) {
+ return path.createTransformedShape(at);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public Rectangle getBounds() {
+ return path.getBounds();
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public Rectangle2D getBounds2D() {
+ return path.getBounds2D();
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public boolean contains(double x, double y) {
+ return path.contains(x, y);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public boolean contains(Point2D p) {
+ return path.contains(p);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public boolean contains(double x, double y, double w, double h) {
+ return path.contains(x, y, w, h);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public boolean contains(Rectangle2D r) {
+ return path.contains(r);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public boolean intersects(double x, double y, double w, double h) {
+ return path.intersects(x, y, w, h);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public boolean intersects(Rectangle2D r) {
+ return path.intersects(r);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public PathIterator getPathIterator(AffineTransform at) {
+ return path.getPathIterator(at);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public PathIterator getPathIterator(AffineTransform at, double flatness) {
+ return path.getPathIterator(at, flatness);
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public ExtendedPathIterator getExtendedPathIterator() {
+ return new EPI();
+ }
+
+ class EPI implements ExtendedPathIterator {
+ private int segNum = 0;
+ private int valsIdx = 0;
+
+ public int currentSegment() {
+ return types[segNum];
+ }
+
+ public int currentSegment(double[] coords) {
+ final int ret = types[segNum];
+ switch (ret) {
+ case SEG_CLOSE:
+ break;
+ case SEG_MOVETO:
+ case SEG_LINETO:
+ coords[0] = values[valsIdx];
+ coords[1] = values[valsIdx + 1];
+ break;
+ case SEG_QUADTO:
+ coords[0] = values[valsIdx];
+ coords[1] = values[valsIdx + 1];
+ coords[2] = values[valsIdx + 2];
+ coords[3] = values[valsIdx + 3];
+ break;
+ case SEG_CUBICTO:
+ coords[0] = values[valsIdx];
+ coords[1] = values[valsIdx + 1];
+ coords[2] = values[valsIdx + 2];
+ coords[3] = values[valsIdx + 3];
+ coords[4] = values[valsIdx + 4];
+ coords[5] = values[valsIdx + 5];
+ break;
+ case SEG_ARCTO:
+ coords[0] = values[valsIdx];
+ coords[1] = values[valsIdx + 1];
+ coords[2] = values[valsIdx + 2];
+ coords[3] = values[valsIdx + 3];
+ coords[4] = values[valsIdx + 4];
+ coords[5] = values[valsIdx + 5];
+ coords[6] = values[valsIdx + 6];
+ break;
+ }
+ return ret;
+ }
+
+ public int getWindingRule() {
+ return path.getWindingRule();
+ }
+
+ public boolean isDone() {
+ return segNum == numSeg;
+ }
+
+ public void next() {
+ final int type = types[segNum++];
+ switch (type) {
+ case SEG_CLOSE:
+ break;
+ case SEG_MOVETO: // fallthrough is intended
+ case SEG_LINETO:
+ valsIdx += 2;
+ break;
+ case SEG_QUADTO:
+ valsIdx += 4;
+ break;
+ case SEG_CUBICTO:
+ valsIdx += 6;
+ break;
+ case SEG_ARCTO:
+ valsIdx += 7;
+ break;
+ }
+ }
+ }
+
+ /**
+ * Delegates to the enclosed <code>GeneralPath</code>.
+ */
+ public Object clone() {
+ try {
+ final ExtendedGeneralPath result = (ExtendedGeneralPath) super.clone();
+ result.path = (GeneralPath) path.clone();
+
+ if (values != null) {
+ result.values = new double[values.length];
+ System.arraycopy(values, 0, result.values, 0, values.length);
+ }
+ result.numVals = numVals;
+
+ if (types != null) {
+ result.types = new int[types.length];
+ System.arraycopy(types, 0, result.types, 0, types.length);
+ }
+ result.numSeg = numSeg;
+
+ return result;
+ } catch (CloneNotSupportedException ex) {
+ ex.printStackTrace();
+ }
+ return null;
+ }
+
+ /**
+ * Make sure, that the requested number of slots in vales[] are available. Must be called even for numValues = 0,
+ * because it is also used for initialization of those arrays.
+ *
+ * @param numValues
+ * number of requested coordinates
+ */
+ private void makeRoom(int numValues) {
+ if (values == null) {
+ values = new double[2 * numValues];
+ types = new int[2];
+ numVals = 0;
+ numSeg = 0;
+ return;
+ }
+
+ final int newSize = numVals + numValues;
+ if (newSize > values.length) {
+ int nlen = values.length * 2;
+ if (nlen < newSize) {
+ nlen = newSize;
+ }
+
+ final double[] nvals = new double[nlen];
+ System.arraycopy(values, 0, nvals, 0, numVals);
+ values = nvals;
+ }
+
+ if (numSeg == types.length) {
+ final int[] ntypes = new int[types.length * 2];
+ System.arraycopy(types, 0, ntypes, 0, types.length);
+ types = ntypes;
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/arc/ExtendedPathIterator.java b/src/net/sourceforge/plantuml/ugraphic/arc/ExtendedPathIterator.java
new file mode 100644
index 0000000..2a7ab22
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/arc/ExtendedPathIterator.java
@@ -0,0 +1,133 @@
+/* ========================================================================
+ * 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.ugraphic.arc;
+
+import java.awt.geom.PathIterator;
+
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
+ * file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
+ * to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+/**
+ * The <code>ExtendedPathIterator</code> class represents a geometric path constructed from straight lines, quadratic
+ * and cubic (Bezier) curves and elliptical arcs. This interface is identical to that of PathIterator except it can
+ * return SEG_ARCTO from currentSegment, also the array of values passed to currentSegment must be of length 7 or an
+ * error will be thrown.
+ *
+ * This does not extend PathIterator as it would break the interface contract for that class.
+ *
+ * @author <a href="mailto:deweese@apache.org">Thomas DeWeese</a>
+ * @version $Id: ExtendedPathIterator.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public interface ExtendedPathIterator {
+
+ /**
+ * The segment type constant that specifies that the preceding subpath should be closed by appending a line segment
+ * back to the point corresponding to the most recent SEG_MOVETO.
+ */
+ int SEG_CLOSE = PathIterator.SEG_CLOSE;
+
+ /**
+ * The segment type constant for a point that specifies the end point of a line to be drawn from the most recently
+ * specified point.
+ */
+ int SEG_MOVETO = PathIterator.SEG_MOVETO;
+
+ /**
+ * The segment type constant for a point that specifies the end point of a line to be drawn from the most recently
+ * specified point.
+ */
+ int SEG_LINETO = PathIterator.SEG_LINETO;
+
+ /**
+ * The segment type constant for the pair of points that specify a quadratic parametric curve to be drawn from the
+ * most recently specified point. The curve is interpolated by solving the parametric control equation in the range
+ * (t=[0..1]) using the most recently specified (current) point (CP), the first control point (P1), and the final
+ * interpolated control point (P2).
+ */
+ int SEG_QUADTO = PathIterator.SEG_QUADTO;
+
+ /**
+ * The segment type constant for the set of 3 points that specify a cubic parametric curve to be drawn from the most
+ * recently specified point. The curve is interpolated by solving the parametric control equation in the range
+ * (t=[0..1]) using the most recently specified (current) point (CP), the first control point (P1), the second
+ * control point (P2), and the final interpolated control point (P3).
+ */
+ int SEG_CUBICTO = PathIterator.SEG_CUBICTO;
+
+ /**
+ * The segment type constant for an elliptical arc. This consists of Seven values [rx, ry, angle, largeArcFlag,
+ * sweepFlag, x, y]. rx, ry are the radious of the ellipse. angle is angle of the x axis of the ellipse.
+ * largeArcFlag is zero if the smaller of the two arcs are to be used. sweepFlag is zero if the 'left' branch is
+ * taken one otherwise. x and y are the destination for the ellipse.
+ */
+ int SEG_ARCTO = 4321;
+
+ /**
+ * The winding rule constant for specifying an even-odd rule for determining the interior of a path. The even-odd
+ * rule specifies that a point lies inside the path if a ray drawn in any direction from that point to infinity is
+ * crossed by path segments an odd number of times.
+ */
+ int WIND_EVEN_ODD = PathIterator.WIND_EVEN_ODD;
+
+ /**
+ * The winding rule constant for specifying a non-zero rule for determining the interior of a path. The non-zero
+ * rule specifies that a point lies inside the path if a ray drawn in any direction from that point to infinity is
+ * crossed by path segments a different number of times in the counter-clockwise direction than the clockwise
+ * direction.
+ */
+ int WIND_NON_ZERO = PathIterator.WIND_NON_ZERO;
+
+ int currentSegment();
+
+ int currentSegment(double[] coords);
+
+ int getWindingRule();
+
+ boolean isDone();
+
+ void next();
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverCenteredCharacterEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverCenteredCharacterEps.java
new file mode 100644
index 0000000..ed3cc6f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverCenteredCharacterEps.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.ugraphic.eps;
+
+import java.awt.font.TextLayout;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UnusedSpace;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverCenteredCharacterEps implements UDriver<EpsGraphics> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
+ final UCenteredCharacter centeredCharacter = (UCenteredCharacter) ushape;
+ final char c = centeredCharacter.getChar();
+ final UFont font = centeredCharacter.getFont();
+ final UnusedSpace unusedSpace = UnusedSpace.getUnusedSpace(font, c);
+
+ final double xpos = x - unusedSpace.getCenterX() - 0.5;
+ final double ypos = y - unusedSpace.getCenterY() - 0.5;
+
+ final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext());
+ eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ DriverTextEps.drawPathIterator(eps, xpos, ypos, t.getOutline(null).getPathIterator(null));
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverDotPathEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverDotPathEps.java
new file mode 100644
index 0000000..b9ca820
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverDotPathEps.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.ugraphic.eps;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverDotPathEps implements UDriver<EpsGraphics> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
+ final DotPath shape = (DotPath) ushape;
+ //DriverLineG2d.manageStroke(param, g2d);
+
+ if (param.getColor() != null) {
+ eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ eps.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDashVisible(), param.getStroke()
+ .getDashSpace());
+ shape.draw(eps, x, y);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverEllipseEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverEllipseEps.java
new file mode 100644
index 0000000..da7961a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverEllipseEps.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.ugraphic.eps;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverEllipseEps implements UDriver<EpsGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverEllipseEps(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
+ final UEllipse shape = (UEllipse) ushape;
+ final double width = shape.getWidth();
+ final double height = shape.getHeight();
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ if (clip.isInside(x, y) == false) {
+ return;
+ }
+ if (clip.isInside(x + width, y + height) == false) {
+ return;
+ }
+ }
+
+ // Shadow
+ if (shape.getDeltaShadow() != 0) {
+ eps.epsEllipseShadow(x + width / 2, y + height / 2, width / 2, height / 2, shape.getDeltaShadow());
+ }
+
+ eps.setFillColor(mapper.getMappedColor(param.getBackcolor()));
+ eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ eps.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDashVisible(), param.getStroke()
+ .getDashSpace());
+
+ if (shape.getStart() == 0 && shape.getExtend() == 0) {
+ eps.epsEllipse(x + width / 2, y + height / 2, width / 2, height / 2);
+ } else {
+ eps.epsEllipse(x + width / 2, y + height / 2, width / 2, height / 2, shape.getStart(), shape.getExtend());
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverImageEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverImageEps.java
new file mode 100644
index 0000000..7beeebe
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverImageEps.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.ugraphic.eps;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverImageEps implements UDriver<EpsGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverImageEps(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
+
+ final UImage shape = (UImage) ushape;
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ if (clip.isInside(x, y) == false) {
+ return;
+ }
+ if (clip.isInside(x + shape.getWidth(), y + shape.getHeight()) == false) {
+ return;
+ }
+ }
+
+ eps.drawImage(shape.getImage(), x, y);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverLineEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverLineEps.java
new file mode 100644
index 0000000..69e7d2b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverLineEps.java
@@ -0,0 +1,79 @@
+/* ========================================================================
+ * 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.ugraphic.eps;
+
+import java.awt.geom.Line2D;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverLineEps implements UDriver<EpsGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverLineEps(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
+ final ULine shape = (ULine) ushape;
+
+ double x2 = x + shape.getDX();
+ double y2 = y + shape.getDY();
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ final Line2D.Double line = clip.getClippedLine(new Line2D.Double(x, y, x2, y2));
+ if (line == null) {
+ return;
+ }
+ x = line.x1;
+ y = line.y1;
+ x2 = line.x2;
+ y2 = line.y2;
+ }
+
+ eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ eps.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDashVisible(), param.getStroke()
+ .getDashSpace());
+ eps.epsLine(x, y, x2, y2);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverPathEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverPathEps.java
new file mode 100644
index 0000000..f7f5ad9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverPathEps.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.ugraphic.eps;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverPathEps implements UDriver<EpsGraphics> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
+ final UPath shape = (UPath) ushape;
+
+ eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ eps.setFillColor(mapper.getMappedColor(param.getBackcolor()));
+ eps.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDashVisible(), param
+ .getStroke().getDashSpace());
+
+ eps.epsPath(x, y, shape);
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverPolygonEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverPolygonEps.java
new file mode 100644
index 0000000..dbd6296
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverPolygonEps.java
@@ -0,0 +1,93 @@
+/* ========================================================================
+ * 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.ugraphic.eps;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverPolygonEps implements UDriver<EpsGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverPolygonEps(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
+ final UPolygon shape = (UPolygon) ushape;
+
+ final double points[] = new double[shape.getPoints().size() * 2];
+ int i = 0;
+
+ for (Point2D pt : shape.getPoints()) {
+ points[i++] = pt.getX() + x;
+ points[i++] = pt.getY() + y;
+ }
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ for (int j = 0; j < points.length; j += 2) {
+ if (clip.isInside(points[j], points[j + 1]) == false) {
+ return;
+ }
+ }
+ }
+
+ if (shape.getDeltaShadow() != 0) {
+ eps.epsPolygonShadow(shape.getDeltaShadow(), points);
+ }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ eps.epsPolygon((HtmlColorGradient) back, mapper, points);
+ } else {
+
+ eps.setFillColor(mapper.getMappedColor(back));
+ eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ eps.epsPolygon(points);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverRectangleEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverRectangleEps.java
new file mode 100644
index 0000000..2707e58
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverRectangleEps.java
@@ -0,0 +1,98 @@
+/* ========================================================================
+ * 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.ugraphic.eps;
+
+import java.awt.geom.Rectangle2D;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverRectangleEps implements UDriver<EpsGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverRectangleEps(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
+ final URectangle rect = (URectangle) ushape;
+
+ double width = rect.getWidth();
+ double height = rect.getHeight();
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ final Rectangle2D.Double orig = new Rectangle2D.Double(x, y, width, height);
+ final Rectangle2D.Double r = clip.getClippedRectangle(orig);
+ if (r.height < 0) {
+ return;
+ }
+ x = r.x;
+ y = r.y;
+ width = r.width;
+ height = r.height;
+ }
+
+ final double rx = rect.getRx();
+ final double ry = rect.getRy();
+
+ // Shadow
+ if (rect.getDeltaShadow() != 0) {
+ eps.epsRectangleShadow(x, y, width, height, rx / 2, ry / 2, rect.getDeltaShadow());
+ }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ eps.epsRectangle(x, y, width, height, rx / 2, ry / 2, (HtmlColorGradient) back, mapper);
+ } else {
+ eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ eps.setFillColor(mapper.getMappedColor(param.getBackcolor()));
+ eps.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDashVisible(), param
+ .getStroke().getDashSpace());
+ eps.epsRectangle(x, y, width, height, rx / 2, ry / 2);
+ }
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/DriverTextEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/DriverTextEps.java
new file mode 100644
index 0000000..8cc6e2c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/DriverTextEps.java
@@ -0,0 +1,225 @@
+/* ========================================================================
+ * 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.ugraphic.eps;
+
+import java.awt.Color;
+import java.awt.FontMetrics;
+import java.awt.font.FontRenderContext;
+import java.awt.font.TextLayout;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.PathIterator;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.eps.EpsGraphicsMacroAndText;
+import net.sourceforge.plantuml.eps.EpsStrategy;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.FontStyle;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.MinMax;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UText;
+import net.sourceforge.plantuml.ugraphic.g2d.DriverTextAsPathG2d;
+
+public class DriverTextEps implements UDriver<EpsGraphics> {
+
+ private final StringBounder stringBounder;
+ private final ClipContainer clipContainer;
+ private final FontRenderContext fontRenderContext;
+ private final EpsStrategy strategy;
+
+ public DriverTextEps(ClipContainer clipContainer, EpsStrategy strategy) {
+ this.stringBounder = TextBlockUtils.getDummyStringBounder();
+ this.clipContainer = clipContainer;
+ this.fontRenderContext = TextBlockUtils.getFontRenderContext();
+ this.strategy = strategy;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, EpsGraphics eps) {
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null && clip.isInside(x, y) == false) {
+ return;
+ }
+
+ final UText shape = (UText) ushape;
+
+ if (strategy == EpsStrategy.WITH_MACRO_AND_TEXT) {
+ drawAsText(shape, x, y, param, eps, mapper);
+ return;
+ }
+
+ final FontConfiguration fontConfiguration = shape.getFontConfiguration();
+ final UFont font = fontConfiguration.getFont();
+
+ final TextLayout t = new TextLayout(shape.getText(), font.getFont(), fontRenderContext);
+
+ MinMax dim = null;
+
+ if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) {
+ final Color extended = mapper.getMappedColor(fontConfiguration.getExtendedColor());
+ if (extended != null) {
+ eps.setStrokeColor(extended);
+ eps.setFillColor(extended);
+ eps.setStrokeWidth("1", 0, 0);
+ if (dim == null) {
+ dim = getMinMax(x, y, t.getOutline(null).getPathIterator(null));
+ }
+ eps.epsRectangle(dim.getMinX() - 1, dim.getMinY() - 1, dim.getWidth() + 2, dim.getHeight() + 2, 0, 0);
+ }
+ }
+
+ eps.setStrokeColor(mapper.getMappedColor(fontConfiguration.getColor()));
+ drawPathIterator(eps, x, y, t.getOutline(null).getPathIterator(null));
+
+ if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
+ final HtmlColor extended = fontConfiguration.getExtendedColor();
+ if (extended != null) {
+ eps.setStrokeColor(mapper.getMappedColor(extended));
+ }
+ if (dim == null) {
+ dim = getMinMax(x, y, t.getOutline(null).getPathIterator(null));
+ }
+ eps.setStrokeWidth("1.1", 0, 0);
+ eps.epsLine(x, y + 1.5, x + dim.getWidth(), y + 1.5);
+ eps.setStrokeWidth("1", 0, 0);
+ }
+ if (fontConfiguration.containsStyle(FontStyle.WAVE)) {
+ if (dim == null) {
+ dim = getMinMax(x, y, t.getOutline(null).getPathIterator(null));
+ }
+ final int ypos = (int) (y + 2.5) - 1;
+ final HtmlColor extended = fontConfiguration.getExtendedColor();
+ if (extended != null) {
+ eps.setStrokeColor(mapper.getMappedColor(extended));
+ }
+ eps.setStrokeWidth("1.1", 0, 0);
+ for (int i = (int) x; i < x + dim.getWidth() - 5; i += 6) {
+ eps.epsLine(i, ypos - 0, i + 3, ypos + 1);
+ eps.epsLine(i + 3, ypos + 1, i + 6, ypos - 0);
+ }
+ eps.setStrokeWidth("1", 0, 0);
+ }
+ if (fontConfiguration.containsStyle(FontStyle.STRIKE)) {
+ final HtmlColor extended = fontConfiguration.getExtendedColor();
+ if (extended != null) {
+ eps.setStrokeColor(mapper.getMappedColor(extended));
+ }
+ if (dim == null) {
+ dim = getMinMax(x, y, t.getOutline(null).getPathIterator(null));
+ }
+ // final FontMetrics fm = font.getFontMetrics();
+ final double ypos = (dim.getMinY() + dim.getMaxY() * 2) / 3;
+ eps.setStrokeWidth("1.3", 0, 0);
+ eps.epsLine(x, ypos, x + dim.getWidth(), ypos);
+ eps.setStrokeWidth("1", 0, 0);
+ }
+
+ }
+
+ private void drawAsText(UText shape, double x, double y, UParam param, EpsGraphics eps, ColorMapper mapper) {
+ final FontConfiguration fontConfiguration = shape.getFontConfiguration();
+ // final FontMetrics fm = g2dummy.getFontMetrics(fontConfiguration.getFont().getFont());
+ // final double ypos = y - fm.getDescent() + 0.5;
+ final double ypos = y - 1;
+
+ eps.setStrokeColor(mapper.getMappedColor(fontConfiguration.getColor()));
+ ((EpsGraphicsMacroAndText) eps).drawText(shape.getText(), fontConfiguration, x, ypos);
+
+ }
+
+ static void drawPathIterator(EpsGraphics eps, double x, double y, PathIterator path) {
+
+ eps.newpath();
+ final double coord[] = new double[6];
+ while (path.isDone() == false) {
+ final int code = path.currentSegment(coord);
+ if (code == PathIterator.SEG_MOVETO) {
+ eps.moveto(coord[0] + x, coord[1] + y);
+ } else if (code == PathIterator.SEG_LINETO) {
+ eps.lineto(coord[0] + x, coord[1] + y);
+ } else if (code == PathIterator.SEG_CLOSE) {
+ eps.closepath();
+ } else if (code == PathIterator.SEG_CUBICTO) {
+ eps.curveto(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y, coord[4] + x, coord[5] + y);
+ } else if (code == PathIterator.SEG_QUADTO) {
+ eps.quadto(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y);
+ } else {
+ throw new UnsupportedOperationException("code=" + code);
+ }
+
+ path.next();
+ }
+
+ eps.fill(path.getWindingRule());
+
+ }
+
+ static private MinMax getMinMax(double x, double y, PathIterator path) {
+
+ MinMax result = MinMax.getEmpty(false);
+
+ final double coord[] = new double[6];
+ while (path.isDone() == false) {
+ final int code = path.currentSegment(coord);
+ if (code == PathIterator.SEG_MOVETO) {
+ result = result.addPoint(coord[0] + x, coord[1] + y);
+ } else if (code == PathIterator.SEG_LINETO) {
+ result = result.addPoint(coord[0] + x, coord[1] + y);
+ } else if (code == PathIterator.SEG_CLOSE) {
+ } else if (code == PathIterator.SEG_CUBICTO) {
+ result = result.addPoint(coord[0] + x, coord[1] + y);
+ result = result.addPoint(coord[2] + x, coord[3] + y);
+ result = result.addPoint(coord[4] + x, coord[5] + y);
+ } else if (code == PathIterator.SEG_QUADTO) {
+ result = result.addPoint(coord[0] + x, coord[1] + y);
+ result = result.addPoint(coord[2] + x, coord[3] + y);
+ } else {
+ throw new UnsupportedOperationException("code=" + code);
+ }
+ path.next();
+ }
+
+ return result;
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/eps/UGraphicEps.java b/src/net/sourceforge/plantuml/ugraphic/eps/UGraphicEps.java
new file mode 100644
index 0000000..2762ba8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/eps/UGraphicEps.java
@@ -0,0 +1,143 @@
+/* ========================================================================
+ * 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.ugraphic.eps;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.eps.EpsGraphics;
+import net.sourceforge.plantuml.eps.EpsStrategy;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UDrawable;
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
+import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class UGraphicEps extends AbstractUGraphic<EpsGraphics> implements ClipContainer, UGraphic2 {
+
+ private final StringBounder stringBounder;
+
+ private final EpsStrategy strategyTOBEREMOVED;
+
+ @Override
+ protected AbstractCommonUGraphic copyUGraphic() {
+ return new UGraphicEps(this);
+ }
+
+ protected UGraphicEps(UGraphicEps other) {
+ super(other);
+ this.stringBounder = other.stringBounder;
+ this.strategyTOBEREMOVED = other.strategyTOBEREMOVED;
+ register(strategyTOBEREMOVED);
+ }
+
+ public UGraphicEps(ColorMapper colorMapper, EpsStrategy strategy) {
+ this(colorMapper, strategy, strategy.creatEpsGraphics());
+ }
+
+ private UGraphicEps(ColorMapper colorMapper, EpsStrategy strategy, EpsGraphics eps) {
+ super(colorMapper, eps);
+ this.strategyTOBEREMOVED = strategy;
+ this.stringBounder = TextBlockUtils.getDummyStringBounder();
+ register(strategy);
+ }
+
+ private void register(EpsStrategy strategy) {
+ registerDriver(URectangle.class, new DriverRectangleEps(this));
+ registerDriver(UText.class, new DriverTextEps(this, strategy));
+ registerDriver(ULine.class, new DriverLineEps(this));
+ registerDriver(UPolygon.class, new DriverPolygonEps(this));
+ registerDriver(UEllipse.class, new DriverEllipseEps(this));
+ registerDriver(UImage.class, new DriverImageEps(this));
+ registerDriver(UPath.class, new DriverPathEps());
+ registerDriver(DotPath.class, new DriverDotPathEps());
+ registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterEps());
+ }
+
+ public void close() {
+ getEpsGraphics().close();
+ }
+
+ public String getEPSCode() {
+ return getEpsGraphics().getEPSCode();
+ }
+
+ public EpsGraphics getEpsGraphics() {
+ return this.getGraphicObject();
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public void drawEps(String eps, double x, double y) {
+ this.getGraphicObject().drawEps(eps, x, y);
+ }
+
+ static public String getEpsString(ColorMapper colorMapper, EpsStrategy epsStrategy, UDrawable udrawable)
+ throws IOException {
+ final UGraphicEps ug = new UGraphicEps(colorMapper, epsStrategy);
+ udrawable.drawU(ug);
+ return ug.getEPSCode();
+ }
+
+ public void startUrl(Url url) {
+ getGraphicObject().openLink(url.getUrl());
+ }
+
+ public void closeAction() {
+ getGraphicObject().closeLink();
+ }
+
+ public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
+ os.write(getEPSCode().getBytes());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverCenteredCharacterG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverCenteredCharacterG2d.java
new file mode 100644
index 0000000..e206fc2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverCenteredCharacterG2d.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.ugraphic.g2d;
+
+import java.awt.Graphics2D;
+
+import net.sourceforge.plantuml.graphic.UnusedSpace;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverCenteredCharacterG2d implements UDriver<Graphics2D> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final UCenteredCharacter characterCircled = (UCenteredCharacter) ushape;
+ final char c = characterCircled.getChar();
+ final UFont font = characterCircled.getFont();
+ final UnusedSpace unusedSpace = UnusedSpace.getUnusedSpace(font, c);
+
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ final double xpos = x - unusedSpace.getCenterX();
+ final double ypos = y - unusedSpace.getCenterY() - 0.5;
+
+ g2d.setFont(font.getFont());
+ g2d.drawString("" + c, (float) xpos, (float) ypos);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverDotPathG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverDotPathG2d.java
new file mode 100644
index 0000000..862b943
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverDotPathG2d.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.ugraphic.g2d;
+
+import java.awt.Graphics2D;
+
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverDotPathG2d implements UDriver<Graphics2D> {
+
+ private final EnsureVisible visible;
+
+ public DriverDotPathG2d(EnsureVisible visible) {
+ this.visible = visible;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final DotPath shape = (DotPath) ushape;
+ DriverLineG2d.manageStroke(param, g2d);
+
+ if (param.getColor() != null) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ shape.draw(g2d, x, y);
+ shape.manageEnsureVisible(x, y, visible);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverEllipseG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverEllipseG2d.java
new file mode 100644
index 0000000..277a65d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverEllipseG2d.java
@@ -0,0 +1,143 @@
+/* ========================================================================
+ * 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.ugraphic.g2d;
+
+import java.awt.BasicStroke;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.Arc2D;
+import java.awt.geom.Ellipse2D;
+
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverEllipseG2d extends DriverShadowedG2d implements UDriver<Graphics2D> {
+
+ private final double dpiFactor;
+ private final EnsureVisible visible;
+
+ public DriverEllipseG2d(double dpiFactor, EnsureVisible visible) {
+ this.dpiFactor = dpiFactor;
+ this.visible = visible;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final UEllipse shape = (UEllipse) ushape;
+ g2d.setStroke(new BasicStroke((float) param.getStroke().getThickness()));
+ visible.ensureVisible(x, y);
+ visible.ensureVisible(x + shape.getWidth(), y + shape.getHeight());
+ if (shape.getStart() == 0 && shape.getExtend() == 0) {
+ final Shape ellipse = new Ellipse2D.Double(x, y, shape.getWidth(), shape.getHeight());
+
+ // Shadow
+ if (shape.getDeltaShadow() != 0) {
+ drawShadow(g2d, ellipse, shape.getDeltaShadow(), dpiFactor);
+ }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final GradientPaint paint = getPaintGradient(x, y, mapper, shape, back);
+ g2d.setPaint(paint);
+ g2d.fill(ellipse);
+
+ if (param.getColor() != null) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ DriverLineG2d.manageStroke(param, g2d);
+ g2d.draw(ellipse);
+ }
+ } else {
+ if (back != null) {
+ g2d.setColor(mapper.getMappedColor(param.getBackcolor()));
+ DriverRectangleG2d.managePattern(param, g2d);
+ g2d.fill(ellipse);
+ }
+ if (param.getColor() != null && param.getColor().equals(param.getBackcolor()) == false) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ DriverLineG2d.manageStroke(param, g2d);
+ g2d.draw(ellipse);
+ }
+ }
+ } else {
+ final Shape arc = new Arc2D.Double(x, y, shape.getWidth(), shape.getHeight(), round(shape.getStart()),
+ round(shape.getExtend()), Arc2D.OPEN);
+ if (param.getColor() != null) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ g2d.draw(arc);
+ }
+ }
+ }
+
+ private GradientPaint getPaintGradient(double x, double y, ColorMapper mapper, final UEllipse shape,
+ final HtmlColor back) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final char policy = gr.getPolicy();
+ final GradientPaint paint;
+ if (policy == '|') {
+ paint = new GradientPaint((float) x, (float) (y + shape.getHeight()) / 2, mapper.getMappedColor(gr
+ .getColor1()), (float) (x + shape.getWidth()), (float) (y + shape.getHeight()) / 2,
+ mapper.getMappedColor(gr.getColor2()));
+ } else if (policy == '\\') {
+ paint = new GradientPaint((float) x, (float) (y + shape.getHeight()), mapper.getMappedColor(gr
+ .getColor1()), (float) (x + shape.getWidth()), (float) y, mapper.getMappedColor(gr.getColor2()));
+ } else if (policy == '-') {
+ paint = new GradientPaint((float) (x + shape.getWidth()) / 2, (float) y, mapper.getMappedColor(gr
+ .getColor1()), (float) (x + shape.getWidth()) / 2, (float) (y + shape.getHeight()),
+ mapper.getMappedColor(gr.getColor2()));
+ } else {
+ // for /
+ paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()),
+ (float) (x + shape.getWidth()), (float) (y + shape.getHeight()), mapper.getMappedColor(gr
+ .getColor2()));
+ }
+ return paint;
+ }
+
+
+ private static final double ROU = 5.0;
+
+ static double round(double value) {
+ return value;
+ // final int v = (int) Math.round(value / ROU);
+ // return v * ROU;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverImageG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverImageG2d.java
new file mode 100644
index 0000000..f63979e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverImageG2d.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.ugraphic.g2d;
+
+import java.awt.Graphics2D;
+
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverImageG2d implements UDriver<Graphics2D> {
+
+ private final EnsureVisible visible;
+
+ public DriverImageG2d(EnsureVisible visible) {
+ this.visible = visible;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final UImage shape = (UImage) ushape;
+ visible.ensureVisible(x, y);
+ visible.ensureVisible(x + shape.getWidth(), y + shape.getHeight());
+ g2d.drawImage(shape.getImage(), (int) x, (int) y, null);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverLineG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverLineG2d.java
new file mode 100644
index 0000000..26472f3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverLineG2d.java
@@ -0,0 +1,82 @@
+/* ========================================================================
+ * 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.ugraphic.g2d;
+
+import java.awt.BasicStroke;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.Line2D;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UStroke;
+
+public class DriverLineG2d extends DriverShadowedG2d implements UDriver<Graphics2D> {
+
+ private final double dpiFactor;
+
+ public DriverLineG2d(double dpiFactor) {
+ this.dpiFactor = dpiFactor;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final ULine shape = (ULine) ushape;
+
+ final Shape line = new Line2D.Double(x, y, x + shape.getDX(), y + shape.getDY());
+ manageStroke(param, g2d);
+ // Shadow
+ if (shape.getDeltaShadow() != 0) {
+ drawShadow(g2d, line, shape.getDeltaShadow(), dpiFactor);
+ }
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ g2d.draw(line);
+ }
+
+ static void manageStroke(UParam param, Graphics2D g2d) {
+ final UStroke stroke = param.getStroke();
+ final float thickness = (float) (stroke.getThickness() * param.getScale());
+ if (stroke.getDashVisible() == 0) {
+ g2d.setStroke(new BasicStroke(thickness));
+ } else {
+ final float dash1 = (float) stroke.getDashVisible();
+ final float dash2 = (float) stroke.getDashSpace();
+ final float[] style = { dash1, dash2 };
+ g2d.setStroke(new BasicStroke(thickness, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, style, 0));
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2d.java
new file mode 100644
index 0000000..6982ade
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2d.java
@@ -0,0 +1,158 @@
+/* ========================================================================
+ * 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.ugraphic.g2d;
+
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.Line2D;
+
+import net.sourceforge.plantuml.golem.MinMaxDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.USegment;
+import net.sourceforge.plantuml.ugraphic.USegmentType;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.arc.ExtendedGeneralPath;
+
+public class DriverPathG2d extends DriverShadowedG2d implements UDriver<Graphics2D> {
+
+ private final double dpiFactor;
+
+ public DriverPathG2d(double dpiFactor) {
+ this.dpiFactor = dpiFactor;
+ }
+
+ public void draw(UShape ushape, final double x, final double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final UPath shape = (UPath) ushape;
+ DriverLineG2d.manageStroke(param, g2d);
+
+ final ExtendedGeneralPath p = new ExtendedGeneralPath();
+ final MinMaxDouble minMax = new MinMaxDouble();
+ minMax.manage(x, y);
+ boolean hasBezier = false;
+ for (USegment seg : shape) {
+ final USegmentType type = seg.getSegmentType();
+ final double coord[] = seg.getCoord();
+ if (type == USegmentType.SEG_MOVETO) {
+ p.moveTo(x + coord[0], y + coord[1]);
+ minMax.manage(x + coord[0], y + coord[1]);
+ } else if (type == USegmentType.SEG_LINETO) {
+ p.lineTo(x + coord[0], y + coord[1]);
+ minMax.manage(x + coord[0], y + coord[1]);
+ } else if (type == USegmentType.SEG_CUBICTO) {
+ p.curveTo(x + coord[0], y + coord[1], x + coord[2], y + coord[3], x + coord[4], y + coord[5]);
+ minMax.manage(x + coord[4], y + coord[5]);
+ hasBezier = true;
+ } else if (type == USegmentType.SEG_ARCTO) {
+ p.arcTo(coord[0], coord[1], coord[2], coord[3] != 0, coord[4] != 0, x + coord[5], y + coord[6]);
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ if (shape.isOpenIconic()) {
+ p.closePath();
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ g2d.fill(p);
+ return;
+ }
+
+ // Shadow
+ if (shape.getDeltaShadow() != 0) {
+ if (hasBezier) {
+ drawShadow(g2d, p, shape.getDeltaShadow(), dpiFactor);
+ } else {
+ double lastX = 0;
+ double lastY = 0;
+ for (USegment seg : shape) {
+ final USegmentType type = seg.getSegmentType();
+ final double coord[] = seg.getCoord();
+ // Cast float for Java 1.5
+ if (type == USegmentType.SEG_MOVETO) {
+ lastX = x + coord[0];
+ lastY = y + coord[1];
+ } else if (type == USegmentType.SEG_LINETO) {
+ final Shape line = new Line2D.Double(lastX, lastY, x + coord[0], y + coord[1]);
+ drawShadow(g2d, line, shape.getDeltaShadow(), dpiFactor);
+ lastX = x + coord[0];
+ lastY = y + coord[1];
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+ }
+ }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final char policy = gr.getPolicy();
+ final GradientPaint paint;
+ if (policy == '|') {
+ paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY() / 2,
+ mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2,
+ mapper.getMappedColor(gr.getColor2()));
+ } else if (policy == '\\') {
+ paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr
+ .getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.getMappedColor(gr
+ .getColor2()));
+ } else if (policy == '-') {
+ paint = new GradientPaint((float) minMax.getMaxX() / 2, (float) minMax.getMinY(),
+ mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(),
+ mapper.getMappedColor(gr.getColor2()));
+ } else {
+ // for /
+ paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()),
+ (float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr.getColor2()));
+ }
+ g2d.setPaint(paint);
+ g2d.fill(p);
+ } else if (back != null) {
+ g2d.setColor(mapper.getMappedColor(back));
+ g2d.fill(p);
+ }
+
+ if (param.getColor() != null) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ g2d.draw(p);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2dLegacy.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2dLegacy.java
new file mode 100644
index 0000000..7a5a324
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathG2dLegacy.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.ugraphic.g2d;
+
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Line2D;
+import java.awt.geom.Path2D;
+
+import net.sourceforge.plantuml.golem.MinMaxDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.USegment;
+import net.sourceforge.plantuml.ugraphic.USegmentType;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverPathG2dLegacy extends DriverShadowedG2d implements UDriver<Graphics2D> {
+
+ private final double dpiFactor;
+
+ public DriverPathG2dLegacy(double dpiFactor) {
+ this.dpiFactor = dpiFactor;
+ }
+
+ public void draw(UShape ushape, final double x, final double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final UPath shape = (UPath) ushape;
+ DriverLineG2d.manageStroke(param, g2d);
+
+ final Path2D.Double p = new Path2D.Double();
+ boolean hasBezier = false;
+ final MinMaxDouble minMax = new MinMaxDouble();
+ minMax.manage(x, y);
+ for (USegment seg : shape) {
+ final USegmentType type = seg.getSegmentType();
+ final double coord[] = seg.getCoord();
+ if (type == USegmentType.SEG_MOVETO) {
+ p.moveTo(x + coord[0], y + coord[1]);
+ minMax.manage(x + coord[0], y + coord[1]);
+ } else if (type == USegmentType.SEG_LINETO) {
+ p.lineTo(x + coord[0], y + coord[1]);
+ minMax.manage(x + coord[0], y + coord[1]);
+ } else if (type == USegmentType.SEG_CUBICTO) {
+ p.curveTo(x + coord[0], y + coord[1], x + coord[2], y + coord[3], x + coord[4], y + coord[5]);
+ minMax.manage(x + coord[4], y + coord[5]);
+ hasBezier = true;
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ if (shape.isOpenIconic()) {
+ p.closePath();
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ g2d.fill(p);
+ return;
+ }
+
+ // Shadow
+ if (shape.getDeltaShadow() != 0) {
+ if (hasBezier) {
+ drawShadow(g2d, p, shape.getDeltaShadow(), dpiFactor);
+ } else {
+ double lastX = 0;
+ double lastY = 0;
+ for (USegment seg : shape) {
+ final USegmentType type = seg.getSegmentType();
+ final double coord[] = seg.getCoord();
+ // Cast float for Java 1.5
+ if (type == USegmentType.SEG_MOVETO) {
+ lastX = x + coord[0];
+ lastY = y + coord[1];
+ } else if (type == USegmentType.SEG_LINETO) {
+ final Shape line = new Line2D.Double(lastX, lastY, x + coord[0], y + coord[1]);
+ drawShadow(g2d, line, shape.getDeltaShadow(), dpiFactor);
+ lastX = x + coord[0];
+ lastY = y + coord[1];
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+ }
+ }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final char policy = gr.getPolicy();
+ final GradientPaint paint;
+ if (policy == '|') {
+ paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY() / 2,
+ mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2,
+ mapper.getMappedColor(gr.getColor2()));
+ } else if (policy == '\\') {
+ paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr
+ .getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.getMappedColor(gr
+ .getColor2()));
+ } else if (policy == '-') {
+ paint = new GradientPaint((float) minMax.getMaxX() / 2, (float) minMax.getMinY(),
+ mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(),
+ mapper.getMappedColor(gr.getColor2()));
+ } else {
+ // for /
+ paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()),
+ (float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr.getColor2()));
+ }
+ g2d.setPaint(paint);
+ g2d.fill(p);
+ } else if (back != null) {
+ g2d.setColor(mapper.getMappedColor(back));
+ g2d.fill(p);
+ }
+
+ if (param.getColor() != null) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ g2d.draw(p);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathOldG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathOldG2d.java
new file mode 100644
index 0000000..02a9e96
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPathOldG2d.java
@@ -0,0 +1,156 @@
+/* ========================================================================
+ * 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.ugraphic.g2d;
+
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Line2D;
+
+import net.sourceforge.plantuml.golem.MinMaxDouble;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.USegment;
+import net.sourceforge.plantuml.ugraphic.USegmentType;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverPathOldG2d extends DriverShadowedG2d implements UDriver<Graphics2D> {
+
+ private final double dpiFactor;
+
+ public DriverPathOldG2d(double dpiFactor) {
+ this.dpiFactor = dpiFactor;
+ }
+
+ public void draw(UShape ushape, final double x, final double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final UPath shape = (UPath) ushape;
+ DriverLineG2d.manageStroke(param, g2d);
+
+ final GeneralPath p = new GeneralPath();
+ boolean hasBezier = false;
+ final MinMaxDouble minMax = new MinMaxDouble();
+ minMax.manage(x, y);
+ for (USegment seg : shape) {
+ final USegmentType type = seg.getSegmentType();
+ final double coord[] = seg.getCoord();
+ // Cast float for Java 1.5
+ if (type == USegmentType.SEG_MOVETO) {
+ p.moveTo((float) (x + coord[0]), (float) (y + coord[1]));
+ minMax.manage(x + coord[0], y + coord[1]);
+ } else if (type == USegmentType.SEG_LINETO) {
+ p.lineTo((float) (x + coord[0]), (float) (y + coord[1]));
+ minMax.manage(x + coord[0], y + coord[1]);
+ } else if (type == USegmentType.SEG_CUBICTO) {
+ p.curveTo((float) (x + coord[0]), (float) (y + coord[1]), (float) (x + coord[2]),
+ (float) (y + coord[3]), (float) (x + coord[4]), (float) (y + coord[5]));
+ minMax.manage(x + coord[4], y + coord[5]);
+ hasBezier = true;
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ // bez = new CubicCurve2D.Double(x + bez.x1, y + bez.y1, x +
+ // bez.ctrlx1, y + bez.ctrly1, x + bez.ctrlx2, y
+ // + bez.ctrly2, x + bez.x2, y + bez.y2);
+ // p.append(bez, true);
+ }
+ // p.closePath();
+
+ // Shadow
+ if (shape.getDeltaShadow() != 0) {
+ if (hasBezier) {
+ drawShadow(g2d, p, shape.getDeltaShadow(), dpiFactor);
+ } else {
+ double lastX = 0;
+ double lastY = 0;
+ for (USegment seg : shape) {
+ final USegmentType type = seg.getSegmentType();
+ final double coord[] = seg.getCoord();
+ // Cast float for Java 1.5
+ if (type == USegmentType.SEG_MOVETO) {
+ lastX = x + coord[0];
+ lastY = y + coord[1];
+ } else if (type == USegmentType.SEG_LINETO) {
+ final Shape line = new Line2D.Double(lastX, lastY, x + coord[0], y + coord[1]);
+ drawShadow(g2d, line, shape.getDeltaShadow(), dpiFactor);
+ lastX = x + coord[0];
+ lastY = y + coord[1];
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ }
+ }
+ }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final char policy = gr.getPolicy();
+ final GradientPaint paint;
+ if (policy == '|') {
+ paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY() / 2,
+ mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX(), (float) minMax.getMaxY() / 2,
+ mapper.getMappedColor(gr.getColor2()));
+ } else if (policy == '\\') {
+ paint = new GradientPaint((float) minMax.getMinX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr
+ .getColor1()), (float) minMax.getMaxX(), (float) minMax.getMinY(), mapper.getMappedColor(gr
+ .getColor2()));
+ } else if (policy == '-') {
+ paint = new GradientPaint((float) minMax.getMaxX() / 2, (float) minMax.getMinY(),
+ mapper.getMappedColor(gr.getColor1()), (float) minMax.getMaxX() / 2, (float) minMax.getMaxY(),
+ mapper.getMappedColor(gr.getColor2()));
+ } else {
+ // for /
+ paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()),
+ (float) minMax.getMaxX(), (float) minMax.getMaxY(), mapper.getMappedColor(gr.getColor2()));
+ }
+ g2d.setPaint(paint);
+ g2d.fill(p);
+ } else if (back != null) {
+ g2d.setColor(mapper.getMappedColor(back));
+ g2d.fill(p);
+ }
+
+ if (param.getColor() != null) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ g2d.draw(p);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPixelG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPixelG2d.java
new file mode 100644
index 0000000..d3c376e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPixelG2d.java
@@ -0,0 +1,51 @@
+/* ========================================================================
+ * 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.ugraphic.g2d;
+
+import java.awt.Graphics2D;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverPixelG2d implements UDriver<Graphics2D> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ g2d.fillRect((int) x, (int) y, 1, 1);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPolygonG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPolygonG2d.java
new file mode 100644
index 0000000..90feb50
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverPolygonG2d.java
@@ -0,0 +1,127 @@
+/* ========================================================================
+ * 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.ugraphic.g2d;
+
+import java.awt.BasicStroke;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.geom.GeneralPath;
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverPolygonG2d extends DriverShadowedG2d implements UDriver<Graphics2D> {
+
+ private final double dpiFactor;
+ private final EnsureVisible visible;
+
+ public DriverPolygonG2d(double dpiFactor, EnsureVisible visible) {
+ this.dpiFactor = dpiFactor;
+ this.visible = visible;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final UPolygon shape = (UPolygon) ushape;
+
+ g2d.setStroke(new BasicStroke((float) param.getStroke().getThickness()));
+
+ final GeneralPath path = new GeneralPath();
+
+ boolean first = true;
+ for (Point2D pt : shape.getPoints()) {
+ final double xp = pt.getX() + x;
+ final double yp = pt.getY() + y;
+ visible.ensureVisible(xp, yp);
+ if (first) {
+ path.moveTo((float) xp, (float) yp);
+ } else {
+ path.lineTo((float) xp, (float) yp);
+ }
+ first = false;
+ }
+
+ if (first == false) {
+ path.closePath();
+ }
+
+ if (shape.getDeltaShadow() != 0) {
+ drawShadow(g2d, path, shape.getDeltaShadow(), dpiFactor);
+ }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final char policy = gr.getPolicy();
+ final GradientPaint paint;
+// final Rectangle2D bound = path.getBounds();
+ if (policy == '|') {
+ paint = new GradientPaint((float) x, (float) (y + shape.getHeight()) / 2, mapper.getMappedColor(gr
+ .getColor1()), (float) (x + shape.getWidth()), (float) (y + shape.getHeight()) / 2,
+ mapper.getMappedColor(gr.getColor2()));
+ } else if (policy == '\\') {
+ paint = new GradientPaint((float) x, (float) (y + shape.getHeight()), mapper.getMappedColor(gr
+ .getColor1()), (float) (x + shape.getWidth()), (float) y, mapper.getMappedColor(gr.getColor2()));
+ } else if (policy == '-') {
+ paint = new GradientPaint((float) (x + shape.getWidth()) / 2, (float) y, mapper.getMappedColor(gr
+ .getColor1()), (float) (x + shape.getWidth()) / 2, (float) (y + shape.getHeight()),
+ mapper.getMappedColor(gr.getColor2()));
+ } else {
+ // for /
+ paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()),
+ (float) (x + shape.getWidth()), (float) (y + shape.getHeight()), mapper.getMappedColor(gr
+ .getColor2()));
+ }
+ g2d.setPaint(paint);
+ g2d.fill(path);
+ } else if (back!=null) {
+ g2d.setColor(mapper.getMappedColor(back));
+ DriverRectangleG2d.managePattern(param, g2d);
+ g2d.fill(path);
+ }
+
+ if (param.getColor() != null) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ DriverLineG2d.manageStroke(param, g2d);
+ g2d.draw(path);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverRectangleG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverRectangleG2d.java
new file mode 100644
index 0000000..9c9faff
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverRectangleG2d.java
@@ -0,0 +1,179 @@
+/* ========================================================================
+ * 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.ugraphic.g2d;
+
+import java.awt.BasicStroke;
+import java.awt.GradientPaint;
+import java.awt.Graphics2D;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.TexturePaint;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.RoundRectangle2D;
+import java.awt.image.BufferedImage;
+
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.graphic.HtmlColorSimple;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPattern;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverRectangleG2d extends DriverShadowedG2d implements UDriver<Graphics2D> {
+
+ private final double dpiFactor;
+ private final EnsureVisible visible;
+
+ public DriverRectangleG2d(double dpiFactor, EnsureVisible visible) {
+ this.dpiFactor = dpiFactor;
+ this.visible = visible;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ g2d.setStroke(new BasicStroke((float) param.getStroke().getThickness()));
+ final URectangle shape = (URectangle) ushape;
+ final double rx = shape.getRx();
+ final double ry = shape.getRy();
+ final Shape rect;
+ if (rx == 0 && ry == 0) {
+ rect = new Rectangle2D.Double(x, y, shape.getWidth(), shape.getHeight());
+ } else {
+ rect = new RoundRectangle2D.Double(x, y, shape.getWidth(), shape.getHeight(), rx, ry);
+ }
+
+ visible.ensureVisible(x, y);
+ visible.ensureVisible(x + shape.getWidth(), y + shape.getHeight());
+
+ // Shadow
+ if (shape.getDeltaShadow() != 0) {
+ drawShadow(g2d, rect, shape.getDeltaShadow(), dpiFactor);
+ }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final GradientPaint paint = getPaintGradient(x, y, mapper, shape, back);
+ g2d.setPaint(paint);
+ g2d.fill(rect);
+
+ if (param.getColor() != null && param.getColor() instanceof HtmlColorGradient == false) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ DriverLineG2d.manageStroke(param, g2d);
+ g2d.draw(rect);
+ }
+
+ } else {
+ if (param.getBackcolor() != null) {
+ g2d.setColor(mapper.getMappedColor(param.getBackcolor()));
+ DriverLineG2d.manageStroke(param, g2d);
+ managePattern(param, g2d);
+ g2d.fill(rect);
+ }
+ if (param.getColor() != null && param.getColor().equals(param.getBackcolor()) == false) {
+ g2d.setColor(mapper.getMappedColor(param.getColor()));
+ DriverLineG2d.manageStroke(param, g2d);
+ g2d.draw(rect);
+ }
+ }
+ }
+
+ private GradientPaint getPaintGradient(double x, double y, ColorMapper mapper, final URectangle shape,
+ final HtmlColor back) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final char policy = gr.getPolicy();
+ final GradientPaint paint;
+ if (policy == '|') {
+ paint = new GradientPaint((float) x, (float) (y + shape.getHeight()) / 2, mapper.getMappedColor(gr
+ .getColor1()), (float) (x + shape.getWidth()), (float) (y + shape.getHeight()) / 2,
+ mapper.getMappedColor(gr.getColor2()));
+ } else if (policy == '\\') {
+ paint = new GradientPaint((float) x, (float) (y + shape.getHeight()), mapper.getMappedColor(gr
+ .getColor1()), (float) (x + shape.getWidth()), (float) y, mapper.getMappedColor(gr.getColor2()));
+ } else if (policy == '-') {
+ paint = new GradientPaint((float) (x + shape.getWidth()) / 2, (float) y, mapper.getMappedColor(gr
+ .getColor1()), (float) (x + shape.getWidth()) / 2, (float) (y + shape.getHeight()),
+ mapper.getMappedColor(gr.getColor2()));
+ } else {
+ // for /
+ paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()),
+ (float) (x + shape.getWidth()), (float) (y + shape.getHeight()), mapper.getMappedColor(gr
+ .getColor2()));
+ }
+ return paint;
+ }
+
+ public static void managePattern(UParam param, Graphics2D g2d) {
+ final UPattern pattern = param.getPattern();
+ if (pattern == UPattern.VERTICAL_STRIPE) {
+ final BufferedImage bi = new BufferedImage(4, 4, BufferedImage.TYPE_INT_ARGB);
+ final Rectangle r = new Rectangle(0, 0, 4, 4);
+ final int rgb = ((HtmlColorSimple) param.getBackcolor()).getColor999().getRGB();
+ for (int i = 0; i < 4; i++) {
+ for (int j = 0; j < 4; j++) {
+ if (i == 0 || i == 1) {
+ bi.setRGB(i, j, rgb);
+ }
+ }
+ }
+ g2d.setPaint(new TexturePaint(bi, r));
+ } else if (pattern == UPattern.HORIZONTAL_STRIPE) {
+ final BufferedImage bi = new BufferedImage(4, 4, BufferedImage.TYPE_INT_ARGB);
+ final Rectangle r = new Rectangle(0, 0, 4, 4);
+ final int rgb = ((HtmlColorSimple) param.getBackcolor()).getColor999().getRGB();
+ for (int i = 0; i < 4; i++) {
+ for (int j = 0; j < 4; j++) {
+ if (j == 0 || j == 1) {
+ bi.setRGB(i, j, rgb);
+ }
+ }
+ }
+ g2d.setPaint(new TexturePaint(bi, r));
+ } else if (pattern == UPattern.SMALL_CIRCLE) {
+ final BufferedImage bi = new BufferedImage(4, 4, BufferedImage.TYPE_INT_ARGB);
+ final Rectangle r = new Rectangle(0, 0, 4, 4);
+ final int rgb = ((HtmlColorSimple) param.getBackcolor()).getColor999().getRGB();
+ bi.setRGB(0, 1, rgb);
+ bi.setRGB(1, 0, rgb);
+ bi.setRGB(1, 1, rgb);
+ bi.setRGB(1, 2, rgb);
+ bi.setRGB(2, 1, rgb);
+ g2d.setPaint(new TexturePaint(bi, r));
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverShadowedG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverShadowedG2d.java
new file mode 100644
index 0000000..6a88f9a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverShadowedG2d.java
@@ -0,0 +1,111 @@
+/* ========================================================================
+ * 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.ugraphic.g2d;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Line2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.awt.image.ConvolveOp;
+import java.awt.image.Kernel;
+
+import net.sourceforge.plantuml.Log;
+
+public class DriverShadowedG2d {
+
+ private ConvolveOp getConvolveOp(int blurRadius, double dpiFactor) {
+ blurRadius = (int) (blurRadius * dpiFactor);
+ final int blurRadius2 = blurRadius * blurRadius;
+ final float blurRadius2F = blurRadius2;
+ // final float weight = (float) (1.0 / blurRadius2F / dpiFactor);
+ final float weight = (float) (1.0 / blurRadius2F);
+ final float[] elements = new float[blurRadius2];
+ for (int k = 0; k < blurRadius2; k++) {
+ elements[k] = weight;
+ }
+ final Kernel myKernel = new Kernel(blurRadius, blurRadius, elements);
+
+ // if EDGE_NO_OP is not selected, EDGE_ZERO_FILL is the default which
+ // creates a black border
+ return new ConvolveOp(myKernel, ConvolveOp.EDGE_NO_OP, null);
+ }
+
+ private final Color color = new Color(170, 170, 170);
+ private final Color colorLine = new Color(30, 30, 30);
+
+ protected void drawShadow(Graphics2D g2d, Shape shape, double deltaShadow, double dpiFactor) {
+ if (dpiFactor < 1) {
+ dpiFactor = 1;
+ }
+ // dpiFactor = 1;
+ // Shadow
+ final Rectangle2D bounds = shape.getBounds2D();
+ final double ww = bounds.getMaxX() - bounds.getMinX();
+ final double hh = bounds.getMaxY() - bounds.getMinY();
+
+ final double w = (ww + deltaShadow * 2 + 6) * dpiFactor;
+ final double h = (hh + deltaShadow * 2 + 6) * dpiFactor;
+ BufferedImage destination = null;
+ try {
+ destination = new BufferedImage((int) w, (int) h, BufferedImage.TYPE_INT_ARGB);
+ final Graphics2D gg = destination.createGraphics();
+ gg.scale(dpiFactor, dpiFactor);
+ gg.translate(deltaShadow - bounds.getMinX(), deltaShadow - bounds.getMinY());
+ final boolean isLine = shape instanceof Line2D.Double;
+ if (isLine) {
+ gg.setColor(colorLine);
+ gg.draw(shape);
+ } else {
+ gg.setColor(color);
+ gg.fill(shape);
+ }
+ gg.dispose();
+
+ final ConvolveOp simpleBlur = getConvolveOp(6, dpiFactor);
+ destination = simpleBlur.filter(destination, null);
+ } catch (OutOfMemoryError error) {
+ Log.info("Warning: Cannot draw shadow, image too big.");
+ }
+ if (destination != null) {
+ final AffineTransform at = g2d.getTransform();
+ g2d.scale(1 / dpiFactor, 1 / dpiFactor);
+ g2d.drawImage(destination, (int) (bounds.getMinX() * dpiFactor), (int) (bounds.getMinY() * dpiFactor), null);
+ g2d.setTransform(at);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextAsPathG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextAsPathG2d.java
new file mode 100644
index 0000000..697242b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextAsPathG2d.java
@@ -0,0 +1,152 @@
+/* ========================================================================
+ * 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.ugraphic.g2d;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.FontMetrics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsEnvironment;
+import java.awt.font.FontRenderContext;
+import java.awt.font.TextLayout;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Rectangle2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.FontStyle;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.StringBounderUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class DriverTextAsPathG2d implements UDriver<Graphics2D> {
+
+ private final EnsureVisible visible;
+ private final FontRenderContext fontRenderContext;
+
+ public DriverTextAsPathG2d(EnsureVisible visible, FontRenderContext fontRenderContext) {
+ this.visible = visible;
+ this.fontRenderContext = fontRenderContext;
+ }
+
+ private static void printFont() {
+ final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ final String fontNames[] = ge.getAvailableFontFamilyNames();
+ final int j = fontNames.length;
+ for (int i = 0; i < j; i++) {
+ Log.info("Available fonts: " + fontNames[i]);
+ }
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final UText shape = (UText) ushape;
+ final FontConfiguration fontConfiguration = shape.getFontConfiguration();
+
+ final UFont font = fontConfiguration.getFont().scaled(param.getScale());
+ final Dimension2D dimBack = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText());
+ if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) {
+ final Color extended = mapper.getMappedColor(fontConfiguration.getExtendedColor());
+ if (extended != null) {
+ g2d.setColor(extended);
+ g2d.setBackground(extended);
+ g2d.fill(new Rectangle2D.Double(x, y - dimBack.getHeight() + 1.5, dimBack.getWidth(), dimBack
+ .getHeight()));
+ }
+ }
+ visible.ensureVisible(x, y - dimBack.getHeight() + 1.5);
+ visible.ensureVisible(x + dimBack.getWidth(), y + 1.5);
+
+ g2d.setFont(font.getFont());
+ g2d.setColor(mapper.getMappedColor(fontConfiguration.getColor()));
+ final TextLayout t = new TextLayout(shape.getText(), font.getFont(), fontRenderContext);
+ g2d.translate(x, y);
+ g2d.fill(t.getOutline(null));
+ g2d.translate(-x, -y);
+
+ if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
+ final HtmlColor extended = fontConfiguration.getExtendedColor();
+ if (extended != null) {
+ g2d.setColor(mapper.getMappedColor(extended));
+ }
+ final Dimension2D dim = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText());
+ final int ypos = (int) (y + 2.5);
+ g2d.setStroke(new BasicStroke((float) 1));
+ g2d.drawLine((int) x, ypos, (int) (x + dim.getWidth()), ypos);
+ g2d.setStroke(new BasicStroke());
+ }
+ if (fontConfiguration.containsStyle(FontStyle.WAVE)) {
+ final Dimension2D dim = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText());
+ final int ypos = (int) (y + 2.5) - 1;
+ final HtmlColor extended = fontConfiguration.getExtendedColor();
+ if (extended != null) {
+ g2d.setColor(mapper.getMappedColor(extended));
+ }
+ for (int i = (int) x; i < x + dim.getWidth() - 5; i += 6) {
+ g2d.drawLine(i, ypos - 0, i + 3, ypos + 1);
+ g2d.drawLine(i + 3, ypos + 1, i + 6, ypos - 0);
+ }
+ }
+ if (fontConfiguration.containsStyle(FontStyle.STRIKE)) {
+ final Dimension2D dim = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText());
+ final FontMetrics fm = g2d.getFontMetrics(font.getFont());
+ final int ypos = (int) (y - fm.getDescent() - 0.5);
+ final HtmlColor extended = fontConfiguration.getExtendedColor();
+ if (extended != null) {
+ g2d.setColor(mapper.getMappedColor(extended));
+ }
+ g2d.setStroke(new BasicStroke((float) 1.5));
+ g2d.drawLine((int) x, ypos, (int) (x + dim.getWidth()), ypos);
+ g2d.setStroke(new BasicStroke());
+ }
+ }
+
+ static public Dimension2D calculateDimension(StringBounder stringBounder, UFont font, String text) {
+ final Dimension2D rect = stringBounder.calculateDimension(font, text);
+ double h = rect.getHeight();
+ if (h < 10) {
+ h = 10;
+ }
+ return new Dimension2DDouble(rect.getWidth(), h);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java
new file mode 100644
index 0000000..baf7b48
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/DriverTextG2d.java
@@ -0,0 +1,145 @@
+/* ========================================================================
+ * 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.ugraphic.g2d;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.FontMetrics;
+import java.awt.Graphics2D;
+import java.awt.GraphicsEnvironment;
+import java.awt.geom.Dimension2D;
+import java.awt.geom.Rectangle2D;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.FontStyle;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.StringBounderUtils;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class DriverTextG2d implements UDriver<Graphics2D> {
+
+ private final EnsureVisible visible;
+
+ public DriverTextG2d(EnsureVisible visible) {
+ this.visible = visible;
+ }
+
+ private static void printFont() {
+ final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
+ final String fontNames[] = ge.getAvailableFontFamilyNames();
+ final int j = fontNames.length;
+ for (int i = 0; i < j; i++) {
+ Log.info("Available fonts: " + fontNames[i]);
+ }
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
+ final UText shape = (UText) ushape;
+ final FontConfiguration fontConfiguration = shape.getFontConfiguration();
+
+ final UFont font = fontConfiguration.getFont().scaled(param.getScale());
+ final Dimension2D dimBack = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText());
+ if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) {
+ final Color extended = mapper.getMappedColor(fontConfiguration.getExtendedColor());
+ if (extended != null) {
+ g2d.setColor(extended);
+ g2d.setBackground(extended);
+ g2d.fill(new Rectangle2D.Double(x, y - dimBack.getHeight() + 1.5, dimBack.getWidth(), dimBack
+ .getHeight()));
+ }
+ }
+ visible.ensureVisible(x, y - dimBack.getHeight() + 1.5);
+ visible.ensureVisible(x + dimBack.getWidth(), y + 1.5);
+
+ g2d.setFont(font.getFont());
+ g2d.setColor(mapper.getMappedColor(fontConfiguration.getColor()));
+ g2d.drawString(shape.getText(), (float) x, (float) y);
+
+ if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
+ final HtmlColor extended = fontConfiguration.getExtendedColor();
+ if (extended != null) {
+ g2d.setColor(mapper.getMappedColor(extended));
+ }
+ final Dimension2D dim = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText());
+ final int ypos = (int) (y + 2.5);
+ g2d.setStroke(new BasicStroke((float) 1));
+ g2d.drawLine((int) x, ypos, (int) (x + dim.getWidth()), ypos);
+ g2d.setStroke(new BasicStroke());
+ }
+ if (fontConfiguration.containsStyle(FontStyle.WAVE)) {
+ final Dimension2D dim = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText());
+ final int ypos = (int) (y + 2.5) - 1;
+ final HtmlColor extended = fontConfiguration.getExtendedColor();
+ if (extended != null) {
+ g2d.setColor(mapper.getMappedColor(extended));
+ }
+ for (int i = (int) x; i < x + dim.getWidth() - 5; i += 6) {
+ g2d.drawLine(i, ypos - 0, i + 3, ypos + 1);
+ g2d.drawLine(i + 3, ypos + 1, i + 6, ypos - 0);
+ }
+ }
+ if (fontConfiguration.containsStyle(FontStyle.STRIKE)) {
+ final Dimension2D dim = calculateDimension(StringBounderUtils.asStringBounder(g2d), font, shape.getText());
+ final FontMetrics fm = g2d.getFontMetrics(font.getFont());
+ final int ypos = (int) (y - fm.getDescent() - 0.5);
+ final HtmlColor extended = fontConfiguration.getExtendedColor();
+ if (extended != null) {
+ g2d.setColor(mapper.getMappedColor(extended));
+ }
+ g2d.setStroke(new BasicStroke((float) 1.5));
+ g2d.drawLine((int) x, ypos, (int) (x + dim.getWidth()), ypos);
+ g2d.setStroke(new BasicStroke());
+ }
+ }
+
+ static public Dimension2D calculateDimension(StringBounder stringBounder, UFont font, String text) {
+ final Dimension2D rect = stringBounder.calculateDimension(font, text);
+ double h = rect.getHeight();
+ if (h < 10) {
+ h = 10;
+ }
+ return new Dimension2DDouble(rect.getWidth(), h);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/g2d/UGraphicG2d.java b/src/net/sourceforge/plantuml/ugraphic/g2d/UGraphicG2d.java
new file mode 100644
index 0000000..1650c8e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/g2d/UGraphicG2d.java
@@ -0,0 +1,216 @@
+/* ========================================================================
+ * 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.ugraphic.g2d;
+
+import java.awt.Graphics2D;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import net.sourceforge.plantuml.EnsureVisible;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.anim.AffineTransformation;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.StringBounderUtils;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.png.PngIO;
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
+import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UAntiAliasing;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPixel;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class UGraphicG2d extends AbstractUGraphic<Graphics2D> implements EnsureVisible, UGraphic2 {
+
+ private BufferedImage bufferedImage;
+
+ private final double dpiFactor;
+
+ private UAntiAliasing antiAliasing = UAntiAliasing.ANTI_ALIASING_ON;
+
+ private/* final */List<Url> urls = new ArrayList<Url>();
+ private Set<Url> allUrls = new HashSet<Url>();
+
+ private final boolean hasAffineTransform;
+
+ public final Set<Url> getAllUrlsEncountered() {
+ return Collections.unmodifiableSet(allUrls);
+ }
+
+ @Override
+ public UGraphic apply(UChange change) {
+ final UGraphicG2d copy = (UGraphicG2d) super.apply(change);
+ if (change instanceof UAntiAliasing) {
+ copy.antiAliasing = (UAntiAliasing) change;
+ }
+ return copy;
+ }
+
+ @Override
+ protected AbstractCommonUGraphic copyUGraphic() {
+ return new UGraphicG2d(this);
+ }
+
+ private UGraphicG2d(UGraphicG2d other) {
+ super(other);
+ this.hasAffineTransform = other.hasAffineTransform;
+ this.dpiFactor = other.dpiFactor;
+ this.bufferedImage = other.bufferedImage;
+ this.urls = other.urls;
+ this.allUrls = other.allUrls;
+ this.antiAliasing = other.antiAliasing;
+ register(dpiFactor);
+ }
+
+ public UGraphicG2d(ColorMapper colorMapper, Graphics2D g2d, double dpiFactor) {
+ this(colorMapper, g2d, dpiFactor, null, 0, 0);
+ }
+
+ public UGraphicG2d(ColorMapper colorMapper, Graphics2D g2d, double dpiFactor, AffineTransformation affineTransform,
+ double dx, double dy) {
+ super(colorMapper, g2d);
+ this.hasAffineTransform = affineTransform != null;
+ this.dpiFactor = dpiFactor;
+ if (dpiFactor != 1.0) {
+ g2d.scale(dpiFactor, dpiFactor);
+ }
+ if (this.hasAffineTransform) {
+ if (dx != 0 || dy != 0) {
+ getGraphicObject().transform(AffineTransform.getTranslateInstance(dx, dy));
+ }
+ getGraphicObject().transform(affineTransform.getAffineTransform());
+ }
+ register(dpiFactor);
+ }
+
+ private void register(double dpiFactor) {
+ registerDriver(URectangle.class, new DriverRectangleG2d(dpiFactor, this));
+ if (this.hasAffineTransform || dpiFactor != 1.0) {
+ registerDriver(UText.class, new DriverTextAsPathG2d(this, TextBlockUtils.getFontRenderContext()));
+ } else {
+ registerDriver(UText.class, new DriverTextG2d(this));
+ }
+ registerDriver(ULine.class, new DriverLineG2d(dpiFactor));
+ registerDriver(UPixel.class, new DriverPixelG2d());
+ registerDriver(UPolygon.class, new DriverPolygonG2d(dpiFactor, this));
+ registerDriver(UEllipse.class, new DriverEllipseG2d(dpiFactor, this));
+ registerDriver(UImage.class, new DriverImageG2d(this));
+ registerDriver(DotPath.class, new DriverDotPathG2d(this));
+ registerDriver(UPath.class, new DriverPathG2d(dpiFactor));
+ registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterG2d());
+ }
+
+ public StringBounder getStringBounder() {
+ if (hasAffineTransform) {
+ return TextBlockUtils.getDummyStringBounder();
+ }
+ return StringBounderUtils.asStringBounder(getGraphicObject());
+ }
+
+ @Override
+ protected void beforeDraw() {
+ super.beforeDraw();
+ applyClip();
+ antiAliasing.apply(getGraphicObject());
+ }
+
+ private void applyClip() {
+ final UClip uclip = getClip();
+ if (uclip == null) {
+ getGraphicObject().setClip(null);
+ } else {
+ final Shape clip = new Rectangle2D.Double(uclip.getX(), uclip.getY(), uclip.getWidth(), uclip.getHeight());
+ getGraphicObject().setClip(clip);
+ }
+ }
+
+ protected final double getDpiFactor() {
+ return dpiFactor;
+ }
+
+ public void startUrl(Url url) {
+ urls.add(url);
+ allUrls.add(url);
+ }
+
+ public void closeAction() {
+ urls.remove(urls.size() - 1);
+ }
+
+ public void ensureVisible(double x, double y) {
+ for (Url u : urls) {
+ u.ensureVisible(x, y);
+ }
+ }
+
+ public BufferedImage getBufferedImage() {
+ return bufferedImage;
+ }
+
+ public void setBufferedImage(BufferedImage bufferedImage) {
+ this.bufferedImage = bufferedImage;
+ }
+
+ public Graphics2D getGraphics2D() {
+ return getGraphicObject();
+ }
+
+ public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
+ final BufferedImage im = getBufferedImage();
+ PngIO.write(im, os, metadata, dpi);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/HandJiggle.java b/src/net/sourceforge/plantuml/ugraphic/hand/HandJiggle.java
new file mode 100644
index 0000000..7a3b628
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/hand/HandJiggle.java
@@ -0,0 +1,152 @@
+/* ========================================================================
+ * 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.ugraphic.hand;
+
+import java.awt.geom.CubicCurve2D;
+import java.awt.geom.Point2D;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+
+public class HandJiggle {
+ private final Collection<Point2D> points = new ArrayList<Point2D>();
+
+ private double startX;
+ private double startY;
+ private final double defaultVariation;
+
+ public HandJiggle(double startX, double startY, double defaultVariation) {
+ this.startX = startX;
+ this.startY = startY;
+ this.defaultVariation = defaultVariation;
+ points.add(new Point2D.Double(startX, startY));
+ }
+
+ public HandJiggle(Point2D start, double defaultVariation) {
+ this(start.getX(), start.getY(), defaultVariation);
+ }
+
+ public void lineTo(Point2D end) {
+ lineTo(end.getX(), end.getY());
+ }
+
+ public void arcTo(double angle0, double angle1, double centerX, double centerY, double rx, double ry) {
+ lineTo(pointOnCircle(centerX, centerY, (angle0 + angle1) / 2, rx, ry));
+ lineTo(pointOnCircle(centerX, centerY, angle1, rx, ry));
+ }
+
+ private static Point2D pointOnCircle(double centerX, double centerY, double angle, double rx, double ry) {
+ final double x = centerX + Math.cos(angle) * rx;
+ final double y = centerY + Math.sin(angle) * ry;
+ return new Point2D.Double(x, y);
+
+ }
+
+ public void lineTo(final double endX, final double endY) {
+
+ final double diffX = Math.abs(endX - startX);
+ final double diffY = Math.abs(endY - startY);
+ final double distance = Math.sqrt(diffX * diffX + diffY * diffY);
+ if (distance < 0.001) {
+ return;
+ }
+
+ int segments = (int) Math.round(distance / 10);
+ double variation = defaultVariation;
+ if (segments < 5) {
+ segments = 5;
+ variation /= 3;
+ }
+
+ final double stepX = Math.signum(endX - startX) * diffX / segments;
+ final double stepY = Math.signum(endY - startY) * diffY / segments;
+
+ final double fx = diffX / distance;
+ final double fy = diffY / distance;
+
+ for (int s = 0; s < segments; s++) {
+ double x = stepX * s + startX;
+ double y = stepY * s + startY;
+
+ final double offset = (Math.random() - 0.5) * variation;
+ points.add(new Point2D.Double(x - offset * fy, y - offset * fx));
+ }
+ points.add(new Point2D.Double(endX, endY));
+
+ this.startX = endX;
+ this.startY = endY;
+ }
+
+ public void curveTo(CubicCurve2D curve) {
+ final double flatness = curve.getFlatness();
+ final double dist = curve.getP1().distance(curve.getP2());
+ if (flatness > 0.1 && dist > 20) {
+ final CubicCurve2D left = new CubicCurve2D.Double();
+ final CubicCurve2D right = new CubicCurve2D.Double();
+ curve.subdivide(left, right);
+ curveTo(left);
+ curveTo(right);
+ return;
+ }
+ lineTo(curve.getP2());
+ }
+
+ public UPolygon toUPolygon() {
+ final UPolygon result = new UPolygon();
+ for (Point2D p : points) {
+ result.addPoint(p.getX(), p.getY());
+ }
+ return result;
+ }
+
+ public UPath toUPath() {
+ UPath path = null;
+ for (Point2D p : points) {
+ if (path == null) {
+ path = new UPath();
+ path.moveTo(p);
+ } else {
+ path.lineTo(p);
+ }
+ }
+ if (path == null) {
+ throw new IllegalStateException();
+ }
+ return path;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/UDotPathHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/UDotPathHand.java
new file mode 100644
index 0000000..739868e
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/hand/UDotPathHand.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.ugraphic.hand;
+
+import java.awt.geom.CubicCurve2D;
+
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.ugraphic.UPath;
+
+public class UDotPathHand {
+
+ private final UPath path;
+
+ public UDotPathHand(DotPath source) {
+
+ final HandJiggle jiggle = new HandJiggle(source.getStartPoint(), 2.0);
+ for (CubicCurve2D curve : source.getBeziers()) {
+ jiggle.curveTo(curve);
+ }
+
+ this.path = jiggle.toUPath();
+ }
+
+ public UPath getHanddrawn() {
+ return this.path;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/UEllipseHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/UEllipseHand.java
new file mode 100644
index 0000000..4ef0bca
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/hand/UEllipseHand.java
@@ -0,0 +1,90 @@
+/* ========================================================================
+ * 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.ugraphic.hand;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.Shadowable;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+
+public class UEllipseHand {
+
+ private Shadowable poly;
+
+ public UEllipseHand(UEllipse source) {
+
+ if (source.getStart() != 0 || source.getExtend() != 0) {
+ this.poly = source;
+ return;
+ }
+ poly = new UPolygon();
+ final double width = source.getWidth();
+ final double height = source.getHeight();
+ double angle = 0;
+ if (width == height) {
+ while (angle < Math.PI * 2) {
+ angle += (10 + Math.random() * 10) * Math.PI / 180;
+ final double variation = 1 + (Math.random() - 0.5) / 8;
+ final double x = width / 2 + Math.cos(angle) * width * variation / 2;
+ final double y = height / 2 + Math.sin(angle) * height * variation / 2;
+ // final Point2D.Double p = new Point2D.Double(x, y);
+ ((UPolygon) poly).addPoint(x, y);
+ }
+ } else {
+ while (angle < Math.PI * 2) {
+ angle += Math.PI / 20;
+ final Point2D pt = getPoint(width, height, angle);
+ ((UPolygon) poly).addPoint(pt.getX(), pt.getY());
+ }
+
+ }
+
+ this.poly.setDeltaShadow(source.getDeltaShadow());
+ }
+
+ private Point2D getPoint(double width, double height, double angle) {
+ final double x = width / 2 + Math.cos(angle) * width / 2;
+ final double y = height / 2 + Math.sin(angle) * height / 2;
+ final double variation = (Math.random() - 0.5) / 50;
+ return new Point2D.Double(x + variation * width, y + variation * height);
+
+ }
+
+ public Shadowable getHanddrawn() {
+ return this.poly;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/UGraphicHandwritten.java b/src/net/sourceforge/plantuml/ugraphic/hand/UGraphicHandwritten.java
new file mode 100644
index 0000000..a85c35f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/hand/UGraphicHandwritten.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.ugraphic.hand;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UChange;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class UGraphicHandwritten implements UGraphic {
+
+ private final UGraphic ug;
+
+ public UGraphicHandwritten(UGraphic ug) {
+ this.ug = ug;
+ }
+
+ public StringBounder getStringBounder() {
+ return ug.getStringBounder();
+ }
+
+ public UParam getParam() {
+ return ug.getParam();
+ }
+
+ public void draw(UShape shape) {
+ // http://www.ufonts.com/fonts/felt-tip-roman.html
+ // http://webdesignledger.com/freebies/20-amazing-free-handwritten-fonts-for-your-designs
+ if (shape instanceof ULine) {
+ drawHand((ULine) shape);
+ } else if (shape instanceof URectangle) {
+ drawHand((URectangle) shape);
+ } else if (shape instanceof UPolygon) {
+ drawHand((UPolygon) shape);
+ } else if (shape instanceof UEllipse) {
+ drawHand((UEllipse) shape);
+ } else if (shape instanceof DotPath) {
+ drawHand((DotPath) shape);
+ } else if (shape instanceof UPath) {
+ drawHand((UPath) shape);
+ } else {
+ ug.draw(shape);
+ }
+ }
+
+ private void drawHand(UPath shape) {
+ final UPathHand uline = new UPathHand(shape);
+ ug.draw(uline.getHanddrawn());
+ }
+
+ private void drawHand(DotPath shape) {
+ final UDotPathHand uline = new UDotPathHand(shape);
+ ug.draw(uline.getHanddrawn());
+ }
+
+ private void drawHand(UPolygon shape) {
+ final UPolygonHand hand = new UPolygonHand(shape);
+ ug.draw(hand.getHanddrawn());
+ }
+
+ private void drawHand(URectangle shape) {
+ final URectangleHand hand = new URectangleHand(shape);
+ ug.draw(hand.getHanddrawn());
+ }
+
+ private void drawHand(ULine shape) {
+ final ULineHand uline = new ULineHand(shape);
+ ug.draw(uline.getHanddrawn());
+ }
+
+ private void drawHand(UEllipse shape) {
+ final UEllipseHand uline = new UEllipseHand(shape);
+ ug.draw(uline.getHanddrawn());
+ }
+
+ public UGraphic apply(UChange change) {
+ return new UGraphicHandwritten(ug.apply(change));
+ }
+
+ public ColorMapper getColorMapper() {
+ return ug.getColorMapper();
+ }
+
+ public void startUrl(Url url) {
+ ug.startUrl(url);
+ }
+
+ public void closeAction() {
+ ug.closeAction();
+ }
+
+ public void flushUg() {
+ ug.flushUg();
+ }
+
+ public boolean isSpecialTxt() {
+ return false;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/ULineHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/ULineHand.java
new file mode 100644
index 0000000..85f2915
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/hand/ULineHand.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.ugraphic.hand;
+
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+
+public class ULineHand {
+
+ private UPath path;
+
+ public ULineHand(ULine line) {
+ final double endX = line.getDX();
+ final double endY = line.getDY();
+ final HandJiggle jiggle = new HandJiggle(0, 0, 2.0);
+ jiggle.lineTo(endX, endY);
+
+ this.path = jiggle.toUPath();
+
+ }
+
+ public UPath getHanddrawn() {
+ return this.path;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/UPathHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/UPathHand.java
new file mode 100644
index 0000000..4525aff
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/hand/UPathHand.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.ugraphic.hand;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.USegment;
+import net.sourceforge.plantuml.ugraphic.USegmentType;
+
+public class UPathHand {
+
+ private final UPath path;
+ private final double defaultVariation = 4.0;
+
+ public UPathHand(UPath source) {
+
+ final UPath jigglePath = new UPath();
+
+ Point2D last = new Point2D.Double();
+
+ for (USegment segment : source) {
+ final USegmentType type = segment.getSegmentType();
+ if (type == USegmentType.SEG_MOVETO) {
+ final double x = segment.getCoord()[0];
+ final double y = segment.getCoord()[1];
+ jigglePath.moveTo(x, y);
+ last = new Point2D.Double(x, y);
+
+ } else if (type == USegmentType.SEG_LINETO) {
+ final double x = segment.getCoord()[0];
+ final double y = segment.getCoord()[1];
+ final HandJiggle jiggle = new HandJiggle(last.getX(), last.getY(), defaultVariation);
+ jiggle.lineTo(x, y);
+ for (USegment seg2 : jiggle.toUPath()) {
+ if (seg2.getSegmentType() == USegmentType.SEG_LINETO) {
+ jigglePath.lineTo(seg2.getCoord()[0], seg2.getCoord()[1]);
+ }
+ }
+ last = new Point2D.Double(x, y);
+ } else {
+ this.path = source;
+ return;
+ }
+ }
+ this.path = jigglePath;
+ }
+
+ public UPath getHanddrawn() {
+ return this.path;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/UPolygonHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/UPolygonHand.java
new file mode 100644
index 0000000..874fa40
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/hand/UPolygonHand.java
@@ -0,0 +1,67 @@
+/* ========================================================================
+ * 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.ugraphic.hand;
+
+import java.awt.geom.Point2D;
+import java.util.List;
+
+import net.sourceforge.plantuml.ugraphic.Shadowable;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+
+public class UPolygonHand {
+
+ private final UPolygon poly;
+
+ public UPolygonHand(UPolygon source) {
+ final List<Point2D.Double> pt = source.getPoints();
+ if (pt.size() == 0) {
+ poly = new UPolygon();
+ return;
+ }
+ final HandJiggle jiggle = new HandJiggle(pt.get(0), 1.5);
+ for (int i = 1; i < pt.size(); i++) {
+ jiggle.lineTo(pt.get(i));
+ }
+ jiggle.lineTo(pt.get(0));
+
+ this.poly = jiggle.toUPolygon();
+ this.poly.setDeltaShadow(source.getDeltaShadow());
+ }
+
+ public Shadowable getHanddrawn() {
+ return this.poly;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/URectangleHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/URectangleHand.java
new file mode 100644
index 0000000..4508cbb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/hand/URectangleHand.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.ugraphic.hand;
+
+import net.sourceforge.plantuml.ugraphic.Shadowable;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+
+public class URectangleHand {
+
+ final private UPolygon poly;
+
+ public URectangleHand(URectangle rectangle) {
+ final double width = rectangle.getWidth();
+ final double height = rectangle.getHeight();
+ final HandJiggle jiggle;
+ final double rx = Math.min(rectangle.getRx() / 2, width / 2);
+ final double ry = Math.min(rectangle.getRy() / 2, height / 2);
+ System.err.println("rx=" + rx + " ry=" + ry);
+ if (rx == 0 && ry == 0) {
+ jiggle = new HandJiggle(0, 0, 1.5);
+ jiggle.lineTo(width, 0);
+ jiggle.lineTo(width, height);
+ jiggle.lineTo(0, height);
+ jiggle.lineTo(0, 0);
+ } else {
+ jiggle = new HandJiggle(rx, 0, 1.5);
+ jiggle.lineTo(width - rx, 0);
+ jiggle.arcTo(-Math.PI / 2, 0, width - rx, ry, rx, ry);
+ jiggle.lineTo(width, height - ry);
+ jiggle.arcTo(0, Math.PI / 2, width - rx, height - ry, rx, ry);
+ jiggle.lineTo(rx, height);
+ jiggle.arcTo(Math.PI / 2, Math.PI, rx, height - ry, rx, ry);
+ jiggle.lineTo(0, ry);
+ jiggle.arcTo(Math.PI, 3 * Math.PI / 2, rx, ry, rx, ry);
+ }
+
+ this.poly = jiggle.toUPolygon();
+ this.poly.setDeltaShadow(rectangle.getDeltaShadow());
+ }
+
+ public Shadowable getHanddrawn() {
+ return this.poly;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/html5/DriverLineHtml5.java b/src/net/sourceforge/plantuml/ugraphic/html5/DriverLineHtml5.java
new file mode 100644
index 0000000..c629b37
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/html5/DriverLineHtml5.java
@@ -0,0 +1,82 @@
+/* ========================================================================
+ * 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.ugraphic.html5;
+
+import java.awt.geom.Line2D;
+
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DriverLineHtml5 implements UDriver<Html5Drawer> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverLineHtml5(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Html5Drawer html) {
+ final ULine shape = (ULine) ushape;
+
+ double x2 = x + shape.getDX();
+ double y2 = y + shape.getDY();
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ final Line2D.Double line = clip.getClippedLine(new Line2D.Double(x, y, x2, y2));
+ if (line == null) {
+ return;
+ }
+ x = line.x1;
+ y = line.y1;
+ x2 = line.x2;
+ y2 = line.y2;
+ }
+
+ final String color = param.getColor() == null ? null : StringUtils.getAsHtml(mapper.getMappedColor(param
+ .getColor()));
+ html.setStrokeColor(color);
+
+// html.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDashVisible(), param.getStroke()
+// .getDashSpace());
+ html.htmlLine(x, y, x2, y2, 0);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/html5/DriverNopHtml5.java b/src/net/sourceforge/plantuml/ugraphic/html5/DriverNopHtml5.java
new file mode 100644
index 0000000..b0ec476
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/html5/DriverNopHtml5.java
@@ -0,0 +1,46 @@
+/* ========================================================================
+ * 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.ugraphic.html5;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverNopHtml5 implements UDriver<Html5Drawer> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Html5Drawer html) {
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/html5/DriverRectangleHtml5.java b/src/net/sourceforge/plantuml/ugraphic/html5/DriverRectangleHtml5.java
new file mode 100644
index 0000000..8cf3095
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/html5/DriverRectangleHtml5.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.ugraphic.html5;
+
+import java.awt.geom.Rectangle2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DriverRectangleHtml5 implements UDriver<Html5Drawer> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverRectangleHtml5(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Html5Drawer html) {
+ final URectangle rect = (URectangle) ushape;
+
+ double width = rect.getWidth();
+ double height = rect.getHeight();
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ final Rectangle2D.Double r = clip.getClippedRectangle(new Rectangle2D.Double(x, y, width, height));
+ x = r.x;
+ y = r.y;
+ width = r.width;
+ height = r.height;
+ }
+
+ final double rx = rect.getRx();
+ final double ry = rect.getRy();
+
+// // Shadow
+// if (rect.getDeltaShadow() != 0) {
+// eps.epsRectangleShadow(x, y, width, height, rx / 2, ry / 2, rect.getDeltaShadow());
+// }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+// eps.setStrokeColor(mapper.getMappedColor(param.getColor()));
+// eps.epsRectangle(x, y, width, height, rx / 2, ry / 2, (HtmlColorGradient) back, mapper);
+ } else {
+ final String color = param.getColor() == null ? null : StringUtils.getAsHtml(mapper.getMappedColor(param
+ .getColor()));
+ final String backcolor = param.getColor() == null ? null : StringUtils.getAsHtml(mapper.getMappedColor(param
+ .getBackcolor()));
+
+ html.setStrokeColor(color);
+ html.setFillColor(backcolor);
+// eps.setStrokeWidth("" + param.getStroke().getThickness(), param.getStroke().getDashVisible(), param
+// .getStroke().getDashSpace());
+ html.htmlRectangle(x, y, width, height, rx / 2, ry / 2);
+ }
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/html5/Html5Drawer.java b/src/net/sourceforge/plantuml/ugraphic/html5/Html5Drawer.java
new file mode 100644
index 0000000..5b9e76d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/html5/Html5Drawer.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.ugraphic.html5;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.plantuml.eps.EpsGraphics;
+
+public class Html5Drawer {
+
+ private int maxX = 10;
+ private int maxY = 10;
+ private String strokeStyle = "black";
+ private String fillStyle = "black";
+
+ private List<String> data = new ArrayList<String>();
+
+ final protected void ensureVisible(double x, double y) {
+ if (x > maxX) {
+ maxX = (int) (x + 1);
+ }
+ if (y > maxY) {
+ maxY = (int) (y + 1);
+ }
+ }
+
+ private static String format(double x) {
+ return EpsGraphics.format(x);
+ }
+
+ public final void setStrokeColor(String stroke) {
+ this.strokeStyle = stroke;
+ }
+
+ public final void setFillColor(String fill) {
+ this.fillStyle = fill;
+ }
+
+ public String generateHtmlCode() {
+ final StringBuilder sb = new StringBuilder();
+ ap(sb, "<html>");
+ ap(sb, "<canvas id=\"demo\" width=\"700\" height=\"350\">");
+ ap(sb, "</canvas>");
+ ap(sb, "</html>");
+ ap(sb, "<script>");
+ ap(sb, "window.addEventListener('load', function () {");
+ ap(sb, "var elem = document.getElementById('demo');");
+ ap(sb, "if (!elem || !elem.getContext) { return;}");
+ ap(sb, "var ctx = elem.getContext('2d');");
+ ap(sb, "if (!ctx) { return;}");
+ // ap(sb, "ctx.fillStyle = 'green';");
+ // ap(sb, "ctx.fillRect(30, 30, 55, 50);");
+ for (String s : data) {
+ ap(sb, s);
+ }
+ ap(sb, "}, false);");
+ ap(sb, "</script>");
+ ap(sb, "</html>");
+ return sb.toString();
+ }
+
+ private void ap(StringBuilder sb, String s) {
+ sb.append(s);
+ sb.append('\n');
+ }
+
+ public void htmlRectangle(double x, double y, double width, double height, double rx, double ry) {
+ ensureVisible(x, y);
+ ensureVisible(x + width, y + height);
+ // if (fillcolor != null) {
+ // appendColor(fillcolor);
+ // epsRectangleInternal(x, y, width, height, rx, ry, true);
+ // append("closepath eofill", true);
+ // }
+ //
+ // if (color != null) {
+ // append(strokeWidth + " setlinewidth", true);
+ // appendColor(color);
+ // epsRectangleInternal(x, y, width, height, rx, ry, false);
+ // append("closepath stroke", true);
+ // }
+ data.add("//RECT");
+ data.add("ctx.strokeStyle='" + strokeStyle + "';");
+ data.add("ctx.fillStyle='" + fillStyle + "';");
+ data.add("ctx.rect(" + format(x) + "," + format(y) + "," + format(width) + "," + format(height) + ");");
+ data.add("ctx.fill();");
+ data.add("ctx.stroke();");
+ }
+
+ public void htmlLine(double x1, double y1, double x2, double y2, double deltaShadow) {
+ ensureVisible(x1 + 2 * deltaShadow, y1 + 2 * deltaShadow);
+ ensureVisible(x2 + 2 * deltaShadow, y2 + 2 * deltaShadow);
+ data.add("ctx.strokeStyle='" + strokeStyle + "';");
+ data.add("ctx.beginPath();");
+ data.add("ctx.moveTo(" + format(x1) + "," + format(y1) + ");");
+ data.add("ctx.lineTo(" + format(x2) + "," + format(y2) + ");");
+ data.add("ctx.stroke();");
+ data.add("ctx.closePath();");
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/html5/UGraphicHtml5.java b/src/net/sourceforge/plantuml/ugraphic/html5/UGraphicHtml5.java
new file mode 100644
index 0000000..37b94f2
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/html5/UGraphicHtml5.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.ugraphic.html5;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
+import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class UGraphicHtml5 extends AbstractUGraphic<Html5Drawer> implements ClipContainer, UGraphic2 {
+
+ private final StringBounder stringBounder;
+
+ @Override
+ protected AbstractCommonUGraphic copyUGraphic() {
+ return this;
+ }
+
+ public UGraphicHtml5(ColorMapper colorMapper) {
+ super(colorMapper, new Html5Drawer());
+ stringBounder = TextBlockUtils.getDummyStringBounder();
+ registerDriver(URectangle.class, new DriverRectangleHtml5(this));
+ // registerDriver(UText.class, new DriverTextEps(imDummy, this, strategy));
+ registerDriver(UText.class, new DriverNopHtml5());
+ registerDriver(ULine.class, new DriverLineHtml5(this));
+ // registerDriver(UPolygon.class, new DriverPolygonEps(this));
+ registerDriver(UPolygon.class, new DriverNopHtml5());
+ // registerDriver(UEllipse.class, new DriverEllipseEps());
+ // registerDriver(UImage.class, new DriverImageEps());
+ // registerDriver(UPath.class, new DriverPathEps());
+ // registerDriver(DotPath.class, new DriverDotPathEps());
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public void startUrl(Url url) {
+ // throw new UnsupportedOperationException();
+
+ }
+
+ public void closeAction() {
+ // throw new UnsupportedOperationException();
+
+ }
+
+ // public void close() {
+ // getEpsGraphics().close();
+ // }
+
+ public String generateHtmlCode() {
+ return getGraphicObject().generateHtmlCode();
+ }
+
+ public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
+ os.write(generateHtmlCode().getBytes());
+ }
+
+ // public void centerChar(double x, double y, char c, UFont font) {
+ // final UnusedSpace unusedSpace = UnusedSpace.getUnusedSpace(font, c);
+ //
+ // final double xpos = x - unusedSpace.getCenterX() - 0.5;
+ // final double ypos = y - unusedSpace.getCenterY() - 0.5;
+ //
+ // final TextLayout t = new TextLayout("" + c, font.getFont(), imDummy.getFontRenderContext());
+ // getGraphicObject().setStrokeColor(getColorMapper().getMappedColor(getParam().getColor()));
+ // DriverTextEps.drawPathIterator(getGraphicObject(), xpos + getTranslateX(), ypos + getTranslateY(), t
+ // .getOutline(null).getPathIterator(null));
+ //
+ // }
+ //
+ // static public String getEpsString(ColorMapper colorMapper, EpsStrategy epsStrategy, UDrawable udrawable)
+ // throws IOException {
+ // final UGraphicHtml5 ug = new UGraphicHtml5(colorMapper, epsStrategy);
+ // udrawable.drawU(ug);
+ // return ug.getEPSCode();
+ // }
+ //
+ // static public void copyEpsToFile(ColorMapper colorMapper, UDrawable udrawable, File f) throws IOException {
+ // final PrintWriter pw = new PrintWriter(f);
+ // final EpsStrategy epsStrategy = EpsStrategy.getDefault2();
+ // pw.print(UGraphicHtml5.getEpsString(colorMapper, epsStrategy, udrawable));
+ // pw.close();
+ // }
+ //
+ // public void setAntiAliasing(boolean trueForOn) {
+ // }
+ //
+ // public void startUrl(String url, String tooltip) {
+ // getGraphicObject().openLink(url);
+ // }
+ //
+ // public void closeAction() {
+ // getGraphicObject().closeLink();
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverCenteredCharacterSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverCenteredCharacterSvg.java
new file mode 100644
index 0000000..0cf7fce
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverCenteredCharacterSvg.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.ugraphic.svg;
+
+import java.awt.font.TextLayout;
+
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UnusedSpace;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DriverCenteredCharacterSvg implements UDriver<SvgGraphics> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+ final UCenteredCharacter characterCircled = (UCenteredCharacter) ushape;
+ final char c = characterCircled.getChar();
+ final UFont font = characterCircled.getFont();
+ final UnusedSpace unusedSpace = UnusedSpace.getUnusedSpace(font, c);
+
+ final double xpos = x - unusedSpace.getCenterX() - 0.5;
+ final double ypos = y - unusedSpace.getCenterY() - 0.5;
+
+ final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext());
+ svg.setStrokeColor(StringUtils.getAsHtml(mapper.getMappedColor(param.getColor())));
+ DriverTextAsPathSvg.drawPathIterator(svg, xpos, ypos, t.getOutline(null).getPathIterator(null));
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverDotPathSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverDotPathSvg.java
new file mode 100644
index 0000000..28659d1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverDotPathSvg.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.ugraphic.svg;
+
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DriverDotPathSvg implements UDriver<SvgGraphics> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+ final DotPath shape = (DotPath) ushape;
+ // DriverLineG2d.manageStroke(param, g2d);
+
+ if (param.getColor() != null) {
+ final String color = StringUtils.getAsSvg(mapper, param.getColor());
+ svg.setStrokeColor(color);
+ svg.setFillColor(null);
+ svg.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDasharraySvg());
+
+ svg.svgPath(x, y, shape.toUPath(), 0);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverEllipseSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverEllipseSvg.java
new file mode 100644
index 0000000..399d984
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverEllipseSvg.java
@@ -0,0 +1,108 @@
+/* ========================================================================
+ * 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.ugraphic.svg;
+
+import net.sourceforge.plantuml.StringUtils;
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.graphic.HtmlColorTransparent;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverEllipseSvg implements UDriver<SvgGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverEllipseSvg(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+ final UEllipse shape = (UEllipse) ushape;
+ final double width = shape.getWidth();
+ final double height = shape.getHeight();
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ if (clip.isInside(x, y) == false) {
+ return;
+ }
+ if (clip.isInside(x + width, y + height) == false) {
+ return;
+ }
+ }
+
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final String id = svg.createSvgGradient(StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor1())),
+ StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor2())), gr.getPolicy());
+ svg.setFillColor("url(#" + id + ")");
+ } else if (back == null || back instanceof HtmlColorTransparent) {
+ svg.setFillColor("none");
+ } else {
+ final String backcolor = StringUtils.getAsSvg(mapper, back);
+ svg.setFillColor(backcolor);
+ }
+ final String color = StringUtils.getAsSvg(mapper, param.getColor());
+ svg.setStrokeColor(color);
+ svg.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDasharraySvg());
+
+ double start = shape.getStart();
+ final double extend = shape.getExtend();
+ final double cx = x + width / 2;
+ final double cy = y + height / 2;
+ if (start == 0 && extend == 0) {
+ svg.svgEllipse(cx, cy, width / 2, height / 2, shape.getDeltaShadow());
+ } else {
+ // http://www.itk.ilstu.edu/faculty/javila/SVG/SVG_drawing1/elliptical_curve.htm
+ start = start + 90;
+ final double x1 = cx + Math.sin(start * Math.PI / 180.) * width / 2;
+ final double y1 = cy + Math.cos(start * Math.PI / 180.) * height / 2;
+ final double x2 = cx + Math.sin((start + extend) * Math.PI / 180.) * width / 2;
+ final double y2 = cy + Math.cos((start + extend) * Math.PI / 180.) * height / 2;
+ // svg.svgEllipse(x1, y1, 1, 1, 0);
+ // svg.svgEllipse(x2, y2, 1, 1, 0);
+ svg.svgArcEllipse(width / 2, height / 2, x1, y1, x2, y2);
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverImagePng.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverImagePng.java
new file mode 100644
index 0000000..74836d1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverImagePng.java
@@ -0,0 +1,76 @@
+/* ========================================================================
+ * 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.ugraphic.svg;
+
+import java.io.IOException;
+
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverImagePng implements UDriver<SvgGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverImagePng(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+
+ final UImage image = (UImage) ushape;
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ if (clip.isInside(x, y) == false) {
+ return;
+ }
+ if (clip.isInside(x + image.getWidth(), y + image.getHeight()) == false) {
+ return;
+ }
+ }
+
+ try {
+ svg.svgImage(image.getImage(), x, y);
+ } catch (IOException e) {
+ Log.error("Error in svg for image " + e);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverImageSvgSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverImageSvgSvg.java
new file mode 100644
index 0000000..c02c31d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverImageSvgSvg.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.ugraphic.svg;
+
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UImageSvg;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverImageSvgSvg implements UDriver<SvgGraphics> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+ final UImageSvg image = (UImageSvg) ushape;
+ svg.svgImage(image.getSvg(), x, y);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverLineSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverLineSvg.java
new file mode 100644
index 0000000..2007978
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverLineSvg.java
@@ -0,0 +1,87 @@
+/* ========================================================================
+ * 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.ugraphic.svg;
+
+import java.awt.geom.Line2D;
+
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DriverLineSvg implements UDriver<SvgGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverLineSvg(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+ final ULine shape = (ULine) ushape;
+
+ double x2 = x + shape.getDX();
+ double y2 = y + shape.getDY();
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ final Line2D.Double line = clip.getClippedLine(new Line2D.Double(x, y, x2, y2));
+ if (line == null) {
+ return;
+ }
+ x = line.x1;
+ y = line.y1;
+ x2 = line.x2;
+ y2 = line.y2;
+ }
+
+ // // Shadow
+ // if (shape.getDeltaShadow() != 0) {
+ // svg.svgLineShadow(x, y, x2, y2, shape.getDeltaShadow());
+ // }
+
+ // svg.setStroke(new BasicStroke((float)
+ // param.getStroke().getThickness()));
+ final String color = StringUtils.getAsSvg(mapper, param.getColor());
+ svg.setStrokeColor(color);
+ svg.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDasharraySvg());
+ svg.svgLine(x, y, x2, y2, shape.getDeltaShadow());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverPathSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverPathSvg.java
new file mode 100644
index 0000000..586f691
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverPathSvg.java
@@ -0,0 +1,83 @@
+/* ========================================================================
+ * 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.ugraphic.svg;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.g2d.DriverShadowedG2d;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DriverPathSvg extends DriverShadowedG2d implements UDriver<SvgGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverPathSvg(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+ final UPath shape = (UPath) ushape;
+
+ final String color = StringUtils.getAsSvg(mapper, param.getColor());
+ if (shape.isOpenIconic()) {
+ svg.setFillColor(color);
+ svg.setStrokeColor("");
+ svg.setStrokeWidth(0, "");
+ } else {
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final String id = svg.createSvgGradient(StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor1())),
+ StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor2())), gr.getPolicy());
+ svg.setFillColor("url(#" + id + ")");
+ } else {
+ final String backcolor = StringUtils.getAsSvg(mapper, back);
+ svg.setFillColor(backcolor);
+ }
+ svg.setStrokeColor(color);
+ svg.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDasharraySvg());
+ }
+
+ svg.svgPath(x, y, shape, shape.getDeltaShadow());
+
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverPolygonSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverPolygonSvg.java
new file mode 100644
index 0000000..a3db97b
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverPolygonSvg.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.ugraphic.svg;
+
+import java.awt.geom.Point2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DriverPolygonSvg implements UDriver<SvgGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverPolygonSvg(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+ final UPolygon shape = (UPolygon) ushape;
+
+ final double points[] = shape.getPointArray(x, y);
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ for (int j = 0; j < points.length; j += 2) {
+ if (clip.isInside(points[j], points[j + 1]) == false) {
+ return;
+ }
+ }
+ }
+
+ final String color = StringUtils.getAsSvg(mapper, param.getColor());
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final String id = svg.createSvgGradient(StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor1())),
+ StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor2())), gr.getPolicy());
+ svg.setFillColor("url(#" + id + ")");
+ } else {
+ final String backcolorString = StringUtils.getAsSvg(mapper, back);
+ svg.setFillColor(backcolorString);
+ }
+
+ svg.setStrokeColor(color);
+ svg.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDasharraySvg());
+
+ svg.svgPolygon(shape.getDeltaShadow(), points);
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverRectangleSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverRectangleSvg.java
new file mode 100644
index 0000000..67bfece
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverRectangleSvg.java
@@ -0,0 +1,96 @@
+/* ========================================================================
+ * 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.ugraphic.svg;
+
+import java.awt.geom.Rectangle2D;
+
+import net.sourceforge.plantuml.graphic.HtmlColor;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DriverRectangleSvg implements UDriver<SvgGraphics> {
+
+ private final ClipContainer clipContainer;
+
+ public DriverRectangleSvg(ClipContainer clipContainer) {
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+ final URectangle rect = (URectangle) ushape;
+
+ final double rx = rect.getRx();
+ final double ry = rect.getRy();
+ double width = rect.getWidth();
+ double height = rect.getHeight();
+
+ final String color = StringUtils.getAsSvg(mapper, param.getColor());
+ final HtmlColor back = param.getBackcolor();
+ if (back instanceof HtmlColorGradient) {
+ final HtmlColorGradient gr = (HtmlColorGradient) back;
+ final String id = svg.createSvgGradient(StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor1())),
+ StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor2())), gr.getPolicy());
+ svg.setFillColor("url(#" + id + ")");
+ svg.setStrokeColor(color);
+ } else {
+ final String backcolor = StringUtils.getAsSvg(mapper, back);
+ svg.setFillColor(backcolor);
+ svg.setStrokeColor(color);
+ }
+
+ svg.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDasharraySvg());
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null) {
+ final Rectangle2D.Double r = clip.getClippedRectangle(new Rectangle2D.Double(x, y, width, height));
+ x = r.x;
+ y = r.y;
+ width = r.width;
+ height = r.height;
+ if (height <= 0) {
+ return;
+ }
+ }
+ svg.svgRectangle(x, y, width, height, rx / 2, ry / 2, rect.getDeltaShadow());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextAsPathSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextAsPathSvg.java
new file mode 100644
index 0000000..878bb17
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextAsPathSvg.java
@@ -0,0 +1,105 @@
+/* ========================================================================
+ * 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.ugraphic.svg;
+
+import java.awt.font.FontRenderContext;
+import java.awt.font.TextLayout;
+import java.awt.geom.PathIterator;
+
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class DriverTextAsPathSvg implements UDriver<SvgGraphics> {
+
+ private final FontRenderContext fontRenderContext;
+ private final ClipContainer clipContainer;
+
+ public DriverTextAsPathSvg(FontRenderContext fontRenderContext, ClipContainer clipContainer) {
+ this.fontRenderContext = fontRenderContext;
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null && clip.isInside(x, y) == false) {
+ return;
+ }
+
+ final UText shape = (UText) ushape;
+ final FontConfiguration fontConfiguration = shape.getFontConfiguration();
+ final UFont font = fontConfiguration.getFont();
+
+ final TextLayout t = new TextLayout(shape.getText(), font.getFont(), fontRenderContext);
+ drawPathIterator(svg, x, y, t.getOutline(null).getPathIterator(null));
+
+ }
+
+ static void drawPathIterator(SvgGraphics svg, double x, double y, PathIterator path) {
+
+ svg.newpath();
+ final double coord[] = new double[6];
+ while (path.isDone() == false) {
+ final int code = path.currentSegment(coord);
+ if (code == PathIterator.SEG_MOVETO) {
+ svg.moveto(coord[0] + x, coord[1] + y);
+ } else if (code == PathIterator.SEG_LINETO) {
+ svg.lineto(coord[0] + x, coord[1] + y);
+ } else if (code == PathIterator.SEG_CLOSE) {
+ svg.closepath();
+ } else if (code == PathIterator.SEG_CUBICTO) {
+ svg.curveto(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y, coord[4] + x, coord[5] + y);
+ } else if (code == PathIterator.SEG_QUADTO) {
+ svg.quadto(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y);
+ } else {
+ throw new UnsupportedOperationException("code=" + code);
+ }
+
+ path.next();
+ }
+
+ svg.fill(path.getWindingRule());
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java
new file mode 100644
index 0000000..e5816b4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/DriverTextSvg.java
@@ -0,0 +1,103 @@
+/* ========================================================================
+ * 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.ugraphic.svg;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.FontStyle;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UClip;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UFontContext;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UText;
+import net.sourceforge.plantuml.StringUtils;
+
+public class DriverTextSvg implements UDriver<SvgGraphics> {
+
+ private final StringBounder stringBounder;
+ private final ClipContainer clipContainer;
+
+ public DriverTextSvg(StringBounder stringBounder, ClipContainer clipContainer) {
+ this.stringBounder = stringBounder;
+ this.clipContainer = clipContainer;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
+
+ final UClip clip = clipContainer.getClip();
+ if (clip != null && clip.isInside(x, y) == false) {
+ return;
+ }
+
+ final UText shape = (UText) ushape;
+ final FontConfiguration fontConfiguration = shape.getFontConfiguration();
+ final UFont font = fontConfiguration.getFont();
+ String fontWeight = null;
+ if (fontConfiguration.containsStyle(FontStyle.BOLD) || font.isBold()) {
+ fontWeight = "bold";
+ }
+ String fontStyle = null;
+ if (fontConfiguration.containsStyle(FontStyle.ITALIC) || font.isItalic()) {
+ fontStyle = "italic";
+ }
+ String textDecoration = null;
+ if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
+ textDecoration = "underline";
+ } else if (fontConfiguration.containsStyle(FontStyle.STRIKE)) {
+ textDecoration = "line-through";
+ }
+
+ svg.setFillColor(StringUtils.getAsHtml(mapper.getMappedColor(fontConfiguration.getColor())));
+ String text = shape.getText();
+ if (text.startsWith(" ")) {
+ final double space = stringBounder.calculateDimension(font, " ").getWidth();
+ while (text.startsWith(" ")) {
+ x += space;
+ text = text.substring(1);
+ }
+ }
+ text = text.trim();
+ final Dimension2D dim = stringBounder.calculateDimension(font, text);
+ svg.text(text, x, y, font.getFamily(UFontContext.SVG), font.getSize(), fontWeight, fontStyle, textDecoration,
+ dim.getWidth(), fontConfiguration.getAttributes());
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/svg/UGraphicSvg.java b/src/net/sourceforge/plantuml/ugraphic/svg/UGraphicSvg.java
new file mode 100644
index 0000000..2ce5faf
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/svg/UGraphicSvg.java
@@ -0,0 +1,174 @@
+/* ========================================================================
+ * 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.ugraphic.svg;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.xml.transform.TransformerException;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.graphic.HtmlColorGradient;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.svg.SvgGraphics;
+import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
+import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UImageSvg;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipContainer, UGraphic2 {
+
+ private final StringBounder stringBounder;
+ private final boolean textAsPath2;
+
+ @Override
+ protected AbstractCommonUGraphic copyUGraphic() {
+ return new UGraphicSvg(this);
+ }
+
+ private UGraphicSvg(UGraphicSvg other) {
+ super(other);
+ this.stringBounder = other.stringBounder;
+ this.textAsPath2 = other.textAsPath2;
+ register();
+ }
+
+ public UGraphicSvg(ColorMapper colorMapper, String backcolor, boolean textAsPath, double scale) {
+ this(colorMapper, new SvgGraphics(backcolor, scale), textAsPath);
+ }
+
+ public UGraphicSvg(ColorMapper colorMapper, boolean textAsPath, double scale) {
+ this(colorMapper, new SvgGraphics(scale), textAsPath);
+ }
+
+ public UGraphicSvg(ColorMapper mapper, HtmlColorGradient gr, boolean textAsPath, double scale) {
+ this(mapper, new SvgGraphics(scale), textAsPath);
+
+ final SvgGraphics svg = getGraphicObject();
+ svg.paintBackcolorGradient(mapper, gr);
+ }
+
+ @Override
+ protected boolean manageHiddenAutomatically() {
+ return false;
+ }
+
+ @Override
+ protected void beforeDraw() {
+ getGraphicObject().setHidden(getParam().isHidden());
+ }
+
+ @Override
+ protected void afterDraw() {
+ getGraphicObject().setHidden(false);
+ }
+
+ private UGraphicSvg(ColorMapper colorMapper, SvgGraphics svg, boolean textAsPath) {
+ super(colorMapper, svg);
+ stringBounder = TextBlockUtils.getDummyStringBounder();
+ this.textAsPath2 = textAsPath;
+ register();
+ }
+
+ private void register() {
+ registerDriver(URectangle.class, new DriverRectangleSvg(this));
+ if (textAsPath2) {
+ registerDriver(UText.class, new DriverTextAsPathSvg(TextBlockUtils.getFontRenderContext(), this));
+ } else {
+ registerDriver(UText.class, new DriverTextSvg(getStringBounder(), this));
+ }
+ registerDriver(ULine.class, new DriverLineSvg(this));
+ registerDriver(UPolygon.class, new DriverPolygonSvg(this));
+ registerDriver(UEllipse.class, new DriverEllipseSvg(this));
+ registerDriver(UImage.class, new DriverImagePng(this));
+ registerDriver(UImageSvg.class, new DriverImageSvgSvg());
+ registerDriver(UPath.class, new DriverPathSvg(this));
+ registerDriver(DotPath.class, new DriverDotPathSvg());
+ registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterSvg());
+ }
+
+ public SvgGraphics getSvgGraphics() {
+ return this.getGraphicObject();
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public void createXml(OutputStream os) throws IOException {
+ try {
+ getGraphicObject().createXml(os);
+ } catch (TransformerException e) {
+ throw new IOException(e.toString());
+ }
+ }
+
+ public void startUrl(Url url) {
+ getGraphicObject().openLink(url.getUrl(), url.getTooltip());
+ }
+
+ public void closeAction() {
+ getGraphicObject().closeLink();
+ }
+
+ public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
+ createXml(os);
+ }
+
+ // @Override
+ // public String startHiddenGroup() {
+ // getGraphicObject().startHiddenGroup();
+ // return null;
+ // }
+ //
+ // @Override
+ // public String closeHiddenGroup() {
+ // getGraphicObject().closeHiddenGroup();
+ // return null;
+ // }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverAtomTextTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverAtomTextTikz.java
new file mode 100644
index 0000000..b2ac3bb
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverAtomTextTikz.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.ugraphic.tikz;
+
+import net.sourceforge.plantuml.creole.AtomText;
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverAtomTextTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) {
+ final AtomText text = (AtomText) shape;
+
+ tikz.text(x, y, text.getText());
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverCenteredCharacterTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverCenteredCharacterTikz.java
new file mode 100644
index 0000000..087d994
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverCenteredCharacterTikz.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.ugraphic.tikz;
+
+import java.awt.font.TextLayout;
+
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.graphic.UnusedSpace;
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverCenteredCharacterTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) {
+ final UCenteredCharacter centeredCharacter = (UCenteredCharacter) ushape;
+ final char c = centeredCharacter.getChar();
+ final UFont font = centeredCharacter.getFont();
+ final UnusedSpace unusedSpace = UnusedSpace.getUnusedSpace(font, c);
+
+ final double xpos = x - unusedSpace.getCenterX() - 0.5;
+ final double ypos = y - unusedSpace.getCenterY() - 0.5;
+
+ final TextLayout t = new TextLayout("" + c, font.getFont(), TextBlockUtils.getFontRenderContext());
+ tikz.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ tikz.drawPathIterator(xpos, ypos, t.getOutline(null).getPathIterator(null));
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverDotPathTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverDotPathTikz.java
new file mode 100644
index 0000000..a49a762
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverDotPathTikz.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.ugraphic.tikz;
+
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverDotPathTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) {
+ final DotPath path = (DotPath) shape;
+ tikz.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz());
+ tikz.upath(x, y, path.toUPath());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverEllipseTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverEllipseTikz.java
new file mode 100644
index 0000000..16acdd4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverEllipseTikz.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.ugraphic.tikz;
+
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverEllipseTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) {
+ final UEllipse shape = (UEllipse) ushape;
+ final double width = shape.getWidth();
+ final double height = shape.getHeight();
+
+ double start = shape.getStart();
+ final double extend = shape.getExtend();
+ final double cx = x + width / 2;
+ final double cy = y + height / 2;
+ tikz.setFillColor(mapper.getMappedColor(param.getBackcolor()));
+ tikz.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz());
+ if (start == 0 && extend == 0) {
+ tikz.ellipse(cx, cy, width / 2, height / 2);
+ } else {
+ throw new UnsupportedOperationException();
+ // // http://www.itk.ilstu.edu/faculty/javila/SVG/SVG_drawing1/elliptical_curve.htm
+ // start = start + 90;
+ // final double x1 = cx + Math.sin(start * Math.PI / 180.) * width / 2;
+ // final double y1 = cy + Math.cos(start * Math.PI / 180.) * height / 2;
+ // final double x2 = cx + Math.sin((start + extend) * Math.PI / 180.) * width / 2;
+ // final double y2 = cy + Math.cos((start + extend) * Math.PI / 180.) * height / 2;
+ // // svg.svgEllipse(x1, y1, 1, 1, 0);
+ // // svg.svgEllipse(x2, y2, 1, 1, 0);
+ // svg.svgArcEllipse(width / 2, height / 2, x1, y1, x2, y2);
+ }
+ }
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverLineTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverLineTikz.java
new file mode 100644
index 0000000..20dd8b7
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverLineTikz.java
@@ -0,0 +1,56 @@
+/* ========================================================================
+ * 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.ugraphic.tikz;
+
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverLineTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) {
+ final ULine line = (ULine) shape;
+
+ double x2 = x + line.getDX();
+ double y2 = y + line.getDY();
+ tikz.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz());
+ tikz.line(x, y, x2, y2);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverNoneTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverNoneTikz.java
new file mode 100644
index 0000000..1c1754c
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverNoneTikz.java
@@ -0,0 +1,48 @@
+/* ========================================================================
+ * 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.ugraphic.tikz;
+
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverNoneTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics object) {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverPolygonTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverPolygonTikz.java
new file mode 100644
index 0000000..6aea91d
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverPolygonTikz.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.ugraphic.tikz;
+
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverPolygonTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) {
+ final UPolygon poly = (UPolygon) shape;
+ final double points[] = poly.getPointArray(x, y);
+
+ tikz.setFillColor(mapper.getMappedColor(param.getBackcolor()));
+ tikz.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz());
+
+ tikz.polygon(points);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverRectangleTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverRectangleTikz.java
new file mode 100644
index 0000000..84b8dc3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverRectangleTikz.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.ugraphic.tikz;
+
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverRectangleTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) {
+ final URectangle rect = (URectangle) shape;
+
+ final double width = rect.getWidth();
+ final double height = rect.getHeight();
+ tikz.setFillColor(mapper.getMappedColor(param.getBackcolor()));
+ tikz.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz());
+ tikz.rectangle(x, y, width, height);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverUPathTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverUPathTikz.java
new file mode 100644
index 0000000..a9e3b3a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverUPathTikz.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.ugraphic.tikz;
+
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverUPathTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) {
+ final UPath path = (UPath) shape;
+ tikz.setStrokeColor(mapper.getMappedColor(param.getColor()));
+ tikz.setStrokeWidth(param.getStroke().getThickness(), param.getStroke().getDashTikz());
+ tikz.upath(x, y, path);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/DriverUTextTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverUTextTikz.java
new file mode 100644
index 0000000..9507fd8
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/DriverUTextTikz.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.ugraphic.tikz;
+
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class DriverUTextTikz implements UDriver<TikzGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, TikzGraphics tikz) {
+ final UText text = (UText) shape;
+
+ tikz.text(x, y, text.getText());
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/tikz/UGraphicTikz.java b/src/net/sourceforge/plantuml/ugraphic/tikz/UGraphicTikz.java
new file mode 100644
index 0000000..9303cc9
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/tikz/UGraphicTikz.java
@@ -0,0 +1,124 @@
+/* ========================================================================
+ * 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.ugraphic.tikz;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.creole.AtomText;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.tikz.TikzGraphics;
+import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
+import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UImageSvg;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class UGraphicTikz extends AbstractUGraphic<TikzGraphics> implements ClipContainer, UGraphic2 {
+
+ private final StringBounder stringBounder;
+
+ private UGraphicTikz(ColorMapper colorMapper, TikzGraphics tikz) {
+ super(colorMapper, tikz);
+ this.stringBounder = TextBlockUtils.getDummyStringBounder();
+ register();
+
+ }
+
+ public UGraphicTikz(ColorMapper colorMapper) {
+ this(colorMapper, new TikzGraphics());
+
+ }
+
+ @Override
+ protected AbstractCommonUGraphic copyUGraphic() {
+ return new UGraphicTikz(this);
+ }
+
+ private UGraphicTikz(UGraphicTikz other) {
+ super(other);
+ this.stringBounder = other.stringBounder;
+ register();
+ }
+
+ private void register() {
+ registerDriver(URectangle.class, new DriverRectangleTikz());
+ registerDriver(UText.class, new DriverUTextTikz());
+ registerDriver(AtomText.class, new DriverAtomTextTikz());
+ registerDriver(ULine.class, new DriverLineTikz());
+ registerDriver(UPolygon.class, new DriverPolygonTikz());
+ registerDriver(UEllipse.class, new DriverEllipseTikz());
+ registerDriver(UImage.class, new DriverNoneTikz());
+ registerDriver(UImageSvg.class, new DriverNoneTikz());
+ registerDriver(UPath.class, new DriverUPathTikz());
+ registerDriver(DotPath.class, new DriverDotPathTikz());
+ registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterTikz());
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
+ createTikz(os);
+ }
+
+ public void createTikz(OutputStream os) throws IOException {
+ getGraphicObject().createData(os);
+ }
+
+ public boolean isSpecialTxt() {
+ return true;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/txt/UGraphicTxt.java b/src/net/sourceforge/plantuml/ugraphic/txt/UGraphicTxt.java
new file mode 100644
index 0000000..528259a
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/txt/UGraphicTxt.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.ugraphic.txt;
+
+import java.awt.geom.Dimension2D;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.Dimension2DDouble;
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.asciiart.TextStringBounder;
+import net.sourceforge.plantuml.asciiart.TranslatedCharArea;
+import net.sourceforge.plantuml.asciiart.UmlCharArea;
+import net.sourceforge.plantuml.asciiart.UmlCharAreaImpl;
+import net.sourceforge.plantuml.graphic.FontStyle;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class UGraphicTxt extends AbstractCommonUGraphic implements ClipContainer {
+
+ private final UmlCharArea charArea;
+
+ @Override
+ protected AbstractCommonUGraphic copyUGraphic() {
+ return new UGraphicTxt(this);
+ }
+
+ private UGraphicTxt(UGraphicTxt other) {
+ super(other);
+ this.charArea = other.charArea;
+ }
+
+ public UGraphicTxt() {
+ super(new ColorMapperIdentity());
+ this.charArea = new UmlCharAreaImpl();
+ }
+
+ public StringBounder getStringBounder() {
+ return new TextStringBounder();
+ }
+
+ public void draw(UShape shape) {
+ // final UClip clip = getClip();
+ if (shape instanceof UText) {
+ final UText txt = (UText) shape;
+ final int y = ((int) (getTranslateY() + txt.getDescent())) / 10;
+ if (txt.getFontConfiguration().containsStyle(FontStyle.WAVE)) {
+ charArea.drawHLine('^', y, getDx(), txt.getText().length());
+ charArea.drawStringLR(txt.getText(), 0, y + 1);
+ } else {
+ charArea.drawStringLR(txt.getText(), 0, y);
+ }
+ return;
+ } else if (shape instanceof UImage) {
+ return;
+ }
+ throw new UnsupportedOperationException("cl=" + shape.getClass());
+ }
+
+ public final UmlCharArea getCharArea() {
+ return new TranslatedCharArea(charArea, getDx(), getDy());
+ }
+
+ private int getDy() {
+ return (int) getTranslateY();
+ }
+
+ private int getDx() {
+ return (int) getTranslateX();
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ public Dimension2D getDimension() {
+ return new Dimension2DDouble(0, 0);
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/DriverDotPathVdx.java b/src/net/sourceforge/plantuml/ugraphic/visio/DriverDotPathVdx.java
new file mode 100644
index 0000000..0df19b1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/DriverDotPathVdx.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.ugraphic.visio;
+
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverDotPathVdx implements UDriver<VisioGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, VisioGraphics visio) {
+ final DotPath path = (DotPath) shape;
+ visio.upath(x, y, path.toUPath());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/DriverLineVdx.java b/src/net/sourceforge/plantuml/ugraphic/visio/DriverLineVdx.java
new file mode 100644
index 0000000..9e7ed05
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/DriverLineVdx.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.ugraphic.visio;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverLineVdx implements UDriver<VisioGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, VisioGraphics visio) {
+ final ULine line = (ULine) shape;
+
+ final double dx = line.getDX();
+ final double dy = line.getDY();
+
+ visio.line(x, y, x + dx, y + dy);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/DriverNoneVdx.java b/src/net/sourceforge/plantuml/ugraphic/visio/DriverNoneVdx.java
new file mode 100644
index 0000000..0c55c5f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/DriverNoneVdx.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.ugraphic.visio;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverNoneVdx implements UDriver<VisioGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, VisioGraphics object) {
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/DriverPolygonVdx.java b/src/net/sourceforge/plantuml/ugraphic/visio/DriverPolygonVdx.java
new file mode 100644
index 0000000..69c29ba
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/DriverPolygonVdx.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.ugraphic.visio;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverPolygonVdx implements UDriver<VisioGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, VisioGraphics visio) {
+ final UPolygon poly = (UPolygon) shape;
+ visio.polygon(poly.translate(x, y));
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/DriverRectangleVdx.java b/src/net/sourceforge/plantuml/ugraphic/visio/DriverRectangleVdx.java
new file mode 100644
index 0000000..147a989
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/DriverRectangleVdx.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.ugraphic.visio;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverRectangleVdx implements UDriver<VisioGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, VisioGraphics visio) {
+ final URectangle rect = (URectangle) shape;
+
+ final double width = rect.getWidth();
+ final double height = rect.getHeight();
+
+ visio.rectangle(x, y, width, height);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/DriverTextVdx.java b/src/net/sourceforge/plantuml/ugraphic/visio/DriverTextVdx.java
new file mode 100644
index 0000000..90419ff
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/DriverTextVdx.java
@@ -0,0 +1,80 @@
+/* ========================================================================
+ * 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.ugraphic.visio;
+
+import java.awt.geom.Dimension2D;
+
+import net.sourceforge.plantuml.graphic.FontConfiguration;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UFont;
+import net.sourceforge.plantuml.ugraphic.UFontContext;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UShape;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class DriverTextVdx implements UDriver<VisioGraphics> {
+
+ private final StringBounder stringBounder;
+
+ public DriverTextVdx(StringBounder stringBounder) {
+ this.stringBounder = stringBounder;
+ }
+
+ public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, VisioGraphics visio) {
+ final UText shape = (UText) ushape;
+ Thread.dumpStack();
+
+ final FontConfiguration fontConfiguration = shape.getFontConfiguration();
+ final UFont font = fontConfiguration.getFont();
+
+ String text = shape.getText();
+ if (text.startsWith(" ")) {
+ final double space = stringBounder.calculateDimension(font, " ").getWidth();
+ while (text.startsWith(" ")) {
+ x += space;
+ text = text.substring(1);
+ }
+ }
+
+ text = text.trim();
+ final Dimension2D dim = stringBounder.calculateDimension(font, text);
+ visio.text(text, x, y, font.getFamily(UFontContext.SVG), font.getSize(), dim.getWidth(), dim.getHeight(),
+ fontConfiguration.getAttributes());
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/DriverUPathVdx.java b/src/net/sourceforge/plantuml/ugraphic/visio/DriverUPathVdx.java
new file mode 100644
index 0000000..6f04eb4
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/DriverUPathVdx.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.ugraphic.visio;
+
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UDriver;
+import net.sourceforge.plantuml.ugraphic.UParam;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UShape;
+
+public class DriverUPathVdx implements UDriver<VisioGraphics> {
+
+ public void draw(UShape shape, double x, double y, ColorMapper mapper, UParam param, VisioGraphics visio) {
+ final UPath path = (UPath) shape;
+
+ visio.upath(x, y, path);
+
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/UGraphicVdx.java b/src/net/sourceforge/plantuml/ugraphic/visio/UGraphicVdx.java
new file mode 100644
index 0000000..f4966f1
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/UGraphicVdx.java
@@ -0,0 +1,123 @@
+/* ========================================================================
+ * 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.ugraphic.visio;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import net.sourceforge.plantuml.Url;
+import net.sourceforge.plantuml.creole.AtomText;
+import net.sourceforge.plantuml.graphic.StringBounder;
+import net.sourceforge.plantuml.graphic.TextBlockUtils;
+import net.sourceforge.plantuml.posimo.DotPath;
+import net.sourceforge.plantuml.ugraphic.AbstractCommonUGraphic;
+import net.sourceforge.plantuml.ugraphic.AbstractUGraphic;
+import net.sourceforge.plantuml.ugraphic.ClipContainer;
+import net.sourceforge.plantuml.ugraphic.ColorMapper;
+import net.sourceforge.plantuml.ugraphic.UCenteredCharacter;
+import net.sourceforge.plantuml.ugraphic.UEllipse;
+import net.sourceforge.plantuml.ugraphic.UGraphic2;
+import net.sourceforge.plantuml.ugraphic.UImage;
+import net.sourceforge.plantuml.ugraphic.UImageSvg;
+import net.sourceforge.plantuml.ugraphic.ULine;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.URectangle;
+import net.sourceforge.plantuml.ugraphic.UText;
+
+public class UGraphicVdx extends AbstractUGraphic<VisioGraphics> implements ClipContainer, UGraphic2 {
+
+ private final StringBounder stringBounder;
+
+ private UGraphicVdx(ColorMapper colorMapper, VisioGraphics visio) {
+ super(colorMapper, visio);
+ this.stringBounder = TextBlockUtils.getDummyStringBounder();
+ register();
+
+ }
+
+ public UGraphicVdx(ColorMapper colorMapper) {
+ this(colorMapper, new VisioGraphics());
+
+ }
+
+ @Override
+ protected AbstractCommonUGraphic copyUGraphic() {
+ return new UGraphicVdx(this);
+ }
+
+ private UGraphicVdx(UGraphicVdx other) {
+ super(other);
+ this.stringBounder = other.stringBounder;
+ register();
+ }
+
+ private void register() {
+ registerDriver(URectangle.class, new DriverRectangleVdx());
+ registerDriver(UText.class, new DriverTextVdx(stringBounder));
+ registerDriver(AtomText.class, new DriverNoneVdx());
+ registerDriver(ULine.class, new DriverLineVdx());
+ registerDriver(UPolygon.class, new DriverPolygonVdx());
+ registerDriver(UEllipse.class, new DriverNoneVdx());
+ registerDriver(UImage.class, new DriverNoneVdx());
+ registerDriver(UImageSvg.class, new DriverNoneVdx());
+ registerDriver(UPath.class, new DriverUPathVdx());
+ registerDriver(DotPath.class, new DriverDotPathVdx());
+ registerDriver(UCenteredCharacter.class, new DriverNoneVdx());
+ }
+
+ public StringBounder getStringBounder() {
+ return stringBounder;
+ }
+
+ public void startUrl(Url url) {
+ }
+
+ public void closeAction() {
+ }
+
+ public void writeImageTOBEMOVED(OutputStream os, String metadata, int dpi) throws IOException {
+ createVsd(os);
+ }
+
+ public void createVsd(OutputStream os) throws IOException {
+ getGraphicObject().createVsd(os);
+ }
+
+ public boolean isSpecialTxt() {
+ return true;
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/VisioGraphics.java b/src/net/sourceforge/plantuml/ugraphic/visio/VisioGraphics.java
new file mode 100644
index 0000000..2cc4e43
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/VisioGraphics.java
@@ -0,0 +1,187 @@
+/* ========================================================================
+ * 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.ugraphic.visio;
+
+import java.awt.geom.Point2D;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import net.sourceforge.plantuml.Log;
+import net.sourceforge.plantuml.golem.MinMaxDouble;
+import net.sourceforge.plantuml.ugraphic.UPath;
+import net.sourceforge.plantuml.ugraphic.UPolygon;
+import net.sourceforge.plantuml.ugraphic.USegment;
+import net.sourceforge.plantuml.ugraphic.USegmentType;
+
+public class VisioGraphics {
+
+ private final List<VisioShape> shapes = new ArrayList<VisioShape>();
+ private final MinMaxDouble limits = new MinMaxDouble();
+
+ public void createVsd(OutputStream os) throws IOException {
+ final double width = toInches(limits.getMaxX());
+ final double height = toInches(limits.getMaxY());
+
+ out(os, "<?xml version='1.0' encoding='utf-8' ?>");
+ out(os,
+ "<VisioDocument xml:space='preserve' xmlns='http://schemas.microsoft.com/visio/2003/core' xmlns:vx='http://schemas.microsoft.com/visio/2006/extension' xmlns:v14='http://schemas.microsoft.com/office/visio/2010/extension'>");
+ out(os, "<DocumentProperties>");
+ out(os, "<Creator>PlantUML</Creator>");
+ out(os, "</DocumentProperties>");
+ out(os, "<DocumentSheet NameU='TheDoc' LineStyle='0' FillStyle='0' TextStyle='0'>");
+ out(os, "</DocumentSheet>");
+ out(os, "<Masters/>");
+ out(os, "<Pages>");
+ out(os, "<Page ID='0' NameU='Page-1' Name='Page 1' ViewScale='1' ViewCenterX='" + (width / 2)
+ + "' ViewCenterY='" + (height / 2) + "'>");
+ out(os, "<PageSheet LineStyle='0' FillStyle='0' TextStyle='0'>");
+ out(os, "<PageProps>");
+ out(os, "<PageWidth Unit='IN_F'>" + width + "</PageWidth>");
+ out(os, "<PageHeight Unit='IN_F'>" + height + "</PageHeight>");
+ out(os, "<PageScale Unit='IN_F'>1</PageScale>");
+ out(os, "<DrawingScale Unit='IN_F'>2</DrawingScale>"); // change for scale
+ out(os, "<DrawingSizeType>3</DrawingSizeType>");
+ out(os, "<DrawingScaleType>0</DrawingScaleType>");
+ out(os, "<InhibitSnap>0</InhibitSnap>");
+ out(os, "</PageProps>");
+ out(os, "</PageSheet>");
+ out(os, "<Shapes>");
+ for (VisioShape sh : shapes) {
+ sh.yReverse(height).print(os);
+ // sh.print(os);
+ }
+ out(os, "</Shapes>");
+ out(os, "</Page>");
+ out(os, "</Pages>");
+ out(os, "</VisioDocument>");
+ }
+
+ private void out(OutputStream os, String s) throws IOException {
+ os.write(s.getBytes());
+ os.write("\n".getBytes());
+ }
+
+ private double toInches(double val) {
+ return val / 72.0;
+ }
+
+ private void ensureVisible(double x, double y) {
+ limits.manage(x, y);
+ }
+
+ public void rectangle(double x, double y, double width, double height) {
+ ensureVisible(x, y);
+ ensureVisible(x + width, y + height);
+ final VisioRectangle rect = VisioRectangle.createInches(shapes.size() + 1, x, y, width, height);
+ shapes.add(rect);
+ }
+
+ public void text(String text, double x, double y, String family, int fontSize, double width, double height,
+ Map<String, String> attributes) {
+ // System.err.println("x=" + x);
+ // System.err.println("y=" + y);
+ // System.err.println("text=" + text);
+ // System.err.println("family=" + family);
+ // System.err.println("fontSize=" + fontSize);
+ // System.err.println("width=" + width);
+ // System.err.println("attributes=" + attributes);
+ ensureVisible(x, y);
+ final VisioText txt = VisioText.createInches(shapes.size() + 1, text, fontSize, x, y, width, height);
+ shapes.add(txt);
+
+ }
+
+ public void line(double x1, double y1, double x2, double y2) {
+ ensureVisible(x1, y1);
+ if (x1 == x2 && y1 == y2) {
+ return;
+ }
+ ensureVisible(x2, y2);
+ final VisioLine line = VisioLine.createInches(shapes.size() + 1, x1, y1, x2, y2);
+ shapes.add(line);
+ }
+
+ private void line(Point2D p1, Point2D p2) {
+ line(p1.getX(), p1.getY(), p2.getX(), p2.getY());
+ }
+
+ public void upath(final double x, final double y, UPath path) {
+ double lx = x;
+ double ly = y;
+ for (USegment seg : path) {
+ final USegmentType type = seg.getSegmentType();
+ final double coord[] = seg.getCoord();
+ if (type == USegmentType.SEG_MOVETO) {
+ lx = coord[0] + x;
+ ly = coord[1] + y;
+ } else if (type == USegmentType.SEG_LINETO) {
+ line(lx, ly, coord[0] + x, coord[1] + y);
+ lx = coord[0] + x;
+ ly = coord[1] + y;
+ } else if (type == USegmentType.SEG_QUADTO) {
+ line(lx, ly, coord[2] + x, coord[3] + y);
+ lx = coord[2] + x;
+ ly = coord[3] + y;
+ } else if (type == USegmentType.SEG_CUBICTO) {
+ line(lx, ly, coord[4] + x, coord[5] + y);
+ // linePoint(lx, ly, coord[0] + x, coord[1] + y);
+ // linePoint(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y);
+ // linePoint(coord[2] + x, coord[3] + y, coord[4] + x, coord[5] + y);
+ lx = coord[4] + x;
+ ly = coord[5] + y;
+ } else if (type == USegmentType.SEG_CLOSE) {
+ // Nothing
+ } else {
+ Log.println("unknown " + seg);
+ }
+
+ }
+
+ }
+
+ public void polygon(UPolygon poly) {
+ Point2D last = null;
+ for (Point2D pt : poly.getPoints()) {
+ if (last != null) {
+ line(last, pt);
+ }
+ last = pt;
+ }
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/VisioLine.java b/src/net/sourceforge/plantuml/ugraphic/visio/VisioLine.java
new file mode 100644
index 0000000..c2481ad
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/VisioLine.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.ugraphic.visio;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class VisioLine implements VisioShape {
+
+ private final int id;
+ private final double x1;
+ private final double y1;
+ private final double x2;
+ private final double y2;
+
+ public static VisioLine createInches(int id, double x1, double y1, double x2, double y2) {
+ return new VisioLine(id, toInches(x1), toInches(y1), toInches(x2), toInches(y2));
+ }
+
+ private VisioLine(int id, double x1, double y1, double x2, double y2) {
+ if (x1 < 0 || y1 < 0 || x2 < 0 || y2 < 0) {
+ throw new IllegalArgumentException();
+ }
+ this.id = id;
+ this.x1 = x1;
+ this.y1 = y1;
+ this.x2 = x2;
+ this.y2 = y2;
+ }
+
+ public VisioShape yReverse(double maxY) {
+ return new VisioLine(id, x1, maxY - y1, x2, maxY - y2);
+ }
+
+ private static double toInches(double val) {
+ return val / 72.0;
+ }
+
+ public void print(OutputStream os) throws IOException {
+ out(os, "<Shape ID='" + id + "' Type='Shape' LineStyle='3' FillStyle='3' TextStyle='3'>");
+ out(os, "<XForm>");
+ final double ddx = x2 - x1;
+ final double ddy = y2 - y1;
+ out(os, "<PinX F='(BeginX+EndX)/2'>" + ((x1 + x2) / 2) + "</PinX>");
+ out(os, "<PinY F='(BeginY+EndY)/2'>" + ((y1 + y2) / 2) + "</PinY>");
+ final double len = Math.sqrt(ddx * ddx + ddy * ddy);
+ out(os, "<Width F='Sqrt((EndX-BeginX)^2+(EndY-BeginY)^2)'>" + len + "</Width>");
+ out(os, "<Height>0</Height>");
+ out(os, "<LocPinX F='Width*0.5'>" + (len / 2) + "</LocPinX>");
+ out(os, "<LocPinY F='Height*0.5'>0</LocPinY>");
+ final double atan2 = Math.atan2(ddy, ddx);
+ out(os, "<Angle F='ATan2(EndY-BeginY,EndX-BeginX)'>" + atan2 + "</Angle>");
+ out(os, "<FlipX>0</FlipX>");
+ out(os, "<FlipY>0</FlipY>");
+ out(os, "<ResizeMode>0</ResizeMode>");
+ out(os, "</XForm>");
+ out(os, "<XForm1D>");
+ out(os, "<BeginX>" + x1 + "</BeginX>");
+ out(os, "<BeginY>" + y1 + "</BeginY>");
+ out(os, "<EndX>" + x2 + "</EndX>");
+ out(os, "<EndY>" + y2 + "</EndY>");
+ out(os, "</XForm1D>");
+ out(os, "<Geom IX='0'>");
+ out(os, "<NoFill>1</NoFill>");
+ out(os, "<NoLine>0</NoLine>");
+ out(os, "<NoShow>0</NoShow>");
+ out(os, "<NoSnap>0</NoSnap>");
+ out(os, "<MoveTo IX='1'>");
+ out(os, "<X F='Width*0'>0</X>");
+ out(os, "<Y>0</Y>");
+ out(os, "</MoveTo>");
+ out(os, "<LineTo IX='2'>");
+ out(os, "<X F='Width*1'>" + len + "</X>");
+ out(os, "<Y>0</Y>");
+ out(os, "</LineTo>");
+ out(os, "</Geom>");
+ out(os, "</Shape>");
+ }
+
+ private void out(OutputStream os, String s) throws IOException {
+ os.write(s.getBytes());
+ os.write("\n".getBytes());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/VisioRectangle.java b/src/net/sourceforge/plantuml/ugraphic/visio/VisioRectangle.java
new file mode 100644
index 0000000..11cfd9f
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/VisioRectangle.java
@@ -0,0 +1,120 @@
+/* ========================================================================
+ * 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.ugraphic.visio;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class VisioRectangle implements VisioShape {
+
+ private final int id;
+ private final double x;
+ private final double y;
+ private final double width;
+ private final double height;
+
+ public static VisioRectangle createInches(int id, double x, double y, double width, double height) {
+ return new VisioRectangle(id, toInches(x), toInches(y), toInches(width), toInches(height));
+ }
+
+ private VisioRectangle(int id, double x, double y, double width, double height) {
+ if (x < 0 || y < 0 || width < 0 || height < 0) {
+ // throw new IllegalArgumentException();
+ }
+ this.id = id;
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+
+ public VisioShape yReverse(double maxY) {
+ final double y2 = maxY - (y + height);
+ return new VisioRectangle(id, x, y2, width, height);
+ }
+
+ private static double toInches(double val) {
+ return val / 72.0;
+ }
+
+ public void print(OutputStream os) throws IOException {
+ out(os, "<Shape ID='" + id + "' Type='Shape' LineStyle='3' FillStyle='3' TextStyle='3'>");
+ out(os, "<XForm>");
+ out(os, "<PinX>" + (x + width / 2) + "</PinX>");
+ out(os, "<PinY>" + (y + height / 2) + "</PinY>");
+ out(os, "<Width>" + width + "</Width>");
+ out(os, "<Height>" + height + "</Height>");
+ // out(os, "<LocPinX F='Width*0.5'>" + (x + width / 2) + "</LocPinX>");
+ // out(os, "<LocPinY F='Height*0.5'>" + (y + height / 2) + "</LocPinY>");
+ out(os, "<Angle>0</Angle>");
+ out(os, "<FlipX>0</FlipX>");
+ out(os, "<FlipY>0</FlipY>");
+ out(os, "<ResizeMode>0</ResizeMode>");
+ out(os, "</XForm>");
+ out(os, "<Geom IX='0'>");
+ out(os, "<NoFill>0</NoFill>");
+ out(os, "<NoLine>0</NoLine>");
+ out(os, "<NoShow>0</NoShow>");
+ out(os, "<NoSnap>0</NoSnap>");
+ out(os, "<MoveTo IX='1'>");
+ out(os, "<X F='Width*0'>0</X>");
+ out(os, "<Y F='Height*0'>0</Y>");
+ out(os, "</MoveTo>");
+ out(os, "<LineTo IX='2'>");
+ out(os, "<X F='Width*1'>" + width + "</X>");
+ out(os, "<Y F='Height*0'>0</Y>");
+ out(os, "</LineTo>");
+ out(os, "<LineTo IX='3'>");
+ out(os, "<X F='Width*1'>" + width + "</X>");
+ out(os, "<Y F='Height*1'>" + height + "</Y>");
+ out(os, "</LineTo>");
+ out(os, "<LineTo IX='4'>");
+ out(os, "<X F='Width*0'>0</X>");
+ out(os, "<Y F='Height*1'>" + height + "</Y>");
+ out(os, "</LineTo>");
+ out(os, "<LineTo IX='5'>");
+ out(os, "<X F='Geometry1.X1'>0</X>");
+ out(os, "<Y F='Geometry1.Y1'>0</Y>");
+ out(os, "</LineTo>");
+ out(os, "</Geom>");
+ out(os, "</Shape>");
+ }
+
+ private void out(OutputStream os, String s) throws IOException {
+ os.write(s.getBytes());
+ os.write("\n".getBytes());
+ }
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/VisioShape.java b/src/net/sourceforge/plantuml/ugraphic/visio/VisioShape.java
new file mode 100644
index 0000000..47f4da3
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/VisioShape.java
@@ -0,0 +1,46 @@
+/* ========================================================================
+ * 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.ugraphic.visio;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public interface VisioShape {
+
+ public void print(OutputStream os) throws IOException;
+
+ public VisioShape yReverse(double maxY);
+
+}
diff --git a/src/net/sourceforge/plantuml/ugraphic/visio/VisioText.java b/src/net/sourceforge/plantuml/ugraphic/visio/VisioText.java
new file mode 100644
index 0000000..d06cb12
--- /dev/null
+++ b/src/net/sourceforge/plantuml/ugraphic/visio/VisioText.java
@@ -0,0 +1,128 @@
+/* ========================================================================
+ * 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.ugraphic.visio;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+public class VisioText implements VisioShape {
+
+ private final int id;
+ private final String text;
+ private final int fontSize;
+ private final double x;
+ private final double y;
+ private final double width;
+ private final double height;
+
+ private final double coefFont = 150.0;
+
+ public static VisioText createInches(int id, String text, int fontSize, double x, double y, double width,
+ double height) {
+ final double coef = 1.8;
+ return new VisioText(id, text, fontSize, toInches(x), toInches(y + 2.5), toInches(width * coef),
+ toInches(height * coef));
+ }
+
+ private static double toInches(double val) {
+ return val / 72.0;
+ }
+
+ private VisioText(int id, String text, int fontSize, double x, double y, double width, double height) {
+ this.id = id;
+ this.text = text;
+ this.x = x;
+ this.y = y;
+ this.height = height;
+ this.width = width;
+ this.fontSize = fontSize;
+ }
+
+ public void print(OutputStream os) throws IOException {
+ out(os, "<Shape ID='" + id + "' Type='Shape' LineStyle='1' FillStyle='1' TextStyle='3'>");
+ out(os, "<XForm>");
+ out(os, "<PinX>" + x + "</PinX>");
+ out(os, "<PinY>" + y + "</PinY>");
+ out(os, "<Width>" + width + "</Width>");
+ out(os, "<Height>" + height + "</Height>");
+ // out(os, "<PinX>1.0625</PinX>");
+ // out(os, "<PinY>1.9375</PinY>");
+ out(os, "<LocPinX F='Width*0'>0</LocPinX>");
+ out(os, "<LocPinY F='Height*0'>0</LocPinY>");
+ out(os, "<Angle>0</Angle>");
+ out(os, "<FlipX>0</FlipX>");
+ out(os, "<FlipY>0</FlipY>");
+ out(os, "<ResizeMode>0</ResizeMode>");
+ out(os, "</XForm>");
+ out(os, "<TextBlock>");
+ out(os, "<VerticalAlign>0</VerticalAlign>");
+ out(os, "</TextBlock>");
+ out(os, "<Char IX='" + id + "'>");
+ out(os, "<Font F='Inh'>0</Font>");
+ out(os, "<Color F='Inh'>0</Color>");
+ out(os, "<Style F='Inh'>0</Style>");
+ out(os, "<Case F='Inh'>0</Case>");
+ out(os, "<Pos F='Inh'>0</Pos>");
+ out(os, "<FontScale F='Inh'>1</FontScale>");
+ out(os, "<Locale F='Inh'>0</Locale>");
+ out(os, "<Size Unit='PT'>" + fontSize / coefFont + "</Size>");
+ out(os, "<DblUnderline F='Inh'>0</DblUnderline>");
+ out(os, "<Overline F='Inh'>0</Overline>");
+ out(os, "<Strikethru F='Inh'>0</Strikethru>");
+ out(os, "<Perpendicular F='Inh'>0</Perpendicular>");
+ out(os, "<Letterspace F='Inh'>0</Letterspace>");
+ out(os, "<ColorTrans F='Inh'>0</ColorTrans>");
+ out(os, "</Char>");
+
+ out(os, "<Para IX='" + id + "'>");
+ out(os, "<HorzAlign>0</HorzAlign>");
+ out(os, "</Para>");
+
+ out(os, "<Text><cp IX='" + id + "'/><pp IX='" + id + "'/>" + text + "</Text>");
+ out(os, "</Shape>");
+
+ }
+
+ public VisioShape yReverse(double maxY) {
+ final double y2 = maxY - y;
+ return new VisioText(id, text, fontSize, x, y2, width, height);
+ }
+
+ private void out(OutputStream os, String s) throws IOException {
+ os.write(s.getBytes());
+ os.write("\n".getBytes());
+ }
+
+}