mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-22 04:55:10 +00:00
version 8027
This commit is contained in:
parent
dd45415e20
commit
1c21c4ddaf
@ -28,22 +28,21 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 16265 $
|
||||
* Revision $Revision: 16390 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import net.sourceforge.plantuml.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.Command;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.ProtectedCommand;
|
||||
import net.sourceforge.plantuml.core.Diagram;
|
||||
import net.sourceforge.plantuml.core.UmlSource;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
|
||||
import net.sourceforge.plantuml.version.License;
|
||||
import net.sourceforge.plantuml.version.Version;
|
||||
|
||||
@ -106,7 +105,7 @@ public abstract class AbstractPSystem implements Diagram {
|
||||
return true;
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeCommand(Command cmd, List<String> lines) {
|
||||
public CommandExecutionResult executeCommand(Command cmd, BlocLines lines) {
|
||||
cmd = new ProtectedCommand(cmd);
|
||||
return cmd.execute(this, lines);
|
||||
}
|
||||
|
@ -44,23 +44,37 @@ import net.sourceforge.plantuml.core.Diagram;
|
||||
|
||||
public class BlockUml {
|
||||
|
||||
private final List<? extends CharSequence> data;
|
||||
private final List<CharSequence2> data;
|
||||
private final int startLine;
|
||||
private Diagram system;
|
||||
|
||||
private static final Pattern patternFilename = MyPattern.cmpile("^@start[^%s{}%g]+[%s{][%s%g]*([^%g]*?)[%s}%g]*$");
|
||||
|
||||
BlockUml(String... strings) {
|
||||
this(Arrays.asList(strings), 0);
|
||||
this(convert(strings), 0);
|
||||
}
|
||||
|
||||
public BlockUml(List<? extends CharSequence> strings, int startLine) {
|
||||
public static List<CharSequence2> convert(String... strings) {
|
||||
return convert(Arrays.asList(strings));
|
||||
}
|
||||
|
||||
public static List<CharSequence2> convert(List<String> strings) {
|
||||
final List<CharSequence2> result = new ArrayList<CharSequence2>();
|
||||
LineLocationImpl location = new LineLocationImpl("block", null);
|
||||
for (String s : strings) {
|
||||
location = location.oneLineRead();
|
||||
result.add(new CharSequence2Impl(s, location));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public BlockUml(List<CharSequence2> strings, int startLine) {
|
||||
this.startLine = startLine;
|
||||
final String s0 = StringUtils.trin(strings.get(0).toString());
|
||||
final CharSequence2 s0 = strings.get(0).trin();
|
||||
if (s0.startsWith("@start") == false) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
this.data = new ArrayList<CharSequence>(strings);
|
||||
this.data = new ArrayList<CharSequence2>(strings);
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
|
@ -37,6 +37,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -54,11 +55,11 @@ final public class BlockUmlBuilder {
|
||||
private Set<File> usedFiles = new HashSet<File>();
|
||||
private final UncommentReadLine reader2;
|
||||
|
||||
public BlockUmlBuilder(List<String> config, String charset, Defines defines, Reader reader, File newCurrentDir)
|
||||
throws IOException {
|
||||
public BlockUmlBuilder(List<String> config, String charset, Defines defines, Reader reader, File newCurrentDir,
|
||||
String desc) throws IOException {
|
||||
Preprocessor includer = null;
|
||||
try {
|
||||
reader2 = new UncommentReadLine(new ReadLineReader(reader));
|
||||
reader2 = new UncommentReadLine(new ReadLineReader(reader, desc));
|
||||
includer = new Preprocessor(reader2, charset, defines, newCurrentDir);
|
||||
init(includer, config);
|
||||
} finally {
|
||||
@ -69,14 +70,19 @@ final public class BlockUmlBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public BlockUmlBuilder(List<String> config, String charset, Defines defines, Reader reader)
|
||||
throws IOException {
|
||||
this(config, charset, defines, reader, null, null);
|
||||
}
|
||||
|
||||
private void init(Preprocessor includer, List<String> config) throws IOException {
|
||||
String s = null;
|
||||
List<String> current = null;
|
||||
CharSequence2 s = null;
|
||||
List<CharSequence2> current2 = null;
|
||||
boolean paused = false;
|
||||
int startLine = 0;
|
||||
while ((s = includer.readLine()) != null) {
|
||||
if (StartUtils.isArobaseStartDiagram(s)) {
|
||||
current = new ArrayList<String>();
|
||||
current2 = new ArrayList<CharSequence2>();
|
||||
paused = false;
|
||||
startLine = includer.getLineNumber();
|
||||
}
|
||||
@ -84,12 +90,12 @@ final public class BlockUmlBuilder {
|
||||
paused = true;
|
||||
reader2.setPaused(true);
|
||||
}
|
||||
if (current != null && paused == false) {
|
||||
current.add(s);
|
||||
if (current2 != null && paused == false) {
|
||||
current2.add(s);
|
||||
} else if (paused) {
|
||||
final String append = StartUtils.getPossibleAppend(s);
|
||||
final CharSequence2 append = StartUtils.getPossibleAppend(s);
|
||||
if (append != null) {
|
||||
current.add(append);
|
||||
current2.add(append);
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,15 +103,23 @@ final public class BlockUmlBuilder {
|
||||
paused = false;
|
||||
reader2.setPaused(false);
|
||||
}
|
||||
if (StartUtils.isArobaseEndDiagram(s) && current != null) {
|
||||
current.addAll(1, config);
|
||||
blocks.add(new BlockUml(current, startLine));
|
||||
current = null;
|
||||
if (StartUtils.isArobaseEndDiagram(s) && current2 != null) {
|
||||
current2.addAll(1, convert(config, s.getLocation()));
|
||||
blocks.add(new BlockUml(current2, startLine));
|
||||
current2 = null;
|
||||
reader2.setPaused(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Collection<CharSequence2> convert(List<String> config, LineLocation location) {
|
||||
final List<CharSequence2> result = new ArrayList<CharSequence2>();
|
||||
for (String s : config) {
|
||||
result.add(new CharSequence2Impl(s, location));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<BlockUml> getBlockUmls() {
|
||||
return Collections.unmodifiableList(blocks);
|
||||
}
|
||||
|
@ -27,31 +27,26 @@
|
||||
* in the United States and other countries.]
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 9786 $
|
||||
*
|
||||
* Revision $Revision: 3824 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.preproc;
|
||||
package net.sourceforge.plantuml;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
public interface CharSequence2 extends CharSequence {
|
||||
|
||||
public class StackReadLine implements ReadLine {
|
||||
public int length();
|
||||
|
||||
final private Iterator<String> it;
|
||||
public char charAt(int index);
|
||||
|
||||
public StackReadLine(Collection<String> all) {
|
||||
this.it = all.iterator();
|
||||
}
|
||||
public CharSequence2 subSequence(int start, int end);
|
||||
|
||||
public void close() {
|
||||
}
|
||||
public String toString2();
|
||||
|
||||
public LineLocation getLocation();
|
||||
|
||||
public String readLine() {
|
||||
if (it.hasNext()) {
|
||||
return it.next();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public CharSequence2 trin();
|
||||
|
||||
public boolean startsWith(String string);
|
||||
|
||||
}
|
90
src/net/sourceforge/plantuml/CharSequence2Impl.java
Normal file
90
src/net/sourceforge/plantuml/CharSequence2Impl.java
Normal file
@ -0,0 +1,90 @@
|
||||
/* ========================================================================
|
||||
* 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: 3824 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
|
||||
public class CharSequence2Impl implements CharSequence2 {
|
||||
|
||||
private final CharSequence s;
|
||||
private final LineLocation location;
|
||||
|
||||
public CharSequence2Impl(CharSequence s, LineLocation location) {
|
||||
if (s == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
this.s = s;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public static CharSequence2 errorPreprocessor(CharSequence s, LineLocation lineLocation) {
|
||||
return new CharSequence2Impl(s, lineLocation);
|
||||
}
|
||||
|
||||
public int length() {
|
||||
return s.length();
|
||||
}
|
||||
|
||||
public char charAt(int index) {
|
||||
return s.charAt(index);
|
||||
}
|
||||
|
||||
public CharSequence2 subSequence(int start, int end) {
|
||||
return new CharSequence2Impl(s.subSequence(start, end), location);
|
||||
}
|
||||
|
||||
public CharSequence toCharSequence() {
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public String toString2() {
|
||||
return s.toString();
|
||||
}
|
||||
|
||||
public LineLocation getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public CharSequence2 trin() {
|
||||
return new CharSequence2Impl(StringUtils.trin(s.toString()), location);
|
||||
}
|
||||
|
||||
public boolean startsWith(String start) {
|
||||
return s.toString().startsWith(start);
|
||||
}
|
||||
|
||||
}
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 15877 $
|
||||
* Revision $Revision: 16364 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
@ -106,25 +106,25 @@ public enum ColorParam {
|
||||
sequenceBoxBackground(HtmlColorUtils.COL_DDDDDD, true),
|
||||
|
||||
artifactBackground(HtmlColorUtils.MY_YELLOW),
|
||||
artifactBorder(HtmlColorUtils.MY_RED),
|
||||
artifactBorder(HtmlColorUtils.BLACK),
|
||||
cloudBackground(HtmlColorUtils.MY_YELLOW),
|
||||
cloudBorder(HtmlColorUtils.MY_RED),
|
||||
cloudBorder(HtmlColorUtils.BLACK),
|
||||
queueBackground(HtmlColorUtils.MY_YELLOW),
|
||||
queueBorder(HtmlColorUtils.MY_RED),
|
||||
databaseBackground(HtmlColorUtils.MY_YELLOW),
|
||||
databaseBorder(HtmlColorUtils.MY_RED),
|
||||
databaseBorder(HtmlColorUtils.BLACK),
|
||||
folderBackground(HtmlColorUtils.MY_YELLOW),
|
||||
folderBorder(HtmlColorUtils.MY_RED),
|
||||
folderBorder(HtmlColorUtils.BLACK),
|
||||
frameBackground(HtmlColorUtils.MY_YELLOW),
|
||||
frameBorder(HtmlColorUtils.MY_RED),
|
||||
frameBorder(HtmlColorUtils.BLACK),
|
||||
nodeBackground(HtmlColorUtils.MY_YELLOW),
|
||||
nodeBorder(HtmlColorUtils.MY_RED),
|
||||
nodeBorder(HtmlColorUtils.BLACK),
|
||||
rectangleBackground(HtmlColorUtils.MY_YELLOW),
|
||||
rectangleBorder(HtmlColorUtils.MY_RED),
|
||||
rectangleBorder(HtmlColorUtils.BLACK),
|
||||
agentBackground(HtmlColorUtils.MY_YELLOW),
|
||||
agentBorder(HtmlColorUtils.MY_RED),
|
||||
storageBackground(HtmlColorUtils.MY_YELLOW),
|
||||
storageBorder(HtmlColorUtils.MY_RED),
|
||||
storageBorder(HtmlColorUtils.BLACK),
|
||||
boundaryBackground(HtmlColorUtils.MY_YELLOW),
|
||||
boundaryBorder(HtmlColorUtils.MY_RED),
|
||||
controlBackground(HtmlColorUtils.MY_YELLOW),
|
||||
|
@ -42,14 +42,16 @@ public class ErrorUml {
|
||||
private final int position;
|
||||
private final ErrorUmlType type;
|
||||
private SuggestEngineResult suggest;
|
||||
private final LineLocation lineLocation;
|
||||
|
||||
public ErrorUml(ErrorUmlType type, String error, int position) {
|
||||
public ErrorUml(ErrorUmlType type, String error, int position, LineLocation lineLocation) {
|
||||
if (error == null || type == null || StringUtils.isEmpty(error)) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
this.error = error;
|
||||
this.type = type;
|
||||
this.position = position;
|
||||
this.lineLocation = lineLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,6 +82,10 @@ public class ErrorUml {
|
||||
return position;
|
||||
}
|
||||
|
||||
public LineLocation getLineLocation() {
|
||||
return lineLocation;
|
||||
}
|
||||
|
||||
public final SuggestEngineResult getSuggest() {
|
||||
return suggest;
|
||||
}
|
||||
@ -92,4 +98,5 @@ public class ErrorUml {
|
||||
this.suggest = suggest;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
61
src/net/sourceforge/plantuml/LineLocation.java
Normal file
61
src/net/sourceforge/plantuml/LineLocation.java
Normal file
@ -0,0 +1,61 @@
|
||||
/* ========================================================================
|
||||
* 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: 3824 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
|
||||
/**
|
||||
* Indicates the location of a line of code within a resource.
|
||||
* The resource maybe a local file or a remote URL.
|
||||
*
|
||||
*/
|
||||
public interface LineLocation {
|
||||
|
||||
/**
|
||||
* Position of the line, starting at 0.
|
||||
*/
|
||||
public int getPosition();
|
||||
|
||||
/**
|
||||
* A description of the ressource.
|
||||
* If the ressource is a file, this is the complete path of the file.
|
||||
*/
|
||||
public String getDescription();
|
||||
|
||||
/**
|
||||
* Get the parent of this location.
|
||||
* If this resource has been included by a !include or !includeurl directive,
|
||||
* this return the location of the !include line.
|
||||
*/
|
||||
public LineLocation getParent();
|
||||
|
||||
}
|
83
src/net/sourceforge/plantuml/LineLocationImpl.java
Normal file
83
src/net/sourceforge/plantuml/LineLocationImpl.java
Normal file
@ -0,0 +1,83 @@
|
||||
/* ========================================================================
|
||||
* 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: 3824 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
|
||||
public class LineLocationImpl implements LineLocation {
|
||||
|
||||
private final String desc;
|
||||
private final int position;
|
||||
private final LineLocation parent;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (desc == null) {
|
||||
return "[?] : " + position;
|
||||
}
|
||||
return desc + " : " + position;
|
||||
}
|
||||
|
||||
public LineLocationImpl(String desc, LineLocation parent) {
|
||||
this(desc, parent, -1);
|
||||
}
|
||||
|
||||
private LineLocationImpl(String desc, LineLocation parent, int position) {
|
||||
this.parent = parent;
|
||||
this.desc = desc;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public LineLocationImpl oneLineRead() {
|
||||
return new LineLocationImpl(desc, parent, position + 1);
|
||||
}
|
||||
|
||||
public static LineLocation fromLine(CharSequence cs) {
|
||||
if (cs instanceof CharSequence2) {
|
||||
return ((CharSequence2) cs).getLocation();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public LineLocation getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
}
|
@ -38,6 +38,7 @@ import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.Command;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.core.Diagram;
|
||||
@ -65,7 +66,7 @@ public class NewpagedDiagram extends AbstractPSystem {
|
||||
return super.toString() + " SIZE=" + diagrams.size() + " " + diagrams;
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeCommand(Command cmd, List<String> lines) {
|
||||
public CommandExecutionResult executeCommand(Command cmd, BlocLines lines) {
|
||||
final int nb = diagrams.size();
|
||||
final CommandExecutionResult tmp = cmd.execute(diagrams.get(nb - 1), lines);
|
||||
if (tmp.getNewDiagram() instanceof NewpagedDiagram) {
|
||||
|
@ -83,13 +83,13 @@ public class PSystemBuilder {
|
||||
|
||||
public static final long startTime = System.currentTimeMillis();
|
||||
|
||||
final public Diagram createPSystem(final List<? extends CharSequence> strings) {
|
||||
final public Diagram createPSystem(final List<CharSequence2> strings2) {
|
||||
|
||||
final List<PSystemFactory> factories = getAllFactories();
|
||||
|
||||
final DiagramType type = DiagramType.getTypeFromArobaseStart(strings.get(0).toString());
|
||||
final DiagramType type = DiagramType.getTypeFromArobaseStart(strings2.get(0).toString2());
|
||||
|
||||
final UmlSource umlSource = new UmlSource(strings, type == DiagramType.UML);
|
||||
final UmlSource umlSource = new UmlSource(strings2, type == DiagramType.UML);
|
||||
final DiagramType diagramType = umlSource.getDiagramType();
|
||||
final List<PSystemError> errors = new ArrayList<PSystemError>();
|
||||
for (PSystemFactory systemFactory : factories) {
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 16158 $
|
||||
* Revision $Revision: 16367 $
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
|
||||
@ -119,7 +119,10 @@ public class PSystemError extends AbstractPSystem {
|
||||
}
|
||||
|
||||
private List<String> getTextStrings() {
|
||||
final List<String> result = new ArrayList<String>();
|
||||
final List<String> result = new ArrayList<String>(getStack());
|
||||
if (result.size() > 0) {
|
||||
result.add(" ");
|
||||
}
|
||||
|
||||
final int limit = 4;
|
||||
int start;
|
||||
@ -168,8 +171,39 @@ public class PSystemError extends AbstractPSystem {
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<String> getStack() {
|
||||
LineLocation lineLocation = getLineLocation();
|
||||
final List<String> result = new ArrayList<String>();
|
||||
if (lineLocation != null) {
|
||||
append(result, lineLocation);
|
||||
while (lineLocation.getParent() != null) {
|
||||
lineLocation = lineLocation.getParent();
|
||||
append(result, lineLocation);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public LineLocation getLineLocation() {
|
||||
for (ErrorUml err : printedErrors) {
|
||||
if (err.getLineLocation() != null) {
|
||||
return err.getLineLocation();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void append(List<String> result, LineLocation lineLocation) {
|
||||
if (lineLocation.getDescription() != null) {
|
||||
result.add("[From " + lineLocation.getDescription() + " (line " + (lineLocation.getPosition() + 1) + ") ]");
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getHtmlStrings(boolean useRed) {
|
||||
final List<String> htmlStrings = new ArrayList<String>();
|
||||
final List<String> htmlStrings = new ArrayList<String>(getStack());
|
||||
if (htmlStrings.size() > 0) {
|
||||
htmlStrings.add("----");
|
||||
}
|
||||
|
||||
final int limit = 4;
|
||||
int start;
|
||||
@ -306,6 +340,9 @@ public class PSystemError extends AbstractPSystem {
|
||||
final List<ErrorUml> errors = new ArrayList<ErrorUml>();
|
||||
final List<String> debugs = new ArrayList<String>();
|
||||
for (PSystemError system : ps) {
|
||||
if (system == null) {
|
||||
continue;
|
||||
}
|
||||
if (system.getSource() != null && source == null) {
|
||||
source = system.getSource();
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 16196 $
|
||||
* Revision $Revision: 16447 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
|
@ -98,7 +98,7 @@ public class SourceFileReader implements ISourceFileReader {
|
||||
this.outputDirectory = outputDirectory;
|
||||
|
||||
builder = new BlockUmlBuilder(config, charset, defines, getReader(charset), file.getAbsoluteFile()
|
||||
.getParentFile());
|
||||
.getParentFile(), file.getAbsolutePath());
|
||||
}
|
||||
|
||||
public boolean hasError() {
|
||||
|
@ -69,7 +69,7 @@ public class SourceFileReader2 implements ISourceFileReader {
|
||||
FileSystem.getInstance().setCurrentDir(file.getAbsoluteFile().getParentFile());
|
||||
|
||||
builder = new BlockUmlBuilder(config, charset, defines, getReader(charset), file.getAbsoluteFile()
|
||||
.getParentFile());
|
||||
.getParentFile(), file.getAbsolutePath());
|
||||
}
|
||||
|
||||
public boolean hasError() {
|
||||
|
@ -72,8 +72,7 @@ public class SourceStringReader {
|
||||
// WARNING GLOBAL LOCK HERE
|
||||
synchronized (SourceStringReader.class) {
|
||||
try {
|
||||
final BlockUmlBuilder builder = new BlockUmlBuilder(config, charset, defines, new StringReader(source),
|
||||
null);
|
||||
final BlockUmlBuilder builder = new BlockUmlBuilder(config, charset, defines, new StringReader(source));
|
||||
this.blocks = builder.getBlockUmls();
|
||||
} catch (IOException e) {
|
||||
Log.error("error " + e);
|
||||
|
@ -35,23 +35,17 @@ package net.sourceforge.plantuml;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.cucadiagram.Code;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorTransparent;
|
||||
import net.sourceforge.plantuml.preproc.ReadLineReader;
|
||||
import net.sourceforge.plantuml.preproc.UncommentReadLine;
|
||||
import net.sourceforge.plantuml.ugraphic.ColorMapper;
|
||||
|
||||
// Do not move
|
||||
@ -61,11 +55,7 @@ public class StringUtils {
|
||||
return file.getAbsolutePath();
|
||||
}
|
||||
|
||||
public static List<String> getWithNewlines2(Code s) {
|
||||
return getWithNewlines2(s.getFullName());
|
||||
}
|
||||
|
||||
public static List<String> getWithNewlines2(String s) {
|
||||
public static List<String> getWithNewlines(CharSequence s) {
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
@ -92,16 +82,6 @@ public class StringUtils {
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
public static String getMergedLines(List<? extends CharSequence> strings) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < strings.size(); i++) {
|
||||
sb.append(strings.get(i));
|
||||
if (i < strings.size() - 1) {
|
||||
sb.append("\\n");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
final static public List<String> getSplit(Pattern pattern, String line) {
|
||||
final Matcher m = pattern.matcher(line);
|
||||
@ -312,7 +292,7 @@ public class StringUtils {
|
||||
public static char hiddenBiggerThan() {
|
||||
return '\u0006';
|
||||
}
|
||||
|
||||
|
||||
public static char hiddenNewLine() {
|
||||
return '\u0009';
|
||||
}
|
||||
@ -329,16 +309,6 @@ public class StringUtils {
|
||||
return s;
|
||||
}
|
||||
|
||||
public static int getWidth(List<? extends CharSequence> stringsToDisplay) {
|
||||
int result = 1;
|
||||
for (CharSequence s : stringsToDisplay) {
|
||||
if (result < s.length()) {
|
||||
result = s.length();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static int getWidth(Display stringsToDisplay) {
|
||||
int result = 1;
|
||||
for (CharSequence s : stringsToDisplay) {
|
||||
@ -357,108 +327,10 @@ public class StringUtils {
|
||||
return stringsToDisplay.size();
|
||||
}
|
||||
|
||||
private static void removeFirstColumn(List<String> data) {
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
final String s = data.get(i);
|
||||
if (s.length() > 0) {
|
||||
data.set(i, s.substring(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean firstColumnRemovable(List<String> data) {
|
||||
boolean allEmpty = true;
|
||||
for (String s : data) {
|
||||
if (s.length() == 0) {
|
||||
continue;
|
||||
}
|
||||
allEmpty = false;
|
||||
final char c = s.charAt(0);
|
||||
if (c != ' ' && c != '\t') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return allEmpty == false;
|
||||
}
|
||||
|
||||
public static List<String> removeEmptyColumns(List<String> data) {
|
||||
if (firstColumnRemovable(data) == false) {
|
||||
return data;
|
||||
}
|
||||
final List<String> result = new ArrayList<String>(data);
|
||||
do {
|
||||
removeFirstColumn(result);
|
||||
} while (firstColumnRemovable(result));
|
||||
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, trin(s));
|
||||
}
|
||||
if (removeEmptyLines) {
|
||||
for (final Iterator<String> it = data.iterator(); it.hasNext();) {
|
||||
if (it.next().length() == 0) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String uncommentSource(String source) {
|
||||
final StringReader sr = new StringReader(source);
|
||||
final UncommentReadLine un = new UncommentReadLine(new ReadLineReader(sr));
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
String s = null;
|
||||
try {
|
||||
while ((s = un.readLine()) != null) {
|
||||
sb.append(s);
|
||||
sb.append('\n');
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.error("Error " + e);
|
||||
throw new IllegalStateException(e.toString());
|
||||
}
|
||||
|
||||
sr.close();
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static boolean isDiagramCacheable(String uml) {
|
||||
uml = uml.toLowerCase();
|
||||
if (uml.startsWith("@startuml\nversion\n")) {
|
||||
@ -550,16 +422,26 @@ public class StringUtils {
|
||||
return st.replaceAll("\\<\\<([^<>]+)\\>\\>", "\u00AB$1\u00BB");
|
||||
}
|
||||
|
||||
public static String trinNoTrace(String s) {
|
||||
return s.trim();
|
||||
public static String trinNoTrace(CharSequence s) {
|
||||
return s.toString().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;
|
||||
public static String trin(CharSequence arg) {
|
||||
if (arg.length() == 0) {
|
||||
return arg.toString();
|
||||
}
|
||||
int i = 0;
|
||||
while (i < arg.length() && isSpaceOrTab(arg.charAt(i))) {
|
||||
i++;
|
||||
}
|
||||
int j = arg.length() - 1;
|
||||
while (j >= i && isSpaceOrTab(arg.charAt(j))) {
|
||||
j--;
|
||||
}
|
||||
if (i == 0 && j == arg.length() - 1) {
|
||||
return arg.toString();
|
||||
}
|
||||
return arg.subSequence(i, j + 1).toString();
|
||||
}
|
||||
|
||||
// http://docs.oracle.com/javase/tutorial/i18n/format/dateFormat.html
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 16158 $
|
||||
* Revision $Revision: 16441 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml;
|
||||
@ -205,7 +205,7 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram {
|
||||
return scale;
|
||||
}
|
||||
|
||||
final public void setAnimation(List<String> animationData) {
|
||||
final public void setAnimation(Iterable<CharSequence> animationData) {
|
||||
try {
|
||||
final AnimationDecoder animationDecoder = new AnimationDecoder(animationData);
|
||||
this.animation = Animation.create(animationDecoder.decode());
|
||||
|
@ -41,7 +41,7 @@ import net.sourceforge.plantuml.activitydiagram.command.CommandEndPartition;
|
||||
import net.sourceforge.plantuml.activitydiagram.command.CommandEndif;
|
||||
import net.sourceforge.plantuml.activitydiagram.command.CommandIf;
|
||||
import net.sourceforge.plantuml.activitydiagram.command.CommandLinkActivity;
|
||||
import net.sourceforge.plantuml.activitydiagram.command.CommandLinkLongActivity2;
|
||||
import net.sourceforge.plantuml.activitydiagram.command.CommandLinkLongActivity;
|
||||
import net.sourceforge.plantuml.activitydiagram.command.CommandPartition;
|
||||
import net.sourceforge.plantuml.command.Command;
|
||||
import net.sourceforge.plantuml.command.CommandFootboxIgnored;
|
||||
@ -66,7 +66,7 @@ public class ActivityDiagramFactory extends UmlDiagramFactory {
|
||||
|
||||
cmds.add(new CommandPartition());
|
||||
cmds.add(new CommandEndPartition());
|
||||
cmds.add(new CommandLinkLongActivity2());
|
||||
cmds.add(new CommandLinkLongActivity());
|
||||
|
||||
final FactoryNoteActivityCommand factoryNoteActivityCommand = new FactoryNoteActivityCommand();
|
||||
cmds.add(factoryNoteActivityCommand.createSingleLine());
|
||||
|
@ -36,10 +36,13 @@ package net.sourceforge.plantuml.activitydiagram.command;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.Direction;
|
||||
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.activitydiagram.ActivityDiagram;
|
||||
import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
|
||||
import net.sourceforge.plantuml.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||
import net.sourceforge.plantuml.command.MultilinesStrategy;
|
||||
@ -58,7 +61,6 @@ import net.sourceforge.plantuml.cucadiagram.Link;
|
||||
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
|
||||
import net.sourceforge.plantuml.cucadiagram.LinkType;
|
||||
import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram> {
|
||||
|
||||
@ -85,7 +87,15 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
|
||||
new RegexLeaf("BACKCOLOR", "(#\\w+)?"), //
|
||||
new RegexLeaf("[%s]*"), //
|
||||
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
|
||||
new RegexLeaf("ARROW", "([-=.]+(?:(left|right|up|down|le?|ri?|up?|do?)(?=[-=.]))?[-=.]*\\>)"), //
|
||||
|
||||
new RegexLeaf("ARROW_BODY1", "([-.]+)"), //
|
||||
new RegexLeaf("ARROW_STYLE1",
|
||||
"(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), //
|
||||
new RegexLeaf("ARROW_DIRECTION", "(\\*|left|right|up|down|le?|ri?|up?|do?)?"), //
|
||||
new RegexLeaf("ARROW_STYLE2",
|
||||
"(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), //
|
||||
new RegexLeaf("ARROW_BODY2", "([-.]*)\\>"), //
|
||||
|
||||
new RegexLeaf("[%s]*"), //
|
||||
new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), //
|
||||
new RegexLeaf("[%s]*"), //
|
||||
@ -94,9 +104,9 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
|
||||
new RegexLeaf("$"));
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(final ActivityDiagram diagram, List<String> lines) {
|
||||
StringUtils.trim(lines, false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
public CommandExecutionResult executeNow(final ActivityDiagram diagram, BlocLines lines) {
|
||||
lines = lines.trim(false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
|
||||
final IEntity entity1 = CommandLinkActivity.getEntity(diagram, line0, true);
|
||||
|
||||
@ -112,29 +122,29 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
|
||||
final String desc0 = line0.get("DESC", 0);
|
||||
Url urlActivity = null;
|
||||
if (StringUtils.isNotEmpty(desc0)) {
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
|
||||
urlActivity = urlBuilder.getUrl(desc0);
|
||||
urlActivity = extractUrl(diagram, desc0);
|
||||
if (urlActivity == null) {
|
||||
sb.append(desc0);
|
||||
sb.append("\\n");
|
||||
}
|
||||
}
|
||||
for (int i = 1; i < lines.size() - 1; i++) {
|
||||
int i = 0;
|
||||
for (CharSequence cs : lines.subExtract(1, 1)) {
|
||||
i++;
|
||||
if (i == 1 && urlActivity == null) {
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
|
||||
urlActivity = urlBuilder.getUrl(lines.get(i));
|
||||
urlActivity = extractUrl(diagram, cs);
|
||||
if (urlActivity != null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
sb.append(lines.get(i));
|
||||
sb.append(cs);
|
||||
if (i < lines.size() - 2) {
|
||||
sb.append("\\n");
|
||||
}
|
||||
}
|
||||
|
||||
final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()),
|
||||
lines.get(lines.size() - 1));
|
||||
final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()), lines.getLast499()
|
||||
.toString());
|
||||
if (StringUtils.isNotEmpty(lineLast.get(0))) {
|
||||
if (sb.length() > 0 && sb.toString().endsWith("\\n") == false) {
|
||||
sb.append("\\n");
|
||||
@ -151,8 +161,7 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
|
||||
partition = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(partition);
|
||||
}
|
||||
if (partition != null) {
|
||||
diagram.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), GroupType.PACKAGE,
|
||||
null);
|
||||
diagram.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), GroupType.PACKAGE, null);
|
||||
}
|
||||
final IEntity entity2 = diagram.createLeaf(code, Display.getWithNewlines(display), LeafType.ACTIVITY, null);
|
||||
if (partition != null) {
|
||||
@ -173,17 +182,22 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
|
||||
return CommandExecutionResult.error("No such entity");
|
||||
}
|
||||
|
||||
final String arrow = StringUtils.manageArrowForCuca(line0.get("ARROW", 0));
|
||||
final String arrowBody1 = CommandLinkClass.notNull(line0.get("ARROW_BODY1", 0));
|
||||
final String arrowBody2 = CommandLinkClass.notNull(line0.get("ARROW_BODY2", 0));
|
||||
final String arrowDirection = CommandLinkClass.notNull(line0.get("ARROW_DIRECTION", 0));
|
||||
|
||||
final String arrow = StringUtils.manageArrowForCuca(arrowBody1 + arrowDirection + arrowBody2 + ">");
|
||||
|
||||
final int lenght = arrow.length() - 1;
|
||||
|
||||
final Display linkLabel = Display.getWithNewlines(line0.get("BRACKET", 0));
|
||||
|
||||
LinkType type = new LinkType(LinkDecor.ARROW, LinkDecor.NONE);
|
||||
if (line0.get("ARROW", 0).contains(".")) {
|
||||
if (arrow.contains(".")) {
|
||||
type = type.getDotted();
|
||||
}
|
||||
Link link = new Link(entity1, entity2, type, linkLabel, lenght);
|
||||
final Direction direction = StringUtils.getArrowDirection(line0.get("ARROW", 0));
|
||||
final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">");
|
||||
if (direction == Direction.LEFT || direction == Direction.UP) {
|
||||
link = link.getInv();
|
||||
}
|
||||
@ -194,9 +208,15 @@ public class CommandLinkLongActivity extends CommandMultilines2<ActivityDiagram>
|
||||
link.setUrl(urlLink);
|
||||
}
|
||||
|
||||
CommandLinkClass.applyStyle(line0.getLazzy("ARROW_STYLE", 0), link);
|
||||
diagram.addLink(link);
|
||||
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
public Url extractUrl(final ActivityDiagram diagram, CharSequence string) {
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
|
||||
return urlBuilder.getUrl(string.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,219 +0,0 @@
|
||||
/* ========================================================================
|
||||
* 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: 5031 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.activitydiagram.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.Direction;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.UrlBuilder;
|
||||
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
|
||||
import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
|
||||
import net.sourceforge.plantuml.classdiagram.command.CommandLinkClass;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||
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.RegexOptional;
|
||||
import net.sourceforge.plantuml.command.regex.RegexOr;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
import net.sourceforge.plantuml.cucadiagram.Code;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.cucadiagram.GroupType;
|
||||
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.cucadiagram.Stereotype;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorSet;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class CommandLinkLongActivity2 extends CommandMultilines2<ActivityDiagram> {
|
||||
|
||||
public CommandLinkLongActivity2() {
|
||||
super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPatternEnd() {
|
||||
return "(?i)^[%s]*([^%g]*)[%g](?:[%s]+as[%s]+([\\p{L}0-9][\\p{L}0-9_.]*))?[%s]*(\\<\\<.*\\>\\>)?[%s]*(?:in[%s]+([%g][^%g]+[%g]|\\S+))?[%s]*(#\\w+)?$";
|
||||
}
|
||||
|
||||
static RegexConcat getRegexConcat() {
|
||||
return new RegexConcat(new RegexLeaf("^"), //
|
||||
new RegexOptional(//
|
||||
new RegexOr("FIRST", //
|
||||
new RegexLeaf("STAR", "(\\(\\*(top)?\\))"), //
|
||||
new RegexLeaf("CODE", "([\\p{L}0-9][\\p{L}0-9_.]*)"), //
|
||||
new RegexLeaf("BAR", "(?:==+)[%s]*([\\p{L}0-9_.]+)[%s]*(?:==+)"), //
|
||||
new RegexLeaf("QUOTED", "[%g]([^%g]+)[%g](?:[%s]+as[%s]+([\\p{L}0-9_.]+))?"))), //
|
||||
new RegexLeaf("[%s]*"), //
|
||||
new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
|
||||
new RegexLeaf("[%s]*"), //
|
||||
new RegexLeaf("BACKCOLOR", "(#\\w+)?"), //
|
||||
new RegexLeaf("[%s]*"), //
|
||||
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
|
||||
|
||||
new RegexLeaf("ARROW_BODY1", "([-.]+)"), //
|
||||
new RegexLeaf("ARROW_STYLE1",
|
||||
"(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), //
|
||||
new RegexLeaf("ARROW_DIRECTION", "(\\*|left|right|up|down|le?|ri?|up?|do?)?"), //
|
||||
new RegexLeaf("ARROW_STYLE2",
|
||||
"(?:\\[((?:#\\w+|dotted|dashed|bold|hidden)(?:,#\\w+|,dotted|,dashed|,bold|,hidden)*)\\])?"), //
|
||||
new RegexLeaf("ARROW_BODY2", "([-.]*)\\>"), //
|
||||
|
||||
new RegexLeaf("[%s]*"), //
|
||||
new RegexLeaf("BRACKET", "(?:\\[([^\\]*]+[^\\]]*)\\])?"), //
|
||||
new RegexLeaf("[%s]*"), //
|
||||
new RegexLeaf("DESC", "[%g]([^%g]*?)"), //
|
||||
new RegexLeaf("[%s]*"), //
|
||||
new RegexLeaf("$"));
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(final ActivityDiagram diagram, List<String> lines) {
|
||||
StringUtils.trim(lines, false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
|
||||
final IEntity entity1 = CommandLinkActivity.getEntity(diagram, line0, true);
|
||||
|
||||
if (line0.get("STEREOTYPE", 0) != null) {
|
||||
entity1.setStereotype(new Stereotype(line0.get("STEREOTYPE", 0)));
|
||||
}
|
||||
if (line0.get("BACKCOLOR", 0) != null) {
|
||||
entity1.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet()
|
||||
.getColorIfValid(line0.get("BACKCOLOR", 0)));
|
||||
}
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
final String desc0 = line0.get("DESC", 0);
|
||||
Url urlActivity = null;
|
||||
if (StringUtils.isNotEmpty(desc0)) {
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
|
||||
urlActivity = urlBuilder.getUrl(desc0);
|
||||
if (urlActivity == null) {
|
||||
sb.append(desc0);
|
||||
sb.append("\\n");
|
||||
}
|
||||
}
|
||||
for (int i = 1; i < lines.size() - 1; i++) {
|
||||
if (i == 1 && urlActivity == null) {
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
|
||||
urlActivity = urlBuilder.getUrl(lines.get(i));
|
||||
if (urlActivity != null) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
sb.append(lines.get(i));
|
||||
if (i < lines.size() - 2) {
|
||||
sb.append("\\n");
|
||||
}
|
||||
}
|
||||
|
||||
final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()),
|
||||
lines.get(lines.size() - 1));
|
||||
if (StringUtils.isNotEmpty(lineLast.get(0))) {
|
||||
if (sb.length() > 0 && sb.toString().endsWith("\\n") == false) {
|
||||
sb.append("\\n");
|
||||
}
|
||||
sb.append(lineLast.get(0));
|
||||
}
|
||||
|
||||
final String display = sb.toString();
|
||||
final Code code = Code.of(lineLast.get(1) == null ? display : lineLast.get(1));
|
||||
|
||||
String partition = null;
|
||||
if (lineLast.get(3) != null) {
|
||||
partition = lineLast.get(3);
|
||||
partition = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(partition);
|
||||
}
|
||||
if (partition != null) {
|
||||
diagram.getOrCreateGroup(Code.of(partition), Display.getWithNewlines(partition), GroupType.PACKAGE,
|
||||
null);
|
||||
}
|
||||
final IEntity entity2 = diagram.createLeaf(code, Display.getWithNewlines(display), LeafType.ACTIVITY, null);
|
||||
if (partition != null) {
|
||||
diagram.endGroup();
|
||||
}
|
||||
if (urlActivity != null) {
|
||||
entity2.addUrl(urlActivity);
|
||||
}
|
||||
|
||||
if (lineLast.get(2) != null) {
|
||||
entity2.setStereotype(new Stereotype(lineLast.get(2)));
|
||||
}
|
||||
if (lineLast.get(4) != null) {
|
||||
entity2.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(lineLast.get(4)));
|
||||
}
|
||||
|
||||
if (entity1 == null || entity2 == null) {
|
||||
return CommandExecutionResult.error("No such entity");
|
||||
}
|
||||
|
||||
final String arrowBody1 = CommandLinkClass.notNull(line0.get("ARROW_BODY1", 0));
|
||||
final String arrowBody2 = CommandLinkClass.notNull(line0.get("ARROW_BODY2", 0));
|
||||
final String arrowDirection = CommandLinkClass.notNull(line0.get("ARROW_DIRECTION", 0));
|
||||
|
||||
final String arrow = StringUtils.manageArrowForCuca(arrowBody1 + arrowDirection + arrowBody2 + ">");
|
||||
|
||||
final int lenght = arrow.length() - 1;
|
||||
|
||||
final Display linkLabel = Display.getWithNewlines(line0.get("BRACKET", 0));
|
||||
|
||||
LinkType type = new LinkType(LinkDecor.ARROW, LinkDecor.NONE);
|
||||
if (arrow.contains(".")) {
|
||||
type = type.getDotted();
|
||||
}
|
||||
Link link = new Link(entity1, entity2, type, linkLabel, lenght);
|
||||
final Direction direction = StringUtils.getArrowDirection(arrowBody1 + arrowDirection + arrowBody2 + ">");
|
||||
if (direction == Direction.LEFT || direction == Direction.UP) {
|
||||
link = link.getInv();
|
||||
}
|
||||
|
||||
if (line0.get("URL", 0) != null) {
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
|
||||
final Url urlLink = urlBuilder.getUrl(line0.get("URL", 0));
|
||||
link.setUrl(urlLink);
|
||||
}
|
||||
|
||||
CommandLinkClass.applyStyle(line0.getLazzy("ARROW_STYLE", 0), link);
|
||||
diagram.addLink(link);
|
||||
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
}
|
@ -99,10 +99,10 @@ public class ActivityDiagramFactory3 extends UmlDiagramFactory {
|
||||
cmds.add(new CommandActivity3());
|
||||
cmds.add(new CommandIf4());
|
||||
cmds.add(new CommandIf2());
|
||||
cmds.add(new CommandDecoratorMultine(new CommandIf2())); // UmlDiagramFactory
|
||||
// cmds.add(new CommandIf2Multilines());
|
||||
cmds.add(new CommandDecoratorMultine(new CommandIf2()));
|
||||
cmds.add(new CommandIfLegacy1());
|
||||
cmds.add(new CommandElseIf2());
|
||||
// cmds.add(new CommandDecoratorMultine(new CommandElseIf2()));
|
||||
cmds.add(new CommandElse3());
|
||||
cmds.add(new CommandDecoratorMultine(new CommandElse3()));
|
||||
cmds.add(new CommandElseLegacy1());
|
||||
|
@ -33,20 +33,18 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.activitydiagram3.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle;
|
||||
import net.sourceforge.plantuml.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||
import net.sourceforge.plantuml.command.MultilinesStrategy;
|
||||
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;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class CommandActivityLong3 extends CommandMultilines2<ActivityDiagram3> {
|
||||
|
||||
@ -67,36 +65,13 @@ public class CommandActivityLong3 extends CommandMultilines2<ActivityDiagram3> {
|
||||
new RegexLeaf("$"));
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(ActivityDiagram3 diagram, List<String> lines) {
|
||||
lines = StringUtils.removeEmptyColumns(lines);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
public CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) {
|
||||
lines = lines.removeEmptyColumns();
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0));
|
||||
final BoxStyle style = BoxStyle.fromChar(getLastChar(lines));
|
||||
removeStarting(lines, line0.get("DATA", 0));
|
||||
removeEnding(lines);
|
||||
diagram.addActivity(Display.create(lines), color, style, null);
|
||||
final BoxStyle style = BoxStyle.fromChar(lines.getLastChar());
|
||||
lines = lines.removeStartingAndEnding2(line0.get("DATA", 0));
|
||||
diagram.addActivity(lines.toDisplay(), color, style, null);
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
private char getLastChar(List<String> lines) {
|
||||
final String s = lines.get(lines.size() - 1);
|
||||
return s.charAt(s.length() - 1);
|
||||
}
|
||||
|
||||
private void removeStarting(List<String> lines, String data) {
|
||||
if (lines.size() == 0) {
|
||||
return;
|
||||
}
|
||||
lines.set(0, data);
|
||||
}
|
||||
|
||||
private void removeEnding(List<String> lines) {
|
||||
if (lines.size() == 0) {
|
||||
return;
|
||||
}
|
||||
final int n = lines.size() - 1;
|
||||
final String s = lines.get(n);
|
||||
lines.set(n, s.substring(0, s.length() - 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,9 @@ package net.sourceforge.plantuml.activitydiagram3.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
|
||||
import net.sourceforge.plantuml.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||
import net.sourceforge.plantuml.command.MultilinesStrategy;
|
||||
@ -45,7 +47,6 @@ import net.sourceforge.plantuml.command.regex.RegexOr;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class CommandArrowLong3 extends CommandMultilines2<ActivityDiagram3> {
|
||||
|
||||
@ -68,31 +69,30 @@ public class CommandArrowLong3 extends CommandMultilines2<ActivityDiagram3> {
|
||||
new RegexLeaf("$"));
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(ActivityDiagram3 diagram, List<String> lines) {
|
||||
lines = StringUtils.removeEmptyColumns(lines);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
public CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) {
|
||||
lines = lines.removeEmptyColumns();
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0));
|
||||
diagram.setColorNextArrow(color);
|
||||
removeStarting(lines, line0.get("LABEL", 0));
|
||||
removeEnding(lines);
|
||||
diagram.setLabelNextArrow(Display.create(lines));
|
||||
lines = lines.removeStartingAndEnding2(line0.get("LABEL", 0));
|
||||
diagram.setLabelNextArrow(lines.toDisplay());
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
private void removeStarting(List<String> lines, String data) {
|
||||
private <CS extends CharSequence> void removeStarting(List<CS> lines, String data) {
|
||||
if (lines.size() == 0) {
|
||||
return;
|
||||
}
|
||||
lines.set(0, data);
|
||||
lines.set(0, (CS)data);
|
||||
}
|
||||
|
||||
private void removeEnding(List<String> lines) {
|
||||
private <CS extends CharSequence> void removeEnding(List<CS> lines) {
|
||||
if (lines.size() == 0) {
|
||||
return;
|
||||
}
|
||||
final int n = lines.size() - 1;
|
||||
final String s = lines.get(n);
|
||||
lines.set(n, s.substring(0, s.length() - 1));
|
||||
final CharSequence s = lines.get(n);
|
||||
lines.set(n, (CS)s.subSequence(0, s.length() - 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ 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;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorSet;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
|
||||
public class CommandElseIf2 extends SingleLineCommand2<ActivityDiagram3> {
|
||||
|
@ -1,94 +0,0 @@
|
||||
/* ========================================================================
|
||||
* 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 net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||
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;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class CommandIf2Multilines extends CommandMultilines2<ActivityDiagram3> {
|
||||
|
||||
public CommandIf2Multilines() {
|
||||
super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPatternEnd() {
|
||||
return "(?i)^(.*?)\\)[%s]*(?:then[%s]*(?:\\((.+?)\\))?)?;?$";
|
||||
}
|
||||
|
||||
static RegexConcat getRegexConcat() {
|
||||
return new RegexConcat(new RegexLeaf("^"), //
|
||||
new RegexLeaf("COLOR", "(?:(" + HtmlColorUtils.COLOR_REGEXP + "):)?"), //
|
||||
new RegexLeaf("if"), //
|
||||
new RegexLeaf("[%s]*"), //
|
||||
new RegexLeaf("\\("), //
|
||||
new RegexLeaf("TEST", "([^)]*)$"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandExecutionResult executeNow(ActivityDiagram3 diagram, List<String> lines) {
|
||||
StringUtils.trim(lines, false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()),
|
||||
lines.get(lines.size() - 1));
|
||||
|
||||
final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0));
|
||||
|
||||
final String test = line0.get("TEST", 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(0);
|
||||
if (StringUtils.isEmpty(trailTest) == false) {
|
||||
testDisplay = testDisplay.add(trailTest);
|
||||
}
|
||||
|
||||
diagram.startIf(testDisplay, Display.getWithNewlines(lineLast.get(1)), color);
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
}
|
@ -35,7 +35,9 @@ package net.sourceforge.plantuml.activitydiagram3.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
|
||||
import net.sourceforge.plantuml.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||
import net.sourceforge.plantuml.command.MultilinesStrategy;
|
||||
@ -44,7 +46,6 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.sequencediagram.NotePosition;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class CommandNoteLong3 extends CommandMultilines2<ActivityDiagram3> {
|
||||
|
||||
@ -56,11 +57,13 @@ public class CommandNoteLong3 extends CommandMultilines2<ActivityDiagram3> {
|
||||
return "(?i)^end[%s]?note$";
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(final ActivityDiagram3 diagram, List<String> lines) {
|
||||
final List<String> in = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
public CommandExecutionResult executeNow(final ActivityDiagram3 diagram, BlocLines lines) {
|
||||
// final List<? extends CharSequence> in = StringUtils.removeEmptyColumns2(lines.subList(1, lines.size() - 1));
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
lines = lines.subExtract(1, 1);
|
||||
lines = lines.removeEmptyColumns();
|
||||
final NotePosition position = getPosition(line0.get("POSITION", 0));
|
||||
final Display note = Display.create(in);
|
||||
final Display note = lines.toDisplay();
|
||||
return diagram.addNote(note, position);
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.activitydiagram3.ActivityDiagram3;
|
||||
import net.sourceforge.plantuml.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines3;
|
||||
import net.sourceforge.plantuml.command.MultilinesStrategy;
|
||||
@ -71,10 +72,10 @@ public class CommandRepeatWhile3Multilines extends CommandMultilines3<ActivityDi
|
||||
}
|
||||
|
||||
@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));
|
||||
public CommandExecutionResult executeNow(ActivityDiagram3 diagram, BlocLines lines) {
|
||||
lines = lines.trim(false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
final RegexResult lineLast = getPatternEnd2().matcher(lines.getLast499().toString());
|
||||
|
||||
// System.err.println("line0=" + line0);
|
||||
// System.err.println("linesLast=" + lineLast);
|
||||
@ -84,8 +85,8 @@ public class CommandRepeatWhile3Multilines extends CommandMultilines3<ActivityDi
|
||||
|
||||
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));
|
||||
for (CharSequence s : lines.subExtract(1, 1)) {
|
||||
testDisplay = testDisplay.add(s);
|
||||
}
|
||||
final String trailTest = lineLast.get("TEST1", 0);
|
||||
if (StringUtils.isEmpty(trailTest) == false) {
|
||||
|
@ -53,7 +53,11 @@ import net.sourceforge.plantuml.graphic.StringBounder;
|
||||
import net.sourceforge.plantuml.graphic.SymbolContext;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||
import net.sourceforge.plantuml.graphic.UGraphicInterceptorUDrawable;
|
||||
import net.sourceforge.plantuml.graphic.USymbol;
|
||||
import net.sourceforge.plantuml.svek.UGraphicForSnake;
|
||||
import net.sourceforge.plantuml.ugraphic.LimitFinder;
|
||||
import net.sourceforge.plantuml.ugraphic.MinMax;
|
||||
import net.sourceforge.plantuml.ugraphic.UFont;
|
||||
import net.sourceforge.plantuml.ugraphic.UGraphic;
|
||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
@ -91,7 +95,7 @@ public class FtileGroup extends AbstractFtile {
|
||||
this.headerNote = new FloatingNote(displayNote, skinParam);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public LinkRendering getInLinkRendering() {
|
||||
return inner.getInLinkRendering();
|
||||
@ -119,8 +123,18 @@ public class FtileGroup extends AbstractFtile {
|
||||
return new UTranslate(suppWidth / 2, diffHeightTitle(stringBounder) + headerNoteHeight(stringBounder));
|
||||
}
|
||||
|
||||
private static MinMax getMinMax(TextBlock tb, StringBounder stringBounder) {
|
||||
final LimitFinder limitFinder = new LimitFinder(stringBounder, false);
|
||||
final UGraphicForSnake interceptor = new UGraphicForSnake(limitFinder);
|
||||
final UGraphicInterceptorUDrawable interceptor2 = new UGraphicInterceptorUDrawable(interceptor);
|
||||
|
||||
tb.drawU(interceptor2);
|
||||
interceptor2.flushUg();
|
||||
return limitFinder.getMinMax();
|
||||
}
|
||||
|
||||
public double suppWidth(StringBounder stringBounder) {
|
||||
final FtileGeometry orig = inner.calculateDimension(stringBounder);
|
||||
final FtileGeometry orig = getInnerDimension(stringBounder);
|
||||
final Dimension2D dimTitle = name.calculateDimension(stringBounder);
|
||||
final Dimension2D dimHeaderNote = headerNote.calculateDimension(stringBounder);
|
||||
final double suppWidth = MathUtils
|
||||
@ -128,8 +142,18 @@ public class FtileGroup extends AbstractFtile {
|
||||
return suppWidth;
|
||||
}
|
||||
|
||||
public FtileGeometry calculateDimension(StringBounder stringBounder) {
|
||||
private FtileGeometry getInnerDimension(StringBounder stringBounder) {
|
||||
final FtileGeometry orig = inner.calculateDimension(stringBounder);
|
||||
final MinMax minMax = getMinMax(inner, stringBounder);
|
||||
final double missingWidth = minMax.getMaxX() - orig.getWidth();
|
||||
if (missingWidth > 0) {
|
||||
return orig.addDim(missingWidth + 5, 0);
|
||||
}
|
||||
return orig;
|
||||
}
|
||||
|
||||
public FtileGeometry calculateDimension(StringBounder stringBounder) {
|
||||
final FtileGeometry orig = getInnerDimension(stringBounder);
|
||||
final double suppWidth = suppWidth(stringBounder);
|
||||
final double width = orig.getWidth() + suppWidth;
|
||||
final double height = orig.getHeight() + diffHeightTitle(stringBounder) + diffYY2
|
||||
|
@ -89,10 +89,10 @@ public class FtileCircleEnd extends AbstractFtile {
|
||||
circle.setDeltaShadow(3);
|
||||
}
|
||||
ug = ug.apply(new UChangeColor(backColor));
|
||||
ug.apply(new UChangeBackColor(HtmlColorUtils.WHITE))
|
||||
final double thickness = 2.5;
|
||||
ug.apply(new UChangeBackColor(HtmlColorUtils.WHITE)).apply(new UStroke(1.5))
|
||||
.apply(new UTranslate(xTheoricalPosition, yTheoricalPosition)).draw(circle);
|
||||
|
||||
final double thickness = 2.5;
|
||||
final double size2 = (SIZE - thickness) / Math.sqrt(2);
|
||||
final double delta = (SIZE - size2) / 2;
|
||||
ug = ug.apply(new UStroke(thickness));
|
||||
|
@ -35,6 +35,7 @@ package net.sourceforge.plantuml.anim;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
@ -44,14 +45,14 @@ public class AnimationDecoder {
|
||||
|
||||
private final List<String> result = new ArrayList<String>();
|
||||
|
||||
public AnimationDecoder(List<String> data) throws ScriptException {
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
String line = data.get(i);
|
||||
public AnimationDecoder(Iterable<CharSequence> data) throws ScriptException {
|
||||
|
||||
for (final Iterator<CharSequence> it = data.iterator(); it.hasNext();) {
|
||||
String line = it.next().toString();
|
||||
if (line.matches("^\\s*\\[script\\]\\s*$")) {
|
||||
final StringBuilder scriptText = new StringBuilder();
|
||||
while (true) {
|
||||
i++;
|
||||
line = data.get(i);
|
||||
line = it.next().toString();
|
||||
if (line.matches("^\\s*\\[/script\\]\\s*$")) {
|
||||
final AnimationScript script = new AnimationScript();
|
||||
final String out = script.eval(scriptText.toString());
|
||||
|
@ -33,13 +33,13 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.classdiagram.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
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.ClassDiagram;
|
||||
import net.sourceforge.plantuml.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||
import net.sourceforge.plantuml.command.MultilinesStrategy;
|
||||
@ -57,11 +57,9 @@ import net.sourceforge.plantuml.cucadiagram.LinkDecor;
|
||||
import net.sourceforge.plantuml.cucadiagram.LinkStyle;
|
||||
import net.sourceforge.plantuml.cucadiagram.LinkType;
|
||||
import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorSet;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.skin.VisibilityModifier;
|
||||
import net.sourceforge.plantuml.ugraphic.UStroke;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagram> {
|
||||
|
||||
@ -109,29 +107,29 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
|
||||
new RegexLeaf("[%s]*\\{[%s]*$"));
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(ClassDiagram diagram, List<String> lines) {
|
||||
StringUtils.trimSmart(lines, 1);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
public CommandExecutionResult executeNow(ClassDiagram diagram, BlocLines lines) {
|
||||
lines = lines.trimSmart(1);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
final IEntity entity = executeArg0(diagram, line0);
|
||||
if (entity == null) {
|
||||
return CommandExecutionResult.error("No such entity");
|
||||
}
|
||||
lines = lines.subList(1, lines.size() - 1);
|
||||
lines = lines.subExtract(1, 1);
|
||||
final Url url;
|
||||
if (lines.size() > 0) {
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
|
||||
url = urlBuilder.getUrl(lines.get(0).toString());
|
||||
url = urlBuilder.getUrl(lines.getFirst499().toString());
|
||||
} else {
|
||||
url = null;
|
||||
}
|
||||
if (url != null) {
|
||||
lines = lines.subList(1, lines.size());
|
||||
lines = lines.subExtract(1, 0);
|
||||
}
|
||||
for (String s : lines) {
|
||||
for (CharSequence s : lines) {
|
||||
if (s.length() > 0 && VisibilityModifier.isVisibilityCharacter(s.charAt(0))) {
|
||||
diagram.setVisibilityModifierPresent(true);
|
||||
}
|
||||
entity.getBodier().addFieldOrMethod(s);
|
||||
entity.getBodier().addFieldOrMethod(s.toString());
|
||||
}
|
||||
if (url != null) {
|
||||
entity.addUrl(url);
|
||||
|
@ -95,8 +95,8 @@ public class CommandCreateElementFull2 extends SingleLineCommand2<ClassDiagram>
|
||||
private static final String DISPLAY_WITHOUT_QUOTE = "(" + DISPLAY_CORE + "|[\\p{L}0-9_.]+)";
|
||||
|
||||
@Override
|
||||
final protected boolean isForbidden(String line) {
|
||||
if (line.matches("^[\\p{L}0-9_.]+$")) {
|
||||
final protected boolean isForbidden(CharSequence line) {
|
||||
if (line.toString().matches("^[\\p{L}0-9_.]+$")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 16197 $
|
||||
* Revision $Revision: 16447 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.classdiagram.command;
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 16194 $
|
||||
* Revision $Revision: 16447 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.classdiagram.command;
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 16194 $
|
||||
* Revision $Revision: 16447 $
|
||||
*
|
||||
*/
|
||||
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.CharSequence2;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.preproc.ReadLine;
|
||||
@ -49,16 +50,16 @@ public class ArobaseStringCompressor implements StringCompressor {
|
||||
private final static Pattern p = MyPattern.cmpile("(?s)(?i)^[%s]*(@startuml[^\\n\\r]*)?[%s]*(.*?)[%s]*(@enduml)?[%s]*$");
|
||||
|
||||
public String compress(final String data) throws IOException {
|
||||
final ReadLine r = new UncommentReadLine(new ReadLineReader(new StringReader(data)));
|
||||
final ReadLine r = new UncommentReadLine(new ReadLineReader(new StringReader(data), "COMPRESS"));
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
final StringBuilder full = new StringBuilder();
|
||||
String s = null;
|
||||
CharSequence2 s = null;
|
||||
boolean startDone = false;
|
||||
while ((s = r.readLine()) != null) {
|
||||
append(full, s);
|
||||
if (s.startsWith("@startuml")) {
|
||||
if (s.toString2().startsWith("@startuml")) {
|
||||
startDone = true;
|
||||
} else if (s.startsWith("@enduml")) {
|
||||
} else if (s.toString2().startsWith("@enduml")) {
|
||||
return sb.toString();
|
||||
} else if (startDone) {
|
||||
append(sb, s);
|
||||
@ -70,11 +71,11 @@ public class ArobaseStringCompressor implements StringCompressor {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private void append(final StringBuilder sb, String s) {
|
||||
private void append(final StringBuilder sb, CharSequence2 s) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append('\n');
|
||||
}
|
||||
sb.append(s);
|
||||
sb.append(s.toString2());
|
||||
}
|
||||
|
||||
private String compressOld(String s) throws IOException {
|
||||
|
224
src/net/sourceforge/plantuml/command/BlocLines.java
Normal file
224
src/net/sourceforge/plantuml/command/BlocLines.java
Normal file
@ -0,0 +1,224 @@
|
||||
/* ========================================================================
|
||||
* 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: 16351 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
|
||||
public class BlocLines implements Iterable<CharSequence> {
|
||||
|
||||
private List<CharSequence> lines;
|
||||
|
||||
private BlocLines(List<? extends CharSequence> lines) {
|
||||
this.lines = Collections.unmodifiableList(lines);
|
||||
}
|
||||
|
||||
public Display toDisplay() {
|
||||
return Display.create(lines);
|
||||
}
|
||||
|
||||
public static BlocLines single(CharSequence single) {
|
||||
return new BlocLines(Arrays.asList(single));
|
||||
}
|
||||
|
||||
public static BlocLines getWithNewlines(CharSequence s) {
|
||||
return new BlocLines(StringUtils.getWithNewlines(s));
|
||||
}
|
||||
|
||||
|
||||
public BlocLines() {
|
||||
this(new ArrayList<CharSequence>());
|
||||
}
|
||||
|
||||
public BlocLines add2(CharSequence s) {
|
||||
final List<CharSequence> copy = new ArrayList<CharSequence>(lines);
|
||||
copy.add(s);
|
||||
return new BlocLines(copy);
|
||||
}
|
||||
|
||||
public List<CharSequence> getLines() {
|
||||
return lines;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return lines.size();
|
||||
}
|
||||
|
||||
public CharSequence get499(int i) {
|
||||
return lines.get(i);
|
||||
}
|
||||
|
||||
public CharSequence getFirst499() {
|
||||
return lines.get(0);
|
||||
}
|
||||
|
||||
public CharSequence getLast499() {
|
||||
return lines.get(lines.size() - 1);
|
||||
}
|
||||
|
||||
public BlocLines cleanList2(MultilinesStrategy strategy) {
|
||||
final List<CharSequence> copy = new ArrayList<CharSequence>(lines);
|
||||
strategy.cleanList(copy);
|
||||
return new BlocLines(copy);
|
||||
}
|
||||
|
||||
public BlocLines trim(boolean removeEmptyLines) {
|
||||
final List<CharSequence> copy = new ArrayList<CharSequence>(lines);
|
||||
for (int i = 0; i < copy.size(); i++) {
|
||||
final CharSequence s = copy.get(i);
|
||||
copy.set(i, StringUtils.trin(s));
|
||||
}
|
||||
if (removeEmptyLines) {
|
||||
for (final Iterator<CharSequence> it = copy.iterator(); it.hasNext();) {
|
||||
if (it.next().length() == 0) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
return new BlocLines(copy);
|
||||
}
|
||||
|
||||
public BlocLines removeEmptyColumns() {
|
||||
if (firstColumnRemovable(lines) == false) {
|
||||
return this;
|
||||
}
|
||||
final List<CharSequence> copy = new ArrayList<CharSequence>(lines);
|
||||
do {
|
||||
for (int i = 0; i < copy.size(); i++) {
|
||||
final CharSequence s = copy.get(i);
|
||||
if (s.length() > 0) {
|
||||
copy.set(i, s.subSequence(1, s.length()));
|
||||
}
|
||||
}
|
||||
} while (firstColumnRemovable(copy));
|
||||
return new BlocLines(copy);
|
||||
}
|
||||
|
||||
private static boolean firstColumnRemovable(List<CharSequence> data) {
|
||||
boolean allEmpty = true;
|
||||
for (CharSequence s : data) {
|
||||
if (s.length() == 0) {
|
||||
continue;
|
||||
}
|
||||
allEmpty = false;
|
||||
final char c = s.charAt(0);
|
||||
if (c != ' ' && c != '\t') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return allEmpty == false;
|
||||
}
|
||||
|
||||
public char getLastChar() {
|
||||
final CharSequence s = lines.get(lines.size() - 1);
|
||||
return s.charAt(s.length() - 1);
|
||||
}
|
||||
|
||||
public BlocLines removeStartingAndEnding2(String data) {
|
||||
if (lines.size() == 0) {
|
||||
return this;
|
||||
}
|
||||
final List<CharSequence> copy = new ArrayList<CharSequence>(lines);
|
||||
copy.set(0, data);
|
||||
final int n = copy.size() - 1;
|
||||
final CharSequence s = copy.get(n);
|
||||
copy.set(n, s.subSequence(0, s.length() - 1));
|
||||
return new BlocLines(copy);
|
||||
}
|
||||
|
||||
public BlocLines concat2() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (CharSequence line : lines) {
|
||||
sb.append(line);
|
||||
sb.append(StringUtils.hiddenNewLine());
|
||||
}
|
||||
return single(sb.substring(0, sb.length() - 1));
|
||||
}
|
||||
|
||||
public BlocLines trimSmart(int referenceLine) {
|
||||
if (lines.size() <= referenceLine) {
|
||||
return this;
|
||||
}
|
||||
final List<CharSequence> copy = new ArrayList<CharSequence>(lines);
|
||||
final int nbStartingSpace = nbStartingSpace(copy.get(referenceLine));
|
||||
for (int i = referenceLine; i < copy.size(); i++) {
|
||||
final CharSequence s = copy.get(i);
|
||||
copy.set(i, removeStartingSpaces(s, nbStartingSpace));
|
||||
}
|
||||
return new BlocLines(copy);
|
||||
}
|
||||
|
||||
private static int nbStartingSpace(CharSequence s) {
|
||||
int nb = 0;
|
||||
while (nb < s.length() && isSpaceOrTab(s.charAt(nb))) {
|
||||
nb++;
|
||||
}
|
||||
return nb;
|
||||
}
|
||||
|
||||
private static boolean isSpaceOrTab(char c) {
|
||||
return c == ' ' || c == '\t';
|
||||
}
|
||||
|
||||
private static CharSequence removeStartingSpaces(CharSequence arg, int nbStartingSpace) {
|
||||
if (arg.length() == 0) {
|
||||
return arg;
|
||||
}
|
||||
int i = 0;
|
||||
while (i < nbStartingSpace && i < arg.length() && isSpaceOrTab(arg.charAt(i))) {
|
||||
i++;
|
||||
}
|
||||
if (i == 0) {
|
||||
return arg;
|
||||
}
|
||||
return arg.subSequence(i, arg.length());
|
||||
}
|
||||
|
||||
public BlocLines subExtract(int start, int end) {
|
||||
List<CharSequence> copy = new ArrayList<CharSequence>(lines);
|
||||
copy = copy.subList(start, copy.size() - end);
|
||||
return new BlocLines(copy);
|
||||
}
|
||||
|
||||
public Iterator<CharSequence> iterator() {
|
||||
return lines.iterator();
|
||||
}
|
||||
|
||||
}
|
@ -28,20 +28,18 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 12235 $
|
||||
* Revision $Revision: 16381 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.core.Diagram;
|
||||
|
||||
public interface Command<D extends Diagram> {
|
||||
|
||||
CommandExecutionResult execute(D diagram, List<String> lines);
|
||||
CommandExecutionResult execute(D diagram, BlocLines lines);
|
||||
|
||||
CommandControl isValid(List<String> lines);
|
||||
CommandControl isValid(BlocLines lines);
|
||||
|
||||
String[] getDescription();
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class CommandAffineTransform extends SingleLineCommand<UmlDiagram> {
|
||||
|
||||
@Override
|
||||
protected CommandExecutionResult executeArg(UmlDiagram diagram, List<String> arg) {
|
||||
final String value = arg.get(0);
|
||||
final CharSequence value = arg.get(0);
|
||||
diagram.setAnimation(Collections.singletonList(value));
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
@ -33,8 +33,6 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.UmlDiagram;
|
||||
|
||||
public class CommandAffineTransformMultiline extends CommandMultilines<UmlDiagram> {
|
||||
@ -48,9 +46,9 @@ public class CommandAffineTransformMultiline extends CommandMultilines<UmlDiagra
|
||||
return "(?i)^[%s]*!\\}[%s]*$";
|
||||
}
|
||||
|
||||
public CommandExecutionResult execute(final UmlDiagram diagram, List<String> lines) {
|
||||
final List<String> data = lines.subList(1, lines.size() - 1);
|
||||
diagram.setAnimation(data);
|
||||
public CommandExecutionResult execute(final UmlDiagram diagram, BlocLines lines) {
|
||||
lines = lines.subExtract(1, 1);
|
||||
diagram.setAnimation(lines);
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
|
@ -33,10 +33,6 @@
|
||||
*/
|
||||
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> {
|
||||
@ -47,20 +43,19 @@ public class CommandDecoratorMultine<D extends Diagram> implements Command<D> {
|
||||
this.cmd = cmd;
|
||||
}
|
||||
|
||||
public CommandExecutionResult execute(D diagram, List<String> lines) {
|
||||
final String concat = concat(lines);
|
||||
return cmd.execute(diagram, Collections.singletonList(concat));
|
||||
public CommandExecutionResult execute(D diagram, BlocLines lines) {
|
||||
return cmd.execute(diagram, lines.concat2());
|
||||
}
|
||||
|
||||
public CommandControl isValid(List<String> lines) {
|
||||
public CommandControl isValid(BlocLines lines) {
|
||||
if (cmd.isCommandForbidden()) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
final String concat = concat(lines);
|
||||
if (cmd.isForbidden(concat)) {
|
||||
lines = lines.concat2();
|
||||
if (cmd.isForbidden(lines.getFirst499())) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
final CommandControl tmp = cmd.isValid(Collections.singletonList(concat));
|
||||
final CommandControl tmp = cmd.isValid(lines);
|
||||
if (tmp == CommandControl.OK_PARTIAL) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
@ -70,15 +65,6 @@ public class CommandDecoratorMultine<D extends Diagram> implements Command<D> {
|
||||
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();
|
||||
}
|
||||
|
@ -28,12 +28,11 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 16196 $
|
||||
* Revision $Revision: 16447 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -58,11 +57,11 @@ public abstract class CommandMultilines<S extends Diagram> implements Command<S>
|
||||
return new String[] { "START: " + starting.pattern(), "END: " + getPatternEnd() };
|
||||
}
|
||||
|
||||
final public CommandControl isValid(List<String> lines) {
|
||||
final public CommandControl isValid(BlocLines lines) {
|
||||
if (isCommandForbidden()) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
Matcher m1 = starting.matcher(StringUtils.trin(lines.get(0)));
|
||||
Matcher m1 = starting.matcher(StringUtils.trin(lines.getFirst499()));
|
||||
if (m1.matches() == false) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
@ -70,7 +69,7 @@ public abstract class CommandMultilines<S extends Diagram> implements Command<S>
|
||||
return CommandControl.OK_PARTIAL;
|
||||
}
|
||||
|
||||
m1 = MyPattern.cmpile(getPatternEnd()).matcher(StringUtils.trin(lines.get(lines.size() - 1)));
|
||||
m1 = MyPattern.cmpile(getPatternEnd()).matcher(StringUtils.trin(lines.getLast499()));
|
||||
if (m1.matches() == false) {
|
||||
return CommandControl.OK_PARTIAL;
|
||||
}
|
||||
|
@ -61,12 +61,12 @@ public abstract class CommandMultilines2<S extends Diagram> implements Command<S
|
||||
return new String[] { "START: " + starting.getPattern(), "END: " + getPatternEnd() };
|
||||
}
|
||||
|
||||
final public CommandControl isValid(List<String> lines) {
|
||||
lines = strategy.filter(lines);
|
||||
final public CommandControl isValid(BlocLines lines) {
|
||||
lines = lines.cleanList2(strategy);
|
||||
if (isCommandForbidden()) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
final boolean result1 = starting.match(StringUtils.trin(lines.get(0)));
|
||||
final boolean result1 = starting.match(StringUtils.trin(lines.getFirst499()));
|
||||
if (result1 == false) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
@ -74,7 +74,7 @@ public abstract class CommandMultilines2<S extends Diagram> implements Command<S
|
||||
return CommandControl.OK_PARTIAL;
|
||||
}
|
||||
|
||||
final Matcher m1 = MyPattern.cmpile(getPatternEnd()).matcher(StringUtils.trinNoTrace(lines.get(lines.size() - 1)));
|
||||
final Matcher m1 = MyPattern.cmpile(getPatternEnd()).matcher(StringUtils.trinNoTrace(lines.getLast499()));
|
||||
if (m1.matches() == false) {
|
||||
return CommandControl.OK_PARTIAL;
|
||||
}
|
||||
@ -83,11 +83,12 @@ public abstract class CommandMultilines2<S extends Diagram> implements Command<S
|
||||
return CommandControl.OK;
|
||||
}
|
||||
|
||||
public final CommandExecutionResult execute(S system, List<String> lines) {
|
||||
return executeNow(system, strategy.filter(lines));
|
||||
public final CommandExecutionResult execute(S system, BlocLines lines) {
|
||||
lines = lines.cleanList2(strategy);
|
||||
return executeNow(system, lines);
|
||||
}
|
||||
|
||||
public abstract CommandExecutionResult executeNow(S system, List<String> lines);
|
||||
public abstract CommandExecutionResult executeNow(S system, BlocLines lines);
|
||||
|
||||
protected boolean isCommandForbidden() {
|
||||
return false;
|
||||
|
@ -33,8 +33,6 @@
|
||||
*/
|
||||
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;
|
||||
@ -59,12 +57,12 @@ public abstract class CommandMultilines3<S extends Diagram> implements Command<S
|
||||
return new String[] { "START: " + starting.getPattern(), "END: " + getPatternEnd2().getPattern() };
|
||||
}
|
||||
|
||||
final public CommandControl isValid(List<String> lines) {
|
||||
lines = strategy.filter(lines);
|
||||
final public CommandControl isValid(BlocLines lines) {
|
||||
lines = lines.cleanList2(strategy);
|
||||
if (isCommandForbidden()) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
final boolean result1 = starting.match(StringUtils.trin(lines.get(0)));
|
||||
final boolean result1 = starting.match(StringUtils.trin(lines.getFirst499()));
|
||||
if (result1 == false) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
@ -72,7 +70,7 @@ public abstract class CommandMultilines3<S extends Diagram> implements Command<S
|
||||
return CommandControl.OK_PARTIAL;
|
||||
}
|
||||
|
||||
final String potentialLast = StringUtils.trinNoTrace(lines.get(lines.size() - 1));
|
||||
final String potentialLast = StringUtils.trinNoTrace(lines.getLast499());
|
||||
final boolean m1 = getPatternEnd2().match(potentialLast);
|
||||
if (m1 == false) {
|
||||
return CommandControl.OK_PARTIAL;
|
||||
@ -82,11 +80,12 @@ public abstract class CommandMultilines3<S extends Diagram> implements Command<S
|
||||
return CommandControl.OK;
|
||||
}
|
||||
|
||||
public final CommandExecutionResult execute(S system, List<String> lines) {
|
||||
return executeNow(system, strategy.filter(lines));
|
||||
public final CommandExecutionResult execute(S system, BlocLines lines) {
|
||||
lines = lines.cleanList2(strategy);
|
||||
return executeNow(system, lines);
|
||||
}
|
||||
|
||||
public abstract CommandExecutionResult executeNow(S system, List<String> lines);
|
||||
public abstract CommandExecutionResult executeNow(S system, BlocLines lines);
|
||||
|
||||
protected boolean isCommandForbidden() {
|
||||
return false;
|
||||
|
@ -33,7 +33,6 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -67,11 +66,11 @@ public abstract class CommandMultilinesBracket<S extends Diagram> implements Com
|
||||
return starting;
|
||||
}
|
||||
|
||||
final public CommandControl isValid(List<String> lines) {
|
||||
final public CommandControl isValid(BlocLines lines) {
|
||||
if (isCommandForbidden()) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
final Matcher m1 = starting.matcher(StringUtils.trin(lines.get(0)));
|
||||
final Matcher m1 = starting.matcher(StringUtils.trin(lines.getFirst499()));
|
||||
if (m1.matches() == false) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
@ -80,8 +79,8 @@ public abstract class CommandMultilinesBracket<S extends Diagram> implements Com
|
||||
}
|
||||
|
||||
int level = 1;
|
||||
for (int i = 1; i < lines.size(); i++) {
|
||||
final String s = StringUtils.trin(lines.get(i));
|
||||
for (CharSequence cs : lines.subExtract(1, 0)) {
|
||||
final String s = StringUtils.trin(cs);
|
||||
if (isLineConsistent(s, level) == false) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
|
@ -33,8 +33,6 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.core.Diagram;
|
||||
|
||||
public class CommandMultilinesComment extends CommandMultilines<Diagram> {
|
||||
@ -48,7 +46,7 @@ public class CommandMultilinesComment extends CommandMultilines<Diagram> {
|
||||
return "(?i)^.*[%q]/[%s]*$";
|
||||
}
|
||||
|
||||
public CommandExecutionResult execute(final Diagram diagram, List<String> lines) {
|
||||
public CommandExecutionResult execute(final Diagram diagram, BlocLines lines) {
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
||||
|
@ -28,18 +28,17 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 16195 $
|
||||
* Revision $Revision: 16447 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.UmlDiagram;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class CommandMultilinesFooter extends CommandMultilines<UmlDiagram> {
|
||||
|
||||
@ -52,9 +51,9 @@ public class CommandMultilinesFooter extends CommandMultilines<UmlDiagram> {
|
||||
return "(?i)^end[%s]?footer$";
|
||||
}
|
||||
|
||||
public CommandExecutionResult execute(final UmlDiagram diagram, List<String> lines) {
|
||||
StringUtils.trim(lines, false);
|
||||
final Matcher m = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
public CommandExecutionResult execute(final UmlDiagram diagram, BlocLines lines) {
|
||||
lines = lines.trim(false);
|
||||
final Matcher m = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
if (m.find() == false) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
@ -62,7 +61,8 @@ public class CommandMultilinesFooter extends CommandMultilines<UmlDiagram> {
|
||||
if (align != null) {
|
||||
diagram.setFooterAlignment(HorizontalAlignment.valueOf(StringUtils.goUpperCase(align)));
|
||||
}
|
||||
final Display strings = Display.create(lines.subList(1, lines.size() - 1));
|
||||
lines = lines.subExtract(1, 1);
|
||||
final Display strings = lines.toDisplay();
|
||||
if (strings.size() > 0) {
|
||||
diagram.setFooter(strings);
|
||||
return CommandExecutionResult.ok();
|
||||
|
@ -28,18 +28,17 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 16195 $
|
||||
* Revision $Revision: 16447 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.UmlDiagram;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class CommandMultilinesHeader extends CommandMultilines<UmlDiagram> {
|
||||
|
||||
@ -53,9 +52,9 @@ public class CommandMultilinesHeader extends CommandMultilines<UmlDiagram> {
|
||||
}
|
||||
|
||||
|
||||
public CommandExecutionResult execute(final UmlDiagram diagram, List<String> lines) {
|
||||
StringUtils.trim(lines, false);
|
||||
final Matcher m = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
public CommandExecutionResult execute(final UmlDiagram diagram, BlocLines lines) {
|
||||
lines = lines.trim(false);
|
||||
final Matcher m = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
if (m.find() == false) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
@ -63,7 +62,8 @@ public class CommandMultilinesHeader extends CommandMultilines<UmlDiagram> {
|
||||
if (align != null) {
|
||||
diagram.setHeaderAlignment(HorizontalAlignment.valueOf(StringUtils.goUpperCase(align)));
|
||||
}
|
||||
final Display strings = Display.create(lines.subList(1, lines.size() - 1));
|
||||
lines = lines.subExtract(1, 1);
|
||||
final Display strings = lines.toDisplay();
|
||||
if (strings.size() > 0) {
|
||||
diagram.setHeader(strings);
|
||||
return CommandExecutionResult.ok();
|
||||
|
@ -33,8 +33,6 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.UmlDiagram;
|
||||
import net.sourceforge.plantuml.command.regex.RegexConcat;
|
||||
@ -64,12 +62,14 @@ public class CommandMultilinesLegend extends CommandMultilines2<UmlDiagram> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandExecutionResult executeNow(UmlDiagram diagram, List<String> lines) {
|
||||
StringUtils.trimSmart(lines, 1);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
public CommandExecutionResult executeNow(UmlDiagram diagram, BlocLines lines) {
|
||||
lines = lines.trimSmart(1);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
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();
|
||||
lines = lines.subExtract(1, 1);
|
||||
lines = lines.removeEmptyColumns();
|
||||
final Display strings = lines.toDisplay();
|
||||
if (strings.size() > 0) {
|
||||
final VerticalAlignment valignment = VerticalAlignment.fromString(valign);
|
||||
HorizontalAlignment alignment = HorizontalAlignment.fromString(align);
|
||||
|
@ -28,16 +28,13 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 14321 $
|
||||
* Revision $Revision: 16435 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.UmlDiagram;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class CommandMultilinesTitle extends CommandMultilines<UmlDiagram> {
|
||||
|
||||
@ -50,8 +47,10 @@ public class CommandMultilinesTitle extends CommandMultilines<UmlDiagram> {
|
||||
return "(?i)^end[%s]?title$";
|
||||
}
|
||||
|
||||
public CommandExecutionResult execute(final UmlDiagram diagram, List<String> lines) {
|
||||
final Display strings = Display.create(lines.subList(1, lines.size() - 1)).removeEmptyColumns();
|
||||
public CommandExecutionResult execute(final UmlDiagram diagram, BlocLines lines) {
|
||||
lines = lines.subExtract(1, 1);
|
||||
lines = lines.removeEmptyColumns();
|
||||
final Display strings = lines.toDisplay();
|
||||
if (strings.size() > 0) {
|
||||
diagram.setTitle(strings);
|
||||
return CommandExecutionResult.ok();
|
||||
|
@ -47,6 +47,7 @@ import net.sourceforge.plantuml.cucadiagram.IEntity;
|
||||
import net.sourceforge.plantuml.cucadiagram.IGroup;
|
||||
import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.graphic.USymbol;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.utils.UniqueSequence;
|
||||
|
||||
@ -91,7 +92,12 @@ public class CommandPackage extends SingleLineCommand2<AbstractEntityDiagram> {
|
||||
currentPackage);
|
||||
final String stereotype = arg.get("STEREOTYPE", 0);
|
||||
if (stereotype != null) {
|
||||
p.setStereotype(new Stereotype(stereotype));
|
||||
final USymbol usymbol = USymbol.getFromString(stereotype);
|
||||
if (usymbol == null) {
|
||||
p.setStereotype(new Stereotype(stereotype));
|
||||
} else {
|
||||
p.setUSymbol(usymbol);
|
||||
}
|
||||
}
|
||||
|
||||
final String urlString = arg.get("URL", 0);
|
||||
|
@ -38,9 +38,9 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.UmlDiagram;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class CommandSkinParamMultilines extends CommandMultilinesBracket<UmlDiagram> {
|
||||
|
||||
@ -80,13 +80,13 @@ public class CommandSkinParamMultilines extends CommandMultilinesBracket<UmlDiag
|
||||
return p1.matcher(line).matches();
|
||||
}
|
||||
|
||||
private boolean hasStartingQuote(String line) {
|
||||
private boolean hasStartingQuote(CharSequence line) {
|
||||
return MyPattern.mtches(line, "[%s]*[%q].*");
|
||||
}
|
||||
|
||||
public CommandExecutionResult execute(UmlDiagram diagram, List<String> lines) {
|
||||
public CommandExecutionResult execute(UmlDiagram diagram, BlocLines lines) {
|
||||
final Context context = new Context();
|
||||
final Matcher mStart = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
final Matcher mStart = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
if (mStart.find() == false) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
@ -94,15 +94,15 @@ public class CommandSkinParamMultilines extends CommandMultilinesBracket<UmlDiag
|
||||
context.push(mStart.group(1));
|
||||
}
|
||||
|
||||
lines = new ArrayList<String>(lines.subList(1, lines.size() - 1));
|
||||
StringUtils.trim(lines, true);
|
||||
lines = lines.subExtract(1, 1);
|
||||
lines = lines.trim(true);
|
||||
|
||||
for (String s : lines) {
|
||||
for (CharSequence s : lines) {
|
||||
assert s.length() > 0;
|
||||
if (hasStartingQuote(s)) {
|
||||
continue;
|
||||
}
|
||||
if (s.equals("}")) {
|
||||
if (s.toString().equals("}")) {
|
||||
context.pop();
|
||||
continue;
|
||||
}
|
||||
@ -116,7 +116,7 @@ public class CommandSkinParamMultilines extends CommandMultilinesBracket<UmlDiag
|
||||
final String key = context.getFullParam() + m.group(1);
|
||||
diagram.setParam(key, m.group(3));
|
||||
} else {
|
||||
throw new IllegalStateException();
|
||||
throw new IllegalStateException("." + s.toString() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -37,6 +37,7 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.UmlDiagram;
|
||||
import net.sourceforge.plantuml.command.note.SingleMultiFactoryCommand;
|
||||
import net.sourceforge.plantuml.command.regex.RegexConcat;
|
||||
@ -44,7 +45,6 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
||||
import net.sourceforge.plantuml.command.regex.RegexResult;
|
||||
import net.sourceforge.plantuml.ugraphic.Sprite;
|
||||
import net.sourceforge.plantuml.ugraphic.SpriteGrayLevel;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public final class FactorySpriteCommand implements SingleMultiFactoryCommand<UmlDiagram> {
|
||||
|
||||
@ -72,7 +72,7 @@ public final class FactorySpriteCommand implements SingleMultiFactoryCommand<Uml
|
||||
|
||||
@Override
|
||||
protected CommandExecutionResult executeArg(final UmlDiagram system, RegexResult arg) {
|
||||
return executeInternal(system, arg, Arrays.asList(arg.get("DATA", 0)));
|
||||
return executeInternal(system, arg, Arrays.asList((CharSequence) arg.get("DATA", 0)));
|
||||
}
|
||||
|
||||
};
|
||||
@ -86,22 +86,23 @@ public final class FactorySpriteCommand implements SingleMultiFactoryCommand<Uml
|
||||
return "(?i)^end[%s]?sprite|\\}$";
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(final UmlDiagram system, List<String> lines) {
|
||||
StringUtils.trim(lines, true);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
public CommandExecutionResult executeNow(final UmlDiagram system, BlocLines lines) {
|
||||
lines = lines.trim(true);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
|
||||
final List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
|
||||
if (strings.size() == 0) {
|
||||
lines = lines.subExtract(1, 1);
|
||||
lines = lines.removeEmptyColumns();
|
||||
if (lines.size() == 0) {
|
||||
return CommandExecutionResult.error("No sprite defined.");
|
||||
}
|
||||
return executeInternal(system, line0, strings);
|
||||
return executeInternal(system, line0, lines.getLines());
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
private CommandExecutionResult executeInternal(UmlDiagram system, RegexResult line0,
|
||||
final List<String> strings) {
|
||||
final List<CharSequence> strings) {
|
||||
try {
|
||||
final Sprite sprite;
|
||||
if (line0.get("DIM", 0) == null) {
|
||||
@ -127,9 +128,9 @@ public final class FactorySpriteCommand implements SingleMultiFactoryCommand<Uml
|
||||
}
|
||||
}
|
||||
|
||||
private String concat(final List<String> strings) {
|
||||
private String concat(final List<? extends CharSequence> strings) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (String s : strings) {
|
||||
for (CharSequence s : strings) {
|
||||
sb.append(StringUtils.trin(s));
|
||||
}
|
||||
return sb.toString();
|
||||
|
@ -41,23 +41,22 @@ import net.sourceforge.plantuml.StringUtils;
|
||||
public enum MultilinesStrategy {
|
||||
REMOVE_STARTING_QUOTE, KEEP_STARTING_QUOTE;
|
||||
|
||||
public List<String> filter(List<String> lines) {
|
||||
public void cleanList(List<? extends CharSequence> lines) {
|
||||
if (this == REMOVE_STARTING_QUOTE) {
|
||||
filterQuote(lines);
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
private void filterQuote(List<String> lines) {
|
||||
for (final Iterator<String> it = lines.iterator(); it.hasNext();) {
|
||||
final String s = it.next();
|
||||
private void filterQuote(List<? extends CharSequence> lines) {
|
||||
for (final Iterator<? extends CharSequence> it = lines.iterator(); it.hasNext();) {
|
||||
final CharSequence s = it.next();
|
||||
if (hasStartingQuote(s)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasStartingQuote(String s) {
|
||||
private boolean hasStartingQuote(CharSequence s) {
|
||||
return StringUtils.trinNoTrace(s).startsWith("\'");
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ package net.sourceforge.plantuml.command;
|
||||
import net.sourceforge.plantuml.AbstractPSystem;
|
||||
import net.sourceforge.plantuml.ErrorUml;
|
||||
import net.sourceforge.plantuml.ErrorUmlType;
|
||||
import net.sourceforge.plantuml.LineLocation;
|
||||
import net.sourceforge.plantuml.PSystemError;
|
||||
import net.sourceforge.plantuml.api.PSystemFactory;
|
||||
import net.sourceforge.plantuml.core.DiagramType;
|
||||
@ -49,15 +50,15 @@ public abstract class PSystemAbstractFactory implements PSystemFactory {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
final protected AbstractPSystem buildEmptyError(UmlSource source) {
|
||||
final protected AbstractPSystem buildEmptyError(UmlSource source, LineLocation lineLocation) {
|
||||
final PSystemError result = new PSystemError(source, new ErrorUml(ErrorUmlType.SYNTAX_ERROR,
|
||||
"Empty description", 1), null);
|
||||
"Empty description", 1, lineLocation), 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), null);
|
||||
final protected PSystemError buildEmptyError(UmlSource source, String err, LineLocation lineLocation) {
|
||||
final PSystemError result = new PSystemError(source, new ErrorUml(ErrorUmlType.EXECUTION_ERROR, err, 1, lineLocation), null);
|
||||
result.setSource(source);
|
||||
return result;
|
||||
}
|
||||
|
@ -34,6 +34,7 @@
|
||||
package net.sourceforge.plantuml.command;
|
||||
|
||||
import net.sourceforge.plantuml.AbstractPSystem;
|
||||
import net.sourceforge.plantuml.CharSequence2;
|
||||
import net.sourceforge.plantuml.ErrorUml;
|
||||
import net.sourceforge.plantuml.ErrorUmlType;
|
||||
import net.sourceforge.plantuml.PSystemError;
|
||||
@ -41,7 +42,7 @@ import net.sourceforge.plantuml.core.Diagram;
|
||||
import net.sourceforge.plantuml.core.DiagramType;
|
||||
import net.sourceforge.plantuml.core.UmlSource;
|
||||
import net.sourceforge.plantuml.utils.StartUtils;
|
||||
import net.sourceforge.plantuml.version.IteratorCounter;
|
||||
import net.sourceforge.plantuml.version.IteratorCounter2;
|
||||
|
||||
public abstract class PSystemBasicFactory<P extends AbstractPSystem> extends PSystemAbstractFactory {
|
||||
|
||||
@ -61,24 +62,24 @@ public abstract class PSystemBasicFactory<P extends AbstractPSystem> extends PSy
|
||||
|
||||
|
||||
final public Diagram createSystem(UmlSource source) {
|
||||
final IteratorCounter it = source.iterator();
|
||||
final String startLine = it.next();
|
||||
P system = init(startLine);
|
||||
final IteratorCounter2 it = source.iterator2();
|
||||
final CharSequence2 startLine = it.next();
|
||||
P system = init(startLine.toString2());
|
||||
while (it.hasNext()) {
|
||||
final String s = it.next();
|
||||
final CharSequence2 s = it.next();
|
||||
if (StartUtils.isArobaseEndDiagram(s)) {
|
||||
if (source.getTotalLineCount() == 2) {
|
||||
return buildEmptyError(source);
|
||||
return buildEmptyError(source, s.getLocation());
|
||||
}
|
||||
if (system != null) {
|
||||
system.setSource(source);
|
||||
}
|
||||
return system;
|
||||
}
|
||||
system = executeLine(system, s);
|
||||
system = executeLine(system, s.toString2());
|
||||
if (system == null) {
|
||||
return new PSystemError(source, new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?",
|
||||
it.currentNum() - 1), null);
|
||||
it.currentNum() - 1, s.getLocation()), null);
|
||||
}
|
||||
}
|
||||
if (system != null) {
|
||||
|
@ -34,6 +34,7 @@
|
||||
package net.sourceforge.plantuml.command;
|
||||
|
||||
import net.sourceforge.plantuml.AbstractPSystem;
|
||||
import net.sourceforge.plantuml.CharSequence2;
|
||||
import net.sourceforge.plantuml.ErrorUml;
|
||||
import net.sourceforge.plantuml.ErrorUmlType;
|
||||
import net.sourceforge.plantuml.PSystemError;
|
||||
@ -41,7 +42,7 @@ import net.sourceforge.plantuml.core.Diagram;
|
||||
import net.sourceforge.plantuml.core.DiagramType;
|
||||
import net.sourceforge.plantuml.core.UmlSource;
|
||||
import net.sourceforge.plantuml.utils.StartUtils;
|
||||
import net.sourceforge.plantuml.version.IteratorCounter;
|
||||
import net.sourceforge.plantuml.version.IteratorCounter2;
|
||||
|
||||
public abstract class PSystemSingleLineFactory extends PSystemAbstractFactory {
|
||||
|
||||
@ -53,27 +54,27 @@ public abstract class PSystemSingleLineFactory extends PSystemAbstractFactory {
|
||||
|
||||
final public Diagram createSystem(UmlSource source) {
|
||||
|
||||
final IteratorCounter2 it = source.iterator2();
|
||||
if (source.isEmpty()) {
|
||||
return buildEmptyError(source);
|
||||
return buildEmptyError(source, it.peek().getLocation());
|
||||
}
|
||||
|
||||
final IteratorCounter it = source.iterator();
|
||||
final String startLine = it.next();
|
||||
final CharSequence2 startLine = it.next();
|
||||
if (StartUtils.isArobaseStartDiagram(startLine) == false) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
if (it.hasNext() == false) {
|
||||
return buildEmptyError(source);
|
||||
return buildEmptyError(source, startLine.getLocation());
|
||||
}
|
||||
final String s = it.next();
|
||||
final CharSequence2 s = it.next();
|
||||
if (StartUtils.isArobaseEndDiagram(s)) {
|
||||
return buildEmptyError(source);
|
||||
return buildEmptyError(source, s.getLocation());
|
||||
}
|
||||
final AbstractPSystem sys = executeLine(s);
|
||||
final AbstractPSystem sys = executeLine(s.toString2());
|
||||
if (sys == null) {
|
||||
return new PSystemError(source, new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?",
|
||||
it.currentNum() - 1), null);
|
||||
it.currentNum() - 1, s.getLocation()), null);
|
||||
}
|
||||
sys.setSource(source);
|
||||
return sys;
|
||||
|
@ -33,8 +33,6 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.Log;
|
||||
import net.sourceforge.plantuml.core.Diagram;
|
||||
import net.sourceforge.plantuml.version.Version;
|
||||
@ -47,7 +45,7 @@ public class ProtectedCommand<S extends Diagram> implements Command<S> {
|
||||
this.cmd = cmd;
|
||||
}
|
||||
|
||||
public CommandExecutionResult execute(S system, List<String> lines) {
|
||||
public CommandExecutionResult execute(S system, BlocLines lines) {
|
||||
try {
|
||||
final CommandExecutionResult result = cmd.execute(system, lines);
|
||||
// if (result.isOk()) {
|
||||
@ -65,7 +63,7 @@ public class ProtectedCommand<S extends Diagram> implements Command<S> {
|
||||
}
|
||||
}
|
||||
|
||||
public CommandControl isValid(List<String> lines) {
|
||||
public CommandControl isValid(BlocLines lines) {
|
||||
return cmd.isValid(lines);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 16195 $
|
||||
* Revision $Revision: 16447 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.command;
|
||||
@ -37,9 +37,9 @@ 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;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public abstract class SingleLineCommand<S extends Diagram> implements Command<S> {
|
||||
|
||||
@ -60,14 +60,14 @@ public abstract class SingleLineCommand<S extends Diagram> implements Command<S>
|
||||
return new String[] { pattern.pattern() };
|
||||
}
|
||||
|
||||
final public CommandControl isValid(List<String> lines) {
|
||||
final public CommandControl isValid(BlocLines lines) {
|
||||
if (lines.size() != 1) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
if (isCommandForbidden()) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
final String line = StringUtils.trin(lines.get(0));
|
||||
final String line = StringUtils.trin(lines.getFirst499());
|
||||
final Matcher m = pattern.matcher(line);
|
||||
final boolean result = m.find();
|
||||
if (result) {
|
||||
@ -83,11 +83,11 @@ public abstract class SingleLineCommand<S extends Diagram> implements Command<S>
|
||||
protected void actionIfCommandValid() {
|
||||
}
|
||||
|
||||
public final CommandExecutionResult execute(S system, List<String> lines) {
|
||||
public final CommandExecutionResult execute(S system, BlocLines lines) {
|
||||
if (lines.size() != 1) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
final String line = StringUtils.trin(lines.get(0));
|
||||
final String line = StringUtils.trin(lines.getFirst499());
|
||||
if (isForbidden(line)) {
|
||||
return CommandExecutionResult.error("Forbidden line " + line);
|
||||
}
|
||||
|
@ -33,8 +33,6 @@
|
||||
*/
|
||||
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;
|
||||
@ -60,14 +58,14 @@ public abstract class SingleLineCommand2<S extends Diagram> implements Command<S
|
||||
return new String[] { pattern.getPattern() };
|
||||
}
|
||||
|
||||
final public CommandControl isValid(List<String> lines) {
|
||||
final public CommandControl isValid(BlocLines lines) {
|
||||
if (lines.size() != 1) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
if (isCommandForbidden()) {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
final String line = StringUtils.trin(lines.get(0));
|
||||
final String line = StringUtils.trin(lines.getFirst499());
|
||||
final boolean result = pattern.match(line);
|
||||
if (result) {
|
||||
actionIfCommandValid();
|
||||
@ -82,11 +80,11 @@ public abstract class SingleLineCommand2<S extends Diagram> implements Command<S
|
||||
protected void actionIfCommandValid() {
|
||||
}
|
||||
|
||||
public final CommandExecutionResult execute(S system, List<String> lines) {
|
||||
public final CommandExecutionResult execute(S system, BlocLines lines) {
|
||||
if (lines.size() != 1) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
final String line = StringUtils.trin(lines.get(0));
|
||||
final String line = StringUtils.trin(lines.getFirst499());
|
||||
if (isForbidden(line)) {
|
||||
return CommandExecutionResult.error("Forbidden line " + line);
|
||||
}
|
||||
@ -103,7 +101,7 @@ public abstract class SingleLineCommand2<S extends Diagram> implements Command<S
|
||||
return executeArg(system, arg);
|
||||
}
|
||||
|
||||
protected boolean isForbidden(String line) {
|
||||
protected boolean isForbidden(CharSequence line) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.AbstractPSystem;
|
||||
import net.sourceforge.plantuml.CharSequence2;
|
||||
import net.sourceforge.plantuml.ErrorUml;
|
||||
import net.sourceforge.plantuml.ErrorUmlType;
|
||||
import net.sourceforge.plantuml.OptionFlags;
|
||||
@ -53,7 +54,7 @@ import net.sourceforge.plantuml.suggest.SuggestEngine;
|
||||
import net.sourceforge.plantuml.suggest.SuggestEngineResult;
|
||||
import net.sourceforge.plantuml.suggest.SuggestEngineStatus;
|
||||
import net.sourceforge.plantuml.utils.StartUtils;
|
||||
import net.sourceforge.plantuml.version.IteratorCounter;
|
||||
import net.sourceforge.plantuml.version.IteratorCounter2;
|
||||
|
||||
public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
|
||||
@ -69,14 +70,14 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
}
|
||||
|
||||
final public Diagram createSystem(UmlSource source) {
|
||||
final IteratorCounter it = source.iterator();
|
||||
final String startLine = it.next();
|
||||
final IteratorCounter2 it = source.iterator2();
|
||||
final CharSequence2 startLine = it.next();
|
||||
if (StartUtils.isArobaseStartDiagram(startLine) == false) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
if (source.isEmpty()) {
|
||||
return buildEmptyError(source);
|
||||
return buildEmptyError(source, startLine.getLocation());
|
||||
}
|
||||
AbstractPSystem sys = createEmptyDiagram();
|
||||
|
||||
@ -84,10 +85,10 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
if (StartUtils.isArobaseEndDiagram(it.peek())) {
|
||||
final String err = checkFinalError(sys);
|
||||
if (err != null) {
|
||||
return buildEmptyError(source, err);
|
||||
return buildEmptyError(source, err, it.peek().getLocation());
|
||||
}
|
||||
if (source.getTotalLineCount() == 2) {
|
||||
return buildEmptyError(source);
|
||||
return buildEmptyError(source, it.peek().getLocation());
|
||||
}
|
||||
if (sys == null) {
|
||||
return null;
|
||||
@ -109,10 +110,11 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
|
||||
}
|
||||
|
||||
private AbstractPSystem executeOneLine(AbstractPSystem sys, UmlSource source, final IteratorCounter it) {
|
||||
private AbstractPSystem executeOneLine(AbstractPSystem sys, UmlSource source, final IteratorCounter2 it) {
|
||||
final CommandControl commandControl = isValid2(it);
|
||||
if (commandControl == CommandControl.NOT_OK) {
|
||||
final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?", it.currentNum());
|
||||
final ErrorUml err = new ErrorUml(ErrorUmlType.SYNTAX_ERROR, "Syntax Error?", it.currentNum(), it.peek()
|
||||
.getLocation());
|
||||
if (OptionFlags.getInstance().isUseSuggestEngine()) {
|
||||
final SuggestEngine engine = new SuggestEngine(source, this);
|
||||
final SuggestEngineResult result = engine.tryToSuggest(sys);
|
||||
@ -122,19 +124,21 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
}
|
||||
sys = new PSystemError(source, err, null);
|
||||
} else if (commandControl == CommandControl.OK_PARTIAL) {
|
||||
final IteratorCounter2 saved = it.cloneMe();
|
||||
final boolean ok = manageMultiline(it, sys);
|
||||
if (ok == false) {
|
||||
sys = new PSystemError(source, new ErrorUml(ErrorUmlType.EXECUTION_ERROR, "Strange Syntax Error?",
|
||||
it.currentNum() - 1), null);
|
||||
it.currentNum() - 1, saved.next().getLocation()), null);
|
||||
|
||||
}
|
||||
} else if (commandControl == CommandControl.OK) {
|
||||
final String line = it.next();
|
||||
Command cmd = getFirstCommandOkForLines(Arrays.asList(line));
|
||||
final CommandExecutionResult result = sys.executeCommand(cmd, Arrays.asList(line));
|
||||
final CharSequence line = it.next();
|
||||
final BlocLines lines = BlocLines.single(line);
|
||||
Command cmd = getFirstCommandOkForLines(lines);
|
||||
final CommandExecutionResult result = sys.executeCommand(cmd, lines);
|
||||
if (result.isOk() == false) {
|
||||
sys = new PSystemError(source, new ErrorUml(ErrorUmlType.EXECUTION_ERROR, result.getError(),
|
||||
it.currentNum() - 1), result.getDebugLines());
|
||||
it.currentNum() - 1, ((CharSequence2) line).getLocation()), result.getDebugLines());
|
||||
}
|
||||
if (result.getNewDiagram() != null) {
|
||||
sys = result.getNewDiagram();
|
||||
@ -145,10 +149,10 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
return sys;
|
||||
}
|
||||
|
||||
public CommandControl isValid2(final IteratorCounter it) {
|
||||
final List<String> asList = Arrays.asList(it.peek());
|
||||
public CommandControl isValid2(final IteratorCounter2 it) {
|
||||
final BlocLines lines = BlocLines.single(it.peek());
|
||||
for (Command cmd : cmds) {
|
||||
final CommandControl result = cmd.isValid(asList);
|
||||
final CommandControl result = cmd.isValid(lines);
|
||||
if (result == CommandControl.OK) {
|
||||
return result;
|
||||
}
|
||||
@ -159,10 +163,10 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
return CommandControl.NOT_OK;
|
||||
}
|
||||
|
||||
public CommandControl goForwardMultiline(final IteratorCounter it) {
|
||||
final List<String> asList = Arrays.asList(it.peek());
|
||||
public CommandControl goForwardMultiline(final IteratorCounter2 it) {
|
||||
final BlocLines lines = BlocLines.single(it.peek());
|
||||
for (Command cmd : cmds) {
|
||||
final CommandControl result = cmd.isValid(asList);
|
||||
final CommandControl result = cmd.isValid(lines);
|
||||
if (result == CommandControl.OK) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
@ -173,20 +177,20 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
private boolean manageMultiline(IteratorCounter it, AbstractPSystem system) {
|
||||
private boolean manageMultiline(IteratorCounter2 it, AbstractPSystem system) {
|
||||
for (Command cmd : cmds) {
|
||||
if (isMultilineCommandOk(it.cloneMe(), cmd) != null) {
|
||||
final List<String> lines = isMultilineCommandOk(it, cmd);
|
||||
final BlocLines lines = isMultilineCommandOk(it, cmd);
|
||||
return cmd.execute(system, lines).isOk();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private List<String> isMultilineCommandOk(IteratorCounter it, Command cmd) {
|
||||
final List<String> lines = new ArrayList<String>();
|
||||
private BlocLines isMultilineCommandOk(IteratorCounter2 it, Command cmd) {
|
||||
BlocLines lines = new BlocLines();
|
||||
while (it.hasNext()) {
|
||||
addOneSingleLineManageEmbedded(it, lines);
|
||||
lines = addOneSingleLineManageEmbedded2(it, lines);
|
||||
final CommandControl result = cmd.isValid(lines);
|
||||
if (result == CommandControl.NOT_OK) {
|
||||
return null;
|
||||
@ -198,18 +202,19 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addOneSingleLineManageEmbedded(IteratorCounter it, final List<String> lines) {
|
||||
final String linetoBeAdded = it.next();
|
||||
lines.add(linetoBeAdded);
|
||||
private BlocLines addOneSingleLineManageEmbedded2(IteratorCounter2 it, BlocLines lines) {
|
||||
final CharSequence linetoBeAdded = it.next();
|
||||
lines = lines.add2(linetoBeAdded);
|
||||
if (StringUtils.trinNoTrace(linetoBeAdded).equals("{{")) {
|
||||
while (it.hasNext()) {
|
||||
final String s = it.next();
|
||||
lines.add(s);
|
||||
final CharSequence s = it.next();
|
||||
lines = lines.add2(s);
|
||||
if (StringUtils.trinNoTrace(s).equals("}}")) {
|
||||
return;
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
// -----------------------------------
|
||||
@ -217,9 +222,8 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
public String checkFinalError(AbstractPSystem system) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
final public CommandControl isValid(List<String> lines) {
|
||||
final public CommandControl isValid(BlocLines lines) {
|
||||
for (Command cmd : cmds) {
|
||||
final CommandControl result = cmd.isValid(lines);
|
||||
if (result == CommandControl.OK) {
|
||||
@ -233,7 +237,7 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
|
||||
|
||||
}
|
||||
|
||||
private Command getFirstCommandOkForLines(List<String> lines) {
|
||||
private Command getFirstCommandOkForLines(BlocLines lines) {
|
||||
for (Command cmd : cmds) {
|
||||
final CommandControl result = cmd.isValid(lines);
|
||||
if (result == CommandControl.OK) {
|
||||
|
@ -33,12 +33,12 @@
|
||||
*/
|
||||
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.activitydiagram.ActivityDiagram;
|
||||
import net.sourceforge.plantuml.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.Command;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||
@ -55,7 +55,6 @@ import net.sourceforge.plantuml.cucadiagram.Link;
|
||||
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
|
||||
import net.sourceforge.plantuml.cucadiagram.LinkType;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.utils.UniqueSequence;
|
||||
|
||||
public final class FactoryNoteActivityCommand implements SingleMultiFactoryCommand<ActivityDiagram> {
|
||||
@ -86,10 +85,13 @@ public final class FactoryNoteActivityCommand implements SingleMultiFactoryComma
|
||||
return "(?i)^end[%s]?note$";
|
||||
}
|
||||
|
||||
public final CommandExecutionResult executeNow(final ActivityDiagram system, List<String> lines) {
|
||||
public final CommandExecutionResult executeNow(final ActivityDiagram system, BlocLines lines) {
|
||||
// StringUtils.trim(lines, true);
|
||||
final RegexResult arg = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
Display strings = Display.create(StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1)));
|
||||
final RegexResult arg = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
lines = lines.subExtract(1, 1);
|
||||
lines = lines.removeEmptyColumns();
|
||||
|
||||
Display strings = lines.toDisplay();
|
||||
|
||||
Url url = null;
|
||||
if (strings.size() > 0) {
|
||||
|
@ -35,7 +35,9 @@ package net.sourceforge.plantuml.command.note;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.classdiagram.AbstractEntityDiagram;
|
||||
import net.sourceforge.plantuml.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.Command;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||
@ -48,9 +50,7 @@ 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.graphic.HtmlColorSet;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public final class FactoryNoteCommand implements SingleMultiFactoryCommand<AbstractEntityDiagram> {
|
||||
|
||||
@ -79,7 +79,7 @@ public final class FactoryNoteCommand implements SingleMultiFactoryCommand<Abstr
|
||||
@Override
|
||||
protected CommandExecutionResult executeArg(final AbstractEntityDiagram system, RegexResult arg) {
|
||||
final String display = arg.get("DISPLAY", 0);
|
||||
return executeInternal(system, arg, StringUtils.getWithNewlines2(display));
|
||||
return executeInternal(system, arg, BlocLines.getWithNewlines(display));
|
||||
}
|
||||
|
||||
};
|
||||
@ -94,24 +94,22 @@ public final class FactoryNoteCommand implements SingleMultiFactoryCommand<Abstr
|
||||
return "(?i)^end[%s]?note$";
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(final AbstractEntityDiagram system, List<String> lines) {
|
||||
public CommandExecutionResult executeNow(final AbstractEntityDiagram system, BlocLines lines) {
|
||||
// StringUtils.trim(lines, false);
|
||||
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);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
lines = lines.subExtract(1, 1);
|
||||
lines = lines.removeEmptyColumns();
|
||||
return executeInternal(system, line0, lines);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private CommandExecutionResult executeInternal(AbstractEntityDiagram diagram, RegexResult arg,
|
||||
final List<? extends CharSequence> display) {
|
||||
private CommandExecutionResult executeInternal(AbstractEntityDiagram diagram, RegexResult arg, BlocLines display) {
|
||||
final Code code = Code.of(arg.get("CODE", 0));
|
||||
if (diagram.leafExist(code)) {
|
||||
return CommandExecutionResult.error("Note already created: " + code.getFullName());
|
||||
}
|
||||
final IEntity entity = diagram.createLeaf(code, Display.create(display), LeafType.NOTE, null);
|
||||
final IEntity entity = diagram.createLeaf(code, display.toDisplay(), LeafType.NOTE, null);
|
||||
assert entity != null;
|
||||
entity.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
|
||||
return CommandExecutionResult.ok();
|
||||
|
@ -33,12 +33,12 @@
|
||||
*/
|
||||
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.BlocLines;
|
||||
import net.sourceforge.plantuml.command.Command;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||
@ -51,14 +51,12 @@ import net.sourceforge.plantuml.command.regex.RegexLeaf;
|
||||
import net.sourceforge.plantuml.command.regex.RegexOr;
|
||||
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;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.utils.UniqueSequence;
|
||||
|
||||
public final class FactoryNoteOnEntityCommand implements SingleMultiFactoryCommand<AbstractEntityDiagram> {
|
||||
@ -102,7 +100,7 @@ public final class FactoryNoteOnEntityCommand implements SingleMultiFactoryComma
|
||||
@Override
|
||||
protected CommandExecutionResult executeArg(final AbstractEntityDiagram system, RegexResult arg) {
|
||||
final String s = arg.get("NOTE", 0);
|
||||
return executeInternal(arg, system, null, StringUtils.getWithNewlines2(s));
|
||||
return executeInternal(arg, system, null, BlocLines.getWithNewlines(s));
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -116,28 +114,29 @@ public final class FactoryNoteOnEntityCommand implements SingleMultiFactoryComma
|
||||
return "(?i)^(end[%s]?note|\\})$";
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(final AbstractEntityDiagram system, List<String> lines) {
|
||||
public CommandExecutionResult executeNow(final AbstractEntityDiagram system, BlocLines lines) {
|
||||
// StringUtils.trim(lines, false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
lines = lines.subExtract(1, 1);
|
||||
lines = lines.removeEmptyColumns();
|
||||
|
||||
List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
|
||||
Url url = null;
|
||||
if (strings.size() > 0) {
|
||||
if (lines.size() > 0) {
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(system.getSkinParam().getValue("topurl"),
|
||||
ModeUrl.STRICT);
|
||||
url = urlBuilder.getUrl(strings.get(0));
|
||||
url = urlBuilder.getUrl(lines.getFirst499().toString());
|
||||
}
|
||||
if (url != null) {
|
||||
strings = strings.subList(1, strings.size());
|
||||
lines = lines.subExtract(1, 0);
|
||||
}
|
||||
|
||||
return executeInternal(line0, system, url, strings);
|
||||
return executeInternal(line0, system, url, lines);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private CommandExecutionResult executeInternal(RegexResult line0, AbstractEntityDiagram diagram, Url url,
|
||||
List<? extends CharSequence> s) {
|
||||
BlocLines strings) {
|
||||
|
||||
final String pos = line0.get("POSITION", 0);
|
||||
|
||||
@ -152,7 +151,7 @@ public final class FactoryNoteOnEntityCommand implements SingleMultiFactoryComma
|
||||
cl1 = diagram.getOrCreateLeaf(code, null, null);
|
||||
}
|
||||
|
||||
final IEntity note = diagram.createLeaf(UniqueSequence.getCode("GMN"), Display.create(s), LeafType.NOTE, null);
|
||||
final IEntity note = diagram.createLeaf(UniqueSequence.getCode("GMN"), strings.toDisplay(), LeafType.NOTE, null);
|
||||
note.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0)));
|
||||
if (url != null) {
|
||||
note.addUrl(url);
|
||||
|
@ -33,11 +33,11 @@
|
||||
*/
|
||||
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.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.Command;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||
@ -48,10 +48,8 @@ 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.CucaDiagram;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.cucadiagram.Link;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public final class FactoryNoteOnLinkCommand implements SingleMultiFactoryCommand<CucaDiagram> {
|
||||
|
||||
@ -81,11 +79,13 @@ public final class FactoryNoteOnLinkCommand implements SingleMultiFactoryCommand
|
||||
return "(?i)^end[%s]?note$";
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(final CucaDiagram system, List<String> lines) {
|
||||
final List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
|
||||
if (strings.size() > 0) {
|
||||
final RegexResult arg = getStartingPattern().matcher(lines.get(0));
|
||||
return executeInternal(system, strings, arg);
|
||||
public CommandExecutionResult executeNow(final CucaDiagram system, BlocLines lines) {
|
||||
final String line0 = lines.getFirst499().toString();
|
||||
lines = lines.subExtract(1, 1);
|
||||
lines = lines.removeEmptyColumns();
|
||||
if (lines.size() > 0) {
|
||||
final RegexResult arg = getStartingPattern().matcher(line0);
|
||||
return executeInternal(system, lines, arg);
|
||||
}
|
||||
return CommandExecutionResult.error("No note defined");
|
||||
}
|
||||
@ -98,14 +98,13 @@ public final class FactoryNoteOnLinkCommand implements SingleMultiFactoryCommand
|
||||
|
||||
@Override
|
||||
protected CommandExecutionResult executeArg(final CucaDiagram system, RegexResult arg) {
|
||||
final List<String> note = StringUtils.getWithNewlines2(arg.get("NOTE", 0));
|
||||
final BlocLines note = BlocLines.getWithNewlines(arg.get("NOTE", 0));
|
||||
return executeInternal(system, note, arg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private CommandExecutionResult executeInternal(CucaDiagram diagram, List<? extends CharSequence> note,
|
||||
final RegexResult arg) {
|
||||
private CommandExecutionResult executeInternal(CucaDiagram diagram, BlocLines note, final RegexResult arg) {
|
||||
final Link link = diagram.getLastLink();
|
||||
if (link == null) {
|
||||
return CommandExecutionResult.error("No link defined");
|
||||
@ -117,12 +116,12 @@ public final class FactoryNoteOnLinkCommand implements SingleMultiFactoryCommand
|
||||
Url url = null;
|
||||
if (note.size() > 0) {
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
|
||||
url = urlBuilder.getUrl(note.get(0).toString());
|
||||
url = urlBuilder.getUrl(note.getFirst499().toString());
|
||||
}
|
||||
if (url != null) {
|
||||
note = note.subList(1, note.size());
|
||||
note = note.subExtract(1, 0);
|
||||
}
|
||||
link.addNote(Display.create(note), position,
|
||||
link.addNote(note.toDisplay(), position,
|
||||
diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
@ -33,13 +33,12 @@
|
||||
*/
|
||||
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.BlocLines;
|
||||
import net.sourceforge.plantuml.command.Command;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||
@ -50,7 +49,6 @@ 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;
|
||||
@ -90,28 +88,29 @@ public final class FactoryTipOnEntityCommand implements SingleMultiFactoryComman
|
||||
return "(?i)^(end[%s]?note|\\})$";
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(final AbstractEntityDiagram system, List<String> lines) {
|
||||
public CommandExecutionResult executeNow(final AbstractEntityDiagram system, BlocLines lines) {
|
||||
// StringUtils.trim(lines, false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
lines = lines.subExtract(1, 1);
|
||||
lines = lines.removeEmptyColumns();
|
||||
|
||||
List<String> strings = StringUtils.removeEmptyColumns(lines.subList(1, lines.size() - 1));
|
||||
Url url = null;
|
||||
if (strings.size() > 0) {
|
||||
if (lines.size() > 0) {
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(system.getSkinParam().getValue("topurl"),
|
||||
ModeUrl.STRICT);
|
||||
url = urlBuilder.getUrl(strings.get(0));
|
||||
url = urlBuilder.getUrl(lines.getFirst499().toString());
|
||||
}
|
||||
if (url != null) {
|
||||
strings = strings.subList(1, strings.size());
|
||||
lines = lines.subExtract(1, 0);
|
||||
}
|
||||
|
||||
return executeInternal(line0, system, url, strings);
|
||||
return executeInternal(line0, system, url, lines);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private CommandExecutionResult executeInternal(RegexResult line0, AbstractEntityDiagram diagram, Url url,
|
||||
List<? extends CharSequence> s) {
|
||||
BlocLines lines) {
|
||||
|
||||
final String pos = line0.get("POSITION", 0);
|
||||
|
||||
@ -137,7 +136,7 @@ public final class FactoryTipOnEntityCommand implements SingleMultiFactoryComman
|
||||
}
|
||||
diagram.addLink(link);
|
||||
}
|
||||
tips.putTip(member, Display.create(s));
|
||||
tips.putTip(member, lines.toDisplay());
|
||||
|
||||
// final IEntity note = diagram.createLeaf(UniqueSequence.getCode("GMN"), Display.create(s), LeafType.NOTE,
|
||||
// null);
|
||||
|
@ -35,6 +35,8 @@ package net.sourceforge.plantuml.command.note.sequence;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.Command;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||
@ -45,14 +47,12 @@ 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.HtmlColorSet;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.sequencediagram.Note;
|
||||
import net.sourceforge.plantuml.sequencediagram.NotePosition;
|
||||
import net.sourceforge.plantuml.sequencediagram.NoteStyle;
|
||||
import net.sourceforge.plantuml.sequencediagram.Participant;
|
||||
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public final class FactorySequenceNoteCommand implements SingleMultiFactoryCommand<SequenceDiagram> {
|
||||
|
||||
@ -89,10 +89,11 @@ public final class FactorySequenceNoteCommand implements SingleMultiFactoryComma
|
||||
return "(?i)^end[%s]?(note|hnote|rnote)$";
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(final SequenceDiagram system, List<String> lines) {
|
||||
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);
|
||||
public CommandExecutionResult executeNow(final SequenceDiagram system, BlocLines lines) {
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
lines = lines.subExtract(1, 1);
|
||||
lines = lines.removeEmptyColumns();
|
||||
return executeInternal(system, line0, lines);
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -102,14 +103,13 @@ public final class FactorySequenceNoteCommand implements SingleMultiFactoryComma
|
||||
|
||||
@Override
|
||||
protected CommandExecutionResult executeArg(final SequenceDiagram system, RegexResult arg) {
|
||||
final List<String> strings = StringUtils.getWithNewlines2(arg.get("NOTE", 0));
|
||||
return executeInternal(system, arg, strings);
|
||||
return executeInternal(system, arg, BlocLines.getWithNewlines(arg.get("NOTE", 0)));
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
private CommandExecutionResult executeInternal(SequenceDiagram diagram, RegexResult arg, final List<String> strings) {
|
||||
private CommandExecutionResult executeInternal(SequenceDiagram diagram, RegexResult arg, BlocLines strings) {
|
||||
final Participant p = diagram.getOrCreateParticipant(StringUtils
|
||||
.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("PARTICIPANT", 0)));
|
||||
|
||||
@ -117,7 +117,7 @@ public final class FactorySequenceNoteCommand implements SingleMultiFactoryComma
|
||||
|
||||
if (strings.size() > 0) {
|
||||
final boolean tryMerge = arg.get("VMERGE", 0) != null;
|
||||
final Note note = new Note(p, position, Display.create(strings));
|
||||
final Note note = new Note(p, position, strings.toDisplay());
|
||||
note.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0)));
|
||||
note.setStyle(NoteStyle.getNoteStyle(arg.get("STYLE", 0)));
|
||||
diagram.addNote(note, tryMerge);
|
||||
|
@ -35,9 +35,11 @@ package net.sourceforge.plantuml.command.note.sequence;
|
||||
|
||||
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.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.Command;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||
@ -53,7 +55,6 @@ import net.sourceforge.plantuml.sequencediagram.AbstractMessage;
|
||||
import net.sourceforge.plantuml.sequencediagram.EventWithDeactivate;
|
||||
import net.sourceforge.plantuml.sequencediagram.NotePosition;
|
||||
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFactoryCommand<SequenceDiagram> {
|
||||
|
||||
@ -78,8 +79,7 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto
|
||||
|
||||
@Override
|
||||
protected CommandExecutionResult executeArg(final SequenceDiagram system, RegexResult arg) {
|
||||
final List<String> strings = StringUtils.getWithNewlines2(arg.get("NOTE", 0));
|
||||
return executeInternal(system, arg, strings);
|
||||
return executeInternal(system, arg, BlocLines.getWithNewlines(arg.get("NOTE", 0)));
|
||||
}
|
||||
|
||||
};
|
||||
@ -94,32 +94,32 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto
|
||||
return "(?i)^end[%s]?note$";
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(final SequenceDiagram system, List<String> lines) {
|
||||
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);
|
||||
public CommandExecutionResult executeNow(final SequenceDiagram system, BlocLines lines) {
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
lines = lines.subExtract(1, 1);
|
||||
lines = lines.removeEmptyColumns();
|
||||
return executeInternal(system, line0, lines);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
private CommandExecutionResult executeInternal(SequenceDiagram system, final RegexResult line0, List<String> in) {
|
||||
private CommandExecutionResult executeInternal(SequenceDiagram system, final RegexResult line0, BlocLines lines) {
|
||||
final EventWithDeactivate m = system.getLastEventWithDeactivate();
|
||||
if (m instanceof AbstractMessage) {
|
||||
final NotePosition position = NotePosition.valueOf(StringUtils.goUpperCase(line0.get("POSITION", 0)));
|
||||
final Url url;
|
||||
if (in.size() > 0) {
|
||||
if (lines.size() > 0) {
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(system.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
|
||||
url = urlBuilder.getUrl(in.get(0).toString());
|
||||
url = urlBuilder.getUrl(lines.getFirst499().toString());
|
||||
} else {
|
||||
url = null;
|
||||
}
|
||||
if (url != null) {
|
||||
in = in.subList(1, in.size());
|
||||
lines = lines.subExtract(1, 0);
|
||||
}
|
||||
|
||||
((AbstractMessage) m).setNote(Display.create(in), position, line0.get("COLOR", 0), url);
|
||||
((AbstractMessage) m).setNote(lines.toDisplay(), position, line0.get("COLOR", 0), url);
|
||||
}
|
||||
|
||||
return CommandExecutionResult.ok();
|
||||
|
@ -33,8 +33,8 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.command.note.sequence;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.Command;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||
@ -44,13 +44,11 @@ import net.sourceforge.plantuml.command.note.SingleMultiFactoryCommand;
|
||||
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.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.sequencediagram.Note;
|
||||
import net.sourceforge.plantuml.sequencediagram.NoteStyle;
|
||||
import net.sourceforge.plantuml.sequencediagram.Participant;
|
||||
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiFactoryCommand<SequenceDiagram> {
|
||||
|
||||
@ -84,7 +82,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF
|
||||
|
||||
@Override
|
||||
protected CommandExecutionResult executeArg(final SequenceDiagram system, RegexResult arg) {
|
||||
final List<String> strings = StringUtils.getWithNewlines2(arg.get("NOTE", 0));
|
||||
final BlocLines strings = BlocLines.getWithNewlines(arg.get("NOTE", 0));
|
||||
|
||||
return executeInternal(system, arg, strings);
|
||||
}
|
||||
@ -101,26 +99,25 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF
|
||||
return "(?i)^end[%s]?(note|hnote|rnote)$";
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(final SequenceDiagram system, List<String> lines) {
|
||||
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);
|
||||
public CommandExecutionResult executeNow(final SequenceDiagram system, BlocLines lines) {
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
lines = lines.subExtract(1, 1);
|
||||
lines = lines.removeEmptyColumns();
|
||||
return executeInternal(system, line0, lines);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
private CommandExecutionResult executeInternal(SequenceDiagram diagram, final RegexResult line0,
|
||||
final List<String> strings) {
|
||||
private CommandExecutionResult executeInternal(SequenceDiagram diagram, final RegexResult line0, BlocLines lines) {
|
||||
final Participant p1 = diagram.getOrCreateParticipant(StringUtils
|
||||
.eventuallyRemoveStartingAndEndingDoubleQuote(line0.get("P1", 0)));
|
||||
final Participant p2 = diagram.getOrCreateParticipant(StringUtils
|
||||
.eventuallyRemoveStartingAndEndingDoubleQuote(line0.get("P2", 0)));
|
||||
|
||||
if (strings.size() > 0) {
|
||||
if (lines.size() > 0) {
|
||||
final boolean tryMerge = line0.get("VMERGE", 0) != null;
|
||||
final Note note = new Note(p1, p2, Display.create(strings));
|
||||
final Note note = new Note(p1, p2, lines.toDisplay());
|
||||
note.setSpecificBackcolor(diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0)));
|
||||
note.setStyle(NoteStyle.getNoteStyle(line0.get("STYLE", 0)));
|
||||
diagram.addNote(note, tryMerge);
|
||||
|
@ -91,7 +91,11 @@ public abstract class MyPattern {
|
||||
return p;
|
||||
}
|
||||
|
||||
public static boolean mtches(String input, String regex) {
|
||||
// public static boolean mtches(String input, String regex) {
|
||||
// return cmpile(regex).matcher(input).matches();
|
||||
// }
|
||||
//
|
||||
public static boolean mtches(CharSequence input, String regex) {
|
||||
return cmpile(regex).matcher(input).matches();
|
||||
}
|
||||
|
||||
|
@ -39,16 +39,18 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.CharSequence2;
|
||||
import net.sourceforge.plantuml.CharSequence2Impl;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.utils.StartUtils;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.version.IteratorCounter;
|
||||
import net.sourceforge.plantuml.version.IteratorCounterImpl;
|
||||
import net.sourceforge.plantuml.version.IteratorCounter2;
|
||||
import net.sourceforge.plantuml.version.IteratorCounter2Impl;
|
||||
|
||||
/**
|
||||
* Represents the textual source of some diagram.
|
||||
* The source should start with a <code>@startfoo</code> and end with <code>@endfoo</code>.
|
||||
* Represents the textual source of some diagram. The source should start with a <code>@startfoo</code> and end with
|
||||
* <code>@endfoo</code>.
|
||||
* <p>
|
||||
* So the diagram does not have to be a UML one.
|
||||
*
|
||||
@ -58,42 +60,45 @@ import net.sourceforge.plantuml.version.IteratorCounterImpl;
|
||||
final public class UmlSource {
|
||||
|
||||
final private List<String> source;
|
||||
final private List<CharSequence2> source2;
|
||||
|
||||
/**
|
||||
* Build the source from a text.
|
||||
*
|
||||
* @param source the source of the diagram
|
||||
* @param checkEndingBackslash <code>true</code> if an ending backslash means that a line has
|
||||
* to be collapsed with the following one.
|
||||
* @param source
|
||||
* the source of the diagram
|
||||
* @param checkEndingBackslash
|
||||
* <code>true</code> if an ending backslash means that a line has to be collapsed with the following one.
|
||||
*/
|
||||
public UmlSource(List<? extends CharSequence> source, boolean checkEndingBackslash) {
|
||||
public UmlSource(List<CharSequence2> source, boolean checkEndingBackslash) {
|
||||
final List<String> tmp = new ArrayList<String>();
|
||||
// final DiagramType type =
|
||||
// DiagramType.getTypeFromArobaseStart(source.get(0).toString());
|
||||
final List<CharSequence2> tmp2 = new ArrayList<CharSequence2>();
|
||||
|
||||
if (checkEndingBackslash) {
|
||||
final StringBuilder pending = new StringBuilder();
|
||||
for (CharSequence cs : source) {
|
||||
final String s = cs.toString();
|
||||
for (CharSequence2 cs : source) {
|
||||
final String s = cs.toString2();
|
||||
if (StringUtils.endsWithBackslash(s)) {
|
||||
pending.append(s.substring(0, s.length() - 1));
|
||||
} else {
|
||||
pending.append(s);
|
||||
tmp.add(pending.toString());
|
||||
tmp2.add(new CharSequence2Impl(pending.toString(), cs.getLocation()));
|
||||
pending.setLength(0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (CharSequence s : source) {
|
||||
tmp.add(s.toString());
|
||||
for (CharSequence2 s : source) {
|
||||
tmp.add(s.toString2());
|
||||
tmp2.add(s);
|
||||
}
|
||||
}
|
||||
this.source = Collections.unmodifiableList(tmp);
|
||||
this.source2 = Collections.unmodifiableList(tmp2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the type of the diagram.
|
||||
* This is based on the first line <code>@startfoo</code>.
|
||||
* Retrieve the type of the diagram. This is based on the first line <code>@startfoo</code>.
|
||||
*
|
||||
* @return the type of the diagram.
|
||||
*/
|
||||
@ -106,8 +111,8 @@ final public class UmlSource {
|
||||
*
|
||||
* @return a iterator that allow counting line number.
|
||||
*/
|
||||
public IteratorCounter iterator() {
|
||||
return new IteratorCounterImpl(source);
|
||||
public IteratorCounter2 iterator2() {
|
||||
return new IteratorCounter2Impl(source2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,7 +133,8 @@ final public class UmlSource {
|
||||
/**
|
||||
* Return a specific line of the diagram description.
|
||||
*
|
||||
* @param n line number, starting at 0
|
||||
* @param n
|
||||
* line number, starting at 0
|
||||
* @return
|
||||
*/
|
||||
public String getLine(int n) {
|
||||
@ -145,8 +151,7 @@ final public class UmlSource {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a source diagram description is empty.
|
||||
* Does not take comment line into account.
|
||||
* Check if a source diagram description is empty. Does not take comment line into account.
|
||||
*
|
||||
* @return <code>true<code> if the diagram does not contain information.
|
||||
*/
|
||||
@ -169,8 +174,8 @@ final public class UmlSource {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the title, if defined in the diagram source.
|
||||
* Never return <code>null</code>.
|
||||
* Retrieve the title, if defined in the diagram source. Never return <code>null</code>.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Display getTitle() {
|
||||
|
@ -43,6 +43,7 @@ import java.util.List;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import net.sourceforge.plantuml.BlockUml;
|
||||
import net.sourceforge.plantuml.CharSequence2;
|
||||
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||
import net.sourceforge.plantuml.EmbededDiagram;
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
@ -55,10 +56,10 @@ import net.sourceforge.plantuml.ugraphic.UShape;
|
||||
|
||||
class AtomEmbededSystem implements Atom {
|
||||
|
||||
final private List<? extends CharSequence> lines;
|
||||
final private List<CharSequence2> lines2;
|
||||
|
||||
public AtomEmbededSystem(EmbededDiagram sys) {
|
||||
this.lines = sys.getLines().as();
|
||||
this.lines2 = sys.getLines().as2();
|
||||
}
|
||||
|
||||
public double getStartingAltitude(StringBounder stringBounder) {
|
||||
@ -106,7 +107,7 @@ class AtomEmbededSystem implements Atom {
|
||||
// }
|
||||
//
|
||||
private Diagram getSystem() throws IOException, InterruptedException {
|
||||
final BlockUml blockUml = new BlockUml(lines, 0);
|
||||
final BlockUml blockUml = new BlockUml(lines2, 0);
|
||||
return blockUml.getDiagram();
|
||||
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
|
||||
import net.sourceforge.plantuml.graphic.TextBlock;
|
||||
import net.sourceforge.plantuml.graphic.TextBlockUtils;
|
||||
import net.sourceforge.plantuml.graphic.TextBlockVertical2;
|
||||
import net.sourceforge.plantuml.skin.VisibilityModifier;
|
||||
|
||||
@ -174,8 +175,9 @@ public class Bodier {
|
||||
return fields.asBlockMemberImpl();
|
||||
} else if (showMethods && showFields == false) {
|
||||
return methods.asBlockMemberImpl();
|
||||
} else if (showFields == false && showMethods == false) {
|
||||
return TextBlockUtils.empty(0, 0);
|
||||
}
|
||||
assert showFields && showMethods;
|
||||
|
||||
final TextBlock bb1 = fields.asBlockMemberImpl();
|
||||
final TextBlock bb2 = methods.asBlockMemberImpl();
|
||||
|
@ -35,13 +35,17 @@ package net.sourceforge.plantuml.cucadiagram;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
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.CharSequence2;
|
||||
import net.sourceforge.plantuml.CharSequence2Impl;
|
||||
import net.sourceforge.plantuml.EmbededDiagram;
|
||||
import net.sourceforge.plantuml.LineLocationImpl;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.Url;
|
||||
import net.sourceforge.plantuml.UrlBuilder;
|
||||
@ -65,7 +69,7 @@ public class Display implements Iterable<CharSequence> {
|
||||
return create(Arrays.asList(s));
|
||||
}
|
||||
|
||||
public static Display create(List<? extends CharSequence> other) {
|
||||
public static Display create(Collection<? extends CharSequence> other) {
|
||||
return new Display(other, null);
|
||||
}
|
||||
|
||||
@ -121,12 +125,12 @@ public class Display implements Iterable<CharSequence> {
|
||||
this.naturalHorizontalAlignment = naturalHorizontalAlignment;
|
||||
}
|
||||
|
||||
private Display(List<? extends CharSequence> other, HorizontalAlignment naturalHorizontalAlignment) {
|
||||
private Display(Collection<? extends CharSequence> other, HorizontalAlignment naturalHorizontalAlignment) {
|
||||
this(naturalHorizontalAlignment);
|
||||
this.display.addAll(manageEmbededDiagrams2(other));
|
||||
}
|
||||
|
||||
private static List<CharSequence> manageEmbededDiagrams2(final List<? extends CharSequence> strings) {
|
||||
private static List<CharSequence> manageEmbededDiagrams2(final Collection<? extends CharSequence> strings) {
|
||||
final List<CharSequence> result = new ArrayList<CharSequence>();
|
||||
final Iterator<? extends CharSequence> it = strings.iterator();
|
||||
while (it.hasNext()) {
|
||||
@ -190,37 +194,6 @@ public class Display implements Iterable<CharSequence> {
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean firstColumnRemovable() {
|
||||
boolean allEmpty = true;
|
||||
for (CharSequence s : this) {
|
||||
if (s.length() == 0) {
|
||||
continue;
|
||||
}
|
||||
allEmpty = false;
|
||||
final char c = s.charAt(0);
|
||||
if (c != ' ' && c != '\t') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return allEmpty == false;
|
||||
}
|
||||
|
||||
public Display removeEmptyColumns() {
|
||||
if (firstColumnRemovable() == false) {
|
||||
return this;
|
||||
}
|
||||
final Display result = new Display(this);
|
||||
do {
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
final CharSequence s = result.get(i);
|
||||
if (s.length() > 0) {
|
||||
result.display.set(i, s.toString().substring(1));
|
||||
}
|
||||
}
|
||||
} while (result.firstColumnRemovable());
|
||||
return result;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return display.size();
|
||||
}
|
||||
@ -241,6 +214,16 @@ public class Display implements Iterable<CharSequence> {
|
||||
return Collections.unmodifiableList(display);
|
||||
}
|
||||
|
||||
public List<CharSequence2> as2() {
|
||||
final List<CharSequence2> result = new ArrayList<CharSequence2>();
|
||||
LineLocationImpl location = new LineLocationImpl("inner", null);
|
||||
for (CharSequence cs : display) {
|
||||
location = location.oneLineRead();
|
||||
result.add(new CharSequence2Impl(cs, location));
|
||||
}
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
public Url initUrl() {
|
||||
if (this.size() == 0) {
|
||||
return null;
|
||||
|
@ -1,241 +0,0 @@
|
||||
/* ========================================================================
|
||||
* 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: 8218 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
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;
|
||||
|
||||
public class Display2 implements Iterable<CharSequence> {
|
||||
|
||||
private final List<CharSequence> display = new ArrayList<CharSequence>();
|
||||
|
||||
public static Display2 empty() {
|
||||
return new Display2();
|
||||
}
|
||||
|
||||
public static Display2 create(CharSequence... s) {
|
||||
if (s.length==1 && s[0]==null) {
|
||||
return empty();
|
||||
}
|
||||
return new Display2(Arrays.asList(s));
|
||||
}
|
||||
|
||||
public static Display2 create(List<? extends CharSequence> other) {
|
||||
return new Display2(other);
|
||||
}
|
||||
|
||||
public static Display2 getWithNewlines(Code s) {
|
||||
return getWithNewlines(s.getFullName());
|
||||
}
|
||||
|
||||
public static Display2 getWithNewlines(String s) {
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
final Display2 result = new Display2();
|
||||
result.display.addAll(getWithNewlinesInternal(s));
|
||||
return result;
|
||||
}
|
||||
|
||||
private Display2(List<? extends CharSequence> other) {
|
||||
for (CharSequence s : other) {
|
||||
this.display.addAll(getWithNewlinesInternal(s));
|
||||
}
|
||||
}
|
||||
|
||||
private Display2(Display2 other) {
|
||||
this.display.addAll(other.display);
|
||||
}
|
||||
|
||||
private Display2() {
|
||||
}
|
||||
|
||||
public Display2 underlined() {
|
||||
final List<CharSequence> result = new ArrayList<CharSequence>();
|
||||
for (CharSequence line : display) {
|
||||
result.add("<u>" + line);
|
||||
}
|
||||
return new Display2(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return display.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return display.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return this.display.equals(((Display2) other).display);
|
||||
}
|
||||
|
||||
public Display2 addAll(Display2 other) {
|
||||
final Display2 result = new Display2(this);
|
||||
result.display.addAll(other.display);
|
||||
return result;
|
||||
}
|
||||
|
||||
public Display2 addFirst(CharSequence s) {
|
||||
final Display2 result = new Display2(this);
|
||||
result.display.addAll(0, getWithNewlinesInternal(s));
|
||||
return result;
|
||||
}
|
||||
|
||||
public Display2 add(CharSequence s) {
|
||||
final Display2 result = new Display2(this);
|
||||
result.display.addAll(getWithNewlinesInternal(s));
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean firstColumnRemovable() {
|
||||
boolean allEmpty = true;
|
||||
for (CharSequence s : this) {
|
||||
if (s.length() == 0) {
|
||||
continue;
|
||||
}
|
||||
allEmpty = false;
|
||||
final char c = s.charAt(0);
|
||||
if (c != ' ' && c != '\t') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return allEmpty == false;
|
||||
}
|
||||
|
||||
public Display2 removeEmptyColumns() {
|
||||
if (firstColumnRemovable() == false) {
|
||||
return this;
|
||||
}
|
||||
final Display2 result = new Display2(this);
|
||||
do {
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
final CharSequence s = result.get(i);
|
||||
if (s.length() > 0) {
|
||||
result.display.set(i, s.toString().substring(1));
|
||||
}
|
||||
}
|
||||
} while (result.firstColumnRemovable());
|
||||
return result;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return display.size();
|
||||
}
|
||||
|
||||
public CharSequence get(int i) {
|
||||
return display.get(i);
|
||||
}
|
||||
|
||||
public Iterator<CharSequence> iterator() {
|
||||
return Collections.unmodifiableList(display).iterator();
|
||||
}
|
||||
|
||||
public Display2 subList(int i, int size) {
|
||||
final Display2 result = new Display2();
|
||||
result.display.addAll(display.subList(i, size));
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<? extends CharSequence> as() {
|
||||
return Collections.unmodifiableList(display);
|
||||
}
|
||||
|
||||
private static List<String> getWithNewlinesInternal(CharSequence s) {
|
||||
final List<String> result = new ArrayList<String>();
|
||||
final StringBuilder current = new StringBuilder();
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
final char c = s.charAt(i);
|
||||
if (c == '\\' && i < s.length() - 1) {
|
||||
final char c2 = s.charAt(i + 1);
|
||||
i++;
|
||||
if (c2 == 'n') {
|
||||
result.add(current.toString());
|
||||
current.setLength(0);
|
||||
} else if (c2 == 't') {
|
||||
current.append('\t');
|
||||
} else if (c2 == '\\') {
|
||||
current.append(c2);
|
||||
} else {
|
||||
current.append(c);
|
||||
current.append(c2);
|
||||
}
|
||||
} else {
|
||||
current.append(c);
|
||||
}
|
||||
}
|
||||
result.add(current.toString());
|
||||
return result;
|
||||
}
|
||||
|
||||
public Url initUrl() {
|
||||
if (this.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.AT_START);
|
||||
return urlBuilder.getUrl(StringUtils.trin(this.get(0).toString()));
|
||||
}
|
||||
|
||||
public Display2 removeUrl(Url url) {
|
||||
if (url == null) {
|
||||
return this;
|
||||
}
|
||||
final Display2 result = new Display2();
|
||||
result.display.add(UrlBuilder.purgeUrl(this.get(0).toString()));
|
||||
result.display.addAll(this.subList(1, this.size()).display);
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean hasUrl() {
|
||||
final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.ANYWHERE);
|
||||
for (CharSequence s : this) {
|
||||
if (urlBuilder.getUrl(s.toString()) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 16196 $
|
||||
* Revision $Revision: 16447 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.cucadiagram.dot;
|
||||
|
@ -124,14 +124,14 @@ public final class CucaDiagramTxtMaker {
|
||||
ug.getCharArea().drawHLine('-', y, 1, w - 1);
|
||||
y++;
|
||||
for (Member att : ent.getBodier().getFieldsToDisplay()) {
|
||||
final List<String> disp = StringUtils.getWithNewlines2(att.getDisplay(true));
|
||||
final List<String> disp = StringUtils.getWithNewlines(att.getDisplay(true));
|
||||
ug.getCharArea().drawStringsLR(disp, 1, y);
|
||||
y += StringUtils.getHeight(disp);
|
||||
}
|
||||
ug.getCharArea().drawHLine('-', y, 1, w - 1);
|
||||
y++;
|
||||
for (Member att : ent.getBodier().getMethodsToDisplay()) {
|
||||
final List<String> disp = StringUtils.getWithNewlines2(att.getDisplay(true));
|
||||
final List<String> disp = StringUtils.getWithNewlines(att.getDisplay(true));
|
||||
ug.getCharArea().drawStringsLR(disp, 1, y);
|
||||
y += StringUtils.getHeight(disp);
|
||||
}
|
||||
|
@ -100,8 +100,8 @@ public class CommandCreateElementFull extends SingleLineCommand2<DescriptionDiag
|
||||
private static final String DISPLAY_WITHOUT_QUOTE = "(" + DISPLAY_CORE + "|[\\p{L}0-9_.]+)";
|
||||
|
||||
@Override
|
||||
final protected boolean isForbidden(String line) {
|
||||
if (line.matches("^[\\p{L}0-9_.]+$")) {
|
||||
final protected boolean isForbidden(CharSequence line) {
|
||||
if (line.toString().matches("^[\\p{L}0-9_.]+$")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -36,6 +36,8 @@ package net.sourceforge.plantuml.descdiagram.command;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||
import net.sourceforge.plantuml.command.MultilinesStrategy;
|
||||
@ -51,7 +53,6 @@ import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
||||
import net.sourceforge.plantuml.descdiagram.DescriptionDiagram;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.graphic.USymbol;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class CommandCreateElementMultilines extends CommandMultilines2<DescriptionDiagram> {
|
||||
|
||||
@ -80,9 +81,9 @@ public class CommandCreateElementMultilines extends CommandMultilines2<Descripti
|
||||
new RegexLeaf("DESC", "as[%s]*[%g](.*)$"));
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(DescriptionDiagram diagram, List<String> lines) {
|
||||
StringUtils.trim(lines, false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
public CommandExecutionResult executeNow(DescriptionDiagram diagram, BlocLines lines) {
|
||||
lines = lines.trim(false);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
final String symbol = StringUtils.goUpperCase(line0.get("TYPE", 0));
|
||||
final LeafType type;
|
||||
final USymbol usymbol;
|
||||
@ -98,14 +99,15 @@ public class CommandCreateElementMultilines extends CommandMultilines2<Descripti
|
||||
}
|
||||
|
||||
final Code code = Code.of(line0.get("CODE", 0));
|
||||
Display display = Display.create(lines.subList(1, lines.size() - 1));
|
||||
final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()),
|
||||
lines.getLast499().toString());
|
||||
lines = lines.subExtract(1, 1);
|
||||
Display display = lines.toDisplay();
|
||||
final String descStart = line0.get("DESC", 0);
|
||||
if (StringUtils.isNotEmpty(descStart)) {
|
||||
display = display.addFirst(descStart);
|
||||
}
|
||||
|
||||
final List<String> lineLast = StringUtils.getSplit(MyPattern.cmpile(getPatternEnd()),
|
||||
lines.get(lines.size() - 1));
|
||||
if (StringUtils.isNotEmpty(lineLast.get(0))) {
|
||||
display = display.add(lineLast.get(0));
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ import java.util.List;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import net.sourceforge.plantuml.BlockUml;
|
||||
import net.sourceforge.plantuml.CharSequence2;
|
||||
import net.sourceforge.plantuml.Dimension2DDouble;
|
||||
import net.sourceforge.plantuml.EmbededDiagram;
|
||||
import net.sourceforge.plantuml.FileFormat;
|
||||
@ -54,10 +55,10 @@ import net.sourceforge.plantuml.ugraphic.UShape;
|
||||
|
||||
class EmbededSystemLine extends AbstractTextBlock implements Line {
|
||||
|
||||
final private List<? extends CharSequence> lines;
|
||||
final private List<CharSequence2> lines2;
|
||||
|
||||
public EmbededSystemLine(EmbededDiagram sys) {
|
||||
this.lines = sys.getLines().as();
|
||||
this.lines2 = sys.getLines().as2();
|
||||
}
|
||||
|
||||
public Dimension2D calculateDimension(StringBounder stringBounder) {
|
||||
@ -101,7 +102,7 @@ class EmbededSystemLine extends AbstractTextBlock implements Line {
|
||||
}
|
||||
|
||||
private Diagram getSystem() throws IOException, InterruptedException {
|
||||
final BlockUml blockUml = new BlockUml(lines, 0);
|
||||
final BlockUml blockUml = new BlockUml(lines2, 0);
|
||||
return blockUml.getDiagram();
|
||||
|
||||
}
|
||||
|
@ -158,7 +158,10 @@ public class QuoteUtils {
|
||||
"I can't lie to you about your chances, but... you have my sympathies.", //
|
||||
"There is an explanation for this, you know.", //
|
||||
"Bishop: I'm afraid I have some bad news.", //
|
||||
"Do me a favour. Disconnect me. I could be reworked, but I'll never be top of the line again."
|
||||
"Do me a favour. Disconnect me. I could be reworked, but I'll never be top of the line again.", //
|
||||
"Take it easy, don't push the little button on the joystick!", //
|
||||
"I'm a very private person.", //
|
||||
"To sculpt an elephant from a big block of marble, just knock away all the bits that don't look like an elephant."
|
||||
);
|
||||
private QuoteUtils() {
|
||||
}
|
||||
|
@ -89,12 +89,12 @@ public abstract class USymbol {
|
||||
}
|
||||
|
||||
public static USymbol getFromString(String s) {
|
||||
final USymbol result = all.get(StringUtils.goUpperCase(s));
|
||||
final USymbol result = all.get(StringUtils.goUpperCase(s.replaceAll("\\W", "")));
|
||||
if (result == null) {
|
||||
if (s.equalsIgnoreCase("component")) {
|
||||
return COMPONENT2;
|
||||
}
|
||||
throw new IllegalArgumentException("s=" + s);
|
||||
return null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -33,10 +33,10 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.objectdiagram.command;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.UrlBuilder;
|
||||
import net.sourceforge.plantuml.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines2;
|
||||
import net.sourceforge.plantuml.command.MultilinesStrategy;
|
||||
@ -51,7 +51,6 @@ import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
||||
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
|
||||
import net.sourceforge.plantuml.objectdiagram.ObjectDiagram;
|
||||
import net.sourceforge.plantuml.skin.VisibilityModifier;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class CommandCreateEntityObjectMultilines extends CommandMultilines2<ObjectDiagram> {
|
||||
|
||||
@ -77,19 +76,20 @@ public class CommandCreateEntityObjectMultilines extends CommandMultilines2<Obje
|
||||
return "(?i)^[%s]*\\}[%s]*$";
|
||||
}
|
||||
|
||||
public CommandExecutionResult executeNow(ObjectDiagram diagram, List<String> lines) {
|
||||
StringUtils.trim(lines, true);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.get(0)));
|
||||
public CommandExecutionResult executeNow(ObjectDiagram diagram, BlocLines lines) {
|
||||
lines = lines.trim(true);
|
||||
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
|
||||
final IEntity entity = executeArg0(diagram, line0);
|
||||
if (entity == null) {
|
||||
return CommandExecutionResult.error("No such entity");
|
||||
}
|
||||
for (String s : lines.subList(1, lines.size() - 1)) {
|
||||
lines = lines.subExtract(1, 1);
|
||||
for (CharSequence s : lines) {
|
||||
assert s.length() > 0;
|
||||
if (VisibilityModifier.isVisibilityCharacter(s.charAt(0))) {
|
||||
diagram.setVisibilityModifierPresent(true);
|
||||
}
|
||||
entity.getBodier().addFieldOrMethod(s);
|
||||
entity.getBodier().addFieldOrMethod(s.toString());
|
||||
}
|
||||
return CommandExecutionResult.ok();
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 12235 $
|
||||
* Revision $Revision: 16353 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.preproc;
|
||||
@ -37,6 +37,7 @@ import java.io.IOException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.CharSequence2;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
|
||||
class IfManager implements ReadLine {
|
||||
@ -55,9 +56,9 @@ class IfManager implements ReadLine {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
final public String readLine() throws IOException {
|
||||
final public CharSequence2 readLine() throws IOException {
|
||||
if (child != null) {
|
||||
final String s = child.readLine();
|
||||
final CharSequence2 s = child.readLine();
|
||||
if (s != null) {
|
||||
return s;
|
||||
}
|
||||
@ -67,8 +68,8 @@ class IfManager implements ReadLine {
|
||||
return readLineInternal();
|
||||
}
|
||||
|
||||
protected String readLineInternal() throws IOException {
|
||||
final String s = source.readLine();
|
||||
protected CharSequence2 readLineInternal() throws IOException {
|
||||
final CharSequence2 s = source.readLine();
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 12235 $
|
||||
* Revision $Revision: 16353 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.preproc;
|
||||
@ -36,6 +36,8 @@ package net.sourceforge.plantuml.preproc;
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import net.sourceforge.plantuml.CharSequence2;
|
||||
|
||||
class IfManagerNegatif extends IfManager {
|
||||
|
||||
private boolean skippingDone = false;
|
||||
@ -45,11 +47,11 @@ class IfManagerNegatif extends IfManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String readLineInternal() throws IOException {
|
||||
protected CharSequence2 readLineInternal() throws IOException {
|
||||
if (skippingDone == false) {
|
||||
skippingDone = true;
|
||||
do {
|
||||
final String s = readLine();
|
||||
final CharSequence2 s = readLine();
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
@ -64,7 +66,7 @@ class IfManagerNegatif extends IfManager {
|
||||
} while (true);
|
||||
}
|
||||
|
||||
final String s = super.readLineInternal();
|
||||
final CharSequence2 s = super.readLineInternal();
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 12235 $
|
||||
* Revision $Revision: 16353 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.preproc;
|
||||
@ -36,6 +36,8 @@ package net.sourceforge.plantuml.preproc;
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import net.sourceforge.plantuml.CharSequence2;
|
||||
|
||||
class IfManagerPositif extends IfManager {
|
||||
|
||||
public IfManagerPositif(ReadLine source, Defines defines) {
|
||||
@ -43,8 +45,8 @@ class IfManagerPositif extends IfManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String readLineInternal() throws IOException {
|
||||
String s = super.readLineInternal();
|
||||
protected CharSequence2 readLineInternal() throws IOException {
|
||||
CharSequence2 s = super.readLineInternal();
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 16305 $
|
||||
* Revision $Revision: 16353 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.preproc;
|
||||
@ -37,12 +37,13 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.CharSequence2;
|
||||
import net.sourceforge.plantuml.CharSequence2Impl;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
import net.sourceforge.plantuml.utils.StartUtils;
|
||||
@ -68,8 +69,8 @@ public class Preprocessor implements ReadLine {
|
||||
this.source = new ReadLineInsertable(new IfManager(rawSource, defines));
|
||||
}
|
||||
|
||||
public String readLine() throws IOException {
|
||||
final String s = source.readLine();
|
||||
public CharSequence2 readLine() throws IOException {
|
||||
final CharSequence2 s = source.readLine();
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
@ -97,30 +98,30 @@ public class Preprocessor implements ReadLine {
|
||||
return s;
|
||||
}
|
||||
|
||||
final List<String> result = defines.applyDefines(s);
|
||||
final List<String> result = defines.applyDefines(s.toString2());
|
||||
if (result.size() > 1) {
|
||||
ignoreDefineDuringSeveralLines = result.size() - 2;
|
||||
source.insert(result.subList(1, result.size() - 1));
|
||||
source.insert(result.subList(1, result.size() - 1), s.getLocation());
|
||||
}
|
||||
return result.get(0);
|
||||
return new CharSequence2Impl(result.get(0), s.getLocation());
|
||||
}
|
||||
|
||||
private int ignoreDefineDuringSeveralLines = 0;
|
||||
|
||||
private String manageUndef(Matcher m) throws IOException {
|
||||
private CharSequence2 manageUndef(Matcher m) throws IOException {
|
||||
defines.undefine(m.group(1));
|
||||
return this.readLine();
|
||||
}
|
||||
|
||||
private String manageDefineLong(Matcher m) throws IOException {
|
||||
private CharSequence2 manageDefineLong(Matcher m) throws IOException {
|
||||
final String group1 = m.group(1);
|
||||
final List<String> def = new ArrayList<String>();
|
||||
while (true) {
|
||||
final String read = this.readLine();
|
||||
final CharSequence2 read = this.readLine();
|
||||
if (read == null) {
|
||||
return null;
|
||||
}
|
||||
def.add(read);
|
||||
def.add(read.toString2());
|
||||
if (enddefinelongPattern.matcher(read).find()) {
|
||||
defines.define(group1, def);
|
||||
return this.readLine();
|
||||
@ -128,7 +129,7 @@ public class Preprocessor implements ReadLine {
|
||||
}
|
||||
}
|
||||
|
||||
private String manageDefine(Matcher m) throws IOException {
|
||||
private CharSequence2 manageDefine(Matcher m) throws IOException {
|
||||
final String group1 = m.group(1);
|
||||
final String group2 = m.group(2);
|
||||
if (group2 == null) {
|
||||
@ -141,8 +142,8 @@ public class Preprocessor implements ReadLine {
|
||||
final StringBuilder value = new StringBuilder(strings.get(0));
|
||||
while (StringUtils.endsWithBackslash(value.toString())) {
|
||||
value.setLength(value.length() - 1);
|
||||
final String read = this.readLine();
|
||||
value.append(read);
|
||||
final CharSequence2 read = this.readLine();
|
||||
value.append(read.toString2());
|
||||
}
|
||||
final List<String> li = new ArrayList<String>();
|
||||
li.add(value.toString());
|
||||
|
@ -29,7 +29,7 @@
|
||||
* Original Author: Arnaud Roques
|
||||
* Modified by: Nicolas Jouanin
|
||||
*
|
||||
* Revision $Revision: 16305 $
|
||||
* Revision $Revision: 16359 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.preproc;
|
||||
@ -48,7 +48,10 @@ import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.CharSequence2;
|
||||
import net.sourceforge.plantuml.CharSequence2Impl;
|
||||
import net.sourceforge.plantuml.FileSystem;
|
||||
import net.sourceforge.plantuml.LineLocation;
|
||||
import net.sourceforge.plantuml.Log;
|
||||
import net.sourceforge.plantuml.OptionFlags;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
@ -101,8 +104,8 @@ class PreprocessorInclude implements ReadLine {
|
||||
}
|
||||
}
|
||||
|
||||
public String readLine() throws IOException {
|
||||
final String result = readLineInternal();
|
||||
public CharSequence2 readLine() throws IOException {
|
||||
final CharSequence2 result = readLineInternal();
|
||||
if (result != null && (StartUtils.isArobaseEndDiagram(result) || StartUtils.isArobaseStartDiagram(result))) {
|
||||
// http://plantuml.sourceforge.net/qa/?qa=3389/error-generating-when-same-file-included-different-diagram
|
||||
filesUsedCurrent.clear();
|
||||
@ -110,9 +113,9 @@ class PreprocessorInclude implements ReadLine {
|
||||
return result;
|
||||
}
|
||||
|
||||
private String readLineInternal() throws IOException {
|
||||
private CharSequence2 readLineInternal() throws IOException {
|
||||
if (included != null) {
|
||||
final String s = included.readLine();
|
||||
final CharSequence2 s = included.readLine();
|
||||
if (s != null) {
|
||||
return s;
|
||||
}
|
||||
@ -120,7 +123,7 @@ class PreprocessorInclude implements ReadLine {
|
||||
included = null;
|
||||
}
|
||||
|
||||
final String s = reader2.readLine();
|
||||
final CharSequence2 s = reader2.readLine();
|
||||
numLine++;
|
||||
if (s == null) {
|
||||
return null;
|
||||
@ -129,17 +132,17 @@ class PreprocessorInclude implements ReadLine {
|
||||
final Matcher m = includePattern.matcher(s);
|
||||
assert included == null;
|
||||
if (m.find()) {
|
||||
return manageFileInclude(m);
|
||||
return manageFileInclude(m, s.getLocation());
|
||||
}
|
||||
}
|
||||
final Matcher mUrl = includeURLPattern.matcher(s);
|
||||
if (mUrl.find()) {
|
||||
return manageUrlInclude(mUrl);
|
||||
return manageUrlInclude(mUrl, s.getLocation());
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
private String manageUrlInclude(Matcher m) throws IOException {
|
||||
private CharSequence2 manageUrlInclude(Matcher m, LineLocation lineLocation) throws IOException {
|
||||
String urlString = m.group(1);
|
||||
urlString = defines.applyDefines(urlString).get(0);
|
||||
//
|
||||
@ -151,15 +154,15 @@ class PreprocessorInclude implements ReadLine {
|
||||
}
|
||||
try {
|
||||
final URL url = new URL(urlString);
|
||||
included = new PreprocessorInclude(getReaderInclude(url, suf), defines, charset, null, filesUsedCurrent,
|
||||
included = new PreprocessorInclude(getReaderInclude(url, suf, lineLocation), defines, charset, null, filesUsedCurrent,
|
||||
filesUsedGlobal);
|
||||
} catch (MalformedURLException e) {
|
||||
return "Cannot include url " + urlString;
|
||||
return CharSequence2Impl.errorPreprocessor("Cannot include url " + urlString, lineLocation);
|
||||
}
|
||||
return this.readLine();
|
||||
}
|
||||
|
||||
private String manageFileInclude(Matcher m) throws IOException {
|
||||
private CharSequence2 manageFileInclude(Matcher m, LineLocation lineLocation) throws IOException {
|
||||
String fileName = m.group(1);
|
||||
fileName = defines.applyDefines(fileName).get(0);
|
||||
final int idx = fileName.lastIndexOf('!');
|
||||
@ -170,13 +173,13 @@ class PreprocessorInclude implements ReadLine {
|
||||
}
|
||||
final File f = FileSystem.getInstance().getFile(withEnvironmentVariable(fileName));
|
||||
if (f.exists() == false) {
|
||||
return "Cannot include " + f.getAbsolutePath();
|
||||
return CharSequence2Impl.errorPreprocessor("Cannot include " + f.getAbsolutePath(), lineLocation);
|
||||
} else if (filesUsedCurrent.contains(f)) {
|
||||
return "File already included " + f.getAbsolutePath();
|
||||
return CharSequence2Impl.errorPreprocessor("File already included " + f.getAbsolutePath(), lineLocation);
|
||||
} else {
|
||||
filesUsedCurrent.add(f);
|
||||
filesUsedGlobal.add(f);
|
||||
included = new PreprocessorInclude(getReaderInclude(f, suf), defines, charset, f.getParentFile(),
|
||||
included = new PreprocessorInclude(getReaderInclude(f, suf, lineLocation), defines, charset, f.getParentFile(),
|
||||
filesUsedCurrent, filesUsedGlobal);
|
||||
}
|
||||
return this.readLine();
|
||||
@ -211,7 +214,7 @@ class PreprocessorInclude implements ReadLine {
|
||||
return null;
|
||||
}
|
||||
|
||||
private ReadLine getReaderInclude(final File f, String suf) throws IOException {
|
||||
private ReadLine getReaderInclude(final File f, String suf, LineLocation parent) throws IOException {
|
||||
if (StartDiagramExtractReader.containsStartDiagram(f, charset)) {
|
||||
int bloc = 0;
|
||||
if (suf != null && suf.matches("\\d+")) {
|
||||
@ -221,13 +224,13 @@ class PreprocessorInclude implements ReadLine {
|
||||
}
|
||||
if (charset == null) {
|
||||
Log.info("Using default charset");
|
||||
return new ReadLineReader(new FileReader(f));
|
||||
return new ReadLineReader(new FileReader(f), f.getAbsolutePath(), parent);
|
||||
}
|
||||
Log.info("Using charset " + charset);
|
||||
return new ReadLineReader(new InputStreamReader(new FileInputStream(f), charset));
|
||||
return new ReadLineReader(new InputStreamReader(new FileInputStream(f), charset), f.getAbsolutePath(), parent);
|
||||
}
|
||||
|
||||
private ReadLine getReaderInclude(final URL url, String suf) throws IOException {
|
||||
private ReadLine getReaderInclude(final URL url, String suf, LineLocation parent) throws IOException {
|
||||
if (StartDiagramExtractReader.containsStartDiagram(url, charset)) {
|
||||
int bloc = 0;
|
||||
if (suf != null && suf.matches("\\d+")) {
|
||||
@ -238,10 +241,10 @@ class PreprocessorInclude implements ReadLine {
|
||||
final InputStream is = url.openStream();
|
||||
if (charset == null) {
|
||||
Log.info("Using default charset");
|
||||
return new ReadLineReader(new InputStreamReader(is));
|
||||
return new ReadLineReader(new InputStreamReader(is), url.toString(), parent);
|
||||
}
|
||||
Log.info("Using charset " + charset);
|
||||
return new ReadLineReader(new InputStreamReader(is, charset));
|
||||
return new ReadLineReader(new InputStreamReader(is, charset), url.toString(), parent);
|
||||
}
|
||||
|
||||
public int getLineNumber() {
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Original Author: Arnaud Roques
|
||||
*
|
||||
* Revision $Revision: 12235 $
|
||||
* Revision $Revision: 16327 $
|
||||
*
|
||||
*/
|
||||
package net.sourceforge.plantuml.preproc;
|
||||
@ -36,7 +36,9 @@ package net.sourceforge.plantuml.preproc;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.sourceforge.plantuml.CharSequence2;
|
||||
|
||||
public interface ReadLine extends Closeable {
|
||||
|
||||
public String readLine() throws IOException;
|
||||
public CharSequence2 readLine() throws IOException;
|
||||
}
|
||||
|
@ -38,10 +38,14 @@ import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.CharSequence2;
|
||||
import net.sourceforge.plantuml.CharSequence2Impl;
|
||||
import net.sourceforge.plantuml.LineLocation;
|
||||
|
||||
class ReadLineInsertable implements ReadLine {
|
||||
|
||||
private final ReadLine source;
|
||||
private final List<String> inserted = new LinkedList<String>();
|
||||
private final List<CharSequence2> inserted = new LinkedList<CharSequence2>();
|
||||
|
||||
public ReadLineInsertable(ReadLine source) {
|
||||
this.source = source;
|
||||
@ -51,18 +55,20 @@ class ReadLineInsertable implements ReadLine {
|
||||
source.close();
|
||||
}
|
||||
|
||||
public String readLine() throws IOException {
|
||||
public CharSequence2 readLine() throws IOException {
|
||||
if (inserted.size() > 0) {
|
||||
final Iterator<String> it = inserted.iterator();
|
||||
final String result = it.next();
|
||||
final Iterator<CharSequence2> it = inserted.iterator();
|
||||
final CharSequence2 result = it.next();
|
||||
it.remove();
|
||||
return result;
|
||||
}
|
||||
return source.readLine();
|
||||
}
|
||||
|
||||
public void insert(List<String> data) {
|
||||
inserted.addAll(data);
|
||||
public void insert(List<? extends CharSequence> data, LineLocation location) {
|
||||
for (CharSequence s : data) {
|
||||
inserted.add(new CharSequence2Impl(s, location));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,34 +37,47 @@ import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
||||
import net.sourceforge.plantuml.CharSequence2;
|
||||
import net.sourceforge.plantuml.CharSequence2Impl;
|
||||
import net.sourceforge.plantuml.LineLocation;
|
||||
import net.sourceforge.plantuml.LineLocationImpl;
|
||||
|
||||
public class ReadLineReader implements ReadLine {
|
||||
|
||||
private final BufferedReader br;
|
||||
private LineLocationImpl location;
|
||||
|
||||
public ReadLineReader(Reader reader) {
|
||||
public ReadLineReader(Reader reader, String desc, LineLocation parent) {
|
||||
br = new BufferedReader(reader);
|
||||
location = new LineLocationImpl(desc, parent);
|
||||
}
|
||||
|
||||
public String readLine() throws IOException {
|
||||
public ReadLineReader(Reader reader, String desc) {
|
||||
this(reader, desc, null);
|
||||
}
|
||||
|
||||
public CharSequence2 readLine() throws IOException {
|
||||
String s = br.readLine();
|
||||
if (s != null && s.startsWith("\uFEFF")) {
|
||||
location = location.oneLineRead();
|
||||
if (s == null) {
|
||||
return null;
|
||||
}
|
||||
if (s.startsWith("\uFEFF")) {
|
||||
s = s.substring(1);
|
||||
}
|
||||
if (s != null) {
|
||||
s = s.replace('\u2013', '-');
|
||||
// s = s.replace('\u00A0', ' ');
|
||||
// s = s.replace('\u201c', '\"');
|
||||
// s = s.replace('\u201d', '\"');
|
||||
// s = s.replace('\u00ab', '\"');
|
||||
// s = s.replace('\u00bb', '\"');
|
||||
// s = s.replace('\u2018', '\'');
|
||||
// s = s.replace('\u2019', '\'');
|
||||
// for (int i = 0; i < s.length(); i++) {
|
||||
// char c = s.charAt(i);
|
||||
// System.err.println("X " + Integer.toHexString((int) c) + " " + c);
|
||||
// }
|
||||
}
|
||||
return s;
|
||||
s = s.replace('\u2013', '-');
|
||||
// s = s.replace('\u00A0', ' ');
|
||||
// s = s.replace('\u201c', '\"');
|
||||
// s = s.replace('\u201d', '\"');
|
||||
// s = s.replace('\u00ab', '\"');
|
||||
// s = s.replace('\u00bb', '\"');
|
||||
// s = s.replace('\u2018', '\'');
|
||||
// s = s.replace('\u2019', '\'');
|
||||
// for (int i = 0; i < s.length(); i++) {
|
||||
// char c = s.charAt(i);
|
||||
// System.err.println("X " + Integer.toHexString((int) c) + " " + c);
|
||||
// }
|
||||
return new CharSequence2Impl(s, location);
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
|
@ -40,6 +40,7 @@ import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
|
||||
import net.sourceforge.plantuml.CharSequence2;
|
||||
import net.sourceforge.plantuml.Log;
|
||||
import net.sourceforge.plantuml.utils.StartUtils;
|
||||
|
||||
@ -61,7 +62,7 @@ public class StartDiagramExtractReader implements ReadLine {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
this.raw = raw;
|
||||
String s = null;
|
||||
CharSequence2 s = null;
|
||||
while ((s = raw.readLine()) != null) {
|
||||
if (StartUtils.isArobaseStartDiagram(s)) {
|
||||
if (num == 0) {
|
||||
@ -77,20 +78,22 @@ public class StartDiagramExtractReader implements ReadLine {
|
||||
|
||||
if (charset == null) {
|
||||
Log.info("Using default charset");
|
||||
return new UncommentReadLine(new ReadLineReader(new FileReader(f)));
|
||||
return new UncommentReadLine(new ReadLineReader(new FileReader(f), f.getAbsolutePath()));
|
||||
}
|
||||
Log.info("Using charset " + charset);
|
||||
return new UncommentReadLine(new ReadLineReader(new InputStreamReader(new FileInputStream(f), charset)));
|
||||
return new UncommentReadLine(new ReadLineReader(new InputStreamReader(new FileInputStream(f), charset),
|
||||
f.getAbsolutePath()));
|
||||
}
|
||||
|
||||
private static ReadLine getReadLine(URL url, String charset) throws IOException {
|
||||
|
||||
if (charset == null) {
|
||||
Log.info("Using default charset");
|
||||
return new UncommentReadLine(new ReadLineReader(new InputStreamReader(url.openStream())));
|
||||
return new UncommentReadLine(new ReadLineReader(new InputStreamReader(url.openStream()), url.toString()));
|
||||
}
|
||||
Log.info("Using charset " + charset);
|
||||
return new UncommentReadLine(new ReadLineReader(new InputStreamReader(url.openStream(), charset)));
|
||||
return new UncommentReadLine(
|
||||
new ReadLineReader(new InputStreamReader(url.openStream(), charset), url.toString()));
|
||||
}
|
||||
|
||||
static public boolean containsStartDiagram(File f, String charset) throws IOException {
|
||||
@ -105,7 +108,7 @@ public class StartDiagramExtractReader implements ReadLine {
|
||||
|
||||
private static boolean containsStartDiagram(final ReadLine r) throws IOException {
|
||||
try {
|
||||
String s = null;
|
||||
CharSequence2 s = null;
|
||||
while ((s = r.readLine()) != null) {
|
||||
if (StartUtils.isArobaseStartDiagram(s)) {
|
||||
return true;
|
||||
@ -119,11 +122,11 @@ public class StartDiagramExtractReader implements ReadLine {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String readLine() throws IOException {
|
||||
public CharSequence2 readLine() throws IOException {
|
||||
if (finished) {
|
||||
return null;
|
||||
}
|
||||
final String result = raw.readLine();
|
||||
final CharSequence2 result = raw.readLine();
|
||||
if (result != null && StartUtils.isArobaseEndDiagram(result)) {
|
||||
finished = true;
|
||||
return null;
|
||||
|
@ -37,6 +37,8 @@ import java.io.IOException;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.sourceforge.plantuml.CharSequence2;
|
||||
import net.sourceforge.plantuml.CharSequence2Impl;
|
||||
import net.sourceforge.plantuml.command.regex.MyPattern;
|
||||
|
||||
public class UncommentReadLine implements ReadLine {
|
||||
@ -53,8 +55,8 @@ public class UncommentReadLine implements ReadLine {
|
||||
this.unpause = MyPattern.cmpile("(?i)((?:\\W|\\<[^<>]*\\>)*)@unpause");
|
||||
}
|
||||
|
||||
public String readLine() throws IOException {
|
||||
final String result = raw.readLine();
|
||||
public CharSequence2 readLine() throws IOException {
|
||||
final CharSequence2 result = raw.readLine();
|
||||
|
||||
if (result == null) {
|
||||
return null;
|
||||
@ -70,11 +72,11 @@ public class UncommentReadLine implements ReadLine {
|
||||
headerToRemove = m2.group(1);
|
||||
}
|
||||
}
|
||||
if (headerToRemove != null && headerToRemove.startsWith(result)) {
|
||||
return "";
|
||||
if (headerToRemove != null && headerToRemove.startsWith(result.toString2())) {
|
||||
return new CharSequence2Impl("", result.getLocation());
|
||||
}
|
||||
if (headerToRemove != null && result.startsWith(headerToRemove)) {
|
||||
return result.substring(headerToRemove.length());
|
||||
if (headerToRemove != null && result.toString2().startsWith(headerToRemove)) {
|
||||
return result.subSequence(headerToRemove.length(), result.length());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -36,9 +36,11 @@ package net.sourceforge.plantuml.sequencediagram.command;
|
||||
import java.util.ArrayList;
|
||||
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.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.CommandExecutionResult;
|
||||
import net.sourceforge.plantuml.command.CommandMultilines;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
@ -46,7 +48,6 @@ import net.sourceforge.plantuml.graphic.HtmlColor;
|
||||
import net.sourceforge.plantuml.sequencediagram.Participant;
|
||||
import net.sourceforge.plantuml.sequencediagram.Reference;
|
||||
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
|
||||
public class CommandReferenceMultilinesOverSeveral extends CommandMultilines<SequenceDiagram> {
|
||||
|
||||
@ -60,8 +61,8 @@ public class CommandReferenceMultilinesOverSeveral extends CommandMultilines<Seq
|
||||
return "(?i)^end[%s]?(ref)?$";
|
||||
}
|
||||
|
||||
public CommandExecutionResult execute(final SequenceDiagram diagram, List<String> lines) {
|
||||
final List<String> line0 = StringUtils.getSplit(getStartingPattern(), StringUtils.trin(lines.get(0)));
|
||||
public CommandExecutionResult execute(final SequenceDiagram diagram, BlocLines lines) {
|
||||
final List<String> line0 = StringUtils.getSplit(getStartingPattern(), StringUtils.trin(lines.getFirst499()));
|
||||
final HtmlColor backColorElement = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get(0));
|
||||
// final HtmlColor backColorGeneral = HtmlColorSet.getInstance().getColorIfValid(line0.get(1));
|
||||
|
||||
@ -71,7 +72,9 @@ public class CommandReferenceMultilinesOverSeveral extends CommandMultilines<Seq
|
||||
p.add(diagram.getOrCreateParticipant(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s)));
|
||||
}
|
||||
|
||||
Display strings = Display.create(lines.subList(1, lines.size() - 1)).removeEmptyColumns();
|
||||
lines = lines.subExtract(1, 1);
|
||||
lines = lines.removeEmptyColumns();
|
||||
Display strings = lines.toDisplay();
|
||||
|
||||
Url u = null;
|
||||
if (strings.size() > 0) {
|
||||
|
@ -105,11 +105,13 @@ public class Segment {
|
||||
result2.add(new Segment(pendingStart, this.pos2));
|
||||
return Collections.unmodifiableCollection(result2);
|
||||
}
|
||||
if (this.contains(d) == false) {
|
||||
throw new IllegalStateException();
|
||||
// if (this.contains(d) == false) {
|
||||
// throw new IllegalStateException();
|
||||
// }
|
||||
if (this.contains(d)) {
|
||||
result2.add(new Segment(pendingStart, d.pos1));
|
||||
pendingStart = d.pos2;
|
||||
}
|
||||
result2.add(new Segment(pendingStart, d.pos1));
|
||||
pendingStart = d.pos2;
|
||||
}
|
||||
result2.add(new Segment(pendingStart, this.pos2));
|
||||
return Collections.unmodifiableCollection(result2);
|
||||
|
@ -34,30 +34,32 @@
|
||||
package net.sourceforge.plantuml.suggest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.plantuml.AbstractPSystem;
|
||||
import net.sourceforge.plantuml.CharSequence2;
|
||||
import net.sourceforge.plantuml.CharSequence2Impl;
|
||||
import net.sourceforge.plantuml.StringUtils;
|
||||
import net.sourceforge.plantuml.command.BlocLines;
|
||||
import net.sourceforge.plantuml.command.CommandControl;
|
||||
import net.sourceforge.plantuml.command.UmlDiagramFactory;
|
||||
import net.sourceforge.plantuml.core.UmlSource;
|
||||
import net.sourceforge.plantuml.utils.StartUtils;
|
||||
import net.sourceforge.plantuml.version.IteratorCounter;
|
||||
import net.sourceforge.plantuml.version.IteratorCounterImpl;
|
||||
import net.sourceforge.plantuml.version.IteratorCounter2;
|
||||
import net.sourceforge.plantuml.version.IteratorCounter2Impl;
|
||||
|
||||
final public class SuggestEngine {
|
||||
|
||||
private final UmlDiagramFactory systemFactory;
|
||||
|
||||
private final IteratorCounter it;
|
||||
private final IteratorCounter2 it99;
|
||||
|
||||
public SuggestEngine(UmlSource source, UmlDiagramFactory systemFactory) {
|
||||
this.systemFactory = systemFactory;
|
||||
this.it = source.iterator();
|
||||
final String startLine = it.next();
|
||||
this.it99 = source.iterator2();
|
||||
final CharSequence startLine = it99.next();
|
||||
if (StartUtils.isArobaseStartDiagram(startLine) == false) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
@ -68,22 +70,22 @@ final public class SuggestEngine {
|
||||
}
|
||||
|
||||
private SuggestEngineResult executeUmlCommand(AbstractPSystem system) {
|
||||
while (it.hasNext()) {
|
||||
if (StartUtils.isArobaseEndDiagram(it.peek())) {
|
||||
while (it99.hasNext()) {
|
||||
if (StartUtils.isArobaseEndDiagram(it99.peek())) {
|
||||
return SuggestEngineResult.SYNTAX_OK;
|
||||
}
|
||||
final SuggestEngineResult check = checkAndCorrect();
|
||||
if (check.getStatus() != SuggestEngineStatus.SYNTAX_OK) {
|
||||
return check;
|
||||
}
|
||||
final CommandControl commandControl = systemFactory.isValid2(it);
|
||||
final CommandControl commandControl = systemFactory.isValid2(it99);
|
||||
if (commandControl == CommandControl.OK_PARTIAL) {
|
||||
systemFactory.goForwardMultiline(it);
|
||||
systemFactory.goForwardMultiline(it99);
|
||||
// if (ok == false) {
|
||||
// return SuggestEngineResult.CANNOT_CORRECT;
|
||||
// }
|
||||
} else if (commandControl == CommandControl.OK) {
|
||||
it.next();
|
||||
it99.next();
|
||||
// final Command cmd = new ProtectedCommand(systemFactory.createCommand(Arrays.asList(s)));
|
||||
// final CommandExecutionResult result = cmd.execute(system, Arrays.asList(s));
|
||||
// if (result.isOk() == false) {
|
||||
@ -96,40 +98,17 @@ final public class SuggestEngine {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
private boolean manageMultiline(final String init) {
|
||||
final List<String> lines = new ArrayList<String>();
|
||||
lines.add(init);
|
||||
while (it.hasNext()) {
|
||||
final String s = it.next();
|
||||
if (StartUtils.isArobaseEndDiagram(s)) {
|
||||
return false;
|
||||
}
|
||||
lines.add(s);
|
||||
final CommandControl commandControl = systemFactory.isValid(lines);
|
||||
if (commandControl == CommandControl.NOT_OK) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
if (commandControl == CommandControl.OK) {
|
||||
// final Command cmd = systemFactory.createCommand(lines);
|
||||
// return cmd.execute(lines).isOk();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
SuggestEngineResult checkAndCorrect() {
|
||||
final CommandControl commandControl = systemFactory.isValid2(it);
|
||||
final CommandControl commandControl = systemFactory.isValid2(it99);
|
||||
if (commandControl != CommandControl.NOT_OK) {
|
||||
return SuggestEngineResult.SYNTAX_OK;
|
||||
}
|
||||
|
||||
final String incorrectLine = it.peek();
|
||||
final String incorrectLine = it99.peek().toString();
|
||||
|
||||
if (StringUtils.trin(incorrectLine).startsWith("{")
|
||||
&& systemFactory.isValid(Arrays.asList(it.peekPrevious() + " {")) != CommandControl.NOT_OK) {
|
||||
return new SuggestEngineResult(it.peekPrevious() + " {");
|
||||
&& systemFactory.isValid(BlocLines.single(it99.peekPrevious() + " {")) != CommandControl.NOT_OK) {
|
||||
return new SuggestEngineResult(it99.peekPrevious() + " {");
|
||||
}
|
||||
|
||||
final Collection<Iterator<String>> all = new ArrayList<Iterator<String>>();
|
||||
@ -163,16 +142,16 @@ final public class SuggestEngine {
|
||||
return null;
|
||||
}
|
||||
|
||||
private IteratorCounter replaceFirstLine(String s) {
|
||||
final List<String> tmp = new ArrayList<String>();
|
||||
tmp.add(s);
|
||||
final Iterator<String> it3 = it.cloneMe();
|
||||
private IteratorCounter2 replaceFirstLine(String s) {
|
||||
final List<CharSequence2> tmp = new ArrayList<CharSequence2>();
|
||||
tmp.add(new CharSequence2Impl(s, null));
|
||||
final Iterator<? extends CharSequence> it3 = it99.cloneMe();
|
||||
if (it3.hasNext()) {
|
||||
it3.next();
|
||||
}
|
||||
while (it3.hasNext()) {
|
||||
tmp.add(it3.next());
|
||||
tmp.add(new CharSequence2Impl(it3.next(), null));
|
||||
}
|
||||
return new IteratorCounterImpl(tmp);
|
||||
return new IteratorCounter2Impl(tmp);
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@
|
||||
*/
|
||||
package net.sourceforge.plantuml.svek;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -41,6 +40,7 @@ import java.util.List;
|
||||
import net.sourceforge.plantuml.ColorParam;
|
||||
import net.sourceforge.plantuml.FontParam;
|
||||
import net.sourceforge.plantuml.ISkinParam;
|
||||
import net.sourceforge.plantuml.SkinParamUtils;
|
||||
import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
|
||||
import net.sourceforge.plantuml.cucadiagram.Display;
|
||||
import net.sourceforge.plantuml.cucadiagram.EntityUtils;
|
||||
@ -53,7 +53,6 @@ import net.sourceforge.plantuml.cucadiagram.LeafType;
|
||||
import net.sourceforge.plantuml.cucadiagram.Link;
|
||||
import net.sourceforge.plantuml.cucadiagram.Member;
|
||||
import net.sourceforge.plantuml.cucadiagram.MethodsOrFieldsArea;
|
||||
import net.sourceforge.plantuml.cucadiagram.Rankdir;
|
||||
import net.sourceforge.plantuml.cucadiagram.Stereotype;
|
||||
import net.sourceforge.plantuml.cucadiagram.dot.DotData;
|
||||
import net.sourceforge.plantuml.graphic.FontConfiguration;
|
||||
@ -110,8 +109,9 @@ public final class GroupPngMakerState {
|
||||
public IEntityImage getImage() {
|
||||
final Display display = group.getDisplay();
|
||||
final ISkinParam skinParam = diagram.getSkinParam();
|
||||
final HtmlColor textColor = SkinParamUtils.getFontColor(skinParam, FontParam.STATE, group.getStereotype());
|
||||
final TextBlock title = TextBlockUtils.create(display, new FontConfiguration(getFont(FontParam.STATE),
|
||||
HtmlColorUtils.BLACK, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()),
|
||||
textColor, skinParam.getHyperlinkColor(), skinParam.useUnderlineForHyperlink()),
|
||||
HorizontalAlignment.CENTER, diagram.getSkinParam());
|
||||
|
||||
if (group.size() == 0) {
|
||||
|
@ -43,6 +43,8 @@ import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
@ -59,6 +61,7 @@ import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollBar;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.ListModel;
|
||||
import javax.swing.WindowConstants;
|
||||
@ -73,11 +76,11 @@ import net.sourceforge.plantuml.version.PSystemVersion;
|
||||
|
||||
class ImageWindow2 extends JFrame {
|
||||
|
||||
final private static Preferences prefs = Preferences.userNodeForPackage(ImageWindow2.class);
|
||||
final private static String KEY_ZOOM_FIT = "zoomfit";
|
||||
private final static Preferences prefs = Preferences.userNodeForPackage(ImageWindow2.class);
|
||||
private final static String KEY_ZOOM_FIT = "zoomfit";
|
||||
|
||||
private SimpleLine2 simpleLine2;
|
||||
final private JScrollPane scrollPane;
|
||||
private final JScrollPane scrollPane;
|
||||
private final JButton next = new JButton("Next");
|
||||
private final JButton copy = new JButton("Copy");
|
||||
private final JButton previous = new JButton("Previous");
|
||||
@ -104,21 +107,25 @@ class ImageWindow2 extends JFrame {
|
||||
north.add(copy);
|
||||
north.add(next);
|
||||
north.add(zoomFitButt);
|
||||
copy.setFocusable(false);
|
||||
copy.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent ae) {
|
||||
copy();
|
||||
}
|
||||
});
|
||||
next.setFocusable(false);
|
||||
next.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent ae) {
|
||||
next();
|
||||
}
|
||||
});
|
||||
previous.setFocusable(false);
|
||||
previous.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent ae) {
|
||||
previous();
|
||||
}
|
||||
});
|
||||
zoomFitButt.setFocusable(false);
|
||||
zoomFitButt.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent ae) {
|
||||
zoomFit();
|
||||
@ -153,6 +160,34 @@ class ImageWindow2 extends JFrame {
|
||||
sizeMode = SizeMode.ZOOM_FIT;
|
||||
}
|
||||
|
||||
this.setFocusable(true);
|
||||
this.addKeyListener(new KeyAdapter() {
|
||||
public void keyPressed(KeyEvent evt) {
|
||||
if (evt.isControlDown() && evt.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||
next();
|
||||
} else if (evt.isControlDown() && evt.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||
previous();
|
||||
} else if (evt.isAltDown() && evt.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||
next();
|
||||
} else if (evt.isAltDown() && evt.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||
previous();
|
||||
} else if (evt.getKeyCode() == KeyEvent.VK_RIGHT) {
|
||||
imageRight();
|
||||
} else if (evt.getKeyCode() == KeyEvent.VK_LEFT) {
|
||||
imageLeft();
|
||||
} else if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
|
||||
imageDown();
|
||||
} else if (evt.getKeyCode() == KeyEvent.VK_UP) {
|
||||
imageUp();
|
||||
} else if (evt.getKeyCode() == KeyEvent.VK_C) {
|
||||
copy();
|
||||
} else if (evt.getKeyCode() == KeyEvent.VK_Z) {
|
||||
zoomFitButt.setSelected(!zoomFitButt.isSelected());
|
||||
zoomFit();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void next() {
|
||||
@ -165,6 +200,26 @@ class ImageWindow2 extends JFrame {
|
||||
updateSimpleLine();
|
||||
}
|
||||
|
||||
private void imageDown() {
|
||||
final JScrollBar bar = scrollPane.getVerticalScrollBar();
|
||||
bar.setValue(bar.getValue() + bar.getBlockIncrement());
|
||||
}
|
||||
|
||||
private void imageUp() {
|
||||
final JScrollBar bar = scrollPane.getVerticalScrollBar();
|
||||
bar.setValue(bar.getValue() - bar.getBlockIncrement());
|
||||
}
|
||||
|
||||
private void imageLeft() {
|
||||
final JScrollBar bar = scrollPane.getHorizontalScrollBar();
|
||||
bar.setValue(bar.getValue() - bar.getBlockIncrement());
|
||||
}
|
||||
|
||||
private void imageRight() {
|
||||
final JScrollBar bar = scrollPane.getHorizontalScrollBar();
|
||||
bar.setValue(bar.getValue() + bar.getBlockIncrement());
|
||||
}
|
||||
|
||||
private void zoomFit() {
|
||||
final boolean selected = zoomFitButt.isSelected();
|
||||
prefs.putBoolean(KEY_ZOOM_FIT, selected);
|
||||
|
@ -95,6 +95,7 @@ public class SyntaxChecker {
|
||||
result.setError(true);
|
||||
final PSystemError sys = (PSystemError) system;
|
||||
result.setErrorLinePosition(sys.getHigherErrorPosition());
|
||||
result.setLineLocation(sys.getLineLocation());
|
||||
for (ErrorUml er : sys.getErrorsUml()) {
|
||||
result.addErrorText(er.getError());
|
||||
}
|
||||
@ -128,6 +129,7 @@ public class SyntaxChecker {
|
||||
result.setError(true);
|
||||
final PSystemError sys = (PSystemError) system;
|
||||
result.setErrorLinePosition(sys.getHigherErrorPosition());
|
||||
result.setLineLocation(sys.getLineLocation());
|
||||
for (ErrorUml er : sys.getErrorsUml()) {
|
||||
result.addErrorText(er.getError());
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import net.sourceforge.plantuml.FileFormatOption;
|
||||
import net.sourceforge.plantuml.LineLocation;
|
||||
import net.sourceforge.plantuml.PSystemError;
|
||||
import net.sourceforge.plantuml.UmlDiagramType;
|
||||
|
||||
@ -54,6 +55,7 @@ public class SyntaxResult {
|
||||
private List<String> suggest;
|
||||
private boolean hasCmapData;
|
||||
private PSystemError systemError;
|
||||
private LineLocation lineLocation;
|
||||
|
||||
public UmlDiagramType getUmlDiagramType() {
|
||||
return umlDiagramType;
|
||||
@ -123,4 +125,12 @@ public class SyntaxResult {
|
||||
systemError.exportDiagram(os, 0, fileFormatOption);
|
||||
}
|
||||
|
||||
public void setLineLocation(LineLocation lineLocation) {
|
||||
this.lineLocation = lineLocation;
|
||||
}
|
||||
|
||||
public LineLocation getLineLocation() {
|
||||
return lineLocation;
|
||||
}
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user