From e3bdf197456fdfa2e2557d4d87a9c22e8c474c0a Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Fri, 6 Apr 2018 22:36:30 +0200 Subject: [PATCH] version 1.2018.3 --- pom.xml | 2 +- src/net/sourceforge/plantuml/ColorParam.java | 2 + .../{RoundParam.java => CornerParam.java} | 11 +- .../plantuml/Dimension2DDouble.java | 3 + src/net/sourceforge/plantuml/FontParam.java | 2 + src/net/sourceforge/plantuml/ISkinParam.java | 4 +- .../sourceforge/plantuml/PSystemUtils.java | 61 + src/net/sourceforge/plantuml/SkinParam.java | 30 +- .../plantuml/SkinParamDelegator.java | 6 +- .../plantuml/ZSourceFileReader.java | 162 ++ .../plantuml/ZSourceFileReader2.java | 66 + .../plantuml/ZSourceFileReaderAbstract.java | 170 ++ .../plantuml/cucadiagram/Bodier.java | 11 + .../plantuml/cucadiagram/BodyEnhanced.java | 16 +- .../plantuml/cucadiagram/CucaDiagram.java | 13 +- .../plantuml/cucadiagram/Link.java | 3 +- .../cucadiagram/entity/EntityFactory.java | 1 + .../plantuml/dedication/Dedication.java | 17 +- .../command/CommandLinkElement.java | 25 +- .../sourceforge/plantuml/eps/EpsGraphics.java | 23 +- .../plantuml/graphic/QuoteUtils.java | 7 +- .../plantuml/graphic/SkinParameter.java | 22 +- .../plantuml/graphic/SymbolContext.java | 29 +- .../plantuml/graphic/TextBlockUtils.java | 4 +- .../plantuml/graphic/USymbolRect.java | 26 +- src/net/sourceforge/plantuml/jasic/Jasic.java | 1636 ++++++++--------- .../plantuml/project3/CommandGanttArrow2.java | 74 + .../plantuml/project3/CommandPage.java | 63 + .../plantuml/project3/CommandSeparator.java | 65 + .../plantuml/project3/ComplementClose.java | 2 +- .../plantuml/project3/ComplementDates.java | 91 + .../project3/ComplementSeveralDays.java | 11 +- .../plantuml/project3/ConstantPlan.java | 58 + .../plantuml/project3/DayAsDate.java | 13 +- .../plantuml/project3/DaysAsDates.java | 78 + .../plantuml/project3/GCalendar.java | 4 +- .../plantuml/project3/GCalendarSimple.java | 16 +- .../plantuml/project3/GanttArrow.java | 2 +- .../plantuml/project3/GanttDiagram.java | 257 ++- .../project3/GanttDiagramFactory.java | 27 +- .../plantuml/project3/Instant.java | 4 - .../plantuml/project3/InstantDay.java | 10 - .../project3/{DurationDay.java => Load.java} | 17 +- .../plantuml/project3/LoadInDays.java | 65 + .../{Duration.java => LoadPlanable.java} | 3 +- .../plantuml/project3/PlanUtils.java | 52 + .../plantuml/project3/Resource.java | 91 + .../plantuml/project3/ResourceDraw.java | 118 ++ .../plantuml/project3/Resources.java | 53 + .../plantuml/project3/Solver2.java | 56 + .../project3/{Solver.java => Solver3.java} | 37 +- .../plantuml/project3/SubjectDayAsDate.java | 68 + .../plantuml/project3/SubjectDaysAsDates.java | 82 + .../plantuml/project3/SubjectResource.java | 63 + .../plantuml/project3/SubjectTask.java | 22 +- .../sourceforge/plantuml/project3/Task.java | 8 +- .../plantuml/project3/TaskAttribute.java | 2 +- .../plantuml/project3/TaskCode.java | 5 +- .../plantuml/project3/TaskDraw.java | 104 +- .../plantuml/project3/TaskDrawRegular.java | 174 ++ .../plantuml/project3/TaskDrawSeparator.java | 128 ++ .../plantuml/project3/TaskImpl.java | 97 +- .../plantuml/project3/TaskSeparator.java | 99 + .../plantuml/project3/TimeScale.java | 2 + .../plantuml/project3/TimeScaleBasic.java | 4 + .../plantuml/project3/TimeScaleBasic2.java | 79 + .../project3/TimeScaleWithoutWeekEnd.java | 4 + .../plantuml/project3/VerbAre.java | 2 +- .../plantuml/project3/VerbHappens.java | 2 +- .../sourceforge/plantuml/project3/VerbIs.java | 73 + .../plantuml/project3/VerbIsOff.java | 74 + .../plantuml/project3/VerbLasts.java | 4 +- .../sourceforge/plantuml/skin/rose/Rose.java | 4 +- .../plantuml/svek/ClusterDecoration.java | 2 +- .../plantuml/svek/image/EntityImageClass.java | 4 +- .../svek/image/EntityImageDescription.java | 5 +- .../plantuml/svek/image/EntityImageNote.java | 4 +- .../svek/image/EntityImageObject.java | 4 +- .../plantuml/svek/image/Footprint.java | 1 + .../plantuml/timingdiagram/Histogram.java | 23 +- .../plantuml/ugraphic/ImageBuilder.java | 4 +- .../plantuml/ugraphic/UHorizontalLine.java | 9 + .../sourceforge/plantuml/version/Version.java | 4 +- .../sourceforge/plantuml/webp/VP8Decoder.java | 21 +- 84 files changed, 3641 insertions(+), 1159 deletions(-) rename src/net/sourceforge/plantuml/{RoundParam.java => CornerParam.java} (88%) create mode 100644 src/net/sourceforge/plantuml/ZSourceFileReader.java create mode 100644 src/net/sourceforge/plantuml/ZSourceFileReader2.java create mode 100644 src/net/sourceforge/plantuml/ZSourceFileReaderAbstract.java create mode 100644 src/net/sourceforge/plantuml/project3/CommandGanttArrow2.java create mode 100644 src/net/sourceforge/plantuml/project3/CommandPage.java create mode 100644 src/net/sourceforge/plantuml/project3/CommandSeparator.java create mode 100644 src/net/sourceforge/plantuml/project3/ComplementDates.java create mode 100644 src/net/sourceforge/plantuml/project3/ConstantPlan.java create mode 100644 src/net/sourceforge/plantuml/project3/DaysAsDates.java rename src/net/sourceforge/plantuml/project3/{DurationDay.java => Load.java} (84%) create mode 100644 src/net/sourceforge/plantuml/project3/LoadInDays.java rename src/net/sourceforge/plantuml/project3/{Duration.java => LoadPlanable.java} (94%) create mode 100644 src/net/sourceforge/plantuml/project3/PlanUtils.java create mode 100644 src/net/sourceforge/plantuml/project3/Resource.java create mode 100644 src/net/sourceforge/plantuml/project3/ResourceDraw.java create mode 100644 src/net/sourceforge/plantuml/project3/Resources.java create mode 100644 src/net/sourceforge/plantuml/project3/Solver2.java rename src/net/sourceforge/plantuml/project3/{Solver.java => Solver3.java} (73%) create mode 100644 src/net/sourceforge/plantuml/project3/SubjectDayAsDate.java create mode 100644 src/net/sourceforge/plantuml/project3/SubjectDaysAsDates.java create mode 100644 src/net/sourceforge/plantuml/project3/SubjectResource.java create mode 100644 src/net/sourceforge/plantuml/project3/TaskDrawRegular.java create mode 100644 src/net/sourceforge/plantuml/project3/TaskDrawSeparator.java create mode 100644 src/net/sourceforge/plantuml/project3/TaskSeparator.java create mode 100644 src/net/sourceforge/plantuml/project3/TimeScaleBasic2.java create mode 100644 src/net/sourceforge/plantuml/project3/VerbIs.java create mode 100644 src/net/sourceforge/plantuml/project3/VerbIsOff.java diff --git a/pom.xml b/pom.xml index 70f8eeec3..a6e030141 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ net.sourceforge.plantuml plantuml - 1.2018.3-SNAPSHOT + 1.2018.4-SNAPSHOT jar PlantUML diff --git a/src/net/sourceforge/plantuml/ColorParam.java b/src/net/sourceforge/plantuml/ColorParam.java index 608ff72f1..b7f80dc9b 100644 --- a/src/net/sourceforge/plantuml/ColorParam.java +++ b/src/net/sourceforge/plantuml/ColorParam.java @@ -139,6 +139,8 @@ public enum ColorParam { nodeBorder(HtmlColorUtils.BLACK, ColorType.LINE), rectangleBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), rectangleBorder(HtmlColorUtils.BLACK, ColorType.LINE), + cardBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), + cardBorder(HtmlColorUtils.BLACK, ColorType.LINE), agentBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), agentBorder(HtmlColorUtils.MY_RED, ColorType.LINE), storageBackground(HtmlColorUtils.MY_YELLOW, true, ColorType.BACK), diff --git a/src/net/sourceforge/plantuml/RoundParam.java b/src/net/sourceforge/plantuml/CornerParam.java similarity index 88% rename from src/net/sourceforge/plantuml/RoundParam.java rename to src/net/sourceforge/plantuml/CornerParam.java index e28cb4add..453acff19 100644 --- a/src/net/sourceforge/plantuml/RoundParam.java +++ b/src/net/sourceforge/plantuml/CornerParam.java @@ -35,14 +35,21 @@ */ package net.sourceforge.plantuml; -public enum RoundParam { +public enum CornerParam { DEFAULT, diagramBorder, titleBorder, rectangle, component; - public String getKey() { + public String getRoundKey() { if (this == DEFAULT) { return "roundcorner"; } return name() + "roundcorner"; } + public String getDiagonalKey() { + if (this == DEFAULT) { + return "diagonalcorner"; + } + return name() + "diagonalcorner"; + } + } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/Dimension2DDouble.java b/src/net/sourceforge/plantuml/Dimension2DDouble.java index 3f79d29d7..5b9c70609 100644 --- a/src/net/sourceforge/plantuml/Dimension2DDouble.java +++ b/src/net/sourceforge/plantuml/Dimension2DDouble.java @@ -45,6 +45,9 @@ public class Dimension2DDouble extends Dimension2D { final private double height; public Dimension2DDouble(double width, double height) { + if (Double.isNaN(width) || Double.isNaN(height)) { + throw new IllegalArgumentException(); + } this.width = width; this.height = height; } diff --git a/src/net/sourceforge/plantuml/FontParam.java b/src/net/sourceforge/plantuml/FontParam.java index 2fdf0c280..ac5712f1d 100644 --- a/src/net/sourceforge/plantuml/FontParam.java +++ b/src/net/sourceforge/plantuml/FontParam.java @@ -76,6 +76,7 @@ public enum FontParam { ENTITY(14, Font.PLAIN), // AGENT(14, Font.PLAIN), // RECTANGLE(14, Font.PLAIN), // + CARD(14, Font.PLAIN), // NODE(14, Font.PLAIN), // DATABASE(14, Font.PLAIN), // QUEUE(14, Font.PLAIN), // @@ -107,6 +108,7 @@ public enum FontParam { ENTITY_STEREOTYPE(14, Font.ITALIC), // AGENT_STEREOTYPE(14, Font.ITALIC), // RECTANGLE_STEREOTYPE(14, Font.ITALIC), // + CARD_STEREOTYPE(14, Font.ITALIC), // NODE_STEREOTYPE(14, Font.ITALIC), // FOLDER_STEREOTYPE(14, Font.ITALIC), // FILE_STEREOTYPE(14, Font.ITALIC), // diff --git a/src/net/sourceforge/plantuml/ISkinParam.java b/src/net/sourceforge/plantuml/ISkinParam.java index f463186c1..8314e44be 100644 --- a/src/net/sourceforge/plantuml/ISkinParam.java +++ b/src/net/sourceforge/plantuml/ISkinParam.java @@ -101,7 +101,9 @@ public interface ISkinParam extends ISkinSimple { public double getRanksep(); - public double getRoundCorner(RoundParam param, Stereotype stereotype); + public double getRoundCorner(CornerParam param, Stereotype stereotype); + + public double getDiagonalCorner(CornerParam param, Stereotype stereotype); public LineBreakStrategy maxMessageSize(); diff --git a/src/net/sourceforge/plantuml/PSystemUtils.java b/src/net/sourceforge/plantuml/PSystemUtils.java index ad8cc3f12..fbcf029d4 100644 --- a/src/net/sourceforge/plantuml/PSystemUtils.java +++ b/src/net/sourceforge/plantuml/PSystemUtils.java @@ -49,8 +49,10 @@ import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3; import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.cucadiagram.CucaDiagram; +import net.sourceforge.plantuml.graphic.HtmlColorUtils; import net.sourceforge.plantuml.html.CucaDiagramHtmlMaker; import net.sourceforge.plantuml.png.PngSplitter; +import net.sourceforge.plantuml.project3.GanttDiagram; import net.sourceforge.plantuml.sequencediagram.SequenceDiagram; public class PSystemUtils { @@ -66,6 +68,9 @@ public class PSystemUtils { if (system instanceof CucaDiagram) { return exportDiagramsCuca((CucaDiagram) system, suggestedFile, fileFormatOption); } + if (system instanceof GanttDiagram) { + return exportDiagramsGantt2((GanttDiagram) system, suggestedFile, fileFormatOption); + } if (system instanceof ActivityDiagram3) { return exportDiagramsActivityDiagram3((ActivityDiagram3) system, suggestedFile, fileFormatOption); } @@ -230,6 +235,62 @@ public class PSystemUtils { } + // static private List exportDiagramsGantt1(GanttDiagram system, SuggestedFile suggestedFile, + // FileFormatOption fileFormat) throws IOException { + // if (suggestedFile.getFile(0).exists() && suggestedFile.getFile(0).isDirectory()) { + // throw new IllegalArgumentException("File is a directory " + suggestedFile); + // } + // OutputStream os = null; + // ImageData imageData = null; + // try { + // if (PSystemUtils.canFileBeWritten(suggestedFile.getFile(0)) == false) { + // return Collections.emptyList(); + // } + // os = new BufferedOutputStream(new FileOutputStream(suggestedFile.getFile(0))); + // imageData = system.exportDiagram(os, 0, fileFormat); + // } finally { + // if (os != null) { + // os.close(); + // } + // } + // return Arrays.asList(new FileImageData(suggestedFile.getFile(0), imageData)); + // } + + static private List exportDiagramsGantt2(GanttDiagram system, SuggestedFile suggestedFile, + FileFormatOption fileFormat) throws IOException { + if (suggestedFile.getFile(0).exists() && suggestedFile.getFile(0).isDirectory()) { + throw new IllegalArgumentException("File is a directory " + suggestedFile); + } + + ImageData cmap = null; + OutputStream os = null; + try { + if (PSystemUtils.canFileBeWritten(suggestedFile.getFile(0)) == false) { + return Collections.emptyList(); + } + os = new NamedOutputStream(suggestedFile.getFile(0)); + cmap = system.exportDiagram(os, 0, fileFormat); + } finally { + if (os != null) { + os.close(); + } + } + List result = Arrays.asList(suggestedFile.getFile(0)); + + if (fileFormat.getFileFormat() == FileFormat.PNG) { + final SplitParam splitParam = new SplitParam(HtmlColorUtils.BLACK, null, 5); + result = new PngSplitter(suggestedFile, system.getHorizontalPages(), system.getVerticalPages(), + system.getMetadata(), system.getDpi(fileFormat), fileFormat.isWithMetadata(), splitParam) + .getFiles(); + } + final List result2 = new ArrayList(); + for (File f : result) { + result2.add(new FileImageData(f, cmap)); + } + return result2; + + } + private static List createFilesHtml(CucaDiagram system, SuggestedFile suggestedFile) throws IOException { final String name = suggestedFile.getName(); diff --git a/src/net/sourceforge/plantuml/SkinParam.java b/src/net/sourceforge/plantuml/SkinParam.java index d53b9a266..c9df5ab12 100644 --- a/src/net/sourceforge/plantuml/SkinParam.java +++ b/src/net/sourceforge/plantuml/SkinParam.java @@ -653,23 +653,39 @@ public class SkinParam implements ISkinParam { return 0; } - public double getRoundCorner(RoundParam param, Stereotype stereotype) { - Double result = getRoundCornerInternal(param, stereotype); + public double getDiagonalCorner(CornerParam param, Stereotype stereotype) { + final String key = param.getDiagonalKey(); + Double result = getCornerInternal(key, param, stereotype); if (result != null) { return result; } - result = getRoundCornerInternal(param, null); + result = getCornerInternal(key, param, null); if (result != null) { return result; } - if (param == RoundParam.DEFAULT) { + if (param == CornerParam.DEFAULT) { return 0; } - return getRoundCorner(RoundParam.DEFAULT, stereotype); + return getDiagonalCorner(CornerParam.DEFAULT, stereotype); } - private Double getRoundCornerInternal(RoundParam param, Stereotype stereotype) { - String key = param.getKey(); + public double getRoundCorner(CornerParam param, Stereotype stereotype) { + final String key = param.getRoundKey(); + Double result = getCornerInternal(key, param, stereotype); + if (result != null) { + return result; + } + result = getCornerInternal(key, param, null); + if (result != null) { + return result; + } + if (param == CornerParam.DEFAULT) { + return 0; + } + return getRoundCorner(CornerParam.DEFAULT, stereotype); + } + + private Double getCornerInternal(String key, CornerParam param, Stereotype stereotype) { if (stereotype != null) { key += stereotype.getLabel(false); } diff --git a/src/net/sourceforge/plantuml/SkinParamDelegator.java b/src/net/sourceforge/plantuml/SkinParamDelegator.java index dd8dc85d7..362f2b6f3 100644 --- a/src/net/sourceforge/plantuml/SkinParamDelegator.java +++ b/src/net/sourceforge/plantuml/SkinParamDelegator.java @@ -147,10 +147,14 @@ public class SkinParamDelegator implements ISkinParam { return skinParam.getRanksep(); } - public double getRoundCorner(RoundParam param, Stereotype stereotype) { + public double getRoundCorner(CornerParam param, Stereotype stereotype) { return skinParam.getRoundCorner(param, stereotype); } + public double getDiagonalCorner(CornerParam param, Stereotype stereotype) { + return skinParam.getDiagonalCorner(param, stereotype); + } + public UStroke getThickness(LineParam param, Stereotype stereotype) { return skinParam.getThickness(param, stereotype); } diff --git a/src/net/sourceforge/plantuml/ZSourceFileReader.java b/src/net/sourceforge/plantuml/ZSourceFileReader.java new file mode 100644 index 000000000..b10e088bf --- /dev/null +++ b/src/net/sourceforge/plantuml/ZSourceFileReader.java @@ -0,0 +1,162 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, 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.io.File; +import java.io.IOException; +import java.util.Collections; +import java.util.List; + +import net.sourceforge.plantuml.preproc.Defines; + +public class ZSourceFileReader extends ZSourceFileReaderAbstract implements ISourceFileReader { + + public ZSourceFileReader(File file) throws IOException { + this(file, file.getAbsoluteFile().getParentFile()); + } + + public ZSourceFileReader(File file, File outputDirectory, String charset) throws IOException { + this(Defines.createWithFileName(file), file, outputDirectory, Collections. emptyList(), charset, + new FileFormatOption(FileFormat.PNG)); + } + + public ZSourceFileReader(final File file, File outputDirectory) throws IOException { + this(Defines.createWithFileName(file), file, outputDirectory, Collections. emptyList(), null, + new FileFormatOption(FileFormat.PNG)); + } + + public ZSourceFileReader(final File file, File outputDirectory, FileFormatOption fileFormatOption) + throws IOException { + this(Defines.createWithFileName(file), file, outputDirectory, Collections. emptyList(), null, + fileFormatOption); + } + + public ZSourceFileReader(Defines defines, final File file, File outputDirectory, List config, + String charset, FileFormatOption fileFormatOption) throws IOException { + this.file = file; + this.fileFormatOption = fileFormatOption; + if (file.exists() == false) { + throw new IllegalArgumentException(); + } + FileSystem.getInstance().setCurrentDir(file.getAbsoluteFile().getParentFile()); + if (outputDirectory == null) { + outputDirectory = file.getAbsoluteFile().getParentFile(); + } else if (outputDirectory.isAbsolute() == false) { + outputDirectory = FileSystem.getInstance().getFile(outputDirectory.getPath()); + } + if (outputDirectory.exists() == false) { + outputDirectory.mkdirs(); + } + this.outputDirectory = outputDirectory; + + builder = new BlockUmlBuilder(config, charset, defines, getReader(charset), file.getAbsoluteFile() + .getParentFile(), file.getAbsolutePath()); + } + + private File getDirIfDirectory(String newName) { + Log.info("Checking=" + newName); + if (endsWithSlashOrAntislash(newName)) { + Log.info("It ends with / so it looks like a directory"); + newName = newName.substring(0, newName.length() - 1); + File f = new File(newName); + Log.info("f=" + f); + if (f.isAbsolute() == false) { + Log.info("It's relative, so let's change it"); + f = new File(outputDirectory, newName); + Log.info("f=" + f); + } + if (f.exists() == false) { + Log.info("It does not exist: let's create it"); + try { + f.mkdirs(); + } catch (Exception e) { + Log.info("Error " + e); + } + if (f.exists() && f.isDirectory()) { + Log.info("Creation ok"); + return f; + } + Log.info("We cannot create it"); + } else if (f.isDirectory() == false) { + Log.info("It exists, but is not a directory: we ignore it"); + return null; + } + return f; + + } + File f = new File(newName); + Log.info("f=" + f); + if (f.isAbsolute() == false) { + Log.info("Relative, so let's change it"); + f = new File(outputDirectory, newName); + Log.info("f=" + f); + } + if (f.exists() && f.isDirectory()) { + Log.info("It's an existing directory"); + return f; + } + Log.info("It's not a directory"); + return null; + + } + + @Override + protected SuggestedFile getSuggestedFile(BlockUml blockUml) { + final String newName = blockUml.getFileOrDirname(); + SuggestedFile suggested = null; + if (newName != null) { + Log.info("name from block=" + newName); + final File dir = getDirIfDirectory(newName); + if (dir == null) { + Log.info(newName + " is not taken as a directory"); + suggested = SuggestedFile.fromOutputFile(new File(outputDirectory, newName), + fileFormatOption.getFileFormat(), 0); + } else { + Log.info("We are going to create files in directory " + dir); + suggested = SuggestedFile.fromOutputFile(new File(dir, file.getName()), + fileFormatOption.getFileFormat(), 0); + } + Log.info("We are going to put data in " + suggested); + } + if (suggested == null) { + suggested = SuggestedFile.fromOutputFile(new File(outputDirectory, file.getName()), + fileFormatOption.getFileFormat(), cpt++); + } + suggested.getParentFile().mkdirs(); + return suggested; + } + +} diff --git a/src/net/sourceforge/plantuml/ZSourceFileReader2.java b/src/net/sourceforge/plantuml/ZSourceFileReader2.java new file mode 100644 index 000000000..e70780fff --- /dev/null +++ b/src/net/sourceforge/plantuml/ZSourceFileReader2.java @@ -0,0 +1,66 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, 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.io.File; +import java.io.IOException; +import java.util.List; + +import net.sourceforge.plantuml.preproc.Defines; + +public class ZSourceFileReader2 extends ZSourceFileReaderAbstract implements ISourceFileReader { + + public ZSourceFileReader2(Defines defines, final File file, File outputFile, List config, String charset, + FileFormatOption fileFormatOption) throws IOException { + this.file = file; + this.fileFormatOption = fileFormatOption; + this.outputFile = outputFile; + if (file.exists() == false) { + throw new IllegalArgumentException(); + } + FileSystem.getInstance().setCurrentDir(file.getAbsoluteFile().getParentFile()); + + builder = new BlockUmlBuilder(config, charset, defines, getReader(charset), file.getAbsoluteFile() + .getParentFile(), file.getAbsolutePath()); + } + + @Override + protected SuggestedFile getSuggestedFile(BlockUml blockUml) { + final SuggestedFile suggested = SuggestedFile.fromOutputFile(outputFile, fileFormatOption.getFileFormat()); + return suggested; + } + +} diff --git a/src/net/sourceforge/plantuml/ZSourceFileReaderAbstract.java b/src/net/sourceforge/plantuml/ZSourceFileReaderAbstract.java new file mode 100644 index 000000000..52eec6965 --- /dev/null +++ b/src/net/sourceforge/plantuml/ZSourceFileReaderAbstract.java @@ -0,0 +1,170 @@ +/* ======================================================================== + * PlantUML : a free UML diagram generator + * ======================================================================== + * + * (C) Copyright 2009-2017, 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.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.PrintStream; +import java.io.Reader; +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; + +import net.sourceforge.plantuml.core.Diagram; +import net.sourceforge.plantuml.preproc.FileWithSuffix; + +public abstract class ZSourceFileReaderAbstract { + + protected File file; + protected File outputDirectory; + protected File outputFile; + + protected BlockUmlBuilder builder; + protected FileFormatOption fileFormatOption; + + public boolean hasError() { + for (final BlockUml b : builder.getBlockUmls()) { + if (b.getDiagram() instanceof PSystemError) { + return true; + } + } + return false; + } + + public List getBlocks() { + return builder.getBlockUmls(); + } + + protected Reader getReader(String charset) throws FileNotFoundException, UnsupportedEncodingException { + if (charset == null) { + Log.info("Using default charset"); + return new InputStreamReader(new FileInputStream(file)); + } + Log.info("Using charset " + charset); + return new InputStreamReader(new FileInputStream(file), charset); + } + + public final Set getIncludedFiles() { + return builder.getIncludedFiles(); + } + + public final void setFileFormatOption(FileFormatOption fileFormatOption) { + this.fileFormatOption = fileFormatOption; + } + + protected boolean endsWithSlashOrAntislash(String newName) { + return newName.endsWith("/") || newName.endsWith("\\"); + } + + protected List getCrashedImage(BlockUml blockUml, Throwable t, File outputFile) throws IOException { + final GeneratedImage image = new GeneratedImageImpl(outputFile, "Crash Error", blockUml); + OutputStream os = null; + try { + os = new BufferedOutputStream(new FileOutputStream(outputFile)); + UmlDiagram.exportDiagramError(os, t, fileFormatOption, 42, null, blockUml.getFlashData(), + UmlDiagram.getFailureText2(t, blockUml.getFlashData())); + } finally { + if (os != null) { + os.close(); + } + } + + return Collections.singletonList(image); + } + + protected void exportWarnOrErrIfWord(final File f, final Diagram system) throws FileNotFoundException { + if (OptionFlags.getInstance().isWord()) { + final String warnOrError = system.getWarningOrError(); + if (warnOrError != null) { + final String name = f.getName().substring(0, f.getName().length() - 4) + ".err"; + final File errorFile = new File(f.getParentFile(), name); + final PrintStream ps = new PrintStream(new FileOutputStream(errorFile)); + ps.print(warnOrError); + ps.close(); + } + } + } + + protected int cpt; + + final public List getGeneratedImages() throws IOException { + Log.info("Reading file: " + file); + + cpt = 0; + final List result = new ArrayList(); + + for (BlockUml blockUml : builder.getBlockUmls()) { + SuggestedFile suggested = getSuggestedFile(blockUml); + + final Diagram system; + try { + system = blockUml.getDiagram(); + } catch (Throwable t) { + return getCrashedImage(blockUml, t, suggested.getFile(0)); + } + + OptionFlags.getInstance().logData(file, system); + final List exportDiagrams = PSystemUtils.exportDiagrams(system, suggested, fileFormatOption); + if (exportDiagrams.size() > 1) { + cpt += exportDiagrams.size() - 1; + } + + for (FileImageData fdata : exportDiagrams) { + final String desc = "[" + file.getName() + "] " + system.getDescription(); + final File f = fdata.getFile(); + exportWarnOrErrIfWord(f, system); + final GeneratedImage generatedImage = new GeneratedImageImpl(f, desc, blockUml); + result.add(generatedImage); + } + + } + + Log.info("Number of image(s): " + result.size()); + + return Collections.unmodifiableList(result); + } + + abstract protected SuggestedFile getSuggestedFile(BlockUml blockUml); + +} diff --git a/src/net/sourceforge/plantuml/cucadiagram/Bodier.java b/src/net/sourceforge/plantuml/cucadiagram/Bodier.java index 6678384fa..bbe69e67d 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Bodier.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Bodier.java @@ -71,6 +71,14 @@ public class Bodier { this.manageModifier = type == null ? false : type.manageModifier(); } + public void setLeaf(ILeaf leaf) { + if (leaf == null) { + throw new IllegalArgumentException(); + } + this.leaf = leaf; + + } + public void addFieldOrMethod(String s, IEntity leaf) { if (leaf == null) { throw new IllegalArgumentException(); @@ -196,6 +204,9 @@ public class Bodier { } return null; } + if (leaf == null) { + throw new IllegalStateException(); + } final MethodsOrFieldsArea fields = new MethodsOrFieldsArea(getFieldsToDisplay(), fontParam, skinParam, stereotype, leaf); if (type == LeafType.OBJECT) { diff --git a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java index 2b4369ac3..8258c70ce 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java +++ b/src/net/sourceforge/plantuml/cucadiagram/BodyEnhanced.java @@ -77,6 +77,7 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo private final List urls = new ArrayList(); private final Stereotype stereotype; private final ILeaf entity; + private final boolean inEllipse; public BodyEnhanced(List rawBody, FontParam fontParam, ISkinParam skinParam, boolean manageModifier, Stereotype stereotype, ILeaf entity) { @@ -91,6 +92,7 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo this.manageHorizontalLine = true; this.manageModifier = manageModifier; this.entity = entity; + this.inEllipse = false; } public BodyEnhanced(Display display, FontParam fontParam, ISkinParam skinParam, HorizontalAlignment align, @@ -98,9 +100,6 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo this.entity = entity; this.stereotype = stereotype; this.rawBody = new ArrayList(); - for (CharSequence s : display) { - this.rawBody.add(s.toString()); - } this.fontParam = fontParam; this.skinParam = skinParam; @@ -109,6 +108,14 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo this.align = skinParam.getDefaultTextAlignment(align); this.manageHorizontalLine = manageHorizontalLine; this.manageModifier = manageModifier; + this.inEllipse = fontParam == FontParam.USECASE; + + if (manageHorizontalLine && inEllipse && display.size() > 0 && isBlockSeparator(display.get(0).toString())) { + this.rawBody.add(""); + } + for (CharSequence s : display) { + this.rawBody.add(s.toString()); + } } @@ -166,6 +173,9 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo } } } + if (inEllipse && members.size() == 0) { + members.add(new MemberImpl("", false, false)); + } blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam, align, stereotype, entity), separator, title)); diff --git a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java b/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java index 4fb79fbea..6a6ce3cdb 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java +++ b/src/net/sourceforge/plantuml/cucadiagram/CucaDiagram.java @@ -289,6 +289,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, this.horizontalPages = horizontalPages; } + final public int getVerticalPages() { return verticalPages; } @@ -296,6 +297,13 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, final public void setVerticalPages(int verticalPages) { this.verticalPages = verticalPages; } + + @Override + public int getNbImages() { + return this.horizontalPages * this.verticalPages; + } + + // final public List createPng2(File pngFile) throws IOException, // InterruptedException { @@ -569,11 +577,6 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy, } } - @Override - public int getNbImages() { - return this.horizontalPages * this.verticalPages; - } - public final Set getHides() { return Collections.unmodifiableSet(hides); } diff --git a/src/net/sourceforge/plantuml/cucadiagram/Link.java b/src/net/sourceforge/plantuml/cucadiagram/Link.java index e3078ea09..a4d92f67d 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/Link.java +++ b/src/net/sourceforge/plantuml/cucadiagram/Link.java @@ -160,9 +160,10 @@ public class Link implements Hideable, Removeable { // } final Link result = new Link(cl2, cl1, getType().getInversed(), label, length, qualifier2, qualifier1, labeldistance, labelangle, specificColor); - result.inverted = true; + result.inverted = !this.inverted; result.port1 = this.port2; result.port2 = this.port1; + result.url = this.url; return result; } diff --git a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java index 2990db5ea..99d6d28f8 100644 --- a/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java +++ b/src/net/sourceforge/plantuml/cucadiagram/entity/EntityFactory.java @@ -99,6 +99,7 @@ public class EntityFactory { final LongCode longCode = getLongCode(code, namespaceSeparator); final EntityImpl result = new EntityImpl(this, code, bodier, parentContainer, entityType, longCode, namespaceSeparator, rawLayout); + bodier.setLeaf(result); result.setDisplay(display); return result; } diff --git a/src/net/sourceforge/plantuml/dedication/Dedication.java b/src/net/sourceforge/plantuml/dedication/Dedication.java index 1888f8551..01685eb3a 100644 --- a/src/net/sourceforge/plantuml/dedication/Dedication.java +++ b/src/net/sourceforge/plantuml/dedication/Dedication.java @@ -40,13 +40,12 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; +import java.lang.reflect.Method; import java.math.BigInteger; import javax.imageio.ImageIO; import javax.imageio.stream.ImageInputStream; -import net.sourceforge.plantuml.webp.VP8Decoder; - public class Dedication { private final String name; @@ -73,13 +72,21 @@ public class Dedication { public BufferedImage getBufferedImage(String keepLetter) { try { + final Class clVP8Decoder = Class.forName("net.sourceforge.plantuml.webp.VP8Decoder"); + final Object vp8Decoder = clVP8Decoder.newInstance(); + // final VP8Decoder vp8Decoder = new VP8Decoder(); + final Method decodeFrame = clVP8Decoder.getMethod("decodeFrame", ImageInputStream.class); final InputStream is = getInputStream(keepLetter); final ImageInputStream iis = ImageIO.createImageInputStream(is); - final VP8Decoder vp8Decoder = new VP8Decoder(); - vp8Decoder.decodeFrame(iis, false); + decodeFrame.invoke(vp8Decoder, iis); + // vp8Decoder.decodeFrame(iis); iis.close(); - return vp8Decoder.getFrame().getBufferedImage(); + final Object frame = clVP8Decoder.getMethod("getFrame").invoke(vp8Decoder); + return (BufferedImage) frame.getClass().getMethod("getBufferedImage").invoke(frame); + // final VP8Frame frame = vp8Decoder.getFrame(); + // return frame.getBufferedImage(); } catch (Exception e) { + e.printStackTrace(); return null; } } diff --git a/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java b/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java index 956fa43a2..c95624486 100644 --- a/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java +++ b/src/net/sourceforge/plantuml/descdiagram/command/CommandLinkElement.java @@ -52,6 +52,7 @@ import net.sourceforge.plantuml.cucadiagram.IEntity; import net.sourceforge.plantuml.cucadiagram.ILeaf; import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.Link; +import net.sourceforge.plantuml.cucadiagram.LinkArrow; import net.sourceforge.plantuml.cucadiagram.LinkDecor; import net.sourceforge.plantuml.cucadiagram.LinkType; import net.sourceforge.plantuml.cucadiagram.Stereotype; @@ -209,6 +210,7 @@ public class CommandLinkElement extends SingleLineCommand2 { private String firstLabel; private String secondLabel; private String labelLink; + private LinkArrow linkArrow = LinkArrow.NONE; Labels(RegexResult arg) { firstLabel = arg.get("LABEL1", 0); @@ -220,6 +222,27 @@ public class CommandLinkElement extends SingleLineCommand2 { init(); } labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(labelLink); + + if ("<".equals(labelLink)) { + linkArrow = LinkArrow.BACKWARD; + labelLink = null; + } else if (">".equals(labelLink)) { + linkArrow = LinkArrow.DIRECT_NORMAL; + labelLink = null; + } else if (labelLink != null && labelLink.startsWith("< ")) { + linkArrow = LinkArrow.BACKWARD; + labelLink = StringUtils.trin(labelLink.substring(2)); + } else if (labelLink != null && labelLink.startsWith("> ")) { + linkArrow = LinkArrow.DIRECT_NORMAL; + labelLink = StringUtils.trin(labelLink.substring(2)); + } else if (labelLink != null && labelLink.endsWith(" >")) { + linkArrow = LinkArrow.DIRECT_NORMAL; + labelLink = StringUtils.trin(labelLink.substring(0, labelLink.length() - 2)); + } else if (labelLink != null && labelLink.endsWith(" <")) { + linkArrow = LinkArrow.BACKWARD; + labelLink = StringUtils.trin(labelLink.substring(0, labelLink.length() - 2)); + } + } } @@ -289,7 +312,7 @@ public class CommandLinkElement extends SingleLineCommand2 { Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(labels.labelLink), queue.length(), labels.firstLabel, labels.secondLabel, diagram.getLabeldistance(), diagram.getLabelangle()); - + link.setLinkArrow(labels.linkArrow); if (dir == Direction.LEFT || dir == Direction.UP) { link = link.getInv(); } diff --git a/src/net/sourceforge/plantuml/eps/EpsGraphics.java b/src/net/sourceforge/plantuml/eps/EpsGraphics.java index bafd3acf9..cf9543249 100644 --- a/src/net/sourceforge/plantuml/eps/EpsGraphics.java +++ b/src/net/sourceforge/plantuml/eps/EpsGraphics.java @@ -364,6 +364,10 @@ public class EpsGraphics { appendColor(fillcolor); epsRectangleInternal(x, y, width, height, rx, ry, true); append("closepath eofill", true); + if (dashSpace != 0 && dashVisible != 0) { + append("[] 0 setdash", true); + } + } if (color != null) { @@ -371,6 +375,9 @@ public class EpsGraphics { appendColor(color); epsRectangleInternal(x, y, width, height, rx, ry, false); append("closepath stroke", true); + if (dashSpace != 0 && dashVisible != 0) { + append("[] 0 setdash", true); + } } } @@ -441,20 +448,26 @@ public class EpsGraphics { } private void roundRectangle(double x, double y, double width, double height, double rx, double ry) { + if (dashSpace != 0 && dashVisible != 0) { + append("[" + (int) dashSpace + " " + (int) dashVisible + "] 0 setdash", true); + } append(format(width) + " " + format(height) + " " + format(x) + " " + format(y) + " " + format((rx + ry) / 2) + " roundrect", true); roundrectUsed = true; } private void simpleRectangle(double x, double y, double width, double height, boolean fill) { + if (dashSpace != 0 && dashVisible != 0) { + append("[" + (int) dashSpace + " " + (int) dashVisible + "] 0 setdash", true); + } if ((dashSpace == 0 && dashVisible == 0) || fill) { append(format(width) + " " + format(height) + " " + format(x) + " " + format(y) + " simplerect", true); simplerectUsed = true; - } else { - epsVLine(y, x, x + width); - epsVLine(y + height, x, x + width); - epsHLine(x, y, y + height); - epsHLine(x + width, y, y + height); + // } else { + // epsVLine(y, x, x + width); + // epsVLine(y + height, x, x + width); + // epsHLine(x, y, y + height); + // epsHLine(x + width, y, y + height); } } diff --git a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java index 4a88a9c36..a335490c2 100644 --- a/src/net/sourceforge/plantuml/graphic/QuoteUtils.java +++ b/src/net/sourceforge/plantuml/graphic/QuoteUtils.java @@ -177,7 +177,6 @@ public class QuoteUtils { "Fbzrgvzrf jr pbzr ynfg ohg jr qvq bhe orfg", "Vs lbh frr fbzrguvat, fnl fbzrguvat", "Va gurbel gurer vf ab qvssrerapr orgjrra gurbel naq cenpgvpr. Ohg, va cenpgvpr, gurer vf.", - "Qnlyvtug, V zhfg jnvg sbe gur fhaevfr. V zhfg guvax bs n arj yvsr. Naq V zhfga'g tvir va.", "Vs V pnaabg oevat lbh pbzsbeg gura ng yrnfg V oevat lbh ubcr", "Jr nyy zhfg yrnea sebz fznyy zvfsbeghar, pbhag gur oyrffvatf gung ner erny", "Cercner Guerr Frnyrq Rairybcrf...", @@ -254,7 +253,11 @@ public class QuoteUtils { "Nyy lbhe onfr ner orybat gb hf", "Znqr ba Rnegu ol uhznaf", "Jvaaref Qba'g Hfr Qehtf", "Lbh xabj jung fhecevfrq zr gur zbfg? Vg jnfa'g zrrgvat gurz. Vg jnf zrrgvat lbh.", "Va jne gurer ner ab jvaaref, bayl jvqbjf", - "Vs lbh guvax guvf Havirefr vf onq, lbh fubhyq frr fbzr bs gur bguref"); + "Vs lbh guvax guvf Havirefr vf onq, lbh fubhyq frr fbzr bs gur bguref", "Cnp-Zna'f n onq thl?", + "Zl ernyvgl vf whfg qvssrerag guna lbhef", + "Uvfgbel vf n avtugzner sebz juvpu V nz gelvat gb njnxr", + "L'ra n dh'bag rffnlr, vyf bag rh qrf ceboyrzrf", + "Gb ree vf uhzna, ohg gb ernyyl sbhy guvatf hc erdhverf n pbzchgre."); private QuoteUtils() { } diff --git a/src/net/sourceforge/plantuml/graphic/SkinParameter.java b/src/net/sourceforge/plantuml/graphic/SkinParameter.java index 249972ffe..421f799ad 100644 --- a/src/net/sourceforge/plantuml/graphic/SkinParameter.java +++ b/src/net/sourceforge/plantuml/graphic/SkinParameter.java @@ -39,7 +39,7 @@ import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineParam; -import net.sourceforge.plantuml.RoundParam; +import net.sourceforge.plantuml.CornerParam; import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.svek.RoundedContainer; import net.sourceforge.plantuml.ugraphic.UStroke; @@ -54,7 +54,7 @@ public class SkinParameter { public static final SkinParameter COMPONENT1 = new SkinParameter("COMPONENT1", ColorParam.componentBackground, ColorParam.componentBorder, FontParam.COMPONENT, FontParam.COMPONENT_STEREOTYPE, LineParam.componentBorder, - RoundParam.component); + CornerParam.component); public static final SkinParameter NODE = new SkinParameter("NODE", ColorParam.nodeBackground, ColorParam.nodeBorder, FontParam.NODE, FontParam.NODE_STEREOTYPE); @@ -76,7 +76,7 @@ public class SkinParameter { public static final SkinParameter COMPONENT2 = new SkinParameter("COMPONENT2", ColorParam.componentBackground, ColorParam.componentBorder, FontParam.COMPONENT, FontParam.COMPONENT_STEREOTYPE, LineParam.componentBorder, - RoundParam.component); + CornerParam.component); public static final SkinParameter AGENT = new SkinParameter("AGENT", ColorParam.agentBackground, ColorParam.agentBorder, FontParam.AGENT, FontParam.AGENT_STEREOTYPE); @@ -90,12 +90,12 @@ public class SkinParameter { public static final SkinParameter PACKAGE = new SkinParameter("PACKAGE", ColorParam.packageBackground, ColorParam.packageBorder, FontParam.FOLDER, FontParam.FOLDER_STEREOTYPE); - public static final SkinParameter CARD = new SkinParameter("CARD", ColorParam.rectangleBackground, - ColorParam.rectangleBorder, FontParam.RECTANGLE, FontParam.RECTANGLE_STEREOTYPE); + public static final SkinParameter CARD = new SkinParameter("CARD", ColorParam.cardBackground, + ColorParam.cardBorder, FontParam.CARD, FontParam.CARD_STEREOTYPE); public static final SkinParameter RECTANGLE = new SkinParameter("RECTANGLE", ColorParam.rectangleBackground, ColorParam.rectangleBorder, FontParam.RECTANGLE, FontParam.RECTANGLE_STEREOTYPE, LineParam.rectangleBorder, - RoundParam.rectangle); + CornerParam.rectangle); public static final SkinParameter COLLECTIONS = new SkinParameter("COLLECTIONS", ColorParam.collectionsBackground, ColorParam.collectionsBorder, FontParam.RECTANGLE, FontParam.RECTANGLE_STEREOTYPE); @@ -124,10 +124,10 @@ public class SkinParameter { private final FontParam fontParamStereotype; private final String name; private final LineParam lineParam; - private final RoundParam roundParam; + private final CornerParam roundParam; private SkinParameter(String name, ColorParam colorParamBack, ColorParam colorParamBorder, FontParam fontParam, - FontParam fontParamStereotype, LineParam lineParam, RoundParam roundParam) { + FontParam fontParamStereotype, LineParam lineParam, CornerParam roundParam) { this.name = name; this.colorParamBack = colorParamBack; this.colorParamBorder = colorParamBorder; @@ -139,7 +139,7 @@ public class SkinParameter { private SkinParameter(String name, ColorParam colorParamBack, ColorParam colorParamBorder, FontParam fontParam, FontParam fontParamStereotype) { - this(name, colorParamBack, colorParamBorder, fontParam, fontParamStereotype, null, RoundParam.DEFAULT); + this(name, colorParamBack, colorParamBorder, fontParam, fontParamStereotype, null, CornerParam.DEFAULT); } public String getUpperCaseName() { @@ -169,6 +169,10 @@ public class SkinParameter { return skinParam.getRoundCorner(roundParam, stereotype); } + public double getDiagonalCorner(ISkinParam skinParam, Stereotype stereotype) { + return skinParam.getDiagonalCorner(roundParam, stereotype); + } + public UStroke getStroke(ISkinParam skinParam, Stereotype stereotype) { UStroke result = null; if (lineParam != null) { diff --git a/src/net/sourceforge/plantuml/graphic/SymbolContext.java b/src/net/sourceforge/plantuml/graphic/SymbolContext.java index 5eb046737..b6e0c1e83 100644 --- a/src/net/sourceforge/plantuml/graphic/SymbolContext.java +++ b/src/net/sourceforge/plantuml/graphic/SymbolContext.java @@ -48,18 +48,17 @@ public class SymbolContext { private final boolean shadowing; private final double deltaShadow; private final double roundCorner; + private final double diagonalCorner; private SymbolContext(HtmlColor backColor, HtmlColor foreColor, UStroke stroke, boolean shadowing, - double deltaShadow, double roundCorner) { + double deltaShadow, double roundCorner, double diagonalCorner) { this.backColor = backColor; this.foreColor = foreColor; this.stroke = stroke; this.shadowing = shadowing; this.deltaShadow = deltaShadow; this.roundCorner = roundCorner; - // if (backColor instanceof HtmlColorTransparent) { - // throw new UnsupportedOperationException(); - // } + this.diagonalCorner = diagonalCorner; } @Override @@ -85,37 +84,37 @@ public class SymbolContext { public SymbolContext transparentBackColorToNull() { if (backColor instanceof HtmlColorTransparent) { - return new SymbolContext(null, foreColor, stroke, shadowing, deltaShadow, roundCorner); + return new SymbolContext(null, foreColor, stroke, shadowing, deltaShadow, roundCorner, diagonalCorner); } return this; } public SymbolContext(HtmlColor backColor, HtmlColor foreColor) { - this(backColor, foreColor, new UStroke(), false, 0, 0); + this(backColor, foreColor, new UStroke(), false, 0, 0, 0); } public SymbolContext withShadow(boolean newShadow) { - return new SymbolContext(backColor, foreColor, stroke, newShadow, deltaShadow, roundCorner); + return new SymbolContext(backColor, foreColor, stroke, newShadow, deltaShadow, roundCorner, diagonalCorner); } public SymbolContext withDeltaShadow(double deltaShadow) { - return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow, roundCorner); + return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow, roundCorner, diagonalCorner); } public SymbolContext withStroke(UStroke newStroke) { - return new SymbolContext(backColor, foreColor, newStroke, shadowing, deltaShadow, roundCorner); + return new SymbolContext(backColor, foreColor, newStroke, shadowing, deltaShadow, roundCorner, diagonalCorner); } public SymbolContext withBackColor(HtmlColor backColor) { - return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow, roundCorner); + return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow, roundCorner, diagonalCorner); } public SymbolContext withForeColor(HtmlColor foreColor) { - return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow, roundCorner); + return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow, roundCorner, diagonalCorner); } - public SymbolContext withRoundCorner(double roundCorner) { - return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow, roundCorner); + public SymbolContext withCorner(double roundCorner, double diagonalCorner) { + return new SymbolContext(backColor, foreColor, stroke, shadowing, deltaShadow, roundCorner, diagonalCorner); } public HtmlColor getBackColor() { @@ -142,4 +141,8 @@ public class SymbolContext { return roundCorner; } + public double getDiagonalCorner() { + return diagonalCorner; + } + } \ No newline at end of file diff --git a/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java b/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java index d5e3d0a5b..c6fd38849 100644 --- a/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java +++ b/src/net/sourceforge/plantuml/graphic/TextBlockUtils.java @@ -49,7 +49,7 @@ import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.LineParam; -import net.sourceforge.plantuml.RoundParam; +import net.sourceforge.plantuml.CornerParam; import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.posimo.Positionable; import net.sourceforge.plantuml.posimo.PositionableImpl; @@ -82,7 +82,7 @@ public class TextBlockUtils { if (borderColor == null) { borderColor = HtmlColorUtils.BLACK; } - final double corner = skinParam.getRoundCorner(RoundParam.titleBorder, null); + final double corner = skinParam.getRoundCorner(CornerParam.titleBorder, null); return withMargin(bordered(result, stroke, borderColor, backgroundColor, corner), 2, 2); } diff --git a/src/net/sourceforge/plantuml/graphic/USymbolRect.java b/src/net/sourceforge/plantuml/graphic/USymbolRect.java index 9baeee428..55d03c418 100644 --- a/src/net/sourceforge/plantuml/graphic/USymbolRect.java +++ b/src/net/sourceforge/plantuml/graphic/USymbolRect.java @@ -38,8 +38,10 @@ package net.sourceforge.plantuml.graphic; import java.awt.geom.Dimension2D; import net.sourceforge.plantuml.Dimension2DDouble; +import net.sourceforge.plantuml.ugraphic.Shadowable; import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphicStencil; +import net.sourceforge.plantuml.ugraphic.UPath; import net.sourceforge.plantuml.ugraphic.URectangle; import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UTranslate; @@ -64,14 +66,30 @@ class USymbolRect extends USymbol { return skinParameter; } - private void drawRect(UGraphic ug, double width, double height, boolean shadowing, double roundCorner) { - final URectangle shape = new URectangle(width, height, roundCorner, roundCorner); + private void drawRect(UGraphic ug, double width, double height, boolean shadowing, double roundCorner, + double diagonalCorner) { + final Shadowable shape = diagonalCorner > 0 ? getDiagonalShape(width, height, diagonalCorner) : new URectangle( + width, height, roundCorner, roundCorner); if (shadowing) { shape.setDeltaShadow(3.0); } ug.draw(shape); } + private Shadowable getDiagonalShape(double width, double height, double diagonalCorner) { + final UPath result = new UPath(); + result.moveTo(diagonalCorner, 0); + result.lineTo(width - diagonalCorner, 0); + result.lineTo(width, diagonalCorner); + result.lineTo(width, height - diagonalCorner); + result.lineTo(width - diagonalCorner, height); + result.lineTo(diagonalCorner, height); + result.lineTo(0, height - diagonalCorner); + result.lineTo(0, diagonalCorner); + result.lineTo(diagonalCorner, 0); + return result; + } + private Margin getMargin() { return new Margin(10, 10, 10, 10); } @@ -86,7 +104,7 @@ class USymbolRect extends USymbol { ug = UGraphicStencil.create(ug, getRectangleStencil(dim), new UStroke()); ug = symbolContext.apply(ug); drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing(), - symbolContext.getRoundCorner()); + symbolContext.getRoundCorner(), symbolContext.getDiagonalCorner()); final Margin margin = getMargin(); final TextBlock tb = TextBlockUtils.mergeTB(stereotype, label, stereotypeAlignement); tb.drawU(ug.apply(new UTranslate(margin.getX1(), margin.getY1()))); @@ -108,7 +126,7 @@ class USymbolRect extends USymbol { final Dimension2D dim = calculateDimension(ug.getStringBounder()); ug = symbolContext.apply(ug); drawRect(ug, dim.getWidth(), dim.getHeight(), symbolContext.isShadowing(), - symbolContext.getRoundCorner()); + symbolContext.getRoundCorner(), 0); final Dimension2D dimStereo = stereotype.calculateDimension(ug.getStringBounder()); final double posStereoX; final double posStereoY; diff --git a/src/net/sourceforge/plantuml/jasic/Jasic.java b/src/net/sourceforge/plantuml/jasic/Jasic.java index 9b96c86da..d16d4fec7 100644 --- a/src/net/sourceforge/plantuml/jasic/Jasic.java +++ b/src/net/sourceforge/plantuml/jasic/Jasic.java @@ -1,6 +1,5 @@ package net.sourceforge.plantuml.jasic; - import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; @@ -12,880 +11,861 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -/** - * This defines a single class that contains an entire interpreter for a - * language very similar to the original BASIC. Everything is here (albeit in - * very simplified form): tokenizing, parsing, and interpretation. The file is - * organized in phases, with each appearing roughly in the order that they - * occur when a program is run. You should be able to read this top-down to walk - * through the entire process of loading and running a program. +/* + Jasic uses the MIT License: + + Copyright (c) 2010 Robert Nystrom + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ +/* + * This defines a single class that contains an entire interpreter for a language very similar to the original BASIC. + * Everything is here (albeit in very simplified form): tokenizing, parsing, and interpretation. The file is organized + * in phases, with each appearing roughly in the order that they occur when a program is run. You should be able to read + * this top-down to walk through the entire process of loading and running a program. * - * Jasic language syntax - * --------------------- + * Jasic language syntax --------------------- * * Comments start with ' and proceed to the end of the line: * - * print "hi there" ' this is a comment + * print "hi there" ' this is a comment * - * Numbers and strings are supported. Strings should be in "double quotes", and - * only positive integers can be parsed (though numbers are double internally). + * Numbers and strings are supported. Strings should be in "double quotes", and only positive integers can be parsed + * (though numbers are double internally). * - * Variables are identified by name which must start with a letter and can - * contain letters or numbers. Case is significant for names and keywords. + * Variables are identified by name which must start with a letter and can contain letters or numbers. Case is + * significant for names and keywords. * - * Each statement is on its own line. Optionally, a line may have a label before - * the statement. A label is a name that ends with a colon: + * Each statement is on its own line. Optionally, a line may have a label before the statement. A label is a name that + * ends with a colon: * - * foo: + * foo: * * * The following statements are supported: * - * = - * Evaluates the expression and assigns the result to the given named - * variable. All variables are globally scoped. - * - * pi = (314159 / 10000) - * - * print - * Evaluates the expression and prints the result. + * = Evaluates the expression and assigns the result to the given named variable. All variables are + * globally scoped. * - * print "hello, " + "world" + * pi = (314159 / 10000) * - * input - * Reads in a line of input from the user and stores it in the variable with - * the given name. - * - * input guess - * - * goto