1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-05 21:17:52 +00:00

version 8058

This commit is contained in:
Arnaud Roques 2017-03-12 18:22:02 +01:00
parent 73307b6df5
commit cb762a8f11
155 changed files with 2121 additions and 644 deletions

View File

@ -30,13 +30,16 @@
*/
package net.sourceforge.plantuml;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.sourceforge.plantuml.code.AsciiEncoder;
import net.sourceforge.plantuml.command.regex.Matcher2;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.utils.StartUtils;
import net.sourceforge.plantuml.version.Version;
public class BlockUml {
@ -125,4 +128,31 @@ public class BlockUml {
return data;
}
private String internalEtag() {
try {
final AsciiEncoder coder = new AsciiEncoder();
final MessageDigest msgDigest = MessageDigest.getInstance("MD5");
for (CharSequence s : data) {
msgDigest.update(s.toString().getBytes("UTF-8"));
}
final byte[] digest = msgDigest.digest();
return coder.encode(digest);
} catch (Exception e) {
e.printStackTrace();
return "NOETAG";
}
}
public String etag() {
final StringBuilder result = new StringBuilder();
result.append(Integer.toString(Version.version(), 36));
result.append(Integer.toString(Version.beta(), 36));
result.append(internalEtag());
return result.toString();
}
public long lastModified() {
return (Version.compileTime() / 1000L / 60) * 1000L * 60 + Version.beta() * 1000L * 3600;
}
}

View File

@ -0,0 +1,55 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* 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;
import java.io.File;
import net.sourceforge.plantuml.core.ImageData;
public class FileImageData {
private final File file;
private final ImageData imageData;
public FileImageData(File file, ImageData imageData) {
this.file = file;
this.imageData = imageData;
}
public File getFile() {
return file;
}
public ImageData getImageData() {
return imageData;
}
}

View File

@ -86,4 +86,7 @@ public class GeneratedImageImpl implements GeneratedImage {
return this2.pngFile.equals(this.pngFile) && this2.description.equals(this.description);
}
public BlockUml getBlockUml() {
return blockUml;
}
}

View File

