1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-12-22 10:59:01 +00:00

version 1.2017.14

This commit is contained in:
Arnaud Roques 2017-06-05 13:27:21 +02:00
parent 2202502f2f
commit f9bf7c08e5
90 changed files with 965 additions and 396 deletions

View File

@ -35,7 +35,7 @@
<groupId>net.sourceforge.plantuml</groupId> <groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId> <artifactId>plantuml</artifactId>
<version>1.2017.14-SNAPSHOT</version> <version>1.2017.15-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>PlantUML</name> <name>PlantUML</name>

View File

@ -65,7 +65,7 @@ public abstract class AbstractPSystem implements Diagram {
toAppend.append("(" + License.getCurrent() + " source distribution)\n"); toAppend.append("(" + License.getCurrent() + " source distribution)\n");
for (String name : OptionPrint.interestingProperties()) { for (String name : OptionPrint.interestingProperties()) {
toAppend.append(name); toAppend.append(name);
toAppend.append('\n'); toAppend.append(BackSlash.CHAR_NEWLINE);
} }
return toAppend.toString(); return toAppend.toString();
} }
@ -74,7 +74,7 @@ public abstract class AbstractPSystem implements Diagram {
if (source == null) { if (source == null) {
return getVersion(); return getVersion();
} }
return source.getPlainString() + "\n" + getVersion(); return source.getPlainString() + BackSlash.NEWLINE + getVersion();
} }
final public UmlSource getSource() { final public UmlSource getSource() {

View File

@ -43,9 +43,18 @@ import java.util.List;
public class BackSlash { public class BackSlash {
private static final char PRIVATE_BLOCK = '\uE000'; private static final char PRIVATE_BLOCK = '\uE000';
public static final String BS_BS_N = "\\n";
public static final String NEWLINE = "\n";
public static final char CHAR_NEWLINE = '\n';
public static char hiddenNewLine() { public static char hiddenNewLine() {
return PRIVATE_BLOCK + '\n'; return PRIVATE_BLOCK + BackSlash.CHAR_NEWLINE;
}
public static String convertHiddenNewLine(String s) {
s = s.replaceAll("(?<!\\\\)\\\\n", "" + hiddenNewLine());
s = s.replaceAll("\\\\\\\\n", "\\\\n");
return s;
} }
public static List<String> splitHiddenNewLine(String s) { public static List<String> splitHiddenNewLine(String s) {
@ -53,7 +62,7 @@ public class BackSlash {
} }
public static String manageNewLine(String string) { public static String manageNewLine(String string) {
return string.replace(hiddenNewLine(), '\n'); return string.replace(hiddenNewLine(), BackSlash.CHAR_NEWLINE);
} }
public static List<String> getWithNewlines(CharSequence s) { public static List<String> getWithNewlines(CharSequence s) {

View File

@ -35,6 +35,7 @@
*/ */
package net.sourceforge.plantuml; package net.sourceforge.plantuml;
import java.io.IOException;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -42,6 +43,8 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.code.AsciiEncoder; import net.sourceforge.plantuml.code.AsciiEncoder;
import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderUtil;
import net.sourceforge.plantuml.command.regex.Matcher2; import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.preproc.Defines; import net.sourceforge.plantuml.preproc.Defines;
@ -59,12 +62,19 @@ public class BlockUml {
this(convert(strings), 0, Defines.createEmpty()); this(convert(strings), 0, Defines.createEmpty());
} }
public String getEncodedUrl() throws IOException {
final Transcoder transcoder = TranscoderUtil.getDefaultTranscoder();
final String source = getDiagram().getSource().getPlainString();
final String encoded = transcoder.encode(source);
return encoded;
}
public String getFlashData() { public String getFlashData() {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
for (CharSequence2 line : data) { for (CharSequence2 line : data) {
sb.append(line); sb.append(line);
sb.append('\r'); sb.append('\r');
sb.append('\n'); sb.append(BackSlash.CHAR_NEWLINE);
} }
return sb.toString(); return sb.toString();
} }
@ -122,7 +132,7 @@ public class BlockUml {
public Diagram getDiagram() { public Diagram getDiagram() {
if (system == null) { if (system == null) {
system = new PSystemBuilder().createPSystem(data); system = new PSystemBuilder().createPSystem(data, startLine);
} }
return system; return system;
} }

View File

@ -108,8 +108,8 @@ public final class BlockUmlBuilder implements DefinitionsContainer {
reader2.setPaused(false); reader2.setPaused(false);
} }
if (StartUtils.isArobaseEndDiagram(s) && current2 != null) { if (StartUtils.isArobaseEndDiagram(s) && current2 != null) {
current2.addAll(1, convert(config, s.getLocation())); current2.addAll(1, convert(config, new LineLocationImpl(null, null).oneLineRead()));
blocks.add(new BlockUml(current2, startLine, defines.cloneMe())); blocks.add(new BlockUml(current2, startLine - config.size(), defines.cloneMe()));
current2 = null; current2 = null;
reader2.setPaused(false); reader2.setPaused(false);
} }

View File

@ -66,14 +66,14 @@ public class CMapData {
appendString("\" href=\""); appendString("\" href=\"");
appendString(url.getUrl()); appendString(url.getUrl());
appendString("\" title=\""); appendString("\" title=\"");
final String tooltip = url.getTooltip().replaceAll("\\\\n", "\n").replaceAll("&", "&#38;") final String tooltip = url.getTooltip().replaceAll("\\\\n", BackSlash.NEWLINE).replaceAll("&", "&#38;")
.replaceAll("\"", "&#34;").replaceAll("\'", "&#39;"); .replaceAll("\"", "&#34;").replaceAll("\'", "&#39;");
appendString(tooltip); appendString(tooltip);
appendString("\" alt=\"\" coords=\""); appendString("\" alt=\"\" coords=\"");
appendString(url.getCoords(scale)); appendString(url.getCoords(scale));
appendString("\"/>"); appendString("\"/>");
appendString("\n"); appendString(BackSlash.NEWLINE);
} }
// private CMapData() { // private CMapData() {

View File

@ -41,35 +41,35 @@ import net.sourceforge.plantuml.suggest.SuggestEngineStatus;
public class ErrorUml { public class ErrorUml {
private final String error; private final String error;
private final int position;
private final ErrorUmlType type; private final ErrorUmlType type;
private SuggestEngineResult suggest; private SuggestEngineResult suggest;
private final LineLocation lineLocation; private final LineLocation lineLocation;
// private final int startLine;
public ErrorUml(ErrorUmlType type, String error, int position, LineLocation lineLocation) { public ErrorUml(ErrorUmlType type, String error, LineLocation lineLocation) {
if (error == null || type == null || StringUtils.isEmpty(error)) { if (error == null || type == null || StringUtils.isEmpty(error)) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
// this.startLine = startLine;
this.error = error; this.error = error;
this.type = type; this.type = type;
this.position = position;
this.lineLocation = lineLocation; this.lineLocation = lineLocation;
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
final ErrorUml this2 = (ErrorUml) obj; final ErrorUml this2 = (ErrorUml) obj;
return this.type == this2.type && this.position == this2.position && this.error.equals(this2.error); return this.type == this2.type && this.getPosition() == this2.getPosition() && this.error.equals(this2.error);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return error.hashCode() + type.hashCode() + position + (suggest == null ? 0 : suggest.hashCode()); return error.hashCode() + type.hashCode() + getPosition() + (suggest == null ? 0 : suggest.hashCode());
} }
@Override @Override
public String toString() { public String toString() {
return type.toString() + " " + position + " " + error + " " + suggest; return type.toString() + " " + getPosition() + " " + error + " " + suggest;
} }
public final String getError() { public final String getError() {
@ -80,8 +80,8 @@ public class ErrorUml {
return type; return type;
} }
public int getPosition() { private int getPosition() {
return position; return lineLocation.getPosition();
} }
public LineLocation getLineLocation() { public LineLocation getLineLocation() {
@ -100,5 +100,4 @@ public class ErrorUml {
this.suggest = suggest; this.suggest = suggest;
} }
} }

View File

@ -62,7 +62,7 @@ public class GeneratedImageImpl implements GeneratedImage {
public int lineErrorRaw() { public int lineErrorRaw() {
final Diagram system = blockUml.getDiagram(); final Diagram system = blockUml.getDiagram();
if (system instanceof PSystemError) { if (system instanceof PSystemError) {
return ((PSystemError) system).getHigherErrorPosition() + blockUml.getStartLine(); return ((PSystemError) system).getHigherErrorPosition2().getPosition();
} }
return -1; return -1;
} }

View File

@ -141,4 +141,6 @@ public interface ISkinParam extends ISkinSimple {
public double getPadding(PaddingParam param); public double getPadding(PaddingParam param);
public boolean useRankSame();
} }

View File

@ -42,7 +42,7 @@ public interface ISourceFileReader {
public List<GeneratedImage> getGeneratedImages() throws IOException; public List<GeneratedImage> getGeneratedImages() throws IOException;
public List<String> getEncodedUrl() throws IOException; public List<BlockUml> getBlocks();
public boolean hasError(); public boolean hasError();

View File

@ -40,7 +40,7 @@ package net.sourceforge.plantuml;
* The resource maybe a local file or a remote URL. * The resource maybe a local file or a remote URL.
* *
*/ */
public interface LineLocation { public interface LineLocation extends Comparable<LineLocation> {
/** /**
* Position of the line, starting at 0. * Position of the line, starting at 0.

View File

@ -82,4 +82,9 @@ public class LineLocationImpl implements LineLocation {
return parent; return parent;
} }
public int compareTo(LineLocation other) {
final LineLocationImpl other2 = (LineLocationImpl) other;
return this.position - other2.position;
}
} }

View File

@ -46,7 +46,7 @@ public enum LineParam {
sequenceParticipantBorder, noteBorder, sequenceGroupBorder, sequenceReferenceBorder, sequenceParticipantBorder, noteBorder, sequenceGroupBorder, sequenceReferenceBorder,
legendBorder, legendBorder,
sequenceArrow, sequenceArrow,
classBorder, objectBorder, classBorder, objectBorder, usecaseBorder,
partitionBorder, partitionBorder,
packageBorder, packageBorder,
swimlaneBorder, swimlaneBorder,

View File

@ -400,7 +400,7 @@ public class Option {
public Defines getDefaultDefines(File f) { public Defines getDefaultDefines(File f) {
final Defines result = Defines.createWithFileName(f); final Defines result = Defines.createWithFileName(f);
for (Map.Entry<String, String> ent : defines.entrySet()) { for (Map.Entry<String, String> ent : defines.entrySet()) {
result.define(ent.getKey(), Arrays.asList(ent.getValue())); result.define(ent.getKey(), Arrays.asList(ent.getValue()), false);
} }
return result; return result;

View File

@ -93,24 +93,24 @@ public class PSystemBuilder {
public static final long startTime = System.currentTimeMillis(); public static final long startTime = System.currentTimeMillis();
final public Diagram createPSystem(final List<CharSequence2> strings2) { final public Diagram createPSystem(final List<CharSequence2> strings2, int startLine) {
final long now = System.currentTimeMillis(); final long now = System.currentTimeMillis();
Diagram result = null; Diagram result = null;
try { try {
final DiagramType type = DiagramType.getTypeFromArobaseStart(strings2.get(0).toString2()); final DiagramType type = DiagramType.getTypeFromArobaseStart(strings2.get(0).toString2());
final UmlSource umlSource = new UmlSource(strings2, type == DiagramType.UML); final UmlSource umlSource = new UmlSource(strings2, type == DiagramType.UML, startLine);
int cpt = 0; // int cpt = 0;
for (CharSequence2 s : strings2) { for (CharSequence2 s : strings2) {
if (s.getPreprocessorError() != null) { if (s.getPreprocessorError() != null) {
Log.error("Preprocessor Error: " + s.getPreprocessorError()); Log.error("Preprocessor Error: " + s.getPreprocessorError());
final ErrorUml singleError = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, s.getPreprocessorError(), cpt, final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, s.getPreprocessorError(), /* cpt */
s.getLocation()); s.getLocation());
return new PSystemError(umlSource, singleError, Collections.<String> emptyList()); return new PSystemError(umlSource, err, Collections.<String> emptyList());
} }
cpt++; // cpt++;
} }
final DiagramType diagramType = umlSource.getDiagramType(); final DiagramType diagramType = umlSource.getDiagramType();

View File

@ -43,6 +43,7 @@ import java.io.PrintStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
@ -72,7 +73,7 @@ import net.sourceforge.plantuml.version.PSystemVersion;
public class PSystemError extends AbstractPSystem { public class PSystemError extends AbstractPSystem {
private final int higherErrorPosition; private final LineLocation higherErrorPosition;
private final List<ErrorUml> printedErrors; private final List<ErrorUml> printedErrors;
private final List<String> debugLines = new ArrayList<String>(); private final List<String> debugLines = new ArrayList<String>();
@ -83,20 +84,20 @@ public class PSystemError extends AbstractPSystem {
private PSystemError(UmlSource source, List<ErrorUml> all, List<String> debugLines) { private PSystemError(UmlSource source, List<ErrorUml> all, List<String> debugLines) {
this.setSource(source); this.setSource(source);
final int higherErrorPositionExecution = getHigherErrorPosition(ErrorUmlType.EXECUTION_ERROR, all); final LineLocation execution = getHigherErrorPosition2(ErrorUmlType.EXECUTION_ERROR, all);
final int higherErrorPositionSyntax = getHigherErrorPosition(ErrorUmlType.SYNTAX_ERROR, all); final LineLocation syntax = getHigherErrorPosition2(ErrorUmlType.SYNTAX_ERROR, all);
if (higherErrorPositionExecution == Integer.MIN_VALUE && higherErrorPositionSyntax == Integer.MIN_VALUE) { if (execution == null && syntax == null) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
if (higherErrorPositionExecution >= higherErrorPositionSyntax) { if (execution != null && (syntax == null || execution.compareTo(syntax) >= 0)) {
higherErrorPosition = higherErrorPositionExecution; higherErrorPosition = execution;
printedErrors = getErrorsAt(higherErrorPositionExecution, ErrorUmlType.EXECUTION_ERROR, all); printedErrors = getErrorsAt2(execution, ErrorUmlType.EXECUTION_ERROR, all);
} else { } else {
assert higherErrorPositionSyntax > higherErrorPositionExecution; // assert syntax.compareTo(execution) > 0;
higherErrorPosition = higherErrorPositionSyntax; higherErrorPosition = syntax;
printedErrors = getErrorsAt(higherErrorPositionSyntax, ErrorUmlType.SYNTAX_ERROR, all); printedErrors = getErrorsAt2(syntax, ErrorUmlType.SYNTAX_ERROR, all);
} }
if (debugLines != null) { if (debugLines != null) {
@ -141,10 +142,10 @@ public class PSystemError extends AbstractPSystem {
} else { } else {
udrawable = result; udrawable = result;
} }
// final int min = (int) (System.currentTimeMillis() / 60000L) % 60; final int min = (int) (System.currentTimeMillis() / 60000L) % 60;
// if (min == 0) { if (min == 0) {
// udrawable = addMessage(udrawable); udrawable = addMessage(udrawable);
// } }
imageBuilder.setUDrawable(udrawable); imageBuilder.setUDrawable(udrawable);
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed(), os); return imageBuilder.writeImageTOBEMOVED(fileFormat, seed(), os);
} }
@ -197,21 +198,24 @@ public class PSystemError extends AbstractPSystem {
result.add(" "); result.add(" ");
} }
final int limit = 4; // final int limit = 4;
int start; // int start;
final int skip = higherErrorPosition - limit + 1; // final int skip = higherErrorPosition - limit + 1;
if (skip <= 0) { // if (skip <= 0) {
start = 0; // start = 0;
} else { // } else {
if (skip == 1) { // if (skip == 1) {
result.add("... (skipping 1 line) ..."); // result.add("... (skipping 1 line) ...");
} else { // } else {
result.add("... (skipping " + skip + " lines) ..."); // result.add("... (skipping " + skip + " lines) ...");
} // }
start = higherErrorPosition - limit + 1; // start = higherErrorPosition - limit + 1;
} // }
for (int i = start; i < higherErrorPosition; i++) { // for (int i = start; i < higherErrorPosition; i++) {
result.add(getSource().getLine(i)); // result.add(getSource().getLine(i));
// }
for (String s : getPartialCode()) {
result.add(s);
} }
final String errorLine = getSource().getLine(higherErrorPosition); final String errorLine = getSource().getLine(higherErrorPosition);
final String err = StringUtils.hideComparatorCharacters(errorLine); final String err = StringUtils.hideComparatorCharacters(errorLine);
@ -272,27 +276,54 @@ public class PSystemError extends AbstractPSystem {
} }
} }
private List<String> getPartialCode() {
List<String> result = new ArrayList<String>();
for (Iterator<CharSequence2> it = getSource().iterator2(); it.hasNext();) {
final CharSequence2 s = it.next();
if (s.getLocation().compareTo(higherErrorPosition) < 0) {
result.add(s.toString());
}
}
final int limit = 4;
if (result.size() > limit) {
final int skip = result.size() - limit + 1;
final String skipMessage;
if (skip == 1) {
skipMessage = "... (skipping 1 line) ...";
} else {
skipMessage = "... (skipping " + skip + " lines) ...";
}
result = new ArrayList<String>(result.subList(skip, result.size()));
result.add(0, skipMessage);
}
return result;
}
private List<String> getHtmlStrings(boolean useRed) { private List<String> getHtmlStrings(boolean useRed) {
final List<String> htmlStrings = new ArrayList<String>(getStack()); final List<String> htmlStrings = new ArrayList<String>(getStack());
if (htmlStrings.size() > 0) { if (htmlStrings.size() > 0) {
htmlStrings.add("----"); htmlStrings.add("----");
} }
final int limit = 4; // final int limit = 4;
int start; // int start;
final int skip = higherErrorPosition - limit + 1; // final int skip = higherErrorPosition - limit + 1;
if (skip <= 0) { // if (skip <= 0) {
start = 0; // start = 0;
} else { // } else {
if (skip == 1) { // if (skip == 1) {
htmlStrings.add("... (skipping 1 line) ..."); // htmlStrings.add("... (skipping 1 line) ...");
} else { // } else {
htmlStrings.add("... (skipping " + skip + " lines) ..."); // htmlStrings.add("... (skipping " + skip + " lines) ...");
} // }
start = higherErrorPosition - limit + 1; // start = higherErrorPosition - limit + 1;
} // }
for (int i = start; i < higherErrorPosition; i++) { // for (int i = start; i < higherErrorPosition; i++) {
htmlStrings.add(StringUtils.hideComparatorCharacters(getSource().getLine(i))); // htmlStrings.add(StringUtils.hideComparatorCharacters(getSource().getLine(i)));
// }
for (String s : getPartialCode()) {
htmlStrings.add(StringUtils.hideComparatorCharacters(s));
} }
final String errorLine = getSource().getLine(higherErrorPosition); final String errorLine = getSource().getLine(higherErrorPosition);
final String err = StringUtils.hideComparatorCharacters(errorLine); final String err = StringUtils.hideComparatorCharacters(errorLine);
@ -352,20 +383,40 @@ public class PSystemError extends AbstractPSystem {
return result; return result;
} }
private int getHigherErrorPosition(ErrorUmlType type, List<ErrorUml> all) { // private int getHigherErrorPosition(ErrorUmlType type, List<ErrorUml> all) {
int max = Integer.MIN_VALUE; // 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) {
LineLocation max = null;
for (ErrorUml error : getErrors(type, all)) { for (ErrorUml error : getErrors(type, all)) {
if (error.getPosition() > max) { if (max == null || error.getLineLocation().compareTo(max) > 0) {
max = error.getPosition(); max = error.getLineLocation();
} }
} }
return max; return max;
} }
private List<ErrorUml> getErrorsAt(int position, ErrorUmlType type, List<ErrorUml> all) { // 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) {
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)) {
if (error.getPosition() == position && StringUtils.isNotEmpty(error.getError())) { if (error.getLineLocation().compareTo(position) == 0 && StringUtils.isNotEmpty(error.getError())) {
result.add(error); result.add(error);
} }
} }
@ -376,7 +427,7 @@ public class PSystemError extends AbstractPSystem {
return new DiagramDescription("(Error)"); return new DiagramDescription("(Error)");
} }
public final int getHigherErrorPosition() { public final LineLocation getHigherErrorPosition2() {
return higherErrorPosition; return higherErrorPosition;
} }
@ -388,15 +439,15 @@ public class PSystemError extends AbstractPSystem {
public String getWarningOrError() { public String getWarningOrError() {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append(getDescription()); sb.append(getDescription());
sb.append('\n'); sb.append(BackSlash.CHAR_NEWLINE);
for (CharSequence t : getTitle().getDisplay()) { for (CharSequence t : getTitle().getDisplay()) {
sb.append(t); sb.append(t);
sb.append('\n'); sb.append(BackSlash.CHAR_NEWLINE);
} }
sb.append('\n'); sb.append(BackSlash.CHAR_NEWLINE);
for (String s : getSuggest()) { for (String s : getSuggest()) {
sb.append(s); sb.append(s);
sb.append('\n'); sb.append(BackSlash.CHAR_NEWLINE);
} }
return sb.toString(); return sb.toString();
} }

View File

@ -72,8 +72,11 @@ public class Pipe {
} }
final SourceStringReader sourceStringReader = new SourceStringReader(Defines.createEmpty(), source, final SourceStringReader sourceStringReader = new SourceStringReader(Defines.createEmpty(), source,
option.getConfig()); option.getConfig());
if (option.isComputeurl()) {
if (option.isSyntax()) { for (BlockUml s : sourceStringReader.getBlocks()) {
ps.println(s.getEncodedUrl());
}
} else if (option.isSyntax()) {
final Diagram system = sourceStringReader.getBlocks().get(0).getDiagram(); final Diagram system = sourceStringReader.getBlocks().get(0).getDiagram();
if (system instanceof UmlDiagram) { if (system instanceof UmlDiagram) {
ps.println(((UmlDiagram) system).getUmlDiagramType().name()); ps.println(((UmlDiagram) system).getUmlDiagramType().name());
@ -117,7 +120,7 @@ public class Pipe {
private void printErrorText(final PrintStream output, final PSystemError sys) { private void printErrorText(final PrintStream output, final PSystemError sys) {
output.println("ERROR"); output.println("ERROR");
output.println(sys.getHigherErrorPosition()); output.println(sys.getHigherErrorPosition2().getPosition());
for (ErrorUml er : sys.getErrorsUml()) { for (ErrorUml er : sys.getErrorsUml()) {
output.println(er.getError()); output.println(er.getError());
} }
@ -136,7 +139,7 @@ public class Pipe {
closed = true; closed = true;
} else { } else {
sb.append(s); sb.append(s);
sb.append("\n"); sb.append(BackSlash.NEWLINE);
} }
if (isFinished(s)) { if (isFinished(s)) {
break; break;

View File

@ -402,9 +402,8 @@ public class Run {
option.getConfig(), option.getCharset(), option.getFileFormatOption()); option.getConfig(), option.getCharset(), option.getFileFormatOption());
} }
if (option.isComputeurl()) { if (option.isComputeurl()) {
final List<String> urls = sourceFileReader.getEncodedUrl(); for (BlockUml s : sourceFileReader.getBlocks()) {
for (String s : urls) { System.out.println(s.getEncodedUrl());
System.out.println(s);
} }
return false; return false;
} }
@ -430,5 +429,4 @@ public class Run {
return result; return result;
} }
} }

View File

@ -850,4 +850,8 @@ public class SkinParam implements ISkinParam {
return 0; return 0;
} }
public boolean useRankSame() {
return false;
}
} }

View File

@ -263,4 +263,8 @@ public class SkinParamDelegator implements ISkinParam {
return skinParam.getPadding(param); return skinParam.getPadding(param);
} }
public boolean useRankSame() {
return skinParam.useRankSame();
}
} }

