diff --git a/build.xml b/build.xml index dd4dad274..2158d69fd 100644 --- a/build.xml +++ b/build.xml @@ -20,7 +20,7 @@ - + + + + + + + + + + + @@ -49,6 +59,8 @@ + + diff --git a/pom.xml b/pom.xml index dfaa7264e..f997c8cc4 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ net.sourceforge.plantuml plantuml - 8025-SNAPSHOT + 8040-SNAPSHOT jar PlantUML @@ -111,10 +111,12 @@ ${project.basedir}/src - net/sourceforge/plantuml/version/logo.png - net/sourceforge/plantuml/version/favicon.png + net/sourceforge/plantuml/version/*.png + net/sourceforge/plantuml/openiconic/data/*.txt net/sourceforge/plantuml/openiconic/data/*.svg net/sourceforge/plantuml/fun/*.png + sprite/archimate/*.png + net/sourceforge/plantuml/dedication/*.png diff --git a/src/net/sourceforge/plantuml/ColorParam.java b/src/net/sourceforge/plantuml/ColorParam.java index 9590f266f..b35e83a73 100644 --- a/src/net/sourceforge/plantuml/ColorParam.java +++ b/src/net/sourceforge/plantuml/ColorParam.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 19109 $ + * Revision $Revision: 19510 $ * */ package net.sourceforge.plantuml; @@ -105,6 +105,7 @@ public enum ColorParam { sequenceDividerBorder(HtmlColorUtils.BLACK, ColorType.LINE), sequenceLifeLineBackground(HtmlColorUtils.WHITE, true, ColorType.BACK), sequenceLifeLineBorder(HtmlColorUtils.MY_RED, ColorType.LINE), + sequenceNewpageSeparator(HtmlColorUtils.BLACK, ColorType.LINE), sequenceArrow(HtmlColorUtils.MY_RED), sequenceBoxBorder(HtmlColorUtils.MY_RED, ColorType.LINE), sequenceBoxBackground(HtmlColorUtils.COL_DDDDDD, true, ColorType.BACK), diff --git a/src/net/sourceforge/plantuml/FileFormat.java b/src/net/sourceforge/plantuml/FileFormat.java index 13dade974..48f4f1667 100644 --- a/src/net/sourceforge/plantuml/FileFormat.java +++ b/src/net/sourceforge/plantuml/FileFormat.java @@ -42,7 +42,7 @@ import java.io.File; * */ public enum FileFormat { - PNG, SVG, EPS, EPS_TEXT, ATXT, UTXT, XMI_STANDARD, XMI_STAR, XMI_ARGO, + PNG, SVG, EPS, EPS_TEXT, ATXT, UTXT, XMI_STANDARD, XMI_STAR, XMI_ARGO, SCXML, PDF, MJPEG, ANIMATED_GIF, HTML, HTML5, VDX, LATEX, LATEX_NO_PREAMBLE, BASE64; /** diff --git a/src/net/sourceforge/plantuml/NewpagedDiagram.java b/src/net/sourceforge/plantuml/NewpagedDiagram.java index febc831dc..e9b640dbd 100644 --- a/src/net/sourceforge/plantuml/NewpagedDiagram.java +++ b/src/net/sourceforge/plantuml/NewpagedDiagram.java @@ -124,7 +124,12 @@ public class NewpagedDiagram extends AbstractPSystem { if (sb.length() > 0) { sb.append(" "); } - sb.append(d.getWarningOrError()); + if (d.getWarningOrError() != null) { + sb.append(d.getWarningOrError()); + } + } + if (sb.length() == 0) { + return null; } return sb.toString(); } diff --git a/src/net/sourceforge/plantuml/Option.java b/src/net/sourceforge/plantuml/Option.java index 0bcf1d7f6..0151c8072 100644 --- a/src/net/sourceforge/plantuml/Option.java +++ b/src/net/sourceforge/plantuml/Option.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 19396 $ + * Revision $Revision: 19543 $ * */ package net.sourceforge.plantuml; @@ -96,6 +96,8 @@ public class Option { setFileFormat(FileFormat.SVG); } else if (s.equalsIgnoreCase("-thtml") || s.equalsIgnoreCase("-html")) { setFileFormat(FileFormat.HTML); + } else if (s.equalsIgnoreCase("-tscxml") || s.equalsIgnoreCase("-scxml")) { + setFileFormat(FileFormat.SCXML); } else if (s.equalsIgnoreCase("-txmi") || s.equalsIgnoreCase("-xmi")) { setFileFormat(FileFormat.XMI_STANDARD); } else if (s.equalsIgnoreCase("-txmi:argo") || s.equalsIgnoreCase("-xmi:argo")) { diff --git a/src/net/sourceforge/plantuml/OptionPrint.java b/src/net/sourceforge/plantuml/OptionPrint.java index 731971e1c..24a659312 100644 --- a/src/net/sourceforge/plantuml/OptionPrint.java +++ b/src/net/sourceforge/plantuml/OptionPrint.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 19254 $ + * Revision $Revision: 19604 $ * */ package net.sourceforge.plantuml; @@ -75,7 +75,8 @@ public class OptionPrint { System.out.println(" -tpdf\t\tTo generate images using PDF format"); System.out.println(" -tvdx\t\tTo generate images using VDX format"); System.out.println(" -txmi\t\tTo generate XMI file for class diagram"); - System.out.println(" -thtml\t\tTo generate HTML files for class diagram"); + System.out.println(" -tscxml\t\tTo generate SCXML file for state diagram"); + System.out.println(" -thtml\t\tTo generate HTML file for class diagram"); System.out.println(" -ttxt\t\tTo generate images with ASCII art"); System.out.println(" -tutxt\t\tTo generate images with ASCII art using Unicode characters"); System.out.println(" -tlatex\t\tTo generate images using LaTeX/Tikz format"); diff --git a/src/net/sourceforge/plantuml/PSystemBuilder.java b/src/net/sourceforge/plantuml/PSystemBuilder.java index a4cd98cb4..db892a4d8 100644 --- a/src/net/sourceforge/plantuml/PSystemBuilder.java +++ b/src/net/sourceforge/plantuml/PSystemBuilder.java @@ -47,6 +47,7 @@ import net.sourceforge.plantuml.core.DiagramType; import net.sourceforge.plantuml.core.UmlSource; import net.sourceforge.plantuml.creole.PSystemCreoleFactory; import net.sourceforge.plantuml.cute.PSystemCuteFactory; +import net.sourceforge.plantuml.dedication.PSystemDedicationFactory; import net.sourceforge.plantuml.descdiagram.DescriptionDiagramFactory; import net.sourceforge.plantuml.directdot.PSystemDotFactory; import net.sourceforge.plantuml.ditaa.PSystemDitaaFactory; @@ -159,6 +160,7 @@ public class PSystemBuilder { factories.add(new FlowDiagramFactory()); factories.add(new PSystemTreeFactory(DiagramType.JUNGLE)); factories.add(new PSystemCuteFactory(DiagramType.CUTE)); + factories.add(new PSystemDedicationFactory()); return factories; } diff --git a/src/net/sourceforge/plantuml/SignatureUtils.java b/src/net/sourceforge/plantuml/SignatureUtils.java index 109e0349e..8d7c33ca9 100644 --- a/src/net/sourceforge/plantuml/SignatureUtils.java +++ b/src/net/sourceforge/plantuml/SignatureUtils.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 19109 $ + * Revision $Revision: 19602 $ * */ package net.sourceforge.plantuml; @@ -60,6 +60,22 @@ public class SignatureUtils { } } + public static String getSignatureSha512(String s) { + try { + final AsciiEncoder coder = new AsciiEncoder(); + final MessageDigest msgDigest = MessageDigest.getInstance("SHA-512"); + msgDigest.update(s.getBytes("UTF-8")); + final byte[] digest = msgDigest.digest(); + return coder.encode(digest); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + throw new UnsupportedOperationException(e); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + throw new UnsupportedOperationException(e); + } + } + public static String getSignatureWithoutImgSrc(String s) { s = getSignature(purge(s)); return s; diff --git a/src/net/sourceforge/plantuml/UmlDiagram.java b/src/net/sourceforge/plantuml/UmlDiagram.java index d6a37286e..84ce517e9 100644 --- a/src/net/sourceforge/plantuml/UmlDiagram.java +++ b/src/net/sourceforge/plantuml/UmlDiagram.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 19398 $ + * Revision $Revision: 19591 $ * */ package net.sourceforge.plantuml; @@ -306,8 +306,8 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann strings.add(" - a bug in PlantUML"); strings.add(" - a problem in GraphViz"); strings.add(" "); - strings.add("You should send this diagram and this image to plantuml@gmail.com to solve this issue."); - strings.add("You can try to turn arround this issue by simplifing your diagram."); + strings.add("You should send this diagram and this image to plantuml@gmail.com or"); + strings.add("post to http://plantuml.com/qa to solve this issue."); strings.add(" "); return strings; } @@ -320,7 +320,8 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann strings.add(" "); strings.add("PlantUML (" + Version.versionString() + ") has crashed."); strings.add(" "); - strings.add("You should send this diagram and this image to plantuml@gmail.com to solve this issue."); + strings.add("You should send this diagram and this image to plantuml@gmail.com or"); + strings.add("post to http://plantuml.com/qa to solve this issue."); strings.add("You can try to turn arround this issue by simplifing your diagram."); strings.add(" "); return strings; diff --git a/src/net/sourceforge/plantuml/ant/PlantUmlTask.java b/src/net/sourceforge/plantuml/ant/PlantUmlTask.java index cd7d3e620..d692bdfe3 100644 --- a/src/net/sourceforge/plantuml/ant/PlantUmlTask.java +++ b/src/net/sourceforge/plantuml/ant/PlantUmlTask.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 19396 $ + * Revision $Revision: 19543 $ * */ package net.sourceforge.plantuml.ant; @@ -282,6 +282,9 @@ public class PlantUmlTask extends Task { } public void setFormat(String s) { + if ("scxml".equalsIgnoreCase(s)) { + option.setFileFormat(FileFormat.SCXML); + } if ("xmi".equalsIgnoreCase(s)) { option.setFileFormat(FileFormat.XMI_STANDARD); } diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java index 48f31e0a5..e3a80d8ed 100644 --- a/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java +++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextArrow.java @@ -105,6 +105,9 @@ public class ComponentTextArrow extends AbstractComponentText { charArea.drawChar('>', width - 1, yarrow); } else if (config.getArrowDirection() == ArrowDirection.RIGHT_TO_LEFT_REVERSE) { charArea.drawChar('<', 1, yarrow); + } else if (config.getArrowDirection() == ArrowDirection.BOTH_DIRECTION) { + charArea.drawChar('>', width - 1, yarrow); + charArea.drawChar('<', 1, yarrow); } else { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/asciiart/ComponentTextNote.java b/src/net/sourceforge/plantuml/asciiart/ComponentTextNote.java index cb84060e3..a65692ce4 100644 --- a/src/net/sourceforge/plantuml/asciiart/ComponentTextNote.java +++ b/src/net/sourceforge/plantuml/asciiart/ComponentTextNote.java @@ -36,15 +36,14 @@ package net.sourceforge.plantuml.asciiart; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.FileFormat; +import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.graphic.StringBounder; 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.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt; -import net.sourceforge.plantuml.StringUtils; public class ComponentTextNote extends AbstractComponentText { @@ -64,10 +63,18 @@ public class ComponentTextNote extends AbstractComponentText { final int width = (int) dimensionToUse.getWidth() - 1; final int height = (int) dimensionToUse.getHeight(); charArea.fillRect(' ', 2, 1, width - 3, height - 2); - if (fileFormat == FileFormat.UTXT) { - charArea.drawNoteSimpleUnicode(2, 0, width - 2, height); - } else { - charArea.drawNoteSimple(2, 0, width - 2, height); + if (type == ComponentType.NOTE) { + if (fileFormat == FileFormat.UTXT) { + charArea.drawNoteSimpleUnicode(2, 0, width - 2, height); + } else { + charArea.drawNoteSimple(2, 0, width - 2, height); + } + } else if (type == ComponentType.NOTE_BOX) { + if (fileFormat == FileFormat.UTXT) { + charArea.drawBoxSimpleUnicode(2, 0, width - 2, height); + } else { + charArea.drawBoxSimple(2, 0, width - 2, height); + } } charArea.drawStringsLR(stringsToDisplay.as(), 3, 1); } diff --git a/src/net/sourceforge/plantuml/asciiart/TextSkin.java b/src/net/sourceforge/plantuml/asciiart/TextSkin.java index bb8e4b643..27412332b 100644 --- a/src/net/sourceforge/plantuml/asciiart/TextSkin.java +++ b/src/net/sourceforge/plantuml/asciiart/TextSkin.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 19109 $ + * Revision $Revision: 19529 $ * */ package net.sourceforge.plantuml.asciiart; @@ -60,7 +60,9 @@ public class TextSkin implements Skin { return new ComponentTextActor(type, stringsToDisplay, fileFormat); } if (type.isArrow() - && ((config.getArrowDirection() == ArrowDirection.LEFT_TO_RIGHT_NORMAL) || (config.getArrowDirection() == ArrowDirection.RIGHT_TO_LEFT_REVERSE))) { + && (config.getArrowDirection() == ArrowDirection.LEFT_TO_RIGHT_NORMAL + || config.getArrowDirection() == ArrowDirection.RIGHT_TO_LEFT_REVERSE || config + .getArrowDirection() == ArrowDirection.BOTH_DIRECTION)) { return new ComponentTextArrow(type, config, stringsToDisplay, fileFormat, param.maxAsciiMessageLength()); } if (type.isArrow() && config.isSelfArrow()) { @@ -87,7 +89,7 @@ public class TextSkin implements Skin { if (type == ComponentType.ALIVE_BOX_OPEN_OPEN) { return new ComponentTextActiveLine(fileFormat); } - if (type == ComponentType.NOTE) { + if (type == ComponentType.NOTE || type == ComponentType.NOTE_BOX) { return new ComponentTextNote(type, stringsToDisplay, fileFormat); } if (type == ComponentType.DIVIDER) { diff --git a/src/net/sourceforge/plantuml/command/ProtectedCommand.java b/src/net/sourceforge/plantuml/command/ProtectedCommand.java index 141e7a0e9..7161b05e2 100644 --- a/src/net/sourceforge/plantuml/command/ProtectedCommand.java +++ b/src/net/sourceforge/plantuml/command/ProtectedCommand.java @@ -56,7 +56,7 @@ public class ProtectedCommand implements Command { } catch (Throwable t) { Log.error("Error " + t); t.printStackTrace(); - String msg = "You should send a mail to plantuml@gmail.com with this log (V" + Version.versionString() + String msg = "You should send a mail to plantuml@gmail.com or post to http://plantuml.com/qa with this log (V" + Version.versionString() + ")"; Log.error(msg); msg += " " + t.toString(); diff --git a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java index d0d13f0dd..0d715ebb6 100644 --- a/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java +++ b/src/net/sourceforge/plantuml/command/note/sequence/FactorySequenceNoteOnArrowCommand.java @@ -51,19 +51,24 @@ import net.sourceforge.plantuml.graphic.color.ColorParser; import net.sourceforge.plantuml.sequencediagram.AbstractMessage; import net.sourceforge.plantuml.sequencediagram.EventWithDeactivate; import net.sourceforge.plantuml.sequencediagram.NotePosition; +import net.sourceforge.plantuml.sequencediagram.NoteStyle; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFactoryCommand { private RegexConcat getRegexConcatMultiLine() { - return new RegexConcat(new RegexLeaf("^[%s]*note[%s]+"), // + return new RegexConcat(new RegexLeaf("^[%s]*"), // + new RegexLeaf("STYLE", "(note|hnote|rnote)"), // + new RegexLeaf("[%s]+"), // new RegexLeaf("POSITION", "(right|left)[%s]*"), // ColorParser.exp1(), // new RegexLeaf("$")); } private RegexConcat getRegexConcatSingleLine() { - return new RegexConcat(new RegexLeaf("^[%s]*note[%s]+"), // + return new RegexConcat(new RegexLeaf("^[%s]*"), // + new RegexLeaf("STYLE", "(note|hnote|rnote)"), // + new RegexLeaf("[%s]+"), // new RegexLeaf("POSITION", "(right|left)[%s]*"), // ColorParser.exp1(), // new RegexLeaf("[%s]*:[%s]*"), // @@ -116,7 +121,8 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto lines = lines.subExtract(1, 0); } - ((AbstractMessage) m).setNote(lines.toDisplay(), position, line0.get("COLOR", 0), url); + final NoteStyle style = NoteStyle.getNoteStyle(line0.get("STYLE", 0)); + ((AbstractMessage) m).setNote(lines.toDisplay(), position, style, line0.get("COLOR", 0), url); } return CommandExecutionResult.ok(); diff --git a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java b/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java index ca01a340e..ac3cc583f 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java +++ b/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 19243 $ + * Revision $Revision: 19540 $ * */ package net.sourceforge.plantuml.cucadiagram; @@ -56,10 +56,12 @@ import net.sourceforge.plantuml.cucadiagram.entity.EntityFactory; import net.sourceforge.plantuml.graphic.USymbol; import net.sourceforge.plantuml.jdot.CucaDiagramFileMakerJDot; import net.sourceforge.plantuml.skin.VisibilityModifier; +import net.sourceforge.plantuml.statediagram.StateDiagram; import net.sourceforge.plantuml.svek.CucaDiagramFileMaker; import net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek; import net.sourceforge.plantuml.ugraphic.ColorMapper; import net.sourceforge.plantuml.xmi.CucaDiagramXmiMaker; +import net.sourceforge.plantuml.xmlsc.StateDiagramScxmlMaker; public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, PortionShower { @@ -288,6 +290,11 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, maker.createFiles(suggestedFile); } + private void createFilesScxml(OutputStream suggestedFile) throws IOException { + final StateDiagramScxmlMaker maker = new StateDiagramScxmlMaker((StateDiagram) this); + maker.createFiles(suggestedFile); + } + @Override protected ImageData exportDiagramInternal(OutputStream os, int index, FileFormatOption fileFormatOption) throws IOException { @@ -307,6 +314,11 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, return new ImageDataSimple(); } + if (fileFormat == FileFormat.SCXML) { + createFilesScxml(os); + return new ImageDataSimple(); + } + if (getUmlDiagramType() == UmlDiagramType.COMPOSITE) { throw new UnsupportedOperationException(); } diff --git a/src/net/sourceforge/plantuml/dedication/DecoderInputStream.java b/src/net/sourceforge/plantuml/dedication/DecoderInputStream.java new file mode 100644 index 000000000..6b55c0834 --- /dev/null +++ b/src/net/sourceforge/plantuml/dedication/DecoderInputStream.java @@ -0,0 +1,102 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 4041 $ + * + */ +package net.sourceforge.plantuml.dedication; + +import java.io.FilterInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Random; + +public class DecoderInputStream extends FilterInputStream { + + private final byte key[]; + private int idx; + private final Random rnd; + + public DecoderInputStream(InputStream source, byte key[]) { + super(source); + this.key = key; + this.rnd = new Random(getSeed()); + } + + private long getSeed() { + long result = 17; + for (byte b : key) { + result = result * 37 + b; + } + return result; + } + + private byte getNextByte() { + for (int i = 0; i < nextKey(); i++) { + rnd.nextInt(); + } + return (byte) rnd.nextInt(); + } + + private int nextKey() { + final int result = key[idx]; + idx++; + if (idx >= key.length) { + idx = 0; + } + if (result < 0) { + return result + 256; + } + return result; + } + + @Override + public int read() throws IOException { + int b = super.read(); + if (b == -1) { + return -1; + } + b = b ^ getNextByte(); + return b; + } + + @Override + public int read(byte[] b, int off, int len) throws IOException { + final int nb = super.read(b, off, len); + if (nb == -1) { + return nb; + } + for (int i = 0; i < nb; i++) { + b[i + off] = (byte) (b[i + off] ^ getNextByte()); + } + return nb; + } + +} diff --git a/src/net/sourceforge/plantuml/dedication/Dedication.java b/src/net/sourceforge/plantuml/dedication/Dedication.java new file mode 100644 index 000000000..f3fd602b4 --- /dev/null +++ b/src/net/sourceforge/plantuml/dedication/Dedication.java @@ -0,0 +1,84 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 4041 $ + * + */ +package net.sourceforge.plantuml.dedication; + +import java.awt.image.BufferedImage; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; + +import javax.imageio.ImageIO; +import javax.imageio.stream.ImageInputStream; + +import net.sourceforge.plantuml.webp.VP8Decoder; + +public class Dedication { + + private final String signature; + + public Dedication(String signature) { + this.signature = signature; + } + + public String getSignature() { + return signature; + } + + public byte[] getKey(String keepLetter) { + try { + return keepLetter.getBytes("UTF8"); + } catch (UnsupportedEncodingException e) { + throw new IllegalStateException(e); + } + } + + private InputStream getInputStream(String keepLetter) { + final byte[] key = getKey(keepLetter); + final InputStream tmp = PSystemDedication.class.getResourceAsStream(getSignature() + ".png"); + return new DecoderInputStream(tmp, key); + } + + public BufferedImage getBufferedImage(String keepLetter) { + try { + final InputStream is = getInputStream(keepLetter); + final ImageInputStream iis = ImageIO.createImageInputStream(is); + final VP8Decoder vp8Decoder = new VP8Decoder(); + vp8Decoder.decodeFrame(iis, false); + iis.close(); + return vp8Decoder.getFrame().getBufferedImage(); + } catch (Exception e) { + return null; + } + } + +} diff --git a/src/net/sourceforge/plantuml/dedication/Dedications.java b/src/net/sourceforge/plantuml/dedication/Dedications.java new file mode 100644 index 000000000..bdb5890e2 --- /dev/null +++ b/src/net/sourceforge/plantuml/dedication/Dedications.java @@ -0,0 +1,78 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 4041 $ + * + */ +package net.sourceforge.plantuml.dedication; + +import java.util.HashMap; +import java.util.Map; + +import net.sourceforge.plantuml.SignatureUtils; + +public class Dedications { + + private static final Map all = new HashMap(); + + static { + addNormal("Write your own dedication!"); + addCrypted("RyHcSMMTGTW-ZlDelq18AwlwfbZZdfo-Yo0ketavjyFxRAFoKx1mAI032reWO3p4Mog-AV6jFqjXfi8G6pKo7G00"); + } + + private static void addNormal(String sentence) { + final String signature = SignatureUtils.getSignatureSha512(keepLetter(sentence)); + addCrypted(signature); + } + + private static void addCrypted(String signature) { + all.put(signature, new Dedication(signature)); + } + + private Dedications() { + } + + public static Dedication get(String line) { + final String signature = SignatureUtils.getSignatureSha512(keepLetter(line)); + return all.get(signature); + } + + public static String keepLetter(String s) { + final StringBuilder sb = new StringBuilder(); + for (int i = 0; i < s.length(); i++) { + final char c = s.charAt(i); + if (Character.isLetter(c)) { + sb.append(c); + } + } + return sb.toString().toUpperCase(); + } + +} diff --git a/src/net/sourceforge/plantuml/dedication/G-vlxV6y0ekXvg4jdrZhpVdo7lhOrgzdDMujAyww7DSmBwYMPUi9rNQVH44hebtYNePymublPiBIpRDwZGKrbG00.png b/src/net/sourceforge/plantuml/dedication/G-vlxV6y0ekXvg4jdrZhpVdo7lhOrgzdDMujAyww7DSmBwYMPUi9rNQVH44hebtYNePymublPiBIpRDwZGKrbG00.png new file mode 100644 index 000000000..568a3bb01 Binary files /dev/null and b/src/net/sourceforge/plantuml/dedication/G-vlxV6y0ekXvg4jdrZhpVdo7lhOrgzdDMujAyww7DSmBwYMPUi9rNQVH44hebtYNePymublPiBIpRDwZGKrbG00.png differ diff --git a/src/net/sourceforge/plantuml/dedication/PSystemDedication.java b/src/net/sourceforge/plantuml/dedication/PSystemDedication.java new file mode 100644 index 000000000..f862966c4 --- /dev/null +++ b/src/net/sourceforge/plantuml/dedication/PSystemDedication.java @@ -0,0 +1,80 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 4041 $ + * + */ +package net.sourceforge.plantuml.dedication; + +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.OutputStream; + +import net.sourceforge.plantuml.AbstractPSystem; +import net.sourceforge.plantuml.FileFormatOption; +import net.sourceforge.plantuml.core.DiagramDescription; +import net.sourceforge.plantuml.core.DiagramDescriptionImpl; +import net.sourceforge.plantuml.core.ImageData; +import net.sourceforge.plantuml.graphic.HtmlColorUtils; +import net.sourceforge.plantuml.graphic.UDrawable; +import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity; +import net.sourceforge.plantuml.ugraphic.ImageBuilder; +import net.sourceforge.plantuml.ugraphic.UGraphic; +import net.sourceforge.plantuml.ugraphic.UImage; + +public class PSystemDedication extends AbstractPSystem { + + private final Dedication dedication; + private final String keepLetter; + + public PSystemDedication(Dedication dedication, String keepLetter) { + this.dedication = dedication; + this.keepLetter = keepLetter; + } + + public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException { + final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE, + getMetadata(), null, 0, 0, null, false); + imageBuilder.setUDrawable(new UDrawable() { + public void drawU(UGraphic ug) { + final BufferedImage bufferedImage = dedication.getBufferedImage(keepLetter); + if (bufferedImage != null) { + ug.draw(new UImage(bufferedImage)); + } + } + }); + return imageBuilder.writeImageTOBEMOVED(fileFormat, os); + } + + public DiagramDescription getDescription() { + return new DiagramDescriptionImpl("(Dedication)", getClass()); + } + +} diff --git a/src/net/sourceforge/plantuml/dedication/PSystemDedicationFactory.java b/src/net/sourceforge/plantuml/dedication/PSystemDedicationFactory.java new file mode 100644 index 000000000..4b79179a8 --- /dev/null +++ b/src/net/sourceforge/plantuml/dedication/PSystemDedicationFactory.java @@ -0,0 +1,50 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 3837 $ + * + */ +package net.sourceforge.plantuml.dedication; + +import net.sourceforge.plantuml.AbstractPSystem; +import net.sourceforge.plantuml.command.PSystemSingleLineFactory; + +public class PSystemDedicationFactory extends PSystemSingleLineFactory { + + @Override + protected AbstractPSystem executeLine(String line) { + final Dedication dedication = Dedications.get(line); + if (dedication != null) { + return new PSystemDedication(dedication, Dedications.keepLetter(line)); + } + return null; + } + +} diff --git a/src/net/sourceforge/plantuml/dedication/RyHcSMMTGTW-ZlDelq18AwlwfbZZdfo-Yo0ketavjyFxRAFoKx1mAI032reWO3p4Mog-AV6jFqjXfi8G6pKo7G00.png b/src/net/sourceforge/plantuml/dedication/RyHcSMMTGTW-ZlDelq18AwlwfbZZdfo-Yo0ketavjyFxRAFoKx1mAI032reWO3p4Mog-AV6jFqjXfi8G6pKo7G00.png new file mode 100644 index 000000000..f6c1ffdd5 Binary files /dev/null and b/src/net/sourceforge/plantuml/dedication/RyHcSMMTGTW-ZlDelq18AwlwfbZZdfo-Yo0ketavjyFxRAFoKx1mAI032reWO3p4Mog-AV6jFqjXfi8G6pKo7G00.png differ diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java index 73184e80b..b99f12725 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandPackageWithUSymbol.java @@ -60,7 +60,7 @@ public class CommandPackageWithUSymbol extends SingleLineCommand2 dotStrings, FileFormatOption fileFormatOption) throws IOException { + lock.lock(); + try { + return createFileLocked(os, dotStrings, fileFormatOption); + } finally { + lock.unlock(); + } + } + + private ImageData createFileLocked(OutputStream os, List dotStrings, FileFormatOption fileFormatOption) + throws IOException { for (ILeaf leaf : diagram.getLeafsvalues()) { printEntityNew(leaf); @@ -399,9 +413,9 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { // } // for (Link link : diagram.getLinks()) { - System.err.println("link=" + link); + // System.err.println("link=" + link); final Agedge_s e = createEdge(g, link); - System.err.println("Agedge_s=" + e); + // System.err.println("Agedge_s=" + e); if (e != null) { edges.put(link, e); } @@ -510,8 +524,8 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { // if (/* pragma.horizontalLineBetweenDifferentPackageAllowed() || */link.isInvis() || length != 1) { agsafeset(e, new CString("minlen"), new CString("" + (length - 1)), new CString("")); // } - System.err.print("EDGE " + link.getEntity1().getUid() + "->" + link.getEntity2().getUid() + " minlen=" - + (length - 1) + " "); + // System.err.print("EDGE " + link.getEntity1().getUid() + "->" + link.getEntity2().getUid() + " minlen=" + // + (length - 1) + " "); final TextBlock label = getLabel(link); if (TextBlockUtils.isEmpty(label) == false) { @@ -520,9 +534,9 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { final CString hackDim = Macro.createHackInitDimensionFromLabel((int) dimLabel.getWidth(), (int) dimLabel.getHeight()); agsafeset(e, new CString("label"), hackDim, new CString("")); - System.err.print(" label=" + hackDim.getContent()); + // System.err.print("label=" + hackDim.getContent()); } - System.err.println(); + // System.err.println(); return e; } @@ -537,7 +551,8 @@ public class CucaDiagramFileMakerJDot implements CucaDiagramFileMaker { strings.add(" "); strings.add("Sorry, the subproject Smetana is not finished yet..."); strings.add(" "); - strings.add("You should send this diagram and this image to plantuml@gmail.com to solve this issue."); + strings.add("You should send this diagram and this image to plantuml@gmail.com or"); + strings.add("post to http://plantuml.com/qa to solve this issue."); strings.add(" "); return strings; } diff --git a/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java b/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java index b31d7c413..a7fd26fa5 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java +++ b/src/net/sourceforge/plantuml/sequencediagram/AbstractMessage.java @@ -56,6 +56,7 @@ public abstract class AbstractMessage implements EventWithDeactivate { private NotePosition notePosition; private HtmlColor noteBackColor; private Url urlNote; + private NoteStyle noteStyle; private final Url url; private final String messageNumber; private boolean parallel = false; @@ -137,7 +138,7 @@ public abstract class AbstractMessage implements EventWithDeactivate { public final Display getLabel() { return label; } - + public final Display getLabelNumbered() { if (getMessageNumber() == null) { return getLabel(); @@ -148,7 +149,6 @@ public abstract class AbstractMessage implements EventWithDeactivate { return result; } - public final ArrowConfiguration getArrowConfiguration() { return arrowConfiguration; } @@ -156,15 +156,20 @@ public abstract class AbstractMessage implements EventWithDeactivate { public final Display getNote() { return notes == null ? notes : notes; } + + public final NoteStyle getNoteStyle() { + return noteStyle; + } public final Url getUrlNote() { return urlNote; } - public final void setNote(Display strings, NotePosition notePosition, String backcolor, Url url) { + public final void setNote(Display strings, NotePosition notePosition, NoteStyle noteStyle, String backcolor, Url url) { if (notePosition != NotePosition.LEFT && notePosition != NotePosition.RIGHT) { throw new IllegalArgumentException(); } + this.noteStyle = noteStyle; this.notes = strings; this.urlNote = url; this.notePosition = overideNotePosition(notePosition); diff --git a/src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java b/src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java index 4d4e29817..4935cbae3 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java +++ b/src/net/sourceforge/plantuml/sequencediagram/NoteStyle.java @@ -33,6 +33,8 @@ */ package net.sourceforge.plantuml.sequencediagram; +import net.sourceforge.plantuml.skin.ComponentType; + public enum NoteStyle { NORMAL, HEXAGONAL, BOX; @@ -45,5 +47,16 @@ public enum NoteStyle { } return NoteStyle.NORMAL; } + + public ComponentType getNoteComponentType() { + if (this == NoteStyle.HEXAGONAL) { + return ComponentType.NOTE_HEXAGONAL; + } + if (this == NoteStyle.BOX) { + return ComponentType.NOTE_BOX; + } + return ComponentType.NOTE; + } + } diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java index d65ba37c4..ddcdf8f0b 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/DrawableSetInitializer.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 19109 $ + * Revision $Revision: 19528 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; @@ -434,7 +434,7 @@ class DrawableSetInitializer { } } final ISkinParam skinParam = n.getSkinParamBackcolored(drawableSet.getSkinParam()); - final ComponentType type = getNoteComponentType(n.getStyle()); + final ComponentType type = n.getStyle().getNoteComponentType(); final NoteBox noteBox = new NoteBox(freeY2.getFreeY(range), drawableSet.getSkin().createComponent(type, null, skinParam, n.getStrings()), p1, p2, n.getPosition(), n.getUrl()); return noteBox; @@ -456,16 +456,6 @@ class DrawableSetInitializer { freeY2 = freeY2.add(notesBoxes.getPreferredHeight(stringBounder), range); } - private ComponentType getNoteComponentType(NoteStyle noteStyle) { - if (noteStyle == NoteStyle.HEXAGONAL) { - return ComponentType.NOTE_HEXAGONAL; - } - if (noteStyle == NoteStyle.BOX) { - return ComponentType.NOTE_BOX; - } - return ComponentType.NOTE; - } - private void prepareLiveEvent(StringBounder stringBounder, LifeEvent lifeEvent, ParticipantRange range) { final double y = freeY2.getFreeY(range); final AbstractMessage message = lifeEvent.getMessage(); diff --git a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java index 968049086..43cd46620 100644 --- a/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java +++ b/src/net/sourceforge/plantuml/sequencediagram/graphic/Step1Message.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 19109 $ + * Revision $Revision: 19528 $ * */ package net.sourceforge.plantuml.sequencediagram.graphic; @@ -73,7 +73,8 @@ class Step1Message extends Step1Abstract { if (message.getNote() != null) { final ISkinParam skinParam = message.getSkinParamNoteBackcolored(drawingSet.getSkinParam()); - setNote(drawingSet.getSkin().createComponent(ComponentType.NOTE, null, skinParam, message.getNote())); + setNote(drawingSet.getSkin().createComponent(message.getNoteStyle().getNoteComponentType(), null, + skinParam, message.getNote())); } } diff --git a/src/net/sourceforge/plantuml/skin/rose/Rose.java b/src/net/sourceforge/plantuml/skin/rose/Rose.java index 2ddf06d8a..ee66c7e22 100644 --- a/src/net/sourceforge/plantuml/skin/rose/Rose.java +++ b/src/net/sourceforge/plantuml/skin/rose/Rose.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 19109 $ + * Revision $Revision: 19510 $ * */ package net.sourceforge.plantuml.skin.rose; @@ -226,7 +226,7 @@ public class Rose implements Skin { return new ComponentRoseDestroy(getHtmlColor(param, ColorParam.sequenceLifeLineBorder)); } if (type == ComponentType.NEWPAGE) { - return new ComponentRoseNewpage(getFontColor(param, FontParam.SEQUENCE_GROUP)); + return new ComponentRoseNewpage(getHtmlColor(param, ColorParam.sequenceNewpageSeparator)); } if (type == ComponentType.DIVIDER) { return new ComponentRoseDivider(getUFont2(param, FontParam.SEQUENCE_DIVIDER), getHtmlColor(param, diff --git a/src/net/sourceforge/plantuml/svek/GraphvizCrash.java b/src/net/sourceforge/plantuml/svek/GraphvizCrash.java index b0af88d25..4e37ef6b0 100644 --- a/src/net/sourceforge/plantuml/svek/GraphvizCrash.java +++ b/src/net/sourceforge/plantuml/svek/GraphvizCrash.java @@ -90,7 +90,8 @@ public class GraphvizCrash extends AbstractTextBlock implements IEntityImage { strings.add("Cannot determine dot version: " + e.toString()); } strings.add(" "); - strings.add("You should send this diagram and this image to plantuml@gmail.com to solve this issue."); + strings.add("You should send this diagram and this image to plantuml@gmail.com or"); + strings.add("post to http://plantuml.com/qa to solve this issue."); strings.add("You can try to turn arround this issue by simplifing your diagram."); if (flashCode != null) { addDecodeHint(strings); diff --git a/src/net/sourceforge/plantuml/ugraphic/UImage.java b/src/net/sourceforge/plantuml/ugraphic/UImage.java index b194a8707..6dd2df8bd 100644 --- a/src/net/sourceforge/plantuml/ugraphic/UImage.java +++ b/src/net/sourceforge/plantuml/ugraphic/UImage.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 19271 $ + * Revision $Revision: 19570 $ * */ package net.sourceforge.plantuml.ugraphic; @@ -69,11 +69,11 @@ public class UImage implements UShape { } public double getWidth() { - return image.getWidth(); + return image.getWidth()-1; } public double getHeight() { - return image.getHeight(); + return image.getHeight()-1; } } diff --git a/src/net/sourceforge/plantuml/version/License.java b/src/net/sourceforge/plantuml/version/License.java index 421b05c76..bc729b9a3 100644 --- a/src/net/sourceforge/plantuml/version/License.java +++ b/src/net/sourceforge/plantuml/version/License.java @@ -37,7 +37,7 @@ import java.util.List; public enum License { - GPL, LGPL, APACHE, EPL, MIT; + GPL, LGPL, APACHE, EPL, MIT, BSD; public static License getCurrent() { return GPL; @@ -114,6 +114,48 @@ public enum License { text.add("by the very same license."); } + private void addBsd(final List text) { + text.add("PlantUML is free software; you can redistribute it and/or modify it"); + text.add("under the terms of the Revised BSD License."); + text.add(""); + text.add("All rights reserved."); + text.add("Redistribution and use in source and binary forms, with or without"); + text.add("modification, are permitted provided that the following conditions are met:"); + text.add(""); + text.add("* Redistributions of source code must retain the above copyright"); + text.add(" notice, this list of conditions and the following disclaimer."); + text.add("* Redistributions in binary form must reproduce the above copyright"); + text.add(" notice, this list of conditions and the following disclaimer in the"); + text.add(" documentation and/or other materials provided with the distribution."); + text.add("* Neither the name of the University of California, Berkeley nor the"); + text.add(" names of its contributors may be used to endorse or promote products"); + text.add(" derived from this software without specific prior written permission."); + text.add(""); + text.add("THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY"); + text.add("EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED"); + text.add("WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE"); + text.add("DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY"); + text.add("DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES"); + text.add("(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;"); + text.add("LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND"); + text.add("ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT"); + text.add("(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS"); + text.add("SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."); + text.add(""); + text.add("Note that images (whatever their format : PNG, SVG...) generated by running PlantUML"); + text.add("are owned by the author of their corresponding sources code (that is, their"); + text.add("textual description in PlantUML language). Those images are not covered by"); + text.add("the Eclipse Public License."); + text.add(""); + text.add("The generated images can then be used without any reference to the Eclipse Public License."); + text.add("It is not even necessary to stipulate that they have been generated with PlantUML,"); + text.add("also this will be appreciate by PlantUML team."); + text.add(""); + text.add("There is an exception : if the textual description in PlantUML language is also covered"); + text.add("by a license (like the BSD), then the generated images are logically covered"); + text.add("by the very same license."); + } + private void addApache(final List text) { text.add("PlantUML is free software; you can redistribute it and/or modify it"); text.add("under the terms of the Apache Software License."); @@ -275,6 +317,32 @@ public enum License { h.add(" * See the License for the specific language governing permissions and"); h.add(" * limitations under the License."); h.add(" * "); + } else if (this == License.BSD) { + h.add(" * Licensed under the Revised BSD License (the Revised Berkeley Software Distribution)"); + h.add(" * "); + h.add(" * Redistribution and use in source and binary forms, with or without"); + h.add(" * modification, are permitted provided that the following conditions are met:"); + h.add(" * "); + h.add(" * * Redistributions of source code must retain the above copyright"); + h.add(" * notice, this list of conditions and the following disclaimer."); + h.add(" * * Redistributions in binary form must reproduce the above copyright"); + h.add(" * notice, this list of conditions and the following disclaimer in the"); + h.add(" * documentation and/or other materials provided with the distribution."); + h.add(" * * Neither the name of the University of California, Berkeley nor the"); + h.add(" * names of its contributors may be used to endorse or promote products"); + h.add(" * derived from this software without specific prior written permission."); + h.add(" * "); + h.add(" * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY"); + h.add(" * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED"); + h.add(" * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE"); + h.add(" * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY"); + h.add(" * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES"); + h.add(" * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;"); + h.add(" * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND"); + h.add(" * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT"); + h.add(" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS"); + h.add(" * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."); + h.add(" * "); } else if (this == License.MIT) { h.add(" * Licensed under The MIT License (Massachusetts Institute of Technology License)"); h.add(" * "); @@ -312,6 +380,8 @@ public enum License { addMit(text); } else if (this == License.EPL) { addEpl(text); + } else if (this == License.BSD) { + addBsd(text); } else if (this == License.APACHE) { addApache(text); } else if (this == License.LGPL) { diff --git a/src/net/sourceforge/plantuml/version/Version.java b/src/net/sourceforge/plantuml/version/Version.java index f54afe0c1..9a5cbe11c 100644 --- a/src/net/sourceforge/plantuml/version/Version.java +++ b/src/net/sourceforge/plantuml/version/Version.java @@ -28,7 +28,7 @@ * * Original Author: Arnaud Roques * - * Revision $Revision: 19505 $ + * Revision $Revision: 19609 $ * */ package net.sourceforge.plantuml.version; @@ -39,7 +39,7 @@ import java.util.Date; public class Version { public static int version() { - return 8038; + return 8039; } public static String versionString() { @@ -63,7 +63,7 @@ public class Version { } private static long compileTime() { - return 1459789355152L; + return 1461342268180L; } public static String compileTimeString() { diff --git a/src/net/sourceforge/plantuml/xmlsc/ScxmlStateDiagramStandard.java b/src/net/sourceforge/plantuml/xmlsc/ScxmlStateDiagramStandard.java new file mode 100644 index 000000000..294cee1cd --- /dev/null +++ b/src/net/sourceforge/plantuml/xmlsc/ScxmlStateDiagramStandard.java @@ -0,0 +1,138 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 5616 $ + * + */ +package net.sourceforge.plantuml.xmlsc; + +import java.io.OutputStream; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import net.sourceforge.plantuml.cucadiagram.Display; +import net.sourceforge.plantuml.cucadiagram.IEntity; +import net.sourceforge.plantuml.cucadiagram.LeafType; +import net.sourceforge.plantuml.cucadiagram.Link; +import net.sourceforge.plantuml.statediagram.StateDiagram; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +public class ScxmlStateDiagramStandard { + + private final StateDiagram diagram; + private final Document document; + + public ScxmlStateDiagramStandard(StateDiagram diagram) throws ParserConfigurationException { + this.diagram = diagram; + final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + + final DocumentBuilder builder = factory.newDocumentBuilder(); + this.document = builder.newDocument(); + document.setXmlVersion("1.0"); + document.setXmlStandalone(true); + + final Element scxml = document.createElement("scxml"); + scxml.setAttribute("xmlns", "http://www.w3.org/2005/07/scxml"); + scxml.setAttribute("version", "1.0"); + final String initial = getInitial(); + if (initial != null) { + scxml.setAttribute("initial", initial); + } + document.appendChild(scxml); + + for (final IEntity ent : diagram.getLeafsvalues()) { + scxml.appendChild(createState(ent)); + } + + } + + private String getInitial() { + for (final IEntity ent : diagram.getLeafsvalues()) { + if (ent.getEntityType() == LeafType.CIRCLE_START) { + return getId(ent); + } + } + return null; + } + + private Element createState(IEntity entity) { + final Element state = document.createElement("state"); + state.setAttribute("id", getId(entity)); + for (final Link link : diagram.getLinks()) { + if (link.getEntity1() == entity) { + addLink(state, link); + } + } + return state; + } + + private void addLink(Element state, Link link) { + final Element transition = document.createElement("transition"); + final Display label = link.getLabel(); + if (Display.isNull(label) == false) { + final String event = label.get(0).toString(); + transition.setAttribute("event", event); + } + transition.setAttribute("target", getId(link.getEntity2())); + state.appendChild(transition); + + } + + private String getId(IEntity entity) { + String result = entity.getDisplay().get(0).toString(); + result = result.replaceAll("\\*", ""); + return result; + } + + public void transformerXml(OutputStream os) throws TransformerException, ParserConfigurationException { + final Source source = new DOMSource(document); + + final Result resultat = new StreamResult(os); + + final TransformerFactory fabrique = TransformerFactory.newInstance(); + final Transformer transformer = fabrique.newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + transformer.transform(source, resultat); + } + +} diff --git a/src/net/sourceforge/plantuml/xmlsc/StateDiagramScxmlMaker.java b/src/net/sourceforge/plantuml/xmlsc/StateDiagramScxmlMaker.java new file mode 100644 index 000000000..4c9c22d80 --- /dev/null +++ b/src/net/sourceforge/plantuml/xmlsc/StateDiagramScxmlMaker.java @@ -0,0 +1,69 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, Arnaud Roques + * + * Project Info: http://plantuml.com + * + * This file is part of PlantUML. + * + * PlantUML is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PlantUML distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + * License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. + * + * [Java is a trademark or registered trademark of Sun Microsystems, Inc. + * in the United States and other countries.] + * + * Original Author: Arnaud Roques + * + * Revision $Revision: 5079 $ + * + */ +package net.sourceforge.plantuml.xmlsc; + +import java.io.IOException; +import java.io.OutputStream; + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.TransformerException; + +import net.sourceforge.plantuml.Log; +import net.sourceforge.plantuml.statediagram.StateDiagram; + +public final class StateDiagramScxmlMaker { + + private final StateDiagram diagram; + + public StateDiagramScxmlMaker(StateDiagram diagram) throws IOException { + this.diagram = diagram; + } + + public void createFiles(OutputStream fos) throws IOException { + try { + final ScxmlStateDiagramStandard xmi; + xmi = new ScxmlStateDiagramStandard(diagram); + xmi.transformerXml(fos); + } catch (ParserConfigurationException e) { + Log.error(e.toString()); + e.printStackTrace(); + throw new IOException(e.toString()); + } catch (TransformerException e) { + Log.error(e.toString()); + e.printStackTrace(); + throw new IOException(e.toString()); + } + } + +}