@ -40,11 +40,13 @@ public abstract class Log {
public synchronized static void info(String s) {
if (OptionFlags.getInstance().isVerbose()) {
ProgressBar.clear();
System.out.println(format(s));
}
}
public synchronized static void error(String s) {
ProgressBar.clear();
System.err.println(s);
}

View File

@ -41,7 +41,6 @@ import net.sourceforge.plantuml.command.Command;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
public class NewpagedDiagram extends AbstractPSystem {
@ -114,7 +113,7 @@ public class NewpagedDiagram extends AbstractPSystem {
}
sb.append(d.getDescription());
}
return new DiagramDescriptionImpl(sb.toString(), getClass());
return new DiagramDescription(sb.toString());
}
public String getWarningOrError() {

View File

@ -65,6 +65,8 @@ public class Option {
private boolean pattern = false;
private boolean duration = false;
private boolean debugsvek = false;
private boolean splash = false;
private boolean textProgressBar = false;
private int nbThreads = 0;
private int ftpPort = -1;
@ -268,6 +270,10 @@ public class Option {
StatsUtils.setRealTimeStats(true);
} else if (s.equalsIgnoreCase("-useseparatorminus")) {
OptionFlags.getInstance().setFileSeparator("-");
} else if (s.equalsIgnoreCase("-splash")) {
splash = true;
} else if (s.equalsIgnoreCase("-progress")) {
textProgressBar = true;
} else if (StringUtils.goLowerCase(s).startsWith("-ftp")) {
final int x = s.indexOf(':');
if (x == -1) {
@ -456,4 +462,16 @@ public class Option {
return debugsvek;
}
public final boolean isSplash() {
return splash;
}
public final void setSplash(boolean splash) {
this.splash = splash;
}
public final boolean isTextProgressBar() {
return textProgressBar;
}
}

View File

@ -125,6 +125,8 @@ public class OptionPrint {
System.out.println(" -xmlstats\t\tTo output general statistics in file plantuml-stats.xml");
System.out.println(" -realtimestats\tTo generate statistics on the fly rather than at the end");
System.out.println(" -loopstats\t\tTo continuously print statistics about usage");
System.out.println(" -splash\t\tTo display a splash screen with some progress bar");
System.out.println(" -progress\t\tTo display a textual progress bar in console");
System.out.println();
System.out.println("If needed, you can setup the environment variable GRAPHVIZ_DOT.");
exit();

View File

@ -51,6 +51,7 @@ import net.sourceforge.plantuml.ditaa.PSystemDitaaFactory;
import net.sourceforge.plantuml.donors.PSystemDonorsFactory;
import net.sourceforge.plantuml.eggs.PSystemAppleTwoFactory;
import net.sourceforge.plantuml.eggs.PSystemCharlieFactory;
import net.sourceforge.plantuml.eggs.PSystemColorsFactory;
import net.sourceforge.plantuml.eggs.PSystemEggFactory;
import net.sourceforge.plantuml.eggs.PSystemEmptyFactory;
import net.sourceforge.plantuml.eggs.PSystemLostFactory;
@ -121,6 +122,7 @@ public class PSystemBuilder {
private List<PSystemFactory> getAllFactories() {
final List<PSystemFactory> factories = new ArrayList<PSystemFactory>();
factories.add(new PSystemEmptyFactory());
factories.add(new PSystemColorsFactory());
factories.add(new SequenceDiagramFactory());
factories.add(new ClassDiagramFactory());
factories.add(new ActivityDiagramFactory());

View File

@ -42,17 +42,16 @@ import java.util.List;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.asciiart.UmlCharArea;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.eggs.PSystemEmpty;
import net.sourceforge.plantuml.graphic.GraphicPosition;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UTranslate;
@ -125,7 +124,7 @@ public class PSystemError extends AbstractPSystem {
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, result.getBackcolor(),
getMetadata(), null, 0, 0, null, false);
if (getSource().getTotalLineCount() < 4) {
final TextBlockBackcolored welcome = new PSystemEmpty(false).getGraphicStrings();
final TextBlockBackcolored welcome = new PSystemEmpty(GraphicPosition.BACKGROUND_CORNER_TOP_RIGHT).getGraphicStrings();
udrawable = new UDrawable() {
public void drawU(UGraphic ug) {
final Dimension2D dim1 = welcome.calculateDimension(ug.getStringBounder());
@ -334,7 +333,7 @@ public class PSystemError extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Error)", getClass());
return new DiagramDescription("(Error)");
}
public final int getHigherErrorPosition() {

View File

@ -50,8 +50,8 @@ import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
public class PSystemUtils {
public static List<File> exportDiagrams(Diagram system, File suggestedFile, FileFormatOption fileFormatOption)
throws IOException {
public static List<FileImageData> exportDiagrams(Diagram system, File suggestedFile,
FileFormatOption fileFormatOption) throws IOException {
if (system instanceof NewpagedDiagram) {
return exportDiagramsNewpaged((NewpagedDiagram) system, suggestedFile, fileFormatOption);
}
@ -67,9 +67,9 @@ public class PSystemUtils {
return exportDiagramsDefault(system, suggestedFile, fileFormatOption);
}
private static List<File> exportDiagramsNewpaged(NewpagedDiagram system, File suggestedFile,
private static List<FileImageData> exportDiagramsNewpaged(NewpagedDiagram system, File suggestedFile,
FileFormatOption fileFormat) throws IOException {
final List<File> result = new ArrayList<File>();
final List<FileImageData> result = new ArrayList<FileImageData>();
final int nbImages = system.getNbImages();
for (int i = 0; i < nbImages; i++) {
@ -78,9 +78,9 @@ public class PSystemUtils {
return result;
}
final OutputStream fos = new BufferedOutputStream(new FileOutputStream(f));
// ImageData cmap = null;
ImageData cmap = null;
try {
/* cmap = */system.exportDiagram(fos, i, fileFormat);
system.exportDiagram(fos, i, fileFormat);
} finally {
fos.close();
}
@ -88,7 +88,7 @@ public class PSystemUtils {
// system.exportCmap(suggestedFile, cmap);
// }
Log.info("File size : " + f.length());
result.add(f);
result.add(new FileImageData(f, cmap));
}
return result;
}
@ -108,40 +108,42 @@ public class PSystemUtils {
return true;
}
static private List<File> exportDiagramsDefault(Diagram system, File suggestedFile, FileFormatOption fileFormat)
throws IOException {
static private List<FileImageData> exportDiagramsDefault(Diagram system, File suggestedFile,
FileFormatOption fileFormat) throws IOException {
if (suggestedFile.exists() && suggestedFile.isDirectory()) {
throw new IllegalArgumentException("File is a directory " + suggestedFile);
}
OutputStream os = null;
ImageData imageData = null;
try {
if (canFileBeWritten(suggestedFile) == false) {
return Collections.emptyList();
}
os = new BufferedOutputStream(new FileOutputStream(suggestedFile));
// system.exportDiagram(os, null, 0, fileFormat);
system.exportDiagram(os, 0, fileFormat);
imageData = system.exportDiagram(os, 0, fileFormat);
} finally {
if (os != null) {
os.close();
}
}
return Arrays.asList(suggestedFile);
return Arrays.asList(new FileImageData(suggestedFile, imageData));
}
static private List<File> exportDiagramsActivityDiagram3(ActivityDiagram3 system, File suggestedFile,
static private List<FileImageData> exportDiagramsActivityDiagram3(ActivityDiagram3 system, File suggestedFile,
FileFormatOption fileFormat) throws IOException {
if (suggestedFile.exists() && suggestedFile.isDirectory()) {
throw new IllegalArgumentException("File is a directory " + suggestedFile);
}
OutputStream os = null;
ImageData cmap = null;
ImageData imageData = null;
try {
if (canFileBeWritten(suggestedFile) == false) {
return Collections.emptyList();
}
os = new BufferedOutputStream(new FileOutputStream(suggestedFile));
cmap = system.exportDiagram(os, 0, fileFormat);
imageData = cmap = system.exportDiagram(os, 0, fileFormat);
} finally {
if (os != null) {
os.close();
@ -150,12 +152,12 @@ public class PSystemUtils {
if (cmap != null && cmap.containsCMapData()) {
system.exportCmap(suggestedFile, cmap);
}
return Arrays.asList(suggestedFile);
return Arrays.asList(new FileImageData(suggestedFile, imageData));
}
private static List<File> exportDiagramsSequence(SequenceDiagram system, File suggestedFile,
private static List<FileImageData> exportDiagramsSequence(SequenceDiagram system, File suggestedFile,
FileFormatOption fileFormat) throws IOException {
final List<File> result = new ArrayList<File>();
final List<FileImageData> result = new ArrayList<FileImageData>();
final int nbImages = system.getNbImages();
for (int i = 0; i < nbImages; i++) {
@ -174,13 +176,13 @@ public class PSystemUtils {
system.exportCmap(suggestedFile, cmap);
}
Log.info("File size : " + f.length());
result.add(f);
result.add(new FileImageData(f, cmap));
}
return result;
}
static private List<File> exportDiagramsCuca(CucaDiagram system, File suggestedFile, FileFormatOption fileFormat)
throws IOException {
static private List<FileImageData> exportDiagramsCuca(CucaDiagram system, File suggestedFile,
FileFormatOption fileFormat) throws IOException {
if (suggestedFile.exists() && suggestedFile.isDirectory()) {
throw new IllegalArgumentException("File is a directory " + suggestedFile);
}
@ -215,11 +217,15 @@ public class PSystemUtils {
system.getMetadata(), system.getDpi(fileFormat), fileFormat.isWithMetadata(), system.getSkinParam()
.getSplitParam()).getFiles();
}
return result;
final List<FileImageData> result2 = new ArrayList<FileImageData>();
for (File f : result) {
result2.add(new FileImageData(f, cmap));
}
return result2;
}
private static List<File> createFilesHtml(CucaDiagram system, File suggestedFile) throws IOException {
private static List<FileImageData> createFilesHtml(CucaDiagram system, File suggestedFile) throws IOException {
final String name = suggestedFile.getName();
final int idx = name.lastIndexOf('.');
final File dir = new File(suggestedFile.getParentFile(), name.substring(0, idx));

View File

@ -0,0 +1,99 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* 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;
import java.util.concurrent.atomic.AtomicInteger;
public class ProgressBar {
private static boolean enable;
private static String last = null;
private static final AtomicInteger total = new AtomicInteger();
private static final AtomicInteger done = new AtomicInteger();
private synchronized static void print(String message) {
clear();
System.err.print(message);
last = message;
}
public synchronized static void clear() {
if (last != null) {
for (int i = 0; i < last.length(); i++) {
System.err.print('\b');
}
for (int i = 0; i < last.length(); i++) {
System.err.print(' ');
}
for (int i = 0; i < last.length(); i++) {
System.err.print('\b');
}
}
last = null;
}
public static void incTotal(int nb) {
total.addAndGet(nb);
printBar(done.intValue(), total.intValue());
}
private synchronized static void printBar(int done, int total) {
if (enable == false) {
return;
}
if (total == 0) {
return;
}
final String message = "[" + getBar(done, total) + "] " + done + "/" + total;
print(message);
}
private static String getBar(int done, int total) {
final StringBuilder sb = new StringBuilder();
final int width = 30;
final int value = width * done / total;
for (int i = 0; i < width; i++) {
sb.append(i < value ? '#' : ' ');
}
return sb.toString();
}
public static void incDone(boolean error) {
done.incrementAndGet();
printBar(done.intValue(), total.intValue());
}
public static void setEnable(boolean value) {
enable = value;
}
}

View File

@ -41,6 +41,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -74,6 +75,7 @@ public class Run {
public static void main(String[] argsArray) throws IOException, InterruptedException {
final long start = System.currentTimeMillis();
final Option option = new Option(argsArray);
ProgressBar.setEnable(option.isTextProgressBar());
if (OptionFlags.getInstance().isDumpStats()) {
StatsUtils.dumpStats();
return;
@ -133,6 +135,9 @@ public class Run {
error = managePipe(option);
forceQuit = true;
} else if (option.isFailfast2()) {
if (option.isSplash()) {
Splash.createSplash();
}
final long start2 = System.currentTimeMillis();
option.setCheckOnly(true);
error = manageAllFiles(option);
@ -146,6 +151,9 @@ public class Run {
}
forceQuit = true;
} else {
if (option.isSplash()) {
Splash.createSplash();
}
error = manageAllFiles(option);
forceQuit = true;
}
@ -337,11 +345,12 @@ public class Run {
}
private static boolean processArgs(Option option) throws IOException, InterruptedException {
if (option.isDecodeurl() == false && option.getNbThreads() > 0 && option.isCheckOnly() == false
if (option.isDecodeurl() == false && option.getNbThreads() > 1 && option.isCheckOnly() == false
&& OptionFlags.getInstance().isMetadata() == false) {
return multithread(option);
}
boolean errorGlobal = false;
final List<File> files = new ArrayList<File>();
for (String s : option.getResult()) {
if (option.isDecodeurl()) {
final Transcoder transcoder = TranscoderUtil.getDefaultTranscoder();
@ -350,19 +359,22 @@ public class Run {
System.out.println("@enduml");
} else {
final FileGroup group = new FileGroup(s, option.getExcludes(), option);
for (File f : group.getFiles()) {
try {
final boolean error = manageFileInternal(f, option);
if (error) {
errorGlobal = true;
}
if (error && option.isFailfastOrFailfast2()) {
return true;
}
} catch (IOException e) {
e.printStackTrace();
}
incTotal(group.getFiles().size());
files.addAll(group.getFiles());
}
}
for (File f : files) {
try {
final boolean error = manageFileInternal(f, option);
if (error) {
errorGlobal = true;
}
incDone(error);
if (error && option.isFailfastOrFailfast2()) {
return true;
}
} catch (IOException e) {
e.printStackTrace();
}
}
return errorGlobal;
@ -375,6 +387,7 @@ public class Run {
for (String s : option.getResult()) {
final FileGroup group = new FileGroup(s, option.getExcludes(), option);
for (final File f : group.getFiles()) {
incTotal(1);
executor.submit(new Runnable() {
public void run() {
if (errors.get() && option.isFailfastOrFailfast2()) {
@ -390,6 +403,7 @@ public class Run {
} catch (InterruptedException e) {
e.printStackTrace();
}
incDone(errors.get());
}
});
}
@ -399,6 +413,16 @@ public class Run {
return errors.get();
}
private static void incDone(boolean error) {
Splash.incDone(error);
ProgressBar.incDone(error);
}
private static void incTotal(int nb) {
Splash.incTotal(nb);
ProgressBar.incTotal(nb);
}
private static boolean manageFileInternal(File f, Option option) throws IOException, InterruptedException {
if (OptionFlags.getInstance().isMetadata()) {
System.out.println("------------------------");

View File

@ -204,11 +204,12 @@ public class SourceFileReader implements ISourceFileReader {
return Collections.singletonList(image);
}
final List<File> exportDiagrams = PSystemUtils.exportDiagrams(system, suggested, fileFormatOption);
final List<FileImageData> exportDiagrams = PSystemUtils.exportDiagrams(system, suggested, fileFormatOption);
OptionFlags.getInstance().logData(file, system);
for (File f : exportDiagrams) {
for (FileImageData fdata : exportDiagrams) {
final String desc = "[" + file.getName() + "] " + system.getDescription();
final File f = fdata.getFile();
if (OptionFlags.getInstance().isWord()) {
final String warnOrError = system.getWarningOrError();
if (warnOrError != null) {

View File

@ -90,9 +90,9 @@ public class SourceFileReader2 implements ISourceFileReader {
final Diagram system = blockUml.getDiagram();
OptionFlags.getInstance().logData(file, system);
for (File f : PSystemUtils.exportDiagrams(system, suggested, fileFormatOption)) {
for (FileImageData fdata : PSystemUtils.exportDiagrams(system, suggested, fileFormatOption)) {
final String desc = "[" + file.getName() + "] " + system.getDescription();
final GeneratedImage generatedImage = new GeneratedImageImpl(f, desc, blockUml);
final GeneratedImage generatedImage = new GeneratedImageImpl(fdata.getFile(), desc, blockUml);
result.add(generatedImage);
}

View File

@ -42,7 +42,6 @@ import java.util.List;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.preproc.Defines;
@ -189,12 +188,10 @@ public class SourceStringReader {
final Diagram system = b.getDiagram();
final int nbInSystem = system.getNbImages();
if (numImage < nbInSystem) {
// final CMapData cmap = new CMapData();
final ImageData imageData = system.exportDiagram(os, numImage, fileFormatOption);
if (imageData.containsCMapData()) {
return ((DiagramDescriptionImpl) system.getDescription()).withCMapData(imageData
.getCMapData("plantuml"));
}
// final ImageData imageData = system.exportDiagram(os, numImage, fileFormatOption);
// if (imageData.containsCMapData()) {
// return system.getDescription().withCMapData(imageData.getCMapData("plantuml"));
// }
return system.getDescription();
}
numImage -= nbInSystem;

View File

@ -0,0 +1,253 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* 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;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.net.URL;
import java.util.concurrent.atomic.AtomicInteger;
import net.sourceforge.plantuml.version.PSystemVersion;
public class Splash extends Window implements MouseListener, MouseMotionListener {
private static final Color LINK_NORMAL = Color.BLUE;
private static final Color LINK_HOVER = new Color(127, 0, 127);
private static Splash singleton;
private final int width = 280;
private final int height = 80;
private final BufferedImage logo;
private final AtomicInteger total = new AtomicInteger();
private final AtomicInteger done = new AtomicInteger();
private final AtomicInteger errors = new AtomicInteger();
private final Font font = new Font("SansSerif", Font.BOLD, 12);
public static void main(String[] args) throws Exception {
Splash.createSplash();
Splash.incTotal(30);
for (int i = 0; i < 20; i++) {
Splash.incDone(i > 3);
Thread.sleep(1000);
}
}
private Splash() {
super(null);
this.logo = PSystemVersion.getPlantumlImage();
final Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
final int x = (int) ((dimension.getWidth() - width)) / 2;
final int y = (int) ((dimension.getHeight() - height)) / 2;
this.setBounds(x, y, width, height);
this.setVisible(true);
this.setAlwaysOnTop(true);
this.setFocusable(false);
this.setFocusableWindowState(false);
addMouseListener(this);
addMouseMotionListener(this);
}
private int xClicked;
private int yClicked;
private int limY;
private int limX;
public void mouseDragged(MouseEvent event) {
int x = event.getXOnScreen();
int y = event.getYOnScreen();
this.setBounds(x - xClicked, y - yClicked, width, height);
}
private Color link = LINK_NORMAL;
public void mouseMoved(MouseEvent event) {
if (event.getY() > limY && event.getX() < limX) {
updateLinkColor(LINK_HOVER);
} else {
updateLinkColor(LINK_NORMAL);
}
}
private void updateLinkColor(final Color newLink) {
if (link != newLink) {
link = newLink;
this.setCursor(link == LINK_NORMAL ? Cursor.getDefaultCursor() : Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
repaint();
}
}
public void mouseReleased(MouseEvent event) {
// System.err.println("mouseReleased " + event);
}
public void mousePressed(MouseEvent event) {
this.xClicked = event.getX();
this.yClicked = event.getY();
}
public void mouseClicked(MouseEvent event) {
if (link != LINK_NORMAL) {
try {
Desktop.getDesktop().browse(new URL("http://plantuml.com").toURI());
} catch (Exception e) {
e.printStackTrace();
}
return;
}
this.xClicked = event.getX();
this.yClicked = event.getY();
}
public void mouseExited(MouseEvent event) {
updateLinkColor(LINK_NORMAL);
}
public void mouseEntered(MouseEvent event) {
// System.err.println("mouseEntered " + event);
}
private void incTotalInternal(int nb) {
this.total.addAndGet(nb);
// invalidate();
repaint();
// System.err.println("INC TOTAL=" + done + "/" + total);
}
private void incDoneInternal(boolean error) {
this.done.incrementAndGet();
if (error) {
this.errors.incrementAndGet();
}
// invalidate();
repaint();
// System.err.println("INC TOTAL=" + done + "/" + total);
}
@Override
public void paint(Graphics g) {
super.paint(g);
g.setColor(Color.WHITE);
g.fillRect(0, 0, width, height);
g.setColor(Color.BLACK);
g.drawRect(0, 0, width - 1, height - 1);
g.drawRect(1, 1, width - 3, height - 3);
// g.setColor(Color.RED);
// final String status = done + "/" + total;
// g.drawString(status, width / 2, height / 2);
g.drawImage(logo, width - logo.getWidth() - 4, height - logo.getHeight() - 4, null);
drawProgessBar(g, done.intValue(), total.intValue());
final int nbErrors = errors.get();
if (nbErrors > 0) {
g.setColor(Color.RED);
final String message = "" + nbErrors + (nbErrors > 1 ? " diagrams" : " diagram") + " contains errors";
g.drawString(message, 10, 20);
}
g.setColor(link);
final String urllink = "http://plantuml.com";
final Rectangle2D rect = getUsed(g, urllink);
g.drawString(urllink, 10, (int) (height - rect.getMaxY()));
limY = (int) (height - rect.getMaxY() + rect.getMinY());
limX = (int) (10 + rect.getMaxX());
}
private void drawProgessBar(Graphics g, int intValue, int totalValue) {
if (totalValue == 0) {
return;
}
g.setFont(font);
final String label = "" + intValue + "/" + totalValue;
final Rectangle2D rect = getUsed(g, label);
final int x = 10;
final int y = 33;
final int barWidth = 170;
final int barHeight = (int) (rect.getHeight() + 2);
final int grey = 230;
g.setColor(new Color(grey, grey, grey));
final int value = barWidth * intValue / totalValue;
g.fillRect(x, y, value, barHeight);
g.setColor(Color.BLACK);
g.drawRect(x, y, barWidth, barHeight);
final double xLabel = x + (barWidth - rect.getWidth()) / 2;
final double yLabel = y - rect.getY() + (barHeight - rect.getHeight()) / 2;
g.drawString(label, (int) xLabel, (int) yLabel);
}
private Rectangle2D getUsed(Graphics g, final String label) {
return g.getFontMetrics().getStringBounds(label, g);
}
// Static
public synchronized static void createSplash() {
if (singleton == null) {
singleton = new Splash();
}
}
public static void incTotal(int nb) {
if (singleton != null) {
singleton.incTotalInternal(nb);
}
}
public static void incDone(boolean error) {
if (singleton != null) {
singleton.incDoneInternal(error);
}
}
public synchronized static void disposeSplash() {
if (singleton != null) {
singleton.setVisible(false);
singleton.dispose();
singleton = null;
}
}
}

View File

@ -347,6 +347,23 @@ public class StringUtils {
return true;
}
public static int getPragmaRevision(String uml) {
uml = uml.toLowerCase();
final String header = "@startuml\n!pragma revision ";
if (uml.startsWith(header) == false) {
return -1;
}
int x1 = header.length();
int x2 = x1;
while (x2 < uml.length() && Character.isDigit(uml.charAt(x2))) {
x2++;
}
if (x1 == x2) {
return -1;
}
return Integer.parseInt(uml.substring(x1, x2));
}
public static List<String> splitComma(String s) {
s = trin(s);
// if (s.matches("([\\p{L}0-9_.]+|[%g][^%g]+[%g])(\\s*,\\s*([\\p{L}0-9_.]+|[%g][^%g]+[%g]))*") == false) {
@ -432,14 +449,13 @@ public class StringUtils {
}
public static String manageUnicodeNotationUplus(String s) {
final Pattern pattern = Pattern.compile("\\<U\\+([0-9a-fA-F]{4})\\>");
final Pattern pattern = Pattern.compile("\\<U\\+([0-9a-fA-F]{4,5})\\>");
final Matcher matcher = pattern.matcher(s);
final StringBuffer result = new StringBuffer();
while (matcher.find()) {
final String num = matcher.group(1);
final int value = Integer.parseInt(num, 16);
final char c = (char) value;
matcher.appendReplacement(result, "" + c);
matcher.appendReplacement(result, new String(Character.toChars(value)));
}
matcher.appendTail(result);
return result.toString();

View File

@ -241,7 +241,7 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
return new ImageDataSimple();
}
public void exportDiagramError(OutputStream os, Throwable exception, FileFormatOption fileFormat,
private void exportDiagramError(OutputStream os, Throwable exception, FileFormatOption fileFormat,
String graphvizVersion) throws IOException {
exportDiagramError(os, exception, fileFormat, getMetadata(), getFlashData(),
getFailureText1(exception, graphvizVersion));

View File

@ -55,22 +55,21 @@ public class Url implements EnsureVisible {
} else {
this.tooltip = StringUtils.manageNewLine(tooltip);
}
if (label == null) {
if (label == null || label.length() == 0) {
this.label = url;
} else {
this.label = label;
}
}
public static boolean isLatex(String pendingUrl) {
return pendingUrl.startsWith("latex://");
}
public boolean isLatex() {
return isLatex(url);
}
public final String getUrl() {
return url;
}
@ -90,7 +89,7 @@ public class Url implements EnsureVisible {
public String getCoords(double scale) {
if (DotMaker2.isJunit() && visible.getCoords(1.0).contains("0,0,0,0")) {
throw new IllegalStateException();
throw new IllegalStateException(toString());
}
return visible.getCoords(scale);
}

View File

@ -37,25 +37,27 @@ import net.sourceforge.plantuml.command.regex.Pattern2;
public class UrlBuilder {
public static enum ModeUrl {
STRICT, AT_START, ANYWHERE, AT_END
STRICT, ANYWHERE
}
private static String level0() {
return "(?:[^{}]|\\{[^{}]*\\})+";
}
// private static String level0() {
// return "(?:[^{}]|\\{[^{}]*\\})+";
// }
//
// private static String levelN(int n) {
// if (n == 0) {
// return level0();
// }
// return "(?:[^{}]|\\{" + levelN(n - 1) + "\\})+";
// }
private static String levelN(int n) {
if (n == 0) {
return level0();
}
return "(?:[^{}]|\\{" + levelN(n - 1) + "\\})+";
}
private static final String URL_PATTERN_OLD = "\\[\\[([%g][^%g]+[%g]|[^{}%s\\]\\[]*)(?:[%s]*\\{((?:[^{}]|\\{[^{}]*\\})+)\\})?(?:[%s]*([^\\]\\[]+))?\\]\\]";
// private static final String URL_PATTERN_OLD =
// "\\[\\[([%g][^%g]+[%g]|[^{}%s\\]\\[]*)(?:[%s]*\\{((?:[^{}]|\\{[^{}]*\\})+)\\})?(?:[%s]*([^\\]\\[]+))?\\]\\]";
private static final String URL_PATTERN = "\\[\\[([%g][^%g]+[%g])?([\\w\\W]*?)\\]\\]";
private static final String URL_PATTERN_BAD = "\\[\\[([%g][^%g]+[%g]|[^{}%s\\]\\[]*)(?:[%s]*\\{" + "(" + levelN(3)
+ ")" + "\\})?(?:[%s]*([^\\]\\[]+))?\\]\\]";
// private static final String URL_PATTERN_BAD = "\\[\\[([%g][^%g]+[%g]|[^{}%s\\]\\[]*)(?:[%s]*\\{" + "(" +
// levelN(3)
// + ")" + "\\})?(?:[%s]*([^\\]\\[]+))?\\]\\]";
private final String topurl;
private ModeUrl mode;
@ -65,7 +67,7 @@ public class UrlBuilder {
this.mode = mode;
}
public static String multilineTooltip(String label) {
private static String multilineTooltip(String label) {
final Pattern2 p = MyPattern.cmpile("(?i)^(" + URL_PATTERN + ")?(.*)$");
final Matcher2 m = p.matcher(label);
if (m.matches() == false) {
@ -84,10 +86,6 @@ public class UrlBuilder {
final Pattern2 p;
if (mode == ModeUrl.STRICT) {
p = MyPattern.cmpile("(?i)^" + URL_PATTERN + "$");
} else if (mode == ModeUrl.AT_START) {
p = MyPattern.cmpile("(?i)^" + URL_PATTERN + ".*");
} else if (mode == ModeUrl.AT_END) {
p = MyPattern.cmpile("(?i).*" + URL_PATTERN + "$");
} else if (mode == ModeUrl.ANYWHERE) {
p = MyPattern.cmpile("(?i).*" + URL_PATTERN + ".*");
} else {
@ -138,15 +136,15 @@ public class UrlBuilder {
return URL_PATTERN;
}
public static String purgeUrl(final String label) {
final Pattern2 p = MyPattern.cmpile("[%s]*" + URL_PATTERN + "[%s]*");
final Matcher2 m = p.matcher(label);
if (m.find() == false) {
return label;
}
final String url = m.group(0);
final int x = label.indexOf(url);
return label.substring(0, x) + label.substring(x + url.length());
}
// private static String purgeUrl(final String label) {
// final Pattern2 p = MyPattern.cmpile("[%s]*" + URL_PATTERN + "[%s]*");
// final Matcher2 m = p.matcher(label);
// if (m.find() == false) {
// return label;
// }
// final String url = m.group(0);
// final int x = label.indexOf(url);
// return label.substring(0, x) + label.substring(x + url.length());
// }
}

View File

@ -46,7 +46,6 @@ import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import com.ctreber.acearth.ACearth;
@ -123,7 +122,7 @@ public class PSystemXearth extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(XEarth)", getClass());
return new DiagramDescription("(XEarth)");
}
}

View File

@ -36,7 +36,6 @@ import java.util.List;
import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
import net.sourceforge.plantuml.cucadiagram.Display;
@ -122,7 +121,7 @@ public class ActivityDiagram extends CucaDiagram {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(" + getLeafssize() + " activities)", getClass());
return new DiagramDescription("(" + getLeafssize() + " activities)");
}
public IEntity getLastEntityConsulted() {

View File

@ -46,7 +46,6 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlanes;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HtmlColor;
@ -133,7 +132,33 @@ public class ActivityDiagram3 extends UmlDiagram {
public void stop() {
manageSwimlaneStrategy();
current().add(new InstructionStop(swinlanes.getCurrentSwimlane(), nextLinkRenderer()));
final InstructionStop ins = new InstructionStop(swinlanes.getCurrentSwimlane(), nextLinkRenderer());
if (manageSpecialStopEndAfterEndWhile(ins)) {
return;
}
current().add(ins);
}
public void end() {
manageSwimlaneStrategy();
final InstructionEnd ins = new InstructionEnd(swinlanes.getCurrentSwimlane(), nextLinkRenderer());
if (manageSpecialStopEndAfterEndWhile(ins)) {
return;
}
current().add(ins);
}
private boolean manageSpecialStopEndAfterEndWhile(Instruction special) {
if (current() instanceof InstructionList == false) {
return false;
}
final InstructionList current = (InstructionList) current();
final Instruction last = current.getLast();
if (last instanceof InstructionWhile == false) {
return false;
}
((InstructionWhile) last).setSpecial(special);
return true;
}
public void breakInstruction() {
@ -141,13 +166,8 @@ public class ActivityDiagram3 extends UmlDiagram {
current().add(new InstructionBreak(swinlanes.getCurrentSwimlane(), nextLinkRenderer()));
}
public void end() {
manageSwimlaneStrategy();
current().add(new InstructionEnd(swinlanes.getCurrentSwimlane(), nextLinkRenderer()));
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("activity3", getClass());
return new DiagramDescription("activity3");
}
@Override
@ -190,16 +210,6 @@ public class ActivityDiagram3 extends UmlDiagram {
return dpiFactor;
}
// private final UFont getFont(FontParam fontParam) {
// final ISkinParam skinParam = getSkinParam();
// return skinParam.getFont(null, false, fontParam);
// }
//
// private final HtmlColor getFontColor(FontParam fontParam, Stereotype stereotype2) {
// final ISkinParam skinParam = getSkinParam();
// return skinParam.getFontHtmlColor(stereotype2, fontParam);
// }
public void fork() {
final InstructionFork instructionFork = new InstructionFork(current(), nextLinkRenderer(), getSkinParam());
current().add(instructionFork);

View File

@ -61,6 +61,8 @@ public class InstructionWhile extends WithNote implements Instruction, Instructi
private final Swimlane swimlane;
private final ISkinParam skinParam;
private Instruction specialOut;
public void overwriteYes(Display yes) {
this.yes = yes;
}
@ -91,11 +93,11 @@ public class InstructionWhile extends WithNote implements Instruction, Instructi
public Ftile createFtile(FtileFactory factory) {
Ftile tmp = factory.decorateOut(repeatList.createFtile(factory), endInlinkRendering);
tmp = factory.createWhile(swimlane, tmp, test, yes, out, afterEndwhile, color);
tmp = factory.createWhile(swimlane, tmp, test, yes, out, afterEndwhile, color, specialOut);
if (getPositionedNotes().size() > 0) {
tmp = FtileWithNoteOpale.create(tmp, getPositionedNotes(), skinParam, false);
}
if (killed) {
if (killed || specialOut != null) {
return new FtileKilled(tmp);
}
return tmp;
@ -155,4 +157,8 @@ public class InstructionWhile extends WithNote implements Instruction, Instructi
return repeatList.getLast();
}
public void setSpecial(Instruction special) {
this.specialOut = special;
}
}

View File

@ -37,6 +37,7 @@ import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.activitydiagram3.Branch;
import net.sourceforge.plantuml.activitydiagram3.ForkStyle;
import net.sourceforge.plantuml.activitydiagram3.Instruction;
import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
import net.sourceforge.plantuml.activitydiagram3.PositionedNote;
import net.sourceforge.plantuml.cucadiagram.Display;
@ -72,7 +73,7 @@ public interface FtileFactory {
HtmlColor color, LinkRendering backRepeatLinkRendering);
public Ftile createWhile(Swimlane swimlane, Ftile whileBlock, Display test, Display yes, Display out,
LinkRendering afterEndwhile, HtmlColor color);
LinkRendering afterEndwhile, HtmlColor color, Instruction specialOut);
public Ftile createIf(Swimlane swimlane, List<Branch> thens, Branch elseBranch, LinkRendering afterEndwhile,
LinkRendering topInlinkRendering);

View File

@ -38,6 +38,7 @@ import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.activitydiagram3.Branch;
import net.sourceforge.plantuml.activitydiagram3.ForkStyle;
import net.sourceforge.plantuml.activitydiagram3.Instruction;
import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
import net.sourceforge.plantuml.activitydiagram3.PositionedNote;
import net.sourceforge.plantuml.creole.CreoleMode;
@ -141,8 +142,8 @@ public class FtileFactoryDelegator implements FtileFactory {
}
public Ftile createWhile(Swimlane swimlane, Ftile whileBlock, Display test, Display yes, Display out,
LinkRendering afterEndwhile, HtmlColor color) {
return factory.createWhile(swimlane, whileBlock, test, yes, out, afterEndwhile, color);
LinkRendering afterEndwhile, HtmlColor color, Instruction specialOut) {
return factory.createWhile(swimlane, whileBlock, test, yes, out, afterEndwhile, color, specialOut);
}
public Ftile createIf(Swimlane swimlane, List<Branch> thens, Branch elseBranch, LinkRendering afterEndwhile,

View File

@ -32,6 +32,7 @@ package net.sourceforge.plantuml.activitydiagram3.ftile.vcompact;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.activitydiagram3.Instruction;
import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
import net.sourceforge.plantuml.activitydiagram3.ftile.Ftile;
import net.sourceforge.plantuml.activitydiagram3.ftile.FtileFactory;
@ -52,10 +53,10 @@ public class FtileFactoryDelegatorWhile extends FtileFactoryDelegator {
@Override
public Ftile createWhile(Swimlane swimlane, Ftile whileBlock, Display test, Display yes, Display out,
LinkRendering afterEndwhile, HtmlColor color) {
LinkRendering afterEndwhile, HtmlColor color, Instruction specialOut) {
final HtmlColor borderColor = getRose().getHtmlColor(skinParam(), ColorParam.activityBorder);
final HtmlColor backColor = color == null ? getRose().getHtmlColor(skinParam(),
ColorParam.activityBackground) : color;
final HtmlColor backColor = color == null ? getRose().getHtmlColor(skinParam(), ColorParam.activityBackground)
: color;
final Rainbow arrowColor = HtmlColorAndStyle.build(skinParam());
final ConditionStyle conditionStyle = skinParam().getConditionStyle();
@ -70,7 +71,7 @@ public class FtileFactoryDelegatorWhile extends FtileFactoryDelegator {
final FontConfiguration fontArrow = new FontConfiguration(skinParam(), FontParam.ARROW, null);
return FtileWhile.create(swimlane, whileBlock, test, borderColor, backColor, arrowColor, yes, out,
endInlinkColor, afterEndwhile, fontArrow, getFactory(), conditionStyle, fcTest);
endInlinkColor, afterEndwhile, fontArrow, getFactory(), conditionStyle, fcTest, specialOut);
}
}

View File

@ -38,6 +38,7 @@ import java.util.List;
import java.util.Set;
import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.activitydiagram3.Instruction;
import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractConnection;
import net.sourceforge.plantuml.activitydiagram3.ftile.AbstractFtile;
@ -73,6 +74,7 @@ class FtileWhile extends AbstractFtile {
private final Ftile whileBlock;
private final Ftile diamond1;
private final Ftile specialOut;
public Set<Swimlane> getSwimlanes() {
final Set<Swimlane> result = new HashSet<Swimlane>(whileBlock.getSwimlanes());
@ -88,16 +90,17 @@ class FtileWhile extends AbstractFtile {
return getSwimlaneIn();
}
private FtileWhile(Ftile whileBlock, Ftile diamond1) {
private FtileWhile(Ftile whileBlock, Ftile diamond1, Ftile specialOut) {
super(whileBlock.skinParam());
this.whileBlock = whileBlock;
this.diamond1 = diamond1;
this.specialOut = specialOut;
}
public static Ftile create(Swimlane swimlane, Ftile whileBlock, Display test, HtmlColor borderColor,
HtmlColor backColor, Rainbow arrowColor, Display yes, Display out2, Rainbow endInlinkColor,
LinkRendering afterEndwhile, FontConfiguration fontArrow, FtileFactory ftileFactory,
ConditionStyle conditionStyle, FontConfiguration fcTest) {
ConditionStyle conditionStyle, FontConfiguration fcTest, Instruction specialOut) {
final TextBlock yesTb = yes.create(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam());
final TextBlock testTb = test.create(fcTest,
@ -118,7 +121,9 @@ class FtileWhile extends AbstractFtile {
throw new IllegalStateException();
}
final FtileWhile result = new FtileWhile(whileBlock, diamond1);
final Ftile special = specialOut == null ? null : specialOut.createFtile(ftileFactory);
final FtileWhile result = new FtileWhile(whileBlock, diamond1, special);
Rainbow afterEndwhileColor = arrowColor;
if (afterEndwhile != null && afterEndwhile.getRainbow() != null && afterEndwhile.getRainbow().size() != 0) {
afterEndwhileColor = afterEndwhile.getRainbow();
@ -135,7 +140,11 @@ class FtileWhile extends AbstractFtile {
conns.add(result.new ConnectionIn(whileBlock.getInLinkRendering().getRainbow(arrowColor)));
conns.add(result.new ConnectionBack(endInlinkColor, back));
}
conns.add(result.new ConnectionOut(afterEndwhileColor));
if (specialOut == null) {
conns.add(result.new ConnectionOut(afterEndwhileColor));
} else {
conns.add(result.new ConnectionOutSpecial(afterEndwhileColor));
}
return FtileUtils.addConnection(result, conns);
}
@ -390,10 +399,54 @@ class FtileWhile extends AbstractFtile {
}
}
class ConnectionOutSpecial extends AbstractConnection {
private final Rainbow afterEndwhileColor;
public ConnectionOutSpecial(Rainbow afterEndwhileColor) {
super(diamond1, specialOut);
this.afterEndwhileColor = afterEndwhileColor;
}
private Point2D getP1(final StringBounder stringBounder) {
return getTranslateDiamond1(stringBounder).getTranslated(new Point2D.Double(0, 0));
}
private Point2D getP2(final StringBounder stringBounder) {
return getTranslateForSpecial(stringBounder).getTranslated(
specialOut.calculateDimension(stringBounder).getPointIn());
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final Snake snake = new Snake(afterEndwhileColor, Arrows.asToDown());
final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
final Point2D p1 = getP1(stringBounder);
final Point2D p2 = getP2(stringBounder);
final double x1 = p1.getX();
final double half = (dimDiamond1.getOutY() - dimDiamond1.getInY()) / 2;
final double y1 = p1.getY() + dimDiamond1.getInY() + half;
final double x2 = p2.getX();
final double y2 = p2.getY();
snake.addPoint(x1, y1);
snake.addPoint(x2, y1);
snake.addPoint(x2, y2);
ug.draw(snake);
}
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
ug.apply(getTranslateForWhile(stringBounder)).draw(whileBlock);
ug.apply(getTranslateDiamond1(stringBounder)).draw(diamond1);
if (specialOut != null) {
ug.apply(getTranslateForSpecial(stringBounder)).draw(specialOut);
}
}
public FtileGeometry calculateDimension(StringBounder stringBounder) {
@ -407,11 +460,18 @@ class FtileWhile extends AbstractFtile {
final FtileGeometry geo = geoDiamond1.appendBottom(geoWhile);
final double height = geo.getHeight() + 4 * Diamond.diamondHalfSize;
final double dx = 2 * Diamond.diamondHalfSize;
return new FtileGeometry(geo.getWidth() + dx + Diamond.diamondHalfSize, height, geo.getLeft() + dx,
geoDiamond1.getInY(), height);
return new FtileGeometry(xDeltaBecauseSpecial(stringBounder) + geo.getWidth() + dx + Diamond.diamondHalfSize,
height, xDeltaBecauseSpecial(stringBounder) + geo.getLeft() + dx, geoDiamond1.getInY(), height);
}
private double xDeltaBecauseSpecial(StringBounder stringBounder) {
if (specialOut == null) {
return 0;
}
return specialOut.calculateDimension(stringBounder).getWidth();
}
@Override
public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
if (child == whileBlock) {
@ -446,4 +506,12 @@ class FtileWhile extends AbstractFtile {
return new UTranslate(x1, y1);
}
private UTranslate getTranslateForSpecial(StringBounder stringBounder) {
final FtileGeometry dimDiamond1 = diamond1.calculateDimension(stringBounder);
final double half = (dimDiamond1.getOutY() - dimDiamond1.getInY()) / 2;
final double y1 = Math.max(3 * half, 4 * Diamond.diamondHalfSize);
final double x1 = getTranslateForWhile(stringBounder).getDx() - xDeltaBecauseSpecial(stringBounder);
return new UTranslate(x1, y1);
}
}

View File

@ -40,6 +40,7 @@ import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.activitydiagram3.Branch;
import net.sourceforge.plantuml.activitydiagram3.ForkStyle;
import net.sourceforge.plantuml.activitydiagram3.Instruction;
import net.sourceforge.plantuml.activitydiagram3.LinkRendering;
import net.sourceforge.plantuml.activitydiagram3.PositionedNote;
import net.sourceforge.plantuml.activitydiagram3.ftile.BoxStyle;
@ -116,7 +117,7 @@ public class VCompactFactory implements FtileFactory {
}
public Ftile createWhile(Swimlane swimlane, Ftile whileBlock, Display test, Display yes, Display out,
LinkRendering afterEndwhile, HtmlColor color) {
LinkRendering afterEndwhile, HtmlColor color, Instruction specialOut) {
return whileBlock;
}

View File

@ -46,6 +46,7 @@ import net.sourceforge.plantuml.GeneratedImage;
import net.sourceforge.plantuml.Option;
import net.sourceforge.plantuml.OptionFlags;
import net.sourceforge.plantuml.SourceFileReader;
import net.sourceforge.plantuml.Splash;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
import net.sourceforge.plantuml.preproc.Defines;
import net.sourceforge.plantuml.stats.StatsUtils;
@ -95,6 +96,10 @@ public class PlantUmlTask extends Task {
@Override
public void execute() throws BuildException {
if (option.isSplash()) {
Splash.createSplash();
}
this.log("Starting PlantUML");
try {
@ -113,6 +118,9 @@ public class PlantUmlTask extends Task {
if (executorService != null) {
executorService.shutdown();
executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
if (option.isSplash()) {
Splash.disposeSplash();
}
}
this.log("Nb images generated: " + nbFiles.get());
} catch (IOException e) {
@ -187,6 +195,7 @@ public class PlantUmlTask extends Task {
return doFile(f, sourceFileReader);
}
Splash.incTotal(1);
executorService.submit(new Callable<Boolean>() {
public Boolean call() throws Exception {
return doFile(f, sourceFileReader);
@ -209,6 +218,7 @@ public class PlantUmlTask extends Task {
error = true;
}
}
Splash.incDone(error);
if (error) {
myLog("Error: " + f.getCanonicalPath());
}
@ -395,4 +405,9 @@ public class PlantUmlTask extends Task {
OptionFlags.getInstance().setEnableStats(flag);
}
public void setSplash(String s) {
final boolean flag = "true".equalsIgnoreCase(s) || "yes".equalsIgnoreCase(s) || "on".equalsIgnoreCase(s);
option.setSplash(flag);
}
}

View File

@ -57,13 +57,16 @@ public class ComponentTextDelay extends AbstractComponentText {
final int textWidth = StringUtils.getWidth(stringsToDisplay);
final int textPos = (width - textWidth) / 2;
if (stringsToDisplay.isWhite()) {
return;
}
final String desc = stringsToDisplay.get(0).toString();
charArea.drawStringLR(desc, textPos, 0);
charArea.drawStringLR(desc, textPos, 1);
}
public double getPreferredHeight(StringBounder stringBounder) {
return StringUtils.getHeight(stringsToDisplay) + 1;
return StringUtils.getHeight(stringsToDisplay) + 4;
}
public double getPreferredWidth(StringBounder stringBounder) {

View File

@ -36,7 +36,6 @@ import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
public abstract class AbstractEntityDiagram extends CucaDiagram {
@ -54,7 +53,7 @@ public abstract class AbstractEntityDiagram extends CucaDiagram {
}
final public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(" + getLeafssize() + " entities)", getClass());
return new DiagramDescription("(" + getLeafssize() + " entities)");
}
}

View File

@ -109,7 +109,9 @@ public class CommandCreateClass extends SingleLineCommand2<ClassDiagram> {
final ILeaf entity;
if (diagram.leafExist(code)) {
entity = diagram.getOrCreateLeaf(code, type, null);
entity.muteToType(type, null);
if (entity.muteToType(type, null) == false) {
return CommandExecutionResult.error("Bad name");
}
} else {
entity = diagram.createLeaf(code, Display.getWithNewlines(display), type, null);
}

View File

@ -121,16 +121,16 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
}
if (lines.size() > 1) {
lines = lines.subExtract(1, 1);
final Url url;
if (lines.size() > 0) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
url = urlBuilder.getUrl(lines.getFirst499().toString());
} else {
url = null;
}
if (url != null) {
lines = lines.subExtract(1, 0);
}
final Url url = null;
// if (lines.size() > 0) {
// final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
// url = urlBuilder.getUrl(lines.getFirst499().toString());
// } else {
// url = null;
// }
// if (url != null) {
// lines = lines.subExtract(1, 0);
// }
for (CharSequence s : lines) {
if (s.length() > 0 && VisibilityModifier.isVisibilityCharacter(s)) {
diagram.setVisibilityModifierPresent(true);
@ -191,7 +191,9 @@ public class CommandCreateClassMultilines extends CommandMultilines2<ClassDiagra
final ILeaf result;
if (diagram.leafExist(code)) {
result = diagram.getOrCreateLeaf(code, null, null);
result.muteToType(type, null);
if (result.muteToType(type, null) == false) {
return null;
}
} else {
result = diagram.createLeaf(code, Display.getWithNewlines(display), type, null);
}

View File

@ -35,6 +35,9 @@ import java.util.StringTokenizer;
import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.Matcher2;
@ -47,8 +50,6 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkArrow;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
@ -72,8 +73,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
return new RegexConcat(
new RegexLeaf("HEADER", "^(?:@([\\d.]+)[%s]+)?"), //
new RegexOr( //
new RegexLeaf("ENT1", "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
+ getClassIdentifier()),//
new RegexLeaf("ENT1", getClassIdentifier()),//
new RegexLeaf("COUPLE1", COUPLE)),
new RegexLeaf("[%s]*"), //
new RegexLeaf("FIRST_LABEL", "(?:[%g]([^%g]+)[%g])?"), //
@ -95,11 +95,11 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
new RegexLeaf("[%s]*"), //
new RegexLeaf("SECOND_LABEL", "(?:[%g]([^%g]+)[%g])?"), new RegexLeaf("[%s]*"), //
new RegexOr( //
new RegexLeaf("ENT2", "(?:" + optionalKeywords(umlDiagramType) + "[%s]+)?"
+ getClassIdentifier()), //
new RegexLeaf("ENT2", getClassIdentifier()), //
new RegexLeaf("COUPLE2", COUPLE)), //
new RegexLeaf("[%s]*"), //
color().getRegex(), //
new RegexLeaf("URL", "[%s]*(" + UrlBuilder.getRegexp() + ")?"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("LABEL_LINK", "(?::[%s]*(.+))?"), //
new RegexLeaf("$"));
@ -117,28 +117,28 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
return "(?:\\.|::|\\\\|\\\\\\\\)";
}
private static String optionalKeywords(UmlDiagramType type) {
if (type == UmlDiagramType.CLASS) {
return "(interface|enum|annotation|abstract[%s]+class|abstract|class|object|entity)";
}
if (type == UmlDiagramType.OBJECT) {
return "(object)";
}
throw new IllegalArgumentException();
}
private LeafType getTypeIfObject(String type) {
if ("object".equalsIgnoreCase(type)) {
return LeafType.OBJECT;
}
return null;
}
// private static String optionalKeywords(UmlDiagramType type) {
// if (type == UmlDiagramType.CLASS) {
// return "(interface|enum|annotation|abstract[%s]+class|abstract|class|object|entity)";
// }
// if (type == UmlDiagramType.OBJECT) {
// return "(object)";
// }
// throw new IllegalArgumentException();
// }
//
// private LeafType getTypeIfObject(String type) {
// if ("object".equalsIgnoreCase(type)) {
// return LeafType.OBJECT;
// }
// return null;
// }
@Override
protected CommandExecutionResult executeArg(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
Code ent1 = Code.of(arg.get("ENT1", 1));
Code ent2 = Code.of(arg.get("ENT2", 1));
Code ent1 = Code.of(arg.get("ENT1", 0));
Code ent2 = Code.of(arg.get("ENT2", 0));
if (ent1 == null) {
return executeArgSpecial1(diagram, arg);
@ -164,35 +164,13 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
ent2 = removeMemberPart(diagram, ent2);
}
final String type1 = arg.get("ENT1", 0);
final LeafType typeIfObject1 = getTypeIfObject(type1);
final IEntity cl1 = isGroupButNotTheCurrentGroup(diagram, ent1) ? diagram.getGroup(Code.of(StringUtils
.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 1), "\""))) : diagram.getOrCreateLeaf(
ent1, typeIfObject1, null);
final String type2 = arg.get("ENT2", 0);
LeafType typeIfObject2 = getTypeIfObject(type2);
if (diagram.leafExist(ent2) == false && cl1.getEntityType() == LeafType.OBJECT && typeIfObject2 == null) {
typeIfObject2 = LeafType.OBJECT;
}
.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\""))) : diagram.getOrCreateLeaf(
ent1, null, null);
final IEntity cl2 = isGroupButNotTheCurrentGroup(diagram, ent2) ? diagram.getGroup(Code.of(StringUtils
.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 1), "\""))) : diagram.getOrCreateLeaf(
ent2, typeIfObject2, null);
if (arg.get("ENT1", 0) != null) {
final LeafType type = LeafType.getLeafType(arg.get("ENT1", 0));
if (type != LeafType.OBJECT) {
((ILeaf) cl1).muteToType(type, null);
}
}
if (arg.get("ENT2", 0) != null) {
final LeafType type = LeafType.getLeafType(arg.get("ENT2", 0));
if (type != LeafType.OBJECT) {
((ILeaf) cl2).muteToType(type, null);
}
}
.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\""))) : diagram.getOrCreateLeaf(
ent2, null, null);
Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
@ -266,6 +244,11 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
Link link = new Link(cl1, cl2, linkType, Display.getWithNewlines(labelLink), queue, firstLabel, secondLabel,
diagram.getLabeldistance(), diagram.getLabelangle());
if (arg.get("URL", 0) != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
final Url url = urlBuilder.getUrl(arg.get("URL", 0));
link.setUrl(url);
}
link.setPortMembers(port1, port2);
if (dir == Direction.LEFT || dir == Direction.UP) {
@ -331,9 +314,9 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
private CommandExecutionResult executePackageLink(AbstractClassOrObjectDiagram diagram, RegexResult arg) {
final IEntity cl1 = diagram.getGroup(Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(
arg.get("ENT1", 1), "\"")));
arg.get("ENT1", 0), "\"")));
final IEntity cl2 = diagram.getGroup(Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(
arg.get("ENT2", 1), "\"")));
arg.get("ENT2", 0), "\"")));
final LinkType linkType = getLinkType(arg);
final Direction dir = getDirection(arg);
@ -371,7 +354,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
return CommandExecutionResult.error("No class " + clName2);
}
final Code ent2 = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 1), "\""));
final Code ent2 = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT2", 0), "\""));
final IEntity cl2 = diagram.getOrCreateLeaf(ent2, null, null);
final LinkType linkType = getLinkType(arg);
@ -397,7 +380,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
return CommandExecutionResult.error("No class " + clName2);
}
final Code ent1 = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 1), "\""));
final Code ent1 = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("ENT1", 0), "\""));
final IEntity cl1 = diagram.getOrCreateLeaf(ent1, null, null);
final LinkType linkType = getLinkType(arg);

View File

@ -78,6 +78,7 @@ public final class FactoryNoteOnEntityCommand implements SingleMultiFactoryComma
new RegexLeaf("")), //
new RegexLeaf("[%s]*"), //
color().getRegex(), //
new RegexLeaf("URL", "[%s]*(" + UrlBuilder.getRegexp() + ")?"), //
new RegexLeaf("[%s]*:[%s]*"), //
new RegexLeaf("NOTE", "(.*)"), //
new RegexLeaf("$") //
@ -96,6 +97,7 @@ public final class FactoryNoteOnEntityCommand implements SingleMultiFactoryComma
new RegexLeaf("")), //
new RegexLeaf("[%s]*"), //
color().getRegex(), //
new RegexLeaf("URL", "[%s]*(" + UrlBuilder.getRegexp() + ")?"), //
new RegexLeaf(withBracket ? "[%s]*\\{" : "[%s]*"), //
new RegexLeaf("$") //
);
@ -129,15 +131,11 @@ public final class FactoryNoteOnEntityCommand implements SingleMultiFactoryComma
final RegexResult line0 = getStartingPattern().matcher(StringUtils.trin(lines.getFirst499()));
lines = lines.subExtract(1, 1);
lines = lines.removeEmptyColumns();
Url url = null;
if (lines.size() > 0) {
final UrlBuilder urlBuilder = new UrlBuilder(system.getSkinParam().getValue("topurl"),
ModeUrl.STRICT);
url = urlBuilder.getUrl(lines.getFirst499().toString());
}
if (url != null) {
lines = lines.subExtract(1, 0);
if (line0.get("URL", 0) != null) {
final UrlBuilder urlBuilder = new UrlBuilder(system.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
url = urlBuilder.getUrl(line0.get("URL", 0));
}
return executeInternal(line0, system, url, lines);

View File

@ -117,12 +117,9 @@ public final class FactoryNoteOnLinkCommand implements SingleMultiFactoryCommand
position = Position.valueOf(StringUtils.goUpperCase(arg.get("POSITION", 0)));
}
Url url = null;
if (note.size() > 0) {
if (arg.get("URL", 0) != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
url = urlBuilder.getUrl(note.getFirst499().toString());
}
if (url != null) {
note = note.subExtract(1, 0);
url = urlBuilder.getUrl(arg.get("URL", 0));
}
final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
link.addNote(note.toDisplay(), position, colors);

View File

@ -71,6 +71,7 @@ public final class FactoryTipOnEntityCommand implements SingleMultiFactoryComman
new RegexLeaf("[%s]+of[%s]+"), partialPattern, //
new RegexLeaf("[%s]*"), //
ColorParser.exp1(), //
new RegexLeaf("URL", "[%s]*(" + UrlBuilder.getRegexp() + ")?"), //
new RegexLeaf(withBracket ? "[%s]*\\{" : "[%s]*"), //
new RegexLeaf("$") //
);
@ -99,13 +100,9 @@ public final class FactoryTipOnEntityCommand implements SingleMultiFactoryComman
lines = lines.removeEmptyColumns();
Url url = null;
if (lines.size() > 0) {
final UrlBuilder urlBuilder = new UrlBuilder(system.getSkinParam().getValue("topurl"),
ModeUrl.STRICT);
url = urlBuilder.getUrl(lines.getFirst499().toString());
}
if (url != null) {
lines = lines.subExtract(1, 0);
if (line0.get("URL", 0) != null) {
final UrlBuilder urlBuilder = new UrlBuilder(system.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
url = urlBuilder.getUrl(line0.get("URL", 0));
}
return executeInternal(line0, system, url, lines);

View File

@ -33,6 +33,9 @@ package net.sourceforge.plantuml.command.note.sequence;
import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
import net.sourceforge.plantuml.command.BlocLines;
import net.sourceforge.plantuml.command.Command;
import net.sourceforge.plantuml.command.CommandExecutionResult;
@ -66,6 +69,7 @@ public final class FactorySequenceNoteCommand implements SingleMultiFactoryComma
new RegexLeaf("POSITION", "(right|left|over)[%s]+"), //
new RegexLeaf("PARTICIPANT", "(?:of[%s]+)?([\\p{L}0-9_.@]+|[%g][^%g]+[%g])[%s]*"), //
color().getRegex(), //
new RegexLeaf("URL", "[%s]*(" + UrlBuilder.getRegexp() + ")?"), //
new RegexLeaf("$"));
}
@ -80,6 +84,7 @@ public final class FactorySequenceNoteCommand implements SingleMultiFactoryComma
new RegexLeaf("POSITION", "(right|left|over)[%s]+"), //
new RegexLeaf("PARTICIPANT", "(?:of[%s])?([\\p{L}0-9_.@]+|[%g][^%g]+[%g])[%s]*"), //
color().getRegex(), //
new RegexLeaf("URL", "[%s]*(" + UrlBuilder.getRegexp() + ")?"), //
new RegexLeaf("[%s]*:[%s]*"), //
new RegexLeaf("NOTE", "(.*)"), //
new RegexLeaf("$"));
@ -137,6 +142,11 @@ public final class FactorySequenceNoteCommand implements SingleMultiFactoryComma
}
note.setColors(colors);
note.setStyle(NoteStyle.getNoteStyle(arg.get("STYLE", 0)));
if (arg.get("URL", 0) != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
final Url urlLink = urlBuilder.getUrl(arg.get("URL", 0));
note.setUrl(urlLink);
}
diagram.addNote(note, tryMerge);
}
return CommandExecutionResult.ok();

View File

@ -47,6 +47,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.graphic.color.ColorParser;
import net.sourceforge.plantuml.sequencediagram.AbstractMessage;
import net.sourceforge.plantuml.sequencediagram.EventWithDeactivate;
import net.sourceforge.plantuml.sequencediagram.GroupingLeaf;
import net.sourceforge.plantuml.sequencediagram.NotePosition;
import net.sourceforge.plantuml.sequencediagram.NoteStyle;
import net.sourceforge.plantuml.sequencediagram.SequenceDiagram;
@ -59,6 +60,7 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto
new RegexLeaf("[%s]+"), //
new RegexLeaf("POSITION", "(right|left)[%s]*"), //
ColorParser.exp1(), //
new RegexLeaf("URL", "[%s]*(" + UrlBuilder.getRegexp() + ")?"), //
new RegexLeaf("$"));
}
@ -68,6 +70,7 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto
new RegexLeaf("[%s]+"), //
new RegexLeaf("POSITION", "(right|left)[%s]*"), //
ColorParser.exp1(), //
new RegexLeaf("URL", "[%s]*(" + UrlBuilder.getRegexp() + ")?"), //
new RegexLeaf("[%s]*:[%s]*"), //
new RegexLeaf("NOTE", "(.*)"), //
new RegexLeaf("$"));
@ -105,21 +108,20 @@ public final class FactorySequenceNoteOnArrowCommand implements SingleMultiFacto
private CommandExecutionResult executeInternal(SequenceDiagram system, final RegexResult line0, BlocLines lines) {
final EventWithDeactivate m = system.getLastEventWithDeactivate();
if (m instanceof AbstractMessage) {
if (m instanceof AbstractMessage || m instanceof GroupingLeaf) {
final NotePosition position = NotePosition.valueOf(StringUtils.goUpperCase(line0.get("POSITION", 0)));
final Url url;
if (lines.size() > 0) {
Url url = null;
if (line0.get("URL", 0) != null) {
final UrlBuilder urlBuilder = new UrlBuilder(system.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
url = urlBuilder.getUrl(lines.getFirst499().toString());
} else {
url = null;
}
if (url != null) {
lines = lines.subExtract(1, 0);
url = urlBuilder.getUrl(line0.get("URL", 0));
}
final NoteStyle style = NoteStyle.getNoteStyle(line0.get("STYLE", 0));
((AbstractMessage) m).setNote(lines.toDisplay(), position, style, line0.get("COLOR", 0), url);
if (m instanceof AbstractMessage) {
((AbstractMessage) m).setNote(lines.toDisplay(), position, style, line0.get("COLOR", 0), url);
} else {
((GroupingLeaf) m).setNote(lines.toDisplay(), position, style, line0.get("COLOR", 0), url);
}
}
return CommandExecutionResult.ok();

View File

@ -31,6 +31,9 @@
package net.sourceforge.plantuml.command.note.sequence;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
import net.sourceforge.plantuml.command.BlocLines;
import net.sourceforge.plantuml.command.Command;
import net.sourceforge.plantuml.command.CommandExecutionResult;
@ -59,6 +62,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF
new RegexLeaf("P1", "([\\p{L}0-9_.@]+|[%g][^%g]+[%g])[%s]*\\,[%s]*"), //
new RegexLeaf("P2", "([\\p{L}0-9_.@]+|[%g][^%g]+[%g])[%s]*"), //
color().getRegex(), //
new RegexLeaf("URL", "[%s]*(" + UrlBuilder.getRegexp() + ")?"), //
new RegexLeaf("$") //
);
}
@ -71,6 +75,7 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF
new RegexLeaf("P1", "([\\p{L}0-9_.@]+|[%g][^%g]+[%g])[%s]*\\,[%s]*"), //
new RegexLeaf("P2", "([\\p{L}0-9_.@]+|[%g][^%g]+[%g])[%s]*"), //
color().getRegex(), //
new RegexLeaf("URL", "[%s]*(" + UrlBuilder.getRegexp() + ")?"), //
new RegexLeaf("[%s]*:[%s]*"), //
new RegexLeaf("NOTE", "(.*)"), //
new RegexLeaf("$"));
@ -126,6 +131,11 @@ public final class FactorySequenceNoteOverSeveralCommand implements SingleMultiF
note.setColors(colors);
// note.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(line0.get("COLOR", 0)));
note.setStyle(NoteStyle.getNoteStyle(line0.get("STYLE", 0)));
if (line0.get("URL", 0) != null) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), ModeUrl.STRICT);
final Url urlLink = urlBuilder.getUrl(line0.get("URL", 0));
note.setUrl(urlLink);
}
diagram.addNote(note, tryMerge);
}
return CommandExecutionResult.ok();

View File

@ -30,12 +30,21 @@
*/
package net.sourceforge.plantuml.core;
public interface DiagramDescription {
public class DiagramDescription {
String getDescription();
private final String description;
String getCmapData();
public DiagramDescription(String description) {
this.description = description;
}
public String getType();
public String getDescription() {
return description;
}
}
@Override
public String toString() {
return description;
}
}

View File

@ -40,7 +40,6 @@ import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
@ -57,7 +56,7 @@ public class PSystemCreole extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Creole)", getClass());
return new DiagramDescription("(Creole)");
}
public void doCommandLine(String line) {

View File

@ -110,7 +110,7 @@ public class Bodier {
if (s.length() == 0 && methodsToDisplay.size() == 0) {
continue;
}
final Member m = new MemberImpl(s, true, manageModifier, true);
final Member m = new MemberImpl(s, true, manageModifier);
if (hides == null || hides.contains(m.getVisibilityModifier()) == false) {
methodsToDisplay.add(m);
}
@ -138,7 +138,7 @@ public class Bodier {
if (s.length() == 0 && fieldsToDisplay.size() == 0) {
continue;
}
final Member m = new MemberImpl(s, false, manageModifier, true);
final Member m = new MemberImpl(s, false, manageModifier);
if (hides == null || hides.contains(m.getVisibilityModifier()) == false) {
fieldsToDisplay.add(m);
}

View File

@ -68,7 +68,6 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo
private final boolean manageHorizontalLine;
private final boolean manageModifier;
private final List<Url> urls = new ArrayList<Url>();
private final boolean manageUrl;
private final Stereotype stereotype;
private final ILeaf entity;
@ -78,7 +77,6 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo
this.stereotype = stereotype;
this.fontParam = fontParam;
this.skinParam = skinParam;
this.manageUrl = true;
this.titleConfig = new FontConfiguration(skinParam, fontParam, stereotype);
this.lineFirst = true;
@ -89,9 +87,8 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo
}
public BodyEnhanced(Display display, FontParam fontParam, ISkinParam skinParam, HorizontalAlignment align,
Stereotype stereotype, boolean manageHorizontalLine, boolean manageModifier, boolean manageUrl, ILeaf entity) {
Stereotype stereotype, boolean manageHorizontalLine, boolean manageModifier, ILeaf entity) {
this.entity = entity;
this.manageUrl = manageUrl;
this.stereotype = stereotype;
this.rawBody = new ArrayList<String>();
for (CharSequence s : display) {
@ -154,7 +151,7 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPo
skinParam, CreoleMode.FULL);
blocks.add(bloc);
} else {
final Member m = new MemberImpl(s, MemberImpl.isMethod(s), manageModifier, manageUrl);
final Member m = new MemberImpl(s, MemberImpl.isMethod(s), manageModifier);
members.add(m);
if (m.getUrl() != null) {
urls.add(m.getUrl());

View File

@ -112,7 +112,9 @@ public abstract class CucaDiagram extends UmlDiagram implements GroupHierarchy,
result.setUSymbol(symbol);
}
if (result.getEntityType() == LeafType.CLASS && type == LeafType.OBJECT) {
result.muteToType(type, symbol);
if (result.muteToType(type, symbol) == false) {
return null;
}
}
this.lastEntity = result;
return result;

View File

@ -45,7 +45,6 @@ import net.sourceforge.plantuml.LineBreakStrategy;
import net.sourceforge.plantuml.LineLocationImpl;
import net.sourceforge.plantuml.SpriteContainer;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.Url;
import net.sourceforge.plantuml.UrlBuilder;
import net.sourceforge.plantuml.UrlBuilder.ModeUrl;
import net.sourceforge.plantuml.command.regex.Matcher2;
@ -76,11 +75,11 @@ public class Display implements Iterable<CharSequence> {
private final boolean isNull;
private final CreoleMode defaultCreoleMode;
public Display removeUrlHiddenNewLineUrl() {
final String full = UrlBuilder.purgeUrl(asStringWithHiddenNewLine());
return new Display(StringUtils.splitHiddenNewLine(full), this.naturalHorizontalAlignment, this.isNull,
this.defaultCreoleMode);
}
// public Display removeUrlHiddenNewLineUrl() {
// final String full = UrlBuilder.purgeUrl(asStringWithHiddenNewLine());
// return new Display(StringUtils.splitHiddenNewLine(full), this.naturalHorizontalAlignment, this.isNull,
// this.defaultCreoleMode);
// }
public final static Display NULL = new Display(null, null, true, CreoleMode.FULL);
@ -296,26 +295,26 @@ public class Display implements Iterable<CharSequence> {
return Collections.unmodifiableList(result);
}
public Url initUrl() {
if (this.size() == 0) {
return null;
}
final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.AT_START);
return urlBuilder.getUrl(StringUtils.trin(this.get(0).toString()));
}
// public Url initUrl() {
// if (this.size() == 0) {
// return null;
// }
// final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.AT_START);
// return urlBuilder.getUrl(StringUtils.trin(this.get(0).toString()));
// }
public Display removeHeadingUrl(Url url) {
if (url == null) {
return this;
}
final Display result = new Display(this.naturalHorizontalAlignment, this.isNull, this.defaultCreoleMode);
result.display.add(UrlBuilder.purgeUrl(this.get(0).toString()));
result.display.addAll(this.subList(1, this.size()).display);
if (result.isWhite() && url.getLabel() != null) {
return Display.getWithNewlines(url.getLabel());
}
return result;
}
// public Display removeHeadingUrl(Url url) {
// if (url == null) {
// return this;
// }
// final Display result = new Display(this.naturalHorizontalAlignment, this.isNull, this.defaultCreoleMode);
// result.display.add(UrlBuilder.purgeUrl(this.get(0).toString()));
// result.display.addAll(this.subList(1, this.size()).display);
// if (result.isWhite() && url.getLabel() != null) {
// return Display.getWithNewlines(url.getLabel());
// }
// return result;
// }
public boolean hasUrl() {
final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.ANYWHERE);

View File

@ -59,7 +59,7 @@ public interface ILeaf extends IEntity {
public String getGeneric();
public void muteToType(LeafType newType, USymbol newSymbol);
public boolean muteToType(LeafType newType, USymbol newSymbol);
public void setGeneric(String generic);

View File

@ -114,9 +114,9 @@ public class Link implements Hideable, Removeable {
this.type = type;
if (Display.isNull(label)) {
this.label = Display.NULL;
} else if (doWeHaveToRemoveUrlAtStart(label)) {
this.url = label.initUrl();
this.label = label.removeHeadingUrl(url).manageGuillemet();
// } else if (doWeHaveToRemoveUrlAtStart(label)) {
// this.url = label.initUrl();
// this.label = label.removeHeadingUrl(url).manageGuillemet();
} else {
this.label = label.manageGuillemet();
}
@ -137,16 +137,16 @@ public class Link implements Hideable, Removeable {
// }
}
private static boolean doWeHaveToRemoveUrlAtStart(Display label) {
if (label.size() == 0) {
return false;
}
final String s = label.get(0).toString();
if (s.matches("^\\[\\[\\S+\\]\\].+$")) {
return true;
}
return false;
}
// private static boolean doWeHaveToRemoveUrlAtStart(Display label) {
// if (label.size() == 0) {
// return false;
// }
// final String s = label.get(0).toString();
// if (s.matches("^\\[\\[\\S+\\]\\].+$")) {
// return true;
// }
// return false;
// }
public Link getInv() {
// if (getLength() == 1) {

View File

@ -49,56 +49,37 @@ public class MemberImpl implements Member {
private final VisibilityModifier visibilityModifier;
public MemberImpl(String tmpDisplay, boolean isMethod, boolean manageModifier, boolean manageUrl) {
public MemberImpl(String tmpDisplay, boolean isMethod, boolean manageModifier) {
tmpDisplay = tmpDisplay.replaceAll("(?i)\\{(method|field)\\}\\s*", "");
if (manageModifier) {
this.hasUrl = new UrlBuilder(null, ModeUrl.ANYWHERE).getUrl(tmpDisplay) != null;
final Pattern2 pstart = MyPattern.cmpile("^(" + UrlBuilder.getRegexp() + ")([^\\[\\]]+)$");
final Matcher2 mstart = pstart.matcher(tmpDisplay);
if (mstart.matches()) {
if (mstart.groupCount() != 4) {
throw new IllegalStateException();
}
final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.AT_START);
this.url = urlBuilder.getUrl(mstart.group(1));
this.url.setMember(true);
tmpDisplay = /* mstart.group(1).trim() + */StringUtils.trin(mstart.group(mstart.groupCount()));
final Pattern2 finalUrl = MyPattern.cmpile("^(.*?)(?:\\[(" + UrlBuilder.getRegexp() + ")\\])?$");
final Matcher2 matcher = finalUrl.matcher(tmpDisplay);
if (matcher.matches() == false) {
throw new IllegalStateException();
}
tmpDisplay = matcher.group(1);
final String urlString = matcher.group(2);
if (urlString == null) {
this.url = null;
} else {
final Pattern2 pend = MyPattern.cmpile("^((?:[^\\[\\]]|\\[[^\\[\\]]*\\])+)(" + UrlBuilder.getRegexp()
+ ")$");
final Matcher2 mend = pend.matcher(tmpDisplay);
if (mend.matches()) {
if (mend.groupCount() != 4) {
throw new IllegalStateException();
}
final UrlBuilder urlBuilder = new UrlBuilder(null, ModeUrl.AT_END);
this.url = urlBuilder.getUrl(mend.group(2));
this.url.setMember(true);
tmpDisplay = StringUtils.trin(mend.group(1));
} else {
this.url = null;
}
this.url = new UrlBuilder(null, ModeUrl.STRICT).getUrl(urlString);
}
} else {
this.url = null;
this.hasUrl = false;
}
this.hasUrl = this.url != null;
final String lower = StringUtils.goLowerCase(tmpDisplay);
if (manageModifier) {
this.staticModifier = lower.contains("{static}") || lower.contains("{classifier}");
this.abstractModifier = lower.contains("{abstract}");
String displayClean = tmpDisplay.replaceAll("(?i)\\{(static|classifier|abstract)\\}\\s*", "");
String displayClean = tmpDisplay.replaceAll("(?i)\\{(static|classifier|abstract)\\}\\s*", "").trim();
if (displayClean.length() == 0) {
displayClean = " ";
}
if (VisibilityModifier.isVisibilityCharacter(displayClean)) {
visibilityModifier = VisibilityModifier
.getVisibilityModifier(displayClean, isMethod == false);
visibilityModifier = VisibilityModifier.getVisibilityModifier(displayClean, isMethod == false);
this.display = StringUtils.trin(StringUtils.manageGuillemet(displayClean.substring(1)));
} else {
this.display = StringUtils.manageGuillemet(displayClean);
@ -140,7 +121,7 @@ public class MemberImpl implements Member {
}
if (isIEMandatory()) {
return "*" + display;
}
}
return display;
}
@ -200,7 +181,7 @@ public class MemberImpl implements Member {
}
public static boolean isMethod(String s) {
s = UrlBuilder.purgeUrl(s);
// s = UrlBuilder.purgeUrl(s);
if (s.contains("{method}")) {
return true;
}

View File

@ -33,8 +33,6 @@ package net.sourceforge.plantuml.cucadiagram;
import java.awt.geom.Dimension2D;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

View File

@ -155,7 +155,7 @@ final class EntityImpl implements ILeaf, IGroup {
return leafType;
}
public void muteToType(LeafType newType, USymbol newSymbol) {
public boolean muteToType(LeafType newType, USymbol newSymbol) {
checkNotGroup();
if (newType == null) {
throw new IllegalArgumentException();
@ -163,11 +163,13 @@ final class EntityImpl implements ILeaf, IGroup {
if (leafType != LeafType.STILL_UNKNOWN) {
if (leafType != LeafType.ANNOTATION && leafType != LeafType.ABSTRACT_CLASS && leafType != LeafType.CLASS
&& leafType != LeafType.ENUM && leafType != LeafType.INTERFACE) {
throw new IllegalArgumentException("type=" + leafType);
return false;
// throw new IllegalArgumentException("type=" + leafType);
}
if (newType != LeafType.ANNOTATION && newType != LeafType.ABSTRACT_CLASS && newType != LeafType.CLASS
&& newType != LeafType.ENUM && newType != LeafType.INTERFACE && newType != LeafType.OBJECT) {
throw new IllegalArgumentException("newtype=" + newType);
return false;
// throw new IllegalArgumentException("newtype=" + newType);
}
}
if (leafType == LeafType.CLASS && newType == LeafType.OBJECT) {
@ -175,6 +177,7 @@ final class EntityImpl implements ILeaf, IGroup {
}
this.leafType = newType;
this.symbol = newSymbol;
return true;
}
public Code getCode() {

View File

@ -38,7 +38,6 @@ import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
@ -54,7 +53,7 @@ public class PSystemCute extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Cute)", getClass());
return new DiagramDescription("(Cute)");
}
public void doCommandLine(String line) {

View File

@ -44,6 +44,7 @@ public class Dedications {
static {
addNormal("Write your own dedication!", "dedication");
addNormal("linux_china", "linux_china");
addCrypted("0", "pOhci6rKgPXw32AeYXhOpSY0suoauHq5VUSwFqHLHsLYgSO6WaJ7BW5vtHBAoU6ePbcW7d8Flx99MWjPSKQTDm00");
}

View File

@ -37,7 +37,6 @@ import java.io.OutputStream;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.UDrawable;
@ -73,7 +72,7 @@ public class PSystemDedication extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Dedication)", getClass());
return new DiagramDescription("(Dedication)");
}
}

View File

@ -39,7 +39,6 @@ import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.dot.ExeState;
import net.sourceforge.plantuml.cucadiagram.dot.Graphviz;
@ -60,7 +59,7 @@ public class PSystemDot extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Dot)", getClass());
return new DiagramDescription("(Dot)");
}
@Override

View File

@ -40,7 +40,6 @@ import net.sourceforge.plantuml.FileFormat;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import org.stathissideris.ascii2image.core.ConversionOptions;
@ -69,7 +68,7 @@ public class PSystemDitaa extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Ditaa)", getClass());
return new DiagramDescription("(Ditaa)");
}
@Override

View File

@ -43,7 +43,6 @@ import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.code.Transcoder;
import net.sourceforge.plantuml.code.TranscoderImpl;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
@ -60,7 +59,18 @@ import net.sourceforge.plantuml.version.PSystemVersion;
public class PSystemDonors extends AbstractPSystem {
public static final String DONORS = "UDfbL4josp0CtUCKN6lIGoXsx5J-96EdwKnsi0HRZ2d29IMdyZbwbImwqrqlu2CLSYkJIhaoJ01y3tXFgKd-7NBmI3KvbTgQhSOSdYW9XokOSmYTXxGlnGrCNRYY5jQqGLzhj6h9fONK5kpKbAa-KVTpkvMCFXqjp35woDOmrdsW3QIXDHzXtGG8BKnrCZoM8UjHDXxMDHrAich4V11-u_uTyZ2hFfIoWn4RRTMA6q-GDH_karSM8drmqB28K6CLX_9KQkWxsaB6EIgrTDsXQuNfwahRxc0PewzFy63qKGh6EjyBykkDjd3dhwrj12AX8unFbQvTg-POSe6GTKD_AL7QHta9cR0kEVjMncInbZp19xYol-1fFs1b2mbTBZEPuCQrUtxpUosDZ9Gzk5gVu3va5mmBdPTar2rgqyOCp2a6upraXFPJXlctXhmQDnk7iaiJ-3xpQqrvgMOEFGP8EnA9HXjxwvGbAMh6HnqBvIALBu6mHbX5uksUY7achr9zY6J5-suoj-pGeZdSg1UgaGyULa8GNQ5ckbijJ0oxRjwBtx-CkImz2C94uXGvpQzoSjXFkzjwEMJauH5xUQpq071gj5eZ5c8TjoFrbUoEt8rQf4-VrscGTi8MfZImJCpSvYAHIZqBwh68TXOo7NMR5RFCYU3k62l_YB0CJQZgGIOHZMcZHHTDHMh23TLXlhc7IRoP2vUW1dkAnoPmbted6bhhAbXG08cJjzsaKLmTWKwCWVEFytlK_ln-_WcZSc3jLepNR2uV0cV52_SyW3CbtcuTjMgfArbSXlz_LLRN_yGZVm26X5oY";
public static final String DONORS = "UDfbL4jksp0GtSyfk1RIGoXsxDI_17QQ0jcDfR75c29TKd8ghOAUeK3NlKABB8eMsVG2oeqwSYkJIWa8"
+ "q8Z3uNipxobMqRz55gwf82jYNHWjCO4RYlmoESoC3ws3k3kAQnXRlqKLh6YDhf2enS9a6cAT6Yl6XegQ"
+ "sjVDXZEwTDGmm-0YNS1GTe5K4FlIvW2hqaEeO2oZ_j869XtAqi6ge7r6MWoCsJE_ONSFEPZchuuQ2mEZ"
+ "f1PBKpg2IVbgFxetJAGBzXBc0MhCmv2lYXLzH9roEmUPvAfRj1KpNPvewoqiGlH53LTA7lZ0K2OxHdxQ"
+ "aHektAcq3a14T81XdSl2LcA6cKaH9ctJxpBaya5UHCgFYzUkuZPfB3YFyJ6koL_mjEknqYc7Dk6UZ71j"
+ "gvrvS3l9XHGVkxA5hE7IPwS6vZB9I8bpbAeA6QWw1ECSJ0Zrcmac7qfoObYkBV8ibUTxQ-uBIZ8njUZG"
+ "GzeIIpIOs4EhB4uHKtEGeL2EKddd2Kk4PI3UzegGPtJFf_U1hCokxSoviQXHxS_47HLezWwMJ11jAgQo"
+ "7IsCbB5jl-U_Vobr7BeNX0h4oNAQdUHaiUjsE_MipyZ1DNRoMCeUu5X9iK9CsJfsI-8zwItPCp6FRzwk"
+ "OY_jo6WOKyyo8NETi4HoSSkeXopQgS-qr4wMpJ8ZWej3gFm3mi8NeRm36GKqngLaNPGvYP4fgV3zJHoC"
+ "miaSkNWrw3fi6yDTo2rhQ2LpRq46n4xUj9r6TdK0Eb8Aci_DKr2-UMf-m23hMRjYuvNhuu_0QlR2fUd1"
+ "6PFPR2nLOY5p7jm4__-hB763IimhfzWZpTVcwUMn-TvU9PelpNFpitb--SJF8t_w1XUMQZ55bREpBiDP"
+ "jt8brkivgNPJmny9r86N";
@Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat)
@ -119,7 +129,7 @@ public class PSystemDonors extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Donors)", getClass());
return new DiagramDescription("(Donors)");
}
public static PSystemDonors create() {

View File

@ -43,7 +43,6 @@ import javax.imageio.ImageIO;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicPosition;
import net.sourceforge.plantuml.graphic.GraphicStrings;
@ -85,7 +84,7 @@ public class PSystemAppleTwo extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Apple //e)", getClass());
return new DiagramDescription("(Apple //e)");
}
private static final byte imm[] = new byte[] { (byte) 255, (byte) 216, (byte) 255, (byte) 224, (byte) 0, (byte) 16,

View File

@ -36,7 +36,6 @@ import java.io.OutputStream;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.UDrawable;
@ -70,7 +69,7 @@ public class PSystemCharlie extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Je Suis Charlie)", getClass());
return new DiagramDescription("(Je Suis Charlie)");
}
}

View File

@ -0,0 +1,277 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* 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.eggs;
import java.awt.Font;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.ImageData;
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.HtmlColorSetSimple;
import net.sourceforge.plantuml.graphic.HtmlColorSimple;
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.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UPolygon;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.UTranslate;
// http://www.redblobgames.com/grids/hexagons/
public class PSystemColors extends AbstractPSystem implements UDrawable {
private final double rectangleHeight = 28;
private final double rectangleWidth = 175;
private final HtmlColorSetSimple colors = new HtmlColorSetSimple();
private final String paletteCentralColor;
private final double size = 60;
public PSystemColors(String option) {
if (option == null) {
this.paletteCentralColor = null;
} else {
this.paletteCentralColor = option.replaceAll("\\#", "");
}
}
@Override
final protected ImageData exportDiagramNow(OutputStream os, int num, FileFormatOption fileFormat)
throws IOException {
final ImageBuilder imageBuilder = new ImageBuilder(new ColorMapperIdentity(), 1.0, HtmlColorUtils.WHITE,
getMetadata(), null, 0, 0, null, false);
imageBuilder.setUDrawable(this);
return imageBuilder.writeImageTOBEMOVED(fileFormat, os);
}
public DiagramDescription getDescription() {
return new DiagramDescription("(Colors)");
}
public void drawU(UGraphic ug) {
if (paletteCentralColor == null) {
drawFull(ug);
} else {
drawPalette(ug);
}
}
private void drawPalette(UGraphic ug) {
double x = (centerHexa(2, 0).getX() + centerHexa(3, 0).getX()) / 2;
double y = centerHexa(0, 2).getY() + corner(1).getY();
ug = ug.apply(new UTranslate(x, y));
final UPolygon hexa = getHexa();
final List<String> friends = getColorsCloseTo(paletteCentralColor);
int idx = 0;
drawOneHexa(ug, friends.get(idx++), 0, 0, hexa);
drawOneHexa(ug, friends.get(idx++), 1, 0, hexa);
drawOneHexa(ug, friends.get(idx++), 0, 1, hexa);
drawOneHexa(ug, friends.get(idx++), -1, 1, hexa);
drawOneHexa(ug, friends.get(idx++), -1, 0, hexa);
drawOneHexa(ug, friends.get(idx++), -1, -1, hexa);
drawOneHexa(ug, friends.get(idx++), 0, -1, hexa);
drawOneHexa(ug, friends.get(idx++), 2, 0, hexa);
drawOneHexa(ug, friends.get(idx++), 1, 1, hexa);
drawOneHexa(ug, friends.get(idx++), 1, 2, hexa);
drawOneHexa(ug, friends.get(idx++), 0, 2, hexa);
drawOneHexa(ug, friends.get(idx++), -1, 2, hexa);
drawOneHexa(ug, friends.get(idx++), -2, 1, hexa);
drawOneHexa(ug, friends.get(idx++), -2, 0, hexa);
drawOneHexa(ug, friends.get(idx++), -2, -1, hexa);
drawOneHexa(ug, friends.get(idx++), -1, -2, hexa);
drawOneHexa(ug, friends.get(idx++), 0, -2, hexa);
drawOneHexa(ug, friends.get(idx++), 1, -2, hexa);
drawOneHexa(ug, friends.get(idx++), 1, -1, hexa);
}
private Point2D centerHexa(int i, int j) {
final double width = getWidth();
final double x = width * i + (j % 2 == 0 ? 0 : width / 2);
final double y = size * j * 1.5;
return new Point2D.Double(x, y);
}
private double getWidth() {
return Math.sqrt(3) / 2 * 2 * size;
}
private void drawOneHexa(UGraphic ug, String colorName, int i, int j, UPolygon hexa) {
final HtmlColorSimple color = (HtmlColorSimple) colors.getColorIfValid(colorName);
ug = applyColor(ug, color);
ug = ug.apply(new UTranslate(centerHexa(i, j)));
ug.draw(hexa);
final UFont font = new UFont("SansSerif", Font.BOLD, 14);
TextBlock tt = getTextName(font, colorName, color);
Dimension2D dimText = tt.calculateDimension(ug.getStringBounder());
if (dimText.getWidth() > getWidth()) {
tt = getTextName(font, findShortest(ug.getStringBounder(), font, colorName), color);
dimText = tt.calculateDimension(ug.getStringBounder());
}
tt.drawU(ug.apply(new UTranslate(-dimText.getWidth() / 2, -dimText.getHeight() / 2)));
}
private String findShortest(StringBounder stringBounder, UFont font, String colorName) {
String result = null;
double min = Double.MAX_VALUE;
for (int i = 1; i < colorName.length() - 1; i++) {
if (Character.isLowerCase(colorName.charAt(i))) {
continue;
}
final String candidat = colorName.substring(0, i) + "\\n" + colorName.substring(i);
final TextBlock tt = getTextName(font, candidat, (HtmlColorSimple) HtmlColorUtils.BLACK);
final double width = tt.calculateDimension(stringBounder).getWidth();
if (width < min) {
result = candidat;
min = width;
}
}
return result;
}
private UGraphic applyColor(UGraphic ug, HtmlColor color) {
return ug.apply(new UChangeColor(color)).apply(new UChangeBackColor(color));
}
private Point2D corner(int i) {
double angle_deg = 60 * i + 30;
double angle_rad = Math.PI / 180 * angle_deg;
return new Point2D.Double(size * Math.cos(angle_rad), size * Math.sin(angle_rad));
}
private UPolygon getHexa() {
final UPolygon result = new UPolygon();
for (int i = 0; i < 6; i++) {
result.addPoint(corner(i));
}
return result;
}
private List<String> getColorsCloseTo(String other) {
final List<String> result = new ArrayList<String>(colors.names());
for (Iterator<String> it = result.iterator(); it.hasNext();) {
final String candidat = it.next();
final String similar = candidat.replaceAll("Gray", "Grey");
if (candidat.equals(similar)) {
continue;
}
if (result.contains(similar)) {
it.remove();
}
}
if (containsCaseInsensitive(result, other) == false) {
result.add(other);
}
Collections.sort(result, closeComparator(paletteCentralColor));
return result;
}
private boolean containsCaseInsensitive(Collection<String> source, String target) {
for (String s : source) {
if (s.equalsIgnoreCase(target)) {
return true;
}
}
return false;
}
private Comparator<String> closeComparator(String center) {
final HtmlColorSimple centerColor = (HtmlColorSimple) colors.getColorIfValid(center);
return new Comparator<String>() {
public int compare(String col1, String col2) {
final double dist1 = centerColor.distance((HtmlColorSimple) colors.getColorIfValid(col1));
final double dist2 = centerColor.distance((HtmlColorSimple) colors.getColorIfValid(col2));
return (int) Math.signum(dist1 - dist2);
}
};
}
private void drawFull(UGraphic ug) {
final UFont font = new UFont("SansSerif", Font.BOLD, 14);
ug = ug.apply(new UChangeColor(HtmlColorUtils.BLACK));
int i = 0;
int j = 0;
for (String name : colors.names()) {
UGraphic tmp = getPositioned(ug, i, j);
final HtmlColorSimple color = (HtmlColorSimple) colors.getColorIfValid(name);
applyColor(tmp, color).draw(new URectangle(rectangleWidth, rectangleHeight));
final TextBlock tt = getTextName(font, name, color);
final Dimension2D dimText = tt.calculateDimension(ug.getStringBounder());
final double dy = (rectangleHeight - dimText.getHeight()) / 2;
final double dx = (rectangleWidth - dimText.getWidth()) / 2;
tt.drawU(tmp.apply(new UTranslate(dx, dy)));
if (j++ == 20) {
j = 0;
i++;
}
}
}
private TextBlock getTextName(final UFont font, String name, final HtmlColorSimple color) {
final HtmlColorSimple opposite = color.opposite();
final FontConfiguration fc = new FontConfiguration(font, opposite, HtmlColorUtils.BLUE, true);
final TextBlock tt = Display.getWithNewlines(name).create(fc, HorizontalAlignment.CENTER,
new SpriteContainerEmpty());
return tt;
}
private UGraphic getPositioned(UGraphic ug, int i, int j) {
return ug.apply(new UTranslate(rectangleWidth * i, rectangleHeight * j));
}
}

View File

@ -0,0 +1,51 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* 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.eggs;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.command.PSystemSingleLineFactory;
public class PSystemColorsFactory extends PSystemSingleLineFactory {
@Override
protected AbstractPSystem executeLine(String line) {
final Pattern pattern = Pattern.compile("^colors?\\s*(#?\\w+)?\\s*$");
final Matcher matcher = pattern.matcher(line);
if (matcher.matches()) {
return new PSystemColors(matcher.group(1));
}
return null;
}
}

View File

@ -39,7 +39,6 @@ import java.util.StringTokenizer;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
@ -72,7 +71,7 @@ public class PSystemEgg extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Easter Eggs)", getClass());
return new DiagramDescription("(Easter Eggs)");
}
}

View File

@ -38,7 +38,6 @@ import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicPosition;
import net.sourceforge.plantuml.graphic.GraphicStrings;
@ -50,10 +49,10 @@ import net.sourceforge.plantuml.version.PSystemVersion;
public class PSystemEmpty extends AbstractPSystem {
private final List<String> strings = new ArrayList<String>();
private final boolean withLogo;
private final GraphicPosition position;
public PSystemEmpty(boolean withLogo) {
this.withLogo = withLogo;
public PSystemEmpty(GraphicPosition position) {
this.position = position;
strings.add("<b>Welcome to PlantUML!");
strings.add(" ");
strings.add("If you use this software, you accept its license.");
@ -68,7 +67,7 @@ public class PSystemEmpty extends AbstractPSystem {
strings.add("\"\"class Example\"\"");
strings.add(" ");
strings.add("You will find more information about PlantUML syntax on <u>http://plantuml.com</u>");
if (withLogo) {
if (position == GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT) {
strings.add(" ");
strings.add(" ");
strings.add(" ");
@ -88,15 +87,14 @@ public class PSystemEmpty extends AbstractPSystem {
}
public TextBlockBackcolored getGraphicStrings() throws IOException {
if (withLogo) {
return GraphicStrings.createBlackOnWhite(strings, PSystemVersion.getPlantumlImage(),
GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT);
if (position != null) {
return GraphicStrings.createBlackOnWhite(strings, PSystemVersion.getPlantumlImage(), position);
}
return GraphicStrings.createBlackOnWhite(strings);
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Empty)", getClass());
return new DiagramDescription("(Empty)");
}
}

View File

@ -34,12 +34,13 @@ import net.sourceforge.plantuml.api.PSystemFactory;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.core.DiagramType;
import net.sourceforge.plantuml.core.UmlSource;
import net.sourceforge.plantuml.graphic.GraphicPosition;
public class PSystemEmptyFactory implements PSystemFactory {
public Diagram createSystem(UmlSource source) {
if (source.getTotalLineCount() == 2) {
return new PSystemEmpty(true);
return new PSystemEmpty(GraphicPosition.BACKGROUND_CORNER_BOTTOM_RIGHT);
}
return null;
}

View File

@ -38,7 +38,6 @@ import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
@ -66,7 +65,7 @@ public class PSystemLost extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Lost)", getClass());
return new DiagramDescription("(Lost)");
}
}

View File

@ -36,7 +36,6 @@ import java.io.OutputStream;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
@ -55,7 +54,7 @@ public class PSystemPath extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Path)", getClass());
return new DiagramDescription("(Path)");
}
}

View File

@ -43,7 +43,6 @@ import javax.imageio.ImageIO;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicPosition;
import net.sourceforge.plantuml.graphic.GraphicStrings;
@ -88,7 +87,7 @@ public class PSystemRIP extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(RIP)", getClass());
return new DiagramDescription("(RIP)");
}
private static final byte imm[] = new byte[] { (byte) 255, (byte) 216, (byte) 255, (byte) 224, (byte) 0, (byte) 16,

View File

@ -44,7 +44,6 @@ import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.golem.MinMaxGolem;
import net.sourceforge.plantuml.golem.Path;
@ -80,7 +79,7 @@ public class FlowDiagram extends UmlDiagram implements TextBlock {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("Flow Diagram", getClass());
return new DiagramDescription("Flow Diagram");
}
@Override

View File

@ -39,7 +39,6 @@ import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
@ -80,7 +79,7 @@ public class PSystemListFonts extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(List fonts)", getClass());
return new DiagramDescription("(List fonts)");
}
}

View File

@ -36,7 +36,6 @@ import net.sourceforge.plantuml.ugraphic.ColorChangerMonochrome;
public class HtmlColorSimple implements HtmlColor {
private final Color color;
private final boolean monochrome;
@ -53,13 +52,11 @@ public class HtmlColorSimple implements HtmlColor {
return this.color.equals(((HtmlColorSimple) other).color);
}
HtmlColorSimple(Color c, boolean monochrome) {
this.color = c;
this.monochrome = monochrome;
}
public Color getColor999() {
return color;
}
@ -71,4 +68,17 @@ public class HtmlColorSimple implements HtmlColor {
return new HtmlColorSimple(new ColorChangerMonochrome().getChangedColor(color), true);
}
public HtmlColorSimple opposite() {
final Color mono = new ColorChangerMonochrome().getChangedColor(color);
final int grayScale = 255 - mono.getGreen() > 127 ? 255 : 0;
return new HtmlColorSimple(new Color(grayScale, grayScale, grayScale), true);
}
public double distance(HtmlColorSimple other) {
final int diffRed = Math.abs(this.color.getRed() - other.color.getRed());
final int diffGreen = Math.abs(this.color.getGreen() - other.color.getGreen());
final int diffBlue = Math.abs(this.color.getBlue() - other.color.getBlue());
return diffRed * .3 + diffGreen * .59 + diffBlue * .11;
}
}

View File

@ -59,6 +59,7 @@ public class QuoteUtils {
"Vg'f yvsr, Wvz, ohg abg nf jr xabj vg.",
"Qba'g Cnavp!",
"Jung qb lbh zrna? Na Nsevpna be Rhebcrna fjnyybj?",
"V arrq lbhe obbgf lbhe pybgurf naq lbhe zbgbeplpyr",
"Lbh sbetbg gb fnl cyrnfr...",
"Lbh unir qvrq bs qlfragrel.",
"Jbhyqa'g lbh cersre n avpr tnzr bs purff?",
@ -204,7 +205,12 @@ public class QuoteUtils {
"P'rfg cerffr-cherr dhv g'nf vagreebtr ?",
"Ybbx, nygreangvir snpgf ner abg snpgf. Gurl'er snyfrubbqf",
"Guvf vf abg n penfu, guvf vf zber bs na nygreangvir erfhyg.",
"Lbh yrnearq gb cebtenz va SBEGENA qvqa'g lbh?");
"Lbh yrnearq gb cebtenz va SBEGENA qvqa'g lbh?",
"Guvf oht vf n srngher nf qrfpevorq ol gur znexrgvat qrcnegzrag.",
"Abg rirelobql haqrefgnaqf gur uhzbe bs cebtenzzref.",
"Vs lbh yvir na beqvanel yvsr, nyy lbh'yy unir ner beqvanel fgbevrf.",
"Pbzr jvgu zr vs lbh jnag gb yvir", "Gh y'nf gebhir bh pryhv-yn ?"
);
private QuoteUtils() {
}

View File

@ -39,6 +39,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import net.sourceforge.plantuml.FileImageData;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.cucadiagram.CucaDiagram;
import net.sourceforge.plantuml.cucadiagram.IEntity;
@ -57,7 +58,7 @@ public final class CucaDiagramHtmlMaker {
this.dir = dir;
}
public List<File> create() throws IOException {
public List<FileImageData> create() throws IOException {
dir.mkdirs();
if (dir.exists() == false) {
throw new IOException("Cannot create " + dir);
@ -71,7 +72,7 @@ public final class CucaDiagramHtmlMaker {
printAllType(pw, LeafType.ABSTRACT_CLASS);
printAllType(pw, LeafType.CLASS);
htmlClose(pw);
return Arrays.asList(dir);
return Arrays.asList(new FileImageData(dir, null));
}
private void printAllType(final PrintWriter pw, LeafType type) throws IOException {

View File

@ -45,7 +45,6 @@ import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
public class PSystemJcckit extends AbstractPSystem {
@ -78,7 +77,7 @@ public class PSystemJcckit extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(JCCKit)", getClass());
return new DiagramDescription("(JCCKit)");
}
}

View File

@ -38,7 +38,6 @@ import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
@ -55,7 +54,7 @@ public class PSystemTree extends AbstractPSystem {
private final Rendering rendering = Rendering.NEEDLE;
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Tree)", getClass());
return new DiagramDescription("(Tree)");
}
@Override

View File

@ -42,7 +42,6 @@ import net.sourceforge.plantuml.EmptyImageBuilder;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.png.PngIO;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
@ -86,7 +85,7 @@ public class PSystemLogo extends AbstractPSystem {
// }
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Logo)", getClass());
return new DiagramDescription("(Logo)");
}
public void doCommandLine(String line) {

View File

@ -37,7 +37,6 @@ import java.io.OutputStream;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
public class PSystemLatex extends AbstractPSystem {
@ -48,7 +47,7 @@ public class PSystemLatex extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Latex)", getClass());
return new DiagramDescription("(Latex)");
}
@Override

View File

@ -37,7 +37,6 @@ import java.io.OutputStream;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
public class PSystemMath extends AbstractPSystem {
@ -48,7 +47,7 @@ public class PSystemMath extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Math)", getClass());
return new DiagramDescription("(Math)");
}
@Override

View File

@ -41,7 +41,6 @@ import java.util.List;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.donors.PSystemDonors;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
@ -88,7 +87,7 @@ public class PSystemListOpenIconic extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Open iconic)", getClass());
return new DiagramDescription("(Open iconic)");
}
}

View File

@ -36,7 +36,6 @@ import java.io.OutputStream;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
@ -80,7 +79,7 @@ public class PSystemOpenIconic extends AbstractPSystem {
// }
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Open iconic)", getClass());
return new DiagramDescription("(Open iconic)");
}
}

View File

@ -39,7 +39,6 @@ import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.graphic.GraphicStrings;
import net.sourceforge.plantuml.svek.TextBlockBackcolored;
@ -105,7 +104,7 @@ public class PSystemOregon extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(The Oregon Trail)", getClass());
return new DiagramDescription("(The Oregon Trail)");
}
}

View File

@ -45,7 +45,6 @@ import net.sourceforge.plantuml.UmlDiagram;
import net.sourceforge.plantuml.UmlDiagramType;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.png.PngIO;
@ -85,7 +84,7 @@ public class PostItDiagram extends UmlDiagram {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("Board of post-it", getClass());
return new DiagramDescription("Board of post-it");
}
public Area getDefaultArea() {

View File

@ -58,6 +58,11 @@ public class Define {
}
}
@Override
public String toString() {
return signature.toString();
}
public String apply(String line) {
if (definition == null) {
return line;

View File

@ -53,6 +53,11 @@ public class DefineSignature {
}
}
@Override
public String toString() {
return key + "/" + fctName + "/" + vars;
}
public boolean isMethod() {
return key.contains("(");
}

View File

@ -46,7 +46,6 @@ import net.sourceforge.plantuml.SkinParam;
import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
@ -158,7 +157,7 @@ class PrintSkin extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("Printing of " + skin.getClass().getName(), getClass());
return new DiagramDescription("Printing of " + skin.getClass().getName());
}
public PrintSkin(String className, List<String> toPrint) {

View File

@ -43,7 +43,6 @@ import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.eps.EpsStrategy;
import net.sourceforge.plantuml.png.PngIO;
@ -65,7 +64,7 @@ public class PSystemProject extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Project)", getClass());
return new DiagramDescription("(Project)");
}
@Override

View File

@ -43,7 +43,6 @@ import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.eps.EpsStrategy;
import net.sourceforge.plantuml.png.PngIO;
@ -64,7 +63,7 @@ public class PSystemProject2 extends AbstractPSystem {
}
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Project)", getClass());
return new DiagramDescription("(Project)");
}
@Override

View File

@ -41,12 +41,12 @@ public class ComplementBeforeOrAfterOrAtTaskStartOrEnd implements ComplementPatt
"(?:at|(\\d+)[%s]+days?[%s]+(before|after))[%s]+\\[([^\\[\\]]+?)\\].?s[%s]+(start|end)");
}
public Complement getComplement(GanttDiagram system, RegexResult arg, String suffix) {
public Failable<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
final String code = arg.get("COMPLEMENT" + suffix, 2);
final String position = arg.get("COMPLEMENT" + suffix, 3);
final Task task = system.getExistingTask(code);
if (task == null) {
throw new IllegalStateException();
return Failable.<Complement> error("No such task " + code);
}
final String days = arg.get("COMPLEMENT" + suffix, 0);
TaskInstant result = new TaskInstant(task, TaskAttribute.fromString(position));
@ -57,6 +57,6 @@ public class ComplementBeforeOrAfterOrAtTaskStartOrEnd implements ComplementPatt
}
result = result.withDelta(delta);
}
return result;
return Failable.<Complement> ok(result);
}
}

View File

@ -0,0 +1,47 @@
/* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* 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.project3;
import net.sourceforge.plantuml.command.regex.IRegex;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexResult;
public class ComplementClose implements ComplementPattern {
public IRegex toRegex(String suffix) {
return new RegexLeaf("ADAY" + suffix, "(closed?)");
}
public Failable<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
return null;
}
}

View File

@ -39,16 +39,16 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
public class ComplementDate implements ComplementPattern {
public IRegex toRegex(String suffix) {
return new RegexOr(toRegexA(suffix), toRegexB(suffix));
return new RegexOr(toRegexA(suffix), toRegexB(suffix), toRegexC(suffix));
}
private IRegex toRegexA(String suffix) {
return new RegexConcat( //
new RegexLeaf("ADAY" + suffix, "([\\d]+)"), //
new RegexLeaf("[\\w ]*?"), //
new RegexLeaf("[\\w, ]*?"), //
new RegexLeaf("AMONTH" + suffix, "(" + Month.getRegexString() + ")"), //
new RegexLeaf("[\\w ]*?"), //
new RegexLeaf("AYEAR" + suffix, "([\\d]+)"));
new RegexLeaf("[\\w, ]*?"), //
new RegexLeaf("AYEAR" + suffix, "([\\d]{4})"));
}
private IRegex toRegexB(String suffix) {
@ -60,12 +60,24 @@ public class ComplementDate implements ComplementPattern {
new RegexLeaf("BDAY" + suffix, "([\\d]{1,2})"));
}
public Complement getComplement(GanttDiagram system, RegexResult arg, String suffix) {
private IRegex toRegexC(String suffix) {
return new RegexConcat( //
new RegexLeaf("CMONTH" + suffix, "(" + Month.getRegexString() + ")"), //
new RegexLeaf("[\\w, ]*?"), //
new RegexLeaf("CDAY" + suffix, "([\\d]+)"), //
new RegexLeaf("[\\w, ]*?"), //
new RegexLeaf("CYEAR" + suffix, "([\\d]{4})"));
}
public Failable<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
if (arg.get("ADAY" + suffix, 0) != null) {
return resultA(arg, suffix);
return Failable.<Complement> ok(resultA(arg, suffix));
}
if (arg.get("BDAY" + suffix, 0) != null) {
return resultB(arg, suffix);
return Failable.<Complement> ok(resultB(arg, suffix));
}
if (arg.get("CDAY" + suffix, 0) != null) {
return Failable.<Complement> ok(resultC(arg, suffix));
}
throw new IllegalStateException();
}
@ -83,4 +95,11 @@ public class ComplementDate implements ComplementPattern {
final int year = Integer.parseInt(arg.get("BYEAR" + suffix, 0));
return DayAsDate.create(year, month, day);
}
private Complement resultC(RegexResult arg, String suffix) {
final int day = Integer.parseInt(arg.get("CDAY" + suffix, 0));
final String month = arg.get("CMONTH" + suffix, 0);
final int year = Integer.parseInt(arg.get("CYEAR" + suffix, 0));
return DayAsDate.create(year, month, day);
}
}

View File

@ -41,11 +41,11 @@ public class ComplementInColors implements ComplementPattern {
return new RegexLeaf("COMPLEMENT" + suffix, "in[%s+](#?\\w+)(?:/(#?\\w+))?");
}
public Complement getComplement(GanttDiagram system, RegexResult arg, String suffix) {
public Failable<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
final String color1 = arg.get("COMPLEMENT" + suffix, 0);
final String color2 = arg.get("COMPLEMENT" + suffix, 1);
final HtmlColor col1 = system.getIHtmlColorSet().getColorIfValid(color1);
final HtmlColor col2 = system.getIHtmlColorSet().getColorIfValid(color2);
return new ComplementColors(col1, col2);
return Failable.<Complement> ok(new ComplementColors(col1, col2));
}
}

View File

@ -35,7 +35,7 @@ import net.sourceforge.plantuml.command.regex.RegexResult;
public interface ComplementPattern {
public Complement getComplement(GanttDiagram system, RegexResult arg, String suffix);
public Failable<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix);
public IRegex toRegex(String suffix);

View File

@ -40,8 +40,8 @@ public class ComplementSeveralDays implements ComplementPattern {
return new RegexLeaf("COMPLEMENT" + suffix, "(\\d+)[%s]+days?");
}
public Complement getComplement(GanttDiagram system, RegexResult arg, String suffix) {
public Failable<Complement> getComplement(GanttDiagram system, RegexResult arg, String suffix) {
final String days = arg.get("COMPLEMENT" + suffix, 0);
return new DurationDay(Integer.parseInt(days));
return Failable.<Complement> ok(new DurationDay(Integer.parseInt(days)));
}
}

View File

@ -32,10 +32,31 @@ package net.sourceforge.plantuml.project3;
import net.sourceforge.plantuml.StringUtils;
public enum DayOfWeek {
public enum DayOfWeek implements Subject {
MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY;
static public String getRegexString() {
final StringBuilder sb = new StringBuilder();
for (DayOfWeek day : DayOfWeek.values()) {
if (sb.length() > 0) {
sb.append("|");
}
sb.append(day.name().substring(0, 3) + "[a-z]*");
}
return sb.toString();
}
public static DayOfWeek fromString(String value) {
value = StringUtils.goUpperCase(value).substring(0, 3);
for (DayOfWeek day : DayOfWeek.values()) {
if (day.name().startsWith(value)) {
return day;
}
}
throw new IllegalArgumentException();
}
public DayOfWeek next() {
return DayOfWeek.values()[(ordinal() + 1) % 7];
}

View File

@ -25,46 +25,51 @@
*
*
* Original Author: Arnaud Roques
*
*
*
*/
package net.sourceforge.plantuml.core;
package net.sourceforge.plantuml.project3;
public class DiagramDescriptionImpl implements DiagramDescription {
public class Failable<O> {
private final String description;
private final String cmapData;
private final Class clazz;
private final O data;
private final String error;
public DiagramDescriptionImpl(String description, Class clazz) {
this(description, clazz, null);
public static <O> Failable<O> ok(O data) {
return new Failable<O>(data, null);
}
private DiagramDescriptionImpl(String description, Class clazz, String cmapData) {
this.description = description;
this.cmapData = cmapData;
this.clazz = clazz;
public static <O> Failable<O> error(String error) {
return new Failable<O>(null, error);
}
public String getDescription() {
return description;
private Failable(O data, String error) {
if (data == null && error == null) {
throw new IllegalArgumentException();
}
if (data != null && error != null) {
throw new IllegalArgumentException();
}
this.data = data;
this.error = error;
}
public String getType() {
return clazz.getSimpleName();
public O get() {
if (data == null) {
throw new IllegalStateException();
}
return data;
}
public String getCmapData() {
return cmapData;
public boolean isFail() {
return data == null;
}
public DiagramDescription withCMapData(String cmapData) {
return new DiagramDescriptionImpl(this.description, this.clazz, cmapData);
}
@Override
public String toString() {
return description;
public String getError() {
if (error == null) {
throw new IllegalStateException();
}
return error;
}
}

View File

@ -119,8 +119,8 @@ public class GanttArrow implements UDrawable {
}
private double getX(TaskInstant when, Direction direction) {
final double x1 = timeScale.getPixel(when.getInstantTheorical());
final double x2 = timeScale.getPixel(when.getInstantTheorical().increment());
final double x1 = timeScale.getStartingPosition(when.getInstantTheorical());
final double x2 = timeScale.getStartingPosition(when.getInstantTheorical().increment());
if (direction == Direction.LEFT) {
return x1;
}

View File

@ -30,7 +30,6 @@
*/
package net.sourceforge.plantuml.project3;
import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.graphic.UDrawable;
public class GanttConstraint implements Complement {

View File

@ -45,7 +45,6 @@ import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
@ -75,7 +74,7 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
private Instant max;
public DiagramDescription getDescription() {
return new DiagramDescriptionImpl("(Project)", getClass());
return new DiagramDescription("(Project)");
}
@Override
@ -114,7 +113,7 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
return new UDrawable() {
public void drawU(UGraphic ug) {
initMinMax();
final TimeScale timeScale = new TimeScale();
final TimeScale timeScale = getTimeScale();
drawTimeHeader(ug, timeScale);
drawTasks(ug, timeScale);
drawConstraints(ug, timeScale);
@ -122,6 +121,11 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
};
}
private TimeScale getTimeScale() {
return new TimeScaleBasic();
// return new TimeScaleWithoutWeekEnd(calendar);
}
private void drawConstraints(final UGraphic ug, TimeScale timeScale) {
for (GanttConstraint constraint : constraints) {
constraint.getUDrawable(timeScale).drawU(ug);
@ -133,8 +137,8 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
final double yTotal = initTaskDraws(timeScale);
final double xmin = timeScale.getPixel(min);
final double xmax = timeScale.getPixel(max.increment());
final double xmin = timeScale.getStartingPosition(min);
final double xmax = timeScale.getStartingPosition(max.increment());
ug.apply(new UChangeColor(HtmlColorUtils.LIGHT_GRAY)).draw(new ULine(xmax - xmin, 0));
ug.apply(new UChangeColor(HtmlColorUtils.LIGHT_GRAY)).apply(new UTranslate(0, getHeaderHeight() - 3))
.draw(new ULine(xmax - xmin, 0));
@ -155,8 +159,8 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
final String d1 = "" + day.getDayOfMonth();
final TextBlock num = Display.getWithNewlines(d1).create(getFontConfiguration(), HorizontalAlignment.LEFT,
new SpriteContainerEmpty());
final double x1 = timeScale.getPixel(i);
final double x2 = timeScale.getPixel(i.increment());
final double x1 = timeScale.getStartingPosition(i);
final double x2 = timeScale.getStartingPosition(i.increment());
if (i.compareTo(max.increment()) < 0) {
final TextBlock weekDay = Display.getWithNewlines(day.getDayOfWeek().shortName()).create(
getFontConfiguration(), HorizontalAlignment.LEFT, new SpriteContainerEmpty());
@ -184,6 +188,9 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
private void drawCenter(final UGraphic ug, final TextBlock text, final double x1, final double x2) {
final double width = text.calculateDimension(ug.getStringBounder()).getWidth();
final double delta = (x2 - x1) - width;
if (delta < 0) {
return;
}
text.drawU(ug.apply(new UTranslate(x1 + delta / 2, 0)));
}
@ -192,8 +199,8 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
for (Instant i = min; i.compareTo(max.increment()) <= 0; i = i.increment()) {
final TextBlock num = Display.getWithNewlines(i.toShortString()).create(getFontConfiguration(),
HorizontalAlignment.LEFT, new SpriteContainerEmpty());
final double x1 = timeScale.getPixel(i);
final double x2 = timeScale.getPixel(i.increment());
final double x1 = timeScale.getStartingPosition(i);
final double x2 = timeScale.getStartingPosition(i.increment());
final double width = num.calculateDimension(ug.getStringBounder()).getWidth();
final double delta = (x2 - x1) - width;
if (i.compareTo(max.increment()) < 0) {
@ -233,7 +240,7 @@ public class GanttDiagram extends AbstractPSystem implements Subject {
final TaskDraw draw = task.getTaskDraw();
draw.drawU(ug.apply(new UTranslate(0, draw.getY())));
draw.getTitle().drawU(
ug.apply(new UTranslate(timeScale.getPixel(task.getStart().increment()), draw.getY())));
ug.apply(new UTranslate(timeScale.getStartingPosition(task.getStart().increment()), draw.getY())));
}
}

View File

@ -46,7 +46,7 @@ import net.sourceforge.plantuml.core.DiagramType;
public class GanttDiagramFactory extends UmlDiagramFactory {
private List<SubjectPattern> subjects() {
return Arrays.<SubjectPattern> asList(new SubjectTask(), new SubjectProject());
return Arrays.<SubjectPattern> asList(new SubjectTask(), new SubjectProject(), new SubjectDayOfWeek());
}
public GanttDiagramFactory() {

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