View File

@ -51,8 +51,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderUtil;
import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.preproc.Defines; import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.preproc.FileWithSuffix; import net.sourceforge.plantuml.preproc.FileWithSuffix;
@ -245,15 +243,8 @@ public class SourceFileReader implements ISourceFileReader {
return newName.endsWith("/") || newName.endsWith("\\"); return newName.endsWith("/") || newName.endsWith("\\");
} }
public List<String> getEncodedUrl() throws IOException { public List<BlockUml> getBlocks() {
final List<String> result = new ArrayList<String>(); return builder.getBlockUmls();
final Transcoder transcoder = TranscoderUtil.getDefaultTranscoder();
for (BlockUml blockUml : builder.getBlockUmls()) {
final String source = blockUml.getDiagram().getSource().getPlainString();
final String encoded = transcoder.encode(source);
result.add(encoded);
}
return Collections.unmodifiableList(result);
} }
private Reader getReader(String charset) throws FileNotFoundException, UnsupportedEncodingException { private Reader getReader(String charset) throws FileNotFoundException, UnsupportedEncodingException {
@ -273,4 +264,5 @@ public class SourceFileReader implements ISourceFileReader {
return builder.getIncludedFiles(); return builder.getIncludedFiles();
} }
} }

View File

@ -47,8 +47,6 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderUtil;
import net.sourceforge.plantuml.core.Diagram; import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.preproc.Defines; import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.preproc.FileWithSuffix; import net.sourceforge.plantuml.preproc.FileWithSuffix;
@ -108,17 +106,6 @@ public class SourceFileReader2 implements ISourceFileReader {
return Collections.unmodifiableList(result); return Collections.unmodifiableList(result);
} }
public List<String> getEncodedUrl() throws IOException {
final List<String> result = new ArrayList<String>();
final Transcoder transcoder = TranscoderUtil.getDefaultTranscoder();
for (BlockUml blockUml : builder.getBlockUmls()) {
final String source = blockUml.getDiagram().getSource().getPlainString();
final String encoded = transcoder.encode(source);
result.add(encoded);
}
return Collections.unmodifiableList(result);
}
private Reader getReader(String charset) throws FileNotFoundException, UnsupportedEncodingException { private Reader getReader(String charset) throws FileNotFoundException, UnsupportedEncodingException {
if (charset == null) { if (charset == null) {
Log.info("Using default charset"); Log.info("Using default charset");
@ -136,4 +123,8 @@ public class SourceFileReader2 implements ISourceFileReader {
return builder.getIncludedFiles(); return builder.getIncludedFiles();
} }
public List<BlockUml> getBlocks() {
return builder.getBlockUmls();
}
} }

View File

@ -153,7 +153,7 @@ public class SourceStringReader {
// final CMapData cmap = new CMapData(); // final CMapData cmap = new CMapData();
final ImageData imageData = system.exportDiagram(os, numImage, fileFormatOption); final ImageData imageData = system.exportDiagram(os, numImage, fileFormatOption);
// if (imageData.containsCMapData()) { // if (imageData.containsCMapData()) {
// return system.getDescription().getDescription() + "\n" + imageData.getCMapData("plantuml"); // return system.getDescription().getDescription() + BackSlash.BS_N + imageData.getCMapData("plantuml");
// } // }
return system.getDescription(); return system.getDescription();
} }

View File

@ -72,20 +72,20 @@ public class UrlBuilder {
this.mode = mode; this.mode = mode;
} }
private static String multilineTooltip(String label) { // private static String multilineTooltip(String label) {
final Pattern2 p = MyPattern.cmpile("(?i)^(" + URL_PATTERN + ")?(.*)$"); // final Pattern2 p = MyPattern.cmpile("(?i)^(" + URL_PATTERN + ")?(.*)$");
final Matcher2 m = p.matcher(label); // final Matcher2 m = p.matcher(label);
if (m.matches() == false) { // if (m.matches() == false) {
return label; // return label;
} // }
String gr1 = m.group(1); // String gr1 = m.group(1);
if (gr1 == null) { // if (gr1 == null) {
return label; // return label;
} // }
final String gr2 = m.group(m.groupCount()); // final String gr2 = m.group(m.groupCount());
gr1 = gr1.replaceAll("\\\\n", "\n"); // gr1 = gr1.replaceAll("\\\\n", BackSlash.BS_N);
return gr1 + gr2; // return gr1 + gr2;
} // }
public Url getUrl(String s) { public Url getUrl(String s) {
final Pattern2 p; final Pattern2 p;

View File

@ -37,6 +37,7 @@ package net.sourceforge.plantuml.activitydiagram.command;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.Direction; import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
@ -128,7 +129,7 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
urlActivity = extractUrl(diagram, desc0); urlActivity = extractUrl(diagram, desc0);
if (urlActivity == null) { if (urlActivity == null) {
sb.append(desc0); sb.append(desc0);
sb.append("\\n"); sb.append(BackSlash.BS_BS_N);
} }
} }
int i = 0; int i = 0;
@ -142,15 +143,15 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
} }
sb.append(cs); sb.append(cs);
if (i < lines.size() - 2) { if (i < lines.size() - 2) {
sb.append("\\n"); sb.append(BackSlash.BS_BS_N);
} }
} }
final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()), lines.getLast499() final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()), lines.getLast499()
.toString()); .toString());
if (StringUtils.isNotEmpty(lineLast.get(0))) { if (StringUtils.isNotEmpty(lineLast.get(0))) {
if (sb.length() > 0 && sb.toString().endsWith("\\n") == false) { if (sb.length() > 0 && sb.toString().endsWith(BackSlash.BS_BS_N) == false) {
sb.append("\\n"); sb.append(BackSlash.BS_BS_N);
} }
sb.append(lineLast.get(0)); sb.append(lineLast.get(0));
} }

View File

@ -54,6 +54,7 @@ import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.LeafType; import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.descdiagram.DescriptionDiagram; import net.sourceforge.plantuml.descdiagram.DescriptionDiagram;
import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram; import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> { public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
@ -91,17 +92,26 @@ public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
} }
@Override @Override
protected CommandExecutionResult executeArg(UmlDiagram classDiagram, RegexResult arg) { protected CommandExecutionResult executeArg(UmlDiagram diagram, RegexResult arg) {
if (classDiagram instanceof AbstractClassOrObjectDiagram) { if (diagram instanceof AbstractClassOrObjectDiagram) {
return executeClassDiagram((AbstractClassOrObjectDiagram) classDiagram, arg); return executeClassDiagram((AbstractClassOrObjectDiagram) diagram, arg);
} }
if (classDiagram instanceof DescriptionDiagram) { if (diagram instanceof DescriptionDiagram) {
return executeDescriptionDiagram((DescriptionDiagram) classDiagram, arg); return executeDescriptionDiagram((DescriptionDiagram) diagram, arg);
}
if (diagram instanceof SequenceDiagram) {
return executeSequenceDiagram((SequenceDiagram) diagram, arg);
} }
// Just ignored // Just ignored
return CommandExecutionResult.ok(); return CommandExecutionResult.ok();
} }
private CommandExecutionResult executeSequenceDiagram(SequenceDiagram diagram, RegexResult arg) {
final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION", 0));
diagram.hideOrShow(portion, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
return CommandExecutionResult.ok();
}
private CommandExecutionResult executeDescriptionDiagram(DescriptionDiagram diagram, RegexResult arg) { private CommandExecutionResult executeDescriptionDiagram(DescriptionDiagram diagram, RegexResult arg) {
final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION", 0)); final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION", 0));
final EntityGender gender; final EntityGender gender;

View File

@ -185,7 +185,7 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
// return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(a); // return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(a);
// } // }
// return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(a) + // return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(a) +
// "\\n" // BackSlash.VV1
// + StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(b); // + StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(b);
// } // }

View File

@ -171,7 +171,7 @@ public class BlocLines implements Iterable<CharSequence> {
return new BlocLines(copy); return new BlocLines(copy);
} }
public BlocLines concat2() { public BlocLines toSingleLineWithHiddenNewLine() {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
for (CharSequence line : lines) { for (CharSequence line : lines) {
sb.append(line); sb.append(line);

View File

@ -57,7 +57,7 @@ public class CommandDecoratorMultine<D extends Diagram> implements Command<D> {
if (removeEmptyColumn) { if (removeEmptyColumn) {
lines = lines.removeEmptyColumns(); lines = lines.removeEmptyColumns();
} }
lines = lines.concat2(); lines = lines.toSingleLineWithHiddenNewLine();
return cmd.execute(diagram, lines); return cmd.execute(diagram, lines);
} }
@ -65,7 +65,7 @@ public class CommandDecoratorMultine<D extends Diagram> implements Command<D> {
if (cmd.isCommandForbidden()) { if (cmd.isCommandForbidden()) {
return CommandControl.NOT_OK; return CommandControl.NOT_OK;
} }
lines = lines.concat2(); lines = lines.toSingleLineWithHiddenNewLine();
if (cmd.isForbidden(lines.getFirst499())) { if (cmd.isForbidden(lines.getFirst499())) {
return CommandControl.NOT_OK; return CommandControl.NOT_OK;
} }

View File

@ -53,14 +53,16 @@ public abstract class PSystemAbstractFactory implements PSystemFactory {
} }
final protected AbstractPSystem buildEmptyError(UmlSource source, LineLocation lineLocation) { final protected AbstractPSystem buildEmptyError(UmlSource source, LineLocation lineLocation) {
final PSystemError result = new PSystemError(source, new ErrorUml(ErrorUmlType.SYNTAX_ERROR, final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Empty description", /* 1, */lineLocation);
"Empty description", 1, lineLocation), null); final PSystemError result = new PSystemError(source, err, null);
result.setSource(source); result.setSource(source);
return result; return result;
} }
final protected PSystemError buildEmptyError(UmlSource source, String err, LineLocation lineLocation) { final protected PSystemError buildExecutionError(UmlSource source, String stringError, LineLocation lineLocation) {
final PSystemError result = new PSystemError(source, new ErrorUml(ErrorUmlType.EXECUTION_ERROR, err, 1, lineLocation), null); final ErrorUml err = new ErrorUml(ErrorUmlType.EXECUTION_ERROR, stringError, /* 1, */
lineLocation);
final PSystemError result = new PSystemError(source, err, null);
result.setSource(source); result.setSource(source);
return result; return result;
} }

View File

@ -88,8 +88,9 @@ public abstract class PSystemBasicFactory<P extends AbstractPSystem> extends PSy
} }
system = executeLine(system, s.toString2()); system = executeLine(system, s.toString2());
if (system == null) { if (system == null) {
return new PSystemError(source, new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?", final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?",
it.currentNum() - 1, s.getLocation()), null); /* it.currentNum() - 1, */s.getLocation());
return new PSystemError(source, err, null);
} }
} }
if (system != null) { if (system != null) {

View File

@ -78,8 +78,9 @@ public abstract class PSystemSingleLineFactory extends PSystemAbstractFactory {
} }
final AbstractPSystem sys = executeLine(s.toString2()); final AbstractPSystem sys = executeLine(s.toString2());
if (sys == null) { if (sys == null) {
return new PSystemError(source, new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?", final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?",
it.currentNum() - 1, s.getLocation()), null); /* it.currentNum() - 1, */s.getLocation());
return new PSystemError(source, err, null);
} }
sys.setSource(source); sys.setSource(source);
return sys; return sys;

