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

version 1.2019.10

This commit is contained in:
Arnaud Roques 2019-09-14 20:12:04 +02:00
parent 0d43b32af2
commit 90372b993c
105 changed files with 1087 additions and 724 deletions

View File

@ -30,13 +30,12 @@
Script Author: Julien Eluard
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>1.2019.9-SNAPSHOT</version>
<version>1.2019.11-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PlantUML</name>
@ -125,6 +124,7 @@
<directory>${project.basedir}</directory>
<includes>
<include>stdlib/**/*.repx</include>
<include>skin/**/*.skin</include>
</includes>
</resource>
</resources>

View File

@ -21,8 +21,8 @@ title {
HorizontalAlignment center
FontSize 14
FontStyle bold
Padding 0
Margin 4
Padding 5
Margin 5
LineColor none
BackGroundColor none
}
@ -145,21 +145,26 @@ actor {
}
boundary {
LineThickness 2.0
}
control {
LineThickness 2.0
}
entity {
LineThickness 2.0
}
queue {
LineThickness 2.0
}
database {
}
collections {
LineThickness 1.5
}
swimlane {

View File

@ -44,7 +44,7 @@ public class AParentFolderRegular implements AParentFolder {
public AParentFolderRegular(File dir) {
this.dir = dir;
Log.info("Creating AParentFolderRegular " + dir);
// Log.info("Creating AParentFolderRegular " + dir);
}
@Override
@ -54,14 +54,14 @@ public class AParentFolderRegular implements AParentFolder {
public AFile getAFile(String nameOrPath) throws IOException {
final File filecurrent;
Log.info("AParentFolderRegular::looking for " + nameOrPath);
Log.info("AParentFolderRegular::dir = " + dir);
// Log.info("AParentFolderRegular::looking for " + nameOrPath);
// Log.info("AParentFolderRegular::dir = " + dir);
if (dir == null) {
filecurrent = new File(nameOrPath);
} else {
filecurrent = new File(dir.getAbsoluteFile(), nameOrPath);
}
Log.info("AParentFolderRegular::Filecurrent " + filecurrent);
// Log.info("AParentFolderRegular::Filecurrent " + filecurrent);
if (filecurrent.exists()) {
return new AFileRegular(filecurrent.getCanonicalFile());
}

View File

@ -82,6 +82,7 @@ public final class BlockUmlBuilder implements DefinitionsContainer {
includer.close();
usedFiles = includer.getFilesUsed();
}
reader.close();
}
}

View File

@ -42,10 +42,13 @@ import java.awt.geom.Dimension2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import net.sourceforge.plantuml.braille.BrailleCharFactory;
import net.sourceforge.plantuml.braille.UGraphicBraille;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.png.MetadataTag;
import net.sourceforge.plantuml.svg.SvgGraphics;
import net.sourceforge.plantuml.ugraphic.UFont;
/**
@ -202,4 +205,32 @@ public enum FileFormat {
return name.replaceAll("\\" + getFileSuffix() + "$",
OptionFlags.getInstance().getFileSeparator() + String.format("%03d", i) + getFileSuffix());
}
public boolean doesSupportMetadata() {
return this == PNG || this == SVG;
}
public boolean equalsMetadata(String currentMetadata, File existingFile) {
try {
if (this == PNG) {
final MetadataTag tag = new MetadataTag(existingFile, "plantuml");
final String previousMetadata = tag.getData();
final boolean sameMetadata = currentMetadata.equals(previousMetadata);
return sameMetadata;
}
if (this == SVG) {
final String svg = FileUtils.readSvg(existingFile);
final String currentSignature = SvgGraphics.getMD5Hex(currentMetadata);
final int idx = svg.lastIndexOf(SvgGraphics.MD5_HEADER);
if (idx != -1) {
final String part = svg.substring(idx + SvgGraphics.MD5_HEADER.length());
return part.startsWith(currentSignature);
}
}
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
}

View File

@ -97,16 +97,16 @@ public abstract class Log {
}
public static void println(Object s) {
if (header2.get() == null) {
System.err.println("L = " + s);
} else {
System.err.println(header2.get() + " " + s);
}
// if (header2.get() == null) {
// System.err.println("L = " + s);
// } else {
// System.err.println(header2.get() + " " + s);
// }
}
private static final ThreadLocal<String> header2 = new ThreadLocal<String>();
// private static final ThreadLocal<String> header2 = new ThreadLocal<String>();
//
public static void header(String s) {
header2.set(s);
// header2.set(s);
}
}

View File

@ -192,12 +192,13 @@ public class OptionPrint {
public static Collection<String> interestingProperties() {
final Properties p = System.getProperties();
final List<String> all = withIp() ? Arrays.asList("java.runtime.name", "Java Runtime", "java.vm.name", "JVM",
final List<String> list1 = Arrays.asList("java.runtime.name", "Java Runtime", "java.vm.name", "JVM",
"java.runtime.version", "Java Version", "os.name", "Operating System", "file.encoding",
"Default Encoding", "user.language", "Language", "user.country", "Country") : Arrays.asList(
"java.runtime.name", "Java Runtime", "java.vm.name", "JVM", "java.runtime.version", "Java Version",
"os.name", "Operating System", "os.version", "OS Version", "file.encoding", "Default Encoding",
"user.language", "Language", "user.country", "Country");
"Default Encoding", "user.language", "Language", "user.country", "Country");
final List<String> list2 = Arrays.asList("java.runtime.name", "Java Runtime", "java.vm.name", "JVM",
"java.runtime.version", "Java Version", "os.name", "Operating System", /* "os.version", "OS Version", */
"file.encoding", "Default Encoding", "user.language", "Language", "user.country", "Country");
final List<String> all = withIp() ? list1 : list2;
final List<String> result = new ArrayList<String>();
for (int i = 0; i < all.size(); i += 2) {
result.add(all.get(i + 1) + ": " + p.getProperty(all.get(i)));

View File

@ -145,14 +145,13 @@ public class PSystemBuilder {
final List<PSystemFactory> factories = new ArrayList<PSystemFactory>();
factories.add(new PSystemWelcomeFactory());
factories.add(new PSystemColorsFactory());
factories.add(new ListSpriteDiagramFactory(skinParam));
factories.add(new SequenceDiagramFactory(skinParam));
factories.add(new ClassDiagramFactory(skinParam));
factories.add(new ActivityDiagramFactory(skinParam));
factories.add(new DescriptionDiagramFactory(skinParam));
factories.add(new StateDiagramFactory(skinParam));
factories.add(new ActivityDiagramFactory3(skinParam));
factories.add(new CompositeDiagramFactory(skinParam));
// factories.add(new CompositeDiagramFactory(skinParam));
factories.add(new BpmDiagramFactory(DiagramType.BPM));
// factories.add(new PostIdDiagramFactory());
factories.add(new PSystemLicenseFactory());
@ -179,6 +178,7 @@ public class PSystemBuilder {
factories.add(new PSystemSudokuFactory());
}
factories.add(new PSystemDefinitionFactory());
factories.add(new ListSpriteDiagramFactory(skinParam));
factories.add(new PSystemMathFactory(DiagramType.MATH));
factories.add(new PSystemLatexFactory(DiagramType.LATEX));
// factories.add(new PSystemStatsFactory());

View File

@ -51,7 +51,6 @@ import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.html.CucaDiagramHtmlMaker;
import net.sourceforge.plantuml.png.MetadataTag;
import net.sourceforge.plantuml.png.PngSplitter;
import net.sourceforge.plantuml.project3.GanttDiagram;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
@ -66,19 +65,19 @@ public class PSystemUtils {
public static List<FileImageData> exportDiagrams(Diagram system, SuggestedFile suggestedFile,
FileFormatOption fileFormatOption, boolean checkMetadata) throws IOException {
final File existing = suggestedFile.getFile(0);
if (checkMetadata && existing.exists() && system.getNbImages() == 1) {
final MetadataTag tag = new MetadataTag(existing, "plantuml");
final String previousMetadata = tag.getData();
final File existingFile = suggestedFile.getFile(0);
if (checkMetadata && fileFormatOption.getFileFormat().doesSupportMetadata() && existingFile.exists()
&& system.getNbImages() == 1) {
// final String version = Version.versionString();
// System.out.println(system.getMetadata());
// System.out.println(data);
// System.out.println(version);
// System.out.println(data.contains(version));
final boolean sameMetadata = system.getMetadata().equals(previousMetadata);
final boolean sameMetadata = fileFormatOption.getFileFormat().equalsMetadata(system.getMetadata(),
existingFile);
if (sameMetadata) {
Log.info("Skipping " + existing.getAbsolutePath() + " because metadata has not changed.");
return Arrays.asList(new FileImageData(existing, null));
Log.info("Skipping " + existingFile.getAbsolutePath() + " because metadata has not changed.");
return Arrays.asList(new FileImageData(existingFile, null));
}
}

View File

@ -100,11 +100,13 @@ public class Pipe {
} else if (option.isPipeMap()) {
final String result = sourceStringReader.getCMapData(option.getImageIndex(),
option.getFileFormatOption());
// https://forum.plantuml.net/10049/2019-pipemap-diagrams-containing-links-give-zero-exit-code
// We don't check errors
error.goOk();
if (result == null) {
ps.println();
} else {
ps.println(result);
error.goOk();
}
} else {
final OutputStream os = noStdErr ? new ByteArrayOutputStream() : ps;

View File

@ -58,7 +58,8 @@ public class SignatureUtils {
// return SignatureUtils.getSHA512raw(tmp);
// }
public static byte[] salting(String pass, byte[] salt) throws NoSuchAlgorithmException, InvalidKeySpecException {
public static synchronized byte[] salting(String pass, byte[] salt) throws NoSuchAlgorithmException,
InvalidKeySpecException {
final int iterations = 500;
final int keyLength = 512;
final SecretKeyFactory skf = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
@ -122,7 +123,7 @@ public class SignatureUtils {
}
}
public static byte[] getMD5raw(String s) throws NoSuchAlgorithmException, UnsupportedEncodingException {
public static synchronized byte[] getMD5raw(String s) throws NoSuchAlgorithmException, UnsupportedEncodingException {
final MessageDigest msgDigest = MessageDigest.getInstance("MD5");
msgDigest.update(s.getBytes("UTF-8"));
return msgDigest.digest();
@ -132,7 +133,8 @@ public class SignatureUtils {
return getSHA512raw(s.getBytes("UTF-8"));
}
public static byte[] getSHA512raw(byte data[]) throws NoSuchAlgorithmException, UnsupportedEncodingException {
public static synchronized byte[] getSHA512raw(byte data[]) throws NoSuchAlgorithmException,
UnsupportedEncodingException {
final MessageDigest msgDigest = MessageDigest.getInstance("SHA-512");
msgDigest.update(data);
return msgDigest.digest();
@ -147,7 +149,7 @@ public class SignatureUtils {
}
}
public static String getSignatureSha512(InputStream is) throws IOException {
public static synchronized String getSignatureSha512(InputStream is) throws IOException {
try {
final MessageDigest msgDigest = MessageDigest.getInstance("SHA-512");
int read = 0;
@ -178,7 +180,7 @@ public class SignatureUtils {
return s;
}
public static String getSignature(File f) throws IOException {
public static synchronized String getSignature(File f) throws IOException {
try {
final MessageDigest msgDigest = MessageDigest.getInstance("MD5");
final FileInputStream is = new FileInputStream(f);

View File

@ -97,11 +97,11 @@ public class SkinParam implements ISkinParam {
USE_STYLE2.set(true);
}
// if (type == UmlDiagramType.SEQUENCE) {
// skin = "debug.skin";
// // skin = "debug.skin";
// USE_STYLE2.set(true);
// }
// if (type == UmlDiagramType.ACTIVITY) {
// skin = "debug.skin";
// // skin = "debug.skin";
// USE_STYLE2.set(true);
// }
}
@ -177,8 +177,7 @@ public class SkinParam implements ISkinParam {
}
if (USE_STYLES()) {
final FromSkinparamToStyle convertor = new FromSkinparamToStyle(key2, value, getCurrentStyleBuilder());
final Style style = convertor.getStyle();
if (style != null) {
for (Style style : convertor.getStyles()) {
muteStyle(style);
}
}

View File

@ -37,6 +37,7 @@ package net.sourceforge.plantuml;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.util.Collections;
import java.util.List;
@ -83,7 +84,8 @@ public class SourceFileReader extends SourceFileReaderAbstract implements ISourc
}
this.outputDirectory = outputDirectory;
builder = new BlockUmlBuilder(config, charset, defines, getReader(charset), file.getAbsoluteFile()
final Reader reader = getReader(charset);
builder = new BlockUmlBuilder(config, charset, defines, reader, file.getAbsoluteFile()
.getParentFile(), FileWithSuffix.getFileName(file));
}

View File

@ -147,6 +147,7 @@ public abstract class SourceFileReaderAbstract {
try {
system = blockUml.getDiagram();
} catch (Throwable t) {
t.printStackTrace();
return getCrashedImage(blockUml, t, suggested.getFile(0));
}

View File

@ -37,7 +37,6 @@ package net.sourceforge.plantuml;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.preproc.Defines;

View File

@ -52,6 +52,10 @@ final public class StringLocated {
return s;
}
public StringLocated append(String endOfLine) {
return new StringLocated(s + endOfLine, location, preprocessorError);
}
public StringLocated(String s, LineLocation location, String preprocessorError) {
if (s == null) {
throw new IllegalArgumentException();
@ -131,4 +135,5 @@ final public class StringLocated {
}
return fox;
}
}

View File

@ -46,7 +46,6 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.List;
@ -60,7 +59,6 @@ import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.command.BlocLines;
import net.sourceforge.plantuml.command.CommandControl;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.CommandSkinParam;
import net.sourceforge.plantuml.command.CommandSkinParamMultilines;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.ImageData;

View File

@ -80,6 +80,7 @@ public class PSystemXearth extends AbstractPSystem {
@Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat, long seed)
throws IOException {
synchronized (PSystemXearth.class) {
final ACearth earth = new ACearth(markers);
final ConfigurationACearth conf = earth.getConf();
conf.setInt("imageWidth", width);
@ -106,6 +107,7 @@ public class PSystemXearth extends AbstractPSystem {
earth.exportPng(os);
return new ImageDataSimple(width, height);
}
}
private Date extractGmt(String s) {
final SimpleDateFormat timeFormat;

View File

@ -46,6 +46,9 @@ public class ConditionalContext {
private final ConditionalContext parent;
public ConditionalContext(ConditionalContext parent, IEntity branch, Direction direction) {
if (branch == null) {
throw new IllegalArgumentException("branch is null");
}
if (branch.getLeafType() != LeafType.BRANCH) {
throw new IllegalArgumentException();
}

View File

@ -80,7 +80,6 @@ public class ActivityDiagram3 extends UmlDiagram {
super(skinParam);
}
private void manageSwimlaneStrategy() {
if (swimlaneStrategy == null) {
swimlaneStrategy = SwimlaneStrategy.SWIMLANE_FORBIDDEN;
@ -123,8 +122,8 @@ public class ActivityDiagram3 extends UmlDiagram {
}
}
public void addSpot(String spot) {
final InstructionSpot ins = new InstructionSpot(spot, nextLinkRenderer(), swinlanes.getCurrentSwimlane());
public void addSpot(String spot, HtmlColor color) {
final InstructionSpot ins = new InstructionSpot(spot, color, nextLinkRenderer(), swinlanes.getCurrentSwimlane());
current().add(ins);
setNextLinkRendererInternal(LinkRendering.none());
manageSwimlaneStrategy();
@ -238,7 +237,9 @@ public class ActivityDiagram3 extends UmlDiagram {
}
public void fork() {
final InstructionFork instructionFork = new InstructionFork(current(), nextLinkRenderer(), getSkinParam());
manageSwimlaneStrategy();
final InstructionFork instructionFork = new InstructionFork(current(), nextLinkRenderer(), getSkinParam(),
swinlanes.getCurrentSwimlane());
current().add(instructionFork);
setNextLinkRendererInternal(LinkRendering.none());
setCurrent(instructionFork);
@ -249,7 +250,7 @@ public class ActivityDiagram3 extends UmlDiagram {
final InstructionFork currentFork = (InstructionFork) current();
currentFork.manageOutRendering(nextLinkRenderer(), false);
setNextLinkRendererInternal(LinkRendering.none());
currentFork.forkAgain();
currentFork.forkAgain(swinlanes.getCurrentSwimlane());
return CommandExecutionResult.ok();
}
return CommandExecutionResult.error("Cannot find fork");
@ -258,7 +259,7 @@ public class ActivityDiagram3 extends UmlDiagram {
public CommandExecutionResult endFork(ForkStyle forkStyle, String label) {
if (current() instanceof InstructionFork) {
final InstructionFork currentFork = (InstructionFork) current();
currentFork.setStyle(forkStyle, label);
currentFork.setStyle(forkStyle, label, swinlanes.getCurrentSwimlane());
currentFork.manageOutRendering(nextLinkRenderer(), true);
setNextLinkRendererInternal(LinkRendering.none());
setCurrent(currentFork.getParent());
@ -268,7 +269,8 @@ public class ActivityDiagram3 extends UmlDiagram {
}
public void split() {
final InstructionSplit instructionSplit = new InstructionSplit(current(), nextLinkRenderer(), swinlanes.getCurrentSwimlane());
final InstructionSplit instructionSplit = new InstructionSplit(current(), nextLinkRenderer(),
swinlanes.getCurrentSwimlane());
setNextLinkRendererInternal(LinkRendering.none());
current().add(instructionSplit);
setCurrent(instructionSplit);
@ -295,8 +297,8 @@ public class ActivityDiagram3 extends UmlDiagram {
public void startSwitch(Display test, HtmlColor color) {
manageSwimlaneStrategy();
final InstructionSwitch instructionSwitch = new InstructionSwitch(swinlanes.getCurrentSwimlane(), current(), test,
nextLinkRenderer(), color, getSkinParam());
final InstructionSwitch instructionSwitch = new InstructionSwitch(swinlanes.getCurrentSwimlane(), current(),
test, nextLinkRenderer(), color, getSkinParam());
current().add(instructionSwitch);
setNextLinkRendererInternal(LinkRendering.none());
setCurrent(instructionSwitch);

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.activitydiagram3;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -55,6 +56,8 @@ public class InstructionFork extends WithNote implements Instruction {
private final Instruction parent;
private final LinkRendering inlinkRendering;
private final ISkinParam skinParam;
private final Swimlane swimlaneIn;
private Swimlane swimlaneOut;
private ForkStyle style = ForkStyle.FORK;
private String label;
boolean finished = false;
@ -68,10 +71,12 @@ public class InstructionFork extends WithNote implements Instruction {
return false;
}
public InstructionFork(Instruction parent, LinkRendering inlinkRendering, ISkinParam skinParam) {
public InstructionFork(Instruction parent, LinkRendering inlinkRendering, ISkinParam skinParam, Swimlane swimlane) {
this.parent = parent;
this.inlinkRendering = inlinkRendering;
this.skinParam = skinParam;
this.swimlaneIn = swimlane;
this.swimlaneOut = swimlane;
this.forks.add(new InstructionList());
if (inlinkRendering == null) {
throw new IllegalArgumentException();
@ -91,7 +96,7 @@ public class InstructionFork extends WithNote implements Instruction {
for (InstructionList list : forks) {
all.add(list.createFtile(factory));
}
Ftile result = factory.createParallel(all, style, label);
Ftile result = factory.createParallel(all, style, label, swimlaneIn, swimlaneOut);
if (getPositionedNotes().size() > 0) {
result = FtileWithNoteOpale.create(result, getPositionedNotes(), skinParam, false);
}
@ -102,7 +107,8 @@ public class InstructionFork extends WithNote implements Instruction {
return parent;
}
public void forkAgain() {
public void forkAgain(Swimlane swimlane) {
this.swimlaneOut = swimlane;
this.forks.add(new InstructionList());
}
@ -126,17 +132,18 @@ public class InstructionFork extends WithNote implements Instruction {
}
public Set<Swimlane> getSwimlanes() {
return InstructionList.getSwimlanes2(forks);
final Set<Swimlane> result = new HashSet<Swimlane>(InstructionList.getSwimlanes2(forks));
result.add(swimlaneIn);
result.add(swimlaneOut);
return result;
}
public Swimlane getSwimlaneIn() {
// return parent.getSwimlaneOut();
return forks.get(0).getSwimlaneIn();
return swimlaneIn;
}
public Swimlane getSwimlaneOut() {
return forks.get(0).getSwimlaneOut();
// return getLastList().getSwimlaneOut();
return swimlaneOut;
}
public void manageOutRendering(LinkRendering nextLinkRenderer, boolean endFork) {
@ -149,9 +156,10 @@ public class InstructionFork extends WithNote implements Instruction {
getLastList().setOutRendering(nextLinkRenderer);
}
public void setStyle(ForkStyle style, String label) {
public void setStyle(ForkStyle style, String label, Swimlane swimlane) {
this.style = style;
this.label = label;
this.swimlaneOut = swimlane;
}
}

View File

@ -88,7 +88,7 @@ public class InstructionSplit implements Instruction {
for (InstructionList list : splits) {
all.add(list.createFtile(factory));
}
return factory.createParallel(all, ForkStyle.SPLIT, null);
return factory.createParallel(all, ForkStyle.SPLIT, null, swimlaneIn, swimlaneOut);
}
public Instruction getParent() {

View File

@ -39,28 +39,31 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileKilled;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.graphic.HtmlColor;
public class InstructionSpot extends MonoSwimable implements Instruction {
private boolean killed = false;
private final LinkRendering inlinkRendering;
private final String spot;
private final HtmlColor color;
public boolean containsBreak() {
return false;
}
public InstructionSpot(String spot, LinkRendering inlinkRendering, Swimlane swimlane) {
public InstructionSpot(String spot, HtmlColor color, LinkRendering inlinkRendering, Swimlane swimlane) {
super(swimlane);
this.spot = spot;
this.inlinkRendering = inlinkRendering;
this.color = color;
if (inlinkRendering == null) {
throw new IllegalArgumentException();
}
}
public Ftile createFtile(FtileFactory factory) {
Ftile result = factory.spot(getSwimlaneIn(), spot);
Ftile result = factory.spot(getSwimlaneIn(), spot, color);
result = eventuallyAddNote(factory, result, result.getSwimlaneIn());
if (killed) {
return new FtileKilled(result);

View File

@ -56,7 +56,7 @@ import net.sourceforge.plantuml.graphic.color.Colors;
public class CommandActivity3 extends SingleLineCommand2<ActivityDiagram3> {
public static final String ENDING_GROUP = "(;|\\\\\\\\|(?<![/|<>}\\]])(?:[/<}\\]])|(?<!\\</?\\w{1,5})(?<!\\<img[^>]{1,999})(?<!\\<\\$\\w{1,999})(?<!\\>)(?:\\>)|(?<!\\|.{1,999})(?:\\|))";
public static final String ENDING_GROUP = "(;|\\\\\\\\|(?<![/|<>}\\]])(?:[/<}\\]])|(?<!\\</?\\w{1,5})(?<!\\<img[^>]{1,999})(?<!\\<[&$]\\w{1,999})(?<!\\>)(?:\\>)|(?<!\\|.{1,999})(?:\\|))";
public CommandActivity3() {
super(getRegexConcat());

View File

@ -43,6 +43,8 @@ import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.color.ColorParser;
public class CommandCircleSpot3 extends SingleLineCommand2<ActivityDiagram3> {
@ -52,6 +54,7 @@ public class CommandCircleSpot3 extends SingleLineCommand2<ActivityDiagram3> {
static IRegex getRegexConcat() {
return RegexConcat.build(CommandCircleSpot3.class.getName(), RegexLeaf.start(), //
ColorParser.exp4(), //
new RegexLeaf("SPOT", "\\((\\S)\\)"), //
new RegexLeaf(";?"), //
RegexLeaf.end());
@ -59,7 +62,8 @@ public class CommandCircleSpot3 extends SingleLineCommand2<ActivityDiagram3> {
@Override
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, LineLocation location, RegexResult arg) {
diagram.addSpot(arg.get("SPOT", 0));
final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("COLOR", 0));
diagram.addSpot(arg.get("SPOT", 0), color);
return CommandExecutionResult.ok();
}

View File

@ -63,7 +63,7 @@ public interface FtileFactory {
public Ftile end(Swimlane swimlane);
public Ftile spot(Swimlane swimlane, String spot);
public Ftile spot(Swimlane swimlane, String spot, HtmlColor color);
public Ftile activity(Display label, Swimlane swimlane, BoxStyle style, Colors colors);
@ -90,7 +90,7 @@ public interface FtileFactory {
public Ftile createSwitch(Swimlane swimlane, List<Branch> branches, LinkRendering afterEndwhile,
LinkRendering topInlinkRendering, Display labelTest);
public Ftile createParallel(List<Ftile> all, ForkStyle style, String label);
public Ftile createParallel(List<Ftile> all, ForkStyle style, String label, Swimlane in, Swimlane out);
public Ftile createGroup(Ftile list, Display name, HtmlColor backColor, HtmlColor titleColor, PositionedNote note,
HtmlColor borderColor, USymbol type, double roundCorner);

View File

@ -145,8 +145,8 @@ public class FtileFactoryDelegator implements FtileFactory {
return factory.stop(swimlane);
}
public Ftile spot(Swimlane swimlane, String spot) {
return factory.spot(swimlane, spot);
public Ftile spot(Swimlane swimlane, String spot, HtmlColor color) {
return factory.spot(swimlane, spot, color);
}
public Ftile activity(Display label, Swimlane swimlane, BoxStyle style, Colors colors) {
@ -201,8 +201,8 @@ public class FtileFactoryDelegator implements FtileFactory {
return factory.createSwitch(swimlane, branches, afterEndwhile, topInlinkRendering, labelTest);
}
public Ftile createParallel(List<Ftile> all, ForkStyle style, String label) {
return factory.createParallel(all, style, label);
public Ftile createParallel(List<Ftile> all, ForkStyle style, String label, Swimlane in, Swimlane out) {
return factory.createParallel(all, style, label, in, out);
}
public Ftile createGroup(Ftile list, Display name, HtmlColor backColor, HtmlColor titleColor, PositionedNote note,

View File

@ -140,7 +140,7 @@ public abstract class AbstractParallelFtilesBuilder {
return middleDimension.getHeight();
}
protected final Swimlane swimlaneOutForStep2() {
protected Swimlane swimlaneOutForStep2() {
return list.get(list.size() - 1).getSwimlaneOut();
}

View File

@ -61,16 +61,17 @@ public class FtileFactoryDelegatorCreateParallel extends FtileFactoryDelegator {
}
@Override
public Ftile createParallel(List<Ftile> all, ForkStyle style, String label) {
public Ftile createParallel(List<Ftile> all, ForkStyle style, String label, Swimlane in, Swimlane out) {
final Dimension2D dimSuper = super.createParallel(all, style, label).calculateDimension(getStringBounder());
final Dimension2D dimSuper = super.createParallel(all, style, label, in, out).calculateDimension(
getStringBounder());
final double height1 = dimSuper.getHeight() + 2 * spaceArroundBlackBar;
final List<Ftile> list = new ArrayList<Ftile>();
for (Ftile tmp : all) {
list.add(new FtileHeightFixed(FtileUtils.addHorizontalMargin(tmp, xMargin), height1));
}
final Ftile inner = super.createParallel(list, style, label);
final Ftile inner = super.createParallel(list, style, label, in, out);
AbstractParallelFtilesBuilder builder;
@ -79,7 +80,7 @@ public class FtileFactoryDelegatorCreateParallel extends FtileFactoryDelegator {
} else if (style == ForkStyle.MERGE) {
builder = new ParallelBuilderMerge(skinParam(), getStringBounder(), list, inner);
} else if (style == ForkStyle.FORK) {
builder = new ParallelBuilderFork(skinParam(), getStringBounder(), list, inner, label);
builder = new ParallelBuilderFork(skinParam(), getStringBounder(), list, inner, label, in, out);
} else {
throw new IllegalStateException();
}

View File

@ -45,6 +45,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactoryDelegator;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileHeightFixed;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileUtils;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
public class FtileFactoryDelegatorCreateParallelAddingMargin extends FtileFactoryDelegator {
@ -56,16 +57,17 @@ public class FtileFactoryDelegatorCreateParallelAddingMargin extends FtileFactor
}
@Override
public Ftile createParallel(List<Ftile> all, ForkStyle style, String label) {
public Ftile createParallel(List<Ftile> all, ForkStyle style, String label, Swimlane in, Swimlane out) {
final Dimension2D dimSuper = super.createParallel(all, style, label).calculateDimension(getStringBounder());
final Dimension2D dimSuper = super.createParallel(all, style, label, in, out).calculateDimension(
getStringBounder());
final double height1 = dimSuper.getHeight() + 2 * spaceArroundBlackBar;
final List<Ftile> list = new ArrayList<Ftile>();
for (Ftile tmp : all) {
list.add(new FtileHeightFixed(FtileUtils.addHorizontalMargin(tmp, xMargin), height1));
}
return super.createParallel(list, style, label);
return super.createParallel(list, style, label, in, out);
}
}

View File

@ -125,7 +125,7 @@ class FtileRepeat extends AbstractFtile {
final TextBlock outTb = out.create(fcArrow, HorizontalAlignment.LEFT, spriteContainer);
final Ftile diamond1;
assert swimlane == repeat.getSwimlaneIn();
// assert swimlane == repeat.getSwimlaneIn();
if (backStart == null) {
diamond1 = new FtileDiamond(repeat.skinParam(), backColor, borderColor, repeat.getSwimlaneIn());
} else {

View File

@ -64,19 +64,29 @@ import net.sourceforge.plantuml.ugraphic.UTranslate;
public class ParallelBuilderFork extends AbstractParallelFtilesBuilder {
private final String label;
private final Swimlane in;
private final Swimlane out;
public ParallelBuilderFork(ISkinParam skinParam, StringBounder stringBounder, final List<Ftile> list, Ftile inner,
String label) {
String label, Swimlane in, Swimlane out) {
super(skinParam, stringBounder, list, inner);
this.label = label;
this.in = in;
this.out = out;
}
@Override
protected Swimlane swimlaneOutForStep2() {
return out;
}
@Override
protected Ftile doStep1() {
Ftile result = getMiddle();
final List<Connection> conns = new ArrayList<Connection>();
final Swimlane swimlaneBlack = in;
final Ftile black = new FtileBlackBlock(skinParam(), getRose()
.getHtmlColor(skinParam(), ColorParam.activityBar), getList().get(0).getSwimlaneIn());
.getHtmlColor(skinParam(), ColorParam.activityBar), swimlaneBlack);
double x = 0;
for (Ftile tmp : getList()) {
final Dimension2D dim = tmp.calculateDimension(getStringBounder());
@ -101,8 +111,9 @@ public class ParallelBuilderFork extends AbstractParallelFtilesBuilder {
@Override
protected Ftile doStep2(Ftile result) {
final Swimlane swimlaneBlack = out;
final Ftile out = new FtileBlackBlock(skinParam(), getRose().getHtmlColor(skinParam(), ColorParam.activityBar),
getList().get(0).getSwimlaneIn());
swimlaneBlack);
((FtileBlackBlock) out).setBlackBlockDimension(result.calculateDimension(getStringBounder()).getWidth(),
barHeight);
if (label != null) {

View File

@ -121,10 +121,10 @@ public class VCompactFactory implements FtileFactory {
return new FtileCircleStop(skinParam(), color, swimlane, style);
}
public Ftile spot(Swimlane swimlane, String spot) {
public Ftile spot(Swimlane swimlane, String spot, HtmlColor color) {
// final HtmlColor color = rose.getHtmlColor(skinParam, ColorParam.activityBackground);
final UFont font = skinParam.getFont(null, false, FontParam.ACTIVITY);
return new FtileCircleSpot(skinParam(), swimlane, spot, font);
return new FtileCircleSpot(skinParam(), swimlane, spot, font, color);
}
public Ftile end(Swimlane swimlane) {
@ -189,7 +189,7 @@ public class VCompactFactory implements FtileFactory {
return new FtileForkInner(ftiles);
}
public Ftile createParallel(List<Ftile> all, ForkStyle style, String label) {
public Ftile createParallel(List<Ftile> all, ForkStyle style, String label, Swimlane in, Swimlane out) {
return new FtileForkInner(all);
}

View File

@ -65,12 +65,13 @@ public class FtileCircleSpot extends AbstractFtile {
private final Swimlane swimlane;
private final String spot;
private final FontConfiguration fc;
private final HtmlColor backColor;
public FtileCircleSpot(ISkinParam skinParam, Swimlane swimlane, String spot, UFont font) {
public FtileCircleSpot(ISkinParam skinParam, Swimlane swimlane, String spot, UFont font, HtmlColor backColor) {
super(skinParam);
this.spot = spot;
this.swimlane = swimlane;
// this.font = font;
this.backColor = backColor;
this.fc = new FontConfiguration(skinParam, FontParam.ACTIVITY, null);
}
@ -97,7 +98,8 @@ public class FtileCircleSpot extends AbstractFtile {
public void drawU(UGraphic ug) {
final HtmlColor borderColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBorder);
final HtmlColor backColor = SkinParamUtils.getColor(skinParam(), null, ColorParam.activityBackground);
final HtmlColor backColor = this.backColor == null ? SkinParamUtils.getColor(skinParam(), null,
ColorParam.activityBackground) : this.backColor;
final UEllipse circle = new UEllipse(SIZE, SIZE);
if (skinParam().shadowing(null)) {

View File

@ -96,7 +96,7 @@ public class BpmDiagram extends UmlDiagram {
cleanGrid(grid);
final GridArray gridArray = grid.toArray(SkinParam.create(getUmlDiagramType()));
// gridArray.addEdges(edges);
System.err.println("gridArray=" + gridArray);
// System.err.println("gridArray=" + gridArray);
return gridArray;
}

View File

@ -39,7 +39,7 @@ package net.sourceforge.plantuml.bpm;
public class CleanerMoveBlock implements GridCleaner {
public boolean clean(Grid grid) {
System.err.println("CleanerMoveBlock");
// System.err.println("CleanerMoveBlock");
for (Line line : grid.lines().toList()) {
tryGrid(grid, line);
}
@ -89,6 +89,6 @@ public class CleanerMoveBlock implements GridCleaner {
}
private void tryBridge(Line line, Col col1, final Col col2) {
System.err.println("LINE=" + line + " " + col1 + " " + col2 + " ");
// System.err.println("LINE=" + line + " " + col1 + " " + col2 + " ");
}
}

View File

@ -60,6 +60,7 @@ import net.sourceforge.plantuml.command.Command;
import net.sourceforge.plantuml.command.CommandEndPackage;
import net.sourceforge.plantuml.command.CommandFootboxIgnored;
import net.sourceforge.plantuml.command.CommandNamespace;
import net.sourceforge.plantuml.command.CommandNamespace2;
import net.sourceforge.plantuml.command.CommandPackage;
import net.sourceforge.plantuml.command.CommandPackageEmpty;
import net.sourceforge.plantuml.command.CommandPage;
@ -123,6 +124,7 @@ public class ClassDiagramFactory extends UmlDiagramFactory {
cmds.add(factoryNoteCommand.createSingleLine());
cmds.add(new CommandNamespace());
cmds.add(new CommandNamespace2());
cmds.add(new CommandStereotype());
cmds.add(new CommandLinkClass(UmlDiagramType.CLASS));

View File

@ -35,9 +35,6 @@
*/
package net.sourceforge.plantuml.classdiagram.command;
import java.util.EnumSet;
import java.util.Set;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagram;
@ -61,17 +58,14 @@ import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
private static final EnumSet<EntityPortion> PORTION_METHOD = EnumSet.<EntityPortion> of(EntityPortion.METHOD);
private static final EnumSet<EntityPortion> PORTION_MEMBER = EnumSet.<EntityPortion> of(EntityPortion.FIELD,
EntityPortion.METHOD);
private static final EnumSet<EntityPortion> PORTION_FIELD = EnumSet.<EntityPortion> of(EntityPortion.FIELD);
public CommandHideShowByGender() {
super(getRegexConcat());
}
static IRegex getRegexConcat() {
return RegexConcat.build(CommandHideShowByGender.class.getName(), RegexLeaf.start(), //
return RegexConcat
.build(CommandHideShowByGender.class.getName(),
RegexLeaf.start(), //
new RegexLeaf("COMMAND", "(hide|show)"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("GENDER",
@ -81,18 +75,19 @@ public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
new RegexLeaf("EMPTY", "(empty)"), //
RegexLeaf.spaceOneOrMore()) //
), //
new RegexLeaf("PORTION", "(members?|attributes?|fields?|methods?|circles?|circled?|stereotypes?)"), //
new RegexLeaf("PORTION",
"(members?|attributes?|fields?|methods?|circles?|circled?|stereotypes?)"), //
RegexLeaf.end());
}
private final EntityGender emptyByGender(Set<EntityPortion> portion) {
if (portion == PORTION_METHOD) {
private final EntityGender emptyByGender(EntityPortion portion) {
if (portion == EntityPortion.METHOD) {
return EntityGenderUtils.emptyMethods();
}
if (portion == PORTION_FIELD) {
if (portion == EntityPortion.FIELD) {
return EntityGenderUtils.emptyFields();
}
if (portion == PORTION_MEMBER) {
if (portion == EntityPortion.MEMBER) {
throw new IllegalArgumentException();
// return EntityGenderUtils.emptyMembers();
}
@ -115,13 +110,13 @@ public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
}
private CommandExecutionResult executeSequenceDiagram(SequenceDiagram diagram, RegexResult arg) {
final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION", 0));
diagram.hideOrShow(portion, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
final EntityPortion portion = getEntityPortion(arg.get("PORTION", 0));
diagram.hideOrShow(portion.asSet(), arg.get("COMMAND", 0).equalsIgnoreCase("show"));
return CommandExecutionResult.ok();
}
private CommandExecutionResult executeDescriptionDiagram(DescriptionDiagram diagram, RegexResult arg) {
final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION", 0));
final EntityPortion portion = getEntityPortion(arg.get("PORTION", 0));
final EntityGender gender;
final String arg1 = arg.get("GENDER", 0);
if (arg1 == null) {
@ -151,7 +146,7 @@ public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
private CommandExecutionResult executeClassDiagram(AbstractClassOrObjectDiagram classDiagram, RegexResult arg) {
final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION", 0));
final EntityPortion portion = getEntityPortion(arg.get("PORTION", 0));
EntityGender gender = null;
final String arg1 = arg.get("GENDER", 0);
@ -177,7 +172,7 @@ public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
}
if (gender != null) {
final boolean empty = arg.get("EMPTY", 0) != null;
final boolean emptyMembers = empty && portion == PORTION_MEMBER;
final boolean emptyMembers = empty && portion == EntityPortion.MEMBER;
if (empty == true && emptyMembers == false) {
gender = EntityGenderUtils.and(gender, emptyByGender(portion));
}
@ -186,9 +181,9 @@ public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
}
if (emptyMembers) {
classDiagram.hideOrShow(EntityGenderUtils.and(gender, emptyByGender(PORTION_FIELD)), PORTION_FIELD, arg
classDiagram.hideOrShow(EntityGenderUtils.and(gender, emptyByGender(EntityPortion.FIELD)), EntityPortion.FIELD, arg
.get("COMMAND", 0).equalsIgnoreCase("show"));
classDiagram.hideOrShow(EntityGenderUtils.and(gender, emptyByGender(PORTION_METHOD)), PORTION_METHOD,
classDiagram.hideOrShow(EntityGenderUtils.and(gender, emptyByGender(EntityPortion.METHOD)), EntityPortion.METHOD,
arg.get("COMMAND", 0).equalsIgnoreCase("show"));
} else {
classDiagram.hideOrShow(gender, portion, arg.get("COMMAND", 0).equalsIgnoreCase("show"));
@ -197,22 +192,22 @@ public class CommandHideShowByGender extends SingleLineCommand2<UmlDiagram> {
return CommandExecutionResult.ok();
}
private Set<EntityPortion> getEntityPortion(String s) {
private EntityPortion getEntityPortion(String s) {
final String sub = StringUtils.goLowerCase(s.substring(0, 3));
if (sub.equals("met")) {
return PORTION_METHOD;
return EntityPortion.METHOD;
}
if (sub.equals("mem")) {
return PORTION_MEMBER;
return EntityPortion.MEMBER;
}
if (sub.equals("att") || sub.equals("fie")) {
return PORTION_FIELD;
return EntityPortion.FIELD;
}
if (sub.equals("cir")) {
return EnumSet.<EntityPortion> of(EntityPortion.CIRCLED_CHARACTER);
return EntityPortion.CIRCLED_CHARACTER;
}
if (sub.equals("ste")) {
return EnumSet.<EntityPortion> of(EntityPortion.STEREOTYPE);
return EntityPortion.STEREOTYPE;
}
throw new IllegalArgumentException();
}

View File

@ -54,11 +54,6 @@ import net.sourceforge.plantuml.skin.VisibilityModifier;
public class CommandHideShowByVisibility extends SingleLineCommand2<UmlDiagram> {
private static final EnumSet<EntityPortion> PORTION_METHOD = EnumSet.<EntityPortion> of(EntityPortion.METHOD);
private static final EnumSet<EntityPortion> PORTION_MEMBER = EnumSet.<EntityPortion> of(EntityPortion.FIELD,
EntityPortion.METHOD);
private static final EnumSet<EntityPortion> PORTION_FIELD = EnumSet.<EntityPortion> of(EntityPortion.FIELD);
public CommandHideShowByVisibility() {
super(getRegexConcat());
}
@ -84,7 +79,7 @@ public class CommandHideShowByVisibility extends SingleLineCommand2<UmlDiagram>
private CommandExecutionResult executeArgClass(ClassDiagram classDiagram, RegexResult arg) {
final Set<EntityPortion> portion = getEntityPortion(arg.get("PORTION", 0));
final EntityPortion portion = getEntityPortion(arg.get("PORTION", 0));
final Set<VisibilityModifier> visibilities = EnumSet.<VisibilityModifier> noneOf(VisibilityModifier.class);
final StringTokenizer st = new StringTokenizer(StringUtils.goLowerCase(arg.get("VISIBILITY", 0)), " ,");
@ -97,43 +92,43 @@ public class CommandHideShowByVisibility extends SingleLineCommand2<UmlDiagram>
return CommandExecutionResult.ok();
}
private void addVisibilities(String token, Set<EntityPortion> portion, Set<VisibilityModifier> result) {
if (token.equals("public") && portion.contains(EntityPortion.FIELD)) {
private void addVisibilities(String token, EntityPortion portion, Set<VisibilityModifier> result) {
if (token.equals("public") && (portion == EntityPortion.MEMBER || portion == EntityPortion.FIELD)) {
result.add(VisibilityModifier.PUBLIC_FIELD);
}
if (token.equals("public") && portion.contains(EntityPortion.METHOD)) {
if (token.equals("public") && (portion == EntityPortion.MEMBER || portion == EntityPortion.METHOD)) {
result.add(VisibilityModifier.PUBLIC_METHOD);
}
if (token.equals("private") && portion.contains(EntityPortion.FIELD)) {
if (token.equals("private") && (portion == EntityPortion.MEMBER || portion == EntityPortion.FIELD)) {
result.add(VisibilityModifier.PRIVATE_FIELD);
}
if (token.equals("private") && portion.contains(EntityPortion.METHOD)) {
if (token.equals("private") && (portion == EntityPortion.MEMBER || portion == EntityPortion.METHOD)) {
result.add(VisibilityModifier.PRIVATE_METHOD);
}
if (token.equals("protected") && portion.contains(EntityPortion.FIELD)) {
if (token.equals("protected") && (portion == EntityPortion.MEMBER || portion == EntityPortion.FIELD)) {
result.add(VisibilityModifier.PROTECTED_FIELD);
}
if (token.equals("protected") && portion.contains(EntityPortion.METHOD)) {
if (token.equals("protected") && (portion == EntityPortion.MEMBER || portion == EntityPortion.METHOD)) {
result.add(VisibilityModifier.PROTECTED_METHOD);
}
if (token.equals("package") && portion.contains(EntityPortion.FIELD)) {
if (token.equals("package") && (portion == EntityPortion.MEMBER || portion == EntityPortion.FIELD)) {
result.add(VisibilityModifier.PACKAGE_PRIVATE_FIELD);
}
if (token.equals("package") && portion.contains(EntityPortion.METHOD)) {
if (token.equals("package") && (portion == EntityPortion.MEMBER || portion == EntityPortion.METHOD)) {
result.add(VisibilityModifier.PACKAGE_PRIVATE_METHOD);
}
}
private Set<EntityPortion> getEntityPortion(String s) {
private EntityPortion getEntityPortion(String s) {
final String sub = StringUtils.goLowerCase(s.substring(0, 3));
if (sub.equals("met")) {
return PORTION_METHOD;
return EntityPortion.METHOD;
}
if (sub.equals("mem")) {
return PORTION_MEMBER;
return EntityPortion.MEMBER;
}
if (sub.equals("att") || sub.equals("fie")) {
return PORTION_FIELD;
return EntityPortion.FIELD;
}
throw new IllegalArgumentException();
}

View File

@ -294,13 +294,29 @@ public class BlocLines implements Iterable<StringLocated> {
final String first = getFirst499().getTrimmed().getString();
final String second = get499(1).getTrimmed().getString();
if (first.endsWith("{") == false && second.equals("{")) {
final String vline = first + " {";
final StringLocated vline = getFirst499().append(" {");
final List<StringLocated> result = new ArrayList<StringLocated>();
result.add(new StringLocated(vline, null));
result.add(vline);
result.addAll(this.lines.subList(2, this.lines.size()));
return new BlocLines(result);
}
return this;
}
public BlocLines eventuallyMoveAllEmptyBracket() {
final List<StringLocated> result = new ArrayList<StringLocated>();
for (StringLocated line : lines) {
if (line.getTrimmed().toString().equals("{")) {
if (result.size() > 0) {
final int pos = result.size() - 1;
StringLocated last = result.get(pos);
result.set(pos, last.append(" {"));
}
} else {
result.add(line);
}
}
return new BlocLines(result);
}
}

View File

@ -64,7 +64,7 @@ public class CommandNamespace extends SingleLineCommand2<ClassDiagram> {
return RegexConcat.build(CommandNamespace.class.getName(), RegexLeaf.start(), //
new RegexLeaf("namespace"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("NAME", "([\\p{L}0-9_][\\p{L}0-9_.:\\\\]*)"), //
new RegexLeaf("NAME", "([\\p{L}0-9_][-\\p{L}0-9_.:\\\\]*)"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), //
@ -79,8 +79,8 @@ public class CommandNamespace extends SingleLineCommand2<ClassDiagram> {
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) {
final Code code = Code.of(arg.get("NAME", 0));
final IGroup currentPackage = diagram.getCurrentGroup();
diagram.gotoGroup2(code, Display.getWithNewlines(code), GroupType.PACKAGE, currentPackage,
NamespaceStrategy.MULTIPLE);
final Display display = Display.getWithNewlines(code);
diagram.gotoGroup2(code, display, GroupType.PACKAGE, currentPackage, NamespaceStrategy.MULTIPLE);
final IEntity p = diagram.getCurrentGroup();
final String stereotype = arg.get("STEREOTYPE", 0);
if (stereotype != null) {

View File

@ -0,0 +1,115 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2020, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* If you like this project or if you find it useful, you can support us at:
*
* http://plantuml.com/patreon (only 1$ per month!)
* http://plantuml.com/paypal
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
*
* Original Author: Arnaud Roques
*
*
*/
package net.sourceforge.plantuml.command;
import net.sourceforge.plantuml.LineLocation;
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.regex.IRegex;
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.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.IGroup;
import net.sourceforge.plantuml.cucadiagram.NamespaceStrategy;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.color.ColorParser;
import net.sourceforge.plantuml.graphic.color.ColorType;
public class CommandNamespace2 extends SingleLineCommand2<ClassDiagram> {
public CommandNamespace2() {
super(getRegexConcat());
}
private static IRegex getRegexConcat() {
return RegexConcat.build(CommandNamespace2.class.getName(), RegexLeaf.start(), //
new RegexLeaf("namespace"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("[%g]"), //
new RegexLeaf("DISPLAY", "([^%g]+)"), //
new RegexLeaf("[%g]"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("as"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("NAME", "([\\p{L}0-9_][-\\p{L}0-9_.:\\\\]*)"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)?"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("URL", "(" + UrlBuilder.getRegexp() + ")?"), //
RegexLeaf.spaceZeroOrMore(), //
ColorParser.exp1(), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("\\{"), RegexLeaf.end());
}
@Override
protected CommandExecutionResult executeArg(ClassDiagram diagram, LineLocation location, RegexResult arg) {
final Code code = Code.of(arg.get("NAME", 0));
final IGroup currentPackage = diagram.getCurrentGroup();
final String disp = arg.getLazzy("DISPLAY", 0);
final Display display = Display.getWithNewlines(disp);
diagram.gotoGroup2(code, display, GroupType.PACKAGE, currentPackage, NamespaceStrategy.MULTIPLE);
final IEntity p = diagram.getCurrentGroup();
final String stereotype = arg.get("STEREOTYPE", 0);
if (stereotype != null) {
p.setStereotype(new Stereotype(stereotype));
}
final String urlString = arg.get("URL", 0);
if (urlString != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
final Url url = urlBuilder.getUrl(urlString);
p.addUrl(url);
}
final String color = arg.get("COLOR", 0);
if (color != null) {
p.setSpecificColorTOBEREMOVED(ColorType.BACK,
diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color));
}
return CommandExecutionResult.ok();
}
}

View File

@ -55,6 +55,7 @@ import net.sourceforge.plantuml.error.PSystemErrorUtils;
import net.sourceforge.plantuml.sequencediagram.command.CommandSkin;
import net.sourceforge.plantuml.sprite.CommandListSprite;
import net.sourceforge.plantuml.statediagram.command.CommandHideEmptyDescription;
import net.sourceforge.plantuml.style.CommandStyleImport;
import net.sourceforge.plantuml.style.CommandStyleMultilinesCSS;
import net.sourceforge.plantuml.utils.StartUtils;
import net.sourceforge.plantuml.version.IteratorCounter2;
@ -220,7 +221,7 @@ public abstract class UmlDiagramFactory extends PSystemAbstractFactory {
addCommonCommands2(cmds);
addCommonHides(cmds);
cmds.add(new CommandStyleMultilinesCSS());
cmds.add(new CommandStyleImport());
}
final protected void addCommonCommands2(List<Command> cmds) {

View File

@ -67,6 +67,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF
private IRegex getRegexConcatMultiLine() {
return RegexConcat.build(FactorySequenceNoteOverSeveralCommand.class.getName() + "multi", RegexLeaf.start(), //
new RegexLeaf("PARALLEL", "(&[%s]*)?"), //
new RegexLeaf("VMERGE", "(/)?"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STYLE", "(note|hnote|rnote)"), //
@ -89,6 +90,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF
private IRegex getRegexConcatSingleLine() {
return RegexConcat.build(FactorySequenceNoteOverSeveralCommand.class.getName() + "single", RegexLeaf.start(), //
new RegexLeaf("PARALLEL", "(&[%s]*)?"), //
new RegexLeaf("VMERGE", "(/)?"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("STYLE", "(note|hnote|rnote)"), //
@ -157,6 +159,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF
if (lines.size() > 0) {
final boolean tryMerge = line0.get("VMERGE", 0) != null;
final boolean parallel = line0.get("PARALLEL", 0) != null;
final Display display = diagram.manageVariable(lines.toDisplay());
final Note note = new Note(p1, p2, display, diagram.getSkinParam().getCurrentStyleBuilder());
Colors colors = color().getColor(line0, diagram.getSkinParam().getIHtmlColorSet());
@ -176,6 +179,9 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF
final Url urlLink = urlBuilder.getUrl(line0.get("URL", 0));
note.setUrl(urlLink);
}
if (parallel) {
note.goParallel();
}
diagram.addNote(note, tryMerge);
}
return CommandExecutionResult.ok();

View File

@ -57,7 +57,8 @@ public class Matcher2 {
final long now = System.currentTimeMillis();
final String id = pattern.pattern();
try {
return new Matcher2(pattern.matcher(input), id);
final Matcher matcher2 = pattern.matcher(input);
return new Matcher2(matcher2, id);
} finally {
if (INSTRUMENT) {
addTime(id, System.currentTimeMillis() - now);

View File

@ -36,11 +36,13 @@
package net.sourceforge.plantuml.command.regex;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.StringLocated;
@ -48,26 +50,32 @@ import net.sourceforge.plantuml.StringLocated;
public abstract class RegexComposed implements IRegex {
protected static final AtomicInteger nbCreateMatches = new AtomicInteger();
protected final List<IRegex> partials;
private final List<IRegex> partials;
protected final List<IRegex> partials() {
return partials;
}
abstract protected String getFullSlow();
private Pattern2 fullCached;
private final AtomicReference<Pattern2> fullCached = new AtomicReference<Pattern2>();
private synchronized Pattern2 getPattern2() {
if (fullCached == null) {
private Pattern2 getPattern2() {
Pattern2 result = fullCached.get();
if (result == null) {
final String fullSlow = getFullSlow();
fullCached = MyPattern.cmpile(fullSlow, Pattern.CASE_INSENSITIVE);
result = MyPattern.cmpile(fullSlow, Pattern.CASE_INSENSITIVE);
fullCached.set(result);
}
return fullCached;
return result;
}
protected boolean isCompiled() {
return fullCached != null;
final protected boolean isCompiled() {
return fullCached.get() != null;
}
public RegexComposed(IRegex... partial) {
this.partials = Arrays.asList(partial);
this.partials = Collections.unmodifiableList(Arrays.asList(partial));
}
public Map<String, RegexPartialMatch> createPartialMatch(Iterator<String> it) {

View File

@ -42,13 +42,11 @@ import java.util.concurrent.atomic.AtomicLong;
import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.StringLocated;
public class RegexConcat extends RegexComposed implements IRegex {
public final class RegexConcat extends RegexComposed implements IRegex {
private static final ConcurrentMap<Object, RegexConcat> cache = new ConcurrentHashMap<Object, RegexConcat>();
private final AtomicLong foxRegex = new AtomicLong(-1L);
private boolean invoked;
// private static final Set<String> PRINTED2 = new HashSet<String>();
public static void printCacheInfo() {
@ -58,7 +56,7 @@ public class RegexConcat extends RegexComposed implements IRegex {
if (reg.isCompiled()) {
nbCompiled++;
}
if (reg.invoked) {
if (reg.invoked()) {
nbInvoked++;
}
}
@ -73,8 +71,8 @@ public class RegexConcat extends RegexComposed implements IRegex {
private long foxRegex() {
if (foxRegex.get() == -1L) {
long tmp = 0L;
for (int i = 1; i < partials.size() - 1; i++) {
final IRegex part = partials.get(i);
for (int i = 1; i < partials().size() - 1; i++) {
final IRegex part = partials().get(i);
if (part instanceof RegexLeaf) {
final RegexLeaf leaf = (RegexLeaf) part;
tmp = tmp | leaf.getFoxSignature();
@ -109,9 +107,12 @@ public class RegexConcat extends RegexComposed implements IRegex {
return result;
}
private boolean invoked() {
return foxRegex.get() != -1L;
}
@Override
public boolean match(StringLocated s) {
invoked = true;
final long foxRegex = foxRegex();
if (foxRegex != 0L) {
final long foxLine = s.getFoxSignature();
@ -129,7 +130,7 @@ public class RegexConcat extends RegexComposed implements IRegex {
@Override
protected String getFullSlow() {
final StringBuilder sb = new StringBuilder();
for (IRegex p : partials) {
for (IRegex p : partials()) {
sb.append(p.getPattern());
}
return sb.toString();

View File

@ -46,7 +46,7 @@ public class RegexOptional extends RegexComposed implements IRegex {
@Override
protected String getFullSlow() {
final StringBuilder sb = new StringBuilder("(?:");
sb.append(partials.get(0).getPattern());
sb.append(partials().get(0).getPattern());
sb.append(")?");
return sb.toString();
}

View File

@ -60,7 +60,7 @@ public class RegexOr extends RegexComposed implements IRegex {
if (name == null) {
sb.append("?:");
}
for (IRegex p : partials) {
for (IRegex p : partials()) {
sb.append(p.getPattern());
sb.append("|");
}

View File

@ -37,6 +37,7 @@ package net.sourceforge.plantuml.creole;
import java.awt.geom.Dimension2D;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -56,6 +57,12 @@ public class AtomTree extends AbstractAtom implements Atom {
private final Map<Atom, Integer> levels = new HashMap<Atom, Integer>();
private final double margin = 2;
@Override
public List<Atom> splitInTwo(StringBounder stringBounder, double width) {
return Arrays.asList((Atom) this);
}
public AtomTree(HtmlColor lineColor) {
this.lineColor = lineColor;
}

View File

@ -36,6 +36,10 @@
package net.sourceforge.plantuml.creole;
import java.awt.geom.Dimension2D;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.graphic.StringBounder;
@ -54,6 +58,24 @@ class AtomWithMargin extends AbstractAtom implements Atom {
this.marginY2 = marginY2;
}
@Override
public List<Atom> splitInTwo(StringBounder stringBounder, double width) {
final List<Atom> result = new ArrayList<Atom>();
final List<Atom> list = atom.splitInTwo(stringBounder, width);
for (Atom a : list) {
double y1 = marginY1;
double y2 = marginY2;
if (list.size() == 2 && result.size() == 0) {
y2 = 0;
}
if (list.size() == 2 && result.size() == 1) {
y1 = 0;
}
result.add(new AtomWithMargin(a, y1, y2));
}
return Collections.unmodifiableList(result);
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
return Dimension2DDouble.delta(atom.calculateDimension(stringBounder), 0, marginY1 + marginY2);
}

View File

@ -563,8 +563,8 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
return result;
}
public final void hideOrShow(EntityGender gender, Set<EntityPortion> portions, boolean show) {
for (EntityPortion portion : portions) {
public final void hideOrShow(EntityGender gender, EntityPortion portions, boolean show) {
for (EntityPortion portion : portions.asSet()) {
this.hideOrShows.add(new HideOrShow(gender, portion, show));
}
}
@ -577,26 +577,6 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
}
}
// public void hideOrShow(IEntity leaf, boolean show) {
// leaf.setRemoved(!show);
// }
// public void hideOrShow(Stereotype stereotype, boolean show) {
// if (show) {
// hiddenStereotype.remove(stereotype.getLabel(Guillemet.DOUBLE_COMPARATOR));
// } else {
// hiddenStereotype.add(stereotype.getLabel(Guillemet.DOUBLE_COMPARATOR));
// }
// }
//
// public void hideOrShow(LeafType leafType, boolean show) {
// if (show) {
// hiddenType.remove(leafType);
// } else {
// hiddenType.add(leafType);
// }
// }
public void hideOrShow2(String what, boolean show) {
this.hides2.add(new HideOrShow2(what, show));
}

View File

@ -115,13 +115,5 @@ public class EntityGenderUtils {
};
}
// static public EntityGender emptyMembers() {
// return new EntityGender() {
// public boolean contains(IEntity test) {
// return test.getBodier().getMethodsToDisplay().size() == 0
// && test.getBodier().getFieldsToDisplay().size() == 0;
// }
// };
// }
}

View File

@ -35,6 +35,16 @@
*/
package net.sourceforge.plantuml.cucadiagram;
import java.util.EnumSet;
import java.util.Set;
public enum EntityPortion {
FIELD, METHOD, CIRCLED_CHARACTER, STEREOTYPE, LOLLIPOP, ENTIRELY
FIELD, METHOD, MEMBER, CIRCLED_CHARACTER, STEREOTYPE;
public Set<EntityPortion> asSet() {
if (this == MEMBER) {
return EnumSet.<EntityPortion> of(FIELD, METHOD);
}
return EnumSet.<EntityPortion> of(this);
}
}

View File

@ -59,9 +59,9 @@ import net.sourceforge.plantuml.skin.VisibilityModifier;
public class EntityFactory {
private final Map<Code, ILeaf> leafs = new Protect<ILeaf>(new LinkedHashMap<Code, ILeaf>());
private final Map<Code, ILeaf> leafs = new LinkedHashMap<Code, ILeaf>();
private final List<Link> links = new ArrayList<Link>();
private final Map<Code, IGroup> groups = new Protect<IGroup>(new LinkedHashMap<Code, IGroup>());
private final Map<Code, IGroup> groups = new LinkedHashMap<Code, IGroup>();
private int rawLayout;
private final IGroup rootGroup = new GroupRoot(this);
@ -209,75 +209,4 @@ public class EntityFactory {
return result;
}
static class Protect<O extends Object> implements Map<Code, O> {
private final Map<Code, O> m;
public Protect(Map<Code, O> data) {
this.m = data;
}
public O remove(Object key) {
if (key instanceof Code == false) {
throw new IllegalArgumentException();
}
return m.remove(key);
}
public O get(Object key) {
if (key instanceof Code == false) {
throw new IllegalArgumentException();
}
return m.get(key);
}
public Set<Code> keySet() {
return m.keySet();
}
public void putAll(Map<? extends Code, ? extends O> m) {
this.m.putAll(m);
}
public boolean containsKey(Object key) {
if (key instanceof Code == false) {
throw new IllegalArgumentException();
}
return m.containsKey(key);
}
public boolean isEmpty() {
return m.isEmpty();
}
public O put(Code key, O value) {
if (key instanceof Code == false) {
throw new IllegalArgumentException();
}
return m.put(key, value);
}
public boolean containsValue(Object value) {
return m.containsValue(value);
}
public Set<Map.Entry<Code, O>> entrySet() {
return m.entrySet();
}
public Collection<O> values() {
return m.values();
}
public void clear() {
m.clear();
}
public int size() {
return m.size();
}
}
}

View File

@ -71,23 +71,23 @@ public class PSystemDonors extends AbstractPSystem {
private static final int COLS = 6;
private static final int FREE_LINES = 6;
public static final String DONORS = "6rW902mFR3hSmrTODcikzuop9yl7Q5RohVaQVmG9QrfMG8eAo04YsxAZMAlDIBlv0O82w3Lqz9ZRTthS"
+ "RwI_YAvqzqqpecqsfpJFA8e5GUFvDksmpP-zgJAa53AGwKICX-1fynfBhQmb_o3XTFytdKBoK166eTaA"
+ "vwCHQlz096FjZgt6TFUZgBjMNTob2jyADQPJn35S5HhbrGDVMoWP5IxzEdyBcfWL4pb4YgUis68UlQ67"
+ "AxdGEYCBPDR-exu0BLB392Xo2L1iFKcYuwsbdNq7ki-HG8SJboYmcJ479Gxh7MZjt12pn2a23PTcOJGs"
+ "aRFbYGaC-w05U_WVzKIEMz3AB8Ks9oxNW88zReR3I5gbYYPYTcWpeBX5jEX8O54NnuLmVHmCJSbvq70B"
+ "KEnYWL9CQW1v4-iTV9gDV57dqZU12bxr3ecZsHbMLzaXPZutPlJjpqC2ol_-oSmOdotbQa6L9LzdVzHf"
+ "87S96ZdiZTR6AblWNY_gb31_iK1-0BrK2og9xrat5bg0k9UK5-Jcd3-vZY8mDgK45di8KrgJ7zOLQ6n2"
+ "bhiP2to4dujDi88jk7BvQj3DjE8vfVE5b9GGlttHgo7zLeWrSRDw-wXtJvbh-V-wQugP53VGIGczJTS2"
+ "58KnMBKB4nF1ow2tGsu4P0EKXzAjE3I_o5_x0fct9lU0o6tEiLygtb0tEWGn3TPq8OKPmFmkHRbpudO7"
+ "4Kvh0tgNgImZRUuocrBDr25ZxhfG9p_kcnchue0SyhpmeKvmSyEugZVBkxGVC0jubByiFlsSH_1O1JWF"
+ "zzxpmj9SWe5sXZfQ86r6rFSzzKNX9WubikXRxEBakrnFN3nqFVZioQ9TpF_C-4yW7uFAonPAwfiCRn9e"
+ "-WwPR4nV-IHlmFyoCCqSZenFCUzV9i_Kn14dJjCnd6ri0B1N5JwnE0Xk1gfkwTbPJ8gORBxwc3aJ_1XV"
+ "W55P2vuAszdTI-8CQ9JO9-QzCkekldLAFXPG9he8bjA2KZqeAKB7C39YrA3dh3LW-rtC5kYrpsnOKYY-"
+ "BQ9x6Xi0hLNHJUXxk06U21ML4bwBIS9W_A_nD3qOw-3ZDosr8WwIrIKnSwY0vkW9fwL-sRgaiDwYzrlN"
+ "zQ9f-FF_oT4CJjMuvgiAeYi8_5-W81nozHvuBIhzz-2J4hSDZ62rdjY9bLT6JpDBI13SibwdRjECz4nK"
+ "b3kGXTfnVAZuJog6mzInmVABPPAYso0dTRs8ErLGzlKlmaaEXSyxHPKTHLoNoZqn8fdO-L6S-TXdJu6R"
+ "c-1cwePB1FgU_cwOn45jpHSfDGm7GvwAIAETpri3";
public static final String DONORS = "6ty902mFR3fSuLzO9ciEU-UTVLaMenKn_Poll0GDwsu450sG0Q8aQloSnDhywO_J0H90rz3HOsxVwN6_"
+ "aVuYkjAzRveHRVcs-MeT28Jb1yTZxQt2wPrlgWmfGKmLss-PqDxVVbneGbeh65VWfd92vl-cq-9uA8HP"
+ "cgrmFXgXChPaZuwvpzsFeYvKNLo2gc-56jEfn35S5JQ6wpFKDHonwDhLyQWe6HGZh28bKJUE8C4TDngr"
+ "KJd19r8B_r4BQDAQJKFIAQ1OHefOyxRC-UC0zJTXu4GGKpeS8CAXf2DuWJ54VI618AeODMgZw8pDLCzv"
+ "ueE955JOWN_af7fl8TkZ31q8OhAXGC9F40HWpzLGuhEvsO3IBRp5l0QRTMfPoMZtDrDIQguqF00wOY9e"
+ "1Ln1o9kW2tuVRUOIPngxei0RdiHubTi7kSZs0DXU3EZRMHC3vGizEVEKPKPrQo6TKwvp_EfiaEyQChEt"
+ "cr75E8k9cD_cKXY-k03xcw2NMaF5-9lpp48sXCUKkf2Tv_Bbt8b0M6KfMUGgbgIc_hIBAMrTpFUcBEBT"
+ "-tLgADimWbTJv80-gfNsXiuNYgk6-kSXZxgEJ-5hqXRYNQBlJiojuk_jRWapJbVGzIPyg6w0A3Lwucgk"
+ "M5GHk8FesP27WDo1wilaLdbPFYIkvmDIRqiu49aDOYDnpRRYa8j5c0TMTgMA0S0MBj6kt_gTf5zvTK8V"
+ "WfLHP8IxVhj9zx1vDioDNYj0Gur1UKDdonSPgxaW3ZDCownPFT1-n564otYGl7hUCxkk0bYJUMzRR8sd"
+ "Cx2kOSumITCH-JZIbcGSwYWzYxFDcxh4gxcTx3nqEpXFRz49Piuswo5J8FUeUMcfMunxrs38crDPnQxb"
+ "ehq4-kfcFL32Cpu5t6wS3Ada4eAeuKn7I4n09BNEApPOulekgdevEPwQbZ1hjzL1eDhv4Ni3GLMm4suW"
+ "plfUusT4YMBdxVDUcNLNtuUKM1TG8GO48wbGjX5ILCBcL3AizrRFyUZWjL_QT46_ZM-MB0aKtW4HQhv1"
+ "qYdC8q_mHirPefHJgv8lUqoCWEzn-GtsnAuES_oEbbOUPv0RWfGxfO3abs15Isst9bXlqVksRNjRDlxy"
+ "tskod5Cprx7o0Bg0k02rUH4xKHVrF2d_TT0ddUCMCWD6dHpxoXjJhmSO28fcsUvLUp-ZVhcKbzjLEtsK"
+ "zKEb_qCgGJ2M5oox6AMeZ3ObM6rxgniLYttxZR2NG-FycwYoAJ-uobIhPqHIiSkTEC_ZjOrK8efAESo0"
+ "jXE2mDblV9P2uoMZZIjWjSC5HJwVPfV3evcMs12Kbf7rm2_T0000";
/*
* Special thanks to our sponsors and donors:

View File

@ -291,6 +291,8 @@ public class EpsGraphics {
curvetoNoMacro(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y, coord[4] + x, coord[5] + y);
} else if (type == USegmentType.SEG_CLOSE) {
// Nothing
} else if (type == USegmentType.SEG_ARCTO) {
// Nothing
} else {
Log.println("unknown1 " + seg);
}
@ -315,6 +317,8 @@ public class EpsGraphics {
curvetoNoMacro(coord[0] + x, coord[1] + y, coord[2] + x, coord[3] + y, coord[4] + x, coord[5] + y);
} else if (type == USegmentType.SEG_CLOSE) {
// Nothing
} else if (type == USegmentType.SEG_ARCTO) {
// Nothing
} else {
Log.println("unknown2 " + seg);
}

View File

@ -208,12 +208,12 @@ public abstract class PSystemError extends AbstractPSystem {
return new ImageDataSimple(1, 1);
}
// final boolean useRed = fileFormat.isUseRedForError();
final TextBlockBackcolored result = getGraphicalFormatted();
TextBlock udrawable;
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
getMetadata(), null, 0, 0, null, false);
imageBuilder.setRandomPixel(true);
if (getSource().getTotalLineCount() < 5) {
udrawable = addWelcome(result);
} else {
@ -242,13 +242,6 @@ public abstract class PSystemError extends AbstractPSystem {
}
}
// private String getRed(boolean useRed) {
// if (useRed) {
// return "#CD0A0A";
// }
// return "red";
// }
//
final public DiagramDescription getDescription() {
return new DiagramDescription("(Error)");
}

View File

@ -66,6 +66,7 @@ public class GraphicStrings extends AbstractTextBlock implements IEntityImage {
private final List<String> strings;
private final BufferedImage image;
private final double imagePadding = 30;
private final GraphicPosition position;
@ -174,9 +175,9 @@ public class GraphicStrings extends AbstractTextBlock implements IEntityImage {
if (position == GraphicPosition.BOTTOM) {
dim = new Dimension2DDouble(dim.getWidth(), dim.getHeight() + image.getHeight());
} else if (position == GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT) {
dim = new Dimension2DDouble(dim.getWidth() + image.getWidth(), dim.getHeight());
dim = new Dimension2DDouble(dim.getWidth() + imagePadding + image.getWidth(), dim.getHeight());
} else if (position == GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT) {
dim = new Dimension2DDouble(dim.getWidth() + image.getWidth(), dim.getHeight());
dim = new Dimension2DDouble(dim.getWidth() + imagePadding + image.getWidth(), dim.getHeight());
}
}
return dim;

View File

@ -153,7 +153,11 @@ class USymbolCloud extends USymbol {
private void bubbleLine(Random rnd, List<Point2D> points, Point2D p1, Point2D p2, double bubbleSize) {
final CoordinateChange change = new CoordinateChange(p1, p2);
final double length = change.getLength();
final int nb = (int) (length / bubbleSize);
int nb = (int) (length / bubbleSize);
if (nb == 0) {
bubbleSize = length / 2;
nb = (int) (length / bubbleSize);
}
for (int i = 0; i < nb; i++) {
points.add(rnd(rnd, change.getTrueCoordinate(i * length / nb, 0), bubbleSize * .2));
}
@ -239,7 +243,8 @@ class USymbolCloud extends USymbol {
@Override
public TextBlock asBig(final TextBlock title, HorizontalAlignment labelAlignment, final TextBlock stereotype,
final double width, final double height, final SymbolContext symbolContext, final HorizontalAlignment stereoAlignment) {
final double width, final double height, final SymbolContext symbolContext,
final HorizontalAlignment stereoAlignment) {
return new AbstractTextBlock() {
public void drawU(UGraphic ug) {

View File

@ -72,6 +72,7 @@ public class FingerImpl implements Finger, UDrawable {
private final Display label;
private final HtmlColor backColor;
private final String stereotype;
private final ISkinParam skinParam;
private final StyleBuilder styleBuilder;
private final IdeaShape shape;
@ -83,23 +84,25 @@ public class FingerImpl implements Finger, UDrawable {
private final List<FingerImpl> nail = new ArrayList<FingerImpl>();
private Tetris tetris = null;
public StyleSignature getDefaultStyleDefinitionNode() {
private StyleSignature getDefaultStyleDefinitionNode() {
if (level == 0) {
return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.node, SName.rootNode);
return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.node, SName.rootNode).add(
stereotype);
}
if (nail.size() == 0) {
return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.node, SName.leafNode);
return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.node, SName.leafNode).add(
stereotype);
}
return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.node);
return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.node).add(stereotype);
}
public StyleSignature getDefaultStyleDefinitionArrow() {
return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.arrow);
return StyleSignature.of(SName.root, SName.element, SName.mindmapDiagram, SName.arrow).add(stereotype);
}
public static FingerImpl build(Idea idea, ISkinParam skinParam, Direction direction) {
final FingerImpl result = new FingerImpl(idea.getStyleBuilder(), idea.getBackColor(), idea.getLabel(),
skinParam, idea.getShape(), direction, idea.getLevel());
skinParam, idea.getShape(), direction, idea.getLevel(), idea.getStereotype());
for (Idea child : idea.getChildren()) {
result.addInNail(build(child, skinParam, direction));
}
@ -112,8 +115,9 @@ public class FingerImpl implements Finger, UDrawable {
}
private FingerImpl(StyleBuilder styleBuilder, HtmlColor backColor, Display label, ISkinParam skinParam,
IdeaShape shape, Direction direction, int level) {
IdeaShape shape, Direction direction, int level, String stereotype) {
this.backColor = backColor;
this.stereotype = stereotype;
this.level = level;
this.label = label;
this.skinParam = skinParam;

View File

@ -57,14 +57,15 @@ class Idea {
private final IdeaShape shape;
private final HtmlColor backColor;
private final StyleBuilder styleBuilder;
private final String stereotype;
public Idea(StyleBuilder styleBuilder, Display label, IdeaShape shape) {
this(styleBuilder, null, 0, null, label, shape);
public Idea(StyleBuilder styleBuilder, Display label, IdeaShape shape, String stereotype) {
this(styleBuilder, null, 0, null, label, shape, stereotype);
}
public Idea createIdea(StyleBuilder styleBuilder, HtmlColor backColor, int newLevel, Display newDisplay,
IdeaShape newShape) {
final Idea result = new Idea(styleBuilder, backColor, newLevel, this, newDisplay, newShape);
IdeaShape newShape, String stereotype) {
final Idea result = new Idea(styleBuilder, backColor, newLevel, this, newDisplay, newShape, stereotype);
this.children.add(result);
return result;
}
@ -77,13 +78,15 @@ class Idea {
// return result;
// }
private Idea(StyleBuilder styleBuilder, HtmlColor backColor, int level, Idea parent, Display label, IdeaShape shape) {
private Idea(StyleBuilder styleBuilder, HtmlColor backColor, int level, Idea parent, Display label,
IdeaShape shape, String stereotype) {
this.backColor = backColor;
this.styleBuilder = styleBuilder;
this.label = label;
this.level = level;
this.parent = parent;
this.shape = shape;
this.stereotype = stereotype;
}
@Override
@ -123,4 +126,8 @@ class Idea {
return styleBuilder;
}
public final String getStereotype() {
return stereotype;
}
}

View File

@ -49,6 +49,7 @@ import net.sourceforge.plantuml.Scale;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display;
@ -62,6 +63,7 @@ import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.MinMax;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.wbs.WBSDiagram;
public class MindMapDiagram extends UmlDiagram {
@ -179,19 +181,25 @@ public class MindMapDiagram extends UmlDiagram {
public CommandExecutionResult addIdea(HtmlColor backColor, int level, String label, IdeaShape shape,
Direction direction) {
final Matcher2 m = WBSDiagram.patternStereotype.matcher(label);
String stereotype = null;
if (m.matches()) {
label = m.group(1);
stereotype = m.group(2);
}
if (level == 0) {
if (this.right.root != null) {
return CommandExecutionResult
.error("I don't know how to draw multi-root diagram. You should suggest an image so that the PlantUML team implements it :-)");
}
right.initRoot(getSkinParam().getCurrentStyleBuilder(), label, shape);
left.initRoot(getSkinParam().getCurrentStyleBuilder(), label, shape);
right.initRoot(getSkinParam().getCurrentStyleBuilder(), label, shape, stereotype);
left.initRoot(getSkinParam().getCurrentStyleBuilder(), label, shape, stereotype);
return CommandExecutionResult.ok();
}
if (direction == Direction.LEFT) {
return left.add(getSkinParam().getCurrentStyleBuilder(), backColor, level, label, shape);
return left.add(getSkinParam().getCurrentStyleBuilder(), backColor, level, label, shape, stereotype);
}
return right.add(getSkinParam().getCurrentStyleBuilder(), backColor, level, label, shape);
return right.add(getSkinParam().getCurrentStyleBuilder(), backColor, level, label, shape, stereotype);
}
static class Branch {
@ -199,8 +207,8 @@ public class MindMapDiagram extends UmlDiagram {
private Idea last;
private Finger finger;
private void initRoot(StyleBuilder styleBuilder, String label, IdeaShape shape) {
root = new Idea(styleBuilder, Display.getWithNewlines(label), shape);
private void initRoot(StyleBuilder styleBuilder, String label, IdeaShape shape, String stereotype) {
root = new Idea(styleBuilder, Display.getWithNewlines(label), shape, stereotype);
last = root;
}
@ -213,17 +221,20 @@ public class MindMapDiagram extends UmlDiagram {
}
private CommandExecutionResult add(StyleBuilder styleBuilder, HtmlColor backColor, int level, String label,
IdeaShape shape) {
IdeaShape shape, String stereotype) {
if (last == null) {
return CommandExecutionResult.error("Check your indentation ?");
}
if (level == last.getLevel() + 1) {
final Idea newIdea = last.createIdea(styleBuilder, backColor, level, Display.getWithNewlines(label),
shape);
shape, stereotype);
last = newIdea;
return CommandExecutionResult.ok();
}
if (level <= last.getLevel()) {
final int diff = last.getLevel() - level + 1;
final Idea newIdea = getParentOfLast(diff).createIdea(styleBuilder, backColor, level,
Display.getWithNewlines(label), shape);
Display.getWithNewlines(label), shape, stereotype);
last = newIdea;
return CommandExecutionResult.ok();
}

View File

@ -58,6 +58,10 @@ public class FileWithSuffix {
private final String entry;
private final String description;
@Override
public String toString() {
return file.toString();
}
public Reader getReader(String charset) throws IOException {
if (entry == null) {
if (charset == null) {

View File

@ -41,7 +41,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.skin.ArrowConfiguration;

View File

@ -57,7 +57,6 @@ import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleBuilder;
import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.style.ValueImpl;
import net.sourceforge.plantuml.style.WithStyle;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UTranslate;
@ -78,7 +77,7 @@ public class Englober implements WithStyle {
}
public Style[] getUsedStyles() {
Style tmp = getDefaultStyleDefinition().getMergedStyle(styleBuilder);
Style tmp = getDefaultStyleDefinition().with(participantEnglober.getStereotype()).getMergedStyle(styleBuilder);
final HtmlColor backColor = participantEnglober.getBoxColor();
if (tmp != null) {
tmp = tmp.eventuallyOverride(PName.BackGroundColor, backColor);

View File

@ -44,7 +44,6 @@ import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorAndStyle;
import net.sourceforge.plantuml.graphic.Rainbow;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;

View File

@ -37,9 +37,7 @@ package net.sourceforge.plantuml.sequencediagram;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.skin.ArrowConfiguration;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleBuilder;
import net.sourceforge.plantuml.style.StyleSignature;
public class MessageExo extends AbstractMessage {

View File

@ -38,7 +38,6 @@ package net.sourceforge.plantuml.sequencediagram;
import java.util.List;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.SpecificBackcolorable;
import net.sourceforge.plantuml.Url;

View File

@ -50,7 +50,6 @@ import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.SymbolContext;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleBuilder;
import net.sourceforge.plantuml.style.StyleSignature;
@ -73,15 +72,16 @@ public class Participant implements SpecificBackcolorable, WithStyle {
// private Style style;
public StyleSignature getDefaultStyleDefinition() {
return type.getDefaultStyleDefinition();
return type.getDefaultStyleDefinition().addClickable(getUrl());
}
public Style[] getUsedStyles() {
if (SkinParam.USE_STYLES() == false) {
return null;
}
Style tmp = getDefaultStyleDefinition().with(stereotype).getMergedStyle(styleBuilder)
.eventuallyOverride(getColors(null));
final StyleSignature signature = getDefaultStyleDefinition().with(stereotype);
Style tmp = signature.getMergedStyle(styleBuilder);
tmp = tmp.eventuallyOverride(getColors(null));
Style stereo = getDefaultStyleDefinition().withStereotype(stereotype).getMergedStyle(styleBuilder);
if (tmp != null) {
stereo = tmp.mergeWith(stereo);

View File

@ -36,16 +36,19 @@
package net.sourceforge.plantuml.sequencediagram;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.HtmlColor;
public class ParticipantEnglober {
final private Display title;
final private HtmlColor boxColor;
final private Stereotype stereotype;
public ParticipantEnglober(Display title, HtmlColor boxColor) {
public ParticipantEnglober(Display title, HtmlColor boxColor, Stereotype stereotype) {
this.title = title;
this.boxColor = boxColor;
this.stereotype = stereotype;
}
public final Display getTitle() {
@ -56,5 +59,8 @@ public class ParticipantEnglober {
return boxColor;
}
public final Stereotype getStereotype() {
return stereotype;
}
}

View File

@ -37,8 +37,8 @@ package net.sourceforge.plantuml.sequencediagram;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Styleable;
import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.style.Styleable;
public enum ParticipantType implements Styleable {
PARTICIPANT(ColorParam.participantBackground), //

View File

@ -42,7 +42,6 @@ import java.util.List;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.skin.ComponentType;
import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;

View File

@ -61,6 +61,7 @@ import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.SymbolContext;
import net.sourceforge.plantuml.sequencediagram.graphic.FileMaker;
@ -391,11 +392,11 @@ public class SequenceDiagram extends UmlDiagram {
private ParticipantEnglober participantEnglober;
public void boxStart(Display comment, HtmlColor color) {
public void boxStart(Display comment, HtmlColor color, Stereotype stereotype) {
if (participantEnglober != null) {
throw new IllegalStateException();
}
this.participantEnglober = new ParticipantEnglober(comment, color);
this.participantEnglober = new ParticipantEnglober(comment, color, stereotype);
}
public void endBox() {

View File

@ -75,7 +75,6 @@ import net.sourceforge.plantuml.sequencediagram.command.CommandParticipantA4;
import net.sourceforge.plantuml.sequencediagram.command.CommandReferenceMultilinesOverSeveral;
import net.sourceforge.plantuml.sequencediagram.command.CommandReferenceOverSeveral;
import net.sourceforge.plantuml.sequencediagram.command.CommandReturn;
import net.sourceforge.plantuml.sequencediagram.command.CommandSkin;
import net.sourceforge.plantuml.sequencediagram.command.CommandUrl;
public class SequenceDiagramFactory extends UmlDiagramFactory {

View File

@ -35,6 +35,8 @@
*/
package net.sourceforge.plantuml.sequencediagram.command;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
@ -45,10 +47,12 @@ 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.Display;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.color.ColorParser;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.graphic.color.Colors;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
import net.sourceforge.plantuml.ugraphic.UFont;
public class CommandBoxStart extends SingleLineCommand2<SequenceDiagram> {
@ -67,7 +71,9 @@ public class CommandBoxStart extends SingleLineCommand2<SequenceDiagram> {
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("NAME2", "([^#]+)")))), //
RegexLeaf.spaceZeroOrMore(), //
color().getRegex(), RegexLeaf.end());
new RegexLeaf("STEREO", "(\\<\\<.*\\>\\>)?"), //
color().getRegex(), //
RegexLeaf.end());
}
private static ColorParser color() {
@ -75,16 +81,24 @@ public class CommandBoxStart extends SingleLineCommand2<SequenceDiagram> {
}
@Override
protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg2) {
protected CommandExecutionResult executeArg(SequenceDiagram diagram, LineLocation location, RegexResult arg) {
if (diagram.isBoxPending()) {
return CommandExecutionResult.error("Box cannot be nested");
}
final String argTitle = arg2.getLazzy("NAME", 0);
final String argColor = arg2.get("COLOR", 0);
final String argTitle = arg.getLazzy("NAME", 0);
final String argColor = arg.get("COLOR", 0);
final String stereo = arg.get("STEREO", 0);
Stereotype stereotype = null;
if (stereo != null) {
final ISkinParam skinParam = diagram.getSkinParam();
stereotype = new Stereotype(stereo);
}
// final HtmlColor color = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(argColor);
Colors colors = color().getColor(arg2, diagram.getSkinParam().getIHtmlColorSet());
Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
final String title = argTitle == null ? "" : argTitle;
diagram.boxStart(Display.getWithNewlines(title), colors.getColor(ColorType.BACK));
diagram.boxStart(Display.getWithNewlines(title), colors.getColor(ColorType.BACK), stereotype);
return CommandExecutionResult.ok();
}

View File

@ -264,7 +264,8 @@ class Step1Message extends Step1Abstract {
}
if (m.getArrowConfiguration().getDressing2().getHead() == ArrowHead.CROSSX) {
result = result.withHead2(m.getArrowConfiguration().getDressing2().getHead());
System.err.println("WARNING : CROSSX");
// System.err.println("WARNING : CROSSX");
// Thread.dumpStack();
// assert false;
}
result = result.withPart(m.getArrowConfiguration().getPart());

View File

@ -103,7 +103,6 @@ public class NoteTile extends AbstractTile implements Tile {
ug = ug.apply(new UTranslate(x, 0));
comp.drawU(ug, area, (Context2D) ug);
// ug.draw(new ULine(x2 - x1, 0));
}
private double getUsedWidth(StringBounder stringBounder) {

View File

@ -76,9 +76,10 @@ public class ComponentRoseArrow extends AbstractComponentRoseArrow {
boolean belowForResponse) {
super(style, foregroundColor, font, stringsToDisplay, arrowConfiguration, spriteContainer,
textHorizontalAlignment, maxMessageSize);
if (SkinParam.USE_STYLES()) {
messagePosition = style.getHorizontalAlignment();
}
// Done in Rose::createComponentArrow
// if (SkinParam.USE_STYLES()) {
// messagePosition = style.getHorizontalAlignment();
// }
this.messagePosition = messagePosition;
this.niceArrow = niceArrow;
this.belowForResponse = belowForResponse;

View File

@ -41,6 +41,7 @@ import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.SkinParamBackcolored;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
@ -69,6 +70,10 @@ public class ComponentRoseGroupingElse extends AbstractTextualComponent {
super(style, LineBreakStrategy.NONE, comment == null ? null : "[" + comment + "]", smallFont,
HorizontalAlignment.LEFT, 5, 5, 1, spriteContainer, null, null);
if (SkinParam.USE_STYLES()) {
if (spriteContainer instanceof SkinParamBackcolored) {
style = style.eventuallyOverride(PName.BackGroundColor,
((SkinParamBackcolored) spriteContainer).getBackgroundColor());
}
this.groupBorder = style.value(PName.LineColor).asColor(getIHtmlColorSet());
this.backgroundColor = style.value(PName.BackGroundColor).asColor(getIHtmlColorSet());
} else {

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.skin.rose;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
@ -43,6 +44,7 @@ import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.SymbolContext;
import net.sourceforge.plantuml.skin.AbstractTextualComponent;
import net.sourceforge.plantuml.skin.Area;
import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.URectangle;
@ -57,8 +59,13 @@ final public class ComponentRoseNoteBox extends AbstractTextualComponent {
public ComponentRoseNoteBox(Style style, SymbolContext symbolContext, FontConfiguration font, Display strings,
ISkinSimple spriteContainer, double roundCorner, HorizontalAlignment alignment) {
super(style, spriteContainer.wrapWidth(), strings, font, alignment, 4, 4, 4, spriteContainer, false, null, null);
this.roundCorner = roundCorner;
if (SkinParam.USE_STYLES()) {
this.symbolContext = style.getSymbolContext(getIHtmlColorSet());
this.roundCorner = style.value(PName.RoundCorner).asInt();
} else {
this.symbolContext = symbolContext;
this.roundCorner = roundCorner;
}
}
@Override

View File

@ -36,6 +36,7 @@
package net.sourceforge.plantuml.skin.rose;
import net.sourceforge.plantuml.ISkinSimple;
import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
@ -43,6 +44,7 @@ import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.SymbolContext;
import net.sourceforge.plantuml.skin.AbstractTextualComponent;
import net.sourceforge.plantuml.skin.Area;
import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UPolygon;
@ -57,8 +59,12 @@ final public class ComponentRoseNoteHexagonal extends AbstractTextualComponent {
public ComponentRoseNoteHexagonal(Style style, SymbolContext symbolContext, FontConfiguration font,
Display strings, ISkinSimple spriteContainer, HorizontalAlignment alignment) {
super(style, spriteContainer.wrapWidth(), strings, font, alignment, 12, 12, 4, spriteContainer, false, null, null);
if (SkinParam.USE_STYLES()) {
this.symbolContext = style.getSymbolContext(getIHtmlColorSet());
} else {
this.symbolContext = symbolContext;
}
}
@Override
final public double getPreferredWidth(StringBounder stringBounder) {

View File

@ -42,6 +42,7 @@ import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.PaddingParam;
import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
@ -55,7 +56,10 @@ import net.sourceforge.plantuml.skin.ArrowConfiguration;
import net.sourceforge.plantuml.skin.ArrowDirection;
import net.sourceforge.plantuml.skin.Component;
import net.sourceforge.plantuml.skin.ComponentType;
import net.sourceforge.plantuml.style.PName;
import net.sourceforge.plantuml.style.SName;
import net.sourceforge.plantuml.style.Style;
import net.sourceforge.plantuml.style.StyleSignature;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UStroke;
@ -307,10 +311,39 @@ public class Rose {
FontParam.ARROW), stringsToDisplay, config, param, param.maxMessageSize(),
param.strictUmlStyle() == false);
}
final HorizontalAlignment messageHorizontalAlignment = param.getHorizontalAlignment(
AlignmentParam.sequenceMessageAlignment, config.getArrowDirection(), config.isReverseDefine());
final HorizontalAlignment textHorizontalAlignment = param.getHorizontalAlignment(
AlignmentParam.sequenceMessageTextAlignment, config.getArrowDirection(), false);
HorizontalAlignment messageHorizontalAlignment;
final HorizontalAlignment textHorizontalAlignment;
final ArrowDirection arrowDirection = config.getArrowDirection();
if (SkinParam.USE_STYLES()) {
final StyleSignature signature = StyleSignature.of(SName.root, SName.element, SName.sequenceDiagram,
SName.arrow);
final Style textStyle = signature.getMergedStyle(param.getCurrentStyleBuilder());
final String value = textStyle.value(PName.HorizontalAlignment).asString();
messageHorizontalAlignment = textStyle.getHorizontalAlignment();
textHorizontalAlignment = textStyle.getHorizontalAlignment();
if ("direction".equalsIgnoreCase(value)) {
if (arrowDirection == ArrowDirection.LEFT_TO_RIGHT_NORMAL) {
messageHorizontalAlignment = HorizontalAlignment.LEFT;
} else if (arrowDirection == ArrowDirection.RIGHT_TO_LEFT_REVERSE) {
messageHorizontalAlignment = HorizontalAlignment.RIGHT;
} else if (arrowDirection == ArrowDirection.BOTH_DIRECTION) {
messageHorizontalAlignment = HorizontalAlignment.CENTER;
}
} else if ("reversedirection".equalsIgnoreCase(value)) {
if (arrowDirection == ArrowDirection.LEFT_TO_RIGHT_NORMAL) {
messageHorizontalAlignment = HorizontalAlignment.RIGHT;
} else if (arrowDirection == ArrowDirection.RIGHT_TO_LEFT_REVERSE) {
messageHorizontalAlignment = HorizontalAlignment.LEFT;
} else if (arrowDirection == ArrowDirection.BOTH_DIRECTION) {
messageHorizontalAlignment = HorizontalAlignment.CENTER;
}
}
} else {
messageHorizontalAlignment = param.getHorizontalAlignment(AlignmentParam.sequenceMessageAlignment,
arrowDirection, config.isReverseDefine());
textHorizontalAlignment = param.getHorizontalAlignment(AlignmentParam.sequenceMessageTextAlignment,
config.getArrowDirection(), false);
}
return new ComponentRoseArrow(styles == null ? null : styles[0], sequenceArrow, getUFont2(param,
FontParam.ARROW), stringsToDisplay, config, messageHorizontalAlignment, param, textHorizontalAlignment,
param.maxMessageSize(), param.strictUmlStyle() == false, param.responseMessageBelowArrow());

View File

@ -33,37 +33,59 @@
*
*
*/
package net.sourceforge.plantuml.classdiagram.command;
package net.sourceforge.plantuml.style;
import java.io.File;
import java.io.IOException;
import net.sourceforge.plantuml.FileSystem;
import net.sourceforge.plantuml.LineLocation;
import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.command.BlocLines;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
public class CommandHideShowSpecificStereotype extends SingleLineCommand2<CucaDiagram> {
public class CommandStyleImport extends SingleLineCommand2<UmlDiagram> {
public CommandHideShowSpecificStereotype() {
public CommandStyleImport() {
super(getRegexConcat());
}
static IRegex getRegexConcat() {
return RegexConcat.build(CommandHideShowSpecificStereotype.class.getName(), RegexLeaf.start(), //
new RegexLeaf("COMMAND", "(hide|show)"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("STEREOTYPE", "(\\<\\<.*\\>\\>)"), RegexLeaf.end());
return RegexConcat.build(CommandStyleImport.class.getName(), //
RegexLeaf.start(), //
new RegexLeaf("\\<style"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("\\w+"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("="), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf("[%q%g]?"), //
new RegexLeaf("PATH", "([^%q%g]*)"), //
new RegexLeaf("[%q%g]?"), //
new RegexLeaf("\\>"), RegexLeaf.end()); //
}
@Override
protected CommandExecutionResult executeArg(CucaDiagram diagram, LineLocation location, RegexResult arg) {
// final String stereotype = arg.get("STEREOTYPE", 0);
// diagram.hideOrShow(new Stereotype(stereotype), arg.get("COMMAND", 0).equalsIgnoreCase("show"));
//
// return CommandExecutionResult.ok();
throw new UnsupportedOperationException();
protected CommandExecutionResult executeArg(UmlDiagram diagram, LineLocation location, RegexResult arg) {
final String path = arg.get("PATH", 0);
try {
final File f = FileSystem.getInstance().getFile(path);
if (f.exists() == false) {
return CommandExecutionResult.error("File does not exist: " + path);
}
final BlocLines lines = BlocLines.load(f, location);
final StyleBuilder styleBuilder = diagram.getSkinParam().getCurrentStyleBuilder();
for (Style modifiedStyle : StyleLoader.getDeclaredStyles(lines, styleBuilder)) {
diagram.getSkinParam().muteStyle(modifiedStyle);
}
} catch (IOException e) {
return CommandExecutionResult.error("File does not exist: " + path);
}
return CommandExecutionResult.ok();
}
}

View File

@ -35,32 +35,18 @@
*/
package net.sourceforge.plantuml.style;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.UmlDiagram;
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.IRegex;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
public class CommandStyleMultilinesCSS extends CommandMultilines2<UmlDiagram> {
public static final String STYLE_SELECTOR_SEPARATOR2 = "-&";
public CommandStyleMultilinesCSS() {
super(getRegexConcat(), MultilinesStrategy.REMOVE_STARTING_QUOTE);
}
@ -77,96 +63,15 @@ public class CommandStyleMultilinesCSS extends CommandMultilines2<UmlDiagram> {
);
}
private static final String NAME_USER = "[\\w()]+?";
private final static Pattern2 userName = MyPattern.cmpile("^[.:]?(" + NAME_USER + ")([%s]+\\*)?[%s]*\\{$");
private final static Pattern2 propertyAndValue = MyPattern.cmpile("^([\\w]+):?[%s]+(.*?);?$");
private final static Pattern2 closeBracket = MyPattern.cmpile("^\\}$");
protected CommandExecutionResult executeNow(UmlDiagram diagram, BlocLines lines) {
if (SkinParam.USE_STYLES() == false) {
return CommandExecutionResult.ok();
}
final StyleBuilder styleBuilder = diagram.getSkinParam().getCurrentStyleBuilder();
for (Style modifiedStyle : getDeclaredStyles(lines.subExtract(1, 1), styleBuilder)) {
for (Style modifiedStyle : StyleLoader.getDeclaredStyles(lines.subExtract(1, 1), styleBuilder)) {
diagram.getSkinParam().muteStyle(modifiedStyle);
}
return CommandExecutionResult.ok();
}
public Collection<Style> getDeclaredStyles(BlocLines lines, AutomaticCounter counter) {
final List<Style> result = new ArrayList<Style>();
final List<String> context = new ArrayList<String>();
final List<Map<PName, Value>> maps = new ArrayList<Map<PName, Value>>();
boolean inComment = false;
for (StringLocated s : lines) {
String trimmed = s.getTrimmed().getString();
if (trimmed.startsWith("/*") || trimmed.startsWith("/'")) {
inComment = true;
continue;
}
if (trimmed.endsWith("*/") || trimmed.endsWith("'/")) {
inComment = false;
continue;
}
if (inComment) {
continue;
}
final int x = trimmed.lastIndexOf("//");
if (x != -1) {
trimmed = trimmed.substring(0, x).trim();
}
final Matcher2 mUserName = userName.matcher(trimmed);
if (mUserName.find()) {
String n = mUserName.group(1);
final boolean isRecurse = mUserName.group(2) != null;
if (isRecurse) {
n += "*";
}
context.add(n);
maps.add(new EnumMap<PName, Value>(PName.class));
continue;
}
final Matcher2 mPropertyAndValue = propertyAndValue.matcher(trimmed);
if (mPropertyAndValue.find()) {
final PName key = PName.getFromName(mPropertyAndValue.group(1));
final String value = mPropertyAndValue.group(2);
if (key != null) {
maps.get(maps.size() - 1).put(key, new ValueImpl(value, counter));
}
continue;
}
final Matcher2 mCloseBracket = closeBracket.matcher(trimmed);
if (mCloseBracket.find()) {
if (context.size() > 0) {
final StyleSignature signature = contextToSignature(context);
final Style style = new Style(signature, maps.get(maps.size() - 1));
result.add(style);
context.remove(context.size() - 1);
maps.remove(maps.size() - 1);
}
}
}
return Collections.unmodifiableList(result);
}
private StyleSignature contextToSignature(List<String> context) {
StyleSignature result = StyleSignature.empty();
boolean star = false;
for (Iterator<String> it = context.iterator(); it.hasNext();) {
String s = it.next();
if (s.endsWith("*")) {
star = true;
s = s.substring(0, s.length() - 1);
}
result = result.add(s);
}
if (star) {
result = result.addStar();
}
return result;
}
}

View File

@ -35,154 +35,180 @@
*/
package net.sourceforge.plantuml.style;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
public class FromSkinparamToStyle {
private Style style;
static class Data {
final private PName propertyName;
final private SName[] styleNames;
public FromSkinparamToStyle(String key, String value, AutomaticCounter counter) {
final Map<PName, Value> map = new EnumMap<PName, Value>(PName.class);
String stereo = null;
Data(PName propertyName, SName[] styleNames) {
this.propertyName = propertyName;
this.styleNames = styleNames;
}
}
private static final Map<String, List<Data>> knowlegde = new HashMap<String, List<Data>>();
static {
addConvert("participantClickableBackgroundColor", PName.BackGroundColor, SName.participant, SName.clickable);
addConvert("participantClickableBorderColor", PName.LineColor, SName.participant, SName.clickable);
addConvert("participantBackgroundColor", PName.BackGroundColor, SName.participant);
addConvert("participantBorderColor", PName.LineColor, SName.participant);
addConvert("participantBorderThickness", PName.LineThickness, SName.participant);
addConFont("participant", SName.participant);
addConvert("boundaryBackgroundColor", PName.BackGroundColor, SName.boundary);
addConvert("boundaryBorderColor", PName.LineColor, SName.boundary);
addConvert("boundaryBorderThickness", PName.LineThickness, SName.boundary);
addConFont("boundary", SName.boundary);
addConvert("controlBackgroundColor", PName.BackGroundColor, SName.control);
addConvert("controlBorderColor", PName.LineColor, SName.control);
addConvert("controlBorderThickness", PName.LineThickness, SName.control);
addConFont("control", SName.control);
addConvert("collectionsBackgroundColor", PName.BackGroundColor, SName.collections);
addConvert("collectionsBorderColor", PName.LineColor, SName.collections);
addConvert("collectionsBorderThickness", PName.LineThickness, SName.collections);
addConFont("collections", SName.collections);
addConvert("actorBackgroundColor", PName.BackGroundColor, SName.actor);
addConvert("actorBorderColor", PName.LineColor, SName.actor);
addConvert("actorBorderThickness", PName.LineThickness, SName.actor);
addConFont("actor", SName.actor);
addConvert("databaseBackgroundColor", PName.BackGroundColor, SName.database);
addConvert("databaseBorderColor", PName.LineColor, SName.database);
addConvert("databaseBorderThickness", PName.LineThickness, SName.database);
addConFont("database", SName.database);
addConvert("entityBackgroundColor", PName.BackGroundColor, SName.entity);
addConvert("entityBorderColor", PName.LineColor, SName.entity);
addConvert("entityBorderThickness", PName.LineThickness, SName.entity);
addConFont("entity", SName.entity);
addConFont("footer", SName.footer);
addConvert("SequenceReferenceBorderColor", PName.LineColor, SName.reference);
addConvert("SequenceReferenceBorderColor", PName.LineColor, SName.referenceHeader);
addConvert("SequenceReferenceBackgroundColor", PName.BackGroundColor, SName.reference);
addConvert("sequenceReferenceHeaderBackgroundColor", PName.BackGroundColor, SName.referenceHeader);
addConFont("sequenceReference", SName.reference);
addConFont("sequenceReference", SName.referenceHeader);
addConvert("SequenceGroupBorderColor", PName.LineColor, SName.group);
addConvert("SequenceGroupBorderColor", PName.LineColor, SName.groupHeader);
addConvert("SequenceGroupBackgroundColor", PName.BackGroundColor, SName.groupHeader);
addConFont("SequenceGroupHeader", SName.groupHeader);
addConvert("SequenceBoxBorderColor", PName.LineColor, SName.box);
addConvert("SequenceBoxBackgroundColor", PName.BackGroundColor, SName.box);
addConvert("SequenceLifeLineBorderColor", PName.LineColor, SName.lifeLine);
addConvert("sequenceDividerBackgroundColor", PName.BackGroundColor, SName.separator);
addConvert("sequenceDividerBorderColor", PName.LineColor, SName.separator);
addConFont("sequenceDivider", SName.separator);
addConvert("sequenceDividerBorderThickness", PName.LineThickness, SName.separator);
addConvert("SequenceMessageAlignment", PName.HorizontalAlignment, SName.arrow);
addConFont("note", SName.note);
addConvert("noteBackgroundColor", PName.BackGroundColor, SName.note);
addConvert("packageBackgroundColor", PName.BackGroundColor, SName.group);
addConvert("packageBorderColor", PName.LineColor, SName.group);
addConvert("PartitionBorderColor", PName.LineColor, SName.partition);
addConvert("PartitionBackgroundColor", PName.BackGroundColor, SName.partition);
addConFont("Partition", SName.partition);
addConvert("hyperlinkColor", PName.HyperLinkColor, SName.root);
addConvert("activityStartColor", PName.LineColor, SName.circle);
addConvert("activityBarColor", PName.LineColor, SName.activityBar);
addConvert("activityBorderColor", PName.LineColor, SName.activity);
addConvert("activityBorderThickness", PName.LineThickness, SName.activity);
addConvert("activityBackgroundColor", PName.BackGroundColor, SName.activity);
addConFont("activity", SName.activity);
addConvert("activityDiamondBackgroundColor", PName.BackGroundColor, SName.diamond);
addConvert("activityDiamondBorderColor", PName.LineColor, SName.diamond);
addConFont("activityDiamond", SName.diamond);
addConvert("arrowColor", PName.LineColor, SName.arrow);
addConFont("arrow", SName.arrow);
addConvert("defaulttextalignment", PName.HorizontalAlignment, SName.root);
addConvert("defaultFontName", PName.FontName, SName.root);
addConFont("SwimlaneTitle", SName.swimlane);
addConvert("SwimlaneTitleBackgroundColor", PName.BackGroundColor, SName.swimlane);
addConvert("SwimlaneBorderColor", PName.LineColor, SName.swimlane);
addConvert("SwimlaneBorderThickness", PName.LineThickness, SName.swimlane);
addConvert("roundCorner", PName.RoundCorner, SName.root);
addConvert("titleBorderThickness", PName.LineThickness, SName.title);
addConvert("titleBorderColor", PName.LineColor, SName.title);
addConvert("titleBackgroundColor", PName.BackGroundColor, SName.title);
addConvert("titleBorderRoundCorner", PName.RoundCorner, SName.title);
addConFont("title", SName.title);
addConvert("legendBorderThickness", PName.LineThickness, SName.legend);
addConvert("legendBorderColor", PName.LineColor, SName.legend);
addConvert("legendBackgroundColor", PName.BackGroundColor, SName.legend);
addConvert("legendBorderRoundCorner", PName.RoundCorner, SName.legend);
addConFont("legend", SName.legend);
addConvert("noteTextAlignment", PName.HorizontalAlignment, SName.note);
}
private final List<Style> styles = new ArrayList<Style>();
private String stereo = null;
public FromSkinparamToStyle(String key, final String value, final AutomaticCounter counter) {
if (key.contains("<<")) {
final StringTokenizer st = new StringTokenizer(key, "<>");
key = st.nextToken();
stereo = st.nextToken();
}
SName styleName = null;
if (key.equalsIgnoreCase("participantBackgroundColor")) {
styleName = SName.participant;
map.put(PName.BackGroundColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("footerFontColor")) {
styleName = SName.footer;
map.put(PName.FontColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("footerFontSize")) {
styleName = SName.footer;
map.put(PName.FontSize, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("SequenceGroupBorderColor")) {
styleName = SName.group;
map.put(PName.LineColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("SequenceBoxBorderColor")) {
styleName = SName.box;
map.put(PName.LineColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("SequenceBoxBackgroundColor")) {
styleName = SName.box;
map.put(PName.BackGroundColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("SequenceLifeLineBorderColor")) {
styleName = SName.lifeLine;
map.put(PName.LineColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("noteFontColor")) {
styleName = SName.note;
map.put(PName.FontColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("noteBackgroundColor")) {
styleName = SName.note;
map.put(PName.BackGroundColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("noteBackgroundColor")) {
styleName = SName.note;
map.put(PName.BackGroundColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("packageBackgroundColor")) {
styleName = SName.group;
map.put(PName.BackGroundColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("packageBorderColor")) {
styleName = SName.group;
map.put(PName.LineColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("PartitionBorderColor")) {
styleName = SName.partition;
map.put(PName.LineColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("PartitionBackgroundColor")) {
styleName = SName.partition;
map.put(PName.BackGroundColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("PartitionFontColor")) {
styleName = SName.partition;
map.put(PName.FontColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("PartitionFontSize")) {
styleName = SName.partition;
map.put(PName.FontSize, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("hyperlinkColor")) {
styleName = SName.root;
map.put(PName.HyperLinkColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("activityStartColor")) {
styleName = SName.circle;
map.put(PName.LineColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("activityBarColor")) {
styleName = SName.activityBar;
map.put(PName.LineColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("activityBorderColor")) {
styleName = SName.activity;
map.put(PName.LineColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("activityBorderThickness")) {
styleName = SName.activity;
map.put(PName.LineThickness, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("activityBackgroundColor")) {
styleName = SName.activity;
map.put(PName.BackGroundColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("activityFontColor")) {
styleName = SName.activity;
map.put(PName.FontColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("activityFontSize")) {
styleName = SName.activity;
map.put(PName.FontSize, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("activityFontName")) {
styleName = SName.activity;
map.put(PName.FontName, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("activityDiamondBackgroundColor")) {
styleName = SName.diamond;
map.put(PName.BackGroundColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("activityDiamondBorderColor")) {
styleName = SName.diamond;
map.put(PName.LineColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("activityDiamondFontSize")) {
styleName = SName.diamond;
map.put(PName.FontSize, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("activityDiamondFontColor")) {
styleName = SName.diamond;
map.put(PName.FontColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("arrowColor")) {
styleName = SName.arrow;
map.put(PName.LineColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("arrowFontColor")) {
styleName = SName.arrow;
map.put(PName.FontColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("defaulttextalignment")) {
styleName = SName.root;
map.put(PName.HorizontalAlignment, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("defaultFontName")) {
styleName = SName.root;
map.put(PName.FontName, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("SwimlaneTitleFontColor")) {
styleName = SName.swimlane;
map.put(PName.FontColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("SwimlaneTitleFontSize")) {
styleName = SName.swimlane;
map.put(PName.FontSize, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("SwimlaneTitleBackgroundColor")) {
styleName = SName.swimlane;
map.put(PName.BackGroundColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("SwimlaneBorderColor")) {
styleName = SName.swimlane;
map.put(PName.LineColor, new ValueImpl(value, counter));
} else if (key.equalsIgnoreCase("SwimlaneBorderThickness")) {
styleName = SName.swimlane;
map.put(PName.LineThickness, new ValueImpl(value, counter));
final List<Data> datas = knowlegde.get(key.toLowerCase());
if (datas != null) {
for (Data data : datas) {
addStyle(data.propertyName, new ValueImpl(value, counter), data.styleNames);
}
} else if (key.equalsIgnoreCase("shadowing")) {
styleName = SName.root;
addStyle(PName.Shadowing, getShadowingValue(value, counter), SName.root);
} else if (key.equalsIgnoreCase("noteshadowing")) {
addStyle(PName.Shadowing, getShadowingValue(value, counter), SName.root, SName.note);
}
}
private ValueImpl getShadowingValue(final String value, final AutomaticCounter counter) {
if (value.equalsIgnoreCase("false") || value.equalsIgnoreCase("no")) {
map.put(PName.Shadowing, new ValueImpl("0", counter));
return new ValueImpl("0", counter);
}
if (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes")) {
return new ValueImpl("3", counter);
}
if (styleName != null && map.size() > 0) {
String tmp = styleName.name();
return new ValueImpl(value, counter);
}
private void addStyle(PName propertyName, Value value, SName... styleNames) {
final Map<PName, Value> map = new EnumMap<PName, Value>(PName.class);
map.put(propertyName, value);
StyleSignature sig = StyleSignature.of(styleNames);
if (stereo != null) {
tmp = tmp + "&" + stereo;
}
style = new Style(tmp, map);
sig = sig.add(stereo);
}
styles.add(new Style(sig, map));
}
public Style getStyle() {
return style;
public List<Style> getStyles() {
return Collections.unmodifiableList(styles);
}
private static void addConvert(String skinparam, PName propertyName, SName... styleNames) {
skinparam = skinparam.toLowerCase();
List<Data> datas = knowlegde.get(skinparam);
if (datas == null) {
datas = new ArrayList<Data>();
knowlegde.put(skinparam, datas);
}
datas.add(new Data(propertyName, styleNames));
}
private static void addConFont(String skinparam, SName... styleNames) {
addConvert(skinparam + "FontSize", PName.FontSize, styleNames);
addConvert(skinparam + "FontStyle", PName.FontStyle, styleNames);
addConvert(skinparam + "FontColor", PName.FontColor, styleNames);
addConvert(skinparam + "FontName", PName.FontName, styleNames);
}
}

View File

@ -43,6 +43,7 @@ public enum SName {
legend,
caption,
element,
clickable,
sequenceDiagram,
destroy,
lifeLine,

View File

@ -62,11 +62,6 @@ public class Style {
private final Map<PName, Value> map;
private final StyleSignature signature;
public Style(String name, Map<PName, Value> map) {
this.map = map;
this.signature = StyleSignature.build(name);
}
public Style(StyleSignature signature, Map<PName, Value> map) {
this.map = map;
this.signature = signature;
@ -119,7 +114,11 @@ public class Style {
if (colors != null) {
final HtmlColor back = colors.getColor(ColorType.BACK);
if (back != null) {
result = this.eventuallyOverride(PName.BackGroundColor, back);
result = result.eventuallyOverride(PName.BackGroundColor, back);
}
final HtmlColor line = colors.getColor(ColorType.LINE);
if (line != null) {
result = result.eventuallyOverride(PName.LineColor, line);
}
}
return result;
@ -188,13 +187,16 @@ public class Style {
return value(PName.HorizontalAlignment).asHorizontalAlignment();
}
private TextBlock createTextBlockInternal(Display display, IHtmlColorSet set, ISkinSimple spriteContainer) {
private TextBlock createTextBlockInternal(Display display, IHtmlColorSet set, ISkinSimple spriteContainer,
HorizontalAlignment alignment) {
final FontConfiguration fc = getFontConfiguration(set);
return display.create(fc, HorizontalAlignment.LEFT, spriteContainer);
return display.create(fc, alignment, spriteContainer);
}
public TextBlock createTextBlockBordered(Display note, IHtmlColorSet set, ISkinSimple spriteContainer) {
final TextBlock textBlock = this.createTextBlockInternal(note, set, spriteContainer);
// final HorizontalAlignment alignment = HorizontalAlignment.LEFT;
final HorizontalAlignment alignment = this.getHorizontalAlignment();
final TextBlock textBlock = this.createTextBlockInternal(note, set, spriteContainer, alignment);
final HtmlColor legendBackgroundColor = this.value(PName.BackGroundColor).asColor(set);
final HtmlColor legendColor = this.value(PName.LineColor).asColor(set);

View File

@ -39,13 +39,23 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.sourceforge.plantuml.FileSystem;
import net.sourceforge.plantuml.LineLocationImpl;
import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.StringLocated;
import net.sourceforge.plantuml.command.BlocLines;
import net.sourceforge.plantuml.command.CommandControl;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.command.regex.MyPattern;
import net.sourceforge.plantuml.command.regex.Pattern2;
public class StyleLoader {
@ -86,10 +96,91 @@ public class StyleLoader {
}
private void loadSkinInternal(final BlocLines lines) {
final CommandStyleMultilinesCSS cmd2 = new CommandStyleMultilinesCSS();
for (Style newStyle : cmd2.getDeclaredStyles(lines, styleBuilder)) {
for (Style newStyle : getDeclaredStyles(lines, styleBuilder)) {
this.styleBuilder.put(newStyle.getSignature(), newStyle);
}
}
private static final String NAME_USER = "[\\w()]+?";
private final static Pattern2 userName = MyPattern.cmpile("^[.:]?(" + NAME_USER + ")([%s]+\\*)?[%s]*\\{$");
private final static Pattern2 propertyAndValue = MyPattern.cmpile("^([\\w]+):?[%s]+(.*?);?$");
private final static Pattern2 closeBracket = MyPattern.cmpile("^\\}$");
public static Collection<Style> getDeclaredStyles(BlocLines lines, AutomaticCounter counter) {
lines = lines.eventuallyMoveAllEmptyBracket();
final List<Style> result = new ArrayList<Style>();
final List<String> context = new ArrayList<String>();
final List<Map<PName, Value>> maps = new ArrayList<Map<PName, Value>>();
boolean inComment = false;
for (StringLocated s : lines) {
String trimmed = s.getTrimmed().getString();
if (trimmed.startsWith("/*") || trimmed.startsWith("/'")) {
inComment = true;
continue;
}
if (trimmed.endsWith("*/") || trimmed.endsWith("'/")) {
inComment = false;
continue;
}
if (inComment) {
continue;
}
final int x = trimmed.lastIndexOf("//");
if (x != -1) {
trimmed = trimmed.substring(0, x).trim();
}
final Matcher2 mUserName = userName.matcher(trimmed);
if (mUserName.find()) {
String n = mUserName.group(1);
final boolean isRecurse = mUserName.group(2) != null;
if (isRecurse) {
n += "*";
}
context.add(n);
maps.add(new EnumMap<PName, Value>(PName.class));
continue;
}
final Matcher2 mPropertyAndValue = propertyAndValue.matcher(trimmed);
if (mPropertyAndValue.find()) {
final PName key = PName.getFromName(mPropertyAndValue.group(1));
final String value = mPropertyAndValue.group(2);
if (key != null) {
maps.get(maps.size() - 1).put(key, new ValueImpl(value, counter));
}
continue;
}
final Matcher2 mCloseBracket = closeBracket.matcher(trimmed);
if (mCloseBracket.find()) {
if (context.size() > 0) {
final StyleSignature signature = contextToSignature(context);
final Style style = new Style(signature, maps.get(maps.size() - 1));
result.add(style);
context.remove(context.size() - 1);
maps.remove(maps.size() - 1);
}
}
}
return Collections.unmodifiableList(result);
}
private static StyleSignature contextToSignature(List<String> context) {
StyleSignature result = StyleSignature.empty();
boolean star = false;
for (Iterator<String> it = context.iterator(); it.hasNext();) {
String s = it.next();
if (s.endsWith("*")) {
star = true;
s = s.substring(0, s.length() - 1);
}
result = result.add(s);
}
if (star) {
result = result.addStar();
}
return result;
}
}

View File

@ -42,28 +42,14 @@ import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
public class StyleSignature {
private final Set<String> names = new LinkedHashSet<String>();
public static StyleSignature build(String name) {
final StyleSignature result = new StyleSignature();
for (StringTokenizer st = new StringTokenizer(name.toLowerCase(),
CommandStyleMultilinesCSS.STYLE_SELECTOR_SEPARATOR2); st.hasMoreTokens();) {
String token = st.nextToken();
if (token.endsWith("*")) {
throw new IllegalArgumentException();
// token = token.substring(0, token.length() - 1);
}
result.names.add(token);
}
return result;
}
public StyleSignature(String s) {
if (s.contains("*") || s.contains("&") || s.contains("-")) {
throw new IllegalArgumentException();
@ -82,6 +68,16 @@ public class StyleSignature {
this.names.addAll(copy);
}
public StyleSignature addClickable(Url url) {
if (url == null) {
return this;
}
final Set<String> result = new HashSet<String>(names);
result.add(SName.clickable.name());
return new StyleSignature(result);
}
public StyleSignature add(String s) {
if (s == null) {
return this;
@ -200,7 +196,7 @@ public class StyleSignature {
public boolean match(Stereotype stereotype) {
for (String s : stereotype.getMultipleLabels()) {
if (names.contains(s)) {
if (names.contains(s.toLowerCase())) {
return true;
}
}

View File

@ -59,6 +59,7 @@ import javax.xml.transform.stream.StreamResult;
import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.SignatureUtils;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.SvgString;
import net.sourceforge.plantuml.code.Base64Coder;
@ -807,7 +808,15 @@ public class SvgGraphics {
this.hidden = hidden;
}
public static final String MD5_HEADER = "<!--MD5=[";
public static String getMD5Hex(String comment) {
return SignatureUtils.getMD5Hex(comment);
}
public void addComment(String comment) {
final String signature = getMD5Hex(comment);
comment = "MD5=[" + signature + "]\n" + comment;
final Comment commentElement = document.createComment(comment);
getG().appendChild(commentElement);
}

View File

@ -496,6 +496,8 @@ public class TikzGraphics {
sb.append(couple(coord[4] + x, coord[5] + y));
} else if (type == USegmentType.SEG_CLOSE) {
// Nothing
} else if (type == USegmentType.SEG_ARCTO) {
// Nothing
} else {
Log.println("unknown4 " + seg);
}

View File

@ -77,6 +77,9 @@ public abstract class Eater {
}
final TokenStack tokenStack = new TokenStack();
addIntoTokenStack(tokenStack, false);
if (tokenStack.size() == 0) {
throw new EaterException("Missing expression");
}
return tokenStack.getResult(context, memory);
}

View File

@ -93,4 +93,8 @@ public class EaterFunctionCall extends Eater {
return Collections.unmodifiableList(values);
}
public final String getEndOfLine() throws EaterException {
return this.eatAllToEnd();
}
}

View File

@ -577,6 +577,8 @@ public class TContext {
}
private void executeIncludesub(TMemory memory, StringLocated s) throws EaterException {
ImportedFiles saveImportedFiles = null;
try {
final EaterIncludesub include = new EaterIncludesub(s.getTrimmed().getString());
include.execute(this, memory);
final String location = include.getLocation();
@ -588,6 +590,8 @@ public class TContext {
try {
final FileWithSuffix f2 = new FileWithSuffix(importedFiles, filename, null);
if (f2.fileOk()) {
saveImportedFiles = this.importedFiles;
this.importedFiles = this.importedFiles.withCurrentDir(f2.getParentFile());
final Reader reader = f2.getReader(charset);
ReadLine readerline = ReadLineReader.create(reader, location, s.getLocation());
readerline = new UncommentReadLine(readerline);
@ -605,6 +609,11 @@ public class TContext {
throw new EaterException("cannot include " + location);
}
runSub(memory, sub);
} finally {
if (saveImportedFiles != null) {
this.importedFiles = saveImportedFiles;
}
}
}
private void runSub(TMemory memory, final Sub2 sub) throws EaterException {
@ -671,6 +680,9 @@ public class TContext {
reader2 = StartDiagramExtractReader.build(f2, s, charset);
} else {
final Reader reader = f2.getReader(charset);
if (reader == null) {
throw new EaterException("Cannot include file");
}
reader2 = ReadLineReader.create(reader, location, s.getLocation());
}
saveImportedFiles = this.importedFiles;
@ -798,4 +810,13 @@ public class TContext {
return sb.toString();
}
public void appendEndOfLine(String endOfLine) {
if (endOfLine.length() > 0) {
final int idx = resultList.size() - 1;
StringLocated last = resultList.get(idx);
last = last.append(endOfLine);
resultList.set(idx, last);
}
}
}

View File

@ -85,8 +85,10 @@ public class TFunctionImpl implements TFunction {
final EaterFunctionCall call = new EaterFunctionCall(s, context.isLegacyDefine(signature.getFunctionName()),
unquoted);
call.execute(context, memory);
final String endOfLine = call.getEndOfLine();
final List<TValue> args = call.getValues();
executeVoidInternal(context, memory, args);
context.appendEndOfLine(endOfLine);
}
public void executeVoidInternal(TContext context, TMemory memory, List<TValue> args) throws EaterException {
@ -114,7 +116,7 @@ public class TFunctionImpl implements TFunction {
return executeReturnLegacyDefine(context, memory, args);
}
if (functionType != TFunctionType.RETURN) {
throw new IllegalStateException();
throw new EaterException("Illegal call here");
}
final TMemory copy = getNewMemory(memory, args);

View File

@ -59,6 +59,10 @@ public class TokenStack {
this.tokens = list;
}
public int size() {
return tokens.size();
}
public TokenStack subTokenStack(int i) {
return new TokenStack(Collections.unmodifiableList(tokens.subList(i, tokens.size())));
}

View File

@ -76,7 +76,7 @@ abstract class CommandChangeState extends SingleLineCommand2<TimingDiagram> {
static IRegex getStateOrHidden() {
return new RegexOr(//
new RegexLeaf("STATE1", "[%g]([^%g]+)[%g]"), //
new RegexLeaf("STATE1", "[%g]([^%g]*)[%g]"), //
new RegexLeaf("STATE2", STATE_CODE), //
new RegexLeaf("STATE3", "(\\{hidden\\})"), //
new RegexLeaf("STATE4", "(\\{\\.\\.\\.\\})"), //

View File

@ -109,16 +109,16 @@ public class TimingRuler {
return highestCommonFactorInternal;
}
private int getNbTick() {
private int getNbTick(boolean capped) {
if (times.size() == 0) {
return 1;
}
final long delta = getMax().getTime().longValue() - getMin().getTime().longValue();
return (int) (1 + delta / tickUnitary());
return Math.min(1000, (int) (1 + delta / tickUnitary()));
}
public double getWidth() {
return getNbTick() * tickIntervalInPixels;
return getNbTick(false) * tickIntervalInPixels;
}
public final double getPosInPixel(TimeTick when) {
@ -151,7 +151,7 @@ public class TimingRuler {
ug = ug.apply(new UStroke(2.0)).apply(new UChangeColor(HtmlColorUtils.BLACK));
final double tickHeight = 5;
final ULine line = new ULine(0, tickHeight);
final int nb = getNbTick();
final int nb = getNbTick(true);
for (int i = 0; i <= nb; i++) {
ug.apply(new UTranslate(tickIntervalInPixels * i, 0)).draw(line);
}
@ -172,7 +172,7 @@ public class TimingRuler {
result.add(round);
}
} else {
final int nb = getNbTick();
final int nb = getNbTick(true);
for (int i = 0; i <= nb; i++) {
final long round = tickUnitary * i;
result.add(round);
@ -187,7 +187,7 @@ public class TimingRuler {
public void draw0(UGraphic ug, double height) {
ug = ug.apply(new UStroke(3, 5, 0.5)).apply(new UChangeColor(new HtmlColorSetSimple().getColorIfValid("#AAA")));
final ULine line = new ULine(0, height);
final int nb = getNbTick();
final int nb = getNbTick(true);
for (int i = 0; i <= nb; i++) {
ug.apply(new UTranslate(tickIntervalInPixels * i, 0)).draw(line);
}

View File

@ -46,6 +46,7 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.Semaphore;
@ -79,7 +80,6 @@ import net.sourceforge.plantuml.graphic.HtmlColorSimple;
import net.sourceforge.plantuml.graphic.HtmlColorTransparent;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.mjpeg.MJPEGGenerator;
import net.sourceforge.plantuml.skin.rose.Rose;
@ -114,6 +114,7 @@ public class ImageBuilder {
private double borderCorner;
private boolean svgDimensionStyle;
private boolean randomPixel;
public ImageBuilder(ColorMapper colorMapper, double dpiFactor, HtmlColor mybackcolor, String metadata,
String warningOrError, double margin1, double margin2, Animation animation, boolean useHandwritten) {
@ -247,6 +248,9 @@ public class ImageBuilder {
- externalMargin() - borderStroke.getThickness(), borderCorner, borderCorner);
ug2.apply(new UChangeColor(color)).apply(borderStroke).draw(shape);
}
if (randomPixel) {
drawRandomPoint(ug2);
}
if (externalMargin1 > 0) {
ug2 = ug2.apply(new UTranslate(externalMargin2, externalMargin2));
}
@ -273,6 +277,17 @@ public class ImageBuilder {
}
private void drawRandomPoint(UGraphic ug2) {
final Random rnd = new Random();
final int red = rnd.nextInt(40);
final int green = rnd.nextInt(40);
final int blue = rnd.nextInt(40);
final Color c = new Color(red, green, blue);
final HtmlColor color = new HtmlColorSimple(c, false);
ug2.apply(new UChangeColor(color)).apply(new UChangeBackColor(color)).draw(new URectangle(1, 1));
}
private double externalMargin() {
return 2 * (externalMargin1 + externalMargin2);
}
@ -452,4 +467,9 @@ public class ImageBuilder {
return ug;
}
public void setRandomPixel(boolean randomPixel) {
this.randomPixel = randomPixel;
}
}

Some files were not shown because too many files have changed in this diff Show More