mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-24 05:47:33 +00:00
version 1.2018.7
This commit is contained in:
parent
55390ef1d1
commit
84e117e287
5
pom.xml
5
pom.xml
@ -30,13 +30,12 @@
|
|||||||
Script Author: Julien Eluard
|
Script Author: Julien Eluard
|
||||||
|
|
||||||
-->
|
-->
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>net.sourceforge.plantuml</groupId>
|
<groupId>net.sourceforge.plantuml</groupId>
|
||||||
<artifactId>plantuml</artifactId>
|
<artifactId>plantuml</artifactId>
|
||||||
<version>1.2018.6-SNAPSHOT</version>
|
<version>1.2018.8-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>PlantUML</name>
|
<name>PlantUML</name>
|
||||||
|
@ -63,7 +63,7 @@ public final class BlockUmlBuilder implements DefinitionsContainer {
|
|||||||
Preprocessor includer = null;
|
Preprocessor includer = null;
|
||||||
this.defines = defines;
|
this.defines = defines;
|
||||||
try {
|
try {
|
||||||
reader2 = new UncommentReadLine(new ReadLineReader(reader, desc));
|
reader2 = new UncommentReadLine(ReadLineReader.create(reader, desc));
|
||||||
includer = new Preprocessor(config, reader2, charset, defines, newCurrentDir, this);
|
includer = new Preprocessor(config, reader2, charset, defines, newCurrentDir, this);
|
||||||
init(includer);
|
init(includer);
|
||||||
} finally {
|
} finally {
|
||||||
|
122
src/net/sourceforge/plantuml/ClipboardLoop.java
Normal file
122
src/net/sourceforge/plantuml/ClipboardLoop.java
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* 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.awt.Toolkit;
|
||||||
|
import java.awt.datatransfer.Clipboard;
|
||||||
|
import java.awt.datatransfer.DataFlavor;
|
||||||
|
import java.awt.datatransfer.Transferable;
|
||||||
|
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.core.DiagramDescription;
|
||||||
|
|
||||||
|
public class ClipboardLoop {
|
||||||
|
|
||||||
|
public static void runLoop() throws IOException, InterruptedException {
|
||||||
|
final ClipboardLoop clipboardLoop = new ClipboardLoop();
|
||||||
|
while (true) {
|
||||||
|
final String text = clipboardLoop.getClipboardText();
|
||||||
|
if (clipboardLoop.isTextOk(text)) {
|
||||||
|
clipboardLoop.runText(text);
|
||||||
|
}
|
||||||
|
Thread.sleep(10000L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void runOnce() throws IOException, InterruptedException {
|
||||||
|
final ClipboardLoop clipboardLoop = new ClipboardLoop();
|
||||||
|
final String text = clipboardLoop.getClipboardText();
|
||||||
|
if (clipboardLoop.isTextOk(text)) {
|
||||||
|
clipboardLoop.runText(text);
|
||||||
|
} else {
|
||||||
|
clipboardLoop.setClipboardImage(new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isTextOk(String text) {
|
||||||
|
if (text == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return text.startsWith("@start");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runText(String text) throws IOException, InterruptedException {
|
||||||
|
Log.info("Getting some text from clipboard");
|
||||||
|
final SourceStringReader source = new SourceStringReader(text);
|
||||||
|
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
final DiagramDescription desc = source.outputImage(baos);
|
||||||
|
if (desc == null) {
|
||||||
|
Log.info("No image generated");
|
||||||
|
} else {
|
||||||
|
Log.info("Image ok " + desc.getDescription());
|
||||||
|
final byte[] data = baos.toByteArray();
|
||||||
|
baos.close();
|
||||||
|
final ByteArrayInputStream bais = new ByteArrayInputStream(data);
|
||||||
|
final BufferedImage image = ImageIO.read(bais);
|
||||||
|
setClipboardImage(image);
|
||||||
|
bais.close();
|
||||||
|
Log.info("Image copied in clipboard");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getClipboardText() {
|
||||||
|
final Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
|
||||||
|
try {
|
||||||
|
if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
|
||||||
|
final String text = (String) t.getTransferData(DataFlavor.stringFlavor);
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
} catch (UnsupportedFlavorException e) {
|
||||||
|
Log.error(e.toString());
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.error(e.toString());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setClipboardImage(BufferedImage image) {
|
||||||
|
final Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||||
|
clipboard.setContents(new ImageSelection(image), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
64
src/net/sourceforge/plantuml/ImageSelection.java
Normal file
64
src/net/sourceforge/plantuml/ImageSelection.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* 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.awt.Image;
|
||||||
|
import java.awt.datatransfer.DataFlavor;
|
||||||
|
import java.awt.datatransfer.Transferable;
|
||||||
|
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ImageSelection implements Transferable {
|
||||||
|
|
||||||
|
private Image image;
|
||||||
|
|
||||||
|
public ImageSelection(Image image) {
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataFlavor[] getTransferDataFlavors() {
|
||||||
|
return new DataFlavor[] { DataFlavor.imageFlavor };
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDataFlavorSupported(DataFlavor flavor) {
|
||||||
|
return DataFlavor.imageFlavor.equals(flavor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -43,9 +43,6 @@ public class LineLocationImpl implements LineLocation {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
if (desc == null) {
|
|
||||||
return "[?] : " + position;
|
|
||||||
}
|
|
||||||
return desc + " : " + position;
|
return desc + " : " + position;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +51,9 @@ public class LineLocationImpl implements LineLocation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private LineLocationImpl(String desc, LineLocation parent, int position) {
|
private LineLocationImpl(String desc, LineLocation parent, int position) {
|
||||||
|
if (desc == null) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
|
@ -108,7 +108,13 @@ public class Option {
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < arg.length; i++) {
|
for (int i = 0; i < arg.length; i++) {
|
||||||
String s = arg[i];
|
String s = arg[i];
|
||||||
if (s.equalsIgnoreCase("-tsvg") || s.equalsIgnoreCase("-svg")) {
|
if (s.equalsIgnoreCase("-headless")) {
|
||||||
|
// Useless because done in Run.java
|
||||||
|
if (i != 0) {
|
||||||
|
Log.error("Warning: -headless flag must be the first one in the command line");
|
||||||
|
}
|
||||||
|
System.setProperty("java.awt.headless", "true");
|
||||||
|
} else if (s.equalsIgnoreCase("-tsvg") || s.equalsIgnoreCase("-svg")) {
|
||||||
setFileFormatOption(new FileFormatOption(FileFormat.SVG));
|
setFileFormatOption(new FileFormatOption(FileFormat.SVG));
|
||||||
} else if (s.equalsIgnoreCase("-tsvg:nornd") || s.equalsIgnoreCase("-svg:nornd")) {
|
} else if (s.equalsIgnoreCase("-tsvg:nornd") || s.equalsIgnoreCase("-svg:nornd")) {
|
||||||
setFileFormatOption(new FileFormatOption(FileFormat.SVG));
|
setFileFormatOption(new FileFormatOption(FileFormat.SVG));
|
||||||
@ -306,6 +312,12 @@ public class Option {
|
|||||||
OptionFlags.getInstance().setEnableStats(false);
|
OptionFlags.getInstance().setEnableStats(false);
|
||||||
} else if (s.equalsIgnoreCase("-extractstdlib")) {
|
} else if (s.equalsIgnoreCase("-extractstdlib")) {
|
||||||
OptionFlags.getInstance().setExtractStdLib(true);
|
OptionFlags.getInstance().setExtractStdLib(true);
|
||||||
|
} else if (s.equalsIgnoreCase("-stdlib")) {
|
||||||
|
OptionFlags.getInstance().setStdLib(true);
|
||||||
|
} else if (s.equalsIgnoreCase("-clipboard")) {
|
||||||
|
OptionFlags.getInstance().setClipboard(true);
|
||||||
|
} else if (s.equalsIgnoreCase("-clipboardloop")) {
|
||||||
|
OptionFlags.getInstance().setClipboardLoop(true);
|
||||||
} else if (s.equalsIgnoreCase("-htmlstats")) {
|
} else if (s.equalsIgnoreCase("-htmlstats")) {
|
||||||
StatsUtils.setHtmlStats(true);
|
StatsUtils.setHtmlStats(true);
|
||||||
} else if (s.equalsIgnoreCase("-xmlstats")) {
|
} else if (s.equalsIgnoreCase("-xmlstats")) {
|
||||||
|
@ -123,7 +123,10 @@ public class OptionFlags {
|
|||||||
private boolean loopStats;
|
private boolean loopStats;
|
||||||
private boolean overwrite;
|
private boolean overwrite;
|
||||||
private boolean enableStats = defaultForStats();
|
private boolean enableStats = defaultForStats();
|
||||||
|
private boolean stdLib;
|
||||||
private boolean extractStdLib;
|
private boolean extractStdLib;
|
||||||
|
private boolean clipboardLoop;
|
||||||
|
private boolean clipboard;
|
||||||
private String fileSeparator = "_";
|
private String fileSeparator = "_";
|
||||||
private long timeoutMs = 15 * 60 * 1000L; // 15 minutes
|
private long timeoutMs = 15 * 60 * 1000L; // 15 minutes
|
||||||
private File logData;
|
private File logData;
|
||||||
@ -339,7 +342,31 @@ public class OptionFlags {
|
|||||||
this.extractStdLib = extractStdLib;
|
this.extractStdLib = extractStdLib;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getExtractStdLib() {
|
public boolean isExtractStdLib() {
|
||||||
return extractStdLib;
|
return extractStdLib;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final boolean isClipboardLoop() {
|
||||||
|
return clipboardLoop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setClipboardLoop(boolean clipboardLoop) {
|
||||||
|
this.clipboardLoop = clipboardLoop;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean isClipboard() {
|
||||||
|
return clipboard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setClipboard(boolean clipboard) {
|
||||||
|
this.clipboard = clipboard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean isStdLib() {
|
||||||
|
return stdLib;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setStdLib(boolean stdLib) {
|
||||||
|
this.stdLib = stdLib;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,6 +142,7 @@ public class OptionPrint {
|
|||||||
System.out.println(" -splash\t\tTo display a splash screen with some progress bar");
|
System.out.println(" -splash\t\tTo display a splash screen with some progress bar");
|
||||||
System.out.println(" -progress\t\tTo display a textual progress bar in console");
|
System.out.println(" -progress\t\tTo display a textual progress bar in console");
|
||||||
System.out.println(" -pipeimageindex N\tTo generate the Nth image with pipe option");
|
System.out.println(" -pipeimageindex N\tTo generate the Nth image with pipe option");
|
||||||
|
System.out.println(" -stdlib\tTo print standart library info");
|
||||||
System.out.println(" -extractstdlib\tTo extract PlantUML Standard Library into stdlib folder");
|
System.out.println(" -extractstdlib\tTo extract PlantUML Standard Library into stdlib folder");
|
||||||
System.out.println(" -filename \"example.puml\"\tTo override %filename% variable");
|
System.out.println(" -filename \"example.puml\"\tTo override %filename% variable");
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
@ -206,22 +206,6 @@ public class PSystemError extends AbstractPSystem {
|
|||||||
result.add(" ");
|
result.add(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
// final int limit = 4;
|
|
||||||
// int start;
|
|
||||||
// final int skip = higherErrorPosition - limit + 1;
|
|
||||||
// if (skip <= 0) {
|
|
||||||
// start = 0;
|
|
||||||
// } else {
|
|
||||||
// if (skip == 1) {
|
|
||||||
// result.add("... (skipping 1 line) ...");
|
|
||||||
// } else {
|
|
||||||
// result.add("... (skipping " + skip + " lines) ...");
|
|
||||||
// }
|
|
||||||
// start = higherErrorPosition - limit + 1;
|
|
||||||
// }
|
|
||||||
// for (int i = start; i < higherErrorPosition; i++) {
|
|
||||||
// result.add(getSource().getLine(i));
|
|
||||||
// }
|
|
||||||
for (String s : getPartialCode()) {
|
for (String s : getPartialCode()) {
|
||||||
result.add(s);
|
result.add(s);
|
||||||
}
|
}
|
||||||
@ -288,11 +272,13 @@ public class PSystemError extends AbstractPSystem {
|
|||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<String>();
|
||||||
for (Iterator<CharSequence2> it = getSource().iterator2(); it.hasNext();) {
|
for (Iterator<CharSequence2> it = getSource().iterator2(); it.hasNext();) {
|
||||||
final CharSequence2 s = it.next();
|
final CharSequence2 s = it.next();
|
||||||
if (s.getLocation().compareTo(higherErrorPosition) < 0) {
|
result.add(s.toString());
|
||||||
result.add(s.toString());
|
if (s.getLocation().getDescription().equals(higherErrorPosition.getDescription())
|
||||||
|
&& s.getLocation().compareTo(higherErrorPosition) >= 0) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final int limit = 4;
|
final int limit = 5;
|
||||||
if (result.size() > limit) {
|
if (result.size() > limit) {
|
||||||
final int skip = result.size() - limit + 1;
|
final int skip = result.size() - limit + 1;
|
||||||
final String skipMessage;
|
final String skipMessage;
|
||||||
@ -314,30 +300,20 @@ public class PSystemError extends AbstractPSystem {
|
|||||||
htmlStrings.add("----");
|
htmlStrings.add("----");
|
||||||
}
|
}
|
||||||
|
|
||||||
// final int limit = 4;
|
final List<String> partialCode = getPartialCode();
|
||||||
// int start;
|
for (String s : partialCode) {
|
||||||
// final int skip = higherErrorPosition - limit + 1;
|
|
||||||
// if (skip <= 0) {
|
|
||||||
// start = 0;
|
|
||||||
// } else {
|
|
||||||
// if (skip == 1) {
|
|
||||||
// htmlStrings.add("... (skipping 1 line) ...");
|
|
||||||
// } else {
|
|
||||||
// htmlStrings.add("... (skipping " + skip + " lines) ...");
|
|
||||||
// }
|
|
||||||
// start = higherErrorPosition - limit + 1;
|
|
||||||
// }
|
|
||||||
// for (int i = start; i < higherErrorPosition; i++) {
|
|
||||||
// htmlStrings.add(StringUtils.hideComparatorCharacters(getSource().getLine(i)));
|
|
||||||
// }
|
|
||||||
for (String s : getPartialCode()) {
|
|
||||||
htmlStrings.add(StringUtils.hideComparatorCharacters(s));
|
htmlStrings.add(StringUtils.hideComparatorCharacters(s));
|
||||||
}
|
}
|
||||||
final String errorLine = getSource().getLine(higherErrorPosition);
|
if (partialCode.size() > 0) {
|
||||||
final String err = StringUtils.hideComparatorCharacters(errorLine);
|
final int idx = htmlStrings.size() - 1;
|
||||||
if (StringUtils.isNotEmpty(err)) {
|
final String last = htmlStrings.get(idx);
|
||||||
htmlStrings.add("<w:" + getRed(useRed) + ">" + err + "</w>");
|
htmlStrings.set(idx, "<w:" + getRed(useRed) + ">" + last + "</w>");
|
||||||
}
|
}
|
||||||
|
// final String errorLine = getSource().getLine(higherErrorPosition);
|
||||||
|
// final String err = StringUtils.hideComparatorCharacters(errorLine);
|
||||||
|
// if (StringUtils.isNotEmpty(err)) {
|
||||||
|
// htmlStrings.add("<w:" + getRed(useRed) + ">" + err + "</w>");
|
||||||
|
// }
|
||||||
final Collection<String> textErrors = new LinkedHashSet<String>();
|
final Collection<String> textErrors = new LinkedHashSet<String>();
|
||||||
for (ErrorUml er : printedErrors) {
|
for (ErrorUml er : printedErrors) {
|
||||||
textErrors.add(er.getError());
|
textErrors.add(er.getError());
|
||||||
@ -360,7 +336,7 @@ public class PSystemError extends AbstractPSystem {
|
|||||||
return htmlStrings;
|
return htmlStrings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getSuggest() {
|
private List<String> getSuggest() {
|
||||||
boolean suggested = false;
|
boolean suggested = false;
|
||||||
for (ErrorUml er : printedErrors) {
|
for (ErrorUml er : printedErrors) {
|
||||||
if (er.hasSuggest()) {
|
if (er.hasSuggest()) {
|
||||||
@ -391,16 +367,6 @@ public class PSystemError extends AbstractPSystem {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private int getHigherErrorPosition(ErrorUmlType type, List<ErrorUml> all) {
|
|
||||||
// int max = Integer.MIN_VALUE;
|
|
||||||
// for (ErrorUml error : getErrors(type, all)) {
|
|
||||||
// if (error.getPosition() > max) {
|
|
||||||
// max = error.getPosition();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return max;
|
|
||||||
// }
|
|
||||||
|
|
||||||
private LineLocation getHigherErrorPosition2(ErrorUmlType type, List<ErrorUml> all) {
|
private LineLocation getHigherErrorPosition2(ErrorUmlType type, List<ErrorUml> all) {
|
||||||
LineLocation max = null;
|
LineLocation max = null;
|
||||||
for (ErrorUml error : getErrors(type, all)) {
|
for (ErrorUml error : getErrors(type, all)) {
|
||||||
@ -411,16 +377,6 @@ public class PSystemError extends AbstractPSystem {
|
|||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private List<ErrorUml> getErrorsAt(int position, ErrorUmlType type, List<ErrorUml> all) {
|
|
||||||
// final List<ErrorUml> result = new ArrayList<ErrorUml>();
|
|
||||||
// for (ErrorUml error : getErrors(type, all)) {
|
|
||||||
// if (error.getPosition() == position && StringUtils.isNotEmpty(error.getError())) {
|
|
||||||
// result.add(error);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
|
|
||||||
private List<ErrorUml> getErrorsAt2(LineLocation position, ErrorUmlType type, List<ErrorUml> all) {
|
private List<ErrorUml> getErrorsAt2(LineLocation position, ErrorUmlType type, List<ErrorUml> all) {
|
||||||
final List<ErrorUml> result = new ArrayList<ErrorUml>();
|
final List<ErrorUml> result = new ArrayList<ErrorUml>();
|
||||||
for (ErrorUml error : getErrors(type, all)) {
|
for (ErrorUml error : getErrors(type, all)) {
|
||||||
|
@ -62,7 +62,7 @@ import net.sourceforge.plantuml.descdiagram.DescriptionDiagramFactory;
|
|||||||
import net.sourceforge.plantuml.ftp.FtpServer;
|
import net.sourceforge.plantuml.ftp.FtpServer;
|
||||||
import net.sourceforge.plantuml.objectdiagram.ObjectDiagramFactory;
|
import net.sourceforge.plantuml.objectdiagram.ObjectDiagramFactory;
|
||||||
import net.sourceforge.plantuml.png.MetadataTag;
|
import net.sourceforge.plantuml.png.MetadataTag;
|
||||||
import net.sourceforge.plantuml.preproc.StdlibOld;
|
import net.sourceforge.plantuml.preproc.Stdlib;
|
||||||
import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory;
|
import net.sourceforge.plantuml.sequencediagram.SequenceDiagramFactory;
|
||||||
import net.sourceforge.plantuml.statediagram.StateDiagramFactory;
|
import net.sourceforge.plantuml.statediagram.StateDiagramFactory;
|
||||||
import net.sourceforge.plantuml.stats.StatsUtils;
|
import net.sourceforge.plantuml.stats.StatsUtils;
|
||||||
@ -74,12 +74,28 @@ import net.sourceforge.plantuml.version.Version;
|
|||||||
public class Run {
|
public class Run {
|
||||||
|
|
||||||
public static void main(String[] argsArray) throws IOException, InterruptedException {
|
public static void main(String[] argsArray) throws IOException, InterruptedException {
|
||||||
|
System.setProperty("log4j.debug", "false");
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
|
if (argsArray.length > 0 && argsArray[0].equalsIgnoreCase("-headless")) {
|
||||||
|
System.setProperty("java.awt.headless", "true");
|
||||||
|
}
|
||||||
saveCommandLine(argsArray);
|
saveCommandLine(argsArray);
|
||||||
final Option option = new Option(argsArray);
|
final Option option = new Option(argsArray);
|
||||||
ProgressBar.setEnable(option.isTextProgressBar());
|
ProgressBar.setEnable(option.isTextProgressBar());
|
||||||
if (OptionFlags.getInstance().getExtractStdLib()) {
|
if (OptionFlags.getInstance().isClipboardLoop()) {
|
||||||
StdlibOld.extractStdLib();
|
ClipboardLoop.runLoop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (OptionFlags.getInstance().isClipboard()) {
|
||||||
|
ClipboardLoop.runOnce();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (OptionFlags.getInstance().isExtractStdLib()) {
|
||||||
|
Stdlib.extractStdLib();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (OptionFlags.getInstance().isStdLib()) {
|
||||||
|
Stdlib.printStdLib();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (OptionFlags.getInstance().isDumpStats()) {
|
if (OptionFlags.getInstance().isDumpStats()) {
|
||||||
|
@ -83,7 +83,7 @@ public class SourceStringReader {
|
|||||||
synchronized (SourceStringReader.class) {
|
synchronized (SourceStringReader.class) {
|
||||||
try {
|
try {
|
||||||
final BlockUmlBuilder builder = new BlockUmlBuilder(config, charset, defines, new StringReader(source),
|
final BlockUmlBuilder builder = new BlockUmlBuilder(config, charset, defines, new StringReader(source),
|
||||||
newCurrentDir, null);
|
newCurrentDir, "string");
|
||||||
this.blocks = builder.getBlockUmls();
|
this.blocks = builder.getBlockUmls();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.error("error " + e);
|
Log.error("error " + e);
|
||||||
|
@ -108,7 +108,7 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
|
|||||||
new RegexLeaf("$"));
|
new RegexLeaf("$"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult executeNow(final ActivityDiagram diagram, BlocLines lines) {
|
protected CommandExecutionResult executeNow(final ActivityDiagram diagram, BlocLines lines) {
|
||||||
lines = lines.trim(false);
|
lines = lines.trim(false);
|
||||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class CommandActivityLong3 extends CommandMultilines2<ActivityDiagram3> {
|
|||||||
new RegexLeaf("$"));
|
new RegexLeaf("$"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) {
|
protected CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) {
|
||||||
lines = lines.removeEmptyColumns();
|
lines = lines.removeEmptyColumns();
|
||||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||||
final Colors colors = color().getColor(line0, diagram.getSkinParam().getIHtmlColorSet());
|
final Colors colors = color().getColor(line0, diagram.getSkinParam().getIHtmlColorSet());
|
||||||
|
@ -70,7 +70,7 @@ public class CommandArrowLong3 extends CommandMultilines2<ActivityDiagram3> {
|
|||||||
new RegexLeaf("$"));
|
new RegexLeaf("$"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) {
|
protected CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) {
|
||||||
lines = lines.removeEmptyColumns();
|
lines = lines.removeEmptyColumns();
|
||||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||||
// final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0));
|
// final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0));
|
||||||
|
@ -66,7 +66,7 @@ public class CommandNoteLong3 extends CommandMultilines2<ActivityDiagram3> {
|
|||||||
return "(?i)^end[%s]?note$";
|
return "(?i)^end[%s]?note$";
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult executeNow(final ActivityDiagram3 diagram, BlocLines lines) {
|
protected CommandExecutionResult executeNow(final ActivityDiagram3 diagram, BlocLines lines) {
|
||||||
// final List<? extends CharSequence> in = StringUtils.removeEmptyColumns2(lines.subList(1, lines.size() - 1));
|
// final List<? extends CharSequence> in = StringUtils.removeEmptyColumns2(lines.subList(1, lines.size() - 1));
|
||||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||||
lines = lines.subExtract(1, 1);
|
lines = lines.subExtract(1, 1);
|
||||||
|
@ -74,7 +74,7 @@ public class CommandRepeatWhile3Multilines extends CommandMultilines3<ActivityDi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) {
|
protected CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) {
|
||||||
lines = lines.trim(false);
|
lines = lines.trim(false);
|
||||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||||
final RegexResult lineLast = getPatternEnd2().matcher(lines.getLast499().toString());
|
final RegexResult lineLast = getPatternEnd2().matcher(lines.getLast499().toString());
|
||||||
|
@ -221,4 +221,8 @@ public class CollisionDetector implements UGraphic {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double dpiFactor() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ import net.sourceforge.plantuml.graphic.StringBounder;
|
|||||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||||
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||||
import net.sourceforge.plantuml.ugraphic.CompressionTransform;
|
import net.sourceforge.plantuml.ugraphic.CompressionTransform;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.MinMax;
|
||||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
import net.sourceforge.plantuml.ugraphic.UPolygon;
|
import net.sourceforge.plantuml.ugraphic.UPolygon;
|
||||||
import net.sourceforge.plantuml.ugraphic.UShape;
|
import net.sourceforge.plantuml.ugraphic.UShape;
|
||||||
@ -273,4 +274,8 @@ public class Snake implements UShape {
|
|||||||
this.emphasizeDirection = direction;
|
this.emphasizeDirection = direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean doesHorizontalCross(MinMax minMax) {
|
||||||
|
return worm.doesHorizontalCross(minMax);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -193,44 +193,7 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (OptionFlags.SWI2) {
|
|
||||||
//
|
|
||||||
// final SlotFinderX slotFinder = new SlotFinderX(ug.getStringBounder());
|
|
||||||
// drawWhenSwimlanes(slotFinder, full);
|
|
||||||
// final SlotSet slotX = slotFinder.getXSlotSet().reverse();
|
|
||||||
// //
|
|
||||||
// // // final SlotSet ysSlotSet = slotFinder.getYSlotSet().reverse().smaller(5.0);
|
|
||||||
// //
|
|
||||||
// System.err.println("slotX=" + slotX);
|
|
||||||
//
|
|
||||||
// printDebug(ug, slotX, HtmlColorUtils.GRAY, full);
|
|
||||||
//
|
|
||||||
// double x2 = 0;
|
|
||||||
// double y2 = 0;
|
|
||||||
// final double stepy = 40;
|
|
||||||
// int i = 0;
|
|
||||||
// final SlotSet deconnectedSwimlanes = new SlotSet();
|
|
||||||
// for (Swimlane swimlane : swimlanes) {
|
|
||||||
// final UGraphic ug2 = ug.apply(new UChangeColor(HtmlColorUtils.GREEN)).apply(
|
|
||||||
// new UChangeBackColor(HtmlColorUtils.GREEN));
|
|
||||||
// final double totalWidth = swimlane.getTotalWidth();
|
|
||||||
// final SlotSet slot2 = slotX.filter(x2 + separationMargin, x2 + totalWidth - separationMargin);
|
|
||||||
// deconnectedSwimlanes.addAll(slot2);
|
|
||||||
// // ug2.apply(new UTranslate(x2, y2)).draw(new URectangle(totalWidth, stepy));
|
|
||||||
// x2 += totalWidth;
|
|
||||||
// y2 += stepy;
|
|
||||||
// i++;
|
|
||||||
// }
|
|
||||||
// // printDebug(ug, deconnectedSwimlanes, HtmlColorUtils.GRAY, full);
|
|
||||||
//
|
|
||||||
// //
|
|
||||||
// final CompressionTransform compressionTransform = new CompressionTransform(deconnectedSwimlanes);
|
|
||||||
// // ug = new UGraphicCompress2(ug, compressionTransform);
|
|
||||||
// drawWhenSwimlanes(ug, full);
|
|
||||||
// } else {
|
|
||||||
drawWhenSwimlanes(ug, full);
|
drawWhenSwimlanes(ug, full);
|
||||||
// }
|
|
||||||
// getCollisionDetector(ug, titleHeightTranslate).drawDebug(ug);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static private void printDebug(UGraphic ug, SlotSet slot, HtmlColor col, TextBlock full) {
|
static private void printDebug(UGraphic ug, SlotSet slot, HtmlColor col, TextBlock full) {
|
||||||
@ -257,13 +220,11 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock {
|
|||||||
+ titleHeightTranslate.getDy()));
|
+ titleHeightTranslate.getDy()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (OptionFlags.SWI2 == false) {
|
|
||||||
final TextBlock swTitle = swimlane.getDisplay().create(getFontConfiguration(), HorizontalAlignment.LEFT,
|
final TextBlock swTitle = swimlane.getDisplay().create(getFontConfiguration(), HorizontalAlignment.LEFT,
|
||||||
skinParam);
|
skinParam);
|
||||||
final double titleWidth = swTitle.calculateDimension(stringBounder).getWidth();
|
final double titleWidth = swTitle.calculateDimension(stringBounder).getWidth();
|
||||||
final double posTitle = x2 + (swimlane.getTotalWidth() - titleWidth) / 2;
|
final double posTitle = x2 + (swimlane.getTotalWidth() - titleWidth) / 2;
|
||||||
swTitle.drawU(ug.apply(new UTranslate(posTitle, 0)));
|
swTitle.drawU(ug.apply(new UTranslate(posTitle, 0)));
|
||||||
// }
|
|
||||||
|
|
||||||
drawSeparation(ug.apply(new UTranslate(x2, 0)), dimensionFull.getHeight() + titleHeightTranslate.getDy());
|
drawSeparation(ug.apply(new UTranslate(x2, 0)), dimensionFull.getHeight() + titleHeightTranslate.getDy());
|
||||||
|
|
||||||
@ -273,6 +234,7 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock {
|
|||||||
|
|
||||||
}
|
}
|
||||||
drawSeparation(ug.apply(new UTranslate(x2, 0)), dimensionFull.getHeight() + titleHeightTranslate.getDy());
|
drawSeparation(ug.apply(new UTranslate(x2, 0)), dimensionFull.getHeight() + titleHeightTranslate.getDy());
|
||||||
|
|
||||||
final Cross cross = new Cross(ug.apply(titleHeightTranslate));
|
final Cross cross = new Cross(ug.apply(titleHeightTranslate));
|
||||||
full.drawU(cross);
|
full.drawU(cross);
|
||||||
cross.flushUg();
|
cross.flushUg();
|
||||||
@ -321,32 +283,6 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void computeSizeOld(UGraphic ug, TextBlock full) {
|
|
||||||
double x1 = 0;
|
|
||||||
final StringBounder stringBounder = ug.getStringBounder();
|
|
||||||
for (Swimlane swimlane : swimlanes) {
|
|
||||||
|
|
||||||
final LimitFinder limitFinder = new LimitFinder(stringBounder, false);
|
|
||||||
final UGraphicInterceptorOneSwimlane interceptor = new UGraphicInterceptorOneSwimlane(new UGraphicForSnake(
|
|
||||||
limitFinder), swimlane);
|
|
||||||
full.drawU(interceptor);
|
|
||||||
interceptor.flushUg();
|
|
||||||
final MinMax minMax = limitFinder.getMinMax();
|
|
||||||
|
|
||||||
final double drawingWidth = minMax.getWidth() + 2 * separationMargin;
|
|
||||||
final TextBlock swTitle = swimlane.getDisplay().create(getFontConfiguration(), HorizontalAlignment.LEFT,
|
|
||||||
skinParam);
|
|
||||||
final double titleWidth = swTitle.calculateDimension(stringBounder).getWidth();
|
|
||||||
final double totalWidth = Math.max(drawingWidth, titleWidth + 2 * separationMargin);
|
|
||||||
|
|
||||||
final UTranslate translate = new UTranslate(x1 - minMax.getMinX() + separationMargin
|
|
||||||
+ (totalWidth - drawingWidth) / 2.0, 0);
|
|
||||||
swimlane.setTranslateAndWidth(translate, totalWidth);
|
|
||||||
|
|
||||||
x1 += totalWidth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private UTranslate getTitleHeightTranslate(final StringBounder stringBounder) {
|
private UTranslate getTitleHeightTranslate(final StringBounder stringBounder) {
|
||||||
double titlesHeight = 0;
|
double titlesHeight = 0;
|
||||||
for (Swimlane swimlane : swimlanes) {
|
for (Swimlane swimlane : swimlanes) {
|
||||||
@ -359,26 +295,6 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock {
|
|||||||
return titleHeightTranslate;
|
return titleHeightTranslate;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CollisionDetector getCollisionDetector(UGraphic ug, final UTranslate titleHeightTranslate) {
|
|
||||||
final FtileFactory factory = getFtileFactory(ug.getStringBounder());
|
|
||||||
final TextBlock full = root.createFtile(factory);
|
|
||||||
ug = new UGraphicForSnake(ug);
|
|
||||||
|
|
||||||
final CollisionDetector collisionDetector = new CollisionDetector(ug.getStringBounder());
|
|
||||||
|
|
||||||
for (Swimlane swimlane : swimlanes) {
|
|
||||||
full.drawU(new UGraphicInterceptorOneSwimlane(collisionDetector, swimlane).apply(swimlane.getTranslate())
|
|
||||||
.apply(titleHeightTranslate));
|
|
||||||
}
|
|
||||||
|
|
||||||
collisionDetector.setManageSnakes(true);
|
|
||||||
final Cross cross = new Cross(collisionDetector.apply(titleHeightTranslate));
|
|
||||||
full.drawU(cross);
|
|
||||||
cross.flushUg();
|
|
||||||
|
|
||||||
return collisionDetector;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void drawSeparation(UGraphic ug, double height) {
|
private void drawSeparation(UGraphic ug, double height) {
|
||||||
HtmlColor color = skinParam.getHtmlColor(ColorParam.swimlaneBorder, null, false);
|
HtmlColor color = skinParam.getHtmlColor(ColorParam.swimlaneBorder, null, false);
|
||||||
if (color == null) {
|
if (color == null) {
|
||||||
@ -388,21 +304,10 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock {
|
|||||||
ug.apply(thickness).apply(new UChangeColor(color)).draw(new ULine(0, height));
|
ug.apply(thickness).apply(new UChangeColor(color)).draw(new ULine(0, height));
|
||||||
}
|
}
|
||||||
|
|
||||||
// private Dimension2D cachedDimension;
|
|
||||||
|
|
||||||
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
||||||
return getMinMax(stringBounder).getDimension();
|
return getMinMax(stringBounder).getDimension();
|
||||||
// if (cachedDimension == null) {
|
|
||||||
// cachedDimension = calculateDimensionSlow(stringBounder);
|
|
||||||
// }
|
|
||||||
// return cachedDimension;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private Dimension2D calculateDimensionSlow(StringBounder stringBounder) {
|
|
||||||
// final Dimension2D result = TextBlockUtils.getMinMax(this, stringBounder).getDimension();
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public Instruction getCurrent() {
|
public Instruction getCurrent() {
|
||||||
return currentInstruction;
|
return currentInstruction;
|
||||||
}
|
}
|
||||||
@ -425,7 +330,7 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock {
|
|||||||
public Swimlane getCurrentSwimlane() {
|
public Swimlane getCurrentSwimlane() {
|
||||||
return currentSwimlane;
|
return currentSwimlane;
|
||||||
}
|
}
|
||||||
|
|
||||||
private MinMax cachedMinMax;
|
private MinMax cachedMinMax;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -436,5 +341,4 @@ public class Swimlanes extends AbstractTextBlock implements TextBlock {
|
|||||||
return cachedMinMax;
|
return cachedMinMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ import net.sourceforge.plantuml.Direction;
|
|||||||
import net.sourceforge.plantuml.cucadiagram.LinkStyle;
|
import net.sourceforge.plantuml.cucadiagram.LinkStyle;
|
||||||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||||
import net.sourceforge.plantuml.graphic.HtmlColorAndStyle;
|
import net.sourceforge.plantuml.graphic.HtmlColorAndStyle;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.MinMax;
|
||||||
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
|
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
|
||||||
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
@ -231,6 +232,17 @@ public class Worm implements Iterable<Point2D.Double> {
|
|||||||
return Collections.unmodifiableCollection(points).iterator();
|
return Collections.unmodifiableCollection(points).iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean doesHorizontalCross(MinMax area) {
|
||||||
|
for (int i = 0; i < points.size() - 1; i++) {
|
||||||
|
final Point2D.Double pt1 = get(i);
|
||||||
|
final Point2D.Double pt2 = get(i + 1);
|
||||||
|
if (pt1.getY() == pt2.getY() && area.doesHorizontalCross(pt1, pt2)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public int size() {
|
public int size() {
|
||||||
return this.points.size();
|
return this.points.size();
|
||||||
}
|
}
|
||||||
|
74
src/net/sourceforge/plantuml/activitydiagram3/ftile/Zad.java
Normal file
74
src/net/sourceforge/plantuml/activitydiagram3/ftile/Zad.java
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* 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.activitydiagram3.ftile;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.MinMax;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
|
||||||
|
public class Zad {
|
||||||
|
|
||||||
|
private final List<MinMax> rectangles = new ArrayList<MinMax>();
|
||||||
|
|
||||||
|
public void add(MinMax rect) {
|
||||||
|
// System.err.println("add " + rect);
|
||||||
|
this.rectangles.add(rect);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawDebug(UGraphic ug) {
|
||||||
|
ug = ug.apply(new UChangeBackColor(HtmlColorUtils.BLUE)).apply(new UChangeColor(HtmlColorUtils.RED_LIGHT));
|
||||||
|
for (MinMax minMax : rectangles) {
|
||||||
|
System.err.println("minmax=" + minMax);
|
||||||
|
minMax.drawGrey(ug);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean doesHorizontalCross(Snake snake) {
|
||||||
|
for (MinMax minMax : rectangles) {
|
||||||
|
if (snake.doesHorizontalCross(minMax)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,135 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* 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.activitydiagram3.ftile;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.Url;
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.ColorMapper;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.MinMax;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UChange;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UParam;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UParamNull;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.URectangle;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UShape;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class ZadBuilder implements UGraphic {
|
||||||
|
|
||||||
|
public UGraphic apply(UChange change) {
|
||||||
|
if (change instanceof UTranslate) {
|
||||||
|
return new ZadBuilder(stringBounder, translate.compose((UTranslate) change), this.context);
|
||||||
|
} else if (change instanceof UStroke) {
|
||||||
|
return new ZadBuilder(this);
|
||||||
|
} else if (change instanceof UChangeBackColor) {
|
||||||
|
return new ZadBuilder(this);
|
||||||
|
} else if (change instanceof UChangeColor) {
|
||||||
|
return new ZadBuilder(this);
|
||||||
|
}
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private final StringBounder stringBounder;
|
||||||
|
private final UTranslate translate;
|
||||||
|
private final Context context;
|
||||||
|
|
||||||
|
static class Context {
|
||||||
|
private final Zad zad = new Zad();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ZadBuilder(StringBounder stringBounder) {
|
||||||
|
this(stringBounder, new UTranslate(), new Context());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ZadBuilder(StringBounder stringBounder, UTranslate translate, Context context) {
|
||||||
|
this.stringBounder = stringBounder;
|
||||||
|
this.translate = translate;
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ZadBuilder(ZadBuilder other) {
|
||||||
|
this(other.stringBounder, other.translate, other.context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringBounder getStringBounder() {
|
||||||
|
return stringBounder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UParam getParam() {
|
||||||
|
return new UParamNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw(UShape shape) {
|
||||||
|
if (shape instanceof URectangle) {
|
||||||
|
drawRectangle((URectangle) shape);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawRectangle(URectangle shape) {
|
||||||
|
final MinMax area = shape.getMinMax().translate(translate);
|
||||||
|
// System.err.println("ZadBuilder " + shape + " " + area);
|
||||||
|
context.zad.add(area);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ColorMapper getColorMapper() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startUrl(Url url) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeAction() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void flushUg() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean matchesProperty(String propertyName) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double dpiFactor() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Zad getZad() {
|
||||||
|
return context.zad;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -111,7 +111,8 @@ public class ParallelBuilderSplit2 extends ParallelFtilesBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Rainbow thinColor = result.getInLinkRendering().getRainbow(HtmlColorAndStyle.build(skinParam()));
|
final Rainbow thinColor = result.getInLinkRendering().getRainbow(HtmlColorAndStyle.build(skinParam()));
|
||||||
final Ftile out = new FtileThinSplit(skinParam(), thinColor.getColor(), getList().get(0).getSwimlaneIn());
|
// final Ftile out = new FtileThinSplit(skinParam(), thinColor.getColor(), getList().get(0).getSwimlaneIn());
|
||||||
|
final Ftile out = new FtileThinSplit(skinParam(), thinColor.getColor(), swimlane());
|
||||||
result = new FtileAssemblySimple(result, out);
|
result = new FtileAssemblySimple(result, out);
|
||||||
final List<Connection> conns = new ArrayList<Connection>();
|
final List<Connection> conns = new ArrayList<Connection>();
|
||||||
double x = 0;
|
double x = 0;
|
||||||
|
@ -40,4 +40,6 @@ public interface INumberAnalyzed {
|
|||||||
|
|
||||||
public long getMean();
|
public long getMean();
|
||||||
|
|
||||||
|
public long getSliddingMean();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
package net.sourceforge.plantuml.api;
|
package net.sourceforge.plantuml.api;
|
||||||
|
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
@ -38,7 +37,7 @@ import net.sourceforge.plantuml.Log;
|
|||||||
|
|
||||||
public class NumberAnalyzed implements INumberAnalyzed {
|
public class NumberAnalyzed implements INumberAnalyzed {
|
||||||
|
|
||||||
private static final int SLIDING_WINDOW = 512;
|
private static final int SLIDING_WINDOW = 1024;
|
||||||
|
|
||||||
private long nb;
|
private long nb;
|
||||||
private long sum;
|
private long sum;
|
||||||
@ -211,6 +210,16 @@ public class NumberAnalyzed implements INumberAnalyzed {
|
|||||||
return sum / nb;
|
return sum / nb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synchronized public final long getSliddingMean() {
|
||||||
|
if (nb == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (nb < SLIDING_WINDOW) {
|
||||||
|
return sum / nb;
|
||||||
|
}
|
||||||
|
return sliddingSum / nb;
|
||||||
|
}
|
||||||
|
|
||||||
public final long getStandardDeviation() {
|
public final long getStandardDeviation() {
|
||||||
final long sum1;
|
final long sum1;
|
||||||
final long sumOfSquare1;
|
final long sumOfSquare1;
|
||||||
|
@ -162,9 +162,21 @@ public class NumberAnalyzed2 implements INumberAnalyzed {
|
|||||||
if (nb.get() == 0) {
|
if (nb.get() == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
// Bad
|
||||||
return sum.get() / nb.get();
|
return sum.get() / nb.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final long getSliddingMean() {
|
||||||
|
if (nb.get() == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (nb.get() < SLIDING_WINDOW) {
|
||||||
|
return sum.get() / nb.get();
|
||||||
|
}
|
||||||
|
// Bad
|
||||||
|
return sliddingSum.get() / nb.get();
|
||||||
|
}
|
||||||
|
|
||||||
final public String getName() {
|
final public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -99,21 +99,23 @@ public class ClassDiagramFactory extends UmlDiagramFactory {
|
|||||||
|
|
||||||
cmds.add(new CommandHideShow2());
|
cmds.add(new CommandHideShow2());
|
||||||
cmds.add(new CommandRemoveRestore());
|
cmds.add(new CommandRemoveRestore());
|
||||||
|
cmds.add(new CommandCreateClassMultilines());
|
||||||
|
cmds.add(new CommandCreateEntityObjectMultilines());
|
||||||
cmds.add(new CommandCreateClass());
|
cmds.add(new CommandCreateClass());
|
||||||
cmds.add(new CommandCreateEntityObject());
|
cmds.add(new CommandCreateEntityObject());
|
||||||
|
|
||||||
cmds.add(new CommandAllowMixing());
|
cmds.add(new CommandAllowMixing());
|
||||||
cmds.add(new CommandLayoutNewLine());
|
cmds.add(new CommandLayoutNewLine());
|
||||||
|
|
||||||
cmds.add(new CommandCreateElementFull2(Mode.NORMAL_KEYWORD));
|
|
||||||
cmds.add(new CommandCreateElementFull2(Mode.WITH_MIX_PREFIX));
|
|
||||||
final FactoryNoteCommand factoryNoteCommand = new FactoryNoteCommand();
|
|
||||||
cmds.add(factoryNoteCommand.createSingleLine());
|
|
||||||
|
|
||||||
cmds.add(new CommandPackage());
|
cmds.add(new CommandPackage());
|
||||||
cmds.add(new CommandEndPackage());
|
cmds.add(new CommandEndPackage());
|
||||||
cmds.add(new CommandPackageEmpty());
|
cmds.add(new CommandPackageEmpty());
|
||||||
cmds.add(new CommandPackageWithUSymbol());
|
cmds.add(new CommandPackageWithUSymbol());
|
||||||
|
|
||||||
|
cmds.add(new CommandCreateElementFull2(Mode.NORMAL_KEYWORD));
|
||||||
|
cmds.add(new CommandCreateElementFull2(Mode.WITH_MIX_PREFIX));
|
||||||
|
final FactoryNoteCommand factoryNoteCommand = new FactoryNoteCommand();
|
||||||
|
cmds.add(factoryNoteCommand.createSingleLine());
|
||||||
|
|
||||||
cmds.add(new CommandNamespace());
|
cmds.add(new CommandNamespace());
|
||||||
cmds.add(new CommandStereotype());
|
cmds.add(new CommandStereotype());
|
||||||
@ -137,9 +139,6 @@ public class ClassDiagramFactory extends UmlDiagramFactory {
|
|||||||
cmds.add(factoryNoteOnEntityCommand.createMultiLine(false));
|
cmds.add(factoryNoteOnEntityCommand.createMultiLine(false));
|
||||||
cmds.add(factoryNoteCommand.createMultiLine(false));
|
cmds.add(factoryNoteCommand.createMultiLine(false));
|
||||||
|
|
||||||
cmds.add(new CommandCreateClassMultilines());
|
|
||||||
cmds.add(new CommandCreateEntityObjectMultilines());
|
|
||||||
|
|
||||||
final FactoryNoteOnLinkCommand factoryNoteOnLinkCommand = new FactoryNoteOnLinkCommand();
|
final FactoryNoteOnLinkCommand factoryNoteOnLinkCommand = new FactoryNoteOnLinkCommand();
|
||||||
cmds.add(factoryNoteOnLinkCommand.createSingleLine());
|
cmds.add(factoryNoteOnLinkCommand.createSingleLine());
|
||||||
cmds.add(factoryNoteOnLinkCommand.createMultiLine(false));
|
cmds.add(factoryNoteOnLinkCommand.createMultiLine(false));
|
||||||
|
@ -114,14 +114,19 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
|
|||||||
new RegexLeaf("IMPLEMENTS", "([%s]+(implements)[%s]+(" + CODES + "))?"), //
|
new RegexLeaf("IMPLEMENTS", "([%s]+(implements)[%s]+(" + CODES + "))?"), //
|
||||||
new RegexLeaf("[%s]*\\{[%s]*$"));
|
new RegexLeaf("[%s]*\\{[%s]*$"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean syntaxWithFinalBracket() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static ColorParser color() {
|
private static ColorParser color() {
|
||||||
return ColorParser.simpleColor(ColorType.BACK);
|
return ColorParser.simpleColor(ColorType.BACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult executeNow(ClassDiagram diagram, BlocLines lines) {
|
protected CommandExecutionResult executeNow(ClassDiagram diagram, BlocLines lines) {
|
||||||
lines = lines.trimSmart(1);
|
lines = lines.trimSmart(1);
|
||||||
lines = lines.removeComments();
|
|
||||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||||
final IEntity entity = executeArg0(diagram, line0);
|
final IEntity entity = executeArg0(diagram, line0);
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
|
@ -52,7 +52,7 @@ public class ArobaseStringCompressor implements StringCompressor {
|
|||||||
private final static Pattern2 p = MyPattern.cmpile("(?s)(?i)^[%s]*(@startuml[^\\n\\r]*)?[%s]*(.*?)[%s]*(@enduml)?[%s]*$");
|
private final static Pattern2 p = MyPattern.cmpile("(?s)(?i)^[%s]*(@startuml[^\\n\\r]*)?[%s]*(.*?)[%s]*(@enduml)?[%s]*$");
|
||||||
|
|
||||||
public String compress(final String data) throws IOException {
|
public String compress(final String data) throws IOException {
|
||||||
final ReadLine r = new UncommentReadLine(new ReadLineReader(new StringReader(data), "COMPRESS"));
|
final ReadLine r = new UncommentReadLine(ReadLineReader.create(new StringReader(data), "COMPRESS"));
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
final StringBuilder full = new StringBuilder();
|
final StringBuilder full = new StringBuilder();
|
||||||
CharSequence2 s = null;
|
CharSequence2 s = null;
|
||||||
|
@ -43,7 +43,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.BackSlash;
|
import net.sourceforge.plantuml.BackSlash;
|
||||||
import net.sourceforge.plantuml.StringUtils;
|
import net.sourceforge.plantuml.StringUtils;
|
||||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
|
||||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
|
|
||||||
public class BlocLines implements Iterable<CharSequence> {
|
public class BlocLines implements Iterable<CharSequence> {
|
||||||
@ -94,7 +93,7 @@ public class BlocLines implements Iterable<CharSequence> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CharSequence getFirst499() {
|
public CharSequence getFirst499() {
|
||||||
if (lines.size()==0) {
|
if (lines.size() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return lines.get(0);
|
return lines.get(0);
|
||||||
@ -232,38 +231,19 @@ public class BlocLines implements Iterable<CharSequence> {
|
|||||||
return lines.iterator();
|
return lines.iterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
public BlocLines eventuallyMoveBracket() {
|
||||||
public BlocLines removeComments() {
|
if (size() < 2) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
final String first = StringUtils.trin(getFirst499());
|
||||||
|
final String second = StringUtils.trin(get499(1));
|
||||||
|
if (first.endsWith("{") == false && second.equals("{")) {
|
||||||
|
final String vline = first + " {";
|
||||||
|
final List<CharSequence> result = new ArrayList<CharSequence>();
|
||||||
|
result.add(vline);
|
||||||
|
result.addAll(this.lines.subList(2, this.lines.size()));
|
||||||
|
return new BlocLines(result);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
// final List<CharSequence> copy = new ArrayList<CharSequence>();
|
|
||||||
// boolean inComment = false;
|
|
||||||
// for (CharSequence cs : lines) {
|
|
||||||
// if (inComment == false && MyPattern.mtches(cs, CommandMultilinesComment.COMMENT_SINGLE_LINE)) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// if (inComment == false && MyPattern.mtches(cs, CommandMultilinesComment.COMMENT_MULTILINE_START)) {
|
|
||||||
// inComment = true;
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// if (inComment && MyPattern.mtches(cs, CommandMultilinesComment.COMMENT_MULTILINE_END)) {
|
|
||||||
// inComment = false;
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// if (inComment == false) {
|
|
||||||
// copy.add(cs);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return new BlocLines(copy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public BlocLines removeInnerComments() {
|
|
||||||
return this;
|
|
||||||
// final List<CharSequence> copy = new ArrayList<CharSequence>();
|
|
||||||
// for (CharSequence cs : lines) {
|
|
||||||
// copy.add(MyPattern.removeAll(cs, CommandMultilinesComment.INNER_COMMENT));
|
|
||||||
// }
|
|
||||||
// return new BlocLines(copy);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,10 @@ public abstract class CommandMultilines2<S extends Diagram> implements Command<S
|
|||||||
this.starting = patternStart;
|
this.starting = patternStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean syntaxWithFinalBracket() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract String getPatternEnd();
|
public abstract String getPatternEnd();
|
||||||
|
|
||||||
public String[] getDescription() {
|
public String[] getDescription() {
|
||||||
@ -66,6 +70,16 @@ public abstract class CommandMultilines2<S extends Diagram> implements Command<S
|
|||||||
if (isCommandForbidden()) {
|
if (isCommandForbidden()) {
|
||||||
return CommandControl.NOT_OK;
|
return CommandControl.NOT_OK;
|
||||||
}
|
}
|
||||||
|
if (syntaxWithFinalBracket()) {
|
||||||
|
if (lines.size() == 1 && StringUtils.trin(lines.getFirst499()).endsWith("{") == false) {
|
||||||
|
final String vline = lines.get499(0).toString() + " {";
|
||||||
|
if (isValid(BlocLines.single(vline)) == CommandControl.OK_PARTIAL) {
|
||||||
|
return CommandControl.OK_PARTIAL;
|
||||||
|
}
|
||||||
|
return CommandControl.NOT_OK;
|
||||||
|
}
|
||||||
|
lines = lines.eventuallyMoveBracket();
|
||||||
|
}
|
||||||
final CharSequence first = lines.getFirst499();
|
final CharSequence first = lines.getFirst499();
|
||||||
if (first == null) {
|
if (first == null) {
|
||||||
return CommandControl.NOT_OK;
|
return CommandControl.NOT_OK;
|
||||||
@ -89,10 +103,13 @@ public abstract class CommandMultilines2<S extends Diagram> implements Command<S
|
|||||||
|
|
||||||
public final CommandExecutionResult execute(S system, BlocLines lines) {
|
public final CommandExecutionResult execute(S system, BlocLines lines) {
|
||||||
lines = lines.cleanList2(strategy);
|
lines = lines.cleanList2(strategy);
|
||||||
|
if (syntaxWithFinalBracket()) {
|
||||||
|
lines = lines.eventuallyMoveBracket();
|
||||||
|
}
|
||||||
return executeNow(system, lines);
|
return executeNow(system, lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract CommandExecutionResult executeNow(S system, BlocLines lines);
|
protected abstract CommandExecutionResult executeNow(S system, BlocLines lines);
|
||||||
|
|
||||||
protected boolean isCommandForbidden() {
|
protected boolean isCommandForbidden() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -91,7 +91,7 @@ public abstract class CommandMultilines3<S extends Diagram> implements Command<S
|
|||||||
return executeNow(system, lines);
|
return executeNow(system, lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract CommandExecutionResult executeNow(S system, BlocLines lines);
|
protected abstract CommandExecutionResult executeNow(S system, BlocLines lines);
|
||||||
|
|
||||||
protected boolean isCommandForbidden() {
|
protected boolean isCommandForbidden() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -65,7 +65,7 @@ public class CommandMultilinesLegend extends CommandMultilines2<UmlDiagram> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandExecutionResult executeNow(UmlDiagram diagram, BlocLines lines) {
|
protected CommandExecutionResult executeNow(UmlDiagram diagram, BlocLines lines) {
|
||||||
lines = lines.trimSmart(1);
|
lines = lines.trimSmart(1);
|
||||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||||
final String align = line0.get("ALIGN", 0);
|
final String align = line0.get("ALIGN", 0);
|
||||||
|
@ -82,6 +82,11 @@ public class CommandPackage extends SingleLineCommand2<AbstractEntityDiagram> {
|
|||||||
new RegexLeaf("[%s]*\\{$"));
|
new RegexLeaf("[%s]*\\{$"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean syntaxWithFinalBracket() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static ColorParser color() {
|
private static ColorParser color() {
|
||||||
return ColorParser.simpleColor(ColorType.BACK);
|
return ColorParser.simpleColor(ColorType.BACK);
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,6 @@ public class CommandSkinParamMultilines extends CommandMultilinesBracket<UmlDiag
|
|||||||
}
|
}
|
||||||
|
|
||||||
lines = lines.subExtract(1, 1);
|
lines = lines.subExtract(1, 1);
|
||||||
lines = lines.removeComments();
|
|
||||||
lines = lines.trim(true);
|
lines = lines.trim(true);
|
||||||
|
|
||||||
for (CharSequence s : lines) {
|
for (CharSequence s : lines) {
|
||||||
|
@ -46,6 +46,7 @@ import net.sourceforge.plantuml.command.regex.RegexConcat;
|
|||||||
import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
||||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||||
import net.sourceforge.plantuml.ugraphic.sprite.Sprite;
|
import net.sourceforge.plantuml.ugraphic.sprite.Sprite;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.sprite.SpriteColorBuilder4096;
|
||||||
import net.sourceforge.plantuml.ugraphic.sprite.SpriteGrayLevel;
|
import net.sourceforge.plantuml.ugraphic.sprite.SpriteGrayLevel;
|
||||||
|
|
||||||
public final class FactorySpriteCommand implements SingleMultiFactoryCommand<UmlDiagram> {
|
public final class FactorySpriteCommand implements SingleMultiFactoryCommand<UmlDiagram> {
|
||||||
@ -54,7 +55,7 @@ public final class FactorySpriteCommand implements SingleMultiFactoryCommand<Uml
|
|||||||
return new RegexConcat(new RegexLeaf("^"), //
|
return new RegexConcat(new RegexLeaf("^"), //
|
||||||
new RegexLeaf("sprite[%s]+\\$?"), //
|
new RegexLeaf("sprite[%s]+\\$?"), //
|
||||||
new RegexLeaf("NAME", "([\\p{L}0-9_]+)[%s]*"), //
|
new RegexLeaf("NAME", "([\\p{L}0-9_]+)[%s]*"), //
|
||||||
new RegexLeaf("DIM", "(?:\\[(\\d+)x(\\d+)/(\\d+)(z)?\\])?"), //
|
new RegexLeaf("DIM", "(?:\\[(\\d+)x(\\d+)/(?:(\\d+)(z)?|(color))\\])?"), //
|
||||||
new RegexLeaf("[%s]*\\{"), //
|
new RegexLeaf("[%s]*\\{"), //
|
||||||
new RegexLeaf("$"));
|
new RegexLeaf("$"));
|
||||||
}
|
}
|
||||||
@ -63,7 +64,7 @@ public final class FactorySpriteCommand implements SingleMultiFactoryCommand<Uml
|
|||||||
return new RegexConcat(new RegexLeaf("^"), //
|
return new RegexConcat(new RegexLeaf("^"), //
|
||||||
new RegexLeaf("sprite[%s]+\\$?"), //
|
new RegexLeaf("sprite[%s]+\\$?"), //
|
||||||
new RegexLeaf("NAME", "([\\p{L}0-9_]+)[%s]*"), //
|
new RegexLeaf("NAME", "([\\p{L}0-9_]+)[%s]*"), //
|
||||||
new RegexLeaf("DIM", "(?:\\[(\\d+)x(\\d+)/(\\d+)(z)\\])?"), //
|
new RegexLeaf("DIM", "(?:\\[(\\d+)x(\\d+)/(?:(\\d+)(z)|(color))\\])?"), //
|
||||||
new RegexLeaf("[%s]+"), //
|
new RegexLeaf("[%s]+"), //
|
||||||
new RegexLeaf("DATA", "([-_A-Za-z0-9]+)"), //
|
new RegexLeaf("DATA", "([-_A-Za-z0-9]+)"), //
|
||||||
new RegexLeaf("$"));
|
new RegexLeaf("$"));
|
||||||
@ -88,7 +89,7 @@ public final class FactorySpriteCommand implements SingleMultiFactoryCommand<Uml
|
|||||||
return "(?i)^end[%s]?sprite|\\}$";
|
return "(?i)^end[%s]?sprite|\\}$";
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult executeNow(final UmlDiagram system, BlocLines lines) {
|
protected CommandExecutionResult executeNow(final UmlDiagram system, BlocLines lines) {
|
||||||
lines = lines.trim(true);
|
lines = lines.trim(true);
|
||||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||||
|
|
||||||
@ -112,15 +113,19 @@ public final class FactorySpriteCommand implements SingleMultiFactoryCommand<Uml
|
|||||||
} else {
|
} else {
|
||||||
final int width = Integer.parseInt(line0.get("DIM", 0));
|
final int width = Integer.parseInt(line0.get("DIM", 0));
|
||||||
final int height = Integer.parseInt(line0.get("DIM", 1));
|
final int height = Integer.parseInt(line0.get("DIM", 1));
|
||||||
final int nbColor = Integer.parseInt(line0.get("DIM", 2));
|
if (line0.get("DIM", 4) == null) {
|
||||||
if (nbColor != 4 && nbColor != 8 && nbColor != 16) {
|
final int nbLevel = Integer.parseInt(line0.get("DIM", 2));
|
||||||
return CommandExecutionResult.error("Only 4, 8 or 16 graylevel are allowed.");
|
if (nbLevel != 4 && nbLevel != 8 && nbLevel != 16) {
|
||||||
}
|
return CommandExecutionResult.error("Only 4, 8 or 16 graylevel are allowed.");
|
||||||
final SpriteGrayLevel level = SpriteGrayLevel.get(nbColor);
|
}
|
||||||
if (line0.get("DIM", 3) == null) {
|
final SpriteGrayLevel level = SpriteGrayLevel.get(nbLevel);
|
||||||
sprite = level.buildSprite(width, height, strings);
|
if (line0.get("DIM", 3) == null) {
|
||||||
|
sprite = level.buildSprite(width, height, strings);
|
||||||
|
} else {
|
||||||
|
sprite = level.buildSpriteZ(width, height, concat(strings));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sprite = level.buildSpriteZ(width, height, concat(strings));
|
sprite = SpriteColorBuilder4096.buildSprite(strings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
system.addSprite(line0.get("NAME", 0), sprite);
|
system.addSprite(line0.get("NAME", 0), sprite);
|
||||||
|
@ -45,6 +45,9 @@ public class ProtectedCommand<S extends Diagram> implements Command<S> {
|
|||||||
|
|
||||||
public ProtectedCommand(Command<S> cmd) {
|
public ProtectedCommand(Command<S> cmd) {
|
||||||
this.cmd = cmd;
|
this.cmd = cmd;
|
||||||
|
if (cmd == null) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult execute(S system, BlocLines lines) {
|
public CommandExecutionResult execute(S system, BlocLines lines) {
|
||||||
@ -58,8 +61,8 @@ public class ProtectedCommand<S extends Diagram> implements Command<S> {
|
|||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Log.error("Error " + t);
|
Log.error("Error " + t);
|
||||||
t.printStackTrace();
|
t.printStackTrace();
|
||||||
String msg = "You should send a mail to plantuml@gmail.com or post to http://plantuml.com/qa 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);
|
Log.error(msg);
|
||||||
msg += " " + t.toString();
|
msg += " " + t.toString();
|
||||||
return CommandExecutionResult.error(msg, t);
|
return CommandExecutionResult.error(msg, t);
|
||||||
|
@ -66,7 +66,6 @@ public abstract class SingleLineCommand<S extends Diagram> implements Command<S>
|
|||||||
if (lines.size() != 1) {
|
if (lines.size() != 1) {
|
||||||
return CommandControl.NOT_OK;
|
return CommandControl.NOT_OK;
|
||||||
}
|
}
|
||||||
lines = lines.removeInnerComments();
|
|
||||||
if (isCommandForbidden()) {
|
if (isCommandForbidden()) {
|
||||||
return CommandControl.NOT_OK;
|
return CommandControl.NOT_OK;
|
||||||
}
|
}
|
||||||
@ -90,7 +89,6 @@ public abstract class SingleLineCommand<S extends Diagram> implements Command<S>
|
|||||||
if (lines.size() != 1) {
|
if (lines.size() != 1) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
lines = lines.removeInnerComments();
|
|
||||||
final String line = StringUtils.trin(lines.getFirst499());
|
final String line = StringUtils.trin(lines.getFirst499());
|
||||||
if (isForbidden(line)) {
|
if (isForbidden(line)) {
|
||||||
return CommandExecutionResult.error("Syntax error: " + line);
|
return CommandExecutionResult.error("Syntax error: " + line);
|
||||||
|
@ -56,19 +56,32 @@ public abstract class SingleLineCommand2<S extends Diagram> implements Command<S
|
|||||||
this.pattern = pattern;
|
this.pattern = pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean syntaxWithFinalBracket() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public String[] getDescription() {
|
public String[] getDescription() {
|
||||||
return new String[] { pattern.getPattern() };
|
return new String[] { pattern.getPattern() };
|
||||||
}
|
}
|
||||||
|
|
||||||
final public CommandControl isValid(BlocLines lines) {
|
final public CommandControl isValid(BlocLines lines) {
|
||||||
|
if (lines.size() == 2 && syntaxWithFinalBracket()) {
|
||||||
|
return isValidBracket(lines);
|
||||||
|
}
|
||||||
if (lines.size() != 1) {
|
if (lines.size() != 1) {
|
||||||
return CommandControl.NOT_OK;
|
return CommandControl.NOT_OK;
|
||||||
}
|
}
|
||||||
lines = lines.removeInnerComments();
|
|
||||||
if (isCommandForbidden()) {
|
if (isCommandForbidden()) {
|
||||||
return CommandControl.NOT_OK;
|
return CommandControl.NOT_OK;
|
||||||
}
|
}
|
||||||
final String line = StringUtils.trin(lines.getFirst499());
|
final String line = StringUtils.trin(lines.getFirst499());
|
||||||
|
if (syntaxWithFinalBracket() && line.endsWith("{") == false) {
|
||||||
|
final String vline = lines.get499(0).toString() + " {";
|
||||||
|
if (isValid(BlocLines.single(vline)) == CommandControl.OK) {
|
||||||
|
return CommandControl.OK_PARTIAL;
|
||||||
|
}
|
||||||
|
return CommandControl.NOT_OK;
|
||||||
|
}
|
||||||
final boolean result = pattern.match(line);
|
final boolean result = pattern.match(line);
|
||||||
if (result) {
|
if (result) {
|
||||||
actionIfCommandValid();
|
actionIfCommandValid();
|
||||||
@ -76,6 +89,16 @@ public abstract class SingleLineCommand2<S extends Diagram> implements Command<S
|
|||||||
return result ? CommandControl.OK : CommandControl.NOT_OK;
|
return result ? CommandControl.OK : CommandControl.NOT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CommandControl isValidBracket(BlocLines lines) {
|
||||||
|
assert lines.size() == 2;
|
||||||
|
assert syntaxWithFinalBracket();
|
||||||
|
if (StringUtils.trin(lines.get499(1)).equals("{") == false) {
|
||||||
|
return CommandControl.NOT_OK;
|
||||||
|
}
|
||||||
|
final String vline = lines.get499(0).toString() + " {";
|
||||||
|
return isValid(BlocLines.single(vline));
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean isCommandForbidden() {
|
protected boolean isCommandForbidden() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -84,10 +107,13 @@ public abstract class SingleLineCommand2<S extends Diagram> implements Command<S
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final CommandExecutionResult execute(S system, BlocLines lines) {
|
public final CommandExecutionResult execute(S system, BlocLines lines) {
|
||||||
|
if (syntaxWithFinalBracket() && lines.size() == 2) {
|
||||||
|
assert StringUtils.trin(lines.get499(1)).equals("{");
|
||||||
|
lines = BlocLines.single(lines.getFirst499() + " {");
|
||||||
|
}
|
||||||
if (lines.size() != 1) {
|
if (lines.size() != 1) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
lines = lines.removeInnerComments();
|
|
||||||
final String line = StringUtils.trin(lines.getFirst499());
|
final String line = StringUtils.trin(lines.getFirst499());
|
||||||
if (isForbidden(line)) {
|
if (isForbidden(line)) {
|
||||||
return CommandExecutionResult.error("Syntax error: " + line);
|
return CommandExecutionResult.error("Syntax error: " + line);
|
||||||
|
@ -45,7 +45,6 @@ import net.sourceforge.plantuml.CharSequence2;
|
|||||||
import net.sourceforge.plantuml.ErrorUml;
|
import net.sourceforge.plantuml.ErrorUml;
|
||||||
import net.sourceforge.plantuml.ErrorUmlType;
|
import net.sourceforge.plantuml.ErrorUmlType;
|
||||||
import net.sourceforge.plantuml.NewpagedDiagram;
|
import net.sourceforge.plantuml.NewpagedDiagram;
|
||||||
import net.sourceforge.plantuml.OptionFlags;
|
|
||||||
import net.sourceforge.plantuml.PSystemError;
|
import net.sourceforge.plantuml.PSystemError;
|
||||||
import net.sourceforge.plantuml.StringUtils;
|
import net.sourceforge.plantuml.StringUtils;
|
||||||
import net.sourceforge.plantuml.classdiagram.command.CommandHideShowByGender;
|
import net.sourceforge.plantuml.classdiagram.command.CommandHideShowByGender;
|
||||||
@ -53,9 +52,6 @@ import net.sourceforge.plantuml.classdiagram.command.CommandHideShowByVisibility
|
|||||||
import net.sourceforge.plantuml.core.Diagram;
|
import net.sourceforge.plantuml.core.Diagram;
|
||||||
import net.sourceforge.plantuml.core.DiagramType;
|
import net.sourceforge.plantuml.core.DiagramType;
|
||||||
import net.sourceforge.plantuml.core.UmlSource;
|
import net.sourceforge.plantuml.core.UmlSource;
|
||||||
import net.sourceforge.plantuml.suggest.SuggestEngine;
|
|
||||||
import net.sourceforge.plantuml.suggest.SuggestEngineResult;
|
|
||||||
import net.sourceforge.plantuml.suggest.SuggestEngineStatus;
|
|
||||||
import net.sourceforge.plantuml.utils.StartUtils;
|
import net.sourceforge.plantuml.utils.StartUtils;
|
||||||
import net.sourceforge.plantuml.version.IteratorCounter2;
|
import net.sourceforge.plantuml.version.IteratorCounter2;
|
||||||
|
|
||||||
@ -103,7 +99,7 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
|||||||
sys.setSource(source);
|
sys.setSource(source);
|
||||||
return sys;
|
return sys;
|
||||||
}
|
}
|
||||||
sys = executeOneLine(sys, source, it);
|
sys = executeFewLines(sys, source, it);
|
||||||
if (sys instanceof PSystemError) {
|
if (sys instanceof PSystemError) {
|
||||||
return sys;
|
return sys;
|
||||||
}
|
}
|
||||||
@ -113,90 +109,57 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private AbstractPSystem executeOneLine(AbstractPSystem sys, UmlSource source, final IteratorCounter2 it) {
|
private AbstractPSystem executeFewLines(AbstractPSystem sys, UmlSource source, final IteratorCounter2 it) {
|
||||||
final CommandControl commandControl = isValid2(it);
|
final Step step = getCandidate(it);
|
||||||
if (commandControl == CommandControl.NOT_OK) {
|
if (step == null) {
|
||||||
final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?", /* it.currentNum(), */it.peek()
|
final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?", it.peek().getLocation());
|
||||||
.getLocation());
|
return new PSystemError(source, err, null);
|
||||||
if (OptionFlags.getInstance().isUseSuggestEngine2()) {
|
}
|
||||||
final SuggestEngine engine = new SuggestEngine(source, this);
|
|
||||||
final SuggestEngineResult result = engine.tryToSuggest(sys);
|
|
||||||
if (result.getStatus() == SuggestEngineStatus.ONE_SUGGESTION) {
|
|
||||||
err.setSuggest(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sys = new PSystemError(source, err, null);
|
|
||||||
} else if (commandControl == CommandControl.OK_PARTIAL) {
|
|
||||||
final IteratorCounter2 saved = it.cloneMe();
|
|
||||||
final CommandExecutionResult result = manageMultiline2(it, sys);
|
|
||||||
if (result.isOk() == false) {
|
|
||||||
final ErrorUml err = new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(),
|
|
||||||
/* it.currentNum() - 1, */saved.next().getLocation());
|
|
||||||
sys = new PSystemError(source, err, null);
|
|
||||||
|
|
||||||
}
|
final CommandExecutionResult result = sys.executeCommand(step.command, step.blocLines);
|
||||||
} else if (commandControl == CommandControl.OK) {
|
if (result.isOk() == false) {
|
||||||
final CharSequence line = it.next();
|
final ErrorUml err = new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(),
|
||||||
final BlocLines lines = BlocLines.single(line);
|
((CharSequence2) step.blocLines.getFirst499()).getLocation());
|
||||||
Command cmd = getFirstCommandOkForLines(lines);
|
sys = new PSystemError(source, err, result.getDebugLines());
|
||||||
final CommandExecutionResult result = sys.executeCommand(cmd, lines);
|
}
|
||||||
if (result.isOk() == false) {
|
if (result.getNewDiagram() != null) {
|
||||||
final ErrorUml err = new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(),
|
sys = result.getNewDiagram();
|
||||||
/* it.currentNum() - 1, */((CharSequence2) line).getLocation());
|
|
||||||
sys = new PSystemError(source, err,
|
|
||||||
result.getDebugLines());
|
|
||||||
}
|
|
||||||
if (result.getNewDiagram() != null) {
|
|
||||||
sys = result.getNewDiagram();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
assert false;
|
|
||||||
}
|
}
|
||||||
return sys;
|
return sys;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandControl isValid2(final IteratorCounter2 it) {
|
static class Step {
|
||||||
final BlocLines lines = BlocLines.single(it.peek());
|
final Command command;
|
||||||
for (Command cmd : cmds) {
|
final BlocLines blocLines;
|
||||||
final CommandControl result = cmd.isValid(lines);
|
|
||||||
if (result == CommandControl.OK) {
|
Step(Command command, BlocLines blocLines) {
|
||||||
return result;
|
this.command = command;
|
||||||
}
|
this.blocLines = blocLines;
|
||||||
if (result == CommandControl.OK_PARTIAL && isMultilineCommandOk(it.cloneMe(), cmd) != null) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return CommandControl.NOT_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandControl goForwardMultiline(final IteratorCounter2 it) {
|
private Step getCandidate(final IteratorCounter2 it) {
|
||||||
final BlocLines lines = BlocLines.single(it.peek());
|
final BlocLines single = BlocLines.single(it.peek());
|
||||||
for (Command cmd : cmds) {
|
for (Command cmd : cmds) {
|
||||||
final CommandControl result = cmd.isValid(lines);
|
final CommandControl result = cmd.isValid(single);
|
||||||
if (result == CommandControl.OK) {
|
if (result == CommandControl.OK) {
|
||||||
throw new IllegalStateException();
|
it.next();
|
||||||
|
return new Step(cmd, single);
|
||||||
}
|
}
|
||||||
if (result == CommandControl.OK_PARTIAL && isMultilineCommandOk(it, cmd) != null) {
|
if (result == CommandControl.OK_PARTIAL) {
|
||||||
return result;
|
final IteratorCounter2 cloned = it.cloneMe();
|
||||||
}
|
final BlocLines lines = isMultilineCommandOk(cloned, cmd);
|
||||||
}
|
if (lines == null) {
|
||||||
return CommandControl.NOT_OK;
|
continue;
|
||||||
// throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
|
|
||||||
private CommandExecutionResult manageMultiline2(IteratorCounter2 it, AbstractPSystem system) {
|
|
||||||
for (Command cmd : cmds) {
|
|
||||||
if (isMultilineCommandOk(it.cloneMe(), cmd) != null) {
|
|
||||||
final BlocLines lines = isMultilineCommandOk(it, cmd);
|
|
||||||
if (system instanceof NewpagedDiagram) {
|
|
||||||
final NewpagedDiagram newpagedDiagram = (NewpagedDiagram) system;
|
|
||||||
return cmd.execute(newpagedDiagram.getLastDiagram(), lines);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return cmd.execute(system, lines);
|
it.copyStateFrom(cloned);
|
||||||
|
assert lines != null;
|
||||||
|
return new Step(cmd, lines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CommandExecutionResult.ok();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlocLines isMultilineCommandOk(IteratorCounter2 it, Command cmd) {
|
private BlocLines isMultilineCommandOk(IteratorCounter2 it, Command cmd) {
|
||||||
@ -236,38 +199,14 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
|||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
|
|
||||||
final public CommandControl isValid(BlocLines lines) {
|
|
||||||
for (Command cmd : cmds) {
|
|
||||||
final CommandControl result = cmd.isValid(lines);
|
|
||||||
if (result == CommandControl.OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
if (result == CommandControl.OK_PARTIAL) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return CommandControl.NOT_OK;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private Command getFirstCommandOkForLines(BlocLines lines) {
|
|
||||||
for (Command cmd : cmds) {
|
|
||||||
final CommandControl result = cmd.isValid(lines);
|
|
||||||
if (result == CommandControl.OK) {
|
|
||||||
return cmd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new IllegalArgumentException();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract List<Command> createCommands();
|
protected abstract List<Command> createCommands();
|
||||||
|
|
||||||
public abstract AbstractPSystem createEmptyDiagram();
|
public abstract AbstractPSystem createEmptyDiagram();
|
||||||
|
|
||||||
final protected void addCommonCommands(List<Command> cmds) {
|
final protected void addCommonCommands(List<Command> cmds) {
|
||||||
cmds.add(new CommandNope());
|
cmds.add(new CommandNope());
|
||||||
// cmds.add(new CommandComment());
|
// cmds.add(new CommandComment());
|
||||||
// cmds.add(new CommandMultilinesComment());
|
// cmds.add(new CommandMultilinesComment());
|
||||||
cmds.add(new CommandPragma());
|
cmds.add(new CommandPragma());
|
||||||
cmds.add(new CommandTitle());
|
cmds.add(new CommandTitle());
|
||||||
cmds.add(new CommandCaption());
|
cmds.add(new CommandCaption());
|
||||||
|
374
src/net/sourceforge/plantuml/command/UmlDiagramFactoryOld.java
Normal file
374
src/net/sourceforge/plantuml/command/UmlDiagramFactoryOld.java
Normal file
@ -0,0 +1,374 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* 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.command;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.AbstractPSystem;
|
||||||
|
import net.sourceforge.plantuml.CharSequence2;
|
||||||
|
import net.sourceforge.plantuml.ErrorUml;
|
||||||
|
import net.sourceforge.plantuml.ErrorUmlType;
|
||||||
|
import net.sourceforge.plantuml.NewpagedDiagram;
|
||||||
|
import net.sourceforge.plantuml.OptionFlags;
|
||||||
|
import net.sourceforge.plantuml.PSystemError;
|
||||||
|
import net.sourceforge.plantuml.StringUtils;
|
||||||
|
import net.sourceforge.plantuml.classdiagram.command.CommandHideShowByGender;
|
||||||
|
import net.sourceforge.plantuml.classdiagram.command.CommandHideShowByVisibility;
|
||||||
|
import net.sourceforge.plantuml.core.Diagram;
|
||||||
|
import net.sourceforge.plantuml.core.DiagramType;
|
||||||
|
import net.sourceforge.plantuml.core.UmlSource;
|
||||||
|
import net.sourceforge.plantuml.suggest.SuggestEngine;
|
||||||
|
import net.sourceforge.plantuml.suggest.SuggestEngineResult;
|
||||||
|
import net.sourceforge.plantuml.suggest.SuggestEngineStatus;
|
||||||
|
import net.sourceforge.plantuml.utils.StartUtils;
|
||||||
|
import net.sourceforge.plantuml.version.IteratorCounter2;
|
||||||
|
|
||||||
|
public abstract class UmlDiagramFactoryOld extends PSystemAbstractFactory {
|
||||||
|
|
||||||
|
private final List<Command> cmds;
|
||||||
|
|
||||||
|
protected UmlDiagramFactoryOld() {
|
||||||
|
this(DiagramType.UML);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected UmlDiagramFactoryOld(DiagramType type) {
|
||||||
|
super(type);
|
||||||
|
cmds = createCommands();
|
||||||
|
}
|
||||||
|
|
||||||
|
final public Diagram createSystem(UmlSource source) {
|
||||||
|
final IteratorCounter2 it = source.iterator2();
|
||||||
|
final CharSequence2 startLine = it.next();
|
||||||
|
if (StartUtils.isArobaseStartDiagram(startLine) == false) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source.isEmpty()) {
|
||||||
|
return buildEmptyError(source, startLine.getLocation());
|
||||||
|
}
|
||||||
|
AbstractPSystem sys = createEmptyDiagram();
|
||||||
|
|
||||||
|
while (it.hasNext()) {
|
||||||
|
if (StartUtils.isArobaseEndDiagram(it.peek())) {
|
||||||
|
if (sys == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final String err = sys.checkFinalError();
|
||||||
|
if (err != null) {
|
||||||
|
return buildExecutionError(source, err, it.peek().getLocation());
|
||||||
|
}
|
||||||
|
if (source.getTotalLineCount() == 2) {
|
||||||
|
return buildEmptyError(source, it.peek().getLocation());
|
||||||
|
}
|
||||||
|
sys.makeDiagramReady();
|
||||||
|
if (sys.isOk() == false) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
sys.setSource(source);
|
||||||
|
return sys;
|
||||||
|
}
|
||||||
|
sys = executeOneLine(sys, source, it);
|
||||||
|
if (sys instanceof PSystemError) {
|
||||||
|
return sys;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sys.setSource(source);
|
||||||
|
return sys;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private AbstractPSystem executeOneLine(AbstractPSystem sys, UmlSource source, final IteratorCounter2 it) {
|
||||||
|
final CommandControl commandControl = isValid2(it);
|
||||||
|
if (commandControl == CommandControl.NOT_OK) {
|
||||||
|
final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?", /* it.currentNum(), */it.peek()
|
||||||
|
.getLocation());
|
||||||
|
if (OptionFlags.getInstance().isUseSuggestEngine2()) {
|
||||||
|
final SuggestEngine engine = new SuggestEngine(source, this);
|
||||||
|
final SuggestEngineResult result = engine.tryToSuggest(sys);
|
||||||
|
if (result.getStatus() == SuggestEngineStatus.ONE_SUGGESTION) {
|
||||||
|
err.setSuggest(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sys = new PSystemError(source, err, null);
|
||||||
|
// } else if (commandControl == CommandControl.MISSING_FINAL_BRACKET) {
|
||||||
|
// final IteratorCounter2 saved = it.cloneMe();
|
||||||
|
// final CommandExecutionResult result = manageMissingBracket(it, sys);
|
||||||
|
// if (result.isOk() == false) {
|
||||||
|
// final ErrorUml err = new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(),
|
||||||
|
// /* it.currentNum() - 1, */saved.next().getLocation());
|
||||||
|
// sys = new PSystemError(source, err, null);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
} else if (commandControl == CommandControl.OK_PARTIAL) {
|
||||||
|
final IteratorCounter2 saved = it.cloneMe();
|
||||||
|
final CommandExecutionResult result = manageMultiline2(it, sys);
|
||||||
|
if (result.isOk() == false) {
|
||||||
|
final ErrorUml err = new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(),
|
||||||
|
/* it.currentNum() - 1, */saved.next().getLocation());
|
||||||
|
sys = new PSystemError(source, err, null);
|
||||||
|
|
||||||
|
}
|
||||||
|
} else if (commandControl == CommandControl.OK) {
|
||||||
|
final CharSequence line = it.next();
|
||||||
|
final BlocLines lines = BlocLines.single(line);
|
||||||
|
Command cmd = getFirstCommandOkForLines(lines);
|
||||||
|
final CommandExecutionResult result = sys.executeCommand(cmd, lines);
|
||||||
|
if (result.isOk() == false) {
|
||||||
|
final ErrorUml err = new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(),
|
||||||
|
/* it.currentNum() - 1, */((CharSequence2) line).getLocation());
|
||||||
|
sys = new PSystemError(source, err, result.getDebugLines());
|
||||||
|
}
|
||||||
|
if (result.getNewDiagram() != null) {
|
||||||
|
sys = result.getNewDiagram();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert false;
|
||||||
|
}
|
||||||
|
return sys;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandControl isValid2(final IteratorCounter2 it) {
|
||||||
|
final BlocLines lines = BlocLines.single(it.peek());
|
||||||
|
for (Command cmd : cmds) {
|
||||||
|
final CommandControl result = cmd.isValid(lines);
|
||||||
|
if (result == CommandControl.OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
// if (result == CommandControl.MISSING_FINAL_BRACKET && isNextLineBracket(it.cloneMe())) {
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
if (result == CommandControl.OK_PARTIAL && isMultilineCommandOk(it.cloneMe(), cmd) != null) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CommandControl.NOT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isNextLineBracket(final IteratorCounter2 it) {
|
||||||
|
it.next();
|
||||||
|
return (StringUtils.trin(it.peek()).equals("{"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandControl goForwardMultiline(final IteratorCounter2 it) {
|
||||||
|
final BlocLines lines = BlocLines.single(it.peek());
|
||||||
|
for (Command cmd : cmds) {
|
||||||
|
final CommandControl result = cmd.isValid(lines);
|
||||||
|
if (result == CommandControl.OK) {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
if (result == CommandControl.OK_PARTIAL && isMultilineCommandOk(it, cmd) != null) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CommandControl.NOT_OK;
|
||||||
|
// throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommandExecutionResult manageMissingBracket(IteratorCounter2 it, AbstractPSystem system) {
|
||||||
|
for (Command cmd : cmds) {
|
||||||
|
if (cmd instanceof SingleLineCommand2 == false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
SingleLineCommand2 cmd2 = (SingleLineCommand2) cmd;
|
||||||
|
if (cmd2.syntaxWithFinalBracket() == false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (isMultilineBracketOk(it.cloneMe(), cmd) != null) {
|
||||||
|
final BlocLines lines = isMultilineBracketOk(it, cmd);
|
||||||
|
if (system instanceof NewpagedDiagram) {
|
||||||
|
final NewpagedDiagram newpagedDiagram = (NewpagedDiagram) system;
|
||||||
|
return cmd.execute(newpagedDiagram.getLastDiagram(), lines);
|
||||||
|
|
||||||
|
}
|
||||||
|
return cmd.execute(system, lines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CommandExecutionResult.error("No bracket");
|
||||||
|
}
|
||||||
|
|
||||||
|
private BlocLines isMultilineBracketOk(IteratorCounter2 it, Command cmd) {
|
||||||
|
BlocLines lines = new BlocLines();
|
||||||
|
int nb = 0;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
// System.err.println("nb=" + nb);
|
||||||
|
lines = addOneSingleLineManageEmbedded2(it, lines);
|
||||||
|
final CommandControl result = cmd.isValid(lines);
|
||||||
|
if (result == CommandControl.NOT_OK) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (result == CommandControl.OK) {
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
nb++;
|
||||||
|
if (nb > 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommandExecutionResult manageMultiline2(IteratorCounter2 it, AbstractPSystem system) {
|
||||||
|
for (Command cmd : cmds) {
|
||||||
|
if (isMultilineCommandOk(it.cloneMe(), cmd) != null) {
|
||||||
|
final BlocLines lines = isMultilineCommandOk(it, cmd);
|
||||||
|
if (system instanceof NewpagedDiagram) {
|
||||||
|
final NewpagedDiagram newpagedDiagram = (NewpagedDiagram) system;
|
||||||
|
return cmd.execute(newpagedDiagram.getLastDiagram(), lines);
|
||||||
|
|
||||||
|
}
|
||||||
|
return cmd.execute(system, lines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CommandExecutionResult.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
private BlocLines isMultilineCommandOk(IteratorCounter2 it, Command cmd) {
|
||||||
|
BlocLines lines = new BlocLines();
|
||||||
|
int nb = 0;
|
||||||
|
while (it.hasNext()) {
|
||||||
|
lines = addOneSingleLineManageEmbedded2(it, lines);
|
||||||
|
final CommandControl result = cmd.isValid(lines);
|
||||||
|
if (result == CommandControl.NOT_OK) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (result == CommandControl.OK) {
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
nb++;
|
||||||
|
if (cmd instanceof CommandDecoratorMultine && nb > ((CommandDecoratorMultine) cmd).getNbMaxLines()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BlocLines addOneSingleLineManageEmbedded2(IteratorCounter2 it, BlocLines lines) {
|
||||||
|
final CharSequence linetoBeAdded = it.next();
|
||||||
|
lines = lines.add2(linetoBeAdded);
|
||||||
|
if (StringUtils.trinNoTrace(linetoBeAdded).equals("{{")) {
|
||||||
|
while (it.hasNext()) {
|
||||||
|
final CharSequence s = it.next();
|
||||||
|
lines = lines.add2(s);
|
||||||
|
if (StringUtils.trinNoTrace(s).equals("}}")) {
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------
|
||||||
|
|
||||||
|
final public CommandControl isValid(BlocLines lines) {
|
||||||
|
for (Command cmd : cmds) {
|
||||||
|
final CommandControl result = cmd.isValid(lines);
|
||||||
|
if (result == CommandControl.OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (result == CommandControl.OK_PARTIAL) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CommandControl.NOT_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Command getFirstCommandOkForLines(BlocLines lines) {
|
||||||
|
for (Command cmd : cmds) {
|
||||||
|
final CommandControl result = cmd.isValid(lines);
|
||||||
|
if (result == CommandControl.OK) {
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract List<Command> createCommands();
|
||||||
|
|
||||||
|
public abstract AbstractPSystem createEmptyDiagram();
|
||||||
|
|
||||||
|
final protected void addCommonCommands(List<Command> cmds) {
|
||||||
|
cmds.add(new CommandNope());
|
||||||
|
// cmds.add(new CommandComment());
|
||||||
|
// cmds.add(new CommandMultilinesComment());
|
||||||
|
cmds.add(new CommandPragma());
|
||||||
|
cmds.add(new CommandTitle());
|
||||||
|
cmds.add(new CommandCaption());
|
||||||
|
cmds.add(new CommandMultilinesTitle());
|
||||||
|
cmds.add(new CommandMultilinesLegend());
|
||||||
|
|
||||||
|
cmds.add(new CommandFooter());
|
||||||
|
cmds.add(new CommandMultilinesFooter());
|
||||||
|
|
||||||
|
cmds.add(new CommandHeader());
|
||||||
|
cmds.add(new CommandMultilinesHeader());
|
||||||
|
|
||||||
|
cmds.add(new CommandSkinParam());
|
||||||
|
cmds.add(new CommandSkinParamMultilines());
|
||||||
|
cmds.add(new CommandMinwidth());
|
||||||
|
cmds.add(new CommandRotate());
|
||||||
|
cmds.add(new CommandScale());
|
||||||
|
cmds.add(new CommandScaleWidthAndHeight());
|
||||||
|
cmds.add(new CommandScaleWidthOrHeight());
|
||||||
|
cmds.add(new CommandScaleMaxWidth());
|
||||||
|
cmds.add(new CommandScaleMaxHeight());
|
||||||
|
cmds.add(new CommandScaleMaxWidthAndHeight());
|
||||||
|
cmds.add(new CommandAffineTransform());
|
||||||
|
cmds.add(new CommandAffineTransformMultiline());
|
||||||
|
cmds.add(new CommandHideUnlinked());
|
||||||
|
final FactorySpriteCommand factorySpriteCommand = new FactorySpriteCommand();
|
||||||
|
cmds.add(factorySpriteCommand.createMultiLine(false));
|
||||||
|
cmds.add(factorySpriteCommand.createSingleLine());
|
||||||
|
cmds.add(new CommandSpriteFile());
|
||||||
|
|
||||||
|
cmds.add(new CommandHideShowByVisibility());
|
||||||
|
cmds.add(new CommandHideShowByGender());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
final public List<String> getDescription() {
|
||||||
|
final List<String> result = new ArrayList<String>();
|
||||||
|
for (Command cmd : createCommands()) {
|
||||||
|
result.addAll(Arrays.asList(cmd.getDescription()));
|
||||||
|
}
|
||||||
|
return Collections.unmodifiableList(result);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -101,7 +101,7 @@ public final class FactoryNoteCommand implements SingleMultiFactoryCommand<Abstr
|
|||||||
return "(?i)^[%s]*end[%s]?note$";
|
return "(?i)^[%s]*end[%s]?note$";
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult executeNow(final AbstractEntityDiagram system, BlocLines lines) {
|
protected CommandExecutionResult executeNow(final AbstractEntityDiagram system, BlocLines lines) {
|
||||||
// StringUtils.trim(lines, false);
|
// StringUtils.trim(lines, false);
|
||||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||||
lines = lines.subExtract(1, 1);
|
lines = lines.subExtract(1, 1);
|
||||||
|
@ -137,7 +137,7 @@ public final class FactoryNoteOnEntityCommand implements SingleMultiFactoryComma
|
|||||||
return "(?i)^[%s]*(end[%s]?note)$";
|
return "(?i)^[%s]*(end[%s]?note)$";
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult executeNow(final AbstractEntityDiagram system, BlocLines lines) {
|
protected CommandExecutionResult executeNow(final AbstractEntityDiagram system, BlocLines lines) {
|
||||||
// StringUtils.trim(lines, false);
|
// StringUtils.trim(lines, false);
|
||||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||||
lines = lines.subExtract(1, 1);
|
lines = lines.subExtract(1, 1);
|
||||||
|
@ -87,7 +87,7 @@ public final class FactoryNoteOnLinkCommand implements SingleMultiFactoryCommand
|
|||||||
return "(?i)^[%s]*end[%s]?note$";
|
return "(?i)^[%s]*end[%s]?note$";
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult executeNow(final CucaDiagram system, BlocLines lines) {
|
protected CommandExecutionResult executeNow(final CucaDiagram system, BlocLines lines) {
|
||||||
final String line0 = lines.getFirst499().toString();
|
final String line0 = lines.getFirst499().toString();
|
||||||
lines = lines.subExtract(1, 1);
|
lines = lines.subExtract(1, 1);
|
||||||
lines = lines.removeEmptyColumns();
|
lines = lines.removeEmptyColumns();
|
||||||
|
@ -98,7 +98,7 @@ public final class FactoryTipOnEntityCommand implements SingleMultiFactoryComman
|
|||||||
return "(?i)^[%s]*(end[%s]?note)$";
|
return "(?i)^[%s]*(end[%s]?note)$";
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult executeNow(final AbstractEntityDiagram system, BlocLines lines) {
|
protected CommandExecutionResult executeNow(final AbstractEntityDiagram system, BlocLines lines) {
|
||||||
// StringUtils.trim(lines, false);
|
// StringUtils.trim(lines, false);
|
||||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||||
lines = lines.subExtract(1, 1);
|
lines = lines.subExtract(1, 1);
|
||||||
|
@ -108,7 +108,7 @@ public final class FactorySequenceNoteCommand implements SingleMultiFactoryComma
|
|||||||
return "(?i)^end[%s]?(note|hnote|rnote)$";
|
return "(?i)^end[%s]?(note|hnote|rnote)$";
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult executeNow(final SequenceDiagram system, BlocLines lines) {
|
protected CommandExecutionResult executeNow(final SequenceDiagram system, BlocLines lines) {
|
||||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||||
lines = lines.subExtract(1, 1);
|
lines = lines.subExtract(1, 1);
|
||||||
lines = lines.removeEmptyColumns();
|
lines = lines.removeEmptyColumns();
|
||||||
|
@ -102,7 +102,7 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto
|
|||||||
return "(?i)^[%s]*end[%s]?note$";
|
return "(?i)^[%s]*end[%s]?note$";
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult executeNow(final SequenceDiagram system, BlocLines lines) {
|
protected CommandExecutionResult executeNow(final SequenceDiagram system, BlocLines lines) {
|
||||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||||
lines = lines.subExtract(1, 1);
|
lines = lines.subExtract(1, 1);
|
||||||
lines = lines.removeEmptyColumns();
|
lines = lines.removeEmptyColumns();
|
||||||
|
@ -113,7 +113,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF
|
|||||||
return "(?i)^end[%s]?(note|hnote|rnote)$";
|
return "(?i)^end[%s]?(note|hnote|rnote)$";
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult executeNow(final SequenceDiagram system, BlocLines lines) {
|
protected CommandExecutionResult executeNow(final SequenceDiagram system, BlocLines lines) {
|
||||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||||
lines = lines.subExtract(1, 1);
|
lines = lines.subExtract(1, 1);
|
||||||
lines = lines.removeEmptyColumns();
|
lines = lines.removeEmptyColumns();
|
||||||
|
@ -158,7 +158,7 @@ public class AtomImg implements Atom {
|
|||||||
|
|
||||||
public void drawU(UGraphic ug) {
|
public void drawU(UGraphic ug) {
|
||||||
// final double h = calculateDimension(ug.getStringBounder()).getHeight();
|
// final double h = calculateDimension(ug.getStringBounder()).getHeight();
|
||||||
ug.draw(new UImage(image, scale));
|
ug.draw(new UImage(image).scale(scale));
|
||||||
// tileImage.drawU(ug.apply(new UTranslate(0, -h)));
|
// tileImage.drawU(ug.apply(new UTranslate(0, -h)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,11 +90,12 @@ public class AtomMath implements Atom {
|
|||||||
back = getColor(background == null ? ug.getParam().getBackcolor() : background, Color.WHITE);
|
back = getColor(background == null ? ug.getParam().getBackcolor() : background, Color.WHITE);
|
||||||
}
|
}
|
||||||
final Color fore = getColor(foreground, Color.BLACK);
|
final Color fore = getColor(foreground, Color.BLACK);
|
||||||
|
final double dpiFactor = ug.dpiFactor();
|
||||||
if (isSvg) {
|
if (isSvg) {
|
||||||
final SvgString svg = math.getSvg(scale, fore, back);
|
final SvgString svg = math.getSvg(scale, fore, back);
|
||||||
ug.draw(new UImageSvg(svg));
|
ug.draw(new UImageSvg(svg));
|
||||||
} else {
|
} else {
|
||||||
ug.draw(new UImage(math.getImage(scale, fore, back)));
|
ug.draw(new UImage(math.getImage(scale * dpiFactor, fore, back)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,14 +106,17 @@ public class StripeTable implements Stripe {
|
|||||||
return line.substring(idx2 + 1);
|
return line.substring(idx2 + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String hiddenBar = "\uE000";
|
||||||
|
|
||||||
private void analyzeAndAddInternal(String line, Mode mode) {
|
private void analyzeAndAddInternal(String line, Mode mode) {
|
||||||
|
line = line.replace("\\|", hiddenBar);
|
||||||
HtmlColor lineBackColor = getBackOrFrontColor(line, 0);
|
HtmlColor lineBackColor = getBackOrFrontColor(line, 0);
|
||||||
if (lineBackColor != null) {
|
if (lineBackColor != null) {
|
||||||
line = withouBackColor(line);
|
line = withouBackColor(line);
|
||||||
}
|
}
|
||||||
table.newLine(lineBackColor);
|
table.newLine(lineBackColor);
|
||||||
for (final StringTokenizer st = new StringTokenizer(line, "|"); st.hasMoreTokens();) {
|
for (final StringTokenizer st = new StringTokenizer(line, "|"); st.hasMoreTokens();) {
|
||||||
String v = st.nextToken();
|
String v = st.nextToken().replace(hiddenBar.charAt(0), '|');
|
||||||
HtmlColor cellBackColor = getBackOrFrontColor(v, 0);
|
HtmlColor cellBackColor = getBackOrFrontColor(v, 0);
|
||||||
if (cellBackColor != null) {
|
if (cellBackColor != null) {
|
||||||
v = withouBackColor(v);
|
v = withouBackColor(v);
|
||||||
|
@ -107,7 +107,7 @@ public class CommandCreateElementMultilines extends CommandMultilines2<AbstractE
|
|||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult executeNow(AbstractEntityDiagram diagram, BlocLines lines) {
|
protected CommandExecutionResult executeNow(AbstractEntityDiagram diagram, BlocLines lines) {
|
||||||
lines = lines.trim(false);
|
lines = lines.trim(false);
|
||||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||||
final String symbol = StringUtils.goUpperCase(line0.get("TYPE", 0));
|
final String symbol = StringUtils.goUpperCase(line0.get("TYPE", 0));
|
||||||
|
@ -67,19 +67,19 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
|
|||||||
import net.sourceforge.plantuml.version.PSystemVersion;
|
import net.sourceforge.plantuml.version.PSystemVersion;
|
||||||
|
|
||||||
public class PSystemDonors extends AbstractPSystem {
|
public class PSystemDonors extends AbstractPSystem {
|
||||||
public static final String DONORS = "6rO702mEpFCVHV0StDQFZQ4KYXIQJO-ICGuxFM7I4cYu9-jpVDvE66nDSPvH5Fk0vi0crmphPDt6pjY2"
|
public static final String DONORS = "6tC70AmEU9ELAuNYZT_MZn6AGOgeeHNOWjgQuZoZA1P0SxnDhXdMoRgDdR45mND5SGKL8Az2C-THCiPX"
|
||||||
+ "uBcYk88Aa1TYgjX-ouJsTXreG_9MC8x0dygP_yi5DYP8xwonAVBmEA0r5cwBnhJ_ZygwwBzeW4wmQLIs"
|
+ "qGYJjjcQVk6-VTu2CLLilsL2UtyTQ4BoLZ2km4tbpF_b0XiJv0R8GZti1NIpXNlZcZIctJyBxB_e5sW1"
|
||||||
+ "B2eDyYodLy4aXy6fi-EKKF9GZEahKfJronQWb8u5cMrdTOGVP9jzenQfIMis3PbP0ehBI95eFZPQsNTo"
|
+ "JwFBbaMbGPxbz2gOv30uCySffUIX6EKhKjYwiGMmql4WLnkhGtmZTVQTMa2JrcmQChC65Cj8aMW-Dbex"
|
||||||
+ "-rx62I1QVZzWAy4E9PAR732Ml16Z8zC3WjGeRiO6QjvvmeC93LHemnSbgQaj93BAm417xXueeFHdd83O"
|
+ "3h1z10CdEhIhmmPaXn87UODnG7qZHacvWWQPKToC3TMyymI32JTKs8alIb9pj93CA4C7EhGjK83rPu80"
|
||||||
+ "9sMKv6p3su3yBR95HOEWZkytflF7XsKfUtvfE4OUa7FG2g02o7-W6_wqDdE9SHcR0ZFaNHZ7ib78QwgN"
|
+ "s2VbbEHiwMr0mHRPegP1KkTUTwQB_SEoL22_D9m07JG7hQ1M0FaFTCEViyrSubp7hgWPygwCSzauvBNH"
|
||||||
+ "KTuyqDTQ5mRWPV9aHk-N7stV5j8vvJh7hyu6UTMGbKTx66kySWdk-SzS2ksB1LG_WBRjEn3Z_SFvpK9t"
|
+ "gzZVFD3NMLS6oilcnSnyBJ-gMmlfd79TurTNW_pGa9MzFOmrNbb2UFutbqBxOW4S7q37MaF5-FlX_6OX"
|
||||||
+ "28yfTI6LS_pE_IO2eXjBOQ4tSSbgzfztwHP3HVDepc8ySh-EjnA17LnNucxeSYr_YZedb6mQwjTBNXqw"
|
+ "7S9ZIbt8mJbvPxk905bbAIpuBYvPBV3pBc6nkbWUpLayH-VNkLOoe8Ch4fkXZsi5iwjpHadLKF-yv5NN"
|
||||||
+ "hYBN-DNcVObUaqr3_7-jbZA3T0UjxiA6ws8493WMLkNYeel0OT2_8RSakP7Q3fD7_R1yYP_t9yczroA1"
|
+ "yIboJT1itfVeHx9fIFp_BMLMqnsqteGFroM8KgElhAh5HHS1qw1_Gsu1kGFLq-JHTLg-9Bxt1-JUUv50"
|
||||||
+ "A6mws3_LP-0cDxim6xfqOXCF0AysYNQZe_0WCmYh0nq7bMTas5t_kqdFiAanQTxfre5XDuRwHxgxSZDz"
|
+ "53OJx9-wPjIdtBo4UM9Bfwfu01Zj4kr6X_4WCuYg0rq7bMTas5s_tQHdsDGOEJTwHRrfDmQkZtIwSZDz"
|
||||||
+ "CvTq2qE_B9hjkzep70NSYXFAuNUr_hOAPN89xwP5Q7oImVejp1c1z1bHzZrjoNHJ1ymiZmMlwkBltUta"
|
+ "DnVu3CEWB9e3XzfR70NSXnFCeTNYRHN3vXhUROlKU2U3_JNC6O7q6L6E8st9zAcEChCybhofIxoRsyMV"
|
||||||
+ "pqFd_xwzMzHmTFvxjtzqVPl9p-RKKeyeQzTWsDlWiZPhuqLr0MrBvNcWEpCk0gvN9XigkOMEp72MGyoJ"
|
+ "Xox-wTsY5ZhlRly8VR_9hwIMUiHuT0s6lKMNzLkRB3eMu5iZ8u7BW9tMxSRaG2MtqAaDPqLFSGBMlQrp"
|
||||||
+ "95JsWuDZwC5DdQ1jFR8pDIrXRZrMoS2Mv8VKdJGgjGDFsETsU-SPeqM1_SbvErOzrBSXnTy558aXmLCg"
|
+ "S5oBuA9ftQnaPsedrypQGGThaXzqD61KP2UIWw_jpiWp7ekgzYVddLZrKD-757yNK2o614-fKBOHKdI5"
|
||||||
+ "m7s45FMmEPrCDywsjBkJxtfhymN3DQfnuKw3meybchJSOF4fm8oT_80qdff8j97NSIPA0B_Zz1lq3DdF" + "hgxRk8wMLW00";
|
+ "pUbamhZTC-uEtiUjpHUgs_ZcmXC61HzBj6cvmUjJAlSKya5J1v0wQrNoqiV42E1tVFq6FS-j3ZJAQ6cL" + "SNPmGsH9";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
|
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
|
||||||
|
@ -49,6 +49,9 @@ public abstract class UGraphicDelegator implements UGraphic {
|
|||||||
return ug.matchesProperty(propertyName);
|
return ug.matchesProperty(propertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double dpiFactor() {
|
||||||
|
return ug.dpiFactor();
|
||||||
|
}
|
||||||
|
|
||||||
public UGraphicDelegator(UGraphic ug) {
|
public UGraphicDelegator(UGraphic ug) {
|
||||||
this.ug = ug;
|
this.ug = ug;
|
||||||
|
@ -82,10 +82,14 @@ public class AsciiMath implements ScientificEquation {
|
|||||||
final ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
|
final ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
|
||||||
engine.eval(JAVASCRIPT_CODE);
|
engine.eval(JAVASCRIPT_CODE);
|
||||||
final Invocable inv = (Invocable) engine;
|
final Invocable inv = (Invocable) engine;
|
||||||
this.tex = (String) inv.invokeFunction("plantuml", form);
|
this.tex = patchColor((String) inv.invokeFunction("plantuml", form));
|
||||||
this.builder = new LatexBuilder(tex);
|
this.builder = new LatexBuilder(tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String patchColor(String latex) {
|
||||||
|
return latex.replace("\\color{", "\\textcolor{");
|
||||||
|
}
|
||||||
|
|
||||||
public Dimension2D getDimension() {
|
public Dimension2D getDimension() {
|
||||||
return builder.getDimension();
|
return builder.getDimension();
|
||||||
}
|
}
|
||||||
|
@ -41,12 +41,19 @@ import java.io.OutputStream;
|
|||||||
|
|
||||||
import net.sourceforge.plantuml.AbstractPSystem;
|
import net.sourceforge.plantuml.AbstractPSystem;
|
||||||
import net.sourceforge.plantuml.FileFormatOption;
|
import net.sourceforge.plantuml.FileFormatOption;
|
||||||
|
import net.sourceforge.plantuml.StringUtils;
|
||||||
import net.sourceforge.plantuml.core.DiagramDescription;
|
import net.sourceforge.plantuml.core.DiagramDescription;
|
||||||
import net.sourceforge.plantuml.core.ImageData;
|
import net.sourceforge.plantuml.core.ImageData;
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||||
|
import net.sourceforge.plantuml.graphic.HtmlColorSetSimple;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
|
||||||
|
|
||||||
public class PSystemMath extends AbstractPSystem {
|
public class PSystemMath extends AbstractPSystem {
|
||||||
|
|
||||||
private String math = "";
|
private String math = "";
|
||||||
|
private float scale = 1;
|
||||||
|
private Color color = Color.BLACK;
|
||||||
|
private Color backColor = Color.WHITE;
|
||||||
|
|
||||||
public PSystemMath() {
|
public PSystemMath() {
|
||||||
}
|
}
|
||||||
@ -59,11 +66,53 @@ public class PSystemMath extends AbstractPSystem {
|
|||||||
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
|
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
final ScientificEquationSafe asciiMath = ScientificEquationSafe.fromAsciiMath(math);
|
final ScientificEquationSafe asciiMath = ScientificEquationSafe.fromAsciiMath(math);
|
||||||
return asciiMath.export(os, fileFormat, 1, Color.BLACK, Color.WHITE);
|
return asciiMath.export(os, fileFormat, scale, color, backColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doCommandLine(String line) {
|
public void doCommandLine(String line) {
|
||||||
this.math = line;
|
final String lineLower = StringUtils.trin(StringUtils.goLowerCase(line));
|
||||||
|
final String colorParam = "color ";
|
||||||
|
final String backParam = "backgroundcolor ";
|
||||||
|
if (lineLower.startsWith(colorParam)) {
|
||||||
|
final Color col3 = getColor(line.substring(colorParam.length()));
|
||||||
|
if (col3 != null) {
|
||||||
|
color = col3;
|
||||||
|
}
|
||||||
|
} else if (lineLower.startsWith(backParam)) {
|
||||||
|
final Color col3 = getColor(line.substring(backParam.length()));
|
||||||
|
if (col3 != null) {
|
||||||
|
backColor = col3;
|
||||||
|
}
|
||||||
|
} else if (lineLower.startsWith("scale ")) {
|
||||||
|
final String value = line.substring("scale ".length());
|
||||||
|
try {
|
||||||
|
final float scale1 = Float.parseFloat(value);
|
||||||
|
if (scale1 > 0) {
|
||||||
|
scale = scale1;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else if (lineLower.startsWith("dpi ")) {
|
||||||
|
final String value = line.substring("dpi ".length());
|
||||||
|
try {
|
||||||
|
final float dpi1 = Float.parseFloat(value);
|
||||||
|
if (dpi1 > 0) {
|
||||||
|
scale = dpi1 / 96;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.math = line;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Color getColor(final String col) {
|
||||||
|
final HtmlColor col2 = new HtmlColorSetSimple().getColorIfValid(col);
|
||||||
|
final Color col3 = new ColorMapperIdentity().getMappedColor(col2);
|
||||||
|
return col3;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ public class CommandCreateEntityObjectMultilines extends CommandMultilines2<Abst
|
|||||||
return "(?i)^[%s]*\\}[%s]*$";
|
return "(?i)^[%s]*\\}[%s]*$";
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult executeNow(AbstractClassOrObjectDiagram diagram, BlocLines lines) {
|
protected CommandExecutionResult executeNow(AbstractClassOrObjectDiagram diagram, BlocLines lines) {
|
||||||
lines = lines.trim(true);
|
lines = lines.trim(true);
|
||||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||||
final IEntity entity = executeArg0(diagram, line0);
|
final IEntity entity = executeArg0(diagram, line0);
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package net.sourceforge.plantuml.pdf;
|
package net.sourceforge.plantuml.pdf;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
@ -50,6 +51,9 @@ public class PdfConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// https://stackoverflow.com/questions/12579468/how-to-set-log4j-property-file
|
||||||
|
System.setProperty("log4j.debug", "false");
|
||||||
|
|
||||||
final Class<?> clSVGConverter = Class.forName("org.apache.batik.apps.rasterizer.SVGConverter");
|
final Class<?> clSVGConverter = Class.forName("org.apache.batik.apps.rasterizer.SVGConverter");
|
||||||
|
|
||||||
final Object converter = clSVGConverter.newInstance();
|
final Object converter = clSVGConverter.newInstance();
|
||||||
|
@ -266,7 +266,7 @@ public class PreprocessorInclude implements ReadLine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private InputStream getStdlibInputStream(String filename) {
|
private InputStream getStdlibInputStream(String filename) {
|
||||||
return StdlibOld.getResourceAsStream(filename);
|
return Stdlib.getResourceAsStream(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
private InputStream getStdlibInputStreamOld(String filename) {
|
private InputStream getStdlibInputStreamOld(String filename) {
|
||||||
@ -285,16 +285,17 @@ public class PreprocessorInclude implements ReadLine {
|
|||||||
if (is == null) {
|
if (is == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
final String description = "<" + filename + ">";
|
||||||
try {
|
try {
|
||||||
if (StartDiagramExtractReader.containsStartDiagram(s, is)) {
|
if (StartDiagramExtractReader.containsStartDiagram(s, is, description)) {
|
||||||
is = getStdlibInputStream(filename);
|
is = getStdlibInputStream(filename);
|
||||||
return new StartDiagramExtractReader(s, is);
|
return new StartDiagramExtractReader(s, is, description);
|
||||||
}
|
}
|
||||||
is = getStdlibInputStream(filename);
|
is = getStdlibInputStream(filename);
|
||||||
if (is == null) {
|
if (is == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new ReadLineReader(new InputStreamReader(is), filename);
|
return ReadLineReader.create(new InputStreamReader(is), filename);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return new ReadLineSimple(s, e.toString());
|
return new ReadLineSimple(s, e.toString());
|
||||||
}
|
}
|
||||||
@ -318,10 +319,10 @@ public class PreprocessorInclude implements ReadLine {
|
|||||||
}
|
}
|
||||||
if (charset == null) {
|
if (charset == null) {
|
||||||
Log.info("Using default charset");
|
Log.info("Using default charset");
|
||||||
return new ReadLineReader(new FileReader(f), f.getAbsolutePath(), s.getLocation());
|
return ReadLineReader.create(new FileReader(f), f.getAbsolutePath(), s.getLocation());
|
||||||
}
|
}
|
||||||
Log.info("Using charset " + charset);
|
Log.info("Using charset " + charset);
|
||||||
return new ReadLineReader(new InputStreamReader(new FileInputStream(f), charset), f.getAbsolutePath(),
|
return ReadLineReader.create(new InputStreamReader(new FileInputStream(f), charset), f.getAbsolutePath(),
|
||||||
s.getLocation());
|
s.getLocation());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return new ReadLineSimple(s, e.toString());
|
return new ReadLineSimple(s, e.toString());
|
||||||
@ -337,10 +338,10 @@ public class PreprocessorInclude implements ReadLine {
|
|||||||
final InputStream is = url.openStream();
|
final InputStream is = url.openStream();
|
||||||
if (charset == null) {
|
if (charset == null) {
|
||||||
Log.info("Using default charset");
|
Log.info("Using default charset");
|
||||||
return new ReadLineReader(new InputStreamReader(is), url.toString(), s.getLocation());
|
return ReadLineReader.create(new InputStreamReader(is), url.toString(), s.getLocation());
|
||||||
}
|
}
|
||||||
Log.info("Using charset " + charset);
|
Log.info("Using charset " + charset);
|
||||||
return new ReadLineReader(new InputStreamReader(is, charset), url.toString(), s.getLocation());
|
return ReadLineReader.create(new InputStreamReader(is, charset), url.toString(), s.getLocation());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return new ReadLineSimple(s, e.toString());
|
return new ReadLineSimple(s, e.toString());
|
||||||
}
|
}
|
||||||
|
@ -50,15 +50,26 @@ public class ReadLineReader implements ReadLine {
|
|||||||
private final BufferedReader br;
|
private final BufferedReader br;
|
||||||
private LineLocationImpl location;
|
private LineLocationImpl location;
|
||||||
|
|
||||||
public ReadLineReader(Reader reader, String desc, LineLocation parent) {
|
private ReadLineReader(Reader reader, String description, LineLocation parent) {
|
||||||
|
if (description == null) {
|
||||||
|
description = "?";
|
||||||
|
}
|
||||||
br = new BufferedReader(reader);
|
br = new BufferedReader(reader);
|
||||||
location = new LineLocationImpl(desc, parent);
|
location = new LineLocationImpl(description, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReadLineReader(Reader reader, String desc) {
|
private ReadLineReader(Reader reader, String desc) {
|
||||||
this(reader, desc, null);
|
this(reader, desc, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ReadLine create(Reader reader, String description) {
|
||||||
|
return new ReadLineReader(reader, description, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ReadLine create(Reader reader, String description, LineLocation parent) {
|
||||||
|
return new ReadLineReader(reader, description, parent);
|
||||||
|
}
|
||||||
|
|
||||||
public CharSequence2 readLine() throws IOException {
|
public CharSequence2 readLine() throws IOException {
|
||||||
String s = br.readLine();
|
String s = br.readLine();
|
||||||
location = location.oneLineRead();
|
location = location.oneLineRead();
|
||||||
|
@ -60,8 +60,8 @@ public class StartDiagramExtractReader implements ReadLine {
|
|||||||
this(getReadLine(s, url, charset), uid);
|
this(getReadLine(s, url, charset), uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StartDiagramExtractReader(CharSequence2 s, InputStream is) {
|
public StartDiagramExtractReader(CharSequence2 s, InputStream is, String desc) {
|
||||||
this(getReadLine(s, is), null);
|
this(getReadLine(s, is, desc), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private StartDiagramExtractReader(ReadLine raw, String suf) {
|
private StartDiagramExtractReader(ReadLine raw, String suf) {
|
||||||
@ -107,29 +107,29 @@ public class StartDiagramExtractReader implements ReadLine {
|
|||||||
try {
|
try {
|
||||||
if (charset == null) {
|
if (charset == null) {
|
||||||
Log.info("Using default charset");
|
Log.info("Using default charset");
|
||||||
return new UncommentReadLine(new ReadLineReader(new FileReader(f), f.getAbsolutePath()));
|
return new UncommentReadLine(ReadLineReader.create(new FileReader(f), f.getAbsolutePath()));
|
||||||
}
|
}
|
||||||
Log.info("Using charset " + charset);
|
Log.info("Using charset " + charset);
|
||||||
return new UncommentReadLine(new ReadLineReader(new InputStreamReader(new FileInputStream(f), charset),
|
return new UncommentReadLine(ReadLineReader.create(new InputStreamReader(new FileInputStream(f), charset),
|
||||||
f.getAbsolutePath()));
|
f.getAbsolutePath()));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return new ReadLineSimple(s, e.toString());
|
return new ReadLineSimple(s, e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReadLine getReadLine(CharSequence2 s, InputStream is) {
|
private static ReadLine getReadLine(CharSequence2 s, InputStream is, String description) {
|
||||||
return new UncommentReadLine(new ReadLineReader(new InputStreamReader(is), null));
|
return new UncommentReadLine(ReadLineReader.create(new InputStreamReader(is), description));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ReadLine getReadLine(CharSequence2 s, URL url, String charset) {
|
private static ReadLine getReadLine(CharSequence2 s, URL url, String charset) {
|
||||||
try {
|
try {
|
||||||
if (charset == null) {
|
if (charset == null) {
|
||||||
Log.info("Using default charset");
|
Log.info("Using default charset");
|
||||||
return new UncommentReadLine(
|
return new UncommentReadLine(ReadLineReader.create(new InputStreamReader(url.openStream()),
|
||||||
new ReadLineReader(new InputStreamReader(url.openStream()), url.toString()));
|
url.toString()));
|
||||||
}
|
}
|
||||||
Log.info("Using charset " + charset);
|
Log.info("Using charset " + charset);
|
||||||
return new UncommentReadLine(new ReadLineReader(new InputStreamReader(url.openStream(), charset),
|
return new UncommentReadLine(ReadLineReader.create(new InputStreamReader(url.openStream(), charset),
|
||||||
url.toString()));
|
url.toString()));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return new ReadLineSimple(s, e.toString());
|
return new ReadLineSimple(s, e.toString());
|
||||||
@ -146,8 +146,8 @@ public class StartDiagramExtractReader implements ReadLine {
|
|||||||
return containsStartDiagram(r);
|
return containsStartDiagram(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public boolean containsStartDiagram(CharSequence2 s, InputStream is) throws IOException {
|
static public boolean containsStartDiagram(CharSequence2 s, InputStream is, String description) throws IOException {
|
||||||
final ReadLine r = getReadLine(s, is);
|
final ReadLine r = getReadLine(s, is, description);
|
||||||
return containsStartDiagram(r);
|
return containsStartDiagram(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
307
src/net/sourceforge/plantuml/preproc/Stdlib.java
Normal file
307
src/net/sourceforge/plantuml/preproc/Stdlib.java
Normal file
@ -0,0 +1,307 @@
|
|||||||
|
package net.sourceforge.plantuml.preproc;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.DataInputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.lang.ref.SoftReference;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.Log;
|
||||||
|
import net.sourceforge.plantuml.brotli.BrotliInputStream;
|
||||||
|
|
||||||
|
public class Stdlib {
|
||||||
|
|
||||||
|
private static final Map<String, Stdlib> all = new ConcurrentHashMap<String, Stdlib>();
|
||||||
|
private static final String SEPARATOR = "\uF8FF";
|
||||||
|
private static final Pattern sizePattern = Pattern.compile("\\[(\\d+)x(\\d+)/16\\]");
|
||||||
|
|
||||||
|
private final Map<String, SoftReference<String>> cache = new ConcurrentHashMap<String, SoftReference<String>>();
|
||||||
|
private final String name;
|
||||||
|
private final Map<String, String> info = new HashMap<String, String>();
|
||||||
|
|
||||||
|
public static InputStream getResourceAsStream(String fullname) {
|
||||||
|
fullname = fullname.toLowerCase().replace(".puml", "");
|
||||||
|
final int last = fullname.indexOf('/');
|
||||||
|
if (last == -1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
final Stdlib folder = retrieve(fullname.substring(0, last));
|
||||||
|
if (folder == null || folder.info.size() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final String data = folder.loadRessource(fullname.substring(last + 1));
|
||||||
|
if (data == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new ByteArrayInputStream(data.getBytes("UTF-8"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Stdlib retrieve(final String name) throws IOException {
|
||||||
|
Stdlib result = all.get(name);
|
||||||
|
if (result == null) {
|
||||||
|
final DataInputStream dataStream = getDataStream(name);
|
||||||
|
if (dataStream == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
final String info = dataStream.readUTF();
|
||||||
|
dataStream.close();
|
||||||
|
result = new Stdlib(name, info);
|
||||||
|
all.put(name, result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String loadRessource(String file) throws IOException {
|
||||||
|
final SoftReference<String> cached = cache.get(file.toLowerCase());
|
||||||
|
if (cached != null) {
|
||||||
|
final String cachedResult = cached.get();
|
||||||
|
if (cachedResult != null) {
|
||||||
|
return cachedResult;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final DataInputStream dataStream = getDataStream();
|
||||||
|
if (dataStream == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
dataStream.readUTF();
|
||||||
|
final InputStream spriteStream = getSpriteStream();
|
||||||
|
if (spriteStream == null) {
|
||||||
|
dataStream.close();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
StringBuilder found = null;
|
||||||
|
while (true) {
|
||||||
|
final String filename = dataStream.readUTF();
|
||||||
|
if (filename.equals(SEPARATOR)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (filename.equalsIgnoreCase(file)) {
|
||||||
|
found = new StringBuilder();
|
||||||
|
}
|
||||||
|
while (true) {
|
||||||
|
final String s = dataStream.readUTF();
|
||||||
|
if (s.equals(SEPARATOR)) {
|
||||||
|
if (found != null) {
|
||||||
|
final String result = found.toString();
|
||||||
|
cache.put(file.toLowerCase(), new SoftReference<String>(result));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (found != null) {
|
||||||
|
found.append(s);
|
||||||
|
found.append("\n");
|
||||||
|
}
|
||||||
|
if (isSpriteLine(s)) {
|
||||||
|
final Matcher m = sizePattern.matcher(s);
|
||||||
|
final boolean ok = m.find();
|
||||||
|
if (ok == false) {
|
||||||
|
throw new IOException(s);
|
||||||
|
}
|
||||||
|
final int width = Integer.parseInt(m.group(1));
|
||||||
|
final int height = Integer.parseInt(m.group(2));
|
||||||
|
final String sprite = readSprite(width, height, spriteStream);
|
||||||
|
if (found != null) {
|
||||||
|
found.append(sprite);
|
||||||
|
found.append("}\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
dataStream.close();
|
||||||
|
spriteStream.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Stdlib(String name, String info) throws IOException {
|
||||||
|
this.name = name;
|
||||||
|
fillMap(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String readSprite(int width, int height, InputStream inputStream) throws IOException {
|
||||||
|
final StringBuilder result = new StringBuilder();
|
||||||
|
final int nbLines = (height + 1) / 2;
|
||||||
|
int line = 0;
|
||||||
|
for (int j = 0; j < nbLines; j++) {
|
||||||
|
final StringBuilder sb1 = new StringBuilder();
|
||||||
|
final StringBuilder sb2 = new StringBuilder();
|
||||||
|
for (int i = 0; i < width; i++) {
|
||||||
|
final int b = inputStream.read();
|
||||||
|
final int b1 = (b & 0xF0) >> 4;
|
||||||
|
final int b2 = (b & 0x0F);
|
||||||
|
sb1.append(toHexString(b1));
|
||||||
|
sb2.append(toHexString(b2));
|
||||||
|
}
|
||||||
|
result.append(sb1.toString());
|
||||||
|
result.append("\n");
|
||||||
|
line++;
|
||||||
|
if (line < height) {
|
||||||
|
result.append(sb2.toString());
|
||||||
|
result.append("\n");
|
||||||
|
line++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String toHexString(final int b) {
|
||||||
|
return Integer.toHexString(b).toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isSpriteLine(String s) {
|
||||||
|
return s.trim().startsWith("sprite") && s.trim().endsWith("{");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillMap(String infoString) {
|
||||||
|
for (String s : infoString.split("\n")) {
|
||||||
|
if (s.contains("=")) {
|
||||||
|
final String data[] = s.split("=");
|
||||||
|
this.info.put(data[0], data[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static DataInputStream getDataStream(String name) throws IOException {
|
||||||
|
final InputStream raw = getInternalInputStream(name, "-abx.repx");
|
||||||
|
if (raw == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new DataInputStream(new BrotliInputStream(raw));
|
||||||
|
}
|
||||||
|
|
||||||
|
private DataInputStream getDataStream() throws IOException {
|
||||||
|
return getDataStream(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private InputStream getSpriteStream() throws IOException {
|
||||||
|
final InputStream raw = getInternalInputStream(name, "-dex.repx");
|
||||||
|
if (raw == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new BrotliInputStream(raw);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static InputStream getInternalInputStream(String fullname, String extension) {
|
||||||
|
final String res = "/stdlib/" + fullname + extension;
|
||||||
|
return Stdlib.class.getResourceAsStream(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void extractStdLib() throws IOException {
|
||||||
|
for (String name : getAll()) {
|
||||||
|
final Stdlib folder = Stdlib.retrieve(name);
|
||||||
|
folder.extractMeFull(new File("stdlib", name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Collection<String> getAll() throws IOException {
|
||||||
|
final Set<String> result = new TreeSet<String>();
|
||||||
|
final InputStream home = getInternalInputStream("home", ".repx");
|
||||||
|
final BufferedReader br = new BufferedReader(new InputStreamReader(home));
|
||||||
|
String name;
|
||||||
|
while ((name = br.readLine()) != null) {
|
||||||
|
result.add(name);
|
||||||
|
}
|
||||||
|
return Collections.unmodifiableCollection(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void extractMeFull(File dir) throws IOException {
|
||||||
|
final DataInputStream dataStream = getDataStream();
|
||||||
|
if (dataStream == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dataStream.readUTF();
|
||||||
|
final InputStream spriteStream = getSpriteStream();
|
||||||
|
try {
|
||||||
|
while (true) {
|
||||||
|
final String filename = dataStream.readUTF();
|
||||||
|
if (filename.equals(SEPARATOR)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final File f = new File("stdlib/" + name + "/" + filename + ".puml");
|
||||||
|
f.getParentFile().mkdirs();
|
||||||
|
final PrintWriter fos = new PrintWriter(f);
|
||||||
|
while (true) {
|
||||||
|
final String s = dataStream.readUTF();
|
||||||
|
if (s.equals(SEPARATOR)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
fos.println(s);
|
||||||
|
if (isSpriteLine(s)) {
|
||||||
|
final Matcher m = sizePattern.matcher(s);
|
||||||
|
final boolean ok = m.find();
|
||||||
|
if (ok == false) {
|
||||||
|
throw new IOException(s);
|
||||||
|
}
|
||||||
|
final int width = Integer.parseInt(m.group(1));
|
||||||
|
final int height = Integer.parseInt(m.group(2));
|
||||||
|
final String sprite = readSprite(width, height, spriteStream);
|
||||||
|
fos.println(sprite);
|
||||||
|
fos.println("}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fos.close();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
dataStream.close();
|
||||||
|
spriteStream.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addInfoVersion(List<String> strings, boolean details) {
|
||||||
|
try {
|
||||||
|
for (String name : getAll()) {
|
||||||
|
final Stdlib folder = Stdlib.retrieve(name);
|
||||||
|
if (details) {
|
||||||
|
strings.add("<b>" + name);
|
||||||
|
strings.add("Version " + folder.getVersion());
|
||||||
|
strings.add("Delivered by " + folder.getSource());
|
||||||
|
strings.add(" ");
|
||||||
|
} else {
|
||||||
|
strings.add("* " + name + " (Version " + folder.getVersion() + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.error("Error " + e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getVersion() {
|
||||||
|
return info.get("VERSION");
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSource() {
|
||||||
|
return info.get("SOURCE");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void printStdLib() {
|
||||||
|
final List<String> print = new ArrayList<String>();
|
||||||
|
addInfoVersion(print, true);
|
||||||
|
for (String s : print) {
|
||||||
|
System.out.println(s.replace("<b>", ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,265 +0,0 @@
|
|||||||
package net.sourceforge.plantuml.preproc;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import net.sourceforge.plantuml.Log;
|
|
||||||
import net.sourceforge.plantuml.brotli.BrotliInputStream;
|
|
||||||
|
|
||||||
public class Stdlib6 {
|
|
||||||
|
|
||||||
static private final Map<String, Stdlib6> all = new ConcurrentHashMap<String, Stdlib6>();
|
|
||||||
private static final String SEPARATOR = "\uF8FF";
|
|
||||||
|
|
||||||
private final Map<String, List<String>> raw = new HashMap<String, List<String>>();
|
|
||||||
// private final Map<String, SoftReference<byte[]>> cache = new ConcurrentHashMap<String, SoftReference<byte[]>>();
|
|
||||||
private final String name;
|
|
||||||
private final Map<String, String> info = new HashMap<String, String>();
|
|
||||||
|
|
||||||
public static InputStream getResourceAsStream(String fullname) {
|
|
||||||
fullname = fullname.toLowerCase().replace(".puml", "");
|
|
||||||
final int last = fullname.indexOf('/');
|
|
||||||
if (last == -1) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
final Stdlib6 folder = retrieve(fullname.substring(0, last));
|
|
||||||
if (folder == null || folder.raw.size() == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final byte[] data = folder.getData(fullname.substring(last + 1));
|
|
||||||
if (data == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new ByteArrayInputStream(data);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static InputStream getInternalInputStream(String fullname, String extension) {
|
|
||||||
final String res = "/stdlib/" + fullname + extension;
|
|
||||||
return Stdlib6.class.getResourceAsStream(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Stdlib6 retrieve(final String name) throws IOException {
|
|
||||||
Stdlib6 result = all.get(name);
|
|
||||||
if (result == null) {
|
|
||||||
result = new Stdlib6(name);
|
|
||||||
all.put(name, result);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Pattern sizePattern = Pattern.compile("\\[(\\d+)x(\\d+)/16\\]");
|
|
||||||
|
|
||||||
private Stdlib6(String name) throws IOException {
|
|
||||||
this.name = name;
|
|
||||||
Log.info("Opening archive " + name);
|
|
||||||
final DataInputStream dataStream = getDataStream();
|
|
||||||
if (dataStream == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fillMap(dataStream.readUTF());
|
|
||||||
// final InputStream spriteStream = getSpriteStream();
|
|
||||||
int pos = 0;
|
|
||||||
while (true) {
|
|
||||||
final String filename = dataStream.readUTF();
|
|
||||||
// System.err.println("filename=" + filename);
|
|
||||||
if (filename.equals(SEPARATOR)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
final List<String> text = new ArrayList<String>();
|
|
||||||
while (true) {
|
|
||||||
final String s = dataStream.readUTF();
|
|
||||||
if (s.equals(SEPARATOR)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
text.add(s);
|
|
||||||
if (isSpriteLine(s)) {
|
|
||||||
final Matcher m = sizePattern.matcher(s);
|
|
||||||
final boolean ok = m.find();
|
|
||||||
if (ok == false) {
|
|
||||||
throw new IOException(s);
|
|
||||||
}
|
|
||||||
final int width = Integer.parseInt(m.group(1));
|
|
||||||
final int height = Integer.parseInt(m.group(2));
|
|
||||||
text.add("" + pos);
|
|
||||||
pos += spriteSize(width, height);
|
|
||||||
// System.err.println("Sprite! " + width + " " + height + " " + s);
|
|
||||||
text.add("}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
raw.put(filename.toLowerCase(), text);
|
|
||||||
// System.err.println("data=" + text.size());
|
|
||||||
// final int len = is.readInt();
|
|
||||||
// this.data.put(filename.toLowerCase(), new Portion(pos, len));
|
|
||||||
// pos += len;
|
|
||||||
}
|
|
||||||
dataStream.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private int spriteSize(int width, int height) {
|
|
||||||
final int nbLines = (height + 1) / 2;
|
|
||||||
return width * nbLines;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String readSprite(int width, int height, InputStream inputStream) throws IOException {
|
|
||||||
final StringBuilder result = new StringBuilder();
|
|
||||||
final int nbLines = (height + 1) / 2;
|
|
||||||
int line = 0;
|
|
||||||
for (int j = 0; j < nbLines; j++) {
|
|
||||||
final StringBuilder sb1 = new StringBuilder();
|
|
||||||
final StringBuilder sb2 = new StringBuilder();
|
|
||||||
for (int i = 0; i < width; i++) {
|
|
||||||
final int b = inputStream.read();
|
|
||||||
final int b1 = (b & 0xF0) >> 4;
|
|
||||||
final int b2 = (b & 0x0F);
|
|
||||||
sb1.append(toHexString(b1));
|
|
||||||
sb2.append(toHexString(b2));
|
|
||||||
}
|
|
||||||
result.append(sb1.toString());
|
|
||||||
result.append("\n");
|
|
||||||
line++;
|
|
||||||
if (line < height) {
|
|
||||||
result.append(sb2.toString());
|
|
||||||
result.append("\n");
|
|
||||||
line++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String toHexString(final int b) {
|
|
||||||
return Integer.toHexString(b).toUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isSpriteLine(String s) {
|
|
||||||
return s.trim().startsWith("sprite") && s.trim().endsWith("{");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fillMap(String infoString) {
|
|
||||||
for (String s : infoString.split("\n")) {
|
|
||||||
if (s.contains("=")) {
|
|
||||||
final String data[] = s.split("=");
|
|
||||||
this.info.put(data[0], data[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private DataInputStream getDataStream() throws IOException {
|
|
||||||
final InputStream raw = getInternalInputStream(name, "-dat2.repx");
|
|
||||||
if (raw == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new DataInputStream(new BrotliInputStream(raw));
|
|
||||||
}
|
|
||||||
|
|
||||||
private InputStream getSpriteStream() throws IOException {
|
|
||||||
final InputStream raw = getInternalInputStream(name, "-spr.repx");
|
|
||||||
if (raw == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new BrotliInputStream(raw);
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] getData(String filename) throws IOException {
|
|
||||||
final List<String> result = raw.get(filename);
|
|
||||||
if (result == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final StringBuilder sb = new StringBuilder();
|
|
||||||
for (Iterator<String> it = result.iterator(); it.hasNext();) {
|
|
||||||
final String s = it.next();
|
|
||||||
sb.append(s);
|
|
||||||
sb.append("\n");
|
|
||||||
if (isSpriteLine(s)) {
|
|
||||||
final Matcher m = sizePattern.matcher(s);
|
|
||||||
final boolean ok = m.find();
|
|
||||||
if (ok == false) {
|
|
||||||
throw new IOException(s);
|
|
||||||
}
|
|
||||||
final int width = Integer.parseInt(m.group(1));
|
|
||||||
final int height = Integer.parseInt(m.group(2));
|
|
||||||
final InputStream spriteStream = getSpriteStream();
|
|
||||||
final int pos = Integer.parseInt(it.next());
|
|
||||||
// System.err.println("pos=" + pos);
|
|
||||||
spriteStream.skip(pos);
|
|
||||||
sb.append(readSprite(width, height, spriteStream));
|
|
||||||
sb.append("\n");
|
|
||||||
spriteStream.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sb.toString().getBytes("UTF-8");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void extractStdLib() throws IOException {
|
|
||||||
// for (String name : getAll()) {
|
|
||||||
// final Stdlib6 folder = new Stdlib6(name);
|
|
||||||
// folder.extractMeFull(new File("stdlib", name));
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<String> getAll() throws IOException {
|
|
||||||
final List<String> result = new ArrayList<String>();
|
|
||||||
final InputStream home = getInternalInputStream("home", ".repx");
|
|
||||||
final BufferedReader br = new BufferedReader(new InputStreamReader(home));
|
|
||||||
String name;
|
|
||||||
while ((name = br.readLine()) != null) {
|
|
||||||
result.add(name);
|
|
||||||
}
|
|
||||||
return Collections.unmodifiableList(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
// private void extractMeFull(File dir) throws IOException {
|
|
||||||
// final DataInputStream idx = getDataIndex();
|
|
||||||
// final DataInputStream txt = getFullTexts();
|
|
||||||
// final String infoString = idx.readUTF();
|
|
||||||
// while (true) {
|
|
||||||
// final String filename = idx.readUTF();
|
|
||||||
// if (filename.length() == 0) {
|
|
||||||
// idx.close();
|
|
||||||
// txt.close();
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// final int len = idx.readInt();
|
|
||||||
// final File f = new File("stdlib/" + name + "/" + filename + ".puml");
|
|
||||||
// f.getParentFile().mkdirs();
|
|
||||||
// final FileOutputStream fos = new FileOutputStream(f);
|
|
||||||
// final byte data[] = new byte[len];
|
|
||||||
// txt.readFully(data);
|
|
||||||
// fos.write(data);
|
|
||||||
// fos.close();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
public static void addInfoVersion(List<String> strings) {
|
|
||||||
try {
|
|
||||||
for (String name : getAll()) {
|
|
||||||
final Stdlib6 folder = new Stdlib6(name);
|
|
||||||
strings.add("* " + name + " (Version " + folder.getVersion() + ")");
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getVersion() {
|
|
||||||
return info.get("VERSION");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,202 +0,0 @@
|
|||||||
package net.sourceforge.plantuml.preproc;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.lang.ref.SoftReference;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import net.sourceforge.plantuml.Log;
|
|
||||||
import net.sourceforge.plantuml.brotli.BrotliInputStream;
|
|
||||||
|
|
||||||
public class StdlibOld {
|
|
||||||
|
|
||||||
static private final Map<String, StdlibOld> all = new ConcurrentHashMap<String, StdlibOld>();
|
|
||||||
|
|
||||||
static class Portion {
|
|
||||||
int position;
|
|
||||||
int length;
|
|
||||||
|
|
||||||
Portion(int position, int length) {
|
|
||||||
this.position = position;
|
|
||||||
this.length = length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] of(DataInputStream is) throws IOException {
|
|
||||||
is.skipBytes(position);
|
|
||||||
final byte result[] = new byte[length];
|
|
||||||
is.readFully(result);
|
|
||||||
is.close();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Map<String, Portion> data = new HashMap<String, Portion>();
|
|
||||||
private final Map<String, SoftReference<byte[]>> cache = new ConcurrentHashMap<String, SoftReference<byte[]>>();
|
|
||||||
private final String name;
|
|
||||||
private final Map<String, String> info = new HashMap<String, String>();
|
|
||||||
|
|
||||||
public static InputStream getResourceAsStream(String fullname) {
|
|
||||||
fullname = fullname.toLowerCase().replace(".puml", "");
|
|
||||||
final int last = fullname.indexOf('/');
|
|
||||||
if (last == -1) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
final StdlibOld folder = retrieve(fullname.substring(0, last));
|
|
||||||
if (folder == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
final byte[] data = folder.getData(fullname.substring(last + 1));
|
|
||||||
if (data == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new ByteArrayInputStream(data);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static InputStream getInternalInputStream(String fullname, String extension) {
|
|
||||||
final String res = "/stdlib/" + fullname + extension;
|
|
||||||
return StdlibOld.class.getResourceAsStream(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static StdlibOld retrieve(final String name) throws IOException {
|
|
||||||
StdlibOld result = all.get(name);
|
|
||||||
if (result == null) {
|
|
||||||
result = new StdlibOld(name);
|
|
||||||
all.put(name, result);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private StdlibOld(String name) throws IOException {
|
|
||||||
this.name = name;
|
|
||||||
Log.info("Opening archive " + name);
|
|
||||||
int pos = 0;
|
|
||||||
final DataInputStream is = getDataIndex();
|
|
||||||
fillMap(is.readUTF());
|
|
||||||
while (true) {
|
|
||||||
final String filename = is.readUTF();
|
|
||||||
if (filename.length() == 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
final int len = is.readInt();
|
|
||||||
this.data.put(filename.toLowerCase(), new Portion(pos, len));
|
|
||||||
pos += len;
|
|
||||||
}
|
|
||||||
is.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fillMap(String infoString) {
|
|
||||||
for (String s : infoString.split("\n")) {
|
|
||||||
if (s.contains("=")) {
|
|
||||||
final String data[] = s.split("=");
|
|
||||||
this.info.put(data[0], data[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private DataInputStream getDataIndex() {
|
|
||||||
final InputStream raw = getInternalInputStream(name, "-idx.repx");
|
|
||||||
if (raw == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new DataInputStream(raw);
|
|
||||||
}
|
|
||||||
|
|
||||||
private DataInputStream getFullTexts() throws IOException {
|
|
||||||
final InputStream raw = getInternalInputStream(name, "-dat.repx");
|
|
||||||
if (raw == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new DataInputStream(new BrotliInputStream(raw));
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] getData(String filename) throws IOException {
|
|
||||||
final SoftReference<byte[]> ref = cache.get(filename);
|
|
||||||
byte[] result = ref == null ? null : ref.get();
|
|
||||||
final String full = name + "/" + filename + ".puml";
|
|
||||||
if (result == null) {
|
|
||||||
result = getDataSlow(filename);
|
|
||||||
cache.put(filename, new SoftReference<byte[]>(result));
|
|
||||||
Log.info("Reading " + full);
|
|
||||||
} else {
|
|
||||||
Log.info("Retrieving " + full);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] getDataSlow(String filename) throws IOException {
|
|
||||||
final Portion portion = data.get(filename);
|
|
||||||
return portion.of(getFullTexts());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void extractStdLib() throws IOException {
|
|
||||||
for (String name : getAll()) {
|
|
||||||
final StdlibOld folder = new StdlibOld(name);
|
|
||||||
folder.extractMeFull(new File("stdlib", name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<String> getAll() throws IOException {
|
|
||||||
final List<String> result = new ArrayList<String>();
|
|
||||||
final InputStream home = getInternalInputStream("home", ".repx");
|
|
||||||
final BufferedReader br = new BufferedReader(new InputStreamReader(home));
|
|
||||||
String name;
|
|
||||||
while ((name = br.readLine()) != null) {
|
|
||||||
result.add(name);
|
|
||||||
}
|
|
||||||
return Collections.unmodifiableList(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void extractMeFull(File dir) throws IOException {
|
|
||||||
final DataInputStream idx = getDataIndex();
|
|
||||||
final DataInputStream txt = getFullTexts();
|
|
||||||
final String infoString = idx.readUTF();
|
|
||||||
while (true) {
|
|
||||||
final String filename = idx.readUTF();
|
|
||||||
if (filename.length() == 0) {
|
|
||||||
idx.close();
|
|
||||||
txt.close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final int len = idx.readInt();
|
|
||||||
final File f = new File("stdlib/" + name + "/" + filename + ".puml");
|
|
||||||
f.getParentFile().mkdirs();
|
|
||||||
final FileOutputStream fos = new FileOutputStream(f);
|
|
||||||
final byte data[] = new byte[len];
|
|
||||||
txt.readFully(data);
|
|
||||||
fos.write(data);
|
|
||||||
fos.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addInfoVersion(List<String> strings) {
|
|
||||||
try {
|
|
||||||
for (String name : getAll()) {
|
|
||||||
final StdlibOld folder = new StdlibOld(name);
|
|
||||||
strings.add("* " + name + " (Version " + folder.getVersion() + ")");
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getVersion() {
|
|
||||||
return info.get("VERSION");
|
|
||||||
}
|
|
||||||
}
|
|
@ -145,10 +145,10 @@ public class SubPreprocessor implements ReadLine {
|
|||||||
try {
|
try {
|
||||||
if (charset == null) {
|
if (charset == null) {
|
||||||
Log.info("Using default charset");
|
Log.info("Using default charset");
|
||||||
return new ReadLineReader(new FileReader(f), f.getAbsolutePath(), s.getLocation());
|
return ReadLineReader.create(new FileReader(f), f.getAbsolutePath(), s.getLocation());
|
||||||
}
|
}
|
||||||
Log.info("Using charset " + charset);
|
Log.info("Using charset " + charset);
|
||||||
return new ReadLineReader(new InputStreamReader(new FileInputStream(f), charset), f.getAbsolutePath(),
|
return ReadLineReader.create(new InputStreamReader(new FileInputStream(f), charset), f.getAbsolutePath(),
|
||||||
s.getLocation());
|
s.getLocation());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return new ReadLineSimple(s, e.toString());
|
return new ReadLineSimple(s, e.toString());
|
||||||
|
@ -61,11 +61,17 @@ public class Englober {
|
|||||||
final private TileArguments tileArguments;
|
final private TileArguments tileArguments;
|
||||||
final private Real core1;
|
final private Real core1;
|
||||||
final private Real core2;
|
final private Real core2;
|
||||||
|
final private boolean isTeoz;
|
||||||
|
private double marginX = 0;
|
||||||
|
|
||||||
@Deprecated
|
public static Englober createPuma(ParticipantEnglober englober, Participant first, ISkinParam skinParam, Skin skin,
|
||||||
public Englober(ParticipantEnglober participantEnglober, Participant first, ISkinParam skinParam, Skin skin,
|
|
||||||
StringBounder stringBounder) {
|
StringBounder stringBounder) {
|
||||||
this(participantEnglober, first, convertFunctionToBeRemoved(skinParam, skin, stringBounder));
|
return new Englober(englober, first, convertFunctionToBeRemoved(skinParam, skin, stringBounder), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Englober createTeoz(ParticipantEnglober participantEnglober, Participant first,
|
||||||
|
TileArguments tileArguments) {
|
||||||
|
return new Englober(participantEnglober, first, tileArguments, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TileArguments convertFunctionToBeRemoved(ISkinParam skinParam, Skin skin, StringBounder stringBounder) {
|
private static TileArguments convertFunctionToBeRemoved(ISkinParam skinParam, Skin skin, StringBounder stringBounder) {
|
||||||
@ -73,10 +79,12 @@ public class Englober {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Englober(ParticipantEnglober participantEnglober, Participant first, TileArguments tileArguments) {
|
private Englober(ParticipantEnglober participantEnglober, Participant first, TileArguments tileArguments,
|
||||||
|
boolean isTeoz) {
|
||||||
if (tileArguments == null) {
|
if (tileArguments == null) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
|
this.isTeoz = isTeoz;
|
||||||
this.participantEnglober = participantEnglober;
|
this.participantEnglober = participantEnglober;
|
||||||
this.participants.add(first);
|
this.participants.add(first);
|
||||||
this.tileArguments = tileArguments;
|
this.tileArguments = tileArguments;
|
||||||
@ -163,6 +171,13 @@ public class Englober {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private double getPreferredWidth() {
|
private double getPreferredWidth() {
|
||||||
|
if (isTeoz) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
return getTitleWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getTitleWidth() {
|
||||||
return getComponent().getPreferredWidth(tileArguments.getStringBounder());
|
return getComponent().getPreferredWidth(tileArguments.getStringBounder());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,14 +196,22 @@ public class Englober {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Real getX2() {
|
private Real getX2() {
|
||||||
return RealUtils.max(getPosD(), core2);
|
return RealUtils.max(getPosD(), core2).addFixed(marginX);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Real getX1() {
|
private Real getX1() {
|
||||||
return RealUtils.min(getPosB(), core1);
|
return RealUtils.min(getPosB(), core1).addFixed(-marginX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addInternalConstraints() {
|
public void addInternalConstraints() {
|
||||||
|
assert isTeoz;
|
||||||
|
final double titleWidth = getTitleWidth();
|
||||||
|
final double x1 = getX1().getCurrentValue();
|
||||||
|
final double x2 = getX2().getCurrentValue();
|
||||||
|
final double actualWidth = x2 - x1;
|
||||||
|
if (titleWidth > actualWidth + 20) {
|
||||||
|
this.marginX = (titleWidth - actualWidth - 20) / 2;
|
||||||
|
}
|
||||||
getX1().ensureBiggerThan(getPosAA().addFixed(10));
|
getX1().ensureBiggerThan(getPosAA().addFixed(10));
|
||||||
final Real posZZ = getPosZZ();
|
final Real posZZ = getPosZZ();
|
||||||
final Real limit = getX2().addFixed(10);
|
final Real limit = getX2().addFixed(10);
|
||||||
|
@ -129,7 +129,12 @@ abstract class CommandExoArrowAny extends SingleLineCommand2<SequenceDiagram> {
|
|||||||
final Url urlLink = urlBuilder.getUrl(arg.get("URL", 0));
|
final Url urlLink = urlBuilder.getUrl(arg.get("URL", 0));
|
||||||
msg.setUrl(urlLink);
|
msg.setUrl(urlLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final boolean parallel = arg.get("PARALLEL", 0) != null;
|
||||||
|
if (parallel) {
|
||||||
|
msg.goParallel();
|
||||||
|
}
|
||||||
|
|
||||||
final String error = diagram.addMessage(msg);
|
final String error = diagram.addMessage(msg);
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
return CommandExecutionResult.error(error);
|
return CommandExecutionResult.error(error);
|
||||||
|
@ -50,6 +50,7 @@ public class CommandExoArrowLeft extends CommandExoArrowAny {
|
|||||||
|
|
||||||
static RegexConcat getRegexConcat() {
|
static RegexConcat getRegexConcat() {
|
||||||
return new RegexConcat(new RegexLeaf("^"), //
|
return new RegexConcat(new RegexLeaf("^"), //
|
||||||
|
new RegexLeaf("PARALLEL", "(&%s*)?"), //
|
||||||
new RegexLeaf("SHORT", "([?\\[\\]][ox]?)?"), //
|
new RegexLeaf("SHORT", "([?\\[\\]][ox]?)?"), //
|
||||||
new RegexOr( //
|
new RegexOr( //
|
||||||
new RegexConcat( //
|
new RegexConcat( //
|
||||||
|
@ -50,6 +50,7 @@ public class CommandExoArrowRight extends CommandExoArrowAny {
|
|||||||
|
|
||||||
static RegexConcat getRegexConcat() {
|
static RegexConcat getRegexConcat() {
|
||||||
return new RegexConcat(new RegexLeaf("^"), //
|
return new RegexConcat(new RegexLeaf("^"), //
|
||||||
|
new RegexLeaf("PARALLEL", "(&%s*)?"), //
|
||||||
new RegexLeaf("PARTICIPANT", "([\\p{L}0-9_.@]+|[%g][^%g]+[%g])"), //
|
new RegexLeaf("PARTICIPANT", "([\\p{L}0-9_.@]+|[%g][^%g]+[%g])"), //
|
||||||
new RegexLeaf("[%s]*"), //
|
new RegexLeaf("[%s]*"), //
|
||||||
new RegexLeaf("ARROW_SUPPCIRCLE", "([%s]+[ox])?"), //
|
new RegexLeaf("ARROW_SUPPCIRCLE", "([%s]+[ox])?"), //
|
||||||
|
@ -167,7 +167,7 @@ public class DrawableSet {
|
|||||||
pending.add(ent.getKey());
|
pending.add(ent.getKey());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pending = new Englober(englober, ent.getKey(), getSkinParam(), skin, stringBounder);
|
pending = Englober.createPuma(englober, ent.getKey(), getSkinParam(), skin, stringBounder);
|
||||||
result.add(pending);
|
result.add(pending);
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableList(result);
|
return Collections.unmodifiableList(result);
|
||||||
|
@ -64,7 +64,7 @@ public class Englobers {
|
|||||||
pending.add(p);
|
pending.add(p);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pending = new Englober(englober, p, tileArguments);
|
pending = Englober.createTeoz(englober, p, tileArguments);
|
||||||
englobers.add(pending);
|
englobers.add(pending);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@ import net.sourceforge.plantuml.sequencediagram.Grouping;
|
|||||||
import net.sourceforge.plantuml.sequencediagram.GroupingLeaf;
|
import net.sourceforge.plantuml.sequencediagram.GroupingLeaf;
|
||||||
import net.sourceforge.plantuml.sequencediagram.GroupingStart;
|
import net.sourceforge.plantuml.sequencediagram.GroupingStart;
|
||||||
import net.sourceforge.plantuml.sequencediagram.GroupingType;
|
import net.sourceforge.plantuml.sequencediagram.GroupingType;
|
||||||
|
import net.sourceforge.plantuml.sequencediagram.Message;
|
||||||
import net.sourceforge.plantuml.skin.Area;
|
import net.sourceforge.plantuml.skin.Area;
|
||||||
import net.sourceforge.plantuml.skin.Component;
|
import net.sourceforge.plantuml.skin.Component;
|
||||||
import net.sourceforge.plantuml.skin.ComponentType;
|
import net.sourceforge.plantuml.skin.ComponentType;
|
||||||
@ -64,7 +65,7 @@ public class GroupingTile implements TileWithCallbackY {
|
|||||||
private static final int EXTERNAL_MARGINX2 = 9;
|
private static final int EXTERNAL_MARGINX2 = 9;
|
||||||
private static final int MARGINX = 16;
|
private static final int MARGINX = 16;
|
||||||
private static final int MARGINY = 10;
|
private static final int MARGINY = 10;
|
||||||
private final List<Tile> tiles = new ArrayList<Tile>();
|
private List<Tile> tiles = new ArrayList<Tile>();
|
||||||
private final Real min;
|
private final Real min;
|
||||||
private final Real max;
|
private final Real max;
|
||||||
private final GroupingStart start;
|
private final GroupingStart start;
|
||||||
@ -102,17 +103,21 @@ public class GroupingTile implements TileWithCallbackY {
|
|||||||
}
|
}
|
||||||
for (Tile tile : TileBuilder.buildOne(it, tileArgumentsOriginal, ev, this)) {
|
for (Tile tile : TileBuilder.buildOne(it, tileArgumentsOriginal, ev, this)) {
|
||||||
tiles.add(tile);
|
tiles.add(tile);
|
||||||
bodyHeight += tile.getPreferredHeight(stringBounder);
|
|
||||||
if (ev instanceof GroupingLeaf && ((Grouping) ev).getType() == GroupingType.ELSE) {
|
|
||||||
allElses.add(tile);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
min2.add(tile.getMinX(stringBounder).addFixed(-MARGINX));
|
|
||||||
final Real m = tile.getMaxX(stringBounder);
|
|
||||||
// max2.add(m == tileArgumentsOriginal.getOmega() ? m : m.addFixed(MARGINX));
|
|
||||||
max2.add(m.addFixed(MARGINX));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tiles = mergeParallel(tiles);
|
||||||
|
for (Tile tile : tiles) {
|
||||||
|
bodyHeight += tile.getPreferredHeight(stringBounder);
|
||||||
|
final Event ev = tile.getEvent();
|
||||||
|
if (ev instanceof GroupingLeaf && ((Grouping) ev).getType() == GroupingType.ELSE) {
|
||||||
|
allElses.add(tile);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
min2.add(tile.getMinX(stringBounder).addFixed(-MARGINX));
|
||||||
|
final Real m = tile.getMaxX(stringBounder);
|
||||||
|
// max2.add(m == tileArgumentsOriginal.getOmega() ? m : m.addFixed(MARGINX));
|
||||||
|
max2.add(m.addFixed(MARGINX));
|
||||||
|
}
|
||||||
final Dimension2D dim1 = getPreferredDimensionIfEmpty(stringBounder);
|
final Dimension2D dim1 = getPreferredDimensionIfEmpty(stringBounder);
|
||||||
final double width = dim1.getWidth();
|
final double width = dim1.getWidth();
|
||||||
if (min2.size() == 0) {
|
if (min2.size() == 0) {
|
||||||
@ -152,9 +157,9 @@ public class GroupingTile implements TileWithCallbackY {
|
|||||||
double h = dim1.getHeight() + MARGINY / 2;
|
double h = dim1.getHeight() + MARGINY / 2;
|
||||||
for (Tile tile : tiles) {
|
for (Tile tile : tiles) {
|
||||||
ug.apply(new UTranslate(0, h)).draw(tile);
|
ug.apply(new UTranslate(0, h)).draw(tile);
|
||||||
h += tile.getPreferredHeight(stringBounder);
|
final double preferredHeight = tile.getPreferredHeight(stringBounder);
|
||||||
|
h += preferredHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getTotalHeight(StringBounder stringBounder) {
|
private double getTotalHeight(StringBounder stringBounder) {
|
||||||
@ -213,23 +218,39 @@ public class GroupingTile implements TileWithCallbackY {
|
|||||||
|
|
||||||
public static double fillPositionelTiles(StringBounder stringBounder, double y, List<Tile> tiles,
|
public static double fillPositionelTiles(StringBounder stringBounder, double y, List<Tile> tiles,
|
||||||
final List<YPositionedTile> positionedTiles) {
|
final List<YPositionedTile> positionedTiles) {
|
||||||
double lastY = y;
|
for (Tile tile : mergeParallel(tiles)) {
|
||||||
for (Tile tile : tiles) {
|
|
||||||
if (tile.getEvent().isParallel()) {
|
|
||||||
y = lastY;
|
|
||||||
}
|
|
||||||
positionedTiles.add(new YPositionedTile(tile, y));
|
positionedTiles.add(new YPositionedTile(tile, y));
|
||||||
if (tile instanceof GroupingTile) {
|
if (tile instanceof GroupingTile) {
|
||||||
final GroupingTile groupingTile = (GroupingTile) tile;
|
final GroupingTile groupingTile = (GroupingTile) tile;
|
||||||
fillPositionelTiles(stringBounder, y, groupingTile.tiles, new ArrayList<YPositionedTile>());
|
final double headerHeight = groupingTile.getPreferredDimensionIfEmpty(stringBounder).getHeight();
|
||||||
|
fillPositionelTiles(stringBounder, y + headerHeight, groupingTile.tiles,
|
||||||
|
new ArrayList<YPositionedTile>());
|
||||||
}
|
}
|
||||||
lastY = y;
|
|
||||||
y += tile.getPreferredHeight(stringBounder);
|
y += tile.getPreferredHeight(stringBounder);
|
||||||
}
|
}
|
||||||
return y;
|
return y;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<Tile> mergeParallel(List<Tile> tiles) {
|
||||||
|
TileParallel pending = null;
|
||||||
|
final List<Tile> result = new ArrayList<Tile>();
|
||||||
|
for (Tile tile : tiles) {
|
||||||
|
if (tile instanceof TileParallel == false && tile.getEvent().isParallel()) {
|
||||||
|
if (pending == null) {
|
||||||
|
pending = new TileParallel();
|
||||||
|
pending.add(result.get(result.size() - 1));
|
||||||
|
result.set(result.size() - 1, pending);
|
||||||
|
}
|
||||||
|
pending.add(tile);
|
||||||
|
} else {
|
||||||
|
result.add(tile);
|
||||||
|
pending = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// public double getStartY() {
|
// public double getStartY() {
|
||||||
// return y + MARGINY;
|
// return y + MARGINY;
|
||||||
// }
|
// }
|
||||||
|
@ -55,6 +55,11 @@ public class LiveBoxFinder implements UGraphic {
|
|||||||
public boolean matchesProperty(String propertyName) {
|
public boolean matchesProperty(String propertyName) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double dpiFactor() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public UGraphic apply(UChange change) {
|
public UGraphic apply(UChange change) {
|
||||||
if (change instanceof UTranslate) {
|
if (change instanceof UTranslate) {
|
||||||
@ -100,6 +105,8 @@ public class LiveBoxFinder implements UGraphic {
|
|||||||
((GroupingTile) shape).drawU(this);
|
((GroupingTile) shape).drawU(this);
|
||||||
} else if (shape instanceof TileWithUpdateStairs) {
|
} else if (shape instanceof TileWithUpdateStairs) {
|
||||||
((TileWithUpdateStairs) shape).updateStairs(stringBounder, y);
|
((TileWithUpdateStairs) shape).updateStairs(stringBounder, y);
|
||||||
|
} else if (shape instanceof EmptyTile) {
|
||||||
|
// Nothing ?
|
||||||
} else if (shape instanceof NotesTile) {
|
} else if (shape instanceof NotesTile) {
|
||||||
// Nothing ?
|
// Nothing ?
|
||||||
} else if (shape instanceof Tile) {
|
} else if (shape instanceof Tile) {
|
||||||
|
@ -0,0 +1,137 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* 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.sequencediagram.teoz;
|
||||||
|
|
||||||
|
import java.util.AbstractCollection;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||||
|
import net.sourceforge.plantuml.real.Real;
|
||||||
|
import net.sourceforge.plantuml.real.RealUtils;
|
||||||
|
import net.sourceforge.plantuml.sequencediagram.Event;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||||
|
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||||
|
|
||||||
|
public class TileParallel implements Tile {
|
||||||
|
|
||||||
|
private final List<Tile> tiles = new ArrayList<Tile>();
|
||||||
|
|
||||||
|
public void add(Tile tile) {
|
||||||
|
this.tiles.add(tile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawU(UGraphic ug) {
|
||||||
|
final StringBounder stringBounder = ug.getStringBounder();
|
||||||
|
final double totalHeight = getPreferredHeight(stringBounder);
|
||||||
|
for (Tile tile : tiles) {
|
||||||
|
tile.drawU(ug.apply(new UTranslate(0, totalHeight - tile.getPreferredHeight(stringBounder))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getPreferredHeight(StringBounder stringBounder) {
|
||||||
|
double height = 0;
|
||||||
|
for (Tile tile : tiles) {
|
||||||
|
height = Math.max(height, tile.getPreferredHeight(stringBounder));
|
||||||
|
}
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addConstraints(StringBounder stringBounder) {
|
||||||
|
for (Tile tile : tiles) {
|
||||||
|
tile.addConstraints(stringBounder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Real getMinX(final StringBounder stringBounder) {
|
||||||
|
return RealUtils.min(new AbstractCollection<Real>() {
|
||||||
|
public Iterator<Real> iterator() {
|
||||||
|
return new Iterator<Real>() {
|
||||||
|
private final Iterator<Tile> source = tiles.iterator();
|
||||||
|
|
||||||
|
public boolean hasNext() {
|
||||||
|
return source.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Real next() {
|
||||||
|
return source.next().getMinX(stringBounder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return tiles.size();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public Real getMaxX(final StringBounder stringBounder) {
|
||||||
|
return RealUtils.max(new AbstractCollection<Real>() {
|
||||||
|
public Iterator<Real> iterator() {
|
||||||
|
return new Iterator<Real>() {
|
||||||
|
private final Iterator<Tile> source = tiles.iterator();
|
||||||
|
|
||||||
|
public boolean hasNext() {
|
||||||
|
return source.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Real next() {
|
||||||
|
return source.next().getMaxX(stringBounder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return tiles.size();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public Event getEvent() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -36,16 +36,12 @@
|
|||||||
package net.sourceforge.plantuml.suggest;
|
package net.sourceforge.plantuml.suggest;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.AbstractPSystem;
|
import net.sourceforge.plantuml.AbstractPSystem;
|
||||||
import net.sourceforge.plantuml.CharSequence2;
|
import net.sourceforge.plantuml.CharSequence2;
|
||||||
import net.sourceforge.plantuml.CharSequence2Impl;
|
import net.sourceforge.plantuml.CharSequence2Impl;
|
||||||
import net.sourceforge.plantuml.StringUtils;
|
|
||||||
import net.sourceforge.plantuml.command.BlocLines;
|
|
||||||
import net.sourceforge.plantuml.command.CommandControl;
|
|
||||||
import net.sourceforge.plantuml.command.UmlDiagramFactory;
|
import net.sourceforge.plantuml.command.UmlDiagramFactory;
|
||||||
import net.sourceforge.plantuml.core.UmlSource;
|
import net.sourceforge.plantuml.core.UmlSource;
|
||||||
import net.sourceforge.plantuml.utils.StartUtils;
|
import net.sourceforge.plantuml.utils.StartUtils;
|
||||||
@ -60,6 +56,10 @@ final public class SuggestEngine {
|
|||||||
|
|
||||||
private final IteratorCounter2 it99;
|
private final IteratorCounter2 it99;
|
||||||
|
|
||||||
|
public SuggestEngine(UmlSource source, Object foo) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
public SuggestEngine(UmlSource source, UmlDiagramFactory systemFactory) {
|
public SuggestEngine(UmlSource source, UmlDiagramFactory systemFactory) {
|
||||||
this.systemFactory = systemFactory;
|
this.systemFactory = systemFactory;
|
||||||
this.it99 = source.iterator2();
|
this.it99 = source.iterator2();
|
||||||
@ -74,79 +74,81 @@ final public class SuggestEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SuggestEngineResult executeUmlCommand(AbstractPSystem system) {
|
private SuggestEngineResult executeUmlCommand(AbstractPSystem system) {
|
||||||
while (it99.hasNext()) {
|
throw new UnsupportedOperationException();
|
||||||
if (StartUtils.isArobaseEndDiagram(it99.peek())) {
|
// while (it99.hasNext()) {
|
||||||
return SuggestEngineResult.SYNTAX_OK;
|
// if (StartUtils.isArobaseEndDiagram(it99.peek())) {
|
||||||
}
|
// return SuggestEngineResult.SYNTAX_OK;
|
||||||
final SuggestEngineResult check = checkAndCorrect();
|
// }
|
||||||
if (check.getStatus() != SuggestEngineStatus.SYNTAX_OK) {
|
// final SuggestEngineResult check = checkAndCorrect();
|
||||||
return check;
|
// if (check.getStatus() != SuggestEngineStatus.SYNTAX_OK) {
|
||||||
}
|
// return check;
|
||||||
final CommandControl commandControl = systemFactory.isValid2(it99);
|
// }
|
||||||
if (commandControl == CommandControl.OK_PARTIAL) {
|
// final CommandControl commandControl = systemFactory.isValid2(it99);
|
||||||
systemFactory.goForwardMultiline(it99);
|
// if (commandControl == CommandControl.OK_PARTIAL) {
|
||||||
// if (ok == false) {
|
// systemFactory.goForwardMultiline(it99);
|
||||||
// return SuggestEngineResult.CANNOT_CORRECT;
|
// // if (ok == false) {
|
||||||
// }
|
// // return SuggestEngineResult.CANNOT_CORRECT;
|
||||||
} else if (commandControl == CommandControl.OK) {
|
// // }
|
||||||
it99.next();
|
// } else if (commandControl == CommandControl.OK) {
|
||||||
// final Command cmd = new ProtectedCommand(systemFactory.createCommand(Arrays.asList(s)));
|
// it99.next();
|
||||||
// final CommandExecutionResult result = cmd.execute(system, Arrays.asList(s));
|
// // final Command cmd = new ProtectedCommand(systemFactory.createCommand(Arrays.asList(s)));
|
||||||
// if (result.isOk() == false) {
|
// // final CommandExecutionResult result = cmd.execute(system, Arrays.asList(s));
|
||||||
// return SuggestEngineResult.CANNOT_CORRECT;
|
// // if (result.isOk() == false) {
|
||||||
// }
|
// // return SuggestEngineResult.CANNOT_CORRECT;
|
||||||
} else {
|
// // }
|
||||||
return SuggestEngineResult.CANNOT_CORRECT;
|
// } else {
|
||||||
}
|
// return SuggestEngineResult.CANNOT_CORRECT;
|
||||||
}
|
// }
|
||||||
return SuggestEngineResult.CANNOT_CORRECT;
|
// }
|
||||||
// throw new IllegalStateException();
|
// return SuggestEngineResult.CANNOT_CORRECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
SuggestEngineResult checkAndCorrect() {
|
SuggestEngineResult checkAndCorrect() {
|
||||||
final String incorrectLine = it99.peek().toString();
|
throw new UnsupportedOperationException();
|
||||||
if (incorrectLine.length() > LIMIT) {
|
// final String incorrectLine = it99.peek().toString();
|
||||||
return SuggestEngineResult.CANNOT_CORRECT;
|
// if (incorrectLine.length() > LIMIT) {
|
||||||
}
|
// return SuggestEngineResult.CANNOT_CORRECT;
|
||||||
final CommandControl commandControl = systemFactory.isValid2(it99);
|
// }
|
||||||
if (commandControl != CommandControl.NOT_OK) {
|
// final CommandControl commandControl = systemFactory.isValid2(it99);
|
||||||
return SuggestEngineResult.SYNTAX_OK;
|
// if (commandControl != CommandControl.NOT_OK) {
|
||||||
}
|
// return SuggestEngineResult.SYNTAX_OK;
|
||||||
|
// }
|
||||||
if (StringUtils.trin(incorrectLine).startsWith("{")
|
//
|
||||||
&& systemFactory.isValid(BlocLines.single(it99.peekPrevious() + " {")) != CommandControl.NOT_OK) {
|
// if (StringUtils.trin(incorrectLine).startsWith("{")
|
||||||
return new SuggestEngineResult(it99.peekPrevious() + " {");
|
// && systemFactory.isValid(BlocLines.single(it99.peekPrevious() + " {")) != CommandControl.NOT_OK) {
|
||||||
}
|
// return new SuggestEngineResult(it99.peekPrevious() + " {");
|
||||||
|
// }
|
||||||
final Collection<Iterator<String>> all = new ArrayList<Iterator<String>>();
|
//
|
||||||
all.add(new VariatorRemoveOneChar(incorrectLine));
|
// final Collection<Iterator<String>> all = new ArrayList<Iterator<String>>();
|
||||||
all.add(new VariatorSwapLetter(incorrectLine));
|
// all.add(new VariatorRemoveOneChar(incorrectLine));
|
||||||
// all.add(new VariatorAddOneCharBetweenWords(incorrectLine, ':'));
|
// all.add(new VariatorSwapLetter(incorrectLine));
|
||||||
all.add(new VariatorAddOneCharBetweenWords(incorrectLine, '-'));
|
// // all.add(new VariatorAddOneCharBetweenWords(incorrectLine, ':'));
|
||||||
all.add(new VariatorAddOneCharBetweenWords(incorrectLine, ' '));
|
// all.add(new VariatorAddOneCharBetweenWords(incorrectLine, '-'));
|
||||||
// all.add(new VariatorAddTwoChar(incorrectLine, '\"'));
|
// all.add(new VariatorAddOneCharBetweenWords(incorrectLine, ' '));
|
||||||
|
// // all.add(new VariatorAddTwoChar(incorrectLine, '\"'));
|
||||||
for (Iterator<String> it2 : all) {
|
//
|
||||||
final SuggestEngineResult result = tryThis(it2);
|
// for (Iterator<String> it2 : all) {
|
||||||
if (result != null) {
|
// final SuggestEngineResult result = tryThis(it2);
|
||||||
return result;
|
// if (result != null) {
|
||||||
}
|
// return result;
|
||||||
}
|
// }
|
||||||
return SuggestEngineResult.CANNOT_CORRECT;
|
// }
|
||||||
|
// return SuggestEngineResult.CANNOT_CORRECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SuggestEngineResult tryThis(Iterator<String> it2) {
|
private SuggestEngineResult tryThis(Iterator<String> it2) {
|
||||||
while (it2.hasNext()) {
|
throw new UnsupportedOperationException();
|
||||||
final String newS = it2.next();
|
// while (it2.hasNext()) {
|
||||||
if (StringUtils.trin(newS).length() == 0) {
|
// final String newS = it2.next();
|
||||||
continue;
|
// if (StringUtils.trin(newS).length() == 0) {
|
||||||
}
|
// continue;
|
||||||
final CommandControl commandControl = systemFactory.isValid2(replaceFirstLine(newS));
|
// }
|
||||||
if (commandControl == CommandControl.OK) {
|
// final CommandControl commandControl = systemFactory.isValid2(replaceFirstLine(newS));
|
||||||
return new SuggestEngineResult(newS);
|
// if (commandControl == CommandControl.OK) {
|
||||||
}
|
// return new SuggestEngineResult(newS);
|
||||||
}
|
// }
|
||||||
return null;
|
// }
|
||||||
|
// return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IteratorCounter2 replaceFirstLine(String s) {
|
private IteratorCounter2 replaceFirstLine(String s) {
|
||||||
|
@ -394,7 +394,7 @@ public final class DotDataImageBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (leaf.getLeafType() == LeafType.USECASE) {
|
if (leaf.getLeafType() == LeafType.USECASE) {
|
||||||
return new EntityImageUseCase(leaf, skinParam);
|
return new EntityImageUseCase(leaf, skinParam, portionShower);
|
||||||
}
|
}
|
||||||
// if (leaf.getEntityType() == LeafType.CIRCLE_INTERFACE) {
|
// if (leaf.getEntityType() == LeafType.CIRCLE_INTERFACE) {
|
||||||
// return new EntityImageCircleInterface(leaf, skinParam);
|
// return new EntityImageCircleInterface(leaf, skinParam);
|
||||||
|
@ -68,11 +68,11 @@ public class UGraphicForSnake extends UGraphicDelegator {
|
|||||||
this.dy = dy;
|
this.dy = dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawInternal() {
|
void drawInternal() {
|
||||||
snake.drawInternal(ug);
|
snake.drawInternal(ug);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeEndDecorationIfTouches(List<PendingSnake> snakes) {
|
void removeEndDecorationIfTouches(List<PendingSnake> snakes) {
|
||||||
for (PendingSnake other : snakes) {
|
for (PendingSnake other : snakes) {
|
||||||
if (moved().touches(other.moved())) {
|
if (moved().touches(other.moved())) {
|
||||||
this.snake.removeEndDecoration();
|
this.snake.removeEndDecoration();
|
||||||
@ -80,7 +80,7 @@ public class UGraphicForSnake extends UGraphicDelegator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Snake moved() {
|
private Snake moved() {
|
||||||
return snake.move(dx, dy);
|
return snake.move(dx, dy);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,9 @@ import net.sourceforge.plantuml.Url;
|
|||||||
import net.sourceforge.plantuml.creole.Stencil;
|
import net.sourceforge.plantuml.creole.Stencil;
|
||||||
import net.sourceforge.plantuml.cucadiagram.BodyEnhanced;
|
import net.sourceforge.plantuml.cucadiagram.BodyEnhanced;
|
||||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
|
||||||
import net.sourceforge.plantuml.cucadiagram.ILeaf;
|
import net.sourceforge.plantuml.cucadiagram.ILeaf;
|
||||||
|
import net.sourceforge.plantuml.cucadiagram.PortionShower;
|
||||||
import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
||||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||||
@ -74,14 +76,15 @@ public class EntityImageUseCase extends AbstractEntityImage {
|
|||||||
|
|
||||||
final private Url url;
|
final private Url url;
|
||||||
|
|
||||||
public EntityImageUseCase(ILeaf entity, ISkinParam skinParam) {
|
public EntityImageUseCase(ILeaf entity, ISkinParam skinParam, PortionShower portionShower) {
|
||||||
super(entity, skinParam);
|
super(entity, skinParam);
|
||||||
final Stereotype stereotype = entity.getStereotype();
|
final Stereotype stereotype = entity.getStereotype();
|
||||||
|
|
||||||
final TextBlock tmp = new BodyEnhanced(entity.getDisplay(), FontParam.USECASE, skinParam,
|
final TextBlock tmp = new BodyEnhanced(entity.getDisplay(), FontParam.USECASE, skinParam,
|
||||||
HorizontalAlignment.CENTER, stereotype, true, false, entity);
|
HorizontalAlignment.CENTER, stereotype, true, false, entity);
|
||||||
|
|
||||||
if (stereotype == null || stereotype.getLabel(false) == null) {
|
if (stereotype == null || stereotype.getLabel(false) == null
|
||||||
|
|| portionShower.showPortion(EntityPortion.STEREOTYPE, entity) == false) {
|
||||||
this.desc = tmp;
|
this.desc = tmp;
|
||||||
} else {
|
} else {
|
||||||
final TextBlock stereo = Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet()))
|
final TextBlock stereo = Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet()))
|
||||||
|
@ -73,6 +73,10 @@ public class Footprint {
|
|||||||
private final UTranslate translate;
|
private final UTranslate translate;
|
||||||
private final List<Point2D.Double> all;
|
private final List<Point2D.Double> all;
|
||||||
|
|
||||||
|
public double dpiFactor() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
private MyUGraphic(List<Point2D.Double> all, UTranslate translate) {
|
private MyUGraphic(List<Point2D.Double> all, UTranslate translate) {
|
||||||
this.all = all;
|
this.all = all;
|
||||||
this.translate = translate;
|
this.translate = translate;
|
||||||
|
@ -40,9 +40,6 @@ import java.awt.Dimension;
|
|||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.datatransfer.DataFlavor;
|
|
||||||
import java.awt.datatransfer.Transferable;
|
|
||||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.KeyAdapter;
|
import java.awt.event.KeyAdapter;
|
||||||
@ -75,6 +72,7 @@ import javax.swing.WindowConstants;
|
|||||||
import net.sourceforge.plantuml.FileFormat;
|
import net.sourceforge.plantuml.FileFormat;
|
||||||
import net.sourceforge.plantuml.FileFormatOption;
|
import net.sourceforge.plantuml.FileFormatOption;
|
||||||
import net.sourceforge.plantuml.GeneratedImage;
|
import net.sourceforge.plantuml.GeneratedImage;
|
||||||
|
import net.sourceforge.plantuml.ImageSelection;
|
||||||
import net.sourceforge.plantuml.graphic.GraphicStrings;
|
import net.sourceforge.plantuml.graphic.GraphicStrings;
|
||||||
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
|
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
|
||||||
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
|
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
|
||||||
@ -442,30 +440,3 @@ class ImageWindow2 extends JFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This class is used to hold an image while on the clipboard.
|
|
||||||
class ImageSelection implements Transferable {
|
|
||||||
private Image image;
|
|
||||||
|
|
||||||
public ImageSelection(Image image) {
|
|
||||||
this.image = image;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns supported flavors
|
|
||||||
public DataFlavor[] getTransferDataFlavors() {
|
|
||||||
return new DataFlavor[] { DataFlavor.imageFlavor };
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if flavor is supported
|
|
||||||
public boolean isDataFlavorSupported(DataFlavor flavor) {
|
|
||||||
return DataFlavor.imageFlavor.equals(flavor);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns image
|
|
||||||
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
|
|
||||||
if (!DataFlavor.imageFlavor.equals(flavor)) {
|
|
||||||
throw new UnsupportedFlavorException(flavor);
|
|
||||||
}
|
|
||||||
return image;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -289,6 +289,7 @@ public class MainWindow2 extends JFrame {
|
|||||||
final JFileChooser chooser = new JFileChooser();
|
final JFileChooser chooser = new JFileChooser();
|
||||||
chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
|
chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
|
||||||
chooser.setDialogTitle("Directory to watch:");
|
chooser.setDialogTitle("Directory to watch:");
|
||||||
|
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||||
chooser.setAcceptAllFileFilterUsed(false);
|
chooser.setAcceptAllFileFilterUsed(false);
|
||||||
final String currentPath = prefs.get(KEY_DIR, ".");
|
final String currentPath = prefs.get(KEY_DIR, ".");
|
||||||
chooser.setCurrentDirectory(new File(currentPath));
|
chooser.setCurrentDirectory(new File(currentPath));
|
||||||
@ -297,11 +298,7 @@ public class MainWindow2 extends JFrame {
|
|||||||
Log.info("Closing OpenDialog");
|
Log.info("Closing OpenDialog");
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||||
final File dir = chooser.getSelectedFile();
|
final File dir = chooser.getSelectedFile();
|
||||||
if (dir.isDirectory()) {
|
changeDir(dir);
|
||||||
changeDir(dir);
|
|
||||||
} else {
|
|
||||||
changeDir(dir.getParentFile());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,7 @@ public class SpriteWindow extends JFrame {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
encodeColor(img, sb);
|
||||||
encode(img, SpriteGrayLevel.GRAY_16, sb);
|
encode(img, SpriteGrayLevel.GRAY_16, sb);
|
||||||
encodeCompressed(img, SpriteGrayLevel.GRAY_16, sb);
|
encodeCompressed(img, SpriteGrayLevel.GRAY_16, sb);
|
||||||
encode(img, SpriteGrayLevel.GRAY_8, sb);
|
encode(img, SpriteGrayLevel.GRAY_8, sb);
|
||||||
@ -120,6 +121,12 @@ public class SpriteWindow extends JFrame {
|
|||||||
printData(sb.toString());
|
printData(sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void encodeColor(BufferedImage img, StringBuilder sb) {
|
||||||
|
sb.append("\n");
|
||||||
|
sb.append(SpriteUtils.encodeColor(img, "demo"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void encodeCompressed(BufferedImage img, SpriteGrayLevel level, StringBuilder sb) {
|
private void encodeCompressed(BufferedImage img, SpriteGrayLevel level, StringBuilder sb) {
|
||||||
sb.append("\n");
|
sb.append("\n");
|
||||||
sb.append(SpriteUtils.encodeCompressed(img, "demo", level));
|
sb.append(SpriteUtils.encodeCompressed(img, "demo", level));
|
||||||
|
@ -71,7 +71,7 @@ public class SyntaxChecker {
|
|||||||
result.setLineLocation(new LineLocationImpl(null, null).oneLineRead());
|
result.setLineLocation(new LineLocationImpl(null, null).oneLineRead());
|
||||||
// result.setErrorLinePosition(0);
|
// result.setErrorLinePosition(0);
|
||||||
result.addErrorText("No @startuml found");
|
result.addErrorText("No @startuml found");
|
||||||
result.setSuggest(Arrays.asList("Did you mean:", "@startuml"));
|
// result.setSuggest(Arrays.asList("Did you mean:", "@startuml"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (source.endsWith("@enduml\n") == false && source.endsWith("@enduml") == false) {
|
if (source.endsWith("@enduml\n") == false && source.endsWith("@enduml") == false) {
|
||||||
@ -79,7 +79,7 @@ public class SyntaxChecker {
|
|||||||
result.setLineLocation(lastLineNumber2(source));
|
result.setLineLocation(lastLineNumber2(source));
|
||||||
// result.setErrorLinePosition(lastLineNumber(source));
|
// result.setErrorLinePosition(lastLineNumber(source));
|
||||||
result.addErrorText("No @enduml found");
|
result.addErrorText("No @enduml found");
|
||||||
result.setSuggest(Arrays.asList("Did you mean:", "@enduml"));
|
// result.setSuggest(Arrays.asList("Did you mean:", "@enduml"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
final SourceStringReader sourceStringReader = new SourceStringReader(Defines.createEmpty(), source,
|
final SourceStringReader sourceStringReader = new SourceStringReader(Defines.createEmpty(), source,
|
||||||
@ -91,7 +91,7 @@ public class SyntaxChecker {
|
|||||||
result.setLineLocation(lastLineNumber2(source));
|
result.setLineLocation(lastLineNumber2(source));
|
||||||
// result.setErrorLinePosition(lastLineNumber(source));
|
// result.setErrorLinePosition(lastLineNumber(source));
|
||||||
result.addErrorText("No @enduml found");
|
result.addErrorText("No @enduml found");
|
||||||
result.setSuggest(Arrays.asList("Did you mean:", "@enduml"));
|
// result.setSuggest(Arrays.asList("Did you mean:", "@enduml"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
final Diagram system = blocks.get(0).getDiagram();
|
final Diagram system = blocks.get(0).getDiagram();
|
||||||
@ -108,7 +108,7 @@ public class SyntaxChecker {
|
|||||||
for (ErrorUml er : sys.getErrorsUml()) {
|
for (ErrorUml er : sys.getErrorsUml()) {
|
||||||
result.addErrorText(er.getError());
|
result.addErrorText(er.getError());
|
||||||
}
|
}
|
||||||
result.setSuggest(sys.getSuggest());
|
// result.setSuggest(sys.getSuggest());
|
||||||
} else {
|
} else {
|
||||||
result.setDescription(system.getDescription().getDescription());
|
result.setDescription(system.getDescription().getDescription());
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ public class SyntaxChecker {
|
|||||||
result.setError(true);
|
result.setError(true);
|
||||||
result.setLineLocation(lastLineNumber2(source));
|
result.setLineLocation(lastLineNumber2(source));
|
||||||
result.addErrorText("No @enduml found");
|
result.addErrorText("No @enduml found");
|
||||||
result.setSuggest(Arrays.asList("Did you mean:", "@enduml"));
|
// result.setSuggest(Arrays.asList("Did you mean:", "@enduml"));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ public class SyntaxChecker {
|
|||||||
result.addErrorText(er.getError());
|
result.addErrorText(er.getError());
|
||||||
}
|
}
|
||||||
result.setSystemError(sys);
|
result.setSystemError(sys);
|
||||||
result.setSuggest(sys.getSuggest());
|
// result.setSuggest(sys.getSuggest());
|
||||||
} else {
|
} else {
|
||||||
result.setDescription(system.getDescription().getDescription());
|
result.setDescription(system.getDescription().getDescription());
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public class SyntaxResult {
|
|||||||
private String description;
|
private String description;
|
||||||
// private int errorLinePosition;
|
// private int errorLinePosition;
|
||||||
private Collection<String> errors = new TreeSet<String>();
|
private Collection<String> errors = new TreeSet<String>();
|
||||||
private List<String> suggest;
|
// private List<String> suggest;
|
||||||
private boolean hasCmapData;
|
private boolean hasCmapData;
|
||||||
private PSystemError systemError;
|
private PSystemError systemError;
|
||||||
private LineLocation lineLocation;
|
private LineLocation lineLocation;
|
||||||
@ -71,13 +71,13 @@ public class SyntaxResult {
|
|||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public int getErrorLinePosition() {
|
// public int getErrorLinePosition() {
|
||||||
// return errorLinePosition;
|
// return errorLinePosition;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public List<String> getSuggest() {
|
// public List<String> getSuggest() {
|
||||||
return suggest;
|
// return suggest;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public Collection<String> getErrors() {
|
public Collection<String> getErrors() {
|
||||||
return Collections.unmodifiableCollection(errors);
|
return Collections.unmodifiableCollection(errors);
|
||||||
@ -95,17 +95,17 @@ public class SyntaxResult {
|
|||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void setErrorLinePosition(int errorLinePosition) {
|
// public void setErrorLinePosition(int errorLinePosition) {
|
||||||
// this.errorLinePosition = errorLinePosition;
|
// this.errorLinePosition = errorLinePosition;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public void addErrorText(String error) {
|
public void addErrorText(String error) {
|
||||||
this.errors.add(error);
|
this.errors.add(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSuggest(List<String> suggest) {
|
// public void setSuggest(List<String> suggest) {
|
||||||
this.suggest = suggest;
|
// this.suggest = suggest;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public final boolean hasCmapData() {
|
public final boolean hasCmapData() {
|
||||||
return hasCmapData;
|
return hasCmapData;
|
||||||
|
@ -345,6 +345,7 @@ public class TikzGraphics {
|
|||||||
text = text.replaceAll("<", "\\\\textless ");
|
text = text.replaceAll("<", "\\\\textless ");
|
||||||
text = text.replaceAll(">", "\\\\textgreater ");
|
text = text.replaceAll(">", "\\\\textgreater ");
|
||||||
text = text.replaceAll("&", "\\\\&");
|
text = text.replaceAll("&", "\\\\&");
|
||||||
|
text = text.replaceAll("%", "\\\\%");
|
||||||
text = text.replaceAll("~", "\\\\~{}");
|
text = text.replaceAll("~", "\\\\~{}");
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public class CommandNoteLong extends CommandMultilines2<TimingDiagram> {
|
|||||||
return "(?i)^end[%s]?note$";
|
return "(?i)^end[%s]?note$";
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandExecutionResult executeNow(final TimingDiagram diagram, BlocLines lines) {
|
protected CommandExecutionResult executeNow(final TimingDiagram diagram, BlocLines lines) {
|
||||||
|
|
||||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||||
lines = lines.subExtract(1, 1);
|
lines = lines.subExtract(1, 1);
|
||||||
|
@ -41,7 +41,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
|
|||||||
|
|
||||||
public class TimeTickBuilder {
|
public class TimeTickBuilder {
|
||||||
|
|
||||||
private static final String WITHOUT_AROBASE = "(\\+?)(\\d+\\.?\\d*)";
|
private static final String WITHOUT_AROBASE = "(\\+?)(-?\\d+\\.?\\d*)";
|
||||||
private static final String WITH_AROBASE = "@" + WITHOUT_AROBASE;
|
private static final String WITH_AROBASE = "@" + WITHOUT_AROBASE;
|
||||||
|
|
||||||
public static RegexLeaf expressionAtWithoutArobase(String name) {
|
public static RegexLeaf expressionAtWithoutArobase(String name) {
|
||||||
|
@ -93,11 +93,8 @@ public class TimingDiagram extends UmlDiagram implements Clock {
|
|||||||
final ImageBuilder imageBuilder = new ImageBuilder(getSkinParam(), dpiFactor,
|
final ImageBuilder imageBuilder = new ImageBuilder(getSkinParam(), dpiFactor,
|
||||||
fileFormatOption.isWithMetadata() ? getMetadata() : null, getWarningOrError(), margin, margin,
|
fileFormatOption.isWithMetadata() ? getMetadata() : null, getWarningOrError(), margin, margin,
|
||||||
getAnimation());
|
getAnimation());
|
||||||
// imageBuilder.setUDrawable(getUDrawable());
|
|
||||||
|
|
||||||
TextBlock result = getTextBlock();
|
TextBlock result = getTextBlock();
|
||||||
// TextBlock result = new TextBlockCompressed(getTextBlock());
|
|
||||||
// result = new TextBlockRecentred(result);
|
|
||||||
final ISkinParam skinParam = getSkinParam();
|
final ISkinParam skinParam = getSkinParam();
|
||||||
result = new AnnotatedWorker(this, skinParam).addAdd(result);
|
result = new AnnotatedWorker(this, skinParam).addAdd(result);
|
||||||
imageBuilder.setUDrawable(result);
|
imageBuilder.setUDrawable(result);
|
||||||
@ -105,14 +102,6 @@ public class TimingDiagram extends UmlDiagram implements Clock {
|
|||||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os);
|
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, seed(), os);
|
||||||
}
|
}
|
||||||
|
|
||||||
private UDrawable getUDrawable() {
|
|
||||||
return new UDrawable() {
|
|
||||||
public void drawU(UGraphic ug) {
|
|
||||||
drawInternal(ug);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private TextBlockBackcolored getTextBlock() {
|
private TextBlockBackcolored getTextBlock() {
|
||||||
return new TextBlockBackcolored() {
|
return new TextBlockBackcolored() {
|
||||||
|
|
||||||
|
@ -64,6 +64,11 @@ public class TimingRuler {
|
|||||||
private long tickIntervalInPixels = 50;
|
private long tickIntervalInPixels = 50;
|
||||||
private long tickUnitary;
|
private long tickUnitary;
|
||||||
|
|
||||||
|
public TimingRuler(ISkinParam skinParam) {
|
||||||
|
this.skinParam = skinParam;
|
||||||
|
this.times.add(new TimeTick(BigDecimal.ZERO));
|
||||||
|
}
|
||||||
|
|
||||||
public void scaleInPixels(long tick, long pixel) {
|
public void scaleInPixels(long tick, long pixel) {
|
||||||
this.tickIntervalInPixels = pixel;
|
this.tickIntervalInPixels = pixel;
|
||||||
this.tickUnitary = tick;
|
this.tickUnitary = tick;
|
||||||
@ -81,7 +86,8 @@ public class TimingRuler {
|
|||||||
if (times.size() == 0) {
|
if (times.size() == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return (int) (1 + getMax().getTime().longValue() / tickUnitary());
|
final long delta = getMax().getTime().longValue() - getMin().getTime().longValue();
|
||||||
|
return (int) (1 + delta / tickUnitary());
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getWidth() {
|
public double getWidth() {
|
||||||
@ -89,13 +95,10 @@ public class TimingRuler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private double getPosInPixel(double time) {
|
private double getPosInPixel(double time) {
|
||||||
|
time -= getMin().getTime().doubleValue();
|
||||||
return time / tickUnitary() * tickIntervalInPixels;
|
return time / tickUnitary() * tickIntervalInPixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimingRuler(ISkinParam skinParam) {
|
|
||||||
this.skinParam = skinParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addTime(TimeTick time) {
|
public void addTime(TimeTick time) {
|
||||||
final boolean added = times.add(time);
|
final boolean added = times.add(time);
|
||||||
if (added) {
|
if (added) {
|
||||||
@ -104,7 +107,8 @@ public class TimingRuler {
|
|||||||
if (highestCommonFactor == -1) {
|
if (highestCommonFactor == -1) {
|
||||||
highestCommonFactor = time.getTime().longValue();
|
highestCommonFactor = time.getTime().longValue();
|
||||||
} else {
|
} else {
|
||||||
highestCommonFactor = computeHighestCommonFactor(highestCommonFactor, time.getTime().longValue());
|
highestCommonFactor = computeHighestCommonFactor(highestCommonFactor,
|
||||||
|
Math.abs(time.getTime().longValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,12 +162,19 @@ public class TimingRuler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TimeTick getMax() {
|
private TimeTick getMax() {
|
||||||
if (times.size() == 0) {
|
// if (times.size() == 0) {
|
||||||
throw new IllegalStateException("Empty list!");
|
// throw new IllegalStateException("Empty list!");
|
||||||
}
|
// }
|
||||||
return times.last();
|
return times.last();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TimeTick getMin() {
|
||||||
|
// if (times.size() == 0) {
|
||||||
|
// throw new IllegalStateException("Empty list!");
|
||||||
|
// }
|
||||||
|
return times.first();
|
||||||
|
}
|
||||||
|
|
||||||
private static long computeHighestCommonFactor(long a, long b) {
|
private static long computeHighestCommonFactor(long a, long b) {
|
||||||
long r = a;
|
long r = a;
|
||||||
while (r != 0) {
|
while (r != 0) {
|
||||||
|
@ -51,6 +51,10 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
|
|||||||
private UClip clip;
|
private UClip clip;
|
||||||
private double scale = 1;
|
private double scale = 1;
|
||||||
|
|
||||||
|
public double dpiFactor() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
public UGraphic apply(UChange change) {
|
public UGraphic apply(UChange change) {
|
||||||
final AbstractCommonUGraphic copy = copyUGraphic();
|
final AbstractCommonUGraphic copy = copyUGraphic();
|
||||||
if (change instanceof UTranslate) {
|
if (change instanceof UTranslate) {
|
||||||
@ -142,10 +146,9 @@ public abstract class AbstractCommonUGraphic implements UGraphic {
|
|||||||
public void flushUg() {
|
public void flushUg() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matchesProperty(String propertyName) {
|
public boolean matchesProperty(String propertyName) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,10 @@ public class LimitFinder implements UGraphic {
|
|||||||
public boolean matchesProperty(String propertyName) {
|
public boolean matchesProperty(String propertyName) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double dpiFactor() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
public UGraphic apply(UChange change) {
|
public UGraphic apply(UChange change) {
|
||||||
if (change instanceof UTranslate) {
|
if (change instanceof UTranslate) {
|
||||||
@ -61,6 +65,8 @@ public class LimitFinder implements UGraphic {
|
|||||||
return new LimitFinder(this);
|
return new LimitFinder(this);
|
||||||
} else if (change instanceof UAntiAliasing) {
|
} else if (change instanceof UAntiAliasing) {
|
||||||
return new LimitFinder(this);
|
return new LimitFinder(this);
|
||||||
|
} else if (change instanceof UScale) {
|
||||||
|
return new LimitFinder(this);
|
||||||
} else if (change instanceof UClip) {
|
} else if (change instanceof UClip) {
|
||||||
final LimitFinder copy = new LimitFinder(this);
|
final LimitFinder copy = new LimitFinder(this);
|
||||||
copy.clip = (UClip) change;
|
copy.clip = (UClip) change;
|
||||||
|
@ -49,6 +49,26 @@ public class MinMax {
|
|||||||
private final double minX;
|
private final double minX;
|
||||||
private final double minY;
|
private final double minY;
|
||||||
|
|
||||||
|
public boolean doesHorizontalCross(Point2D.Double pt1, Point2D.Double pt2) {
|
||||||
|
if (pt1.getY() != pt2.getY()) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
if (pt1.getX() == pt2.getX()) {
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
final double y = pt1.getY();
|
||||||
|
if (y < minY || y > maxY) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (pt1.getX() < minX && pt2.getX() > maxX) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (pt2.getX() < minX && pt1.getX() > maxX) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static MinMax getEmpty(boolean initToZero) {
|
public static MinMax getEmpty(boolean initToZero) {
|
||||||
if (initToZero) {
|
if (initToZero) {
|
||||||
return new MinMax(0, 0, 0, 0);
|
return new MinMax(0, 0, 0, 0);
|
||||||
@ -81,7 +101,8 @@ public class MinMax {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MinMax addMinMax(MinMax other) {
|
public MinMax addMinMax(MinMax other) {
|
||||||
return new MinMax(Math.min(other.minX, minX), Math.min(other.minY, minY), Math.max(other.maxX, maxX), Math.max(other.maxY, maxY));
|
return new MinMax(Math.min(other.minX, minX), Math.min(other.minY, minY), Math.max(other.maxX, maxX), Math.max(
|
||||||
|
other.maxY, maxY));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MinMax fromMax(double maxX, double maxY) {
|
public static MinMax fromMax(double maxX, double maxY) {
|
||||||
|
@ -44,6 +44,10 @@ public class SlotFinder implements UGraphic {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double dpiFactor() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
public UGraphic apply(UChange change) {
|
public UGraphic apply(UChange change) {
|
||||||
if (change instanceof UTranslate) {
|
if (change instanceof UTranslate) {
|
||||||
return new SlotFinder(stringBounder, yslot, translate.compose((UTranslate) change));
|
return new SlotFinder(stringBounder, yslot, translate.compose((UTranslate) change));
|
||||||
|
@ -44,6 +44,10 @@ public class SlotFinderX implements UGraphic {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double dpiFactor() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
public UGraphic apply(UChange change) {
|
public UGraphic apply(UChange change) {
|
||||||
if (change instanceof UTranslate) {
|
if (change instanceof UTranslate) {
|
||||||
return new SlotFinderX(stringBounder, xslot, yslot, translate.compose((UTranslate) change));
|
return new SlotFinderX(stringBounder, xslot, yslot, translate.compose((UTranslate) change));
|
||||||
|
@ -45,6 +45,11 @@ public class TextLimitFinder implements UGraphic {
|
|||||||
public boolean matchesProperty(String propertyName) {
|
public boolean matchesProperty(String propertyName) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double dpiFactor() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public UGraphic apply(UChange change) {
|
public UGraphic apply(UChange change) {
|
||||||
if (change instanceof UTranslate) {
|
if (change instanceof UTranslate) {
|
||||||
|
@ -57,4 +57,6 @@ public interface UGraphic {
|
|||||||
public void flushUg();
|
public void flushUg();
|
||||||
|
|
||||||
public boolean matchesProperty(String propertyName);
|
public boolean matchesProperty(String propertyName);
|
||||||
|
|
||||||
|
public double dpiFactor();
|
||||||
}
|
}
|
||||||
|
@ -43,27 +43,42 @@ public class UImage implements UShape {
|
|||||||
|
|
||||||
private final BufferedImage image;
|
private final BufferedImage image;
|
||||||
|
|
||||||
|
// public final double getScale() {
|
||||||
|
// return scale;
|
||||||
|
// }
|
||||||
|
|
||||||
public UImage(BufferedImage image) {
|
public UImage(BufferedImage image) {
|
||||||
this.image = image;
|
this.image = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UImage(BufferedImage before, double scale) {
|
// public UImage(BufferedImage before, double scale) {
|
||||||
if (scale == 1) {
|
// this.image = before;
|
||||||
this.image = before;
|
// this.scale = scale;
|
||||||
return;
|
// // if (scale == 1) {
|
||||||
}
|
// // this.image = before;
|
||||||
|
// // return;
|
||||||
|
// // }
|
||||||
|
//
|
||||||
|
// // final int w = (int) Math.round(before.getWidth() * scale);
|
||||||
|
// // final int h = (int) Math.round(before.getHeight() * scale);
|
||||||
|
// // final BufferedImage after = new BufferedImage(w, h, before.getType());
|
||||||
|
// // final AffineTransform at = new AffineTransform();
|
||||||
|
// // at.scale(scale, scale);
|
||||||
|
// // final AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
|
||||||
|
// // this.image = scaleOp.filter(before, after);
|
||||||
|
// }
|
||||||
|
|
||||||
final int w = (int) Math.round(before.getWidth() * scale);
|
public UImage scale(double scale) {
|
||||||
final int h = (int) Math.round(before.getHeight() * scale);
|
if (scale == 1) {
|
||||||
final BufferedImage after = new BufferedImage(w, h, before.getType());
|
return this;
|
||||||
|
}
|
||||||
|
final int w = (int) Math.round(image.getWidth() * scale);
|
||||||
|
final int h = (int) Math.round(image.getHeight() * scale);
|
||||||
|
final BufferedImage after = new BufferedImage(w, h, image.getType());
|
||||||
final AffineTransform at = new AffineTransform();
|
final AffineTransform at = new AffineTransform();
|
||||||
at.scale(scale, scale);
|
at.scale(scale, scale);
|
||||||
final AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
|
final AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR);
|
||||||
this.image = scaleOp.filter(before, after);
|
return new UImage(scaleOp.filter(image, after));
|
||||||
}
|
|
||||||
|
|
||||||
public UImage scale(double scale) {
|
|
||||||
return new UImage(image, scale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final BufferedImage getImage() {
|
public final BufferedImage getImage() {
|
||||||
@ -71,11 +86,15 @@ public class UImage implements UShape {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public double getWidth() {
|
public double getWidth() {
|
||||||
return image.getWidth()-1;
|
return image.getWidth() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getHeight() {
|
public double getHeight() {
|
||||||
return image.getHeight()-1;
|
return image.getHeight() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public UShape getScaled(double scale) {
|
||||||
|
// return scale(scale);
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,11 @@ public class UGraphicCrossing implements UGraphic {
|
|||||||
private final UGraphic ug;
|
private final UGraphic ug;
|
||||||
private final List<Pending> lines;
|
private final List<Pending> lines;
|
||||||
private final UTranslate translate;
|
private final UTranslate translate;
|
||||||
|
|
||||||
|
public double dpiFactor() {
|
||||||
|
return ug.dpiFactor();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static class Pending {
|
static class Pending {
|
||||||
final UGraphic ug;
|
final UGraphic ug;
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
package net.sourceforge.plantuml.ugraphic.g2d;
|
package net.sourceforge.plantuml.ugraphic.g2d;
|
||||||
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.geom.AffineTransform;
|
||||||
|
|
||||||
import net.sourceforge.plantuml.EnsureVisible;
|
import net.sourceforge.plantuml.EnsureVisible;
|
||||||
import net.sourceforge.plantuml.ugraphic.ColorMapper;
|
import net.sourceforge.plantuml.ugraphic.ColorMapper;
|
||||||
@ -48,19 +49,24 @@ import net.sourceforge.plantuml.ugraphic.UShape;
|
|||||||
public class DriverImageG2d implements UDriver<Graphics2D> {
|
public class DriverImageG2d implements UDriver<Graphics2D> {
|
||||||
|
|
||||||
private final EnsureVisible visible;
|
private final EnsureVisible visible;
|
||||||
|
private final double dpiFactor;
|
||||||
|
|
||||||
public DriverImageG2d(EnsureVisible visible) {
|
public DriverImageG2d(double dpiFactor, EnsureVisible visible) {
|
||||||
this.visible = visible;
|
this.visible = visible;
|
||||||
|
this.dpiFactor = dpiFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
|
public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, Graphics2D g2d) {
|
||||||
if (ushape instanceof UImageSvg) {
|
if (ushape instanceof UImageSvg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final UImage shape = (UImage) ushape;
|
final UImage shape = ((UImage) ushape);
|
||||||
visible.ensureVisible(x, y);
|
visible.ensureVisible(x, y);
|
||||||
visible.ensureVisible(x + shape.getWidth(), y + shape.getHeight());
|
visible.ensureVisible(x + shape.getWidth(), y + shape.getHeight());
|
||||||
g2d.drawImage(shape.getImage(), (int) x, (int) y, null);
|
final AffineTransform back = g2d.getTransform();
|
||||||
|
g2d.scale(1 / dpiFactor, 1 / dpiFactor);
|
||||||
|
g2d.drawImage(shape.getImage(), (int) (x * dpiFactor), (int) (y * dpiFactor), null);
|
||||||
|
g2d.setTransform(back);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -150,8 +150,8 @@ public class UGraphicG2d extends AbstractUGraphic<Graphics2D> implements EnsureV
|
|||||||
registerDriver(UPixel.class, new DriverPixelG2d());
|
registerDriver(UPixel.class, new DriverPixelG2d());
|
||||||
registerDriver(UPolygon.class, new DriverPolygonG2d(dpiFactor, this));
|
registerDriver(UPolygon.class, new DriverPolygonG2d(dpiFactor, this));
|
||||||
registerDriver(UEllipse.class, new DriverEllipseG2d(dpiFactor, this));
|
registerDriver(UEllipse.class, new DriverEllipseG2d(dpiFactor, this));
|
||||||
registerDriver(UImageSvg.class, new DriverImageG2d(this));
|
registerDriver(UImageSvg.class, new DriverImageG2d(dpiFactor, this));
|
||||||
registerDriver(UImage.class, new DriverImageG2d(this));
|
registerDriver(UImage.class, new DriverImageG2d(dpiFactor, this));
|
||||||
registerDriver(DotPath.class, new DriverDotPathG2d(this));
|
registerDriver(DotPath.class, new DriverDotPathG2d(this));
|
||||||
registerDriver(UPath.class, new DriverPathG2d(dpiFactor));
|
registerDriver(UPath.class, new DriverPathG2d(dpiFactor));
|
||||||
registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterG2d());
|
registerDriver(UCenteredCharacter.class, new DriverCenteredCharacterG2d());
|
||||||
@ -222,4 +222,9 @@ public class UGraphicG2d extends AbstractUGraphic<Graphics2D> implements EnsureV
|
|||||||
PngIO.write(im, os, metadata, dpi);
|
PngIO.write(im, os, metadata, dpi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double dpiFactor() {
|
||||||
|
return dpiFactor;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user