View File

@ -91,7 +91,7 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
} }
final String err = sys.checkFinalError(); final String err = sys.checkFinalError();
if (err != null) { if (err != null) {
return buildEmptyError(source, err, it.peek().getLocation()); return buildExecutionError(source, err, it.peek().getLocation());
} }
if (source.getTotalLineCount() == 2) { if (source.getTotalLineCount() == 2) {
return buildEmptyError(source, it.peek().getLocation()); return buildEmptyError(source, it.peek().getLocation());
@ -116,7 +116,7 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
private AbstractPSystem executeOneLine(AbstractPSystem sys, UmlSource source, final IteratorCounter2 it) { private AbstractPSystem executeOneLine(AbstractPSystem sys, UmlSource source, final IteratorCounter2 it) {
final CommandControl commandControl = isValid2(it); final CommandControl commandControl = isValid2(it);
if (commandControl == CommandControl.NOT_OK) { if (commandControl == CommandControl.NOT_OK) {
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.currentNum(), */it.peek()
.getLocation()); .getLocation());
if (OptionFlags.getInstance().isUseSuggestEngine()) { if (OptionFlags.getInstance().isUseSuggestEngine()) {
final SuggestEngine engine = new SuggestEngine(source, this); final SuggestEngine engine = new SuggestEngine(source, this);
@ -130,8 +130,9 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
final IteratorCounter2 saved = it.cloneMe(); final IteratorCounter2 saved = it.cloneMe();
final CommandExecutionResult result = manageMultiline2(it, sys); final CommandExecutionResult result = manageMultiline2(it, sys);
if (result.isOk() == false) { if (result.isOk() == false) {
sys = new PSystemError(source, new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(), final ErrorUml err = new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(),
it.currentNum() - 1, saved.next().getLocation()), null); /* it.currentNum() - 1, */saved.next().getLocation());
sys = new PSystemError(source, err, null);
} }
} else if (commandControl == CommandControl.OK) { } else if (commandControl == CommandControl.OK) {
@ -140,8 +141,10 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
Command cmd = getFirstCommandOkForLines(lines); Command cmd = getFirstCommandOkForLines(lines);
final CommandExecutionResult result = sys.executeCommand(cmd, lines); final CommandExecutionResult result = sys.executeCommand(cmd, lines);
if (result.isOk() == false) { if (result.isOk() == false) {
sys = new PSystemError(source, new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(), final ErrorUml err = new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(),
it.currentNum() - 1, ((CharSequence2) line).getLocation()), result.getDebugLines()); /* it.currentNum() - 1, */((CharSequence2) line).getLocation());
sys = new PSystemError(source, err,
result.getDebugLines());
} }
if (result.getNewDiagram() != null) { if (result.getNewDiagram() != null) {
sys = result.getNewDiagram(); sys = result.getNewDiagram();

View File

@ -41,8 +41,10 @@ import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.CharSequence2; import net.sourceforge.plantuml.CharSequence2;
import net.sourceforge.plantuml.CharSequence2Impl; import net.sourceforge.plantuml.CharSequence2Impl;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.regex.Matcher2; import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern; import net.sourceforge.plantuml.command.regex.MyPattern;
@ -66,6 +68,9 @@ final public class UmlSource {
final private List<String> source; final private List<String> source;
final private List<CharSequence2> source2; final private List<CharSequence2> source2;
// final private int startLine;
// final private LineLocation startLocation;
/** /**
* Build the source from a text. * Build the source from a text.
* *
@ -73,8 +78,11 @@ final public class UmlSource {
* the source of the diagram * the source of the diagram
* @param checkEndingBackslash * @param checkEndingBackslash
* <code>true</code> if an ending backslash means that a line has to be collapsed with the following one. * <code>true</code> if an ending backslash means that a line has to be collapsed with the following one.
* @param startLine
*/ */
public UmlSource(List<CharSequence2> source, boolean checkEndingBackslash) { public UmlSource(List<CharSequence2> source, boolean checkEndingBackslash, int startLine) {
// this.startLocation = source.get(0).getLocation();
// this.startLine = startLine;
final List<String> tmp = new ArrayList<String>(); final List<String> tmp = new ArrayList<String>();
final List<CharSequence2> tmp2 = new ArrayList<CharSequence2>(); final List<CharSequence2> tmp2 = new ArrayList<CharSequence2>();
@ -129,7 +137,7 @@ final public class UmlSource {
for (String s : source) { for (String s : source) {
sb.append(s); sb.append(s);
sb.append('\r'); sb.append('\r');
sb.append('\n'); sb.append(BackSlash.CHAR_NEWLINE);
} }
return sb.toString(); return sb.toString();
} }
@ -152,10 +160,22 @@ final public class UmlSource {
* line number, starting at 0 * line number, starting at 0
* @return * @return
*/ */
public String getLine(int n) { private String getLine(int n) {
if (n < 0 || n >= source.size()) {
return "";
}
return source.get(n); return source.get(n);
} }
public String getLine(LineLocation n) {
for (CharSequence2 s : source2) {
if (s.getLocation().compareTo(n) == 0) {
return s.toString();
}
}
return null;
}
/** /**
* Return the number of line in the diagram. * Return the number of line in the diagram.
* *
@ -217,4 +237,8 @@ final public class UmlSource {
} }
return null; return null;
} }
// public final int getStartLine() {
// return startLine;
// }
} }

View File

@ -42,11 +42,13 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.StringBounder; import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlockUtils; import net.sourceforge.plantuml.graphic.TextBlockUtils;
@ -80,6 +82,15 @@ public class AtomText implements Atom {
public static Atom createUrl(Url url, FontConfiguration fontConfiguration) { public static Atom createUrl(Url url, FontConfiguration fontConfiguration) {
fontConfiguration = fontConfiguration.hyperlink(); fontConfiguration = fontConfiguration.hyperlink();
final Display display = Display.getWithNewlines(url.getLabel());
if (display.size() > 1) {
final List<AtomText> all = new ArrayList<AtomText>();
for (CharSequence s : display.as()) {
all.add(new AtomText(s.toString(), fontConfiguration, url, ZERO, ZERO));
}
return new AtomTexts(all);
}
return new AtomText(url.getLabel(), fontConfiguration, url, ZERO, ZERO); return new AtomText(url.getLabel(), fontConfiguration, url, ZERO, ZERO);
} }
@ -118,6 +129,9 @@ public class AtomText implements Atom {
} }
private AtomText(String text, FontConfiguration style, Url url, DelayedDouble marginLeft, DelayedDouble marginRight) { private AtomText(String text, FontConfiguration style, Url url, DelayedDouble marginLeft, DelayedDouble marginRight) {
if (text.contains("" + BackSlash.hiddenNewLine())) {
throw new IllegalArgumentException(text);
}
this.marginLeft = marginLeft; this.marginLeft = marginLeft;
this.marginRight = marginRight; this.marginRight = marginRight;
// this.text = StringUtils.showComparatorCharacters(StringUtils.manageBackslash(text)); // this.text = StringUtils.showComparatorCharacters(StringUtils.manageBackslash(text));

View File

@ -0,0 +1,77 @@
/* ========================================================================
* 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.creole;
import java.awt.geom.Dimension2D;
import java.util.List;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class AtomTexts implements Atom {
private final List<AtomText> all;
public AtomTexts(List<AtomText> texts) {
this.all = texts;
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
double width = 0;
double height = 0;
for (AtomText text : all) {
final Dimension2D dim = text.calculateDimension(stringBounder);
width = Math.max(width, dim.getWidth());
height += dim.getHeight();
}
return new Dimension2DDouble(width, height);
}
public double getStartingAltitude(StringBounder stringBounder) {
return all.get(0).getStartingAltitude(stringBounder);
}
public void drawU(UGraphic ug) {
double y = 0;
for (AtomText text : all) {
final Dimension2D dim = text.calculateDimension(ug.getStringBounder());
text.drawU(ug.apply(new UTranslate(0, y)));
y += dim.getHeight();
}
}
}

View File

@ -35,6 +35,7 @@
*/ */
package net.sourceforge.plantuml.creole; package net.sourceforge.plantuml.creole;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.regex.Matcher2; import net.sourceforge.plantuml.command.regex.Matcher2;
@ -54,6 +55,9 @@ public class CreoleStripeSimpleParser {
public CreoleStripeSimpleParser(String line, CreoleContext creoleContext, FontConfiguration fontConfiguration, public CreoleStripeSimpleParser(String line, CreoleContext creoleContext, FontConfiguration fontConfiguration,
ISkinSimple skinParam, CreoleMode modeSimpleLine) { ISkinSimple skinParam, CreoleMode modeSimpleLine) {
if (line.contains("" + BackSlash.hiddenNewLine())) {
throw new IllegalArgumentException(line);
}
this.fontConfiguration = fontConfiguration; this.fontConfiguration = fontConfiguration;
this.modeSimpleLine = modeSimpleLine; this.modeSimpleLine = modeSimpleLine;
this.skinParam = skinParam; this.skinParam = skinParam;

View File

@ -44,6 +44,8 @@ import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem; import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.UmlDiagramType;
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.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
@ -74,7 +76,7 @@ public class PSystemCreole extends AbstractPSystem {
final Display display = Display.create(lines); final Display display = Display.create(lines);
final UFont font = UFont.serif(14); final UFont font = UFont.serif(14);
final FontConfiguration fontConfiguration = FontConfiguration.blackBlueTrue(font); final FontConfiguration fontConfiguration = FontConfiguration.blackBlueTrue(font);
final Sheet sheet = new CreoleParser(fontConfiguration, HorizontalAlignment.LEFT, null, CreoleMode.FULL) final Sheet sheet = new CreoleParser(fontConfiguration, HorizontalAlignment.LEFT, SkinParam.create(UmlDiagramType.SEQUENCE), CreoleMode.FULL)
.createSheet(display); .createSheet(display);
final SheetBlock1 sheetBlock = new SheetBlock1(sheet, LineBreakStrategy.NONE, 0); final SheetBlock1 sheetBlock = new SheetBlock1(sheet, LineBreakStrategy.NONE, 0);

View File

@ -39,6 +39,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
@ -150,6 +151,9 @@ public class StripeSimple implements Stripe {
if (line == null) { if (line == null) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
if (line.contains("" + BackSlash.hiddenNewLine())) {
throw new IllegalArgumentException(line);
}
line = CharHidder.hide(line); line = CharHidder.hide(line);
if (style.getType() == StripeStyleType.HEADING) { if (style.getType() == StripeStyleType.HEADING) {
atoms.add(AtomText.createHeading(line, fontConfiguration, style.getOrder())); atoms.add(AtomText.createHeading(line, fontConfiguration, style.getOrder()));

View File

@ -40,6 +40,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.ISkinSimple; import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.LineBreakStrategy; import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
@ -147,6 +148,9 @@ public class StripeTable implements Stripe {
current.append(c); current.append(c);
current.append(c2); current.append(c2);
} }
} else if (c == BackSlash.hiddenNewLine()) {
result.add(current.toString());
current.setLength(0);
} else { } else {
current.append(c); current.append(c);
} }

View File

@ -46,6 +46,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.Log;
@ -355,7 +356,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
if (generalWarningOrError == null) { if (generalWarningOrError == null) {
return warningOrError; return warningOrError;
} }
return generalWarningOrError + "\n" + warningOrError; return generalWarningOrError + BackSlash.NEWLINE + warningOrError;
} }
private void createFilesTxt(OutputStream os, int index, FileFormat fileFormat) throws IOException { private void createFilesTxt(OutputStream os, int index, FileFormat fileFormat) throws IOException {

View File

@ -111,16 +111,16 @@ public class Display implements Iterable<CharSequence> {
final List<String> result = new ArrayList<String>(); final List<String> result = new ArrayList<String>();
final StringBuilder current = new StringBuilder(); final StringBuilder current = new StringBuilder();
HorizontalAlignment naturalHorizontalAlignment = null; HorizontalAlignment naturalHorizontalAlignment = null;
boolean mathMode = false; boolean rawMode = false;
for (int i = 0; i < s.length(); i++) { for (int i = 0; i < s.length(); i++) {
final char c = s.charAt(i); final char c = s.charAt(i);
final String sub = s.substring(i); final String sub = s.substring(i);
if (sub.startsWith("<math>") || sub.startsWith("<latex>")) { if (sub.startsWith("<math>") || sub.startsWith("<latex>") || sub.startsWith("[[")) {
mathMode = true; rawMode = true;
} else if (sub.startsWith("</math>") || sub.startsWith("</latex>")) { } else if (sub.startsWith("</math>") || sub.startsWith("</latex>") || sub.startsWith("]]")) {
mathMode = false; rawMode = false;
} }
if (mathMode == false && c == '\\' && i < s.length() - 1) { if (rawMode == false && c == '\\' && i < s.length() - 1) {
final char c2 = s.charAt(i + 1); final char c2 = s.charAt(i + 1);
i++; i++;
if (c2 == 'n' || c2 == 'r' || c2 == 'l') { if (c2 == 'n' || c2 == 'r' || c2 == 'l') {

View File

@ -41,6 +41,7 @@ import java.io.OutputStream;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import net.sourceforge.plantuml.AbstractPSystem; import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.api.ImageDataSimple; import net.sourceforge.plantuml.api.ImageDataSimple;
@ -68,7 +69,7 @@ public class PSystemDitaa extends AbstractPSystem {
} }
PSystemDitaa add(String line) { PSystemDitaa add(String line) {
return new PSystemDitaa(data + line + "\n", processingOptions.performSeparationOfCommonEdges(), dropShadows, return new PSystemDitaa(data + line + BackSlash.NEWLINE, processingOptions.performSeparationOfCommonEdges(), dropShadows,
scale); scale);
} }

View File

@ -44,6 +44,7 @@ import java.util.List;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import net.sourceforge.plantuml.AbstractPSystem; import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.code.Transcoder; import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderImpl; import net.sourceforge.plantuml.code.TranscoderImpl;
@ -65,17 +66,17 @@ import net.sourceforge.plantuml.version.PSystemVersion;
public class PSystemDonors extends AbstractPSystem { public class PSystemDonors extends AbstractPSystem {
public static final String DONORS = "UDfbL4jksp0GtSyfk1RIGoXsujI_17QQ0jcDvR75c29Tad8ghuBUe421hdk3eaKMHOjiUW7bHXsvbKcb" public static final String DONORS = "UDfbL4jksp0GtSyfk1RIGoXsujI_17QQ0jcDvR75c29Tad8ghuBUe421hdk3eaKMHOjiUW7bHXsvbKcb"
+ "10oOudpUctapgKh-7R9mHPwiIBKtMc86rvI4OmeOct2r3jBM5HSmiE69AfZJ0fsNgCNKv1fIlJHM30pv" + "10oOud3clPdtcAhato8BL-J9YbHxeoLcS4r9MAQ0iGbRwo1jh-821ZOSKGLpMg3p4hMOcbn3gfV6Ye4X"
+ "FJL_LoksQCrHmnYZHDf3NxONgI0DeSqEvcM0KC509jsZ3GnRbAM3kQTjJbhqZDaoltwRXnoCYXUknaBF" + "lwVcxsh54MquQXXZL4XxwCjs8nMa8RNPmRmC42eOoAIxj85XYx9qCFUqpKcBdZ5RvjTlwv23KV7Ygh7G"
+ "AAd5p9IEO5Y-U4_k31DfBri9amWr5l6LKwMAtgDUSZbxkUIeQxGLCvqTQUirJ6FqVW-NIkxOeI-p3IC_" + "CqfgCJEb8nYMBywJEyD4sirMmYH2ZKMyvLAfelUebzpENYuvwnfjnKndHzfw3TCOlT_3fP8xlj2NsOQH"
+ "laWDP-uOMaSW4jf1Vrz8Roinnjmi4OPDqMzpvF2HNK8gj8lFfk8oQVHin_WOr_0lUDfqMEabNst6DJd7" + "7q-aXZDtJAqZ40djeBylfBUL66DkbWZ3fkctENBwA2uX5SR5QrDncpHwZcDyZ6lu5pnjEgpqahSsuvwS"
+ "XQqsvjvj90TIx7PflTp3HR1U6fZ8B2SbJb6gAcQWzZ4Ovs18g5yDCNjNaXFzSc6HUwa2tnjpvodBnSYY" + "uy9M6tFlDf8JARvsQRtSmqM8NXgOo2md9KvHgYfceFOn6ETWIAXV3J5xLv8J_N9XaMUf0jyRS-SfoyN8"
+ "mm1fJIpHg6FtZRBOH8pCJiP2EKZbJI0i4MQHU9iKCS_aZhstaQpCfgdCgR6eKMrFn2rvD5i7CoQ8TYb6" + "eiC0QKqiqMXYzusoE4ICp4x6GZb8vKqWB15caNYR4Z7Fv8vlRoDPcKtJcLDZKQFQdeXRycYs3cPC4ErI"
+ "icajd2jZctfFVlzIwj3q80WLYPFbD3xAoM9RxQRhUPUHWojivJ6J7S2facAEkEJHiMiIRqcloPw8INhz" + "Z6GpMZXNnZRzdlp-fTHXw44GAX8dosbyb9F5jjlDrFCk8mTNsCfZ9Zk0KoN57779rh5h4cz9hycUY4bw"
+ "Ufu6QIT6mu0w8nCprnbBf10tZBhFeXq5IqjDPtbOnaHmjekLlqEOXY1Kj22JYCQWbAoBiY1nRahoeRwP" + "_NgU1cadHiE0EfQ9cUkC9LA86qRTPz6EGgIbPh9ibZ4HdErYvUyGfY495It89A8nA2NheYn8d9kIVEXl"
+ "W_EuCmSkGGrw7vUDuKxbcZKqbqKOGGR4axngAeqyrH7eH2ceFzMFKVZwiVu1lRmpsXKFNhauB0AhUHOk" + "vk0ydio1Ir23tiTjOxXJkMODpMKHBCY0sCchfjF8hev09qf1_Qb-ZDBNZ_KFwEKTQrTil79nU0YiPYzS"
+ "J0VEWCngPQaIKrbmuuRu_rQPuGgLc5HEyOpKN-h7vuVwUvDAr9_hf_fd_VJyWNyF_EaRd5dQYn6gWYVh" + "c0wS0PdLob8bfhBWmGtn_rTbXYjKOb8vnHwflzIFpm_rzwQKg3_NJ_NF-kdv0_yU-DCtEBEq5oDK1Jlh"
+ "8kvr8rTYlPwIQXvrr3RE8gEjc2Iy9BiiM60tz78f9QNYlT5IyJ0_17GUwe_rrsD961Zy0II4d1O0"; + "8fvr8rTYlPwIQWvrD3Qk8gDNCKduaUooO87TqCj7AIaLlnij5G_pGqBdeVvOVpssX86nvqAUFuVhdim0";
@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)
@ -126,7 +127,7 @@ public class PSystemDonors extends AbstractPSystem {
final List<String> lines = new ArrayList<String>(); final List<String> lines = new ArrayList<String>();
final Transcoder t = new TranscoderImpl(); final Transcoder t = new TranscoderImpl();
final String s = t.decode(DONORS).replace('*', '.'); final String s = t.decode(DONORS).replace('*', '.');
final StringTokenizer st = new StringTokenizer(s, "\n"); final StringTokenizer st = new StringTokenizer(s, BackSlash.NEWLINE);
while (st.hasMoreTokens()) { while (st.hasMoreTokens()) {
lines.add(st.nextToken()); lines.add(st.nextToken());
} }

View File

@ -47,6 +47,7 @@ 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.BackSlash;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.SpriteContainerEmpty; import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.core.DiagramDescription; import net.sourceforge.plantuml.core.DiagramDescription;
@ -176,7 +177,7 @@ public class PSystemColors extends AbstractPSystem implements UDrawable {
if (Character.isLowerCase(colorName.charAt(i))) { if (Character.isLowerCase(colorName.charAt(i))) {
continue; continue;
} }
final String candidat = colorName.substring(0, i) + "\\n" + colorName.substring(i); final String candidat = colorName.substring(0, i) + BackSlash.BS_BS_N + colorName.substring(i);
final TextBlock tt = getTextName(font, candidat, (HtmlColorSimple) HtmlColorUtils.BLACK); final TextBlock tt = getTextName(font, candidat, (HtmlColorSimple) HtmlColorUtils.BLACK);
final double width = tt.calculateDimension(stringBounder).getWidth(); final double width = tt.calculateDimension(stringBounder).getWidth();
if (width < min) { if (width < min) {

View File

@ -41,6 +41,7 @@ import java.awt.image.BufferedImage;
import java.util.Locale; import java.util.Locale;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.graphic.HtmlColorGradient; import net.sourceforge.plantuml.graphic.HtmlColorGradient;
import net.sourceforge.plantuml.ugraphic.ColorMapper; import net.sourceforge.plantuml.ugraphic.ColorMapper;
@ -74,9 +75,9 @@ public class EpsGraphics {
public EpsGraphics() { public EpsGraphics() {
header.append("%!PS-Adobe-3.0 EPSF-3.0\n"); header.append("%!PS-Adobe-3.0 EPSF-3.0\n");
header.append("%%Creator: PlantUML v" + Version.versionString(15) + "\n"); header.append("%%Creator: PlantUML v" + Version.versionString(15) + BackSlash.NEWLINE);
header.append("%%Title: noTitle\n"); header.append("%%Title: noTitle\n");
// header.append("%%CreationDate: " + new Date() + "\n"); // header.append("%%CreationDate: " + new Date() + BackSlash.BS_N);
setcolorgradient.add(new PostScriptCommandRaw("3 index 7 index sub 1 index mul 7 index add", true)); setcolorgradient.add(new PostScriptCommandRaw("3 index 7 index sub 1 index mul 7 index add", true));
setcolorgradient.add(new PostScriptCommandRaw("3 index 7 index sub 2 index mul 7 index add", true)); setcolorgradient.add(new PostScriptCommandRaw("3 index 7 index sub 2 index mul 7 index add", true));
setcolorgradient.add(new PostScriptCommandRaw("3 index 7 index sub 3 index mul 7 index add", true)); setcolorgradient.add(new PostScriptCommandRaw("3 index 7 index sub 3 index mul 7 index add", true));
@ -123,7 +124,7 @@ public class EpsGraphics {
public void close() { public void close() {
checkCloseDone(); checkCloseDone();
header.append("%%BoundingBox: 0 0 " + maxX + " " + maxY + "\n"); header.append("%%BoundingBox: 0 0 " + maxX + " " + maxY + BackSlash.NEWLINE);
// header.append("%%DocumentData: Clean7Bit\n"); // header.append("%%DocumentData: Clean7Bit\n");
// header.append("%%DocumentProcessColors: Black\n"); // header.append("%%DocumentProcessColors: Black\n");
header.append("%%ColorUsage: Color\n"); header.append("%%ColorUsage: Color\n");
@ -554,7 +555,7 @@ public class EpsGraphics {
if (checkConsistence && s.indexOf(" ") != -1) { if (checkConsistence && s.indexOf(" ") != -1) {
throw new IllegalArgumentException(s); throw new IllegalArgumentException(s);
} }
body.append(s + "\n"); body.append(s + BackSlash.NEWLINE);
} }
final public void linetoNoMacro(double x1, double y1) { final public void linetoNoMacro(double x1, double y1) {

View File

@ -232,7 +232,9 @@ public class QuoteUtils {
"V'z fbeel, ner lbh sebz gur cnfg ?", "Unir lbh gevrq gheavat vg bss naq ba ntnva ?", "V'z fbeel, ner lbh sebz gur cnfg ?", "Unir lbh gevrq gheavat vg bss naq ba ntnva ?",
"Vs lbh qba'g xabj jurer lbh ner tbvat nal ebnq pna gnxr lbh gurer", "Vs lbh qba'g xabj jurer lbh ner tbvat nal ebnq pna gnxr lbh gurer",
"Ortva ng gur ortvaavat, naq tb ba gvyy lbh pbzr gb gur raq: gura fgbc", "Ortva ng gur ortvaavat, naq tb ba gvyy lbh pbzr gb gur raq: gura fgbc",
"Xrrc pnyz naq cerff Pgey-Nyg-Qry", "Vs lbh glcr Tbbtyr vagb Tbbtyr, lbh pna oernx gur Vagrearg."); "Xrrc pnyz naq cerff Pgey-Nyg-Qry", "Vs lbh glcr Tbbtyr vagb Tbbtyr, lbh pna oernx gur Vagrearg.",
"V unir cneg bs n cyna.", "V'z cerggl fher gur nafjre vf: V nz Tebbg.",
"Nalguvat gung pna cbffvoyl tb jebat, qbrf", "Cyhf pn engr, cyhf ba n qr punapr dhr pn znepur");
private QuoteUtils() { private QuoteUtils() {
} }

View File

@ -146,7 +146,7 @@ public class Splitter {
String s = cmd.getText(); String s = cmd.getText();
final Collection<Text> result = new ArrayList<Text>(); final Collection<Text> result = new ArrayList<Text>();
while (true) { while (true) {
final int x = s.indexOf(Text.NEWLINE.getText()); final int x = s.indexOf(Text.TEXT_BS_BS_N.getText());
if (x == -1) { if (x == -1) {
result.add(new Text(s)); result.add(new Text(s));
return result; return result;
@ -154,7 +154,7 @@ public class Splitter {
if (x > 0) { if (x > 0) {
result.add(new Text(s.substring(0, x))); result.add(new Text(s.substring(0, x)));
} }
result.add(Text.NEWLINE); result.add(Text.TEXT_BS_BS_N);
s = s.substring(x + 2); s = s.substring(x + 2);
} }
} }

View File

@ -35,15 +35,17 @@
*/ */
package net.sourceforge.plantuml.graphic; package net.sourceforge.plantuml.graphic;
import net.sourceforge.plantuml.BackSlash;
public class Text implements HtmlCommand { public class Text implements HtmlCommand {
private final String text; private final String text;
public static final Text NEWLINE = new Text("\\n"); public static final Text TEXT_BS_BS_N = new Text(BackSlash.BS_BS_N);
Text(String text) { Text(String text) {
this.text = text.replaceAll("\\\\\\[", "[").replaceAll("\\\\\\]", "]"); this.text = text.replaceAll("\\\\\\[", "[").replaceAll("\\\\\\]", "]");
if (text.indexOf('\n') != -1) { if (text.indexOf(BackSlash.CHAR_NEWLINE) != -1) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
if (text.length() == 0) { if (text.length() == 0) {
@ -57,6 +59,6 @@ public class Text implements HtmlCommand {
} }
public boolean isNewline() { public boolean isNewline() {
return text.equals("\\n"); return text.equals(BackSlash.BS_BS_N);
} }
} }

View File

@ -39,6 +39,7 @@ import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
import java.util.Properties; import java.util.Properties;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.command.PSystemBasicFactory; import net.sourceforge.plantuml.command.PSystemBasicFactory;
@ -112,7 +113,7 @@ public class PSystemJcckitFactory extends PSystemBasicFactory<PSystemJcckit> {
return null; return null;
} }
data.append(StringUtils.trin(line)); data.append(StringUtils.trin(line));
data.append("\n"); data.append(BackSlash.NEWLINE);
return createSystem(); return createSystem();
} }

View File

@ -48,6 +48,7 @@ import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager; import javax.script.ScriptEngineManager;
import javax.script.ScriptException; import javax.script.ScriptException;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.SvgString; import net.sourceforge.plantuml.SvgString;
public class AsciiMath implements ScientificEquation { public class AsciiMath implements ScientificEquation {
@ -67,7 +68,7 @@ public class AsciiMath implements ScientificEquation {
String s = null; String s = null;
while ((s = br.readLine()) != null) { while ((s = br.readLine()) != null) {
sb.append(s); sb.append(s);
sb.append("\n"); sb.append(BackSlash.NEWLINE);
} }
br.close(); br.close();
JAVASCRIPT_CODE = sb.toString(); JAVASCRIPT_CODE = sb.toString();

View File

@ -53,6 +53,7 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.Dimension2DDouble; import net.sourceforge.plantuml.Dimension2DDouble;
import org.w3c.dom.Document; import org.w3c.dom.Document;
@ -72,7 +73,7 @@ public class AsciiMathOld {
String s = null; String s = null;
while ((s = br.readLine()) != null) { while ((s = br.readLine()) != null) {
sb.append(s); sb.append(s);
sb.append("\n"); sb.append(BackSlash.NEWLINE);
} }
br.close(); br.close();
JAVASCRIPT_CODE = sb.toString(); JAVASCRIPT_CODE = sb.toString();

View File

@ -46,9 +46,11 @@ public class Define {
private final DefineSignature signature; private final DefineSignature signature;
private final String definition; private final String definition;
private final String definitionQuoted; private final String definitionQuoted;
private final boolean emptyParentheses;
public Define(String key, List<String> lines) { public Define(String key, List<String> lines, boolean emptyParentheses) {
this.signature = new DefineSignature(key); this.signature = new DefineSignature(key);
this.emptyParentheses = emptyParentheses;
if (lines == null) { if (lines == null) {
this.definition = null; this.definition = null;
this.definitionQuoted = null; this.definitionQuoted = null;
@ -79,7 +81,7 @@ public class Define {
line = vars.applyOn(line, signature.getFonctionName(), definitionQuoted); line = vars.applyOn(line, signature.getFonctionName(), definitionQuoted);
} }
} else { } else {
final String regex = "\\b" + signature.getKey() + "\\b"; final String regex = "\\b" + signature.getKey() + "\\b" + (emptyParentheses ? "(\\(\\))?" : "");
line = BackSlash.translateBackSlashes(line); line = BackSlash.translateBackSlashes(line);
line = line.replaceAll(regex, definitionQuoted); line = line.replaceAll(regex, definitionQuoted);
line = BackSlash.untranslateBackSlashes(line); line = BackSlash.untranslateBackSlashes(line);

View File

@ -47,6 +47,7 @@ import java.util.regex.Pattern;
import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.api.ApiWarning; import net.sourceforge.plantuml.api.ApiWarning;
import net.sourceforge.plantuml.version.Version;
public class Defines implements Truth { public class Defines implements Truth {
@ -57,6 +58,7 @@ public class Defines implements Truth {
@Deprecated @Deprecated
@ApiWarning(willBeRemoved = "in next major release") @ApiWarning(willBeRemoved = "in next major release")
public Defines() { public Defines() {
environment.put("PLANTUML_VERSION", "" + Version.versionString());
} }
@Override @Override
@ -90,8 +92,8 @@ public class Defines implements Truth {
return result; return result;
} }
public void define(String name, List<String> value) { public void define(String name, List<String> value, boolean emptyParentheses) {
values.put(name, new Define(name, value)); values.put(name, new Define(name, value, emptyParentheses));
} }
public boolean isDefine(String expression) { public boolean isDefine(String expression) {

View File

@ -41,10 +41,13 @@ import net.sourceforge.plantuml.CharSequence2;
import net.sourceforge.plantuml.command.regex.Matcher2; import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern; import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2; import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.version.Version;
class IfManager implements ReadLine { class IfManager implements ReadLine {
protected static final Pattern2 ifdefPattern = MyPattern.cmpile("^[%s]*!if(n)?def[%s]+(.+)$"); protected static final Pattern2 ifdefPattern = MyPattern.cmpile("^[%s]*!if(n)?def[%s]+(.+)$");
protected static final Pattern2 ifcomparePattern = MyPattern
.cmpile("^[%s]*!if[%s]+\\%(\\w+)\\%[%s]*(\\<|\\<=|\\>|\\>=|=|==|!=|\\<\\>)[%s]*(\\d+)$");
protected static final Pattern2 elsePattern = MyPattern.cmpile("^[%s]*!else[%s]*$"); protected static final Pattern2 elsePattern = MyPattern.cmpile("^[%s]*!else[%s]*$");
protected static final Pattern2 endifPattern = MyPattern.cmpile("^[%s]*!endif[%s]*$"); protected static final Pattern2 endifPattern = MyPattern.cmpile("^[%s]*!endif[%s]*$");
@ -76,7 +79,21 @@ class IfManager implements ReadLine {
return null; return null;
} }
final Matcher2 m = ifdefPattern.matcher(s); Matcher2 m = ifcomparePattern.matcher(s);
if (m.find()) {
final int value1 = getValue(m.group(1));
final String operator = m.group(2);
final int value2 = Integer.parseInt(m.group(3));
final boolean ok = new NumericCompare(operator).isCompareOk(value1, value2);
if (ok) {
child = new IfManagerPositif(source, defines);
} else {
child = new IfManagerNegatif(source, defines);
}
return this.readLine();
}
m = ifdefPattern.matcher(s);
if (m.find()) { if (m.find()) {
boolean ok = defines.isDefine(m.group(2)); boolean ok = defines.isDefine(m.group(2));
if (m.group(1) != null) { if (m.group(1) != null) {
@ -93,6 +110,13 @@ class IfManager implements ReadLine {
return s; return s;
} }
private int getValue(final String arg) {
if (arg.equalsIgnoreCase("PLANTUML_VERSION")) {
return Version.versionPatched();
}
return 0;
}
public void close() throws IOException { public void close() throws IOException {
source.close(); source.close();
} }

View File

@ -0,0 +1,68 @@
/* ========================================================================
* 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.preproc;
class NumericCompare {
private final String operator;
public NumericCompare(String operator) {
this.operator = operator;
}
public boolean isCompareOk(int value1, int value2) {
if (operator.equals("<")) {
return value1 < value2;
}
if (operator.equals("<=")) {
return value1 <= value2;
}
if (operator.equals(">")) {
return value1 > value2;
}
if (operator.equals(">=")) {
return value1 >= value2;
}
if (operator.equals("=") || operator.equals("==")) {
return value1 == value2;
}
if (operator.equals("!=") || operator.equals("<>")) {
return value1 != value2;
}
throw new IllegalStateException();
}
}

View File

@ -38,7 +38,6 @@ package net.sourceforge.plantuml.preproc;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -87,12 +86,12 @@ public class Preprocessor implements ReadLine {
Matcher2 m = definePattern.matcher(s); Matcher2 m = definePattern.matcher(s);
if (m.find()) { if (m.find()) {
return manageDefine(m); return manageDefine(m, s.toString().trim().endsWith("()"));
} }
m = definelongPattern.matcher(s); m = definelongPattern.matcher(s);
if (m.find()) { if (m.find()) {
return manageDefineLong(m); return manageDefineLong(m, s.toString().trim().endsWith("()"));
} }
m = undefPattern.matcher(s); m = undefPattern.matcher(s);
@ -105,21 +104,38 @@ public class Preprocessor implements ReadLine {
return s; return s;
} }
final List<String> result = defines.applyDefines(s.toString2()); List<String> result = defines.applyDefines(s.toString2());
if (result.size() > 1) { if (result.size() > 1) {
final String last = result.get(result.size() - 1); result = cleanEndDefineLong(result);
final List<String> inserted = result.subList(1, result.size() - 1); final List<String> inserted = cleanEndDefineLong(result.subList(1, result.size()));
assert last.startsWith(END_DEFINE_LONG);
ignoreDefineDuringSeveralLines = inserted.size(); ignoreDefineDuringSeveralLines = inserted.size();
source.insert(inserted, s.getLocation()); source.insert(inserted, s.getLocation());
if (last.length() > END_DEFINE_LONG.length()) {
source.insert(last.substring(END_DEFINE_LONG.length()), s.getLocation());
ignoreDefineDuringSeveralLines++;
}
} }
return new CharSequence2Impl(result.get(0), s.getLocation(), s.getPreprocessorError()); return new CharSequence2Impl(result.get(0), s.getLocation(), s.getPreprocessorError());
} }
private List<String> cleanEndDefineLong(List<String> data) {
final List<String> result = new ArrayList<String>();
for (String s : data) {
final String clean = cleanEndDefineLong(s);
if (clean != null) {
result.add(clean);
}
}
return result;
}
private String cleanEndDefineLong(String s) {
if (s.trim().startsWith(END_DEFINE_LONG)) {
s = s.trim().substring(END_DEFINE_LONG.length());
if (s.length() == 0) {
return null;
}
}
return s;
}
private int ignoreDefineDuringSeveralLines = 0; private int ignoreDefineDuringSeveralLines = 0;
private CharSequence2 manageUndef(Matcher2 m) throws IOException { private CharSequence2 manageUndef(Matcher2 m) throws IOException {
@ -127,7 +143,7 @@ public class Preprocessor implements ReadLine {
return this.readLine(); return this.readLine();
} }
private CharSequence2 manageDefineLong(Matcher2 m) throws IOException { private CharSequence2 manageDefineLong(Matcher2 m, boolean emptyParentheses) throws IOException {
final String group1 = m.group(1); final String group1 = m.group(1);
final List<String> def = new ArrayList<String>(); final List<String> def = new ArrayList<String>();
while (true) { while (true) {
@ -137,21 +153,21 @@ public class Preprocessor implements ReadLine {
} }
def.add(read.toString2()); def.add(read.toString2());
if (enddefinelongPattern.matcher(read).find()) { if (enddefinelongPattern.matcher(read).find()) {
defines.define(group1, def); defines.define(group1, def, emptyParentheses);
return this.readLine(); return this.readLine();
} }
} }
} }
private CharSequence2 manageDefine(Matcher2 m) throws IOException { private CharSequence2 manageDefine(Matcher2 m, boolean emptyParentheses) throws IOException {
final String group1 = m.group(1); final String group1 = m.group(1);
final String group2 = m.group(2); final String group2 = m.group(2);
if (group2 == null) { if (group2 == null) {
defines.define(group1, null); defines.define(group1, null, emptyParentheses);
} else { } else {
final List<String> strings = defines.applyDefines(group2); final List<String> strings = defines.applyDefines(group2);
if (strings.size() > 1) { if (strings.size() > 1) {
defines.define(group1, strings); defines.define(group1, strings, emptyParentheses);
} else { } else {
final StringBuilder value = new StringBuilder(strings.get(0)); final StringBuilder value = new StringBuilder(strings.get(0));
while (StringUtils.endsWithBackslash(value.toString())) { while (StringUtils.endsWithBackslash(value.toString())) {
@ -161,7 +177,7 @@ public class Preprocessor implements ReadLine {
} }
final List<String> li = new ArrayList<String>(); final List<String> li = new ArrayList<String>();
li.add(value.toString()); li.add(value.toString());
defines.define(group1, li); defines.define(group1, li, emptyParentheses);
} }
} }
return this.readLine(); return this.readLine();

View File

@ -73,6 +73,7 @@ public class ReadLineReader implements ReadLine {
s = s.substring(1); s = s.substring(1);
} }
s = s.replace('\u2013', '-'); s = s.replace('\u2013', '-');
// s = BackSlash.convertHiddenNewLine(s);
// s = s.replace('\u00A0', ' '); // s = s.replace('\u00A0', ' ');
// s = s.replace('\u201c', '\"'); // s = s.replace('\u201c', '\"');
// s = s.replace('\u201d', '\"'); // s = s.replace('\u201d', '\"');

View File

@ -42,6 +42,7 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import net.sourceforge.plantuml.AbstractPSystem; import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.EmptyImageBuilder; import net.sourceforge.plantuml.EmptyImageBuilder;
import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
@ -81,7 +82,7 @@ public class PSystemProject extends AbstractPSystem {
final BufferedImage im = createImage(diagram); final BufferedImage im = createImage(diagram);
PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96); PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96);
} else if (fileFormat == FileFormat.SVG) { } else if (fileFormat == FileFormat.SVG) {
final UGraphicSvg svg = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(background), false, 1.0, final UGraphicSvg svg = new UGraphicSvg(new Dimension2DDouble(0, 0), colorMapper, StringUtils.getAsHtml(background), false, 1.0,
fileFormatOption.getSvgLinkTarget(), fileFormatOption.getHoverColor(), seed()); fileFormatOption.getSvgLinkTarget(), fileFormatOption.getHoverColor(), seed());
diagram.draw(svg, 0, 0); diagram.draw(svg, 0, 0);
svg.createXml(os, fileFormatOption.isWithMetadata() ? getMetadata() : null); svg.createXml(os, fileFormatOption.isWithMetadata() ? getMetadata() : null);

View File

@ -42,6 +42,7 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import net.sourceforge.plantuml.AbstractPSystem; import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.EmptyImageBuilder; import net.sourceforge.plantuml.EmptyImageBuilder;
import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
@ -80,7 +81,7 @@ public class PSystemProject2 extends AbstractPSystem {
final BufferedImage im = createImage(diagram); final BufferedImage im = createImage(diagram);
PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96); PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96);
} else if (fileFormat == FileFormat.SVG) { } else if (fileFormat == FileFormat.SVG) {
final UGraphicSvg svg = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(background), false, 1.0, final UGraphicSvg svg = new UGraphicSvg(new Dimension2DDouble(0, 0),colorMapper, StringUtils.getAsHtml(background), false, 1.0,
fileFormatOption.getSvgLinkTarget(), fileFormatOption.getHoverColor(), seed()); fileFormatOption.getSvgLinkTarget(), fileFormatOption.getHoverColor(), seed());
diagram.draw(svg, 0, 0); diagram.draw(svg, 0, 0);
svg.createXml(os, fileFormatOption.isWithMetadata() ? getMetadata() : null); svg.createXml(os, fileFormatOption.isWithMetadata() ? getMetadata() : null);

View File

@ -35,12 +35,15 @@
*/ */
package net.sourceforge.plantuml.sequencediagram; package net.sourceforge.plantuml.sequencediagram;
import java.util.Set;
import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.SkinParamBackcolored; import net.sourceforge.plantuml.SkinParamBackcolored;
import net.sourceforge.plantuml.SpecificBackcolorable; import net.sourceforge.plantuml.SpecificBackcolorable;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
import net.sourceforge.plantuml.cucadiagram.Stereotype; import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.SymbolContext; import net.sourceforge.plantuml.graphic.SymbolContext;
@ -56,8 +59,11 @@ public class Participant implements SpecificBackcolorable {
private int initialLife = 0; private int initialLife = 0;
private Stereotype stereotype; private Stereotype stereotype;
private boolean stereotypePositionTop;
private final Set<EntityPortion> hiddenPortions;
public Participant(ParticipantType type, String code, Display display) { public Participant(ParticipantType type, String code, Display display, Set<EntityPortion> hiddenPortions) {
this.hiddenPortions = hiddenPortions;
if (type == null) { if (type == null) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
@ -82,10 +88,15 @@ public class Participant implements SpecificBackcolorable {
} }
public Display getDisplay(boolean underlined) { public Display getDisplay(boolean underlined) {
if (underlined) { Display result = underlined ? display.underlined() : display;
return display.underlined(); if (stereotype != null && hiddenPortions.contains(EntityPortion.STEREOTYPE) == false) {
if (stereotypePositionTop) {
result = result.addFirst(stereotype);
} else {
result = result.add(stereotype);
} }
return display; }
return result;
} }
public ParticipantType getType() { public ParticipantType getType() {
@ -93,9 +104,6 @@ public class Participant implements SpecificBackcolorable {
} }
public final void setStereotype(Stereotype stereotype, boolean stereotypePositionTop) { public final void setStereotype(Stereotype stereotype, boolean stereotypePositionTop) {
// if (type == ParticipantType.ACTOR) {
// return;
// }
if (this.stereotype != null) { if (this.stereotype != null) {
throw new IllegalStateException(); throw new IllegalStateException();
} }
@ -103,11 +111,7 @@ public class Participant implements SpecificBackcolorable {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
this.stereotype = stereotype; this.stereotype = stereotype;
if (stereotypePositionTop) { this.stereotypePositionTop = stereotypePositionTop;
display = display.addFirst(stereotype);
} else {
display = display.add(stereotype);
}
} }
public final int getInitialLife() { public final int getInitialLife() {

View File

@ -43,6 +43,7 @@ public enum ParticipantType {
BOUNDARY(ColorParam.boundaryBackground), // BOUNDARY(ColorParam.boundaryBackground), //
CONTROL(ColorParam.controlBackground), // CONTROL(ColorParam.controlBackground), //
ENTITY(ColorParam.entityBackground), // ENTITY(ColorParam.entityBackground), //
QUEUE(ColorParam.queueBackground), //
DATABASE(ColorParam.databaseBackground), // DATABASE(ColorParam.databaseBackground), //
COLLECTIONS(ColorParam.collectionsBackground); COLLECTIONS(ColorParam.collectionsBackground);

View File

@ -40,10 +40,12 @@ import java.io.OutputStream;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.Stack; import java.util.Stack;
import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.ColorParam;
@ -57,6 +59,7 @@ import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData; import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display; import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned; import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
import net.sourceforge.plantuml.graphic.HtmlColor; import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.SymbolContext; import net.sourceforge.plantuml.graphic.SymbolContext;
import net.sourceforge.plantuml.sequencediagram.graphic.FileMaker; import net.sourceforge.plantuml.sequencediagram.graphic.FileMaker;
@ -87,7 +90,7 @@ public class SequenceDiagram extends UmlDiagram {
public Participant getOrCreateParticipant(String code, Display display) { public Participant getOrCreateParticipant(String code, Display display) {
Participant result = participants.get(code); Participant result = participants.get(code);
if (result == null) { if (result == null) {
result = new Participant(ParticipantType.PARTICIPANT, code, display); result = new Participant(ParticipantType.PARTICIPANT, code, display, hiddenPortions);
participants.put(code, result); participants.put(code, result);
participantEnglobers2.put(result, participantEnglober); participantEnglobers2.put(result, participantEnglober);
} }
@ -108,7 +111,7 @@ public class SequenceDiagram extends UmlDiagram {
// display = Arrays.asList(code); // display = Arrays.asList(code);
display = Display.getWithNewlines(code); display = Display.getWithNewlines(code);
} }
final Participant result = new Participant(type, code, display); final Participant result = new Participant(type, code, display, hiddenPortions);
participants.put(code, result); participants.put(code, result);
participantEnglobers2.put(result, participantEnglober); participantEnglobers2.put(result, participantEnglober);
return result; return result;
@ -505,7 +508,6 @@ public class SequenceDiagram extends UmlDiagram {
return dpiFactor; return dpiFactor;
} }
@Override @Override
public String checkFinalError() { public String checkFinalError() {
if (this.isHideUnlinkedData()) { if (this.isHideUnlinkedData()) {
@ -514,5 +516,14 @@ public class SequenceDiagram extends UmlDiagram {
return super.checkFinalError(); return super.checkFinalError();
} }
private final Set<EntityPortion> hiddenPortions = EnumSet.<EntityPortion> noneOf(EntityPortion.class);
public void hideOrShow(Set<EntityPortion> portions, boolean show) {
if (show) {
hiddenPortions.removeAll(portions);
} else {
hiddenPortions.addAll(portions);
}
}
} }

View File

@ -64,8 +64,8 @@ public abstract class CommandParticipant extends SingleLineCommand2<SequenceDiag
} }
static IRegex getRegexType() { static IRegex getRegexType() {
return new RegexOr(new RegexLeaf("TYPE", "(participant|actor|create|boundary|control|entity|database|collections)"), // return new RegexOr(new RegexLeaf("TYPE", "(participant|actor|create|boundary|control|entity|queue|database|collections)"), //
new RegexLeaf("CREATE", "create[%s](participant|actor|boundary|control|entity|database|collections)")); new RegexLeaf("CREATE", "create[%s](participant|actor|boundary|control|entity|queue|database|collections)"));
} }
@Override @Override

View File

@ -599,6 +599,9 @@ class DrawableSetInitializer {
} else if (p.getType() == ParticipantType.ENTITY) { } else if (p.getType() == ParticipantType.ENTITY) {
headType = ComponentType.ENTITY_HEAD; headType = ComponentType.ENTITY_HEAD;
tailType = ComponentType.ENTITY_TAIL; tailType = ComponentType.ENTITY_TAIL;
} else if (p.getType() == ParticipantType.QUEUE) {
headType = ComponentType.QUEUE_HEAD;
tailType = ComponentType.QUEUE_TAIL;
} else if (p.getType() == ParticipantType.DATABASE) { } else if (p.getType() == ParticipantType.DATABASE) {
headType = ComponentType.DATABASE_HEAD; headType = ComponentType.DATABASE_HEAD;
tailType = ComponentType.DATABASE_TAIL; tailType = ComponentType.DATABASE_TAIL;

View File

@ -127,9 +127,15 @@ public class LivingSpace {
} else if (p.getType() == ParticipantType.ENTITY) { } else if (p.getType() == ParticipantType.ENTITY) {
headType = ComponentType.ENTITY_HEAD; headType = ComponentType.ENTITY_HEAD;
tailType = ComponentType.ENTITY_TAIL; tailType = ComponentType.ENTITY_TAIL;
} else if (p.getType() == ParticipantType.QUEUE) {
headType = ComponentType.QUEUE_HEAD;
tailType = ComponentType.QUEUE_TAIL;
} else if (p.getType() == ParticipantType.DATABASE) { } else if (p.getType() == ParticipantType.DATABASE) {
headType = ComponentType.DATABASE_HEAD; headType = ComponentType.DATABASE_HEAD;
tailType = ComponentType.DATABASE_TAIL; tailType = ComponentType.DATABASE_TAIL;
} else if (p.getType() == ParticipantType.COLLECTIONS) {
headType = ComponentType.COLLECTIONS_HEAD;
tailType = ComponentType.COLLECTIONS_TAIL;
} else { } else {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }

View File

@ -44,6 +44,7 @@ public enum ComponentType {
BOUNDARY_HEAD, BOUNDARY_TAIL, BOUNDARY_HEAD, BOUNDARY_TAIL,
CONTROL_HEAD, CONTROL_TAIL, CONTROL_HEAD, CONTROL_TAIL,
ENTITY_HEAD, ENTITY_TAIL, ENTITY_HEAD, ENTITY_TAIL,
QUEUE_HEAD, QUEUE_TAIL,
DATABASE_HEAD, DATABASE_TAIL, DATABASE_HEAD, DATABASE_TAIL,
COLLECTIONS_HEAD, COLLECTIONS_TAIL, COLLECTIONS_HEAD, COLLECTIONS_TAIL,

View File

@ -0,0 +1,93 @@
/* ========================================================================
* 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.skin.rose;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.SymbolContext;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.skin.AbstractTextualComponent;
import net.sourceforge.plantuml.skin.Area;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class ComponentRoseQueue extends AbstractTextualComponent {
private final TextBlock stickman;
private final boolean head;
public ComponentRoseQueue(SymbolContext biColor, FontConfiguration font, Display stringsToDisplay, boolean head,
ISkinSimple spriteContainer, UFont fontForStereotype, HtmlColor htmlColorForStereotype) {
super(LineBreakStrategy.NONE, stringsToDisplay, font, HorizontalAlignment.CENTER, 3, 3, 0, spriteContainer,
false, fontForStereotype, htmlColorForStereotype);
this.head = head;
this.stickman = USymbol.QUEUE.asSmall(TextBlockUtils.empty(0, 0), getTextBlock(), TextBlockUtils.empty(0, 0),
biColor);
}
@Override
protected void drawInternalU(UGraphic ug, Area area) {
final StringBounder stringBounder = ug.getStringBounder();
final Dimension2D dimStickman = stickman.calculateDimension(stringBounder);
final double delta = (getPreferredWidth(stringBounder) - dimStickman.getWidth()) / 2;
ug = ug.apply(new UTranslate(delta, 0));
stickman.drawU(ug);
}
@Override
public double getPreferredHeight(StringBounder stringBounder) {
final Dimension2D dimStickman = stickman.calculateDimension(stringBounder);
return dimStickman.getHeight();
}
@Override
public double getPreferredWidth(StringBounder stringBounder) {
final Dimension2D dimStickman = stickman.calculateDimension(stringBounder);
return dimStickman.getWidth();
}
}

View File

@ -92,40 +92,44 @@ public class Rose implements Skin {
// final FontConfiguration fc = new FontConfiguration(fontArrow, HtmlColorUtils.BLACK); // final FontConfiguration fc = new FontConfiguration(fontArrow, HtmlColorUtils.BLACK);
// stringsToDisplay = DisplayUtils.breakLines(stringsToDisplay, fc, param, param.maxMessageSize()); // stringsToDisplay = DisplayUtils.breakLines(stringsToDisplay, fc, param, param.maxMessageSize());
// } // }
final HtmlColor sequenceArrow = config.getColor() == null ? getHtmlColor(param, ColorParam.arrow) final HtmlColor sequenceArrow = config.getColor() == null ? getHtmlColor(param, ColorParam.arrow) : config
: config.getColor(); .getColor();
if (config.getArrowDirection() == ArrowDirection.SELF) { if (config.getArrowDirection() == ArrowDirection.SELF) {
return new ComponentRoseSelfArrow(sequenceArrow, getUFont2(param, FontParam.ARROW), return new ComponentRoseSelfArrow(sequenceArrow, getUFont2(param, FontParam.ARROW), stringsToDisplay,
stringsToDisplay, config, param, param.maxMessageSize(), param.strictUmlStyle() == false); config, param, param.maxMessageSize(), param.strictUmlStyle() == false);
} }
final HorizontalAlignment messageHorizontalAlignment = param.getHorizontalAlignment( final HorizontalAlignment messageHorizontalAlignment = param.getHorizontalAlignment(
AlignParam.SEQUENCE_MESSAGE_ALIGN, config.getArrowDirection()); AlignParam.SEQUENCE_MESSAGE_ALIGN, config.getArrowDirection());
final HorizontalAlignment textHorizontalAlignment = param.getHorizontalAlignment( final HorizontalAlignment textHorizontalAlignment = param.getHorizontalAlignment(
AlignParam.SEQUENCE_MESSAGETEXT_ALIGN, config.getArrowDirection()); AlignParam.SEQUENCE_MESSAGETEXT_ALIGN, config.getArrowDirection());
return new ComponentRoseArrow(sequenceArrow, getUFont2(param, FontParam.ARROW), stringsToDisplay, return new ComponentRoseArrow(sequenceArrow, getUFont2(param, FontParam.ARROW), stringsToDisplay, config,
config, messageHorizontalAlignment, param, textHorizontalAlignment, param.maxMessageSize(), messageHorizontalAlignment, param, textHorizontalAlignment, param.maxMessageSize(),
param.strictUmlStyle() == false); param.strictUmlStyle() == false);
} }
final double padding = param.getPadding(PaddingParam.PARTICIPANT); final double padding = param.getPadding(PaddingParam.PARTICIPANT);
if (type == ComponentType.PARTICIPANT_HEAD) { if (type == ComponentType.PARTICIPANT_HEAD) {
return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param, return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param,
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null), newFontForStereotype, FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null),
getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), false, padding); newFontForStereotype, getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(),
false, padding);
} }
if (type == ComponentType.PARTICIPANT_TAIL) { if (type == ComponentType.PARTICIPANT_TAIL) {
return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param, return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param,
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null), newFontForStereotype, FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null),
getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), false, padding); newFontForStereotype, getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(),
false, padding);
} }
if (type == ComponentType.COLLECTIONS_HEAD) { if (type == ComponentType.COLLECTIONS_HEAD) {
return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param, return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param,
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null), newFontForStereotype, FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null),
getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), true, padding); newFontForStereotype, getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(),
true, padding);
} }
if (type == ComponentType.COLLECTIONS_TAIL) { if (type == ComponentType.COLLECTIONS_TAIL) {
return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param, return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param,
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null), newFontForStereotype, FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null),
getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), true, padding); newFontForStereotype, getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(),
true, padding);
} }
if (type == ComponentType.PARTICIPANT_LINE) { if (type == ComponentType.PARTICIPANT_LINE) {
final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder); final HtmlColor borderColor = getHtmlColor(param, ColorParam.sequenceLifeLineBorder);
@ -175,6 +179,16 @@ public class Rose implements Skin {
FontParam.ACTOR), stringsToDisplay, false, param, newFontForStereotype, getFontColor(param, FontParam.ACTOR), stringsToDisplay, false, param, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE)); FontParam.SEQUENCE_STEREOTYPE));
} }
if (type == ComponentType.QUEUE_HEAD) {
return new ComponentRoseQueue(getSymbolContext(param, ColorParam.entityBorder), getUFont2(param,
FontParam.ACTOR), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE));
}
if (type == ComponentType.QUEUE_TAIL) {
return new ComponentRoseQueue(getSymbolContext(param, ColorParam.entityBorder), getUFont2(param,
FontParam.ACTOR), stringsToDisplay, false, param, newFontForStereotype, getFontColor(param,
FontParam.SEQUENCE_STEREOTYPE));
}
if (type == ComponentType.DATABASE_HEAD) { if (type == ComponentType.DATABASE_HEAD) {
return new ComponentRoseDatabase(getSymbolContext(param, ColorParam.databaseBorder), getUFont2(param, return new ComponentRoseDatabase(getSymbolContext(param, ColorParam.databaseBorder), getUFont2(param,
FontParam.ACTOR), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param, FontParam.ACTOR), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param,

View File

@ -40,6 +40,7 @@ import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.stats.api.Stats; import net.sourceforge.plantuml.stats.api.Stats;
import net.sourceforge.plantuml.stats.api.StatsColumn; import net.sourceforge.plantuml.stats.api.StatsColumn;
import net.sourceforge.plantuml.stats.api.StatsLine; import net.sourceforge.plantuml.stats.api.StatsLine;
@ -134,7 +135,7 @@ public class HtmlConverter {
sb.append("<tr bgcolor=#e0e0e0>"); sb.append("<tr bgcolor=#e0e0e0>");
for (StatsColumn col : headers) { for (StatsColumn col : headers) {
sb.append("<td><b>"); sb.append("<td><b>");
sb.append(col.getTitle().replace("\\n", "<br>")); sb.append(col.getTitle().replace(BackSlash.BS_BS_N, "<br>"));
sb.append("</b></td>"); sb.append("</b></td>");
} }
sb.append("</tr>"); sb.append("</tr>");

View File

@ -51,6 +51,7 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.stats.api.Stats; import net.sourceforge.plantuml.stats.api.Stats;
import net.sourceforge.plantuml.stats.api.StatsColumn; import net.sourceforge.plantuml.stats.api.StatsColumn;
import net.sourceforge.plantuml.stats.api.StatsLine; import net.sourceforge.plantuml.stats.api.StatsLine;
@ -212,7 +213,7 @@ public class XmlConverter {
sb.append("<tr bgcolor=#e0e0e0>"); sb.append("<tr bgcolor=#e0e0e0>");
for (StatsColumn col : headers) { for (StatsColumn col : headers) {
sb.append("<td><b>"); sb.append("<td><b>");
sb.append(col.getTitle().replace("\\n", "<br>")); sb.append(col.getTitle().replace(BackSlash.BS_BS_N, "<br>"));
sb.append("</b></td>"); sb.append("</b></td>");
} }
sb.append("</tr>"); sb.append("</tr>");

View File

@ -53,6 +53,7 @@ import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam; import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagramType; import net.sourceforge.plantuml.UmlDiagramType;
@ -564,7 +565,7 @@ public class Cluster implements Moveable {
added = true; added = true;
} }
if (dotMode != DotMode.NO_LEFT_RIGHT_AND_XLABEL) { if (skinParam.useRankSame() && dotMode != DotMode.NO_LEFT_RIGHT_AND_XLABEL) {
appendRankSame(sb, lines); appendRankSame(sb, lines);
} }

View File

@ -143,19 +143,7 @@ public final class GroupPngMakerState {
final Stereotype stereo = group.getStereotype(); final Stereotype stereo = group.getStereotype();
final HtmlColor backColor = group.getColors(skinParam).getColor(ColorType.BACK) == null ? getColor( final HtmlColor backColor = group.getColors(skinParam).getColor(ColorType.BACK) == null ? getColor(
ColorParam.stateBackground, stereo) : group.getColors(skinParam).getColor(ColorType.BACK); ColorParam.stateBackground, stereo) : group.getColors(skinParam).getColor(ColorType.BACK);
final List<String> details = ((IEntity) group).getBodier().getRawBody(); final TextBlockWidth attribute = getAttributes(skinParam);
final TextBlockWidth attribute;
if (details.size() == 0) {
attribute = new TextBlockEmpty();
} else {
final FontConfiguration fontConfiguration = new FontConfiguration(skinParam, FontParam.STATE_ATTRIBUTE,
null);
final TextBlock tmp = Display.create(details)
.create(fontConfiguration, HorizontalAlignment.LEFT, skinParam);
attribute = new TextBlockWidthAdapter(tmp, 0);
// attribute = new MethodsOrFieldsArea(members, FontParam.STATE_ATTRIBUTE, diagram.getSkinParam(),
// group.getStereotype(), null);
}
final Stereotype stereotype = group.getStereotype(); final Stereotype stereotype = group.getStereotype();
final boolean withSymbol = stereotype != null && stereotype.isWithOOSymbol(); final boolean withSymbol = stereotype != null && stereotype.isWithOOSymbol();
@ -172,6 +160,19 @@ public final class GroupPngMakerState {
} }
private TextBlockWidth getAttributes(final ISkinParam skinParam) {
final List<String> details = ((IEntity) group).getBodier().getRawBody();
if (details.size() == 0) {
return new TextBlockEmpty();
}
final FontConfiguration fontConfiguration = new FontConfiguration(skinParam, FontParam.STATE_ATTRIBUTE, null);
final Display display = details.size() == 1 ? Display.getWithNewlines(details.get(0)) : Display.create(details);
final TextBlock result = display.create(fontConfiguration, HorizontalAlignment.LEFT, skinParam);
return new TextBlockWidthAdapter(result, 0);
}
private IEntityImage buildImageForConcurrentState(DotData dotData) { private IEntityImage buildImageForConcurrentState(DotData dotData) {
final List<IEntityImage> inners = new ArrayList<IEntityImage>(); final List<IEntityImage> inners = new ArrayList<IEntityImage>();
for (ILeaf inner : dotData.getLeafs()) { for (ILeaf inner : dotData.getLeafs()) {

View File

@ -85,7 +85,9 @@ import net.sourceforge.plantuml.svek.image.EntityImageNoteLink;
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.UComment; import net.sourceforge.plantuml.ugraphic.UComment;
import net.sourceforge.plantuml.ugraphic.UEllipse;
import net.sourceforge.plantuml.ugraphic.UGraphic; import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.ULine;
import net.sourceforge.plantuml.ugraphic.UPolygon; import net.sourceforge.plantuml.ugraphic.UPolygon;
import net.sourceforge.plantuml.ugraphic.UShape; import net.sourceforge.plantuml.ugraphic.UShape;
import net.sourceforge.plantuml.ugraphic.UStroke; import net.sourceforge.plantuml.ugraphic.UStroke;
@ -130,6 +132,7 @@ public class Line implements Moveable, Hideable {
private final Pragma pragma; private final Pragma pragma;
private final HtmlColor backgroundColor; private final HtmlColor backgroundColor;
private final boolean useRankSame;
@Override @Override
public String toString() { public String toString() {
@ -211,6 +214,7 @@ public class Line implements Moveable, Hideable {
if (link == null) { if (link == null) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
this.useRankSame = skinParam.useRankSame();
this.startUid = link.getEntityPort1(bibliotekon); this.startUid = link.getEntityPort1(bibliotekon);
this.endUid = link.getEntityPort2(bibliotekon); this.endUid = link.getEntityPort2(bibliotekon);
@ -338,7 +342,7 @@ public class Line implements Moveable, Hideable {
sb.append("["); sb.append("[");
final LinkType linkType = link.getTypePatchCluster(); final LinkType linkType = link.getTypePatchCluster();
String decoration = linkType.getSpecificDecorationSvek(); String decoration = linkType.getSpecificDecorationSvek();
if (decoration.endsWith(",") == false) { if (decoration.length() > 0 && decoration.endsWith(",") == false) {
decoration += ","; decoration += ",";
} }
sb.append(decoration); sb.append(decoration);
@ -347,12 +351,17 @@ public class Line implements Moveable, Hideable {
// if (graphvizVersion == GraphvizVersion.V2_34_0 && length == 1) { // if (graphvizVersion == GraphvizVersion.V2_34_0 && length == 1) {
// length = 2; // length = 2;
// } // }
if (useRankSame) {
if (pragma.horizontalLineBetweenDifferentPackageAllowed() || link.isInvis() || length != 1) { if (pragma.horizontalLineBetweenDifferentPackageAllowed() || link.isInvis() || length != 1) {
// if (graphvizVersion.isJs() == false) { // if (graphvizVersion.isJs() == false) {
sb.append("minlen=" + (length - 1)); sb.append("minlen=" + (length - 1));
sb.append(","); sb.append(",");
// } // }
} }
} else {
sb.append("minlen=" + (length - 1));
sb.append(",");
}
sb.append("color=\"" + StringUtils.getAsHtml(lineColor) + "\""); sb.append("color=\"" + StringUtils.getAsHtml(lineColor) + "\"");
if (labelText != null) { if (labelText != null) {
sb.append(","); sb.append(",");
@ -446,8 +455,8 @@ public class Line implements Moveable, Hideable {
return endUid.getPrefix(); return endUid.getPrefix();
} }
private UDrawable getExtremity(LinkDecor decor, PointListIterator pointListIterator, Point2D center, double angle, private UDrawable getExtremity(LinkDecor decor, PointListIterator pointListIterator, final Point2D center,
Cluster cluster, Shape shapeContact) { double angle, Cluster cluster, Shape shapeContact) {
final ExtremityFactory extremityFactory = decor.getExtremityFactory(backgroundColor); final ExtremityFactory extremityFactory = decor.getExtremityFactory(backgroundColor);
if (cluster != null) { if (cluster != null) {
@ -464,7 +473,7 @@ public class Line implements Moveable, Hideable {
if (extremityFactory != null) { if (extremityFactory != null) {
final List<Point2D.Double> points = pointListIterator.next(); final List<Point2D.Double> points = pointListIterator.next();
if (points.size() == 0) { if (points.size() == 0) {
return null; return extremityFactory.createUDrawable(center, angle, null);
} }
final Point2D p0 = points.get(0); final Point2D p0 = points.get(0);
final Point2D p1 = points.get(1); final Point2D p1 = points.get(1);
@ -474,6 +483,18 @@ public class Line implements Moveable, Hideable {
side = shapeContact.getClusterPosition().getClosestSide(p1); side = shapeContact.getClusterPosition().getClosestSide(p1);
} }
return extremityFactory.createUDrawable(p0, p1, p2, side); return extremityFactory.createUDrawable(p0, p1, p2, side);
} else if (decor == LinkDecor.NONE) {
final UPolygon sh = new UPolygon(pointListIterator.cloneMe().next());
final Point2D contact = sh.checkMiddleContactForSpecificTriangle(center);
if (contact != null) {
return new UDrawable() {
public void drawU(UGraphic ug) {
ULine line = new ULine(contact.getX() - center.getX(), contact.getY() - center.getY());
ug = ug.apply(new UTranslate(center));
ug.draw(line);
}
};
}
} else if (decor != LinkDecor.NONE) { } else if (decor != LinkDecor.NONE) {
final UShape sh = new UPolygon(pointListIterator.next()); final UShape sh = new UPolygon(pointListIterator.next());
return new UDrawable() { return new UDrawable() {
@ -491,7 +512,7 @@ public class Line implements Moveable, Hideable {
return; return;
} }
int idx = getIndexFromColor(svg, this.lineColor); int idx = SvekUtils.getIndexFromColor(svg, this.lineColor);
if (idx == -1) { if (idx == -1) {
return; return;
// throw new IllegalStateException(); // throw new IllegalStateException();
@ -519,7 +540,7 @@ public class Line implements Moveable, Hideable {
} }
dotPath = dotPath.simulateCompound(lhead, ltail); dotPath = dotPath.simulateCompound(lhead, ltail);
PointListIterator pointListIterator = new PointListIterator(svg.substring(end), fullHeight); PointListIterator pointListIterator = PointListIterator.create(svg.substring(end), fullHeight, lineColor);
final LinkType linkType = link.getType(); final LinkType linkType = link.getType();
this.extremity1 = getExtremity(linkType.getDecor2(), pointListIterator, dotPath.getStartPoint(), this.extremity1 = getExtremity(linkType.getDecor2(), pointListIterator, dotPath.getStartPoint(),
@ -536,7 +557,7 @@ public class Line implements Moveable, Hideable {
final double dist2start = p2.distance(dotPath.getStartPoint()); final double dist2start = p2.distance(dotPath.getStartPoint());
final double dist2end = p2.distance(dotPath.getEndPoint()); final double dist2end = p2.distance(dotPath.getEndPoint());
if (dist1start > dist1end && dist2end > dist2start) { if (dist1start > dist1end && dist2end > dist2start) {
pointListIterator = new PointListIterator(svg.substring(end), fullHeight); pointListIterator = PointListIterator.create(svg.substring(end), fullHeight, lineColor);
this.extremity2 = getExtremity(linkType.getDecor1(), pointListIterator, dotPath.getEndPoint(), this.extremity2 = getExtremity(linkType.getDecor1(), pointListIterator, dotPath.getEndPoint(),
dotPath.getEndAngle(), lhead, bibliotekon.getShape(link.getEntity2())); dotPath.getEndAngle(), lhead, bibliotekon.getShape(link.getEntity2()));
this.extremity1 = getExtremity(linkType.getDecor2(), pointListIterator, dotPath.getStartPoint(), this.extremity1 = getExtremity(linkType.getDecor2(), pointListIterator, dotPath.getStartPoint(),
@ -581,7 +602,7 @@ public class Line implements Moveable, Hideable {
} }
private Point2D.Double getXY(String svg, int color, int height) { private Point2D.Double getXY(String svg, int color, int height) {
final int idx = getIndexFromColor(svg, color); final int idx = SvekUtils.getIndexFromColor(svg, color);
if (idx == -1) { if (idx == -1) {
return null; return null;
} }
@ -589,27 +610,6 @@ public class Line implements Moveable, Hideable {
} }
private int getIndexFromColor(String svg, int color) {
String s = "stroke=\"" + StringUtils.goLowerCase(StringUtils.getAsHtml(color)) + "\"";
int idx = svg.indexOf(s);
if (idx != -1) {
return idx;
}
s = ";stroke:" + StringUtils.goLowerCase(StringUtils.getAsHtml(color)) + ";";
idx = svg.indexOf(s);
if (idx != -1) {
return idx;
}
s = "fill=\"" + StringUtils.goLowerCase(StringUtils.getAsHtml(color)) + "\"";
idx = svg.indexOf(s);
if (idx != -1) {
return idx;
}
Log.info("Cannot find color=" + color + " " + StringUtils.goLowerCase(StringUtils.getAsHtml(color)));
return -1;
}
public void drawU(UGraphic ug, HtmlColor color) { public void drawU(UGraphic ug, HtmlColor color) {
if (opale) { if (opale) {
return; return;

View File

@ -48,6 +48,7 @@ import java.util.Locale;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import net.sourceforge.plantuml.Log; import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.StringUtils;
public class SvekUtils { public class SvekUtils {
@ -70,7 +71,22 @@ public class SvekUtils {
private final double yDelta; private final double yDelta;
private int pos = 0; private int pos = 0;
public PointListIterator(String text, double yDelta) { public static PointListIterator create(String text, double yDelta, int lineColor) {
final PointListIterator result = new PointListIterator(text, yDelta);
final int idx = getIndexFromColor(text, lineColor);
if (idx == -1) {
result.pos = -1;
}
return result;
}
public PointListIterator cloneMe() {
final PointListIterator result = new PointListIterator(text, yDelta);
result.pos = this.pos;
return result;
}
private PointListIterator(String text, double yDelta) {
this.text = text; this.text = text;
this.yDelta = yDelta; this.yDelta = yDelta;
} }
@ -80,6 +96,9 @@ public class SvekUtils {
} }
public List<Point2D.Double> next() { public List<Point2D.Double> next() {
if (pos == -1) {
return Collections.emptyList();
}
try { try {
final List<Point2D.Double> result = extractPointsList(text, pos, yDelta); final List<Point2D.Double> result = extractPointsList(text, pos, yDelta);
pos = text.indexOf(pointsString, pos) + pointsString.length() + 1; pos = text.indexOf(pointsString, pos) + pointsString.length() + 1;
@ -114,6 +133,27 @@ public class SvekUtils {
return pointsList; return pointsList;
} }
public static int getIndexFromColor(String svg, int color) {
String s = "stroke=\"" + StringUtils.goLowerCase(StringUtils.getAsHtml(color)) + "\"";
int idx = svg.indexOf(s);
if (idx != -1) {
return idx;
}
s = ";stroke:" + StringUtils.goLowerCase(StringUtils.getAsHtml(color)) + ";";
idx = svg.indexOf(s);
if (idx != -1) {
return idx;
}
s = "fill=\"" + StringUtils.goLowerCase(StringUtils.getAsHtml(color)) + "\"";
idx = svg.indexOf(s);
if (idx != -1) {
return idx;
}
// Log.info("Cannot find color=" + color + " " + StringUtils.goLowerCase(StringUtils.getAsHtml(color)));
return -1;
}
static public double getValue(String svg, int starting, String varName) { static public double getValue(String svg, int starting, String varName) {
final String varNameString = varName + "=\""; final String varNameString = varName + "=\"";
int p1 = svg.indexOf(varNameString, starting); int p1 = svg.indexOf(varNameString, starting);
@ -171,6 +211,7 @@ public class SvekUtils {
} }
static private List<Point2D.Double> getPoints(String points, double yDelta) { static private List<Point2D.Double> getPoints(String points, double yDelta) {
try {
final List<Point2D.Double> result = new ArrayList<Point2D.Double>(); final List<Point2D.Double> result = new ArrayList<Point2D.Double>();
final StringTokenizer st = new StringTokenizer(points, " MC"); final StringTokenizer st = new StringTokenizer(points, " MC");
while (st.hasMoreTokens()) { while (st.hasMoreTokens()) {
@ -181,6 +222,9 @@ public class SvekUtils {
result.add(new Point2D.Double(x, y)); result.add(new Point2D.Double(x, y));
} }
return result; return result;
} catch (NumberFormatException e) {
return Collections.emptyList();
}
} }
public static void println(StringBuilder sb) { public static void println(StringBuilder sb) {

View File

@ -44,6 +44,11 @@ import net.sourceforge.plantuml.svek.Side;
public class ExtremityFactoryParenthesis extends AbstractExtremityFactory implements ExtremityFactory { public class ExtremityFactoryParenthesis extends AbstractExtremityFactory implements ExtremityFactory {
@Override
public UDrawable createUDrawable(Point2D p0, double angle, Side side) {
return new ExtremityParenthesis(p0, angle - Math.PI / 2);
}
public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side) { public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2, Side side) {
final double ortho = atan2(p0, p2); final double ortho = atan2(p0, p2);
if (OptionFlags.USE_INTERFACE_EYE2) { if (OptionFlags.USE_INTERFACE_EYE2) {

View File

@ -61,7 +61,6 @@ import net.sourceforge.plantuml.graphic.USymbol;
import net.sourceforge.plantuml.graphic.USymbolFolder; import net.sourceforge.plantuml.graphic.USymbolFolder;
import net.sourceforge.plantuml.graphic.color.ColorType; import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.svek.AbstractEntityImage; import net.sourceforge.plantuml.svek.AbstractEntityImage;
import net.sourceforge.plantuml.svek.Bibliotekon;
import net.sourceforge.plantuml.svek.Margins; import net.sourceforge.plantuml.svek.Margins;
import net.sourceforge.plantuml.svek.ShapeType; import net.sourceforge.plantuml.svek.ShapeType;
import net.sourceforge.plantuml.ugraphic.UComment; import net.sourceforge.plantuml.ugraphic.UComment;
@ -85,10 +84,12 @@ public class EntityImageDescription extends AbstractEntityImage {
private final boolean hideText; private final boolean hideText;
private final Collection<Link> links; private final Collection<Link> links;
private final boolean useRankSame;
public EntityImageDescription(ILeaf entity, ISkinParam skinParam, PortionShower portionShower, public EntityImageDescription(ILeaf entity, ISkinParam skinParam, PortionShower portionShower,
Collection<Link> links) { Collection<Link> links) {
super(entity, entity.getColors(skinParam).mute(skinParam)); super(entity, entity.getColors(skinParam).mute(skinParam));
this.useRankSame = skinParam.useRankSame();
this.links = links; this.links = links;
final Stereotype stereotype = entity.getStereotype(); final Stereotype stereotype = entity.getStereotype();
USymbol symbol = getUSymbol(entity); USymbol symbol = getUSymbol(entity);
@ -161,7 +162,7 @@ public class EntityImageDescription extends AbstractEntityImage {
@Override @Override
public Margins getShield(StringBounder stringBounder) { public Margins getShield(StringBounder stringBounder) {
if (hideText && hasSomeHorizontalLink((ILeaf) getEntity(), links) == false) { if (hideText && (useRankSame == false || hasSomeHorizontalLink((ILeaf) getEntity(), links) == false)) {
final Dimension2D dimStereo = stereo.calculateDimension(stringBounder); final Dimension2D dimStereo = stereo.calculateDimension(stringBounder);
final Dimension2D dimDesc = desc.calculateDimension(stringBounder); final Dimension2D dimDesc = desc.calculateDimension(stringBounder);
final Dimension2D dimSmall = asSmall.calculateDimension(stringBounder); final Dimension2D dimSmall = asSmall.calculateDimension(stringBounder);
@ -185,8 +186,6 @@ public class EntityImageDescription extends AbstractEntityImage {
return false; return false;
} }
final public void drawU(UGraphic ug) { final public void drawU(UGraphic ug) {
ug.draw(new UComment("entity " + getEntity().getCode().getFullName())); ug.draw(new UComment("entity " + getEntity().getCode().getFullName()));
if (url != null) { if (url != null) {

View File

@ -40,6 +40,7 @@ import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.ColorParam; import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.FontParam; import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam; import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.SkinParamUtils; import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.Url; import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.creole.Stencil; import net.sourceforge.plantuml.creole.Stencil;
@ -72,8 +73,6 @@ public class EntityImageUseCase extends AbstractEntityImage {
final private Url url; final private Url url;
static private final UStroke stroke = new UStroke(1.5);
public EntityImageUseCase(ILeaf entity, ISkinParam skinParam) { public EntityImageUseCase(ILeaf entity, ISkinParam skinParam) {
super(entity, skinParam); super(entity, skinParam);
final Stereotype stereotype = entity.getStereotype(); final Stereotype stereotype = entity.getStereotype();
@ -93,6 +92,15 @@ public class EntityImageUseCase extends AbstractEntityImage {
} }
private UStroke getStroke() {
UStroke stroke = getSkinParam().getThickness(LineParam.usecaseBorder, getStereo());
if (stroke == null) {
stroke = new UStroke(1.5);
}
return stroke;
}
public Dimension2D calculateDimension(StringBounder stringBounder) { public Dimension2D calculateDimension(StringBounder stringBounder) {
return new TextBlockInEllipse(desc, stringBounder).calculateDimension(stringBounder); return new TextBlockInEllipse(desc, stringBounder).calculateDimension(stringBounder);
} }
@ -108,7 +116,7 @@ public class EntityImageUseCase extends AbstractEntityImage {
ug.startUrl(url); ug.startUrl(url);
} }
ug = ug.apply(stroke); ug = ug.apply(getStroke());
HtmlColor linecolor = getEntity().getColors(getSkinParam()).getColor(ColorType.LINE); HtmlColor linecolor = getEntity().getColors(getSkinParam()).getColor(ColorType.LINE);
if (linecolor == null) { if (linecolor == null) {
linecolor = SkinParamUtils.getColor(getSkinParam(), ColorParam.usecaseBorder, getStereo()); linecolor = SkinParamUtils.getColor(getSkinParam(), ColorParam.usecaseBorder, getStereo());
@ -185,6 +193,7 @@ public class EntityImageUseCase extends AbstractEntityImage {
@Override @Override
protected void drawHline(UGraphic ug, UHorizontalLine line, UTranslate translate) { protected void drawHline(UGraphic ug, UHorizontalLine line, UTranslate translate) {
final UStroke stroke = new UStroke(1.5);
line.drawLineInternal(ug.apply(translate), getStencil2(translate), 0, stroke); line.drawLineInternal(ug.apply(translate), getStencil2(translate), 0, stroke);
} }

View File

@ -35,6 +35,7 @@
*/ */
package net.sourceforge.plantuml.svg; package net.sourceforge.plantuml.svg;
import java.awt.geom.Dimension2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
@ -44,7 +45,6 @@ import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
@ -116,15 +116,16 @@ public class SvgGraphics {
} }
} }
public SvgGraphics(double scale, String hover, long seed) { public SvgGraphics(Dimension2D minDim, double scale, String hover, long seed) {
this(null, scale, hover, seed); this(minDim, null, scale, hover, seed);
} }
public SvgGraphics(String backcolor, double scale, String hover, long seed) { public SvgGraphics(Dimension2D minDim, String backcolor, double scale, String hover, long seed) {
try { try {
this.scale = scale; this.scale = scale;
this.document = getDocument(); this.document = getDocument();
this.backcolor = backcolor; this.backcolor = backcolor;
ensureVisible(minDim.getWidth(), minDim.getHeight());
this.root = getRootNode(); this.root = getRootNode();

View File

@ -153,6 +153,7 @@ public class LanguageDescriptor {
preproc.add("!pragma"); preproc.add("!pragma");
preproc.add("!define"); preproc.add("!define");
preproc.add("!undef"); preproc.add("!undef");
preproc.add("!if");
preproc.add("!ifdef"); preproc.add("!ifdef");
preproc.add("!endif"); preproc.add("!endif");
preproc.add("!ifndef"); preproc.add("!ifndef");

View File

@ -39,8 +39,11 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.BackSlash;
import net.sourceforge.plantuml.BlockUml; import net.sourceforge.plantuml.BlockUml;
import net.sourceforge.plantuml.ErrorUml; import net.sourceforge.plantuml.ErrorUml;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.LineLocationImpl;
import net.sourceforge.plantuml.OptionFlags; import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.PSystemError; import net.sourceforge.plantuml.PSystemError;
import net.sourceforge.plantuml.SourceStringReader; import net.sourceforge.plantuml.SourceStringReader;
@ -54,7 +57,7 @@ public class SyntaxChecker {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
for (String s : source) { for (String s : source) {
sb.append(s); sb.append(s);
sb.append("\n"); sb.append(BackSlash.NEWLINE);
} }
return checkSyntax(sb.toString()); return checkSyntax(sb.toString());
} }
@ -65,14 +68,16 @@ public class SyntaxChecker {
if (source.startsWith("@startuml\n") == false) { if (source.startsWith("@startuml\n") == false) {
result.setError(true); result.setError(true);
result.setErrorLinePosition(0); result.setLineLocation(new LineLocationImpl(null, null).oneLineRead());
// 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) {
result.setError(true); result.setError(true);
result.setErrorLinePosition(lastLineNumber(source)); result.setLineLocation(lastLineNumber2(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;
@ -83,7 +88,8 @@ public class SyntaxChecker {
final List<BlockUml> blocks = sourceStringReader.getBlocks(); final List<BlockUml> blocks = sourceStringReader.getBlocks();
if (blocks.size() == 0) { if (blocks.size() == 0) {
result.setError(true); result.setError(true);
result.setErrorLinePosition(lastLineNumber(source)); result.setLineLocation(lastLineNumber2(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;
@ -96,7 +102,7 @@ public class SyntaxChecker {
} else if (system instanceof PSystemError) { } else if (system instanceof PSystemError) {
result.setError(true); result.setError(true);
final PSystemError sys = (PSystemError) system; final PSystemError sys = (PSystemError) system;
result.setErrorLinePosition(sys.getHigherErrorPosition()); // result.setErrorLinePosition(sys.getHigherErrorPosition());
result.setLineLocation(sys.getLineLocation()); result.setLineLocation(sys.getLineLocation());
result.setSystemError(sys); result.setSystemError(sys);
for (ErrorUml er : sys.getErrorsUml()) { for (ErrorUml er : sys.getErrorsUml()) {
@ -117,7 +123,7 @@ public class SyntaxChecker {
final List<BlockUml> blocks = sourceStringReader.getBlocks(); final List<BlockUml> blocks = sourceStringReader.getBlocks();
if (blocks.size() == 0) { if (blocks.size() == 0) {
result.setError(true); result.setError(true);
result.setErrorLinePosition(lastLineNumber(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;
@ -131,7 +137,7 @@ public class SyntaxChecker {
} else if (system instanceof PSystemError) { } else if (system instanceof PSystemError) {
result.setError(true); result.setError(true);
final PSystemError sys = (PSystemError) system; final PSystemError sys = (PSystemError) system;
result.setErrorLinePosition(sys.getHigherErrorPosition()); // result.setErrorLinePosition(sys.getHigherErrorPosition());
result.setLineLocation(sys.getLineLocation()); result.setLineLocation(sys.getLineLocation());
for (ErrorUml er : sys.getErrorsUml()) { for (ErrorUml er : sys.getErrorsUml()) {
result.addErrorText(er.getError()); result.addErrorText(er.getError());
@ -153,4 +159,14 @@ public class SyntaxChecker {
} }
return result; return result;
} }
private static LineLocation lastLineNumber2(String source) {
LineLocationImpl result = new LineLocationImpl(null, null).oneLineRead();
for (int i = 0; i < source.length(); i++) {
if (source.charAt(i) == '\n') {
result = result.oneLineRead();
}
}
return result;
}
} }

View File

@ -52,7 +52,7 @@ public class SyntaxResult {
private UmlDiagramType umlDiagramType; private UmlDiagramType umlDiagramType;
private boolean isError; private boolean isError;
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;
@ -71,9 +71,9 @@ 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;
@ -95,9 +95,9 @@ 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);

View File

@ -40,23 +40,23 @@ import java.util.Map;
public abstract class AbstractUGraphic<O> extends AbstractCommonUGraphic { public abstract class AbstractUGraphic<O> extends AbstractCommonUGraphic {
private final O g2d; private final O graphic;
private final Map<Class<? extends UShape>, UDriver<O>> drivers = new HashMap<Class<? extends UShape>, UDriver<O>>(); private final Map<Class<? extends UShape>, UDriver<O>> drivers = new HashMap<Class<? extends UShape>, UDriver<O>>();
public AbstractUGraphic(ColorMapper colorMapper, O g2d) { public AbstractUGraphic(ColorMapper colorMapper, O graphic) {
super(colorMapper); super(colorMapper);
this.g2d = g2d; this.graphic = graphic;
} }
protected AbstractUGraphic(AbstractUGraphic<O> other) { protected AbstractUGraphic(AbstractUGraphic<O> other) {
super(other); super(other);
this.g2d = other.g2d; this.graphic = other.graphic;
// this.drivers.putAll(other.drivers); // this.drivers.putAll(other.drivers);
} }
protected final O getGraphicObject() { protected final O getGraphicObject() {
return g2d; return graphic;
} }
protected boolean manageHiddenAutomatically() { protected boolean manageHiddenAutomatically() {
@ -86,9 +86,9 @@ public abstract class AbstractUGraphic<O> extends AbstractCommonUGraphic {
if (shape instanceof Scalable) { if (shape instanceof Scalable) {
final double scale = getParam().getScale(); final double scale = getParam().getScale();
shape = ((Scalable) shape).getScaled(scale); shape = ((Scalable) shape).getScaled(scale);
driver.draw(shape, getTranslateX(), getTranslateY(), getColorMapper(), getParam(), g2d); driver.draw(shape, getTranslateX(), getTranslateY(), getColorMapper(), getParam(), graphic);
} else { } else {
driver.draw(shape, getTranslateX(), getTranslateY(), getColorMapper(), getParam(), g2d); driver.draw(shape, getTranslateX(), getTranslateY(), getColorMapper(), getParam(), graphic);
} }
afterDraw(); afterDraw();
} }

View File

@ -54,6 +54,7 @@ import java.util.Set;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerException;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FileFormat; import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption; import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.graphic.FontConfiguration; import net.sourceforge.plantuml.graphic.FontConfiguration;
@ -157,7 +158,7 @@ public class FontChecker {
} }
private String getSvgImage(char c) throws IOException, TransformerException { private String getSvgImage(char c) throws IOException, TransformerException {
final SvgGraphics svg = new SvgGraphics(1.0, null, 42); final SvgGraphics svg = new SvgGraphics(new Dimension2DDouble(0, 0), 1.0, null, 42);
svg.setStrokeColor("black"); svg.setStrokeColor("black");
svg.svgImage(getBufferedImage(c), 0, 0); svg.svgImage(getBufferedImage(c), 0, 0);
final ByteArrayOutputStream os = new ByteArrayOutputStream(); final ByteArrayOutputStream os = new ByteArrayOutputStream();

View File

@ -394,11 +394,11 @@ public class ImageBuilder {
} }
final UGraphicSvg ug; final UGraphicSvg ug;
if (mybackcolor instanceof HtmlColorGradient) { if (mybackcolor instanceof HtmlColorGradient) {
ug = new UGraphicSvg(colorMapper, (HtmlColorGradient) mybackcolor, false, scale, svgLinkTarget, hover, seed); ug = new UGraphicSvg(dim, colorMapper, (HtmlColorGradient) mybackcolor, false, scale, svgLinkTarget, hover, seed);
} else if (backColor == null || backColor.equals(Color.WHITE)) { } else if (backColor == null || backColor.equals(Color.WHITE)) {
ug = new UGraphicSvg(colorMapper, false, scale, svgLinkTarget, hover, seed); ug = new UGraphicSvg(dim, colorMapper, false, scale, svgLinkTarget, hover, seed);
} else { } else {
ug = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(backColor), false, scale, svgLinkTarget, hover, ug = new UGraphicSvg(dim, colorMapper, StringUtils.getAsHtml(backColor), false, scale, svgLinkTarget, hover,
seed); seed);
} }
return ug; return ug;

View File

@ -62,7 +62,8 @@ public abstract class UGraphicUtils {
final BufferedImage im = createImage(colorMapper, background, image); final BufferedImage im = createImage(colorMapper, background, image);
PngIO.write(im, os, fileFormatOption.isWithMetadata() ? metadata : null, 96); PngIO.write(im, os, fileFormatOption.isWithMetadata() ? metadata : null, 96);
} else if (fileFormat == FileFormat.SVG) { } else if (fileFormat == FileFormat.SVG) {
final UGraphicSvg svg = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(colorMapper final Dimension2D size = computeSize(colorMapper, background, image);
final UGraphicSvg svg = new UGraphicSvg(size, colorMapper, StringUtils.getAsHtml(colorMapper
.getMappedColor(background)), false, 1.0, fileFormatOption.getSvgLinkTarget(), .getMappedColor(background)), false, 1.0, fileFormatOption.getSvgLinkTarget(),
fileFormatOption.getHoverColor(), seed); fileFormatOption.getHoverColor(), seed);
image.drawU(svg); image.drawU(svg);
@ -81,16 +82,12 @@ public abstract class UGraphicUtils {
} }
private static BufferedImage createImage(ColorMapper colorMapper, HtmlColor background, TextBlock image) { private static BufferedImage createImage(ColorMapper colorMapper, HtmlColor background, TextBlock image) {
EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, colorMapper.getMappedColor(background)); final Dimension2D size = computeSize(colorMapper, background, image);
Graphics2D g2d = builder.getGraphics2D();
final UGraphicG2d tmp = new UGraphicG2d(colorMapper, g2d, 1.0); final EmptyImageBuilder builder = new EmptyImageBuilder(size.getWidth(), size.getHeight(),
final Dimension2D size = image.calculateDimension(tmp.getStringBounder()); colorMapper.getMappedColor(background));
g2d.dispose();
builder = new EmptyImageBuilder(size.getWidth(), size.getHeight(), colorMapper.getMappedColor(background));
final BufferedImage im = builder.getBufferedImage(); final BufferedImage im = builder.getBufferedImage();
g2d = builder.getGraphics2D(); final Graphics2D g2d = builder.getGraphics2D();
final UGraphicG2d ug = new UGraphicG2d(colorMapper, g2d, 1.0); final UGraphicG2d ug = new UGraphicG2d(colorMapper, g2d, 1.0);
image.drawU(ug); image.drawU(ug);
@ -98,22 +95,14 @@ public abstract class UGraphicUtils {
return im; return im;
} }
// public static void writeImage(OutputStream os, UGraphic ug, String metadata, int dpi) throws IOException { private static Dimension2D computeSize(ColorMapper colorMapper, HtmlColor background, TextBlock image) {
// if (ug instanceof UGraphicG2d) { final EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, colorMapper.getMappedColor(background));
// final BufferedImage im = ((UGraphicG2d) ug).getBufferedImage(); final Graphics2D g2d = builder.getGraphics2D();
// PngIO.write(im, os, metadata, dpi);
// } else if (ug instanceof UGraphicSvg) { final UGraphicG2d tmp = new UGraphicG2d(colorMapper, g2d, 1.0);
// final UGraphicSvg svg = (UGraphicSvg) ug; final Dimension2D size = image.calculateDimension(tmp.getStringBounder());
// svg.createXml(os); g2d.dispose();
// } else if (ug instanceof UGraphicEps) { return size;
// final UGraphicEps eps = (UGraphicEps) ug; }
// os.write(eps.getEPSCode().getBytes());
// } else if (ug instanceof UGraphicHtml5) {
// final UGraphicHtml5 html5 = (UGraphicHtml5) ug;
// os.write(html5.generateHtmlCode().getBytes());
// } else {
// throw new UnsupportedOperationException();
// }
// }
} }

View File

@ -63,6 +63,20 @@ public class UPolygon extends AbstractShadowable {
this.name = name; this.name = name;
} }
public Point2D checkMiddleContactForSpecificTriangle(Point2D center) {
for (int i = 0; i < all.size() - 1; i++) {
final Point2D.Double pt1 = all.get(i);
final Point2D.Double pt2 = all.get(i + 1);
final Point2D.Double middle = new Point2D.Double((pt1.getX() + pt2.getX()) / 2,
(pt1.getY() + pt2.getY()) / 2);
final double delta = middle.distance(center);
if (delta < 1) {
return all.get((i - 1) % all.size());
}
}
return null;
}
public void addPoint(double x, double y) { public void addPoint(double x, double y) {
all.add(new Point2D.Double(x, y)); all.add(new Point2D.Double(x, y));
manageMinMax(x, y); manageMinMax(x, y);
@ -142,4 +156,5 @@ public class UPolygon extends AbstractShadowable {
} }
return points; return points;
} }
} }

View File

@ -38,6 +38,8 @@ package net.sourceforge.plantuml.ugraphic.sprite;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.util.List; import java.util.List;
import net.sourceforge.plantuml.BackSlash;
public class SpriteUtils { public class SpriteUtils {
public static final String SPRITE_NAME = "[-\\p{L}0-9_/]+"; public static final String SPRITE_NAME = "[-\\p{L}0-9_/]+";
@ -52,7 +54,7 @@ public class SpriteUtils {
final List<String> result = level.encode(img); final List<String> result = level.encode(img);
for (String s : result) { for (String s : result) {
sb.append(s); sb.append(s);
sb.append("\n"); sb.append(BackSlash.NEWLINE);
} }
sb.append("}\n"); sb.append("}\n");
return sb.toString(); return sb.toString();
@ -64,12 +66,12 @@ public class SpriteUtils {
final List<String> list = level.encodeZ(img); final List<String> list = level.encodeZ(img);
if (list.size() == 1) { if (list.size() == 1) {
sb.append(list.get(0)); sb.append(list.get(0));
sb.append("\n"); sb.append(BackSlash.NEWLINE);
} else { } else {
sb.append("{\n"); sb.append("{\n");
for (String s : list) { for (String s : list) {
sb.append(s); sb.append(s);
sb.append("\n"); sb.append(BackSlash.NEWLINE);
} }
sb.append("}\n"); sb.append("}\n");
} }

View File

@ -34,9 +34,9 @@
*/ */
package net.sourceforge.plantuml.ugraphic.svg; package net.sourceforge.plantuml.ugraphic.svg;
import java.awt.geom.Dimension2D;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Random;
import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerException;
@ -82,19 +82,19 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
register(); register();
} }
public UGraphicSvg(ColorMapper colorMapper, String backcolor, boolean textAsPath, double scale, String linkTarget, public UGraphicSvg(Dimension2D minDim, ColorMapper colorMapper, String backcolor, boolean textAsPath, double scale,
String hover, long seed) { String linkTarget, String hover, long seed) {
this(colorMapper, new SvgGraphics(backcolor, scale, hover, seed), textAsPath, linkTarget); this(minDim, colorMapper, new SvgGraphics(minDim, backcolor, scale, hover, seed), textAsPath, linkTarget);
} }
public UGraphicSvg(ColorMapper colorMapper, boolean textAsPath, double scale, String linkTarget, String hover, public UGraphicSvg(Dimension2D minDim, ColorMapper colorMapper, boolean textAsPath, double scale,
long seed) { String linkTarget, String hover, long seed) {
this(colorMapper, new SvgGraphics(scale, hover, seed), textAsPath, linkTarget); this(minDim, colorMapper, new SvgGraphics(minDim, scale, hover, seed), textAsPath, linkTarget);
} }
public UGraphicSvg(ColorMapper mapper, HtmlColorGradient gr, boolean textAsPath, double scale, String linkTarget, public UGraphicSvg(Dimension2D minDim, ColorMapper mapper, HtmlColorGradient gr, boolean textAsPath, double scale,
String hover, long seed) { String linkTarget, String hover, long seed) {
this(mapper, new SvgGraphics(scale, hover, seed), textAsPath, linkTarget); this(minDim, mapper, new SvgGraphics(minDim, scale, hover, seed), textAsPath, linkTarget);
final SvgGraphics svg = getGraphicObject(); final SvgGraphics svg = getGraphicObject();
svg.paintBackcolorGradient(mapper, gr); svg.paintBackcolorGradient(mapper, gr);
@ -115,7 +115,8 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
getGraphicObject().setHidden(false); getGraphicObject().setHidden(false);
} }
private UGraphicSvg(ColorMapper colorMapper, SvgGraphics svg, boolean textAsPath, String linkTarget) { private UGraphicSvg(Dimension2D minDim, ColorMapper colorMapper, SvgGraphics svg, boolean textAsPath,
String linkTarget) {
super(colorMapper, svg); super(colorMapper, svg);
this.stringBounder = FileFormat.PNG.getDefaultStringBounder(); this.stringBounder = FileFormat.PNG.getDefaultStringBounder();
this.textAsPath2 = textAsPath; this.textAsPath2 = textAsPath;

View File

@ -43,7 +43,14 @@ public class Version {
private static final int MAJOR_SEPARATOR = 1000000; private static final int MAJOR_SEPARATOR = 1000000;
public static int version() { public static int version() {
return 1201713; return 1201714;
}
public static int versionPatched() {
if (beta() != 0) {
return version() + 1;
}
return version();
} }
public static String versionString() { public static String versionString() {
@ -81,7 +88,7 @@ public class Version {
} }
public static long compileTime() { public static long compileTime() {
return 1494435153042L; return 1496656592758L;
} }
public static String compileTimeString() { public static String compileTimeString() {