mirror of
https://github.com/octoleo/plantuml.git
synced 2024-12-22 02:49:06 +00:00
version 8025
This commit is contained in:
parent
136819ca48
commit
f35a3a00df
@ -56,7 +56,7 @@ public class BlockUml {
|
||||
|
||||
public BlockUml(List<? extends CharSequence> strings, int startLine) {
|
||||
this.startLine = startLine;
|
||||
final String s0 = strings.get(0).toString().trim();
|
||||
final String s0 = StringUtils.trin(strings.get(0).toString());
|
||||
if (s0.startsWith("@start") == false) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
@ -67,7 +67,7 @@ public class BlockUml {
|
||||
if (OptionFlags.getInstance().isWord()) {
|
||||
return null;
|
||||
}
|
||||
final Matcher m = patternFilename.matcher(data.get(0).toString().trim());
|
||||
final Matcher m = patternFilename.matcher(StringUtils.trin(data.get(0).toString()));
|
||||
final boolean ok = m.find();
|
||||
if (ok == false) {
|
||||
return null;
|
||||
|
@ -70,9 +70,14 @@ public class FileFormatOption {
|
||||
private final AffineTransform affineTransform;
|
||||
private final boolean withMetadata;
|
||||
private final boolean useRedForError;
|
||||
private final String svgLinkTarget;
|
||||
|
||||
public FileFormatOption(FileFormat fileFormat) {
|
||||
this(fileFormat, null, true, false);
|
||||
this(fileFormat, null, true, false, "_top");
|
||||
}
|
||||
|
||||
public String getSvgLinkTarget() {
|
||||
return svgLinkTarget;
|
||||
}
|
||||
|
||||
public final boolean isWithMetadata() {
|
||||
@ -80,18 +85,23 @@ public class FileFormatOption {
|
||||
}
|
||||
|
||||
public FileFormatOption(FileFormat fileFormat, boolean withMetadata) {
|
||||
this(fileFormat, null, false, false);
|
||||
this(fileFormat, null, false, false, "_top");
|
||||
}
|
||||
|
||||
private FileFormatOption(FileFormat fileFormat, AffineTransform at, boolean withMetadata, boolean useRedForError) {
|
||||
private FileFormatOption(FileFormat fileFormat, AffineTransform at, boolean withMetadata, boolean useRedForError, String svgLinkTarget) {
|
||||
this.fileFormat = fileFormat;
|
||||
this.affineTransform = at;
|
||||
this.withMetadata = withMetadata;
|
||||
this.useRedForError = useRedForError;
|
||||
this.svgLinkTarget = svgLinkTarget;
|
||||
}
|
||||
|
||||
public FileFormatOption withUseRedForError() {
|
||||
return new FileFormatOption(fileFormat, affineTransform, withMetadata, true);
|
||||
return new FileFormatOption(fileFormat, affineTransform, withMetadata, true, svgLinkTarget);
|
||||
}
|
||||
|
||||
public FileFormatOption withSvgLinkTarget(String target) {
|
||||
return new FileFormatOption(fileFormat, affineTransform, withMetadata, useRedForError, target);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -152,11 +162,11 @@ public class FileFormatOption {
|
||||
}
|
||||
final UGraphicSvg ug;
|
||||
if (mybackcolor instanceof HtmlColorGradient) {
|
||||
ug = new UGraphicSvg(colorMapper, (HtmlColorGradient) mybackcolor, false, scale);
|
||||
ug = new UGraphicSvg(colorMapper, (HtmlColorGradient) mybackcolor, false, scale, getSvgLinkTarget());
|
||||
} else if (backColor == null || backColor.equals(Color.WHITE)) {
|
||||
ug = new UGraphicSvg(colorMapper, false, scale);
|
||||
ug = new UGraphicSvg(colorMapper, false, scale, getSvgLinkTarget());
|
||||
} else {
|
||||
ug = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(backColor), false, scale);
|
||||
ug = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(backColor), false, scale, getSvgLinkTarget());
|
||||
}
|
||||
return ug;
|
||||
|
||||
|
@ -28,13 +28,18 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 15877 $
|
||||
* Revision $Revision: 16206 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
|
||||
import java.awt.Font;
|
||||
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
import net.sourceforge.plantuml.skin.rose.Rose;
|
||||
import net.sourceforge.plantuml.ugraphic.UFont;
|
||||
|
||||
interface FontParamConstant {
|
||||
String FAMILY = "SansSerif";
|
||||
String COLOR = "black";
|
||||
@ -146,4 +151,12 @@ public enum FontParam {
|
||||
return defaultFamily;
|
||||
}
|
||||
|
||||
public FontConfiguration getFontConfiguration(ISkinParam skinParam) {
|
||||
final UFont font = skinParam.getFont(this, null, false);
|
||||
final HtmlColor color = new Rose().getFontColor(skinParam, this);
|
||||
final HtmlColor hyperlinkColor = skinParam.getHyperlinkColor();
|
||||
final boolean useUnderlineForHyperlink = skinParam.useUnderlineForHyperlink();
|
||||
return new FontConfiguration(font, color, hyperlinkColor, useUnderlineForHyperlink);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -121,4 +121,6 @@ public interface ISkinParam extends ISkinSimple {
|
||||
|
||||
public boolean handwritten();
|
||||
|
||||
public String getSvgLinkTarget();
|
||||
|
||||
}
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 15892 $
|
||||
* Revision $Revision: 16158 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
|
@ -103,7 +103,7 @@ public class PSystemBuilder {
|
||||
errors.add((PSystemError) sys);
|
||||
}
|
||||
|
||||
final PSystemError err = merge(errors);
|
||||
final PSystemError err = PSystemError.merge(errors);
|
||||
// if (OptionFlags.getInstance().isQuiet() == false) {
|
||||
// err.print(System.err);
|
||||
// }
|
||||
@ -160,21 +160,6 @@ public class PSystemBuilder {
|
||||
return factories;
|
||||
}
|
||||
|
||||
private PSystemError merge(Collection<PSystemError> ps) {
|
||||
UmlSource source = null;
|
||||
final List<ErrorUml> errors = new ArrayList<ErrorUml>();
|
||||
for (PSystemError system : ps) {
|
||||
if (system.getSource() != null && source == null) {
|
||||
source = system.getSource();
|
||||
}
|
||||
errors.addAll(system.getErrorsUml());
|
||||
}
|
||||
if (source == null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
return new PSystemError(source, errors);
|
||||
}
|
||||
|
||||
private boolean isOk(Diagram ps) {
|
||||
if (ps == null || ps instanceof PSystemError) {
|
||||
return false;
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 15848 $
|
||||
* Revision $Revision: 16158 $
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
|
||||
@ -54,24 +54,15 @@ import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
|
||||
|
||||
public class PSystemError extends AbstractPSystem {
|
||||
|
||||
private String getSuggestColor(boolean useRed) {
|
||||
if (useRed) {
|
||||
return "black";
|
||||
}
|
||||
return "white";
|
||||
}
|
||||
|
||||
private String getRed(boolean useRed) {
|
||||
if (useRed) {
|
||||
return "#CD0A0A";
|
||||
}
|
||||
return "red";
|
||||
}
|
||||
|
||||
private final int higherErrorPosition;
|
||||
private final List<ErrorUml> printedErrors;
|
||||
private final List<String> debugLines = new ArrayList<String>();
|
||||
|
||||
public PSystemError(UmlSource source, List<ErrorUml> all) {
|
||||
public PSystemError(UmlSource source, ErrorUml singleError, List<String> debugLines) {
|
||||
this(source, Collections.singletonList(singleError), debugLines);
|
||||
}
|
||||
|
||||
private PSystemError(UmlSource source, List<ErrorUml> all, List<String> debugLines) {
|
||||
this.setSource(source);
|
||||
|
||||
final int higherErrorPositionExecution = getHigherErrorPosition(ErrorUmlType.EXECUTION_ERROR, all);
|
||||
@ -90,10 +81,24 @@ public class PSystemError extends AbstractPSystem {
|
||||
printedErrors = getErrorsAt(higherErrorPositionSyntax, ErrorUmlType.SYNTAX_ERROR, all);
|
||||
}
|
||||
|
||||
if (debugLines != null) {
|
||||
this.debugLines.addAll(debugLines);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public PSystemError(UmlSource source, ErrorUml singleError) {
|
||||
this(source, Collections.singletonList(singleError));
|
||||
private String getSuggestColor(boolean useRed) {
|
||||
if (useRed) {
|
||||
return "black";
|
||||
}
|
||||
return "white";
|
||||
}
|
||||
|
||||
private String getRed(boolean useRed) {
|
||||
if (useRed) {
|
||||
return "#CD0A0A";
|
||||
}
|
||||
return "red";
|
||||
}
|
||||
|
||||
public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
|
||||
@ -110,7 +115,7 @@ public class PSystemError extends AbstractPSystem {
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.addUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
}
|
||||
|
||||
private List<String> getTextStrings() {
|
||||
@ -158,6 +163,7 @@ public class PSystemError extends AbstractPSystem {
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
result.addAll(this.debugLines);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -186,10 +192,10 @@ public class PSystemError extends AbstractPSystem {
|
||||
if (StringUtils.isNotEmpty(err)) {
|
||||
htmlStrings.add("<w:" + getRed(useRed) + ">" + err + "</w>");
|
||||
}
|
||||
// final StringBuilder underscore = new StringBuilder();
|
||||
// for (int i = 0; i < errorLine.length(); i++) {
|
||||
// underscore.append("^");
|
||||
// }
|
||||
// final StringBuilder underscore = new StringBuilder();
|
||||
// for (int i = 0; i < errorLine.length(); i++) {
|
||||
// underscore.append("^");
|
||||
// }
|
||||
final Collection<String> textErrors = new LinkedHashSet<String>();
|
||||
for (ErrorUml er : printedErrors) {
|
||||
textErrors.add(er.getError());
|
||||
@ -207,6 +213,7 @@ public class PSystemError extends AbstractPSystem {
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
htmlStrings.addAll(this.debugLines);
|
||||
|
||||
return htmlStrings;
|
||||
}
|
||||
@ -293,4 +300,25 @@ public class PSystemError extends AbstractPSystem {
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static PSystemError merge(Collection<PSystemError> ps) {
|
||||
UmlSource source = null;
|
||||
final List<ErrorUml> errors = new ArrayList<ErrorUml>();
|
||||
final List<String> debugs = new ArrayList<String>();
|
||||
for (PSystemError system : ps) {
|
||||
if (system.getSource() != null && source == null) {
|
||||
source = system.getSource();
|
||||
}
|
||||
errors.addAll(system.getErrorsUml());
|
||||
debugs.addAll(system.debugLines);
|
||||
if (system.debugLines.size() > 0) {
|
||||
debugs.add("-");
|
||||
}
|
||||
}
|
||||
if (source == null) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
return new PSystemError(source, errors, debugs);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -55,6 +55,10 @@ public class PSystemUtils {
|
||||
|
||||
public static List<File> exportDiagrams(Diagram system, File suggestedFile, FileFormatOption fileFormatOption)
|
||||
throws IOException {
|
||||
if (system instanceof UmlDiagram) {
|
||||
final ISkinParam skinParam = ((UmlDiagram) system).getSkinParam();
|
||||
fileFormatOption = fileFormatOption.withSvgLinkTarget(skinParam.getSvgLinkTarget());
|
||||
}
|
||||
if (system instanceof NewpagedDiagram) {
|
||||
return exportDiagramsNewpaged((NewpagedDiagram) system, suggestedFile, fileFormatOption);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 15982 $
|
||||
* Revision $Revision: 16196 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
@ -70,7 +70,7 @@ public class SkinParam implements ISkinParam {
|
||||
private Rankdir rankdir = Rankdir.TOP_TO_BOTTOM;
|
||||
|
||||
public void setParam(String key, String value) {
|
||||
params.put(cleanForKey(key), value.trim());
|
||||
params.put(cleanForKey(key), StringUtils.trin(value));
|
||||
}
|
||||
|
||||
private static final String stereoPatternString = "\\<\\<(.*?)\\>\\>";
|
||||
@ -93,7 +93,7 @@ public class SkinParam implements ISkinParam {
|
||||
// }
|
||||
|
||||
static String cleanForKey(String key) {
|
||||
key = StringUtils.goLowerCase(key).trim();
|
||||
key = StringUtils.trin(StringUtils.goLowerCase(key));
|
||||
key = key.replaceAll("_|\\.|\\s", "");
|
||||
key = replaceSmart(key, "partition", "package");
|
||||
key = replaceSmart(key, "sequenceparticipant", "participant");
|
||||
@ -664,4 +664,12 @@ public class SkinParam implements ISkinParam {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getSvgLinkTarget() {
|
||||
final String value = getValue("svglinktarget");
|
||||
if (value == null) {
|
||||
return "_top";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -212,5 +212,9 @@ public class SkinParamDelegator implements ISkinParam {
|
||||
return skinParam.handwritten();
|
||||
}
|
||||
|
||||
public String getSvgLinkTarget() {
|
||||
return skinParam.getSvgLinkTarget();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ public class SourceStringReader {
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, error.getBackcolor(), null,
|
||||
null, 0, 0, null, false);
|
||||
imageBuilder.addUDrawable(error);
|
||||
imageBuilder.writeImageTOBEMOVED(fileFormatOption.getFileFormat(), os);
|
||||
imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
|
||||
}
|
||||
|
||||
public DiagramDescription generateDiagramDescription(OutputStream os) throws IOException {
|
||||
|
@ -117,7 +117,7 @@ public class StringUtils {
|
||||
}
|
||||
|
||||
public static boolean isNotEmpty(String input) {
|
||||
return input != null && input.trim().length() > 0;
|
||||
return input != null && trin(input).length() > 0;
|
||||
}
|
||||
|
||||
public static boolean isNotEmpty(List<? extends CharSequence> input) {
|
||||
@ -125,7 +125,7 @@ public class StringUtils {
|
||||
}
|
||||
|
||||
public static boolean isEmpty(String input) {
|
||||
return input == null || input.trim().length() == 0;
|
||||
return input == null || trin(input).length() == 0;
|
||||
}
|
||||
|
||||
public static String manageHtml(String s) {
|
||||
@ -179,7 +179,7 @@ public class StringUtils {
|
||||
public static String capitalize(String s) {
|
||||
return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
public static String goUpperCase(String s) {
|
||||
return s.toUpperCase(Locale.ENGLISH);
|
||||
}
|
||||
@ -312,6 +312,10 @@ public class StringUtils {
|
||||
public static char hiddenBiggerThan() {
|
||||
return '\u0006';
|
||||
}
|
||||
|
||||
public static char hiddenNewLine() {
|
||||
return '\u0009';
|
||||
}
|
||||
|
||||
public static String hideComparatorCharacters(String s) {
|
||||
s = s.replace('<', hiddenLesserThan());
|
||||
@ -388,10 +392,44 @@ public class StringUtils {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void trimSmart(List<String> data, int referenceLine) {
|
||||
if (data.size() <= referenceLine) {
|
||||
return;
|
||||
}
|
||||
final int nbStartingSpace = nbStartingSpace(data.get(referenceLine));
|
||||
for (int i = referenceLine; i < data.size(); i++) {
|
||||
final String s = data.get(i);
|
||||
data.set(i, removeStartingSpaces(s, nbStartingSpace));
|
||||
}
|
||||
}
|
||||
|
||||
public static String removeStartingSpaces(String s, int nbStartingSpace) {
|
||||
for (int i = 0; i < nbStartingSpace; i++) {
|
||||
if (s.length() > 0 && isSpaceOrTab(s.charAt(0))) {
|
||||
s = s.substring(1);
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
private static boolean isSpaceOrTab(char c) {
|
||||
return c == ' ' || c == '\t';
|
||||
}
|
||||
|
||||
private static int nbStartingSpace(String s) {
|
||||
int nb = 0;
|
||||
while (nb < s.length() && isSpaceOrTab(s.charAt(nb))) {
|
||||
nb++;
|
||||
}
|
||||
return nb;
|
||||
}
|
||||
|
||||
public static void trim(List<String> data, boolean removeEmptyLines) {
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
final String s = data.get(i);
|
||||
data.set(i, s.trim());
|
||||
data.set(i, trin(s));
|
||||
}
|
||||
if (removeEmptyLines) {
|
||||
for (final Iterator<String> it = data.iterator(); it.hasNext();) {
|
||||
@ -439,7 +477,7 @@ public class StringUtils {
|
||||
}
|
||||
|
||||
public static List<String> splitComma(String s) {
|
||||
s = s.trim();
|
||||
s = trin(s);
|
||||
// if (s.matches("([\\p{L}0-9_.]+|[%g][^%g]+[%g])(\\s*,\\s*([\\p{L}0-9_.]+|[%g][^%g]+[%g]))*") == false) {
|
||||
// throw new IllegalArgumentException();
|
||||
// }
|
||||
@ -494,5 +532,35 @@ public class StringUtils {
|
||||
return s.endsWith("\\") && s.endsWith("\\\\") == false;
|
||||
}
|
||||
|
||||
public static String manageGuillemetStrict(String st) {
|
||||
if (st.startsWith("<< ")) {
|
||||
st = "\u00AB" + st.substring(3);
|
||||
} else if (st.startsWith("<<")) {
|
||||
st = "\u00AB" + st.substring(2);
|
||||
}
|
||||
if (st.endsWith(" >>")) {
|
||||
st = st.substring(0, st.length() - 3) + "\u00BB";
|
||||
} else if (st.endsWith(">>")) {
|
||||
st = st.substring(0, st.length() - 2) + "\u00BB";
|
||||
}
|
||||
return st;
|
||||
}
|
||||
|
||||
public static String manageGuillemet(String st) {
|
||||
return st.replaceAll("\\<\\<([^<>]+)\\>\\>", "\u00AB$1\u00BB");
|
||||
}
|
||||
|
||||
public static String trinNoTrace(String s) {
|
||||
return s.trim();
|
||||
}
|
||||
|
||||
public static String trin(String s) {
|
||||
final String result = s.trim();
|
||||
// if (result.equals(s) == false && s.contains("prop")) {
|
||||
// System.err.println("TRIMING " + s);
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
|
||||
// http://docs.oracle.com/javase/tutorial/i18n/format/dateFormat.html
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 15848 $
|
||||
* Revision $Revision: 16158 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
@ -55,6 +55,7 @@ import javax.script.ScriptException;
|
||||
import net.sourceforge.plantuml.anim.Animation;
|
||||
import net.sourceforge.plantuml.anim.AnimationDecoder;
|
||||
import net.sourceforge.plantuml.api.ImageDataSimple;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.core.Diagram;
|
||||
import net.sourceforge.plantuml.core.ImageData;
|
||||
import net.sourceforge.plantuml.core.UmlSource;
|
||||
@ -166,6 +167,26 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
|
||||
return footerAlignment;
|
||||
}
|
||||
|
||||
public final HorizontalAlignment getAlignmentTeoz(FontParam param) {
|
||||
if (param == FontParam.FOOTER) {
|
||||
return getFooterAlignment();
|
||||
}
|
||||
if (param == FontParam.HEADER) {
|
||||
return getHeaderAlignment();
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
public final Display getFooterOrHeaderTeoz(FontParam param) {
|
||||
if (param == FontParam.FOOTER) {
|
||||
return getFooter();
|
||||
}
|
||||
if (param == FontParam.HEADER) {
|
||||
return getHeader();
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
public final void setFooterAlignment(HorizontalAlignment footerAlignment) {
|
||||
this.footerAlignment = footerAlignment;
|
||||
}
|
||||
@ -236,7 +257,6 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
|
||||
exportDiagramError(os, e, fileFormatOption, null, null);
|
||||
}
|
||||
return new ImageDataSimple();
|
||||
|
||||
}
|
||||
|
||||
private void exportDiagramError(OutputStream os, Throwable exception, FileFormatOption fileFormat,
|
||||
@ -245,18 +265,7 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
|
||||
final List<String> strings = getFailureText(exception, graphvizVersion);
|
||||
|
||||
final String flash = getFlashData();
|
||||
for (StackTraceElement ste : exception.getStackTrace()) {
|
||||
strings.add(" " + ste.toString());
|
||||
}
|
||||
if (exception.getCause() != null) {
|
||||
final Throwable cause = exception.getCause();
|
||||
strings.add(" ");
|
||||
strings.add("Caused by " + cause.toString());
|
||||
for (StackTraceElement ste : cause.getStackTrace()) {
|
||||
strings.add(" " + ste.toString());
|
||||
}
|
||||
|
||||
}
|
||||
strings.addAll(CommandExecutionResult.getStackTrace(exception));
|
||||
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE,
|
||||
getMetadata(), null, 0, 0, null, getSkinParam().handwritten());
|
||||
@ -283,7 +292,7 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
|
||||
}
|
||||
});
|
||||
}
|
||||
imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
|
||||
imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
}
|
||||
|
||||
private String getFlashData() {
|
||||
@ -320,7 +329,6 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
|
||||
strings.add("You should send this diagram and this image to <b>plantuml@gmail.com</b> to solve this issue.");
|
||||
strings.add("You can try to turn arround this issue by simplifing your diagram.");
|
||||
strings.add(" ");
|
||||
strings.add(exception.toString());
|
||||
return strings;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class UrlBuilder {
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
final Matcher m = p.matcher(s.trim());
|
||||
final Matcher m = p.matcher(StringUtils.trinNoTrace(s));
|
||||
if (m.matches() == false) {
|
||||
return null;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
|
||||
|
||||
public CommandExecutionResult executeNow(final ActivityDiagram diagram, List<String> lines) {
|
||||
StringUtils.trim(lines, false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
|
||||
final IEntity entity1 = CommandLinkActivity.getEntity(diagram, line0, true);
|
||||
|
||||
|
@ -107,7 +107,7 @@ public class CommandLinkLongActivity2 extends CommandMultilines2<ActivityDiagram
|
||||
|
||||
public CommandExecutionResult executeNow(final ActivityDiagram diagram, List<String> lines) {
|
||||
StringUtils.trim(lines, false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
|
||||
final IEntity entity1 = CommandLinkActivity.getEntity(diagram, line0, true);
|
||||
|
||||
|
@ -187,7 +187,7 @@ public class ActivityDiagram3 extends UmlDiagram {
|
||||
margin, margin, getAnimation(), getSkinParam().handwritten());
|
||||
imageBuilder.addUDrawable(result);
|
||||
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption.getFileFormat(), os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
|
||||
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,6 @@ import net.sourceforge.plantuml.activitydiagram3.command.CommandGoto;
|
||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandGroup3;
|
||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandGroupEnd3;
|
||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandIf2;
|
||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandIf2Multilines;
|
||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandIf4;
|
||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandIfLegacy1;
|
||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandKill3;
|
||||
@ -64,6 +63,7 @@ import net.sourceforge.plantuml.activitydiagram3.command.CommandNoteLong3;
|
||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandPartition3;
|
||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandRepeat3;
|
||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandRepeatWhile3;
|
||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandRepeatWhile3Multilines;
|
||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandSplit3;
|
||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandSplitAgain3;
|
||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandSplitEnd3;
|
||||
@ -75,6 +75,7 @@ import net.sourceforge.plantuml.activitydiagram3.command.CommandSwimlane2;
|
||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandWhile3;
|
||||
import net.sourceforge.plantuml.activitydiagram3.command.CommandWhileEnd3;
|
||||
import net.sourceforge.plantuml.command.Command;
|
||||
import net.sourceforge.plantuml.command.CommandDecoratorMultine;
|
||||
import net.sourceforge.plantuml.command.CommandFootboxIgnored;
|
||||
import net.sourceforge.plantuml.command.UmlDiagramFactory;
|
||||
|
||||
@ -98,14 +99,17 @@ public class ActivityDiagramFactory3 extends UmlDiagramFactory {
|
||||
cmds.add(new CommandActivity3());
|
||||
cmds.add(new CommandIf4());
|
||||
cmds.add(new CommandIf2());
|
||||
cmds.add(new CommandIf2Multilines());
|
||||
cmds.add(new CommandDecoratorMultine(new CommandIf2())); // UmlDiagramFactory
|
||||
// cmds.add(new CommandIf2Multilines());
|
||||
cmds.add(new CommandIfLegacy1());
|
||||
cmds.add(new CommandElseIf2());
|
||||
cmds.add(new CommandElse3());
|
||||
cmds.add(new CommandDecoratorMultine(new CommandElse3()));
|
||||
cmds.add(new CommandElseLegacy1());
|
||||
cmds.add(new CommandEndif3());
|
||||
cmds.add(new CommandRepeat3());
|
||||
cmds.add(new CommandRepeatWhile3());
|
||||
cmds.add(new CommandRepeatWhile3Multilines());
|
||||
cmds.add(new CommandWhile3());
|
||||
cmds.add(new CommandWhileEnd3());
|
||||
cmds.add(new CommandFork3());
|
||||
@ -114,8 +118,8 @@ public class ActivityDiagramFactory3 extends UmlDiagramFactory {
|
||||
cmds.add(new CommandSplit3());
|
||||
cmds.add(new CommandSplitAgain3());
|
||||
cmds.add(new CommandSplitEnd3());
|
||||
// cmds.add(new CommandGroup3());
|
||||
// cmds.add(new CommandGroupEnd3());
|
||||
// cmds.add(new CommandGroup3());
|
||||
// cmds.add(new CommandGroupEnd3());
|
||||
cmds.add(new CommandStart3());
|
||||
cmds.add(new CommandStop3());
|
||||
cmds.add(new CommandStopLegacy1());
|
||||
@ -130,7 +134,6 @@ public class ActivityDiagramFactory3 extends UmlDiagramFactory {
|
||||
cmds.add(new CommandLabel());
|
||||
cmds.add(new CommandGoto());
|
||||
|
||||
|
||||
return cmds;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class CommandActivityLong3 extends CommandMultilines2<ActivityDiagram3> {
|
||||
|
||||
public CommandExecutionResult executeNow(ActivityDiagram3 diagram, List<String> lines) {
|
||||
lines = StringUtils.removeEmptyColumns(lines);
|
||||
final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0));
|
||||
final BoxStyle style = BoxStyle.fromChar(getLastChar(lines));
|
||||
removeStarting(lines, line0.get("DATA", 0));
|
||||
|
@ -70,7 +70,7 @@ public class CommandArrowLong3 extends CommandMultilines2<ActivityDiagram3> {
|
||||
|
||||
public CommandExecutionResult executeNow(ActivityDiagram3 diagram, List<String> lines) {
|
||||
lines = StringUtils.removeEmptyColumns(lines);
|
||||
final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0));
|
||||
diagram.setColorNextArrow(color);
|
||||
removeStarting(lines, line0.get("LABEL", 0));
|
||||
|
@ -71,7 +71,7 @@ public class CommandIf2Multilines extends CommandMultilines2<ActivityDiagram3> {
|
||||
@Override
|
||||
public CommandExecutionResult executeNow(ActivityDiagram3 diagram, List<String> lines) {
|
||||
StringUtils.trim(lines, false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()),
|
||||
lines.get(lines.size() - 1));
|
||||
|
||||
|
@ -57,9 +57,8 @@ public class CommandNoteLong3 extends CommandMultilines2<ActivityDiagram3> {
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(final ActivityDiagram3 diagram, List<String> lines) {
|
||||
// final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final List<String> in = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
|
||||
final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
final NotePosition position = getPosition(line0.get("POSITION", 0));
|
||||
final Display note = Display.create(in);
|
||||
return diagram.addNote(note, position);
|
||||
|
@ -0,0 +1,111 @@
|
||||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2014, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.sourceforge.net
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 4762 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.activitydiagram3.command;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines3;
|
||||
import net.sourceforge.plantuml.command.MultilinesStrategy;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.command.regex.RegexConcat;
|
||||
import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
|
||||
public class CommandRepeatWhile3Multilines extends CommandMultilines3<ActivityDiagram3> {
|
||||
|
||||
public CommandRepeatWhile3Multilines() {
|
||||
super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegexConcat getPatternEnd2() {
|
||||
return new RegexConcat(//
|
||||
new RegexLeaf("TEST1", "([^)]*)"), new RegexLeaf("\\)"), //
|
||||
new RegexLeaf(";?$"));
|
||||
}
|
||||
|
||||
static RegexConcat getRegexConcat() {
|
||||
return new RegexConcat(//
|
||||
new RegexLeaf("^"), //
|
||||
new RegexLeaf("repeat[%s]?while"), //
|
||||
new RegexLeaf("[%s]*"), //
|
||||
new RegexLeaf("\\("), //
|
||||
new RegexLeaf("TEST1", "([^)]*)$"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandExecutionResult executeNow(ActivityDiagram3 diagram, List<String> lines) {
|
||||
StringUtils.trim(lines, false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
final RegexResult lineLast = getPatternEnd2().matcher(lines.get(lines.size() - 1));
|
||||
|
||||
// System.err.println("line0=" + line0);
|
||||
// System.err.println("linesLast=" + lineLast);
|
||||
|
||||
//
|
||||
// final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0));
|
||||
|
||||
final String test = line0.get("TEST1", 0);
|
||||
Display testDisplay = Display.getWithNewlines(test);
|
||||
for (int i = 1; i < lines.size() - 1; i++) {
|
||||
testDisplay = testDisplay.add(lines.get(i));
|
||||
}
|
||||
final String trailTest = lineLast.get("TEST1", 0);
|
||||
if (StringUtils.isEmpty(trailTest) == false) {
|
||||
testDisplay = testDisplay.add(trailTest);
|
||||
}
|
||||
|
||||
Display yes = null;// Display.getWithNewlines("arg.getLazzy(\"WHEN\", 0)");
|
||||
final Display out = null; // Display.getWithNewlines("arg.getLazzy(\"OUT\", 0)");
|
||||
final HtmlColor linkColor = null; // diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR",
|
||||
// 0));
|
||||
final Display linkLabel = null; // Display.getWithNewlines("arg.get(\"LABEL\", 0)");
|
||||
final List<Display> splitted = testDisplay.splitMultiline(MyPattern.cmpile("\\)[%s]*(is|equals?)[%s]*\\(",
|
||||
Pattern.CASE_INSENSITIVE));
|
||||
if (splitted.size() == 2) {
|
||||
testDisplay = splitted.get(0);
|
||||
yes = splitted.get(1);
|
||||
|
||||
}
|
||||
|
||||
return diagram.repeatWhile(testDisplay, yes, out, linkLabel, linkColor);
|
||||
}
|
||||
|
||||
}
|
@ -85,7 +85,6 @@ public class Swimlanes implements TextBlock {
|
||||
private final ISkinParam skinParam;;
|
||||
|
||||
private final List<Swimlane> swimlanes = new ArrayList<Swimlane>();
|
||||
private final FontConfiguration fontConfiguration;
|
||||
private Swimlane currentSwimlane = null;
|
||||
|
||||
private final Instruction root = new InstructionList();
|
||||
@ -95,10 +94,12 @@ public class Swimlanes implements TextBlock {
|
||||
|
||||
public Swimlanes(ISkinParam skinParam) {
|
||||
this.skinParam = skinParam;
|
||||
final UFont font = skinParam.getFont(FontParam.TITLE, null, false);
|
||||
this.fontConfiguration = new FontConfiguration(font, HtmlColorUtils.BLACK, skinParam.getHyperlinkColor(),
|
||||
skinParam.useUnderlineForHyperlink());
|
||||
}
|
||||
|
||||
private FontConfiguration getFontConfiguration() {
|
||||
final UFont font = skinParam.getFont(FontParam.TITLE, null, false);
|
||||
return new FontConfiguration(font, HtmlColorUtils.BLACK, skinParam.getHyperlinkColor(),
|
||||
skinParam.useUnderlineForHyperlink());
|
||||
}
|
||||
|
||||
private FtileFactory getFtileFactory() {
|
||||
@ -248,7 +249,7 @@ public class Swimlanes implements TextBlock {
|
||||
}
|
||||
|
||||
if (OptionFlags.SWI2 == false) {
|
||||
final TextBlock swTitle = TextBlockUtils.create(swimlane.getDisplay(), fontConfiguration,
|
||||
final TextBlock swTitle = TextBlockUtils.create(swimlane.getDisplay(), getFontConfiguration(),
|
||||
HorizontalAlignment.LEFT, skinParam);
|
||||
final double titleWidth = swTitle.calculateDimension(stringBounder).getWidth();
|
||||
final double posTitle = x2 + (swimlane.getTotalWidth() - titleWidth) / 2;
|
||||
@ -281,7 +282,7 @@ public class Swimlanes implements TextBlock {
|
||||
final MinMax minMax = limitFinder.getMinMax();
|
||||
|
||||
final double drawingWidth = minMax.getWidth() + 2 * separationMargin;
|
||||
final TextBlock swTitle = TextBlockUtils.create(swimlane.getDisplay(), fontConfiguration,
|
||||
final TextBlock swTitle = TextBlockUtils.create(swimlane.getDisplay(), getFontConfiguration(),
|
||||
HorizontalAlignment.LEFT, skinParam);
|
||||
final double titleWidth = swTitle.calculateDimension(stringBounder).getWidth();
|
||||
final double totalWidth = Math.max(drawingWidth, titleWidth + 2 * separationMargin);
|
||||
@ -297,7 +298,7 @@ public class Swimlanes implements TextBlock {
|
||||
private UTranslate getTitleHeightTranslate(final StringBounder stringBounder) {
|
||||
double titlesHeight = 0;
|
||||
for (Swimlane swimlane : swimlanes) {
|
||||
final TextBlock swTitle = TextBlockUtils.create(swimlane.getDisplay(), fontConfiguration,
|
||||
final TextBlock swTitle = TextBlockUtils.create(swimlane.getDisplay(), getFontConfiguration(),
|
||||
HorizontalAlignment.LEFT, skinParam);
|
||||
|
||||
titlesHeight = Math.max(titlesHeight, swTitle.calculateDimension(stringBounder).getHeight());
|
||||
|
@ -66,8 +66,6 @@ import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||
import net.sourceforge.plantuml.svek.ConditionStyle;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UFont;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
@ -106,7 +104,8 @@ class FtileRepeat extends AbstractFtile {
|
||||
|
||||
final FontConfiguration fc = new FontConfiguration(fontTest, HtmlColorUtils.BLACK, hyperlinkColor,
|
||||
useUnderlineForHyperlink);
|
||||
final TextBlock tbTest = TextBlockUtils.create(test, fc, HorizontalAlignment.LEFT, spriteContainer);
|
||||
final TextBlock tbTest = (test == null || test.isWhite()) ? TextBlockUtils.empty(0, 0) : TextBlockUtils.create(
|
||||
test, fc, HorizontalAlignment.LEFT, spriteContainer);
|
||||
final TextBlock yesTb = TextBlockUtils.create(yes, fc, HorizontalAlignment.LEFT, spriteContainer);
|
||||
final TextBlock outTb = TextBlockUtils.create(out, fc, HorizontalAlignment.LEFT, spriteContainer);
|
||||
|
||||
@ -137,7 +136,7 @@ class FtileRepeat extends AbstractFtile {
|
||||
final TextBlock tbbackLink1 = backLink1 == null ? null : TextBlockUtils.create(backLink1, fc,
|
||||
HorizontalAlignment.LEFT, spriteContainer, true);
|
||||
conns.add(result.new ConnectionBack(LinkRendering.getColor(backRepeatLinkRendering, arrowColor), tbbackLink1));
|
||||
|
||||
|
||||
final Display out1 = LinkRendering.getDisplay(repeat.getOutLinkRendering());
|
||||
final TextBlock tbout1 = out1 == null ? null : TextBlockUtils.create(out1, fc, HorizontalAlignment.LEFT,
|
||||
spriteContainer, true);
|
||||
|
@ -40,6 +40,7 @@ import java.util.StringTokenizer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.ugraphic.MinMax;
|
||||
|
||||
public class AffineTransformation {
|
||||
@ -88,7 +89,7 @@ public class AffineTransformation {
|
||||
}
|
||||
|
||||
private static AffineTransformation createSimple(String value) {
|
||||
Matcher m = rotate.matcher(value.trim());
|
||||
Matcher m = rotate.matcher(StringUtils.trin(value));
|
||||
if (m.find()) {
|
||||
final double angle = Double.parseDouble(m.group(1));
|
||||
return new AffineTransformation(AffineTransform.getRotateInstance(angle * Math.PI / 180.0));
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 15848 $
|
||||
* Revision $Revision: 16021 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.classdiagram;
|
||||
@ -213,7 +213,7 @@ public class ClassDiagram extends AbstractClassOrObjectDiagram {
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(getSkinParam().getColorMapper(), 1, HtmlColorUtils.WHITE,
|
||||
null, null, 0, 10, null, getSkinParam().handwritten());
|
||||
imageBuilder.addUDrawable(fullLayout);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption.getFileFormat(), os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
|
||||
}
|
||||
|
||||
private RowLayout getRawLayout(int raw) {
|
||||
|
@ -66,6 +66,7 @@ import net.sourceforge.plantuml.command.UmlDiagramFactory;
|
||||
import net.sourceforge.plantuml.command.note.FactoryNoteCommand;
|
||||
import net.sourceforge.plantuml.command.note.FactoryNoteOnEntityCommand;
|
||||
import net.sourceforge.plantuml.command.note.FactoryNoteOnLinkCommand;
|
||||
import net.sourceforge.plantuml.command.note.FactoryTipOnEntityCommand;
|
||||
import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
||||
import net.sourceforge.plantuml.cucadiagram.Link;
|
||||
|
||||
@ -107,6 +108,11 @@ public class ClassDiagramFactory extends UmlDiagramFactory {
|
||||
cmds.add(new CommandLinkLollipop(UmlDiagramType.CLASS));
|
||||
|
||||
cmds.add(new CommandImport());
|
||||
|
||||
final FactoryTipOnEntityCommand factoryTipOnEntityCommand = new FactoryTipOnEntityCommand(new RegexLeaf(
|
||||
"ENTITY", "(" + CommandCreateClass.CODE_NO_DOTDOT + "|[%g][^%g]+[%g])::([^%s]+)"));
|
||||
cmds.add(factoryTipOnEntityCommand.createMultiLine());
|
||||
|
||||
final FactoryNoteOnEntityCommand factoryNoteOnEntityCommand = new FactoryNoteOnEntityCommand(new RegexLeaf(
|
||||
"ENTITY", "(" + CommandCreateClass.CODE + "|[%g][^%g]+[%g])"));
|
||||
cmds.add(factoryNoteOnEntityCommand.createSingleLine());
|
||||
@ -114,6 +120,7 @@ public class ClassDiagramFactory extends UmlDiagramFactory {
|
||||
|
||||
cmds.add(factoryNoteOnEntityCommand.createMultiLine());
|
||||
cmds.add(factoryNoteCommand.createMultiLine());
|
||||
|
||||
cmds.add(new CommandCreateClassMultilines());
|
||||
|
||||
final FactoryNoteOnLinkCommand factoryNoteOnLinkCommand = new FactoryNoteOnLinkCommand();
|
||||
|
@ -57,6 +57,7 @@ import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
public class CommandCreateClass extends SingleLineCommand2<ClassDiagram> {
|
||||
|
||||
public static final String CODE = "[^%s{}%g<>]+";
|
||||
public static final String CODE_NO_DOTDOT = "[^%s{}%g<>:]+";
|
||||
|
||||
enum Mode {
|
||||
EXTENDS, IMPLEMENTS
|
||||
|
@ -110,8 +110,8 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(ClassDiagram diagram, List<String> lines) {
|
||||
StringUtils.trim(lines, false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
|
||||
StringUtils.trimSmart(lines, 1);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
final IEntity entity = executeArg0(diagram, line0);
|
||||
if (entity == null) {
|
||||
return CommandExecutionResult.error("No such entity");
|
||||
@ -155,7 +155,7 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
|
||||
}
|
||||
final String codes = arg.get(keyword, 2);
|
||||
for (String s : codes.split(",")) {
|
||||
final Code other = Code.of(s.trim());
|
||||
final Code other = Code.of(StringUtils.trin(s));
|
||||
final IEntity cl2 = system.getOrCreateLeaf(other, type2, null);
|
||||
LinkType typeLink = new LinkType(LinkDecor.NONE, LinkDecor.EXTENDS);
|
||||
if (type2 == LeafType.INTERFACE && entity.getEntityType() != LeafType.INTERFACE) {
|
||||
|
@ -115,7 +115,7 @@ public class CommandCreateElementFull2 extends SingleLineCommand2<ClassDiagram>
|
||||
final String symbol;
|
||||
if (codeRaw.startsWith("()")) {
|
||||
symbol = "interface";
|
||||
codeRaw = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw.substring(2).trim());
|
||||
codeRaw = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(codeRaw.substring(2)));
|
||||
} else if (codeChar == '(' || codeDisplay == '(') {
|
||||
symbol = "usecase";
|
||||
} else if (codeChar == ':' || codeDisplay == ':') {
|
||||
|
@ -39,6 +39,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.Direction;
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.UmlDiagramType;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.SingleLineCommand2;
|
||||
@ -58,7 +59,6 @@ import net.sourceforge.plantuml.cucadiagram.LinkDecor;
|
||||
import net.sourceforge.plantuml.cucadiagram.LinkType;
|
||||
import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
||||
import net.sourceforge.plantuml.objectdiagram.AbstractClassOrObjectDiagram;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrObjectDiagram> {
|
||||
|
||||
@ -190,24 +190,24 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
|
||||
final Matcher m1 = p1.matcher(labelLink);
|
||||
if (m1.matches()) {
|
||||
firstLabel = m1.group(1);
|
||||
labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m1.group(2).trim(), "\"")
|
||||
.trim();
|
||||
labelLink = StringUtils.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(
|
||||
StringUtils.trin(m1.group(2)), "\""));
|
||||
secondLabel = m1.group(3);
|
||||
} else {
|
||||
final Pattern p2 = MyPattern.cmpile("^[%g]([^%g]+)[%g]([^%g]+)$");
|
||||
final Matcher m2 = p2.matcher(labelLink);
|
||||
if (m2.matches()) {
|
||||
firstLabel = m2.group(1);
|
||||
labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m2.group(2).trim(), "\"")
|
||||
.trim();
|
||||
labelLink = StringUtils.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(
|
||||
StringUtils.trin(m2.group(2)), "\""));
|
||||
secondLabel = null;
|
||||
} else {
|
||||
final Pattern p3 = MyPattern.cmpile("^([^%g]+)[%g]([^%g]+)[%g]$");
|
||||
final Matcher m3 = p3.matcher(labelLink);
|
||||
if (m3.matches()) {
|
||||
firstLabel = null;
|
||||
labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m3.group(1).trim(),
|
||||
"\"").trim();
|
||||
labelLink = StringUtils.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(
|
||||
StringUtils.trin(m3.group(1)), "\""));
|
||||
secondLabel = m3.group(2);
|
||||
}
|
||||
}
|
||||
@ -225,16 +225,16 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
|
||||
labelLink = null;
|
||||
} else if (labelLink != null && labelLink.startsWith("< ")) {
|
||||
linkArrow = LinkArrow.BACKWARD;
|
||||
labelLink = labelLink.substring(2).trim();
|
||||
labelLink = StringUtils.trin(labelLink.substring(2));
|
||||
} else if (labelLink != null && labelLink.startsWith("> ")) {
|
||||
linkArrow = LinkArrow.DIRECT_NORMAL;
|
||||
labelLink = labelLink.substring(2).trim();
|
||||
labelLink = StringUtils.trin(labelLink.substring(2));
|
||||
} else if (labelLink != null && labelLink.endsWith(" >")) {
|
||||
linkArrow = LinkArrow.DIRECT_NORMAL;
|
||||
labelLink = labelLink.substring(0, labelLink.length() - 2).trim();
|
||||
labelLink = StringUtils.trin(labelLink.substring(0, labelLink.length() - 2));
|
||||
} else if (labelLink != null && labelLink.endsWith(" <")) {
|
||||
linkArrow = LinkArrow.BACKWARD;
|
||||
labelLink = labelLink.substring(0, labelLink.length() - 2).trim();
|
||||
labelLink = StringUtils.trin(labelLink.substring(0, labelLink.length() - 2));
|
||||
}
|
||||
|
||||
Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(labelLink), queue, firstLabel, secondLabel,
|
||||
@ -295,6 +295,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
|
||||
diagram.getLabeldistance(), diagram.getLabelangle());
|
||||
|
||||
diagram.resetPragmaLabel();
|
||||
applyStyle(arg.getLazzy("ARROW_STYLE", 0), link);
|
||||
addLink(diagram, link, arg.get("HEADER", 0));
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
@ -355,7 +356,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
|
||||
if (s == null) {
|
||||
return LinkDecor.NONE;
|
||||
}
|
||||
s = s.trim();
|
||||
s = StringUtils.trin(s);
|
||||
if ("<|".equals(s)) {
|
||||
return LinkDecor.EXTENDS;
|
||||
}
|
||||
@ -384,7 +385,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
|
||||
if (s == null) {
|
||||
return LinkDecor.NONE;
|
||||
}
|
||||
s = s.trim();
|
||||
s = StringUtils.trin(s);
|
||||
if ("|>".equals(s)) {
|
||||
return LinkDecor.EXTENDS;
|
||||
}
|
||||
|
@ -104,11 +104,13 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
|
||||
if (arg.get("LOL_THEN_ENT", 0) == null) {
|
||||
assert arg.get("ENT_THEN_LOL", 0) != null;
|
||||
cl1 = diagram.getOrCreateLeaf(ent1, null, null);
|
||||
cl2 = diagram.createLeaf(cl1.getCode().addSuffix(suffix), Display.getWithNewlines(ent2), LeafType.LOLLIPOP, null);
|
||||
cl2 = diagram.createLeaf(cl1.getCode().addSuffix(suffix), Display.getWithNewlines(ent2), LeafType.LOLLIPOP,
|
||||
null);
|
||||
normalEntity = cl1;
|
||||
} else {
|
||||
cl2 = diagram.getOrCreateLeaf(ent2, null, null);
|
||||
cl1 = diagram.createLeaf(cl2.getCode().addSuffix(suffix), Display.getWithNewlines(ent1), LeafType.LOLLIPOP, null);
|
||||
cl1 = diagram.createLeaf(cl2.getCode().addSuffix(suffix), Display.getWithNewlines(ent1), LeafType.LOLLIPOP,
|
||||
null);
|
||||
normalEntity = cl2;
|
||||
}
|
||||
|
||||
@ -132,22 +134,24 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
|
||||
final Matcher m1 = p1.matcher(labelLink);
|
||||
if (m1.matches()) {
|
||||
firstLabel = m1.group(1);
|
||||
labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m1.group(2).trim()).trim();
|
||||
labelLink = StringUtils.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils
|
||||
.trin(m1.group(2))));
|
||||
secondLabel = m1.group(3);
|
||||
} else {
|
||||
final Pattern p2 = MyPattern.cmpile("^\"([^\"]+)\"([^\"]+)$");
|
||||
final Matcher m2 = p2.matcher(labelLink);
|
||||
if (m2.matches()) {
|
||||
firstLabel = m2.group(1);
|
||||
labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m2.group(2).trim()).trim();
|
||||
labelLink = StringUtils.trin(StringUtils
|
||||
.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m2.group(2))));
|
||||
secondLabel = null;
|
||||
} else {
|
||||
final Pattern p3 = MyPattern.cmpile("^([^\"]+)\"([^\"]+)\"$");
|
||||
final Matcher m3 = p3.matcher(labelLink);
|
||||
if (m3.matches()) {
|
||||
firstLabel = null;
|
||||
labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m3.group(1).trim())
|
||||
.trim();
|
||||
labelLink = StringUtils.trin(StringUtils
|
||||
.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m3.group(1))));
|
||||
secondLabel = m3.group(2);
|
||||
}
|
||||
}
|
||||
@ -212,10 +216,10 @@ final public class CommandLinkLollipop extends SingleLineCommand2<AbstractClassO
|
||||
|
||||
private String getQueue(RegexResult arg) {
|
||||
if (arg.get("LOL_THEN_ENT", 0) != null) {
|
||||
return arg.get("LOL_THEN_ENT", 0).trim();
|
||||
return StringUtils.trin(arg.get("LOL_THEN_ENT", 0));
|
||||
}
|
||||
if (arg.get("ENT_THEN_LOL", 0) != null) {
|
||||
return arg.get("ENT_THEN_LOL", 0).trim();
|
||||
return StringUtils.trin(arg.get("ENT_THEN_LOL", 0));
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public class CommandMouseOver extends CommandMultilines2<ClassDiagram> {
|
||||
|
||||
public CommandExecutionResult executeNow(ClassDiagram system, List<String> lines) {
|
||||
StringUtils.trim(lines, false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
Code code = Code.of(line0.get("NAME1", 0));
|
||||
if (code == null) {
|
||||
code = Code.of(line0.get("NAME3", 0));
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 12235 $
|
||||
* Revision $Revision: 16197 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.classdiagram.command;
|
||||
@ -38,6 +38,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.cucadiagram.LeafType;
|
||||
|
||||
class JavaClass {
|
||||
@ -54,9 +55,9 @@ class JavaClass {
|
||||
if (p == null) {
|
||||
p = "";
|
||||
}
|
||||
final StringTokenizer st = new StringTokenizer(p.trim(), ",");
|
||||
final StringTokenizer st = new StringTokenizer(StringUtils.trin(p), ",");
|
||||
while (st.hasMoreTokens()) {
|
||||
this.parents.add(st.nextToken().trim().replaceAll("\\<.*", ""));
|
||||
this.parents.add(StringUtils.trin(st.nextToken()).replaceAll("\\<.*", ""));
|
||||
}
|
||||
this.type = type;
|
||||
this.parentType = parentType;
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 14726 $
|
||||
* Revision $Revision: 16194 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.classdiagram.command;
|
||||
@ -72,7 +72,7 @@ class JavaFile {
|
||||
String javaPackage = null;
|
||||
String s;
|
||||
while ((s = br.readLine()) != null) {
|
||||
s = s.trim();
|
||||
s = StringUtils.trin(s);
|
||||
final Matcher matchPackage = packageDefinition.matcher(s);
|
||||
if (matchPackage.find()) {
|
||||
javaPackage = matchPackage.group(1);
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 12235 $
|
||||
* Revision $Revision: 16194 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.code;
|
||||
@ -38,6 +38,7 @@ import java.io.StringReader;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.preproc.ReadLine;
|
||||
import net.sourceforge.plantuml.preproc.ReadLineReader;
|
||||
@ -98,11 +99,11 @@ public class ArobaseStringCompressor implements StringCompressor {
|
||||
}
|
||||
|
||||
private String clean(String s) {
|
||||
s = s.trim();
|
||||
s = StringUtils.trin(s);
|
||||
s = clean1(s);
|
||||
s = s.replaceAll("@enduml[^\\n\\r]*", "");
|
||||
s = s.replaceAll("@startuml[^\\n\\r]*", "");
|
||||
s = s.trim();
|
||||
s = StringUtils.trin(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,86 @@
|
||||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2014, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.sourceforge.net
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 12235 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.core.Diagram;
|
||||
|
||||
public class CommandDecoratorMultine<D extends Diagram> implements Command<D> {
|
||||
|
||||
private final SingleLineCommand2<D> cmd;
|
||||
|
||||
public CommandDecoratorMultine(SingleLineCommand2<D> cmd) {
|
||||
this.cmd = cmd;
|
||||
}
|
||||
|
||||
public CommandExecutionResult execute(D diagram, List<String> lines) {
|
||||
final String concat = concat(lines);
|
||||
return cmd.execute(diagram, Collections.singletonList(concat));
|
||||
}
|
||||
|
||||
public CommandControl isValid(List<String> lines) {
|
||||
if (cmd.isCommandForbidden()) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
final String concat = concat(lines);
|
||||
if (cmd.isForbidden(concat)) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
final CommandControl tmp = cmd.isValid(Collections.singletonList(concat));
|
||||
if (tmp == CommandControl.OK_PARTIAL) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
if (tmp == CommandControl.OK) {
|
||||
return tmp;
|
||||
}
|
||||
return CommandControl.OK_PARTIAL;
|
||||
}
|
||||
|
||||
private String concat(List<String> lines) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (String line : lines) {
|
||||
sb.append(line);
|
||||
sb.append(StringUtils.hiddenNewLine());
|
||||
}
|
||||
return sb.substring(0, sb.length() - 1);
|
||||
}
|
||||
|
||||
public String[] getDescription() {
|
||||
return cmd.getDescription();
|
||||
}
|
||||
|
||||
}
|
@ -33,20 +33,25 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.AbstractPSystem;
|
||||
|
||||
public class CommandExecutionResult {
|
||||
|
||||
private final String error;
|
||||
private final AbstractPSystem newDiagram;
|
||||
private final List<String> debugLines;
|
||||
|
||||
private CommandExecutionResult(String error, AbstractPSystem newDiagram) {
|
||||
private CommandExecutionResult(String error, AbstractPSystem newDiagram, List<String> debugLines) {
|
||||
this.error = error;
|
||||
this.newDiagram = newDiagram;
|
||||
this.debugLines = debugLines;
|
||||
}
|
||||
|
||||
public CommandExecutionResult withDiagram(AbstractPSystem newDiagram) {
|
||||
return new CommandExecutionResult(error, newDiagram);
|
||||
return new CommandExecutionResult(error, newDiagram, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -55,15 +60,37 @@ public class CommandExecutionResult {
|
||||
}
|
||||
|
||||
public static CommandExecutionResult newDiagram(AbstractPSystem result) {
|
||||
return new CommandExecutionResult(null, result);
|
||||
return new CommandExecutionResult(null, result, null);
|
||||
}
|
||||
|
||||
public static CommandExecutionResult ok() {
|
||||
return new CommandExecutionResult(null, null);
|
||||
return new CommandExecutionResult(null, null, null);
|
||||
}
|
||||
|
||||
public static CommandExecutionResult error(String error) {
|
||||
return new CommandExecutionResult(error, null);
|
||||
return new CommandExecutionResult(error, null, null);
|
||||
}
|
||||
|
||||
public static CommandExecutionResult error(String error, Throwable t) {
|
||||
return new CommandExecutionResult(error, null, getStackTrace(t));
|
||||
}
|
||||
|
||||
public static List<String> getStackTrace(Throwable exception) {
|
||||
final List<String> result = new ArrayList<String>();
|
||||
result.add(exception.toString());
|
||||
for (StackTraceElement ste : exception.getStackTrace()) {
|
||||
result.add(" " + ste.toString());
|
||||
}
|
||||
if (exception.getCause() != null) {
|
||||
final Throwable cause = exception.getCause();
|
||||
result.add(" ");
|
||||
result.add("Caused by " + cause.toString());
|
||||
for (StackTraceElement ste : cause.getStackTrace()) {
|
||||
result.add(" " + ste.toString());
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean isOk() {
|
||||
@ -81,4 +108,8 @@ public class CommandExecutionResult {
|
||||
return newDiagram;
|
||||
}
|
||||
|
||||
public List<String> getDebugLines() {
|
||||
return debugLines;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 12235 $
|
||||
* Revision $Revision: 16196 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
@ -37,6 +37,7 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.core.Diagram;
|
||||
|
||||
@ -61,7 +62,7 @@ public abstract class CommandMultilines<S extends Diagram> implements Command<S>
|
||||
if (isCommandForbidden()) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
Matcher m1 = starting.matcher(lines.get(0).trim());
|
||||
Matcher m1 = starting.matcher(StringUtils.trin(lines.get(0)));
|
||||
if (m1.matches() == false) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
@ -69,7 +70,7 @@ public abstract class CommandMultilines<S extends Diagram> implements Command<S>
|
||||
return CommandControl.OK_PARTIAL;
|
||||
}
|
||||
|
||||
m1 = MyPattern.cmpile(getPatternEnd()).matcher(lines.get(lines.size() - 1).trim());
|
||||
m1 = MyPattern.cmpile(getPatternEnd()).matcher(StringUtils.trin(lines.get(lines.size() - 1)));
|
||||
if (m1.matches() == false) {
|
||||
return CommandControl.OK_PARTIAL;
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ package net.sourceforge.plantuml.command;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.command.regex.RegexConcat;
|
||||
import net.sourceforge.plantuml.core.Diagram;
|
||||
@ -65,7 +66,7 @@ public abstract class CommandMultilines2<S extends Diagram> implements Command<S
|
||||
if (isCommandForbidden()) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
final boolean result1 = starting.match(lines.get(0).trim());
|
||||
final boolean result1 = starting.match(StringUtils.trin(lines.get(0)));
|
||||
if (result1 == false) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
@ -73,7 +74,7 @@ public abstract class CommandMultilines2<S extends Diagram> implements Command<S
|
||||
return CommandControl.OK_PARTIAL;
|
||||
}
|
||||
|
||||
final Matcher m1 = MyPattern.cmpile(getPatternEnd()).matcher(lines.get(lines.size() - 1).trim());
|
||||
final Matcher m1 = MyPattern.cmpile(getPatternEnd()).matcher(StringUtils.trinNoTrace(lines.get(lines.size() - 1)));
|
||||
if (m1.matches() == false) {
|
||||
return CommandControl.OK_PARTIAL;
|
||||
}
|
||||
|
102
src/net/sourceforge/plantuml/command/CommandMultilines3.java
Normal file
102
src/net/sourceforge/plantuml/command/CommandMultilines3.java
Normal file
@ -0,0 +1,102 @@
|
||||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2014, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.sourceforge.net
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 5041 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.regex.RegexConcat;
|
||||
import net.sourceforge.plantuml.core.Diagram;
|
||||
|
||||
public abstract class CommandMultilines3<S extends Diagram> implements Command<S> {
|
||||
|
||||
private final RegexConcat starting;
|
||||
|
||||
private final MultilinesStrategy strategy;
|
||||
|
||||
public CommandMultilines3(RegexConcat patternStart, MultilinesStrategy strategy) {
|
||||
if (patternStart.getPattern().startsWith("^") == false || patternStart.getPattern().endsWith("$") == false) {
|
||||
throw new IllegalArgumentException("Bad pattern " + patternStart.getPattern());
|
||||
}
|
||||
this.strategy = strategy;
|
||||
this.starting = patternStart;
|
||||
}
|
||||
|
||||
public abstract RegexConcat getPatternEnd2();
|
||||
|
||||
public String[] getDescription() {
|
||||
return new String[] { "START: " + starting.getPattern(), "END: " + getPatternEnd2().getPattern() };
|
||||
}
|
||||
|
||||
final public CommandControl isValid(List<String> lines) {
|
||||
lines = strategy.filter(lines);
|
||||
if (isCommandForbidden()) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
final boolean result1 = starting.match(StringUtils.trin(lines.get(0)));
|
||||
if (result1 == false) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
if (lines.size() == 1) {
|
||||
return CommandControl.OK_PARTIAL;
|
||||
}
|
||||
|
||||
final String potentialLast = StringUtils.trinNoTrace(lines.get(lines.size() - 1));
|
||||
final boolean m1 = getPatternEnd2().match(potentialLast);
|
||||
if (m1 == false) {
|
||||
return CommandControl.OK_PARTIAL;
|
||||
}
|
||||
|
||||
actionIfCommandValid();
|
||||
return CommandControl.OK;
|
||||
}
|
||||
|
||||
public final CommandExecutionResult execute(S system, List<String> lines) {
|
||||
return executeNow(system, strategy.filter(lines));
|
||||
}
|
||||
|
||||
public abstract CommandExecutionResult executeNow(S system, List<String> lines);
|
||||
|
||||
protected boolean isCommandForbidden() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void actionIfCommandValid() {
|
||||
}
|
||||
|
||||
protected final RegexConcat getStartingPattern() {
|
||||
return starting;
|
||||
}
|
||||
|
||||
}
|
@ -37,6 +37,7 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.core.Diagram;
|
||||
|
||||
@ -70,7 +71,7 @@ public abstract class CommandMultilinesBracket<S extends Diagram> implements Com
|
||||
if (isCommandForbidden()) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
final Matcher m1 = starting.matcher(lines.get(0).trim());
|
||||
final Matcher m1 = starting.matcher(StringUtils.trin(lines.get(0)));
|
||||
if (m1.matches() == false) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
@ -80,7 +81,7 @@ public abstract class CommandMultilinesBracket<S extends Diagram> implements Com
|
||||
|
||||
int level = 1;
|
||||
for (int i = 1; i < lines.size(); i++) {
|
||||
final String s = lines.get(i).trim();
|
||||
final String s = StringUtils.trin(lines.get(i));
|
||||
if (isLineConsistent(s, level) == false) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 14726 $
|
||||
* Revision $Revision: 16195 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
@ -54,7 +54,7 @@ public class CommandMultilinesFooter extends CommandMultilines<UmlDiagram> {
|
||||
|
||||
public CommandExecutionResult execute(final UmlDiagram diagram, List<String> lines) {
|
||||
StringUtils.trim(lines, false);
|
||||
final Matcher m = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final Matcher m = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
if (m.find() == false) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 14726 $
|
||||
* Revision $Revision: 16195 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
@ -55,7 +55,7 @@ public class CommandMultilinesHeader extends CommandMultilines<UmlDiagram> {
|
||||
|
||||
public CommandExecutionResult execute(final UmlDiagram diagram, List<String> lines) {
|
||||
StringUtils.trim(lines, false);
|
||||
final Matcher m = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final Matcher m = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
if (m.find() == false) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
@ -65,8 +65,8 @@ public class CommandMultilinesLegend extends CommandMultilines2<UmlDiagram> {
|
||||
|
||||
@Override
|
||||
public CommandExecutionResult executeNow(UmlDiagram diagram, List<String> lines) {
|
||||
StringUtils.trim(lines, false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
|
||||
StringUtils.trimSmart(lines, 1);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
final String align = line0.get("ALIGN", 0);
|
||||
final String valign = line0.get("VALIGN", 0);
|
||||
final Display strings = Display.create(lines.subList(1, lines.size() - 1)).removeEmptyColumns();
|
||||
|
@ -72,13 +72,13 @@ public class CommandSkinParamMultilines extends CommandMultilinesBracket<UmlDiag
|
||||
|
||||
@Override
|
||||
protected boolean isLineConsistent(String line, int level) {
|
||||
line = line.trim();
|
||||
line = StringUtils.trin(line);
|
||||
return p1.matcher(line).matches();
|
||||
}
|
||||
|
||||
public CommandExecutionResult execute(UmlDiagram diagram, List<String> lines) {
|
||||
final Context context = new Context();
|
||||
final Matcher mStart = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final Matcher mStart = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
if (mStart.find() == false) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public final class FactorySpriteCommand implements SingleMultiFactoryCommand<Uml
|
||||
|
||||
public CommandExecutionResult executeNow(final UmlDiagram system, List<String> lines) {
|
||||
StringUtils.trim(lines, true);
|
||||
final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
|
||||
final List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
|
||||
if (strings.size() == 0) {
|
||||
@ -130,7 +130,7 @@ public final class FactorySpriteCommand implements SingleMultiFactoryCommand<Uml
|
||||
private String concat(final List<String> strings) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (String s : strings) {
|
||||
sb.append(s.trim());
|
||||
sb.append(StringUtils.trin(s));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -36,6 +36,8 @@ package net.sourceforge.plantuml.command;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public enum MultilinesStrategy {
|
||||
REMOVE_STARTING_QUOTE, KEEP_STARTING_QUOTE;
|
||||
|
||||
@ -56,6 +58,6 @@ public enum MultilinesStrategy {
|
||||
}
|
||||
|
||||
private boolean hasStartingQuote(String s) {
|
||||
return s.trim().startsWith("\'");
|
||||
return StringUtils.trinNoTrace(s).startsWith("\'");
|
||||
}
|
||||
}
|
||||
|
@ -51,13 +51,13 @@ public abstract class PSystemAbstractFactory implements PSystemFactory {
|
||||
|
||||
final protected AbstractPSystem buildEmptyError(UmlSource source) {
|
||||
final PSystemError result = new PSystemError(source, new ErrorUml(ErrorUmlType.SYNTAX_ERROR,
|
||||
"Empty description", 1));
|
||||
"Empty description", 1), null);
|
||||
result.setSource(source);
|
||||
return result;
|
||||
}
|
||||
|
||||
final protected PSystemError buildEmptyError(UmlSource source, String err) {
|
||||
final PSystemError result = new PSystemError(source, new ErrorUml(ErrorUmlType.EXECUTION_ERROR, err, 1));
|
||||
final PSystemError result = new PSystemError(source, new ErrorUml(ErrorUmlType.EXECUTION_ERROR, err, 1), null);
|
||||
result.setSource(source);
|
||||
return result;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public abstract class PSystemBasicFactory<P extends AbstractPSystem> extends PSy
|
||||
system = executeLine(system, s);
|
||||
if (system == null) {
|
||||
return new PSystemError(source, new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?",
|
||||
it.currentNum() - 1));
|
||||
it.currentNum() - 1), null);
|
||||
}
|
||||
}
|
||||
if (system != null) {
|
||||
|
@ -73,7 +73,7 @@ public abstract class PSystemSingleLineFactory extends PSystemAbstractFactory {
|
||||
final AbstractPSystem sys = executeLine(s);
|
||||
if (sys == null) {
|
||||
return new PSystemError(source, new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?",
|
||||
it.currentNum() - 1));
|
||||
it.currentNum() - 1), null);
|
||||
}
|
||||
sys.setSource(source);
|
||||
return sys;
|
||||
|
@ -33,8 +33,6 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.Log;
|
||||
@ -52,22 +50,18 @@ public class ProtectedCommand<S extends Diagram> implements Command<S> {
|
||||
public CommandExecutionResult execute(S system, List<String> lines) {
|
||||
try {
|
||||
final CommandExecutionResult result = cmd.execute(system, lines);
|
||||
// if (result.isOk()) {
|
||||
// // TRACECOMMAND
|
||||
// System.err.println("CMD = " + cmd.getClass());
|
||||
// }
|
||||
// if (result.isOk()) {
|
||||
// // TRACECOMMAND
|
||||
// System.err.println("CMD = " + cmd.getClass());
|
||||
// }
|
||||
return result;
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
final PrintWriter pw = new PrintWriter(baos);
|
||||
t.printStackTrace(pw);
|
||||
Log.error("Error " + t);
|
||||
String msg = "You should send a mail to plantuml@gmail.com with this log (V" + Version.versionString()
|
||||
+ ")";
|
||||
Log.error(msg);
|
||||
msg += " " + new String(baos.toByteArray());
|
||||
return CommandExecutionResult.error(msg);
|
||||
msg += " " + t.toString();
|
||||
return CommandExecutionResult.error(msg, t);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 14321 $
|
||||
* Revision $Revision: 16195 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
@ -67,7 +67,7 @@ public abstract class SingleLineCommand<S extends Diagram> implements Command<S>
|
||||
if (isCommandForbidden()) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
final String line = lines.get(0).trim();
|
||||
final String line = StringUtils.trin(lines.get(0));
|
||||
final Matcher m = pattern.matcher(line);
|
||||
final boolean result = m.find();
|
||||
if (result) {
|
||||
@ -87,7 +87,7 @@ public abstract class SingleLineCommand<S extends Diagram> implements Command<S>
|
||||
if (lines.size() != 1) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
final String line = lines.get(0).trim();
|
||||
final String line = StringUtils.trin(lines.get(0));
|
||||
if (isForbidden(line)) {
|
||||
return CommandExecutionResult.error("Forbidden line " + line);
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ package net.sourceforge.plantuml.command;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.PSystemError;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.regex.RegexConcat;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
import net.sourceforge.plantuml.core.Diagram;
|
||||
@ -66,7 +67,7 @@ public abstract class SingleLineCommand2<S extends Diagram> implements Command<S
|
||||
if (isCommandForbidden()) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
final String line = lines.get(0).trim();
|
||||
final String line = StringUtils.trin(lines.get(0));
|
||||
final boolean result = pattern.match(line);
|
||||
if (result) {
|
||||
actionIfCommandValid();
|
||||
@ -85,7 +86,7 @@ public abstract class SingleLineCommand2<S extends Diagram> implements Command<S
|
||||
if (lines.size() != 1) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
final String line = lines.get(0).trim();
|
||||
final String line = StringUtils.trin(lines.get(0));
|
||||
if (isForbidden(line)) {
|
||||
return CommandExecutionResult.error("Forbidden line " + line);
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ import net.sourceforge.plantuml.ErrorUml;
|
||||
import net.sourceforge.plantuml.ErrorUmlType;
|
||||
import net.sourceforge.plantuml.OptionFlags;
|
||||
import net.sourceforge.plantuml.PSystemError;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.classdiagram.command.CommandHideShow;
|
||||
import net.sourceforge.plantuml.classdiagram.command.CommandHideShow3;
|
||||
import net.sourceforge.plantuml.core.Diagram;
|
||||
@ -80,8 +81,7 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
AbstractPSystem sys = createEmptyDiagram();
|
||||
|
||||
while (it.hasNext()) {
|
||||
final String line = it.next();
|
||||
if (StartUtils.isArobaseEndDiagram(line)) {
|
||||
if (StartUtils.isArobaseEndDiagram(it.peek())) {
|
||||
final String err = checkFinalError(sys);
|
||||
if (err != null) {
|
||||
return buildEmptyError(source, err);
|
||||
@ -99,7 +99,7 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
sys.setSource(source);
|
||||
return sys;
|
||||
}
|
||||
sys = executeOneLine(sys, source, it, line);
|
||||
sys = executeOneLine(sys, source, it);
|
||||
if (sys instanceof PSystemError) {
|
||||
return sys;
|
||||
}
|
||||
@ -109,11 +109,10 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
|
||||
}
|
||||
|
||||
private AbstractPSystem executeOneLine(AbstractPSystem sys, UmlSource source, final IteratorCounter it,
|
||||
final String line) {
|
||||
final CommandControl commandControl = isValid(Arrays.asList(line));
|
||||
private AbstractPSystem executeOneLine(AbstractPSystem sys, UmlSource source, final IteratorCounter it) {
|
||||
final CommandControl commandControl = isValid2(it);
|
||||
if (commandControl == CommandControl.NOT_OK) {
|
||||
final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?", it.currentNum() - 1);
|
||||
final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?", it.currentNum());
|
||||
if (OptionFlags.getInstance().isUseSuggestEngine()) {
|
||||
final SuggestEngine engine = new SuggestEngine(source, this);
|
||||
final SuggestEngineResult result = engine.tryToSuggest(sys);
|
||||
@ -121,20 +120,21 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
err.setSuggest(result);
|
||||
}
|
||||
}
|
||||
sys = new PSystemError(source, err);
|
||||
sys = new PSystemError(source, err, null);
|
||||
} else if (commandControl == CommandControl.OK_PARTIAL) {
|
||||
final boolean ok = manageMultiline(sys, line, it);
|
||||
final boolean ok = manageMultiline(it, sys);
|
||||
if (ok == false) {
|
||||
sys = new PSystemError(source, new ErrorUml(ErrorUmlType.EXECUTION_ERROR, "Syntax Error?",
|
||||
it.currentNum() - 1));
|
||||
sys = new PSystemError(source, new ErrorUml(ErrorUmlType.EXECUTION_ERROR, "Strange Syntax Error?",
|
||||
it.currentNum() - 1), null);
|
||||
|
||||
}
|
||||
} else if (commandControl == CommandControl.OK) {
|
||||
Command cmd = createCommand(Arrays.asList(line));
|
||||
final String line = it.next();
|
||||
Command cmd = getFirstCommandOkForLines(Arrays.asList(line));
|
||||
final CommandExecutionResult result = sys.executeCommand(cmd, Arrays.asList(line));
|
||||
if (result.isOk() == false) {
|
||||
sys = new PSystemError(source, new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(),
|
||||
it.currentNum() - 1));
|
||||
it.currentNum() - 1), result.getDebugLines());
|
||||
}
|
||||
if (result.getNewDiagram() != null) {
|
||||
sys = result.getNewDiagram();
|
||||
@ -145,37 +145,67 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
return sys;
|
||||
}
|
||||
|
||||
private boolean manageMultiline(AbstractPSystem system, final String init, IteratorCounter it) {
|
||||
final List<String> lines = new ArrayList<String>();
|
||||
addOneSingleLineManageEmbedded(lines, init, it);
|
||||
while (it.hasNext()) {
|
||||
final String s = it.next();
|
||||
if (StartUtils.isArobaseEndDiagram(s)) {
|
||||
return false;
|
||||
public CommandControl isValid2(final IteratorCounter it) {
|
||||
final List<String> asList = Arrays.asList(it.peek());
|
||||
for (Command cmd : cmds) {
|
||||
final CommandControl result = cmd.isValid(asList);
|
||||
if (result == CommandControl.OK) {
|
||||
return result;
|
||||
}
|
||||
addOneSingleLineManageEmbedded(lines, s, it);
|
||||
final CommandControl commandControl = isValid(lines);
|
||||
if (commandControl == CommandControl.NOT_OK) {
|
||||
// throw new IllegalStateException();
|
||||
return false;
|
||||
if (result == CommandControl.OK_PARTIAL && isMultilineCommandOk(it.cloneMe(), cmd) != null) {
|
||||
return result;
|
||||
}
|
||||
if (commandControl == CommandControl.OK) {
|
||||
final Command cmd = createCommand(lines);
|
||||
final CommandExecutionResult result = system.executeCommand(cmd, lines);
|
||||
return result.isOk();
|
||||
}
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
|
||||
public CommandControl goForwardMultiline(final IteratorCounter it) {
|
||||
final List<String> asList = Arrays.asList(it.peek());
|
||||
for (Command cmd : cmds) {
|
||||
final CommandControl result = cmd.isValid(asList);
|
||||
if (result == CommandControl.OK) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
if (result == CommandControl.OK_PARTIAL && isMultilineCommandOk(it, cmd) != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
private boolean manageMultiline(IteratorCounter it, AbstractPSystem system) {
|
||||
for (Command cmd : cmds) {
|
||||
if (isMultilineCommandOk(it.cloneMe(), cmd) != null) {
|
||||
final List<String> lines = isMultilineCommandOk(it, cmd);
|
||||
return cmd.execute(system, lines).isOk();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private void addOneSingleLineManageEmbedded(final List<String> lines, final String linetoBeAdded, IteratorCounter it) {
|
||||
private List<String> isMultilineCommandOk(IteratorCounter it, Command cmd) {
|
||||
final List<String> lines = new ArrayList<String>();
|
||||
while (it.hasNext()) {
|
||||
addOneSingleLineManageEmbedded(it, lines);
|
||||
final CommandControl result = cmd.isValid(lines);
|
||||
if (result == CommandControl.NOT_OK) {
|
||||
return null;
|
||||
}
|
||||
if (result == CommandControl.OK) {
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addOneSingleLineManageEmbedded(IteratorCounter it, final List<String> lines) {
|
||||
final String linetoBeAdded = it.next();
|
||||
lines.add(linetoBeAdded);
|
||||
if (linetoBeAdded.trim().equals("{{")) {
|
||||
if (StringUtils.trinNoTrace(linetoBeAdded).equals("{{")) {
|
||||
while (it.hasNext()) {
|
||||
final String s = it.next();
|
||||
lines.add(s);
|
||||
if (s.trim().equals("}}")) {
|
||||
if (StringUtils.trinNoTrace(s).equals("}}")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -187,11 +217,15 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
public String checkFinalError(AbstractPSystem system) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
final public CommandControl isValid(List<String> lines) {
|
||||
for (Command cmd : cmds) {
|
||||
final CommandControl result = cmd.isValid(lines);
|
||||
if (result == CommandControl.OK || result == CommandControl.OK_PARTIAL) {
|
||||
if (result == CommandControl.OK) {
|
||||
return result;
|
||||
}
|
||||
if (result == CommandControl.OK_PARTIAL) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -199,13 +233,11 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
|
||||
}
|
||||
|
||||
final public Command createCommand(List<String> lines) {
|
||||
private Command getFirstCommandOkForLines(List<String> lines) {
|
||||
for (Command cmd : cmds) {
|
||||
final CommandControl result = cmd.isValid(lines);
|
||||
if (result == CommandControl.OK) {
|
||||
return cmd;
|
||||
} else if (result == CommandControl.OK_PARTIAL) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
@ -244,11 +276,10 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
cmds.add(factorySpriteCommand.createMultiLine());
|
||||
cmds.add(factorySpriteCommand.createSingleLine());
|
||||
cmds.add(new CommandSpriteFile());
|
||||
|
||||
|
||||
cmds.add(new CommandHideShow3());
|
||||
cmds.add(new CommandHideShow());
|
||||
|
||||
|
||||
}
|
||||
|
||||
final public List<String> getDescription() {
|
||||
|
@ -88,7 +88,7 @@ public final class FactoryNoteActivityCommand implements SingleMultiFactoryComma
|
||||
|
||||
public final CommandExecutionResult executeNow(final ActivityDiagram system, List<String> lines) {
|
||||
// StringUtils.trim(lines, true);
|
||||
final RegexResult arg = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final RegexResult arg = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
Display strings = Display.create(StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1)));
|
||||
|
||||
Url url = null;
|
||||
|
@ -96,7 +96,7 @@ public final class FactoryNoteCommand implements SingleMultiFactoryCommand<Abstr
|
||||
|
||||
public CommandExecutionResult executeNow(final AbstractEntityDiagram system, List<String> lines) {
|
||||
// StringUtils.trim(lines, false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
|
||||
final List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
|
||||
|
||||
|
@ -118,7 +118,7 @@ public final class FactoryNoteOnEntityCommand implements SingleMultiFactoryComma
|
||||
|
||||
public CommandExecutionResult executeNow(final AbstractEntityDiagram system, List<String> lines) {
|
||||
// StringUtils.trim(lines, false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
|
||||
List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
|
||||
Url url = null;
|
||||
|
@ -0,0 +1,163 @@
|
||||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2014, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.sourceforge.net
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 7558 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command.note;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.UrlBuilder;
|
||||
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
|
||||
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
|
||||
import net.sourceforge.plantuml.command.Command;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||
import net.sourceforge.plantuml.command.MultilinesStrategy;
|
||||
import net.sourceforge.plantuml.command.regex.IRegex;
|
||||
import net.sourceforge.plantuml.command.regex.RegexConcat;
|
||||
import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
import net.sourceforge.plantuml.cucadiagram.Code;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.cucadiagram.IEntity;
|
||||
import net.sourceforge.plantuml.cucadiagram.LeafType;
|
||||
import net.sourceforge.plantuml.cucadiagram.Link;
|
||||
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
|
||||
import net.sourceforge.plantuml.cucadiagram.LinkType;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
|
||||
public final class FactoryTipOnEntityCommand implements SingleMultiFactoryCommand<AbstractEntityDiagram> {
|
||||
|
||||
private final IRegex partialPattern;
|
||||
|
||||
public FactoryTipOnEntityCommand(IRegex partialPattern) {
|
||||
this.partialPattern = partialPattern;
|
||||
}
|
||||
|
||||
private RegexConcat getRegexConcatMultiLine(IRegex partialPattern) {
|
||||
return new RegexConcat(new RegexLeaf("^note[%s]+"), //
|
||||
new RegexLeaf("POSITION", "(right|left)"), //
|
||||
new RegexLeaf("[%s]+of[%s]+"), partialPattern, //
|
||||
new RegexLeaf("[%s]*"), //
|
||||
new RegexLeaf("COLOR", "(" + HtmlColorUtils.COLOR_REGEXP + ")?"), //
|
||||
new RegexLeaf("[%s]*\\{?"), //
|
||||
new RegexLeaf("$") //
|
||||
);
|
||||
}
|
||||
|
||||
public Command<AbstractEntityDiagram> createSingleLine() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Command<AbstractEntityDiagram> createMultiLine() {
|
||||
return new CommandMultilines2<AbstractEntityDiagram>(getRegexConcatMultiLine(partialPattern),
|
||||
MultilinesStrategy.KEEP_STARTING_QUOTE) {
|
||||
|
||||
@Override
|
||||
public String getPatternEnd() {
|
||||
return "(?i)^(end[%s]?note|\\})$";
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(final AbstractEntityDiagram system, List<String> lines) {
|
||||
// StringUtils.trim(lines, false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
|
||||
List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
|
||||
Url url = null;
|
||||
if (strings.size() > 0) {
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(system.getSkinParam().getValue("topurl"),
|
||||
ModeUrl.STRICT);
|
||||
url = urlBuilder.getUrl(strings.get(0));
|
||||
}
|
||||
if (url != null) {
|
||||
strings = strings.subList(1, strings.size());
|
||||
}
|
||||
|
||||
return executeInternal(line0, system, url, strings);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private CommandExecutionResult executeInternal(RegexResult line0, AbstractEntityDiagram diagram, Url url,
|
||||
List<? extends CharSequence> s) {
|
||||
|
||||
final String pos = line0.get("POSITION", 0);
|
||||
|
||||
final Code code = Code.of(line0.get("ENTITY", 0));
|
||||
final String member = line0.get("ENTITY", 1);
|
||||
if (code == null) {
|
||||
return CommandExecutionResult.error("Nothing to note to");
|
||||
}
|
||||
final IEntity cl1 = diagram.getOrCreateLeaf(code, null, null);
|
||||
|
||||
final Code codeTip = code.addSuffix("$$$right");
|
||||
IEntity tips = diagram.getLeafsget(codeTip);
|
||||
if (tips == null) {
|
||||
tips = diagram.getOrCreateLeaf(codeTip, LeafType.TIPS, null);
|
||||
final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getInvisible();
|
||||
final Link link = new Link(cl1, (IEntity) tips, type, null, 1);
|
||||
diagram.addLink(link);
|
||||
}
|
||||
tips.putTip(member, Display.create(s));
|
||||
|
||||
// final IEntity note = diagram.createLeaf(UniqueSequence.getCode("GMN"), Display.create(s), LeafType.NOTE,
|
||||
// null);
|
||||
// note.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0)));
|
||||
// if (url != null) {
|
||||
// note.addUrl(url);
|
||||
// }
|
||||
//
|
||||
// final Position position = Position.valueOf(StringUtils.goUpperCase(pos)).withRankdir(
|
||||
// diagram.getSkinParam().getRankdir());
|
||||
// final Link link;
|
||||
//
|
||||
// final LinkType type = new LinkType(LinkDecor.NONE, LinkDecor.NONE).getDashed();
|
||||
// if (position == Position.RIGHT) {
|
||||
// link = new Link(cl1, note, type, null, 1);
|
||||
// link.setHorizontalSolitary(true);
|
||||
// } else if (position == Position.LEFT) {
|
||||
// link = new Link(note, cl1, type, null, 1);
|
||||
// link.setHorizontalSolitary(true);
|
||||
// } else if (position == Position.BOTTOM) {
|
||||
// link = new Link(cl1, note, type, null, 2);
|
||||
// } else if (position == Position.TOP) {
|
||||
// link = new Link(note, cl1, type, null, 2);
|
||||
// } else {
|
||||
// throw new IllegalArgumentException();
|
||||
// }
|
||||
// diagram.addLink(link);
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
}
|
@ -90,7 +90,7 @@ public final class FactorySequenceNoteCommand implements SingleMultiFactoryComma
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(final SequenceDiagram system, List<String> lines) {
|
||||
final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
final List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
|
||||
return executeInternal(system, line0, strings);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(final SequenceDiagram system, List<String> lines) {
|
||||
final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
final List<String> in = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
|
||||
|
||||
return executeInternal(system, line0, in);
|
||||
|
@ -102,7 +102,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(final SequenceDiagram system, List<String> lines) {
|
||||
final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
final List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
|
||||
|
||||
return executeInternal(system, line0, strings);
|
||||
|
@ -107,7 +107,7 @@ final public class UmlSource {
|
||||
* @return a iterator that allow counting line number.
|
||||
*/
|
||||
public IteratorCounter iterator() {
|
||||
return new IteratorCounterImpl(source.iterator());
|
||||
return new IteratorCounterImpl(source);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -161,7 +161,7 @@ final public class UmlSource {
|
||||
if (s.matches("\\s*'.*")) {
|
||||
continue;
|
||||
}
|
||||
if (s.trim().length() != 0) {
|
||||
if (StringUtils.trin(s).length() != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
102
src/net/sourceforge/plantuml/creole/AtomTree.java
Normal file
102
src/net/sourceforge/plantuml/creole/AtomTree.java
Normal file
@ -0,0 +1,102 @@
|
||||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2014, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.sourceforge.net
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 11025 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.creole;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.salt.element.Skeleton2;
|
||||
import net.sourceforge.plantuml.ugraphic.UChangeColor;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.UTranslate;
|
||||
|
||||
public class AtomTree implements Atom {
|
||||
|
||||
private final HtmlColor lineColor;
|
||||
private final List<Atom> cells = new ArrayList<Atom>();
|
||||
private final Map<Atom, Integer> levels = new HashMap<Atom, Integer>();
|
||||
private final double margin = 2;
|
||||
|
||||
public AtomTree(HtmlColor lineColor) {
|
||||
this.lineColor = lineColor;
|
||||
}
|
||||
|
||||
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
||||
final Skeleton2 skeleton = new Skeleton2();
|
||||
double width = 0;
|
||||
double height = 0;
|
||||
for (Atom cell : cells) {
|
||||
final Dimension2D dim = cell.calculateDimension(stringBounder);
|
||||
height += dim.getHeight();
|
||||
final int level = getLevel(cell);
|
||||
width = Math.max(width, skeleton.getXEndForLevel(level) + margin + dim.getWidth());
|
||||
}
|
||||
return new Dimension2DDouble(width, height);
|
||||
}
|
||||
|
||||
public double getStartingAltitude(StringBounder stringBounder) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void drawU(final UGraphic ugInit) {
|
||||
final Skeleton2 skeleton = new Skeleton2();
|
||||
double y = 0;
|
||||
UGraphic ug = ugInit;
|
||||
for (Atom cell : cells) {
|
||||
final int level = getLevel(cell);
|
||||
cell.drawU(ug.apply(new UTranslate(margin + skeleton.getXEndForLevel(level), 0)));
|
||||
final Dimension2D dim = cell.calculateDimension(ug.getStringBounder());
|
||||
skeleton.add(level, y + dim.getHeight() / 2);
|
||||
ug = ug.apply(new UTranslate(0, dim.getHeight()));
|
||||
y += dim.getHeight();
|
||||
}
|
||||
skeleton.draw(ugInit.apply(new UChangeColor(this.lineColor)));
|
||||
}
|
||||
|
||||
private int getLevel(Atom atom) {
|
||||
return levels.get(atom);
|
||||
}
|
||||
|
||||
public void addCell(Atom cell, int level) {
|
||||
this.cells.add(cell);
|
||||
this.levels.put(cell, level);
|
||||
}
|
||||
|
||||
}
|
@ -38,6 +38,7 @@ import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.EmbededDiagram;
|
||||
import net.sourceforge.plantuml.ISkinSimple;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||
@ -62,10 +63,22 @@ public class CreoleParser {
|
||||
final StripeTable table = (StripeTable) lastStripe;
|
||||
table.analyzeAndAddNormal(line);
|
||||
return null;
|
||||
} else if (lastStripe instanceof StripeTree && isTreeStart(StringUtils.trinNoTrace(line))) {
|
||||
final StripeTree tree = (StripeTree) lastStripe;
|
||||
tree.analyzeAndAdd(line);
|
||||
return null;
|
||||
} else if (line.startsWith("|=") && line.endsWith("|")) {
|
||||
return new StripeTable(fontConfiguration, skinParam, line);
|
||||
} else if (isTreeStart(line)) {
|
||||
return new StripeTree(fontConfiguration, skinParam, line);
|
||||
}
|
||||
return new CreoleStripeSimpleParser(line, context, fontConfiguration, skinParam, modeSimpleLine).createStripe(context);
|
||||
return new CreoleStripeSimpleParser(line, context, fontConfiguration, skinParam, modeSimpleLine)
|
||||
.createStripe(context);
|
||||
}
|
||||
|
||||
public static boolean isTreeStart(String line) {
|
||||
// return false;
|
||||
return line.startsWith("|_");
|
||||
}
|
||||
|
||||
public Sheet createSheet(Display display) {
|
||||
|
@ -37,6 +37,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.ISkinSimple;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
import net.sourceforge.plantuml.utils.CharHidder;
|
||||
@ -101,7 +102,7 @@ public class CreoleStripeSimpleParser {
|
||||
final Pattern p1 = MyPattern.cmpile("^(\\*+)([^*]+(?:[^*]|\\*\\*[^*]+\\*\\*)*)$");
|
||||
final Matcher m1 = p1.matcher(line);
|
||||
if (m1.find()) {
|
||||
this.line = m1.group(2).trim();
|
||||
this.line = StringUtils.trin(m1.group(2));
|
||||
final int order = m1.group(1).length() - 1;
|
||||
this.style = new StripeStyle(StripeStyleType.LIST_WITHOUT_NUMBER, order, '\0');
|
||||
return;
|
||||
@ -112,7 +113,7 @@ public class CreoleStripeSimpleParser {
|
||||
final Pattern p2 = MyPattern.cmpile("^(#+)(.+)$");
|
||||
final Matcher m2 = p2.matcher(CharHidder.hide(line));
|
||||
if (m2.find()) {
|
||||
this.line = CharHidder.unhide(m2.group(2)).trim();
|
||||
this.line = StringUtils.trin(CharHidder.unhide(m2.group(2)));
|
||||
final int order = CharHidder.unhide(m2.group(1)).length() - 1;
|
||||
this.style = new StripeStyle(StripeStyleType.LIST_WITH_NUMBER, order, '\0');
|
||||
return;
|
||||
@ -122,7 +123,7 @@ public class CreoleStripeSimpleParser {
|
||||
final Pattern p3 = MyPattern.cmpile("^(=+)(.+)$");
|
||||
final Matcher m3 = p3.matcher(line);
|
||||
if (m3.find()) {
|
||||
this.line = m3.group(2).trim();
|
||||
this.line = StringUtils.trin(m3.group(2));
|
||||
final int order = m3.group(1).length() - 1;
|
||||
this.style = new StripeStyle(StripeStyleType.HEADING, order, '\0');
|
||||
return;
|
||||
|
@ -78,7 +78,7 @@ public class PSystemCreole extends AbstractPSystem {
|
||||
|
||||
final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, null, null, null, 0, 0, null, false);
|
||||
builder.addUDrawable(sheetBlock);
|
||||
return builder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
|
||||
return builder.writeImageTOBEMOVED(fileFormat, os);
|
||||
|
||||
// final Dimension2D dim = TextBlockUtils.getDimension(sheetBlock);
|
||||
// final UGraphic2 ug = fileFormat.createUGraphic(new ColorMapperIdentity(), 1, dim, null, false);
|
||||
|
@ -34,5 +34,5 @@
|
||||
package net.sourceforge.plantuml.creole;
|
||||
|
||||
public enum StripeStyleType {
|
||||
NORMAL, HEADING, LIST_WITHOUT_NUMBER, LIST_WITH_NUMBER, HORIZONTAL_LINE
|
||||
NORMAL, HEADING, LIST_WITHOUT_NUMBER, LIST_WITH_NUMBER, HORIZONTAL_LINE, TREE
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class StripeTable implements Stripe {
|
||||
return Collections.<Atom> singletonList(marged);
|
||||
}
|
||||
|
||||
private static Atom asAtom(List<StripeSimple> cells, double padding) {
|
||||
static Atom asAtom(List<StripeSimple> cells, double padding) {
|
||||
final Sheet sheet = new Sheet(HorizontalAlignment.LEFT);
|
||||
for (StripeSimple cell : cells) {
|
||||
sheet.add(cell);
|
||||
@ -93,7 +93,7 @@ public class StripeTable implements Stripe {
|
||||
}
|
||||
}
|
||||
|
||||
private static List<String> getWithNewlinesInternal(String s) {
|
||||
static List<String> getWithNewlinesInternal(String s) {
|
||||
final List<String> result = new ArrayList<String>();
|
||||
final StringBuilder current = new StringBuilder();
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
|
76
src/net/sourceforge/plantuml/creole/StripeTree.java
Normal file
76
src/net/sourceforge/plantuml/creole/StripeTree.java
Normal file
@ -0,0 +1,76 @@
|
||||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2014, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.sourceforge.net
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 11025 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.creole;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.ISkinSimple;
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
|
||||
public class StripeTree implements Stripe {
|
||||
|
||||
private FontConfiguration fontConfiguration;
|
||||
final private ISkinSimple skinParam;
|
||||
final private AtomTree tree;
|
||||
final private Atom marged;
|
||||
final private StripeStyle stripeStyle = new StripeStyle(StripeStyleType.TREE, 0, '\0');
|
||||
|
||||
public StripeTree(FontConfiguration fontConfiguration, ISkinSimple skinParam, String line) {
|
||||
this.fontConfiguration = fontConfiguration;
|
||||
this.skinParam = skinParam;
|
||||
this.tree = new AtomTree(fontConfiguration.getColor());
|
||||
this.marged = new AtomWithMargin(tree, 2, 2);
|
||||
analyzeAndAdd(line);
|
||||
}
|
||||
|
||||
public List<Atom> getAtoms() {
|
||||
return Collections.<Atom> singletonList(marged);
|
||||
}
|
||||
|
||||
public void analyzeAndAdd(String line) {
|
||||
final List<String> lines = StripeTable.getWithNewlinesInternal(line);
|
||||
for (String s : lines) {
|
||||
final StripeSimple cell = new StripeSimple(fontConfiguration, stripeStyle, new CreoleContext(), skinParam,
|
||||
false);
|
||||
// EMTEC
|
||||
final String text = s.replaceFirst("^\\s*\\|_", "");
|
||||
final int level = (s.length() - text.length()) / 2;
|
||||
cell.analyzeAndAdd(text);
|
||||
this.tree.addCell(StripeTable.asAtom(Collections.singletonList(cell), 0), level);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -33,12 +33,17 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram;
|
||||
|
||||
import java.awt.geom.Rectangle2D;
|
||||
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
|
||||
public interface BlockMember {
|
||||
|
||||
public TextBlock asTextBlock(FontParam fontParam, ISkinParam skinParam);
|
||||
|
||||
public Rectangle2D getPosition(String member, StringBounder stringBounder, FontParam fontParam, ISkinParam skinParam);
|
||||
|
||||
}
|
||||
|
@ -33,12 +33,14 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram;
|
||||
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.graphic.TextBlockLineBefore;
|
||||
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||
@ -56,8 +58,18 @@ public class BlockMemberImpl implements BlockMember {
|
||||
}
|
||||
|
||||
public TextBlock asTextBlock(FontParam fontParam, ISkinParam skinParam) {
|
||||
return new TextBlockLineBefore(TextBlockUtils.withMargin((TextBlock) new MethodsOrFieldsArea(members,
|
||||
fontParam, skinParam), 6, 4));
|
||||
final MethodsOrFieldsArea methodsOrFieldsArea = new MethodsOrFieldsArea(members, fontParam, skinParam);
|
||||
return new TextBlockLineBefore(TextBlockUtils.withMargin((TextBlock) methodsOrFieldsArea, 6, 4));
|
||||
}
|
||||
|
||||
public Rectangle2D getPosition(String member, StringBounder stringBounder, FontParam fontParam, ISkinParam skinParam) {
|
||||
final MethodsOrFieldsArea methodsOrFieldsArea = new MethodsOrFieldsArea(members, fontParam, skinParam);
|
||||
return methodsOrFieldsArea.getPosition(member, stringBounder);
|
||||
}
|
||||
|
||||
public boolean contains(String member, FontParam fontParam, ISkinParam skinParam) {
|
||||
final MethodsOrFieldsArea methodsOrFieldsArea = new MethodsOrFieldsArea(members, fontParam, skinParam);
|
||||
return methodsOrFieldsArea.contains(member);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram;
|
||||
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -40,9 +41,10 @@ import java.util.Set;
|
||||
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.skin.VisibilityModifier;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class Bodier {
|
||||
|
||||
@ -81,6 +83,9 @@ public class Bodier {
|
||||
final BodyEnhanced result = new BodyEnhanced(rawBody, fontParam, skinParam, manageModifier);
|
||||
return result;
|
||||
}
|
||||
public Rectangle2D getPosition(String member, StringBounder stringBounder, FontParam fontParam, ISkinParam skinParam) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -108,7 +113,7 @@ public class Bodier {
|
||||
if (s.length() == 0 && methodsToDisplay.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
final Member m = new Member(s, true, manageModifier);
|
||||
final Member m = new MemberImpl(s, true, manageModifier, true);
|
||||
if (hides == null || hides.contains(m.getVisibilityModifier()) == false) {
|
||||
methodsToDisplay.add(m);
|
||||
}
|
||||
@ -136,7 +141,7 @@ public class Bodier {
|
||||
if (s.length() == 0 && fieldsToDisplay.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
final Member m = new Member(s, false, manageModifier);
|
||||
final Member m = new MemberImpl(s, false, manageModifier, true);
|
||||
if (hides == null || hides.contains(m.getVisibilityModifier()) == false) {
|
||||
fieldsToDisplay.add(m);
|
||||
}
|
||||
@ -147,7 +152,7 @@ public class Bodier {
|
||||
}
|
||||
|
||||
private void removeFinalEmptyMembers(List<Member> result) {
|
||||
while (result.size() > 0 && result.get(result.size() - 1).getDisplay(false).trim().length() == 0) {
|
||||
while (result.size() > 0 && StringUtils.trin(result.get(result.size() - 1).getDisplay(false)).length() == 0) {
|
||||
result.remove(result.size() - 1);
|
||||
}
|
||||
}
|
||||
|
@ -37,11 +37,14 @@ import java.awt.geom.Dimension2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.ISkinSimple;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.creole.CreoleParser;
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
@ -51,7 +54,6 @@ import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||
import net.sourceforge.plantuml.graphic.TextBlockVertical2;
|
||||
import net.sourceforge.plantuml.skin.rose.Rose;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class BodyEnhanced implements TextBlock {
|
||||
|
||||
@ -65,14 +67,16 @@ public class BodyEnhanced implements TextBlock {
|
||||
private final boolean manageHorizontalLine;
|
||||
private final boolean manageModifier;
|
||||
private final List<Url> urls = new ArrayList<Url>();
|
||||
private final boolean manageUrl;
|
||||
|
||||
public BodyEnhanced(List<String> rawBody, FontParam fontParam, ISkinParam skinParam, boolean manageModifier) {
|
||||
this.rawBody = new ArrayList<String>(rawBody);
|
||||
this.fontParam = fontParam;
|
||||
this.skinParam = skinParam;
|
||||
this.manageUrl = true;
|
||||
|
||||
this.titleConfig = new FontConfiguration(skinParam.getFont(fontParam, null, false), new Rose().getFontColor(skinParam,
|
||||
fontParam), skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink());
|
||||
this.titleConfig = new FontConfiguration(skinParam.getFont(fontParam, null, false), new Rose().getFontColor(
|
||||
skinParam, fontParam), skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink());
|
||||
this.lineFirst = true;
|
||||
this.align = HorizontalAlignment.LEFT;
|
||||
this.manageHorizontalLine = true;
|
||||
@ -80,7 +84,8 @@ public class BodyEnhanced implements TextBlock {
|
||||
}
|
||||
|
||||
public BodyEnhanced(Display display, FontParam fontParam, ISkinParam skinParam, HorizontalAlignment align,
|
||||
Stereotype stereotype, boolean manageHorizontalLine, boolean manageModifier) {
|
||||
Stereotype stereotype, boolean manageHorizontalLine, boolean manageModifier, boolean manageUrl) {
|
||||
this.manageUrl = manageUrl;
|
||||
this.rawBody = new ArrayList<String>();
|
||||
for (CharSequence s : display) {
|
||||
this.rawBody.add(s.toString());
|
||||
@ -123,15 +128,26 @@ public class BodyEnhanced implements TextBlock {
|
||||
char separator = lineFirst ? '_' : 0;
|
||||
TextBlock title = null;
|
||||
List<Member> members = new ArrayList<Member>();
|
||||
for (String s : rawBody) {
|
||||
for (ListIterator<String> it = rawBody.listIterator(); it.hasNext();) {
|
||||
final String s = it.next();
|
||||
if (manageHorizontalLine && isBlockSeparator(s)) {
|
||||
blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam, align),
|
||||
separator, title));
|
||||
separator = s.charAt(0);
|
||||
title = getTitle(s, skinParam);
|
||||
members = new ArrayList<Member>();
|
||||
} else if (CreoleParser.isTreeStart(s)) {
|
||||
if (members.size() > 0) {
|
||||
blocks.add(decorate(stringBounder, new MethodsOrFieldsArea(members, fontParam, skinParam, align),
|
||||
separator, title));
|
||||
}
|
||||
members = new ArrayList<Member>();
|
||||
final List<String> allTree = buildAllTree(s, it);
|
||||
final TextBlock bloc = TextBlockUtils.create(Display.create(allTree),
|
||||
fontParam.getFontConfiguration(skinParam), align, skinParam, false);
|
||||
blocks.add(bloc);
|
||||
} else {
|
||||
final Member m = new Member(s, StringUtils.isMethod(s), manageModifier);
|
||||
final Member m = new MemberImpl(s, StringUtils.isMethod(s), manageModifier, manageUrl);
|
||||
members.add(m);
|
||||
if (m.getUrl() != null) {
|
||||
urls.add(m.getUrl());
|
||||
@ -150,6 +166,22 @@ public class BodyEnhanced implements TextBlock {
|
||||
return area2;
|
||||
}
|
||||
|
||||
private static List<String> buildAllTree(String init, ListIterator<String> it) {
|
||||
final List<String> result = new ArrayList<String>();
|
||||
result.add(init);
|
||||
while (it.hasNext()) {
|
||||
final String s = it.next();
|
||||
if (CreoleParser.isTreeStart(StringUtils.trinNoTrace(s))) {
|
||||
result.add(s);
|
||||
} else {
|
||||
it.previous();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean isBlockSeparator(String s) {
|
||||
if (s.startsWith("--") && s.endsWith("--")) {
|
||||
return true;
|
||||
@ -170,7 +202,7 @@ public class BodyEnhanced implements TextBlock {
|
||||
if (s.length() <= 4) {
|
||||
return null;
|
||||
}
|
||||
s = s.substring(2, s.length() - 2).trim();
|
||||
s = StringUtils.trin(s.substring(2, s.length() - 2));
|
||||
return TextBlockUtils
|
||||
.create(Display.getWithNewlines(s), titleConfig, HorizontalAlignment.LEFT, spriteContainer);
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.ISkinSimple;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
@ -143,7 +144,7 @@ public class BodyEnhanced2 implements TextBlock {
|
||||
if (s.length() <= 4) {
|
||||
return null;
|
||||
}
|
||||
s = s.substring(2, s.length() - 2).trim();
|
||||
s = StringUtils.trin(s.substring(2, s.length() - 2));
|
||||
return TextBlockUtils
|
||||
.create(Display.getWithNewlines(s), titleConfig, HorizontalAlignment.LEFT, spriteContainer);
|
||||
}
|
||||
|
@ -38,8 +38,11 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.EmbededDiagram;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.UrlBuilder;
|
||||
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
|
||||
@ -98,6 +101,9 @@ public class Display implements Iterable<CharSequence> {
|
||||
current.append(c);
|
||||
current.append(c2);
|
||||
}
|
||||
} else if (c == StringUtils.hiddenNewLine()) {
|
||||
result.add(current.toString());
|
||||
current.setLength(0);
|
||||
} else {
|
||||
current.append(c);
|
||||
}
|
||||
@ -125,12 +131,12 @@ public class Display implements Iterable<CharSequence> {
|
||||
final Iterator<? extends CharSequence> it = strings.iterator();
|
||||
while (it.hasNext()) {
|
||||
CharSequence s = it.next();
|
||||
if (s != null && s.toString().trim().equals("{{")) {
|
||||
if (s != null && StringUtils.trin(s.toString()).equals("{{")) {
|
||||
final List<CharSequence> other = new ArrayList<CharSequence>();
|
||||
other.add("@startuml");
|
||||
while (it.hasNext()) {
|
||||
final CharSequence s2 = it.next();
|
||||
if (s2 != null && s2.toString().trim().equals("}}")) {
|
||||
if (s2 != null && StringUtils.trin(s2.toString()).equals("}}")) {
|
||||
break;
|
||||
}
|
||||
other.add(s2);
|
||||
@ -240,7 +246,7 @@ public class Display implements Iterable<CharSequence> {
|
||||
return null;
|
||||
}
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.AT_START);
|
||||
return urlBuilder.getUrl(this.get(0).toString().trim());
|
||||
return urlBuilder.getUrl(StringUtils.trin(this.get(0).toString()));
|
||||
}
|
||||
|
||||
public Display removeUrl(Url url) {
|
||||
@ -267,4 +273,24 @@ public class Display implements Iterable<CharSequence> {
|
||||
return naturalHorizontalAlignment;
|
||||
}
|
||||
|
||||
public List<Display> splitMultiline(Pattern separator) {
|
||||
final List<Display> result = new ArrayList<Display>();
|
||||
Display pending = new Display(this.naturalHorizontalAlignment);
|
||||
result.add(pending);
|
||||
for (CharSequence line : display) {
|
||||
final Matcher m = separator.matcher(line);
|
||||
if (m.find()) {
|
||||
final CharSequence s1 = line.subSequence(0, m.start());
|
||||
pending.display.add(s1);
|
||||
final CharSequence s2 = line.subSequence(m.end(), line.length());
|
||||
pending = new Display(this.naturalHorizontalAlignment);
|
||||
result.add(pending);
|
||||
pending.display.add(s2);
|
||||
} else {
|
||||
pending.display.add(line);
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.UrlBuilder;
|
||||
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
|
||||
@ -214,7 +215,7 @@ public class Display2 implements Iterable<CharSequence> {
|
||||
return null;
|
||||
}
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.AT_START);
|
||||
return urlBuilder.getUrl(this.get(0).toString().trim());
|
||||
return urlBuilder.getUrl(StringUtils.trin(this.get(0).toString()));
|
||||
}
|
||||
|
||||
public Display2 removeUrl(Url url) {
|
||||
|
@ -37,6 +37,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
@ -277,4 +278,12 @@ public class GroupRoot implements IGroup {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void putTip(String member, Display display) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Map<String, Display> getTips() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,6 +34,7 @@
|
||||
package net.sourceforge.plantuml.cucadiagram;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sourceforge.plantuml.Hideable;
|
||||
import net.sourceforge.plantuml.LineConfigurable;
|
||||
@ -92,4 +93,8 @@ public interface IEntity extends SpecificBackcolorable, Hideable, Removeable, Li
|
||||
|
||||
public int getRawLayout();
|
||||
|
||||
public void putTip(String member, Display display);
|
||||
|
||||
public Map<String, Display> getTips();
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 14727 $
|
||||
* Revision $Revision: 16249 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram;
|
||||
@ -39,7 +39,7 @@ public enum LeafType {
|
||||
|
||||
EMPTY_PACKAGE,
|
||||
|
||||
ABSTRACT_CLASS, CLASS, INTERFACE, ANNOTATION, LOLLIPOP, NOTE, OBJECT, ASSOCIATION, ENUM,
|
||||
ABSTRACT_CLASS, CLASS, INTERFACE, ANNOTATION, LOLLIPOP, NOTE, TIPS, OBJECT, ASSOCIATION, ENUM,
|
||||
|
||||
USECASE,
|
||||
|
||||
|
@ -33,159 +33,20 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.UrlBuilder;
|
||||
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.skin.VisibilityModifier;
|
||||
|
||||
public class Member {
|
||||
public interface Member {
|
||||
|
||||
private final String display;
|
||||
private final boolean staticModifier;
|
||||
private final boolean abstractModifier;
|
||||
private final Url url;
|
||||
private final boolean hasUrl;
|
||||
public Url getUrl();
|
||||
|
||||
private final VisibilityModifier visibilityModifier;
|
||||
public String getDisplay(boolean withVisibilityChar);
|
||||
|
||||
public Member(String display, boolean isMethod, boolean manageModifier) {
|
||||
this.hasUrl = new UrlBuilder(null, ModeUrl.ANYWHERE).getUrl(display) != null;
|
||||
final Pattern pstart = MyPattern.cmpile("^(" + UrlBuilder.getRegexp() + ")([^\\[\\]]+)$");
|
||||
final Matcher mstart = pstart.matcher(display);
|
||||
public boolean hasUrl();
|
||||
|
||||
if (mstart.matches()) {
|
||||
if (mstart.groupCount() != 5) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.AT_START);
|
||||
url = urlBuilder.getUrl(mstart.group(1));
|
||||
url.setMember(true);
|
||||
display = /* mstart.group(1).trim() + */mstart.group(mstart.groupCount()).trim();
|
||||
} else {
|
||||
final Pattern pend = MyPattern.cmpile("^((?:[^\\[\\]]|\\[[^\\[\\]]*\\])+)(" + UrlBuilder.getRegexp() + ")$");
|
||||
final Matcher mend = pend.matcher(display);
|
||||
public VisibilityModifier getVisibilityModifier();
|
||||
|
||||
if (mend.matches()) {
|
||||
if (mend.groupCount() != 5) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.AT_END);
|
||||
url = urlBuilder.getUrl(mend.group(2));
|
||||
url.setMember(true);
|
||||
display = mend.group(1).trim();
|
||||
} else {
|
||||
url = null;
|
||||
}
|
||||
}
|
||||
|
||||
final String lower = StringUtils.goLowerCase(display);
|
||||
|
||||
if (manageModifier) {
|
||||
this.staticModifier = lower.contains("{static}") || lower.contains("{classifier}");
|
||||
this.abstractModifier = lower.contains("{abstract}");
|
||||
String displayClean = display.replaceAll("(?i)\\{(static|classifier|abstract)\\}", "").trim();
|
||||
if (displayClean.length() == 0) {
|
||||
displayClean = " ";
|
||||
}
|
||||
|
||||
if (VisibilityModifier.isVisibilityCharacter(displayClean.charAt(0))) {
|
||||
visibilityModifier = VisibilityModifier.getVisibilityModifier(display.charAt(0), isMethod == false);
|
||||
this.display = displayClean.substring(1).trim();
|
||||
} else {
|
||||
this.display = displayClean;
|
||||
visibilityModifier = null;
|
||||
}
|
||||
} else {
|
||||
this.staticModifier = false;
|
||||
this.visibilityModifier = null;
|
||||
this.abstractModifier = false;
|
||||
display = display.trim();
|
||||
this.display = display.length() == 0 ? " " : display.trim();
|
||||
}
|
||||
}
|
||||
|
||||
public String getDisplay(boolean withVisibilityChar) {
|
||||
if (withVisibilityChar) {
|
||||
return getDisplayWithVisibilityChar();
|
||||
}
|
||||
return getDisplayWithoutVisibilityChar();
|
||||
}
|
||||
|
||||
public String getDisplayWithoutVisibilityChar() {
|
||||
// assert display.length() == 0 || VisibilityModifier.isVisibilityCharacter(display.charAt(0)) == false;
|
||||
return display;
|
||||
}
|
||||
|
||||
public String getDisplayWithVisibilityChar() {
|
||||
if (isPrivate()) {
|
||||
return "-" + display;
|
||||
}
|
||||
if (isPublic()) {
|
||||
return "+" + display;
|
||||
}
|
||||
if (isPackagePrivate()) {
|
||||
return "~" + display;
|
||||
}
|
||||
if (isProtected()) {
|
||||
return "#" + display;
|
||||
}
|
||||
return display;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
final Member other = (Member) obj;
|
||||
return this.display.equals(other.display);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return display.hashCode();
|
||||
}
|
||||
|
||||
public final boolean isStatic() {
|
||||
return staticModifier;
|
||||
}
|
||||
|
||||
public final boolean isAbstract() {
|
||||
return abstractModifier;
|
||||
}
|
||||
|
||||
private boolean isPrivate() {
|
||||
return visibilityModifier == VisibilityModifier.PRIVATE_FIELD
|
||||
|| visibilityModifier == VisibilityModifier.PRIVATE_METHOD;
|
||||
}
|
||||
|
||||
private boolean isProtected() {
|
||||
return visibilityModifier == VisibilityModifier.PROTECTED_FIELD
|
||||
|| visibilityModifier == VisibilityModifier.PROTECTED_METHOD;
|
||||
}
|
||||
|
||||
private boolean isPublic() {
|
||||
return visibilityModifier == VisibilityModifier.PUBLIC_FIELD
|
||||
|| visibilityModifier == VisibilityModifier.PUBLIC_METHOD;
|
||||
}
|
||||
|
||||
private boolean isPackagePrivate() {
|
||||
return visibilityModifier == VisibilityModifier.PACKAGE_PRIVATE_FIELD
|
||||
|| visibilityModifier == VisibilityModifier.PACKAGE_PRIVATE_METHOD;
|
||||
}
|
||||
|
||||
public final VisibilityModifier getVisibilityModifier() {
|
||||
return visibilityModifier;
|
||||
}
|
||||
|
||||
public final Url getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public boolean hasUrl() {
|
||||
return hasUrl;
|
||||
}
|
||||
public boolean isStatic();
|
||||
|
||||
public boolean isAbstract();
|
||||
}
|
||||
|
197
src/net/sourceforge/plantuml/cucadiagram/MemberImpl.java
Normal file
197
src/net/sourceforge/plantuml/cucadiagram/MemberImpl.java
Normal file
@ -0,0 +1,197 @@
|
||||
/* ========================================================================
|
||||
* PlantUML : a free UML diagram generator
|
||||
* ========================================================================
|
||||
*
|
||||
* (C) Copyright 2009-2014, Arnaud Roques
|
||||
*
|
||||
* Project Info: http://plantuml.sourceforge.net
|
||||
*
|
||||
* This file is part of PlantUML.
|
||||
*
|
||||
* PlantUML is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PlantUML distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*
|
||||
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 4749 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.UrlBuilder;
|
||||
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.skin.VisibilityModifier;
|
||||
|
||||
public class MemberImpl implements Member {
|
||||
|
||||
private final String display;
|
||||
private final boolean staticModifier;
|
||||
private final boolean abstractModifier;
|
||||
private final Url url;
|
||||
private final boolean hasUrl;
|
||||
|
||||
private final VisibilityModifier visibilityModifier;
|
||||
|
||||
public MemberImpl(String tmpDisplay, boolean isMethod, boolean manageModifier, boolean manageUrl) {
|
||||
if (manageModifier) {
|
||||
this.hasUrl = new UrlBuilder(null, ModeUrl.ANYWHERE).getUrl(tmpDisplay) != null;
|
||||
final Pattern pstart = MyPattern.cmpile("^(" + UrlBuilder.getRegexp() + ")([^\\[\\]]+)$");
|
||||
final Matcher mstart = pstart.matcher(tmpDisplay);
|
||||
|
||||
if (mstart.matches()) {
|
||||
if (mstart.groupCount() != 5) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.AT_START);
|
||||
this.url = urlBuilder.getUrl(mstart.group(1));
|
||||
this.url.setMember(true);
|
||||
tmpDisplay = /* mstart.group(1).trim() + */StringUtils.trin(mstart.group(mstart.groupCount()));
|
||||
} else {
|
||||
final Pattern pend = MyPattern.cmpile("^((?:[^\\[\\]]|\\[[^\\[\\]]*\\])+)(" + UrlBuilder.getRegexp()
|
||||
+ ")$");
|
||||
final Matcher mend = pend.matcher(tmpDisplay);
|
||||
|
||||
if (mend.matches()) {
|
||||
if (mend.groupCount() != 5) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.AT_END);
|
||||
this.url = urlBuilder.getUrl(mend.group(2));
|
||||
this.url.setMember(true);
|
||||
tmpDisplay = StringUtils.trin(mend.group(1));
|
||||
} else {
|
||||
this.url = null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.url = null;
|
||||
this.hasUrl = false;
|
||||
}
|
||||
|
||||
final String lower = StringUtils.goLowerCase(tmpDisplay);
|
||||
|
||||
if (manageModifier) {
|
||||
this.staticModifier = lower.contains("{static}") || lower.contains("{classifier}");
|
||||
this.abstractModifier = lower.contains("{abstract}");
|
||||
String displayClean = tmpDisplay.replaceAll("(?i)\\{(static|classifier|abstract)\\}\\s*", "");
|
||||
if (displayClean.length() == 0) {
|
||||
displayClean = " ";
|
||||
}
|
||||
|
||||
if (VisibilityModifier.isVisibilityCharacter(displayClean.charAt(0))) {
|
||||
visibilityModifier = VisibilityModifier.getVisibilityModifier(displayClean.charAt(0), isMethod == false);
|
||||
this.display = StringUtils.trin(StringUtils.manageGuillemet(displayClean.substring(1)));
|
||||
} else {
|
||||
this.display = StringUtils.manageGuillemet(displayClean);
|
||||
visibilityModifier = null;
|
||||
}
|
||||
} else {
|
||||
this.staticModifier = false;
|
||||
this.visibilityModifier = null;
|
||||
this.abstractModifier = false;
|
||||
tmpDisplay = StringUtils.trin(tmpDisplay);
|
||||
this.display = tmpDisplay.length() == 0 ? " " : StringUtils.manageGuillemet(StringUtils.trin(tmpDisplay));
|
||||
}
|
||||
}
|
||||
|
||||
public String getDisplay(boolean withVisibilityChar) {
|
||||
if (withVisibilityChar) {
|
||||
return getDisplayWithVisibilityChar();
|
||||
}
|
||||
return getDisplayWithoutVisibilityChar();
|
||||
}
|
||||
|
||||
public String getDisplayWithoutVisibilityChar() {
|
||||
// assert display.length() == 0 || VisibilityModifier.isVisibilityCharacter(display.charAt(0)) == false;
|
||||
return display;
|
||||
}
|
||||
|
||||
public String getDisplayWithVisibilityChar() {
|
||||
if (isPrivate()) {
|
||||
return "-" + display;
|
||||
}
|
||||
if (isPublic()) {
|
||||
return "+" + display;
|
||||
}
|
||||
if (isPackagePrivate()) {
|
||||
return "~" + display;
|
||||
}
|
||||
if (isProtected()) {
|
||||
return "#" + display;
|
||||
}
|
||||
return display;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
final MemberImpl other = (MemberImpl) obj;
|
||||
return this.display.equals(other.display);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return display.hashCode();
|
||||
}
|
||||
|
||||
public final boolean isStatic() {
|
||||
return staticModifier;
|
||||
}
|
||||
|
||||
public final boolean isAbstract() {
|
||||
return abstractModifier;
|
||||
}
|
||||
|
||||
private boolean isPrivate() {
|
||||
return visibilityModifier == VisibilityModifier.PRIVATE_FIELD
|
||||
|| visibilityModifier == VisibilityModifier.PRIVATE_METHOD;
|
||||
}
|
||||
|
||||
private boolean isProtected() {
|
||||
return visibilityModifier == VisibilityModifier.PROTECTED_FIELD
|
||||
|| visibilityModifier == VisibilityModifier.PROTECTED_METHOD;
|
||||
}
|
||||
|
||||
private boolean isPublic() {
|
||||
return visibilityModifier == VisibilityModifier.PUBLIC_FIELD
|
||||
|| visibilityModifier == VisibilityModifier.PUBLIC_METHOD;
|
||||
}
|
||||
|
||||
private boolean isPackagePrivate() {
|
||||
return visibilityModifier == VisibilityModifier.PACKAGE_PRIVATE_FIELD
|
||||
|| visibilityModifier == VisibilityModifier.PACKAGE_PRIVATE_METHOD;
|
||||
}
|
||||
|
||||
public final VisibilityModifier getVisibilityModifier() {
|
||||
return visibilityModifier;
|
||||
}
|
||||
|
||||
public final Url getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public boolean hasUrl() {
|
||||
return hasUrl;
|
||||
}
|
||||
|
||||
}
|
@ -34,6 +34,7 @@
|
||||
package net.sourceforge.plantuml.cucadiagram;
|
||||
|
||||
import java.awt.geom.Dimension2D;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -191,6 +192,29 @@ public class MethodsOrFieldsArea implements TextBlockWidth, TextBlock {
|
||||
};
|
||||
}
|
||||
|
||||
public Rectangle2D getPosition(String member, StringBounder stringBounder) {
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
for (Member att : members) {
|
||||
final TextBlock bloc = createTextBlock(att);
|
||||
final Dimension2D dim = bloc.calculateDimension(stringBounder);
|
||||
if (att.getDisplay(false).startsWith(member)) {
|
||||
return new Rectangle2D.Double(x, y, dim.getWidth(), dim.getHeight());
|
||||
}
|
||||
y += dim.getHeight();
|
||||
}
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
public boolean contains(String member) {
|
||||
for (Member att : members) {
|
||||
if (att.getDisplay(false).startsWith(member)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void drawU(UGraphic ug) {
|
||||
final Dimension2D dim = calculateDimension(ug.getStringBounder());
|
||||
final ULayoutGroup group;
|
||||
@ -220,4 +244,5 @@ public class MethodsOrFieldsArea implements TextBlockWidth, TextBlock {
|
||||
}
|
||||
group.drawU(ug, 0, 0, dim.getWidth(), dim.getHeight());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 15849 $
|
||||
* Revision $Revision: 16159 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram;
|
||||
@ -145,7 +145,7 @@ public class Stereotype implements CharSequence, Hideable {
|
||||
return null;
|
||||
}
|
||||
if (withGuillement) {
|
||||
return manageGuillemet(label);
|
||||
return StringUtils.manageGuillemetStrict(label);
|
||||
}
|
||||
return label;
|
||||
}
|
||||
@ -194,7 +194,7 @@ public class Stereotype implements CharSequence, Hideable {
|
||||
final Matcher m = p.matcher(getLabel(false));
|
||||
while (m.find()) {
|
||||
if (useGuillemet) {
|
||||
result.add(manageGuillemet(m.group()));
|
||||
result.add(StringUtils.manageGuillemetStrict(m.group()));
|
||||
} else {
|
||||
result.add(m.group());
|
||||
}
|
||||
@ -202,20 +202,6 @@ public class Stereotype implements CharSequence, Hideable {
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
private static String manageGuillemet(String st) {
|
||||
if (st.startsWith("<< ")) {
|
||||
st = "\u00AB" + st.substring(3);
|
||||
} else if (st.startsWith("<<")) {
|
||||
st = "\u00AB" + st.substring(2);
|
||||
}
|
||||
if (st.endsWith(" >>")) {
|
||||
st = st.substring(0, st.length() - 3) + "\u00BB";
|
||||
} else if (st.endsWith(">>")) {
|
||||
st = st.substring(0, st.length() - 2) + "\u00BB";
|
||||
}
|
||||
return st;
|
||||
}
|
||||
|
||||
public PackageStyle getPackageStyle() {
|
||||
if (automaticPackageStyle == false) {
|
||||
return null;
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 15599 $
|
||||
* Revision $Revision: 16196 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram.dot;
|
||||
@ -147,7 +147,7 @@ abstract class AbstractGraphviz implements Graphviz {
|
||||
}
|
||||
sb.append(p.getError());
|
||||
}
|
||||
return sb.toString().replace('\n', ' ').trim();
|
||||
return StringUtils.trin(sb.toString().replace('\n', ' '));
|
||||
}
|
||||
|
||||
final String[] getCommandLine() {
|
||||
|
@ -97,7 +97,7 @@ public class GraphvizVersionFinder {
|
||||
}
|
||||
sb.append(p.getError());
|
||||
}
|
||||
return sb.toString().replace('\n', ' ').trim();
|
||||
return StringUtils.trin(sb.toString().replace('\n', ' '));
|
||||
}
|
||||
|
||||
private String[] getCommandLine() {
|
||||
|
@ -33,10 +33,13 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram.entity;
|
||||
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
@ -64,6 +67,7 @@ import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
||||
import net.sourceforge.plantuml.cucadiagram.dot.Neighborhood;
|
||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.graphic.TextBlockVertical2;
|
||||
import net.sourceforge.plantuml.graphic.USymbol;
|
||||
@ -299,6 +303,11 @@ final class EntityImpl implements ILeaf, IGroup {
|
||||
public TextBlock asTextBlock(FontParam fontParam, ISkinParam skinParam) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Rectangle2D getPosition(String member, StringBounder stringBounder, FontParam fontParam,
|
||||
ISkinParam skinParam) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
return new BlockMember() {
|
||||
@ -306,10 +315,11 @@ final class EntityImpl implements ILeaf, IGroup {
|
||||
if (getEntityType().isLikeClass()) {
|
||||
|
||||
if (showFields && showMethods) {
|
||||
return new TextBlockVertical2(new BlockMemberImpl(getFieldsToDisplay()).asTextBlock(fontParam,
|
||||
skinParam),
|
||||
new BlockMemberImpl(getMethodsToDisplay()).asTextBlock(fontParam, skinParam),
|
||||
HorizontalAlignment.LEFT);
|
||||
final BlockMemberImpl bb1 = new BlockMemberImpl(getFieldsToDisplay());
|
||||
final BlockMemberImpl bb2 = new BlockMemberImpl(getMethodsToDisplay());
|
||||
final TextBlock b1 = bb1.asTextBlock(fontParam, skinParam);
|
||||
final TextBlock b2 = bb2.asTextBlock(fontParam, skinParam);
|
||||
return new TextBlockVertical2(b1, b2, HorizontalAlignment.LEFT);
|
||||
} else if (showFields) {
|
||||
return new BlockMemberImpl(getFieldsToDisplay()).asTextBlock(fontParam, skinParam);
|
||||
} else if (showMethods) {
|
||||
@ -322,6 +332,25 @@ final class EntityImpl implements ILeaf, IGroup {
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Rectangle2D getPosition(String member, StringBounder stringBounder, FontParam fontParam,
|
||||
ISkinParam skinParam) {
|
||||
if (getEntityType().isLikeClass()) {
|
||||
|
||||
if (showFields && showMethods) {
|
||||
final BlockMemberImpl bb1 = new BlockMemberImpl(getFieldsToDisplay());
|
||||
final BlockMemberImpl bb2 = new BlockMemberImpl(getMethodsToDisplay());
|
||||
if (bb1.contains(member, fontParam, skinParam)) {
|
||||
return bb1.getPosition(member, stringBounder, fontParam, skinParam);
|
||||
}
|
||||
if (bb2.contains(member, fontParam, skinParam)) {
|
||||
return bb2.getPosition(member, stringBounder, fontParam, skinParam);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -333,6 +362,11 @@ final class EntityImpl implements ILeaf, IGroup {
|
||||
public TextBlock asTextBlock(FontParam fontParam, ISkinParam skinParam) {
|
||||
return new BodyEnhanced(mouseOver, fontParam, skinParam, leafType.manageModifier());
|
||||
}
|
||||
|
||||
public Rectangle2D getPosition(String member, StringBounder stringBounder, FontParam fontParam,
|
||||
ISkinParam skinParam) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -648,4 +682,14 @@ final class EntityImpl implements ILeaf, IGroup {
|
||||
return neighborhood;
|
||||
}
|
||||
|
||||
private final Map<String, Display> tips = new LinkedHashMap<String, Display>();
|
||||
|
||||
public void putTip(String member, Display display) {
|
||||
tips.put(member, display);
|
||||
}
|
||||
|
||||
public Map<String, Display> getTips() {
|
||||
return Collections.unmodifiableMap(tips);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,6 +35,8 @@ package net.sourceforge.plantuml.cute;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class CuteShapeFactory {
|
||||
|
||||
private final Map<String, Group> groups;
|
||||
@ -50,7 +52,7 @@ public class CuteShapeFactory {
|
||||
}
|
||||
|
||||
private CuteShape createCuteShape(String data) {
|
||||
data = data.toLowerCase().trim();
|
||||
data = StringUtils.trin(data.toLowerCase());
|
||||
final VarArgs varArgs = new VarArgs(data);
|
||||
if (data.startsWith("circle ")) {
|
||||
return new Circle(varArgs);
|
||||
|
@ -35,14 +35,11 @@ package net.sourceforge.plantuml.cute;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import net.sourceforge.plantuml.AbstractPSystem;
|
||||
import net.sourceforge.plantuml.FileFormatOption;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.core.DiagramDescription;
|
||||
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
|
||||
import net.sourceforge.plantuml.core.ImageData;
|
||||
@ -64,7 +61,7 @@ public class PSystemCute extends AbstractPSystem {
|
||||
}
|
||||
|
||||
public void doCommandLine(String line) {
|
||||
line = line.trim();
|
||||
line = StringUtils.trin(line);
|
||||
if (line.length()==0 || line.startsWith("'")) {
|
||||
return;
|
||||
}
|
||||
@ -88,6 +85,6 @@ public class PSystemCute extends AbstractPSystem {
|
||||
public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
|
||||
final ImageBuilder builder = new ImageBuilder(new ColorMapperIdentity(), 1.0, null, null, null, 10, 10, null, false);
|
||||
builder.addUDrawable(root);
|
||||
return builder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
|
||||
return builder.writeImageTOBEMOVED(fileFormat, os);
|
||||
}
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class DescriptionDiagram extends AbstractEntityDiagram {
|
||||
LeafType.DESCRIPTION, USymbol.ACTOR);
|
||||
}
|
||||
if (code2.startsWith("()")) {
|
||||
code2 = code2.substring(2).trim();
|
||||
code2 = StringUtils.trin(code2.substring(2));
|
||||
code2 = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(code2);
|
||||
return getOrCreateLeafDefault(Code.of(code2), LeafType.DESCRIPTION, USymbol.INTERFACE);
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ public class CommandCreateElementFull extends SingleLineCommand2<DescriptionDiag
|
||||
final String symbol;
|
||||
if (codeRaw.startsWith("()")) {
|
||||
symbol = "interface";
|
||||
codeRaw = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(codeRaw.substring(2).trim());
|
||||
codeRaw = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(codeRaw.substring(2)));
|
||||
} else if (codeChar == '(' || codeDisplay == '(') {
|
||||
symbol = "usecase";
|
||||
} else if (codeChar == ':' || codeDisplay == ':') {
|
||||
|
@ -82,7 +82,7 @@ public class CommandCreateElementMultilines extends CommandMultilines2<Descripti
|
||||
|
||||
public CommandExecutionResult executeNow(DescriptionDiagram diagram, List<String> lines) {
|
||||
StringUtils.trim(lines, false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(lines.get(0).trim());
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
final String symbol = StringUtils.goUpperCase(line0.get("TYPE", 0));
|
||||
final LeafType type;
|
||||
final USymbol usymbol;
|
||||
|
@ -167,7 +167,7 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
|
||||
if (s == null) {
|
||||
return "";
|
||||
}
|
||||
return StringUtils.goLowerCase(s.trim());
|
||||
return StringUtils.goLowerCase(StringUtils.trin(s));
|
||||
}
|
||||
|
||||
private Direction getDirection(RegexResult arg) {
|
||||
@ -213,7 +213,7 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
|
||||
final Matcher m1 = p1.matcher(labelLink);
|
||||
if (m1.matches()) {
|
||||
firstLabel = m1.group(1);
|
||||
labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m1.group(2).trim()).trim();
|
||||
labelLink = StringUtils.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m1.group(2))));
|
||||
secondLabel = m1.group(3);
|
||||
return;
|
||||
}
|
||||
@ -221,7 +221,7 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
|
||||
final Matcher m2 = p2.matcher(labelLink);
|
||||
if (m2.matches()) {
|
||||
firstLabel = m2.group(1);
|
||||
labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m2.group(2).trim()).trim();
|
||||
labelLink = StringUtils.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m2.group(2))));
|
||||
secondLabel = null;
|
||||
return;
|
||||
}
|
||||
@ -229,7 +229,7 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
|
||||
final Matcher m3 = p3.matcher(labelLink);
|
||||
if (m3.matches()) {
|
||||
firstLabel = null;
|
||||
labelLink = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(m3.group(1).trim()).trim();
|
||||
labelLink = StringUtils.trin(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(m3.group(1))));
|
||||
secondLabel = m3.group(2);
|
||||
}
|
||||
}
|
||||
@ -286,7 +286,7 @@ public class CommandLinkElement extends SingleLineCommand2<DescriptionDiagram> {
|
||||
final String code = code2.getFullName();
|
||||
if (code.startsWith("()")) {
|
||||
return diagram.getOrCreateLeaf(
|
||||
Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(code.substring(2).trim())),
|
||||
Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(StringUtils.trin(code.substring(2)))),
|
||||
LeafType.DESCRIPTION, USymbol.INTERFACE);
|
||||
}
|
||||
final char codeChar = code.length() > 2 ? code.charAt(0) : 0;
|
||||
|
@ -58,19 +58,14 @@ import net.sourceforge.plantuml.version.PSystemVersion;
|
||||
|
||||
public class PSystemDonors extends AbstractPSystem {
|
||||
|
||||
public static final String DONORS = "UDfTaikosZ0CXlTw2gypquT8IOTEu5pcqEcYEv7e41sCH6s7DddwYhR11gsiqUtx9TU--cyKu9KI1LTBKc7iu1jLsVG4MyrkY50lfRY7TSWXcc17Uuo9KTop3WArz1hSMYdDT7s-lrl6aeu2Mom6IOA65uSzrBcrNc0tPeG9rbpTcoYq2-KOOPVeF92ubUhPz3NB78gmEJsKQe2LUXRtfcCaQCU7UFMX9cHnpWnF1JMUIjT6rPv-e_IspjN0rlM0OJAbRpVPSe3daZxDyEBvOWKDTqSZlqLOu4kyjPO2eg8BDFE9KvZS5WVj4ThhqdyCQEsBl8fyFfVPSR8r2IRBCpxZQl_1q_5EbVHtxjzAjaRUobv2uXc-vd2lyCJTGDvzHlPJgS3F9KoCZsWjeNngiVivKdJDk0zef_LP_dVzIDGDRXCmOaOwaFtOue2_hX_DKjn6Bmn_0C5QlDy0";
|
||||
|
||||
// public ImageData exportDiagram(OutputStream os, int num, FileFormatOption
|
||||
// fileFormat) throws IOException {
|
||||
// return getGraphicStrings().exportDiagram(os, fileFormat);
|
||||
// }
|
||||
public static final String DONORS = "UDfTaisIsZ0Cn-zw2fypquT8IOTEO7SxIwU7taIY9LgCH6s7DddwYcs33JfPew_VNrRjg_z60RvHek1gIIgC7NodAfkUOAlP3H7gfHJti0uvH1FiQ8ynCOfxra6Wbbw3MokbcQxFjpVBMD9HO8l584dGyEAmXpgtrWlinemmmPghUnE5Tg4S8-mIdGSIjr8zcxvccKCHDgU7KWsmKi_YNdMC1Etu4A_UrOGipfdXgQ36K-dQgDhJ7vJUrhaQsBeUC4oczFKcMmxmNDAd6LuyNwoWuUvevBS82to9jzPIG5HqWMO-SGgJs-AWFK9xNVhF0QrzaLUHpzzbTfniJOB9yepFkDf_y7IyKoNzdVjHoTR8MzbBI3p3rnpk5Pwu6yYxpyX-AXNukOI9yH6j9PHFBNQ_Hegk6VS1xMjzblz3tnDrWzi4Z9YH3cGNMtpWx-kXMOhRw8NBk_cudB-jFS1F";
|
||||
|
||||
public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
|
||||
final GraphicStrings result = getGraphicStrings();
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.addUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
}
|
||||
|
||||
private GraphicStrings getGraphicStrings() throws IOException {
|
||||
|
@ -76,7 +76,7 @@ public class PSystemAppleTwo extends AbstractPSystem {
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.addUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
}
|
||||
|
||||
private GraphicStrings getGraphicStrings() throws IOException {
|
||||
|
@ -66,7 +66,7 @@ public class PSystemCharlie extends AbstractPSystem {
|
||||
ug.draw(im);
|
||||
}
|
||||
});
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
}
|
||||
|
||||
public DiagramDescription getDescription() {
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 15848 $
|
||||
* Revision $Revision: 16021 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.eggs;
|
||||
@ -68,7 +68,7 @@ public class PSystemEgg extends AbstractPSystem {
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.addUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
}
|
||||
|
||||
private GraphicStrings getGraphicStrings() throws IOException {
|
||||
|
@ -64,7 +64,7 @@ public class PSystemLost extends AbstractPSystem {
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.addUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
}
|
||||
|
||||
private GraphicStrings getGraphicStrings() throws IOException {
|
||||
|
@ -85,7 +85,7 @@ public class PSystemRIP extends AbstractPSystem {
|
||||
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
|
||||
getMetadata(), null, 0, 0, null, false);
|
||||
imageBuilder.addUDrawable(result);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat.getFileFormat(), os);
|
||||
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
|
||||
}
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user