1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-05-31 23:50:49 +00:00

version 8048

This commit is contained in:
Arnaud Roques 2016-09-29 21:51:18 +02:00
parent b165be16e3
commit 6e2c2c32c9
71 changed files with 912 additions and 510 deletions

View File

@ -35,7 +35,7 @@
<groupId>net.sourceforge.plantuml</groupId>
<artifactId>plantuml</artifactId>
<version>8048-SNAPSHOT</version>
<version>8049-SNAPSHOT</version>
<packaging>jar</packaging>
<name>PlantUML</name>

View File

@ -56,14 +56,10 @@ public abstract class AbstractPSystem implements Diagram {
toAppend.append("(" + Version.compileTimeString() + ")\n");
toAppend.append("(" + License.getCurrent() + " source distribution)\n");
final Properties p = System.getProperties();
toAppend.append(p.getProperty("java.runtime.name"));
toAppend.append('\n');
toAppend.append(p.getProperty("java.vm.name"));
toAppend.append('\n');
toAppend.append(p.getProperty("java.runtime.version"));
toAppend.append('\n');
toAppend.append(p.getProperty("os.name"));
for (String name : OptionPrint.interestingProperties()) {
toAppend.append(p.getProperty(name));
toAppend.append('\n');
}
return toAppend.toString();
}
@ -96,12 +92,11 @@ public abstract class AbstractPSystem implements Diagram {
public String getWarningOrError() {
return null;
}
public String checkFinalError() {
return null;
}
public void makeDiagramReady() {
}

View File

@ -59,6 +59,7 @@ public enum ColorParam {
classBackground(HtmlColorUtils.MY_YELLOW, ColorType.BACK),
classBorder(HtmlColorUtils.MY_RED, ColorType.LINE),
stereotypeCBackground(HtmlColorUtils.COL_ADD1B2),
stereotypeNBackground(HtmlColorUtils.COL_E3664A),
stereotypeABackground(HtmlColorUtils.COL_A9DCDF),
stereotypeIBackground(HtmlColorUtils.COL_B4A7E5),
stereotypeEBackground(HtmlColorUtils.COL_EB937F),

View File

@ -78,8 +78,8 @@ public enum FileFormat {
return "." + StringUtils.goLowerCase(name());
}
final static BufferedImage imDummy = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
final static Graphics2D gg = imDummy.createGraphics();
final static private BufferedImage imDummy = new BufferedImage(800, 100, BufferedImage.TYPE_INT_RGB);
final static private Graphics2D gg = imDummy.createGraphics();
public StringBounder getDefaultStringBounder() {
if (this == BRAILLE_PNG) {
@ -96,11 +96,8 @@ public enum FileFormat {
}
return new StringBounder() {
public Dimension2D calculateDimension(UFont font, String text) {
// Log.info("FileFormat::calculateDimension text="+text);
final FontMetrics fm = gg.getFontMetrics(font.getFont());
// Log.info("FileFormat::calculateDimension fm="+fm);
final Rectangle2D rect = fm.getStringBounds(text, gg);
// Log.info("FileFormat::calculateDimension rect="+rect);
return new Dimension2DDouble(rect.getWidth(), rect.getHeight());
}
};
@ -142,10 +139,6 @@ public enum FileFormat {
}
final File dir = pngFile.getParentFile();
return new File(dir, computeFilename(pngFile.getName(), i));
// String name = pngFile.getName();
// name = name.replaceAll("\\" + getFileSuffix() + "$", "_" + String.format("%03d", i) + getFileSuffix());
// return new File(dir, name);
}
public String computeFilename(String name, int i) {
@ -154,5 +147,4 @@ public enum FileFormat {
}
return name.replaceAll("\\" + getFileSuffix() + "$", "_" + String.format("%03d", i) + getFileSuffix());
}
}

View File

@ -30,30 +30,10 @@
*/
package net.sourceforge.plantuml;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Dimension2D;
import java.awt.image.BufferedImage;
import java.io.Serializable;
import net.sourceforge.plantuml.eps.EpsStrategy;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorGradient;
import net.sourceforge.plantuml.graphic.HtmlColorSimple;
import net.sourceforge.plantuml.graphic.HtmlColorTransparent;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
import net.sourceforge.plantuml.ugraphic.ColorMapperIdentity;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UGraphic2;
import net.sourceforge.plantuml.ugraphic.URectangle;
import net.sourceforge.plantuml.ugraphic.eps.UGraphicEps;
import net.sourceforge.plantuml.ugraphic.g2d.UGraphicG2d;
import net.sourceforge.plantuml.ugraphic.html5.UGraphicHtml5;
import net.sourceforge.plantuml.ugraphic.svg.UGraphicSvg;
import net.sourceforge.plantuml.ugraphic.tikz.UGraphicTikz;
import net.sourceforge.plantuml.ugraphic.visio.UGraphicVdx;
/**
* A FileFormat with some parameters.
@ -121,96 +101,6 @@ public class FileFormatOption implements Serializable {
return affineTransform;
}
/**
* Create a UGraphic corresponding to this FileFormatOption
*
* @param colorMapper
* @param dpiFactor
* 1.0 for a standard dot per inch
* @param dim
* @param mybackcolor
* @param rotation
* @return
*/
public UGraphic2 createUGraphic(ColorMapper colorMapper, double dpiFactor, final Dimension2D dim,
HtmlColor mybackcolor, boolean rotation) {
switch (fileFormat) {
case PNG:
return createUGraphicPNG(colorMapper, dpiFactor, dim, mybackcolor, rotation);
case SVG:
return createUGraphicSVG(colorMapper, dpiFactor, dim, mybackcolor, rotation);
case EPS:
return new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
case EPS_TEXT:
return new UGraphicEps(colorMapper, EpsStrategy.WITH_MACRO_AND_TEXT);
case HTML5:
return new UGraphicHtml5(colorMapper);
case VDX:
return new UGraphicVdx(colorMapper);
case LATEX:
return new UGraphicTikz(colorMapper, true);
case LATEX_NO_PREAMBLE:
return new UGraphicTikz(colorMapper, false);
default:
throw new UnsupportedOperationException(fileFormat.toString());
}
}
public UGraphic2 createUGraphic(final Dimension2D dim) {
return createUGraphic(new ColorMapperIdentity(), 1.0, dim, null, false);
}
private UGraphic2 createUGraphicSVG(ColorMapper colorMapper, double scale, Dimension2D dim, HtmlColor mybackcolor,
boolean rotation) {
Color backColor = Color.WHITE;
if (mybackcolor instanceof HtmlColorSimple) {
backColor = colorMapper.getMappedColor(mybackcolor);
}
final UGraphicSvg ug;
if (mybackcolor instanceof HtmlColorGradient) {
ug = new UGraphicSvg(colorMapper, (HtmlColorGradient) mybackcolor, false, scale, getSvgLinkTarget());
} else if (backColor == null || backColor.equals(Color.WHITE)) {
ug = new UGraphicSvg(colorMapper, false, scale, getSvgLinkTarget());
} else {
ug = new UGraphicSvg(colorMapper, StringUtils.getAsHtml(backColor), false, scale, getSvgLinkTarget());
}
return ug;
}
private UGraphic2 createUGraphicPNG(ColorMapper colorMapper, double dpiFactor, final Dimension2D dim,
HtmlColor mybackcolor, boolean rotation) {
Color backColor = Color.WHITE;
if (mybackcolor instanceof HtmlColorSimple) {
backColor = colorMapper.getMappedColor(mybackcolor);
} else if (mybackcolor instanceof HtmlColorTransparent) {
backColor = null;
}
final EmptyImageBuilder builder;
final Graphics2D graphics2D;
if (rotation) {
builder = new EmptyImageBuilder((int) (dim.getHeight() * dpiFactor), (int) (dim.getWidth() * dpiFactor),
backColor);
graphics2D = builder.getGraphics2D();
graphics2D.rotate(-Math.PI / 2);
graphics2D.translate(-builder.getBufferedImage().getHeight(), 0);
} else {
builder = new EmptyImageBuilder((int) (dim.getWidth() * dpiFactor), (int) (dim.getHeight() * dpiFactor),
backColor);
graphics2D = builder.getGraphics2D();
}
final UGraphicG2d ug = new UGraphicG2d(colorMapper, graphics2D, dpiFactor);
ug.setBufferedImage(builder.getBufferedImage());
final BufferedImage im = ((UGraphicG2d) ug).getBufferedImage();
if (mybackcolor instanceof HtmlColorGradient) {
ug.apply(new UChangeBackColor(mybackcolor)).draw(new URectangle(im.getWidth(), im.getHeight()));
}
return ug;
}
public final boolean isUseRedForError() {
return useRedForError;
}

View File

@ -40,8 +40,6 @@ public interface LineConfigurable {
public void setSpecificColorTOBEREMOVED(ColorType type, HtmlColor color);
// public void setSpecificLineStroke(UStroke specificLineStroke);
}

View File

@ -39,6 +39,7 @@ public enum LineParam {
// sequenceReferenceBorder(0.1),
sequenceLifeLineBorder,
sequenceParticipantBorder, noteBorder, sequenceGroupBorder, sequenceReferenceBorder,
legendBorder,
sequenceArrow,
classBorder, objectBorder,
partitionBorder,

View File

@ -38,6 +38,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import net.sourceforge.plantuml.core.Diagram;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
public class OptionFlags {
@ -46,6 +47,10 @@ public class OptionFlags {
// static public final boolean TRACE_DOT = false;
static public boolean ALLOW_INCLUDE = true;
static public void setMaxPixel(int max) {
ImageBuilder.setMaxPixel(max);
}
static public final boolean USE_HECTOR = false;
static public boolean ADD_NICE_FOR_DOT = false;

View File

@ -32,6 +32,12 @@ package net.sourceforge.plantuml;
import java.io.File;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizUtils;
@ -94,7 +100,8 @@ public class OptionPrint {
System.out.println(" -testdot\t\tTo test the installation of graphviz");
System.out.println(" -graphvizdot \"exe\"\tTo specify dot executable");
System.out.println(" -p[ipe]\t\tTo use stdin for PlantUML source and stdout for PNG/SVG/EPS generation");
System.out.println(" -encodesprite 4|8|16[z] \"file\"\tTo encode a sprite at gray level (z for compression) from an image");
System.out
.println(" -encodesprite 4|8|16[z] \"file\"\tTo encode a sprite at gray level (z for compression) from an image");
System.out.println(" -computeurl|-encodeurl\tTo compute the encoded URL of a PlantUML source file");
System.out.println(" -decodeurl\t\tTo retrieve the PlantUML source from an encoded URL");
System.out.println(" -syntax\t\tTo report any syntax error from standard input without generating images");
@ -130,14 +137,15 @@ public class OptionPrint {
}
public static void printVersion() throws InterruptedException {
System.out
.println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")");
System.out.println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")");
System.out.println("(" + License.getCurrent() + " source distribution)");
final Properties p = System.getProperties();
System.out.println(p.getProperty("java.runtime.name"));
System.out.println(p.getProperty("java.vm.name"));
System.out.println(p.getProperty("java.runtime.version"));
System.out.println(p.getProperty("os.name"));
for (String name : interestingProperties()) {
System.out.println(p.getProperty(name));
}
for (String v : interestingValues()) {
System.out.println(v);
}
System.out.println();
for (String s : GraphvizUtils.getTestDotStrings(false)) {
System.out.println(s);
@ -145,9 +153,32 @@ public class OptionPrint {
exit();
}
public static Collection<String> interestingProperties() {
return Arrays.asList("java.runtime.name", "java.vm.name", "java.runtime.version", "os.name", "file.encoding");
}
public static Collection<String> interestingValues() {
final List<String> strings = new ArrayList<String>();
strings.add("Processors: " + Runtime.getRuntime().availableProcessors());
final long freeMemory = Runtime.getRuntime().freeMemory();
final long maxMemory = Runtime.getRuntime().maxMemory();
final long totalMemory = Runtime.getRuntime().totalMemory();
final long usedMemory = totalMemory - freeMemory;
final int threadActiveCount = Thread.activeCount();
strings.add("Max Memory: " + format(maxMemory));
strings.add("Total Memory: " + format(totalMemory));
strings.add("Free Memory: " + format(freeMemory));
strings.add("Used Memory: " + format(usedMemory));
strings.add("Thread Active Count: " + threadActiveCount);
return Collections.unmodifiableCollection(strings);
}
private static String format(final long value) {
return String.format(Locale.US, "%,d", value);
}
public static void checkVersion() throws InterruptedException {
System.out
.println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")");
System.out.println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")");
System.out.println();
final int lastversion = PSystemVersion.extractDownloadableVersion(null, null);
if (lastversion == -1) {
@ -172,8 +203,7 @@ public class OptionPrint {
public static void printAbout() throws InterruptedException {
// Duplicate in PSystemVersion
System.out
.println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")");
System.out.println("PlantUML version " + Version.versionString() + " (" + Version.compileTimeString() + ")");
System.out.println();
System.out.println("Original idea: Arnaud Roques");
System.out.println("Word Macro: Alain Bertucat & Matthieu Sabatier");

View File

@ -52,10 +52,10 @@ public class PSystemUtils {
public static List<File> exportDiagrams(Diagram system, File suggestedFile, FileFormatOption fileFormatOption)
throws IOException {
if (system instanceof UmlDiagram) {
final ISkinParam skinParam = ((UmlDiagram) system).getSkinParam();
fileFormatOption = fileFormatOption.withSvgLinkTarget(skinParam.getSvgLinkTarget());
}
// if (system instanceof UmlDiagram) {
// final ISkinParam skinParam = ((UmlDiagram) system).getSkinParam();
// fileFormatOption = fileFormatOption.withSvgLinkTarget(skinParam.getSvgLinkTarget());
// }
if (system instanceof NewpagedDiagram) {
return exportDiagramsNewpaged((NewpagedDiagram) system, suggestedFile, fileFormatOption);
}

View File

@ -31,7 +31,10 @@
package net.sourceforge.plantuml;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
@ -94,6 +97,7 @@ public class Run {
return;
}
forceOpenJdkResourceLoad();
boolean error = false;
boolean forceQuit = false;
if (option.isPattern()) {
@ -148,6 +152,15 @@ public class Run {
}
}
public static void forceOpenJdkResourceLoad() {
final BufferedImage imDummy = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
final Graphics2D gg = imDummy.createGraphics();
final String text = "Alice";
final Font font = new Font("SansSerif", Font.PLAIN, 12);
final FontMetrics fm = gg.getFontMetrics(font);
final Rectangle2D rect = fm.getStringBounds(text, gg);
}
private static void encodeSprite(List<String> result) throws IOException {
SpriteGrayLevel level = SpriteGrayLevel.GRAY_16;
boolean compressed = false;

View File

@ -342,6 +342,35 @@ public class SkinParam implements ISkinParam {
result.add("DefaultFontStyle");
result.add("DefaultFontSize");
result.add("DefaultFontColor");
result.add("MinClassWidth");
result.add("MinClassWidth");
result.add("Dpi");
result.add("DefaultTextAlignment");
result.add("Shadowing");
result.add("NoteShadowing");
result.add("Handwritten");
result.add("CircledCharacterRadius");
result.add("ClassAttributeIconSize");
result.add("Linetype");
result.add("PackageStyle");
result.add("ComponentStyle");
result.add("StereotypePosition");
result.add("Nodesep");
result.add("Ranksep");
result.add("RoundCorner");
result.add("MaxMessageSize");
result.add("Style");
result.add("SequenceParticipant");
result.add("ConditionStyle");
result.add("SameClassWidth");
result.add("HyperlinkUnderline");
result.add("Padding");
result.add("Guillemet");
result.add("SvglinkTarget");
result.add("DefaultMonospacedFontName");
result.add("TabSize");
result.add("MaxAsciiMessageLength");
result.add("ColorArrowSeparationSpace");
for (FontParam p : EnumSet.allOf(FontParam.class)) {
final String h = humanName(p.name());
result.add(h + "FontStyle");

View File

@ -216,6 +216,8 @@ public abstract class UmlDiagram extends AbstractPSystem implements Diagram, Ann
final public ImageData exportDiagram(OutputStream os, int index, FileFormatOption fileFormatOption)
throws IOException {
fileFormatOption = fileFormatOption.withSvgLinkTarget(getSkinParam().getSvgLinkTarget());
if (fileFormatOption.getFileFormat() == FileFormat.PDF) {
return exportDiagramInternalPdf(os, index);
}

View File

@ -30,35 +30,63 @@
*/
package net.sourceforge.plantuml.activitydiagram.command;
import java.util.List;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.activitydiagram.ActivityDiagram;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOr;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Code;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.GroupType;
import net.sourceforge.plantuml.cucadiagram.IEntity;
import net.sourceforge.plantuml.cucadiagram.IGroup;
import net.sourceforge.plantuml.graphic.color.ColorParser;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.graphic.color.Colors;
public class CommandPartition extends SingleLineCommand<ActivityDiagram> {
public class CommandPartition extends SingleLineCommand2<ActivityDiagram> {
public CommandPartition() {
super("(?i)^partition[%s]+([%g][^%g]+[%g]|\\S+)[%s]*(#[0-9a-fA-F]{6}|#?\\w+)?[%s]*\\{?$");
super(getRegexConcat());
}
private static RegexConcat getRegexConcat() {
return new RegexConcat(//
new RegexLeaf("^"), //
new RegexLeaf("partition"), //
new RegexLeaf("[%s]+"), //
new RegexLeaf("NAME", "([%g][^%g]+[%g]|\\S+)"), //
new RegexLeaf("[%s]*"), //
new RegexOr(//
color().getRegex(), //
new RegexLeaf("LEGACYCOLORIGNORED", "(#[0-9a-fA-F]{6}|#?\\w+)?")), //
new RegexLeaf("[%s]*\\{?$"));
}
private static ColorParser color() {
return ColorParser.simpleColor(ColorType.BACK);
}
@Override
protected CommandExecutionResult executeArg(ActivityDiagram diagram, List<String> arg) {
final Code code = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get(0)));
protected CommandExecutionResult executeArg(ActivityDiagram diagram, RegexResult arg) {
final Code code = Code.of(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0)));
final IGroup currentPackage = diagram.getCurrentGroup();
final IEntity p = diagram.getOrCreateGroup(code, Display.getWithNewlines(code), GroupType.PACKAGE,
currentPackage);
final String color = arg.get(1);
if (color != null) {
p.setSpecificColorTOBEREMOVED(ColorType.BACK, diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color));
final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
if (colors.isEmpty() == false) {
p.setColors(colors);
}
// final String color = arg.get("COLOR", 0);
// if (color != null) {
// p.setSpecificColorTOBEREMOVED(ColorType.BACK,
// diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(color));
// }
return CommandExecutionResult.ok();
}

View File

@ -259,9 +259,9 @@ public class ActivityDiagram3 extends UmlDiagram {
setCurrent(instructionIf);
}
public CommandExecutionResult elseIf(Display test, Display whenThen, HtmlColor color) {
public CommandExecutionResult elseIf(Display inlabel, Display test, Display whenThen, HtmlColor color) {
if (current() instanceof InstructionIf) {
final boolean ok = ((InstructionIf) current()).elseIf(test, whenThen, nextLinkRenderer(), color);
final boolean ok = ((InstructionIf) current()).elseIf(inlabel, test, whenThen, nextLinkRenderer(), color);
if (ok == false) {
return CommandExecutionResult.error("You cannot put an elseIf here");
}

View File

@ -48,18 +48,23 @@ public class Branch {
private final InstructionList list;
private final Display labelTest;
private final Display labelPositive;
private final Display inlabel;
private final HtmlColor color;
private LinkRendering inlinkRendering = LinkRendering.none();
private Ftile ftile;
public Branch(Swimlane swimlane, Display labelPositive, Display labelTest, HtmlColor color) {
public Branch(Swimlane swimlane, Display labelPositive, Display labelTest, HtmlColor color, Display inlabel) {
if (labelPositive == null) {
throw new IllegalArgumentException();
}
if (labelTest == null) {
throw new IllegalArgumentException();
}
if (inlabel == null) {
throw new IllegalArgumentException();
}
this.inlabel = inlabel;
this.list = new InstructionList(swimlane);
this.labelTest = labelTest;
this.labelPositive = labelPositive;
@ -109,6 +114,10 @@ public class Branch {
return inlinkRendering == null ? null : inlinkRendering.getRainbow();
}
public Display getInlabel() {
return inlabel;
}
public final Ftile getFtile() {
return ftile;
}

View File

@ -71,7 +71,7 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC
throw new IllegalArgumentException();
}
this.swimlane = swimlane;
this.thens.add(new Branch(swimlane, whenThen, labelTest, color));
this.thens.add(new Branch(swimlane, whenThen, labelTest, color, Display.NULL));
this.current = this.thens.get(0);
}
@ -84,7 +84,7 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC
branch.updateFtile(factory);
}
if (elseBranch == null) {
this.elseBranch = new Branch(swimlane, Display.NULL, Display.NULL, null);
this.elseBranch = new Branch(swimlane, Display.NULL, Display.NULL, null, Display.NULL);
}
elseBranch.updateFtile(factory);
Ftile result = factory.createIf(swimlane, thens, elseBranch, afterEndwhile, topInlinkRendering);
@ -103,17 +103,18 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC
return false;
}
this.current.setInlinkRendering(nextLinkRenderer);
this.elseBranch = new Branch(swimlane, whenElse, Display.NULL, null);
this.elseBranch = new Branch(swimlane, whenElse, Display.NULL, null, Display.NULL);
this.current = elseBranch;
return true;
}
public boolean elseIf(Display test, Display whenThen, LinkRendering nextLinkRenderer, HtmlColor color) {
public boolean elseIf(Display inlabel, Display test, Display whenThen, LinkRendering nextLinkRenderer,
HtmlColor color) {
if (elseBranch != null) {
return false;
}
this.current.setInlinkRendering(nextLinkRenderer);
this.current = new Branch(swimlane, whenThen, test, color);
this.current = new Branch(swimlane, whenThen, test, color, inlabel);
this.thens.add(current);
return true;
@ -122,7 +123,7 @@ public class InstructionIf extends WithNote implements Instruction, InstructionC
public void endif(LinkRendering nextLinkRenderer) {
endifCalled = true;
if (elseBranch == null) {
this.elseBranch = new Branch(swimlane, Display.NULL, Display.NULL, null);
this.elseBranch = new Branch(swimlane, Display.NULL, Display.NULL, null, Display.NULL);
}
this.current.setInlinkRendering(nextLinkRenderer);
}

View File

@ -49,6 +49,11 @@ public class PositionedNote {
this.colors = colors;
}
@Override
public String toString() {
return "type=" + type + " notePosition=" + notePosition + " " + display;
}
public PositionedNote(Display note, NotePosition position, NoteType type) {
this(note, position, type, null);
}

View File

@ -49,6 +49,9 @@ public class CommandElseIf2 extends SingleLineCommand2<ActivityDiagram3> {
static RegexConcat getRegexConcat() {
return new RegexConcat(new RegexLeaf("^"), //
ColorParser.exp4(), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("INLABEL", "(?:\\((.+?)\\))?"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("else[%s]*if"), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("TEST", "\\((.*?)\\)"), //
@ -66,7 +69,10 @@ public class CommandElseIf2 extends SingleLineCommand2<ActivityDiagram3> {
test = null;
}
return diagram.elseIf(Display.getWithNewlines(test), Display.getWithNewlines(arg.get("WHEN", 0)), color);
final String inlabel = arg.get("INLABEL", 0);
return diagram.elseIf(Display.getWithNewlines(inlabel), Display.getWithNewlines(test),
Display.getWithNewlines(arg.get("WHEN", 0)), color);
}
}

View File

@ -37,10 +37,14 @@ import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.SingleLineCommand2;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorUtils;
import net.sourceforge.plantuml.graphic.color.ColorParser;
import net.sourceforge.plantuml.graphic.color.ColorType;
import net.sourceforge.plantuml.graphic.color.Colors;
public class CommandPartition3 extends SingleLineCommand2<ActivityDiagram3> {
@ -52,23 +56,32 @@ public class CommandPartition3 extends SingleLineCommand2<ActivityDiagram3> {
return new RegexConcat(new RegexLeaf("^"), //
new RegexLeaf("partition"), //
new RegexLeaf("[%s]+"), //
new RegexLeaf("BACKCOLOR", "(?:(#\\w+)[%s]+)?"), //
new RegexOptional(//
new RegexConcat( //
color().getRegex(),//
new RegexLeaf("[%s]+"))), //
new RegexLeaf("TITLECOLOR", "(?:(#\\w+)[%s]+)?"), //
new RegexLeaf("NAME", "([%g][^%g]+[%g]|\\S+)"), //
new RegexLeaf("[%s]*\\{?$"));
}
private static ColorParser color() {
return ColorParser.simpleColor(ColorType.BACK);
}
@Override
protected CommandExecutionResult executeArg(ActivityDiagram3 diagram, RegexResult arg) {
final String partitionTitle = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(arg.get("NAME", 0));
final HtmlColor titleColor = diagram.getSkinParam().getIHtmlColorSet()
.getColorIfValid(arg.get("TITLECOLOR", 0));
final Colors colors = color().getColor(arg, diagram.getSkinParam().getIHtmlColorSet());
final HtmlColor backColorInSkinparam = diagram.getSkinParam().getHtmlColor(ColorParam.partitionBackground,
null, false);
final HtmlColor backColor;
if (backColorInSkinparam == null) {
backColor = diagram.getSkinParam().getIHtmlColorSet().getColorIfValid(arg.get("BACKCOLOR", 0));
backColor = colors.getColor(ColorType.BACK);
} else {
backColor = backColorInSkinparam;

View File

@ -36,6 +36,7 @@ import net.sourceforge.plantuml.ColorParam;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.FontConfiguration;
@ -49,25 +50,28 @@ import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UChangeColor;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UPolygon;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
public class EntityImageLegend extends AbstractTextBlock implements TextBlock {
private final int cornersize = 10;
private final HtmlColor noteBackgroundColor;
private final HtmlColor borderColor;
private final HtmlColor legendBackgroundColor;
private final HtmlColor legendColor;
private final int marginX = 6;
private final int marginY = 5;
private final boolean withShadow;
private final ISkinParam skinParam;
private final TextBlock textBlock;
private EntityImageLegend(Display note, ISkinParam skinParam) {
this.withShadow = false;
final Rose rose = new Rose();
this.skinParam = skinParam;
noteBackgroundColor = rose.getHtmlColor(skinParam, ColorParam.legendBackground);
borderColor = rose.getHtmlColor(skinParam, ColorParam.legendBorder);
legendBackgroundColor = rose.getHtmlColor(skinParam, ColorParam.legendBackground);
legendColor = rose.getHtmlColor(skinParam, ColorParam.legendBorder);
this.textBlock = note.create(new FontConfiguration(skinParam, FontParam.LEGEND, null),
HorizontalAlignment.LEFT, skinParam);
@ -97,13 +101,22 @@ public class EntityImageLegend extends AbstractTextBlock implements TextBlock {
return new Dimension2DDouble(width + 1, height + 1);
}
private UGraphic applyStroke(UGraphic ug) {
final UStroke stroke = skinParam.getThickness(LineParam.legendBorder, null);
if (stroke == null) {
return ug;
}
return ug.apply(stroke);
}
public void drawU(UGraphic ug) {
final StringBounder stringBounder = ug.getStringBounder();
final UPolygon polygon = getPolygonNormal(stringBounder);
if (withShadow) {
polygon.setDeltaShadow(4);
}
ug = ug.apply(new UChangeBackColor(noteBackgroundColor)).apply(new UChangeColor(borderColor));
ug = ug.apply(new UChangeBackColor(legendBackgroundColor)).apply(new UChangeColor(legendColor));
ug = applyStroke(ug);
ug.draw(polygon);
textBlock.drawU(ug.apply(new UTranslate(marginX, marginY)));
}

View File

@ -78,6 +78,12 @@ public class FtileMarged extends AbstractFtile {
orig.getInY(), orig.getOutY());
}
public UTranslate getTranslateFor(Ftile child, StringBounder stringBounder) {
UTranslate result = tile.getTranslateFor(child, stringBounder);
result = result.compose(new UTranslate(margin1, 0));
return result;
}
public void drawU(UGraphic ug) {
ug.apply(new UTranslate(margin1, 0)).draw(tile);
}

View File

@ -51,15 +51,15 @@ public class FtileFactoryDelegatorAddNote extends FtileFactoryDelegator {
if (notes.size() == 0) {
throw new IllegalArgumentException();
}
if (notes.size() > 1) {
throw new IllegalArgumentException();
}
// if (notes.size() > 1) {
// throw new IllegalArgumentException();
// }
ISkinParam skinParam = skinParam();
final PositionedNote note = notes.iterator().next();
if (note.getColors() != null) {
skinParam = note.getColors().mute(skinParam);
}
if (ftile == null) {
final PositionedNote note = notes.iterator().next();
if (note.getColors() != null) {
skinParam = note.getColors().mute(skinParam);
}
return new FtileNoteAlone(skinParam.shadowing(), note.getDisplay(), skinParam,
note.getType() == NoteType.NOTE, swimlane);
}

View File

@ -68,10 +68,10 @@ public class FtileGroup extends AbstractFtile {
private final Ftile inner;
private final TextBlock name;
private final TextBlock headerNote;
private final HtmlColor arrowColor;
// private final HtmlColor arrowColor;
private final HtmlColor borderColor;
private final HtmlColor backColor;
private final HtmlColor titleColor;
// private final HtmlColor titleColor;
private final UStroke stroke;
public FtileGroup(Ftile inner, Display title, Display displayNote, HtmlColor arrowColor, HtmlColor backColor,
@ -79,12 +79,11 @@ public class FtileGroup extends AbstractFtile {
super(inner.skinParam());
this.backColor = backColor == null ? HtmlColorUtils.WHITE : backColor;
this.inner = FtileUtils.addHorizontalMargin(inner, 10);
this.arrowColor = arrowColor;
this.titleColor = titleColor;
// this.arrowColor = arrowColor;
// this.titleColor = titleColor;
this.borderColor = backColor == null ? HtmlColorUtils.BLACK : borderColor;
final UFont font = skinParam.getFont(null, false, FontParam.PARTITION);
// final UFont font = new UFont("Serif", Font.PLAIN, 14);
// final HtmlColor fontColor = HtmlColorUtils.BLACK;
final HtmlColor fontColor = skinParam.getFontHtmlColor(null, FontParam.PARTITION);
final FontConfiguration fc = new FontConfiguration(font, fontColor, skinParam.getHyperlinkColor(),
skinParam.useUnderlineForHyperlink(), skinParam.getTabSize());
@ -182,8 +181,8 @@ public class FtileGroup extends AbstractFtile {
final StringBounder stringBounder = ug.getStringBounder();
final Dimension2D dimTotal = calculateDimension(stringBounder);
final SymbolContext symbolContext = new SymbolContext(backColor, borderColor).withShadow(skinParam().shadowing())
.withStroke(stroke);
final SymbolContext symbolContext = new SymbolContext(backColor, borderColor).withShadow(
skinParam().shadowing()).withStroke(stroke);
USymbol.FRAME.asBig(name, TextBlockUtils.empty(0, 0), dimTotal.getWidth(), dimTotal.getHeight(), symbolContext)
.drawU(ug);

View File

@ -74,7 +74,7 @@ public class FtileIfDown extends AbstractFtile {
}
public Swimlane getSwimlaneOut() {
if (optionalStop==null) {
if (optionalStop == null) {
return getSwimlaneIn();
}
return thenBlock.getSwimlaneOut();
@ -89,8 +89,9 @@ public class FtileIfDown extends AbstractFtile {
}
public static Ftile create(Ftile diamond1, Ftile diamond2, Swimlane swimlane, Ftile thenBlock, Rainbow arrowColor,
FtileFactory ftileFactory, Ftile optionalStop) {
FtileFactory ftileFactory, Ftile optionalStop, Rainbow elseColor) {
elseColor = elseColor.withDefault(arrowColor);
final FtileIfDown result = new FtileIfDown(thenBlock, diamond1, optionalStop == null ? diamond2
: new FtileEmpty(ftileFactory.skinParam()), optionalStop);
@ -99,12 +100,12 @@ public class FtileIfDown extends AbstractFtile {
final boolean hasPointOut1 = thenBlock.calculateDimension(ftileFactory.getStringBounder()).hasPointOut();
if (optionalStop == null) {
if (hasPointOut1) {
conns.add(result.new ConnectionElse(thenBlock.getInLinkRendering().getRainbow(arrowColor)));
conns.add(result.new ConnectionElse(elseColor));
} else {
conns.add(result.new ConnectionElseNoDiamond(thenBlock.getInLinkRendering().getRainbow(arrowColor)));
conns.add(result.new ConnectionElseNoDiamond(elseColor));
}
}
conns.add(result.new ConnectionOut(arrowColor));
conns.add(result.new ConnectionOut(thenBlock.getOutLinkRendering().getRainbow(arrowColor)));
return FtileUtils.addConnection(result, conns);
}

View File

@ -57,6 +57,7 @@ import net.sourceforge.plantuml.activitydiagram3.ftile.Snake;
import net.sourceforge.plantuml.activitydiagram3.ftile.Swimlane;
import net.sourceforge.plantuml.activitydiagram3.ftile.vcompact.cond.FtileIfWithLinks;
import net.sourceforge.plantuml.activitydiagram3.ftile.vertical.FtileDiamondInside2;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
import net.sourceforge.plantuml.graphic.HtmlColor;
@ -78,13 +79,16 @@ class FtileIfLongHorizontal extends AbstractFtile {
private final Rainbow arrowColor;
private FtileIfLongHorizontal(List<Ftile> diamonds, List<Ftile> tiles, Ftile tile2, Rainbow arrowColor) {
private FtileIfLongHorizontal(List<Ftile> diamonds, List<Double> inlabelSizes, List<Ftile> tiles, Ftile tile2,
Rainbow arrowColor) {
super(tiles.get(0).skinParam());
if (diamonds.size() != tiles.size()) {
throw new IllegalArgumentException();
}
for (int i = 0; i < diamonds.size(); i++) {
couples.add(new FtileAssemblySimple(diamonds.get(i), tiles.get(i)));
final Ftile diamond = diamonds.get(i);
final FtileAssemblySimple tmp = new FtileAssemblySimple(diamond, tiles.get(i));
couples.add(FtileUtils.addHorizontalMargin(tmp, inlabelSizes.get(i), 0));
}
this.tile2 = tile2;
this.diamonds = new ArrayList<Ftile>(diamonds);
@ -145,11 +149,24 @@ class FtileIfLongHorizontal extends AbstractFtile {
final Ftile tile2 = new FtileMinWidth(branch2.getFtile(), 30);
List<Ftile> diamonds = new ArrayList<Ftile>();
List<Double> inlabelSizes = new ArrayList<Double>();
for (Branch branch : thens) {
final TextBlock tb1 = branch.getLabelPositive().create(fc, HorizontalAlignment.LEFT, ftileFactory.skinParam());
final TextBlock tbTest = branch.getLabelTest().create(fc, HorizontalAlignment.LEFT, ftileFactory.skinParam());
FtileDiamondInside2 diamond = new FtileDiamondInside2(branch.skinParam(), backColor, borderColor, swimlane,
tbTest);
final TextBlock tb1 = branch.getLabelPositive().create(fc, HorizontalAlignment.LEFT,
ftileFactory.skinParam());
final TextBlock tbTest = branch.getLabelTest().create(fc, HorizontalAlignment.LEFT,
ftileFactory.skinParam());
final HtmlColor diamondColor = branch.getColor() == null ? backColor : branch.getColor();
FtileDiamondInside2 diamond = new FtileDiamondInside2(branch.skinParam(), diamondColor, borderColor,
swimlane, tbTest);
TextBlock tbInlabel = null;
if (Display.isNull(branch.getInlabel())) {
inlabelSizes.add(0.0);
} else {
tbInlabel = branch.getInlabel().create(fc, HorizontalAlignment.LEFT, ftileFactory.skinParam());
inlabelSizes.add(tbInlabel.calculateDimension(ftileFactory.getStringBounder()).getWidth());
diamond = diamond.withWest(tbInlabel);
}
diamond = diamond.withNorth(tb1);
diamonds.add(diamond);
}
@ -160,7 +177,7 @@ class FtileIfLongHorizontal extends AbstractFtile {
diamonds = alignDiamonds(diamonds, ftileFactory.getStringBounder());
final FtileIfLongHorizontal result = new FtileIfLongHorizontal(diamonds, tiles, tile2, arrowColor);
final FtileIfLongHorizontal result = new FtileIfLongHorizontal(diamonds, inlabelSizes, tiles, tile2, arrowColor);
final List<Connection> conns = new ArrayList<Connection>();
for (int i = 0; i < thens.size(); i++) {

View File

@ -103,16 +103,16 @@ public class ConditionalBuilder {
final ConditionalBuilder builder = new ConditionalBuilder(swimlane, borderColor, backColor, arrowColor,
ftileFactory, conditionStyle, branch1, branch2, skinParam, stringBounder, fcArrow, fcTest);
// if (isEmptyOrOnlySingleStop(branch2) && isEmptyOrOnlySingleStop(branch1) == false) {
// return builder.createDown(builder.getLabelBranch1(), builder.getLabelBranch2());
// return builder.createDown(builder.branch1, builder.branch2);
// }
// if (branch1.isEmpty() && branch2.isOnlySingleStop()) {
// return builder.createDown(builder.getLabelBranch1(), builder.getLabelBranch2());
// return builder.createDown(builder.branch1, builder.branch2);
// }
// if (isEmptyOrOnlySingleStop(branch1) && isEmptyOrOnlySingleStop(branch2) == false) {
// return builder.createDown(builder.getLabelBranch2(), builder.getLabelBranch1());
// return builder.createDown(builder.branch2, builder.branch1);
// }
// if (branch2.isEmpty() && branch1.isOnlySingleStop()) {
// return builder.createDown(builder.getLabelBranch2(), builder.getLabelBranch1());
// return builder.createDown(builder.branch2, builder.branch1);
// }
return builder.createWithLinks();
// return builder.createWithDiamonds();
@ -123,23 +123,27 @@ public class ConditionalBuilder {
return branch.isEmpty() || branch.isOnlySingleStop();
}
private Ftile createDown(TextBlock tb1, TextBlock tb2) {
private Ftile createDown(Branch branch1, Branch branch2) {
final Ftile tile1 = new FtileMinWidth(branch1.getFtile(), 30);
final Ftile tile2 = new FtileMinWidth(branch2.getFtile(), 30);
final TextBlock tb1 = getLabelPositive(branch1);
final TextBlock tb2 = getLabelPositive(branch2);
final Ftile diamond1 = getDiamond1(false, tb1, tb2);
final Ftile diamond2 = getDiamond2();
final Ftile diamond2 = getDiamond2(branch1, branch2, true);
if (branch2.isOnlySingleStop()) {
return FtileIfDown.create(diamond1, diamond2, swimlane, FtileUtils.addHorizontalMargin(tile1, 10),
arrowColor, ftileFactory, branch2.getFtile());
arrowColor, ftileFactory, branch2.getFtile(), branch2.getInlinkRenderingColorAndStyle());
}
if (branch1.isOnlySingleStop()) {
return FtileIfDown.create(diamond1, diamond2, swimlane, FtileUtils.addHorizontalMargin(tile2, 10),
arrowColor, ftileFactory, branch1.getFtile());
arrowColor, ftileFactory, branch1.getFtile(), branch1.getInlinkRenderingColorAndStyle());
}
if (branch1.isEmpty()) {
return FtileIfDown.create(diamond1, diamond2, swimlane, FtileUtils.addHorizontalMargin(tile2, 10),
arrowColor, ftileFactory, null);
arrowColor, ftileFactory, null, null);
}
return FtileIfDown.create(diamond1, diamond2, swimlane, FtileUtils.addHorizontalMargin(tile1, 10), arrowColor,
ftileFactory, null);
ftileFactory, null, branch2.getInlinkRenderingColorAndStyle());
}
private Ftile createNude() {
@ -149,11 +153,11 @@ public class ConditionalBuilder {
private Ftile createWithDiamonds() {
final Ftile diamond1 = getDiamond1(true);
final Ftile diamond2 = getDiamond2();
final Ftile diamond2 = getDiamond2(branch1, branch2, false);
final FtileIfWithDiamonds ftile = new FtileIfWithDiamonds(diamond1, tile1, tile2, diamond2, swimlane,
stringBounder);
final Dimension2D label1 = getLabelBranch1().calculateDimension(stringBounder);
final Dimension2D label2 = getLabelBranch2().calculateDimension(stringBounder);
final Dimension2D label1 = getLabelPositive(branch1).calculateDimension(stringBounder);
final Dimension2D label2 = getLabelPositive(branch2).calculateDimension(stringBounder);
final double diff1 = ftile.computeMarginNeedForBranchLabe1(stringBounder, label1);
final double diff2 = ftile.computeMarginNeedForBranchLabe2(stringBounder, label2);
Ftile result = FtileUtils.addHorizontalMargin(ftile, diff1, diff2);
@ -164,13 +168,13 @@ public class ConditionalBuilder {
private Ftile createWithLinks() {
final Ftile diamond1 = getDiamond1(true);
final Ftile diamond2 = getDiamond2();
final Ftile diamond2 = getDiamond2(branch1, branch2, false);
final Ftile tmp1 = FtileUtils.addHorizontalMargin(tile1, 10);
final Ftile tmp2 = FtileUtils.addHorizontalMargin(tile2, 10);
final FtileIfWithLinks ftile = new FtileIfWithLinks(diamond1, tmp1, tmp2, diamond2, swimlane, arrowColor,
stringBounder);
final Dimension2D label1 = getLabelBranch1().calculateDimension(stringBounder);
final Dimension2D label2 = getLabelBranch2().calculateDimension(stringBounder);
final Dimension2D label1 = getLabelPositive(branch1).calculateDimension(stringBounder);
final Dimension2D label2 = getLabelPositive(branch2).calculateDimension(stringBounder);
final double diff1 = ftile.computeMarginNeedForBranchLabe1(stringBounder, label1);
final double diff2 = ftile.computeMarginNeedForBranchLabe2(stringBounder, label2);
final double suppHeight = ftile.computeVerticalMarginNeedForBranchs(stringBounder, label1, label2);
@ -181,7 +185,7 @@ public class ConditionalBuilder {
}
private Ftile getDiamond1(boolean eastWest) {
return getDiamond1(eastWest, getLabelBranch1(), getLabelBranch2());
return getDiamond1(eastWest, getLabelPositive(branch1), getLabelPositive(branch2));
}
private Ftile getDiamond1(boolean eastWest, TextBlock tb1, TextBlock tb2) {
@ -215,19 +219,12 @@ public class ConditionalBuilder {
return diamond1;
}
private TextBlock getLabelBranch2() {
final TextBlock tb2 = branch2.getLabelPositive().create(fontArrow, HorizontalAlignment.LEFT,
ftileFactory.skinParam(), CreoleMode.SIMPLE_LINE);
return tb2;
private TextBlock getLabelPositive(Branch branch) {
return branch.getLabelPositive().create(fontArrow, HorizontalAlignment.LEFT, ftileFactory.skinParam(),
CreoleMode.SIMPLE_LINE);
}
private TextBlock getLabelBranch1() {
final TextBlock tb1 = branch1.getLabelPositive().create(fontArrow, HorizontalAlignment.LEFT,
ftileFactory.skinParam(), CreoleMode.SIMPLE_LINE);
return tb1;
}
private Ftile getDiamond2() {
private Ftile getDiamond2(Branch branch1, Branch branch2, boolean useNorth) {
final Ftile diamond2;
if (hasTwoBranches()) {
final Display out1 = branch1.getFtile().getOutLinkRendering().getDisplay();
@ -236,11 +233,11 @@ public class ConditionalBuilder {
final Display out2 = branch2.getFtile().getOutLinkRendering().getDisplay();
final TextBlock tbout2 = out2 == null ? null : out2.create(fontArrow, HorizontalAlignment.LEFT,
ftileFactory.skinParam(), CreoleMode.SIMPLE_LINE);
diamond2 = new FtileDiamond(tile1.skinParam(), backColor, borderColor, swimlane).withWest(tbout1).withEast(
tbout2);
FtileDiamond tmp = new FtileDiamond(tile1.skinParam(), backColor, borderColor, swimlane);
tmp = useNorth ? tmp.withNorth(tbout1) : tmp.withWest(tbout1);
tmp = tmp.withEast(tbout2);
diamond2 = tmp;
} else {
// diamond2 = new FtileEmpty(tile1.shadowing(), Diamond.diamondHalfSize * 2, Diamond.diamondHalfSize * 2,
// swimlane, swimlane);
diamond2 = new FtileEmpty(tile1.skinParam(), 0, Diamond.diamondHalfSize / 2, swimlane, swimlane);
}
return diamond2;

View File

@ -80,7 +80,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
new RegexConcat(
//
new RegexLeaf("ARROW_HEAD1", "([%s]+o|[#\\[<*+^]|[<\\[]\\|)?"), //
new RegexLeaf("ARROW_HEAD1", "([%s]+[ox]|[#\\[<*+^]|[<\\[]\\|)?"), //
new RegexLeaf("ARROW_BODY1", "([-=.]+)"), //
new RegexLeaf("ARROW_STYLE1",
"(?:\\[((?:#\\w+|dotted|dashed|plain|bold|hidden|norank)(?:,#\\w+|,dotted|,dashed|,plain|,bold|,hidden|,norank)*)\\])?"),
@ -89,7 +89,7 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
new RegexLeaf("ARROW_STYLE2",
"(?:\\[((?:#\\w+|dotted|dashed|plain|bold|hidden|norank)(?:,#\\w+|,dotted|,dashed|,plain|,bold|,hidden|,norank)*)\\])?"),
new RegexLeaf("ARROW_BODY2", "([-=.]*)"), //
new RegexLeaf("ARROW_HEAD2", "(o[%s]+|[#\\]>*+^]|\\|[>\\]])?")), //
new RegexLeaf("ARROW_HEAD2", "([ox][%s]+|[#\\]>*+^]|\\|[>\\]])?")), //
new RegexLeaf("[%s]*"), //
new RegexLeaf("SECOND_LABEL", "(?:[%g]([^%g]+)[%g])?"),
@ -427,6 +427,9 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
if ("o".equals(s)) {
return LinkDecor.AGREGATION;
}
if ("x".equals(s)) {
return LinkDecor.NOT_NAVIGABLE;
}
if ("*".equals(s)) {
return LinkDecor.COMPOSITION;
}
@ -456,6 +459,9 @@ final public class CommandLinkClass extends SingleLineCommand2<AbstractClassOrOb
if ("o".equals(s)) {
return LinkDecor.AGREGATION;
}
if ("x".equals(s)) {
return LinkDecor.NOT_NAVIGABLE;
}
if ("*".equals(s)) {
return LinkDecor.COMPOSITION;
}

View File

@ -37,6 +37,9 @@ import java.util.zip.Inflater;
public class CompressionZlib implements Compression {
// private static final int COMPRESSION_LEVEL = 9;
private static final int COMPRESSION_LEVEL = 1;
public byte[] compress(byte[] in) {
if (in.length == 0) {
return null;
@ -55,7 +58,7 @@ public class CompressionZlib implements Compression {
private byte[] tryCompress(byte[] in, final int len) {
// Compress the bytes
final Deflater compresser = new Deflater(9, true);
final Deflater compresser = new Deflater(COMPRESSION_LEVEL, true);
compresser.setInput(in);
compresser.finish();

View File

@ -52,9 +52,11 @@ import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockLineBefore;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.TextBlockVertical2;
import net.sourceforge.plantuml.svek.Ports;
import net.sourceforge.plantuml.svek.WithPorts;
import net.sourceforge.plantuml.ugraphic.UGraphic;
public class BodyEnhanced extends AbstractTextBlock implements TextBlock {
public class BodyEnhanced extends AbstractTextBlock implements TextBlock, WithPorts {
private TextBlock area2;
private final FontConfiguration titleConfig;
@ -208,6 +210,14 @@ public class BodyEnhanced extends AbstractTextBlock implements TextBlock {
return Display.getWithNewlines(s).create(titleConfig, HorizontalAlignment.LEFT, spriteContainer);
}
public Ports getPorts(StringBounder stringBounder) {
final TextBlock area = getArea(stringBounder);
if (area instanceof WithPorts) {
return ((WithPorts) area).getPorts(stringBounder);
}
return new Ports();
}
public void drawU(UGraphic ug) {
getArea(ug.getStringBounder()).drawU(ug);
}

View File

@ -69,6 +69,7 @@ public class Link implements Hideable, Removeable {
private Display note;
private Position notePosition;
private Colors noteColors;
private NoteLinkStrategy noteLinkStrategy;
private boolean invis = false;
private double weight = 1.0;
@ -328,6 +329,10 @@ public class Link implements Hideable, Removeable {
return note;
}
public final NoteLinkStrategy getNoteLinkStrategy() {
return noteLinkStrategy;
}
public final Colors getNoteColors() {
return noteColors;
}
@ -340,13 +345,15 @@ public class Link implements Hideable, Removeable {
this.note = note;
this.notePosition = position;
this.noteColors = colors;
this.noteLinkStrategy = NoteLinkStrategy.NORMAL;
}
// public final void addNote(String n, Position position, Colors colors) {
// this.note = Display.getWithNewlines(n);
// this.notePosition = position;
// this.noteColors = colors;
// }
public final void addNoteFrom(Link other, NoteLinkStrategy strategy) {
this.note = other.note;
this.notePosition = other.notePosition;
this.noteColors = other.noteColors;
this.noteLinkStrategy = strategy;
}
public boolean isAutoLinkOfAGroup() {
if (getEntity1().isGroup() == false) {

View File

@ -39,6 +39,7 @@ import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryCircle;
import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryCircleConnect;
import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryCircleCross;
import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryDiamond;
import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryNotNavigable;
import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryParenthesis;
import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryPlus;
import net.sourceforge.plantuml.svek.extremity.ExtremityFactorySquarre;
@ -46,7 +47,8 @@ import net.sourceforge.plantuml.svek.extremity.ExtremityFactoryTriangle;
public enum LinkDecor {
NONE(2, false, 0), EXTENDS(30, false, 2), COMPOSITION(15, true, 1.3), AGREGATION(15, false, 1.3),
NONE(2, false, 0), EXTENDS(30, false, 2), COMPOSITION(15, true, 1.3), AGREGATION(15, false, 1.3), NOT_NAVIGABLE(1,
false, 0.1),
ARROW(10, true, 0.5), ARROW_TRIANGLE(10, true, 0.8), ARROW_AND_CIRCLE(10, false, 0.5),
@ -88,6 +90,8 @@ public enum LinkDecor {
return new ExtremityFactoryArrow();
} else if (this == LinkDecor.ARROW_AND_CIRCLE) {
return new ExtremityFactoryArrowAndCircle();
} else if (this == LinkDecor.NOT_NAVIGABLE) {
return new ExtremityFactoryNotNavigable();
} else if (this == LinkDecor.AGREGATION) {
return new ExtremityFactoryDiamond(false, backgroundColor);
} else if (this == LinkDecor.COMPOSITION) {

View File

@ -0,0 +1,49 @@
/* ========================================================================
* 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.cucadiagram;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.Dimension2DDouble;
public enum NoteLinkStrategy {
NORMAL, HALF_PRINTED_FULL, HALF_NOT_PRINTED;
public Dimension2D computeDimension(double width, double height) {
if (this == HALF_PRINTED_FULL) {
return new Dimension2DDouble(width / 2, height);
}
if (this == HALF_NOT_PRINTED) {
return new Dimension2DDouble(0, 0);
}
return new Dimension2DDouble(width, height);
}
}

View File

@ -55,14 +55,15 @@ public class Stereotype implements CharSequence, Hideable {
private final static Pattern2 circleSprite = MyPattern.cmpile("\\<\\<[%s]*\\(?\\$(" + SpriteUtils.SPRITE_NAME
+ ")[%s]*(?:,[%s]*(#[0-9a-fA-F]{6}|\\w+))?[%s]*(?:[),](.*?))?\\>\\>");
private final String label;
private final HtmlColor htmlColor;
private final char character;
private final String sprite;
private final double radius;
private final UFont circledFont;
private final boolean automaticPackageStyle;
private String label;
private HtmlColor htmlColor;
private char character;
private String sprite;
public Stereotype(String label, double radius, UFont circledFont, IHtmlColorSet htmlColorSet) {
this(label, radius, circledFont, true, htmlColorSet);
}
@ -78,34 +79,41 @@ public class Stereotype implements CharSequence, Hideable {
this.automaticPackageStyle = automaticPackageStyle;
this.radius = radius;
this.circledFont = circledFont;
final Matcher2 mCircleChar = circleChar.matcher(label);
final Matcher2 mCircleSprite = circleSprite.matcher(label);
if (mCircleSprite.find()) {
if (StringUtils.isNotEmpty(mCircleSprite.group(3))) {
this.label = "<<" + mCircleSprite.group(3) + ">>";
} else {
this.label = null;
final StringBuilder tmpLabel = new StringBuilder();
final List<String> list = cutLabels(label, false);
for (String local : list) {
final Matcher2 mCircleChar = circleChar.matcher(local);
final Matcher2 mCircleSprite = circleSprite.matcher(local);
if (mCircleSprite.find()) {
if (StringUtils.isNotEmpty(mCircleSprite.group(3))) {
local = "<<" + mCircleSprite.group(3) + ">>";
} else {
local = null;
}
final String colName = mCircleSprite.group(2);
final HtmlColor col = htmlColorSet.getColorIfValid(colName);
this.htmlColor = col == null ? HtmlColorUtils.BLACK : col;
this.sprite = mCircleSprite.group(1);
this.character = '\0';
} else if (mCircleChar.find()) {
if (StringUtils.isNotEmpty(mCircleChar.group(3))) {
local = "<<" + mCircleChar.group(3) + ">>";
} else {
local = null;
}
final String colName = mCircleChar.group(2);
this.htmlColor = htmlColorSet.getColorIfValid(colName);
this.character = mCircleChar.group(1).charAt(0);
this.sprite = null;
}
final String colName = mCircleSprite.group(2);
final HtmlColor col = htmlColorSet.getColorIfValid(colName);
this.htmlColor = col == null ? HtmlColorUtils.BLACK : col;
this.sprite = mCircleSprite.group(1);
this.character = '\0';
} else if (mCircleChar.find()) {
if (StringUtils.isNotEmpty(mCircleChar.group(3))) {
this.label = "<<" + mCircleChar.group(3) + ">>";
} else {
this.label = null;
if (local != null) {
tmpLabel.append(local);
}
final String colName = mCircleChar.group(2);
this.htmlColor = htmlColorSet.getColorIfValid(colName);
this.character = mCircleChar.group(1).charAt(0);
this.sprite = null;
} else {
this.label = label;
this.character = '\0';
this.htmlColor = null;
this.sprite = null;
}
if (tmpLabel.length() > 0) {
this.label = tmpLabel.toString();
}
}
@ -143,17 +151,6 @@ public class Stereotype implements CharSequence, Hideable {
return "<<O-O>>".equalsIgnoreCase(label);
}
public String getLabel(boolean withGuillement) {
assert label == null || label.length() > 0;
if (isWithOOSymbol()) {
return null;
}
if (withGuillement) {
return StringUtils.manageGuillemet(label);
}
return label;
}
public List<String> getMultipleLabels() {
final List<String> result = new ArrayList<String>();
if (label != null) {
@ -201,13 +198,29 @@ public class Stereotype implements CharSequence, Hideable {
return circledFont;
}
public List<String> getLabels(boolean useGuillemet) {
if (getLabel(false) == null) {
public String getLabel(boolean withGuillement) {
assert label == null || label.length() > 0;
if (isWithOOSymbol()) {
return null;
}
if (withGuillement) {
return StringUtils.manageGuillemet(label);
}
return label;
}
public List<String> getLabels(boolean useGuillemet) {
final String labelLocal = getLabel(false);
if (labelLocal == null) {
return null;
}
return cutLabels(labelLocal, useGuillemet);
}
private static List<String> cutLabels(final String label, boolean useGuillemet) {
final List<String> result = new ArrayList<String>();
final Pattern2 p = MyPattern.cmpile("\\<\\<.*?\\>\\>");
final Matcher2 m = p.matcher(getLabel(false));
final Matcher2 m = p.matcher(label);
while (m.find()) {
if (useGuillemet) {
result.add(StringUtils.manageGuillemetStrict(m.group()));

View File

@ -54,15 +54,17 @@ public class PSystemDitaa extends AbstractPSystem {
private final ProcessingOptions processingOptions = new ProcessingOptions();
private final boolean dropShadows;
private final String data;
private final float scale;
public PSystemDitaa(String data, boolean performSeparationOfCommonEdges, boolean dropShadows) {
public PSystemDitaa(String data, boolean performSeparationOfCommonEdges, boolean dropShadows, float scale) {
this.data = data;
this.dropShadows = dropShadows;
this.processingOptions.setPerformSeparationOfCommonEdges(performSeparationOfCommonEdges);
this.scale = scale;
}
PSystemDitaa add(String line) {
return new PSystemDitaa(data + line + "\n", processingOptions.performSeparationOfCommonEdges(), dropShadows);
return new PSystemDitaa(data + line + "\n", processingOptions.performSeparationOfCommonEdges(), dropShadows, scale);
}
public DiagramDescription getDescription() {
@ -76,6 +78,7 @@ public class PSystemDitaa extends AbstractPSystem {
}
// ditaa can only export png so file format is mostly ignored
final ConversionOptions options = new ConversionOptions();
options.renderingOptions.setScale(scale);
options.setDropShadows(dropShadows);
final TextGrid grid = new TextGrid();
grid.initialiseWithText(data, null);

View File

@ -29,6 +29,9 @@
*/
package net.sourceforge.plantuml.ditaa;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.sourceforge.plantuml.command.PSystemBasicFactory;
import net.sourceforge.plantuml.core.DiagramType;
@ -54,10 +57,11 @@ public class PSystemDitaaFactory extends PSystemBasicFactory<PSystemDitaa> {
if (startLine != null && (startLine.contains("-S") || startLine.contains("--no-shadows"))) {
dropShadows = false;
}
final float scale = extractScale(startLine);
if (getDiagramType() == DiagramType.UML) {
return null;
} else if (getDiagramType() == DiagramType.DITAA) {
return new PSystemDitaa("", performSeparationOfCommonEdges, dropShadows);
return new PSystemDitaa("", performSeparationOfCommonEdges, dropShadows, scale);
} else {
throw new IllegalStateException(getDiagramType().name());
}
@ -74,7 +78,8 @@ public class PSystemDitaaFactory extends PSystemBasicFactory<PSystemDitaa> {
if (line.contains("-S") || line.contains("--no-shadows")) {
dropShadows = false;
}
return new PSystemDitaa("", performSeparationOfCommonEdges, dropShadows);
final float scale = extractScale(line);
return new PSystemDitaa("", performSeparationOfCommonEdges, dropShadows, scale);
}
if (system == null) {
return null;
@ -82,4 +87,16 @@ public class PSystemDitaaFactory extends PSystemBasicFactory<PSystemDitaa> {
return system.add(line);
}
private float extractScale(String line) {
if (line == null) {
return 1;
}
final Pattern p = Pattern.compile("scale=([\\d.]+)");
final Matcher m = p.matcher(line);
if (m.find()) {
final String number = m.group(1);
return Float.parseFloat(number);
}
return 1;
}
}

View File

@ -55,7 +55,7 @@ import net.sourceforge.plantuml.version.PSystemVersion;
public class PSystemDonors extends AbstractPSystem {
public static final String DONORS = "UDfTKyjosp0ClEChUDQa7w5OYLlvaOoTfZEvmH9YqQ88bPIKoj_MMt-iK5gPj7aYXdZiBfQfIVuVSl1C7JcLsewjnW9UA0c76rXp29s7T2x50onTUA8HzdH0tscqQikLXTIMxDIIgJlJT7r_bumv7IsiCHfaEyZq76W3QMZD0-px0664fKwkZsN8PvIzXtr7RKLMBPXRuPVDSyZ3ghafPGSBDjgg7VUU8EzltfCJ2v4vQ3Li8jJOnA6CIWtzGbkAd8jAIzSZkb6OxYwqxH6sCVhk34z63rAGwQ8Mv9SNRU71NrhR24H20sJdHdTkL6kik4J89z7VAfJsKLv29gnBJZsAJ1OxoHDyWYl_1vxgArQsbD0LeiaZ7jnOyuUljJGoKlRaEds6ho6xPDZeeYAZxb6RCMPWpZ4Oxs-XvOJsIux5pvwyolg3Grcj2VHV-THHKQcLGuy1uP74iT42FoQZIOfQyQ1ZttmwvtlWhn5saPUd4J7jv2JLRUGohYUXxjcXHTFUgJVga5iFE-6BhbGhFMqQ7WsxIVxDdz_6V7eW-CD4NXLthI_kSZYBFvcWkcRa8yDCGZtZx9sTleAV6gtsYANyAtSazOFiaToTsgGlt_Pfy7t25fPqzPzY7MmX_cdKgt38nD6haEbeMhlyf3KHR4CDDV0mn9zaGFWBXv0VcW00";
public static final String DONORS = "UDfTKqjosp0CtUCKN6lIGoXMx5R-96EdwKnsi8HOj2d29IcbyjcwwyKAfPL9XojX183lnzna_myvUA90JkKsiDLOmJDbyN0BAuwbyv1FexY7XOk_Q80TxT47ZLPjkB6GsvgTMZ252usVRs_ICRMZXHKc5za0XPuARI2Fgxc7NHSX3B3GsUsn3EM4ilEm2tHkoAePyrdu5TCzv67PVXfb1pCssgejTvwWx3xzpuuiHARYh66TeCOsBUMgtD0ljBN8EMkqR3sW6uJfzahR7c2JeWyNU3Iwbu52LoT1VlsZBJpuwsgRWCYeX-BIwk06jSA6QuHo5FsrGLcVz6LaebroJeF8P358d-0JNEK_y7IwOMLhALqbcinnxuOJl_kJbaL6nXvTq1Vu6hjhXhMk6ZBg7hKPKWRcaeBn7af2-wN4wcT7NXNTtg5uQIBV5pu6gXgrTEWnGZgGH3Hnx7rCbhIe9VSw3Sf7LBv7mXfXcuHtl2BbcHrb-fp4Ya-ZClViqA8vtwbN2iXd3riXYAvMIprQ2tF3RjHx_UUtCH-cnq2O99mIfzKrJWudjKVNcrj6Fad8QDeJJc7PwXlukT5gXrZBGt87KZ_87iZTgNN-_6sNnw1dR651DmyerS5M4fXMlGY7GYAyZ9sEHf_bwQo8uA5Ftq6Fi8bBg9r0PWcfHQSb9LrBQiuTXQXsvM6U-ZHo-Giz_Inc";
public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat) throws IOException {
final GraphicStrings result = getGraphicStrings();

View File

@ -58,6 +58,7 @@ import net.sourceforge.plantuml.webp.Portrait;
public class PSystemMemorial extends AbstractPSystem {
public static final String PARIS = "A thought for those who died in Paris the 13th November 2015.";
private Portrait portrait;
PSystemMemorial(Portrait portrait) {
@ -78,9 +79,7 @@ public class PSystemMemorial extends AbstractPSystem {
final FontConfiguration fc = new FontConfiguration(font, HtmlColorUtils.BLACK, HtmlColorUtils.BLACK,
true);
final TextBlock top = DateEventUtils.getComment(
Arrays.asList("A thought for those who died in Paris the 13th November 2015."),
HtmlColorUtils.BLACK);
final TextBlock top = DateEventUtils.getComment(Arrays.asList(PARIS), HtmlColorUtils.BLACK);
final TextBlock tb = Display.create(name, age, quote).create(fc, HorizontalAlignment.LEFT,
new SpriteContainerEmpty());

View File

@ -1,80 +0,0 @@
/* ========================================================================
* 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.graph;
import net.sourceforge.plantuml.cucadiagram.IEntity;
public class EntityImageFactory {
public AbstractEntityImage createEntityImage(IEntity entity) {
throw new UnsupportedOperationException();
// if (entity.getEntityType() == LeafType.CLASS || entity.getEntityType() == LeafType.ANNOTATION
// || entity.getEntityType() == LeafType.ABSTRACT_CLASS || entity.getEntityType() == LeafType.INTERFACE
// || entity.getEntityType() == LeafType.ENUM) {
// return new EntityImageClass(entity);
// }
// if (entity.getEntityType() == LeafType.ACTIVITY) {
// return new EntityImageActivity(entity);
// }
// if (entity.getEntityType() == LeafType.NOTE) {
// return new EntityImageNote(entity);
// }
// if (entity.getEntityType() == LeafType.POINT_FOR_ASSOCIATION) {
// return new EntityImageActivityCircle(entity, 4, 4);
// }
// if (entity.getEntityType() == LeafType.CIRCLE_START) {
// return new EntityImageActivityCircle(entity, 18, 18);
// }
// if (entity.getEntityType() == LeafType.CIRCLE_END) {
// return new EntityImageActivityCircle(entity, 18, 11);
// }
// if (entity.getEntityType() == LeafType.BRANCH) {
// return new EntityImageActivityBranch(entity);
// }
// if (entity.getEntityType() == LeafType.SYNCHRO_BAR) {
// return new EntityImageActivityBar(entity);
// }
// if (entity.getEntityType() == LeafType.USECASE) {
// return new EntityImageUsecase(entity);
// }
// if (entity.getEntityType() == LeafType.ACTOR) {
// return new EntityImageActor(entity);
// }
// if (entity.getEntityType() == LeafType.CIRCLE_INTERFACE) {
// return new EntityImageCircleInterface(entity);
// }
// if (entity.getEntityType() == LeafType.COMPONENT) {
// return new EntityImageComponent(entity);
// }
// return new EntityImageDefault(entity);
}
}

View File

@ -44,6 +44,7 @@ import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.SpriteContainerEmpty;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.eggs.PSystemMemorial;
import net.sourceforge.plantuml.ugraphic.LimitFinder;
import net.sourceforge.plantuml.ugraphic.UFont;
import net.sourceforge.plantuml.ugraphic.UGraphic;
@ -106,8 +107,7 @@ public class DateEventUtils {
new SpriteContainerEmpty());
comment = TextBlockUtils.withMinWidth(TextBlockUtils.withMargin(comment, 4, 4), 800, HorizontalAlignment.LEFT);
final TextBlock bottom0 = getComment(
Arrays.asList("A thought for those who died in Paris the 13th November 2015."), color);
final TextBlock bottom0 = getComment(Arrays.asList(PSystemMemorial.PARIS), color);
final TextBlock bottom1 = new AbstractTextBlock() {
private double margin = 10;
@ -127,7 +127,11 @@ public class DateEventUtils {
final TextBlock bottom = TextBlockUtils.mergeTB(bottom0,
TextBlockUtils.mergeLR(bottom1, comment, VerticalAlignment.CENTER), HorizontalAlignment.LEFT);
final TextBlock mergeTB = TextBlockUtils.mergeTB(textBlock, bottom, HorizontalAlignment.LEFT);
return addMajesty(mergeTB, color);
}
public static TextBlock addMajesty(TextBlock block, HtmlColor color) {
final UFont font12 = new UFont("SansSerif", Font.BOLD, 12);
final String arabic1 = "<size:16>\u0625\u0646 \u0627\u0644\u0625\u0631\u0647\u0627\u0628\u064A\u064A\u0646 \u0628\u0627\u0633\u0645 \u0627\u0644\u0625\u0633\u0644\u0627\u0645 \u0644\u064A\u0633\u0648\u0627 \u0645\u0633\u0644\u0645\u064A\u0646\u060C \u0648\u0644\u0627 \u064A\u0631\u0628\u0637\u0647\u0645 \u0628\u0627\u0644\u0625\u0633\u0644\u0627\u0645 \u0625\u0644\u0627 \u0627\u0644\u062F\u0648\u0627\u0641\u0639 \u0627\u0644\u062A\u064A \u064A\u0631\u0643\u0628\u0648\u0646 \u0639\u0644\u064A\u0647\u0627 \u0644\u062A\u0628\u0631\u064A\u0631 \u062C\u0631\u0627\u0626\u0645\u0647\u0645 \u0648\u062D\u0645\u0627\u0642\u0627\u062A\u0647\u0645.";
final String arabic2 = "<size:16>\u0641\u0647\u0645 \u0642\u0648\u0645 \u0636\u0627\u0644\u0648\u0646\u060C \u0645\u0635\u064A\u0631\u0647\u0645 \u062C\u0647\u0646\u0645 \u062E\u0627\u0644\u062F\u064A\u0646 \u0641\u064A\u0647\u0627 \u0623\u0628\u062F\u0627.";
final String english1 = "<size:10>Those who engage in terrorism, in the name of Islam, are not Muslims.";
@ -144,7 +148,7 @@ public class DateEventUtils {
"<size:10>-- His Majesty the King Mohammed the Sixth, Commander of the Faithful").create(
new FontConfiguration(font12, color, HtmlColorUtils.BLUE, true), HorizontalAlignment.LEFT,
new SpriteContainerEmpty());
return TextBlockUtils.mergeTB(mergeTB, TextBlockUtils.mergeTB(arabic, english, HorizontalAlignment.LEFT),
return TextBlockUtils.mergeTB(block, TextBlockUtils.mergeTB(arabic, english, HorizontalAlignment.LEFT),
HorizontalAlignment.LEFT);
}

View File

@ -64,14 +64,15 @@ public enum FontStyle {
return "\\<[wW](?::(#[0-9a-fA-F]{6}|\\w+))?\\>";
}
if (this == BACKCOLOR) {
return "\\<[bB][aA][cC][kK](?::(#[0-9a-fA-F]{6}|\\w+))?\\>";
// return "\\<[bB][aA][cC][kK](?::(#[0-9a-fA-F]{6}|\\w+))?\\>";
return "\\<[bB][aA][cC][kK](?::(#?\\w+(?:[-\\\\|/]#?\\w+)?))?\\>";
}
if (this == STRIKE) {
return "\\<(?:s|S|strike|STRIKE|del|DEL)(?::(#[0-9a-fA-F]{6}|\\w+))?\\>";
}
return null;
}
public boolean canHaveExtendedColor() {
if (this == UNDERLINE) {
return true;
@ -88,7 +89,6 @@ public enum FontStyle {
return false;
}
public String getCreoleSyntax() {
if (this == ITALIC) {
return "//";
@ -154,5 +154,4 @@ public enum FontStyle {
throw new IllegalArgumentException(line);
}
}

View File

@ -58,6 +58,7 @@ public class HtmlColorUtils {
public static final HtmlColor COL_FBFB77;
public static final HtmlColor COL_ADD1B2;
public static final HtmlColor COL_A9DCDF;
public static final HtmlColor COL_E3664A;
public static final HtmlColor COL_EB937F;
public static final HtmlColor COL_B4A7E5;
public static final HtmlColor COL_527BC6;
@ -96,6 +97,7 @@ public class HtmlColorUtils {
COL_FBFB77 = set.getColorIfValid("#FBFB77");
COL_ADD1B2 = set.getColorIfValid("#ADD1B2");
COL_A9DCDF = set.getColorIfValid("#A9DCDF");
COL_E3664A = set.getColorIfValid("#E3664A");
COL_EB937F = set.getColorIfValid("#EB937F");
COL_B4A7E5 = set.getColorIfValid("#B4A7E5");
COL_527BC6 = set.getColorIfValid("#527BC6");

View File

@ -93,12 +93,10 @@ public class TextBlockUtils {
}
private static final Graphics2D gg;
// private static final StringBounder dummyStringBounder;
static {
final BufferedImage imDummy = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
gg = imDummy.createGraphics();
// dummyStringBounder = StringBounderUtils.asStringBounder();
}
public static boolean isEmpty(TextBlock text, StringBounder dummyStringBounder) {
@ -109,22 +107,10 @@ public class TextBlockUtils {
return dim.getHeight() == 0 && dim.getWidth() == 0;
}
// public static StringBounder getDummyStringBounder() {
// return dummyStringBounder;
// }
public static FontRenderContext getFontRenderContext() {
return gg.getFontRenderContext();
}
// public static MinMax getMinMax(TextBlock tb) {
// return getMinMax(tb, dummyStringBounder);
// }
// public static Dimension2D getDimension(TextBlock tb) {
// return tb.calculateDimension(dummyStringBounder);
// }
public static LineMetrics getLineMetrics(UFont font, String text) {
return font.getLineMetrics(gg, text);
}

View File

@ -94,8 +94,9 @@ public class TextBlockVertical2 extends AbstractTextBlock implements TextBlock,
final Ports result = new Ports();
for (TextBlock block : blocks) {
final Dimension2D dimb = block.calculateDimension(stringBounder);
final Ports tmp = ((WithPorts) block).getPorts(stringBounder).translateY(y);
result.addThis(tmp);
y += dimb.getHeight();
result.addThis(((WithPorts) block).getPorts(stringBounder));
}
return result;
}

View File

@ -33,6 +33,7 @@ package net.sourceforge.plantuml.graphic;
import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.ugraphic.UChangeBackColor;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UGraphicStencil;
import net.sourceforge.plantuml.ugraphic.UPath;
@ -47,7 +48,6 @@ class USymbolFrame extends USymbol {
return SkinParameter.FRAME;
}
private void drawFrame(UGraphic ug, double width, double height, Dimension2D dimTitle, boolean shadowing) {
final URectangle shape = new URectangle(width, height);
if (shadowing) {
@ -74,7 +74,7 @@ class USymbolFrame extends USymbol {
polygon.lineTo(textWidth - cornersize, textHeight);
polygon.lineTo(0, textHeight);
ug.draw(polygon);
ug.apply(new UChangeBackColor(null)).draw(polygon);
}
@ -89,7 +89,8 @@ class USymbolFrame extends USymbol {
return new Margin(10 + 5, 20 + 5, 15 + 5, 5 + 5);
}
public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype, final SymbolContext symbolContext) {
public TextBlock asSmall(TextBlock name, final TextBlock label, final TextBlock stereotype,
final SymbolContext symbolContext) {
return new AbstractTextBlock() {
public void drawU(UGraphic ug) {
@ -133,11 +134,10 @@ class USymbolFrame extends USymbol {
}
};
}
@Override
public boolean manageHorizontalLine() {
return true;
}
}

View File

@ -68,6 +68,10 @@ public class ColorParser {
return new ColorParser("COLOR", new RegexLeaf("COLOR", "(" + COLORS_REGEXP + ")?"), mainType);
}
public static ColorParser mandatoryColor(ColorType mainType) {
return new ColorParser("COLOR", new RegexLeaf("COLOR", "(" + COLORS_REGEXP + ")"), mainType);
}
public static ColorParser simpleColor(String optPrefix, ColorType mainType) {
return new ColorParser("COLOR", new RegexLeaf("COLOR", "(?:" + optPrefix + " (" + COLORS_REGEXP + "))?"),
mainType);

View File

@ -61,6 +61,10 @@ public class Colors {
return new Colors();
}
public boolean isEmpty() {
return map.isEmpty();
}
private Colors copy() {
final Colors result = new Colors();
result.map.putAll(this.map);

View File

@ -41,6 +41,7 @@ import net.sourceforge.plantuml.cucadiagram.LeafType;
import net.sourceforge.plantuml.cucadiagram.Link;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.cucadiagram.NoteLinkStrategy;
import net.sourceforge.plantuml.utils.UniqueSequence;
public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram {
@ -157,8 +158,10 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
removeLink(existingLink);
}
final IEntity entity1real = existingLink.isInverted() ? existingLink.getEntity2() : existingLink.getEntity1();
final IEntity entity2real = existingLink.isInverted() ? existingLink.getEntity1() : existingLink.getEntity2();
final IEntity entity1real = existingLink.isInverted() ? existingLink.getEntity2() : existingLink
.getEntity1();
final IEntity entity2real = existingLink.isInverted() ? existingLink.getEntity1() : existingLink
.getEntity2();
entity1ToPoint = new Link(entity1real, point, existingLink.getType().getPart2(), existingLink.getLabel(),
existingLink.getLength(), existingLink.getQualifier1(), null, existingLink.getLabeldistance(),
@ -167,8 +170,6 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
pointToEntity2 = new Link(point, entity2real, existingLink.getType().getPart1(), Display.NULL,
existingLink.getLength(), null, existingLink.getQualifier2(), existingLink.getLabeldistance(),
existingLink.getLabelangle());
addLink(entity1ToPoint);
addLink(pointToEntity2);
int length = 1;
if (existingLink.getLength() == 1 && entity1 != entity2) {
@ -177,6 +178,14 @@ public abstract class AbstractClassOrObjectDiagram extends AbstractEntityDiagram
if (existingLink.getLength() == 2 && entity1 == entity2) {
length = 2;
}
if (length == 1) {
entity1ToPoint.addNoteFrom(existingLink, NoteLinkStrategy.NORMAL);
} else {
entity1ToPoint.addNoteFrom(existingLink, NoteLinkStrategy.HALF_PRINTED_FULL);
pointToEntity2.addNoteFrom(existingLink, NoteLinkStrategy.HALF_NOT_PRINTED);
}
addLink(entity1ToPoint);
addLink(pointToEntity2);
if (mode == 1) {
pointToAssocied = new Link(point, associed, linkType, label, length);

View File

@ -61,6 +61,7 @@ import net.sourceforge.plantuml.ugraphic.UClip;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UStroke;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.txt.UGraphicTxt;
public class DrawableSet {
@ -265,6 +266,8 @@ public class DrawableSet {
}
private void drawLineU22(UGraphic ug, boolean showTail, Page page) {
// http://plantuml.sourceforge.net/qa/?qa=4826/lifelines-broken-for-txt-seq-diagrams-when-create-is-used
final boolean isTxt = ug instanceof UGraphicTxt;
for (LivingParticipantBox box : getAllLivingParticipantBox()) {
final double create = box.getCreate();
final double startMin = page.getBodyRelativePosition() - box.magicMargin(ug.getStringBounder());
@ -275,7 +278,11 @@ public class DrawableSet {
continue;
}
if (create >= page.getNewpage1() && create < page.getNewpage2()) {
start += create - page.getNewpage1() + 2 * box.magicMargin(ug.getStringBounder());
if (isTxt) {
start = (int) create;
} else {
start += create - page.getNewpage1() + 2 * box.magicMargin(ug.getStringBounder());
}
}
}
final double myDelta = page.getNewpage1() - page.getHeaderHeight();

View File

@ -39,7 +39,6 @@ import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.activitydiagram3.ftile.EntityImageLegend;
import net.sourceforge.plantuml.api.ImageDataSimple;
import net.sourceforge.plantuml.core.ImageData;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.DisplayPositionned;
@ -48,6 +47,7 @@ import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlock;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.graphic.VerticalAlignment;
import net.sourceforge.plantuml.png.PngTitler;
import net.sourceforge.plantuml.real.Real;
@ -60,10 +60,9 @@ import net.sourceforge.plantuml.skin.Component;
import net.sourceforge.plantuml.skin.ComponentType;
import net.sourceforge.plantuml.skin.SimpleContext2D;
import net.sourceforge.plantuml.skin.Skin;
import net.sourceforge.plantuml.ugraphic.ImageBuilder;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UGraphic2;
import net.sourceforge.plantuml.ugraphic.UTranslate;
import net.sourceforge.plantuml.ugraphic.hand.UGraphicHandwritten;
import net.sourceforge.plantuml.utils.MathUtils;
public class SequenceDiagramFileMakerTeoz implements FileMaker {
@ -118,43 +117,61 @@ public class SequenceDiagramFileMakerTeoz implements FileMaker {
private final LivingSpaces livingSpaces = new LivingSpaces();
private final double heightEnglober1;
private final double heightEnglober2;
private double oneOf(double a, double b) {
if (a == 1) {
return b;
}
return a;
}
public ImageData createOne(OutputStream os, int index, boolean isWithMetadata) throws IOException {
final UTranslate min1translate = new UTranslate(-min1.getCurrentValue(), 0);
final double dpiFactor = diagram.getDpiFactor(fileFormatOption, dimTotal);
final UGraphic2 ug2 = (UGraphic2) fileFormatOption.createUGraphic(getSkinParam().getColorMapper(), dpiFactor,
dimTotal, getSkinParam().getBackgroundColor(), false).apply(min1translate);
UGraphic ug = getSkinParam().handwritten() ? new UGraphicHandwritten(ug2) : ug2;
englobers.drawEnglobers(goDownForEnglobers(ug), main.calculateDimension(stringBounder).getHeight()
+ this.heightEnglober1 + this.heightEnglober2 / 2, new SimpleContext2D(true));
final double scale = 1;
final String metadata = fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null;
printAligned(ug, diagram.getFooterOrHeaderTeoz(FontParam.HEADER).getHorizontalAlignment(), header);
ug = goDown(ug, header);
final ImageBuilder imageBuilder = new ImageBuilder(diagram.getSkinParam().getColorMapper(), oneOf(scale,
dpiFactor), diagram.getSkinParam().getBackgroundColor(), metadata, null, 3, 10, diagram.getAnimation(),
diagram.getSkinParam().handwritten());
imageBuilder.setUDrawable(new UDrawable() {
public void drawU(UGraphic ug) {
ug = ug.apply(min1translate);
englobers.drawEnglobers(goDownForEnglobers(ug), main.calculateDimension(stringBounder).getHeight()
+ heightEnglober1 + heightEnglober2 / 2, new SimpleContext2D(true));
printAligned(ug, HorizontalAlignment.CENTER, title);
ug = goDown(ug, title);
printAligned(ug, diagram.getFooterOrHeaderTeoz(FontParam.HEADER).getHorizontalAlignment(), header);
ug = goDown(ug, header);
printAligned(ug, HorizontalAlignment.CENTER, title);
ug = goDown(ug, title);
if (diagram.getLegend().getVerticalAlignment() == VerticalAlignment.TOP) {
printAligned(ug, diagram.getLegend().getHorizontalAlignment(), legend);
ug = goDown(ug, legend);
}
ug = ug.apply(new UTranslate(0, heightEnglober1));
printAligned(ug, HorizontalAlignment.CENTER, main);
ug = goDown(ug, main);
ug = ug.apply(new UTranslate(0, heightEnglober2));
if (diagram.getLegend().getVerticalAlignment() == VerticalAlignment.BOTTOM) {
printAligned(ug, diagram.getLegend().getHorizontalAlignment(), legend);
ug = goDown(ug, legend);
}
printAligned(ug, diagram.getFooterOrHeaderTeoz(FontParam.FOOTER).getHorizontalAlignment(), footer);
}
});
return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
if (diagram.getLegend().getVerticalAlignment() == VerticalAlignment.TOP) {
printAligned(ug, diagram.getLegend().getHorizontalAlignment(), legend);
ug = goDown(ug, legend);
}
ug = ug.apply(new UTranslate(0, this.heightEnglober1));
printAligned(ug, HorizontalAlignment.CENTER, main);
ug = goDown(ug, main);
ug = ug.apply(new UTranslate(0, this.heightEnglober2));
if (diagram.getLegend().getVerticalAlignment() == VerticalAlignment.BOTTOM) {
printAligned(ug, diagram.getLegend().getHorizontalAlignment(), legend);
ug = goDown(ug, legend);
}
printAligned(ug, diagram.getFooterOrHeaderTeoz(FontParam.FOOTER).getHorizontalAlignment(), footer);
ug2.writeImageTOBEMOVED(os, isWithMetadata ? diagram.getMetadata() : null, diagram.getDpi(fileFormatOption));
return new ImageDataSimple(dimTotal);
}
private UGraphic goDownForEnglobers(UGraphic ug) {

View File

@ -405,7 +405,7 @@ public final class DotDataImageBuilder {
return new EntityImageDescription(leaf, new SkinParamForecolored(skinParam, HtmlColorUtils.BLACK),
portionShower);
}
return new EntityImageEmptyPackage(leaf, skinParam);
return new EntityImageEmptyPackage(leaf, skinParam, portionShower);
}
if (leaf.getEntityType() == LeafType.ASSOCIATION) {
return new EntityImageAssociation(leaf, skinParam);

View File

@ -35,6 +35,7 @@ import java.awt.geom.Point2D;
import java.util.Collection;
import java.util.List;
import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.Hideable;
import net.sourceforge.plantuml.ISkinParam;
@ -52,6 +53,7 @@ import net.sourceforge.plantuml.cucadiagram.LinkArrow;
import net.sourceforge.plantuml.cucadiagram.LinkDecor;
import net.sourceforge.plantuml.cucadiagram.LinkMiddleDecor;
import net.sourceforge.plantuml.cucadiagram.LinkType;
import net.sourceforge.plantuml.cucadiagram.NoteLinkStrategy;
import net.sourceforge.plantuml.cucadiagram.dot.GraphvizVersion;
import net.sourceforge.plantuml.graphic.AbstractTextBlock;
import net.sourceforge.plantuml.graphic.FontConfiguration;
@ -94,6 +96,7 @@ public class Line implements Moveable, Hideable {
private final TextBlock startTailText;
private final TextBlock endHeadText;
private final TextBlock labelText;
private boolean divideLabelWidthByTwo = false;
private final int lineColor;
private final int noteLabelColor;
@ -266,6 +269,10 @@ public class Line implements Moveable, Hideable {
noteOnly = null;
} else {
noteOnly = new EntityImageNoteLink(link.getNote(), link.getNoteColors(), skinParam);
if (link.getNoteLinkStrategy() == NoteLinkStrategy.HALF_NOT_PRINTED
|| link.getNoteLinkStrategy() == NoteLinkStrategy.HALF_PRINTED_FULL) {
divideLabelWidthByTwo = true;
}
}
if (labelOnly != null && noteOnly != null) {
@ -347,7 +354,8 @@ public class Line implements Moveable, Hideable {
} else {
sb.append("label=<");
}
appendTable(sb, labelText.calculateDimension(stringBounder), noteLabelColor, graphvizVersion);
appendTable(sb, eventuallyDivideByTwo(labelText.calculateDimension(stringBounder)), noteLabelColor,
graphvizVersion);
sb.append(">");
// sb.append(",labelfloat=true");
}
@ -384,6 +392,13 @@ public class Line implements Moveable, Hideable {
SvekUtils.println(sb);
}
private Dimension2D eventuallyDivideByTwo(Dimension2D dim) {
if (divideLabelWidthByTwo) {
return new Dimension2DDouble(dim.getWidth() / 2, dim.getHeight());
}
return dim;
}
public String rankSame() {
// if (graphvizVersion == GraphvizVersion.V2_34_0) {
// return null;
@ -662,7 +677,8 @@ public class Line implements Moveable, Hideable {
// System.err.println("Line::draw EXTREMITY2");
this.extremity1.drawU(ug.apply(new UTranslate(x, y)));
}
if (this.labelText != null && this.labelXY != null) {
if (this.labelText != null && this.labelXY != null
&& link.getNoteLinkStrategy() != NoteLinkStrategy.HALF_NOT_PRINTED) {
this.labelText.drawU(ug.apply(new UTranslate(x + this.labelXY.getPosition().getX(), y
+ this.labelXY.getPosition().getY())));
}

View File

@ -40,6 +40,11 @@ public class Ports {
public void addThis(Ports other) {
all.putAll(other.all);
}
@Override
public String toString() {
return all.toString();
}
public Ports translateY(double deltaY) {
final Ports result = new Ports();

View File

@ -0,0 +1,50 @@
/* ========================================================================
* 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.svek.extremity;
import java.awt.geom.Point2D;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.svek.AbstractExtremityFactory;
public class ExtremityFactoryNotNavigable extends AbstractExtremityFactory implements ExtremityFactory {
@Override
public UDrawable createUDrawable(Point2D p0, double angle) {
return new ExtremityNotNavigable(p0, angle - Math.PI / 2);
}
public UDrawable createUDrawable(Point2D p0, Point2D p1, Point2D p2) {
final double ortho = atan2(p0, p2);
return new ExtremityNotNavigable(p1, ortho);
}
}

View File

@ -0,0 +1,67 @@
/* ========================================================================
* 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.svek.extremity;
import java.awt.geom.Point2D;
import net.sourceforge.plantuml.ugraphic.UGraphic;
import net.sourceforge.plantuml.ugraphic.UPath;
class ExtremityNotNavigable extends Extremity {
private UPath path = new UPath();
private final Point2D contact;
@Override
public Point2D somePoint() {
return contact;
}
public ExtremityNotNavigable(Point2D p1, double angle) {
this.contact = new Point2D.Double(p1.getX(), p1.getY());
angle = manageround(angle);
final double size = 4;
final double move = 5;
path.moveTo(-size, 0);
path.lineTo(size, 2 * size);
path.moveTo(size, 0);
path.lineTo(-size, 2 * size);
path = path.translate(0, move);
path = path.rotate(angle + Math.PI);
path = path.translate(p1.getX(), p1.getY());
}
public void drawU(UGraphic ug) {
ug.draw(path);
}
}

View File

@ -69,7 +69,7 @@ public class EntityImageClassHeader2 extends AbstractEntityImage {
final boolean italic = entity.getEntityType() == LeafType.ABSTRACT_CLASS
|| entity.getEntityType() == LeafType.INTERFACE;
final HtmlColor color = SkinParamUtils.getFontColor(getSkinParam(), FontParam.CLASS, getStereo());
// final HtmlColor color = SkinParamUtils.getFontColor(getSkinParam(), FontParam.CLASS, getStereo());
final Stereotype stereotype = entity.getStereotype();
final String generic = entity.getGeneric();
FontConfiguration fontConfigurationName = new FontConfiguration(getSkinParam(), FontParam.CLASS, stereotype);
@ -142,7 +142,7 @@ public class EntityImageClassHeader2 extends AbstractEntityImage {
}
if (entity.getEntityType() == LeafType.ANNOTATION) {
return new CircledCharacter('@', getSkinParam().getCircledCharacterRadius(), font, SkinParamUtils.getColor(
getSkinParam(), ColorParam.stereotypeABackground, stereotype), classBorder,
getSkinParam(), ColorParam.stereotypeNBackground, stereotype), classBorder,
SkinParamUtils.getFontColor(getSkinParam(), FontParam.CIRCLED_CHARACTER, null));
}
if (entity.getEntityType() == LeafType.ABSTRACT_CLASS) {

View File

@ -38,7 +38,10 @@ import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.cucadiagram.EntityPortion;
import net.sourceforge.plantuml.cucadiagram.ILeaf;
import net.sourceforge.plantuml.cucadiagram.PortionShower;
import net.sourceforge.plantuml.cucadiagram.Stereotype;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.HorizontalAlignment;
@ -61,20 +64,34 @@ public class EntityImageEmptyPackage extends AbstractEntityImage {
final private HtmlColor specificBackColor;
final private ISkinParam skinParam;
final private Stereotype stereotype;
final TextBlock stereoBlock;
public EntityImageEmptyPackage(ILeaf entity, ISkinParam skinParam) {
public EntityImageEmptyPackage(ILeaf entity, ISkinParam skinParam, PortionShower portionShower) {
super(entity, skinParam);
this.skinParam = skinParam;
this.specificBackColor = entity.getColors(skinParam).getColor(ColorType.BACK);
this.stereotype = entity.getStereotype();
this.desc = entity.getDisplay().create(
new FontConfiguration(getSkinParam(), FontParam.PACKAGE, stereotype),
this.desc = entity.getDisplay().create(new FontConfiguration(getSkinParam(), FontParam.PACKAGE, stereotype),
HorizontalAlignment.CENTER, skinParam);
if (stereotype == null || stereotype.getLabel(false) == null
|| portionShower.showPortion(EntityPortion.STEREOTYPE, entity) == false) {
stereoBlock = TextBlockUtils.empty(0, 0);
} else {
stereoBlock = TextBlockUtils.withMargin(
Display.create(stereotype.getLabels(skinParam.useGuillemet())).create(
new FontConfiguration(getSkinParam(), FontParam.PACKAGE_STEREOTYPE, stereotype),
HorizontalAlignment.CENTER, skinParam), 1, 0);
}
}
public Dimension2D calculateDimension(StringBounder stringBounder) {
final Dimension2D dim = desc.calculateDimension(stringBounder);
return Dimension2DDouble.delta(dim, MARGIN * 2, MARGIN * 2 + dim.getHeight() * 2);
final Dimension2D dimDesc = desc.calculateDimension(stringBounder);
Dimension2D dim = TextBlockUtils.mergeTB(desc, stereoBlock, HorizontalAlignment.LEFT).calculateDimension(
stringBounder);
dim = Dimension2DDouble.atLeast(dim, 0, 2 * dimDesc.getHeight());
return Dimension2DDouble.delta(dim, MARGIN * 2, MARGIN * 2);
}
private UStroke getStroke() {
@ -95,10 +112,11 @@ public class EntityImageEmptyPackage extends AbstractEntityImage {
final HtmlColor back = Cluster.getBackColor(specificBackColor, skinParam, stereotype);
final ClusterDecoration decoration = new ClusterDecoration(getSkinParam().getPackageStyle(), null, desc,
TextBlockUtils.empty(0, 0), 0, 0, widthTotal, heightTotal, getStroke());
stereoBlock, 0, 0, widthTotal, heightTotal, getStroke());
decoration.drawU(ug, back, SkinParamUtils.getColor(getSkinParam(), ColorParam.packageBorder, getStereo()),
getSkinParam().shadowing());
decoration.drawU(ug, back,
SkinParamUtils.getColor(getSkinParam(), ColorParam.packageBorder, getStereo()), getSkinParam().shadowing());
}
public ShapeType getShapeType() {

View File

@ -39,6 +39,7 @@ import net.sourceforge.plantuml.Dimension2DDouble;
import net.sourceforge.plantuml.Direction;
import net.sourceforge.plantuml.FontParam;
import net.sourceforge.plantuml.ISkinParam;
import net.sourceforge.plantuml.LineParam;
import net.sourceforge.plantuml.SkinParamBackcolored;
import net.sourceforge.plantuml.SkinParamUtils;
import net.sourceforge.plantuml.Url;
@ -206,7 +207,8 @@ public class EntityImageNote extends AbstractEntityImage implements Stencil {
-shape.getMinY());
final Opale opale = new Opale(borderColor, noteBackgroundColor, textBlock, skinParam.shadowing(), true);
opale.setOpale(strategy, pp1, projection);
opale.drawU(Colors.applyStroke(ug2, getEntity().getColors(skinParam)));
final UGraphic stroked = applyStroke(ug2);
opale.drawU(Colors.applyStroke(stroked, getEntity().getColors(skinParam)));
}
if (url != null) {
ug.closeAction();
@ -224,13 +226,22 @@ public class EntityImageNote extends AbstractEntityImage implements Stencil {
polygon.setDeltaShadow(4);
}
ug = ug.apply(new UChangeBackColor(noteBackgroundColor)).apply(new UChangeColor(borderColor));
ug.draw(polygon);
final UGraphic stroked = applyStroke(ug);
stroked.draw(polygon);
ug.apply(new UTranslate(getTextWidth(stringBounder) - cornersize, 0)).draw(new ULine(0, cornersize));
ug.apply(new UTranslate(getTextWidth(stringBounder), cornersize)).draw(new ULine(-cornersize, 0));
stroked.apply(new UTranslate(getTextWidth(stringBounder) - cornersize, 0)).draw(new ULine(0, cornersize));
stroked.apply(new UTranslate(getTextWidth(stringBounder), cornersize)).draw(new ULine(-cornersize, 0));
getTextBlock().drawU(ug.apply(new UTranslate(marginX1, marginY)));
}
private UGraphic applyStroke(UGraphic ug) {
final UStroke stroke = skinParam.getThickness(LineParam.noteBorder, null);
if (stroke == null) {
return ug;
}
return ug.apply(stroke);
}
private UPolygon getPolygonNormal(final StringBounder stringBounder) {
final UPolygon polygon = new UPolygon();
polygon.addPoint(0, 0);

View File

@ -87,7 +87,7 @@ public class EntityImageObject extends AbstractEntityImage implements Stencil {
if (stereotype == null || stereotype.getLabel(false) == null) {
this.stereo = null;
} else {
this.stereo = Display.getWithNewlines(stereotype.getLabel(getSkinParam().useGuillemet())).create(
this.stereo = Display.create(stereotype.getLabels(skinParam.useGuillemet())).create(
new FontConfiguration(getSkinParam(), FontParam.OBJECT_STEREOTYPE, stereotype),
HorizontalAlignment.CENTER, skinParam);
}

View File

@ -98,6 +98,7 @@ public class SvgGraphics {
private final double scale;
private final String filterUid;
private final String shadowId;
private final String gradientId;
final protected void ensureVisible(double x, double y) {
if (x > maxX) {
@ -128,6 +129,7 @@ public class SvgGraphics {
final Random rnd = new Random();
this.filterUid = "b" + getRandomString(rnd);
this.shadowId = "f" + getRandomString(rnd);
this.gradientId = "g" + getRandomString(rnd);
} catch (ParserConfigurationException e) {
e.printStackTrace();
throw new IllegalStateException(e);
@ -252,7 +254,7 @@ public class SvgGraphics {
elt.setAttribute("x2", "100%");
elt.setAttribute("y2", "100%");
}
id = "gr" + gradients.size();
id = gradientId + gradients.size();
gradients.put(key, id);
elt.setAttribute("id", id);

View File

@ -93,6 +93,7 @@ public class SyntaxChecker {
final PSystemError sys = (PSystemError) system;
result.setErrorLinePosition(sys.getHigherErrorPosition());
result.setLineLocation(sys.getLineLocation());
result.setSystemError(sys);
for (ErrorUml er : sys.getErrorsUml()) {
result.addErrorText(er.getError());
}

View File

@ -42,6 +42,7 @@ import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Set;
import java.util.concurrent.Semaphore;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
@ -68,7 +69,6 @@ import net.sourceforge.plantuml.graphic.HtmlColorGradient;
import net.sourceforge.plantuml.graphic.HtmlColorSimple;
import net.sourceforge.plantuml.graphic.HtmlColorTransparent;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.graphic.TextBlockUtils;
import net.sourceforge.plantuml.graphic.UDrawable;
import net.sourceforge.plantuml.mjpeg.MJPEGGenerator;
import net.sourceforge.plantuml.ugraphic.crossing.UGraphicCrossing;
@ -121,6 +121,23 @@ public class ImageBuilder {
return writeImageInternal(fileFormatOption, os, animation);
}
private static Semaphore SEMAPHORE;
private static int MAX_PRICE = 0;
public static void setMaxPixel(int max) {
MAX_PRICE = max;
SEMAPHORE = new Semaphore(MAX_PRICE, true);
}
private int getPrice(FileFormatOption fileFormatOption, Dimension2D dim) {
if (fileFormatOption.getFileFormat() != FileFormat.PNG) {
return 0;
}
final int price = Math.min(MAX_PRICE, ((int) (dim.getHeight() * dpiFactor))
* ((int) (dim.getWidth() * dpiFactor)));
return price;
}
private ImageData writeImageInternal(FileFormatOption fileFormatOption, OutputStream os, Animation animationArg)
throws IOException {
Dimension2D dim = getFinalDimension(fileFormatOption.getDefaultStringBounder());
@ -134,22 +151,38 @@ public class ImageBuilder {
dy = -minmax.getMinY();
}
final UGraphic2 ug = createUGraphic(fileFormatOption, dim, animationArg, dx, dy);
final UGraphic ugDecored = handwritten(ug.apply(new UTranslate(margin1, margin1)));
udrawable.drawU(ugDecored);
ugDecored.flushUg();
ug.writeImageTOBEMOVED(os, metadata, 96);
os.flush();
int price = 0;
if (SEMAPHORE != null) {
price = getPrice(fileFormatOption, dim);
try {
SEMAPHORE.acquire(price);
} catch (InterruptedException e) {
e.printStackTrace();
throw new IOException(e);
}
}
try {
final UGraphic2 ug = createUGraphic(fileFormatOption, dim, animationArg, dx, dy);
final UGraphic ugDecored = handwritten(ug.apply(new UTranslate(margin1, margin1)));
udrawable.drawU(ugDecored);
ugDecored.flushUg();
ug.writeImageTOBEMOVED(os, metadata, 96);
os.flush();
if (ug instanceof UGraphicG2d) {
final Set<Url> urls = ((UGraphicG2d) ug).getAllUrlsEncountered();
if (urls.size() > 0) {
final CMapData cmap = CMapData.cmapString(urls, dpiFactor);
return new ImageDataComplex(dim, cmap, warningOrError);
if (ug instanceof UGraphicG2d) {
final Set<Url> urls = ((UGraphicG2d) ug).getAllUrlsEncountered();
if (urls.size() > 0) {
final CMapData cmap = CMapData.cmapString(urls, dpiFactor);
return new ImageDataComplex(dim, cmap, warningOrError);
}
}
return new ImageDataSimple(dim);
} finally {
if (SEMAPHORE != null) {
SEMAPHORE.release(price);
}
}
return new ImageDataSimple(dim);
}
public Dimension2D getFinalDimension(StringBounder stringBounder) {

View File

@ -150,4 +150,8 @@ public class UClip implements UChange {
return yp;
}
public boolean isInside(double x, double y, UPath shape) {
return isInside(x + shape.getMinX(), y + shape.getMinY()) && isInside(x + shape.getMaxX(), y + shape.getMaxY());
}
}

View File

@ -43,11 +43,16 @@ public class UPath extends AbstractShadowable implements Iterable<USegment> {
private boolean isOpenIconic;
public void add(double[] coord, USegmentType pathType) {
segments.add(new USegment(coord, pathType));
if (pathType == USegmentType.SEG_ARCTO) {
addInternal(new USegment(coord, pathType));
}
private void addInternal(USegment segment) {
segments.add(segment);
final double coord[] = segment.getCoord();
if (segment.getSegmentType() == USegmentType.SEG_ARCTO) {
minmax = minmax.addPoint(coord[5], coord[6]);
// minmax = minmax.addPoint(coord[5] + coord[0], coord[6] + coord[1]);
// minmax = minmax.addPoint(coord[5] - coord[0], coord[6] - coord[1]);
// minmax = minmax.addPoint(coord[5] + coord[0], coord[6] + coord[1]);
// minmax = minmax.addPoint(coord[5] - coord[0], coord[6] - coord[1]);
} else {
for (int i = 0; i < coord.length; i += 2) {
minmax = minmax.addPoint(coord[i], coord[i + 1]);
@ -55,6 +60,22 @@ public class UPath extends AbstractShadowable implements Iterable<USegment> {
}
}
public UPath translate(double dx, double dy) {
final UPath result = new UPath();
for (USegment seg : segments) {
result.addInternal(seg.translate(dx, dy));
}
return result;
}
public UPath rotate(double theta) {
final UPath result = new UPath();
for (USegment seg : segments) {
result.addInternal(seg.rotate(theta));
}
return result;
}
public void moveTo(Point2D pt) {
moveTo(pt.getX(), pt.getY());
}

View File

@ -30,6 +30,8 @@
*/
package net.sourceforge.plantuml.ugraphic;
import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.util.Arrays;
public class USegment {
@ -55,4 +57,22 @@ public class USegment {
return pathType;
}
public USegment translate(double dx, double dy) {
if (coord.length != 2) {
throw new UnsupportedOperationException();
}
Point2D p1 = new Point2D.Double(coord[0] + dx, coord[1] + dy);
return new USegment(new double[] { p1.getX(), p1.getY() }, pathType);
}
public USegment rotate(double theta) {
if (coord.length != 2) {
throw new UnsupportedOperationException();
}
Point2D p1 = new Point2D.Double(coord[0], coord[1]);
final AffineTransform rotate = AffineTransform.getRotateInstance(theta);
rotate.transform(p1, p1);
return new USegment(new double[] { p1.getX(), p1.getY() }, pathType);
}
}

View File

@ -110,25 +110,30 @@ public class DriverRectangleG2d extends DriverShadowedG2d implements UDriver<Gra
private GradientPaint getPaintGradient(double x, double y, ColorMapper mapper, final URectangle shape,
final HtmlColor back) {
final double width = shape.getWidth();
final double height = shape.getHeight();
return getPaintGradient(x, y, mapper, width, height, back);
}
public static GradientPaint getPaintGradient(double x, double y, ColorMapper mapper, double width, double height,
final HtmlColor back) {
final HtmlColorGradient gr = (HtmlColorGradient) back;
final char policy = gr.getPolicy();
final GradientPaint paint;
if (policy == '|') {
paint = new GradientPaint((float) x, (float) (y + shape.getHeight()) / 2, mapper.getMappedColor(gr
.getColor1()), (float) (x + shape.getWidth()), (float) (y + shape.getHeight()) / 2,
mapper.getMappedColor(gr.getColor2()));
paint = new GradientPaint((float) x, (float) (y + height) / 2, mapper.getMappedColor(gr.getColor1()),
(float) (x + width), (float) (y + height) / 2, mapper.getMappedColor(gr.getColor2()));
} else if (policy == '\\') {
paint = new GradientPaint((float) x, (float) (y + shape.getHeight()), mapper.getMappedColor(gr
.getColor1()), (float) (x + shape.getWidth()), (float) y, mapper.getMappedColor(gr.getColor2()));
paint = new GradientPaint((float) x, (float) (y + height), mapper.getMappedColor(gr.getColor1()),
(float) (x + width), (float) y, mapper.getMappedColor(gr.getColor2()));
} else if (policy == '-') {
paint = new GradientPaint((float) (x + shape.getWidth()) / 2, (float) y, mapper.getMappedColor(gr
.getColor1()), (float) (x + shape.getWidth()) / 2, (float) (y + shape.getHeight()),
mapper.getMappedColor(gr.getColor2()));
paint = new GradientPaint((float) (x + width) / 2, (float) y, mapper.getMappedColor(gr.getColor1()),
(float) (x + width) / 2, (float) (y + height), mapper.getMappedColor(gr.getColor2()));
} else {
// for /
paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()),
(float) (x + shape.getWidth()), (float) (y + shape.getHeight()), mapper.getMappedColor(gr
.getColor2()));
paint = new GradientPaint((float) x, (float) y, mapper.getMappedColor(gr.getColor1()), (float) (x + width),
(float) (y + height), mapper.getMappedColor(gr.getColor2()));
}
return paint;
}

View File

@ -33,6 +33,7 @@ package net.sourceforge.plantuml.ugraphic.g2d;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.GraphicsEnvironment;
import java.awt.geom.Dimension2D;
@ -45,6 +46,7 @@ import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.FontStyle;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorGradient;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
import net.sourceforge.plantuml.ugraphic.UDriver;
@ -76,13 +78,22 @@ public class DriverTextG2d implements UDriver<Graphics2D> {
final UFont font = fontConfiguration.getFont().scaled(param.getScale());
final Dimension2D dimBack = calculateDimension(FileFormat.PNG.getDefaultStringBounder(), font, shape.getText());
final HtmlColor extended = fontConfiguration.getExtendedColor();
if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) {
final Color extended = mapper.getMappedColor(fontConfiguration.getExtendedColor());
if (extended != null) {
g2d.setColor(extended);
g2d.setBackground(extended);
g2d.fill(new Rectangle2D.Double(x, y - dimBack.getHeight() + 1.5, dimBack.getWidth(), dimBack
.getHeight()));
final Rectangle2D.Double area = new Rectangle2D.Double(x, y - dimBack.getHeight() + 1.5,
dimBack.getWidth(), dimBack.getHeight());
if (extended instanceof HtmlColorGradient) {
final GradientPaint paint = DriverRectangleG2d.getPaintGradient(x, y, mapper, dimBack.getWidth(),
dimBack.getHeight(), extended);
g2d.setPaint(paint);
g2d.fill(area);
} else {
final Color backColor = mapper.getMappedColor(extended);
if (backColor != null) {
g2d.setColor(backColor);
g2d.setBackground(backColor);
g2d.fill(area);
}
}
}
visible.ensureVisible(x, y - dimBack.getHeight() + 1.5);
@ -93,7 +104,6 @@ public class DriverTextG2d implements UDriver<Graphics2D> {
g2d.drawString(shape.getText(), (float) x, (float) y);
if (fontConfiguration.containsStyle(FontStyle.UNDERLINE)) {
final HtmlColor extended = fontConfiguration.getExtendedColor();
if (extended != null) {
g2d.setColor(mapper.getMappedColor(extended));
}
@ -106,7 +116,6 @@ public class DriverTextG2d implements UDriver<Graphics2D> {
if (fontConfiguration.containsStyle(FontStyle.WAVE)) {
final Dimension2D dim = calculateDimension(FileFormat.PNG.getDefaultStringBounder(), font, shape.getText());
final int ypos = (int) (y + 2.5) - 1;
final HtmlColor extended = fontConfiguration.getExtendedColor();
if (extended != null) {
g2d.setColor(mapper.getMappedColor(extended));
}
@ -119,7 +128,6 @@ public class DriverTextG2d implements UDriver<Graphics2D> {
final Dimension2D dim = calculateDimension(FileFormat.PNG.getDefaultStringBounder(), font, shape.getText());
final FontMetrics fm = g2d.getFontMetrics(font.getFont());
final int ypos = (int) (y - fm.getDescent() - 0.5);
final HtmlColor extended = fontConfiguration.getExtendedColor();
if (extended != null) {
g2d.setColor(mapper.getMappedColor(extended));
}

View File

@ -35,6 +35,7 @@ import net.sourceforge.plantuml.graphic.HtmlColorGradient;
import net.sourceforge.plantuml.svg.SvgGraphics;
import net.sourceforge.plantuml.ugraphic.ClipContainer;
import net.sourceforge.plantuml.ugraphic.ColorMapper;
import net.sourceforge.plantuml.ugraphic.UClip;
import net.sourceforge.plantuml.ugraphic.UDriver;
import net.sourceforge.plantuml.ugraphic.UParam;
import net.sourceforge.plantuml.ugraphic.UPath;
@ -52,6 +53,11 @@ public class DriverPathSvg extends DriverShadowedG2d implements UDriver<SvgGraph
public void draw(UShape ushape, double x, double y, ColorMapper mapper, UParam param, SvgGraphics svg) {
final UPath shape = (UPath) ushape;
final UClip clip = clipContainer.getClip();
if (clip != null && clip.isInside(x, y, shape) == false) {
return;
}
final String color = StringUtils.getAsSvg(mapper, param.getColor());
if (shape.isOpenIconic()) {
svg.setFillColor(color);

View File

@ -34,6 +34,8 @@ import java.awt.geom.Dimension2D;
import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.graphic.FontConfiguration;
import net.sourceforge.plantuml.graphic.FontStyle;
import net.sourceforge.plantuml.graphic.HtmlColor;
import net.sourceforge.plantuml.graphic.HtmlColorGradient;
import net.sourceforge.plantuml.graphic.StringBounder;
import net.sourceforge.plantuml.svg.SvgGraphics;
import net.sourceforge.plantuml.ugraphic.ClipContainer;
@ -81,12 +83,6 @@ public class DriverTextSvg implements UDriver<SvgGraphics> {
textDecoration = "line-through";
}
String backColor = null;
if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) {
backColor = StringUtils.getAsHtml(mapper.getMappedColor(fontConfiguration.getExtendedColor()));
}
svg.setFillColor(StringUtils.getAsHtml(mapper.getMappedColor(fontConfiguration.getColor())));
String text = shape.getText();
if (text.startsWith(" ")) {
final double space = stringBounder.calculateDimension(font, " ").getWidth();
@ -97,7 +93,28 @@ public class DriverTextSvg implements UDriver<SvgGraphics> {
}
text = StringUtils.trin(text);
final Dimension2D dim = stringBounder.calculateDimension(font, text);
String backColor = null;
final double width = dim.getWidth();
final double height = dim.getHeight();
if (fontConfiguration.containsStyle(FontStyle.BACKCOLOR)) {
final HtmlColor back = fontConfiguration.getExtendedColor();
if (back instanceof HtmlColorGradient) {
final HtmlColorGradient gr = (HtmlColorGradient) back;
final String id = svg.createSvgGradient(StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor1())),
StringUtils.getAsHtml(mapper.getMappedColor(gr.getColor2())), gr.getPolicy());
svg.setFillColor("url(#" + id + ")");
svg.setStrokeColor(null);
final double deltaPatch = 2;
svg.svgRectangle(x, y - height + deltaPatch, width, height, 0, 0, 0);
} else {
backColor = StringUtils.getAsHtml(mapper.getMappedColor(back));
}
}
svg.setFillColor(StringUtils.getAsHtml(mapper.getMappedColor(fontConfiguration.getColor())));
svg.text(text, x, y, font.getFamily(UFontContext.SVG), font.getSize(), fontWeight, fontStyle, textDecoration,
dim.getWidth(), fontConfiguration.getAttributes(), backColor);
width, fontConfiguration.getAttributes(), backColor);
}
}

View File

@ -50,6 +50,7 @@ import javax.imageio.ImageIO;
import net.sourceforge.plantuml.AbstractPSystem;
import net.sourceforge.plantuml.FileFormatOption;
import net.sourceforge.plantuml.Log;
import net.sourceforge.plantuml.OptionPrint;
import net.sourceforge.plantuml.core.DiagramDescription;
import net.sourceforge.plantuml.core.DiagramDescriptionImpl;
import net.sourceforge.plantuml.core.ImageData;
@ -150,11 +151,13 @@ public class PSystemVersion extends AbstractPSystem {
strings.addAll(GraphvizUtils.getTestDotStrings(true));
strings.add(" ");
final Properties p = System.getProperties();
strings.add(p.getProperty("java.runtime.name"));
strings.add(p.getProperty("java.vm.name"));
strings.add(p.getProperty("java.runtime.version"));
strings.add(p.getProperty("os.name"));
strings.add("Processors: " + Runtime.getRuntime().availableProcessors());
for (String name : OptionPrint.interestingProperties()) {
strings.add(p.getProperty(name));
}
for (String v : OptionPrint.interestingValues()) {
strings.add(v);
}
return new PSystemVersion(true, strings);
}

View File

@ -36,7 +36,7 @@ import java.util.Date;
public class Version {
public static int version() {
return 8047;
return 8048;
}
public static String versionString() {
@ -68,7 +68,7 @@ public class Version {
}
public static long compileTime() {
return 1472140770579L;
return 1475168642530L;
}
public static String compileTimeString() {