diff --git a/pom.xml b/pom.xml index 6f9734fc8..559d0d61b 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,8 @@ Script Author: Julien Eluard --> - + 4.0.0 net.sourceforge.plantuml diff --git a/src/net/sourceforge/plantuml/BlockUml.java b/src/net/sourceforge/plantuml/BlockUml.java index 759e1a89a..5f6db3042 100644 --- a/src/net/sourceforge/plantuml/BlockUml.java +++ b/src/net/sourceforge/plantuml/BlockUml.java @@ -56,9 +56,10 @@ public class BlockUml { private final List data; private Diagram system; private final Defines localDefines; + private final ISkinSimple skinParam; BlockUml(String... strings) { - this(convert(strings), Defines.createEmpty()); + this(convert(strings), Defines.createEmpty(), null); } public String getEncodedUrl() throws IOException { @@ -92,8 +93,9 @@ public class BlockUml { return result; } - public BlockUml(List strings, Defines defines) { + public BlockUml(List strings, Defines defines, ISkinSimple skinParam) { this.localDefines = defines; + this.skinParam = skinParam; final CharSequence2 s0 = strings.get(0).trin(); if (StartUtils.startsWithSymbolAnd("start", s0) == false) { throw new IllegalArgumentException(); @@ -130,7 +132,7 @@ public class BlockUml { public Diagram getDiagram() { if (system == null) { - system = new PSystemBuilder().createPSystem(data); + system = new PSystemBuilder().createPSystem(skinParam, data); } return system; } diff --git a/src/net/sourceforge/plantuml/BlockUmlBuilder.java b/src/net/sourceforge/plantuml/BlockUmlBuilder.java index b414f0633..6f07791ec 100644 --- a/src/net/sourceforge/plantuml/BlockUmlBuilder.java +++ b/src/net/sourceforge/plantuml/BlockUmlBuilder.java @@ -117,21 +117,13 @@ public final class BlockUmlBuilder implements DefinitionsContainer { if (paused) { current2.add(s); } - blocks.add(new BlockUml(current2, defines.cloneMe())); + blocks.add(new BlockUml(current2, defines.cloneMe(), null)); current2 = null; reader2.setPaused(false); } } } - // private Collection convert(List config, LineLocation location) { - // final List result = new ArrayList(); - // for (String s : config) { - // result.add(new CharSequence2Impl(s, location)); - // } - // return result; - // } - public List getBlockUmls() { return Collections.unmodifiableList(blocks); } diff --git a/src/net/sourceforge/plantuml/EmbeddedDiagram.java b/src/net/sourceforge/plantuml/EmbeddedDiagram.java new file mode 100644 index 000000000..2af3b39c1 --- /dev/null +++ b/src/net/sourceforge/plantuml/EmbeddedDiagram.java @@ -0,0 +1,164 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml; + +import java.awt.geom.Dimension2D; +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import net.sourceforge.plantuml.core.Diagram; +import net.sourceforge.plantuml.creole.Atom; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.AbstractTextBlock; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.Line; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.preproc.Defines; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UImage; +import net.sourceforge.plantuml.ugraphic.UImageSvg; +import net.sourceforge.plantuml.ugraphic.UShape; + +public class EmbeddedDiagram implements CharSequence { + + private final Display system; + + public EmbeddedDiagram(Display system) { + this.system = system; + } + + public int length() { + return toString().length(); + } + + public char charAt(int index) { + return toString().charAt(index); + } + + public CharSequence subSequence(int start, int end) { + return toString().subSequence(start, end); + } + + public Draw asDraw(ISkinSimple skinParam) { + return new Draw(skinParam); + } + + public class Draw extends AbstractTextBlock implements Line, Atom { + private BufferedImage image; + private final ISkinSimple skinParam; + + private Draw(ISkinSimple skinParam) { + this.skinParam = skinParam; + } + + public double getStartingAltitude(StringBounder stringBounder) { + return 0; + } + + public Dimension2D calculateDimension(StringBounder stringBounder) { + try { + final BufferedImage im = getImage(); + return new Dimension2DDouble(im.getWidth(), im.getHeight()); + } catch (IOException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + return new Dimension2DDouble(42, 42); + } + + public void drawU(UGraphic ug) { + try { + final boolean isSvg = ug.matchesProperty("SVG"); + if (isSvg) { + final String imageSvg = getImageSvg(); + final SvgString svg = new SvgString(imageSvg, 1); + ug.draw(new UImageSvg(svg)); + return; + } + final BufferedImage im = getImage(); + final UShape image = new UImage(im); + ug.draw(image); + } catch (IOException e) { + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + } + + private String getImageSvg() throws IOException, InterruptedException { + final Diagram system = getSystem(); + final ByteArrayOutputStream os = new ByteArrayOutputStream(); + system.exportDiagram(os, 0, new FileFormatOption(FileFormat.SVG)); + os.close(); + return new String(os.toByteArray()); + } + + private BufferedImage getImage() throws IOException, InterruptedException { + if (image == null) { + image = getImageSlow(); + } + return image; + } + + private BufferedImage getImageSlow() throws IOException, InterruptedException { + final Diagram system = getSystem(); + final ByteArrayOutputStream os = new ByteArrayOutputStream(); + system.exportDiagram(os, 0, new FileFormatOption(FileFormat.PNG)); + os.close(); + final ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray()); + final BufferedImage im = ImageIO.read(is); + is.close(); + return im; + } + + public HorizontalAlignment getHorizontalAlignment() { + return HorizontalAlignment.LEFT; + } + + private Diagram getSystem() throws IOException, InterruptedException { + final BlockUml blockUml = new BlockUml(system.as2(), Defines.createEmpty(), skinParam); + return blockUml.getDiagram(); + + } + } + +} diff --git a/src/net/sourceforge/plantuml/ISkinSimple.java b/src/net/sourceforge/plantuml/ISkinSimple.java index a9dd7e7bc..b008383e8 100644 --- a/src/net/sourceforge/plantuml/ISkinSimple.java +++ b/src/net/sourceforge/plantuml/ISkinSimple.java @@ -35,6 +35,8 @@ */ package net.sourceforge.plantuml; +import java.util.Map; + import net.sourceforge.plantuml.graphic.IHtmlColorSet; import net.sourceforge.plantuml.ugraphic.ColorMapper; @@ -42,18 +44,22 @@ public interface ISkinSimple extends SpriteContainer { public String getValue(String key); + public Map values(); + public double getPadding(); - + public String getMonospacedFamily(); public int getTabSize(); - + public IHtmlColorSet getIHtmlColorSet(); - + public int getDpi(); - + public LineBreakStrategy wrapWidth(); - + public ColorMapper getColorMapper(); + public void copyAllFrom(ISkinSimple other); + } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/PSystemBuilder.java b/src/net/sourceforge/plantuml/PSystemBuilder.java index 04240752f..72f1bb54e 100644 --- a/src/net/sourceforge/plantuml/PSystemBuilder.java +++ b/src/net/sourceforge/plantuml/PSystemBuilder.java @@ -68,17 +68,18 @@ import net.sourceforge.plantuml.eggs.PSystemRIPFactory; import net.sourceforge.plantuml.eggs.PSystemWelcomeFactory; import net.sourceforge.plantuml.flowdiagram.FlowDiagramFactory; import net.sourceforge.plantuml.font.PSystemListFontsFactory; +import net.sourceforge.plantuml.help.HelpFactory; import net.sourceforge.plantuml.jcckit.PSystemJcckitFactory; import net.sourceforge.plantuml.jungle.PSystemTreeFactory; import net.sourceforge.plantuml.logo.PSystemLogoFactory; import net.sourceforge.plantuml.math.PSystemLatexFactory; import net.sourceforge.plantuml.math.PSystemMathFactory; +import net.sourceforge.plantuml.mindmap.MindMapDiagramFactory; import net.sourceforge.plantuml.nwdiag.NwDiagramFactory; import net.sourceforge.plantuml.openiconic.PSystemListOpenIconicFactory; import net.sourceforge.plantuml.openiconic.PSystemOpenIconicFactory; import net.sourceforge.plantuml.oregon.PSystemOregonFactory; import net.sourceforge.plantuml.postit.PostIdDiagramFactory; -import net.sourceforge.plantuml.printskin.PrintSkinFactory; import net.sourceforge.plantuml.project3.GanttDiagramFactory; import net.sourceforge.plantuml.salt.PSystemSaltFactory; import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory; @@ -95,7 +96,7 @@ public class PSystemBuilder { public static final long startTime = System.currentTimeMillis(); - final public Diagram createPSystem(final List strings2) { + final public Diagram createPSystem(ISkinSimple skinParam, final List strings2) { final long now = System.currentTimeMillis(); @@ -117,7 +118,7 @@ public class PSystemBuilder { final DiagramType diagramType = umlSource.getDiagramType(); final List errors = new ArrayList(); - final List factories = getAllFactories(); + final List factories = getAllFactories(skinParam); for (PSystemFactory systemFactory : factories) { if (diagramType != systemFactory.getDiagramType()) { continue; @@ -141,11 +142,11 @@ public class PSystemBuilder { } - private List getAllFactories() { + private List getAllFactories(ISkinSimple skinParam) { final List factories = new ArrayList(); factories.add(new PSystemWelcomeFactory()); factories.add(new PSystemColorsFactory()); - factories.add(new SequenceDiagramFactory()); + factories.add(new SequenceDiagramFactory(skinParam)); factories.add(new ClassDiagramFactory()); factories.add(new ActivityDiagramFactory()); factories.add(new DescriptionDiagramFactory()); @@ -155,7 +156,7 @@ public class PSystemBuilder { // factories.add(new ObjectDiagramFactory()); factories.add(new BpmDiagramFactory(DiagramType.BPM)); factories.add(new PostIdDiagramFactory()); - factories.add(new PrintSkinFactory()); + // factories.add(new PrintSkinFactory()); factories.add(new PSystemLicenseFactory()); factories.add(new PSystemVersionFactory()); factories.add(new PSystemDonorsFactory()); @@ -169,6 +170,7 @@ public class PSystemBuilder { factories.add(new PSystemDotFactory(DiagramType.DOT)); factories.add(new PSystemDotFactory(DiagramType.UML)); factories.add(new NwDiagramFactory()); + factories.add(new MindMapDiagramFactory()); if (License.getCurrent() == License.GPL || License.getCurrent() == License.GPLV2) { factories.add(new PSystemDitaaFactory(DiagramType.DITAA)); factories.add(new PSystemDitaaFactory(DiagramType.UML)); @@ -199,6 +201,7 @@ public class PSystemBuilder { factories.add(new PSystemCuteFactory(DiagramType.CUTE)); factories.add(new PSystemDedicationFactory()); factories.add(new TimingDiagramFactory()); + factories.add(new HelpFactory()); return factories; } diff --git a/src/net/sourceforge/plantuml/Run.java b/src/net/sourceforge/plantuml/Run.java index 7f166b258..05f17f7f3 100644 --- a/src/net/sourceforge/plantuml/Run.java +++ b/src/net/sourceforge/plantuml/Run.java @@ -336,7 +336,7 @@ public class Run { } private static void managePattern() { - printPattern(new SequenceDiagramFactory()); + printPattern(new SequenceDiagramFactory(null)); printPattern(new ClassDiagramFactory()); printPattern(new ActivityDiagramFactory()); printPattern(new DescriptionDiagramFactory()); diff --git a/src/net/sourceforge/plantuml/SkinParam.java b/src/net/sourceforge/plantuml/SkinParam.java index 63ab65175..91c7210c5 100644 --- a/src/net/sourceforge/plantuml/SkinParam.java +++ b/src/net/sourceforge/plantuml/SkinParam.java @@ -84,6 +84,14 @@ public class SkinParam implements ISkinParam { private final UmlDiagramType type; private boolean useVizJs; + public void copyAllFrom(ISkinSimple other) { + this.params.putAll(other.values()); + } + + public Map values() { + return Collections.unmodifiableMap(params); + } + public void setParam(String key, String value) { for (String key2 : cleanForKey(key)) { params.put(key2, StringUtils.trin(value)); @@ -425,6 +433,7 @@ public class SkinParam implements ISkinParam { result.add("SwimlaneWidth"); result.add("SwimlaneWrapTitleWidth"); result.add("FixCircleLabelOverlapping"); + result.add("LifelineStrategy"); for (FontParam p : EnumSet.allOf(FontParam.class)) { final String h = humanName(p.name()); diff --git a/src/net/sourceforge/plantuml/SkinParamDelegator.java b/src/net/sourceforge/plantuml/SkinParamDelegator.java index 16ca6b617..9ca92c204 100644 --- a/src/net/sourceforge/plantuml/SkinParamDelegator.java +++ b/src/net/sourceforge/plantuml/SkinParamDelegator.java @@ -35,6 +35,8 @@ */ package net.sourceforge.plantuml; +import java.util.Map; + import net.sourceforge.plantuml.cucadiagram.Rankdir; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.dot.DotSplines; @@ -308,4 +310,12 @@ public class SkinParamDelegator implements ISkinParam { return skinParam.isUseVizJs(); } + public void copyAllFrom(ISkinSimple other) { + skinParam.copyAllFrom(other); + } + + public Map values() { + return skinParam.values(); + } + } diff --git a/src/net/sourceforge/plantuml/SpriteContainerEmpty.java b/src/net/sourceforge/plantuml/SpriteContainerEmpty.java index bf3795d9e..5c9fb0edc 100644 --- a/src/net/sourceforge/plantuml/SpriteContainerEmpty.java +++ b/src/net/sourceforge/plantuml/SpriteContainerEmpty.java @@ -35,6 +35,8 @@ */ package net.sourceforge.plantuml; +import java.util.Map; + import net.sourceforge.plantuml.creole.CommandCreoleMonospaced; import net.sourceforge.plantuml.graphic.HtmlColorSetSimple; import net.sourceforge.plantuml.graphic.IHtmlColorSet; @@ -84,5 +86,15 @@ public class SpriteContainerEmpty implements SpriteContainer, ISkinSimple { public ColorMapper getColorMapper() { return new ColorMapperIdentity(); } + + public void copyAllFrom(ISkinSimple other) { + throw new UnsupportedOperationException(); + } + + public Map values() { + throw new UnsupportedOperationException(); + } + + } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/UmlDiagram.java b/src/net/sourceforge/plantuml/UmlDiagram.java index ea46ddfec..a846e1791 100644 --- a/src/net/sourceforge/plantuml/UmlDiagram.java +++ b/src/net/sourceforge/plantuml/UmlDiagram.java @@ -80,7 +80,6 @@ import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.mjpeg.MJPEGGenerator; import net.sourceforge.plantuml.pdf.PdfConverter; -import net.sourceforge.plantuml.sequencediagram.command.CommandSkin; import net.sourceforge.plantuml.svek.EmptySvgException; import net.sourceforge.plantuml.svek.GraphvizCrash; import net.sourceforge.plantuml.svek.TextBlockBackcolored; @@ -109,7 +108,18 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann private final Pragma pragma = new Pragma(); private Animation animation; - private final SkinParam skinParam = SkinParam.create(getUmlDiagramType()); + private final SkinParam skinParam; + + public UmlDiagram() { + this.skinParam = SkinParam.create(getUmlDiagramType()); + } + + public UmlDiagram(ISkinSimple orig) { + this(); + if (orig != null) { + this.skinParam.copyAllFrom(orig); + } + } final public void setTitle(DisplayPositionned title) { if (title.isNull() || title.getDisplay().isWhite()) { diff --git a/src/net/sourceforge/plantuml/UmlDiagramType.java b/src/net/sourceforge/plantuml/UmlDiagramType.java index 56b71534a..048ada7ff 100644 --- a/src/net/sourceforge/plantuml/UmlDiagramType.java +++ b/src/net/sourceforge/plantuml/UmlDiagramType.java @@ -36,5 +36,5 @@ package net.sourceforge.plantuml; public enum UmlDiagramType { - SEQUENCE, STATE, CLASS, OBJECT, ACTIVITY, DESCRIPTION, COMPOSITE, FLOW, TIMING, BPM, NWDIAG + SEQUENCE, STATE, CLASS, OBJECT, ACTIVITY, DESCRIPTION, COMPOSITE, FLOW, TIMING, BPM, NWDIAG, MINDMAP, HELP } diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java index a6488dc3f..7fed04901 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Snake.java @@ -59,6 +59,7 @@ import net.sourceforge.plantuml.ugraphic.comp.CompressionTransform; public class Snake implements UShape { private final Worm worm = new Worm(); + private UPolygon startDecoration; private UPolygon endDecoration; private final Rainbow color; private TextBlock textBlock; @@ -67,7 +68,7 @@ public class Snake implements UShape { private final HorizontalAlignment horizontalAlignment; public Snake transformX(CompressionTransform compressionTransform) { - final Snake result = new Snake(horizontalAlignment, color, endDecoration); + final Snake result = new Snake(startDecoration, horizontalAlignment, color, endDecoration); result.textBlock = this.textBlock; result.mergeable = this.mergeable; result.emphasizeDirection = this.emphasizeDirection; @@ -84,19 +85,25 @@ public class Snake implements UShape { } public Snake(HorizontalAlignment horizontalAlignment, Rainbow color, UPolygon endDecoration) { + this(null, horizontalAlignment, color, endDecoration); + } + + public Snake(UPolygon startDecoration, HorizontalAlignment horizontalAlignment, Rainbow color, + UPolygon endDecoration) { if (color == null) { throw new IllegalArgumentException(); } if (color.size() == 0) { throw new IllegalArgumentException(); } + this.startDecoration = startDecoration; this.endDecoration = endDecoration; this.color = color; this.horizontalAlignment = horizontalAlignment; } public Snake(HorizontalAlignment horizontalAlignment, Rainbow color) { - this(horizontalAlignment, color, null); + this(null, horizontalAlignment, color, null); } public void setLabel(TextBlock label) { @@ -104,7 +111,7 @@ public class Snake implements UShape { } public Snake move(double dx, double dy) { - final Snake result = new Snake(horizontalAlignment, color, endDecoration); + final Snake result = new Snake(startDecoration, horizontalAlignment, color, endDecoration); for (Point2D pt : worm) { result.addPoint(pt.getX() + dx, pt.getY() + dy); } @@ -135,7 +142,8 @@ public class Snake implements UShape { if (color.size() > 1) { drawRainbow(ug); } else { - worm.drawInternalOneColor(ug, color.getColors().get(0), 1.5, emphasizeDirection, endDecoration); + worm.drawInternalOneColor(startDecoration, ug, color.getColors().get(0), 1.5, emphasizeDirection, + endDecoration); drawInternalLabel(ug); } @@ -160,7 +168,7 @@ public class Snake implements UShape { if (colorArrowSeparationSpace == 0) { stroke = i == colors.size() - 1 ? 2.0 : 3.0; } - current.drawInternalOneColor(ug, colors.get(i), stroke, emphasizeDirection, endDecoration); + current.drawInternalOneColor(startDecoration, ug, colors.get(i), stroke, emphasizeDirection, endDecoration); current = mutation.mute(current); } final UTranslate textTranslate = mutation.getTextTranslate(colors.size()); @@ -243,7 +251,10 @@ public class Snake implements UShape { } if (same(this.getLast(), other.getFirst())) { final UPolygon oneOf = other.endDecoration == null ? endDecoration : other.endDecoration; - final Snake result = new Snake(horizontalAlignment, color, oneOf); + if (this.startDecoration != null || other.startDecoration != null) { + throw new UnsupportedOperationException("Not yet coded: to be done"); + } + final Snake result = new Snake(null, horizontalAlignment, color, oneOf); // result.textBlock = oneOf(this.textBlock, other.textBlock, stringBounder); result.emphasizeDirection = emphasizeDirection == null ? other.emphasizeDirection : emphasizeDirection; result.worm.addAll(this.worm.merge(other.worm, strategy)); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Worm.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Worm.java index bc06d04d5..0048c8e82 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/Worm.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/Worm.java @@ -64,8 +64,8 @@ public class Worm implements Iterable { return points.size() == 2 && points.get(0).getY() == points.get(1).getY(); } - public void drawInternalOneColor(UGraphic ug, HtmlColorAndStyle color, double stroke, Direction emphasizeDirection, - UPolygon endDecoration) { + public void drawInternalOneColor(UPolygon startDecoration, UGraphic ug, HtmlColorAndStyle color, double stroke, + Direction emphasizeDirection, UPolygon endDecoration) { final HtmlColor color2 = color.getColor(); if (color2 == null) { throw new IllegalArgumentException(); @@ -93,6 +93,11 @@ public class Worm implements Iterable { drawLine(ug, line, null); } } + if (startDecoration != null) { + ug = ug.apply(new UStroke(1.5)); + final Point2D start = points.get(0); + ug.apply(new UTranslate(start)).apply(new UStroke()).draw(startDecoration); + } if (endDecoration != null) { ug = ug.apply(new UStroke(1.5)); final Point2D end = points.get(points.size() - 1); diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/WormTexted.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/WormTexted.java index 41933cf2a..e9e31234d 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/WormTexted.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/WormTexted.java @@ -69,9 +69,9 @@ public class WormTexted implements Iterable { worm.addPoint(x, y); } - public void drawInternalOneColor(UGraphic ug, HtmlColorAndStyle color, double stroke, Direction emphasizeDirection, - UPolygon endDecoration) { - worm.drawInternalOneColor(ug, color, stroke, emphasizeDirection, endDecoration); + public void drawInternalOneColor(UPolygon startDecoration, UGraphic ug, HtmlColorAndStyle color, double stroke, + Direction emphasizeDirection, UPolygon endDecoration) { + worm.drawInternalOneColor(startDecoration, ug, color, stroke, emphasizeDirection, endDecoration); } public Worm getWorm() { diff --git a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java index f701446e3..5c1b0a7fa 100644 --- a/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java +++ b/src/net/sourceforge/plantuml/activitydiagram3/ftile/vcompact/FtileGroup.java @@ -36,6 +36,7 @@ package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact; import java.awt.geom.Dimension2D; +import java.util.Collection; import java.util.Set; import net.sourceforge.plantuml.AlignmentParam; @@ -107,6 +108,11 @@ public class FtileGroup extends AbstractFtile { final UStroke thickness = skinParam.getThickness(LineParam.partitionBorder, null); this.stroke = thickness == null ? new UStroke(2) : thickness; } + + @Override + public Collection getMyChildren() { + return inner.getMyChildren(); + } @Override public LinkRendering getInLinkRendering() { diff --git a/src/net/sourceforge/plantuml/asciiart/TextSkin.java b/src/net/sourceforge/plantuml/asciiart/TextSkin.java index a30220c78..247def47c 100644 --- a/src/net/sourceforge/plantuml/asciiart/TextSkin.java +++ b/src/net/sourceforge/plantuml/asciiart/TextSkin.java @@ -42,10 +42,10 @@ import net.sourceforge.plantuml.skin.ArrowConfiguration; import net.sourceforge.plantuml.skin.ArrowDirection; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; -import net.sourceforge.plantuml.skin.Skin; import net.sourceforge.plantuml.skin.rose.ComponentRoseGroupingSpace; +import net.sourceforge.plantuml.skin.rose.Rose; -public class TextSkin implements Skin { +public class TextSkin extends Rose { private final FileFormat fileFormat; @@ -125,8 +125,4 @@ public class TextSkin implements Skin { throw new UnsupportedOperationException(type.toString()); } - public Object getProtocolVersion() { - return 1; - } - } diff --git a/src/net/sourceforge/plantuml/command/SingleLineCommand2.java b/src/net/sourceforge/plantuml/command/SingleLineCommand2.java index 41cf88b87..1ba9e4980 100644 --- a/src/net/sourceforge/plantuml/command/SingleLineCommand2.java +++ b/src/net/sourceforge/plantuml/command/SingleLineCommand2.java @@ -44,8 +44,14 @@ import net.sourceforge.plantuml.core.Diagram; public abstract class SingleLineCommand2 implements Command { private final RegexConcat pattern; + private final boolean doTrim; public SingleLineCommand2(RegexConcat pattern) { + this(true, pattern); + } + + public SingleLineCommand2(boolean doTrim, RegexConcat pattern) { + this.doTrim = doTrim; if (pattern == null) { throw new IllegalArgumentException(); } @@ -64,6 +70,13 @@ public abstract class SingleLineCommand2 implements Command implements Command implements Command implements Command it = new MatcherIterator(matcher); diff --git a/src/net/sourceforge/plantuml/core/DiagramType.java b/src/net/sourceforge/plantuml/core/DiagramType.java index 45fa769a5..6e99cc493 100644 --- a/src/net/sourceforge/plantuml/core/DiagramType.java +++ b/src/net/sourceforge/plantuml/core/DiagramType.java @@ -38,7 +38,7 @@ package net.sourceforge.plantuml.core; import net.sourceforge.plantuml.utils.StartUtils; public enum DiagramType { - UML, BPM, DITAA, DOT, PROJECT, JCCKIT, SALT, FLOW, CREOLE, JUNGLE, CUTE, MATH, LATEX, DEFINITION, GANTT, NW, UNKNOWN; + UML, BPM, DITAA, DOT, PROJECT, JCCKIT, SALT, FLOW, CREOLE, JUNGLE, CUTE, MATH, LATEX, DEFINITION, GANTT, NW, MINDMAP, UNKNOWN; static public DiagramType getTypeFromArobaseStart(String s) { s = s.toLowerCase(); @@ -93,6 +93,9 @@ public enum DiagramType { if (StartUtils.startsWithSymbolAnd("startnwdiag", s)) { return NW; } + if (StartUtils.startsWithSymbolAnd("startmindmap", s)) { + return MINDMAP; + } return UNKNOWN; } } diff --git a/src/net/sourceforge/plantuml/creole/Atom.java b/src/net/sourceforge/plantuml/creole/Atom.java index d6a193d82..e963b40f2 100644 --- a/src/net/sourceforge/plantuml/creole/Atom.java +++ b/src/net/sourceforge/plantuml/creole/Atom.java @@ -41,7 +41,7 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UShape; -interface Atom extends UShape { +public interface Atom extends UShape { public Dimension2D calculateDimension(StringBounder stringBounder); diff --git a/src/net/sourceforge/plantuml/creole/AtomEmbededSystem.java b/src/net/sourceforge/plantuml/creole/AtomEmbededSystem.java deleted file mode 100644 index a89b53922..000000000 --- a/src/net/sourceforge/plantuml/creole/AtomEmbededSystem.java +++ /dev/null @@ -1,134 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.creole; - -import java.awt.geom.Dimension2D; -import java.awt.image.BufferedImage; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.List; - -import javax.imageio.ImageIO; - -import net.sourceforge.plantuml.BlockUml; -import net.sourceforge.plantuml.CharSequence2; -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.EmbededDiagram; -import net.sourceforge.plantuml.FileFormat; -import net.sourceforge.plantuml.FileFormatOption; -import net.sourceforge.plantuml.SvgString; -import net.sourceforge.plantuml.core.Diagram; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.preproc.Defines; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UImage; -import net.sourceforge.plantuml.ugraphic.UImageSvg; -import net.sourceforge.plantuml.ugraphic.UShape; - -class AtomEmbededSystem implements Atom { - - final private List lines2; - - public AtomEmbededSystem(EmbededDiagram sys) { - this.lines2 = sys.getLines().as2(); - } - - public double getStartingAltitude(StringBounder stringBounder) { - return 0; - } - - public Dimension2D calculateDimension(StringBounder stringBounder) { - try { - final BufferedImage im = getImage(); - return new Dimension2DDouble(im.getWidth(), im.getHeight()); - } catch (IOException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - return new Dimension2DDouble(42, 42); - } - - public void drawU(UGraphic ug) { - try { - final boolean isSvg = ug.matchesProperty("SVG"); - if (isSvg) { - final String imageSvg = getImageSvg(); - final SvgString svg = new SvgString(imageSvg, 1); - ug.draw(new UImageSvg(svg)); - return; - } - final BufferedImage im = getImage(); - final UShape image = new UImage(im); - ug.draw(image); - } catch (IOException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - } - - private String getImageSvg() throws IOException, InterruptedException { - final Diagram system = getSystem(); - final ByteArrayOutputStream os = new ByteArrayOutputStream(); - system.exportDiagram(os, 0, new FileFormatOption(FileFormat.SVG)); - os.close(); - return new String(os.toByteArray()); - } - - private BufferedImage getImage() throws IOException, InterruptedException { - final Diagram system = getSystem(); - final ByteArrayOutputStream os = new ByteArrayOutputStream(); - system.exportDiagram(os, 0, new FileFormatOption(FileFormat.PNG)); - os.close(); - final ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray()); - final BufferedImage im = ImageIO.read(is); - is.close(); - return im; - } - - // public HorizontalAlignment getHorizontalAlignment() { - // return HorizontalAlignment.LEFT; - // } - // - private Diagram getSystem() throws IOException, InterruptedException { - final BlockUml blockUml = new BlockUml(lines2, Defines.createEmpty()); - return blockUml.getDiagram(); - } - -} diff --git a/src/net/sourceforge/plantuml/creole/AtomText.java b/src/net/sourceforge/plantuml/creole/AtomText.java index 0bade2e31..fd7e22db5 100644 --- a/src/net/sourceforge/plantuml/creole/AtomText.java +++ b/src/net/sourceforge/plantuml/creole/AtomText.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.creole; import java.awt.font.LineMetrics; import java.awt.geom.Dimension2D; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.StringTokenizer; @@ -305,20 +306,25 @@ public class AtomText implements Atom { public List getSplitted(StringBounder stringBounder, LineBreakStrategy maxWidthAsString) { final double maxWidth = maxWidthAsString.getMaxWidth(); + if (maxWidth == 0) { + throw new IllegalStateException(); + } final List result = new ArrayList(); final StringTokenizer st = new StringTokenizer(text, " ", true); final StringBuilder currentLine = new StringBuilder(); while (st.hasMoreTokens()) { - final String token = st.nextToken(); - final double w = getWidth(stringBounder, currentLine + token); - if (w > maxWidth) { - result.add(new AtomText(currentLine.toString(), fontConfiguration, url, marginLeft, marginRight)); - currentLine.setLength(0); - if (token.startsWith(" ") == false) { - currentLine.append(token); + final String token1 = st.nextToken(); + for (String tmp : splitLong1(stringBounder, maxWidth, token1)) { + final double w = getWidth(stringBounder, currentLine + tmp); + if (w > maxWidth) { + result.add(new AtomText(currentLine.toString(), fontConfiguration, url, marginLeft, marginRight)); + currentLine.setLength(0); + if (tmp.startsWith(" ") == false) { + currentLine.append(tmp); + } + } else { + currentLine.append(tmp); } - } else { - currentLine.append(token); } } result.add(new AtomText(currentLine.toString(), fontConfiguration, url, marginLeft, marginRight)); @@ -326,6 +332,31 @@ public class AtomText implements Atom { } + private List splitLong1(StringBounder stringBounder, double maxWidth, String add) { + return Arrays.asList(add); + } + + private List splitLong2(StringBounder stringBounder, double maxWidth, String add) { + final List result = new ArrayList(); + if (getWidth(stringBounder, add) <= maxWidth) { + result.add(add); + return result; + } + final StringBuilder current = new StringBuilder(); + for (int i = 0; i < add.length(); i++) { + final char c = add.charAt(i); + if (getWidth(stringBounder, current.toString() + c) > maxWidth) { + result.add(current.toString()); + current.setLength(0); + } + current.append(c); + } + if (current.length() > 0) { + result.add(current.toString()); + } + return result; + } + public final String getText() { return text; } diff --git a/src/net/sourceforge/plantuml/creole/CreoleParser.java b/src/net/sourceforge/plantuml/creole/CreoleParser.java index 7d4b8125f..83087bf9e 100644 --- a/src/net/sourceforge/plantuml/creole/CreoleParser.java +++ b/src/net/sourceforge/plantuml/creole/CreoleParser.java @@ -38,7 +38,7 @@ package net.sourceforge.plantuml.creole; import java.util.Arrays; import java.util.List; -import net.sourceforge.plantuml.EmbededDiagram; +import net.sourceforge.plantuml.EmbeddedDiagram; import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.cucadiagram.Display; @@ -100,12 +100,13 @@ public class CreoleParser { final CreoleContext context = new CreoleContext(); for (CharSequence cs : display) { final Stripe stripe; - if (cs instanceof EmbededDiagram) { - final Atom atom = new AtomEmbededSystem((EmbededDiagram) cs); + if (cs instanceof EmbeddedDiagram) { + final Atom atom = ((EmbeddedDiagram) cs).asDraw(skinParam); stripe = new Stripe() { public Atom getHeader() { return null; } + public List getAtoms() { return Arrays.asList(atom); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java index 1487603d4..2bdf76bfd 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java @@ -42,10 +42,10 @@ import java.util.Collections; import java.util.List; import java.util.ListIterator; +import net.sourceforge.plantuml.EmbeddedDiagram; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.creole.CreoleMode; @@ -67,7 +67,7 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo private TextBlock area2; private final FontConfiguration titleConfig; - private final List rawBody; + private final List rawBody; private final FontParam fontParam; private final ISkinParam skinParam; private final boolean lineFirst; @@ -81,7 +81,7 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo public BodyEnhanced(List rawBody, FontParam fontParam, ISkinParam skinParam, boolean manageModifier, Stereotype stereotype, ILeaf entity) { - this.rawBody = new ArrayList(rawBody); + this.rawBody = new ArrayList(rawBody); this.stereotype = stereotype; this.fontParam = fontParam; this.skinParam = skinParam; @@ -99,7 +99,7 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo Stereotype stereotype, boolean manageHorizontalLine, boolean manageModifier, ILeaf entity) { this.entity = entity; this.stereotype = stereotype; - this.rawBody = new ArrayList(); + this.rawBody = new ArrayList(); this.fontParam = fontParam; this.skinParam = skinParam; @@ -114,7 +114,7 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo this.rawBody.add(""); } for (CharSequence s : display) { - this.rawBody.add(s.toString()); + this.rawBody.add(s); } } @@ -147,29 +147,34 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo TextBlock title = null; List members = new ArrayList(); // final LineBreakStrategy lineBreakStrategy = skinParam.wrapWidth(); - for (ListIterator it = rawBody.listIterator(); it.hasNext();) { - final String s = it.next(); - if (manageHorizontalLine && isBlockSeparator(s)) { - blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam, align, - stereotype, entity), separator, title)); - separator = s.charAt(0); - title = getTitle(s, skinParam); - members = new ArrayList(); - } else if (CreoleParser.isTreeStart(s)) { - if (members.size() > 0) { + for (ListIterator it = rawBody.listIterator(); it.hasNext();) { + final CharSequence s2 = it.next(); + if (s2 instanceof EmbeddedDiagram) { + blocks.add(((EmbeddedDiagram) s2).asDraw(skinParam)); + } else { + final String s = s2.toString(); + if (manageHorizontalLine && isBlockSeparator(s)) { blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam, align, stereotype, entity), separator, title)); - } - members = new ArrayList(); - final List allTree = buildAllTree(s, it); - final TextBlock bloc = Display.create(allTree).create(fontParam.getFontConfiguration(skinParam), align, - skinParam, CreoleMode.FULL); - blocks.add(bloc); - } else { - final Member m = new MemberImpl(s, MemberImpl.isMethod(s), manageModifier); - members.add(m); - if (m.getUrl() != null) { - urls.add(m.getUrl()); + separator = s.charAt(0); + title = getTitle(s, skinParam); + members = new ArrayList(); + } else if (CreoleParser.isTreeStart(s)) { + if (members.size() > 0) { + blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam, + align, stereotype, entity), separator, title)); + } + members = new ArrayList(); + final List allTree = buildAllTree(s, it); + final TextBlock bloc = Display.create(allTree).create(fontParam.getFontConfiguration(skinParam), + align, skinParam, CreoleMode.FULL); + blocks.add(bloc); + } else { + final Member m = new MemberImpl(s, MemberImpl.isMethod(s), manageModifier); + members.add(m); + if (m.getUrl() != null) { + urls.add(m.getUrl()); + } } } } @@ -188,11 +193,11 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo return area2; } - private static List buildAllTree(String init, ListIterator it) { - final List result = new ArrayList(); + private static List buildAllTree(String init, ListIterator it) { + final List result = new ArrayList(); result.add(init); while (it.hasNext()) { - final String s = it.next(); + final CharSequence s = it.next(); if (CreoleParser.isTreeStart(StringUtils.trinNoTrace(s))) { result.add(s); } else { diff --git a/src/net/sourceforge/plantuml/cucadiagram/Display.java b/src/net/sourceforge/plantuml/cucadiagram/Display.java index b2b4eb781..96a539a87 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Display.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Display.java @@ -45,7 +45,7 @@ import java.util.List; import net.sourceforge.plantuml.BackSlash; import net.sourceforge.plantuml.CharSequence2; import net.sourceforge.plantuml.CharSequence2Impl; -import net.sourceforge.plantuml.EmbededDiagram; +import net.sourceforge.plantuml.EmbeddedDiagram; import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.LineLocationImpl; @@ -190,11 +190,11 @@ public class Display implements Iterable { boolean isNull, CreoleMode defaultCreoleMode) { this(naturalHorizontalAlignment, isNull, defaultCreoleMode); if (isNull == false) { - this.display.addAll(manageEmbededDiagrams2(other)); + this.display.addAll(manageEmbeddedDiagrams(other)); } } - private static List manageEmbededDiagrams2(final Collection strings) { + private static List manageEmbeddedDiagrams(final Collection strings) { final List result = new ArrayList(); final Iterator it = strings.iterator(); while (it.hasNext()) { @@ -210,7 +210,7 @@ public class Display implements Iterable { other.add(s2); } other.add("@enduml"); - s = new EmbededDiagram(Display.create(other)); + s = new EmbeddedDiagram(Display.create(other)); } result.add(s); } @@ -480,11 +480,8 @@ public class Display implements Iterable { if (stereotype.isSpotted()) { circledCharacter = new CircledCharacter(stereotype.getCharacter(), stereotype.getRadius(), stereotype.getCircledFont(), stereotype.getHtmlColor(), null, fontConfiguration.getColor()); - } else if (stereotype.getSprite() != null) { - final Sprite tmp = spriteContainer.getSprite(stereotype.getSprite()); - if (tmp != null) { - circledCharacter = tmp.asTextBlock(stereotype.getHtmlColor(), 1); - } + } else { + circledCharacter = stereotype.getSprite(spriteContainer); } if (circledCharacter != null) { if (stereotype.getLabel(false) == null) { diff --git a/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java b/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java index 1a819aeb3..cfc30daaf 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java +++ b/src/net/sourceforge/plantuml/cucadiagram/MethodsOrFieldsArea.java @@ -210,6 +210,11 @@ public class MethodsOrFieldsArea extends AbstractTextBlock implements TextBlockW public void drawU(UGraphic ug) { } + + @Override + public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) { + return null; + } public Dimension2D calculateDimension(StringBounder stringBounder) { return new Dimension2DDouble(1, 1); diff --git a/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java b/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java index 88fd6c6b4..e00b84997 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Stereotype.java @@ -42,22 +42,48 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +import net.sourceforge.plantuml.SpriteContainer; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.command.regex.Matcher2; import net.sourceforge.plantuml.command.regex.MyPattern; import net.sourceforge.plantuml.command.regex.Pattern2; +import net.sourceforge.plantuml.command.regex.RegexComposed; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; +import net.sourceforge.plantuml.creole.CommandCreoleImg; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.IHtmlColorSet; +import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.svek.PackageStyle; import net.sourceforge.plantuml.ugraphic.UFont; +import net.sourceforge.plantuml.ugraphic.sprite.Sprite; import net.sourceforge.plantuml.ugraphic.sprite.SpriteUtils; public class Stereotype implements CharSequence { - private final static Pattern2 circleChar = MyPattern - .cmpile("\\<\\<[%s]*\\(?(\\S)[%s]*,[%s]*(#[0-9a-fA-F]{6}|\\w+)[%s]*(?:[),](.*?))?\\>\\>"); - private final static Pattern2 circleSprite = MyPattern.cmpile("\\<\\<[%s]*\\(?\\$(" + SpriteUtils.SPRITE_NAME - + ")[%s]*(?:,[%s]*(#[0-9a-fA-F]{6}|\\w+))?[%s]*(?:[),](.*?))?\\>\\>"); + private final static RegexComposed circleChar = new RegexConcat( // + new RegexLeaf("\\<\\<[%s]*"), // + new RegexLeaf("\\(?"), // + new RegexLeaf("CHAR", "(\\S)"), // + new RegexLeaf("[%s]*,[%s]*"), // + new RegexLeaf("COLOR", "(#[0-9a-fA-F]{6}|\\w+)"), // + new RegexLeaf("[%s]*"), // + new RegexLeaf("LABEL", "(?:[),](.*?))?"), // + new RegexLeaf("\\>\\>") // + ); + + private final static RegexComposed circleSprite = new RegexConcat( // + new RegexLeaf("\\<\\<[%s]*"), // + new RegexLeaf("\\(?\\$"), // + new RegexLeaf("NAME", "(" + SpriteUtils.SPRITE_NAME + ")"), // + new RegexLeaf("SCALE", "((?:\\{scale=|\\*)([0-9.]+)\\}?)?"), // + new RegexLeaf("[%s]*"), // + new RegexLeaf("COLOR", "(?:,[%s]*(#[0-9a-fA-F]{6}|\\w+))?"), // + new RegexLeaf("[%s]*"), // + new RegexLeaf("LABEL", "(?:[),](.*?))?"), // + new RegexLeaf("\\>\\>") // + ); private final double radius; private final UFont circledFont; @@ -66,11 +92,28 @@ public class Stereotype implements CharSequence { private String label; private HtmlColor htmlColor; private char character; - private String sprite; + private String spriteName; + private double spriteScale; public Stereotype(String label, double radius, UFont circledFont, IHtmlColorSet htmlColorSet) { this(label, radius, circledFont, true, htmlColorSet); } + + public Stereotype(String label, boolean automaticPackageStyle) { + this.automaticPackageStyle = automaticPackageStyle; + this.label = label; + this.htmlColor = null; + this.character = '\0'; + this.radius = 0; + this.circledFont = null; + if (label.startsWith("<<$") && label.endsWith(">>")) { + final RegexResult mCircleSprite = circleSprite.matcher(label); + this.spriteName = mCircleSprite.get("NAME", 0); + this.spriteScale = CommandCreoleImg.getScale(mCircleSprite.get("SCALE", 0), 1); + } else { + this.spriteName = null; + } + } public Stereotype(String label, double radius, UFont circledFont, boolean automaticPackageStyle, IHtmlColorSet htmlColorSet) { @@ -88,29 +131,30 @@ public class Stereotype implements CharSequence { final List list = cutLabels(label, false); for (String local : list) { - final Matcher2 mCircleChar = circleChar.matcher(local); - final Matcher2 mCircleSprite = circleSprite.matcher(local); - if (mCircleSprite.find()) { - if (StringUtils.isNotEmpty(mCircleSprite.group(3))) { - local = "<<" + mCircleSprite.group(3) + ">>"; + final RegexResult mCircleChar = circleChar.matcher(local); + final RegexResult mCircleSprite = circleSprite.matcher(local); + if (mCircleSprite != null) { + if (StringUtils.isNotEmpty(mCircleSprite.get("LABEL", 0))) { + local = "<<" + mCircleSprite.get("LABEL", 0) + ">>"; } else { local = null; } - final String colName = mCircleSprite.group(2); + final String colName = mCircleSprite.get("COLOR", 0); final HtmlColor col = htmlColorSet.getColorIfValid(colName); this.htmlColor = col == null ? HtmlColorUtils.BLACK : col; - this.sprite = mCircleSprite.group(1); + this.spriteName = mCircleSprite.get("NAME", 0); this.character = '\0'; - } else if (mCircleChar.find()) { - if (StringUtils.isNotEmpty(mCircleChar.group(3))) { - local = "<<" + mCircleChar.group(3) + ">>"; + this.spriteScale = CommandCreoleImg.getScale(mCircleSprite.get("SCALE", 0), 1); + } else if (mCircleChar != null) { + if (StringUtils.isNotEmpty(mCircleChar.get("LABEL", 0))) { + local = "<<" + mCircleChar.get("LABEL", 0) + ">>"; } else { local = null; } - final String colName = mCircleChar.group(2); + final String colName = mCircleChar.get("COLOR", 0); this.htmlColor = htmlColorSet.getColorIfValid(colName); - this.character = mCircleChar.group(1).charAt(0); - this.sprite = null; + this.character = mCircleChar.get("CHAR", 0).charAt(0); + this.spriteName = null; } if (local != null) { tmpLabel.append(local); @@ -125,19 +169,6 @@ public class Stereotype implements CharSequence { this(label, true); } - public Stereotype(String label, boolean automaticPackageStyle) { - this.automaticPackageStyle = automaticPackageStyle; - this.label = label; - this.htmlColor = null; - this.character = '\0'; - this.radius = 0; - this.circledFont = null; - if (label.startsWith("<<$") && label.endsWith(">>")) { - this.sprite = label.substring(3, label.length() - 2).trim(); - } else { - this.sprite = null; - } - } public HtmlColor getHtmlColor() { return htmlColor; @@ -147,8 +178,15 @@ public class Stereotype implements CharSequence { return character; } - public final String getSprite() { - return sprite; + public final TextBlock getSprite(SpriteContainer container) { + if (spriteName == null || container == null) { + return null; + } + final Sprite tmp = container.getSprite(spriteName); + if (tmp == null) { + return null; + } + return tmp.asTextBlock(getHtmlColor(), spriteScale); } public boolean isWithOOSymbol() { diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java index 67d3b651a..e5100b76f 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java @@ -36,7 +36,9 @@ package net.sourceforge.plantuml.descdiagram.command; import net.sourceforge.plantuml.StringUtils; +import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.UrlBuilder; +import net.sourceforge.plantuml.UrlBuilder.ModeUrl; import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram; import net.sourceforge.plantuml.classdiagram.command.CommandCreateClassMultilines; import net.sourceforge.plantuml.command.CommandExecutionResult; @@ -134,6 +136,12 @@ public class CommandPackageWithUSymbol extends SingleLineCommand2 lines2; - - public EmbededSystemLine(EmbededDiagram sys) { - this.lines2 = sys.getLines().as2(); - } - - public Dimension2D calculateDimension(StringBounder stringBounder) { - try { - final BufferedImage im = getImage(); - return new Dimension2DDouble(im.getWidth(), im.getHeight()); - } catch (IOException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - return new Dimension2DDouble(42, 42); - } - - public void drawU(UGraphic ug) { - try { - final BufferedImage im = getImage(); - final UShape image = new UImage(im); - ug.draw(image); - } catch (IOException e) { - e.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - } - - private BufferedImage getImage() throws IOException, InterruptedException { - final Diagram system = getSystem(); - final ByteArrayOutputStream os = new ByteArrayOutputStream(); - system.exportDiagram(os, 0, new FileFormatOption(FileFormat.PNG)); - os.close(); - final ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray()); - final BufferedImage im = ImageIO.read(is); - is.close(); - return im; - } - - public HorizontalAlignment getHorizontalAlignment() { - return HorizontalAlignment.LEFT; - } - - private Diagram getSystem() throws IOException, InterruptedException { - final BlockUml blockUml = new BlockUml(lines2, Defines.createEmpty()); - return blockUml.getDiagram(); - - } -} diff --git a/src/net/sourceforge/plantuml/graphic/Line.java b/src/net/sourceforge/plantuml/graphic/Line.java index 4220cfc07..4093d0d29 100644 --- a/src/net/sourceforge/plantuml/graphic/Line.java +++ b/src/net/sourceforge/plantuml/graphic/Line.java @@ -36,7 +36,7 @@ package net.sourceforge.plantuml.graphic; -interface Line extends TextBlock { +public interface Line extends TextBlock { HorizontalAlignment getHorizontalAlignment(); } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java index 805e6ef21..ec8fec644 100644 --- a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java +++ b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java @@ -300,7 +300,11 @@ public class QuoteUtils { "P unf gur fcrrq naq rssvpvrapl bs nffrzoyl ynathntr pbzovarq jvgu ernqnovyvgl bs nffrzoyl ynathntr", "Crey vf gur bayl ynathntr gung ybbxf gur fnzr orsber naq nsgre EFN rapelcgvba", "Gur zber vg snvyf, gur zber yvxryl vg vf gung vg jvyy jbex", - "V ubcr V qvqa'g gnxr hc gbb zhpu bs lbhe gvzr", "Lbh'er tbaan arrq n ovttre obng"); + "V ubcr V qvqa'g gnxr hc gbb zhpu bs lbhe gvzr", "Lbh'er tbaan arrq n ovttre obng", + "Dhnaq ibhf rgrf rzorgrf, rzoebhvyyrm gbhg", "Gurer nva'g ab phevat jung'f jebat jvgu gung guvat", + "Vs lbh cevpx hf, qb jr abg oyrrq?", "V qvq lbhe wbo bapr - V jnf tbbq ng vg.", + "Vyf cbheenvrag snver har fryrpgvba nh fgnaqneq...", "Gung'f ab jnl gb gerng n sevraq.", + "Ubjrire ornhgvshy gur fgengrtl, lbh fubhyq bppnfvbanyyl ybbx ng gur erfhygf"); private QuoteUtils() { } diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java b/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java index cd723b3b7..a0c3d3229 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockSimple.java @@ -42,7 +42,7 @@ import java.util.List; import java.util.StringTokenizer; import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.EmbededDiagram; +import net.sourceforge.plantuml.EmbeddedDiagram; import net.sourceforge.plantuml.SpriteContainer; import net.sourceforge.plantuml.command.regex.MyPattern; import net.sourceforge.plantuml.cucadiagram.Display; @@ -91,8 +91,8 @@ public class TextBlockSimple extends AbstractTextBlock implements TextBlock { lines2.addAll(createLinesForStereotype( fontConfiguration.forceFont(fontForStereotype, htmlColorForStereotype), (Stereotype) s, horizontalAlignment, spriteContainer)); - } else if (s instanceof EmbededDiagram) { - lines2.add(new EmbededSystemLine((EmbededDiagram) s)); + } else if (s instanceof EmbeddedDiagram) { + lines2.add(((EmbeddedDiagram) s).asDraw(null)); } else { addInLines(stringBounder, s.toString()); } diff --git a/src/net/sourceforge/plantuml/help/CommandHelp.java b/src/net/sourceforge/plantuml/help/CommandHelp.java new file mode 100644 index 000000000..85288d864 --- /dev/null +++ b/src/net/sourceforge/plantuml/help/CommandHelp.java @@ -0,0 +1,73 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.help; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; + +public class CommandHelp extends SingleLineCommand2 { + + public CommandHelp() { + super(getRegexConcat()); + } + + static RegexConcat getRegexConcat() { + return new RegexConcat(new RegexLeaf("^"), // + new RegexLeaf("help"), // + new RegexLeaf("$")); + } + + @Override + protected CommandExecutionResult executeArg(Help diagram, RegexResult arg) { + diagram.add("General help"); + diagram.add(" "); + diagram.add("The code of this command is located in net.sourceforge.plantuml.help package."); + diagram.add("You may improve it on https://github.com/plantuml/plantuml/tree/master/src/net/sourceforge/plantuml/help"); + diagram.add(" "); + diagram.add(" There are some other help command:"); + diagram.add("* help types"); + diagram.add("* help keywords"); + diagram.add("* help preprocessors"); + diagram.add("* help colors"); + diagram.add("* help font"); + diagram.add("* help skinparams"); + + return CommandExecutionResult.ok(); + } +} diff --git a/src/net/sourceforge/plantuml/help/CommandHelpColor.java b/src/net/sourceforge/plantuml/help/CommandHelpColor.java new file mode 100644 index 000000000..dcdaaea72 --- /dev/null +++ b/src/net/sourceforge/plantuml/help/CommandHelpColor.java @@ -0,0 +1,74 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.help; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; +import net.sourceforge.plantuml.graphic.HtmlColorSetSimple; +import net.sourceforge.plantuml.syntax.LanguageDescriptor; + +public class CommandHelpColor extends SingleLineCommand2 { + + public CommandHelpColor() { + super(getRegexConcat()); + } + + static RegexConcat getRegexConcat() { + return new RegexConcat(new RegexLeaf("^"), // + new RegexLeaf("help"), // + new RegexLeaf("[%s]+"), // + new RegexLeaf("colors?"), // + new RegexLeaf("$")); + } + + @Override + protected CommandExecutionResult executeArg(Help diagram, RegexResult arg) { + diagram.add("Help on colors"); + diagram.add(" "); + diagram.add("The code of this command is located in net.sourceforge.plantuml.help package."); + diagram.add("You may improve it on https://github.com/plantuml/plantuml/tree/master/src/net/sourceforge/plantuml/help"); + diagram.add(" "); + diagram.add(" The possible colors are :"); + for (String type : new HtmlColorSetSimple().names()) { + diagram.add("* " + type); + } + + return CommandExecutionResult.ok(); + } +} diff --git a/src/net/sourceforge/plantuml/help/CommandHelpFont.java b/src/net/sourceforge/plantuml/help/CommandHelpFont.java new file mode 100644 index 000000000..7c505c828 --- /dev/null +++ b/src/net/sourceforge/plantuml/help/CommandHelpFont.java @@ -0,0 +1,76 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.help; + +import java.awt.GraphicsEnvironment; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; +import net.sourceforge.plantuml.syntax.LanguageDescriptor; + +public class CommandHelpFont extends SingleLineCommand2 { + + public CommandHelpFont() { + super(getRegexConcat()); + } + + static RegexConcat getRegexConcat() { + return new RegexConcat(new RegexLeaf("^"), // + new RegexLeaf("help"), // + new RegexLeaf("[%s]+"), // + new RegexLeaf("fonts?"), // + new RegexLeaf("$")); + } + + @Override + protected CommandExecutionResult executeArg(Help diagram, RegexResult arg) { + diagram.add("Help on font"); + diagram.add(" "); + diagram.add("The code of this command is located in net.sourceforge.plantuml.help package."); + diagram.add("You may improve it on https://github.com/plantuml/plantuml/tree/master/src/net/sourceforge/plantuml/help"); + diagram.add(" "); + diagram.add(" The possible font on your system are :"); + final String name[] = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); + for (String n : name) { + diagram.add("* " + n); + } + + return CommandExecutionResult.ok(); + } +} diff --git a/src/net/sourceforge/plantuml/help/CommandHelpKeyword.java b/src/net/sourceforge/plantuml/help/CommandHelpKeyword.java new file mode 100644 index 000000000..bb57068de --- /dev/null +++ b/src/net/sourceforge/plantuml/help/CommandHelpKeyword.java @@ -0,0 +1,73 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.help; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; +import net.sourceforge.plantuml.syntax.LanguageDescriptor; + +public class CommandHelpKeyword extends SingleLineCommand2 { + + public CommandHelpKeyword() { + super(getRegexConcat()); + } + + static RegexConcat getRegexConcat() { + return new RegexConcat(new RegexLeaf("^"), // + new RegexLeaf("help"), // + new RegexLeaf("[%s]+"), // + new RegexLeaf("keywords?"), // + new RegexLeaf("$")); + } + + @Override + protected CommandExecutionResult executeArg(Help diagram, RegexResult arg) { + diagram.add("Help on keywords"); + diagram.add(" "); + diagram.add("The code of this command is located in net.sourceforge.plantuml.help package."); + diagram.add("You may improve it on https://github.com/plantuml/plantuml/tree/master/src/net/sourceforge/plantuml/help"); + diagram.add(" "); + diagram.add(" The possible keywords are :"); + for (String type : new LanguageDescriptor().getKeyword()) { + diagram.add("* " + type); + } + + return CommandExecutionResult.ok(); + } +} diff --git a/src/net/sourceforge/plantuml/help/CommandHelpSkinparam.java b/src/net/sourceforge/plantuml/help/CommandHelpSkinparam.java new file mode 100644 index 000000000..230e13604 --- /dev/null +++ b/src/net/sourceforge/plantuml/help/CommandHelpSkinparam.java @@ -0,0 +1,74 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.help; + +import net.sourceforge.plantuml.SkinParam; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; +import net.sourceforge.plantuml.syntax.LanguageDescriptor; + +public class CommandHelpSkinparam extends SingleLineCommand2 { + + public CommandHelpSkinparam() { + super(getRegexConcat()); + } + + static RegexConcat getRegexConcat() { + return new RegexConcat(new RegexLeaf("^"), // + new RegexLeaf("help"), // + new RegexLeaf("[%s]+"), // + new RegexLeaf("skinparams?"), // + new RegexLeaf("$")); + } + + @Override + protected CommandExecutionResult executeArg(Help diagram, RegexResult arg) { + diagram.add("Help on skinparam"); + diagram.add(" "); + diagram.add("The code of this command is located in net.sourceforge.plantuml.help package."); + diagram.add("You may improve it on https://github.com/plantuml/plantuml/tree/master/src/net/sourceforge/plantuml/help"); + diagram.add(" "); + diagram.add(" The possible skinparam are :"); + for (String type : SkinParam.getPossibleValues()) { + diagram.add("* " + type); + } + + return CommandExecutionResult.ok(); + } +} diff --git a/src/net/sourceforge/plantuml/help/CommandHelpType.java b/src/net/sourceforge/plantuml/help/CommandHelpType.java new file mode 100644 index 000000000..f7f5ff6d8 --- /dev/null +++ b/src/net/sourceforge/plantuml/help/CommandHelpType.java @@ -0,0 +1,73 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.help; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; +import net.sourceforge.plantuml.syntax.LanguageDescriptor; + +public class CommandHelpType extends SingleLineCommand2 { + + public CommandHelpType() { + super(getRegexConcat()); + } + + static RegexConcat getRegexConcat() { + return new RegexConcat(new RegexLeaf("^"), // + new RegexLeaf("help"), // + new RegexLeaf("[%s]+"), // + new RegexLeaf("types?"), // + new RegexLeaf("$")); + } + + @Override + protected CommandExecutionResult executeArg(Help diagram, RegexResult arg) { + diagram.add("Help on types"); + diagram.add(" "); + diagram.add("The code of this command is located in net.sourceforge.plantuml.help package."); + diagram.add("You may improve it on https://github.com/plantuml/plantuml/tree/master/src/net/sourceforge/plantuml/help"); + diagram.add(" "); + diagram.add(" The possible types are :"); + for (String type : new LanguageDescriptor().getType()) { + diagram.add("* " + type); + } + + return CommandExecutionResult.ok(); + } +} diff --git a/src/net/sourceforge/plantuml/help/Help.java b/src/net/sourceforge/plantuml/help/Help.java new file mode 100644 index 000000000..a87545e0d --- /dev/null +++ b/src/net/sourceforge/plantuml/help/Help.java @@ -0,0 +1,92 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + */ +package net.sourceforge.plantuml.help; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; + +import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.LineBreakStrategy; +import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.core.DiagramDescription; +import net.sourceforge.plantuml.core.ImageData; +import net.sourceforge.plantuml.creole.CreoleMode; +import net.sourceforge.plantuml.creole.CreoleParser; +import net.sourceforge.plantuml.creole.Sheet; +import net.sourceforge.plantuml.creole.SheetBlock1; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; +import net.sourceforge.plantuml.ugraphic.ImageBuilder; +import net.sourceforge.plantuml.ugraphic.UFont; + +public class Help extends UmlDiagram { + + private final List lines = new ArrayList(); + + public DiagramDescription getDescription() { + return new DiagramDescription("(Help)"); + } + + @Override + public UmlDiagramType getUmlDiagramType() { + return UmlDiagramType.HELP; + } + + @Override + protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormat) + throws IOException { + final Display display = Display.create(lines); + final UFont font = UFont.serif(16); + final FontConfiguration fontConfiguration = FontConfiguration.blackBlueTrue(font); + final Sheet sheet = new CreoleParser(fontConfiguration, HorizontalAlignment.LEFT, getSkinParam(), + CreoleMode.FULL).createSheet(display); + final SheetBlock1 sheetBlock = new SheetBlock1(sheet, LineBreakStrategy.NONE, 0); + + final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, null, null, null, 0, 0, null, + false); + builder.setUDrawable(sheetBlock); + return builder.writeImageTOBEMOVED(fileFormat, 0, os); + } + + public void add(CharSequence line) { + this.lines.add(line); + } + +} diff --git a/src/net/sourceforge/plantuml/printskin/PrintSkinFactory.java b/src/net/sourceforge/plantuml/help/HelpFactory.java similarity index 64% rename from src/net/sourceforge/plantuml/printskin/PrintSkinFactory.java rename to src/net/sourceforge/plantuml/help/HelpFactory.java index 3f209f604..e10a418f0 100644 --- a/src/net/sourceforge/plantuml/printskin/PrintSkinFactory.java +++ b/src/net/sourceforge/plantuml/help/HelpFactory.java @@ -33,27 +33,34 @@ * * */ -package net.sourceforge.plantuml.printskin; +package net.sourceforge.plantuml.help; -import java.util.Arrays; +import java.util.ArrayList; +import java.util.List; -import net.sourceforge.plantuml.AbstractPSystem; -import net.sourceforge.plantuml.command.PSystemSingleLineFactory; -import net.sourceforge.plantuml.command.regex.Matcher2; -import net.sourceforge.plantuml.command.regex.MyPattern; -import net.sourceforge.plantuml.command.regex.Pattern2; +import net.sourceforge.plantuml.command.Command; +import net.sourceforge.plantuml.command.UmlDiagramFactory; -public class PrintSkinFactory extends PSystemSingleLineFactory { - - static final Pattern2 p = MyPattern.cmpile("(?i)^testskin[%s]+([\\w.]+)[%s]*(.*)$"); +public class HelpFactory extends UmlDiagramFactory { @Override - protected AbstractPSystem executeLine(String line) { - final Matcher2 m = p.matcher(line); - if (m.find() == false) { - return null; - } - return new PrintSkin(m.group(1), Arrays.asList(m.group(2))); + public Help createEmptyDiagram() { + return new Help(); + } + + @Override + protected List createCommands() { + + final List cmds = new ArrayList(); + + cmds.add(new CommandHelp()); + cmds.add(new CommandHelpColor()); + cmds.add(new CommandHelpFont()); + cmds.add(new CommandHelpKeyword()); + cmds.add(new CommandHelpSkinparam()); + cmds.add(new CommandHelpType()); + + return cmds; } } diff --git a/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java b/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java index d8e2c7a3a..eab7d99d8 100644 --- a/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java +++ b/src/net/sourceforge/plantuml/jdot/CucaDiagramFileMakerJDot.java @@ -42,11 +42,10 @@ import static gen.lib.cgraph.node__c.agnode; import static gen.lib.cgraph.subg__c.agsubg; import static gen.lib.gvc.gvc__c.gvContext; import static gen.lib.gvc.gvlayout__c.gvLayoutJobs; -import h.ST_Agraph_s; -import h.ST_Agraphinfo_t; import h.ST_Agedge_s; import h.ST_Agnode_s; import h.ST_Agnodeinfo_t; +import h.ST_Agraph_s; import h.ST_Agraphinfo_t; import h.ST_GVC_s; import h.ST_boxf; @@ -108,7 +107,6 @@ import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; -import net.sourceforge.plantuml.ugraphic.sprite.Sprite; import smetana.core.CString; import smetana.core.JUtils; import smetana.core.JUtilsDebug; @@ -154,7 +152,8 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { for (Map.Entry ent : edges.entrySet()) { final Link link = ent.getKey(); final ST_Agedge_s edge = ent.getValue(); - new JDotPath(link, edge, ymirror, diagram, getLabel(link), getQualifier(link, 1), getQualifier(link, 2)).drawU(ug); + new JDotPath(link, edge, ymirror, diagram, getLabel(link), getQualifier(link, 1), getQualifier(link, 2)) + .drawU(ug); } } @@ -333,11 +332,9 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { if (stereotype == null) { return TextBlockUtils.empty(0, 0); } - if (stereotype.getSprite() != null) { - final Sprite tmp = diagram.getSkinParam().getSprite(stereotype.getSprite()); - if (tmp != null) { - return tmp.asTextBlock(stereotype.getHtmlColor(), 1); - } + final TextBlock tmp = stereotype.getSprite(diagram.getSkinParam()); + if (tmp != null) { + return tmp; } final List stereos = stereotype.getLabels(diagram.getSkinParam().useGuillemet()); if (stereos == null) { diff --git a/src/net/sourceforge/plantuml/mindmap/CommandMindMapLeft.java b/src/net/sourceforge/plantuml/mindmap/CommandMindMapLeft.java new file mode 100644 index 000000000..9fe506998 --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/CommandMindMapLeft.java @@ -0,0 +1,67 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.mindmap; + +import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; + +public class CommandMindMapLeft extends SingleLineCommand2 { + + public CommandMindMapLeft() { + super(getRegexConcat()); + } + + static RegexConcat getRegexConcat() { + return new RegexConcat(new RegexLeaf("^"), // + new RegexLeaf("TYPE", "([*][<]*)"), // + new RegexLeaf("SHAPE", "(_)?"), // + new RegexLeaf("[%s]+"), // + new RegexLeaf("LABEL", "([^%s].*)"), // + new RegexLeaf("$")); + } + + @Override + protected CommandExecutionResult executeArg(MindMapDiagram diagram, RegexResult arg) { + final String type = arg.get("TYPE", 0); + final String label = arg.get("LABEL", 0); + return diagram.addIdea(type.length() - 1, label, IdeaShape.fromDesc(arg.get("SHAPE", 0)), Direction.LEFT); + } + +} diff --git a/src/net/sourceforge/plantuml/mindmap/CommandMindMapLeftNumber.java b/src/net/sourceforge/plantuml/mindmap/CommandMindMapLeftNumber.java new file mode 100644 index 000000000..29e3dabdb --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/CommandMindMapLeftNumber.java @@ -0,0 +1,67 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.mindmap; + +import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; + +public class CommandMindMapLeftNumber extends SingleLineCommand2 { + + public CommandMindMapLeftNumber() { + super(getRegexConcat()); + } + + static RegexConcat getRegexConcat() { + return new RegexConcat(new RegexLeaf("^"), // + new RegexLeaf("TYPE", "([1-9][0-9]?)[<]"), // + new RegexLeaf("SHAPE", "(_)?"), // + new RegexLeaf("[%s]+"), // + new RegexLeaf("LABEL", "([^%s].*)"), // + new RegexLeaf("$")); + } + + @Override + protected CommandExecutionResult executeArg(MindMapDiagram diagram, RegexResult arg) { + final String label = arg.get("LABEL", 0); + return diagram.addIdea(Integer.parseInt(arg.get("TYPE", 0)), label, IdeaShape.fromDesc(arg.get("SHAPE", 0)), + Direction.LEFT); + } + +} diff --git a/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmode.java b/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmode.java new file mode 100644 index 000000000..b2e9d6fcb --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/CommandMindMapOrgmode.java @@ -0,0 +1,67 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.mindmap; + +import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; + +public class CommandMindMapOrgmode extends SingleLineCommand2 { + + public CommandMindMapOrgmode() { + super(false, getRegexConcat()); + } + + static RegexConcat getRegexConcat() { + return new RegexConcat(new RegexLeaf("^"), // + new RegexLeaf("TYPE", "([*]+)"), // + new RegexLeaf("SHAPE", "(_)?"), // + new RegexLeaf("[%s]+"), // + new RegexLeaf("LABEL", "([^%s].*)"), // + new RegexLeaf("$")); + } + + @Override + protected CommandExecutionResult executeArg(MindMapDiagram diagram, RegexResult arg) { + final String type = arg.get("TYPE", 0); + final String label = arg.get("LABEL", 0); + return diagram.addIdea(type.length() - 1, label, IdeaShape.fromDesc(arg.get("SHAPE", 0)), Direction.RIGHT); + } + +} diff --git a/src/net/sourceforge/plantuml/mindmap/CommandMindMapRight.java b/src/net/sourceforge/plantuml/mindmap/CommandMindMapRight.java new file mode 100644 index 000000000..492b22789 --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/CommandMindMapRight.java @@ -0,0 +1,67 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.mindmap; + +import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; + +public class CommandMindMapRight extends SingleLineCommand2 { + + public CommandMindMapRight() { + super(getRegexConcat()); + } + + static RegexConcat getRegexConcat() { + return new RegexConcat(new RegexLeaf("^"), // + new RegexLeaf("TYPE", "([*][>]*)"), // + new RegexLeaf("SHAPE", "(_)?"), // + new RegexLeaf("[%s]+"), // + new RegexLeaf("LABEL", "([^%s].*)"), // + new RegexLeaf("$")); + } + + @Override + protected CommandExecutionResult executeArg(MindMapDiagram diagram, RegexResult arg) { + final String type = arg.get("TYPE", 0); + final String label = arg.get("LABEL", 0); + return diagram.addIdea(type.length() - 1, label, IdeaShape.fromDesc(arg.get("SHAPE", 0)), Direction.RIGHT); + } + +} diff --git a/src/net/sourceforge/plantuml/mindmap/CommandMindMapRightNumber.java b/src/net/sourceforge/plantuml/mindmap/CommandMindMapRightNumber.java new file mode 100644 index 000000000..299f693aa --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/CommandMindMapRightNumber.java @@ -0,0 +1,67 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.mindmap; + +import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; + +public class CommandMindMapRightNumber extends SingleLineCommand2 { + + public CommandMindMapRightNumber() { + super(getRegexConcat()); + } + + static RegexConcat getRegexConcat() { + return new RegexConcat(new RegexLeaf("^"), // + new RegexLeaf("TYPE", "([1-9][0-9]?)[>]"), // + new RegexLeaf("SHAPE", "(_)?"), // + new RegexLeaf("[%s]+"), // + new RegexLeaf("LABEL", "([^%s].*)"), // + new RegexLeaf("$")); + } + + @Override + protected CommandExecutionResult executeArg(MindMapDiagram diagram, RegexResult arg) { + final String label = arg.get("LABEL", 0); + return diagram.addIdea(Integer.parseInt(arg.get("TYPE", 0)), label, IdeaShape.fromDesc(arg.get("SHAPE", 0)), + Direction.RIGHT); + } + +} diff --git a/src/net/sourceforge/plantuml/mindmap/CommandMindMapRoot.java b/src/net/sourceforge/plantuml/mindmap/CommandMindMapRoot.java new file mode 100644 index 000000000..c4aa0394e --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/CommandMindMapRoot.java @@ -0,0 +1,64 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.mindmap; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; + +public class CommandMindMapRoot extends SingleLineCommand2 { + + public CommandMindMapRoot() { + super(getRegexConcat()); + } + + static RegexConcat getRegexConcat() { + return new RegexConcat(new RegexLeaf("^"), // + new RegexLeaf("TYPE", "(0)"), // + new RegexLeaf("[%s]+"), // + new RegexLeaf("LABEL", "([^%s].*)"), // + new RegexLeaf("$")); + } + + @Override + protected CommandExecutionResult executeArg(MindMapDiagram diagram, RegexResult arg) { + final String label = arg.get("LABEL", 0); + return diagram.addIdea(0, label, IdeaShape.BOX, null); + } + +} diff --git a/src/net/sourceforge/plantuml/mindmap/CommandMindMapTabulation.java b/src/net/sourceforge/plantuml/mindmap/CommandMindMapTabulation.java new file mode 100644 index 000000000..c9db66f89 --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/CommandMindMapTabulation.java @@ -0,0 +1,69 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.mindmap; + +import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.command.BlocLines; +import net.sourceforge.plantuml.command.CommandControl; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; + +public class CommandMindMapTabulation extends SingleLineCommand2 { + + public CommandMindMapTabulation() { + super(false, getRegexConcat()); + } + + static RegexConcat getRegexConcat() { + return new RegexConcat(new RegexLeaf("^"), // + new RegexLeaf("TYPE", "([ \t]*[*])"), // + new RegexLeaf("SHAPE", "(_)?"), // + new RegexLeaf("[%s]+"), // + new RegexLeaf("LABEL", "([^%s].*)"), // + new RegexLeaf("$")); + } + + @Override + protected CommandExecutionResult executeArg(MindMapDiagram diagram, RegexResult arg) { + final String type = arg.get("TYPE", 0); + final String label = arg.get("LABEL", 0); + return diagram.addIdea(type.length() - 1, label, IdeaShape.fromDesc(arg.get("SHAPE", 0)), Direction.RIGHT); + } + +} diff --git a/src/net/sourceforge/plantuml/mindmap/Finger.java b/src/net/sourceforge/plantuml/mindmap/Finger.java new file mode 100644 index 000000000..d1e05432a --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/Finger.java @@ -0,0 +1,57 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.mindmap; + +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.UDrawable; + +public interface Finger extends UDrawable { + + public double getPhalanxThickness(StringBounder stringBounder); + + public double getNailThickness(StringBounder stringBounder); + + public double getFullThickness(StringBounder stringBounder); + + public double getPhalanxElongation(StringBounder stringBounder); + + public double getNailElongation(StringBounder stringBounder); + + public double getFullElongation(StringBounder stringBounder); + + public void doNotDrawFirstPhalanx(); + +} diff --git a/src/net/sourceforge/plantuml/mindmap/FingerImpl.java b/src/net/sourceforge/plantuml/mindmap/FingerImpl.java new file mode 100644 index 000000000..cdee30fe4 --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/FingerImpl.java @@ -0,0 +1,187 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.mindmap; + +import java.awt.geom.Dimension2D; +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.List; + +import net.sourceforge.plantuml.ColorParam; +import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle; +import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBox; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.ugraphic.UChangeColor; +import net.sourceforge.plantuml.ugraphic.UFont; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UPath; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class FingerImpl implements Finger, UDrawable { + + private final Display label; + private final ISkinParam skinParam; + private final IdeaShape shape; + private final Direction direction; + private boolean drawPhalanx = true; + + private final List nail = new ArrayList(); + + public static FingerImpl build(Idea idea, ISkinParam skinParam, Direction direction) { + final FingerImpl result = new FingerImpl(idea.getLabel(), skinParam, idea.getShape(), direction); + for (Idea child : idea.getChildren()) { + result.addInNail(build(child, skinParam, direction)); + } + return result; + } + + public void addInNail(FingerImpl child) { + nail.add(child); + } + + private FingerImpl(Display label, ISkinParam skinParam, IdeaShape shape, Direction direction) { + this.label = label; + this.skinParam = skinParam; + this.shape = shape; + this.direction = direction; + } + + public double getPhalanxThickness(StringBounder stringBounder) { + return getPhalanx().calculateDimension(stringBounder).getHeight(); + } + + public double getPhalanxElongation(StringBounder stringBounder) { + return getPhalanx().calculateDimension(stringBounder).getWidth(); + } + + public double getNailThickness(StringBounder stringBounder) { + double result = 0; + for (FingerImpl child : nail) { + result += child.getFullThickness(stringBounder); + } + return result; + } + + public double getNailElongation(StringBounder stringBounder) { + double result = 0; + for (FingerImpl child : nail) { + result = Math.max(result, child.getFullElongation(stringBounder)); + } + return result; + } + + public double getFullElongation(StringBounder stringBounder) { + return getPhalanxElongation(stringBounder) + marginX1 + getNailElongation(stringBounder); + } + + public double getFullThickness(StringBounder stringBounder) { + return Math.max(getPhalanxThickness(stringBounder), getNailThickness(stringBounder)); + } + + public void doNotDrawFirstPhalanx() { + this.drawPhalanx = false; + } + + public void drawU(final UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final TextBlock phalanx = getPhalanx(); + final Dimension2D dimPhalanx = phalanx.calculateDimension(stringBounder); + if (drawPhalanx) { + final double posY = -getPhalanxThickness(stringBounder) / 2; + final double posX = direction == Direction.RIGHT ? 0 : -dimPhalanx.getWidth(); + phalanx.drawU(ug.apply(new UTranslate(posX, posY))); + } + final Point2D p1 = new Point2D.Double(direction == Direction.RIGHT ? dimPhalanx.getWidth() + : -dimPhalanx.getWidth(), 0); + + double y = -getFullThickness(stringBounder) / 2; + for (FingerImpl child : nail) { + final double childThickness = child.getFullThickness(stringBounder); + final double x = direction == Direction.RIGHT ? dimPhalanx.getWidth() + marginX1 : -dimPhalanx.getWidth() + - marginX1; + child.drawU(ug.apply(new UTranslate(x, y + childThickness / 2))); + final Point2D p2 = new Point2D.Double(x, y + childThickness / 2); + drawLine(ug.apply(new UChangeColor(getLinkColor())), p1, p2); + y += childThickness; + } + } + + private HtmlColor getLinkColor() { + // return skinParam.getColors(ColorParam.activityBorder, null).getColor(ColorType.ARROW); + return ColorParam.activityBorder.getDefaultValue(); + // return HtmlColorUtils.BLACK; + } + + final private double marginX1 = 50; + + private void drawLine(UGraphic ug, Point2D p1, Point2D p2) { + // final ULine line = new ULine(p1, p2); + // ug.apply(new UTranslate(p1)).draw(line); + final UPath path = new UPath(); + final double delta1 = direction == Direction.RIGHT ? 10 : -10; + final double delta2 = direction == Direction.RIGHT ? 25 : -25; + path.moveTo(p1); + path.lineTo(p1.getX() + delta1, p1.getY()); + path.cubicTo(p1.getX() + delta2, p1.getY(), p2.getX() - delta2, p2.getY(), p2.getX() - delta1, p2.getY()); + path.lineTo(p2); + ug.draw(path); + } + + private TextBlock getPhalanx() { + if (drawPhalanx == false) { + return TextBlockUtils.empty(0, 0); + } + final UFont font = skinParam.getFont(null, false, FontParam.ACTIVITY); + if (shape == IdeaShape.BOX) { + final FtileBox box = new FtileBox(Colors.empty().mute(skinParam), label, font, null, BoxStyle.PLAIN); + return TextBlockUtils.withMargin(box, 0, 10); + } + return TextBlockUtils.withMargin( + label.create(FontConfiguration.blackBlueTrue(font), HorizontalAlignment.LEFT, skinParam), 5, 5); + } + +} diff --git a/src/net/sourceforge/plantuml/mindmap/FingerImpl2.java b/src/net/sourceforge/plantuml/mindmap/FingerImpl2.java new file mode 100644 index 000000000..d4cef9a9b --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/FingerImpl2.java @@ -0,0 +1,215 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.mindmap; + +import java.awt.geom.Dimension2D; +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.List; + +import net.sourceforge.plantuml.ColorParam; +import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle; +import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileBox; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.graphic.TextBlockUtils; +import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.ugraphic.UChangeColor; +import net.sourceforge.plantuml.ugraphic.UFont; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UPath; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class FingerImpl2 implements Finger, UDrawable { + + // private final double xmargin = 50; + private final Display label; + private final ISkinParam skinParam; + private final IdeaShape shape; + private final Direction direction; + private boolean drawPhalanx = true; + + private final List nail = new ArrayList(); + private Tetris tetris = null; + + public static FingerImpl2 build(Idea idea, ISkinParam skinParam, Direction direction) { + final FingerImpl2 result = new FingerImpl2(idea.getLabel(), skinParam, idea.getShape(), direction); + for (Idea child : idea.getChildren()) { + result.addInNail(build(child, skinParam, direction)); + } + return result; + } + + public void addInNail(FingerImpl2 child) { + nail.add(child); + } + + private FingerImpl2(Display label, ISkinParam skinParam, IdeaShape shape, Direction direction) { + this.label = label; + this.skinParam = skinParam; + this.shape = shape; + this.direction = direction; + } + + public void drawU(final UGraphic ug) { + final StringBounder stringBounder = ug.getStringBounder(); + final TextBlock phalanx = getPhalanx(); + final Dimension2D dimPhalanx = phalanx.calculateDimension(stringBounder); + if (drawPhalanx) { + final double posY = -getPhalanxThickness(stringBounder) / 2; + final double posX = direction == Direction.RIGHT ? 0 : -dimPhalanx.getWidth(); + phalanx.drawU(ug.apply(new UTranslate(posX, posY))); + } + final Point2D p1 = new Point2D.Double(direction == Direction.RIGHT ? dimPhalanx.getWidth() + : -dimPhalanx.getWidth(), 0); + + for (int i = 0; i < nail.size(); i++) { + final FingerImpl2 child = nail.get(i); + final SymetricalTeePositioned stp = tetris(stringBounder).getElements().get(i); + final double x = direction == Direction.RIGHT ? dimPhalanx.getWidth() + getX12() : -dimPhalanx.getWidth() + - getX12(); + final Point2D p2 = new Point2D.Double(x, stp.getY()); + child.drawU(ug.apply(new UTranslate(p2))); + drawLine(ug.apply(new UChangeColor(getLinkColor())), p1, p2); + } + + } + + private HtmlColor getLinkColor() { + return ColorParam.activityBorder.getDefaultValue(); + } + + private void drawLine(UGraphic ug, Point2D p1, Point2D p2) { + // final ULine line = new ULine(p1, p2); + // ug.apply(new UTranslate(p1)).draw(line); + final UPath path = new UPath(); + final double delta1 = direction == Direction.RIGHT ? 10 : -10; + final double delta2 = direction == Direction.RIGHT ? 25 : -25; + path.moveTo(p1); + path.lineTo(p1.getX() + delta1, p1.getY()); + path.cubicTo(p1.getX() + delta2, p1.getY(), p2.getX() - delta2, p2.getY(), p2.getX() - delta1, p2.getY()); + path.lineTo(p2); + ug.draw(path); + } + + private Tetris tetris(StringBounder stringBounder) { + if (tetris == null) { + tetris = new Tetris(); + for (FingerImpl2 child : nail) { + tetris.add(child.asSymetricalTee(stringBounder)); + } + tetris.balance(); + } + return tetris; + } + + private SymetricalTee asSymetricalTee(StringBounder stringBounder) { + final double thickness1 = getPhalanxThickness(stringBounder); + final double elongation1 = getPhalanxElongation(stringBounder); + if (nail.size() == 0) { + return new SymetricalTee(thickness1, elongation1, 0, 0); + } + final double thickness2 = getNailThickness(stringBounder); + final double elongation2 = getNailElongation(stringBounder); + return new SymetricalTee(thickness1, elongation1 + getX1(), thickness2, getX2() + elongation2); + } + + private double getX1() { + return 10; + } + + private double getX2() { + return 40; + } + + public double getX12() { + return getX1() + getX2(); + } + + public double getPhalanxThickness(StringBounder stringBounder) { + return getPhalanx().calculateDimension(stringBounder).getHeight(); + } + + public double getPhalanxElongation(StringBounder stringBounder) { + return getPhalanx().calculateDimension(stringBounder).getWidth(); + } + + private TextBlock getPhalanx() { + if (drawPhalanx == false) { + return TextBlockUtils.empty(0, 0); + } + final UFont font = skinParam.getFont(null, false, FontParam.ACTIVITY); + if (shape == IdeaShape.BOX) { + final FtileBox box = new FtileBox(Colors.empty().mute(skinParam), label, font, null, BoxStyle.PLAIN); + return TextBlockUtils.withMargin(box, 0, 0, 10, 10); + } + + final TextBlock text = label.create(FontConfiguration.blackBlueTrue(font), HorizontalAlignment.LEFT, skinParam); + if (direction == Direction.RIGHT) { + return TextBlockUtils.withMargin(text, 3, 0, 1, 1); + } + return TextBlockUtils.withMargin(text, 0, 3, 1, 1); + } + + public double getNailThickness(StringBounder stringBounder) { + return tetris(stringBounder).getHeight(); + } + + public double getNailElongation(StringBounder stringBounder) { + return tetris(stringBounder).getWidth(); + } + + public double getFullThickness(StringBounder stringBounder) { + return Math.max(getPhalanxThickness(stringBounder), getNailThickness(stringBounder)); + } + + public double getFullElongation(StringBounder stringBounder) { + return getPhalanxElongation(stringBounder) + getNailElongation(stringBounder); + } + + public void doNotDrawFirstPhalanx() { + this.drawPhalanx = false; + } + +} diff --git a/src/net/sourceforge/plantuml/mindmap/Idea.java b/src/net/sourceforge/plantuml/mindmap/Idea.java new file mode 100644 index 000000000..debd04aed --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/Idea.java @@ -0,0 +1,87 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.mindmap; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import net.sourceforge.plantuml.cucadiagram.Display; + +public class Idea { + + private final Display label; + private final int level; + private final Idea parent; + private final List children = new ArrayList(); + private final IdeaShape shape; + + public Idea(int level, Idea parent, Display label, IdeaShape shape) { + this.label = label; + this.level = level; + this.parent = parent; + this.shape = shape; + if (parent != null) { + this.parent.children.add(this); + } + } + + public final int getLevel() { + return level; + } + + public final Display getLabel() { + return label; + } + + public Collection getChildren() { + return Collections.unmodifiableList(children); + } + + public boolean hasChildren() { + return children.size() > 0; + } + + public Idea getParent() { + return parent; + } + + public final IdeaShape getShape() { + return shape; + } + +} diff --git a/src/net/sourceforge/plantuml/skin/Skin.java b/src/net/sourceforge/plantuml/mindmap/IdeaShape.java similarity index 79% rename from src/net/sourceforge/plantuml/skin/Skin.java rename to src/net/sourceforge/plantuml/mindmap/IdeaShape.java index a63ee0aaa..2558c6af4 100644 --- a/src/net/sourceforge/plantuml/skin/Skin.java +++ b/src/net/sourceforge/plantuml/mindmap/IdeaShape.java @@ -30,18 +30,18 @@ * * * Original Author: Arnaud Roques - * + * * */ -package net.sourceforge.plantuml.skin; +package net.sourceforge.plantuml.mindmap; -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.cucadiagram.Display; - -public interface Skin { - - Object getProtocolVersion(); - - Component createComponent(ComponentType type, ArrowConfiguration config, ISkinParam param, Display stringsToDisplay); +public enum IdeaShape { + BOX, NONE; + public static IdeaShape fromDesc(String s) { + if ("_".equals(s)) { + return NONE; + } + return BOX; + } } diff --git a/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java b/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java new file mode 100644 index 000000000..f7df5e0b3 --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/MindMapDiagram.java @@ -0,0 +1,216 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.mindmap; + +import java.awt.geom.Dimension2D; +import java.awt.geom.Rectangle2D; +import java.io.IOException; +import java.io.OutputStream; + +import net.sourceforge.plantuml.AnnotatedWorker; +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.Direction; +import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.Scale; +import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.core.DiagramDescription; +import net.sourceforge.plantuml.core.ImageData; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.InnerStrategy; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.svek.TextBlockBackcolored; +import net.sourceforge.plantuml.ugraphic.ImageBuilder; +import net.sourceforge.plantuml.ugraphic.MinMax; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class MindMapDiagram extends UmlDiagram { + + public DiagramDescription getDescription() { + return new DiagramDescription("MindMap"); + } + + @Override + public UmlDiagramType getUmlDiagramType() { + return UmlDiagramType.MINDMAP; + } + + @Override + protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) + throws IOException { + final Scale scale = getScale(); + + final double dpiFactor = scale == null ? 1 : scale.getScale(100, 100); + final ISkinParam skinParam = getSkinParam(); + final ImageBuilder imageBuilder = new ImageBuilder(skinParam.getColorMapper(), dpiFactor, + skinParam.getBackgroundColor(), "", "", 10, 10, null, skinParam.handwritten()); + TextBlock result = getTextBlock(); + + result = new AnnotatedWorker(this, skinParam, fileFormatOption.getDefaultStringBounder()).addAdd(result); + imageBuilder.setUDrawable(result); + + return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os); + } + + private TextBlockBackcolored getTextBlock() { + return new TextBlockBackcolored() { + + public void drawU(UGraphic ug) { + drawMe(ug); + } + + public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) { + return null; + } + + public Dimension2D calculateDimension(StringBounder stringBounder) { + computeFinger(); + final double y1 = right.finger == null ? 0 : right.finger.getFullThickness(stringBounder) / 2; + final double y2 = left.finger == null ? 0 : left.finger.getFullThickness(stringBounder) / 2; + final double y = Math.max(y1, y2); + + final double x = left.finger == null ? 0 : left.finger.getFullElongation(stringBounder); + + final double width = right.finger == null ? x : x + right.finger.getFullElongation(stringBounder); + final double height = y + + Math.max(left.finger == null ? 0 : left.finger.getFullThickness(stringBounder) / 2, + right.finger == null ? 0 : right.finger.getFullThickness(stringBounder) / 2); + return new Dimension2DDouble(width, height); + + } + + public MinMax getMinMax(StringBounder stringBounder) { + throw new UnsupportedOperationException(); + } + + public HtmlColor getBackcolor() { + return null; + } + }; + } + + private void drawMe(UGraphic ug) { + computeFinger(); + + final StringBounder stringBounder = ug.getStringBounder(); + final double y1 = right.finger == null ? 0 : right.finger.getFullThickness(stringBounder) / 2; + final double y2 = left.finger == null ? 0 : left.finger.getFullThickness(stringBounder) / 2; + final double y = Math.max(y1, y2); + + final double x = left.finger == null ? 0 : left.finger.getFullElongation(stringBounder) + + ((FingerImpl2) left.finger).getX12(); + if (right.finger != null) { + right.finger.drawU(ug.apply(new UTranslate(x, y))); + } + if (left.finger != null) { + left.finger.drawU(ug.apply(new UTranslate(x, y))); + } + } + + private void computeFinger() { + if (left.finger == null && right.finger == null) { + if (left.root.hasChildren()) { + left.finger = FingerImpl2.build(left.root, getSkinParam(), Direction.LEFT); + } + if (left.finger == null || right.root.hasChildren()) { + right.finger = FingerImpl2.build(right.root, getSkinParam(), Direction.RIGHT); + } + if (left.finger != null && right.finger != null) { + left.finger.doNotDrawFirstPhalanx(); + } + } + } + + private Branch left = new Branch(); + private Branch right = new Branch(); + + public CommandExecutionResult addIdea(int level, String label, IdeaShape shape, Direction direction) { + if (level == 0) { + if (this.right.root != null) { + return CommandExecutionResult + .error("I don't know how to draw multi-root diagram. You should suggest an image so that the PlantUML team implements it :-)"); + } + right.initRoot(label, shape); + left.initRoot(label, shape); + return CommandExecutionResult.ok(); + } + if (direction == Direction.LEFT) { + return left.add(level, label, shape); + } + return right.add(level, label, shape); + } + + static class Branch { + private Idea root; + private Idea last; + private Finger finger; + + private void initRoot(String label, IdeaShape shape) { + root = new Idea(0, null, Display.getWithNewlines(label), shape); + last = root; + } + + private Idea getParentOfLast(int nb) { + Idea result = last; + for (int i = 0; i < nb; i++) { + result = result.getParent(); + } + return result; + } + + private CommandExecutionResult add(int level, String label, IdeaShape shape) { + if (level == last.getLevel() + 1) { + final Idea newIdea = new Idea(level, last, Display.getWithNewlines(label), shape); + last = newIdea; + return CommandExecutionResult.ok(); + } + if (level <= last.getLevel()) { + final int diff = last.getLevel() - level + 1; + final Idea newIdea = new Idea(level, getParentOfLast(diff), Display.getWithNewlines(label), shape); + last = newIdea; + return CommandExecutionResult.ok(); + } + return CommandExecutionResult.error("error42L"); + } + + } + +} diff --git a/src/net/sourceforge/plantuml/mindmap/MindMapDiagramFactory.java b/src/net/sourceforge/plantuml/mindmap/MindMapDiagramFactory.java new file mode 100644 index 000000000..1f7194e09 --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/MindMapDiagramFactory.java @@ -0,0 +1,72 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.mindmap; + +import java.util.ArrayList; +import java.util.List; + +import net.sourceforge.plantuml.command.Command; +import net.sourceforge.plantuml.command.UmlDiagramFactory; +import net.sourceforge.plantuml.core.DiagramType; + +public class MindMapDiagramFactory extends UmlDiagramFactory { + + public MindMapDiagramFactory() { + super(DiagramType.MINDMAP); + } + + @Override + protected List createCommands() { + + final List cmds = new ArrayList(); + addCommonCommands(cmds); + cmds.add(new CommandMindMapTabulation()); + cmds.add(new CommandMindMapOrgmode()); + cmds.add(new CommandMindMapRoot()); + cmds.add(new CommandMindMapRight()); + cmds.add(new CommandMindMapRightNumber()); + cmds.add(new CommandMindMapLeft()); + cmds.add(new CommandMindMapLeftNumber()); + + return cmds; + } + + @Override + public MindMapDiagram createEmptyDiagram() { + return new MindMapDiagram(); + } + +} diff --git a/src/net/sourceforge/plantuml/mindmap/Stripe.java b/src/net/sourceforge/plantuml/mindmap/Stripe.java new file mode 100644 index 000000000..f21ceff80 --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/Stripe.java @@ -0,0 +1,80 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.mindmap; + +public class Stripe implements Comparable { + + private final double x1; + private final double x2; + private final double value; + + @Override + public String toString() { + return "" + (int) x1 + "->" + (int) x2 + " (" + (int) value + ")"; + } + + public Stripe(double x1, double x2, double value) { + if (x2 <= x1) { + System.err.println("x1=" + x1); + System.err.println("x2=" + x2); + throw new IllegalArgumentException(); + } + this.x1 = x1; + this.x2 = x2; + this.value = value; + } + + public boolean contains(double x) { + return x >= x1 && x <= x2; + } + + public int compareTo(Stripe other) { + return (int) Math.signum(this.x1 - other.x1); + } + + public double getValue() { + return value; + } + + public final double getStart() { + return x1; + } + + public final double getEnd() { + return x2; + } + +} diff --git a/src/net/sourceforge/plantuml/mindmap/StripeFrontier.java b/src/net/sourceforge/plantuml/mindmap/StripeFrontier.java new file mode 100644 index 000000000..15e39423e --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/StripeFrontier.java @@ -0,0 +1,153 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.mindmap; + +import java.util.Iterator; +import java.util.SortedSet; +import java.util.TreeSet; + +public class StripeFrontier { + + private final SortedSet stripes = new TreeSet(); + + public StripeFrontier() { + this.stripes.add(new Stripe(-Double.MAX_VALUE, Double.MAX_VALUE, -Double.MAX_VALUE)); + } + + public boolean isEmpty() { + return stripes.size() == 1; + } + + @Override + public String toString() { + return stripes.toString(); + } + + public boolean contains(double x, double y) { + for (Stripe stripe : stripes) { + if (stripe.contains(x)) { + return y <= stripe.getValue(); + } + } + throw new UnsupportedOperationException(); + } + + public double getContact(double x1, double x2) { + final SortedSet collisions = collisionning(x1, x2); + double result = -Double.MAX_VALUE; + for (Stripe strip : collisions) { + result = Math.max(result, strip.getValue()); + } + return result; + + } + + public void addSegment(double x1, double x2, double value) { + if (x2 <= x1) { + System.err.println("x1=" + x1); + System.err.println("x2=" + x2); + throw new IllegalArgumentException(); + } + final SortedSet collisions = collisionning(x1, x2); + if (collisions.size() > 1) { + final Iterator it = collisions.iterator(); + it.next(); + double x = x1; + while (it.hasNext()) { + final Stripe tmp = it.next(); + addSegment(x, tmp.getStart(), value); + x = tmp.getStart(); + } + addSegment(x, x2, value); + // System.err.println("x1=" + x1); + // System.err.println("x2=" + x2); + // System.err.println("All=" + stripes); + // System.err.println("collisions" + collisions); + // throw new UnsupportedOperationException(); + } else { + final Stripe touch = collisions.iterator().next(); + addSingleInternal(x1, x2, value, touch); + } + } + + private void addSingleInternal(double x1, double x2, double value, final Stripe touch) { + if (value <= touch.getValue()) { + return; + } + final boolean ok = this.stripes.remove(touch); + assert ok; + if (touch.getStart() != x1) { + this.stripes.add(new Stripe(touch.getStart(), x1, touch.getValue())); + } + this.stripes.add(new Stripe(x1, x2, value)); + if (x2 != touch.getEnd()) { + this.stripes.add(new Stripe(x2, touch.getEnd(), touch.getValue())); + } + assert checkConsistent(); + } + + private boolean checkConsistent() { + Stripe last = null; + for (Stripe stripe : stripes) { + if (last == null && stripe.getStart() != -Double.MAX_VALUE) { + return false; + } + if (last != null && last.getEnd() != stripe.getStart()) { + return false; + } + last = stripe; + } + if (last.getEnd() != Double.MAX_VALUE) { + return false; + } + return true; + } + + private SortedSet collisionning(double x1, double x2) { + final SortedSet result = new TreeSet(); + for (Iterator it = stripes.iterator(); it.hasNext();) { + Stripe stripe = it.next(); + if (x1 >= stripe.getEnd()) { + continue; + } + result.add(stripe); + if (x2 <= stripe.getEnd()) { + return result; + } + } + throw new UnsupportedOperationException(); + } +} diff --git a/src/net/sourceforge/plantuml/mindmap/SymetricalTee.java b/src/net/sourceforge/plantuml/mindmap/SymetricalTee.java new file mode 100644 index 000000000..9a5d287d7 --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/SymetricalTee.java @@ -0,0 +1,76 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.mindmap; + +public class SymetricalTee { + + private final double thickness1; + private final double elongation1; + private final double thickness2; + private final double elongation2; + + public SymetricalTee(double thickness1, double elongation1, double thickness2, double elongation2) { + this.thickness1 = thickness1; + this.elongation1 = elongation1; + this.thickness2 = thickness2; + this.elongation2 = elongation2; + } + + public double getThickness1() { + return thickness1; + } + + public double getElongation1() { + return elongation1; + } + + public double getThickness2() { + return thickness2; + } + + public double getElongation2() { + return elongation2; + } + + public double getFullElongation() { + return elongation1 + elongation2; + } + + public double getFullThickness() { + return Math.max(thickness1, thickness2); + } + +} diff --git a/src/net/sourceforge/plantuml/mindmap/SymetricalTeePositioned.java b/src/net/sourceforge/plantuml/mindmap/SymetricalTeePositioned.java new file mode 100644 index 000000000..4ae54f104 --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/SymetricalTeePositioned.java @@ -0,0 +1,112 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.mindmap; + +import java.awt.geom.Line2D; + +public class SymetricalTeePositioned { + + private final SymetricalTee tee; + private double y; + + public SymetricalTeePositioned(SymetricalTee tee) { + this(tee, 0); + } + + private SymetricalTeePositioned(SymetricalTee tee, double y) { + this.tee = tee; + this.y = y; + } + + public void moveSoThatSegmentA1isOn(double newY) { + final double current = getSegmentA1().getY1(); + y += newY - current; + } + + public void moveSoThatSegmentA2isOn(double newY) { + final double current = getSegmentA2().getY1(); + y += newY - current; + } + + public void move(double delta) { + y += delta; + } + + public Line2D getSegmentA1() { + return new Line2D.Double(0, y - tee.getThickness1() / 2, tee.getElongation1(), y - tee.getThickness1() / 2); + } + + public Line2D getSegmentB1() { + return new Line2D.Double(0, y + tee.getThickness1() / 2, tee.getElongation1(), y + tee.getThickness1() / 2); + } + + public Line2D getSegmentA2() { + return new Line2D.Double(tee.getElongation1(), y - tee.getThickness2() / 2, tee.getElongation1() + + tee.getElongation2(), y - tee.getThickness2() / 2); + } + + public Line2D getSegmentB2() { + return new Line2D.Double(tee.getElongation1(), y + tee.getThickness2() / 2, tee.getElongation1() + + tee.getElongation2(), y + tee.getThickness2() / 2); + } + + public double getMaxX() { + return tee.getElongation1() + tee.getElongation2(); + } + + public double getMaxY() { + return y + Math.max(tee.getThickness1() / 2, tee.getThickness2() / 2); + } + + public double getMinY() { + return y - Math.max(tee.getThickness1() / 2, tee.getThickness2() / 2); + } + + public final double getY() { + return y; + } + + public SymetricalTeePositioned getMax(SymetricalTeePositioned other) { + if (this.tee != other.tee) { + throw new IllegalArgumentException(); + } + if (other.y > this.y) { + return other; + } + return this; + } + +} diff --git a/src/net/sourceforge/plantuml/mindmap/Tetris.java b/src/net/sourceforge/plantuml/mindmap/Tetris.java new file mode 100644 index 000000000..c0fc3e27b --- /dev/null +++ b/src/net/sourceforge/plantuml/mindmap/Tetris.java @@ -0,0 +1,125 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.mindmap; + +import java.awt.geom.Line2D; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class Tetris { + + private final StripeFrontier frontier = new StripeFrontier(); + private final List elements = new ArrayList(); + private double minY = Double.MAX_VALUE; + private double maxY = -Double.MAX_VALUE; + + public void balance() { + if (elements.size() == 0) { + return; + } + if (minY != Double.MAX_VALUE) { + throw new IllegalStateException(); + } + for (SymetricalTeePositioned element : elements) { + minY = Math.min(minY, element.getMinY()); + maxY = Math.max(maxY, element.getMaxY()); + } + final double mean = (minY + maxY) / 2; + for (SymetricalTeePositioned stp : elements) { + stp.move(-mean); + } + } + + public double getHeight() { + if (elements.size() == 0) { + return 0; + } + return maxY - minY; + } + + public double getWidth() { + double result = 0; + for (SymetricalTeePositioned tee : elements) { + result = Math.max(result, tee.getMaxX()); + } + return result; + } + + public void add(SymetricalTee tee) { + + if (frontier.isEmpty()) { + final SymetricalTeePositioned p1 = new SymetricalTeePositioned(tee); + addInternal(p1); + return; + } + + final double c1 = frontier.getContact(0, tee.getElongation1()); + final double c2 = frontier.getContact(tee.getElongation1(), tee.getElongation2()); + + // System.err.println("c1=" + c1 + " c2=" + c2); + + final SymetricalTeePositioned p1 = new SymetricalTeePositioned(tee); + p1.moveSoThatSegmentA1isOn(c1); + + final SymetricalTeePositioned p2 = new SymetricalTeePositioned(tee); + p2.moveSoThatSegmentA2isOn(c2); + + final SymetricalTeePositioned result = p1.getMax(p2); + + // System.err.println("p1=" + p1.getY() + " p2=" + p2.getY()); + // System.err.println("result=" + result.getY()); + addInternal(result); + } + + private void addInternal(SymetricalTeePositioned result) { + this.elements.add(result); + final Line2D b1 = result.getSegmentB1(); + frontier.addSegment(b1.getX1(), b1.getX2(), b1.getY1()); + assert b1.getY1() == b1.getY2(); + + final Line2D b2 = result.getSegmentB2(); + if (b2.getX1() != b2.getX2()) { + frontier.addSegment(b2.getX1(), b2.getX2(), b2.getY1()); + } + assert b2.getY1() == b2.getY2(); + } + + public List getElements() { + return Collections.unmodifiableList(elements); + } + +} diff --git a/src/net/sourceforge/plantuml/printskin/PrintSkin.java b/src/net/sourceforge/plantuml/printskin/PrintSkin.java deleted file mode 100644 index 19ba4f2b4..000000000 --- a/src/net/sourceforge/plantuml/printskin/PrintSkin.java +++ /dev/null @@ -1,171 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.printskin; - -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.io.OutputStream; -import java.util.List; - -import net.sourceforge.plantuml.AbstractPSystem; -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.EmptyImageBuilder; -import net.sourceforge.plantuml.FileFormatOption; -import net.sourceforge.plantuml.SkinParam; -import net.sourceforge.plantuml.SpriteContainerEmpty; -import net.sourceforge.plantuml.api.ImageDataSimple; -import net.sourceforge.plantuml.core.DiagramDescription; -import net.sourceforge.plantuml.core.ImageData; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.png.PngIO; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.skin.ArrowConfiguration; -import net.sourceforge.plantuml.skin.Component; -import net.sourceforge.plantuml.skin.ComponentType; -import net.sourceforge.plantuml.skin.SimpleContext2D; -import net.sourceforge.plantuml.skin.Skin; -import net.sourceforge.plantuml.skin.rose.Rose; -import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UFont; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UTranslate; -import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d; - -class PrintSkin extends AbstractPSystem { - - private static final UFont FONT1 = UFont.sansSerif(10); - - final private Skin skin; - final private List toPrint; - private UGraphic ug; - private float xpos = 10; - private float ypos = 0; - private float maxYpos = 0; - - // public List createFiles(File suggestedFile, FileFormatOption fileFormat) throws IOException, - // InterruptedException { - // final List result = Arrays.asList(suggestedFile); - // final BufferedImage im = createImage(); - // - // PngIO.write(im.getSubimage(0, 0, im.getWidth(), (int) maxYpos), suggestedFile, 96); - // return result; - // - // } - - @Override - final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormatOption, long seed) - throws IOException { - final BufferedImage im = createImage(); - final ImageData imageData = new ImageDataSimple(im.getWidth(), (int) maxYpos); - PngIO.write(im.getSubimage(0, 0, imageData.getWidth(), imageData.getHeight()), os, 96); - return imageData; - } - - private BufferedImage createImage() { - final EmptyImageBuilder builder = new EmptyImageBuilder(2000, 830, Color.WHITE); - - final BufferedImage im = builder.getBufferedImage(); - final Graphics2D g2d = builder.getGraphics2D(); - - ug = new UGraphicG2d(new ColorMapperIdentity(), g2d, 1.0); - - for (ComponentType type : ComponentType.values()) { - printComponent(type); - ypos += 10; - maxYpos = Math.max(maxYpos, ypos); - if (ypos > 620) { - ypos = 0; - xpos += 200; - } - } - g2d.dispose(); - return im; - } - - private void printComponent(ComponentType type) { - println(type.name()); - final Component comp = skin.createComponent(type, ArrowConfiguration.withDirectionNormal(), - SkinParam.noShadowing(null), Display.create(toPrint)); - if (comp == null) { - println("null"); - return; - } - double height = comp.getPreferredHeight(ug.getStringBounder()); - double width = comp.getPreferredWidth(ug.getStringBounder()); - println("height = " + String.format("%4.2f", height)); - println("width = " + width); - - if (height == 0) { - height = 42; - } - if (width == 0) { - width = 42; - } - ug.apply(new UChangeBackColor(HtmlColorUtils.LIGHT_GRAY)).apply(new UChangeColor(HtmlColorUtils.LIGHT_GRAY)) - .apply(new UTranslate((double) (xpos - 1), (double) (ypos - 1))) - .draw(new URectangle(width + 2, height + 2)); - - comp.drawU(ug.apply(new UTranslate(xpos, ypos)), new Area(new Dimension2DDouble(width, height)), - new SimpleContext2D(false)); - - ypos += height; - } - - private void println(String s) { - final TextBlock textBlock = Display.create(s).create(FontConfiguration.blackBlueTrue(FONT1), - HorizontalAlignment.LEFT, new SpriteContainerEmpty()); - textBlock.drawU(ug.apply(new UTranslate(xpos, ypos))); - ypos += textBlock.calculateDimension(ug.getStringBounder()).getHeight(); - } - - public DiagramDescription getDescription() { - return new DiagramDescription("Printing of " + skin.getClass().getName()); - } - - public PrintSkin(String className, List toPrint) { - this.skin = new Rose(); - this.toPrint = toPrint; - } -} diff --git a/src/net/sourceforge/plantuml/salt/Dictionary.java b/src/net/sourceforge/plantuml/salt/Dictionary.java index eed6067fb..bf42d8743 100644 --- a/src/net/sourceforge/plantuml/salt/Dictionary.java +++ b/src/net/sourceforge/plantuml/salt/Dictionary.java @@ -113,4 +113,12 @@ public class Dictionary implements SpriteContainer, ISkinSimple { return new ColorMapperIdentity(); } + public void copyAllFrom(ISkinSimple other) { + throw new UnsupportedOperationException(); + } + + public Map values() { + throw new UnsupportedOperationException(); + } + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/Englober.java b/src/net/sourceforge/plantuml/sequencediagram/Englober.java index f997d1a35..62cd2d9d3 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/Englober.java +++ b/src/net/sourceforge/plantuml/sequencediagram/Englober.java @@ -51,7 +51,7 @@ import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -65,7 +65,7 @@ public class Englober { final private boolean isTeoz; private double marginX = 0; - public static Englober createPuma(ParticipantEnglober englober, Participant first, ISkinParam skinParam, Skin skin, + public static Englober createPuma(ParticipantEnglober englober, Participant first, ISkinParam skinParam, Rose skin, StringBounder stringBounder) { return new Englober(englober, first, convertFunctionToBeRemoved(skinParam, skin, stringBounder), false); } @@ -75,7 +75,7 @@ public class Englober { return new Englober(participantEnglober, first, tileArguments, true); } - private static TileArguments convertFunctionToBeRemoved(ISkinParam skinParam, Skin skin, StringBounder stringBounder) { + private static TileArguments convertFunctionToBeRemoved(ISkinParam skinParam, Rose skin, StringBounder stringBounder) { final TileArguments result = new TileArguments(stringBounder, null, skin, skinParam, null); return result; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/LinkAnchor.java b/src/net/sourceforge/plantuml/sequencediagram/LinkAnchor.java index 363dcba65..d32381415 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/LinkAnchor.java +++ b/src/net/sourceforge/plantuml/sequencediagram/LinkAnchor.java @@ -35,6 +35,24 @@ */ package net.sourceforge.plantuml.sequencediagram; +import net.sourceforge.plantuml.ColorParam; +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.activitydiagram3.ftile.Arrows; +import net.sourceforge.plantuml.activitydiagram3.ftile.Snake; +import net.sourceforge.plantuml.creole.CreoleMode; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.HtmlColorAndStyle; +import net.sourceforge.plantuml.graphic.Rainbow; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.sequencediagram.teoz.YPositionedTile; +import net.sourceforge.plantuml.skin.rose.Rose; +import net.sourceforge.plantuml.ugraphic.UGraphic; + public class LinkAnchor { private final String anchor1; @@ -64,4 +82,29 @@ public class LinkAnchor { return message; } + public void drawAnchor(UGraphic ug, YPositionedTile tile1, YPositionedTile tile2, ISkinParam param) { + + final StringBounder stringBounder = ug.getStringBounder(); + final double y1 = tile1.getY(stringBounder); + final double y2 = tile2.getY(stringBounder); + final double xx1 = tile1.getMiddleX(stringBounder); + final double xx2 = tile2.getMiddleX(stringBounder); + final double x = (xx1 + xx2) / 2; + final double ymin = Math.min(y1, y2); + final double ymax = Math.max(y1, y2); + + final HtmlColor color = new Rose().getHtmlColor(param, ColorParam.arrow); + final Rainbow rainbow = HtmlColorAndStyle.fromColor(color); + final Snake snake = new Snake(Arrows.asToUp(), HorizontalAlignment.CENTER, rainbow, Arrows.asToDown()); + + final Display display = Display.getWithNewlines(message); + final TextBlock title = display.create(new FontConfiguration(param, FontParam.ARROW, null), + HorizontalAlignment.CENTER, param); + snake.setLabel(title); + + snake.addPoint(x, ymin + 2); + snake.addPoint(x, ymax - 2); + snake.drawInternal(ug); + } + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java index 6045ecef8..3a11fc18a 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java +++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagram.java @@ -51,6 +51,7 @@ import java.util.Stack; import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.Scale; import net.sourceforge.plantuml.UmlDiagram; @@ -66,20 +67,21 @@ import net.sourceforge.plantuml.sequencediagram.graphic.FileMaker; import net.sourceforge.plantuml.sequencediagram.graphic.SequenceDiagramFileMakerPuma2; import net.sourceforge.plantuml.sequencediagram.graphic.SequenceDiagramTxtMaker; import net.sourceforge.plantuml.sequencediagram.teoz.SequenceDiagramFileMakerTeoz; -import net.sourceforge.plantuml.skin.ProtectedSkin; -import net.sourceforge.plantuml.skin.Skin; import net.sourceforge.plantuml.skin.rose.Rose; public class SequenceDiagram extends UmlDiagram { - // private final Map participants = new LinkedHashMap(); private final List participantsList = new ArrayList(); private final List events = new ArrayList(); private final Map participantEnglobers2 = new HashMap(); - private final Skin skin2 = new ProtectedSkin(new Rose()); + private final Rose skin2 = new Rose(); + + public SequenceDiagram(ISkinSimple skinParam) { + super(skinParam); + } @Deprecated public Participant getOrCreateParticipant(String code) { diff --git a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java index 71675356c..9e826ed32 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java +++ b/src/net/sourceforge/plantuml/sequencediagram/SequenceDiagramFactory.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.sequencediagram; import java.util.ArrayList; import java.util.List; +import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.command.Command; import net.sourceforge.plantuml.command.UmlDiagramFactory; import net.sourceforge.plantuml.command.note.sequence.FactorySequenceNoteCommand; @@ -78,9 +79,15 @@ import net.sourceforge.plantuml.sequencediagram.command.CommandUrl; public class SequenceDiagramFactory extends UmlDiagramFactory { + private final ISkinSimple skinParam; + + public SequenceDiagramFactory(ISkinSimple skinParam) { + this.skinParam = skinParam; + } + @Override public SequenceDiagram createEmptyDiagram() { - return new SequenceDiagram(); + return new SequenceDiagram(skinParam); } @Override diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java index 801de04ce..ea823c6df 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandBoxStart.java @@ -44,6 +44,9 @@ import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.color.ColorParser; +import net.sourceforge.plantuml.graphic.color.ColorType; +import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; public class CommandBoxStart extends SingleLineCommand2 { @@ -59,9 +62,14 @@ public class CommandBoxStart extends SingleLineCommand2 { new RegexLeaf("NAME1", "[%s]+[%g]([^%g]+)[%g]"), // new RegexLeaf("NAME2", "[%s]+([^#]+)"))), // new RegexLeaf("[%s]*"), // - new RegexLeaf("COLOR", "(#\\w+)?"), // + color().getRegex(), // new RegexLeaf("$")); } + + private static ColorParser color() { + return ColorParser.simpleColor(ColorType.BACK); + } + @Override protected CommandExecutionResult executeArg(SequenceDiagram diagram, RegexResult arg2) { @@ -70,9 +78,10 @@ public class CommandBoxStart extends SingleLineCommand2 { } final String argTitle = arg2.getLazzy("NAME", 0); final String argColor = arg2.get("COLOR", 0); - final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(argColor); + // final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(argColor); + Colors colors = color().getColor(arg2, diagram.getSkinParam().getIHtmlColorSet()); final String title = argTitle == null ? "" : argTitle; - diagram.boxStart(Display.getWithNewlines(title), color); + diagram.boxStart(Display.getWithNewlines(title), colors.getColor(ColorType.BACK)); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java index e10c0af77..bcf8e6c27 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java +++ b/src/net/sourceforge/plantuml/sequencediagram/command/CommandReturn.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.HtmlColorSet; import net.sourceforge.plantuml.sequencediagram.EventWithDeactivate; import net.sourceforge.plantuml.sequencediagram.LifeEventType; import net.sourceforge.plantuml.sequencediagram.Message; @@ -59,6 +60,7 @@ public class CommandReturn extends SingleLineCommand2 { new RegexLeaf("PARALLEL", "(&%s*)?"), // new RegexLeaf("[%s]*"), // new RegexLeaf("return[%s]*"), // + new RegexLeaf("COLOR", "(?:(#\\w+)[%s]+)?"), // new RegexLeaf("MESSAGE", "(.*)"), // new RegexLeaf("$")); } @@ -77,7 +79,11 @@ public class CommandReturn extends SingleLineCommand2 { doDeactivation = false; } - final ArrowConfiguration arrow = message1.getArrowConfiguration().withBody(ArrowBody.DOTTED); + ArrowConfiguration arrow = message1.getArrowConfiguration().withBody(ArrowBody.DOTTED); + final String color = arg.get("COLOR", 0); + if (color != null) { + arrow = arrow.withColor(HtmlColorSet.getInstance().getColorIfValid(color)); + } final Display display = Display.getWithNewlines(arg.get("MESSAGE", 0)); final Message message2 = new Message(message1.getParticipant2(), message1.getParticipant1(), display, arrow, diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Arrow.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Arrow.java index ead9c8a00..1e7e114b9 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/Arrow.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Arrow.java @@ -40,12 +40,12 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.sequencediagram.InGroupable; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.skin.Component; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; abstract class Arrow extends GraphicalElement implements InGroupable { - private final Skin skin; + private final Rose skin; private final Component arrowComponent; private double paddingArrowHead; private double maxX; @@ -67,7 +67,7 @@ abstract class Arrow extends GraphicalElement implements InGroupable { public abstract double getActualWidth(StringBounder stringBounder); - Arrow(double startingY, Skin skin, Component arrowComponent, Url url) { + Arrow(double startingY, Rose skin, Component arrowComponent, Url url) { super(startingY); this.skin = skin; this.arrowComponent = arrowComponent; @@ -92,7 +92,7 @@ abstract class Arrow extends GraphicalElement implements InGroupable { public abstract int getDirection(StringBounder stringBounder); - protected Skin getSkin() { + protected Rose getSkin() { return skin; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java index 7a71d6097..44912ae1d 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSet.java @@ -64,7 +64,7 @@ import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.Context2D; import net.sourceforge.plantuml.skin.SimpleContext2D; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.MinMax; import net.sourceforge.plantuml.ugraphic.UClip; import net.sourceforge.plantuml.ugraphic.UGraphic; @@ -79,12 +79,12 @@ public class DrawableSet { private final Map participantEnglobers2 = new LinkedHashMap(); private final List eventsList = new ArrayList(); - private final Skin skin; + private final Rose skin; private final ISkinParam skinParam; private Dimension2D dimension; private double topStartingY; - DrawableSet(Skin skin, ISkinParam skinParam) { + DrawableSet(Rose skin, ISkinParam skinParam) { if (skin == null) { throw new IllegalArgumentException(); } @@ -99,7 +99,7 @@ public class DrawableSet { return participants.values().iterator().next().getParticipantBox(); } - public final Skin getSkin() { + public final Rose getSkin() { return skin; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java index 3ee141b05..c81a191af 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java @@ -69,7 +69,7 @@ import net.sourceforge.plantuml.sequencediagram.ParticipantType; import net.sourceforge.plantuml.sequencediagram.Reference; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; class DrawableSetInitializer { @@ -85,7 +85,7 @@ class DrawableSetInitializer { private ConstraintSet constraintSet; - public DrawableSetInitializer(Skin skin, ISkinParam skinParam, boolean showTail, double autonewpage) { + public DrawableSetInitializer(Rose skin, ISkinParam skinParam, boolean showTail, double autonewpage) { this.drawableSet = new DrawableSet(skin, skinParam); this.showTail = showTail; this.autonewpage = autonewpage; diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java index 23bb30541..58373ccde 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/LifeLine.java @@ -50,7 +50,7 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.SymbolContext; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -198,7 +198,7 @@ public class LifeLine { return Collections.emptyList(); } - public void drawU(UGraphic ug, Skin skin, ISkinParam skinParam) { + public void drawU(UGraphic ug, Rose skin, ISkinParam skinParam) { final StringBounder stringBounder = ug.getStringBounder(); ug = ug.apply(new UTranslate(getStartingX(stringBounder), 0)); diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageArrow.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageArrow.java index 556b13704..d59f08f36 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageArrow.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageArrow.java @@ -45,7 +45,7 @@ import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.skin.ArrowComponent; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -55,7 +55,7 @@ class MessageArrow extends Arrow { private final LivingParticipantBox p2; private final Component compAliveBox; - public MessageArrow(double startingY, Skin skin, Component arrow, LivingParticipantBox p1, LivingParticipantBox p2, + public MessageArrow(double startingY, Rose skin, Component arrow, LivingParticipantBox p1, LivingParticipantBox p2, Url url, Component compAliveBox) { super(startingY, skin, arrow, url); diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageExoArrow.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageExoArrow.java index 6ed871bbe..6cea31089 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageExoArrow.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageExoArrow.java @@ -48,8 +48,8 @@ import net.sourceforge.plantuml.skin.ArrowConfiguration; import net.sourceforge.plantuml.skin.ArrowDecoration; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.Skin; import net.sourceforge.plantuml.skin.rose.ComponentRoseArrow; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -60,7 +60,7 @@ public class MessageExoArrow extends Arrow { private final boolean shortArrow; private final ArrowConfiguration arrowConfiguration; - public MessageExoArrow(double startingY, Skin skin, Component arrow, LivingParticipantBox p, MessageExoType type, + public MessageExoArrow(double startingY, Rose skin, Component arrow, LivingParticipantBox p, MessageExoType type, Url url, boolean shortArrow, ArrowConfiguration arrowConfiguration) { super(startingY, skin, arrow, url); this.p = p; diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageSelfArrow.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageSelfArrow.java index 7925fa45e..e53096463 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageSelfArrow.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/MessageSelfArrow.java @@ -45,7 +45,7 @@ import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.skin.ArrowComponent; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -55,7 +55,7 @@ class MessageSelfArrow extends Arrow { private final double deltaX; private final double deltaY; - public MessageSelfArrow(double startingY, Skin skin, Component arrow, LivingParticipantBox p1, double deltaY, + public MessageSelfArrow(double startingY, Rose skin, Component arrow, LivingParticipantBox p1, double deltaY, Url url, double deltaX) { super(startingY, skin, arrow, url); this.p1 = p1; diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java index b4cf50659..ec0211c17 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramFileMakerPuma2.java @@ -65,7 +65,7 @@ import net.sourceforge.plantuml.sequencediagram.Newpage; import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; import net.sourceforge.plantuml.skin.ComponentType; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -81,7 +81,7 @@ public class SequenceDiagramFileMakerPuma2 implements FileMaker { private double scale; - public SequenceDiagramFileMakerPuma2(SequenceDiagram sequenceDiagram, Skin skin, FileFormatOption fileFormatOption) { + public SequenceDiagramFileMakerPuma2(SequenceDiagram sequenceDiagram, Rose skin, FileFormatOption fileFormatOption) { this.diagram = sequenceDiagram; this.stringBounder = fileFormatOption.getDefaultStringBounder(); this.fileFormatOption = fileFormatOption; diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java index 085aac18e..fd3b0f1b6 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/SequenceDiagramTxtMaker.java @@ -52,7 +52,6 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.sequencediagram.Event; import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; -import net.sourceforge.plantuml.skin.Skin; import net.sourceforge.plantuml.ugraphic.UTranslate; import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt; @@ -64,7 +63,7 @@ public class SequenceDiagramTxtMaker implements FileMaker { private final StringBounder dummyStringBounder = new TextStringBounder(); private final UGraphicTxt ug = new UGraphicTxt(); private final FileFormat fileFormat; - private final Skin skin; + private final TextSkin skin; public SequenceDiagramTxtMaker(SequenceDiagram sequenceDiagram, FileFormat fileFormat) { this.fileFormat = fileFormat; diff --git a/src/net/sourceforge/plantuml/EmbededDiagram.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/AbstractTile.java similarity index 70% rename from src/net/sourceforge/plantuml/EmbededDiagram.java rename to src/net/sourceforge/plantuml/sequencediagram/teoz/AbstractTile.java index b4e4be31e..39e8c5511 100644 --- a/src/net/sourceforge/plantuml/EmbededDiagram.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/AbstractTile.java @@ -33,31 +33,20 @@ * * */ -package net.sourceforge.plantuml; +package net.sourceforge.plantuml.sequencediagram.teoz; -import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.StringBounder; -public class EmbededDiagram implements CharSequence { +public abstract class AbstractTile implements Tile { - private final Display system; - - public EmbededDiagram(Display system) { - this.system = system; + public double getYPoint(StringBounder stringBounder) { + throw new UnsupportedOperationException(getClass().toString()); } - public int length() { - return toString().length(); + final public double getZ(StringBounder stringBounder) { + final double result = getPreferredHeight(stringBounder) - getYPoint(stringBounder); + assert result >= 0; + return result; } - public char charAt(int index) { - return toString().charAt(index); - } - - public CharSequence subSequence(int start, int end) { - return toString().subSequence(start, end); - } - - public final Display getLines() { - return system; - } } diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationExoTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationExoTile.java index bd23840f6..3242b4285 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationExoTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationExoTile.java @@ -48,18 +48,17 @@ import net.sourceforge.plantuml.skin.ArrowComponent; import net.sourceforge.plantuml.skin.ArrowConfiguration; import net.sourceforge.plantuml.skin.ArrowDecoration; import net.sourceforge.plantuml.skin.Component; -import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.Skin; import net.sourceforge.plantuml.skin.rose.ComponentRoseArrow; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class CommunicationExoTile implements TileWithUpdateStairs { +public class CommunicationExoTile extends AbstractTile implements TileWithUpdateStairs { private final LivingSpace livingSpace; private final MessageExo message; - private final Skin skin; + private final Rose skin; private final ISkinParam skinParam; private final TileArguments tileArguments; @@ -67,7 +66,7 @@ public class CommunicationExoTile implements TileWithUpdateStairs { return message; } - public CommunicationExoTile(LivingSpace livingSpace, MessageExo message, Skin skin, ISkinParam skinParam, + public CommunicationExoTile(LivingSpace livingSpace, MessageExo message, Rose skin, ISkinParam skinParam, TileArguments tileArguments) { this.tileArguments = tileArguments; this.livingSpace = livingSpace; @@ -75,14 +74,20 @@ public class CommunicationExoTile implements TileWithUpdateStairs { this.skin = skin; this.skinParam = skinParam; } + + @Override + public double getYPoint(StringBounder stringBounder) { + return getComponent(stringBounder).getYPoint(stringBounder); + } - private Component getComponent(StringBounder stringBounder) { + + private ArrowComponent getComponent(StringBounder stringBounder) { ArrowConfiguration arrowConfiguration = message.getArrowConfiguration(); if (message.getType().getDirection() == -1) { arrowConfiguration = arrowConfiguration.reverse(); } - final Component comp = skin.createComponent(ComponentType.ARROW, arrowConfiguration, skinParam, - message.getLabelNumbered()); + final ArrowComponent comp = skin + .createComponentArrow(arrowConfiguration, skinParam, message.getLabelNumbered()); return comp; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTile.java index 4f65a79dd..e586e34f5 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTile.java @@ -39,7 +39,6 @@ import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.VerticalAlignment; import net.sourceforge.plantuml.real.Real; @@ -49,27 +48,29 @@ import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.skin.ArrowComponent; import net.sourceforge.plantuml.skin.ArrowConfiguration; import net.sourceforge.plantuml.skin.Component; -import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.Skin; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UEllipse; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class CommunicationTile implements TileWithUpdateStairs, TileWithCallbackY { +public class CommunicationTile extends AbstractTile implements TileWithUpdateStairs, TileWithCallbackY { private final LivingSpace livingSpace1; private final LivingSpace livingSpace2; private final Message message; - private final Skin skin; + private final Rose skin; private final ISkinParam skinParam; public Event getEvent() { return message; } - public CommunicationTile(LivingSpace livingSpace1, LivingSpace livingSpace2, Message message, Skin skin, + @Override + public String toString() { + return super.toString() + " " + message; + } + + public CommunicationTile(LivingSpace livingSpace1, LivingSpace livingSpace2, Message message, Rose skin, ISkinParam skinParam) { if (livingSpace1 == livingSpace2) { throw new IllegalArgumentException(); @@ -103,7 +104,7 @@ public class CommunicationTile implements TileWithUpdateStairs, TileWithCallback return message.isCreate(); } - private Component getComponent(StringBounder stringBounder) { + private ArrowComponent getComponent(StringBounder stringBounder) { ArrowConfiguration arrowConfiguration = message.getArrowConfiguration(); /* * if (isSelf()) { arrowConfiguration = arrowConfiguration.self(); } else @@ -111,11 +112,17 @@ public class CommunicationTile implements TileWithUpdateStairs, TileWithCallback if (isReverse(stringBounder)) { arrowConfiguration = arrowConfiguration.reverse(); } - final Component comp = skin.createComponent(ComponentType.ARROW, arrowConfiguration, skinParam, - message.getLabelNumbered()); + + final ArrowComponent comp = skin + .createComponentArrow(arrowConfiguration, skinParam, message.getLabelNumbered()); return comp; } + @Override + public double getYPoint(StringBounder stringBounder) { + return getComponent(stringBounder).getYPoint(stringBounder); + } + public static final double LIVE_DELTA_SIZE = 5; public void updateStairs(StringBounder stringBounder, double y) { @@ -167,18 +174,6 @@ public class CommunicationTile implements TileWithUpdateStairs, TileWithCallback } } comp.drawU(ug, area, (Context2D) ug); - - if (message.getAnchor() != null) { - drawAnchor(ug); - } - // ug.draw(new ULine(x2 - x1, 0)); - - } - - private void drawAnchor(UGraphic ug) { - ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK)); - ug.draw(new UEllipse(10, 10)); - } public double getPreferredHeight(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java index 0b0f6bb25..64455f8b2 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteLeft.java @@ -47,15 +47,15 @@ import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class CommunicationTileNoteLeft implements TileWithUpdateStairs, TileWithCallbackY { +public class CommunicationTileNoteLeft extends AbstractTile implements TileWithUpdateStairs, TileWithCallbackY { private final TileWithUpdateStairs tile; private final AbstractMessage message; - private final Skin skin; + private final Rose skin; private final ISkinParam skinParam; private final LivingSpace livingSpace; private final Note noteOnMessage; @@ -63,8 +63,13 @@ public class CommunicationTileNoteLeft implements TileWithUpdateStairs, TileWith public Event getEvent() { return message; } + + @Override + public double getYPoint(StringBounder stringBounder) { + return tile.getYPoint(stringBounder); + } - public CommunicationTileNoteLeft(TileWithUpdateStairs tile, AbstractMessage message, Skin skin, + public CommunicationTileNoteLeft(TileWithUpdateStairs tile, AbstractMessage message, Rose skin, ISkinParam skinParam, LivingSpace livingSpace, Note noteOnMessage) { this.tile = tile; this.message = message; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java index fafb2bd8b..848dbb32a 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileNoteRight.java @@ -47,15 +47,15 @@ import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class CommunicationTileNoteRight implements TileWithUpdateStairs, TileWithCallbackY { +public class CommunicationTileNoteRight extends AbstractTile implements TileWithUpdateStairs, TileWithCallbackY { private final TileWithUpdateStairs tile; private final AbstractMessage message; - private final Skin skin; + private final Rose skin; private final ISkinParam skinParam; private final LivingSpace livingSpace; private final Note noteOnMessage; @@ -67,8 +67,13 @@ public class CommunicationTileNoteRight implements TileWithUpdateStairs, TileWit private boolean isCreate() { return message.isCreate(); } + + @Override + public double getYPoint(StringBounder stringBounder) { + return tile.getYPoint(stringBounder); + } - public CommunicationTileNoteRight(TileWithUpdateStairs tile, AbstractMessage message, Skin skin, + public CommunicationTileNoteRight(TileWithUpdateStairs tile, AbstractMessage message, Rose skin, ISkinParam skinParam, LivingSpace livingSpace, Note noteOnMessage) { this.tile = tile; this.message = message; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.java index 118722e37..2543dfdac 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelf.java @@ -51,15 +51,15 @@ import net.sourceforge.plantuml.skin.ArrowConfiguration; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class CommunicationTileSelf implements TileWithUpdateStairs { +public class CommunicationTileSelf extends AbstractTile implements TileWithUpdateStairs { private final LivingSpace livingSpace1; private final Message message; - private final Skin skin; + private final Rose skin; private final ISkinParam skinParam; private final LivingSpaces livingSpaces; @@ -67,7 +67,7 @@ public class CommunicationTileSelf implements TileWithUpdateStairs { return message; } - public CommunicationTileSelf(LivingSpace livingSpace1, Message message, Skin skin, ISkinParam skinParam, + public CommunicationTileSelf(LivingSpace livingSpace1, Message message, Rose skin, ISkinParam skinParam, LivingSpaces livingSpaces) { this.livingSpace1 = livingSpace1; this.livingSpaces = livingSpaces; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.java index b4aa6cdc1..69ca895a5 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/CommunicationTileSelfNoteRight.java @@ -47,15 +47,15 @@ import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class CommunicationTileSelfNoteRight implements TileWithUpdateStairs { +public class CommunicationTileSelfNoteRight extends AbstractTile implements TileWithUpdateStairs { private final CommunicationTileSelf tile; private final Message message; - private final Skin skin; + private final Rose skin; private final ISkinParam skinParam; private final Note noteOnMessage; @@ -63,7 +63,7 @@ public class CommunicationTileSelfNoteRight implements TileWithUpdateStairs { return message; } - public CommunicationTileSelfNoteRight(CommunicationTileSelf tile, Message message, Skin skin, ISkinParam skinParam, + public CommunicationTileSelfNoteRight(CommunicationTileSelf tile, Message message, Rose skin, ISkinParam skinParam, Note noteOnMessage) { this.tile = tile; this.message = message; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/DelayTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/DelayTile.java index 23b425b6d..b9d09e911 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/DelayTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/DelayTile.java @@ -49,7 +49,7 @@ import net.sourceforge.plantuml.skin.Context2D; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class DelayTile implements Tile, TileWithCallbackY { +public class DelayTile extends AbstractTile implements Tile, TileWithCallbackY { private final Delay delay; private final TileArguments tileArguments; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/DividerTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/DividerTile.java index 653f5d2de..437e63aeb 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/DividerTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/DividerTile.java @@ -46,13 +46,13 @@ import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class DividerTile implements Tile { +public class DividerTile extends AbstractTile implements Tile { - private final Skin skin; + private final Rose skin; private final ISkinParam skinParam; private final Divider divider; private final Real origin; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java index 82d5b5e0f..210237d99 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/ElseTile.java @@ -46,12 +46,12 @@ import net.sourceforge.plantuml.sequencediagram.Event; import net.sourceforge.plantuml.sequencediagram.GroupingLeaf; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; -public class ElseTile implements TileWithCallbackY { +public class ElseTile extends AbstractTile implements TileWithCallbackY { - private final Skin skin; + private final Rose skin; private final ISkinParam skinParam; private final GroupingLeaf anElse; private final Tile parent; @@ -59,8 +59,13 @@ public class ElseTile implements TileWithCallbackY { public Event getEvent() { return anElse; } + + @Override + public double getYPoint(StringBounder stringBounder) { + return 0; + } - public ElseTile(GroupingLeaf anElse, Skin skin, ISkinParam skinParam, Tile parent) { + public ElseTile(GroupingLeaf anElse, Rose skin, ISkinParam skinParam, Tile parent) { this.anElse = anElse; this.skin = skin; this.skinParam = skinParam; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/EmptyTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/EmptyTile.java index 726d20b56..b13982755 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/EmptyTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/EmptyTile.java @@ -42,7 +42,7 @@ import net.sourceforge.plantuml.sequencediagram.Event; import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.ugraphic.UGraphic; -public class EmptyTile implements Tile { +public class EmptyTile extends AbstractTile implements Tile { private final double height; private final Tile position; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java index 29c50dad9..733a2b3f6 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/GroupingTile.java @@ -54,11 +54,11 @@ import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class GroupingTile implements TileWithCallbackY { +public class GroupingTile extends AbstractTile implements TileWithCallbackY { private static final int EXTERNAL_MARGINX1 = 3; private static final int EXTERNAL_MARGINX2 = 9; @@ -71,7 +71,7 @@ public class GroupingTile implements TileWithCallbackY { // private final double marginX = 20; - private final Skin skin; + private final Rose skin; private final ISkinParam skinParam; private final Display display; @@ -81,6 +81,11 @@ public class GroupingTile implements TileWithCallbackY { return start; } + @Override + public double getYPoint(StringBounder stringBounder) { + return 0; + } + public GroupingTile(Iterator it, GroupingStart start, TileArguments tileArgumentsBachColorChanged, TileArguments tileArgumentsOriginal) { final StringBounder stringBounder = tileArgumentsOriginal.getStringBounder(); @@ -239,8 +244,17 @@ public class GroupingTile implements TileWithCallbackY { if (isParallel(tile)) { if (pending == null) { pending = new TileParallel(); - pending.add(result.get(result.size() - 1)); - result.set(result.size() - 1, pending); + final Tile tmp = result.get(result.size() - 1); + if (tmp instanceof LifeEventTile) { + pending.add(result.get(result.size() - 2)); + pending.add(tmp); +// result.set(result.size() - 1, pending); + result.set(result.size() - 2, pending); + result.remove(result.size() - 1); + } else { + pending.add(tmp); + result.set(result.size() - 1, pending); + } } pending.add(tile); } else { diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/HSpaceTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/HSpaceTile.java index 53d9690e7..818f19a3a 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/HSpaceTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/HSpaceTile.java @@ -41,7 +41,7 @@ import net.sourceforge.plantuml.sequencediagram.Event; import net.sourceforge.plantuml.sequencediagram.HSpace; import net.sourceforge.plantuml.ugraphic.UGraphic; -public class HSpaceTile implements Tile { +public class HSpaceTile extends AbstractTile implements Tile { private final HSpace hspace; private final Real origin; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LifeEventTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LifeEventTile.java index a3e63743a..1a7d03808 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/LifeEventTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LifeEventTile.java @@ -47,16 +47,16 @@ import net.sourceforge.plantuml.sequencediagram.LifeEventType; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class LifeEventTile implements TileWithUpdateStairs { +public class LifeEventTile extends AbstractTile implements TileWithUpdateStairs { private final LifeEvent lifeEvent; private final TileArguments tileArguments; private final LivingSpace livingSpace; - private final Skin skin; + private final Rose skin; private final ISkinParam skinParam; public void updateStairs(StringBounder stringBounder, double y) { @@ -67,8 +67,13 @@ public class LifeEventTile implements TileWithUpdateStairs { public Event getEvent() { return lifeEvent; } + + @Override + public double getYPoint(StringBounder stringBounder) { + return 0; + } - public LifeEventTile(LifeEvent lifeEvent, TileArguments tileArguments, LivingSpace livingSpace, Skin skin, + public LifeEventTile(LifeEvent lifeEvent, TileArguments tileArguments, LivingSpace livingSpace, Rose skin, ISkinParam skinParam) { this.lifeEvent = lifeEvent; this.tileArguments = tileArguments; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxFinder.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxFinder.java index 0114d2fd4..4d590e92e 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxFinder.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxFinder.java @@ -43,6 +43,7 @@ import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; import net.sourceforge.plantuml.ugraphic.UChange; import net.sourceforge.plantuml.ugraphic.UChangeBackColor; import net.sourceforge.plantuml.ugraphic.UChangeColor; +import net.sourceforge.plantuml.ugraphic.UEllipse; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UParam; import net.sourceforge.plantuml.ugraphic.UParamNull; @@ -55,12 +56,11 @@ public class LiveBoxFinder implements UGraphic { public boolean matchesProperty(String propertyName) { return false; } - + public double dpiFactor() { return 1; } - public UGraphic apply(UChange change) { if (change instanceof UTranslate) { return new LiveBoxFinder(stringBounder, translate.compose((UTranslate) change)); @@ -105,16 +105,17 @@ public class LiveBoxFinder implements UGraphic { ((GroupingTile) shape).drawU(this); } else if (shape instanceof TileWithUpdateStairs) { ((TileWithUpdateStairs) shape).updateStairs(stringBounder, y); - } else if (shape instanceof EmptyTile) { - // Nothing ? - } else if (shape instanceof TileParallel) { - // Nothing ? - } else if (shape instanceof NotesTile) { - // Nothing ? - } else if (shape instanceof Tile) { - Log.info("OtherTile " + shape); + // } else if (shape instanceof EmptyTile) { + // // Nothing ? + // } else if (shape instanceof TileParallel) { + // // Nothing ? + // } else if (shape instanceof NotesTile) { + // // Nothing ? + // } else if (shape instanceof Tile) { + // Log.info("OtherTile " + shape); } else { - throw new UnsupportedOperationException(shape.getClass().getName()); + // Nothing ? + // throw new UnsupportedOperationException(shape.getClass().getName()); } } diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxes.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxes.java index 6f286a88e..932561d96 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxes.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxes.java @@ -44,18 +44,18 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.skin.Context2D; import net.sourceforge.plantuml.skin.SimpleContext2D; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; public class LiveBoxes { private final EventsHistory eventsHistory; - private final Skin skin; + private final Rose skin; private final ISkinParam skinParam; private final Map delays = new TreeMap(); - public LiveBoxes(EventsHistory eventsHistory, Skin skin, ISkinParam skinParam, Participant participant) { + public LiveBoxes(EventsHistory eventsHistory, Rose skin, ISkinParam skinParam, Participant participant) { this.eventsHistory = eventsHistory; this.skin = skin; this.skinParam = skinParam; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxesDrawer.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxesDrawer.java index c9f68da5e..d6f4b9e59 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxesDrawer.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LiveBoxesDrawer.java @@ -50,7 +50,7 @@ import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -61,12 +61,12 @@ public class LiveBoxesDrawer { private final Component cross; private final Context2D context; - private final Skin skin; + private final Rose skin; private final ISkinParam skinParam; private final Component compForWidth; private final Collection delays; - public LiveBoxesDrawer(Context2D context, Skin skin, ISkinParam skinParam, Map delays) { + public LiveBoxesDrawer(Context2D context, Rose skin, ISkinParam skinParam, Map delays) { this.cross = skin.createComponent(ComponentType.DESTROY, null, skinParam, null); this.compForWidth = skin.createComponent(ComponentType.ALIVE_BOX_CLOSE_CLOSE, null, skinParam, null); this.context = context; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpace.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpace.java index 3d3dee221..e1acf5e38 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpace.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/LivingSpace.java @@ -53,7 +53,6 @@ import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.Skin; import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -61,7 +60,7 @@ import net.sourceforge.plantuml.ugraphic.UTranslate; public class LivingSpace { private final Participant p; - private final Skin skin; + private final Rose skin; private final ISkinParam skinParam; private final ComponentType headType; private final ComponentType tailType; @@ -104,7 +103,7 @@ public class LivingSpace { return "" + pos.getCurrentValue(); } - public LivingSpace(Participant p, ParticipantEnglober englober, Skin skin, ISkinParam skinParam, Real position, + public LivingSpace(Participant p, ParticipantEnglober englober, Rose skin, ISkinParam skinParam, Real position, List events) { this.eventsHistory = new EventsHistory(p, events); this.p = p; @@ -195,7 +194,8 @@ public class LivingSpace { } public Dimension2D getHeadPreferredDimension(StringBounder stringBounder) { - final Component comp = rose.createComponent(headType, null, skinParam, p.getDisplay(skinParam.forceSequenceParticipantUnderlined())); + final Component comp = rose.createComponent(headType, null, skinParam, + p.getDisplay(skinParam.forceSequenceParticipantUnderlined())); final Dimension2D dim = comp.getPreferredDimension(stringBounder); return dim; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/MainTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/MainTile.java index c6975cde4..37b05e629 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/MainTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/MainTile.java @@ -38,6 +38,7 @@ package net.sourceforge.plantuml.sequencediagram.teoz; import java.util.ArrayList; import java.util.List; +import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.real.Real; import net.sourceforge.plantuml.real.RealUtils; @@ -47,7 +48,7 @@ import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; import net.sourceforge.plantuml.ugraphic.LimitFinder; import net.sourceforge.plantuml.ugraphic.UGraphic; -public class MainTile implements Tile, Bordered { +public class MainTile extends AbstractTile implements Tile, Bordered { private final double startingY = 8; private final Real min; @@ -57,11 +58,13 @@ public class MainTile implements Tile, Bordered { private final List tiles = new ArrayList(); private final LivingSpaces livingSpaces; private final List linkAnchors; + private final ISkinParam skinParam; public MainTile(SequenceDiagram diagram, Englobers englobers, TileArguments tileArguments) { this.livingSpaces = tileArguments.getLivingSpaces(); this.linkAnchors = diagram.getLinkAnchors(); + this.skinParam = diagram.getSkinParam(); final List min2 = new ArrayList(); final List max2 = new ArrayList(); @@ -116,11 +119,9 @@ public class MainTile implements Tile, Bordered { tile.drawU(ug); } for (LinkAnchor linkAnchor : linkAnchors) { - System.err.println("linkAnchor=" + linkAnchor); final YPositionedTile tile1 = getFromAnchor(positionedTiles, linkAnchor.getAnchor1()); final YPositionedTile tile2 = getFromAnchor(positionedTiles, linkAnchor.getAnchor2()); - System.err.println("tile1=" + tile1); - System.err.println("tile2=" + tile2); + linkAnchor.drawAnchor(ug, tile1, tile2, skinParam); } // System.err.println("MainTile::drawUInternal finalY=" + y); return y; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/MutingLine.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/MutingLine.java index 342a0a568..a50ee08e5 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/MutingLine.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/MutingLine.java @@ -47,18 +47,18 @@ import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; public class MutingLine { - private final Skin skin; + private final Rose skin; private final ISkinParam skinParam; private final boolean useContinueLineBecauseOfDelay; private final Map delays = new TreeMap(); - public MutingLine(Skin skin, ISkinParam skinParam, List events) { + public MutingLine(Rose skin, ISkinParam skinParam, List events) { this.skin = skin; this.skinParam = skinParam; this.useContinueLineBecauseOfDelay = useContinueLineBecauseOfDelay(events); diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java index ae9c4e5bc..78b0c1585 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/NoteTile.java @@ -49,23 +49,28 @@ import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class NoteTile implements Tile { +public class NoteTile extends AbstractTile implements Tile { private final LivingSpace livingSpace1; private final LivingSpace livingSpace2; - private final Skin skin; + private final Rose skin; private final ISkinParam skinParam; private final Note note; public Event getEvent() { return note; } + + @Override + public double getYPoint(StringBounder stringBounder) { + return 0; + } - public NoteTile(LivingSpace livingSpace1, LivingSpace livingSpace2, Note note, Skin skin, ISkinParam skinParam) { + public NoteTile(LivingSpace livingSpace1, LivingSpace livingSpace2, Note note, Rose skin, ISkinParam skinParam) { this.livingSpace1 = livingSpace1; this.livingSpace2 = livingSpace2; this.note = note; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/NotesTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/NotesTile.java index bb3391c48..4b9cc403d 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/NotesTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/NotesTile.java @@ -52,14 +52,14 @@ import net.sourceforge.plantuml.skin.Area; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; import net.sourceforge.plantuml.skin.Context2D; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class NotesTile implements Tile { +public class NotesTile extends AbstractTile implements Tile { private final LivingSpaces livingSpaces; - private final Skin skin; + private final Rose skin; private final ISkinParam skinParam; private final Notes notes; @@ -67,7 +67,7 @@ public class NotesTile implements Tile { return notes; } - public NotesTile(LivingSpaces livingSpaces, Notes notes, Skin skin, ISkinParam skinParam) { + public NotesTile(LivingSpaces livingSpaces, Notes notes, Rose skin, ISkinParam skinParam) { this.livingSpaces = livingSpaces; this.notes = notes; this.skin = skin; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.java index 6e50d2081..dec3508f2 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/ReferenceTile.java @@ -50,7 +50,7 @@ import net.sourceforge.plantuml.skin.Context2D; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class ReferenceTile implements Tile { +public class ReferenceTile extends AbstractTile implements Tile { private final Reference reference; private final TileArguments tileArguments; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java index c24ecbf95..5fd4c6de3 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/SequenceDiagramFileMakerTeoz.java @@ -64,7 +64,7 @@ import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; import net.sourceforge.plantuml.sequencediagram.graphic.FileMaker; import net.sourceforge.plantuml.skin.SimpleContext2D; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -74,10 +74,10 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker { private final SequenceDiagram diagram; private final FileFormatOption fileFormatOption; - private final Skin skin; + private final Rose skin; private final AnnotatedWorker annotatedWorker; - public SequenceDiagramFileMakerTeoz(SequenceDiagram sequenceDiagram, Skin skin, FileFormatOption fileFormatOption) { + public SequenceDiagramFileMakerTeoz(SequenceDiagram sequenceDiagram, Rose skin, FileFormatOption fileFormatOption) { this.stringBounder = fileFormatOption.getDefaultStringBounder(); this.diagram = sequenceDiagram; this.fileFormatOption = fileFormatOption; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/Tile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/Tile.java index 2cd37fae6..b70ef0dbb 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/Tile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/Tile.java @@ -53,4 +53,8 @@ public interface Tile extends UDrawable, UShape { public Event getEvent(); + public double getYPoint(StringBounder stringBounder); + + public double getZ(StringBounder stringBounder); + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.java index dbca3c045..7675178ed 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileArguments.java @@ -43,16 +43,16 @@ import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.real.Real; import net.sourceforge.plantuml.sequencediagram.Participant; import net.sourceforge.plantuml.sequencediagram.Reference; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; public class TileArguments implements Bordered { private final StringBounder stringBounder; private final Real origin; private final LivingSpaces livingSpaces; - private final Skin skin; + private final Rose skin; private final ISkinParam skinParam; - public TileArguments(StringBounder stringBounder, LivingSpaces livingSpaces, Skin skin, ISkinParam skinParam, + public TileArguments(StringBounder stringBounder, LivingSpaces livingSpaces, Rose skin, ISkinParam skinParam, Real origin) { this.stringBounder = stringBounder; this.origin = origin; @@ -88,7 +88,7 @@ public class TileArguments implements Bordered { return livingSpaces; } - public final Skin getSkin() { + public final Rose getSkin() { return skin; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java index 0b55295fb..a80aa5201 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileBuilder.java @@ -57,7 +57,7 @@ import net.sourceforge.plantuml.sequencediagram.Note; import net.sourceforge.plantuml.sequencediagram.NotePosition; import net.sourceforge.plantuml.sequencediagram.Notes; import net.sourceforge.plantuml.sequencediagram.Reference; -import net.sourceforge.plantuml.skin.Skin; +import net.sourceforge.plantuml.skin.rose.Rose; public class TileBuilder { @@ -76,7 +76,7 @@ public class TileBuilder { public static List buildOne(Iterator it, TileArguments tileArguments, final Event ev, Tile parent) { final StringBounder stringBounder = tileArguments.getStringBounder(); - final Skin skin = tileArguments.getSkin(); + final Rose skin = tileArguments.getSkin(); final ISkinParam skinParam = tileArguments.getSkinParam(); final LivingSpaces livingSpaces = tileArguments.getLivingSpaces(); diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileMarged.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileMarged.java index cc296498e..00c871317 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileMarged.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileMarged.java @@ -41,7 +41,7 @@ import net.sourceforge.plantuml.sequencediagram.Event; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class TileMarged implements Tile { +public class TileMarged extends AbstractTile implements Tile { private final Tile tile; private final double x1; diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileParallel.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileParallel.java index 42adb9733..eddafe856 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/TileParallel.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/TileParallel.java @@ -37,7 +37,6 @@ package net.sourceforge.plantuml.sequencediagram.teoz; import java.util.AbstractCollection; import java.util.ArrayList; -import java.util.Collection; import java.util.Iterator; import java.util.List; @@ -48,28 +47,51 @@ import net.sourceforge.plantuml.sequencediagram.Event; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class TileParallel implements Tile { +public class TileParallel implements Tile, TileWithUpdateStairs { private final List tiles = new ArrayList(); + public void updateStairs(StringBounder stringBounder, double y) { + for (Tile tile : tiles) { + if (tile instanceof TileWithUpdateStairs) { + ((TileWithUpdateStairs) tile).updateStairs(stringBounder, y); + } + } + } + public void add(Tile tile) { this.tiles.add(tile); } public void drawU(UGraphic ug) { final StringBounder stringBounder = ug.getStringBounder(); - final double totalHeight = getPreferredHeight(stringBounder); + // final double totalHeight = getPreferredHeight(stringBounder); + final double yPointAll = getYPoint(stringBounder); for (Tile tile : tiles) { - tile.drawU(ug.apply(new UTranslate(0, totalHeight - tile.getPreferredHeight(stringBounder)))); + final double yPoint = tile.getYPoint(stringBounder); + // tile.drawU(ug.apply(new UTranslate(0, totalHeight - tile.getPreferredHeight(stringBounder)))); + tile.drawU(ug.apply(new UTranslate(0, yPointAll - yPoint))); } } - public double getPreferredHeight(StringBounder stringBounder) { - double height = 0; + public double getYPoint(StringBounder stringBounder) { + double result = 0; for (Tile tile : tiles) { - height = Math.max(height, tile.getPreferredHeight(stringBounder)); + result = Math.max(result, tile.getYPoint(stringBounder)); } - return height; + return result; + } + + public double getZ(StringBounder stringBounder) { + double result = 0; + for (Tile tile : tiles) { + result = Math.max(result, tile.getZ(stringBounder)); + } + return result; + } + + public double getPreferredHeight(StringBounder stringBounder) { + return getYPoint(stringBounder) + getZ(stringBounder); } public void addConstraints(StringBounder stringBounder) { diff --git a/src/net/sourceforge/plantuml/sequencediagram/teoz/YPositionedTile.java b/src/net/sourceforge/plantuml/sequencediagram/teoz/YPositionedTile.java index aa84d1b11..7d1716f9f 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/teoz/YPositionedTile.java +++ b/src/net/sourceforge/plantuml/sequencediagram/teoz/YPositionedTile.java @@ -35,6 +35,7 @@ */ package net.sourceforge.plantuml.sequencediagram.teoz; +import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.UDrawable; import net.sourceforge.plantuml.sequencediagram.AbstractMessage; import net.sourceforge.plantuml.sequencediagram.Event; @@ -70,4 +71,15 @@ public class YPositionedTile implements UDrawable { return false; } + public final double getY(StringBounder stringBounder) { + final CommunicationTile communicationTile = (CommunicationTile) tile; + return y + communicationTile.getYPoint(stringBounder); + } + + public double getMiddleX(StringBounder stringBounder) { + final double max = tile.getMaxX(stringBounder).getCurrentValue(); + final double min = tile.getMinX(stringBounder).getCurrentValue(); + return (min + max) / 2; + } + } diff --git a/src/net/sourceforge/plantuml/skin/ArrowComponent.java b/src/net/sourceforge/plantuml/skin/ArrowComponent.java index 893e346bd..758a857ff 100644 --- a/src/net/sourceforge/plantuml/skin/ArrowComponent.java +++ b/src/net/sourceforge/plantuml/skin/ArrowComponent.java @@ -47,5 +47,8 @@ public interface ArrowComponent extends Component { Point2D getEndPoint(StringBounder stringBounder, Dimension2D dimensionToUse); double getPaddingY(); + + public double getYPoint(StringBounder stringBounder); + } diff --git a/src/net/sourceforge/plantuml/skin/GrayComponent.java b/src/net/sourceforge/plantuml/skin/GrayComponent.java deleted file mode 100644 index 116b725f2..000000000 --- a/src/net/sourceforge/plantuml/skin/GrayComponent.java +++ /dev/null @@ -1,93 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.skin; - -import java.awt.Font; -import java.util.ArrayList; -import java.util.List; - -import net.sourceforge.plantuml.SpriteContainerEmpty; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UFont; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.URectangle; - -class GrayComponent extends AbstractComponent { - - private static final UFont NORMAL = UFont.sansSerif(7); - - private final ComponentType type; - - public GrayComponent(ComponentType type) { - this.type = type; - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - final StringBounder stringBounder = ug.getStringBounder(); - ug = ug.apply(new UChangeBackColor(HtmlColorUtils.LIGHT_GRAY)).apply(new UChangeColor(HtmlColorUtils.BLACK)); - ug.draw(new URectangle(getPreferredWidth(stringBounder), getPreferredHeight(stringBounder))); - - final String n = type.name(); - final int split = 9; - final List strings = new ArrayList(); - for (int i = 0; i < n.length(); i += split) { - strings.add(n.substring(i, Math.min(i + split, n.length()))); - } - - final TextBlock textBlock = Display.create(strings).create(FontConfiguration.blackBlueTrue(NORMAL), - HorizontalAlignment.LEFT, new SpriteContainerEmpty()); - textBlock.drawU(ug); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return 42; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return 42; - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/AbstractComponentBlueModernArrow.java b/src/net/sourceforge/plantuml/skin/bluemodern/AbstractComponentBlueModernArrow.java deleted file mode 100644 index 5d1c5b97c..000000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/AbstractComponentBlueModernArrow.java +++ /dev/null @@ -1,94 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.skin.bluemodern; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.skin.AbstractTextualComponent; -import net.sourceforge.plantuml.skin.ArrowComponent; -import net.sourceforge.plantuml.skin.ArrowConfiguration; - -public abstract class AbstractComponentBlueModernArrow extends AbstractTextualComponent implements ArrowComponent { - - private final int arrowDeltaX = 12; - private final int arrowDeltaY = 10; - - private final int arrowDeltaX2 = 10; - private final int arrowDeltaY2 = 5; - private final ArrowConfiguration arrowConfiguration; - private final HtmlColor foregroundColor; - - public AbstractComponentBlueModernArrow(HtmlColor foregroundColor, FontConfiguration font, Display stringsToDisplay, ArrowConfiguration arrowConfiguration, ISkinSimple spriteContainer) { - super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.LEFT, 17, 17, - 2, spriteContainer, false, null, null); - this.arrowConfiguration = arrowConfiguration; - this.foregroundColor = foregroundColor; - } - - protected final HtmlColor getForegroundColor() { - return foregroundColor; - } - - final protected int getArrowDeltaX() { - return arrowDeltaX; - } - - final protected int getArrowDeltaY() { - return arrowDeltaY; - } - - final protected int getArrowDeltaY2() { - return arrowDeltaY2; - } - - final protected int getArrowDeltaX2() { - return arrowDeltaX2; - } - - @Override - public final double getPaddingY() { - return 6; - } - - final protected ArrowConfiguration getArrowConfiguration() { - return arrowConfiguration; - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java b/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java deleted file mode 100644 index 7cf6a44a2..000000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/BlueModern.java +++ /dev/null @@ -1,188 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.skin.bluemodern; - -import net.sourceforge.plantuml.FontParam; -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.LineParam; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; -import net.sourceforge.plantuml.graphic.SymbolContext; -import net.sourceforge.plantuml.skin.ArrowConfiguration; -import net.sourceforge.plantuml.skin.Component; -import net.sourceforge.plantuml.skin.ComponentType; -import net.sourceforge.plantuml.skin.Skin; -import net.sourceforge.plantuml.skin.rose.ComponentRoseDestroy; -import net.sourceforge.plantuml.skin.rose.ComponentRoseGroupingElse; -import net.sourceforge.plantuml.skin.rose.ComponentRoseGroupingSpace; -import net.sourceforge.plantuml.skin.rose.ComponentRoseReference; -import net.sourceforge.plantuml.skin.rose.Rose; -import net.sourceforge.plantuml.ugraphic.UFont; - -public class BlueModern implements Skin { - - private final UFont bigFont = UFont.sansSerif(20).bold(); - private final UFont participantFont = UFont.sansSerif(17); - private final UFont normalFont = UFont.sansSerif(13); - private final UFont smallFont = UFont.sansSerif(11).bold(); - - private final HtmlColor hyperlinkColor = HtmlColorUtils.BLUE; - private final boolean useUnderlineForHyperlink = true; - private final HtmlColor blue1 = HtmlColorUtils.COL_527BC6; - private final HtmlColor blue2 = HtmlColorUtils.COL_D1DBEF; - private final HtmlColor blue3 = HtmlColorUtils.COL_D7E0F2; - - private final HtmlColor red = HtmlColorUtils.MY_RED; - - private final HtmlColor lineColor = HtmlColorUtils.COL_989898; - private final HtmlColor borderGroupColor = HtmlColorUtils.COL_BBBBBB; - - public Component createComponent(ComponentType type, ArrowConfiguration config, ISkinParam param, - Display stringsToDisplay) { - - if (type.isArrow()) { - final HtmlColor sequenceArrow = config.getColor() == null ? HtmlColorUtils.BLACK : config.getColor(); - if (config.isSelfArrow()) { - return new ComponentBlueModernSelfArrow(sequenceArrow, normalFont.toFont2(HtmlColorUtils.BLACK, - useUnderlineForHyperlink, hyperlinkColor, param.getTabSize()), stringsToDisplay, config, param); - } - return new ComponentBlueModernArrow(sequenceArrow, useUnderlineForHyperlink, normalFont.toFont2( - HtmlColorUtils.BLACK, useUnderlineForHyperlink, hyperlinkColor, param.getTabSize()), - stringsToDisplay, config, param); - } - if (type == ComponentType.PARTICIPANT_HEAD) { - return new ComponentBlueModernParticipant(blue1, blue2, participantFont.toFont2(HtmlColorUtils.WHITE, - useUnderlineForHyperlink, hyperlinkColor, param.getTabSize()), stringsToDisplay, param); - } - if (type == ComponentType.PARTICIPANT_TAIL) { - return new ComponentBlueModernParticipant(blue1, blue2, participantFont.toFont2(HtmlColorUtils.WHITE, - useUnderlineForHyperlink, hyperlinkColor, param.getTabSize()), stringsToDisplay, param); - } - if (type == ComponentType.PARTICIPANT_LINE) { - return new ComponentBlueModernLine(lineColor); - } - if (type == ComponentType.CONTINUE_LINE) { - return new ComponentBlueModernLine(lineColor); - } - if (type == ComponentType.ACTOR_HEAD) { - return new ComponentBlueModernActor(blue2, blue1, participantFont.toFont2(blue1, useUnderlineForHyperlink, - hyperlinkColor, param.getTabSize()), stringsToDisplay, true, param); - } - if (type == ComponentType.ACTOR_TAIL) { - return new ComponentBlueModernActor(blue2, blue1, participantFont.toFont2(blue1, useUnderlineForHyperlink, - hyperlinkColor, param.getTabSize()), stringsToDisplay, false, param); - } - if (type == ComponentType.NOTE) { - return new ComponentBlueModernNote(HtmlColorUtils.WHITE, HtmlColorUtils.BLACK, normalFont.toFont2( - HtmlColorUtils.BLACK, useUnderlineForHyperlink, hyperlinkColor, param.getTabSize()), - stringsToDisplay, param); - } - if (type == ComponentType.ALIVE_BOX_CLOSE_CLOSE) { - return new ComponentBlueModernActiveLine(blue1, true, true); - } - if (type == ComponentType.ALIVE_BOX_CLOSE_OPEN) { - return new ComponentBlueModernActiveLine(blue1, true, false); - } - if (type == ComponentType.ALIVE_BOX_OPEN_CLOSE) { - return new ComponentBlueModernActiveLine(blue1, false, true); - } - if (type == ComponentType.ALIVE_BOX_OPEN_OPEN) { - return new ComponentBlueModernActiveLine(blue1, false, false); - } - if (type == ComponentType.DELAY_LINE) { - return new ComponentBlueModernDelayLine(lineColor); - } - if (type == ComponentType.DELAY_TEXT) { - return new ComponentBlueModernDelayText(param.getFont(null, false, FontParam.SEQUENCE_DELAY).toFont2( - HtmlColorUtils.BLACK, useUnderlineForHyperlink, hyperlinkColor, param.getTabSize()), - stringsToDisplay, param); - } - if (type == ComponentType.DESTROY) { - return new ComponentRoseDestroy(red); - } - if (type == ComponentType.GROUPING_HEADER) { - return new ComponentBlueModernGroupingHeader(blue1, blue3, borderGroupColor, HtmlColorUtils.BLACK, - normalFont.toFont2(HtmlColorUtils.WHITE, useUnderlineForHyperlink, hyperlinkColor, - param.getTabSize()), smallFont, stringsToDisplay, param); - } - if (type == ComponentType.GROUPING_ELSE) { - return new ComponentRoseGroupingElse(HtmlColorUtils.BLACK, smallFont.toFont2(HtmlColorUtils.BLACK, - useUnderlineForHyperlink, hyperlinkColor, param.getTabSize()), stringsToDisplay.get(0), param, - blue3); - } - if (type == ComponentType.GROUPING_SPACE) { - return new ComponentRoseGroupingSpace(7); - } - // if (type == ComponentType.TITLE) { - // return new ComponentRoseTitle(bigFont.toFont2(HtmlColorUtils.BLACK, useUnderlineForHyperlink, - // hyperlinkColor, param.getTabSize()), stringsToDisplay, param); - // } - if (type == ComponentType.REFERENCE) { - return new ComponentRoseReference(normalFont.toFont2(HtmlColorUtils.BLACK, useUnderlineForHyperlink, - hyperlinkColor, param.getTabSize()), new SymbolContext(blue1, borderGroupColor).withStroke(Rose - .getStroke(param, LineParam.sequenceDividerBorder, 2)), normalFont.toFont2(HtmlColorUtils.WHITE, - useUnderlineForHyperlink, hyperlinkColor, param.getTabSize()), stringsToDisplay, - HorizontalAlignment.CENTER, param, blue3); - } - if (type == ComponentType.NEWPAGE) { - return new ComponentBlueModernNewpage(blue1); - } - if (type == ComponentType.DIVIDER) { - return new ComponentBlueModernDivider(normalFont.toFont2(HtmlColorUtils.BLACK, useUnderlineForHyperlink, - hyperlinkColor, param.getTabSize()), blue2, blue1, HtmlColorUtils.BLACK, stringsToDisplay, param); - } - // if (type == ComponentType.SIGNATURE) { - // return new ComponentRoseTitle(smallFont.toFont2(HtmlColorUtils.BLACK, useUnderlineForHyperlink, - // hyperlinkColor, param.getTabSize()), Display.create("This skin was created ", "in April 2009."), - // param); - // } - if (type == ComponentType.ENGLOBER) { - return new ComponentBlueModernEnglober(blue1, blue3, stringsToDisplay, param.getFont(null, false, - FontParam.SEQUENCE_BOX).toFont2(HtmlColorUtils.BLACK, useUnderlineForHyperlink, hyperlinkColor, - param.getTabSize()), param); - } - - return null; - - } - - public Object getProtocolVersion() { - return 1; - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActiveLine.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActiveLine.java deleted file mode 100644 index 6bac868e3..000000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActiveLine.java +++ /dev/null @@ -1,82 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.skin.bluemodern; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.AbstractComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernActiveLine extends AbstractComponent { - - private final int shadowview = 3; - private final HtmlColor foregroundColor; - - public ComponentBlueModernActiveLine(HtmlColor foregroundColor, boolean closeUp, boolean closeDown) { - this.foregroundColor = foregroundColor; - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - final StringBounder stringBounder = ug.getStringBounder(); - final int x = (int) (dimensionToUse.getWidth() - getPreferredWidth(stringBounder)) / 2; - final ShadowShape shadowShape = new ShadowShape(getPreferredWidth(stringBounder), dimensionToUse.getHeight() - - shadowview, 3); - shadowShape.drawU(ug.apply(new UTranslate(shadowview, shadowview))); - - ug.apply(new UChangeColor(foregroundColor)) - .apply(new UChangeBackColor(foregroundColor)).apply(new UTranslate(x, 0)).draw(new URectangle(getPreferredWidth(stringBounder), dimensionToUse.getHeight() - shadowview)); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return 0; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return 10; - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActor.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActor.java deleted file mode 100644 index b89a2cfda..000000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernActor.java +++ /dev/null @@ -1,99 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.skin.bluemodern; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.skin.AbstractTextualComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.skin.StickMan; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernActor extends AbstractTextualComponent { - - private final StickMan stickman; - private final boolean head; - - public ComponentBlueModernActor(HtmlColor backgroundColor, HtmlColor foregroundColor, FontConfiguration font, - Display stringsToDisplay, boolean head, ISkinSimple spriteContainer) { - super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, - 0, spriteContainer, false, null, null); - this.head = head; - stickman = new StickMan(backgroundColor, foregroundColor); - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - ug = ug.apply(new UChangeColor(getFontColor())); - final TextBlock textBlock = getTextBlock(); - final StringBounder stringBounder = ug.getStringBounder(); - final double delta = (getPreferredWidth(stringBounder) - stickman.getPreferredWidth()) / 2; - - if (head) { - textBlock - .drawU(ug.apply(new UTranslate(getTextMiddlePostion(stringBounder), stickman.getPreferredHeight()))); - ug = ug.apply(new UTranslate(delta, 0)); - } else { - textBlock.drawU(ug.apply(new UTranslate(getTextMiddlePostion(stringBounder), 0))); - ug = ug.apply(new UTranslate(delta, getTextHeight(stringBounder))); - } - stickman.drawU(ug); - - } - - private double getTextMiddlePostion(StringBounder stringBounder) { - return (getPreferredWidth(stringBounder) - getTextWidth(stringBounder)) / 2.0; - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return stickman.getPreferredHeight() + getTextHeight(stringBounder); - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return Math.max(stickman.getPreferredWidth(), getTextWidth(stringBounder)); - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernArrow.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernArrow.java deleted file mode 100644 index b2a2a1a4d..000000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernArrow.java +++ /dev/null @@ -1,197 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.skin.bluemodern; - -import java.awt.Graphics2D; -import java.awt.geom.Dimension2D; -import java.awt.geom.Point2D; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.skin.ArrowConfiguration; -import net.sourceforge.plantuml.skin.ArrowDirection; -import net.sourceforge.plantuml.skin.ArrowPart; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; -import net.sourceforge.plantuml.ugraphic.UPolygon; -import net.sourceforge.plantuml.ugraphic.UStroke; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernArrow extends AbstractComponentBlueModernArrow { - - public ComponentBlueModernArrow(HtmlColor foregroundColor, boolean useUnderlineForHyperlink, - FontConfiguration font, Display stringsToDisplay, ArrowConfiguration arrowConfiguration, - ISkinSimple spriteContainer) { - super(foregroundColor, font, stringsToDisplay, arrowConfiguration, spriteContainer); - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - if (getArrowConfiguration().isHidden()) { - return; - } - final Dimension2D dimensionToUse = area.getDimensionToUse(); - final StringBounder stringBounder = ug.getStringBounder(); - final int textHeight = (int) getTextHeight(stringBounder); - - ug = ug.apply(new UChangeColor(getForegroundColor())); - ug = ug.apply(new UChangeBackColor(getForegroundColor())); - - final int x2 = (int) dimensionToUse.getWidth(); - - if (getArrowConfiguration().isDotted()) { - ug = ArrowConfiguration.stroke(ug, 5, 2, 1); - } else { - ug = ug.apply(new UStroke(2)); - } - - ug.apply(new UTranslate(2, textHeight)).draw(new ULine(x2 - 4, 0)); - ug = ug.apply(new UStroke()); - - final int direction = getDirection(); - final UPolygon polygon = new UPolygon(); - - if (getArrowConfiguration().isAsync()) { - ug = ug.apply(new UStroke(1.5)); - if (direction == 1) { - if (getArrowConfiguration().getPart() != ArrowPart.BOTTOM_PART) { - ug.apply(new UTranslate(x2 - getArrowDeltaX2(), textHeight - getArrowDeltaY2())).draw( - new ULine(getArrowDeltaX2(), getArrowDeltaY2())); - } - if (getArrowConfiguration().getPart() != ArrowPart.TOP_PART) { - ug.apply(new UTranslate(x2 - getArrowDeltaX2(), textHeight + getArrowDeltaY2())).draw( - new ULine(getArrowDeltaX2(), -getArrowDeltaY2())); - } - } else { - if (getArrowConfiguration().getPart() != ArrowPart.BOTTOM_PART) { - ug.apply(new UTranslate(getArrowDeltaX2(), textHeight - getArrowDeltaY2())).draw( - new ULine(-getArrowDeltaX2(), getArrowDeltaY2())); - } - if (getArrowConfiguration().getPart() != ArrowPart.TOP_PART) { - ug.apply(new UTranslate(getArrowDeltaX2(), textHeight + getArrowDeltaY2())).draw( - new ULine(-getArrowDeltaX2(), -getArrowDeltaY2())); - } - } - ug = ug.apply(new UStroke()); - } else if (direction == 1) { - createPolygonNormal(textHeight, x2, polygon); - } else { - createPolygonReverse(textHeight, polygon); - } - ug.draw(polygon); - - getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), 0))); - } - - private void createPolygonReverse(final int textHeight, final UPolygon polygon) { - if (getArrowConfiguration().getPart() == ArrowPart.TOP_PART) { - polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY()); - polygon.addPoint(0, textHeight); - polygon.addPoint(getArrowDeltaX(), textHeight); - } else if (getArrowConfiguration().getPart() == ArrowPart.BOTTOM_PART) { - polygon.addPoint(getArrowDeltaX(), textHeight); - polygon.addPoint(0, textHeight); - polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY()); - } else { - polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY()); - polygon.addPoint(0, textHeight); - polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY()); - } - } - - private void createPolygonNormal(final int textHeight, final int x2, final UPolygon polygon) { - if (getArrowConfiguration().getPart() == ArrowPart.TOP_PART) { - polygon.addPoint(x2 - getArrowDeltaX(), textHeight - getArrowDeltaY()); - polygon.addPoint(x2, textHeight); - polygon.addPoint(x2 - getArrowDeltaX(), textHeight); - } else if (getArrowConfiguration().getPart() == ArrowPart.BOTTOM_PART) { - polygon.addPoint(x2 - getArrowDeltaX(), textHeight); - polygon.addPoint(x2, textHeight); - polygon.addPoint(x2 - getArrowDeltaX(), textHeight + getArrowDeltaY()); - } else { - polygon.addPoint(x2 - getArrowDeltaX(), textHeight - getArrowDeltaY()); - polygon.addPoint(x2, textHeight); - polygon.addPoint(x2 - getArrowDeltaX(), textHeight + getArrowDeltaY()); - } - } - - protected int getDirection(Graphics2D g2d) { - return getDirection(); - } - - protected int getDirection() { - if (getArrowConfiguration().getArrowDirection() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) { - return 1; - } - if (getArrowConfiguration().getArrowDirection() == ArrowDirection.RIGHT_TO_LEFT_REVERSE) { - return -1; - } - throw new IllegalStateException(); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return getTextHeight(stringBounder) + getArrowDeltaY() + 2 * getPaddingY(); - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return getTextWidth(stringBounder); - } - - public Point2D getStartPoint(StringBounder stringBounder, Dimension2D dimensionToUse) { - final int textHeight = (int) getTextHeight(stringBounder); - if (getArrowConfiguration().getArrowDirection() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) { - return new Point2D.Double(getPaddingX(), textHeight + getPaddingY()); - } - return new Point2D.Double(dimensionToUse.getWidth() + getPaddingX(), textHeight + getPaddingY()); - } - - public Point2D getEndPoint(StringBounder stringBounder, Dimension2D dimensionToUse) { - final int textHeight = (int) getTextHeight(stringBounder); - if (getArrowConfiguration().getArrowDirection() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) { - return new Point2D.Double(dimensionToUse.getWidth() + getPaddingX(), textHeight + getPaddingY()); - } - return new Point2D.Double(getPaddingX(), textHeight + getPaddingY()); - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayLine.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayLine.java deleted file mode 100644 index 32ebcd6d4..000000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayLine.java +++ /dev/null @@ -1,79 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.skin.bluemodern; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.AbstractComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.skin.ArrowConfiguration; -import net.sourceforge.plantuml.ugraphic.UAntiAliasing; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernDelayLine extends AbstractComponent { - - private final HtmlColor color; - - public ComponentBlueModernDelayLine(HtmlColor color) { - this.color = color; - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - ug = ug.apply(new UChangeColor(color)); - ug = ArrowConfiguration.stroke(ug, 1, 4, 1); - final int x = (int) (dimensionToUse.getWidth() / 2); - ug.apply(new UChangeBackColor(color)).apply(UAntiAliasing.ANTI_ALIASING_OFF).apply(new UTranslate(x + 1, 0)).draw(new ULine(0, dimensionToUse.getHeight())); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return 20; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return 2; - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayText.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayText.java deleted file mode 100644 index 5a7eb9922..000000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDelayText.java +++ /dev/null @@ -1,84 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.skin.bluemodern; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.skin.AbstractTextualComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernDelayText extends AbstractTextualComponent { - - public ComponentBlueModernDelayText(FontConfiguration font, Display stringsToDisplay, - ISkinSimple spriteContainer) { - super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 4, 4, - 4, spriteContainer, false, null, null); - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - final TextBlock textBlock = getTextBlock(); - final StringBounder stringBounder = ug.getStringBounder(); - final double textWidth = getTextWidth(stringBounder); - final double textHeight = getTextHeight(stringBounder); - - final double xpos = (dimensionToUse.getWidth() - textWidth) / 2; - final double ypos = (dimensionToUse.getHeight() - textHeight) / 2; - - textBlock.drawU(ug.apply(new UTranslate(xpos, (ypos + getMarginY())))); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return getTextHeight(stringBounder) + 20; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return getTextWidth(stringBounder) + 30; - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDivider.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDivider.java deleted file mode 100644 index f1fcf01b8..000000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernDivider.java +++ /dev/null @@ -1,114 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.skin.bluemodern; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.skin.AbstractTextualComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UStroke; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernDivider extends AbstractTextualComponent { - - private final HtmlColor background1; - private final HtmlColor background2; - private final HtmlColor borderColor; - - public ComponentBlueModernDivider(FontConfiguration font, HtmlColor background1, HtmlColor background2, - HtmlColor borderColor, Display stringsToDisplay, ISkinSimple spriteContainer) { - super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 4, 4, - 4, spriteContainer, false, null, null); - this.background1 = background1; - this.background2 = background2; - this.borderColor = borderColor; - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - final TextBlock textBlock = getTextBlock(); - final StringBounder stringBounder = ug.getStringBounder(); - final double textWidth = getTextWidth(stringBounder); - final double textHeight = getTextHeight(stringBounder); - - final double deltaX = 6; - final double xpos = (dimensionToUse.getWidth() - textWidth - deltaX) / 2; - final double ypos = (dimensionToUse.getHeight() - textHeight) / 2; - - ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK)); - ug = ug.apply(new UChangeBackColor(HtmlColorUtils.BLACK)); - ug = ug.apply(new UStroke(2)); - - ug.apply(new UTranslate(0, dimensionToUse.getHeight() / 2 - 1)).draw(new ULine(dimensionToUse.getWidth(), 0)); - ug.apply(new UTranslate(0, dimensionToUse.getHeight() / 2 + 2)).draw(new ULine(dimensionToUse.getWidth(), 0)); - - final FillRoundShape shape = new FillRoundShape(textWidth + deltaX, textHeight, background1, background2, 5); - shape.drawU(ug.apply(new UTranslate(xpos, ypos))); - - ug = ug.apply(new UChangeColor(borderColor)); - ug = ug.apply(new UChangeBackColor(null)); - ug.apply(new UTranslate(xpos, ypos)).draw(new URectangle(textWidth + deltaX, textHeight, 5, 5)); - ug = ug.apply(new UStroke()); - - textBlock.drawU(ug.apply(new UTranslate(xpos + deltaX, ypos + getMarginY()))); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return getTextHeight(stringBounder) + 20; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return getTextWidth(stringBounder) + 30; - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernEnglober.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernEnglober.java deleted file mode 100644 index d22c1df4f..000000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernEnglober.java +++ /dev/null @@ -1,97 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.skin.bluemodern; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.AbstractTextualComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UStroke; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernEnglober extends AbstractTextualComponent { - - private final HtmlColor borderColor; - private final HtmlColor backColor; - - public ComponentBlueModernEnglober(HtmlColor borderColor, HtmlColor backColor, Display strings, - FontConfiguration font, ISkinSimple spriteContainer) { - super(LineBreakStrategy.NONE, strings, font, HorizontalAlignment.CENTER, 4, 4, 1, spriteContainer, false, - null, null); - this.borderColor = borderColor; - this.backColor = backColor; - } - - @Override - protected void drawBackgroundInternalU(UGraphic ug, Area area) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - ug = ug.apply(new UChangeColor(borderColor)); - ug = ug.apply(new UChangeBackColor(backColor)); - ug.apply(new UStroke(2)).draw(new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight(), 9, 9)); - final double xpos = (dimensionToUse.getWidth() - getPureTextWidth(ug.getStringBounder())) / 2; - - getTextBlock().drawU(ug.apply(new UTranslate(xpos, 0))); - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - // ug.getParam().setColor(Color.RED); - // ug.getParam().setBackcolor(Color.YELLOW); - // ug.draw(0, 0, new URectangle(dimensionToUse.getWidth(), - // dimensionToUse.getHeight())); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return getTextHeight(stringBounder) + 3; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return getTextWidth(stringBounder) + 10; - } -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java deleted file mode 100644 index 8d53f6b1e..000000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernGroupingHeader.java +++ /dev/null @@ -1,161 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.skin.bluemodern; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.skin.AbstractTextualComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UFont; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; -import net.sourceforge.plantuml.ugraphic.UPolygon; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UStroke; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernGroupingHeader extends AbstractTextualComponent { - - private final int cornersize = 10; - private final int commentMargin = 0; // 8; - - private final TextBlock commentTextBlock; - - private final HtmlColor headerBackgroundColor; - private final HtmlColor generalBackgroundColor; - private final HtmlColor borderColor; - - public ComponentBlueModernGroupingHeader(HtmlColor headerBackgroundColor, HtmlColor generalBackgroundColor, - HtmlColor borderColor, HtmlColor fontColor2, FontConfiguration bigFont, UFont smallFont, Display strings, - ISkinSimple spriteContainer) { - super(LineBreakStrategy.NONE, strings.get(0), bigFont, HorizontalAlignment.LEFT, 15, 30, 1, spriteContainer, null, null); - this.headerBackgroundColor = headerBackgroundColor; - this.generalBackgroundColor = generalBackgroundColor; - this.borderColor = borderColor; - if (strings.size() == 1 || strings.get(1) == null) { - this.commentTextBlock = null; - } else { - final FontConfiguration fontConfiguration = new FontConfiguration(smallFont, fontColor2, - bigFont.getHyperlinkColor(), bigFont.useUnderlineForHyperlink(), spriteContainer.getTabSize()); - this.commentTextBlock = Display.create("[" + strings.get(1) + "]").create(fontConfiguration, - HorizontalAlignment.LEFT, spriteContainer); - } - } - - // @Override - // public double getPaddingY() { - // return 6; - // } - - @Override - final public double getPreferredWidth(StringBounder stringBounder) { - final double sup; - if (commentTextBlock == null) { - sup = commentMargin * 2; - } else { - final Dimension2D size = commentTextBlock.calculateDimension(stringBounder); - sup = getMarginX1() + commentMargin + size.getWidth(); - - } - return getTextWidth(stringBounder) + sup; - } - - @Override - final public double getPreferredHeight(StringBounder stringBounder) { - return getTextHeight(stringBounder) + 2 * getPaddingY(); - } - - @Override - protected void drawBackgroundInternalU(UGraphic ug, Area area) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - ug.apply(new UChangeColor(borderColor)).apply(new UStroke(2)) - .apply(new UChangeBackColor(generalBackgroundColor)) - .draw(new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight())); - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - ug = ug.apply(new UChangeColor(borderColor)); - ug.apply(new UStroke(2)).draw(new URectangle(dimensionToUse.getWidth(), dimensionToUse.getHeight())); - - final StringBounder stringBounder = ug.getStringBounder(); - final int textWidth = (int) getTextWidth(stringBounder); - final int textHeight = (int) getTextHeight(stringBounder); - - final UPolygon polygon = new UPolygon(); - polygon.addPoint(0, 0); - polygon.addPoint(textWidth, 0); - - polygon.addPoint(textWidth, textHeight - cornersize); - polygon.addPoint(textWidth - cornersize, textHeight); - - polygon.addPoint(0, textHeight); - polygon.addPoint(0, 0); - - ug = ug.apply(new UStroke(2)); - ug = ug.apply(new UChangeBackColor(headerBackgroundColor)); - ug.draw(polygon); - ug.draw(new ULine(dimensionToUse.getWidth(), 0)); - - final double heightWithoutPadding = dimensionToUse.getHeight() - getPaddingY(); - - ug.apply(new UTranslate(dimensionToUse.getWidth(), 0)).draw(new ULine(0, heightWithoutPadding)); - ug.apply(new UTranslate(0, textHeight)).draw(new ULine(0, heightWithoutPadding - textHeight)); - ug = ug.apply(new UStroke()); - - getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), getMarginY()))); - - if (commentTextBlock != null) { - final int x1 = getMarginX1() + textWidth; - final int y2 = getMarginY() + 1; - - commentTextBlock.drawU(ug.apply(new UChangeColor(generalBackgroundColor)).apply( - new UTranslate(x1 + commentMargin, y2))); - } - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernLine.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernLine.java deleted file mode 100644 index 229fdc3ea..000000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernLine.java +++ /dev/null @@ -1,76 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.skin.bluemodern; - -import java.awt.geom.Dimension2D; - -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.AbstractComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.URectangle; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernLine extends AbstractComponent { - - private final HtmlColor color; - - public ComponentBlueModernLine(HtmlColor color) { - this.color = color; - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - final int x = (int) (dimensionToUse.getWidth() / 2); - final StringBounder stringBounder = ug.getStringBounder(); - ug.apply(new UChangeColor(color)).apply(new UChangeBackColor(color)).apply(new UTranslate(x, 0)).draw(new URectangle(getPreferredWidth(stringBounder), dimensionToUse.getHeight())); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return 20; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return 2; - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNote.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNote.java deleted file mode 100644 index 603acfc20..000000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNote.java +++ /dev/null @@ -1,119 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.skin.bluemodern; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.AbstractTextualComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; -import net.sourceforge.plantuml.ugraphic.UPolygon; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -final public class ComponentBlueModernNote extends AbstractTextualComponent { - - private final int shadowview = 4; - private final int cornersize = 10; - private final HtmlColor back; - private final HtmlColor foregroundColor; - - public ComponentBlueModernNote(HtmlColor back, HtmlColor foregroundColor, FontConfiguration font, - Display strings, ISkinSimple spriteContainer) { - super(LineBreakStrategy.NONE, strings, font, HorizontalAlignment.LEFT, 6, 15, 5, spriteContainer, false, - null, null); - this.back = back; - this.foregroundColor = foregroundColor; - } - - @Override - final public double getPreferredWidth(StringBounder stringBounder) { - final double result = getTextWidth(stringBounder) + 2 * getPaddingX(); - return result; - } - - @Override - final public double getPreferredHeight(StringBounder stringBounder) { - return getTextHeight(stringBounder) + 2 * getPaddingY(); - } - - @Override - public double getPaddingX() { - return 9; - } - - @Override - public double getPaddingY() { - return 9; - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - final StringBounder stringBounder = ug.getStringBounder(); - final double textHeight = getTextHeight(stringBounder); - - final double textWidth = getTextWidth(stringBounder); - - final ShadowShape shadowShape = new ShadowShape(textWidth, textHeight, 3); - shadowShape.drawU(ug.apply(new UTranslate(shadowview, shadowview))); - - final UPolygon polygon = new UPolygon(); - polygon.addPoint(0, 0); - polygon.addPoint(0, textHeight); - polygon.addPoint(textWidth, textHeight); - polygon.addPoint(textWidth, cornersize); - polygon.addPoint(textWidth - cornersize, 0); - polygon.addPoint(0, 0); - - ug = ug.apply(new UChangeBackColor(back)); - ug = ug.apply(new UChangeColor(foregroundColor)); - ug.draw(polygon); - - ug.apply(new UTranslate(textWidth - cornersize, 0)).draw(new ULine(0, cornersize)); - ug.apply(new UTranslate(textWidth, cornersize)).draw(new ULine(-cornersize, 0)); - - getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), getMarginY()))); - - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernParticipant.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernParticipant.java deleted file mode 100644 index d1906e024..000000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernParticipant.java +++ /dev/null @@ -1,92 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.skin.bluemodern; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.LineBreakStrategy; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.AbstractTextualComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernParticipant extends AbstractTextualComponent { - - private final int shadowview = 3; - private final HtmlColor blue1; - private final HtmlColor blue2; - - public ComponentBlueModernParticipant(HtmlColor blue1, HtmlColor blue2, FontConfiguration font, - Display stringsToDisplay, ISkinSimple spriteContainer) { - super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 7, 7, - 7, spriteContainer, false, null, null); - this.blue1 = blue1; - this.blue2 = blue2; - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - final StringBounder stringBounder = ug.getStringBounder(); - - final ShadowShape shadowShape = new ShadowShape(getTextWidth(stringBounder), getTextHeight(stringBounder), 10); - final UGraphic ugShadow = ug.apply(new UTranslate(shadowview, shadowview)).apply(new UChangeColor(null)); - // ug.translate(shadowview, shadowview); - shadowShape.drawU(ugShadow); - // ug.translate(-shadowview, -shadowview); - - final FillRoundShape shape = new FillRoundShape(getTextWidth(stringBounder), getTextHeight(stringBounder), - blue1, blue2, 10); - shape.drawU(ug); - - getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), getMarginY()))); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return getTextHeight(stringBounder) + shadowview; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return getTextWidth(stringBounder); - } - -} diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernSelfArrow.java b/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernSelfArrow.java deleted file mode 100644 index cf65fec50..000000000 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernSelfArrow.java +++ /dev/null @@ -1,157 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - * - */ -package net.sourceforge.plantuml.skin.bluemodern; - -import java.awt.geom.Dimension2D; -import java.awt.geom.Point2D; - -import net.sourceforge.plantuml.ISkinSimple; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.skin.ArrowConfiguration; -import net.sourceforge.plantuml.skin.ArrowPart; -import net.sourceforge.plantuml.ugraphic.UChangeBackColor; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; -import net.sourceforge.plantuml.ugraphic.UPolygon; -import net.sourceforge.plantuml.ugraphic.UStroke; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class ComponentBlueModernSelfArrow extends AbstractComponentBlueModernArrow { - - private final double arrowWidth = 45; - - public ComponentBlueModernSelfArrow(HtmlColor foregroundColor, FontConfiguration font, Display stringsToDisplay, - ArrowConfiguration arrowConfiguration, ISkinSimple spriteContainer) { - super(foregroundColor, font, stringsToDisplay, arrowConfiguration, spriteContainer); - } - - @Override - protected void drawInternalU(UGraphic ug, Area area) { - if (getArrowConfiguration().isHidden()) { - return; - } - final StringBounder stringBounder = ug.getStringBounder(); - final int textHeight = (int) getTextHeight(stringBounder); - - ug = ug.apply(new UChangeBackColor(getForegroundColor())).apply(new UChangeColor(getForegroundColor())); - final double x2 = arrowWidth - 3; - - if (getArrowConfiguration().isDotted()) { - ug = ArrowConfiguration.stroke(ug, 5, 2, 1); - } else { - ug = ug.apply(new UStroke(2)); - } - - ug.apply(new UTranslate(0, textHeight)).draw(new ULine(x2, 0)); - - final int textAndArrowHeight = (int) (textHeight + getArrowOnlyHeight(stringBounder)); - - ug.apply(new UTranslate(x2, textHeight)).draw(new ULine(0, textAndArrowHeight - textHeight)); - ug.apply(new UTranslate(x2, textAndArrowHeight)).draw(new ULine(2 - x2, 0)); - - ug = ug.apply(new UStroke()); - - final int delta = (int) getArrowOnlyHeight(stringBounder); - - if (getArrowConfiguration().isAsync()) { - if (getArrowConfiguration().getPart() != ArrowPart.BOTTOM_PART) { - ug.apply(new UStroke(1.5)) - .apply(new UTranslate(getArrowDeltaX2(), textHeight - getArrowDeltaY2() + delta)) - .draw(new ULine(-getArrowDeltaX2(), getArrowDeltaY2())); - } - if (getArrowConfiguration().getPart() != ArrowPart.TOP_PART) { - ug.apply(new UStroke(1.5)) - .apply(new UTranslate(getArrowDeltaX2(), textHeight + getArrowDeltaY2() + delta)) - .draw(new ULine(-getArrowDeltaX2(), -getArrowDeltaY2())); - } - } else { - final UPolygon polygon = getPolygon(textHeight, delta); - ug.draw(polygon); - } - - getTextBlock().drawU(ug.apply(new UTranslate(getMarginX1(), 0))); - - } - - private UPolygon getPolygon(final int textHeight, final int delta) { - final UPolygon polygon = new UPolygon(); - if (getArrowConfiguration().getPart() == ArrowPart.TOP_PART) { - polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY() + delta); - polygon.addPoint(0, textHeight + delta); - polygon.addPoint(getArrowDeltaX(), textHeight + delta); - } else if (getArrowConfiguration().getPart() == ArrowPart.BOTTOM_PART) { - polygon.addPoint(getArrowDeltaX(), textHeight + delta); - polygon.addPoint(0, textHeight + delta); - polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY() + delta); - } else { - polygon.addPoint(getArrowDeltaX(), textHeight - getArrowDeltaY() + delta); - polygon.addPoint(0, textHeight + delta); - polygon.addPoint(getArrowDeltaX(), textHeight + getArrowDeltaY() + delta); - } - return polygon; - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return getTextHeight(stringBounder) + getArrowDeltaY() + getArrowOnlyHeight(stringBounder) + 2 * getPaddingY(); - } - - private double getArrowOnlyHeight(StringBounder stringBounder) { - return 13; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return Math.max(getTextWidth(stringBounder), arrowWidth); - } - - public Point2D getStartPoint(StringBounder stringBounder, Dimension2D dimensionToUse) { - final int textHeight = (int) getTextHeight(stringBounder); - return new Point2D.Double(getPaddingX(), textHeight + getPaddingY()); - } - - public Point2D getEndPoint(StringBounder stringBounder, Dimension2D dimensionToUse) { - final int textHeight = (int) getTextHeight(stringBounder); - final int textAndArrowHeight = (int) (textHeight + getArrowOnlyHeight(stringBounder)); - return new Point2D.Double(getPaddingX(), textAndArrowHeight + getPaddingY()); - } - -} diff --git a/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java b/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java index c42372729..b5d9237cd 100644 --- a/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java +++ b/src/net/sourceforge/plantuml/skin/rose/AbstractComponentRoseArrow.java @@ -41,6 +41,7 @@ import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; +import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.skin.AbstractTextualComponent; import net.sourceforge.plantuml.skin.ArrowComponent; import net.sourceforge.plantuml.skin.ArrowConfiguration; @@ -60,6 +61,9 @@ public abstract class AbstractComponentRoseArrow extends AbstractTextualComponen this.arrowConfiguration = arrowConfiguration; this.foregroundColor = foregroundColor; } + + abstract public double getYPoint(StringBounder stringBounder); + protected final HtmlColor getForegroundColor() { return foregroundColor; diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java index f3c9a520a..65625b700 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseArrow.java @@ -291,7 +291,8 @@ public class ComponentRoseArrow extends AbstractComponentRoseArrow { return new Point2D.Double(getPaddingX(), y); } - private double getYPoint(StringBounder stringBounder) { + @Override + public double getYPoint(StringBounder stringBounder) { if (isBelowForResponse()) { return getPaddingY(); } diff --git a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java index 36b35f800..436d668a0 100644 --- a/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java +++ b/src/net/sourceforge/plantuml/skin/rose/ComponentRoseSelfArrow.java @@ -65,7 +65,8 @@ public class ComponentRoseSelfArrow extends AbstractComponentRoseArrow { private final boolean niceArrow; public ComponentRoseSelfArrow(HtmlColor foregroundColor, FontConfiguration font, Display stringsToDisplay, - ArrowConfiguration arrowConfiguration, ISkinSimple spriteContainer, LineBreakStrategy maxMessageSize, boolean niceArrow) { + ArrowConfiguration arrowConfiguration, ISkinSimple spriteContainer, LineBreakStrategy maxMessageSize, + boolean niceArrow) { super(foregroundColor, font, stringsToDisplay, arrowConfiguration, spriteContainer, HorizontalAlignment.LEFT, maxMessageSize); this.niceArrow = niceArrow; @@ -164,16 +165,23 @@ public class ComponentRoseSelfArrow extends AbstractComponentRoseArrow { } public Point2D getStartPoint(StringBounder stringBounder, Dimension2D dimensionToUse) { - final int textHeight = (int) getTextHeight(stringBounder); + final double textHeight = getTextHeight(stringBounder); return new Point2D.Double(getPaddingX(), textHeight + getPaddingY()); } public Point2D getEndPoint(StringBounder stringBounder, Dimension2D dimensionToUse) { - final int textHeight = (int) getTextHeight(stringBounder); - final int textAndArrowHeight = (int) (textHeight + getArrowOnlyHeight(stringBounder)); + final double textHeight = getTextHeight(stringBounder); + final double textAndArrowHeight = (textHeight + getArrowOnlyHeight(stringBounder)); return new Point2D.Double(getPaddingX(), textAndArrowHeight + getPaddingY()); } + @Override + public double getYPoint(StringBounder stringBounder) { + final double textHeight = getTextHeight(stringBounder); + final double textAndArrowHeight = (textHeight + getArrowOnlyHeight(stringBounder)); + return (textHeight + textAndArrowHeight) / 2 + getPaddingX(); + } + @Override public double getPreferredHeight(StringBounder stringBounder) { return getTextHeight(stringBounder) + getArrowDeltaY() + getArrowOnlyHeight(stringBounder) + 2 * getPaddingY(); diff --git a/src/net/sourceforge/plantuml/skin/rose/Rose.java b/src/net/sourceforge/plantuml/skin/rose/Rose.java index a11633878..27d8046da 100644 --- a/src/net/sourceforge/plantuml/skin/rose/Rose.java +++ b/src/net/sourceforge/plantuml/skin/rose/Rose.java @@ -37,11 +37,11 @@ package net.sourceforge.plantuml.skin.rose; import net.sourceforge.plantuml.AlignmentParam; import net.sourceforge.plantuml.ColorParam; +import net.sourceforge.plantuml.CornerParam; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.PaddingParam; -import net.sourceforge.plantuml.CornerParam; import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Stereotype; @@ -49,15 +49,15 @@ import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.SymbolContext; +import net.sourceforge.plantuml.skin.ArrowComponent; import net.sourceforge.plantuml.skin.ArrowConfiguration; import net.sourceforge.plantuml.skin.ArrowDirection; import net.sourceforge.plantuml.skin.Component; import net.sourceforge.plantuml.skin.ComponentType; -import net.sourceforge.plantuml.skin.Skin; import net.sourceforge.plantuml.ugraphic.UFont; import net.sourceforge.plantuml.ugraphic.UStroke; -public class Rose implements Skin { +public class Rose { final private double paddingX = 5; final private double paddingY = 5; @@ -91,23 +91,7 @@ public class Rose implements Skin { final UFont newFontForStereotype = param.getFont(null, false, FontParam.SEQUENCE_STEREOTYPE); if (type.isArrow()) { - // if (param.maxMessageSize() > 0) { - // final FontConfiguration fc = new FontConfiguration(fontArrow, HtmlColorUtils.BLACK); - // stringsToDisplay = DisplayUtils.breakLines(stringsToDisplay, fc, param, param.maxMessageSize()); - // } - final HtmlColor sequenceArrow = config.getColor() == null ? getHtmlColor(param, ColorParam.arrow) : config - .getColor(); - if (config.getArrowDirection() == ArrowDirection.SELF) { - return new ComponentRoseSelfArrow(sequenceArrow, getUFont2(param, FontParam.ARROW), stringsToDisplay, - config, param, param.maxMessageSize(), param.strictUmlStyle() == false); - } - final HorizontalAlignment messageHorizontalAlignment = param.getHorizontalAlignment( - AlignmentParam.sequenceMessageAlignment, config.getArrowDirection(), config.isReverseDefine()); - final HorizontalAlignment textHorizontalAlignment = param.getHorizontalAlignment( - AlignmentParam.sequenceMessageTextAlignment, config.getArrowDirection(), false); - return new ComponentRoseArrow(sequenceArrow, getUFont2(param, FontParam.ARROW), stringsToDisplay, config, - messageHorizontalAlignment, param, textHorizontalAlignment, param.maxMessageSize(), - param.strictUmlStyle() == false, param.responseMessageBelowArrow()); + return createComponentArrow(config, param, stringsToDisplay); } final double padding = param.getPadding(PaddingParam.PARTICIPANT); final double roundCorner = param.getRoundCorner(CornerParam.DEFAULT, null); @@ -285,6 +269,23 @@ public class Rose implements Skin { return null; } + public ArrowComponent createComponentArrow(ArrowConfiguration config, ISkinParam param, + Display stringsToDisplay) { + final HtmlColor sequenceArrow = config.getColor() == null ? getHtmlColor(param, ColorParam.arrow) : config + .getColor(); + if (config.getArrowDirection() == ArrowDirection.SELF) { + return new ComponentRoseSelfArrow(sequenceArrow, getUFont2(param, FontParam.ARROW), stringsToDisplay, + config, param, param.maxMessageSize(), param.strictUmlStyle() == false); + } + final HorizontalAlignment messageHorizontalAlignment = param.getHorizontalAlignment( + AlignmentParam.sequenceMessageAlignment, config.getArrowDirection(), config.isReverseDefine()); + final HorizontalAlignment textHorizontalAlignment = param.getHorizontalAlignment( + AlignmentParam.sequenceMessageTextAlignment, config.getArrowDirection(), false); + return new ComponentRoseArrow(sequenceArrow, getUFont2(param, FontParam.ARROW), stringsToDisplay, config, + messageHorizontalAlignment, param, textHorizontalAlignment, param.maxMessageSize(), + param.strictUmlStyle() == false, param.responseMessageBelowArrow()); + } + private double deltaShadow(ISkinParam param) { return param.shadowing(null) ? 4.0 : 0; } @@ -359,8 +360,4 @@ public class Rose implements Skin { return result; } - public Object getProtocolVersion() { - return 1; - } - } diff --git a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java index 6f8e69b2f..08b4d8ed2 100644 --- a/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java +++ b/src/net/sourceforge/plantuml/svek/GeneralImageBuilder.java @@ -570,12 +570,11 @@ public final class GeneralImageBuilder { if (stereotype == null) { return TextBlockUtils.empty(0, 0); } - if (stereotype.getSprite() != null) { - final Sprite tmp = dotData.getSkinParam().getSprite(stereotype.getSprite()); - if (tmp != null) { - return tmp.asTextBlock(stereotype.getHtmlColor(), 1); - } + final TextBlock tmp = stereotype.getSprite(dotData.getSkinParam()); + if (tmp != null) { + return tmp; } + final List stereos = stereotype.getLabels(dotData.getSkinParam().useGuillemet()); if (stereos == null) { return TextBlockUtils.empty(0, 0); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java b/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java index 1469f1b67..d95ae0ad1 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageClassHeader2.java @@ -35,8 +35,6 @@ */ package net.sourceforge.plantuml.svek.image; -import h.tedge_t; - import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.ColorParam; @@ -140,8 +138,8 @@ public class EntityImageClassHeader2 extends AbstractEntityImage { private TextBlock getCircledCharacter(ILeaf entity, ISkinParam skinParam) { final Stereotype stereotype = entity.getStereotype(); - if (stereotype != null && stereotype.getSprite() != null) { - return skinParam.getSprite(stereotype.getSprite()).asTextBlock(stereotype.getHtmlColor(), 1); + if (stereotype != null && stereotype.getSprite(skinParam) != null) { + return stereotype.getSprite(skinParam); } final UFont font = SkinParamUtils.getFont(getSkinParam(), FontParam.CIRCLED_CHARACTER, null); final HtmlColor classBorder = SkinParamUtils.getColor(getSkinParam(), stereotype, ColorParam.classBorder); diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java b/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java index c0ff71c1f..6533d4281 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageDescription.java @@ -137,10 +137,9 @@ public class EntityImageDescription extends AbstractEntityImage { stereo = TextBlockUtils.empty(0, 0); - if (stereotype != null && stereotype.getSprite() != null - && getSkinParam().getSprite(stereotype.getSprite()) != null) { + if (stereotype != null && stereotype.getSprite(getSkinParam()) != null) { symbol = symbol.withStereoAlignment(HorizontalAlignment.RIGHT); - stereo = getSkinParam().getSprite(stereotype.getSprite()).asTextBlock(stereotype.getHtmlColor(), 1); + stereo = stereotype.getSprite(getSkinParam()); } else if (stereotype != null && stereotype.getLabel(false) != null && portionShower.showPortion(EntityPortion.STEREOTYPE, entity)) { stereo = Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())).create( diff --git a/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java b/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java index 9fbfa4910..fcad8c49a 100644 --- a/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java +++ b/src/net/sourceforge/plantuml/svek/image/EntityImageObject.java @@ -119,7 +119,10 @@ public class EntityImageObject extends AbstractEntityImage implements Stencil { public Dimension2D calculateDimension(StringBounder stringBounder) { final Dimension2D dimTitle = getTitleDimension(stringBounder); final Dimension2D dimFields = fields.calculateDimension(stringBounder); - final double width = Math.max(dimFields.getWidth(), dimTitle.getWidth() + 2 * xMarginCircle); + double width = Math.max(dimFields.getWidth(), dimTitle.getWidth() + 2 * xMarginCircle); + if (width < getSkinParam().minClassWidth()) { + width = getSkinParam().minClassWidth(); + } final double height = getMethodOrFieldHeight(dimFields) + dimTitle.getHeight(); return new Dimension2DDouble(width, height); diff --git a/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java b/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java index db08847ce..74ca14848 100644 --- a/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java +++ b/src/net/sourceforge/plantuml/syntax/LanguageDescriptor.java @@ -37,6 +37,7 @@ package net.sourceforge.plantuml.syntax; import java.io.PrintStream; import java.util.Collection; +import java.util.Collections; import java.util.Set; import java.util.TreeSet; @@ -208,4 +209,16 @@ public class LanguageDescriptor { ps.println(); } + public final Set getType() { + return Collections.unmodifiableSet(type); + } + + public final Set getKeyword() { + return Collections.unmodifiableSet(keyword); + } + + public final Set getPreproc() { + return Collections.unmodifiableSet(preproc); + } + } diff --git a/src/net/sourceforge/plantuml/timingdiagram/AbstractPlayer.java b/src/net/sourceforge/plantuml/timingdiagram/AbstractPlayer.java new file mode 100644 index 000000000..49f8c2e13 --- /dev/null +++ b/src/net/sourceforge/plantuml/timingdiagram/AbstractPlayer.java @@ -0,0 +1,208 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + */ +package net.sourceforge.plantuml.timingdiagram; + +import java.awt.geom.Dimension2D; +import java.awt.geom.Rectangle2D; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.FontParam; +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.command.Position; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.FontConfiguration; +import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.HtmlColorUtils; +import net.sourceforge.plantuml.graphic.InnerStrategy; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.TextBlock; +import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.ugraphic.MinMax; +import net.sourceforge.plantuml.ugraphic.UChangeColor; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.UStroke; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public abstract class AbstractPlayer implements Player { + + // private final String code; + private final Display full; + protected final ISkinParam skinParam; + protected final TimingRuler ruler; + private String initialState; + + private final Set changes = new TreeSet(); + private final List constraints = new ArrayList(); + protected final List notes = new ArrayList(); + protected final Map statesLabel = new LinkedHashMap(); + + public AbstractPlayer(String full, ISkinParam skinParam, TimingRuler ruler) { + // this.code = code; + this.full = Display.getWithNewlines(full); + this.skinParam = skinParam; + this.ruler = ruler; + } + + protected abstract TimeDrawing buildDrawing(); + + private FontConfiguration getFontConfiguration() { + return new FontConfiguration(skinParam, FontParam.TIMING, null); + } + + public void drawTitle(UGraphic ug) { + final TextBlock title = getTitle(); + title.drawU(ug); + final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder()); + drawLine(ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UStroke(1.0)), -TimingDiagram.marginX1, + dimTitle.getHeight() + 1, dimTitle.getWidth() + 1, dimTitle.getHeight() + 1, + dimTitle.getWidth() + 1 + 10, 0); + } + + public void drawContent(UGraphic ug) { + ug = ug.apply(getTranslateForTimeDrawing(ug.getStringBounder())); + getTimeDrawing().drawU(ug); + } + + public void drawLeftHeader(UGraphic ug) { + ug = ug.apply(getTranslateForTimeDrawing(ug.getStringBounder())); + getTimeDrawing().getWidthHeader(ug.getStringBounder()).drawU(ug); + } + + public double getWidthHeader(StringBounder stringBounder) { + return getTimeDrawing().getWidthHeader(stringBounder).calculateDimension(stringBounder).getWidth(); + } + + private void drawLine(UGraphic ug, double... coord) { + for (int i = 0; i < coord.length - 2; i += 2) { + final double x1 = coord[i]; + final double y1 = coord[i + 1]; + final double x2 = coord[i + 2]; + final double y2 = coord[i + 3]; + ug.apply(new UTranslate(x1, y1)).draw(new ULine(x2 - x1, y2 - y1)); + } + + } + + private UTranslate getTranslateForTimeDrawing(StringBounder stringBounder) { + final TextBlock title = getTitle(); + return new UTranslate(0, title.calculateDimension(stringBounder).getHeight() * 2); + } + + private TextBlock getTitle() { + return full.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam); + } + + private TimeDrawing cached; + private Colors initialColors; + + private TimeDrawing getTimeDrawing() { + if (cached == null) { + cached = computeTimeDrawing(); + } + return cached; + } + + private TimeDrawing computeTimeDrawing() { + final TimeDrawing result = buildDrawing(); + result.setInitialState(initialState, initialColors); + for (ChangeState change : changes) { + result.addChange(change); + } + for (TimeConstraint constraint : constraints) { + result.addConstraint(constraint); + } + return result; + } + + public double getHeight(StringBounder stringBounder) { + final TextBlock title = getTitle(); + final double zoneHeight = getZoneHeight(stringBounder); + return title.calculateDimension(stringBounder).getHeight() * 2 + zoneHeight; + } + + private double getZoneHeight(StringBounder stringBounder) { + return getTimeDrawing().getHeight(stringBounder); + } + + public void setState(TimeTick now, String comment, Colors color, String... states) { + for (int i = 0; i < states.length; i++) { + states[i] = decodeState(states[i]); + } + if (now == null) { + this.initialState = states[0]; + this.initialColors = color; + } else { + this.changes.add(new ChangeState(now, comment, color, states)); + } + + } + + private String decodeState(String code) { + final String label = statesLabel.get(code); + if (label == null) { + return code; + } + return label; + } + + public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) { + final IntricatedPoint point = getTimeDrawing().getTimeProjection(stringBounder, tick); + if (point == null) { + return null; + } + final UTranslate translation = getTranslateForTimeDrawing(stringBounder); + return point.translated(translation); + } + + public void createConstraint(TimeTick tick1, TimeTick tick2, String message) { + this.constraints.add(new TimeConstraint(tick1, tick2, message)); + } + + public void addNote(TimeTick now, Display note, Position position) { + this.notes.add(new TimingNote(now, this, note, position, skinParam)); + } + + public void defineState(String stateCode, String label) { + statesLabel.put(stateCode, label); + } + +} diff --git a/src/net/sourceforge/plantuml/timingdiagram/ChangeState.java b/src/net/sourceforge/plantuml/timingdiagram/ChangeState.java index 5dd4d94b6..05d026e39 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/ChangeState.java +++ b/src/net/sourceforge/plantuml/timingdiagram/ChangeState.java @@ -45,13 +45,16 @@ import net.sourceforge.plantuml.ugraphic.UStroke; public class ChangeState implements Comparable { private final TimeTick when; - private final String state; + private final String[] states; private final String comment; private final Colors colors; - public ChangeState(TimeTick when, String state, String comment, Colors colors) { + public ChangeState(TimeTick when, String comment, Colors colors, String... states) { + if (states.length == 0) { + throw new IllegalArgumentException(); + } this.when = when; - this.state = state; + this.states = states; this.comment = comment; this.colors = colors; } @@ -64,15 +67,19 @@ public class ChangeState implements Comparable { return when; } + public final String[] getStates() { + return states; + } + public final String getState() { - return state; + return states[0]; } public String getComment() { return comment; } - private final HtmlColor getBackColor() { + public final HtmlColor getBackColor() { if (colors == null || colors.getColor(ColorType.BACK) == null) { return HtmlColorUtils.COL_D7E0F2; } @@ -91,11 +98,19 @@ public class ChangeState implements Comparable { } public final boolean isBlank() { - return state.equals("{...}"); + return states[0].equals("{...}"); } public final boolean isCompletelyHidden() { - return state.equals("{hidden}"); + return states[0].equals("{hidden}"); } + public final boolean isFlat() { + return states[0].equals("{-}"); + } + + // public final boolean isUnknown() { + // return states[0].equals("{?}"); + // } + } diff --git a/src/net/sourceforge/plantuml/timingdiagram/Clock.java b/src/net/sourceforge/plantuml/timingdiagram/Clocks.java similarity index 93% rename from src/net/sourceforge/plantuml/timingdiagram/Clock.java rename to src/net/sourceforge/plantuml/timingdiagram/Clocks.java index 3a07f5058..dea055ac7 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/Clock.java +++ b/src/net/sourceforge/plantuml/timingdiagram/Clocks.java @@ -34,8 +34,10 @@ */ package net.sourceforge.plantuml.timingdiagram; -public interface Clock { +public interface Clocks { public TimeTick getNow(); + public TimeTick getClockValue(String clockName, int nb); + } diff --git a/src/net/sourceforge/plantuml/timingdiagram/CommandAtTime.java b/src/net/sourceforge/plantuml/timingdiagram/CommandAtTime.java index 3eaf9000f..e8995f9f9 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/CommandAtTime.java +++ b/src/net/sourceforge/plantuml/timingdiagram/CommandAtTime.java @@ -56,6 +56,9 @@ public class CommandAtTime extends SingleLineCommand2 { @Override final protected CommandExecutionResult executeArg(TimingDiagram diagram, RegexResult arg) { final TimeTick timeTick = TimeTickBuilder.parseTimeTick("TIME", arg, diagram); + if (timeTick == null) { + return CommandExecutionResult.error("What time?"); + } diagram.addTime(timeTick); return CommandExecutionResult.ok(); } diff --git a/src/net/sourceforge/plantuml/timingdiagram/CommandBinary.java b/src/net/sourceforge/plantuml/timingdiagram/CommandBinary.java new file mode 100644 index 000000000..5a9161ad6 --- /dev/null +++ b/src/net/sourceforge/plantuml/timingdiagram/CommandBinary.java @@ -0,0 +1,67 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.timingdiagram; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; + +public class CommandBinary extends SingleLineCommand2 { + + public CommandBinary() { + super(getRegexConcat()); + } + + private static RegexConcat getRegexConcat() { + return new RegexConcat(new RegexLeaf("^"), // + new RegexLeaf("TYPE", // + "(binary)[%s]+"), // + new RegexLeaf("FULL", "[%g]([^%g]+)[%g]"), // + new RegexLeaf("[%s]+as[%s]+"), // + new RegexLeaf("CODE", "([\\p{L}0-9_.@]+)"), // + new RegexLeaf("$")); + } + + @Override + final protected CommandExecutionResult executeArg(TimingDiagram diagram, RegexResult arg) { + final String code = arg.get("CODE", 0); + final String full = arg.get("FULL", 0); + return diagram.createBinary(code, full); + } + +} diff --git a/src/net/sourceforge/plantuml/timingdiagram/CommandChangeState.java b/src/net/sourceforge/plantuml/timingdiagram/CommandChangeState.java new file mode 100644 index 000000000..268531dac --- /dev/null +++ b/src/net/sourceforge/plantuml/timingdiagram/CommandChangeState.java @@ -0,0 +1,90 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + * + */ +package net.sourceforge.plantuml.timingdiagram; + +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.IRegex; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOr; +import net.sourceforge.plantuml.command.regex.RegexResult; +import net.sourceforge.plantuml.graphic.color.ColorParser; +import net.sourceforge.plantuml.graphic.color.ColorType; +import net.sourceforge.plantuml.graphic.color.Colors; + +abstract class CommandChangeState extends SingleLineCommand2 { + + CommandChangeState(RegexConcat pattern) { + super(pattern); + } + + static final String STATE_CODE = "([\\p{L}0-9_][\\p{L}0-9_.]*)"; + + static ColorParser color() { + return ColorParser.simpleColor(ColorType.BACK); + } + + protected CommandExecutionResult addState(TimingDiagram diagram, RegexResult arg, final Player player, + final TimeTick now) { + final String comment = arg.get("COMMENT", 0); + final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); + player.setState(now, comment, colors, getStates(arg)); + return CommandExecutionResult.ok(); + } + + private String[] getStates(RegexResult arg) { + if (arg.get("STATE7", 0) != null) { + final String state1 = arg.get("STATE7", 0); + final String state2 = arg.get("STATE7", 1); + return new String[] { state1, state2 }; + } + return new String[] { arg.getLazzy("STATE", 0) }; + } + + static IRegex getStateOrHidden() { + return new RegexOr(// + new RegexLeaf("STATE1", "[%g]([^%g]+)[%g]"), // + new RegexLeaf("STATE2", STATE_CODE), // + new RegexLeaf("STATE3", "(\\{hidden\\})"), // + new RegexLeaf("STATE4", "(\\{\\.\\.\\.\\})"), // + new RegexLeaf("STATE5", "(\\{-\\})"), // + new RegexLeaf("STATE6", "(\\{\\?\\})"), // + new RegexLeaf("STATE7", "(?:\\{" + STATE_CODE + "," + STATE_CODE + "\\})") // + ); + } + +} diff --git a/src/net/sourceforge/plantuml/timingdiagram/CommandChangeStateByPlayerCode.java b/src/net/sourceforge/plantuml/timingdiagram/CommandChangeStateByPlayerCode.java index 4e5c3e344..316494158 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/CommandChangeStateByPlayerCode.java +++ b/src/net/sourceforge/plantuml/timingdiagram/CommandChangeStateByPlayerCode.java @@ -36,19 +36,11 @@ package net.sourceforge.plantuml.timingdiagram; import net.sourceforge.plantuml.command.CommandExecutionResult; -import net.sourceforge.plantuml.command.SingleLineCommand2; -import net.sourceforge.plantuml.command.regex.IRegex; import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; -import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.graphic.color.ColorParser; -import net.sourceforge.plantuml.graphic.color.ColorType; -import net.sourceforge.plantuml.graphic.color.Colors; -public class CommandChangeStateByPlayerCode extends SingleLineCommand2 { - - private static final String STATE_CODE = "([\\p{L}0-9_][\\p{L}0-9_.]*)"; +public class CommandChangeStateByPlayerCode extends CommandChangeState { public CommandChangeStateByPlayerCode() { super(getRegexConcat()); @@ -66,19 +58,6 @@ public class CommandChangeStateByPlayerCode extends SingleLineCommand2 { +public class CommandChangeStateByTime extends CommandChangeState { public CommandChangeStateByTime() { super(getRegexConcat()); @@ -55,7 +51,7 @@ public class CommandChangeStateByTime extends SingleLineCommand2 new RegexLeaf("[%s]*"), // TimeTickBuilder.expressionAtWithoutArobase("TIME"), // new RegexLeaf("[%s]*is[%s]*"), // - CommandChangeStateByPlayerCode.getStateOrHidden(), // + getStateOrHidden(), // new RegexLeaf("[%s]*"), // color().getRegex(), // new RegexLeaf("[%s]*"), // @@ -63,10 +59,6 @@ public class CommandChangeStateByTime extends SingleLineCommand2 new RegexLeaf("[%s]*$")); } - private static ColorParser color() { - return ColorParser.simpleColor(ColorType.BACK); - } - @Override final protected CommandExecutionResult executeArg(TimingDiagram diagram, RegexResult arg) { final Player player = diagram.getLastPlayer(); @@ -74,11 +66,8 @@ public class CommandChangeStateByTime extends SingleLineCommand2 return CommandExecutionResult.error("Missing @ line before this"); } final TimeTick tick = TimeTickBuilder.parseTimeTick("TIME", arg, diagram); - final String comment = arg.get("COMMENT", 0); - final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet()); - player.setState(tick, arg.getLazzy("STATE", 0), comment, colors); diagram.addTime(tick); - return CommandExecutionResult.ok(); + return addState(diagram, arg, player, tick); } } diff --git a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNewpage.java b/src/net/sourceforge/plantuml/timingdiagram/CommandClock.java similarity index 52% rename from src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNewpage.java rename to src/net/sourceforge/plantuml/timingdiagram/CommandClock.java index 79218abc6..46a06242a 100644 --- a/src/net/sourceforge/plantuml/skin/bluemodern/ComponentBlueModernNewpage.java +++ b/src/net/sourceforge/plantuml/timingdiagram/CommandClock.java @@ -33,42 +33,38 @@ * * */ -package net.sourceforge.plantuml.skin.bluemodern; +package net.sourceforge.plantuml.timingdiagram; -import java.awt.geom.Dimension2D; +import net.sourceforge.plantuml.command.CommandExecutionResult; +import net.sourceforge.plantuml.command.SingleLineCommand2; +import net.sourceforge.plantuml.command.regex.RegexConcat; +import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexResult; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.skin.AbstractComponent; -import net.sourceforge.plantuml.skin.Area; -import net.sourceforge.plantuml.skin.ArrowConfiguration; -import net.sourceforge.plantuml.ugraphic.UChangeColor; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; +public class CommandClock extends SingleLineCommand2 { -public class ComponentBlueModernNewpage extends AbstractComponent { + public CommandClock() { + super(getRegexConcat()); + } - private final HtmlColor foregroundColor; - - public ComponentBlueModernNewpage(HtmlColor foregroundColor) { - this.foregroundColor = foregroundColor; + private static RegexConcat getRegexConcat() { + return new RegexConcat(new RegexLeaf("^"), // + new RegexLeaf("TYPE", // + "(clock)[%s]+"), // + // new RegexLeaf("FULL", "[%g]([^%g]+)[%g]"), // + // new RegexLeaf("[%s]+as[%s]+"), // + new RegexLeaf("CODE", "([\\p{L}0-9_.@]+)"), // + new RegexLeaf("[%s]+with[%s]+period[%s]+"), // + new RegexLeaf("PERIOD", "([0-9]+)"), // + new RegexLeaf("$")); } @Override - protected void drawInternalU(UGraphic ug, Area area) { - final Dimension2D dimensionToUse = area.getDimensionToUse(); - ug = ArrowConfiguration.stroke(ug, 10, 2, 1); - ug.apply(new UChangeColor(foregroundColor)).draw(new ULine(dimensionToUse.getWidth(), 0)); - } - - @Override - public double getPreferredHeight(StringBounder stringBounder) { - return 2; - } - - @Override - public double getPreferredWidth(StringBounder stringBounder) { - return 0; + final protected CommandExecutionResult executeArg(TimingDiagram diagram, RegexResult arg) { + final String code = arg.get("CODE", 0); + // final String full = arg.get("FULL", 0); + final int period = Integer.parseInt(arg.get("PERIOD", 0)); + return diagram.createClock(code, code, period); } } diff --git a/src/net/sourceforge/plantuml/timingdiagram/CommandDefineStateShort.java b/src/net/sourceforge/plantuml/timingdiagram/CommandDefineStateShort.java index 3097b4350..4ace2d78f 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/CommandDefineStateShort.java +++ b/src/net/sourceforge/plantuml/timingdiagram/CommandDefineStateShort.java @@ -35,6 +35,8 @@ */ package net.sourceforge.plantuml.timingdiagram; +import java.util.StringTokenizer; + import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.command.SingleLineCommand2; import net.sourceforge.plantuml.command.regex.RegexConcat; @@ -52,6 +54,7 @@ public class CommandDefineStateShort extends SingleLineCommand2 { new RegexLeaf("PLAYER", "([\\p{L}0-9_.@]+)"), // new RegexLeaf("[%s]+has[%s]+"), // new RegexLeaf("STATE", "([\\p{L}0-9_.@]+)"), // + new RegexLeaf("STATES", "((,([\\p{L}0-9_.@]+))*)"), // new RegexLeaf("$")); } @@ -64,8 +67,14 @@ public class CommandDefineStateShort extends SingleLineCommand2 { } final String stateCode = arg.get("STATE", 0); player.defineState(stateCode, stateCode); + final String states = arg.get("STATES", 0); + if (states != null) { + for (StringTokenizer st = new StringTokenizer(states, ","); st.hasMoreTokens();) { + final String token = st.nextToken(); + player.defineState(token, token); + } + } return CommandExecutionResult.ok(); } - } diff --git a/src/net/sourceforge/plantuml/timingdiagram/CommandLifeLine.java b/src/net/sourceforge/plantuml/timingdiagram/CommandRobustConcise.java similarity index 92% rename from src/net/sourceforge/plantuml/timingdiagram/CommandLifeLine.java rename to src/net/sourceforge/plantuml/timingdiagram/CommandRobustConcise.java index 941aafbba..3d5cb3f6a 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/CommandLifeLine.java +++ b/src/net/sourceforge/plantuml/timingdiagram/CommandRobustConcise.java @@ -41,9 +41,9 @@ import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; import net.sourceforge.plantuml.command.regex.RegexResult; -public class CommandLifeLine extends SingleLineCommand2 { +public class CommandRobustConcise extends SingleLineCommand2 { - public CommandLifeLine() { + public CommandRobustConcise() { super(getRegexConcat()); } @@ -62,8 +62,7 @@ public class CommandLifeLine extends SingleLineCommand2 { final String code = arg.get("CODE", 0); final String full = arg.get("FULL", 0); final TimingStyle type = TimingStyle.valueOf(arg.get("TYPE", 0).toUpperCase()); - diagram.createLifeLine(code, full, type); - return CommandExecutionResult.ok(); + return diagram.createRobustConcise(code, full, type); } } diff --git a/src/net/sourceforge/plantuml/timingdiagram/Histogram.java b/src/net/sourceforge/plantuml/timingdiagram/Histogram.java index 52c816e36..b96019c0d 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/Histogram.java +++ b/src/net/sourceforge/plantuml/timingdiagram/Histogram.java @@ -36,7 +36,6 @@ package net.sourceforge.plantuml.timingdiagram; import java.awt.geom.Dimension2D; import java.awt.geom.Point2D; -import java.awt.geom.Point2D.Double; import java.awt.geom.Rectangle2D; import java.util.ArrayList; import java.util.Arrays; @@ -57,8 +56,10 @@ import net.sourceforge.plantuml.graphic.SymbolContext; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.ugraphic.MinMax; +import net.sourceforge.plantuml.ugraphic.UChangeBackColor; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.URectangle; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -133,23 +134,62 @@ public class Histogram implements TimeDrawing { } public void addChange(ChangeState change) { - final String state = change.getState(); - if (allStates.contains(state) == false) { - allStates.add(state); - } changes.add(change); + final String[] states = change.getStates(); + for (String state : states) { + if (allStates.contains(state) == false) { + allStates.add(state); + } + } } - private Point2D getPoint(int i) { - final ChangeState change = changes.get(i); + private Point2D[] getPoints(int n) { + final ChangeState change = changes.get(n); final double x = ruler.getPosInPixel(change.getWhen()); - return new Point2D.Double(x, yOfState(change.getState())); + final String[] states = change.getStates(); + if (states.length == 2) { + return new Point2D[] { new Point2D.Double(x, yOfState(states[0])), + new Point2D.Double(x, yOfState(states[1])) }; + } + return new Point2D[] { new Point2D.Double(x, yOfState(states[0])) }; + } + + private double getPointx(int n) { + final ChangeState change = changes.get(n); + return ruler.getPosInPixel(change.getWhen()); + } + + private double getPointMinY(int n) { + final String[] states = changes.get(n).getStates(); + if (states.length == 2) { + return Math.min(yOfState(states[0]), yOfState(states[1])); + } + return yOfState(states[0]); + } + + private double getPointMaxY(int n) { + final String[] states = changes.get(n).getStates(); + if (states.length == 2) { + return Math.max(yOfState(states[0]), yOfState(states[1])); + } + return yOfState(states[0]); } private double yOfState(String state) { + // if (state.equals("{?}")) { + // throw new IllegalArgumentException(); + // } return -stepHeight * allStates.indexOf(state); } + // private SortedSet getAllYofStates() { + // final SortedSet result = new TreeSet(); + // for (String state : allStates) { + // result.add(yOfState(state)); + // } + // return result; + // } + private SymbolContext getContext() { return new SymbolContext(HtmlColorUtils.COL_D7E0F2, HtmlColorUtils.COL_038048).withStroke(new UStroke(1.5)); } @@ -161,32 +201,41 @@ public class Histogram implements TimeDrawing { return; } if (initialState != null) { - final Point2D pt = getPoint(0); - drawHLine(ug, getInitialPoint(), getInitialWidth() + pt.getX()); + for (Point2D pt : getPoints(0)) { + drawHLine(ug, getInitialPoint(), getInitialWidth() + pt.getX()); + } } - for (int i = 0; i < changes.size() - 1; i++) { - final Point2D pt = getPoint(i); - final Point2D pt2 = getPoint(i + 1); - final double len = pt2.getX() - pt.getX(); + for (int i = 0; i < changes.size(); i++) { + final double x2 = i < changes.size() - 1 ? getPointx(i + 1) : ruler.getWidth(); + final double len = x2 - getPointx(i); + final Point2D[] points = getPoints(i); + if (points.length == 2) { + drawHBlock(ug.apply(new UChangeBackColor(changes.get(i).getBackColor())), points[0], points[1], len); + } + if (i < changes.size() - 1) { + for (Point2D pt : points) { + drawHLine(ug, pt, len); + } + } + } + for (Point2D pt : getPoints(changes.size() - 1)) { + final double len = ruler.getWidth() - pt.getX(); drawHLine(ug, pt, len); } - final Point2D pt = getPoint(changes.size() - 1); - final double len = ruler.getWidth() - pt.getX(); - drawHLine(ug, pt, len); if (initialState != null) { final Point2D before = getInitialPoint(); - final Point2D current = getPoint(0); + final Point2D current = getPoints(0)[0]; ug.apply(new UTranslate(current).compose(deltaY)).draw(new ULine(0, before.getY() - current.getY())); } for (int i = 1; i < changes.size(); i++) { - final Point2D before = getPoint(i - 1); - final Point2D current = getPoint(i); - ug.apply(new UTranslate(current).compose(deltaY)).draw(new ULine(0, before.getY() - current.getY())); + final double minY = Math.min(getPointMinY(i), getPointMinY(i - 1)); + final double maxY = Math.max(getPointMaxY(i), getPointMaxY(i - 1)); + ug.apply(new UTranslate(getPointx(i), minY).compose(deltaY)).draw(new ULine(0, maxY - minY)); } for (int i = 0; i < changes.size(); i++) { - final Point2D ptLabel = getPoint(i); + final Point2D ptLabel = getPoints(i)[0]; final String comment = changes.get(i).getComment(); if (comment == null) { continue; @@ -210,19 +259,28 @@ public class Histogram implements TimeDrawing { return list.get(list.size() - 1); } - private Double getInitialPoint() { + private Point2D.Double getInitialPoint() { return new Point2D.Double(-getInitialWidth(), yOfState(initialState)); } + private void drawHBlock(UGraphic ug, Point2D pt1, Point2D pt2, double len) { + final double minY = Math.min(pt1.getY(), pt2.getY()); + final double maxY = Math.max(pt1.getY(), pt2.getY()); + final Point2D pt = new Point2D.Double(pt1.getX(), minY); + final UTranslate deltaY = new UTranslate(0, getFullDeltaY()); + final UTranslate pos = new UTranslate(pt).compose(deltaY); + ug = ug.apply(pos); + ug.draw(new URectangle(len, maxY - minY)); + for (double x = 0; x < len; x += 5) { + ug.apply(new UTranslate(x, 0)).draw(new ULine(0, maxY - minY)); + } + + } + private void drawHLine(UGraphic ug, final Point2D pt, final double len) { final UTranslate deltaY = new UTranslate(0, getFullDeltaY()); final UTranslate pos = new UTranslate(pt).compose(deltaY); ug = ug.apply(pos); - // final SymbolContext context = getContext(); - // final double height = -pt.getY(); - // if (height > 0) { - // context.withForeColor(context.getBackColor()).apply(ug).draw(new URectangle(len, height)); - // } ug.draw(new ULine(len, 0)); } diff --git a/src/net/sourceforge/plantuml/timingdiagram/Player.java b/src/net/sourceforge/plantuml/timingdiagram/Player.java index 297130332..a1f008711 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/Player.java +++ b/src/net/sourceforge/plantuml/timingdiagram/Player.java @@ -34,192 +34,31 @@ */ package net.sourceforge.plantuml.timingdiagram; -import java.awt.geom.Dimension2D; -import java.awt.geom.Rectangle2D; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import net.sourceforge.plantuml.Dimension2DDouble; -import net.sourceforge.plantuml.FontParam; -import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.command.Position; import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColorUtils; -import net.sourceforge.plantuml.graphic.InnerStrategy; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; import net.sourceforge.plantuml.graphic.color.Colors; -import net.sourceforge.plantuml.ugraphic.MinMax; -import net.sourceforge.plantuml.ugraphic.UChangeColor; import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.ULine; -import net.sourceforge.plantuml.ugraphic.UStroke; -import net.sourceforge.plantuml.ugraphic.UTranslate; -public class Player implements TextBlock, TimeProjected { +public interface Player extends TimeProjected { - private final String code; - private final Display full; - private final TimingStyle type; - private final ISkinParam skinParam; - private final TimingRuler ruler; - private String initialState; + public void addNote(TimeTick now, Display note, Position position); - private final Set changes = new TreeSet(); - private final List constraints = new ArrayList(); - private final List notes = new ArrayList(); - private final Map statesLabel = new LinkedHashMap(); + public void defineState(String stateCode, String label); - public Player(String code, String full, TimingStyle type, ISkinParam skinParam, TimingRuler ruler) { - this.code = code; - this.full = Display.getWithNewlines(full); - this.type = type; - this.skinParam = skinParam; - this.ruler = ruler; - } + public void setState(TimeTick now, String comment, Colors color, String... states); - private FontConfiguration getFontConfiguration() { - return new FontConfiguration(skinParam, FontParam.TIMING, null); - } + public void createConstraint(TimeTick tick1, TimeTick tick2, String message); - public void drawU(UGraphic ug) { - final TextBlock title = getTitle(); - title.drawU(ug); - final Dimension2D dimTitle = title.calculateDimension(ug.getStringBounder()); - drawLine(ug.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(new UStroke(1.0)), -TimingDiagram.marginX1, - dimTitle.getHeight() + 1, dimTitle.getWidth() + 1, dimTitle.getHeight() + 1, - dimTitle.getWidth() + 1 + 10, 0); - } + public void drawTitle(UGraphic ug); - public void drawContent(UGraphic ug) { - ug = ug.apply(getTranslateForTimeDrawing(ug.getStringBounder())); - getTimeDrawing().drawU(ug); - } + public void drawContent(UGraphic ug); - public void drawWidthHeader(UGraphic ug) { - ug = ug.apply(getTranslateForTimeDrawing(ug.getStringBounder())); - getTimeDrawing().getWidthHeader(ug.getStringBounder()).drawU(ug); - } + public void drawLeftHeader(UGraphic ug); - public double getGetWidthHeader(StringBounder stringBounder) { - return getTimeDrawing().getWidthHeader(stringBounder).calculateDimension(stringBounder).getWidth(); - } + public double getWidthHeader(StringBounder stringBounder); - private void drawLine(UGraphic ug, double... coord) { - for (int i = 0; i < coord.length - 2; i += 2) { - final double x1 = coord[i]; - final double y1 = coord[i + 1]; - final double x2 = coord[i + 2]; - final double y2 = coord[i + 3]; - ug.apply(new UTranslate(x1, y1)).draw(new ULine(x2 - x1, y2 - y1)); - } - - } - - private UTranslate getTranslateForTimeDrawing(StringBounder stringBounder) { - final TextBlock title = getTitle(); - return new UTranslate(0, title.calculateDimension(stringBounder).getHeight() * 2); - } - - private TextBlock getTitle() { - return full.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam); - } - - private TimeDrawing cached; - private Colors initialColors; - - private TimeDrawing getTimeDrawing() { - if (cached == null) { - cached = computeTimeDrawing(); - } - return cached; - } - - private TimeDrawing computeTimeDrawing() { - final TimeDrawing result; - if (type == TimingStyle.CONCISE) { - result = new Ribbon(ruler, skinParam, notes); - } else if (type == TimingStyle.ROBUST) { - result = new Histogram(ruler, skinParam, statesLabel.values()); - } else { - throw new IllegalStateException(); - } - result.setInitialState(initialState, initialColors); - for (ChangeState change : changes) { - result.addChange(change); - } - for (TimeConstraint constraint : constraints) { - result.addConstraint(constraint); - } - return result; - } - - public Dimension2D calculateDimension(StringBounder stringBounder) { - final TextBlock title = getTitle(); - final double width = ruler.getWidth(); - final double zoneHeight = getZoneHeight(stringBounder); - return new Dimension2DDouble(width, title.calculateDimension(stringBounder).getHeight() * 2 + zoneHeight); - } - - public MinMax getMinMax(StringBounder stringBounder) { - throw new UnsupportedOperationException(); - } - - private double getZoneHeight(StringBounder stringBounder) { - return getTimeDrawing().getHeight(stringBounder); - } - - public Rectangle2D getInnerPosition(String member, StringBounder stringBounder, InnerStrategy strategy) { - return null; - } - - public void setState(TimeTick now, String state, String comment, Colors color) { - state = decodeState(state); - if (now == null) { - this.initialState = state; - this.initialColors = color; - } else { - if (state == null) { - throw new IllegalArgumentException(); - } - this.changes.add(new ChangeState(now, state, comment, color)); - } - - } - - private String decodeState(String code) { - final String label = statesLabel.get(code); - if (label == null) { - return code; - } - return label; - } - - public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) { - final IntricatedPoint point = getTimeDrawing().getTimeProjection(stringBounder, tick); - if (point == null) { - return null; - } - final UTranslate translation = getTranslateForTimeDrawing(stringBounder); - return point.translated(translation); - } - - public void createConstraint(TimeTick tick1, TimeTick tick2, String message) { - this.constraints.add(new TimeConstraint(tick1, tick2, message)); - } - - public void addNote(TimeTick now, Display note, Position position) { - this.notes.add(new TimingNote(now, this, note, position, skinParam)); - } - - public void defineState(String stateCode, String label) { - statesLabel.put(stateCode, label); - } + public double getHeight(StringBounder stringBounder); } diff --git a/src/net/sourceforge/plantuml/timingdiagram/PlayerBinary.java b/src/net/sourceforge/plantuml/timingdiagram/PlayerBinary.java new file mode 100644 index 000000000..e0c5051ab --- /dev/null +++ b/src/net/sourceforge/plantuml/timingdiagram/PlayerBinary.java @@ -0,0 +1,129 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + */ +package net.sourceforge.plantuml.timingdiagram; + +import java.util.Map; +import java.util.SortedMap; +import java.util.TreeMap; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.command.Position; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.HtmlColorUtils; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.SymbolContext; +import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.UStroke; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class PlayerBinary implements Player { + + private static final int HEIGHT = 30; + private final TimingRuler ruler; + private final SortedMap values = new TreeMap(); + + public PlayerBinary(ISkinParam skinParam, TimingRuler ruler) { + this.ruler = ruler; + } + + public double getHeight(StringBounder stringBounder) { + return HEIGHT; + } + + private SymbolContext getContext() { + return new SymbolContext(HtmlColorUtils.COL_D7E0F2, HtmlColorUtils.COL_038048).withStroke(new UStroke(1.5)); + } + + public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) { + throw new UnsupportedOperationException(); + } + + public void addNote(TimeTick now, Display note, Position position) { + throw new UnsupportedOperationException(); + } + + public void defineState(String stateCode, String label) { + throw new UnsupportedOperationException(); + } + + public void setState(TimeTick now, String comment, Colors color, String... states) { + final boolean state = getState(states[0]); + this.values.put(now, state); + } + + private boolean getState(String value) { + return "1".equals(value) || "high".equalsIgnoreCase(value); + } + + public void createConstraint(TimeTick tick1, TimeTick tick2, String message) { + throw new UnsupportedOperationException(); + } + + private final double ymargin = 8; + + public void drawTitle(UGraphic ug) { + } + + private double getYpos(boolean state) { + return state ? ymargin : HEIGHT - ymargin; + } + + public void drawContent(UGraphic ug) { + ug = getContext().apply(ug); + double lastx = 0; + boolean lastValue = false; + for (Map.Entry ent : values.entrySet()) { + final double x = ruler.getPosInPixel(ent.getKey()); + ug.apply(new UTranslate(lastx, getYpos(lastValue))).draw(new ULine(x - lastx, 0)); + if (lastValue != ent.getValue()) { + ug.apply(new UTranslate(x, ymargin)).draw(new ULine(0, HEIGHT - 2 * ymargin)); + } + lastx = x; + lastValue = ent.getValue(); + } + ug.apply(new UTranslate(lastx, getYpos(lastValue))).draw(new ULine(ruler.getWidth() - lastx, 0)); + } + + public void drawLeftHeader(UGraphic ug) { + + } + + public double getWidthHeader(StringBounder stringBounder) { + return 0; + } + +} diff --git a/src/net/sourceforge/plantuml/timingdiagram/PlayerClock.java b/src/net/sourceforge/plantuml/timingdiagram/PlayerClock.java new file mode 100644 index 000000000..90859375e --- /dev/null +++ b/src/net/sourceforge/plantuml/timingdiagram/PlayerClock.java @@ -0,0 +1,126 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + */ +package net.sourceforge.plantuml.timingdiagram; + +import java.math.BigDecimal; + +import net.sourceforge.plantuml.ISkinParam; +import net.sourceforge.plantuml.command.Position; +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.graphic.HtmlColorUtils; +import net.sourceforge.plantuml.graphic.StringBounder; +import net.sourceforge.plantuml.graphic.SymbolContext; +import net.sourceforge.plantuml.graphic.color.Colors; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.ULine; +import net.sourceforge.plantuml.ugraphic.UStroke; +import net.sourceforge.plantuml.ugraphic.UTranslate; + +public class PlayerClock implements Player { + + private final TimingRuler ruler; + private final int period; + + public PlayerClock(ISkinParam skinParam, TimingRuler ruler, int period) { + this.ruler = ruler; + this.period = period; + } + + public double getHeight(StringBounder stringBounder) { + return 30; + } + + private SymbolContext getContext() { + return new SymbolContext(HtmlColorUtils.COL_D7E0F2, HtmlColorUtils.COL_038048).withStroke(new UStroke(1.5)); + } + + public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) { + throw new UnsupportedOperationException(); + } + + public void addNote(TimeTick now, Display note, Position position) { + throw new UnsupportedOperationException(); + } + + public void defineState(String stateCode, String label) { + throw new UnsupportedOperationException(); + } + + public void setState(TimeTick now, String comment, Colors color, String... states) { + throw new UnsupportedOperationException(); + } + + public void createConstraint(TimeTick tick1, TimeTick tick2, String message) { + throw new UnsupportedOperationException(); + } + + private final double ymargin = 8; + + public void drawTitle(UGraphic ug) { + } + + public void drawContent(UGraphic ug) { + ug = getContext().apply(ug); + final ULine vline = new ULine(0, getHeight(ug.getStringBounder()) - 2 * ymargin); + int i = 0; + double lastx = -Double.MAX_VALUE; + while (i < 1000) { + final double x = ruler.getPosInPixel(new BigDecimal(i * period)) / 2; + if (x > ruler.getWidth()) { + return; + } + i++; + if (x > lastx) { + ug.apply(new UTranslate(lastx, ymargin)).draw(vline); + ug.apply(new UTranslate(lastx, i % 2 == 0 ? ymargin : ymargin + vline.getDY())).draw( + new ULine(x - lastx, 0)); + } + lastx = x; + } + } + + public void drawLeftHeader(UGraphic ug) { + + } + + public double getWidthHeader(StringBounder stringBounder) { + return 0; + } + + public final int getPeriod() { + return period; + } + +} diff --git a/src/net/sourceforge/plantuml/skin/ProtectedSkin.java b/src/net/sourceforge/plantuml/timingdiagram/PlayerConcise.java similarity index 65% rename from src/net/sourceforge/plantuml/skin/ProtectedSkin.java rename to src/net/sourceforge/plantuml/timingdiagram/PlayerConcise.java index a69b9232b..5e8d2e35c 100644 --- a/src/net/sourceforge/plantuml/skin/ProtectedSkin.java +++ b/src/net/sourceforge/plantuml/timingdiagram/PlayerConcise.java @@ -30,37 +30,22 @@ * * * Original Author: Arnaud Roques - * * */ -package net.sourceforge.plantuml.skin; +package net.sourceforge.plantuml.timingdiagram; import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.cucadiagram.Display; -public class ProtectedSkin implements Skin { +public class PlayerConcise extends AbstractPlayer { - final private Skin skinToProtect; - - public ProtectedSkin(Skin skinToProtect) { - this.skinToProtect = skinToProtect; - - } - - public Component createComponent(ComponentType type, ArrowConfiguration config, ISkinParam param, Display stringsToDisplay) { - Component result = null; - try { - result = skinToProtect.createComponent(type, config, param, stringsToDisplay); - } catch (Throwable e) { - e.printStackTrace(); - } - if (result == null) { - return new GrayComponent(type); - } + protected TimeDrawing buildDrawing() { + final TimeDrawing result; + result = new Ribbon(ruler, skinParam, notes); return result; } - public Object getProtocolVersion() { - return skinToProtect.getProtocolVersion(); + public PlayerConcise(String full, ISkinParam skinParam, TimingRuler ruler) { + super(full, skinParam, ruler); } + } diff --git a/src/net/sourceforge/plantuml/timingdiagram/PlayerRobust.java b/src/net/sourceforge/plantuml/timingdiagram/PlayerRobust.java new file mode 100644 index 000000000..fdc44b45a --- /dev/null +++ b/src/net/sourceforge/plantuml/timingdiagram/PlayerRobust.java @@ -0,0 +1,51 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2020, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * If you like this project or if you find it useful, you can support us at: + * + * http://plantuml.com/patreon (only 1$ per month!) + * http://plantuml.com/paypal + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * + * Original Author: Arnaud Roques + * + */ +package net.sourceforge.plantuml.timingdiagram; + +import net.sourceforge.plantuml.ISkinParam; + +public class PlayerRobust extends AbstractPlayer { + + protected TimeDrawing buildDrawing() { + final TimeDrawing result; + result = new Histogram(ruler, skinParam, statesLabel.values()); + return result; + } + + public PlayerRobust(String full, ISkinParam skinParam, TimingRuler ruler) { + super(full, skinParam, ruler); + } + +} diff --git a/src/net/sourceforge/plantuml/timingdiagram/Ribbon.java b/src/net/sourceforge/plantuml/timingdiagram/Ribbon.java index 338e2eabf..209c80814 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/Ribbon.java +++ b/src/net/sourceforge/plantuml/timingdiagram/Ribbon.java @@ -53,6 +53,7 @@ import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.Colors; import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.UTranslate; public class Ribbon implements TimeDrawing { @@ -127,14 +128,18 @@ public class Ribbon implements TimeDrawing { final double a = getPosInPixel(changes.get(i)); final double b = getPosInPixel(changes.get(i + 1)); assert b > a; - if (changes.get(i).isCompletelyHidden() == false) { + if (changes.get(i).isFlat()) { + drawFlat(ugDown.apply(new UTranslate(a, -halfDelta)), b - a, changes.get(i)); + } else if (changes.get(i).isCompletelyHidden() == false) { drawHexa(ugDown.apply(new UTranslate(a, -halfDelta)), b - a, changes.get(i)); } } if (changes.size() >= 1) { final ChangeState last = changes.get(changes.size() - 1); final double a = getPosInPixel(last); - if (last.isCompletelyHidden() == false) { + if (last.isFlat()) { + drawFlat(ugDown.apply(new UTranslate(a, -halfDelta)), ruler.getWidth() - a, last); + } else if (last.isCompletelyHidden() == false) { drawPentaB(ugDown.apply(new UTranslate(a, -halfDelta)), ruler.getWidth() - a, last); } } @@ -148,7 +153,7 @@ public class Ribbon implements TimeDrawing { for (int i = 0; i < changes.size(); i++) { final ChangeState change = changes.get(i); final double x = ruler.getPosInPixel(change.getWhen()); - if (change.isBlank() == false && change.isCompletelyHidden() == false) { + if (change.isBlank() == false && change.isCompletelyHidden() == false && change.isFlat() == false) { final TextBlock state = createTextBlock(change.getState()); final Dimension2D dim = state.calculateDimension(stringBounder); final double xtext; @@ -196,6 +201,11 @@ public class Ribbon implements TimeDrawing { shape.drawU(ug); } + private void drawFlat(UGraphic ug, double len, ChangeState change) { + final ULine line = new ULine(len, 0); + change.getContext().apply(ug).apply(new UTranslate(0, getRibbonHeight() / 2)).draw(line); + } + private double getRibbonHeight() { return 2 * delta; } diff --git a/src/net/sourceforge/plantuml/timingdiagram/RibbonNew.java b/src/net/sourceforge/plantuml/timingdiagram/RibbonNew.java deleted file mode 100644 index 5a76fd587..000000000 --- a/src/net/sourceforge/plantuml/timingdiagram/RibbonNew.java +++ /dev/null @@ -1,244 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - */ -package net.sourceforge.plantuml.timingdiagram; - -import java.awt.geom.Dimension2D; -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.List; - -import net.sourceforge.plantuml.FontParam; -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.SymbolContext; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; -import net.sourceforge.plantuml.graphic.color.ColorType; -import net.sourceforge.plantuml.graphic.color.Colors; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class RibbonNew implements TimeDrawing { - - private final List changes = new ArrayList(); - private final List constraints = new ArrayList(); - - private final double delta = 12; - private final ISkinParam skinParam; - private final TimingRuler ruler; - private String initialState; - private Colors initialColors; - private final List notes; - - public RibbonNew(TimingRuler ruler, ISkinParam skinParam, List notes) { - this.ruler = ruler; - this.skinParam = skinParam; - this.notes = notes; - } - - public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) { - final double x = ruler.getPosInPixel(tick); - final double y = delta * 0.5 + getHeightForConstraints(); - for (ChangeState change : changes) { - if (change.getWhen().compareTo(tick) == 0) { - return new IntricatedPoint(new Point2D.Double(x, y), new Point2D.Double(x, y)); - } - } - return new IntricatedPoint(new Point2D.Double(x, y - delta), new Point2D.Double(x, y + delta)); - } - - public void addChange(ChangeState change) { - this.changes.add(change); - } - - private double getPosInPixel(ChangeState change) { - return ruler.getPosInPixel(change.getWhen()); - } - - private FontConfiguration getFontConfiguration() { - return new FontConfiguration(skinParam, FontParam.TIMING, null); - } - - private TextBlock createTextBlock(String value) { - final Display display = Display.getWithNewlines(value); - return display.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam); - } - - public void drawU(UGraphic ug) { - - final StringBounder stringBounder = ug.getStringBounder(); - - final double ribbonHeight = getRibbonHeight(stringBounder); - UGraphic ugDown = ug.apply(new UTranslate(0, getHeightForConstraints())); - - final TextBlock inital; - if (initialState == null) { - inital = null; - } else { - inital = createTextBlock(initialState); - final double a = getPosInPixel(changes.get(0)); - drawPentaA(ribbonHeight, ugDown.apply(new UTranslate(-getInitialWidth(stringBounder), -delta / 2)), - getInitialWidth(stringBounder) + a, changes.get(0)); - } - - for (int i = 0; i < changes.size() - 1; i++) { - final double a = getPosInPixel(changes.get(i)); - final double b = getPosInPixel(changes.get(i + 1)); - assert b > a; - if (changes.get(i).isCompletelyHidden() == false) { - drawHexa(ribbonHeight, ugDown.apply(new UTranslate(a, -delta / 2)), b - a, changes.get(i)); - } - } - if (changes.size() >= 1) { - final ChangeState last = changes.get(changes.size() - 1); - final double a = getPosInPixel(last); - if (last.isCompletelyHidden() == false) { - drawPentaB(ribbonHeight, ugDown.apply(new UTranslate(a, -delta / 2)), ruler.getWidth() - a, last); - } - } - - ugDown = ugDown.apply(new UTranslate(0, delta / 2)); - - if (inital != null) { - final Dimension2D dimInital = inital.calculateDimension(stringBounder); - inital.drawU(ugDown.apply(new UTranslate(-getDelta() - dimInital.getWidth(), -dimInital.getHeight() / 2))); - } - for (int i = 0; i < changes.size(); i++) { - final ChangeState change = changes.get(i); - final double x = ruler.getPosInPixel(change.getWhen()); - if (change.isBlank() == false && change.isCompletelyHidden() == false) { - final TextBlock state = createTextBlock(change.getState()); - final Dimension2D dim = state.calculateDimension(stringBounder); - final double xtext; - if (i == changes.size() - 1) { - xtext = x + getDelta(); - } else { - final double x2 = ruler.getPosInPixel(changes.get(i + 1).getWhen()); - xtext = (x + x2) / 2 - dim.getWidth() / 2; - } - state.drawU(ugDown.apply(new UTranslate(xtext, -dim.getHeight() / 2))); - } - final String commentString = change.getComment(); - if (commentString != null) { - final TextBlock comment = createTextBlock(commentString); - final Dimension2D dimComment = comment.calculateDimension(stringBounder); - comment.drawU(ugDown.apply(new UTranslate(x + getDelta(), -delta - dimComment.getHeight()))); - } - } - - for (TimeConstraint constraint : constraints) { - constraint.drawU(ug.apply(new UTranslate(0, ribbonHeight / 2)), ruler, skinParam); - } - - for (TimingNote note : notes) { - final double x = ruler.getPosInPixel(note.getWhen()); - note.drawU(ug.apply(new UTranslate(x, ribbonHeight))); - } - - } - - private double getInitialWidth(final StringBounder stringBounder) { - return createTextBlock(initialState).calculateDimension(stringBounder).getWidth() + 2 * delta; - } - - private void drawHexa(double ribbonHeight, UGraphic ug, double len, ChangeState change) { - final HexaShape shape = HexaShape.create(len, ribbonHeight, change.getContext()); - shape.drawU(ug); - } - - private void drawPentaB(double ribbonHeight, UGraphic ug, double len, ChangeState change) { - final PentaBShape shape = PentaBShape.create(len, ribbonHeight, change.getContext()); - shape.drawU(ug); - } - - private void drawPentaA(double ribbonHeight, UGraphic ug, double len, ChangeState change) { - SymbolContext context = change.getContext(); - final HtmlColor back = initialColors.getColor(ColorType.BACK); - if (back != null) { - context = context.withBackColor(back); - } - final PentaAShape shape = PentaAShape.create(len, ribbonHeight, context); - shape.drawU(ug); - } - - private double getHeightForConstraints() { - if (constraints.size() == 0) { - return 0; - } - return 30; - } - - public double getHeight(StringBounder stringBounder) { - return getHeightForConstraints() + getRibbonHeight(stringBounder) + getHeightForNotes(stringBounder); - } - - private double getRibbonHeight(StringBounder stringBounder) { - double height = 24; - return height; - } - - private double getHeightForNotes(StringBounder stringBounder) { - double height = 0; - for (TimingNote note : notes) { - height = Math.max(height, note.getHeight(stringBounder)); - } - return height; - } - - public double getDelta() { - return delta; - } - - public TextBlock getWidthHeader(StringBounder stringBounder) { - if (initialState != null) { - return TextBlockUtils.empty(getInitialWidth(stringBounder), getRibbonHeight(stringBounder)); - } - return TextBlockUtils.empty(0, 0); - } - - public void setInitialState(String initialState, Colors initialColors) { - this.initialState = initialState; - this.initialColors = initialColors; - } - - public void addConstraint(TimeConstraint constraint) { - this.constraints.add(constraint); - } - -} diff --git a/src/net/sourceforge/plantuml/timingdiagram/RibbonOld.java b/src/net/sourceforge/plantuml/timingdiagram/RibbonOld.java deleted file mode 100644 index fab2df528..000000000 --- a/src/net/sourceforge/plantuml/timingdiagram/RibbonOld.java +++ /dev/null @@ -1,226 +0,0 @@ -/* ======================================================================== - * PlantUML : a free UML diagram generator - * ======================================================================== - * - * (C) Copyright 2009-2020, Arnaud Roques - * - * Project Info: http://plantuml.com - * - * If you like this project or if you find it useful, you can support us at: - * - * http://plantuml.com/patreon (only 1$ per month!) - * http://plantuml.com/paypal - * - * This file is part of PlantUML. - * - * PlantUML is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PlantUML distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public - * License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - * USA. - * - * - * Original Author: Arnaud Roques - * - */ -package net.sourceforge.plantuml.timingdiagram; - -import java.awt.geom.Dimension2D; -import java.awt.geom.Point2D; -import java.util.ArrayList; -import java.util.List; - -import net.sourceforge.plantuml.FontParam; -import net.sourceforge.plantuml.ISkinParam; -import net.sourceforge.plantuml.cucadiagram.Display; -import net.sourceforge.plantuml.graphic.FontConfiguration; -import net.sourceforge.plantuml.graphic.HorizontalAlignment; -import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.StringBounder; -import net.sourceforge.plantuml.graphic.SymbolContext; -import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.graphic.TextBlockUtils; -import net.sourceforge.plantuml.graphic.color.ColorType; -import net.sourceforge.plantuml.graphic.color.Colors; -import net.sourceforge.plantuml.ugraphic.UGraphic; -import net.sourceforge.plantuml.ugraphic.UTranslate; - -public class RibbonOld implements TimeDrawing { - - private final List changes = new ArrayList(); - private final List constraints = new ArrayList(); - - private final double delta = 12; - private final ISkinParam skinParam; - private final TimingRuler ruler; - private String initialState; - private Colors initialColors; - - public RibbonOld(TimingRuler ruler, ISkinParam skinParam) { - this.ruler = ruler; - this.skinParam = skinParam; - } - - public IntricatedPoint getTimeProjection(StringBounder stringBounder, TimeTick tick) { - final double x = ruler.getPosInPixel(tick); - final double y = delta * 0.5 + getHeightForConstraints(); - for (ChangeState change : changes) { - if (change.getWhen().compareTo(tick) == 0) { - return new IntricatedPoint(new Point2D.Double(x, y), new Point2D.Double(x, y)); - } - } - return new IntricatedPoint(new Point2D.Double(x, y - delta), new Point2D.Double(x, y + delta)); - } - - public void addChange(ChangeState change) { - this.changes.add(change); - } - - private double getPosInPixel(ChangeState change) { - return ruler.getPosInPixel(change.getWhen()); - } - - private FontConfiguration getFontConfiguration() { - return new FontConfiguration(skinParam, FontParam.TIMING, null); - } - - private TextBlock getTextBlock(String value) { - final Display display = Display.getWithNewlines(value); - return display.create(getFontConfiguration(), HorizontalAlignment.LEFT, skinParam); - } - - public void drawU(UGraphic ug) { - - UGraphic ugDown = ug.apply(new UTranslate(0, getHeightForConstraints())); - - final TextBlock inital; - final StringBounder stringBounder = ugDown.getStringBounder(); - if (initialState == null) { - inital = null; - } else { - inital = getTextBlock(initialState); - final double a = getPosInPixel(changes.get(0)); - drawPentaA(ugDown.apply(new UTranslate(-getInitialWidth(stringBounder), -delta / 2)), - getInitialWidth(stringBounder) + a, changes.get(0)); - } - - for (int i = 0; i < changes.size() - 1; i++) { - final double a = getPosInPixel(changes.get(i)); - final double b = getPosInPixel(changes.get(i + 1)); - assert b > a; - if (changes.get(i).isCompletelyHidden() == false) { - drawHexa(ugDown.apply(new UTranslate(a, -delta / 2)), b - a, changes.get(i)); - } - } - if (changes.size() >= 1) { - final ChangeState last = changes.get(changes.size() - 1); - final double a = getPosInPixel(last); - if (last.isCompletelyHidden() == false) { - drawPentaB(ugDown.apply(new UTranslate(a, -delta / 2)), ruler.getWidth() - a, last); - } - } - - ugDown = ugDown.apply(new UTranslate(0, delta / 2)); - - if (inital != null) { - final Dimension2D dimInital = inital.calculateDimension(stringBounder); - inital.drawU(ugDown.apply(new UTranslate(-getDelta() - dimInital.getWidth(), -dimInital.getHeight() / 2))); - } - for (int i = 0; i < changes.size(); i++) { - final ChangeState change = changes.get(i); - final double x = ruler.getPosInPixel(change.getWhen()); - if (change.isBlank() == false && change.isCompletelyHidden() == false) { - final TextBlock state = getTextBlock(change.getState()); - final Dimension2D dim = state.calculateDimension(stringBounder); - final double xtext; - if (i == changes.size() - 1) { - xtext = x + getDelta(); - } else { - final double x2 = ruler.getPosInPixel(changes.get(i + 1).getWhen()); - xtext = (x + x2) / 2 - dim.getWidth() / 2; - } - state.drawU(ugDown.apply(new UTranslate(xtext, -dim.getHeight() / 2))); - } - final String commentString = change.getComment(); - if (commentString != null) { - final TextBlock comment = getTextBlock(commentString); - final Dimension2D dimComment = comment.calculateDimension(stringBounder); - comment.drawU(ugDown.apply(new UTranslate(x + getDelta(), -delta - dimComment.getHeight()))); - } - } - - for (TimeConstraint constraint : constraints) { - constraint.drawU(ug.apply(new UTranslate(0, 15)), ruler, skinParam); - } - - } - - private double getInitialWidth(final StringBounder stringBounder) { - return getTextBlock(initialState).calculateDimension(stringBounder).getWidth() + getRibonHeight(); - } - - private void drawHexa(UGraphic ug, double len, ChangeState change) { - final HexaShape shape = HexaShape.create(len, getRibonHeight(), change.getContext()); - shape.drawU(ug); - } - - private double getRibonHeight() { - return 2 * delta; - } - - private void drawPentaB(UGraphic ug, double len, ChangeState change) { - final PentaBShape shape = PentaBShape.create(len, getRibonHeight(), change.getContext()); - shape.drawU(ug); - } - - private void drawPentaA(UGraphic ug, double len, ChangeState change) { - SymbolContext context = change.getContext(); - final HtmlColor back = initialColors.getColor(ColorType.BACK); - if (back != null) { - context = context.withBackColor(back); - } - final PentaAShape shape = PentaAShape.create(len, getRibonHeight(), context); - shape.drawU(ug); - } - - private double getHeightForConstraints() { - if (constraints.size() == 0) { - return 0; - } - return 30; - } - - public double getHeight(StringBounder stringBounder) { - return 3 * delta + getHeightForConstraints(); - } - - public double getDelta() { - return delta; - } - - public TextBlock getWidthHeader(StringBounder stringBounder) { - if (initialState != null) { - return TextBlockUtils.empty(getInitialWidth(stringBounder), getRibonHeight()); - } - return TextBlockUtils.empty(0, 0); - } - - public void setInitialState(String initialState, Colors initialColors) { - this.initialState = initialState; - this.initialColors = initialColors; - } - - public void addConstraint(TimeConstraint constraint) { - this.constraints.add(constraint); - } - -} diff --git a/src/net/sourceforge/plantuml/timingdiagram/TimeTickBuilder.java b/src/net/sourceforge/plantuml/timingdiagram/TimeTickBuilder.java index b51febc7a..d9cbe0d23 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/TimeTickBuilder.java +++ b/src/net/sourceforge/plantuml/timingdiagram/TimeTickBuilder.java @@ -36,37 +36,46 @@ package net.sourceforge.plantuml.timingdiagram; import java.math.BigDecimal; +import net.sourceforge.plantuml.command.regex.IRegex; +import net.sourceforge.plantuml.command.regex.RegexConcat; import net.sourceforge.plantuml.command.regex.RegexLeaf; +import net.sourceforge.plantuml.command.regex.RegexOptional; +import net.sourceforge.plantuml.command.regex.RegexOr; import net.sourceforge.plantuml.command.regex.RegexResult; public class TimeTickBuilder { - private static final String WITHOUT_AROBASE = "(\\+?)(-?\\d+\\.?\\d*)"; - private static final String WITH_AROBASE = "@" + WITHOUT_AROBASE; - - public static RegexLeaf expressionAtWithoutArobase(String name) { - return new RegexLeaf(name, WITHOUT_AROBASE); + public static IRegex expressionAtWithoutArobase(String name) { + return new RegexOr( // + new RegexLeaf(name + "DIGIT", "(\\+?)(-?\\d+\\.?\\d*)"), // + new RegexLeaf(name + "CLOCK", "([\\p{L}0-9_.@]+)\\*(\\d+)")); } - public static RegexLeaf expressionAtWithArobase(String name) { - return new RegexLeaf(name, WITH_AROBASE); + public static IRegex expressionAtWithArobase(String name) { + return new RegexConcat( // + new RegexLeaf("@"), // + expressionAtWithoutArobase(name)); } - public static RegexLeaf optionalExpressionAtWithArobase(String name) { - return new RegexLeaf(name, "(?:" + WITH_AROBASE + ")?"); + public static IRegex optionalExpressionAtWithArobase(String name) { + return new RegexOptional(expressionAtWithArobase(name)); } - public static TimeTick parseTimeTick(String name, RegexResult arg, Clock clock) { - final String number = arg.get(name, 1); + public static TimeTick parseTimeTick(String name, RegexResult arg, Clocks clock) { + final String clockName = arg.get(name + "CLOCK", 0); + if (clockName != null) { + final int number = Integer.parseInt(arg.get(name + "CLOCK", 1)); + return clock.getClockValue(clockName, number); + } + final String number = arg.get(name + "DIGIT", 1); if (number == null) { return clock.getNow(); } - final boolean isRelative = "+".equals(arg.get(name, 0)); + final boolean isRelative = "+".equals(arg.get(name + "DIGIT", 0)); BigDecimal value = new BigDecimal(number); if (isRelative) { value = clock.getNow().getTime().add(value); } return new TimeTick(value); } - } diff --git a/src/net/sourceforge/plantuml/timingdiagram/TimingDiagram.java b/src/net/sourceforge/plantuml/timingdiagram/TimingDiagram.java index 0d4488fdd..094e53a06 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/TimingDiagram.java +++ b/src/net/sourceforge/plantuml/timingdiagram/TimingDiagram.java @@ -38,27 +38,27 @@ import java.awt.geom.Dimension2D; import java.awt.geom.Rectangle2D; import java.io.IOException; import java.io.OutputStream; +import java.math.BigDecimal; import java.util.ArrayList; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import net.sourceforge.plantuml.AnnotatedWorker; -import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.UmlDiagram; import net.sourceforge.plantuml.UmlDiagramType; +import net.sourceforge.plantuml.command.CommandExecutionResult; import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.graphic.HtmlColor; -import net.sourceforge.plantuml.graphic.HtmlColorSet; import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.InnerStrategy; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; -import net.sourceforge.plantuml.skin.rose.Rose; import net.sourceforge.plantuml.svek.TextBlockBackcolored; import net.sourceforge.plantuml.ugraphic.ImageBuilder; import net.sourceforge.plantuml.ugraphic.MinMax; @@ -68,9 +68,10 @@ import net.sourceforge.plantuml.ugraphic.ULine; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; -public class TimingDiagram extends UmlDiagram implements Clock { +public class TimingDiagram extends UmlDiagram implements Clocks { private final Map players = new LinkedHashMap(); + private final Map clocks = new HashMap(); private final List messages = new ArrayList(); private final TimingRuler ruler = new TimingRuler(getSkinParam()); private TimeTick now; @@ -147,11 +148,12 @@ public class TimingDiagram extends UmlDiagram implements Clock { ug = ug.apply(new UTranslate(marginX1, 0)); + ruler.draw0(ug.apply(new UTranslate(withBeforeRuler, 0)), getUTranslateForPlayer(null, stringBounder).getDy()); for (Player player : players.values()) { final UGraphic playerUg = ug.apply(getUTranslateForPlayer(player, stringBounder)); - player.drawU(playerUg); + player.drawTitle(playerUg); player.drawContent(playerUg.apply(new UTranslate(withBeforeRuler, 0))); - player.drawWidthHeader(playerUg); + player.drawLeftHeader(playerUg); playerUg.apply(new UChangeColor(HtmlColorUtils.BLACK)).apply(borderStroke) .apply(new UTranslate(-marginX1, 0)).draw(new ULine(totalWith, 0)); } @@ -165,7 +167,7 @@ public class TimingDiagram extends UmlDiagram implements Clock { private double getWithBeforeRuler(StringBounder stringBounder) { double width = 0; for (Player player : players.values()) { - width = Math.max(width, player.getGetWidthHeader(stringBounder)); + width = Math.max(width, player.getWidthHeader(stringBounder)); } return width; @@ -194,11 +196,10 @@ public class TimingDiagram extends UmlDiagram implements Clock { public UTranslate getUTranslateForPlayer(Player candidat, StringBounder stringBounder) { double y = 0; for (Player player : players.values()) { - final Dimension2D dim = player.calculateDimension(stringBounder); if (candidat == player) { return new UTranslate(0, y); } - y += dim.getHeight(); + y += player.getHeight(stringBounder); } if (candidat == null) { return new UTranslate(0, y); @@ -206,10 +207,26 @@ public class TimingDiagram extends UmlDiagram implements Clock { throw new IllegalArgumentException(); } - public void createLifeLine(String code, String full, TimingStyle type) { - final Player player = new Player(code, full, type, getSkinParam(), ruler); + public CommandExecutionResult createRobustConcise(String code, String full, TimingStyle type) { + final Player player = type.createPlayer(full, getSkinParam(), ruler); players.put(code, player); lastPlayer = player; + return CommandExecutionResult.ok(); + } + + public CommandExecutionResult createClock(String code, String full, int period) { + final PlayerClock player = new PlayerClock(getSkinParam(), ruler, period); + players.put(code, player); + clocks.put(code, player); + final TimeTick tick = new TimeTick(new BigDecimal(period)); + ruler.addTime(tick); + return CommandExecutionResult.ok(); + } + + public CommandExecutionResult createBinary(String code, String full) { + final Player player = new PlayerBinary(getSkinParam(), ruler); + players.put(code, player); + return CommandExecutionResult.ok(); } public TimeMessage createTimeMessage(Player player1, TimeTick time1, Player player2, TimeTick time2, String label) { @@ -233,12 +250,17 @@ public class TimingDiagram extends UmlDiagram implements Clock { } public TimeTick getNow() { - // if (now == null) { - // throw new IllegalStateException(); - // } return now; } + public TimeTick getClockValue(String clockName, int nb) { + final PlayerClock clock = clocks.get(clockName); + if (clock == null) { + return null; + } + return new TimeTick(new BigDecimal(nb * clock.getPeriod())); + } + public void setLastPlayer(Player player) { this.lastPlayer = player; } diff --git a/src/net/sourceforge/plantuml/timingdiagram/TimingDiagramFactory.java b/src/net/sourceforge/plantuml/timingdiagram/TimingDiagramFactory.java index 05b7fc588..0f36e89bd 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/TimingDiagramFactory.java +++ b/src/net/sourceforge/plantuml/timingdiagram/TimingDiagramFactory.java @@ -56,7 +56,9 @@ public class TimingDiagramFactory extends UmlDiagramFactory { addCommonCommands(cmds); cmds.add(new CommandFootboxIgnored()); - cmds.add(new CommandLifeLine()); + cmds.add(new CommandRobustConcise()); + cmds.add(new CommandClock()); + cmds.add(new CommandBinary()); cmds.add(new CommandDefineStateShort()); cmds.add(new CommandDefineStateLong()); cmds.add(new CommandChangeStateByPlayerCode()); diff --git a/src/net/sourceforge/plantuml/timingdiagram/TimingRuler.java b/src/net/sourceforge/plantuml/timingdiagram/TimingRuler.java index 4da793bc3..ffa3a5da5 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/TimingRuler.java +++ b/src/net/sourceforge/plantuml/timingdiagram/TimingRuler.java @@ -46,6 +46,7 @@ import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.HorizontalAlignment; +import net.sourceforge.plantuml.graphic.HtmlColorSetSimple; import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.TextBlock; @@ -140,6 +141,15 @@ public class TimingRuler { } } + public void draw0(UGraphic ug, double height) { + ug = ug.apply(new UStroke(3, 5, 0.5)).apply(new UChangeColor(new HtmlColorSetSimple().getColorIfValid("#AAA"))); + final ULine line = new ULine(0, height); + final int nb = getNbTick(); + for (int i = 0; i <= nb; i++) { + ug.apply(new UTranslate(tickIntervalInPixels * i, 0)).draw(line); + } + } + public double getHeight(StringBounder stringBounder) { return getTimeTextBlock(0).calculateDimension(stringBounder).getHeight(); } diff --git a/src/net/sourceforge/plantuml/timingdiagram/TimingStyle.java b/src/net/sourceforge/plantuml/timingdiagram/TimingStyle.java index 0e9643e1b..b3e606263 100644 --- a/src/net/sourceforge/plantuml/timingdiagram/TimingStyle.java +++ b/src/net/sourceforge/plantuml/timingdiagram/TimingStyle.java @@ -34,8 +34,20 @@ */ package net.sourceforge.plantuml.timingdiagram; +import net.sourceforge.plantuml.ISkinParam; + public enum TimingStyle { - ROBUST, CONCISE + ROBUST, CONCISE; + + public Player createPlayer(String full, ISkinParam skinParam, TimingRuler ruler) { + if (this == ROBUST) { + return new PlayerRobust(full, skinParam, ruler); + } + if (this == CONCISE) { + return new PlayerConcise(full, skinParam, ruler); + } + throw new UnsupportedOperationException(); + } } diff --git a/src/net/sourceforge/plantuml/ugraphic/ULine.java b/src/net/sourceforge/plantuml/ugraphic/ULine.java index 7960deb0d..7c50ca71b 100644 --- a/src/net/sourceforge/plantuml/ugraphic/ULine.java +++ b/src/net/sourceforge/plantuml/ugraphic/ULine.java @@ -35,6 +35,8 @@ */ package net.sourceforge.plantuml.ugraphic; +import java.awt.geom.Point2D; + public class ULine extends AbstractShadowable implements Scalable, UShapeSized { private final double dx; @@ -49,6 +51,10 @@ public class ULine extends AbstractShadowable implements Scalable, UShapeSized { return result; } + public ULine(Point2D p1, Point2D p2) { + this(p2.getX() - p1.getX(), p2.getY() - p1.getY()); + } + public ULine(double dx, double dy) { this.dx = dx; this.dy = dy; diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/HandJiggle.java b/src/net/sourceforge/plantuml/ugraphic/hand/HandJiggle.java index 6f76e6e4c..0d4986ed9 100644 --- a/src/net/sourceforge/plantuml/ugraphic/hand/HandJiggle.java +++ b/src/net/sourceforge/plantuml/ugraphic/hand/HandJiggle.java @@ -156,4 +156,10 @@ public class HandJiggle { return path; } + public void appendTo(UPath result) { + for (Point2D p : points) { + result.lineTo(p); + } + } + } diff --git a/src/net/sourceforge/plantuml/ugraphic/hand/UPathHand.java b/src/net/sourceforge/plantuml/ugraphic/hand/UPathHand.java index 40443ec97..4ff001e2f 100644 --- a/src/net/sourceforge/plantuml/ugraphic/hand/UPathHand.java +++ b/src/net/sourceforge/plantuml/ugraphic/hand/UPathHand.java @@ -34,6 +34,7 @@ */ package net.sourceforge.plantuml.ugraphic.hand; +import java.awt.geom.CubicCurve2D; import java.awt.geom.Point2D; import java.util.Random; @@ -48,7 +49,7 @@ public class UPathHand { public UPathHand(UPath source, Random rnd) { - final UPath jigglePath = new UPath(); + final UPath result = new UPath(); Point2D last = new Point2D.Double(); @@ -57,9 +58,18 @@ public class UPathHand { if (type == USegmentType.SEG_MOVETO) { final double x = segment.getCoord()[0]; final double y = segment.getCoord()[1]; - jigglePath.moveTo(x, y); + result.moveTo(x, y); last = new Point2D.Double(x, y); + } else if (type == USegmentType.SEG_CUBICTO) { + final double x2 = segment.getCoord()[4]; + final double y2 = segment.getCoord()[5]; + final HandJiggle jiggle = new HandJiggle(last, 2.0, rnd); + final CubicCurve2D tmp = new CubicCurve2D.Double(last.getX(), last.getY(), segment.getCoord()[0], + segment.getCoord()[1], segment.getCoord()[2], segment.getCoord()[3], x2, y2); + jiggle.curveTo(tmp); + jiggle.appendTo(result); + last = new Point2D.Double(x2, y2); } else if (type == USegmentType.SEG_LINETO) { final double x = segment.getCoord()[0]; final double y = segment.getCoord()[1]; @@ -67,7 +77,7 @@ public class UPathHand { jiggle.lineTo(x, y); for (USegment seg2 : jiggle.toUPath()) { if (seg2.getSegmentType() == USegmentType.SEG_LINETO) { - jigglePath.lineTo(seg2.getCoord()[0], seg2.getCoord()[1]); + result.lineTo(seg2.getCoord()[0], seg2.getCoord()[1]); } } last = new Point2D.Double(x, y); @@ -76,7 +86,7 @@ public class UPathHand { return; } } - this.path = jigglePath; + this.path = result; this.path.setDeltaShadow(source.getDeltaShadow()); } diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index 2ee5d3aa4..426224f15 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -43,7 +43,7 @@ public class Version { private static final int MAJOR_SEPARATOR = 1000000; public static int version() { - return 1201901; + return 1201902; } public static int versionPatched() { @@ -88,7 +88,7 @@ public class Version { } public static long compileTime() { - return 1549726324013L; + return 1551475240238L; } public static String compileTimeString() {