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:
parent
2202502f2f
commit
f9bf7c08e5
2
pom.xml
2
pom.xml
@ -35,7 +35,7 @@
|
||||
|
||||
<groupId>net.sourceforge.plantuml</groupId>
|
||||
<artifactId>plantuml</artifactId>
|
||||
<version>1.2017.14-SNAPSHOT</version>
|
||||
<version>1.2017.15-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>PlantUML</name>
|
||||
|
@ -65,7 +65,7 @@ public abstract class AbstractPSystem implements Diagram {
|
||||
toAppend.append("(" + License.getCurrent() + " source distribution)\n");
|
||||
for (String name : OptionPrint.interestingProperties()) {
|
||||
toAppend.append(name);
|
||||
toAppend.append('\n');
|
||||
toAppend.append(BackSlash.CHAR_NEWLINE);
|
||||
}
|
||||
return toAppend.toString();
|
||||
}
|
||||
@ -74,7 +74,7 @@ public abstract class AbstractPSystem implements Diagram {
|
||||
if (source == null) {
|
||||
return getVersion();
|
||||
}
|
||||
return source.getPlainString() + "\n" + getVersion();
|
||||
return source.getPlainString() + BackSlash.NEWLINE + getVersion();
|
||||
}
|
||||
|
||||
final public UmlSource getSource() {
|
||||
|
@ -43,9 +43,18 @@ import java.util.List;
|
||||
public class BackSlash {
|
||||
|
||||
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() {
|
||||
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) {
|
||||
@ -53,7 +62,7 @@ public class BackSlash {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -35,6 +35,7 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -42,6 +43,8 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
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.core.Diagram;
|
||||
import net.sourceforge.plantuml.preproc.Defines;
|
||||
@ -59,12 +62,19 @@ public class BlockUml {
|
||||
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() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (CharSequence2 line : data) {
|
||||
sb.append(line);
|
||||
sb.append('\r');
|
||||
sb.append('\n');
|
||||
sb.append(BackSlash.CHAR_NEWLINE);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
@ -122,7 +132,7 @@ public class BlockUml {
|
||||
|
||||
public Diagram getDiagram() {
|
||||
if (system == null) {
|
||||
system = new PSystemBuilder().createPSystem(data);
|
||||
system = new PSystemBuilder().createPSystem(data, startLine);
|
||||
}
|
||||
return system;
|
||||
}
|
||||
|
@ -108,8 +108,8 @@ public final class BlockUmlBuilder implements DefinitionsContainer {
|
||||
reader2.setPaused(false);
|
||||
}
|
||||
if (StartUtils.isArobaseEndDiagram(s) && current2 != null) {
|
||||
current2.addAll(1, convert(config, s.getLocation()));
|
||||
blocks.add(new BlockUml(current2, startLine, defines.cloneMe()));
|
||||
current2.addAll(1, convert(config, new LineLocationImpl(null, null).oneLineRead()));
|
||||
blocks.add(new BlockUml(current2, startLine - config.size(), defines.cloneMe()));
|
||||
current2 = null;
|
||||
reader2.setPaused(false);
|
||||
}
|
||||
|
@ -66,14 +66,14 @@ public class CMapData {
|
||||
appendString("\" href=\"");
|
||||
appendString(url.getUrl());
|
||||
appendString("\" title=\"");
|
||||
final String tooltip = url.getTooltip().replaceAll("\\\\n", "\n").replaceAll("&", "&")
|
||||
final String tooltip = url.getTooltip().replaceAll("\\\\n", BackSlash.NEWLINE).replaceAll("&", "&")
|
||||
.replaceAll("\"", """).replaceAll("\'", "'");
|
||||
appendString(tooltip);
|
||||
appendString("\" alt=\"\" coords=\"");
|
||||
appendString(url.getCoords(scale));
|
||||
appendString("\"/>");
|
||||
|
||||
appendString("\n");
|
||||
appendString(BackSlash.NEWLINE);
|
||||
}
|
||||
|
||||
// private CMapData() {
|
||||
|
@ -41,35 +41,35 @@ import net.sourceforge.plantuml.suggest.SuggestEngineStatus;
|
||||
public class ErrorUml {
|
||||
|
||||
private final String error;
|
||||
private final int position;
|
||||
private final ErrorUmlType type;
|
||||
private SuggestEngineResult suggest;
|
||||
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)) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
// this.startLine = startLine;
|
||||
this.error = error;
|
||||
this.type = type;
|
||||
this.position = position;
|
||||
this.lineLocation = lineLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object 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
|
||||
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
|
||||
public String toString() {
|
||||
return type.toString() + " " + position + " " + error + " " + suggest;
|
||||
return type.toString() + " " + getPosition() + " " + error + " " + suggest;
|
||||
}
|
||||
|
||||
public final String getError() {
|
||||
@ -80,8 +80,8 @@ public class ErrorUml {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getPosition() {
|
||||
return position;
|
||||
private int getPosition() {
|
||||
return lineLocation.getPosition();
|
||||
}
|
||||
|
||||
public LineLocation getLineLocation() {
|
||||
@ -100,5 +100,4 @@ public class ErrorUml {
|
||||
this.suggest = suggest;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class GeneratedImageImpl implements GeneratedImage {
|
||||
public int lineErrorRaw() {
|
||||
final Diagram system = blockUml.getDiagram();
|
||||
if (system instanceof PSystemError) {
|
||||
return ((PSystemError) system).getHigherErrorPosition() + blockUml.getStartLine();
|
||||
return ((PSystemError) system).getHigherErrorPosition2().getPosition();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@ -140,5 +140,7 @@ public interface ISkinParam extends ISkinSimple {
|
||||
public HtmlColor getHoverPathColor();
|
||||
|
||||
public double getPadding(PaddingParam param);
|
||||
|
||||
public boolean useRankSame();
|
||||
|
||||
}
|
@ -41,8 +41,8 @@ import java.util.List;
|
||||
public interface ISourceFileReader {
|
||||
|
||||
public List<GeneratedImage> getGeneratedImages() throws IOException;
|
||||
|
||||
public List<String> getEncodedUrl() throws IOException;
|
||||
|
||||
public List<BlockUml> getBlocks();
|
||||
|
||||
public boolean hasError();
|
||||
|
||||
|
@ -40,7 +40,7 @@ package net.sourceforge.plantuml;
|
||||
* 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.
|
||||
|
@ -82,4 +82,9 @@ public class LineLocationImpl implements LineLocation {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public int compareTo(LineLocation other) {
|
||||
final LineLocationImpl other2 = (LineLocationImpl) other;
|
||||
return this.position - other2.position;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public enum LineParam {
|
||||
sequenceParticipantBorder, noteBorder, sequenceGroupBorder, sequenceReferenceBorder,
|
||||
legendBorder,
|
||||
sequenceArrow,
|
||||
classBorder, objectBorder,
|
||||
classBorder, objectBorder, usecaseBorder,
|
||||
partitionBorder,
|
||||
packageBorder,
|
||||
swimlaneBorder,
|
||||
|
@ -400,7 +400,7 @@ public class Option {
|
||||
public Defines getDefaultDefines(File f) {
|
||||
final Defines result = Defines.createWithFileName(f);
|
||||
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;
|
||||
|
@ -93,24 +93,24 @@ public class PSystemBuilder {
|
||||
|
||||
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();
|
||||
|
||||
Diagram result = null;
|
||||
try {
|
||||
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) {
|
||||
if (s.getPreprocessorError() != null) {
|
||||
Log.error("Preprocessor Error: " + s.getPreprocessorError());
|
||||
final ErrorUml singleError = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, s.getPreprocessorError(), cpt,
|
||||
s.getLocation());
|
||||
return new PSystemError(umlSource, singleError, Collections.<String> emptyList());
|
||||
final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, s.getPreprocessorError(), /* cpt */
|
||||
s.getLocation());
|
||||
return new PSystemError(umlSource, err, Collections.<String> emptyList());
|
||||
}
|
||||
cpt++;
|
||||
// cpt++;
|
||||
}
|
||||
|
||||
final DiagramType diagramType = umlSource.getDiagramType();
|
||||
|
@ -43,6 +43,7 @@ import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
||||
@ -72,7 +73,7 @@ import net.sourceforge.plantuml.version.PSystemVersion;
|
||||
|
||||
public class PSystemError extends AbstractPSystem {
|
||||
|
||||
private final int higherErrorPosition;
|
||||
private final LineLocation higherErrorPosition;
|
||||
private final List<ErrorUml> printedErrors;
|
||||
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) {
|
||||
this.setSource(source);
|
||||
|
||||
final int higherErrorPositionExecution = getHigherErrorPosition(ErrorUmlType.EXECUTION_ERROR, all);
|
||||
final int higherErrorPositionSyntax = getHigherErrorPosition(ErrorUmlType.SYNTAX_ERROR, all);
|
||||
final LineLocation execution = getHigherErrorPosition2(ErrorUmlType.EXECUTION_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();
|
||||
}
|
||||
|
||||
if (higherErrorPositionExecution >= higherErrorPositionSyntax) {
|
||||
higherErrorPosition = higherErrorPositionExecution;
|
||||
printedErrors = getErrorsAt(higherErrorPositionExecution, ErrorUmlType.EXECUTION_ERROR, all);
|
||||
if (execution != null && (syntax == null || execution.compareTo(syntax) >= 0)) {
|
||||
higherErrorPosition = execution;
|
||||
printedErrors = getErrorsAt2(execution, ErrorUmlType.EXECUTION_ERROR, all);
|
||||
} else {
|
||||
assert higherErrorPositionSyntax > higherErrorPositionExecution;
|
||||
higherErrorPosition = higherErrorPositionSyntax;
|
||||
printedErrors = getErrorsAt(higherErrorPositionSyntax, ErrorUmlType.SYNTAX_ERROR, all);
|
||||
// assert syntax.compareTo(execution) > 0;
|
||||
higherErrorPosition = syntax;
|
||||
printedErrors = getErrorsAt2(syntax, ErrorUmlType.SYNTAX_ERROR, all);
|
||||
}
|
||||
|
||||
if (debugLines != null) {
|
||||
@ -141,10 +142,10 @@ public class PSystemError extends AbstractPSystem {
|
||||
} else {
|
||||
udrawable = result;
|
||||
}
|
||||
// final int min = (int) (System.currentTimeMillis() / 60000L) % 60;
|
||||
// if (min == 0) {
|
||||
// udrawable = addMessage(udrawable);
|
||||
// }
|
||||
final int min = (int) (System.currentTimeMillis() / 60000L) % 60;
|
||||
if (min == 0) {
|
||||
udrawable = addMessage(udrawable);
|
||||
}
|
||||
imageBuilder.setUDrawable(udrawable);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, seed(), os);
|
||||
}
|
||||
@ -197,21 +198,24 @@ public class PSystemError extends AbstractPSystem {
|
||||
result.add(" ");
|
||||
}
|
||||
|
||||
final int limit = 4;
|
||||
int start;
|
||||
final int skip = higherErrorPosition - limit + 1;
|
||||
if (skip <= 0) {
|
||||
start = 0;
|
||||
} else {
|
||||
if (skip == 1) {
|
||||
result.add("... (skipping 1 line) ...");
|
||||
} else {
|
||||
result.add("... (skipping " + skip + " lines) ...");
|
||||
}
|
||||
start = higherErrorPosition - limit + 1;
|
||||
}
|
||||
for (int i = start; i < higherErrorPosition; i++) {
|
||||
result.add(getSource().getLine(i));
|
||||
// final int limit = 4;
|
||||
// int start;
|
||||
// final int skip = higherErrorPosition - limit + 1;
|
||||
// if (skip <= 0) {
|
||||
// start = 0;
|
||||
// } else {
|
||||
// if (skip == 1) {
|
||||
// result.add("... (skipping 1 line) ...");
|
||||
// } else {
|
||||
// result.add("... (skipping " + skip + " lines) ...");
|
||||
// }
|
||||
// start = higherErrorPosition - limit + 1;
|
||||
// }
|
||||
// for (int i = start; i < higherErrorPosition; i++) {
|
||||
// result.add(getSource().getLine(i));
|
||||
// }
|
||||
for (String s : getPartialCode()) {
|
||||
result.add(s);
|
||||
}
|
||||
final String errorLine = getSource().getLine(higherErrorPosition);
|
||||
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) {
|
||||
final List<String> htmlStrings = new ArrayList<String>(getStack());
|
||||
if (htmlStrings.size() > 0) {
|
||||
htmlStrings.add("----");
|
||||
}
|
||||
|
||||
final int limit = 4;
|
||||
int start;
|
||||
final int skip = higherErrorPosition - limit + 1;
|
||||
if (skip <= 0) {
|
||||
start = 0;
|
||||
} else {
|
||||
if (skip == 1) {
|
||||
htmlStrings.add("... (skipping 1 line) ...");
|
||||
} else {
|
||||
htmlStrings.add("... (skipping " + skip + " lines) ...");
|
||||
}
|
||||
start = higherErrorPosition - limit + 1;
|
||||
}
|
||||
for (int i = start; i < higherErrorPosition; i++) {
|
||||
htmlStrings.add(StringUtils.hideComparatorCharacters(getSource().getLine(i)));
|
||||
// final int limit = 4;
|
||||
// int start;
|
||||
// final int skip = higherErrorPosition - limit + 1;
|
||||
// if (skip <= 0) {
|
||||
// start = 0;
|
||||
// } else {
|
||||
// if (skip == 1) {
|
||||
// htmlStrings.add("... (skipping 1 line) ...");
|
||||
// } else {
|
||||
// htmlStrings.add("... (skipping " + skip + " lines) ...");
|
||||
// }
|
||||
// start = higherErrorPosition - limit + 1;
|
||||
// }
|
||||
// for (int i = start; i < higherErrorPosition; i++) {
|
||||
// htmlStrings.add(StringUtils.hideComparatorCharacters(getSource().getLine(i)));
|
||||
// }
|
||||
for (String s : getPartialCode()) {
|
||||
htmlStrings.add(StringUtils.hideComparatorCharacters(s));
|
||||
}
|
||||
final String errorLine = getSource().getLine(higherErrorPosition);
|
||||
final String err = StringUtils.hideComparatorCharacters(errorLine);
|
||||
@ -352,20 +383,40 @@ public class PSystemError extends AbstractPSystem {
|
||||
return result;
|
||||
}
|
||||
|
||||
private int getHigherErrorPosition(ErrorUmlType type, List<ErrorUml> all) {
|
||||
int max = Integer.MIN_VALUE;
|
||||
// private int getHigherErrorPosition(ErrorUmlType type, List<ErrorUml> all) {
|
||||
// int max = Integer.MIN_VALUE;
|
||||
// for (ErrorUml error : getErrors(type, all)) {
|
||||
// if (error.getPosition() > max) {
|
||||
// max = error.getPosition();
|
||||
// }
|
||||
// }
|
||||
// return max;
|
||||
// }
|
||||
|
||||
private LineLocation getHigherErrorPosition2(ErrorUmlType type, List<ErrorUml> all) {
|
||||
LineLocation max = null;
|
||||
for (ErrorUml error : getErrors(type, all)) {
|
||||
if (error.getPosition() > max) {
|
||||
max = error.getPosition();
|
||||
if (max == null || error.getLineLocation().compareTo(max) > 0) {
|
||||
max = error.getLineLocation();
|
||||
}
|
||||
}
|
||||
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>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -376,7 +427,7 @@ public class PSystemError extends AbstractPSystem {
|
||||
return new DiagramDescription("(Error)");
|
||||
}
|
||||
|
||||
public final int getHigherErrorPosition() {
|
||||
public final LineLocation getHigherErrorPosition2() {
|
||||
return higherErrorPosition;
|
||||
}
|
||||
|
||||
@ -388,15 +439,15 @@ public class PSystemError extends AbstractPSystem {
|
||||
public String getWarningOrError() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(getDescription());
|
||||
sb.append('\n');
|
||||
sb.append(BackSlash.CHAR_NEWLINE);
|
||||
for (CharSequence t : getTitle().getDisplay()) {
|
||||
sb.append(t);
|
||||
sb.append('\n');
|
||||
sb.append(BackSlash.CHAR_NEWLINE);
|
||||
}
|
||||
sb.append('\n');
|
||||
sb.append(BackSlash.CHAR_NEWLINE);
|
||||
for (String s : getSuggest()) {
|
||||
sb.append(s);
|
||||
sb.append('\n');
|
||||
sb.append(BackSlash.CHAR_NEWLINE);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -72,8 +72,11 @@ public class Pipe {
|
||||
}
|
||||
final SourceStringReader sourceStringReader = new SourceStringReader(Defines.createEmpty(), source,
|
||||
option.getConfig());
|
||||
|
||||
if (option.isSyntax()) {
|
||||
if (option.isComputeurl()) {
|
||||
for (BlockUml s : sourceStringReader.getBlocks()) {
|
||||
ps.println(s.getEncodedUrl());
|
||||
}
|
||||
} else if (option.isSyntax()) {
|
||||
final Diagram system = sourceStringReader.getBlocks().get(0).getDiagram();
|
||||
if (system instanceof UmlDiagram) {
|
||||
ps.println(((UmlDiagram) system).getUmlDiagramType().name());
|
||||
@ -117,7 +120,7 @@ public class Pipe {
|
||||
|
||||
private void printErrorText(final PrintStream output, final PSystemError sys) {
|
||||
output.println("ERROR");
|
||||
output.println(sys.getHigherErrorPosition());
|
||||
output.println(sys.getHigherErrorPosition2().getPosition());
|
||||
for (ErrorUml er : sys.getErrorsUml()) {
|
||||
output.println(er.getError());
|
||||
}
|
||||
@ -136,7 +139,7 @@ public class Pipe {
|
||||
closed = true;
|
||||
} else {
|
||||
sb.append(s);
|
||||
sb.append("\n");
|
||||
sb.append(BackSlash.NEWLINE);
|
||||
}
|
||||
if (isFinished(s)) {
|
||||
break;
|
||||
|
@ -402,9 +402,8 @@ public class Run {
|
||||
option.getConfig(), option.getCharset(), option.getFileFormatOption());
|
||||
}
|
||||
if (option.isComputeurl()) {
|
||||
final List<String> urls = sourceFileReader.getEncodedUrl();
|
||||
for (String s : urls) {
|
||||
System.out.println(s);
|
||||
for (BlockUml s : sourceFileReader.getBlocks()) {
|
||||
System.out.println(s.getEncodedUrl());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -430,5 +429,4 @@ public class Run {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -850,4 +850,8 @@ public class SkinParam implements ISkinParam {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean useRankSame() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -263,4 +263,8 @@ public class SkinParamDelegator implements ISkinParam {
|
||||
return skinParam.getPadding(param);
|
||||
}
|
||||
|
||||
public boolean useRankSame() {
|
||||
return skinParam.useRankSame();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -51,8 +51,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
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.preproc.Defines;
|
||||
import net.sourceforge.plantuml.preproc.FileWithSuffix;
|
||||
@ -245,15 +243,8 @@ public class SourceFileReader implements ISourceFileReader {
|
||||
return newName.endsWith("/") || newName.endsWith("\\");
|
||||
}
|
||||
|
||||
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);
|
||||
public List<BlockUml> getBlocks() {
|
||||
return builder.getBlockUmls();
|
||||
}
|
||||
|
||||
private Reader getReader(String charset) throws FileNotFoundException, UnsupportedEncodingException {
|
||||
@ -273,4 +264,5 @@ public class SourceFileReader implements ISourceFileReader {
|
||||
return builder.getIncludedFiles();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -47,8 +47,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
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.preproc.Defines;
|
||||
import net.sourceforge.plantuml.preproc.FileWithSuffix;
|
||||
@ -108,17 +106,6 @@ public class SourceFileReader2 implements ISourceFileReader {
|
||||
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 {
|
||||
if (charset == null) {
|
||||
Log.info("Using default charset");
|
||||
@ -136,4 +123,8 @@ public class SourceFileReader2 implements ISourceFileReader {
|
||||
return builder.getIncludedFiles();
|
||||
}
|
||||
|
||||
public List<BlockUml> getBlocks() {
|
||||
return builder.getBlockUmls();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ public class SourceStringReader {
|
||||
// final CMapData cmap = new CMapData();
|
||||
final ImageData imageData = system.exportDiagram(os, numImage, fileFormatOption);
|
||||
// if (imageData.containsCMapData()) {
|
||||
// return system.getDescription().getDescription() + "\n" + imageData.getCMapData("plantuml");
|
||||
// return system.getDescription().getDescription() + BackSlash.BS_N + imageData.getCMapData("plantuml");
|
||||
// }
|
||||
return system.getDescription();
|
||||
}
|
||||
|
@ -72,20 +72,20 @@ public class UrlBuilder {
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
private static String multilineTooltip(String label) {
|
||||
final Pattern2 p = MyPattern.cmpile("(?i)^(" + URL_PATTERN + ")?(.*)$");
|
||||
final Matcher2 m = p.matcher(label);
|
||||
if (m.matches() == false) {
|
||||
return label;
|
||||
}
|
||||
String gr1 = m.group(1);
|
||||
if (gr1 == null) {
|
||||
return label;
|
||||
}
|
||||
final String gr2 = m.group(m.groupCount());
|
||||
gr1 = gr1.replaceAll("\\\\n", "\n");
|
||||
return gr1 + gr2;
|
||||
}
|
||||
// private static String multilineTooltip(String label) {
|
||||
// final Pattern2 p = MyPattern.cmpile("(?i)^(" + URL_PATTERN + ")?(.*)$");
|
||||
// final Matcher2 m = p.matcher(label);
|
||||
// if (m.matches() == false) {
|
||||
// return label;
|
||||
// }
|
||||
// String gr1 = m.group(1);
|
||||
// if (gr1 == null) {
|
||||
// return label;
|
||||
// }
|
||||
// final String gr2 = m.group(m.groupCount());
|
||||
// gr1 = gr1.replaceAll("\\\\n", BackSlash.BS_N);
|
||||
// return gr1 + gr2;
|
||||
// }
|
||||
|
||||
public Url getUrl(String s) {
|
||||
final Pattern2 p;
|
||||
|
@ -37,6 +37,7 @@ package net.sourceforge.plantuml.activitydiagram.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
import net.sourceforge.plantuml.Direction;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
@ -128,7 +129,7 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
|
||||
urlActivity = extractUrl(diagram, desc0);
|
||||
if (urlActivity == null) {
|
||||
sb.append(desc0);
|
||||
sb.append("\\n");
|
||||
sb.append(BackSlash.BS_BS_N);
|
||||
}
|
||||
}
|
||||
int i = 0;
|
||||
@ -142,15 +143,15 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
|
||||
}
|
||||
sb.append(cs);
|
||||
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()
|
||||
.toString());
|
||||
if (StringUtils.isNotEmpty(lineLast.get(0))) {
|
||||
if (sb.length() > 0 && sb.toString().endsWith("\\n") == false) {
|
||||
sb.append("\\n");
|
||||
if (sb.length() > 0 && sb.toString().endsWith(BackSlash.BS_BS_N) == false) {
|
||||
sb.append(BackSlash.BS_BS_N);
|
||||
}
|
||||
sb.append(lineLast.get(0));
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ import net.sourceforge.plantuml.cucadiagram.IEntity;
|
||||
import net.sourceforge.plantuml.cucadiagram.LeafType;
|
||||
import net.sourceforge.plantuml.descdiagram.DescriptionDiagram;
|
||||
import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
|
||||
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
|
||||
|
||||
public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
|
||||
|
||||
@ -91,17 +92,26 @@ public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CommandExecutionResult executeArg(UmlDiagram classDiagram, RegexResult arg) {
|
||||
if (classDiagram instanceof AbstractClassOrObjectDiagram) {
|
||||
return executeClassDiagram((AbstractClassOrObjectDiagram) classDiagram, arg);
|
||||
protected CommandExecutionResult executeArg(UmlDiagram diagram, RegexResult arg) {
|
||||
if (diagram instanceof AbstractClassOrObjectDiagram) {
|
||||
return executeClassDiagram((AbstractClassOrObjectDiagram) diagram, arg);
|
||||
}
|
||||
if (classDiagram instanceof DescriptionDiagram) {
|
||||
return executeDescriptionDiagram((DescriptionDiagram) classDiagram, arg);
|
||||
if (diagram instanceof DescriptionDiagram) {
|
||||
return executeDescriptionDiagram((DescriptionDiagram) diagram, arg);
|
||||
}
|
||||
if (diagram instanceof SequenceDiagram) {
|
||||
return executeSequenceDiagram((SequenceDiagram) diagram, arg);
|
||||
}
|
||||
// Just ignored
|
||||
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) {
|
||||
final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION", 0));
|
||||
final EntityGender gender;
|
||||
|
@ -185,7 +185,7 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
|
||||
// return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(a);
|
||||
// }
|
||||
// return StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(a) +
|
||||
// "\\n"
|
||||
// BackSlash.VV1
|
||||
// + StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(b);
|
||||
// }
|
||||
|
||||
|
@ -171,7 +171,7 @@ public class BlocLines implements Iterable<CharSequence> {
|
||||
return new BlocLines(copy);
|
||||
}
|
||||
|
||||
public BlocLines concat2() {
|
||||
public BlocLines toSingleLineWithHiddenNewLine() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (CharSequence line : lines) {
|
||||
sb.append(line);
|
||||
|
@ -57,7 +57,7 @@ public class CommandDecoratorMultine<D extends Diagram> implements Command<D> {
|
||||
if (removeEmptyColumn) {
|
||||
lines = lines.removeEmptyColumns();
|
||||
}
|
||||
lines = lines.concat2();
|
||||
lines = lines.toSingleLineWithHiddenNewLine();
|
||||
return cmd.execute(diagram, lines);
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ public class CommandDecoratorMultine<D extends Diagram> implements Command<D> {
|
||||
if (cmd.isCommandForbidden()) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
lines = lines.concat2();
|
||||
lines = lines.toSingleLineWithHiddenNewLine();
|
||||
if (cmd.isForbidden(lines.getFirst499())) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
|
@ -53,14 +53,16 @@ public abstract class PSystemAbstractFactory implements PSystemFactory {
|
||||
}
|
||||
|
||||
final protected AbstractPSystem buildEmptyError(UmlSource source, LineLocation lineLocation) {
|
||||
final PSystemError result = new PSystemError(source, new ErrorUml(ErrorUmlType.SYNTAX_ERROR,
|
||||
"Empty description", 1, lineLocation), null);
|
||||
final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Empty description", /* 1, */lineLocation);
|
||||
final PSystemError result = new PSystemError(source, err, null);
|
||||
result.setSource(source);
|
||||
return result;
|
||||
}
|
||||
|
||||
final protected PSystemError buildEmptyError(UmlSource source, String err, LineLocation lineLocation) {
|
||||
final PSystemError result = new PSystemError(source, new ErrorUml(ErrorUmlType.EXECUTION_ERROR, err, 1, lineLocation), null);
|
||||
|
||||
final protected PSystemError buildExecutionError(UmlSource source, String stringError, LineLocation lineLocation) {
|
||||
final ErrorUml err = new ErrorUml(ErrorUmlType.EXECUTION_ERROR, stringError, /* 1, */
|
||||
lineLocation);
|
||||
final PSystemError result = new PSystemError(source, err, null);
|
||||
result.setSource(source);
|
||||
return result;
|
||||
}
|
||||
|
@ -88,8 +88,9 @@ public abstract class PSystemBasicFactory<P extends AbstractPSystem> extends PSy
|
||||
}
|
||||
system = executeLine(system, s.toString2());
|
||||
if (system == null) {
|
||||
return new PSystemError(source, new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?",
|
||||
it.currentNum() - 1, s.getLocation()), null);
|
||||
final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?",
|
||||
/* it.currentNum() - 1, */s.getLocation());
|
||||
return new PSystemError(source, err, null);
|
||||
}
|
||||
}
|
||||
if (system != null) {
|
||||
|
@ -78,8 +78,9 @@ public abstract class PSystemSingleLineFactory extends PSystemAbstractFactory {
|
||||
}
|
||||
final AbstractPSystem sys = executeLine(s.toString2());
|
||||
if (sys == null) {
|
||||
return new PSystemError(source, new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?",
|
||||
it.currentNum() - 1, s.getLocation()), null);
|
||||
final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?",
|
||||
/* it.currentNum() - 1, */s.getLocation());
|
||||
return new PSystemError(source, err, null);
|
||||
}
|
||||
sys.setSource(source);
|
||||
return sys;
|
||||
|
@ -91,7 +91,7 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
}
|
||||
final String err = sys.checkFinalError();
|
||||
if (err != null) {
|
||||
return buildEmptyError(source, err, it.peek().getLocation());
|
||||
return buildExecutionError(source, err, it.peek().getLocation());
|
||||
}
|
||||
if (source.getTotalLineCount() == 2) {
|
||||
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) {
|
||||
final CommandControl commandControl = isValid2(it);
|
||||
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());
|
||||
if (OptionFlags.getInstance().isUseSuggestEngine()) {
|
||||
final SuggestEngine engine = new SuggestEngine(source, this);
|
||||
@ -130,8 +130,9 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
final IteratorCounter2 saved = it.cloneMe();
|
||||
final CommandExecutionResult result = manageMultiline2(it, sys);
|
||||
if (result.isOk() == false) {
|
||||
sys = new PSystemError(source, new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(),
|
||||
it.currentNum() - 1, saved.next().getLocation()), null);
|
||||
final ErrorUml err = new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(),
|
||||
/* it.currentNum() - 1, */saved.next().getLocation());
|
||||
sys = new PSystemError(source, err, null);
|
||||
|
||||
}
|
||||
} else if (commandControl == CommandControl.OK) {
|
||||
@ -140,8 +141,10 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
Command cmd = getFirstCommandOkForLines(lines);
|
||||
final CommandExecutionResult result = sys.executeCommand(cmd, lines);
|
||||
if (result.isOk() == false) {
|
||||
sys = new PSystemError(source, new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(),
|
||||
it.currentNum() - 1, ((CharSequence2) line).getLocation()), result.getDebugLines());
|
||||
final ErrorUml err = new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(),
|
||||
/* it.currentNum() - 1, */((CharSequence2) line).getLocation());
|
||||
sys = new PSystemError(source, err,
|
||||
result.getDebugLines());
|
||||
}
|
||||
if (result.getNewDiagram() != null) {
|
||||
sys = result.getNewDiagram();
|
||||
|
@ -41,8 +41,10 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
import net.sourceforge.plantuml.CharSequence2;
|
||||
import net.sourceforge.plantuml.CharSequence2Impl;
|
||||
import net.sourceforge.plantuml.LineLocation;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.regex.Matcher2;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
@ -66,6 +68,9 @@ final public class UmlSource {
|
||||
final private List<String> source;
|
||||
final private List<CharSequence2> source2;
|
||||
|
||||
// final private int startLine;
|
||||
// final private LineLocation startLocation;
|
||||
|
||||
/**
|
||||
* Build the source from a text.
|
||||
*
|
||||
@ -73,8 +78,11 @@ final public class UmlSource {
|
||||
* the source of the diagram
|
||||
* @param checkEndingBackslash
|
||||
* <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<CharSequence2> tmp2 = new ArrayList<CharSequence2>();
|
||||
|
||||
@ -129,7 +137,7 @@ final public class UmlSource {
|
||||
for (String s : source) {
|
||||
sb.append(s);
|
||||
sb.append('\r');
|
||||
sb.append('\n');
|
||||
sb.append(BackSlash.CHAR_NEWLINE);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
@ -152,10 +160,22 @@ final public class UmlSource {
|
||||
* line number, starting at 0
|
||||
* @return
|
||||
*/
|
||||
public String getLine(int n) {
|
||||
private String getLine(int n) {
|
||||
if (n < 0 || n >= source.size()) {
|
||||
return "";
|
||||
}
|
||||
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.
|
||||
*
|
||||
@ -217,4 +237,8 @@ final public class UmlSource {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// public final int getStartLine() {
|
||||
// return startLine;
|
||||
// }
|
||||
}
|
||||
|
@ -42,11 +42,13 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||
import net.sourceforge.plantuml.LineBreakStrategy;
|
||||
import net.sourceforge.plantuml.Log;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||
@ -80,6 +82,15 @@ public class AtomText implements Atom {
|
||||
|
||||
public static Atom createUrl(Url url, FontConfiguration fontConfiguration) {
|
||||
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);
|
||||
}
|
||||
|
||||
@ -118,6 +129,9 @@ public class AtomText implements Atom {
|
||||
}
|
||||
|
||||
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.marginRight = marginRight;
|
||||
// this.text = StringUtils.showComparatorCharacters(StringUtils.manageBackslash(text));
|
||||
|
77
src/net/sourceforge/plantuml/creole/AtomTexts.java
Normal file
77
src/net/sourceforge/plantuml/creole/AtomTexts.java
Normal 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -35,6 +35,7 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.creole;
|
||||
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
import net.sourceforge.plantuml.ISkinSimple;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.regex.Matcher2;
|
||||
@ -54,6 +55,9 @@ public class CreoleStripeSimpleParser {
|
||||
|
||||
public CreoleStripeSimpleParser(String line, CreoleContext creoleContext, FontConfiguration fontConfiguration,
|
||||
ISkinSimple skinParam, CreoleMode modeSimpleLine) {
|
||||
if (line.contains("" + BackSlash.hiddenNewLine())) {
|
||||
throw new IllegalArgumentException(line);
|
||||
}
|
||||
this.fontConfiguration = fontConfiguration;
|
||||
this.modeSimpleLine = modeSimpleLine;
|
||||
this.skinParam = skinParam;
|
||||
|
@ -44,6 +44,8 @@ import java.util.List;
|
||||
import net.sourceforge.plantuml.AbstractPSystem;
|
||||
import net.sourceforge.plantuml.FileFormatOption;
|
||||
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.ImageData;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
@ -74,7 +76,7 @@ public class PSystemCreole extends AbstractPSystem {
|
||||
final Display display = Display.create(lines);
|
||||
final UFont font = UFont.serif(14);
|
||||
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);
|
||||
final SheetBlock1 sheetBlock = new SheetBlock1(sheet, LineBreakStrategy.NONE, 0);
|
||||
|
||||
|
@ -39,6 +39,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
import net.sourceforge.plantuml.ISkinSimple;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
@ -150,6 +151,9 @@ public class StripeSimple implements Stripe {
|
||||
if (line == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (line.contains("" + BackSlash.hiddenNewLine())) {
|
||||
throw new IllegalArgumentException(line);
|
||||
}
|
||||
line = CharHidder.hide(line);
|
||||
if (style.getType() == StripeStyleType.HEADING) {
|
||||
atoms.add(AtomText.createHeading(line, fontConfiguration, style.getOrder()));
|
||||
|
@ -40,6 +40,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
import net.sourceforge.plantuml.ISkinSimple;
|
||||
import net.sourceforge.plantuml.LineBreakStrategy;
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
@ -147,6 +148,9 @@ public class StripeTable implements Stripe {
|
||||
current.append(c);
|
||||
current.append(c2);
|
||||
}
|
||||
} else if (c == BackSlash.hiddenNewLine()) {
|
||||
result.add(current.toString());
|
||||
current.setLength(0);
|
||||
} else {
|
||||
current.append(c);
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.FileFormatOption;
|
||||
import net.sourceforge.plantuml.Log;
|
||||
@ -355,7 +356,7 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
|
||||
if (generalWarningOrError == null) {
|
||||
return warningOrError;
|
||||
}
|
||||
return generalWarningOrError + "\n" + warningOrError;
|
||||
return generalWarningOrError + BackSlash.NEWLINE + warningOrError;
|
||||
}
|
||||
|
||||
private void createFilesTxt(OutputStream os, int index, FileFormat fileFormat) throws IOException {
|
||||
|
@ -111,16 +111,16 @@ public class Display implements Iterable<CharSequence> {
|
||||
final List<String> result = new ArrayList<String>();
|
||||
final StringBuilder current = new StringBuilder();
|
||||
HorizontalAlignment naturalHorizontalAlignment = null;
|
||||
boolean mathMode = false;
|
||||
boolean rawMode = false;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
final char c = s.charAt(i);
|
||||
final String sub = s.substring(i);
|
||||
if (sub.startsWith("<math>") || sub.startsWith("<latex>")) {
|
||||
mathMode = true;
|
||||
} else if (sub.startsWith("</math>") || sub.startsWith("</latex>")) {
|
||||
mathMode = false;
|
||||
if (sub.startsWith("<math>") || sub.startsWith("<latex>") || sub.startsWith("[[")) {
|
||||
rawMode = true;
|
||||
} else if (sub.startsWith("</math>") || sub.startsWith("</latex>") || sub.startsWith("]]")) {
|
||||
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);
|
||||
i++;
|
||||
if (c2 == 'n' || c2 == 'r' || c2 == 'l') {
|
||||
|
@ -41,6 +41,7 @@ import java.io.OutputStream;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import net.sourceforge.plantuml.AbstractPSystem;
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.FileFormatOption;
|
||||
import net.sourceforge.plantuml.api.ImageDataSimple;
|
||||
@ -68,7 +69,7 @@ public class PSystemDitaa extends AbstractPSystem {
|
||||
}
|
||||
|
||||
PSystemDitaa add(String line) {
|
||||
return new PSystemDitaa(data + line + "\n", processingOptions.performSeparationOfCommonEdges(), dropShadows,
|
||||
return new PSystemDitaa(data + line + BackSlash.NEWLINE, processingOptions.performSeparationOfCommonEdges(), dropShadows,
|
||||
scale);
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@ import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import net.sourceforge.plantuml.AbstractPSystem;
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
import net.sourceforge.plantuml.FileFormatOption;
|
||||
import net.sourceforge.plantuml.code.Transcoder;
|
||||
import net.sourceforge.plantuml.code.TranscoderImpl;
|
||||
@ -65,17 +66,17 @@ import net.sourceforge.plantuml.version.PSystemVersion;
|
||||
public class PSystemDonors extends AbstractPSystem {
|
||||
|
||||
public static final String DONORS = "UDfbL4jksp0GtSyfk1RIGoXsujI_17QQ0jcDvR75c29Tad8ghuBUe421hdk3eaKMHOjiUW7bHXsvbKcb"
|
||||
+ "10oOudpUctapgKh-7R9mHPwiIBKtMc86rvI4OmeOct2r3jBM5HSmiE69AfZJ0fsNgCNKv1fIlJHM30pv"
|
||||
+ "FJL_LoksQCrHmnYZHDf3NxONgI0DeSqEvcM0KC509jsZ3GnRbAM3kQTjJbhqZDaoltwRXnoCYXUknaBF"
|
||||
+ "AAd5p9IEO5Y-U4_k31DfBri9amWr5l6LKwMAtgDUSZbxkUIeQxGLCvqTQUirJ6FqVW-NIkxOeI-p3IC_"
|
||||
+ "laWDP-uOMaSW4jf1Vrz8Roinnjmi4OPDqMzpvF2HNK8gj8lFfk8oQVHin_WOr_0lUDfqMEabNst6DJd7"
|
||||
+ "XQqsvjvj90TIx7PflTp3HR1U6fZ8B2SbJb6gAcQWzZ4Ovs18g5yDCNjNaXFzSc6HUwa2tnjpvodBnSYY"
|
||||
+ "mm1fJIpHg6FtZRBOH8pCJiP2EKZbJI0i4MQHU9iKCS_aZhstaQpCfgdCgR6eKMrFn2rvD5i7CoQ8TYb6"
|
||||
+ "icajd2jZctfFVlzIwj3q80WLYPFbD3xAoM9RxQRhUPUHWojivJ6J7S2facAEkEJHiMiIRqcloPw8INhz"
|
||||
+ "Ufu6QIT6mu0w8nCprnbBf10tZBhFeXq5IqjDPtbOnaHmjekLlqEOXY1Kj22JYCQWbAoBiY1nRahoeRwP"
|
||||
+ "W_EuCmSkGGrw7vUDuKxbcZKqbqKOGGR4axngAeqyrH7eH2ceFzMFKVZwiVu1lRmpsXKFNhauB0AhUHOk"
|
||||
+ "J0VEWCngPQaIKrbmuuRu_rQPuGgLc5HEyOpKN-h7vuVwUvDAr9_hf_fd_VJyWNyF_EaRd5dQYn6gWYVh"
|
||||
+ "8kvr8rTYlPwIQXvrr3RE8gEjc2Iy9BiiM60tz78f9QNYlT5IyJ0_17GUwe_rrsD961Zy0II4d1O0";
|
||||
+ "10oOud3clPdtcAhato8BL-J9YbHxeoLcS4r9MAQ0iGbRwo1jh-821ZOSKGLpMg3p4hMOcbn3gfV6Ye4X"
|
||||
+ "lwVcxsh54MquQXXZL4XxwCjs8nMa8RNPmRmC42eOoAIxj85XYx9qCFUqpKcBdZ5RvjTlwv23KV7Ygh7G"
|
||||
+ "CqfgCJEb8nYMBywJEyD4sirMmYH2ZKMyvLAfelUebzpENYuvwnfjnKndHzfw3TCOlT_3fP8xlj2NsOQH"
|
||||
+ "7q-aXZDtJAqZ40djeBylfBUL66DkbWZ3fkctENBwA2uX5SR5QrDncpHwZcDyZ6lu5pnjEgpqahSsuvwS"
|
||||
+ "uy9M6tFlDf8JARvsQRtSmqM8NXgOo2md9KvHgYfceFOn6ETWIAXV3J5xLv8J_N9XaMUf0jyRS-SfoyN8"
|
||||
+ "eiC0QKqiqMXYzusoE4ICp4x6GZb8vKqWB15caNYR4Z7Fv8vlRoDPcKtJcLDZKQFQdeXRycYs3cPC4ErI"
|
||||
+ "Z6GpMZXNnZRzdlp-fTHXw44GAX8dosbyb9F5jjlDrFCk8mTNsCfZ9Zk0KoN57779rh5h4cz9hycUY4bw"
|
||||
+ "_NgU1cadHiE0EfQ9cUkC9LA86qRTPz6EGgIbPh9ibZ4HdErYvUyGfY495It89A8nA2NheYn8d9kIVEXl"
|
||||
+ "vk0ydio1Ir23tiTjOxXJkMODpMKHBCY0sCchfjF8hev09qf1_Qb-ZDBNZ_KFwEKTQrTil79nU0YiPYzS"
|
||||
+ "c0wS0PdLob8bfhBWmGtn_rTbXYjKOb8vnHwflzIFpm_rzwQKg3_NJ_NF-kdv0_yU-DCtEBEq5oDK1Jlh"
|
||||
+ "8fvr8rTYlPwIQWvrD3Qk8gDNCKduaUooO87TqCj7AIaLlnij5G_pGqBdeVvOVpssX86nvqAUFuVhdim0";
|
||||
|
||||
@Override
|
||||
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 Transcoder t = new TranscoderImpl();
|
||||
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()) {
|
||||
lines.add(st.nextToken());
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.AbstractPSystem;
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
import net.sourceforge.plantuml.FileFormatOption;
|
||||
import net.sourceforge.plantuml.SpriteContainerEmpty;
|
||||
import net.sourceforge.plantuml.core.DiagramDescription;
|
||||
@ -176,7 +177,7 @@ public class PSystemColors extends AbstractPSystem implements UDrawable {
|
||||
if (Character.isLowerCase(colorName.charAt(i))) {
|
||||
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 double width = tt.calculateDimension(stringBounder).getWidth();
|
||||
if (width < min) {
|
||||
|
@ -41,6 +41,7 @@ import java.awt.image.BufferedImage;
|
||||
import java.util.Locale;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
import net.sourceforge.plantuml.Log;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorGradient;
|
||||
import net.sourceforge.plantuml.ugraphic.ColorMapper;
|
||||
@ -74,9 +75,9 @@ public class EpsGraphics {
|
||||
|
||||
public EpsGraphics() {
|
||||
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("%%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 2 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() {
|
||||
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("%%DocumentProcessColors: Black\n");
|
||||
header.append("%%ColorUsage: Color\n");
|
||||
@ -554,7 +555,7 @@ public class EpsGraphics {
|
||||
if (checkConsistence && s.indexOf(" ") != -1) {
|
||||
throw new IllegalArgumentException(s);
|
||||
}
|
||||
body.append(s + "\n");
|
||||
body.append(s + BackSlash.NEWLINE);
|
||||
}
|
||||
|
||||
final public void linetoNoMacro(double x1, double y1) {
|
||||
|
@ -232,7 +232,9 @@ public class QuoteUtils {
|
||||
"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",
|
||||
"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() {
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ public class Splitter {
|
||||
String s = cmd.getText();
|
||||
final Collection<Text> result = new ArrayList<Text>();
|
||||
while (true) {
|
||||
final int x = s.indexOf(Text.NEWLINE.getText());
|
||||
final int x = s.indexOf(Text.TEXT_BS_BS_N.getText());
|
||||
if (x == -1) {
|
||||
result.add(new Text(s));
|
||||
return result;
|
||||
@ -154,7 +154,7 @@ public class Splitter {
|
||||
if (x > 0) {
|
||||
result.add(new Text(s.substring(0, x)));
|
||||
}
|
||||
result.add(Text.NEWLINE);
|
||||
result.add(Text.TEXT_BS_BS_N);
|
||||
s = s.substring(x + 2);
|
||||
}
|
||||
}
|
||||
|
@ -35,15 +35,17 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.graphic;
|
||||
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
|
||||
public class Text implements HtmlCommand {
|
||||
|
||||
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) {
|
||||
this.text = text.replaceAll("\\\\\\[", "[").replaceAll("\\\\\\]", "]");
|
||||
if (text.indexOf('\n') != -1) {
|
||||
if (text.indexOf(BackSlash.CHAR_NEWLINE) != -1) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (text.length() == 0) {
|
||||
@ -57,6 +59,6 @@ public class Text implements HtmlCommand {
|
||||
}
|
||||
|
||||
public boolean isNewline() {
|
||||
return text.equals("\\n");
|
||||
return text.equals(BackSlash.BS_BS_N);
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.Properties;
|
||||
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
import net.sourceforge.plantuml.Log;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.PSystemBasicFactory;
|
||||
@ -112,7 +113,7 @@ public class PSystemJcckitFactory extends PSystemBasicFactory<PSystemJcckit> {
|
||||
return null;
|
||||
}
|
||||
data.append(StringUtils.trin(line));
|
||||
data.append("\n");
|
||||
data.append(BackSlash.NEWLINE);
|
||||
return createSystem();
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,7 @@ import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
import net.sourceforge.plantuml.SvgString;
|
||||
|
||||
public class AsciiMath implements ScientificEquation {
|
||||
@ -67,7 +68,7 @@ public class AsciiMath implements ScientificEquation {
|
||||
String s = null;
|
||||
while ((s = br.readLine()) != null) {
|
||||
sb.append(s);
|
||||
sb.append("\n");
|
||||
sb.append(BackSlash.NEWLINE);
|
||||
}
|
||||
br.close();
|
||||
JAVASCRIPT_CODE = sb.toString();
|
||||
|
@ -53,6 +53,7 @@ import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
@ -72,7 +73,7 @@ public class AsciiMathOld {
|
||||
String s = null;
|
||||
while ((s = br.readLine()) != null) {
|
||||
sb.append(s);
|
||||
sb.append("\n");
|
||||
sb.append(BackSlash.NEWLINE);
|
||||
}
|
||||
br.close();
|
||||
JAVASCRIPT_CODE = sb.toString();
|
||||
|
@ -46,9 +46,11 @@ public class Define {
|
||||
private final DefineSignature signature;
|
||||
private final String definition;
|
||||
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.emptyParentheses = emptyParentheses;
|
||||
if (lines == null) {
|
||||
this.definition = null;
|
||||
this.definitionQuoted = null;
|
||||
@ -79,7 +81,7 @@ public class Define {
|
||||
line = vars.applyOn(line, signature.getFonctionName(), definitionQuoted);
|
||||
}
|
||||
} else {
|
||||
final String regex = "\\b" + signature.getKey() + "\\b";
|
||||
final String regex = "\\b" + signature.getKey() + "\\b" + (emptyParentheses ? "(\\(\\))?" : "");
|
||||
line = BackSlash.translateBackSlashes(line);
|
||||
line = line.replaceAll(regex, definitionQuoted);
|
||||
line = BackSlash.untranslateBackSlashes(line);
|
||||
|
@ -47,6 +47,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.Log;
|
||||
import net.sourceforge.plantuml.api.ApiWarning;
|
||||
import net.sourceforge.plantuml.version.Version;
|
||||
|
||||
public class Defines implements Truth {
|
||||
|
||||
@ -57,6 +58,7 @@ public class Defines implements Truth {
|
||||
@Deprecated
|
||||
@ApiWarning(willBeRemoved = "in next major release")
|
||||
public Defines() {
|
||||
environment.put("PLANTUML_VERSION", "" + Version.versionString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -90,8 +92,8 @@ public class Defines implements Truth {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void define(String name, List<String> value) {
|
||||
values.put(name, new Define(name, value));
|
||||
public void define(String name, List<String> value, boolean emptyParentheses) {
|
||||
values.put(name, new Define(name, value, emptyParentheses));
|
||||
}
|
||||
|
||||
public boolean isDefine(String expression) {
|
||||
|
@ -41,10 +41,13 @@ import net.sourceforge.plantuml.CharSequence2;
|
||||
import net.sourceforge.plantuml.command.regex.Matcher2;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.command.regex.Pattern2;
|
||||
import net.sourceforge.plantuml.version.Version;
|
||||
|
||||
class IfManager implements ReadLine {
|
||||
|
||||
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 endifPattern = MyPattern.cmpile("^[%s]*!endif[%s]*$");
|
||||
|
||||
@ -76,7 +79,21 @@ class IfManager implements ReadLine {
|
||||
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()) {
|
||||
boolean ok = defines.isDefine(m.group(2));
|
||||
if (m.group(1) != null) {
|
||||
@ -93,6 +110,13 @@ class IfManager implements ReadLine {
|
||||
return s;
|
||||
}
|
||||
|
||||
private int getValue(final String arg) {
|
||||
if (arg.equalsIgnoreCase("PLANTUML_VERSION")) {
|
||||
return Version.versionPatched();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
source.close();
|
||||
}
|
||||
|
68
src/net/sourceforge/plantuml/preproc/NumericCompare.java
Normal file
68
src/net/sourceforge/plantuml/preproc/NumericCompare.java
Normal 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();
|
||||
}
|
||||
|
||||
}
|
@ -38,7 +38,6 @@ package net.sourceforge.plantuml.preproc;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -87,12 +86,12 @@ public class Preprocessor implements ReadLine {
|
||||
|
||||
Matcher2 m = definePattern.matcher(s);
|
||||
if (m.find()) {
|
||||
return manageDefine(m);
|
||||
return manageDefine(m, s.toString().trim().endsWith("()"));
|
||||
}
|
||||
|
||||
m = definelongPattern.matcher(s);
|
||||
if (m.find()) {
|
||||
return manageDefineLong(m);
|
||||
return manageDefineLong(m, s.toString().trim().endsWith("()"));
|
||||
}
|
||||
|
||||
m = undefPattern.matcher(s);
|
||||
@ -105,21 +104,38 @@ public class Preprocessor implements ReadLine {
|
||||
return s;
|
||||
}
|
||||
|
||||
final List<String> result = defines.applyDefines(s.toString2());
|
||||
List<String> result = defines.applyDefines(s.toString2());
|
||||
if (result.size() > 1) {
|
||||
final String last = result.get(result.size() - 1);
|
||||
final List<String> inserted = result.subList(1, result.size() - 1);
|
||||
assert last.startsWith(END_DEFINE_LONG);
|
||||
result = cleanEndDefineLong(result);
|
||||
final List<String> inserted = cleanEndDefineLong(result.subList(1, result.size()));
|
||||
ignoreDefineDuringSeveralLines = inserted.size();
|
||||
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());
|
||||
}
|
||||
|
||||
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 CharSequence2 manageUndef(Matcher2 m) throws IOException {
|
||||
@ -127,7 +143,7 @@ public class Preprocessor implements 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 List<String> def = new ArrayList<String>();
|
||||
while (true) {
|
||||
@ -137,21 +153,21 @@ public class Preprocessor implements ReadLine {
|
||||
}
|
||||
def.add(read.toString2());
|
||||
if (enddefinelongPattern.matcher(read).find()) {
|
||||
defines.define(group1, def);
|
||||
defines.define(group1, def, emptyParentheses);
|
||||
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 group2 = m.group(2);
|
||||
if (group2 == null) {
|
||||
defines.define(group1, null);
|
||||
defines.define(group1, null, emptyParentheses);
|
||||
} else {
|
||||
final List<String> strings = defines.applyDefines(group2);
|
||||
if (strings.size() > 1) {
|
||||
defines.define(group1, strings);
|
||||
defines.define(group1, strings, emptyParentheses);
|
||||
} else {
|
||||
final StringBuilder value = new StringBuilder(strings.get(0));
|
||||
while (StringUtils.endsWithBackslash(value.toString())) {
|
||||
@ -161,7 +177,7 @@ public class Preprocessor implements ReadLine {
|
||||
}
|
||||
final List<String> li = new ArrayList<String>();
|
||||
li.add(value.toString());
|
||||
defines.define(group1, li);
|
||||
defines.define(group1, li, emptyParentheses);
|
||||
}
|
||||
}
|
||||
return this.readLine();
|
||||
@ -178,5 +194,5 @@ public class Preprocessor implements ReadLine {
|
||||
public Set<FileWithSuffix> getFilesUsed() {
|
||||
return Collections.unmodifiableSet(rawSource.getFilesUsedGlobal());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -73,6 +73,7 @@ public class ReadLineReader implements ReadLine {
|
||||
s = s.substring(1);
|
||||
}
|
||||
s = s.replace('\u2013', '-');
|
||||
// s = BackSlash.convertHiddenNewLine(s);
|
||||
// s = s.replace('\u00A0', ' ');
|
||||
// s = s.replace('\u201c', '\"');
|
||||
// s = s.replace('\u201d', '\"');
|
||||
|
@ -42,6 +42,7 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import net.sourceforge.plantuml.AbstractPSystem;
|
||||
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||
import net.sourceforge.plantuml.EmptyImageBuilder;
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.FileFormatOption;
|
||||
@ -81,7 +82,7 @@ public class PSystemProject extends AbstractPSystem {
|
||||
final BufferedImage im = createImage(diagram);
|
||||
PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96);
|
||||
} 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());
|
||||
diagram.draw(svg, 0, 0);
|
||||
svg.createXml(os, fileFormatOption.isWithMetadata() ? getMetadata() : null);
|
||||
|
@ -42,6 +42,7 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import net.sourceforge.plantuml.AbstractPSystem;
|
||||
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||
import net.sourceforge.plantuml.EmptyImageBuilder;
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.FileFormatOption;
|
||||
@ -80,7 +81,7 @@ public class PSystemProject2 extends AbstractPSystem {
|
||||
final BufferedImage im = createImage(diagram);
|
||||
PngIO.write(im, os, fileFormatOption.isWithMetadata() ? getMetadata() : null, 96);
|
||||
} 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());
|
||||
diagram.draw(svg, 0, 0);
|
||||
svg.createXml(os, fileFormatOption.isWithMetadata() ? getMetadata() : null);
|
||||
|
@ -35,12 +35,15 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.sequencediagram;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.sourceforge.plantuml.ColorParam;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.SkinParamBackcolored;
|
||||
import net.sourceforge.plantuml.SpecificBackcolorable;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
|
||||
import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
import net.sourceforge.plantuml.graphic.SymbolContext;
|
||||
@ -56,8 +59,11 @@ public class Participant implements SpecificBackcolorable {
|
||||
private int initialLife = 0;
|
||||
|
||||
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) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
@ -82,10 +88,15 @@ public class Participant implements SpecificBackcolorable {
|
||||
}
|
||||
|
||||
public Display getDisplay(boolean underlined) {
|
||||
if (underlined) {
|
||||
return display.underlined();
|
||||
Display result = underlined ? display.underlined() : display;
|
||||
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() {
|
||||
@ -93,9 +104,6 @@ public class Participant implements SpecificBackcolorable {
|
||||
}
|
||||
|
||||
public final void setStereotype(Stereotype stereotype, boolean stereotypePositionTop) {
|
||||
// if (type == ParticipantType.ACTOR) {
|
||||
// return;
|
||||
// }
|
||||
if (this.stereotype != null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
@ -103,11 +111,7 @@ public class Participant implements SpecificBackcolorable {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
this.stereotype = stereotype;
|
||||
if (stereotypePositionTop) {
|
||||
display = display.addFirst(stereotype);
|
||||
} else {
|
||||
display = display.add(stereotype);
|
||||
}
|
||||
this.stereotypePositionTop = stereotypePositionTop;
|
||||
}
|
||||
|
||||
public final int getInitialLife() {
|
||||
|
@ -43,6 +43,7 @@ public enum ParticipantType {
|
||||
BOUNDARY(ColorParam.boundaryBackground), //
|
||||
CONTROL(ColorParam.controlBackground), //
|
||||
ENTITY(ColorParam.entityBackground), //
|
||||
QUEUE(ColorParam.queueBackground), //
|
||||
DATABASE(ColorParam.databaseBackground), //
|
||||
COLLECTIONS(ColorParam.collectionsBackground);
|
||||
|
||||
|
@ -40,10 +40,12 @@ import java.io.OutputStream;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Stack;
|
||||
|
||||
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.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
|
||||
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
import net.sourceforge.plantuml.graphic.SymbolContext;
|
||||
import net.sourceforge.plantuml.sequencediagram.graphic.FileMaker;
|
||||
@ -87,7 +90,7 @@ public class SequenceDiagram extends UmlDiagram {
|
||||
public Participant getOrCreateParticipant(String code, Display display) {
|
||||
Participant result = participants.get(code);
|
||||
if (result == null) {
|
||||
result = new Participant(ParticipantType.PARTICIPANT, code, display);
|
||||
result = new Participant(ParticipantType.PARTICIPANT, code, display, hiddenPortions);
|
||||
participants.put(code, result);
|
||||
participantEnglobers2.put(result, participantEnglober);
|
||||
}
|
||||
@ -108,7 +111,7 @@ public class SequenceDiagram extends UmlDiagram {
|
||||
// display = Arrays.asList(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);
|
||||
participantEnglobers2.put(result, participantEnglober);
|
||||
return result;
|
||||
@ -504,8 +507,7 @@ public class SequenceDiagram extends UmlDiagram {
|
||||
}
|
||||
return dpiFactor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String checkFinalError() {
|
||||
if (this.isHideUnlinkedData()) {
|
||||
@ -514,5 +516,14 @@ public class SequenceDiagram extends UmlDiagram {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -64,8 +64,8 @@ public abstract class CommandParticipant extends SingleLineCommand2<SequenceDiag
|
||||
}
|
||||
|
||||
static IRegex getRegexType() {
|
||||
return new RegexOr(new RegexLeaf("TYPE", "(participant|actor|create|boundary|control|entity|database|collections)"), //
|
||||
new RegexLeaf("CREATE", "create[%s](participant|actor|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|queue|database|collections)"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -599,6 +599,9 @@ class DrawableSetInitializer {
|
||||
} else if (p.getType() == ParticipantType.ENTITY) {
|
||||
headType = ComponentType.ENTITY_HEAD;
|
||||
tailType = ComponentType.ENTITY_TAIL;
|
||||
} else if (p.getType() == ParticipantType.QUEUE) {
|
||||
headType = ComponentType.QUEUE_HEAD;
|
||||
tailType = ComponentType.QUEUE_TAIL;
|
||||
} else if (p.getType() == ParticipantType.DATABASE) {
|
||||
headType = ComponentType.DATABASE_HEAD;
|
||||
tailType = ComponentType.DATABASE_TAIL;
|
||||
|
@ -127,9 +127,15 @@ public class LivingSpace {
|
||||
} else if (p.getType() == ParticipantType.ENTITY) {
|
||||
headType = ComponentType.ENTITY_HEAD;
|
||||
tailType = ComponentType.ENTITY_TAIL;
|
||||
} else if (p.getType() == ParticipantType.QUEUE) {
|
||||
headType = ComponentType.QUEUE_HEAD;
|
||||
tailType = ComponentType.QUEUE_TAIL;
|
||||
} else if (p.getType() == ParticipantType.DATABASE) {
|
||||
headType = ComponentType.DATABASE_HEAD;
|
||||
tailType = ComponentType.DATABASE_TAIL;
|
||||
} else if (p.getType() == ParticipantType.COLLECTIONS) {
|
||||
headType = ComponentType.COLLECTIONS_HEAD;
|
||||
tailType = ComponentType.COLLECTIONS_TAIL;
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ public enum ComponentType {
|
||||
BOUNDARY_HEAD, BOUNDARY_TAIL,
|
||||
CONTROL_HEAD, CONTROL_TAIL,
|
||||
ENTITY_HEAD, ENTITY_TAIL,
|
||||
QUEUE_HEAD, QUEUE_TAIL,
|
||||
DATABASE_HEAD, DATABASE_TAIL,
|
||||
COLLECTIONS_HEAD, COLLECTIONS_TAIL,
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -92,40 +92,44 @@ public class Rose implements Skin {
|
||||
// final FontConfiguration fc = new FontConfiguration(fontArrow, HtmlColorUtils.BLACK);
|
||||
// stringsToDisplay = DisplayUtils.breakLines(stringsToDisplay, fc, param, param.maxMessageSize());
|
||||
// }
|
||||
final HtmlColor sequenceArrow = config.getColor() == null ? getHtmlColor(param, ColorParam.arrow)
|
||||
: config.getColor();
|
||||
final HtmlColor sequenceArrow = config.getColor() == null ? getHtmlColor(param, ColorParam.arrow) : config
|
||||
.getColor();
|
||||
if (config.getArrowDirection() == ArrowDirection.SELF) {
|
||||
return new ComponentRoseSelfArrow(sequenceArrow, getUFont2(param, FontParam.ARROW),
|
||||
stringsToDisplay, config, param, param.maxMessageSize(), param.strictUmlStyle() == false);
|
||||
return new ComponentRoseSelfArrow(sequenceArrow, getUFont2(param, FontParam.ARROW), stringsToDisplay,
|
||||
config, param, param.maxMessageSize(), param.strictUmlStyle() == false);
|
||||
}
|
||||
final HorizontalAlignment messageHorizontalAlignment = param.getHorizontalAlignment(
|
||||
AlignParam.SEQUENCE_MESSAGE_ALIGN, config.getArrowDirection());
|
||||
final HorizontalAlignment textHorizontalAlignment = param.getHorizontalAlignment(
|
||||
AlignParam.SEQUENCE_MESSAGETEXT_ALIGN, config.getArrowDirection());
|
||||
return new ComponentRoseArrow(sequenceArrow, getUFont2(param, FontParam.ARROW), stringsToDisplay,
|
||||
config, messageHorizontalAlignment, param, textHorizontalAlignment, param.maxMessageSize(),
|
||||
return new ComponentRoseArrow(sequenceArrow, getUFont2(param, FontParam.ARROW), stringsToDisplay, config,
|
||||
messageHorizontalAlignment, param, textHorizontalAlignment, param.maxMessageSize(),
|
||||
param.strictUmlStyle() == false);
|
||||
}
|
||||
final double padding = param.getPadding(PaddingParam.PARTICIPANT);
|
||||
if (type == ComponentType.PARTICIPANT_HEAD) {
|
||||
return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param,
|
||||
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null), newFontForStereotype,
|
||||
getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), false, padding);
|
||||
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null),
|
||||
newFontForStereotype, getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(),
|
||||
false, padding);
|
||||
}
|
||||
if (type == ComponentType.PARTICIPANT_TAIL) {
|
||||
return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param,
|
||||
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null), newFontForStereotype,
|
||||
getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), false, padding);
|
||||
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null),
|
||||
newFontForStereotype, getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(),
|
||||
false, padding);
|
||||
}
|
||||
if (type == ComponentType.COLLECTIONS_HEAD) {
|
||||
return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param,
|
||||
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null), newFontForStereotype,
|
||||
getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), true, padding);
|
||||
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null),
|
||||
newFontForStereotype, getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(),
|
||||
true, padding);
|
||||
}
|
||||
if (type == ComponentType.COLLECTIONS_TAIL) {
|
||||
return new ComponentRoseParticipant(getSymbolContext(param, ColorParam.participantBorder), getUFont2(param,
|
||||
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null), newFontForStereotype,
|
||||
getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(), true, padding);
|
||||
FontParam.PARTICIPANT), stringsToDisplay, param, param.getRoundCorner("", null),
|
||||
newFontForStereotype, getFontColor(param, FontParam.SEQUENCE_STEREOTYPE), param.minClassWidth(),
|
||||
true, padding);
|
||||
}
|
||||
if (type == ComponentType.PARTICIPANT_LINE) {
|
||||
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.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) {
|
||||
return new ComponentRoseDatabase(getSymbolContext(param, ColorParam.databaseBorder), getUFont2(param,
|
||||
FontParam.ACTOR), stringsToDisplay, true, param, newFontForStereotype, getFontColor(param,
|
||||
|
@ -40,6 +40,7 @@ import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
import net.sourceforge.plantuml.stats.api.Stats;
|
||||
import net.sourceforge.plantuml.stats.api.StatsColumn;
|
||||
import net.sourceforge.plantuml.stats.api.StatsLine;
|
||||
@ -134,7 +135,7 @@ public class HtmlConverter {
|
||||
sb.append("<tr bgcolor=#e0e0e0>");
|
||||
for (StatsColumn col : headers) {
|
||||
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("</tr>");
|
||||
|
@ -51,6 +51,7 @@ import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
import net.sourceforge.plantuml.stats.api.Stats;
|
||||
import net.sourceforge.plantuml.stats.api.StatsColumn;
|
||||
import net.sourceforge.plantuml.stats.api.StatsLine;
|
||||
@ -212,7 +213,7 @@ public class XmlConverter {
|
||||
sb.append("<tr bgcolor=#e0e0e0>");
|
||||
for (StatsColumn col : headers) {
|
||||
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("</tr>");
|
||||
|
@ -53,6 +53,7 @@ import net.sourceforge.plantuml.Dimension2DDouble;
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.LineParam;
|
||||
import net.sourceforge.plantuml.OptionFlags;
|
||||
import net.sourceforge.plantuml.SkinParamUtils;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.UmlDiagramType;
|
||||
@ -564,7 +565,7 @@ public class Cluster implements Moveable {
|
||||
added = true;
|
||||
}
|
||||
|
||||
if (dotMode != DotMode.NO_LEFT_RIGHT_AND_XLABEL) {
|
||||
if (skinParam.useRankSame() && dotMode != DotMode.NO_LEFT_RIGHT_AND_XLABEL) {
|
||||
appendRankSame(sb, lines);
|
||||
}
|
||||
|
||||
|
@ -143,19 +143,7 @@ public final class GroupPngMakerState {
|
||||
final Stereotype stereo = group.getStereotype();
|
||||
final HtmlColor backColor = group.getColors(skinParam).getColor(ColorType.BACK) == null ? getColor(
|
||||
ColorParam.stateBackground, stereo) : group.getColors(skinParam).getColor(ColorType.BACK);
|
||||
final List<String> details = ((IEntity) group).getBodier().getRawBody();
|
||||
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 TextBlockWidth attribute = getAttributes(skinParam);
|
||||
|
||||
final Stereotype stereotype = group.getStereotype();
|
||||
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) {
|
||||
final List<IEntityImage> inners = new ArrayList<IEntityImage>();
|
||||
for (ILeaf inner : dotData.getLeafs()) {
|
||||
|
@ -85,7 +85,9 @@ import net.sourceforge.plantuml.svek.image.EntityImageNoteLink;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UComment;
|
||||
import net.sourceforge.plantuml.ugraphic.UEllipse;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.ULine;
|
||||
import net.sourceforge.plantuml.ugraphic.UPolygon;
|
||||
import net.sourceforge.plantuml.ugraphic.UShape;
|
||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
@ -130,6 +132,7 @@ public class Line implements Moveable, Hideable {
|
||||
|
||||
private final Pragma pragma;
|
||||
private final HtmlColor backgroundColor;
|
||||
private final boolean useRankSame;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@ -211,6 +214,7 @@ public class Line implements Moveable, Hideable {
|
||||
if (link == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
this.useRankSame = skinParam.useRankSame();
|
||||
this.startUid = link.getEntityPort1(bibliotekon);
|
||||
this.endUid = link.getEntityPort2(bibliotekon);
|
||||
|
||||
@ -338,7 +342,7 @@ public class Line implements Moveable, Hideable {
|
||||
sb.append("[");
|
||||
final LinkType linkType = link.getTypePatchCluster();
|
||||
String decoration = linkType.getSpecificDecorationSvek();
|
||||
if (decoration.endsWith(",") == false) {
|
||||
if (decoration.length() > 0 && decoration.endsWith(",") == false) {
|
||||
decoration += ",";
|
||||
}
|
||||
sb.append(decoration);
|
||||
@ -347,11 +351,16 @@ public class Line implements Moveable, Hideable {
|
||||
// if (graphvizVersion == GraphvizVersion.V2_34_0 && length == 1) {
|
||||
// length = 2;
|
||||
// }
|
||||
if (pragma.horizontalLineBetweenDifferentPackageAllowed() || link.isInvis() || length != 1) {
|
||||
// if (graphvizVersion.isJs() == false) {
|
||||
if (useRankSame) {
|
||||
if (pragma.horizontalLineBetweenDifferentPackageAllowed() || link.isInvis() || length != 1) {
|
||||
// if (graphvizVersion.isJs() == false) {
|
||||
sb.append("minlen=" + (length - 1));
|
||||
sb.append(",");
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
sb.append("minlen=" + (length - 1));
|
||||
sb.append(",");
|
||||
// }
|
||||
}
|
||||
sb.append("color=\"" + StringUtils.getAsHtml(lineColor) + "\"");
|
||||
if (labelText != null) {
|
||||
@ -446,8 +455,8 @@ public class Line implements Moveable, Hideable {
|
||||
return endUid.getPrefix();
|
||||
}
|
||||
|
||||
private UDrawable getExtremity(LinkDecor decor, PointListIterator pointListIterator, Point2D center, double angle,
|
||||
Cluster cluster, Shape shapeContact) {
|
||||
private UDrawable getExtremity(LinkDecor decor, PointListIterator pointListIterator, final Point2D center,
|
||||
double angle, Cluster cluster, Shape shapeContact) {
|
||||
final ExtremityFactory extremityFactory = decor.getExtremityFactory(backgroundColor);
|
||||
|
||||
if (cluster != null) {
|
||||
@ -464,7 +473,7 @@ public class Line implements Moveable, Hideable {
|
||||
if (extremityFactory != null) {
|
||||
final List<Point2D.Double> points = pointListIterator.next();
|
||||
if (points.size() == 0) {
|
||||
return null;
|
||||
return extremityFactory.createUDrawable(center, angle, null);
|
||||
}
|
||||
final Point2D p0 = points.get(0);
|
||||
final Point2D p1 = points.get(1);
|
||||
@ -474,6 +483,18 @@ public class Line implements Moveable, Hideable {
|
||||
side = shapeContact.getClusterPosition().getClosestSide(p1);
|
||||
}
|
||||
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) {
|
||||
final UShape sh = new UPolygon(pointListIterator.next());
|
||||
return new UDrawable() {
|
||||
@ -491,7 +512,7 @@ public class Line implements Moveable, Hideable {
|
||||
return;
|
||||
}
|
||||
|
||||
int idx = getIndexFromColor(svg, this.lineColor);
|
||||
int idx = SvekUtils.getIndexFromColor(svg, this.lineColor);
|
||||
if (idx == -1) {
|
||||
return;
|
||||
// throw new IllegalStateException();
|
||||
@ -519,7 +540,7 @@ public class Line implements Moveable, Hideable {
|
||||
}
|
||||
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();
|
||||
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 dist2end = p2.distance(dotPath.getEndPoint());
|
||||
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(),
|
||||
dotPath.getEndAngle(), lhead, bibliotekon.getShape(link.getEntity2()));
|
||||
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) {
|
||||
final int idx = getIndexFromColor(svg, color);
|
||||
final int idx = SvekUtils.getIndexFromColor(svg, color);
|
||||
if (idx == -1) {
|
||||
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) {
|
||||
if (opale) {
|
||||
return;
|
||||
|
@ -48,6 +48,7 @@ import java.util.Locale;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import net.sourceforge.plantuml.Log;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class SvekUtils {
|
||||
|
||||
@ -70,7 +71,22 @@ public class SvekUtils {
|
||||
private final double yDelta;
|
||||
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.yDelta = yDelta;
|
||||
}
|
||||
@ -80,6 +96,9 @@ public class SvekUtils {
|
||||
}
|
||||
|
||||
public List<Point2D.Double> next() {
|
||||
if (pos == -1) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
try {
|
||||
final List<Point2D.Double> result = extractPointsList(text, pos, yDelta);
|
||||
pos = text.indexOf(pointsString, pos) + pointsString.length() + 1;
|
||||
@ -114,6 +133,27 @@ public class SvekUtils {
|
||||
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) {
|
||||
final String varNameString = varName + "=\"";
|
||||
int p1 = svg.indexOf(varNameString, starting);
|
||||
@ -171,16 +211,20 @@ public class SvekUtils {
|
||||
}
|
||||
|
||||
static private List<Point2D.Double> getPoints(String points, double yDelta) {
|
||||
final List<Point2D.Double> result = new ArrayList<Point2D.Double>();
|
||||
final StringTokenizer st = new StringTokenizer(points, " MC");
|
||||
while (st.hasMoreTokens()) {
|
||||
final String t = st.nextToken();
|
||||
final StringTokenizer st2 = new StringTokenizer(t, ",");
|
||||
final double x = Double.parseDouble(st2.nextToken());
|
||||
final double y = Double.parseDouble(st2.nextToken()) + yDelta;
|
||||
result.add(new Point2D.Double(x, y));
|
||||
try {
|
||||
final List<Point2D.Double> result = new ArrayList<Point2D.Double>();
|
||||
final StringTokenizer st = new StringTokenizer(points, " MC");
|
||||
while (st.hasMoreTokens()) {
|
||||
final String t = st.nextToken();
|
||||
final StringTokenizer st2 = new StringTokenizer(t, ",");
|
||||
final double x = Double.parseDouble(st2.nextToken());
|
||||
final double y = Double.parseDouble(st2.nextToken()) + yDelta;
|
||||
result.add(new Point2D.Double(x, y));
|
||||
}
|
||||
return result;
|
||||
} catch (NumberFormatException e) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void println(StringBuilder sb) {
|
||||
|
@ -44,6 +44,11 @@ import net.sourceforge.plantuml.svek.Side;
|
||||
|
||||
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) {
|
||||
final double ortho = atan2(p0, p2);
|
||||
if (OptionFlags.USE_INTERFACE_EYE2) {
|
||||
|
@ -61,7 +61,6 @@ import net.sourceforge.plantuml.graphic.USymbol;
|
||||
import net.sourceforge.plantuml.graphic.USymbolFolder;
|
||||
import net.sourceforge.plantuml.graphic.color.ColorType;
|
||||
import net.sourceforge.plantuml.svek.AbstractEntityImage;
|
||||
import net.sourceforge.plantuml.svek.Bibliotekon;
|
||||
import net.sourceforge.plantuml.svek.Margins;
|
||||
import net.sourceforge.plantuml.svek.ShapeType;
|
||||
import net.sourceforge.plantuml.ugraphic.UComment;
|
||||
@ -85,10 +84,12 @@ public class EntityImageDescription extends AbstractEntityImage {
|
||||
|
||||
private final boolean hideText;
|
||||
private final Collection<Link> links;
|
||||
private final boolean useRankSame;
|
||||
|
||||
public EntityImageDescription(ILeaf entity, ISkinParam skinParam, PortionShower portionShower,
|
||||
Collection<Link> links) {
|
||||
super(entity, entity.getColors(skinParam).mute(skinParam));
|
||||
this.useRankSame = skinParam.useRankSame();
|
||||
this.links = links;
|
||||
final Stereotype stereotype = entity.getStereotype();
|
||||
USymbol symbol = getUSymbol(entity);
|
||||
@ -161,7 +162,7 @@ public class EntityImageDescription extends AbstractEntityImage {
|
||||
|
||||
@Override
|
||||
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 dimDesc = desc.calculateDimension(stringBounder);
|
||||
final Dimension2D dimSmall = asSmall.calculateDimension(stringBounder);
|
||||
@ -175,7 +176,7 @@ public class EntityImageDescription extends AbstractEntityImage {
|
||||
}
|
||||
return Margins.NONE;
|
||||
}
|
||||
|
||||
|
||||
private boolean hasSomeHorizontalLink(ILeaf leaf, Collection<Link> links) {
|
||||
for (Link link : links) {
|
||||
if (link.getLength() == 1 && link.contains(leaf)) {
|
||||
@ -185,8 +186,6 @@ public class EntityImageDescription extends AbstractEntityImage {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
final public void drawU(UGraphic ug) {
|
||||
ug.draw(new UComment("entity " + getEntity().getCode().getFullName()));
|
||||
if (url != null) {
|
||||
|
@ -40,6 +40,7 @@ import java.awt.geom.Dimension2D;
|
||||
import net.sourceforge.plantuml.ColorParam;
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.LineParam;
|
||||
import net.sourceforge.plantuml.SkinParamUtils;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.creole.Stencil;
|
||||
@ -72,8 +73,6 @@ public class EntityImageUseCase extends AbstractEntityImage {
|
||||
|
||||
final private Url url;
|
||||
|
||||
static private final UStroke stroke = new UStroke(1.5);
|
||||
|
||||
public EntityImageUseCase(ILeaf entity, ISkinParam skinParam) {
|
||||
super(entity, skinParam);
|
||||
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) {
|
||||
return new TextBlockInEllipse(desc, stringBounder).calculateDimension(stringBounder);
|
||||
}
|
||||
@ -108,7 +116,7 @@ public class EntityImageUseCase extends AbstractEntityImage {
|
||||
ug.startUrl(url);
|
||||
}
|
||||
|
||||
ug = ug.apply(stroke);
|
||||
ug = ug.apply(getStroke());
|
||||
HtmlColor linecolor = getEntity().getColors(getSkinParam()).getColor(ColorType.LINE);
|
||||
if (linecolor == null) {
|
||||
linecolor = SkinParamUtils.getColor(getSkinParam(), ColorParam.usecaseBorder, getStereo());
|
||||
@ -185,6 +193,7 @@ public class EntityImageUseCase extends AbstractEntityImage {
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.svg;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -44,7 +45,6 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
@ -116,15 +116,16 @@ public class SvgGraphics {
|
||||
}
|
||||
}
|
||||
|
||||
public SvgGraphics(double scale, String hover, long seed) {
|
||||
this(null, scale, hover, seed);
|
||||
public SvgGraphics(Dimension2D minDim, double scale, String hover, long 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 {
|
||||
this.scale = scale;
|
||||
this.document = getDocument();
|
||||
this.backcolor = backcolor;
|
||||
ensureVisible(minDim.getWidth(), minDim.getHeight());
|
||||
|
||||
this.root = getRootNode();
|
||||
|
||||
|
@ -153,6 +153,7 @@ public class LanguageDescriptor {
|
||||
preproc.add("!pragma");
|
||||
preproc.add("!define");
|
||||
preproc.add("!undef");
|
||||
preproc.add("!if");
|
||||
preproc.add("!ifdef");
|
||||
preproc.add("!endif");
|
||||
preproc.add("!ifndef");
|
||||
|
@ -39,8 +39,11 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
import net.sourceforge.plantuml.BlockUml;
|
||||
import net.sourceforge.plantuml.ErrorUml;
|
||||
import net.sourceforge.plantuml.LineLocation;
|
||||
import net.sourceforge.plantuml.LineLocationImpl;
|
||||
import net.sourceforge.plantuml.OptionFlags;
|
||||
import net.sourceforge.plantuml.PSystemError;
|
||||
import net.sourceforge.plantuml.SourceStringReader;
|
||||
@ -54,7 +57,7 @@ public class SyntaxChecker {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (String s : source) {
|
||||
sb.append(s);
|
||||
sb.append("\n");
|
||||
sb.append(BackSlash.NEWLINE);
|
||||
}
|
||||
return checkSyntax(sb.toString());
|
||||
}
|
||||
@ -65,14 +68,16 @@ public class SyntaxChecker {
|
||||
|
||||
if (source.startsWith("@startuml\n") == false) {
|
||||
result.setError(true);
|
||||
result.setErrorLinePosition(0);
|
||||
result.setLineLocation(new LineLocationImpl(null, null).oneLineRead());
|
||||
// result.setErrorLinePosition(0);
|
||||
result.addErrorText("No @startuml found");
|
||||
result.setSuggest(Arrays.asList("Did you mean:", "@startuml"));
|
||||
return result;
|
||||
}
|
||||
if (source.endsWith("@enduml\n") == false && source.endsWith("@enduml") == false) {
|
||||
result.setError(true);
|
||||
result.setErrorLinePosition(lastLineNumber(source));
|
||||
result.setLineLocation(lastLineNumber2(source));
|
||||
// result.setErrorLinePosition(lastLineNumber(source));
|
||||
result.addErrorText("No @enduml found");
|
||||
result.setSuggest(Arrays.asList("Did you mean:", "@enduml"));
|
||||
return result;
|
||||
@ -83,7 +88,8 @@ public class SyntaxChecker {
|
||||
final List<BlockUml> blocks = sourceStringReader.getBlocks();
|
||||
if (blocks.size() == 0) {
|
||||
result.setError(true);
|
||||
result.setErrorLinePosition(lastLineNumber(source));
|
||||
result.setLineLocation(lastLineNumber2(source));
|
||||
// result.setErrorLinePosition(lastLineNumber(source));
|
||||
result.addErrorText("No @enduml found");
|
||||
result.setSuggest(Arrays.asList("Did you mean:", "@enduml"));
|
||||
return result;
|
||||
@ -96,7 +102,7 @@ public class SyntaxChecker {
|
||||
} else if (system instanceof PSystemError) {
|
||||
result.setError(true);
|
||||
final PSystemError sys = (PSystemError) system;
|
||||
result.setErrorLinePosition(sys.getHigherErrorPosition());
|
||||
// result.setErrorLinePosition(sys.getHigherErrorPosition());
|
||||
result.setLineLocation(sys.getLineLocation());
|
||||
result.setSystemError(sys);
|
||||
for (ErrorUml er : sys.getErrorsUml()) {
|
||||
@ -117,7 +123,7 @@ public class SyntaxChecker {
|
||||
final List<BlockUml> blocks = sourceStringReader.getBlocks();
|
||||
if (blocks.size() == 0) {
|
||||
result.setError(true);
|
||||
result.setErrorLinePosition(lastLineNumber(source));
|
||||
result.setLineLocation(lastLineNumber2(source));
|
||||
result.addErrorText("No @enduml found");
|
||||
result.setSuggest(Arrays.asList("Did you mean:", "@enduml"));
|
||||
return result;
|
||||
@ -131,7 +137,7 @@ public class SyntaxChecker {
|
||||
} else if (system instanceof PSystemError) {
|
||||
result.setError(true);
|
||||
final PSystemError sys = (PSystemError) system;
|
||||
result.setErrorLinePosition(sys.getHigherErrorPosition());
|
||||
// result.setErrorLinePosition(sys.getHigherErrorPosition());
|
||||
result.setLineLocation(sys.getLineLocation());
|
||||
for (ErrorUml er : sys.getErrorsUml()) {
|
||||
result.addErrorText(er.getError());
|
||||
@ -153,4 +159,14 @@ public class SyntaxChecker {
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class SyntaxResult {
|
||||
private UmlDiagramType umlDiagramType;
|
||||
private boolean isError;
|
||||
private String description;
|
||||
private int errorLinePosition;
|
||||
// private int errorLinePosition;
|
||||
private Collection<String> errors = new TreeSet<String>();
|
||||
private List<String> suggest;
|
||||
private boolean hasCmapData;
|
||||
@ -71,9 +71,9 @@ public class SyntaxResult {
|
||||
return description;
|
||||
}
|
||||
|
||||
public int getErrorLinePosition() {
|
||||
return errorLinePosition;
|
||||
}
|
||||
// public int getErrorLinePosition() {
|
||||
// return errorLinePosition;
|
||||
// }
|
||||
|
||||
public List<String> getSuggest() {
|
||||
return suggest;
|
||||
@ -95,9 +95,9 @@ public class SyntaxResult {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setErrorLinePosition(int errorLinePosition) {
|
||||
this.errorLinePosition = errorLinePosition;
|
||||
}
|
||||
// public void setErrorLinePosition(int errorLinePosition) {
|
||||
// this.errorLinePosition = errorLinePosition;
|
||||
// }
|
||||
|
||||
public void addErrorText(String error) {
|
||||
this.errors.add(error);
|
||||
|
@ -40,23 +40,23 @@ import java.util.Map;
|
||||
|
||||
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>>();
|
||||
|
||||
public AbstractUGraphic(ColorMapper colorMapper, O g2d) {
|
||||
public AbstractUGraphic(ColorMapper colorMapper, O graphic) {
|
||||
super(colorMapper);
|
||||
this.g2d = g2d;
|
||||
this.graphic = graphic;
|
||||
}
|
||||
|
||||
protected AbstractUGraphic(AbstractUGraphic<O> other) {
|
||||
super(other);
|
||||
this.g2d = other.g2d;
|
||||
this.graphic = other.graphic;
|
||||
// this.drivers.putAll(other.drivers);
|
||||
}
|
||||
|
||||
protected final O getGraphicObject() {
|
||||
return g2d;
|
||||
return graphic;
|
||||
}
|
||||
|
||||
protected boolean manageHiddenAutomatically() {
|
||||
@ -86,9 +86,9 @@ public abstract class AbstractUGraphic<O> extends AbstractCommonUGraphic {
|
||||
if (shape instanceof Scalable) {
|
||||
final double scale = getParam().getScale();
|
||||
shape = ((Scalable) shape).getScaled(scale);
|
||||
driver.draw(shape, getTranslateX(), getTranslateY(), getColorMapper(), getParam(), g2d);
|
||||
driver.draw(shape, getTranslateX(), getTranslateY(), getColorMapper(), getParam(), graphic);
|
||||
} else {
|
||||
driver.draw(shape, getTranslateX(), getTranslateY(), getColorMapper(), getParam(), g2d);
|
||||
driver.draw(shape, getTranslateX(), getTranslateY(), getColorMapper(), getParam(), graphic);
|
||||
}
|
||||
afterDraw();
|
||||
}
|
||||
|
@ -54,6 +54,7 @@ import java.util.Set;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
import net.sourceforge.plantuml.FileFormatOption;
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
@ -157,7 +158,7 @@ public class FontChecker {
|
||||
}
|
||||
|
||||
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.svgImage(getBufferedImage(c), 0, 0);
|
||||
final ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||
|
@ -394,11 +394,11 @@ public class ImageBuilder {
|
||||
}
|
||||
final UGraphicSvg ug;
|
||||
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)) {
|
||||
ug = new UGraphicSvg(colorMapper, false, scale, svgLinkTarget, hover, seed);
|
||||
ug = new UGraphicSvg(dim, colorMapper, false, scale, svgLinkTarget, hover, seed);
|
||||
} 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);
|
||||
}
|
||||
return ug;
|
||||
|
@ -62,7 +62,8 @@ public abstract class UGraphicUtils {
|
||||
final BufferedImage im = createImage(colorMapper, background, image);
|
||||
PngIO.write(im, os, fileFormatOption.isWithMetadata() ? metadata : null, 96);
|
||||
} 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(),
|
||||
fileFormatOption.getHoverColor(), seed);
|
||||
image.drawU(svg);
|
||||
@ -81,16 +82,12 @@ public abstract class UGraphicUtils {
|
||||
}
|
||||
|
||||
private static BufferedImage createImage(ColorMapper colorMapper, HtmlColor background, TextBlock image) {
|
||||
EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, colorMapper.getMappedColor(background));
|
||||
Graphics2D g2d = builder.getGraphics2D();
|
||||
final Dimension2D size = computeSize(colorMapper, background, image);
|
||||
|
||||
final UGraphicG2d tmp = new UGraphicG2d(colorMapper, g2d, 1.0);
|
||||
final Dimension2D size = image.calculateDimension(tmp.getStringBounder());
|
||||
g2d.dispose();
|
||||
|
||||
builder = new EmptyImageBuilder(size.getWidth(), size.getHeight(), colorMapper.getMappedColor(background));
|
||||
final EmptyImageBuilder builder = new EmptyImageBuilder(size.getWidth(), size.getHeight(),
|
||||
colorMapper.getMappedColor(background));
|
||||
final BufferedImage im = builder.getBufferedImage();
|
||||
g2d = builder.getGraphics2D();
|
||||
final Graphics2D g2d = builder.getGraphics2D();
|
||||
|
||||
final UGraphicG2d ug = new UGraphicG2d(colorMapper, g2d, 1.0);
|
||||
image.drawU(ug);
|
||||
@ -98,22 +95,14 @@ public abstract class UGraphicUtils {
|
||||
return im;
|
||||
}
|
||||
|
||||
// public static void writeImage(OutputStream os, UGraphic ug, String metadata, int dpi) throws IOException {
|
||||
// if (ug instanceof UGraphicG2d) {
|
||||
// final BufferedImage im = ((UGraphicG2d) ug).getBufferedImage();
|
||||
// PngIO.write(im, os, metadata, dpi);
|
||||
// } else if (ug instanceof UGraphicSvg) {
|
||||
// final UGraphicSvg svg = (UGraphicSvg) ug;
|
||||
// svg.createXml(os);
|
||||
// } else if (ug instanceof UGraphicEps) {
|
||||
// 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();
|
||||
// }
|
||||
// }
|
||||
private static Dimension2D computeSize(ColorMapper colorMapper, HtmlColor background, TextBlock image) {
|
||||
final EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, colorMapper.getMappedColor(background));
|
||||
final Graphics2D g2d = builder.getGraphics2D();
|
||||
|
||||
final UGraphicG2d tmp = new UGraphicG2d(colorMapper, g2d, 1.0);
|
||||
final Dimension2D size = image.calculateDimension(tmp.getStringBounder());
|
||||
g2d.dispose();
|
||||
return size;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -63,6 +63,20 @@ public class UPolygon extends AbstractShadowable {
|
||||
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) {
|
||||
all.add(new Point2D.Double(x, y));
|
||||
manageMinMax(x, y);
|
||||
@ -142,4 +156,5 @@ public class UPolygon extends AbstractShadowable {
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ package net.sourceforge.plantuml.ugraphic.sprite;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.BackSlash;
|
||||
|
||||
public class SpriteUtils {
|
||||
|
||||
public static final String SPRITE_NAME = "[-\\p{L}0-9_/]+";
|
||||
@ -52,7 +54,7 @@ public class SpriteUtils {
|
||||
final List<String> result = level.encode(img);
|
||||
for (String s : result) {
|
||||
sb.append(s);
|
||||
sb.append("\n");
|
||||
sb.append(BackSlash.NEWLINE);
|
||||
}
|
||||
sb.append("}\n");
|
||||
return sb.toString();
|
||||
@ -64,12 +66,12 @@ public class SpriteUtils {
|
||||
final List<String> list = level.encodeZ(img);
|
||||
if (list.size() == 1) {
|
||||
sb.append(list.get(0));
|
||||
sb.append("\n");
|
||||
sb.append(BackSlash.NEWLINE);
|
||||
} else {
|
||||
sb.append("{\n");
|
||||
for (String s : list) {
|
||||
sb.append(s);
|
||||
sb.append("\n");
|
||||
sb.append(BackSlash.NEWLINE);
|
||||
}
|
||||
sb.append("}\n");
|
||||
}
|
||||
|
@ -34,9 +34,9 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.ugraphic.svg;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Random;
|
||||
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
@ -82,19 +82,19 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
|
||||
register();
|
||||
}
|
||||
|
||||
public UGraphicSvg(ColorMapper colorMapper, String backcolor, boolean textAsPath, double scale, String linkTarget,
|
||||
String hover, long seed) {
|
||||
this(colorMapper, new SvgGraphics(backcolor, scale, hover, seed), textAsPath, linkTarget);
|
||||
public UGraphicSvg(Dimension2D minDim, ColorMapper colorMapper, String backcolor, boolean textAsPath, double scale,
|
||||
String linkTarget, String hover, long seed) {
|
||||
this(minDim, colorMapper, new SvgGraphics(minDim, backcolor, scale, hover, seed), textAsPath, linkTarget);
|
||||
}
|
||||
|
||||
public UGraphicSvg(ColorMapper colorMapper, boolean textAsPath, double scale, String linkTarget, String hover,
|
||||
long seed) {
|
||||
this(colorMapper, new SvgGraphics(scale, hover, seed), textAsPath, linkTarget);
|
||||
public UGraphicSvg(Dimension2D minDim, ColorMapper colorMapper, boolean textAsPath, double scale,
|
||||
String linkTarget, String hover, long seed) {
|
||||
this(minDim, colorMapper, new SvgGraphics(minDim, scale, hover, seed), textAsPath, linkTarget);
|
||||
}
|
||||
|
||||
public UGraphicSvg(ColorMapper mapper, HtmlColorGradient gr, boolean textAsPath, double scale, String linkTarget,
|
||||
String hover, long seed) {
|
||||
this(mapper, new SvgGraphics(scale, hover, seed), textAsPath, linkTarget);
|
||||
public UGraphicSvg(Dimension2D minDim, ColorMapper mapper, HtmlColorGradient gr, boolean textAsPath, double scale,
|
||||
String linkTarget, String hover, long seed) {
|
||||
this(minDim, mapper, new SvgGraphics(minDim, scale, hover, seed), textAsPath, linkTarget);
|
||||
|
||||
final SvgGraphics svg = getGraphicObject();
|
||||
svg.paintBackcolorGradient(mapper, gr);
|
||||
@ -115,7 +115,8 @@ public class UGraphicSvg extends AbstractUGraphic<SvgGraphics> implements ClipCo
|
||||
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);
|
||||
this.stringBounder = FileFormat.PNG.getDefaultStringBounder();
|
||||
this.textAsPath2 = textAsPath;
|
||||
|
@ -43,7 +43,14 @@ public class Version {
|
||||
private static final int MAJOR_SEPARATOR = 1000000;
|
||||
|
||||
public static int version() {
|
||||
return 1201713;
|
||||
return 1201714;
|
||||
}
|
||||
|
||||
public static int versionPatched() {
|
||||
if (beta() != 0) {
|
||||
return version() + 1;
|
||||
}
|
||||
return version();
|
||||
}
|
||||
|
||||
public static String versionString() {
|
||||
@ -81,7 +88,7 @@ public class Version {
|
||||
}
|
||||
|
||||
public static long compileTime() {
|
||||
return 1494435153042L;
|
||||
return 1496656592758L;
|
||||
}
|
||||
|
||||
public static String compileTimeString() {
|
||||
|
Loading…
Reference in New Issue
Block a user